Fixed site minification.

Ylian Saint-Hilaire committed Jul 3, 2019 at 19:02 UTC b6793d6ec20b67e94be3f4cb6358c1a841a569d3
3 files changed +3 -14266
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.3.7-c",
3 + "version": "0.3.7-e",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",
public/scripts/amt-terminal-0.0.2.js
+1 -1
@@ -178,7 +178,7 @@ var CreateAmtRemoteTerminal = function (divid, options) {
178 _termstate = 0;
179 break;
180 case 6: // ']' Code, xterm
181 - const bx = b.charCodeAt(0);
181 + var bx = b.charCodeAt(0);
182 if (b == ';') {
183 _escNumberPtr++;
184 } else if (bx == 7) {
views/default-min.handlebars
+1 -14264
@@ -1,14264 +1 @@
1 -<!DOCTYPE html> <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <meta name="viewport" content="user-scalable=1.0,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="format-detection" content="telephone=no"> <link rel="shortcut icon" type="image/x-icon" href="{{{domainurl}}}favicon.ico"> <link keeplink="1" type="text/css" href="styles/style.css" media="screen" rel="stylesheet" title="CSS"> <style>.ol-box{box-sizing:border-box;border-radius:2px;border:2px solid #00f;}.ol-mouse-position{top:8px;right:8px;position:absolute;}.ol-scale-line{background:rgba(0,60,136,.3);border-radius:4px;bottom:8px;left:8px;padding:2px;position:absolute;}.ol-scale-line-inner{border:1px solid #eee;border-top:none;color:#eee;font-size:10px;text-align:center;margin:1px;will-change:contents,width;}.ol-overlay-container{will-change:left,right,top,bottom;}.ol-unsupported{display:none;}.ol-unselectable, .ol-viewport{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;}.ol-selectable{-webkit-touch-callout:default;-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto;}.ol-grabbing{cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing;}.ol-grab{cursor:move;cursor:-webkit-grab;cursor:-moz-grab;cursor:grab;}.ol-control{position:absolute;background-color:rgba(255,255,255,.4);border-radius:4px;padding:2px;}.ol-control:hover{background-color:rgba(255,255,255,.6);}.ol-zoom{top:.5em;right:.5em;}.ol-rotate{top:.5em;right:.5em;transition:opacity .25s linear,visibility 0s linear;}.ol-rotate.ol-hidden{opacity:0;visibility:hidden;transition:opacity .25s linear,visibility 0s linear .25s;}.ol-zoom-extent{top:4.643em;left:.5em;}.ol-full-screen{right:.5em;top:.5em;}@media print{.ol-control{display:none;}}.ol-control button{display:block;margin:1px;padding:0;color:#fff;font-size:1.14em;font-weight:700;text-decoration:none;text-align:center;height:1.375em;width:1.375em;line-height:.4em;background-color:rgba(0,60,136,.5);border:none;border-radius:2px;}.ol-control button::-moz-focus-inner{border:none;padding:0;}.ol-zoom-extent button{line-height:1.4em;}.ol-compass{display:block;font-weight:400;font-size:1.2em;will-change:transform;}.ol-touch .ol-control button{font-size:1.5em;}.ol-touch .ol-zoom-extent{top:5.5em;}.ol-control button:focus, .ol-control button:hover{text-decoration:none;background-color:rgba(0,60,136,.7);}.ol-zoom .ol-zoom-in{border-radius:2px 2px 0 0;}.ol-zoom .ol-zoom-out{border-radius:0 0 2px 2px;}.ol-attribution{text-align:right;bottom:.5em;right:.5em;max-width:calc(100% - 1.3em);}.ol-attribution ul{margin:0;padding:0 .5em;font-size:.7rem;line-height:1.375em;color:#000;text-shadow:0 0 2px #fff;}.ol-attribution li{display:inline;list-style:none;line-height:inherit;}.ol-attribution li:not(:last-child):after{content:" ";}.ol-attribution img{max-height:2em;max-width:inherit;vertical-align:middle;}.ol-attribution button, .ol-attribution ul{display:inline-block;}.ol-attribution.ol-collapsed ul{display:none;}.ol-attribution.ol-logo-only ul{display:block;}.ol-attribution:not(.ol-collapsed){background:rgba(255,255,255,.8);}.ol-attribution.ol-uncollapsible{bottom:0;right:0;border-radius:4px 0 0;height:1.1em;line-height:1em;}.ol-attribution.ol-logo-only{background:0 0;bottom:.4em;height:1.1em;line-height:1em;}.ol-attribution.ol-uncollapsible img{margin-top:-.2em;max-height:1.6em;}.ol-attribution.ol-logo-only button, .ol-attribution.ol-uncollapsible button{display:none;}.ol-zoomslider{top:4.5em;left:.5em;height:200px;}.ol-zoomslider button{position:relative;height:10px;}.ol-touch .ol-zoomslider{top:5.5em;}.ol-overviewmap{left:.5em;bottom:.5em;}.ol-overviewmap.ol-uncollapsible{bottom:0;left:0;border-radius:0 4px 0 0;}.ol-overviewmap .ol-overviewmap-map, .ol-overviewmap button{display:inline-block;}.ol-overviewmap .ol-overviewmap-map{border:1px solid #7b98bc;height:150px;margin:2px;width:150px;}.ol-overviewmap:not(.ol-collapsed) button{bottom:1px;left:2px;position:absolute;}.ol-overviewmap.ol-collapsed .ol-overviewmap-map, .ol-overviewmap.ol-uncollapsible button{display:none;}.ol-overviewmap:not(.ol-collapsed){background:rgba(255,255,255,.8);}.ol-overviewmap-box{border:2px dotted rgba(0,60,136,.7);}.ol-overviewmap .ol-overviewmap-box:hover{cursor:move;}</style> <style> .ol-ctx-menu-container{position:absolute;padding:8px;background:#fff;color:#222;font-size:13px;border-radius:5px;box-shadow:3px 3px 5px rgba(0,0,0,.2);box-sizing:border-box}.ol-ctx-menu-container a,.ol-ctx-menu-container div,.ol-ctx-menu-container img,.ol-ctx-menu-container li,.ol-ctx-menu-container span,.ol-ctx-menu-container ul{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline}.ol-ctx-menu-container a img{border:none}.ol-ctx-menu-container *,.ol-ctx-menu-container :after,.ol-ctx-menu-container :before{box-sizing:inherit}.ol-ctx-menu-container.ol-ctx-menu-hidden{opacity:0;visibility:hidden;-webkit-transition:visibility 0s linear .3s,opacity .3s;transition:visibility 0s linear .3s,opacity .3s}.ol-ctx-menu-container ul{list-style:none}.ol-ctx-menu-container li{position:relative;line-height:20px;padding:2px 5px}.ol-ctx-menu-container li:not(.ol-ctx-menu-separator):hover{cursor:pointer;background-color:#333;color:#eee}.ol-ctx-menu-container li.ol-ctx-menu-submenu .ol-ctx-menu-container{border:1px solid #eee;padding:8px;top:0;opacity:0;visibility:hidden;-webkit-transition:visibility 0s linear .3s,opacity .3s;transition:visibility 0s linear .3s,opacity .3s}.ol-ctx-menu-container li.ol-ctx-menu-submenu:hover .ol-ctx-menu-container{opacity:1;visibility:visible;-webkit-transition-delay:0s;transition-delay:0s}.ol-ctx-menu-container li.ol-ctx-menu-submenu:after{position:absolute;top:7px;right:10px;content:"";display:inline-block;width:.6em;height:.6em;border-right:.3em solid #222;border-top:.3em solid #222;-webkit-transform:rotate(45deg);transform:rotate(45deg)}.ol-ctx-menu-container li.ol-ctx-menu-submenu:hover:after{border-color:#eee}.ol-ctx-menu-container li.ol-ctx-menu-separator{padding:0}.ol-ctx-menu-container li.ol-ctx-menu-separator hr{border:0;height:1px;background-image:-webkit-linear-gradient(right,transparent,rgba(0,0,0,.75),transparent);background-image:linear-gradient(270deg,transparent,rgba(0,0,0,.75),transparent)}.ol-ctx-menu-icon{text-indent:20px;background-size:20px auto;background-repeat:no-repeat;background-position:0}.ol-ctx-menu-zoom-in{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABaUlEQVQ4T72U7VHCQBCGn90GtAMuNGCswFiBWIFQgWMFxg6wArECsQKhArEBiB1Qwa1zgQn5IAYcxv13k71n3919L8KJQ07M47+BzgG9TRfZ/JBuWhS6BJFHRJICYrZGZIz3z5Ct2+B7gG6I6kt+wewdkQVwjtkAkR5mC8yu26A1oItR/cTsOweQBdgutD8G7jGm2PJ2n8oqUKIpIjd4HxTM8gvaT/F+AlmWnyWaIXKF95eNguFzTYFhNsdWu9kFgFlaFMANUH3D8wDLoLgSTSD2il8NCe2ZXQBxWDGwxmyUzzOMBZ7wy7Qb2K0wQfXjMOBuhlFpZtNty5sFaTQBuTusZdymeqs1SpYKcO9HkE3KbTd9WFijMHJQ5hBNEAYNq5Qd0dhyke0GiE4QzjqfW23mHT8Hl4DG4Lce3FPE7AtbBSdsbNqpoJLgYkRnNeUV+xwJDHTnUEkxHGbhBXUs5TjJjew/KPy94g+NRaIVRYmMXwAAAABJRU5ErkJggg==")}.ol-ctx-menu-container li:hover.ol-ctx-menu-zoom-in{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABc0lEQVQ4T71U21ECQRDsJgGdvQDECMQIxAjECMQILCPwzAAjECIQI0AiEDPQAPaWCBhrcKHuCUcV5f7dY3v6tUscefHIePhfwBBCF8CZqRCReRs1tQxDCH1VfQLQz4EsSY4AvIjIsgm8AhhCGKrqa9zwrqoLAKckB5HtguR1E2gBMITQU9VPAD8GICIGtl3e+xHJBwBT59xtHcsCYJZlUwA3kcGHbfDep51OZywi3/acZZm9vyJ5WR5o38uACmDunNt6ZwAkUxFZDwghDFT1jeSjiJinhVUBVNVJkiTDKO8CQA+AsbNQ7s1Ps0VVn5MkSfcCtmBoDZi1Bdx4eJ7zbBolrwPy3o9J3rWSHPs3A1BbjVKlYBaIyDgvu9LDXDU2RTZmXVW1oKyLxRD+OrkOrJLy5mVM0iaftDhuhVbsvBzMglzKUNW6IV/OOWtCM8MmVvEkmbwt83LaB19fdgOtVquUZJeknaDdobTwbOcvBzPcN/AXH1DFFWP7u9oAAAAASUVORK5CYII=")}.ol-ctx-menu-zoom-out{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABU0lEQVQ4T72U7VECMRRFz3sNaAdkacC1AtcKxApcKnCsQOwAK3CtQKxAqEBsANYOqCDPyTIC+8WCw5jfybn33dxEOPGSE/P4b6BzQG89RT47ZJoWhy5B5BGRZAMxWyEyxvtnyFdt8AagS1F9KQ6YvSMyB84xGyDSw2yO2XUbtAJ0MaqfmH0XAPIA2y7tj4F7jAm2uG1yWQZKNEHkBu+Dg2njWBJNEbnC+8uaIFRuWfuG2QxbbrOrUd0A1Tc8D7AIjkur7DAAsVf8MiWMZ3ZR2m02LPIMscATfjHqBnY7TFD9OAy4zTCCPG/MUKMM5O6wkXFr9dZq7FQqqHk/hDzbFa73cFONTZFDdRyiCcKg5rrSiLaXkiI6RjjrfG6VzDs+B5eAxuDXeYpmNRGzL2wZ/wof+du4GNFpBVqqz5HA4MM5VEYYDrOs+1I6Q9u/4Q8O9wN/AGgWjBVqQjjgAAAAAElFTkSuQmCC")}.ol-ctx-menu-container li:hover.ol-ctx-menu-zoom-out{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABYklEQVQ4T72U4VHCQBCF36tA91KAWIFYgViBWIFYgWMFYgdYgVCBWAFSgdiBFpAsFWSdxcDkQoBkhnF/ZjbfvX377ogjF4/Mw/8CVbUD4MynEJF5k2lqFapqz8yeAPRKkCXJEYAXEVnugm8BVXVgZq/FD+9mtgBwSrJfqF2QvN4FjYCq2jWzTwA/DhARh20qTdMRyQcA0xDCbZ3KCJhl2RTATaHgo+6HLMv8+xXJy+qB3l8FGoB5CKHsXcRV1b6ZvZF8FBH3NKotoJlNkiQZFONdlLtJ3rufbouZPSdJMjwIbKDQEzBrClx7eC4i33Uepmk6JnnXaOQifzMAtdGoRApugYiMI1uqKkrRWAfZo9MxM1+UZzFewl8mN4nYdVM83L7BkwbXLUrF3sfBLQDQBbDy08x8vOohXyEE71lVq9emuEk+3gZa3XYroCvwFyjP8yHJDsnxwaU08GxvS2uFhw78BbzWrxXgMbsHAAAAAElFTkSuQmCC")}</style> <script type="text/javascript" src="scripts/u2f-api.js"></script> <script type="text/javascript" src="scripts/charts.js"></script> <script type="text/javascript" src="scripts/filesaver.js"></script> <script type="text/javascript" src="scripts/ol.js"></script> <script type="text/javascript" src="scripts/ol3-contextmenu.js"></script> <title>{{{title}}}</title> </head> <body id="body" onload="if (typeof(startup) !== 'undefined') startup();" oncontextmenu="handleContextMenu(event)" style="display:none"> <div id="contextMenu" class="contextMenu noselect" style="display:none"> <div id="cxinfo" class="cmtext" onclick="cmaction(1,event)"><b>Information</b></div> <div id="cxdesktop" class="cmtext" onclick="cmaction(3,event)">Desktop</div> <div id="cxterminal" class="cmtext" onclick="cmaction(2,event)">Terminal</div> <div id="cxfiles" class="cmtext" onclick="cmaction(4,event)">Files</div> <div id="cxevents" class="cmtext" onclick="cmaction(5,event)">Events</div> <div id="cxconsole" class="cmtext" onclick="cmaction(6,event)">Console</div> <hr id="cxmgroupsplit"> <div id="cxmdesktop" class="cmtext" onclick="cmaction(7,event)" style="display:none">Multi-Desktop</div> </div> <div id="meshContextMenu" class="contextMenu,noselect" style="display:none;min-width:0px"> <div id="cxselectall" class="cmtext" onclick="cmmeshaction(1,event)">Select All</div> <div id="cxselectnone" class="cmtext" onclick="cmmeshaction(2,event)">Select None</div> <hr id="cxmgroupsplit2" style="display:none"> <div id="cxmmdesktop" class="cmtext" style="display:none" onclick="cmmeshaction(3,event)">Multi-Desktop</div> </div> <div id="container"> <div id="notifiyBox" class="notifiyBox" style="display:none"></div> <div id="masthead" class="noselect"> <div class="title">{{{title}}}</div> <div class="title2">{{{title2}}}</div> <div style="float:right"> <div id="notificationCount" onclick="clickNotificationIcon()" class="unselectable" style="display:none;" title="Click to view current notifications">0</div> </div> <p id="logoutControl">{{{logoutControl}}}<span id="idleTimeoutNotify" style="color:yellow"></span></p> </div> <div id="page_leftbar"> <div style="height:16px"></div> <div id="LeftMenuMyDevices" class="lbbutton lbbuttonsel" title="My Devices" onclick="go(1)"> <div class="lb2"></div> </div> <div id="LeftMenuMyAccount" class="lbbutton" title="My Account" onclick="go(2)"> <div class="lb1"></div> </div> <div id="LeftMenuMyEvents" class="lbbutton" title="My Events" onclick="go(3)"> <div class="lb3"></div> </div> <div id="LeftMenuMyFiles" class="lbbutton" style="display:none" title="My Files" onclick="go(5)"> <div class="lb4"></div> </div> <div id="LeftMenuMyUsers" class="lbbutton" style="display:none" title="My Users" onclick="go(4)"> <div class="lb5"></div> </div> <div id="LeftMenuMyServer" class="lbbutton" style="display:none" title="My Server" onclick="go(6)" style="display:none"> <div class="lb6"></div> </div> </div> <div id="topbar" class="noselect"> <div> <div style="position:relative"> <div id="uiMenuButton" title="User interface selection" onclick="showUserInterfaceSelectMenu()">&diams; <div id="uiMenu" style="display:none"> <div id="uiViewButton1" class="uiSelector" onclick="userInterfaceSelectMenu(1)" title="Left bar interface"><div class="uiSelector1"></div></div> <div id="uiViewButton2" class="uiSelector" onclick="userInterfaceSelectMenu(2)" title="Top bar interface"><div class="uiSelector2"></div></div> <div id="uiViewButton3" class="uiSelector" onclick="userInterfaceSelectMenu(3)" title="Fixed width interface"><div class="uiSelector3"></div></div> <div id="uiViewButton4" class="uiSelector" onclick="toggleNightMode()" title="Toggle night mode"><div class="uiSelector4"></div></div> </div> </div> <table id="MainMenuSpan" cellpadding="0" cellspacing="0" class="style1"> <tr> <td id="MainMenuMyDevices" class="topbar_td style3x" onclick="go(1)">My Devices</td> <td id="MainMenuMyAccount" class="topbar_td style3x" onclick="go(2)">My Account</td> <td id="MainMenuMyEvents" class="topbar_td style3x" onclick="go(3)">My Events</td> <td id="MainMenuMyFiles" class="topbar_td style3x" onclick="go(5)">My Files</td> <td id="MainMenuMyUsers" class="topbar_td style3x" onclick="go(4)">My Users</td> <td id="MainMenuMyServer" class="topbar_td style3x" onclick="go(6)">My Server</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> <div id="MainSubMenuSpan" style="display:none"> <table id="MainSubMenu" cellpadding="0" cellspacing="0" class="style1"> <tr> <td id="MainDev" class="topbar_td style3x" onclick="go(10)">General</td> <td id="MainDevDesktop" class="topbar_td style3x" onclick="go(11)">Desktop</td> <td id="MainDevTerminal" class="topbar_td style3x" onclick="go(12)">Terminal</td> <td id="MainDevFiles" class="topbar_td style3x" onclick="go(13)">Files</td> <td id="MainDevEvents" class="topbar_td style3x" onclick="go(16)">Events</td> <td id="MainDevAmt" class="topbar_td style3x" onclick="go(14)">Intel&reg; AMT</td> <td id="MainDevConsole" class="topbar_td style3x" onclick="go(15)">Console</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> </div> <div id="MeshSubMenuSpan" style="display:none"> <table id="MeshSubMenu" cellpadding="0" cellspacing="0" class="style1"> <tr> <td id="MeshGeneral" class="topbar_td style3x" onclick="go(20)">General</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> </div> <div id="UserSubMenuSpan" style="display:none"> <table id="UserSubMenu" cellpadding="0" cellspacing="0" class="style1"> <tr> <td id="UserGeneral" class="topbar_td style3x" onclick="go(30)">General</td> <td id="UserEvents" class="topbar_td style3x" onclick="go(31)">Events</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> </div> <div id="ServerSubMenuSpan" style="display:none"> <table id="ServerSubMenu" cellpadding="0" cellspacing="0" class="style1"> <tr> <td id="ServerGeneral" class="topbar_td style3x" onclick="go(6)">General</td> <td id="ServerStats" class="topbar_td style3x" onclick="go(40)">Stats</td> <td id="ServerConsole" class="topbar_td style3x" onclick="go(115)">Console</td> <td class="topbar_td_end style3">&nbsp;</td> </tr> </table> </div> <div id="UserDummyMenuSpan"> <table id="UserDummyMenu" cellpadding="0" cellspacing="0" class="style1"> <tr><td class="style3" style="">&nbsp;</td></tr> </table> </div> </div> </div> </div> <div id="column_l"> <div id="p0" style="display:none"> <div id="p0message"><span id="p0span">Server disconnected</span>, <href onclick="reload()" style="cursor:pointer"><u>click to reconnect</u></href>.</div> </div> <div id="p1" style="display:none"> <div style="display:none" id="devListToolbarViewIcons"> <div id="devViewButton1" class="viewSelector" onclick="onDeviceViewChange(1)" title="Columns"><div class="viewSelector2"></div></div> <div id="devViewButton2" class="viewSelector" onclick="onDeviceViewChange(2)" title="List"><div class="viewSelector1"></div></div> <div id="devViewButton3" class="viewSelector" onclick="onDeviceViewChange(3)" title="Desktops"><div class="viewSelector3"></div></div> <div id="devViewButton4" class="viewSelector" onclick="onDeviceViewChange(4)" title="Map"><div class="viewSelector4"></div></div> </div><div><h1>My Devices</h1></div> <table id="devListToolbarSpan" class="noselect"> <tr> <td class="h1"></td> <td id="devListToolbar" class="style14" style="display:none"> &nbsp;&nbsp;<input type="button" id="SelectAllButton" onclick="selectallButtonFunction();" value="Select All">&nbsp; <input type="button" id="GroupActionButton" disabled="disabled" value="Group Action" onclick="groupActionFunction()">&nbsp; <input id="SearchInput" type="text" placeholder="Filter" onchange="masterUpdate(5)" onkeyup="masterUpdate(5)" autocomplete="off" onfocus="onSearchFocus(1)" onblur="onSearchFocus(0)">&nbsp; <label><input type="checkbox" id="RealNameCheckBox" onclick="onRealNameCheckBox()"><span title="Show devices operating system name">OS Name</span></label> </td> <td id="kvmListToolbar" class="style14" style="display:none"> &nbsp;&nbsp;<input type="button" onclick="connectAllKvmFunction()" value="Connect All">&nbsp; <input type="button" onclick="disconnectAllKvmFunction()" value="Disconnect All">&nbsp; <label><input type="checkbox" id="autoConnectDesktopCheckbox" onclick="autoConnectDesktops(event)" title="Automatic connect">Auto&nbsp;</label> <input type="button" onclick="showMultiDesktopSettings()" value="Settings">&nbsp; </td> <td id="devMapToolbar" class="style14" style="display:none"> &nbsp;&nbsp;<input type="text" id="mapSearchLocation" placeholder="Search Location" onfocus="onMapSearchFocus(1)" onblur="onMapSearchFocus(0)"> <input type="button" value="Search" title="Search for location" onclick="getSearchLocation()"> <input type="button" id="refreshmap" title="Reset map view" value="Reset" onclick="refreshMap(false,true)"> </td> <td class="auto-style1" style="height:100%"> <div style="display:none" id="devListToolbarView"> View <select id="viewselect" onchange="onDeviceViewChange()"> <option value="1">Columns <option value="2">List <option value="3">Desktops <option id="viewselectmapoption" value="4">Map </select> </div> <div style="display:none" id="devListToolbarSort"> Sort <select id="sortselect" onchange="masterUpdate(6)"> <option>Group <option>Power <option>Device <option>Tags </select> &nbsp; </div> <div style="display:none" id="devListToolbarSize"> Size <select id="sizeselect" onchange="onDeviceViewChange()"> <option value="0">Small <option value="1">Medium <option value="2">Large </select> &nbsp; </div> </td> <td class="h2"></td> </tr> </table> <div id="NoMeshesPanel" style="display:none"> <table> <tr> <td valign="top" style="width:50px"> <img src="images/info.png"> </td> <td> <div id="getStarted1">To get started, <a onclick="account_createMesh()"><strong>click here to create a device group</strong></a>.</div> <div id="getStarted2">No device groups.</div> </td> </tr> </table> </div> <div id="xdevices" class="noselect" style="display:none"></div> <div id="xdevicesmap" style="display:none"> <div id="xmapSearchResultsDlg" style="display:none"> <div id="xmapSearchResultsBck"> <div id="xmapSearchClose" onclick="mapCloseSearchWindow()"><b>X</b></div> <div style="padding:5px">Location Results</div> <div style="width:100%;margin:6px"></div> </div> <div id="xmapSearchResults" style="margin:6px"></div> </div> </div> <div id="xmap-info-window"></div> </div> <div id="p2" style="display:none"> <h1>My Account</h1> <img id="p2AccountImage" alt="" src="images/clipboard-128.png"> <div id="p2AccountSecurity" style="display:none"> <p><strong>Account security</strong></p> <div style="margin-left:25px"> <div id="manageAuthApp"><div class="p2AccountActions"><span id="authAppSetupCheck"><strong>&#x2713;</strong></span></div><span><a onclick="account_manageAuthApp()">Manage authenticator app</a><br></span></div> <div id="manageHardwareOtp"><div class="p2AccountActions"><span id="authKeySetupCheck"><strong>&#x2713;</strong></span></div><span><a onclick="account_manageHardwareOtp(0)">Manage security keys</a><br></span></div> <div id="manageOtp"><div class="p2AccountActions"><span id="authCodesSetupCheck"><strong>&#x2713;</strong></span></div><span><a onclick="account_manageOtp(0)">Manage backup codes</a><br></span></div> </div> </div> <div id="p2AccountActions"> <p><strong>Account actions</strong></p> <p class="mL"> <span id="verifyEmailId" style="display:none"><a onclick="account_showVerifyEmail()">Verify email</a><br></span> <span id="accountEnableNotificationsSpan" style="display:none"><a onclick="account_enableNotifications()">Enable web notifications</a><br></span> <a onclick="account_showChangeEmail()">Change email address</a><br> <a onclick="account_showChangePassword()">Change password</a><span id="p2nextPasswordUpdateTime"></span><br> <a onclick="account_showDeleteAccount()">Delete account</a><br> </p> <br style="clear:both"> </div> <strong>Device Groups</strong> <span id="p2createMeshLink1">( <a onclick="account_createMesh()" class="newMeshBtn"> New</a> )</span> <br><br> <div id="p2meshes"></div> <div id="p2noMeshFound" style="display:none">No device groups.<span id="p2createMeshLink2"> <a onclick="account_createMesh()"><strong>Get started here!</strong></a></span></div> <br style="clear:both"> </div> <div id="p3" style="display:none"> <h1>My Events</h1> <table class="pTable"> <tr> <td class="h1"></td> <td>&nbsp;<input id="p2deleteall" type="button" onclick="showDeleteAllEventsDialog()" style="display:none" value="Delete All..."></td> <td class="auto-style1"> Show <select id="p3limitdropdown" onchange="refreshEvents()"> <option value="60">Last 60 <option value="120">Last 120 <option value="250">Last 250 <option value="500">Last 500 <option value="1000">Last 1000 </select>&nbsp; <img src="images/link4.png" height="10" width="10" title="Download Events" style="cursor:pointer" onclick="p3showDownloadEventsDialog()">&nbsp; </td> <td class="h2"></td> </tr> </table> <div id="p3events" style=""></div> </div> <div id="p4" style="display:none"> <h1>My Users</h1> <table class="pTable"> <tr> <td class="h1"></td> <td class="style14"> <div style="float:right"> <input type="button" onclick="showUserBroadcastDialog()" style="margin-right:6px" value="Broadcast"> <img onclick="p4downloadUserInfo()" style="cursor:pointer" title="Download user information" src="images/link4.png"> <img id="p4UserBatchCreate" onclick="p4batchAccountCreate()" style="cursor:pointer;display:none" title="Batch create many user accounts" src="images/link6.png"> </div> <div> <input id="UserNewAccountButton" type="button" style="margin-left:6px" onclick="showCreateNewAccountDialog()" value="New Account..."> <input id="UserSearchInput" type="text" style="width:120px;margin-left:6px" placeholder="Filter" onchange="onUserSearchInputChanged()" onkeyup="onUserSearchInputChanged()" autocomplete="off" onfocus="onUserSearchFocus(1)" onblur="onUserSearchFocus(0)"> </div> </td> <td class="h2"></td> </tr> </table> <div id="p3users"></div> </div> <div id="p5" style="display:none"> <h1>My Files</h1> <table id="p5toolbar" cellpadding="0" cellspacing="0"> <tr> <td id="p5filehead" valign="bottom"> <div id="p5rightOfButtons"></div> <div> <input type="button" id="p5FolderUp" disabled="disabled" onclick="p5folderup();" value="Up">&nbsp; <input type="button" id="p5SelectAllButton" disabled="disabled" onclick="p5selectallfile();" value="Select All" onkeypress="return false;" onkeydown="return false;">&nbsp; <input type="button" id="p5RenameFileButton" disabled="disabled" value="Rename" onclick="p5renamefile();" onkeypress="return false;" onkeydown="return false;">&nbsp; <input type="button" id="p5DeleteFileButton" disabled="disabled" value="Delete" onclick="p5deletefile();" onkeypress="return false;" onkeydown="return false;">&nbsp; <input type="button" id="p5NewFolderButton" disabled="disabled" value="New Folder" onclick="p5createfolder();" onkeypress="return false;" onkeydown="return false;">&nbsp; <input type="button" id="p5UploadButton" disabled="disabled" value="Upload" onclick="p5uploadFile()" onkeypress="return false;" onkeydown="return false;">&nbsp; <input type="button" id="p5CutButton" disabled="disabled" value="Cut" onclick="p5copyFile(1)" onkeypress="return false" onkeydown="return false">&nbsp; <input type="button" id="p5CopyButton" disabled="disabled" value="Copy" onclick="p5copyFile(0)" onkeypress="return false" onkeydown="return false">&nbsp; <input type="button" id="p5PasteButton" disabled="disabled" value="Paste" onclick="p5pasteFile()" onkeypress="return false" onkeydown="return false">&nbsp; </div> </td> </tr> <tr> <td id="p5filesubhead"> <div style="float:right"> <select id="p5sortdropdown" onchange="updateFiles()"> <option value="1" selected="selected">Sort by name <option value="2">Sort by size <option value="3">Sort by date <option value="4">Descend by name <option value="5">Descend by size <option value="6">Descend by date </select> </div> <div>&nbsp;&nbsp;<span id="p5currentpath"></span></div> </td> </tr> </table> <div id="p5filetable"> <div id="p5PublicShare" style=""><div>These files are shared publicly, click "link" to get public url.</div></div> <div id="bigok" style="display:none"><b>&checkmark;</b></div> <div id="bigfail" style="display:none"><b>&#10007;</b></div> <span id="p5files"></span> </div> <table id="p5toolbarBottom" style="width:100%" cellpadding="0" cellspacing="0"> <tr><td class="style6">&nbsp;<span id="p5bottomstatus"></span></td></tr> </table> </div> <div id="p6" style="display:none"> <img id="MainMeshImage" src="serverpic.ashx"> <h1>My Server</h1> <div id="p2ServerActions"> <p><strong>Server actions</strong></p> <div class="mL"> <div id="p2ServerActionsBackup"><a href="{{{domainurl}}}backup.zip" rel="noreferrer noopener" target="_blank">Download server backup</a></div> <div id="p2ServerActionsRestore"><a onclick="server_showRestoreDlg()">Restore server with backup</a></div> <div id="p2ServerActionsVersion"><a onclick="server_showVersionDlg()">Check server version</a></div> <div id="p2ServerActionsErrors"><a onclick="server_showErrorsDlg()">Show server error log</a></div> </div> </div> <br><strong>Server Statistics</strong><br><br> <div id="serverStats"> <div id="serverCpuChartView" style="display:none"> <div class="chartViewCanvas"><canvas id="serverCpuChart"></canvas></div> <div class="chartViewText" id="serverCpuChartText"></div> </div> <div id="serverMemoryChartView" style="display:none"> <div class="chartViewCanvas"><canvas id="serverMemoryChart"></canvas></div> <div class="chartViewText" id="serverMemoryChartText"></div> </div><br><br> <div id="serverStatsTable"></div> </div> </div> <div id="p10" style="display:none"> <table style="width:100%" cellpadding="0" cellspacing="0"> <tr> <td style="width:auto" valign="top"> <div id="p10title"> <div id="p10BackButton"><div class="backButton" onclick="goBack()" title="Back"><div class="backButtonEx"></div></div></div> <h1>General - <span id="p10deviceName"></span></h1> </div> <div id="p10html"></div> </td> <td style="width:20px"></td> <td style="width:200px"> <a onclick="p10showiconselector()"><img id="MainComputerImage"></a> <div id="MainComputerState"></div> </td> </tr> </table><br> <div id="p10html2"></div> <div id="p10html3"></div> </div> <div id="p11" class="noselect" style="display:none"> <div id="p11title"> <div id="p11deviceNameHeader"> <div id="p11BackButton"><div class="backButton" onclick="goBack()" title="Back"><div class="backButtonEx"></div></div></div> <div id="devListToolbarViewIcons"><div class="viewSelector" onclick="deskToggleFull(event)" title="Full Screen. Hold shift to browser full screen."><div class="viewSelector5"></div></div></div> <h1>Desktop - <span id="p11deviceName"></span></h1> </div> </div> <div id="p11warning" onclick="showFeaturesDlg()"> <div class="icon2"></div> <div class="warningbox">Intel&reg; AMT Redirection port or KVM feature is disabled<span id="p11warninga">, click here to enable it.</span></div> </div> <div id="p11warning2" onclick="showPowerActionDlg()"> <div class="icon2"></div> <div class="warningbox">Remote computer is not powered on, click here to issue a power command.</div> </div> <div id="deskarea0" cellpadding="0" cellspacing="0"> <div id="deskarea1" class="areaHead"> <div class="toright2"> <span id="p11power"></span>&nbsp; <div class='deskareaicon' title="Toggle View Mode" onclick="toggleAspectRatio(1)">&#8690;</div> <div class='deskareaicon' title="Rotate Left" onclick="drotate(-1)">&olarr;</div> <div class='deskareaicon' title="Rotate Right" onclick="drotate(1)">&orarr;</div> <input id="deskFocusBtn" type="button" title="Toggle focus mode, when active only the region around the mouse is updated" onkeypress="return false" onkeydown="return false" value="Focus All" onclick="deskToggleFocus()" style="margin-right:3px;display:none"> <input id="deskSaveBtn" type="button" title="Save a screenshot of the remote desktop" onkeypress="return false" onkeydown="return false" value="Save..." onclick="deskSaveImage()" class="mR"> <input id="deskActionsBtn" type="button" title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value="Actions" onclick="deviceActionFunction()" class="mR"> <input id="deskActionsSettings" type="button" value="Settings..." title="Edit remote desktop settings" onkeypress="return false" onkeydown="return false" onclick="showDesktopSettings()" class="mR"> <input type="button" title="Change the power state of the remote machine" onkeypress="return false" onkeydown="return false" value="Power Actions..." onclick="showPowerActionDlg()" style="display:none"> </div> <div> <div id="idx_deskFullBtn2" onclick="deskToggleFull(event)">&nbsp;&#x2716;</div> <input type="button" id="autoconnectbutton1" value="AutoConnect" onclick="autoConnectDesktop(event)" onkeypress="return false" onkeydown="return false" style="display:none"> <span id="connectbutton1span"><input type="button" id="connectbutton1" value="Connect" onclick="connectDesktop(event,1)" onkeypress="return false" onkeydown="return false" disabled="disabled"></span> <span id="connectbutton1hspan">&nbsp;<input type="button" id="connectbutton1h" value="HW Connect" onclick="connectDesktop(event,2)" onkeypress="return false" onkeydown="return false" disabled="disabled"></span> <span id="disconnectbutton1span">&nbsp;<input type="button" id="disconnectbutton1" value="Disconnect" onclick="connectDesktop(event,0)" onkeypress="return false" onkeydown="return false"></span> &nbsp;<span id="deskstatus">Disconnected</span> </div> </div> <div id="deskarea2" style=""> <div class="areaProgress"><div id="progressbar" style=""></div></div> </div> <div id="deskarea3x"> <div id="DeskFocus" oncontextmenu="return false" onmousedown="dmousedown(event)" onmouseup="dmouseup(event)" onmousemove="dmousemove(event)"></div> <div id="DeskParent"> <canvas id="Desk" width="640" height="480" oncontextmenu="return false" onmousedown="dmousedown(event)" onmouseup="dmouseup(event)" onmousemove="dmousemove(event)" onmousewheel="dmousewheel(event)"></canvas> </div> <div id="DeskTools"> <a id="DeskToolsRefreshButton" style="" onclick="refreshDeskTools()">Refresh</a> <div id="DeskToolsBar">Processes</div> <div id="deskToolsArea"> <div id="deskToolsHeader"> <a class="colmn1" title="Sort by process id" onclick="sortProcess(0)">PID</a> <a class="colmn2" title="Sort by name" onclick="sortProcess(1)">Name</a></div> <div id="DeskToolsProcesses" style=""></div> </div> </div> <div id="p11DeskConsoleMsg" style="display:none;cursor:pointer;position:absolute;left:30px;top:17px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick="p11clearConsoleMsg()"></div> </div> <div id="deskarea4" class="areaFoot"> <div class="toright2"> <select id="termdisplays" style="display:none" onchange="deskSetDisplay(event)"></select>&nbsp; <input id="DeskToolsButton" type="button" value="Tools" title="Toggle tools view" onkeypress="return false" onkeydown="return false" onclick="toggleDeskTools()">&nbsp; <span id="DeskChatButton" class="deskarea" title="Open chat window to this computer"><img src='images/icon-chat.png' onclick="deviceChat()" height="16" width="16" style="padding-top:2px"></span> <span id="DeskNotifyButton" title="Display a notification on the remote computer"><img src='images/icon-notify.png' onclick="deviceToastFunction()" height="16" width="16" style="padding-top:2px"></span> <span id="DeskOpenWebButton" title="Open a web address on remote computer"><img src='images/icon-url2.png' onclick="deviceUrlFunction()" height="16" width="16" style="padding-top:2px"></span> </div> <div> <select id="deskkeys"> <option value="5">Win <option value="0">Win+Down <option value="1">Win+Up <option value="2">Win+L <option value="3">Win+M <option value="4">Shift+Win+M <option value="6">Win+R <option value="7">Alt-F4 <option value="8">Ctrl-W <option value="9">Alt-Tab </select> <input id="DeskWD" type="button" value="Send" onkeypress="return false" onkeydown="return false" onclick="deskSendKeys()"> <input id="DeskClip" style="" type="button" value="Clipboard" onkeypress="return false" onkeydown="return false" onclick="showDeskClip()"> <input id="DeskCAD" type="button" value="Ctrl-Alt-Del" onkeypress="return false" onkeydown="return false" onclick="sendCAD()"> <label><span id="DeskControlSpan" title="Toggle mouse and keyboard input"><input id="DeskControl" type="checkbox" onkeypress="return false" onkeydown="return false" onclick="toggleKvmControl()">Input</span></label>&nbsp; </div> </div> </div> </div> <div id="p12" style="display:none"> <div id="p12title"> <div id="p12BackButton"><div class="backButton" onclick="goBack()" title="Back"><div class="backButtonEx"></div></div></div> <h1>Terminal - <span id="p12deviceName"></span></h1> </div> <div id="p12warning" onclick="showFeaturesDlg()"> <div class="icon2"></div> <div class="warningbox">Intel&reg; AMT Redirection port or KVM feature is disabled<span id="p12warninga">, click here to enable it.</span></div> </div> <div id="p12warning2" onclick="showPowerActionDlg()"> <div class="icon2"></div> <div class="warningbox">Remote computer is not powered on, click here to issue a power command.</div> </div> <div id="termTable" style="position:relative"> <table style="width:100%" cellpadding="0" cellspacing="0"> <tr> <td class="areaHead"> <div class="toright2"> <input id="termActionsBtn" type="button" title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value="Actions" onclick="deviceActionFunction()/"> </div> <div> <input type="button" id="autoconnectbutton2" value="AutoConnect" onclick="autoConnectTerminal(event)" onkeypress="return false" onkeydown="return false" style="display:none"> <span id="connectbutton2span"><input type="button" id="connectbutton2" value="Connect" onclick="connectTerminal(event,1)" onkeypress="return false" onkeydown="return false" disabled="disabled"></span> <span id="connectbutton2hspan">&nbsp;<input type="button" id="connectbutton2h" value="HW Connect" onclick="connectTerminal(event,2)" onkeypress="return false" onkeydown="return false" disabled="disabled"></span> <span id="disconnectbutton2span">&nbsp;<input type="button" id="disconnectbutton2" value="Disconnect" onclick="connectTerminal(event,0)" onkeypress="return false" onkeydown="return false"></span> &nbsp;<span id="termstatus">Disconnected</span><span id="termtitle"></span> </div> </td> </tr> <tr> <td> <div class="areaProgress"><div id="termprogressbar" style=""></div></div> </td> </tr> <tr> <td id="termarea3x"> <pre id="Term"></pre> </td> </tr> <tr> <td class="areaFoot"> <div class="toright2"> <span id="terminalSettingsButtons" style="display:none"> <input id="id_tcrbutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="CR+LF" title="Toggle what the return key will send" onclick="termToggleCr()"> <input id="id_tfxkeysbutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Intel (F10 = ESC+[OM)" title="Toggle F1 to F10 keys emulation type" onclick="termToggleFx()"> <input id="id_ttypebutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Extended Ascii" title="Toggle terminal emulation type" onclick="termToggleType()"> </span> <span id="terminalSizeDropDown"> <select id="termSizeList" onkeypress="return false"><option value="1">80x25<option value="2">100x30<option value="3" selected="">Auto</select> </span> <select id="specialkeylist" onkeypress="return false"></select> <input id="specialkeylistinput" type="button" onkeypress="return false" class="bottombutton" value="Send" title="Send the selected special key" onclick="sendSpecialKey()"> </div> <div> &nbsp; <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlcbutton" value="Ctl-C" onclick="termSendKey(3,'ctrlcbutton')"> <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlxbutton" value="Ctl-X" onclick="termSendKey(24,'ctrlxbutton')"> <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="escbutton" value="ESC" onclick="termSendKey(27,'escbutton')"> <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="bsbutton" value="Backspace" onclick="termSendKey(8,'bsbutton')"> <input type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" id="pastebutton" value="Paste" title="Paste text into the terminal" onclick="showTermPasteDialog()"> </div> </td> </tr> </table> <div id="p12TermConsoleMsg" style="display:none;cursor:pointer;position:absolute;left:30px;top:45px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick="p12clearConsoleMsg()"></div> </div> </div> <div id="p13" style="display:none"> <div id="p13title"> <div id="p13BackButton" style="float:left"><div class="backButton" onclick="goBack()" title="Back"><div class="backButtonEx"></div></div></div> <h1>Files - <span id="p13deviceName"></span></h1> </div> <table id="p13toolbar" cellpadding="0" cellspacing="0"> <tr> <td class="areaHead"> <div class="toright2"> <input id="filesActionsBtn" type="button" title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value="Actions" onclick="deviceActionFunction()"> </div> <div> <input id="p13AutoConnect" value="AutoConnect" onclick="autoConnectFiles(event)" onkeypress="return false" onkeydown="return false" type="button" style="display:none"> <input id="p13Connect" value="Connect" onclick="connectFiles(event)" onkeypress="return false" onkeydown="return false" type="button"> <span id="p13Status">Disconnected</span> </div> </td> </tr> <tr> <td class="areaHead2" valign="bottom"> <div id="p13rightOfButtons" class="toright2"></div> <div> <input type="button" id="p13FolderUp" disabled="disabled" onclick="p13folderup()" value="Up">&nbsp; <input type="button" id="p13SelectAllButton" disabled="disabled" onclick="p13selectallfile()" value="Select All" onkeypress="return false" onkeydown="return false">&nbsp; <input type="button" id="p13RenameFileButton" disabled="disabled" value="Rename" onclick="p13renamefile()" onkeypress="return false" onkeydown="return false">&nbsp; <input type="button" id="p13DeleteFileButton" disabled="disabled" value="Delete" onclick="p13deletefile()" onkeypress="return false" onkeydown="return false">&nbsp; <input type="button" id="p13NewFolderButton" disabled="disabled" value="New Folder" onclick="p13createfolder()" onkeypress="return false" onkeydown="return false">&nbsp; <input type="button" id="p13UploadButton" disabled="disabled" value="Upload" onclick="p13uploadFile()" onkeypress="return false" onkeydown="return false">&nbsp; <input type="button" id="p13CutButton" disabled="disabled" value="Cut" onclick="p13copyFile(1)" onkeypress="return false" onkeydown="return false">&nbsp; <input type="button" id="p13CopyButton" disabled="disabled" value="Copy" onclick="p13copyFile(0)" onkeypress="return false" onkeydown="return false">&nbsp; <input type="button" id="p13PasteButton" disabled="disabled" value="Paste" onclick="p13pasteFile()" onkeypress="return false" onkeydown="return false">&nbsp; <input type="button" id="p13RefreshButton" disabled="disabled" value="Refresh" onclick="p13folderup(9999)" onkeypress="return false" onkeydown="return false">&nbsp; </div> </td> </tr> <tr> <td class="areaHead3"> <div class="toright2"> <select id="p13sortdropdown" onchange="p13updateFiles()"> <option value="1" selected="selected">Sort by name <option value="2">Sort by size <option value="3">Sort by date <option value="4">Descend by name <option value="5">Descend by size <option value="6">Descend by date </select> </div> <div>&nbsp;&nbsp;<span id="p13currentpath"></span></div> </td> </tr> </table> <div id="p13FilesConsoleMsg" style="display:none;cursor:pointer;position:absolute;left:30px;top:165px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick="p13clearConsoleMsg()"></div> <div id="p13filetable" style=""> <div id="p13bigok" style="display:none"><b>&checkmark;</b></div> <div id="p13bigfail" style="display:none"><b>&#10007;</b></div> <span id="p13files"></span> </div> <table id="p13toolbarBottom" cellpadding="0" cellspacing="0"> <tr><td class="style6">&nbsp;<span id="p13bottomstatus"></span></td></tr> </table> </div> <div id="p14" style="display:none"> <div id="p14title"> <div id="p14BackButton" style="float:left"><div class="backButton" onclick="goBack()" title="Back"><div class="backButtonEx"></div></div></div> <div id="devListToolbarViewIcons"><div class="viewSelector" onclick="deskToggleFull(event)" title="Full Screen. Hold shift to browser full screen."><div class="viewSelector5"></div></div></div> <h1>Intel&reg; AMT - <span id="p14deviceName"></span></h1> </div> <iframe id="p14iframe" src="{{{domainurl}}}commander.htm"></iframe> </div> <div id="p15" style="display:none"> <div id="p15title"> <div id="p15BackButton" style="float:left"><div class="backButton" onclick="goBack()" title="Back"><div class="backButtonEx"></div></div></div> <h1><span id="p15deviceName"></span></h1> </div> <table id="consoleTable" cellpadding="0" cellspacing="0"> <tr> <td class="areaHead"> <div class="toright2"> <div id="p15coreName" title="Information about current core running on this agent"></div> <input type="button" id="p15uploadCore" value="Agent Action" onclick="p15uploadCore(event)" title="Change the agent Java Script code module"> <img onclick="p15downloadConsoleText()" style="cursor:pointer;margin-top:6px" title="Download console text" src="images/link4.png"> </div> <div id="p15statetext"></div> </td> </tr> <tr> <td> <div class="areaProgress"><div id="consoleprogressbar" style=""></div></div> </td> </tr> <tr> <td id="p15agentConsole"> <pre id="p15agentConsoleText"></pre> </td> </tr> <tr> <td class="areaFoot"> <table style="width:100%"> <tr> <td style="width:99%"> <input id="p15consoleText" style="width:100%" onkeyup="p15consoleSend(event)" onfocus="onConsoleFocus(1)" onblur="onConsoleFocus(0)"> </td> <td>&nbsp;</td> <td style="width:1%"><input id="id_p15consoleClear" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Clear" onclick="p15consoleClear()"></td> </tr> </table> </td> </tr> </table> </div> <div id="p16" style="display:none"> <div id="p16title"> <div id="p16BackButton" style="float:left"><div class="backButton" onclick="goBack()" title="Back"><div class="backButtonEx"></div></div></div> <h1>Events - <span id="p16deviceName"></span></h1> </div> <table class="pTable"> <tr> <td class="h1"></td> <td>&nbsp;<input type="button" onclick="refreshDeviceEvents()" value="Refresh"></td> <td class="auto-style1"> Show <select id="p16limitdropdown" onchange="refreshDeviceEvents()"> <option value="60">Last 60 <option value="120">Last 120 <option value="250">Last 250 <option value="500">Last 500 <option value="1000">Last 1000 </select> </td> <td class="h2"></td> </tr> </table> <div id="p16events"></div> </div> <div id="p20" style="display:none"> <picture id="MainMeshImage" style="border-width:0px;height:200px;width:200px;float:right"> <source type="image/webp" width="200" height="200" srcset="images/webp/mesh-256.webp"> <img alt="" width="200" height="200" src="images/mesh-256.png"> </source></picture> <div style="float:left"><div class="backButton" onclick="goBack()" title="Back"><div class="backButtonEx"></div></div></div> <h1>General - <span id="p20meshName"></span></h1> <p id="p20info"> </div> <div id="p30" style="display:none"> <table style="width:100%" cellpadding="0" cellspacing="0"> <tr> <td style="width:auto" valign="top"> <div id="p30title"> <div style="float:left"><div class="backButton" onclick="goBack()" title="Back"><div class="backButtonEx"></div></div></div> <h1>General - <span id="p30userName"></span></h1> </div> <div id="p30html"></div> </td> <td style="width:20px"></td> <td style="width:200px"> <picture id="MainUserImage" style="border-width:0px;height:200px;width:200px;float:right"> <source type="image/webp" width="200" height="200" srcset="images/webp/user-256.webp"> <img alt="" width="200" height="200" src="images/user-256.png"> </source></picture> <div style="width:100%;text-align:center"><strong><span id="MainUserState"></span></strong></div> </td> </tr> </table><br> <div id="p30html2"></div> <div id="p30html3"></div> </div> <div id="p31" style="display:none"> <div style="float:left"><div class="backButton" onclick="goBack()" title="Back"><div class="backButtonEx"></div></div></div> <h1>Events - <span id="p31userName"></span></h1> <table class="pTable"> <tr> <td class="h1"></td> <td>&nbsp;<input type="button" onclick="refreshUsersEvents()" value="Refresh"></td> <td class="auto-style1"> Show <select id="p31limitdropdown" onchange="refreshUsersEvents()"> <option value="60">Last 60 <option value="120">Last 120 <option value="250">Last 250 <option value="500">Last 500 <option value="1000">Last 1000 </select> </td> <td class="h2"></td> </tr> </table> <div id="p31events"></div> </div> <div id="p40" style="display:none;"> <h1>My Server Stats</h1> <div class="areaHead"> <div class="toright2"> <select id="p40type" onchange="updateServerTimelineStats()"> <option value="0">Connections <option value="1">Memory </select>&nbsp; <select id="p40time" onchange="updateServerTimelineHours()"> <option value="3">Last 3 hours <option value="8">Last 8 hours <option value="24">Last day <option value="168">Last week <option value="720">Last 30 days </select>&nbsp; <img src="images/link4.png" height="10" width="10" title="Download data points (.csv)" style="cursor:pointer" onclick="p40downloadEvents()">&nbsp; </div> <div> <input value="Refresh" type="button" onclick="refreshServerTimelineStats()"> &nbsp;<input id="p40log" type="checkbox" onclick="updateServerTimelineHours()">Log-X </div> </div> <canvas id="serverMainStats" style=""></canvas> </div> <br id="column_l_bottomgap"> </div> <div id="footer"> <div class="footer1">{{{footer}}}</div> <div class="footer2"> <a id="verifyEmailId2" style="display:none" onclick="account_showVerifyEmail()">Verify Email</a> &nbsp;<a href="terms">Terms &amp; Privacy</a> </div> </div> <div id="dialog" style="display:none"> <div id="dialogHeader"> <div id="id_dialogclose" onclick="setDialogMode()">&#x2716;</div> <div id="id_dialogtitle"></div> </div> <div id="dialogBody"> <div id="dialog1"> <div id="id_dialogMessage" style=""></div> </div> <div id="dialog2" style=""> <div id="id_dialogOptions"></div> </div> <div id="dialog3" style=""> <div id="d3upload"> <div>File Selection</div> <select id="d3uploadMode" onchange="d3modechange()"> <option value="1">Local file upload <option value="2">Server file selection </select> </div> <div id="d3localmode" style="display:none"> <div>Upload File</div> <form id="d3localmodeform" method="post" enctype="multipart/form-data" action="uploadfile.ashx" target="fileUploadFrame"> <input type="text" id="d3attrib" name="attrib" style="display:none"> <input type="file" id="d3localFile" name="files" onchange="d3setActions()"> <input type="submit" id="d3submit" style="display:none"> </form> </div> <div id="d3servermode"> <div id="d3serveraction" valign="bottom"> <input type="button" id="p3FolderUp" disabled="disabled" onclick="d3folderup()" value="Up">&nbsp; </div> <div id="d3serverfiles"></div> </div> </div> <div id="dialog7" style=""> <div id="d7meshkvm"> <h4>Agent Remote Desktop</h4> <div> <div>Quality</div> <select id="d7bitmapquality" dir="rtl"></select> </div> <div> <div>Scaling</div> <select id="d7bitmapscaling" style="" dir="rtl"> <option selected="selected" value="1024">100% <option value="896">87.5% <option value="768">75% <option value="640">62.5% <option value="512">50% <option value="384">37.5% <option value="256">25% <option value="128">12.5% </select> </div> <div> <div>Frame rate</div> <select id="d7framelimiter" dir="rtl"> <option selected="selected" value="50">Fast <option value="100">Medium <option value="400">Slow <option value="1000">Very slow </select> </div> </div> <div id="d7amtkvm"> <h4>Intel&reg; AMT Hardware KVM</h4> <div> <div>Image Encoding</div> <select id="d7desktopmode"> <option value="1">RLE8, Fastest <option value="2">RLE16, Recommended <option value="3">RAW8, Slow <option value="4">RAW16, Very Slow </select> </div> <div> <div>Other Settings</div> <div id="d7otherset" style="display:block"> <label style="display:block"><input type="checkbox" id="d7showfocus">Show Focus Tool</label> <label style="display:block"><input type="checkbox" id="d7showcursor">Show Local Mouse Cursor</label> <label style="display:block"><input type="checkbox" id="d7localKeyMap">Local Keyboard Map</label> </div> </div> </div> </div> </div> <div id="idx_dlgButtonBar"> <input id="idx_dlgCancelButton" type="button" value="Cancel" style="" onclick="dialogclose(0)"> <input id="idx_dlgOkButton" type="button" value="OK" style="" onclick="dialogclose(1)"> <div><input id="idx_dlgDeleteButton" type="button" value="Delete" style="display:none" onclick="dialogclose(2)"></div> </div> </div> <iframe name="fileUploadFrame" style="display:none"></iframe> <form style="display:none" method="post" action="uploadfile.ashx" enctype="multipart/form-data" target="fileUploadFrame"><input id="p5fileDragName" name="name"><input id="p5fileDragSize" name="size"><input id="p5fileDragType" name="type"><input id="p5fileDragData" name="data"><input id="p5fileDragLink" name="link"><input type="submit" id="p5loginSubmit2" style="display:none"></form> <form style="display:none" method="post" action="uploadnodefile.ashx" enctype="multipart/form-data" target="fileUploadFrame"><input id="p13fileDragName" name="name"><input id="p13fileDragSize" name="size"><input id="p13fileDragType" name="type"><input id="p13fileDragData" name="data"><input id="p13fileDragLink" name="link"><input type="submit" id="p13loginSubmit2" style="display:none"></form> <audio id="chimes"><source src="sounds/chimes.mp3" type="audio/mp3"></source></audio> </div> <script>/**
2 -* @description Set of short commonly used methods for handling HTML elements
3 -* @author Ylian Saint-Hilaire
4 -* @version v0.0.1b
5 -*/
6 -
7 -// Add startsWith for IE browser
8 -if (!String.prototype.startsWith) { String.prototype.startsWith = function (str) { return this.lastIndexOf(str, 0) === 0; }; }
9 -if (!String.prototype.endsWith) { String.prototype.endsWith = function (str) { return this.indexOf(str, this.length - str.length) !== -1; }; }
10 -
11 -// Quick UI functions, a bit of a replacement for jQuery
12 -//function Q(x) { if (document.getElementById(x) == null) { console.log('Invalid element: ' + x); } return document.getElementById(x); } // "Q"
13 -function Q(x) { return document.getElementById(x); } // "Q"
14 -function QS(x) { try { return Q(x).style; } catch (x) { } } // "Q" style
15 -function QE(x, y) { try { Q(x).disabled = !y; } catch (x) { } } // "Q" enable
16 -function QV(x, y) { try { QS(x).display = (y ? '' : 'none'); } catch (x) { } } // "Q" visible
17 -function QA(x, y) { Q(x).innerHTML += y; } // "Q" append
18 -function QH(x, y) { Q(x).innerHTML = y; } // "Q" html
19 -function QC(x) { try { return Q(x).classList; } catch (x) { } } // "Q" class
20 -
21 -// Move cursor to end of input box
22 -function inputBoxFocus(x) { Q(x).focus(); var v = Q(x).value; Q(x).value = ''; Q(x).value = v; }
23 -
24 -// Binary encoding and decoding functions
25 -function ReadShort(v, p) { return (v.charCodeAt(p) << 8) + v.charCodeAt(p + 1); }
26 -function ReadShortX(v, p) { return (v.charCodeAt(p + 1) << 8) + v.charCodeAt(p); }
27 -function ReadInt(v, p) { return (v.charCodeAt(p) * 0x1000000) + (v.charCodeAt(p + 1) << 16) + (v.charCodeAt(p + 2) << 8) + v.charCodeAt(p + 3); } // We use "*0x1000000" instead of "<<24" because the shift converts the number to signed int32.
28 -function ReadSInt(v, p) { return (v.charCodeAt(p) << 24) + (v.charCodeAt(p + 1) << 16) + (v.charCodeAt(p + 2) << 8) + v.charCodeAt(p + 3); }
29 -function ReadIntX(v, p) { return (v.charCodeAt(p + 3) * 0x1000000) + (v.charCodeAt(p + 2) << 16) + (v.charCodeAt(p + 1) << 8) + v.charCodeAt(p); }
30 -function ShortToStr(v) { return String.fromCharCode((v >> 8) & 0xFF, v & 0xFF); }
31 -function ShortToStrX(v) { return String.fromCharCode(v & 0xFF, (v >> 8) & 0xFF); }
32 -function IntToStr(v) { return String.fromCharCode((v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF); }
33 -function IntToStrX(v) { return String.fromCharCode(v & 0xFF, (v >> 8) & 0xFF, (v >> 16) & 0xFF, (v >> 24) & 0xFF); }
34 -function MakeToArray(v) { if (!v || v == null || typeof v == 'object') return v; return [v]; }
35 -function SplitArray(v) { return v.split(','); }
36 -function Clone(v) { return JSON.parse(JSON.stringify(v)); }
37 -function EscapeHtml(x) { if (typeof x == "string") return x.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;'); if (typeof x == "boolean") return x; if (typeof x == "number") return x; }
38 -function EscapeHtmlBreaks(x) { if (typeof x == "string") return x.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;').replace(/\r/g, '<br />').replace(/\n/g, '').replace(/\t/g, '&nbsp;&nbsp;'); if (typeof x == "boolean") return x; if (typeof x == "number") return x; }
39 -
40 -// Move an element from one position in an array to a new position
41 -function ArrayElementMove(arr, from, to) { arr.splice(to, 0, arr.splice(from, 1)[0]); };
42 -
43 -// Print object for HTML
44 -function ObjectToStringEx(x, c) {
45 - var r = "";
46 - if (x != 0 && (!x || x == null)) return "(Null)";
47 - if (x instanceof Array) { for (var i in x) { r += '<br />' + gap(c) + "Item #" + i + ": " + ObjectToStringEx(x[i], c + 1); } }
48 - else if (x instanceof Object) { for (var i in x) { r += '<br />' + gap(c) + i + " = " + ObjectToStringEx(x[i], c + 1); } }
49 - else { r += EscapeHtml(x); }
50 - return r;
51 -}
52 -
53 -// Print object for console
54 -function ObjectToStringEx2(x, c) {
55 - var r = "";
56 - if (x != 0 && (!x || x == null)) return "(Null)";
57 - if (x instanceof Array) { for (var i in x) { r += '\r\n' + gap2(c) + "Item #" + i + ": " + ObjectToStringEx2(x[i], c + 1); } }
58 - else if (x instanceof Object) { for (var i in x) { r += '\r\n' + gap2(c) + i + " = " + ObjectToStringEx2(x[i], c + 1); } }
59 - else { r += EscapeHtml(x); }
60 - return r;
61 -}
62 -
63 -// Create an ident gap
64 -function gap(c) { var x = ''; for (var i = 0; i < (c * 4) ; i++) { x += '&nbsp;'; } return x; }
65 -function gap2(c) { var x = ''; for (var i = 0; i < (c * 4) ; i++) { x += ' '; } return x; }
66 -
67 -// Print an object in html
68 -function ObjectToString(x) { return ObjectToStringEx(x, 0); }
69 -function ObjectToString2(x) { return ObjectToStringEx2(x, 0); }
70 -
71 -// Convert a hex string to a raw string
72 -function hex2rstr(d) {
73 - if (typeof d != "string" || d.length == 0) return '';
74 - var r = '', m = ('' + d).match(/../g), t;
75 - while (t = m.shift()) r += String.fromCharCode('0x' + t);
76 - return r
77 -}
78 -
79 -// Convert decimal to hex
80 -function char2hex(i) { return (i + 0x100).toString(16).substr(-2).toUpperCase(); }
81 -
82 -// Convert a raw string to a hex string
83 -function rstr2hex(input) { var r = '', i; for (i = 0; i < input.length; i++) { r += char2hex(input.charCodeAt(i)); } return r; }
84 -
85 -// UTF-8 encoding & decoding functions
86 -function encode_utf8(s) { return unescape(encodeURIComponent(s)); }
87 -function decode_utf8(s) { return decodeURIComponent(escape(s)); }
88 -
89 -// Convert a string into a blob
90 -function data2blob(data) {
91 - var bytes = new Array(data.length);
92 - for (var i = 0; i < data.length; i++) bytes[i] = data.charCodeAt(i);
93 - var blob = new Blob([new Uint8Array(bytes)]);
94 - return blob;
95 -}
96 -
97 -// Generate random numbers
98 -function random(max) { return Math.floor(Math.random() * max); }
99 -
100 -// Trademarks
101 -function trademarks(x) { return x.replace(/\(R\)/g, '&reg;').replace(/\(TM\)/g, '&trade;'); }
102 -/**
103 -* @fileoverview Meshcentral.js
104 -* @author Ylian Saint-Hilaire
105 -* @version v0.0.1
106 -*/
107 -
108 -var MeshServerCreateControl = function (domain, authCookie) {
109 - var obj = {};
110 - obj.State = 0;
111 - obj.connectstate = 0;
112 - obj.pingTimer = null;
113 - obj.authCookie = authCookie;
114 - obj.trace = false;
115 -
116 - obj.xxStateChange = function (newstate, errCode) {
117 - if (obj.State == newstate) return;
118 - var previousState = obj.State;
119 - obj.State = newstate;
120 - if (obj.onStateChanged) obj.onStateChanged(obj, obj.State, previousState, errCode);
121 - }
122 -
123 - obj.Start = function () {
124 - if (obj.connectstate != 0) return;
125 - obj.connectstate = 0;
126 - var url = window.location.protocol.replace("http", "ws") + "//" + window.location.host + domain + "control.ashx";
127 - if (obj.authCookie && (obj.authCookie != '')) { url += '?auth=' + obj.authCookie; }
128 - obj.socket = new WebSocket(url);
129 - obj.socket.onopen = function (e) { obj.connectstate = 1; }
130 - obj.socket.onmessage = obj.xxOnMessage;
131 - obj.socket.onclose = function(e) { obj.Stop(e.code); }
132 - obj.xxStateChange(1, 0);
133 - if (obj.pingTimer != null) { clearInterval(obj.pingTimer); }
134 - obj.pingTimer = setInterval(function () { obj.send({ action: 'ping' }); }, 29000); // Ping the server every 29 seconds, stops corporate proxies from disconnecting.
135 - }
136 -
137 - obj.Stop = function (errCode) {
138 - obj.connectstate = 0;
139 - if (obj.socket) { obj.socket.close(); delete obj.socket; }
140 - if (obj.pingTimer != null) { clearInterval(obj.pingTimer); obj.pingTimer = null; }
141 - obj.xxStateChange(0, errCode);
142 - }
143 -
144 - obj.xxOnMessage = function (e) {
145 - if (obj.State == 1) { obj.xxStateChange(2); }
146 - //console.log('xxOnMessage', e.data);
147 - var message;
148 - try { message = JSON.parse(e.data); } catch (e) { return; }
149 - if ((typeof message != 'object') || (message.action == 'pong')) { return; }
150 - if (message.action == 'close') { if (message.msg) { console.log(message.msg); } obj.Stop(message.cause); return; }
151 - if (obj.trace) { console.log('RECV', message); }
152 - if (obj.onMessage) obj.onMessage(obj, message);
153 - };
154 -
155 - obj.send = function (x) {
156 - if (obj.socket != null && obj.connectstate == 1) {
157 - if (obj.trace) { console.log('SEND', x); }
158 - obj.socket.send(JSON.stringify(x));
159 - }
160 - }
161 -
162 - return obj;
163 -}
164 -/**
165 -* @fileoverview Intel(r) AMT Communication Stack
166 -* @author Ylian Saint-Hilaire
167 -* @version v0.2.0b
168 -*/
169 -
170 -/**
171 - * Construct a AmtStackCreateService object, this ia the main Intel AMT communication stack.
172 - * @constructor
173 - */
174 -function AmtStackCreateService(wsmanStack) {
175 - var obj = new Object();
176 - obj.wsman = wsmanStack;
177 - obj.pfx = ["http://intel.com/wbem/wscim/1/amt-schema/1/", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/", "http://intel.com/wbem/wscim/1/ips-schema/1/"];
178 - obj.PendingEnums = [];
179 - obj.PendingBatchOperations = 0;
180 - obj.ActiveEnumsCount = 0;
181 - obj.MaxActiveEnumsCount = 1; // Maximum number of enumerations that can be done at the same time.
182 - obj.onProcessChanged = null;
183 - var _MaxProcess = 0;
184 - var _LastProcess = 0;
185 -
186 - // Return the number of pending actions
187 - obj.GetPendingActions = function () { return (obj.PendingEnums.length * 2) + (obj.ActiveEnumsCount) + obj.wsman.comm.PendingAjax.length + obj.wsman.comm.ActiveAjaxCount + obj.PendingBatchOperations; }
188 -
189 - // Private Method, Update the current processing status, this gives the application an idea of what progress is being done by the WSMAN stack
190 - function _up() {
191 - var x = obj.GetPendingActions();
192 - if (_MaxProcess < x) _MaxProcess = x;
193 - if (obj.onProcessChanged != null && _LastProcess != x) {
194 - //console.log("Process Old=" + _LastProcess + ", New=" + x + ", PEnums=" + obj.PendingEnums.length + ", AEnums=" + obj.ActiveEnumsCount + ", PAjax=" + obj.wsman.comm.PendingAjax.length + ", AAjax=" + obj.wsman.comm.ActiveAjaxCount + ", PBatch=" + obj.PendingBatchOperations);
195 - _LastProcess = x;
196 - obj.onProcessChanged(x, _MaxProcess);
197 - }
198 - if (x == 0) _MaxProcess = 0;
199 - }
200 -
201 - // Perform a WSMAN "SUBSCRIBE" operation.
202 - obj.Subscribe = function (name, delivery, url, callback, tag, pri, selectors, opaque, user, pass) { obj.wsman.ExecSubscribe(obj.CompleteName(name), delivery, url, function (ws, resuri, response, xstatus) { _up(); callback(obj, name, response, xstatus, tag); }, 0, pri, selectors, opaque, user, pass); _up(); }
203 -
204 - // Perform a WSMAN "UNSUBSCRIBE" operation.
205 - obj.UnSubscribe = function (name, callback, tag, pri, selectors) { obj.wsman.ExecUnSubscribe(obj.CompleteName(name), function (ws, resuri, response, xstatus) { _up(); callback(obj, name, response, xstatus, tag); }, 0, pri, selectors); _up(); }
206 -
207 - // Perform a WSMAN "GET" operation.
208 - obj.Get = function (name, callback, tag, pri) { obj.wsman.ExecGet(obj.CompleteName(name), function (ws, resuri, response, xstatus) { _up(); callback(obj, name, response, xstatus, tag); }, 0, pri); _up(); }
209 -
210 - // Perform a WSMAN "PUT" operation.
211 - obj.Put = function (name, putobj, callback, tag, pri, selectors) { obj.wsman.ExecPut(obj.CompleteName(name), putobj, function (ws, resuri, response, xstatus) { _up(); callback(obj, name, response, xstatus, tag); }, 0, pri, selectors); _up(); }
212 -
213 - // Perform a WSMAN "CREATE" operation.
214 - obj.Create = function (name, putobj, callback, tag, pri) { obj.wsman.ExecCreate(obj.CompleteName(name), putobj, function (ws, resuri, response, xstatus) { _up(); callback(obj, name, response, xstatus, tag); }, 0, pri); _up(); }
215 -
216 - // Perform a WSMAN "DELETE" operation.
217 - obj.Delete = function (name, putobj, callback, tag, pri) { obj.wsman.ExecDelete(obj.CompleteName(name), putobj, function (ws, resuri, response, xstatus) { _up(); callback(obj, name, response, xstatus, tag); }, 0, pri); _up(); }
218 -
219 - // Perform a WSMAN method call operation.
220 - obj.Exec = function (name, method, args, callback, tag, pri, selectors) { obj.wsman.ExecMethod(obj.CompleteName(name), method, args, function (ws, resuri, response, xstatus) { _up(); callback(obj, name, obj.CompleteExecResponse(response), xstatus, tag); }, 0, pri, selectors); _up(); }
221 -
222 - // Perform a WSMAN method call operation.
223 - obj.ExecWithXml = function (name, method, args, callback, tag, pri, selectors) { obj.wsman.ExecMethodXml(obj.CompleteName(name), method, execArgumentsToXml(args), function (ws, resuri, response, xstatus) { _up(); callback(obj, name, obj.CompleteExecResponse(response), xstatus, tag); }, 0, pri, selectors); _up(); }
224 -
225 - // Perform a WSMAN "ENUMERATE" operation.
226 - obj.Enum = function (name, callback, tag, pri) {
227 - if (obj.ActiveEnumsCount < obj.MaxActiveEnumsCount) {
228 - obj.ActiveEnumsCount++; obj.wsman.ExecEnum(obj.CompleteName(name), function (ws, resuri, response, xstatus, tag0) { _up(); _EnumStartSink(name, response, callback, resuri, xstatus, tag0); }, tag, pri);
229 - } else {
230 - obj.PendingEnums.push([name, callback, tag, pri]);
231 - }
232 - _up();
233 - }
234 -
235 - // Private method
236 - function _EnumStartSink(name, response, callback, resuri, status, tag, pri) {
237 - if (status != 200) { callback(obj, name, null, status, tag); _EnumDoNext(1); return; }
238 - if (response == null || response.Header["Method"] != "EnumerateResponse" || !response.Body["EnumerationContext"]) { callback(obj, name, null, 603, tag); _EnumDoNext(1); return; }
239 - var enumctx = response.Body["EnumerationContext"];
240 - obj.wsman.ExecPull(resuri, enumctx, function (ws, resuri, response, xstatus) { _EnumContinueSink(name, response, callback, resuri, [], xstatus, tag, pri); });
241 - }
242 -
243 - // Private method
244 - function _EnumContinueSink(name, response, callback, resuri, items, status, tag, pri) {
245 - if (status != 200) { callback(obj, name, null, status, tag); _EnumDoNext(1); return; }
246 - if (response == null || response.Header["Method"] != "PullResponse") { callback(obj, name, null, 604, tag); _EnumDoNext(1); return; }
247 - for (var i in response.Body["Items"]) {
248 - if (response.Body["Items"][i] instanceof Array) {
249 - for (var j in response.Body["Items"][i]) { items.push(response.Body["Items"][i][j]); }
250 - } else {
251 - items.push(response.Body["Items"][i]);
252 - }
253 - }
254 - if (response.Body["EnumerationContext"]) {
255 - var enumctx = response.Body["EnumerationContext"];
256 - obj.wsman.ExecPull(resuri, enumctx, function (ws, resuri, response, xstatus) { _EnumContinueSink(name, response, callback, resuri, items, xstatus, tag, 1); });
257 - } else {
258 - _EnumDoNext(1);
259 - callback(obj, name, items, status, tag);
260 - _up();
261 - }
262 - }
263 -
264 - // Private method
265 - function _EnumDoNext(dec) {
266 - obj.ActiveEnumsCount -= dec;
267 - if (obj.ActiveEnumsCount >= obj.MaxActiveEnumsCount || obj.PendingEnums.length == 0) return;
268 - var x = obj.PendingEnums.shift();
269 - obj.Enum(x[0], x[1], x[2]);
270 - _EnumDoNext(0);
271 - }
272 -
273 - // Perform a batch of WSMAN "ENUM" operations.
274 - obj.BatchEnum = function (batchname, names, callback, tag, continueOnError, pri) {
275 - obj.PendingBatchOperations += (names.length * 2);
276 - _BatchNextEnum(batchname, Clone(names), callback, tag, {}, continueOnError, pri); _up();
277 - }
278 -
279 - // Request each enum in the batch, stopping if something does not return status 200
280 - function _BatchNextEnum(batchname, names, callback, tag, results, continueOnError, pri) {
281 - obj.PendingBatchOperations -= 2;
282 - var n = names.shift(), f = obj.Enum;
283 - if (n[0] == '*') { f = obj.Get; n = n.substring(1); } // If the name starts with a star, do a GET instead of an ENUM. This will reduce round trips.
284 - //console.log((f == obj.Get?'Get ':'Enum ') + n);
285 - // Perform a GET/ENUM action
286 - f(n, function (stack, name, responses, status, tag0) {
287 - tag0[2][name] = { response: (responses==null?null:responses.Body), responses: responses, status: status };
288 - if (tag0[1].length == 0 || status == 401 || (continueOnError != true && status != 200 && status != 400)) { obj.PendingBatchOperations -= (names.length * 2); _up(); callback(obj, batchname, tag0[2], status, tag); }
289 - else { _up(); _BatchNextEnum(batchname, names, callback, tag, tag0[2], pri); }
290 - }, [batchname, names, results], pri);
291 - _up();
292 - }
293 -
294 - // Perform a batch of WSMAN "GET" operations.
295 - obj.BatchGet = function (batchname, names, callback, tag, pri) {
296 - _FetchNext({ name: batchname, names: names, callback: callback, current: 0, responses: {}, tag: tag, pri: pri }); _up();
297 - }
298 -
299 - // Private method
300 - function _FetchNext(batch) {
301 - if (batch.names.length <= batch.current) {
302 - batch.callback(obj, batch.name, batch.responses, 200, batch.tag);
303 - } else {
304 - obj.wsman.ExecGet(obj.CompleteName(batch.names[batch.current]), function (ws, resuri, response, xstatus) { _Fetched(batch, response, xstatus); }, batch.pri);
305 - batch.current++;
306 - }
307 - _up();
308 - }
309 -
310 - // Private method
311 - function _Fetched(batch, response, status) {
312 - if (response == null || status != 200) {
313 - batch.callback(obj, batch.name, null, status, batch.tag);
314 - } else {
315 - batch.responses[response.Header["Method"]] = response;
316 - _FetchNext(batch);
317 - }
318 - }
319 -
320 - // Private method
321 - obj.CompleteName = function(name) {
322 - if (name.indexOf("AMT_") == 0) return obj.pfx[0] + name;
323 - if (name.indexOf("CIM_") == 0) return obj.pfx[1] + name;
324 - if (name.indexOf("IPS_") == 0) return obj.pfx[2] + name;
325 - }
326 -
327 - obj.CompleteExecResponse = function (resp) {
328 - if (resp && resp != null && resp.Body && resp.Body["ReturnValue"]) resp.Body.ReturnValueStr = obj.AmtStatusToStr(resp.Body["ReturnValue"]);
329 - return resp;
330 - }
331 -
332 - obj.RequestPowerStateChange = function (PowerState, callback_func) {
333 - obj.CIM_PowerManagementService_RequestPowerStateChange(PowerState, "<Address xmlns=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"><ResourceURI xmlns=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem</ResourceURI><SelectorSet xmlns=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\"><Selector Name=\"CreationClassName\">CIM_ComputerSystem</Selector><Selector Name=\"Name\">ManagedSystem</Selector></SelectorSet></ReferenceParameters>", null, null, callback_func);
334 - }
335 -
336 - obj.SetBootConfigRole = function (Role, callback_func) {
337 - obj.CIM_BootService_SetBootConfigRole("<Address xmlns=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"><ResourceURI xmlns=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootConfigSetting</ResourceURI><SelectorSet xmlns=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\"><Selector Name=\"InstanceID\">Intel(r) AMT: Boot Configuration 0</Selector></SelectorSet></ReferenceParameters>", Role, callback_func);
338 - }
339 -
340 - // Cancel all pending queries with given status
341 - obj.CancelAllQueries = function (s) {
342 - obj.wsman.CancelAllQueries(s);
343 - }
344 -
345 - // Auto generated methods
346 - obj.AMT_AgentPresenceWatchdog_RegisterAgent = function (callback_func) { obj.Exec("AMT_AgentPresenceWatchdog", "RegisterAgent", {}, callback_func); }
347 - obj.AMT_AgentPresenceWatchdog_AssertPresence = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdog", "AssertPresence", { "SequenceNumber": SequenceNumber }, callback_func); }
348 - obj.AMT_AgentPresenceWatchdog_AssertShutdown = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdog", "AssertShutdown", { "SequenceNumber": SequenceNumber }, callback_func); }
349 - obj.AMT_AgentPresenceWatchdog_AddAction = function (OldState, NewState, EventOnTransition, ActionSd, ActionEac, callback_func, tag, pri, selectors) { obj.Exec("AMT_AgentPresenceWatchdog", "AddAction", { "OldState": OldState, "NewState": NewState, "EventOnTransition": EventOnTransition, "ActionSd": ActionSd, "ActionEac": ActionEac }, callback_func, tag, pri, selectors); }
350 - obj.AMT_AgentPresenceWatchdog_DeleteAllActions = function (callback_func, tag, pri, selectors) { obj.Exec("AMT_AgentPresenceWatchdog", "DeleteAllActions", {}, callback_func, tag, pri, selectors); }
351 - obj.AMT_AgentPresenceWatchdogAction_GetActionEac = function (callback_func) { obj.Exec("AMT_AgentPresenceWatchdogAction", "GetActionEac", {}, callback_func); }
352 - obj.AMT_AgentPresenceWatchdogVA_RegisterAgent = function (callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "RegisterAgent", {}, callback_func); }
353 - obj.AMT_AgentPresenceWatchdogVA_AssertPresence = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "AssertPresence", { "SequenceNumber": SequenceNumber }, callback_func); }
354 - obj.AMT_AgentPresenceWatchdogVA_AssertShutdown = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "AssertShutdown", { "SequenceNumber": SequenceNumber }, callback_func); }
355 - obj.AMT_AgentPresenceWatchdogVA_AddAction = function (OldState, NewState, EventOnTransition, ActionSd, ActionEac, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "AddAction", { "OldState": OldState, "NewState": NewState, "EventOnTransition": EventOnTransition, "ActionSd": ActionSd, "ActionEac": ActionEac }, callback_func); }
356 - obj.AMT_AgentPresenceWatchdogVA_DeleteAllActions = function (_method_dummy, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "DeleteAllActions", { "_method_dummy": _method_dummy }, callback_func); }
357 - obj.AMT_AuditLog_ClearLog = function (callback_func) { obj.Exec("AMT_AuditLog", "ClearLog", {}, callback_func); }
358 - obj.AMT_AuditLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_AuditLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
359 - obj.AMT_AuditLog_ReadRecords = function (StartIndex, callback_func, tag) { obj.Exec("AMT_AuditLog", "ReadRecords", { "StartIndex": StartIndex }, callback_func, tag); }
360 - obj.AMT_AuditLog_SetAuditLock = function (LockTimeoutInSeconds, Flag, Handle, callback_func) { obj.Exec("AMT_AuditLog", "SetAuditLock", { "LockTimeoutInSeconds": LockTimeoutInSeconds, "Flag": Flag, "Handle": Handle }, callback_func); }
361 - obj.AMT_AuditLog_ExportAuditLogSignature = function (SigningMechanism, callback_func) { obj.Exec("AMT_AuditLog", "ExportAuditLogSignature", { "SigningMechanism": SigningMechanism }, callback_func); }
362 - obj.AMT_AuditLog_SetSigningKeyMaterial = function (SigningMechanismType, SigningKey, LengthOfCertificates, Certificates, callback_func) { obj.Exec("AMT_AuditLog", "SetSigningKeyMaterial", { "SigningMechanismType": SigningMechanismType, "SigningKey": SigningKey, "LengthOfCertificates": LengthOfCertificates, "Certificates": Certificates }, callback_func); }
363 - obj.AMT_AuditPolicyRule_SetAuditPolicy = function (Enable, AuditedAppID, EventID, PolicyType, callback_func) { obj.Exec("AMT_AuditPolicyRule", "SetAuditPolicy", { "Enable": Enable, "AuditedAppID": AuditedAppID, "EventID": EventID, "PolicyType": PolicyType }, callback_func); }
364 - obj.AMT_AuditPolicyRule_SetAuditPolicyBulk = function (Enable, AuditedAppID, EventID, PolicyType, callback_func) { obj.Exec("AMT_AuditPolicyRule", "SetAuditPolicyBulk", { "Enable": Enable, "AuditedAppID": AuditedAppID, "EventID": EventID, "PolicyType": PolicyType }, callback_func); }
365 - obj.AMT_AuthorizationService_AddUserAclEntryEx = function (DigestUsername, DigestPassword, KerberosUserSid, AccessPermission, Realms, callback_func) { obj.Exec("AMT_AuthorizationService", "AddUserAclEntryEx", { "DigestUsername": DigestUsername, "DigestPassword": DigestPassword, "KerberosUserSid": KerberosUserSid, "AccessPermission": AccessPermission, "Realms": Realms }, callback_func); }
366 - obj.AMT_AuthorizationService_EnumerateUserAclEntries = function (StartIndex, callback_func) { obj.Exec("AMT_AuthorizationService", "EnumerateUserAclEntries", { "StartIndex": StartIndex }, callback_func); }
367 - obj.AMT_AuthorizationService_GetUserAclEntryEx = function (Handle, callback_func, tag) { obj.Exec("AMT_AuthorizationService", "GetUserAclEntryEx", { "Handle": Handle }, callback_func, tag); }
368 - obj.AMT_AuthorizationService_UpdateUserAclEntryEx = function (Handle, DigestUsername, DigestPassword, KerberosUserSid, AccessPermission, Realms, callback_func) { obj.Exec("AMT_AuthorizationService", "UpdateUserAclEntryEx", { "Handle": Handle, "DigestUsername": DigestUsername, "DigestPassword": DigestPassword, "KerberosUserSid": KerberosUserSid, "AccessPermission": AccessPermission, "Realms": Realms }, callback_func); }
369 - obj.AMT_AuthorizationService_RemoveUserAclEntry = function (Handle, callback_func) { obj.Exec("AMT_AuthorizationService", "RemoveUserAclEntry", { "Handle": Handle }, callback_func); }
370 - obj.AMT_AuthorizationService_SetAdminAclEntryEx = function (Username, DigestPassword, callback_func) { obj.Exec("AMT_AuthorizationService", "SetAdminAclEntryEx", { "Username": Username, "DigestPassword": DigestPassword }, callback_func); }
371 - obj.AMT_AuthorizationService_GetAdminAclEntry = function (callback_func) { obj.Exec("AMT_AuthorizationService", "GetAdminAclEntry", {}, callback_func); }
372 - obj.AMT_AuthorizationService_GetAdminAclEntryStatus = function (callback_func) { obj.Exec("AMT_AuthorizationService", "GetAdminAclEntryStatus", {}, callback_func); }
373 - obj.AMT_AuthorizationService_GetAdminNetAclEntryStatus = function (callback_func) { obj.Exec("AMT_AuthorizationService", "GetAdminNetAclEntryStatus", {}, callback_func); }
374 - obj.AMT_AuthorizationService_SetAclEnabledState = function (Handle, Enabled, callback_func, tag) { obj.Exec("AMT_AuthorizationService", "SetAclEnabledState", { "Handle": Handle, "Enabled": Enabled }, callback_func, tag); }
375 - obj.AMT_AuthorizationService_GetAclEnabledState = function (Handle, callback_func, tag) { obj.Exec("AMT_AuthorizationService", "GetAclEnabledState", { "Handle": Handle }, callback_func, tag); }
376 - obj.AMT_EndpointAccessControlService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
377 - obj.AMT_EndpointAccessControlService_GetPosture = function (PostureType, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "GetPosture", { "PostureType": PostureType }, callback_func); }
378 - obj.AMT_EndpointAccessControlService_GetPostureHash = function (PostureType, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "GetPostureHash", { "PostureType": PostureType }, callback_func); }
379 - obj.AMT_EndpointAccessControlService_UpdatePostureState = function (UpdateType, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "UpdatePostureState", { "UpdateType": UpdateType }, callback_func); }
380 - obj.AMT_EndpointAccessControlService_GetEacOptions = function (callback_func) { obj.Exec("AMT_EndpointAccessControlService", "GetEacOptions", {}, callback_func); }
381 - obj.AMT_EndpointAccessControlService_SetEacOptions = function (EacVendors, PostureHashAlgorithm, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "SetEacOptions", { "EacVendors": EacVendors, "PostureHashAlgorithm": PostureHashAlgorithm }, callback_func); }
382 - obj.AMT_EnvironmentDetectionSettingData_SetSystemDefensePolicy = function (Policy, callback_func) { obj.Exec("AMT_EnvironmentDetectionSettingData", "SetSystemDefensePolicy", { "Policy": Policy }, callback_func); }
383 - obj.AMT_EnvironmentDetectionSettingData_EnableVpnRouting = function (Enable, callback_func) { obj.Exec("AMT_EnvironmentDetectionSettingData", "EnableVpnRouting", { "Enable": Enable }, callback_func); }
384 - obj.AMT_EthernetPortSettings_SetLinkPreference = function (LinkPreference, Timeout, callback_func) { obj.Exec("AMT_EthernetPortSettings", "SetLinkPreference", { "LinkPreference": LinkPreference, "Timeout": Timeout }, callback_func); }
385 - obj.AMT_HeuristicPacketFilterStatistics_ResetSelectedStats = function (SelectedStatistics, callback_func) { obj.Exec("AMT_HeuristicPacketFilterStatistics", "ResetSelectedStats", { "SelectedStatistics": SelectedStatistics }, callback_func); }
386 - obj.AMT_KerberosSettingData_GetCredentialCacheState = function (callback_func) { obj.Exec("AMT_KerberosSettingData", "GetCredentialCacheState", {}, callback_func); }
387 - obj.AMT_KerberosSettingData_SetCredentialCacheState = function (Enable, callback_func) { obj.Exec("AMT_KerberosSettingData", "SetCredentialCacheState", { "Enable": Enable }, callback_func); }
388 - obj.AMT_MessageLog_CancelIteration = function (IterationIdentifier, callback_func) { obj.Exec("AMT_MessageLog", "CancelIteration", { "IterationIdentifier": IterationIdentifier }, callback_func); }
389 - obj.AMT_MessageLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_MessageLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
390 - obj.AMT_MessageLog_ClearLog = function (callback_func) { obj.Exec("AMT_MessageLog", "ClearLog", { }, callback_func); }
391 - obj.AMT_MessageLog_GetRecords = function (IterationIdentifier, MaxReadRecords, callback_func, tag) { obj.Exec("AMT_MessageLog", "GetRecords", { "IterationIdentifier": IterationIdentifier, "MaxReadRecords": MaxReadRecords }, callback_func, tag); }
392 - obj.AMT_MessageLog_GetRecord = function (IterationIdentifier, PositionToNext, callback_func) { obj.Exec("AMT_MessageLog", "GetRecord", { "IterationIdentifier": IterationIdentifier, "PositionToNext": PositionToNext }, callback_func); }
393 - obj.AMT_MessageLog_PositionAtRecord = function (IterationIdentifier, MoveAbsolute, RecordNumber, callback_func) { obj.Exec("AMT_MessageLog", "PositionAtRecord", { "IterationIdentifier": IterationIdentifier, "MoveAbsolute": MoveAbsolute, "RecordNumber": RecordNumber }, callback_func); }
394 - obj.AMT_MessageLog_PositionToFirstRecord = function (callback_func, tag) { obj.Exec("AMT_MessageLog", "PositionToFirstRecord", {}, callback_func, tag); }
395 - obj.AMT_MessageLog_FreezeLog = function (Freeze, callback_func) { obj.Exec("AMT_MessageLog", "FreezeLog", { "Freeze": Freeze }, callback_func); }
396 - obj.AMT_PublicKeyManagementService_AddCRL = function (Url, SerialNumbers, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddCRL", { "Url": Url, "SerialNumbers": SerialNumbers }, callback_func); }
397 - obj.AMT_PublicKeyManagementService_ResetCRLList = function (_method_dummy, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "ResetCRLList", { "_method_dummy": _method_dummy }, callback_func); }
398 - obj.AMT_PublicKeyManagementService_AddCertificate = function (CertificateBlob, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddCertificate", { "CertificateBlob": CertificateBlob }, callback_func); }
399 - obj.AMT_PublicKeyManagementService_AddTrustedRootCertificate = function (CertificateBlob, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddTrustedRootCertificate", { "CertificateBlob": CertificateBlob }, callback_func); }
400 - obj.AMT_PublicKeyManagementService_AddKey = function (KeyBlob, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddKey", { "KeyBlob": KeyBlob }, callback_func); }
401 - obj.AMT_PublicKeyManagementService_GeneratePKCS10Request = function (KeyPair, DNName, Usage, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "GeneratePKCS10Request", { "KeyPair": KeyPair, "DNName": DNName, "Usage": Usage }, callback_func); }
402 - obj.AMT_PublicKeyManagementService_GeneratePKCS10RequestEx = function (KeyPair, SigningAlgorithm, NullSignedCertificateRequest, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "GeneratePKCS10RequestEx", { "KeyPair": KeyPair, "SigningAlgorithm": SigningAlgorithm, "NullSignedCertificateRequest": NullSignedCertificateRequest }, callback_func); }
403 - obj.AMT_PublicKeyManagementService_GenerateKeyPair = function (KeyAlgorithm, KeyLength, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "GenerateKeyPair", { "KeyAlgorithm": KeyAlgorithm, "KeyLength": KeyLength }, callback_func); }
404 - obj.AMT_RedirectionService_RequestStateChange = function (RequestedState, callback_func) { obj.Exec("AMT_RedirectionService", "RequestStateChange", { "RequestedState": RequestedState }, callback_func); }
405 - obj.AMT_RedirectionService_TerminateSession = function (SessionType, callback_func) { obj.Exec("AMT_RedirectionService", "TerminateSession", { "SessionType": SessionType }, callback_func); }
406 - obj.AMT_RemoteAccessService_AddMpServer = function (AccessInfo, InfoFormat, Port, AuthMethod, Certificate, Username, Password, CN, callback_func) { obj.Exec("AMT_RemoteAccessService", "AddMpServer", { "AccessInfo": AccessInfo, "InfoFormat": InfoFormat, "Port": Port, "AuthMethod": AuthMethod, "Certificate": Certificate, "Username": Username, "Password": Password, "CN": CN }, callback_func); }
407 - obj.AMT_RemoteAccessService_AddRemoteAccessPolicyRule = function (Trigger, TunnelLifeTime, ExtendedData, MpServer, callback_func) { obj.Exec("AMT_RemoteAccessService", "AddRemoteAccessPolicyRule", { "Trigger": Trigger, "TunnelLifeTime": TunnelLifeTime, "ExtendedData": ExtendedData, "MpServer": MpServer }, callback_func); }
408 - obj.AMT_RemoteAccessService_CloseRemoteAccessConnection = function (_method_dummy, callback_func) { obj.Exec("AMT_RemoteAccessService", "CloseRemoteAccessConnection", { "_method_dummy": _method_dummy }, callback_func); }
409 - obj.AMT_SetupAndConfigurationService_CommitChanges = function (_method_dummy, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "CommitChanges", { "_method_dummy": _method_dummy }, callback_func); }
410 - obj.AMT_SetupAndConfigurationService_Unprovision = function (ProvisioningMode, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "Unprovision", { "ProvisioningMode": ProvisioningMode }, callback_func); }
411 - obj.AMT_SetupAndConfigurationService_PartialUnprovision = function (_method_dummy, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "PartialUnprovision", { "_method_dummy": _method_dummy }, callback_func); }
412 - obj.AMT_SetupAndConfigurationService_ResetFlashWearOutProtection = function (_method_dummy, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "ResetFlashWearOutProtection", { "_method_dummy": _method_dummy }, callback_func); }
413 - obj.AMT_SetupAndConfigurationService_ExtendProvisioningPeriod = function (Duration, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "ExtendProvisioningPeriod", { "Duration": Duration }, callback_func); }
414 - obj.AMT_SetupAndConfigurationService_SetMEBxPassword = function (Password, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "SetMEBxPassword", { "Password": Password }, callback_func); }
415 - obj.AMT_SetupAndConfigurationService_SetTLSPSK = function (PID, PPS, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "SetTLSPSK", { "PID": PID, "PPS": PPS }, callback_func); }
416 - obj.AMT_SetupAndConfigurationService_GetProvisioningAuditRecord = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetProvisioningAuditRecord", {}, callback_func); }
417 - obj.AMT_SetupAndConfigurationService_GetUuid = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetUuid", {}, callback_func); }
418 - obj.AMT_SetupAndConfigurationService_GetUnprovisionBlockingComponents = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetUnprovisionBlockingComponents", {}, callback_func); }
419 - obj.AMT_SetupAndConfigurationService_GetProvisioningAuditRecordV2 = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetProvisioningAuditRecordV2", {}, callback_func); }
420 - obj.AMT_SystemDefensePolicy_GetTimeout = function (callback_func) { obj.Exec("AMT_SystemDefensePolicy", "GetTimeout", {}, callback_func); }
421 - obj.AMT_SystemDefensePolicy_SetTimeout = function (Timeout, callback_func) { obj.Exec("AMT_SystemDefensePolicy", "SetTimeout", { "Timeout": Timeout }, callback_func); }
422 - obj.AMT_SystemDefensePolicy_UpdateStatistics = function (NetworkInterface, ResetOnRead, callback_func, tag, pri, selectors) { obj.Exec("AMT_SystemDefensePolicy", "UpdateStatistics", { "NetworkInterface": NetworkInterface, "ResetOnRead": ResetOnRead }, callback_func, tag, pri, selectors); }
423 - obj.AMT_SystemPowerScheme_SetPowerScheme = function (callback_func, schemeInstanceId, tag) { obj.Exec("AMT_SystemPowerScheme", "SetPowerScheme", {}, callback_func, tag, 0, { "InstanceID": schemeInstanceId }); }
424 - obj.AMT_TimeSynchronizationService_GetLowAccuracyTimeSynch = function (callback_func, tag) { obj.Exec("AMT_TimeSynchronizationService", "GetLowAccuracyTimeSynch", {}, callback_func, tag); }
425 - obj.AMT_TimeSynchronizationService_SetHighAccuracyTimeSynch = function (Ta0, Tm1, Tm2, callback_func, tag) { obj.Exec("AMT_TimeSynchronizationService", "SetHighAccuracyTimeSynch", { "Ta0": Ta0, "Tm1": Tm1, "Tm2": Tm2 }, callback_func, tag); }
426 - obj.AMT_UserInitiatedConnectionService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_UserInitiatedConnectionService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
427 - obj.AMT_WebUIService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_WebUIService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
428 - obj.AMT_WiFiPortConfigurationService_AddWiFiSettings = function (WiFiEndpoint, WiFiEndpointSettingsInput, IEEE8021xSettingsInput, ClientCredential, CACredential, callback_func) { obj.ExecWithXml("AMT_WiFiPortConfigurationService", "AddWiFiSettings", { "WiFiEndpoint": WiFiEndpoint, "WiFiEndpointSettingsInput": WiFiEndpointSettingsInput, "IEEE8021xSettingsInput": IEEE8021xSettingsInput, "ClientCredential": ClientCredential, "CACredential": CACredential }, callback_func); }
429 - obj.AMT_WiFiPortConfigurationService_UpdateWiFiSettings = function (WiFiEndpointSettings, WiFiEndpointSettingsInput, IEEE8021xSettingsInput, ClientCredential, CACredential, callback_func) { obj.ExecWithXml("AMT_WiFiPortConfigurationService", "UpdateWiFiSettings", { "WiFiEndpointSettings": WiFiEndpointSettings, "WiFiEndpointSettingsInput": WiFiEndpointSettingsInput, "IEEE8021xSettingsInput": IEEE8021xSettingsInput, "ClientCredential": ClientCredential, "CACredential": CACredential }, callback_func); }
430 - obj.AMT_WiFiPortConfigurationService_DeleteAllITProfiles = function (_method_dummy, callback_func) { obj.Exec("AMT_WiFiPortConfigurationService", "DeleteAllITProfiles", { "_method_dummy": _method_dummy }, callback_func); }
431 - obj.AMT_WiFiPortConfigurationService_DeleteAllUserProfiles = function (_method_dummy, callback_func) { obj.Exec("AMT_WiFiPortConfigurationService", "DeleteAllUserProfiles", { "_method_dummy": _method_dummy }, callback_func); }
432 - obj.CIM_Account_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Account", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
433 - obj.CIM_AccountManagementService_CreateAccount = function (System, AccountTemplate, callback_func) { obj.Exec("CIM_AccountManagementService", "CreateAccount", { "System": System, "AccountTemplate": AccountTemplate }, callback_func); }
434 - obj.CIM_BootConfigSetting_ChangeBootOrder = function (Source, callback_func) { obj.Exec("CIM_BootConfigSetting", "ChangeBootOrder", { "Source": Source }, callback_func); }
435 - obj.CIM_BootService_SetBootConfigRole = function (BootConfigSetting, Role, callback_func) { obj.Exec("CIM_BootService", "SetBootConfigRole", { "BootConfigSetting": BootConfigSetting, "Role": Role }, callback_func, 0, 1); }
436 - obj.CIM_Card_ConnectorPower = function (Connector, PoweredOn, callback_func) { obj.Exec("CIM_Card", "ConnectorPower", { "Connector": Connector, "PoweredOn": PoweredOn }, callback_func); }
437 - obj.CIM_Card_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_Card", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
438 - obj.CIM_Chassis_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_Chassis", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
439 - obj.CIM_Fan_SetSpeed = function (DesiredSpeed, callback_func) { obj.Exec("CIM_Fan", "SetSpeed", { "DesiredSpeed": DesiredSpeed }, callback_func); }
440 - obj.CIM_KVMRedirectionSAP_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_KVMRedirectionSAP", "RequestStateChange", { "RequestedState": RequestedState/*, "TimeoutPeriod": TimeoutPeriod */}, callback_func); }
441 - obj.CIM_MediaAccessDevice_LockMedia = function (Lock, callback_func) { obj.Exec("CIM_MediaAccessDevice", "LockMedia", { "Lock": Lock }, callback_func); }
442 - obj.CIM_MediaAccessDevice_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_MediaAccessDevice", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
443 - obj.CIM_MediaAccessDevice_Reset = function (callback_func) { obj.Exec("CIM_MediaAccessDevice", "Reset", {}, callback_func); }
444 - obj.CIM_MediaAccessDevice_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_MediaAccessDevice", "EnableDevice", { "Enabled": Enabled }, callback_func); }
445 - obj.CIM_MediaAccessDevice_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_MediaAccessDevice", "OnlineDevice", { "Online": Online }, callback_func); }
446 - obj.CIM_MediaAccessDevice_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_MediaAccessDevice", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
447 - obj.CIM_MediaAccessDevice_SaveProperties = function (callback_func) { obj.Exec("CIM_MediaAccessDevice", "SaveProperties", {}, callback_func); }
448 - obj.CIM_MediaAccessDevice_RestoreProperties = function (callback_func) { obj.Exec("CIM_MediaAccessDevice", "RestoreProperties", {}, callback_func); }
449 - obj.CIM_MediaAccessDevice_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_MediaAccessDevice", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
450 - obj.CIM_PhysicalFrame_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_PhysicalFrame", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
451 - obj.CIM_PhysicalPackage_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_PhysicalPackage", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
452 - obj.CIM_PowerManagementService_RequestPowerStateChange = function (PowerState, ManagedElement, Time, TimeoutPeriod, callback_func) { obj.Exec("CIM_PowerManagementService", "RequestPowerStateChange", { "PowerState": PowerState, "ManagedElement": ManagedElement, "Time": Time, "TimeoutPeriod": TimeoutPeriod }, callback_func, 0, 1); }
453 - obj.CIM_PowerSupply_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_PowerSupply", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
454 - obj.CIM_PowerSupply_Reset = function (callback_func) { obj.Exec("CIM_PowerSupply", "Reset", {}, callback_func); }
455 - obj.CIM_PowerSupply_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_PowerSupply", "EnableDevice", { "Enabled": Enabled }, callback_func); }
456 - obj.CIM_PowerSupply_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_PowerSupply", "OnlineDevice", { "Online": Online }, callback_func); }
457 - obj.CIM_PowerSupply_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_PowerSupply", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
458 - obj.CIM_PowerSupply_SaveProperties = function (callback_func) { obj.Exec("CIM_PowerSupply", "SaveProperties", {}, callback_func); }
459 - obj.CIM_PowerSupply_RestoreProperties = function (callback_func) { obj.Exec("CIM_PowerSupply", "RestoreProperties", {}, callback_func); }
460 - obj.CIM_PowerSupply_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_PowerSupply", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
461 - obj.CIM_Processor_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_Processor", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
462 - obj.CIM_Processor_Reset = function (callback_func) { obj.Exec("CIM_Processor", "Reset", {}, callback_func); }
463 - obj.CIM_Processor_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_Processor", "EnableDevice", { "Enabled": Enabled }, callback_func); }
464 - obj.CIM_Processor_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_Processor", "OnlineDevice", { "Online": Online }, callback_func); }
465 - obj.CIM_Processor_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_Processor", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
466 - obj.CIM_Processor_SaveProperties = function (callback_func) { obj.Exec("CIM_Processor", "SaveProperties", {}, callback_func); }
467 - obj.CIM_Processor_RestoreProperties = function (callback_func) { obj.Exec("CIM_Processor", "RestoreProperties", {}, callback_func); }
468 - obj.CIM_Processor_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Processor", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
469 - obj.CIM_RecordLog_ClearLog = function (callback_func) { obj.Exec("CIM_RecordLog", "ClearLog", {}, callback_func); }
470 - obj.CIM_RecordLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_RecordLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
471 - obj.CIM_RedirectionService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_RedirectionService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
472 - obj.CIM_Sensor_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_Sensor", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
473 - obj.CIM_Sensor_Reset = function (callback_func) { obj.Exec("CIM_Sensor", "Reset", {}, callback_func); }
474 - obj.CIM_Sensor_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_Sensor", "EnableDevice", { "Enabled": Enabled }, callback_func); }
475 - obj.CIM_Sensor_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_Sensor", "OnlineDevice", { "Online": Online }, callback_func); }
476 - obj.CIM_Sensor_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_Sensor", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
477 - obj.CIM_Sensor_SaveProperties = function (callback_func) { obj.Exec("CIM_Sensor", "SaveProperties", {}, callback_func); }
478 - obj.CIM_Sensor_RestoreProperties = function (callback_func) { obj.Exec("CIM_Sensor", "RestoreProperties", {}, callback_func); }
479 - obj.CIM_Sensor_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Sensor", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
480 - obj.CIM_StatisticalData_ResetSelectedStats = function (SelectedStatistics, callback_func) { obj.Exec("CIM_StatisticalData", "ResetSelectedStats", { "SelectedStatistics": SelectedStatistics }, callback_func); }
481 - obj.CIM_Watchdog_KeepAlive = function (callback_func) { obj.Exec("CIM_Watchdog", "KeepAlive", {}, callback_func); }
482 - obj.CIM_Watchdog_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_Watchdog", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
483 - obj.CIM_Watchdog_Reset = function (callback_func) { obj.Exec("CIM_Watchdog", "Reset", {}, callback_func); }
484 - obj.CIM_Watchdog_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_Watchdog", "EnableDevice", { "Enabled": Enabled }, callback_func); }
485 - obj.CIM_Watchdog_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_Watchdog", "OnlineDevice", { "Online": Online }, callback_func); }
486 - obj.CIM_Watchdog_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_Watchdog", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
487 - obj.CIM_Watchdog_SaveProperties = function (callback_func) { obj.Exec("CIM_Watchdog", "SaveProperties", {}, callback_func); }
488 - obj.CIM_Watchdog_RestoreProperties = function (callback_func) { obj.Exec("CIM_Watchdog", "RestoreProperties", {}, callback_func); }
489 - obj.CIM_Watchdog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Watchdog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
490 - obj.CIM_WiFiPort_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_WiFiPort", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
491 - obj.CIM_WiFiPort_Reset = function (callback_func) { obj.Exec("CIM_WiFiPort", "Reset", {}, callback_func); }
492 - obj.CIM_WiFiPort_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_WiFiPort", "EnableDevice", { "Enabled": Enabled }, callback_func); }
493 - obj.CIM_WiFiPort_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_WiFiPort", "OnlineDevice", { "Online": Online }, callback_func); }
494 - obj.CIM_WiFiPort_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_WiFiPort", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
495 - obj.CIM_WiFiPort_SaveProperties = function (callback_func) { obj.Exec("CIM_WiFiPort", "SaveProperties", {}, callback_func); }
496 - obj.CIM_WiFiPort_RestoreProperties = function (callback_func) { obj.Exec("CIM_WiFiPort", "RestoreProperties", {}, callback_func); }
497 - obj.CIM_WiFiPort_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_WiFiPort", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
498 - obj.IPS_HostBasedSetupService_Setup = function (NetAdminPassEncryptionType, NetworkAdminPassword, McNonce, Certificate, SigningAlgorithm, DigitalSignature, callback_func) { obj.Exec("IPS_HostBasedSetupService", "Setup", { "NetAdminPassEncryptionType": NetAdminPassEncryptionType, "NetworkAdminPassword": NetworkAdminPassword, "McNonce": McNonce, "Certificate": Certificate, "SigningAlgorithm": SigningAlgorithm, "DigitalSignature": DigitalSignature }, callback_func); }
499 - obj.IPS_HostBasedSetupService_AddNextCertInChain = function (NextCertificate, IsLeafCertificate, IsRootCertificate, callback_func) { obj.Exec("IPS_HostBasedSetupService", "AddNextCertInChain", { "NextCertificate": NextCertificate, "IsLeafCertificate": IsLeafCertificate, "IsRootCertificate": IsRootCertificate }, callback_func); }
500 - obj.IPS_HostBasedSetupService_AdminSetup = function (NetAdminPassEncryptionType, NetworkAdminPassword, McNonce, SigningAlgorithm, DigitalSignature, callback_func) { obj.Exec("IPS_HostBasedSetupService", "AdminSetup", { "NetAdminPassEncryptionType": NetAdminPassEncryptionType, "NetworkAdminPassword": NetworkAdminPassword, "McNonce": McNonce, "SigningAlgorithm": SigningAlgorithm, "DigitalSignature": DigitalSignature }, callback_func); }
501 - obj.IPS_HostBasedSetupService_UpgradeClientToAdmin = function (McNonce, SigningAlgorithm, DigitalSignature, callback_func) { obj.Exec("IPS_HostBasedSetupService", "UpgradeClientToAdmin", { "McNonce": McNonce, "SigningAlgorithm": SigningAlgorithm, "DigitalSignature": DigitalSignature }, callback_func); }
502 - obj.IPS_HostBasedSetupService_DisableClientControlMode = function (_method_dummy, callback_func) { obj.Exec("IPS_HostBasedSetupService", "DisableClientControlMode", { "_method_dummy": _method_dummy }, callback_func); }
503 - obj.IPS_KVMRedirectionSettingData_TerminateSession = function (callback_func) { obj.Exec("IPS_KVMRedirectionSettingData", "TerminateSession", {}, callback_func); }
504 - obj.IPS_OptInService_StartOptIn = function (callback_func) { obj.Exec("IPS_OptInService", "StartOptIn", {}, callback_func); }
505 - obj.IPS_OptInService_CancelOptIn = function (callback_func) { obj.Exec("IPS_OptInService", "CancelOptIn", {}, callback_func); }
506 - obj.IPS_OptInService_SendOptInCode = function (OptInCode, callback_func) { obj.Exec("IPS_OptInService", "SendOptInCode", { "OptInCode": OptInCode }, callback_func); }
507 - obj.IPS_OptInService_StartService = function (callback_func) { obj.Exec("IPS_OptInService", "StartService", {}, callback_func); }
508 - obj.IPS_OptInService_StopService = function (callback_func) { obj.Exec("IPS_OptInService", "StopService", {}, callback_func); }
509 - obj.IPS_OptInService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("IPS_OptInService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
510 - obj.IPS_ProvisioningRecordLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("IPS_ProvisioningRecordLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
511 - obj.IPS_ProvisioningRecordLog_ClearLog = function (_method_dummy, callback_func) { obj.Exec("IPS_ProvisioningRecordLog", "ClearLog", { "_method_dummy": _method_dummy }, callback_func); }
512 - obj.IPS_SecIOService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("IPS_SecIOService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
513 -
514 - obj.AmtStatusToStr = function (code) { if (obj.AmtStatusCodes[code]) return obj.AmtStatusCodes[code]; else return "UNKNOWN_ERROR" }
515 - obj.AmtStatusCodes = {
516 - 0x0000: "SUCCESS",
517 - 0x0001: "INTERNAL_ERROR",
518 - 0x0002: "NOT_READY",
519 - 0x0003: "INVALID_PT_MODE",
520 - 0x0004: "INVALID_MESSAGE_LENGTH",
521 - 0x0005: "TABLE_FINGERPRINT_NOT_AVAILABLE",
522 - 0x0006: "INTEGRITY_CHECK_FAILED",
523 - 0x0007: "UNSUPPORTED_ISVS_VERSION",
524 - 0x0008: "APPLICATION_NOT_REGISTERED",
525 - 0x0009: "INVALID_REGISTRATION_DATA",
526 - 0x000A: "APPLICATION_DOES_NOT_EXIST",
527 - 0x000B: "NOT_ENOUGH_STORAGE",
528 - 0x000C: "INVALID_NAME",
529 - 0x000D: "BLOCK_DOES_NOT_EXIST",
530 - 0x000E: "INVALID_BYTE_OFFSET",
531 - 0x000F: "INVALID_BYTE_COUNT",
532 - 0x0010: "NOT_PERMITTED",
533 - 0x0011: "NOT_OWNER",
534 - 0x0012: "BLOCK_LOCKED_BY_OTHER",
535 - 0x0013: "BLOCK_NOT_LOCKED",
536 - 0x0014: "INVALID_GROUP_PERMISSIONS",
537 - 0x0015: "GROUP_DOES_NOT_EXIST",
538 - 0x0016: "INVALID_MEMBER_COUNT",
539 - 0x0017: "MAX_LIMIT_REACHED",
540 - 0x0018: "INVALID_AUTH_TYPE",
541 - 0x0019: "AUTHENTICATION_FAILED",
542 - 0x001A: "INVALID_DHCP_MODE",
543 - 0x001B: "INVALID_IP_ADDRESS",
544 - 0x001C: "INVALID_DOMAIN_NAME",
545 - 0x001D: "UNSUPPORTED_VERSION",
546 - 0x001E: "REQUEST_UNEXPECTED",
547 - 0x001F: "INVALID_TABLE_TYPE",
548 - 0x0020: "INVALID_PROVISIONING_STATE",
549 - 0x0021: "UNSUPPORTED_OBJECT",
550 - 0x0022: "INVALID_TIME",
551 - 0x0023: "INVALID_INDEX",
552 - 0x0024: "INVALID_PARAMETER",
553 - 0x0025: "INVALID_NETMASK",
554 - 0x0026: "FLASH_WRITE_LIMIT_EXCEEDED",
555 - 0x0027: "INVALID_IMAGE_LENGTH",
556 - 0x0028: "INVALID_IMAGE_SIGNATURE",
557 - 0x0029: "PROPOSE_ANOTHER_VERSION",
558 - 0x002A: "INVALID_PID_FORMAT",
559 - 0x002B: "INVALID_PPS_FORMAT",
560 - 0x002C: "BIST_COMMAND_BLOCKED",
561 - 0x002D: "CONNECTION_FAILED",
562 - 0x002E: "CONNECTION_TOO_MANY",
563 - 0x002F: "RNG_GENERATION_IN_PROGRESS",
564 - 0x0030: "RNG_NOT_READY",
565 - 0x0031: "CERTIFICATE_NOT_READY",
566 - 0x0400: "DISABLED_BY_POLICY",
567 - 0x0800: "NETWORK_IF_ERROR_BASE",
568 - 0x0801: "UNSUPPORTED_OEM_NUMBER",
569 - 0x0802: "UNSUPPORTED_BOOT_OPTION",
570 - 0x0803: "INVALID_COMMAND",
571 - 0x0804: "INVALID_SPECIAL_COMMAND",
572 - 0x0805: "INVALID_HANDLE",
573 - 0x0806: "INVALID_PASSWORD",
574 - 0x0807: "INVALID_REALM",
575 - 0x0808: "STORAGE_ACL_ENTRY_IN_USE",
576 - 0x0809: "DATA_MISSING",
577 - 0x080A: "DUPLICATE",
578 - 0x080B: "EVENTLOG_FROZEN",
579 - 0x080C: "PKI_MISSING_KEYS",
580 - 0x080D: "PKI_GENERATING_KEYS",
581 - 0x080E: "INVALID_KEY",
582 - 0x080F: "INVALID_CERT",
583 - 0x0810: "CERT_KEY_NOT_MATCH",
584 - 0x0811: "MAX_KERB_DOMAIN_REACHED",
585 - 0x0812: "UNSUPPORTED",
586 - 0x0813: "INVALID_PRIORITY",
587 - 0x0814: "NOT_FOUND",
588 - 0x0815: "INVALID_CREDENTIALS",
589 - 0x0816: "INVALID_PASSPHRASE",
590 - 0x0818: "NO_ASSOCIATION",
591 - 0x081B: "AUDIT_FAIL",
592 - 0x081C: "BLOCKING_COMPONENT",
593 - 0x0821: "USER_CONSENT_REQUIRED",
594 - 0x1000: "APP_INTERNAL_ERROR",
595 - 0x1001: "NOT_INITIALIZED",
596 - 0x1002: "LIB_VERSION_UNSUPPORTED",
597 - 0x1003: "INVALID_PARAM",
598 - 0x1004: "RESOURCES",
599 - 0x1005: "HARDWARE_ACCESS_ERROR",
600 - 0x1006: "REQUESTOR_NOT_REGISTERED",
601 - 0x1007: "NETWORK_ERROR",
602 - 0x1008: "PARAM_BUFFER_TOO_SHORT",
603 - 0x1009: "COM_NOT_INITIALIZED_IN_THREAD",
604 - 0x100A: "URL_REQUIRED"
605 - }
606 -
607 - //
608 - // Methods used for getting the event log
609 - //
610 -
611 - obj.GetMessageLog = function (func, tag) {
612 - obj.AMT_MessageLog_PositionToFirstRecord(_GetMessageLog0, [func, tag, []]);
613 - }
614 - function _GetMessageLog0(stack, name, responses, status, tag) {
615 - if (status != 200 || responses.Body["ReturnValue"] != '0') { tag[0](obj, null, tag[2]); return; }
616 - obj.AMT_MessageLog_GetRecords(responses.Body["IterationIdentifier"], 390, _GetMessageLog1, tag);
617 - }
618 - function _GetMessageLog1(stack, name, responses, status, tag) {
619 - if (status != 200 || responses.Body["ReturnValue"] != '0') { tag[0](obj, null, tag[2]); return; }
620 - var i, j, x, e, AmtMessages = tag[2], t = new Date(), TimeStamp, ra = responses.Body["RecordArray"];
621 - if (typeof ra === 'string') { responses.Body["RecordArray"] = [responses.Body["RecordArray"]]; }
622 -
623 - for (i in ra) {
624 - e = null;
625 - try { e = window.atob(ra[i]); } catch (ex) { }
626 - if (e != null) {
627 - TimeStamp = ReadIntX(e, 0);
628 - if ((TimeStamp > 0) && (TimeStamp < 0xFFFFFFFF)) {
629 - x = { 'DeviceAddress': e.charCodeAt(4), 'EventSensorType': e.charCodeAt(5), 'EventType': e.charCodeAt(6), 'EventOffset': e.charCodeAt(7), 'EventSourceType': e.charCodeAt(8), 'EventSeverity': e.charCodeAt(9), 'SensorNumber': e.charCodeAt(10), 'Entity': e.charCodeAt(11), 'EntityInstance': e.charCodeAt(12), 'EventData': [], 'Time': new Date((TimeStamp + (t.getTimezoneOffset() * 60)) * 1000) };
630 - for (j = 13; j < 21; j++) { x['EventData'].push(e.charCodeAt(j)); }
631 - x['EntityStr'] = _SystemEntityTypes[x['Entity']];
632 - x['Desc'] = _GetEventDetailStr(x['EventSensorType'], x['EventOffset'], x['EventData'], x['Entity']);
633 - if (!x['EntityStr']) x['EntityStr'] = "Unknown";
634 - AmtMessages.push(x);
635 - }
636 - }
637 - }
638 -
639 - if (responses.Body["NoMoreRecords"] != true) { obj.AMT_MessageLog_GetRecords(responses.Body["IterationIdentifier"], 390, _GetMessageLog1, [tag[0], AmtMessages, tag[2]]); } else { tag[0](obj, AmtMessages, tag[2]); }
640 - }
641 -
642 - var _EventTrapSourceTypes = "Platform firmware (e.g. BIOS)|SMI handler|ISV system management software|Alert ASIC|IPMI|BIOS vendor|System board set vendor|System integrator|Third party add-in|OSV|NIC|System management card".split('|');
643 - var _SystemFirmwareError = "Unspecified.|No system memory is physically installed in the system.|No usable system memory, all installed memory has experienced an unrecoverable failure.|Unrecoverable hard-disk/ATAPI/IDE device failure.|Unrecoverable system-board failure.|Unrecoverable diskette subsystem failure.|Unrecoverable hard-disk controller failure.|Unrecoverable PS/2 or USB keyboard failure.|Removable boot media not found.|Unrecoverable video controller failure.|No video device detected.|Firmware (BIOS) ROM corruption detected.|CPU voltage mismatch (processors that share same supply have mismatched voltage requirements)|CPU speed matching failure".split('|');
644 - var _SystemFirmwareProgress = "Unspecified.|Memory initialization.|Starting hard-disk initialization and test|Secondary processor(s) initialization|User authentication|User-initiated system setup|USB resource configuration|PCI resource configuration|Option ROM initialization|Video initialization|Cache initialization|SM Bus initialization|Keyboard controller initialization|Embedded controller/management controller initialization|Docking station attachment|Enabling docking station|Docking station ejection|Disabling docking station|Calling operating system wake-up vector|Starting operating system boot process|Baseboard or motherboard initialization|reserved|Floppy initialization|Keyboard test|Pointing device test|Primary processor initialization".split('|');
645 - var _SystemEntityTypes = "Unspecified|Other|Unknown|Processor|Disk|Peripheral|System management module|System board|Memory module|Processor module|Power supply|Add in card|Front panel board|Back panel board|Power system board|Drive backplane|System internal expansion board|Other system board|Processor board|Power unit|Power module|Power management board|Chassis back panel board|System chassis|Sub chassis|Other chassis board|Disk drive bay|Peripheral bay|Device bay|Fan cooling|Cooling unit|Cable interconnect|Memory device|System management software|BIOS|Intel(r) ME|System bus|Group|Intel(r) ME|External environment|Battery|Processing blade|Connectivity switch|Processor/memory module|I/O module|Processor I/O module|Management controller firmware|IPMI channel|PCI bus|PCI express bus|SCSI bus|SATA/SAS bus|Processor front side bus".split('|');
646 - obj.RealmNames = "||Redirection|PT Administration|Hardware Asset|Remote Control|Storage|Event Manager|Storage Admin|Agent Presence Local|Agent Presence Remote|Circuit Breaker|Network Time|General Information|Firmware Update|EIT|LocalUN|Endpoint Access Control|Endpoint Access Control Admin|Event Log Reader|Audit Log|ACL Realm|||Local System".split('|');
647 - obj.WatchdogCurrentStates = { 1: 'Not Started', 2: 'Stopped', 4: 'Running', 8: 'Expired', 16: 'Suspended' };
648 -
649 - function _GetEventDetailStr(eventSensorType, eventOffset, eventDataField, entity) {
650 -
651 - if (eventSensorType == 15)
652 - {
653 - if (eventDataField[0] == 235) return "Invalid Data";
654 - if (eventOffset == 0) return _SystemFirmwareError[eventDataField[1]];
655 - return _SystemFirmwareProgress[eventDataField[1]];
656 - }
657 -
658 - if (eventSensorType == 18 && eventDataField[0] == 170) // System watchdog event
659 - {
660 - return "Agent watchdog " + char2hex(eventDataField[4]) + char2hex(eventDataField[3]) + char2hex(eventDataField[2]) + char2hex(eventDataField[1]) + "-" + char2hex(eventDataField[6]) + char2hex(eventDataField[5]) + "-... changed to " + obj.WatchdogCurrentStates[eventDataField[7]];
661 - }
662 -
663 - /*
664 - if (eventSensorType == 5 && eventOffset == 0) // System chassis
665 - {
666 - return "Case intrusion";
667 - }
668 -
669 - if (eventSensorType == 192 && eventOffset == 0 && eventDataField[0] == 170 && eventDataField[1] == 48)
670 - {
671 - if (eventDataField[2] == 0) return "A remote Serial Over LAN session was established.";
672 - if (eventDataField[2] == 1) return "Remote Serial Over LAN session finished. User control was restored.";
673 - if (eventDataField[2] == 2) return "A remote IDE-Redirection session was established.";
674 - if (eventDataField[2] == 3) return "Remote IDE-Redirection session finished. User control was restored.";
675 - }
676 -
677 - if (eventSensorType == 36)
678 - {
679 - long handle = ((long)(eventDataField[1]) << 24) + ((long)(eventDataField[2]) << 16) + ((long)(eventDataField[3]) << 8) + (long)(eventDataField[4]);
680 - string nic = string.Format("#{0}", eventDataField[0]);
681 - if (eventDataField[0] == 0xAA) nic = "wired"; // TODO: Add wireless *****
682 - //if (eventDataField[0] == 0xAA) nic = "wireless";
683 -
684 - if (handle == 4294967293) { return string.Format("All received packet filter was matched on {0} interface.", nic); }
685 - if (handle == 4294967292) { return string.Format("All outbound packet filter was matched on {0} interface.", nic); }
686 - if (handle == 4294967290) { return string.Format("Spoofed packet filter was matched on {0} interface.", nic); }
687 - return string.Format("Filter {0} was matched on {1} interface.", handle, nic);
688 - }
689 -
690 - if (eventSensorType == 192)
691 - {
692 - if (eventDataField[2] == 0) return "Security policy invoked. Some or all network traffic (TX) was stopped.";
693 - if (eventDataField[2] == 2) return "Security policy invoked. Some or all network traffic (RX) was stopped.";
694 - return "Security policy invoked.";
695 - }
696 -
697 - if (eventSensorType == 193)
698 - {
699 - if (eventDataField[0] == 0xAA && eventDataField[1] == 0x30 && eventDataField[2] == 0x00 && eventDataField[3] == 0x00) { return "User request for remote connection."; }
700 - if (eventDataField[0] == 0xAA && eventDataField[1] == 0x20 && eventDataField[2] == 0x03 && eventDataField[3] == 0x01) { return "EAC error: attempt to get posture while NAC in Intel� AMT is disabled."; // eventDataField = 0xAA20030100000000 }
701 - if (eventDataField[0] == 0xAA && eventDataField[1] == 0x20 && eventDataField[2] == 0x04 && eventDataField[3] == 0x00) { return "Certificate revoked. "; }
702 - }
703 - */
704 -
705 - if (eventSensorType == 6) return "Authentication failed " + (eventDataField[1] + (eventDataField[2] << 8)) + " times. The system may be under attack.";
706 - if (eventSensorType == 30) return "No bootable media";
707 - if (eventSensorType == 32) return "Operating system lockup or power interrupt";
708 - if (eventSensorType == 35) return "System boot failure";
709 - if (eventSensorType == 37) return "System firmware started (at least one CPU is properly executing).";
710 - return "Unknown Sensor Type #" + eventSensorType;
711 - }
712 -
713 -
714 - return obj;
715 -}
716 -
717 -
718 -
719 -
720 -
721 -// TinyMD5 from https://github.com/jbt/js-crypto
722 -
723 -// Perform MD5 setup
724 -var md5_k = [];
725 -for (var i = 0; i < 64;) { md5_k[i] = 0 | (Math.abs(Math.sin(++i)) * 4294967296); }
726 -
727 -// Perform MD5 on raw string and return hex
728 -function hex_md5(str) {
729 - var b, c, d, j,
730 - x = [],
731 - str2 = unescape(encodeURI(str)),
732 - a = str2.length,
733 - h = [b = 1732584193, c = -271733879, ~b, ~c],
734 - i = 0;
735 -
736 - for (; i <= a;) x[i >> 2] |= (str2.charCodeAt(i) || 128) << 8 * (i++ % 4);
737 -
738 - x[str = (a + 8 >> 6) * 16 + 14] = a * 8;
739 - i = 0;
740 -
741 - for (; i < str; i += 16) {
742 - a = h; j = 0;
743 - for (; j < 64;) {
744 - a = [
745 - d = a[3],
746 - ((b = a[1] | 0) +
747 - ((d = (
748 - (a[0] +
749 - [
750 - b & (c = a[2]) | ~b & d,
751 - d & b | ~d & c,
752 - b ^ c ^ d,
753 - c ^ (b | ~d)
754 - ][a = j >> 4]
755 - ) +
756 - (md5_k[j] +
757 - (x[[
758 - j,
759 - 5 * j + 1,
760 - 3 * j + 5,
761 - 7 * j
762 - ][a] % 16 + i] | 0)
763 - )
764 - )) << (a = [
765 - 7, 12, 17, 22,
766 - 5, 9, 14, 20,
767 - 4, 11, 16, 23,
768 - 6, 10, 15, 21
769 - ][4 * a + j++ % 4]) | d >>> 32 - a)
770 - ),
771 - b,
772 - c
773 - ];
774 - }
775 - for (j = 4; j;) h[--j] = h[j] + a[j];
776 - }
777 -
778 - str = '';
779 - for (; j < 32;) str += ((h[j >> 3] >> ((1 ^ j++ & 7) * 4)) & 15).toString(16);
780 - return str;
781 -}
782 -
783 -
784 -// Perform MD5 on raw string and return raw string result
785 -function rstr_md5(str) { return hex2rstr(hex_md5(str)); }
786 -
787 -/*
788 -Convert arguments into selector set and body XML. Used by AMT_WiFiPortConfigurationService_UpdateWiFiSettings.
789 -args = {
790 - "WiFiEndpoint": {
791 - __parameterType: 'reference',
792 - __resourceUri: 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpoint',
793 - Name: 'WiFi Endpoint 0'
794 - },
795 - "WiFiEndpointSettingsInput":
796 - {
797 - __parameterType: 'instance',
798 - __namespace: 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings',
799 - ElementName: document.querySelector('#editProfile-profileName').value,
800 - InstanceID: 'Intel(r) AMT:WiFi Endpoint Settings ' + document.querySelector('#editProfile-profileName').value,
801 - AuthenticationMethod: document.querySelector('#editProfile-networkAuthentication').value,
802 - //BSSType: 3, // Intel(r) AMT supports only infrastructure networks
803 - EncryptionMethod: document.querySelector('#editProfile-encryption').value,
804 - SSID: document.querySelector('#editProfile-networkName').value,
805 - Priority: 100,
806 - PSKPassPhrase: document.querySelector('#editProfile-passPhrase').value
807 - },
808 - "IEEE8021xSettingsInput": null,
809 - "ClientCredential": null,
810 - "CACredential": null
811 -},
812 -*/
813 -function execArgumentsToXml(args) {
814 - if(args === undefined || args === null) return null;
815 -
816 - var result = '';
817 - for(var argName in args) {
818 - var arg = args[argName];
819 - if(!arg) continue;
820 - if(arg['__parameterType'] === 'reference') result += referenceToXml(argName, arg);
821 - else result += instanceToXml(argName, arg);
822 - //if(arg['__isInstance']) result += instanceToXml(argName, arg);
823 - }
824 - return result;
825 -}
826 -
827 -/**
828 - * Convert JavaScript object into XML
829 -
830 - <r:WiFiEndpointSettingsInput xmlns:q="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings">
831 - <q:ElementName>Wireless-Profile-Admin</q:ElementName>
832 - <q:InstanceID>Intel(r) AMT:WiFi Endpoint Settings Wireless-Profile-Admin</q:InstanceID>
833 - <q:AuthenticationMethod>6</q:AuthenticationMethod>
834 - <q:EncryptionMethod>4</q:EncryptionMethod>
835 - <q:Priority>100</q:Priority>
836 - <q:PSKPassPhrase>P@ssw0rd</q:PSKPassPhrase>
837 - </r:WiFiEndpointSettingsInput>
838 - */
839 -function instanceToXml(instanceName, inInstance) {
840 - if(inInstance === undefined || inInstance === null) return null;
841 -
842 - var hasNamespace = !!inInstance['__namespace'];
843 - var startTag = hasNamespace ? '<q:' : '<';
844 - var endTag = hasNamespace ? '</q:' : '</';
845 - var namespaceDef = hasNamespace ? (' xmlns:q="' + inInstance['__namespace'] + '"' ): '';
846 - var result = '<r:' + instanceName + namespaceDef + '>';
847 - for(var prop in inInstance) {
848 - if (!inInstance.hasOwnProperty(prop) || prop.indexOf('__') === 0) continue;
849 -
850 - if (typeof inInstance[prop] === 'function' || Array.isArray(inInstance[prop]) ) continue;
851 -
852 - if (typeof inInstance[prop] === 'object') {
853 - //result += startTag + prop +'>' + instanceToXml('prop', inInstance[prop]) + endTag + prop +'>';
854 - console.error('only convert one level down...');
855 - }
856 - else {
857 - result += startTag + prop +'>' + inInstance[prop].toString() + endTag + prop +'>';
858 - }
859 - }
860 - result += '</r:' + instanceName + '>';
861 - return result;
862 -}
863 -
864 -
865 -/**
866 - * Convert a selector set into XML. Expect no nesting.
867 - * {
868 - * selectorName : selectorValue,
869 - * selectorName : selectorValue,
870 - * ... ...
871 - * }
872 -
873 - <r:WiFiEndpoint>
874 - <a:Address>http://192.168.1.103:16992/wsman</a:Address>
875 - <a:ReferenceParameters>
876 - <w:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpoint</w:ResourceURI>
877 - <w:SelectorSet>
878 - <w:Selector Name="Name">WiFi Endpoint 0</w:Selector>
879 - </w:SelectorSet>
880 - </a:ReferenceParameters>
881 - </r:WiFiEndpoint>
882 -
883 - */
884 -function referenceToXml(referenceName, inReference) {
885 - if(inReference === undefined || inReference === null ) return null;
886 -
887 - var result = '<r:' + referenceName + '><a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>'+ inReference['__resourceUri']+'</w:ResourceURI><w:SelectorSet>';
888 - for(var selectorName in inReference) {
889 - if (!inReference.hasOwnProperty(selectorName) || selectorName.indexOf('__') === 0) continue;
890 -
891 - if (typeof inReference[selectorName] === 'function' ||
892 - typeof inReference[selectorName] === 'object' ||
893 - Array.isArray(inReference[selectorName]) )
894 - continue;
895 -
896 - result += '<w:Selector Name="' + selectorName +'">' + inReference[selectorName].toString() + '</w:Selector>';
897 - }
898 -
899 - result += '</w:SelectorSet></a:ReferenceParameters></r:' + referenceName + '>';
900 - return result;
901 -}
902 -
903 -// Convert a byte array of SID into string
904 -function GetSidString(sid) {
905 - var r = "S-" + sid.charCodeAt(0) + "-" + sid.charCodeAt(7);
906 - for (var i = 2; i < (sid.length / 4) ; i++) r += "-" + ReadIntX(sid, i * 4);
907 - return r;
908 -}
909 -
910 -// Convert a SID readable string into bytes
911 -function GetSidByteArray(sidString) {
912 - if (!sidString || sidString == null) return null;
913 - var sidParts = sidString.split('-');
914 -
915 - // Make sure the SID has at least 4 parts and starts with 'S'
916 - if (sidParts.length < 4 || (sidParts[0] != 's' && sidParts[0] != 'S')) return null;
917 -
918 - // Check that each part of the SID is really an integer
919 - for (var i = 1; i < sidParts.length; i++) { var y = parseInt(sidParts[i]); if (y != sidParts[i]) return null; sidParts[i] = y; }
920 -
921 - // Version (8 bit) + Id count (8 bit) + 48 bit in big endian -- DO NOT use bitwise right shift operator. JavaScript converts the number into a 32 bit integer before shifting. In real world, it's highly likely this part is always 0.
922 - var r = String.fromCharCode(sidParts[1]) + String.fromCharCode(sidParts.length - 3) + ShortToStr(Math.floor(sidParts[2] / Math.pow(2, 32))) + IntToStr((sidParts[2]) & 0xFFFF);
923 -
924 - // the rest are in 32 bit in little endian
925 - for (var i = 3; i < sidParts.length; i++) r += IntToStrX(sidParts[i]);
926 - return r;
927 -}
928 -/**
929 -* @description Intel(r) AMT WSMAN Stack
930 -* @author Ylian Saint-Hilaire
931 -* @version v0.2.0
932 -*/
933 -
934 -// Construct a MeshServer object
935 -var WsmanStackCreateService = function (host, port, user, pass, tls, extra) {
936 - var obj = {};
937 - //obj.onDebugMessage = null; // Set to a function if you want to get debug messages.
938 - obj.NextMessageId = 1; // Next message number, used to label WSMAN calls.
939 - obj.Address = '/wsman';
940 - obj.comm = CreateWsmanComm(host, port, user, pass, tls, extra);
941 -
942 - obj.PerformAjax = function (postdata, callback, tag, pri, namespaces) {
943 - if (namespaces == undefined) namespaces = '';
944 - obj.comm.PerformAjax('<?xml version=\"1.0\" encoding=\"utf-8\"?><Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns=\"http://www.w3.org/2003/05/soap-envelope\" ' + namespaces + '><Header><a:Action>' + postdata, function (data, status, tag) {
945 - if (status != 200) { callback(obj, null, { Header: { HttpError: status } }, status, tag); return; }
946 - var wsresponse = obj.ParseWsman(data);
947 - if (!wsresponse || wsresponse == null) { callback(obj, null, { Header: { HttpError: status } }, 601, tag); } else { callback(obj, wsresponse.Header["ResourceURI"], wsresponse, 200, tag); }
948 - }, tag, pri);
949 - }
950 -
951 - // Private method
952 - //obj.Debug = function (msg) { /*console.log(msg);*/ }
953 -
954 - // Cancel all pending queries with given status
955 - obj.CancelAllQueries = function (s) { obj.comm.CancelAllQueries(s); }
956 -
957 - // Get the last element of a URI string
958 - obj.GetNameFromUrl = function (resuri) {
959 - var x = resuri.lastIndexOf("/");
960 - return (x == -1)?resuri:resuri.substring(x + 1);
961 - }
962 -
963 - // Perform a WSMAN Subscribe operation
964 - obj.ExecSubscribe = function (resuri, delivery, url, callback, tag, pri, selectors, opaque, user, pass) {
965 - var digest = "", digest2 = "";
966 - if (user != undefined && pass != undefined) { digest = '<t:IssuedTokens><t:RequestSecurityTokenResponse><t:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken</t:TokenType><t:RequestedSecurityToken><se:UsernameToken><se:Username>' + user + '</se:Username><se:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#PasswordText">' + pass + '</se:Password></se:UsernameToken></t:RequestedSecurityToken></t:RequestSecurityTokenResponse></t:IssuedTokens>'; digest2 = '<Auth Profile="http://schemas.xmlsoap.org/ws/2004/08/eventing/DeliveryModes/secprofile/http/digest"/>'; }
967 - if (opaque != undefined && opaque != null) { opaque = '<a:ReferenceParameters>' + opaque + '</a:ReferenceParameters>'; } else { opaque = ""; }
968 - var data = "http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>" + _PutObjToSelectorsXml(selectors) + digest + '</Header><Body><e:Subscribe><e:Delivery Mode="http://schemas.dmtf.org/wbem/wsman/1/wsman/' + delivery + '"><e:NotifyTo><a:Address>' + url + '</a:Address></e:NotifyTo>' + digest2 + '</e:Delivery><e:Expires>PT0.000000S</e:Expires></e:Subscribe>';
969 - obj.PerformAjax(data + "</Body></Envelope>", callback, tag, pri, 'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:se="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:m="http://x.com"');
970 - }
971 -
972 - // Perform a WSMAN UnSubscribe operation
973 - obj.ExecUnSubscribe = function (resuri, callback, tag, pri, selectors) {
974 - var data = "http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>" + _PutObjToSelectorsXml(selectors) + '</Header><Body><e:Unsubscribe/>';
975 - obj.PerformAjax(data + "</Body></Envelope>", callback, tag, pri, 'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"');
976 - }
977 -
978 - // Perform a WSMAN PUT operation
979 - obj.ExecPut = function (resuri, putobj, callback, tag, pri, selectors) {
980 - var data = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Put</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60.000S</w:OperationTimeout>" + _PutObjToSelectorsXml(selectors) + '</Header><Body>' + _PutObjToBodyXml(resuri, putobj);
981 - obj.PerformAjax(data + "</Body></Envelope>", callback, tag, pri);
982 - }
983 -
984 - // Perform a WSMAN CREATE operation
985 - obj.ExecCreate = function (resuri, putobj, callback, tag, pri, selectors) {
986 - var objname = obj.GetNameFromUrl(resuri);
987 - var data = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Create</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>" + _PutObjToSelectorsXml(selectors) + "</Header><Body><g:" + objname + " xmlns:g=\"" + resuri + "\">";
988 - for (var n in putobj) { data += "<g:" + n + ">" + putobj[n] + "</g:" + n + ">" }
989 - obj.PerformAjax(data + "</g:" + objname + "></Body></Envelope>", callback, tag, pri);
990 - }
991 -
992 - // Perform a WSMAN CREATE operation
993 - obj.ExecCreateXml = function (resuri, argsxml, callback, tag, pri) {
994 - var objname = obj.GetNameFromUrl(resuri), selector = "";
995 - obj.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Create</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60.000S</w:OperationTimeout></Header><Body><r:" + objname + " xmlns:r=\"" + resuri + "\">" + argsxml + "</r:" + objname + "></Body></Envelope>", callback, tag, pri);
996 - }
997 -
998 - // Perform a WSMAN DELETE operation
999 - obj.ExecDelete = function (resuri, putobj, callback, tag, pri) {
1000 - var data = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>" + _PutObjToSelectorsXml(putobj) + "</Header><Body /></Envelope>";
1001 - obj.PerformAjax(data, callback, tag, pri);
1002 - }
1003 -
1004 - // Perform a WSMAN GET operation
1005 - obj.ExecGet = function (resuri, callback, tag, pri) {
1006 - obj.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body /></Envelope>", callback, tag, pri);
1007 - }
1008 -
1009 - // Perform a WSMAN method call operation
1010 - obj.ExecMethod = function (resuri, method, args, callback, tag, pri, selectors) {
1011 - var argsxml = "";
1012 - for (var i in args) { if (args[i] != null) { if (Array.isArray(args[i])) { for (var x in args[i]) { argsxml += "<r:" + i + ">" + args[i][x] + "</r:" + i + ">"; } } else { argsxml += "<r:" + i + ">" + args[i] + "</r:" + i + ">"; } } }
1013 - obj.ExecMethodXml(resuri, method, argsxml, callback, tag, pri, selectors);
1014 - }
1015 -
1016 - // Perform a WSMAN method call operation. The arguments are already formatted in XML.
1017 - obj.ExecMethodXml = function (resuri, method, argsxml, callback, tag, pri, selectors) {
1018 - obj.PerformAjax(resuri + "/" + method + "</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>" + _PutObjToSelectorsXml(selectors) + "</Header><Body><r:" + method + '_INPUT' + " xmlns:r=\"" + resuri + "\">" + argsxml + "</r:" + method + "_INPUT></Body></Envelope>", callback, tag, pri);
1019 - }
1020 -
1021 - // Perform a WSMAN ENUM operation
1022 - obj.ExecEnum = function (resuri, callback, tag, pri) {
1023 - obj.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Enumerate xmlns=\"http://schemas.xmlsoap.org/ws/2004/09/enumeration\" /></Body></Envelope>", callback, tag, pri);
1024 - }
1025 -
1026 - // Perform a WSMAN PULL operation
1027 - obj.ExecPull = function (resuri, enumctx, callback, tag, pri) {
1028 - obj.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Pull xmlns=\"http://schemas.xmlsoap.org/ws/2004/09/enumeration\"><EnumerationContext>" + enumctx + "</EnumerationContext><MaxElements>999</MaxElements><MaxCharacters>99999</MaxCharacters></Pull></Body></Envelope>", callback, tag, pri);
1029 - }
1030 -
1031 - // Private method
1032 - obj.ParseWsman = function (xml) {
1033 - try {
1034 - if (!xml.childNodes) xml = _turnToXml(xml);
1035 - var r = { Header:{} }, header = xml.getElementsByTagName("Header")[0], t;
1036 - if (!header) header = xml.getElementsByTagName("a:Header")[0];
1037 - if (!header) return null;
1038 - for (var i = 0; i < header.childNodes.length; i++) {
1039 - var child = header.childNodes[i];
1040 - r.Header[child.localName] = child.textContent;
1041 - }
1042 - var body = xml.getElementsByTagName("Body")[0];
1043 - if (!body) body = xml.getElementsByTagName("a:Body")[0];
1044 - if (!body) return null;
1045 - if (body.childNodes.length > 0) {
1046 - t = body.childNodes[0].localName;
1047 - if (t.indexOf("_OUTPUT") == t.length - 7) { t = t.substring(0, t.length - 7); }
1048 - r.Header['Method'] = t;
1049 - r.Body = _ParseWsmanRec(body.childNodes[0]);
1050 - }
1051 - return r;
1052 - } catch (e) {
1053 - console.log("Unable to parse XML: " + xml);
1054 - return null;
1055 - }
1056 - }
1057 -
1058 - // Private method
1059 - function _ParseWsmanRec(node) {
1060 - var data, r = {};
1061 - for (var i = 0; i < node.childNodes.length; i++) {
1062 - var child = node.childNodes[i];
1063 - if (child.childElementCount == 0) { data = child.textContent; } else { data = _ParseWsmanRec(child); }
1064 - if (data == 'true') data = true; // Convert 'true' into true
1065 - if (data == 'false') data = false; // Convert 'false' into false
1066 -
1067 - var childObj = data;
1068 - if (child.attributes.length > 0) {
1069 - childObj = {'Value': data };
1070 - for(var j = 0; j < child.attributes.length; j++) {
1071 - childObj['@' + child.attributes[j].name] = child.attributes[j].value;
1072 - }
1073 - }
1074 -
1075 - if (r[child.localName] instanceof Array) { r[child.localName].push(childObj); }
1076 - else if (r[child.localName] == undefined) { r[child.localName] = childObj; }
1077 - else { r[child.localName] = [r[child.localName], childObj]; }
1078 - }
1079 - return r;
1080 - }
1081 -
1082 - function _PutObjToBodyXml(resuri, putObj) {
1083 - if(!resuri || putObj === undefined || putObj === null) return '';
1084 - var objname = obj.GetNameFromUrl(resuri);
1085 - var result = '<r:' + objname + ' xmlns:r="' + resuri + '">';
1086 -
1087 - for (var prop in putObj) {
1088 - if (!putObj.hasOwnProperty(prop) || prop.indexOf('__') === 0 || prop.indexOf('@') === 0) continue;
1089 - if (putObj[prop] === undefined || putObj[prop] === null || typeof putObj[prop] === 'function') continue;
1090 - if (typeof putObj[prop] === 'object' && putObj[prop]['ReferenceParameters']) {
1091 - result += '<r:' + prop + '><a:Address>' + putObj[prop].Address + '</a:Address><a:ReferenceParameters><w:ResourceURI>' + putObj[prop]['ReferenceParameters']["ResourceURI"] + '</w:ResourceURI><w:SelectorSet>';
1092 - var selectorArray = putObj[prop]['ReferenceParameters']['SelectorSet']['Selector'];
1093 - if (Array.isArray(selectorArray)) {
1094 - for (var i=0; i< selectorArray.length; i++) {
1095 - result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray[i]) + '>' + selectorArray[i]['Value'] + '</w:Selector>';
1096 - }
1097 - }
1098 - else {
1099 - result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray) + '>' + selectorArray['Value'] + '</w:Selector>';
1100 - }
1101 - result += '</w:SelectorSet></a:ReferenceParameters></r:' + prop + '>';
1102 - }
1103 - else {
1104 - if (Array.isArray(putObj[prop])) {
1105 - for (var i = 0; i < putObj[prop].length; i++) {
1106 - result += '<r:' + prop + '>' + putObj[prop][i].toString() + '</r:' + prop + '>';
1107 - }
1108 - } else {
1109 - result += '<r:' + prop + '>' + putObj[prop].toString() + '</r:' + prop + '>';
1110 - }
1111 - }
1112 - }
1113 -
1114 - result += '</r:' + objname + '>';
1115 - return result;
1116 - }
1117 -
1118 - /*
1119 - convert
1120 - { @Name: 'InstanceID', @AttrName: 'Attribute Value'}
1121 - into
1122 - ' Name="InstanceID" AttrName="Attribute Value" '
1123 - */
1124 - function _ObjectToXmlAttributes(objWithAttributes) {
1125 - if(!objWithAttributes) return '';
1126 - var result = ' ';
1127 - for (var propName in objWithAttributes) {
1128 - if (!objWithAttributes.hasOwnProperty(propName) || propName.indexOf('@') !== 0) continue;
1129 - result += propName.substring(1) + '="' + objWithAttributes[propName] + '" ';
1130 - }
1131 - return result;
1132 - }
1133 -
1134 - function _PutObjToSelectorsXml(selectorSet) {
1135 - if (!selectorSet) return '';
1136 - if (typeof selectorSet == 'string') return selectorSet;
1137 - if (selectorSet['InstanceID']) return "<w:SelectorSet><w:Selector Name=\"InstanceID\">" + selectorSet['InstanceID'] + "</w:Selector></w:SelectorSet>";
1138 - var result = '<w:SelectorSet>';
1139 - for(var propName in selectorSet) {
1140 - if (!selectorSet.hasOwnProperty(propName)) continue;
1141 - result += '<w:Selector Name="' + propName + '">';
1142 - if (selectorSet[propName]['ReferenceParameters']) {
1143 - result += '<a:EndpointReference>';
1144 - result += '<a:Address>' + selectorSet[propName]['Address'] + '</a:Address><a:ReferenceParameters><w:ResourceURI>' + selectorSet[propName]['ReferenceParameters']['ResourceURI'] + '</w:ResourceURI><w:SelectorSet>';
1145 - var selectorArray = selectorSet[propName]['ReferenceParameters']['SelectorSet']['Selector'];
1146 - if (Array.isArray(selectorArray)) {
1147 - for (var i = 0; i < selectorArray.length; i++) {
1148 - result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray[i]) + '>' + selectorArray[i]['Value'] + '</w:Selector>';
1149 - }
1150 - }
1151 - else {
1152 - result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray) + '>' + selectorArray['Value'] + '</w:Selector>';
1153 - }
1154 - result += '</w:SelectorSet></a:ReferenceParameters></a:EndpointReference>';
1155 - } else {
1156 - result += selectorSet[propName];
1157 - }
1158 - result += '</w:Selector>';
1159 - }
1160 - result += '</w:SelectorSet>';
1161 - return result;
1162 - }
1163 -
1164 - function _turnToXml(text) {
1165 - if (window.DOMParser) {
1166 - return new DOMParser().parseFromString(text, "text/xml");
1167 - }
1168 - else // Internet Explorer
1169 - {
1170 - var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
1171 - xmlDoc.async = false;
1172 - xmlDoc.loadXML(text);
1173 - return xmlDoc;
1174 - }
1175 - }
1176 -
1177 - return obj;
1178 -}
1179 -/**
1180 -* @description Remote Desktop
1181 -* @author Ylian Saint-Hilaire
1182 -* @version v0.0.2g
1183 -*/
1184 -
1185 -// Construct a MeshServer object
1186 -var CreateAmtRemoteDesktop = function (divid, scrolldiv) {
1187 - var obj = {};
1188 - obj.canvasid = divid;
1189 - obj.CanvasId = Q(divid);
1190 - obj.scrolldiv = scrolldiv;
1191 - obj.canvas = Q(divid).getContext("2d");
1192 - obj.protocol = 2; // KVM
1193 - obj.state = 0;
1194 - obj.acc = "";
1195 - obj.ScreenWidth = 960;
1196 - obj.ScreenHeight = 700;
1197 - obj.width = 0;
1198 - obj.height = 0;
1199 - obj.rwidth = 0;
1200 - obj.rheight = 0;
1201 - obj.bpp = 2; // Bytes per pixel (1 or 2 supported)
1202 - obj.useZRLE = true;
1203 - obj.showmouse = true;
1204 - obj.buttonmask = 0;
1205 - obj.localKeyMap = true;
1206 - //obj.inbytes = 0;
1207 - //obj.outbytes = 0;
1208 - obj.spare = null;
1209 - obj.sparew = 0;
1210 - obj.spareh = 0;
1211 - obj.sparew2 = 0;
1212 - obj.spareh2 = 0;
1213 - obj.sparecache = {};
1214 - obj.ZRLEfirst = 1;
1215 - obj.onScreenSizeChange = null;
1216 - obj.frameRateDelay = 0;
1217 - // ###BEGIN###{DesktopInband}
1218 - obj.kvmDataSupported = false;
1219 - obj.onKvmData = null;
1220 - obj.onKvmDataPending = [];
1221 - obj.onKvmDataAck = -1;
1222 - obj.holding = false;
1223 - obj.lastKeepAlive = Date.now();
1224 - // ###END###{DesktopInband}
1225 -
1226 -
1227 - // Private method
1228 - obj.Debug = function (msg) { console.log(msg); }
1229 -
1230 - obj.xxStateChange = function (newstate) {
1231 - if (newstate == 0) {
1232 - obj.canvas.fillStyle = '#000000';
1233 - obj.canvas.fillRect(0, 0, obj.width, obj.height);
1234 - obj.canvas.canvas.width = obj.rwidth = obj.width = 640;
1235 - obj.canvas.canvas.height = obj.rheight = obj.height = 400;
1236 - QS(obj.canvasid).cursor = 'default';
1237 - } else {
1238 - QS(obj.canvasid).cursor = obj.showmouse ?'default':'none';
1239 - }
1240 - }
1241 -
1242 - obj.ProcessData = function (data) {
1243 - if (!data) return;
1244 - // obj.Debug("KRecv(" + data.length + "): " + rstr2hex(data));
1245 - //obj.inbytes += data.length;
1246 - //obj.Debug("KRecv(" + obj.inbytes + ")");
1247 - obj.acc += data;
1248 - while (obj.acc.length > 0) {
1249 - //obj.Debug("KAcc(" + obj.acc.length + "): " + rstr2hex(obj.acc));
1250 - var cmdsize = 0;
1251 - if (obj.state == 0 && obj.acc.length >= 12) {
1252 - // Getting handshake & version
1253 - cmdsize = 12;
1254 - //if (obj.acc.substring(0, 4) != "RFB ") { return obj.Stop(); }
1255 - //var version = parseFloat(obj.acc.substring(4, 11));
1256 - //obj.Debug("KVersion: " + version);
1257 - obj.state = 1;
1258 - obj.send("RFB 003.008\n");
1259 - }
1260 - else if (obj.state == 1 && obj.acc.length >= 1) {
1261 - // Getting security options
1262 - cmdsize = obj.acc.charCodeAt(0) + 1;
1263 - obj.send(String.fromCharCode(1)); // Send the "None" security type. Since we already authenticated using redirection digest auth, we don't need to do this again.
1264 - obj.state = 2;
1265 - }
1266 - else if (obj.state == 2 && obj.acc.length >= 4) {
1267 - // Getting security response
1268 - cmdsize = 4;
1269 - if (ReadInt(obj.acc, 0) != 0) { return obj.Stop(); }
1270 - obj.send(String.fromCharCode(1)); // Send share desktop flag
1271 - obj.state = 3;
1272 - }
1273 - else if (obj.state == 3 && obj.acc.length >= 24) {
1274 - // Getting server init
1275 - var namelen = ReadInt(obj.acc, 20);
1276 - if (obj.acc.length < 24 + namelen) return;
1277 - cmdsize = 24 + namelen;
1278 - obj.canvas.canvas.width = obj.rwidth = obj.width = obj.ScreenWidth = ReadShort(obj.acc, 0);
1279 - obj.canvas.canvas.height = obj.rheight = obj.height = obj.ScreenHeight = ReadShort(obj.acc, 2);
1280 -
1281 - // These are all values we don't really need, we are going to only run in RGB565 or RGB332 and not use the flexibility provided by these settings.
1282 - // Makes the javascript code smaller and maybe a bit faster.
1283 - /*
1284 - obj.xbpp = obj.acc.charCodeAt(4);
1285 - obj.depth = obj.acc.charCodeAt(5);
1286 - obj.bigend = obj.acc.charCodeAt(6);
1287 - obj.truecolor = obj.acc.charCodeAt(7);
1288 - obj.rmax = ReadShort(obj.acc, 8);
1289 - obj.gmax = ReadShort(obj.acc, 10);
1290 - obj.bmax = ReadShort(obj.acc, 12);
1291 - obj.rsh = obj.acc.charCodeAt(14);
1292 - obj.gsh = obj.acc.charCodeAt(15);
1293 - obj.bsh = obj.acc.charCodeAt(16);
1294 - var name = obj.acc.substring(24, 24 + namelen);
1295 - obj.Debug("name: " + name);
1296 - obj.Debug("width: " + obj.width + ", height: " + obj.height);
1297 - obj.Debug("bits-per-pixel: " + obj.xbpp);
1298 - obj.Debug("depth: " + obj.depth);
1299 - obj.Debug("big-endian-flag: " + obj.bigend);
1300 - obj.Debug("true-colour-flag: " + obj.truecolor);
1301 - obj.Debug("rgb max: " + obj.rmax + "," + obj.gmax + "," + obj.bmax);
1302 - obj.Debug("rgb shift: " + obj.rsh + "," + obj.gsh + "," + obj.bsh);
1303 - */
1304 -
1305 - // SetEncodings, with AMT we can't omit RAW, must be specified.
1306 - // Intel AMT supports encodings: RAW (0), ZRLE (16), Desktop Size (0xFFFFFF21, -223)
1307 -
1308 - var supportedEncodings = '';
1309 - if (obj.useZRLE) supportedEncodings += IntToStr(16);
1310 - supportedEncodings += IntToStr(0);
1311 - // ###BEGIN###{DesktopInband}
1312 - supportedEncodings += IntToStr(1092);
1313 - // ###END###{DesktopInband}
1314 -
1315 - obj.send(String.fromCharCode(2, 0) + ShortToStr((supportedEncodings.length / 4) + 1) + supportedEncodings + IntToStr(-223)); // Supported Encodings + Desktop Size
1316 -
1317 - // Set the pixel encoding to something much smaller
1318 - // obj.send(String.fromCharCode(0, 0, 0, 0, 16, 16, 0, 1) + ShortToStr(31) + ShortToStr(63) + ShortToStr(31) + String.fromCharCode(11, 5, 0, 0, 0, 0)); // Setup 16 bit color RGB565 (This is the default, so we don't need to set it)
1319 - if (obj.bpp == 1) obj.send(String.fromCharCode(0, 0, 0, 0, 8, 8, 0, 1) + ShortToStr(7) + ShortToStr(7) + ShortToStr(3) + String.fromCharCode(5, 2, 0, 0, 0, 0)); // Setup 8 bit color RGB332
1320 -
1321 - obj.state = 4;
1322 - obj.parent.xxStateChange(3);
1323 - _SendRefresh();
1324 - //obj.timer = setInterval(obj.xxOnTimer, 50);
1325 -
1326 -
1327 - if (obj.onScreenSizeChange != null) { obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight); }
1328 - }
1329 - else if (obj.state == 4) {
1330 - switch (obj.acc.charCodeAt(0)) {
1331 - case 0: // FramebufferUpdate
1332 - if (obj.acc.length < 4) return;
1333 - obj.state = 100 + ReadShort(obj.acc, 2); // Read the number of tiles that are going to be sent, add 100 and use that as our protocol state.
1334 - cmdsize = 4;
1335 - break;
1336 - case 2: // This is the bell, do nothing.
1337 - cmdsize = 1;
1338 - break;
1339 - case 3: // This is ServerCutText
1340 - if (obj.acc.length < 8) return;
1341 - var len = ReadInt(obj.acc, 4) + 8;
1342 - if (obj.acc.length < len) return;
1343 - cmdsize = handleServerCutText(obj.acc);
1344 - break;
1345 - }
1346 - }
1347 - else if (obj.state > 100 && obj.acc.length >= 12) {
1348 - var x = ReadShort(obj.acc, 0),
1349 - y = ReadShort(obj.acc, 2),
1350 - width = ReadShort(obj.acc, 4),
1351 - height = ReadShort(obj.acc, 6),
1352 - s = width * height,
1353 - encoding = ReadInt(obj.acc, 8);
1354 -
1355 - if (encoding < 17) {
1356 - if (width < 1 || width > 64 || height < 1 || height > 64) { console.log("Invalid tile size (" + width + "," + height + "), disconnecting."); return obj.Stop(); }
1357 -
1358 - // Set the spare bitmap to the rigth size if it's not already. This allows us to recycle the spare most if not all the time.
1359 - if (obj.sparew != width || obj.spareh != height) {
1360 - obj.sparew = obj.sparew2 = width;
1361 - obj.spareh = obj.spareh2 = height;
1362 - var xspacecachename = obj.sparew2 + 'x' + obj.spareh2;
1363 - obj.spare = obj.sparecache[xspacecachename];
1364 - if (!obj.spare) {
1365 - obj.sparecache[xspacecachename] = obj.spare = obj.canvas.createImageData(obj.sparew2, obj.spareh2);
1366 - var j = (obj.sparew2 * obj.spareh2) << 2;
1367 - for (var i = 3; i < j; i += 4) { obj.spare.data[i] = 0xFF; } // Set alpha channel to opaque.
1368 - }
1369 - }
1370 - }
1371 -
1372 - if (encoding == 0xFFFFFF21) {
1373 - // Desktop Size (0xFFFFFF21, -223)
1374 - obj.canvas.canvas.width = obj.rwidth = obj.width = width;
1375 - obj.canvas.canvas.height = obj.rheight = obj.height = height;
1376 - obj.send(String.fromCharCode(3, 0, 0, 0, 0, 0) + ShortToStr(obj.width) + ShortToStr(obj.height)); // FramebufferUpdateRequest
1377 - cmdsize = 12;
1378 - if (obj.onScreenSizeChange != null) { obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight); }
1379 - // obj.Debug("New desktop width: " + obj.width + ", height: " + obj.height);
1380 - }
1381 - else if (encoding == 0) {
1382 - // RAW encoding
1383 - var ptr = 12, cs = 12 + (s * obj.bpp);
1384 - if (obj.acc.length < cs) return; // Check we have all the data needed and we can only draw 64x64 tiles.
1385 - cmdsize = cs;
1386 -
1387 - // CRITICAL LOOP, optimize this as much as possible
1388 - if (obj.bpp == 2) {
1389 - for (var i = 0; i < s; i++) { _setPixel16(obj.acc.charCodeAt(ptr++) + (obj.acc.charCodeAt(ptr++) << 8), i); }
1390 - } else {
1391 - for (var i = 0; i < s; i++) { _setPixel8(obj.acc.charCodeAt(ptr++), i); }
1392 - }
1393 - _putImage(obj.spare, x, y);
1394 - }
1395 - else if (encoding == 16) {
1396 - // ZRLE encoding
1397 - if (obj.acc.length < 16) return;
1398 - var datalen = ReadInt(obj.acc, 12);
1399 - if (obj.acc.length < (16 + datalen)) return;
1400 - //obj.Debug("RECT ZRLE (" + x + "," + y + "," + width + "," + height + ") LEN = " + datalen);
1401 - //obj.Debug("RECT ZRLE LEN: " + ReadShortX(obj.acc, 17) + ", DATA: " + rstr2hex(obj.acc.substring(16)));
1402 -
1403 - // Process the ZLib header if this is the first block
1404 - var ptr = 16, delta = 5, dx = 0;
1405 -
1406 - if (datalen > 5 && obj.acc.charCodeAt(ptr) == 0 && ReadShortX(obj.acc, ptr + 1) == (datalen - delta)) {
1407 - // This is an uncompressed ZLib data block
1408 - _decodeLRE(obj.acc, ptr + 5, x, y, width, height, s, datalen);
1409 - }
1410 -
1411 - cmdsize = 16 + datalen;
1412 - }
1413 - else {
1414 - obj.Debug("Unknown Encoding: " + encoding);
1415 - return obj.Stop();
1416 - }
1417 - if (--obj.state == 100) {
1418 - obj.state = 4;
1419 - if (obj.frameRateDelay == 0) {
1420 - _SendRefresh(); // Ask for new frame
1421 - } else {
1422 - setTimeout(_SendRefresh, obj.frameRateDelay); // Hold x miliseconds before asking for a new frame
1423 - }
1424 - }
1425 - }
1426 -
1427 - if (cmdsize == 0) return;
1428 - obj.acc = obj.acc.substring(cmdsize);
1429 - }
1430 - }
1431 -
1432 - function _decodeLRE(data, ptr, x, y, width, height, s, datalen) {
1433 - var subencoding = data.charCodeAt(ptr++), index, v, runlengthdecode, palette = {}, rlecount = 0, runlength = 0, i;
1434 - // obj.Debug("RECT RLE (" + (datalen - 5) + ", " + subencoding + "):" + rstr2hex(data.substring(21, 21 + (datalen - 5))));
1435 - if (subencoding == 0) {
1436 - // RAW encoding
1437 - if (obj.bpp == 2) {
1438 - for (i = 0; i < s; i++) { _setPixel16(data.charCodeAt(ptr++) + (data.charCodeAt(ptr++) << 8), i); }
1439 - } else {
1440 - for (i = 0; i < s; i++) { _setPixel8(data.charCodeAt(ptr++), i); }
1441 - }
1442 - _putImage(obj.spare, x, y);
1443 - }
1444 - else if (subencoding == 1) {
1445 - // Solid color tile
1446 - v = data.charCodeAt(ptr++) + ((obj.bpp == 2) ? (data.charCodeAt(ptr++) << 8) : 0);
1447 - obj.canvas.fillStyle = 'rgb(' + ((obj.bpp == 1) ? ((v & 224) + ',' + ((v & 28) << 3) + ',' + _fixColor((v & 3) << 6)) : (((v >> 8) & 248) + ',' + ((v >> 3) & 252) + ',' + ((v & 31) << 3))) + ')';
1448 -
1449 -
1450 - obj.canvas.fillRect(x, y, width, height);
1451 - }
1452 - else if (subencoding > 1 && subencoding < 17) { // Packed palette encoded tile
1453 - // Read the palette
1454 - var br = 4, bm = 15; // br is BitRead and bm is BitMask. By adjusting these two we can support all the variations in this encoding.
1455 - if (obj.bpp == 2) {
1456 - for (i = 0; i < subencoding; i++) { palette[i] = data.charCodeAt(ptr++) + (data.charCodeAt(ptr++) << 8); }
1457 - if (subencoding == 2) { br = 1; bm = 1; } else if (subencoding <= 4) { br = 2; bm = 3; } // Compute bits to read & bit mark
1458 - while (rlecount < s && ptr < data.length) { v = data.charCodeAt(ptr++); for (i = (8 - br) ; i >= 0; i -= br) { _setPixel16(palette[(v >> i) & bm], rlecount++); } } // Display all the bits
1459 - } else {
1460 - for (i = 0; i < subencoding; i++) { palette[i] = data.charCodeAt(ptr++); }
1461 - if (subencoding == 2) { br = 1; bm = 1; } else if (subencoding <= 4) { br = 2; bm = 3; } // Compute bits to read & bit mark
1462 - while (rlecount < s && ptr < data.length) { v = data.charCodeAt(ptr++); for (i = (8 - br) ; i >= 0; i -= br) { _setPixel8(palette[(v >> i) & bm], rlecount++); } } // Display all the bits
1463 - }
1464 - _putImage(obj.spare, x, y);
1465 - }
1466 - else if (subencoding == 128) { // RLE encoded tile
1467 - if (obj.bpp == 2) {
1468 - while (rlecount < s && ptr < data.length) {
1469 - // Get the run color
1470 - v = data.charCodeAt(ptr++) + (data.charCodeAt(ptr++) << 8);
1471 -
1472 - // Decode the run length. This is the fastest and most compact way I found to do this.
1473 - runlength = 1; do { runlength += (runlengthdecode = data.charCodeAt(ptr++)); } while (runlengthdecode == 255);
1474 -
1475 - // Draw a run
1476 - if (obj.rotation == 0) {
1477 - _setPixel16run(v, rlecount, runlength); rlecount += runlength;
1478 - } else {
1479 - while (--runlength >= 0) { _setPixel16(v, rlecount++); }
1480 - }
1481 - }
1482 - } else {
1483 - while (rlecount < s && ptr < data.length) {
1484 - // Get the run color
1485 - v = data.charCodeAt(ptr++);
1486 -
1487 - // Decode the run length. This is the fastest and most compact way I found to do this.
1488 - runlength = 1; do { runlength += (runlengthdecode = data.charCodeAt(ptr++)); } while (runlengthdecode == 255);
1489 -
1490 - // Draw a run
1491 - if (obj.rotation == 0) {
1492 - _setPixel8run(v, rlecount, runlength); rlecount += runlength;
1493 - } else {
1494 - while (--runlength >= 0) { _setPixel8(v, rlecount++); }
1495 - }
1496 - }
1497 - }
1498 - _putImage(obj.spare, x, y);
1499 - }
1500 - else if (subencoding > 129) { // Palette RLE encoded tile
1501 - // Read the palette
1502 - if (obj.bpp == 2) {
1503 - for (i = 0; i < (subencoding - 128) ; i++) { palette[i] = data.charCodeAt(ptr++) + (data.charCodeAt(ptr++) << 8); }
1504 - } else {
1505 - for (i = 0; i < (subencoding - 128) ; i++) { palette[i] = data.charCodeAt(ptr++); }
1506 - }
1507 -
1508 - // Decode RLE on palette
1509 - while (rlecount < s && ptr < data.length) {
1510 - // Setup the run, get the color index and get the color from the palette.
1511 - runlength = 1; index = data.charCodeAt(ptr++); v = palette[index % 128];
1512 -
1513 - // If the index starts with high order bit 1, this is a run and decode the run length.
1514 - if (index > 127) { do { runlength += (runlengthdecode = data.charCodeAt(ptr++)); } while (runlengthdecode == 255); }
1515 -
1516 - // Draw a run
1517 - if (obj.rotation == 0) {
1518 - if (obj.bpp == 2) {
1519 - _setPixel16run(v, rlecount, runlength); rlecount += runlength;
1520 - } else {
1521 - _setPixel8run(v, rlecount, runlength); rlecount += runlength;
1522 - }
1523 - } else {
1524 - if (obj.bpp == 2) {
1525 - while (--runlength >= 0) { _setPixel16(v, rlecount++); }
1526 - } else {
1527 - while (--runlength >= 0) { _setPixel8(v, rlecount++); }
1528 - }
1529 - }
1530 - }
1531 - _putImage(obj.spare, x, y);
1532 - }
1533 - }
1534 -
1535 - // ###BEGIN###{DesktopInband}
1536 - obj.hold = function (holding) {
1537 - if (obj.holding == holding) return;
1538 - obj.holding = holding;
1539 - obj.canvas.fillStyle = '#000000';
1540 - obj.canvas.fillRect(0, 0, obj.width, obj.height); // Paint black
1541 - if (obj.holding == false) {
1542 - // Go back to normal operations
1543 - // Set canvas size and ask for full screen refresh
1544 - if ((obj.canvas.canvas.width != obj.width) || (obj.canvas.canvas.height != obj.height)) {
1545 - obj.canvas.canvas.width = obj.width; obj.canvas.canvas.height = obj.height;
1546 - if (obj.onScreenSizeChange != null) { obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight); } // ???
1547 - }
1548 - obj.Send(String.fromCharCode(3, 0, 0, 0, 0, 0) + ShortToStr(obj.width) + ShortToStr(obj.height)); // FramebufferUpdateRequest
1549 - } else {
1550 - obj.UnGrabMouseInput();
1551 - obj.UnGrabKeyInput();
1552 - }
1553 - }
1554 - // ###END###{DesktopInband}
1555 -
1556 - function _putImage(i, x, y) {
1557 - // ###BEGIN###{DesktopInband}
1558 - if (obj.holding == true) return;
1559 - // ###END###{DesktopInband}
1560 - obj.canvas.putImageData(i, x, y);
1561 - }
1562 -
1563 - // Set 8bit color RGB332
1564 - function _setPixel8(v, p) {
1565 - var pp = p << 2;
1566 -
1567 -
1568 - obj.spare.data[pp] = v & 224;
1569 - obj.spare.data[pp + 1] = (v & 28) << 3;
1570 - obj.spare.data[pp + 2] = _fixColor((v & 3) << 6);
1571 - }
1572 -
1573 - // Set 16bit color RGB565
1574 - function _setPixel16(v, p) {
1575 - var pp = p << 2;
1576 -
1577 -
1578 - obj.spare.data[pp] = (v >> 8) & 248;
1579 - obj.spare.data[pp + 1] = (v >> 3) & 252;
1580 - obj.spare.data[pp + 2] = (v & 31) << 3;
1581 - }
1582 -
1583 - // Set a run of 8bit color RGB332
1584 - function _setPixel8run(v, p, run) {
1585 - var pp = (p << 2), r = (v & 224), g = ((v & 28) << 3), b = (_fixColor((v & 3) << 6));
1586 - while (--run >= 0) { obj.spare.data[pp] = r; obj.spare.data[pp + 1] = g; obj.spare.data[pp + 2] = b; pp += 4; }
1587 - }
1588 -
1589 - // Set a run of 16bit color RGB565
1590 - function _setPixel16run(v, p, run) {
1591 - var pp = (p << 2), r = ((v >> 8) & 248), g = ((v >> 3) & 252), b = ((v & 31) << 3);
1592 - while (--run >= 0) { obj.spare.data[pp] = r; obj.spare.data[pp + 1] = g; obj.spare.data[pp + 2] = b; pp += 4; }
1593 - }
1594 -
1595 -
1596 - function _fixColor(c) { return (c > 127) ? (c + 32) : c; }
1597 -
1598 - function _SendRefresh() {
1599 - // ###BEGIN###{DesktopInband}
1600 - if (obj.holding == true) return;
1601 - // ###END###{DesktopInband}
1602 - // Request the entire screen
1603 - obj.send(String.fromCharCode(3, 1, 0, 0, 0, 0) + ShortToStr(obj.rwidth) + ShortToStr(obj.rheight)); // FramebufferUpdateRequest
1604 - }
1605 -
1606 - obj.Start = function () {
1607 - //obj.Debug("KVM-Start");
1608 - obj.state = 0;
1609 - obj.acc = "";
1610 - obj.ZRLEfirst = 1;
1611 - //obj.inbytes = 0;
1612 - //obj.outbytes = 0;
1613 - // ###BEGIN###{DesktopInband}
1614 - obj.onKvmDataPending = [];
1615 - obj.onKvmDataAck = -1;
1616 - obj.kvmDataSupported = false;
1617 - // ###END###{DesktopInband}
1618 - for (var i in obj.sparecache) { delete obj.sparecache[i]; }
1619 - }
1620 -
1621 - obj.Stop = function () {
1622 - obj.UnGrabMouseInput();
1623 - obj.UnGrabKeyInput();
1624 - obj.parent.Stop();
1625 - }
1626 -
1627 - obj.send = function (x) {
1628 - //obj.Debug("KSend(" + x.length + "): " + rstr2hex(x));
1629 - //obj.outbytes += x.length;
1630 - obj.parent.send(x);
1631 - }
1632 -
1633 - var convertAmtKeyCodeTable = {
1634 - "Pause": 19,
1635 - "CapsLock": 20,
1636 - "Space": 32,
1637 - "Quote": 39,
1638 - "Minus": 45,
1639 - "NumpadMultiply": 42,
1640 - "NumpadAdd": 43,
1641 - "PrintScreen": 44,
1642 - "Comma": 44,
1643 - "NumpadSubtract": 45,
1644 - "NumpadDecimal": 46,
1645 - "Period": 46,
1646 - "Slash": 47,
1647 - "NumpadDivide": 47,
1648 - "Semicolon": 59,
1649 - "Equal": 61,
1650 - "OSLeft": 91,
1651 - "BracketLeft": 91,
1652 - "OSRight": 91,
1653 - "Backslash": 92,
1654 - "BracketRight": 93,
1655 - "ContextMenu": 93,
1656 - "Backquote": 96,
1657 - "NumLock": 144,
1658 - "ScrollLock": 145,
1659 - "Backspace": 0xff08,
1660 - "Tab": 0xff09,
1661 - "Enter": 0xff0d,
1662 - "NumpadEnter": 0xff0d,
1663 - "Escape": 0xff1b,
1664 - "Delete": 0xffff,
1665 - "Home": 0xff50,
1666 - "PageUp": 0xff55,
1667 - "PageDown": 0xff56,
1668 - "ArrowLeft": 0xff51,
1669 - "ArrowUp": 0xff52,
1670 - "ArrowRight": 0xff53,
1671 - "ArrowDown": 0xff54,
1672 - "End": 0xff57,
1673 - "Insert": 0xff63,
1674 - "F1": 0xffbe,
1675 - "F2": 0xffbf,
1676 - "F3": 0xffc0,
1677 - "F4": 0xffc1,
1678 - "F5": 0xffc2,
1679 - "F6": 0xffc3,
1680 - "F7": 0xffc4,
1681 - "F8": 0xffc5,
1682 - "F9": 0xffc6,
1683 - "F10": 0xffc7,
1684 - "F11": 0xffc8,
1685 - "F12": 0xffc9,
1686 - "ShiftLeft": 0xffe1,
1687 - "ShiftRight": 0xffe2,
1688 - "ControlLeft": 0xffe3,
1689 - "ControlRight": 0xffe4,
1690 - "AltLeft": 0xffe9,
1691 - "AltRight": 0xffea,
1692 - "MetaLeft": 0xffe7,
1693 - "MetaRight": 0xffe8
1694 - }
1695 - function convertAmtKeyCode(e) {
1696 - if (e.code.startsWith('Key') && e.code.length == 4) { return e.code.charCodeAt(3) + ((e.shiftKey == false) ? 32 : 0); }
1697 - if (e.code.startsWith('Digit') && e.code.length == 6) { return e.code.charCodeAt(5); }
1698 - if (e.code.startsWith('Numpad') && e.code.length == 7) { return e.code.charCodeAt(6); }
1699 - return convertAmtKeyCodeTable[e.code];
1700 - }
1701 -
1702 - /*
1703 - Intel AMT only recognizes a small subset of keysym characters defined in the keysymdef.h so you don�t need to
1704 - implement all the languages (this is taken care by the USB Scancode Extension in RFB4.0 protocol).
1705 - The only subset recognized by the FW is the defined by the following sets : XK_LATIN1 , XK_MISCELLANY, XK_3270, XK_XKB_KEYS, XK_KATAKANA.
1706 - In addition to keysymdef.h symbols there are 6 japanese extra keys that we do support:
1707 -
1708 - #define XK_Intel_EU_102kbd_backslash_pipe_45 0x17170056 // European 102-key: 45 (backslash/pipe), usb Usage: 0x64
1709 - #define XK_Intel_JP_106kbd_yen_pipe 0x1717007d // Japanese 106-key: 14 (Yen/pipe), usb Usage: 0x89
1710 - #define XK_Intel_JP_106kbd_backslash_underbar 0x17170073 // Japanese 106-key: 56 (backslash/underbar), usb Usage: 0x87
1711 - #define XK_Intel_JP_106kbd_NoConvert 0x1717007b // Japanese 106-key: 131 (NoConvert), usb Usage: 0x8b
1712 - #define XK_Intel_JP_106kbd_Convert 0x17170079 // Japanese 106-key: 132 (Convert), usb Usage: 0x8a
1713 - #define XK_Intel_JP_106kbd_Hirigana_Katakana 0x17170070 // Japanese 106-key: 133 (Hirigana/Katakana), usb Usage: 0x88
1714 - */
1715 -
1716 - function _keyevent(d, e) {
1717 - if (!e) { e = window.event; }
1718 -
1719 - if (e.code && (obj.localKeyMap == false)) {
1720 - // For new browsers, this mapping is keyboard language independent
1721 - var k = convertAmtKeyCode(e);
1722 - if (k != null) { obj.sendkey(k, d); }
1723 - } else {
1724 - // For older browsers, this mapping works best for EN-US keyboard
1725 - var k = e.keyCode, kk = k;
1726 - if (e.shiftKey == false && k >= 65 && k <= 90) kk = k + 32;
1727 - if (k >= 112 && k <= 124) kk = k + 0xFF4E;
1728 - if (k == 8) kk = 0xff08; // Backspace
1729 - if (k == 9) kk = 0xff09; // Tab
1730 - if (k == 13) kk = 0xff0d; // Return
1731 - if (k == 16) kk = 0xffe1; // Shift (Left)
1732 - if (k == 17) kk = 0xffe3; // Ctrl (Left)
1733 - if (k == 18) kk = 0xffe9; // Alt (Left)
1734 - if (k == 27) kk = 0xff1b; // ESC
1735 - if (k == 33) kk = 0xff55; // PageUp
1736 - if (k == 34) kk = 0xff56; // PageDown
1737 - if (k == 35) kk = 0xff57; // End
1738 - if (k == 36) kk = 0xff50; // Home
1739 - if (k == 37) kk = 0xff51; // Left
1740 - if (k == 38) kk = 0xff52; // Up
1741 - if (k == 39) kk = 0xff53; // Right
1742 - if (k == 40) kk = 0xff54; // Down
1743 - if (k == 45) kk = 0xff63; // Insert
1744 - if (k == 46) kk = 0xffff; // Delete
1745 - if (k >= 96 && k <= 105) kk = k - 48; // Key pad numbers
1746 - if (k == 106) kk = 42; // Pad *
1747 - if (k == 107) kk = 43; // Pad +
1748 - if (k == 109) kk = 45; // Pad -
1749 - if (k == 110) kk = 46; // Pad .
1750 - if (k == 111) kk = 47; // Pad /
1751 - if (k == 186) kk = 59; // ;
1752 - if (k == 187) kk = 61; // =
1753 - if (k == 188) kk = 44; // ,
1754 - if (k == 189) kk = 45; // -
1755 - if (k == 190) kk = 46; // .
1756 - if (k == 191) kk = 47; // /
1757 - if (k == 192) kk = 96; // `
1758 - if (k == 219) kk = 91; // [
1759 - if (k == 220) kk = 92; // \
1760 - if (k == 221) kk = 93; // ]
1761 - if (k == 222) kk = 39; // '
1762 - //console.log('Key' + d + ": " + k + " = " + kk);
1763 - obj.sendkey(kk, d);
1764 - }
1765 - return obj.haltEvent(e);
1766 - }
1767 -
1768 - obj.sendkey = function (k, d) {
1769 - if (typeof k == 'object') { for (var i in k) { obj.sendkey(k[i][0], k[i][1]); } }
1770 - else { obj.send(String.fromCharCode(4, d, 0, 0) + IntToStr(k)); }
1771 - }
1772 -
1773 - function handleServerCutText(acc) {
1774 - if (acc.length < 8) return 0;
1775 - var len = ReadInt(obj.acc, 4) + 8;
1776 - if (acc.length < len) return 0;
1777 - // ###BEGIN###{DesktopInband}
1778 - if (obj.onKvmData != null) {
1779 - var d = acc.substring(8, len);
1780 - if ((d.length >= 16) && (d.substring(0, 15) == '\0KvmDataChannel')) {
1781 - if (obj.kvmDataSupported == false) { obj.kvmDataSupported = true; console.log('KVM Data Channel Supported.'); }
1782 - if (((obj.onKvmDataAck == -1) && (d.length == 16)) || (d.charCodeAt(15) != 0)) { obj.onKvmDataAck = true; }
1783 - //if (urlvars && urlvars['kvmdatatrace']) { console.log('KVM-Recv(' + (d.length - 16) + '): ' + d.substring(16)); }
1784 - if (d.length >= 16) { obj.onKvmData(d.substring(16)); } // Event the data and ack
1785 - if ((obj.onKvmDataAck == true) && (obj.onKvmDataPending.length > 0)) { obj.sendKvmData(obj.onKvmDataPending.shift()); } // Send pending data
1786 - }
1787 - }
1788 - // ###END###{DesktopInband}
1789 - return len;
1790 - }
1791 -
1792 - // ###BEGIN###{DesktopInband}
1793 - obj.sendKvmData = function (x) {
1794 - if (obj.onKvmDataAck !== true) {
1795 - obj.onKvmDataPending.push(x);
1796 - } else {
1797 - //if (urlvars && urlvars['kvmdatatrace']) { console.log('KVM-Send(' + x.length + '): ' + x); }
1798 - x = '\0KvmDataChannel\0' + x;
1799 - obj.send(String.fromCharCode(6, 0, 0, 0) + IntToStr(x.length) + x);
1800 - obj.onKvmDataAck = false;
1801 - }
1802 - }
1803 -
1804 - // Send a HWKVM keep alive if it's not been sent in the last 5 seconds.
1805 - obj.sendKeepAlive = function () {
1806 - if (obj.lastKeepAlive < Date.now() - 5000) { obj.lastKeepAlive = Date.now(); obj.send(String.fromCharCode(6, 0, 0, 0) + IntToStr(16) + '\0KvmDataChannel\0'); }
1807 - }
1808 - // ###END###{DesktopInband}
1809 -
1810 - obj.SendCtrlAltDelMsg = function () { obj.sendcad(); }
1811 - obj.sendcad = function () { obj.sendkey([[0xFFE3, 1], [0xFFE9, 1], [0xFFFF, 1], [0xFFFF, 0], [0xFFE9, 0], [0xFFE3, 0]]); } // Control down, Alt down, Delete down, Delete up , Alt up , Control up
1812 -
1813 - var _MouseInputGrab = false;
1814 - var _KeyInputGrab = false;
1815 -
1816 - obj.GrabMouseInput = function () {
1817 - if (_MouseInputGrab == true) return;
1818 - var c = obj.canvas.canvas;
1819 - c.onmouseup = obj.mouseup;
1820 - c.onmousedown = obj.mousedown;
1821 - c.onmousemove = obj.mousemove;
1822 - //if (navigator.userAgent.match(/mozilla/i)) c.DOMMouseScroll = obj.xxDOMMouseScroll; else c.onmousewheel = obj.xxMouseWheel;
1823 - _MouseInputGrab = true;
1824 - }
1825 -
1826 - obj.UnGrabMouseInput = function () {
1827 - if (_MouseInputGrab == false) return;
1828 - var c = obj.canvas.canvas;
1829 - c.onmousemove = null;
1830 - c.onmouseup = null;
1831 - c.onmousedown = null;
1832 - //if (navigator.userAgent.match(/mozilla/i)) c.DOMMouseScroll = null; else c.onmousewheel = null;
1833 - _MouseInputGrab = false;
1834 - }
1835 -
1836 - obj.GrabKeyInput = function () {
1837 - if (_KeyInputGrab == true) return;
1838 - document.onkeyup = obj.handleKeyUp;
1839 - document.onkeydown = obj.handleKeyDown;
1840 - document.onkeypress = obj.handleKeys;
1841 - _KeyInputGrab = true;
1842 - }
1843 -
1844 - obj.UnGrabKeyInput = function () {
1845 - if (_KeyInputGrab == false) return;
1846 - document.onkeyup = null;
1847 - document.onkeydown = null;
1848 - document.onkeypress = null;
1849 - _KeyInputGrab = false;
1850 - }
1851 -
1852 - obj.handleKeys = function (e) { return obj.haltEvent(e); }
1853 - obj.handleKeyUp = function (e) { return _keyevent(0, e); }
1854 - obj.handleKeyDown = function (e) { return _keyevent(1, e); }
1855 - obj.haltEvent = function (e) { if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; }
1856 -
1857 - // RFB "PointerEvent" and mouse handlers
1858 - obj.mousedblclick = function (e) { }
1859 - obj.mousedown = function (e) { obj.buttonmask |= (1 << e.button); return obj.mousemove(e); }
1860 - obj.mouseup = function (e) { obj.buttonmask &= (0xFFFF - (1 << e.button)); return obj.mousemove(e); }
1861 - obj.mousemove = function (e) {
1862 - if (obj.state != 4) return true;
1863 - var ScaleFactorHeight = (obj.canvas.canvas.height / Q(obj.canvasid).offsetHeight);
1864 - var ScaleFactorWidth = (obj.canvas.canvas.width / Q(obj.canvasid).offsetWidth);
1865 - var Offsets = obj.getPositionOfControl(Q(obj.canvasid));
1866 - obj.mx = ((event.pageX - Offsets[0]) * ScaleFactorWidth);
1867 - obj.my = ((event.pageY - Offsets[1]) * ScaleFactorHeight);
1868 - if (event.addx) { obj.mx += event.addx; }
1869 - if (event.addy) { obj.my += event.addy; }
1870 -
1871 -
1872 - obj.send(String.fromCharCode(5, obj.buttonmask) + ShortToStr(obj.mx) + ShortToStr(obj.my));
1873 -
1874 -
1875 - return obj.haltEvent(e);
1876 - }
1877 -
1878 - obj.getPositionOfControl = function (Control) {
1879 - var Position = Array(2);
1880 - Position[0] = Position[1] = 0;
1881 - while (Control) {
1882 - Position[0] += Control.offsetLeft;
1883 - Position[1] += Control.offsetTop;
1884 - Control = Control.offsetParent;
1885 - }
1886 - return Position;
1887 - }
1888 -
1889 - return obj;
1890 -}
1891 -/**
1892 -* @description Remote Terminal
1893 -* @author Ylian Saint-Hilaire
1894 -* @version v0.0.2c
1895 -*/
1896 -
1897 -// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
1898 -// https://www.x.org/docs/xterm/ctlseqs.pdf
1899 -
1900 -// Construct a MeshServer object
1901 -var CreateAmtRemoteTerminal = function (divid, options) {
1902 - var obj = {};
1903 - obj.DivId = divid;
1904 - obj.DivElement = document.getElementById(divid);
1905 - obj.protocol = 1; // SOL
1906 - obj.fxEmulation = 0;
1907 - obj.lineFeed = '\r\n';
1908 - obj.debugmode = 0;
1909 -
1910 - obj.width = 80; // 80 or 100
1911 - obj.height = 25; // 25 or 30
1912 - obj.heightLock = 0;
1913 -
1914 - var _Terminal_CellHeight = 21;
1915 - var _Terminal_CellWidth = 13;
1916 - var _TermColors = ['000000', 'BB0000', '00BB00', 'BBBB00', '0000BB', 'BB00BB', '00BBBB', 'BBBBBB', '555555', 'FF5555', '55FF55', 'FFFF55', '5555FF', 'FF55FF', '55FFFF', 'FFFFFF'];
1917 - var _TermCurrentReverse = 0;
1918 - var _TermCurrentFColor = 7;
1919 - var _TermCurrentBColor = 0;
1920 - var _TermLineWrap = true;
1921 - var _termx = 0;
1922 - var _termy = 0;
1923 - var _termsavex = 0;
1924 - var _termsavey = 0;
1925 - var _termstate = 0;
1926 - var _escNumber = [];
1927 - var _escNumberPtr = 0;
1928 - var _escNumberMode = 0;
1929 - var _scratt = [];
1930 - var _tscreen = [];
1931 - var _VTUNDERLINE = 1;
1932 - var _VTREVERSE = 2;
1933 - var _backSpaceErase = false;
1934 - var _cursorVisible = true;
1935 - var _scrollRegion;
1936 - var _altKeypadMode = false;
1937 - var scrollBackBuffer = [];
1938 - obj.title = null;
1939 - obj.onTitleChange = null;
1940 -
1941 - obj.Start = function () { }
1942 -
1943 - obj.Init = function (width, height) {
1944 - obj.width = width ? width : 80;
1945 - obj.height = height ? height : 25;
1946 - for (var y = 0; y < obj.height; y++) {
1947 - _tscreen[y] = [];
1948 - _scratt[y] = [];
1949 - for (var x = 0; x < obj.width; x++) { _tscreen[y][x] = ' '; _scratt[y][x] = (7 << 6); }
1950 - }
1951 - obj.TermInit();
1952 - obj.TermDraw();
1953 - }
1954 -
1955 - obj.xxStateChange = function (newstate) {
1956 - if ((newstate == 3) && (options != null) && (options.xterm == true)) { obj.TermSendKeys('stty rows ' + obj.height + ' cols ' + obj.width + '\nclear\n'); }
1957 - }
1958 -
1959 - obj.ProcessData = function (str) {
1960 - if (obj.debugmode == 2) { console.log("TRecv(" + str.length + "): " + rstr2hex(str)); }
1961 - if (obj.capture != null) obj.capture += str; _ProcessVt100EscString(str); obj.TermDraw();
1962 - }
1963 -
1964 - function _ProcessVt100EscString(str) { for (var i = 0; i < str.length; i++) _ProcessVt100EscChar(String.fromCharCode(str.charCodeAt(i)), str.charCodeAt(i)); }
1965 -
1966 - function _ProcessVt100EscChar(b, c) {
1967 - switch (_termstate) {
1968 - case 0: // Normal Term State
1969 - switch (c) {
1970 - case 27: // ESC
1971 - _termstate = 1;
1972 - _escNumber = [];
1973 - _escNumberPtr = 0;
1974 - _escNumberMode = 0;
1975 - break;
1976 - default:
1977 - // Process a single char
1978 - _ProcessVt100Char(b);
1979 - break;
1980 - }
1981 - break;
1982 - case 1:
1983 - switch (b) {
1984 - case '[':
1985 - _termstate = 2;
1986 - break;
1987 - case '(':
1988 - _termstate = 4;
1989 - break;
1990 - case ')':
1991 - _termstate = 5;
1992 - break;
1993 - case ']':
1994 - _termstate = 6; // xterm strings
1995 - break;
1996 - case '=':
1997 - // Set alternate keypad mode
1998 - _altKeypadMode = true;
1999 - _termstate = 0;
2000 - break;
2001 - case '>':
2002 - // Set numeric keypad mode
2003 - _altKeypadMode = false;
2004 - _termstate = 0;
2005 - break;
2006 - case '7':
2007 - // Save Cursor
2008 - _termsavex = _termx;
2009 - _termsavey = _termy;
2010 - _termstate = 0;
2011 - break;
2012 - case '8':
2013 - // Restore Cursor
2014 - _termx = _termsavex;
2015 - _termy = _termsavey;
2016 - _termstate = 0;
2017 - break;
2018 - case 'M':
2019 - // Scroll down one
2020 - var x = 1;
2021 - for (var y = _scrollRegion[1]; y >= _scrollRegion[0] + x; y--) {
2022 - for (var z = 0; z < obj.width; z++) { _tscreen[y][z] = _tscreen[y - x][z]; _scratt[y][z] = _scratt[y - x][z]; }
2023 - }
2024 - for (var y = _scrollRegion[0] + x - 1; y > _scrollRegion[0] - 1; y--) {
2025 - for (var z = 0; z < obj.width; z++) { _tscreen[y][z] = ' '; _scratt[y][z] = (7 << 6); }
2026 - }
2027 - _termstate = 0;
2028 - break;
2029 - default:
2030 - console.log('unknown terminal short code', b);
2031 - _termstate = 0;
2032 - break;
2033 - }
2034 - break;
2035 - case 2:
2036 - if (b >= '0' && b <= '9') {
2037 - // This is a number
2038 - if (!_escNumber[_escNumberPtr]) { _escNumber[_escNumberPtr] = (b - '0'); }
2039 - else { _escNumber[_escNumberPtr] = ((_escNumber[_escNumberPtr] * 10) + (b - '0')); }
2040 - break;
2041 - } else if (b == ';') {
2042 - // New number
2043 - _escNumberPtr++;
2044 - break;
2045 - } else if (b == '?') {
2046 - _escNumberMode = 1;
2047 - break;
2048 - } else {
2049 - // Process Escape Sequence
2050 - if (!_escNumber[0]) _escNumber[0] = 0;
2051 - _ProcessEscapeHandler(b, _escNumber, _escNumberPtr + 1, _escNumberMode);
2052 - _termstate = 0;
2053 - }
2054 - break;
2055 - case 4: // '(' Code
2056 - _termstate = 0;
2057 - break;
2058 - case 5: // ')' Code
2059 - _termstate = 0;
2060 - break;
2061 - case 6: // ']' Code, xterm
2062 - const bx = b.charCodeAt(0);
2063 - if (b == ';') {
2064 - _escNumberPtr++;
2065 - } else if (bx == 7) {
2066 - _ProcessXTermHandler(_escNumber);
2067 - _termstate = 0;
2068 - } else {
2069 - if (!_escNumber[_escNumberPtr]) { _escNumber[_escNumberPtr] = b; }
2070 - else { _escNumber[_escNumberPtr] += b; }
2071 - }
2072 - break;
2073 - }
2074 - }
2075 -
2076 - function _ProcessXTermHandler(_escNumber) {
2077 - if (_escNumber.length == 0) return;
2078 - var cmd = parseInt(_escNumber[0]);
2079 - if ((cmd == 0 || cmd == 2) && (_escNumber.length > 1) && (_escNumber[1] != '?')) {
2080 - if (obj.onTitleChange) { obj.onTitleChange(obj, obj.title = _escNumber[1]); }
2081 - }
2082 - }
2083 -
2084 - function _ProcessEscapeHandler(code, args, argslen, mode) {
2085 - //console.log('process', code, args, mode);
2086 - if (mode == 1) {
2087 - switch (code) {
2088 - case 'l': // Hide the cursor
2089 - if (args[0] == 25) { _cursorVisible = false; }
2090 - break;
2091 - case 'h': // Show the cursor
2092 - if (args[0] == 25) { _cursorVisible = true; }
2093 - break;
2094 - }
2095 - } else if (mode == 0) {
2096 - var i;
2097 - switch (code) {
2098 - case 'c': // ResetDevice
2099 - // Reset
2100 - obj.TermResetScreen();
2101 - break;
2102 - case 'A': // Move cursor up n lines
2103 - if (argslen == 1) {
2104 - if (args[0] == 0) { _termy--; } else { _termy -= args[0]; }
2105 - if (_termy < 0) _termy = 0;
2106 - }
2107 - break;
2108 - case 'B': // Move cursor down n lines
2109 - if (argslen == 1) {
2110 - if (args[0] == 0) { _termy++; } else { _termy += args[0]; }
2111 - if (_termy > obj.height) _termy = obj.height;
2112 - }
2113 - break;
2114 - case 'C': // Move cursor right n lines
2115 - if (argslen == 1) {
2116 - if (args[0] == 0) { _termx++; } else { _termx += args[0]; }
2117 - if (_termx > obj.width) _termx = obj.width;
2118 - }
2119 - break;
2120 - case 'D': // Move cursor left n lines
2121 - if (argslen == 1) {
2122 - if (args[0] == 0) { _termx--; } else { _termx -= args[0]; }
2123 - if (_termx < 0) _termx = 0;
2124 - }
2125 - break;
2126 - case 'd': // Set cursor to line n
2127 - if (argslen == 1) {
2128 - _termy = args[0] - 1;
2129 - if (_termy > obj.height) _termy = obj.height;
2130 - if (_termy < 0) _termy = 0;
2131 - }
2132 - break;
2133 - case 'G': // Set cursor to col n
2134 - if (argslen == 1) {
2135 - _termx = args[0] - 1;
2136 - if (_termx < 0) _termx = 0;
2137 - if (_termx > (obj.width - 1)) _termx = (obj.width - 1);
2138 - }
2139 - break;
2140 - case 'P': // Delete X Character(s), default 1 char
2141 - var x = 1;
2142 - if (argslen == 1) { x = args[0]; }
2143 - for (i = _termx; i < obj.width - x; i++) { _tscreen[_termy][i] = _tscreen[_termy][i + x]; _scratt[_termy][i] = _scratt[_termy][i + x]; }
2144 - for (i = (obj.width - x); i < obj.width; i++) { _tscreen[_termy][i] = ' '; _scratt[_termy][i] = (7 << 6); }
2145 - break;
2146 - case 'L': // Insert X Line(s), default 1 char
2147 - var linecount = 1;
2148 - if (argslen == 1) { linecount = args[0]; }
2149 - if (linecount == 0) { linecount = 1; }
2150 - for (y = _scrollRegion[1]; y >= _termy + linecount; y--) {
2151 - _tscreen[y] = _tscreen[y - linecount];
2152 - _scratt[y] = _scratt[y - linecount];
2153 - }
2154 - for (y = _termy; y < _termy + linecount; y++) {
2155 - _tscreen[y] = [];
2156 - _scratt[y] = [];
2157 - for (x = 0; x < obj.width; x++) { _tscreen[y][x] = ' '; _scratt[y][x] = (7 << 6); }
2158 - }
2159 - break;
2160 - case 'J': // ClearScreen:
2161 - if (argslen == 1 && args[0] == 2) {
2162 - obj.TermClear((_TermCurrentBColor << 12) + (_TermCurrentFColor << 6)); // Erase entire screen
2163 - _termx = 0;
2164 - _termy = 0;
2165 - scrollBackBuffer = [];
2166 - }
2167 - else if (argslen == 0 || argslen == 1 && args[0] == 0) // Erase cursor down
2168 - {
2169 - _EraseCursorToEol();
2170 - for (i = _termy + 1; i < obj.height; i++) _EraseLine(i);
2171 - }
2172 - else if (argslen == 1 && args[0] == 1) // Erase cursor up
2173 - {
2174 - _EraseCursorToEol();
2175 - for (i = 0; i < _termy - 1; i++) _EraseLine(i);
2176 - }
2177 - break;
2178 - case 'H': // MoveCursor:
2179 - if (argslen == 2) {
2180 - if (args[0] < 1) args[0] = 1;
2181 - if (args[1] < 1) args[1] = 1;
2182 - if (args[0] > obj.height) args[0] = obj.height;
2183 - if (args[1] > obj.width) args[1] = obj.width;
2184 - _termy = args[0] - 1;
2185 - _termx = args[1] - 1;
2186 - } else {
2187 - _termy = 0;
2188 - _termx = 0;
2189 - }
2190 - break;
2191 - case 'm': // ScreenAttribs:
2192 - // Change attributes
2193 - for (i = 0; i < argslen; i++) {
2194 - if (!args[i] || args[i] == 0) {
2195 - // Reset Attributes
2196 - _TermCurrentBColor = 0;
2197 - _TermCurrentFColor = 7;
2198 - _TermCurrentReverse = 0;
2199 - }
2200 - else if (args[i] == 1) {
2201 - // Bright
2202 - if (_TermCurrentFColor < 8) _TermCurrentFColor += 8;
2203 - }
2204 - else if (args[i] == 2 || args[i] == 22) {
2205 - // Dim
2206 - if (_TermCurrentFColor >= 8) _TermCurrentFColor -= 8;
2207 - }
2208 - else if (args[i] == 7) {
2209 - // Set Reverse attribute true
2210 - _TermCurrentReverse = 2;
2211 - }
2212 - else if (args[i] == 27) {
2213 - // Set Reverse attribute false
2214 - _TermCurrentReverse = 0;
2215 - }
2216 - else if (args[i] >= 30 && args[i] <= 37) {
2217 - // Set Foreground Color
2218 - var bright = (_TermCurrentFColor >= 8);
2219 - _TermCurrentFColor = (args[i] - 30);
2220 - if (bright && _TermCurrentFColor <= 8) _TermCurrentFColor += 8;
2221 - }
2222 - else if (args[i] >= 40 && args[i] <= 47) {
2223 - // Set Background Color
2224 - _TermCurrentBColor = (args[i] - 40);
2225 - }
2226 - else if (args[i] >= 90 && args[i] <= 99) {
2227 - // Set Bright Foreground Color
2228 - _TermCurrentFColor = (args[i] - 82);
2229 - }
2230 - else if (args[i] >= 100 && args[i] <= 109) {
2231 - // Set Bright Background Color
2232 - _TermCurrentBColor = (args[i] - 92);
2233 - }
2234 - }
2235 - break;
2236 - case 'K': // EraseLine:
2237 - if (argslen == 0 || (argslen == 1 && (!args[0] || args[0] == 0))) {
2238 - _EraseCursorToEol(); // Erase from the cursor to the end of the line
2239 - } else if (argslen == 1) {
2240 - if (args[0] == 1) { // Erase from the beginning of the line to the cursor
2241 - _EraseBolToCursor();
2242 - } else if (args[0] == 2) { // Erase the line with the cursor
2243 - _EraseLine(_termy);
2244 - }
2245 - }
2246 - break;
2247 - case 'h': // EnableLineWrap:
2248 - _TermLineWrap = true;
2249 - break;
2250 - case 'l': // DisableLineWrap:
2251 - _TermLineWrap = false;
2252 - break;
2253 - case 'r': // Set the scroll region
2254 - if (argslen == 2) { _scrollRegion = [args[0] - 1, args[1] - 1]; }
2255 - if (_scrollRegion[0] < 0) { _scrollRegion[0] = 0; }
2256 - if (_scrollRegion[0] > (obj.height - 1)) { _scrollRegion[0] = (obj.height - 1); }
2257 - if (_scrollRegion[1] < 0) { _scrollRegion[1] = 0; }
2258 - if (_scrollRegion[1] > (obj.height - 1)) { _scrollRegion[1] = (obj.height - 1); }
2259 - if (_scrollRegion[0] > _scrollRegion[1]) { _scrollRegion[0] = _scrollRegion[1]; }
2260 - break;
2261 - case 'S': // Scroll up the scroll region X lines, default 1
2262 - var x = 1;
2263 - if (argslen == 1) { x = args[0] }
2264 - for (var y = _scrollRegion[0]; y <= _scrollRegion[1] - x; y++) {
2265 - for (var z = 0; z < obj.width; z++) { _tscreen[y][z] = _tscreen[y + x][z]; _scratt[y][z] = _scratt[y + x][z]; }
2266 - }
2267 - for (var y = _scrollRegion[1] - x + 1; y < _scrollRegion[1]; y++) {
2268 - for (var z = 0; z < obj.width; z++) { _tscreen[y][z] = ' '; _scratt[y][z] = (7 << 6); }
2269 - }
2270 - break;
2271 - case 'M': // Delete X lines, default 1
2272 - var x = 1;
2273 - if (argslen == 1) { x = args[0] }
2274 - for (var y = _termy; y <= _scrollRegion[1] - x; y++) {
2275 - for (var z = 0; z < obj.width; z++) { _tscreen[y][z] = _tscreen[y + x][z]; _scratt[y][z] = _scratt[y + x][z]; }
2276 - }
2277 - for (var y = _scrollRegion[1] - x + 1; y < _scrollRegion[1]; y++) {
2278 - for (var z = 0; z < obj.width; z++) { _tscreen[y][z] = ' '; _scratt[y][z] = (7 << 6); }
2279 - }
2280 - break;
2281 - case 'T': // Scroll down the scroll region X lines, default 1
2282 - var x = 1;
2283 - if (argslen == 1) { x = args[0] }
2284 - for (var y = _scrollRegion[1]; y > _scrollRegion[0] + x; y--) {
2285 - for (var z = 0; z < obj.width; z++) { _tscreen[y][z] = _tscreen[y - x][z]; _scratt[y][z] = _scratt[y - x][z]; }
2286 - }
2287 - for (var y = _scrollRegion[0] + x; y > _scrollRegion[0]; y--) {
2288 - for (var z = 0; z < obj.width; z++) { _tscreen[y][z] = ' '; _scratt[y][z] = (7 << 6); }
2289 - }
2290 - break;
2291 - case 'X': // Erase X characters, default 1 (untested)
2292 - var x = 1;
2293 - if (argslen == 1) { x = args[0] }
2294 - while ((x > 0) && (_termx > 0)) { _tscreen[_termy][_termx] = ' '; _termx--; x--; }
2295 - break;
2296 - default:
2297 - //if (code != '@') alert(code);
2298 - console.log('unknown terminal code', code, args, mode);
2299 - break;
2300 - }
2301 - }
2302 - }
2303 -
2304 - obj.ProcessVt100String = function (str) {
2305 - for (var i = 0; i < str.length; i++) _ProcessVt100Char(String.fromCharCode(str.charCodeAt(i)));
2306 - }
2307 -
2308 -
2309 -
2310 -
2311 - function _ProcessVt100Char(c) {
2312 - if (c == '\0' || c.charCodeAt() == 7) return; // Ignore null & bell
2313 - var ch = c.charCodeAt();
2314 - //console.log('_ProcessVt100Char', ch, c);
2315 -
2316 -
2317 -
2318 -
2319 - //if (ch < 32 && ch != 10 && ch != 13) alert(ch);
2320 - switch (ch) {
2321 - case 16: { c = ' '; break; } // This is an odd char that show up on Intel BIOS's.
2322 - case 24: { c = '↑'; break; }
2323 - case 25: { c = '↓'; break; }
2324 - }
2325 -
2326 - if (_termx > obj.width) _termx = obj.width;
2327 - if (_termy > (obj.height - 1)) _termy = (obj.height - 1);
2328 -
2329 - switch (c) {
2330 - case '\b': // Backspace
2331 - if (_termx > 0) {
2332 - _termx--;
2333 - if (_backSpaceErase) { _TermDrawChar(' '); }
2334 - }
2335 - break;
2336 - case '\t': // tab
2337 - var tab = 8 - (_termx % 8)
2338 - for (var x = 0; x < tab; x++) _ProcessVt100Char(" ");
2339 - break;
2340 - case '\n': // Linefeed
2341 - _termy++;
2342 - if (_termy > _scrollRegion[1]) {
2343 - // Move everything up one line
2344 - obj.recordLineTobackBuffer(0);
2345 - _TermMoveUp(1);
2346 - _termy = _scrollRegion[1];
2347 - }
2348 - if (obj.lineFeed = '\r') { _termx = 0; } // *** If we are in Linux mode, \n will also return the cursor to the first col
2349 - break;
2350 - case '\r': // Carriage Return
2351 - _termx = 0;
2352 - break;
2353 - default:
2354 - if (_termx >= obj.width) {
2355 - _termx = 0;
2356 - if (_TermLineWrap) { _termy++; }
2357 - if (_termy >= (obj.height - 1)) { _TermMoveUp(1); _termy = (obj.height - 1); }
2358 - }
2359 - _TermDrawChar(c);
2360 - _termx++;
2361 - break;
2362 - }
2363 - }
2364 -
2365 - function _TermDrawChar(c) {
2366 - _tscreen[_termy][_termx] = c;
2367 - _scratt[_termy][_termx] = (_TermCurrentFColor << 6) + (_TermCurrentBColor << 12) + _TermCurrentReverse;
2368 - }
2369 -
2370 - obj.TermClear = function(TermColor) {
2371 - for (var y = 0; y < obj.height; y++) {
2372 - for (var x = 0; x < obj.width; x++) {
2373 - _tscreen[y][x] = ' ';
2374 - _scratt[y][x] = TermColor;
2375 - }
2376 - }
2377 - scrollBackBuffer = [];
2378 - }
2379 -
2380 - obj.TermResetScreen = function () {
2381 - _TermCurrentReverse = 0;
2382 - _TermCurrentFColor = 7;
2383 - _TermCurrentBColor = 0;
2384 - _TermLineWrap = _cursorVisible = true;
2385 - _termx = _termy = 0;
2386 - _backSpaceErase = false;
2387 - _scrollRegion = [0, (obj.height - 1)];
2388 - _altKeypadMode = false;
2389 - obj.TermClear(7 << 6);
2390 - }
2391 -
2392 - function _EraseCursorToEol() {
2393 - var t = (_TermCurrentFColor << 6) + (_TermCurrentBColor << 12) + _TermCurrentReverse;
2394 - for (var x = _termx; x < obj.width; x++) {
2395 - _tscreen[_termy][x] = ' ';
2396 - _scratt[_termy][x] = t;
2397 - }
2398 - }
2399 -
2400 - function _EraseBolToCursor() {
2401 - var t = (_TermCurrentFColor << 6) + (_TermCurrentBColor << 12) + _TermCurrentReverse;
2402 - for (var x = 0; x < _termx; x++) {
2403 - _tscreen[_termy][x] = ' ';
2404 - _scratt[_termy][x] = t;
2405 - }
2406 - }
2407 -
2408 - function _EraseLine(line) {
2409 - var t = (_TermCurrentFColor << 6) + (_TermCurrentBColor << 12) + _TermCurrentReverse;
2410 - for (var x = 0; x < obj.width; x++) {
2411 - _tscreen[line][x] = ' ';
2412 - _scratt[line][x] = t;
2413 - }
2414 - }
2415 -
2416 - obj.TermSendKeys = function (keys) { if (obj.debugmode == 2) { console.log("TSend(" + keys.length + "): " + rstr2hex(keys), keys); } obj.parent.send(keys); }
2417 - obj.TermSendKey = function (key) { if (obj.debugmode == 2) { console.log("TSend(1): " + rstr2hex(String.fromCharCode(key)), key); } obj.parent.send(String.fromCharCode(key)); }
2418 -
2419 - function _TermMoveUp(linecount) {
2420 - var x, y;
2421 - for (y = _scrollRegion[0]; y <= _scrollRegion[1] - linecount; y++) {
2422 - _tscreen[y] = _tscreen[y + linecount];
2423 - _scratt[y] = _scratt[y + linecount];
2424 - }
2425 - for (y = _scrollRegion[1] - linecount + 1; y <= _scrollRegion[1]; y++) {
2426 - _tscreen[y] = [];
2427 - _scratt[y] = [];
2428 - for (x = 0; x < obj.width; x++) {
2429 - _tscreen[y][x] = ' ';
2430 - _scratt[y][x] = (7 << 6);
2431 - }
2432 - }
2433 - }
2434 -
2435 - obj.TermHandleKeys = function (e) {
2436 - if (!e.ctrlKey) {
2437 - if (e.which == 127) obj.TermSendKey(8);
2438 - else if (e.which == 13) { obj.TermSendKeys(obj.lineFeed); }
2439 - else if (e.which != 0) obj.TermSendKey(e.which);
2440 - return false;
2441 - }
2442 - if (e.preventDefault) e.preventDefault();
2443 - if (e.stopPropagation) e.stopPropagation();
2444 - }
2445 -
2446 - obj.TermHandleKeyUp = function (e) {
2447 - if ((e.which != 8) && (e.which != 32) && (e.which != 9)) return true;
2448 - if (e.preventDefault) e.preventDefault();
2449 - if (e.stopPropagation) e.stopPropagation();
2450 - return false;
2451 - }
2452 -
2453 - obj.TermHandleKeyDown = function (e) {
2454 - if ((e.which >= 65) && (e.which <= 90) && (e.ctrlKey == true)) {
2455 - obj.TermSendKey(e.which - 64);
2456 - if (e.preventDefault) e.preventDefault();
2457 - if (e.stopPropagation) e.stopPropagation();
2458 - return;
2459 - }
2460 - if (e.which == 27) { obj.TermSendKeys(String.fromCharCode(27)); return true; }; // ESC
2461 -
2462 - if (_altKeypadMode == true) {
2463 - if (e.which == 37) { obj.TermSendKeys(String.fromCharCode(27, 79, 68)); return true; }; // Left
2464 - if (e.which == 38) { obj.TermSendKeys(String.fromCharCode(27, 79, 65)); return true; }; // Up
2465 - if (e.which == 39) { obj.TermSendKeys(String.fromCharCode(27, 79, 67)); return true; }; // Right
2466 - if (e.which == 40) { obj.TermSendKeys(String.fromCharCode(27, 79, 66)); return true; }; // Down
2467 - } else {
2468 - if (e.which == 37) { obj.TermSendKeys(String.fromCharCode(27, 91, 68)); return true; }; // Left
2469 - if (e.which == 38) { obj.TermSendKeys(String.fromCharCode(27, 91, 65)); return true; }; // Up
2470 - if (e.which == 39) { obj.TermSendKeys(String.fromCharCode(27, 91, 67)); return true; }; // Right
2471 - if (e.which == 40) { obj.TermSendKeys(String.fromCharCode(27, 91, 66)); return true; }; // Down
2472 - }
2473 -
2474 - if (e.which == 33) { obj.TermSendKeys(String.fromCharCode(27, 91, 53, 126)); return true; }; // PageUp
2475 - if (e.which == 34) { obj.TermSendKeys(String.fromCharCode(27, 91, 54, 126)); return true; }; // PageDown
2476 - if (e.which == 35) { obj.TermSendKeys(String.fromCharCode(27, 91, 70)); return true; }; // End
2477 - if (e.which == 36) { obj.TermSendKeys(String.fromCharCode(27, 91, 72)); return true; }; // Home
2478 - if (e.which == 45) { obj.TermSendKeys(String.fromCharCode(27, 91, 50, 126)); return true; }; // Insert
2479 - if (e.which == 46) { obj.TermSendKeys(String.fromCharCode(27, 91, 51, 126)); return true; }; // Delete
2480 -
2481 - if (e.which == 9) { obj.TermSendKeys("\t"); if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return true; }; // TAB
2482 -
2483 - // F1 to F12 keys
2484 -
2485 - if (e.which != 8 && e.which != 32 && e.which != 9) return true;
2486 - obj.TermSendKey(e.which);
2487 - if (e.preventDefault) e.preventDefault();
2488 - if (e.stopPropagation) e.stopPropagation();
2489 - return false;
2490 - }
2491 -
2492 - obj.recordLineTobackBuffer = function(y) {
2493 - var closetag = '', buf = '';
2494 - var r = obj.TermDrawLine(buf, y, closetag);
2495 - buf = r[0];
2496 - closetag = r[1];
2497 - scrollBackBuffer.push(buf + closetag + '<br>');
2498 - }
2499 -
2500 - obj.TermDrawLine = function (buf, y, closetag) {
2501 - var newat, c, oldat = 1, x1, x2;
2502 - for (var x = 0; x < obj.width; ++x) {
2503 - newat = _scratt[y][x];
2504 - if (_termx == x && _termy == y && _cursorVisible) { newat |= _VTREVERSE; } // If this is the cursor location, reverse the color.
2505 - if (newat != oldat) {
2506 - buf += closetag;
2507 - closetag = '';
2508 - x1 = 6; x2 = 12;
2509 - if (newat & _VTREVERSE) { x1 = 12; x2 = 6; }
2510 - buf += '<span style="color:#' + _TermColors[(newat >> x1) & 0x3F] + ';background-color:#' + _TermColors[(newat >> x2) & 0x3F];
2511 - if (newat & _VTUNDERLINE) buf += ';text-decoration:underline';
2512 - buf += ';">';
2513 - closetag = "</span>" + closetag;
2514 - oldat = newat;
2515 - }
2516 -
2517 - c = _tscreen[y][x];
2518 - switch (c) {
2519 - case '&': buf += '&amp;'; break;
2520 - case '<': buf += '&lt;'; break;
2521 - case '>': buf += '&gt;'; break;
2522 - case ' ': buf += '&nbsp;'; break;
2523 - default: buf += c; break;
2524 - }
2525 - }
2526 - return [buf, closetag];
2527 - }
2528 -
2529 - obj.TermDraw = function() {
2530 - var closetag = '', buf = '';
2531 - for (var y = 0; y < obj.height; ++y) {
2532 - var r = obj.TermDrawLine(buf, y, closetag);
2533 - buf = r[0];
2534 - closetag = r[1];
2535 - if (y != (obj.height - 1)) buf += '<br>';
2536 - }
2537 -
2538 - if (scrollBackBuffer.length > 800) { scrollBackBuffer = scrollBackBuffer.slice(scrollBackBuffer.length - 800); }
2539 - var backbuffer = scrollBackBuffer.join('');
2540 - obj.DivElement.innerHTML = "<font size='4'><b>" + backbuffer + buf + closetag + "</b></font>";
2541 - obj.DivElement.scrollTop = obj.DivElement.scrollHeight;
2542 - if (obj.heightLock == 0) { setTimeout(obj.TermLockHeight, 10); }
2543 - }
2544 -
2545 - obj.TermLockHeight = function () {
2546 - obj.heightLock = obj.DivElement.clientHeight;
2547 - obj.DivElement.style['height'] = obj.DivElement.parentNode.style['height'] = obj.heightLock + 'px';
2548 - obj.DivElement.style['overflow-y'] = 'scroll';
2549 - }
2550 -
2551 - obj.TermInit = function () { obj.TermResetScreen(); }
2552 -
2553 - obj.heightLock = 0;
2554 - obj.DivElement.style['height'] = '';
2555 - if ((options != null) && (options.width != null) && (options.height != null)) { obj.Init(options.width, options.height); } else { obj.Init(); }
2556 - return obj;
2557 -}/* zlib.js -- JavaScript implementation for the zlib.
2558 - Version: 0.2.0
2559 - LastModified: Apr 12 2012
2560 - Copyright (C) 2012 Masanao Izumo <iz@onicos.co.jp>
2561 -
2562 - The original copyright notice (zlib 1.2.6):
2563 -
2564 - Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler
2565 -
2566 - This software is provided 'as-is', without any express or implied
2567 - warranty. In no event will the authors be held liable for any damages
2568 - arising from the use of this software.
2569 -
2570 - Permission is granted to anyone to use this software for any purpose,
2571 - including commercial applications, and to alter it and redistribute it
2572 - freely, subject to the following restrictions:
2573 -
2574 - 1. The origin of this software must not be misrepresented; you must not
2575 - claim that you wrote the original software. If you use this software
2576 - in a product, an acknowledgment in the product documentation would be
2577 - appreciated but is not required.
2578 - 2. Altered source versions must be plainly marked as such, and must not be
2579 - misrepresented as being the original software.
2580 - 3. This notice may not be removed or altered from any source distribution.
2581 -
2582 - Jean-loup Gailly Mark Adler
2583 - jloup@gzip.org madler@alumni.caltech.edu
2584 -
2585 -
2586 - The data format used by the zlib library is described by RFCs (Request for
2587 - Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
2588 - (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
2589 -*/
2590 -
2591 -var ZLIB = ( ZLIB || {} ); // ZLIB namespace initialization
2592 -
2593 -// common definitions
2594 -if(typeof ZLIB.common_initialized === 'undefined') {
2595 - ZLIB.Z_NO_FLUSH = 0;
2596 - ZLIB.Z_PARTIAL_FLUSH = 1;
2597 - ZLIB.Z_SYNC_FLUSH = 2;
2598 - ZLIB.Z_FULL_FLUSH = 3;
2599 - ZLIB.Z_FINISH = 4;
2600 - ZLIB.Z_BLOCK = 5;
2601 - ZLIB.Z_TREES = 6;
2602 - /* Allowed flush values; see deflate() and inflate() below for details */
2603 -
2604 - ZLIB.Z_OK = 0;
2605 - ZLIB.Z_STREAM_END = 1;
2606 - ZLIB.Z_NEED_DICT = 2;
2607 - ZLIB.Z_ERRNO = (-1);
2608 - ZLIB.Z_STREAM_ERROR = (-2);
2609 - ZLIB.Z_DATA_ERROR = (-3);
2610 - ZLIB.Z_MEM_ERROR = (-4);
2611 - ZLIB.Z_BUF_ERROR = (-5);
2612 - ZLIB.Z_VERSION_ERROR = (-6);
2613 - /* Return codes for the compression/decompression functions. Negative values
2614 - * are errors, positive values are used for special but normal events.
2615 - */
2616 -
2617 - ZLIB.Z_DEFLATED = 8; /* The deflate compression method (the only one supported in this version) */
2618 -
2619 - /**
2620 - * z_stream constructor
2621 - * @constructor
2622 - */
2623 - ZLIB.z_stream = function() {
2624 - this.next_in = 0; /* next input byte */
2625 - this.avail_in = 0; /* number of bytes available in input_data */
2626 - this.total_in = 0; /* total number of input bytes read so far */
2627 -
2628 - this.next_out = 0; /* next output byte */
2629 - this.avail_out = 0; /* remaining free space at next_out */
2630 - this.total_out = 0; /* total number of bytes output so far */
2631 -
2632 - this.msg = null; /* last error message, null if no error */
2633 - this.state = null; /* not visible by applications */
2634 -
2635 - this.data_type = 0; /* best guess about the data type: binary or text */
2636 - this.adler = 0; /* TODO: adler32 value of the uncompressed data */
2637 -
2638 - // zlib.js
2639 - this.input_data = ''; /* input data */
2640 - this.output_data = ''; /* output data */
2641 - this.error = 0; /* error code */
2642 - this.checksum_function = null; /* crc32(for gzip) or adler32(for zlib) */
2643 - };
2644 -
2645 - /**
2646 - * TODO
2647 - * @constructor
2648 - */
2649 - ZLIB.gz_header = function() {
2650 - this.text = 0; /* true if compressed data believed to be text */
2651 - this.time = 0; /* modification time */
2652 - this.xflags = 0; /* extra flags (not used when writing a gzip file) */
2653 - this.os = 0xff; /* operating system */
2654 - this.extra = null; /* extra field string or null if none */
2655 - this.extra_len = 0; /* this.extra.length (only when reading header) */
2656 - this.extra_max = 0; /* space at extra (only when reading header) */
2657 - this.name = null; /* file name string or null if none */
2658 - this.name_max = 0; /* space at name (only when reading header) */
2659 - this.comment = null; /* comment string or null if none */
2660 - this.comm_max = 0; /* space at comment (only when reading header) */
2661 - this.hcrc = 0; /* true if there was or will be a header crc */
2662 - this.done = 0; /* true when done reading gzip header (not used
2663 - when writing a gzip file) */
2664 - };
2665 -
2666 - ZLIB.common_initialized = true;
2667 -} // common definitions
2668 -/* zlib-inflate.js -- JavaScript implementation for the zlib inflate.
2669 - Version: 0.2.0
2670 - LastModified: Apr 12 2012
2671 - Copyright (C) 2012 Masanao Izumo <iz@onicos.co.jp>
2672 -
2673 - This library is one of the JavaScript zlib implementation.
2674 - Some API's are modified from the original.
2675 - Only inflate API is implemented.
2676 -
2677 - The original copyright notice (zlib 1.2.6):
2678 -
2679 - Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler
2680 -
2681 - This software is provided 'as-is', without any express or implied
2682 - warranty. In no event will the authors be held liable for any damages
2683 - arising from the use of this software.
2684 -
2685 - Permission is granted to anyone to use this software for any purpose,
2686 - including commercial applications, and to alter it and redistribute it
2687 - freely, subject to the following restrictions:
2688 -
2689 - 1. The origin of this software must not be misrepresented; you must not
2690 - claim that you wrote the original software. If you use this software
2691 - in a product, an acknowledgment in the product documentation would be
2692 - appreciated but is not required.
2693 - 2. Altered source versions must be plainly marked as such, and must not be
2694 - misrepresented as being the original software.
2695 - 3. This notice may not be removed or altered from any source distribution.
2696 -
2697 - Jean-loup Gailly Mark Adler
2698 - jloup@gzip.org madler@alumni.caltech.edu
2699 -
2700 -
2701 - The data format used by the zlib library is described by RFCs (Request for
2702 - Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
2703 - (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
2704 -*/
2705 -
2706 -/*
2707 - API documentation
2708 -==============================================================================
2709 -Usage: z_stream = ZLIB.inflateInit([windowBits]);
2710 -
2711 - Create the stream object for decompression.
2712 - See zlib.h for windowBits information.
2713 -
2714 -==============================================================================
2715 -Usage: decoded_string = z_stream.inflate(encoded_string [, {OPTIONS...}]);
2716 -
2717 -OPTIONS:
2718 - next_in: decode start offset for encoded_string.
2719 -
2720 - avail_in: // TODO document. See zlib.h for the information.
2721 -
2722 - avail_out: // TODO document. See zlib.h for the information.
2723 -
2724 - flush: // TODO document. See zlib.h for the information.
2725 -
2726 -Ex: decoded_string = z_stream.inflate(encoded_string);
2727 - decoded_string = z_stream.inflate(encoded_string,
2728 - {next_in: 0,
2729 - avail_in: encoded_string.length,
2730 - avail_out: 1024,
2731 - flush: ZLIB.Z_NO_FLUSH});
2732 -
2733 - See zlib.h for more information.
2734 -
2735 -==============================================================================
2736 -Usage: z_stream.inflateReset();
2737 - TODO document
2738 -
2739 -*/
2740 -
2741 -if( typeof ZLIB === 'undefined' ) {
2742 - alert('ZLIB is not defined. SRC zlib.js before zlib-inflate.js')
2743 -}
2744 -
2745 -(function() {
2746 -
2747 -/* inflate.c -- zlib decompression
2748 - * Copyright (C) 1995-2011 Mark Adler
2749 - * For conditions of distribution and use, see copyright notice in zlib.h
2750 - */
2751 -
2752 -var DEF_WBITS = 15;
2753 -
2754 -// inflate_mode
2755 -var HEAD = 0; /* i: waiting for magic header */
2756 -var FLAGS = 1; /* i: waiting for method and flags (gzip) */
2757 -var TIME = 2; /* i: waiting for modification time (gzip) */
2758 -var OS = 3; /* i: waiting for extra flags and operating system (gzip) */
2759 -var EXLEN = 4; /* i: waiting for extra length (gzip) */
2760 -var EXTRA = 5; /* i: waiting for extra bytes (gzip) */
2761 -var NAME = 6; /* i: waiting for end of file name (gzip) */
2762 -var COMMENT = 7; /* i: waiting for end of comment (gzip) */
2763 -var HCRC = 8; /* i: waiting for header crc (gzip) */
2764 -var DICTID = 9; /* i: waiting for dictionary check value */
2765 -var DICT = 10; /* waiting for inflateSetDictionary() call */
2766 -var TYPE = 11; /* i: waiting for type bits, including last-flag bit */
2767 -var TYPEDO = 12; /* i: same, but skip check to exit inflate on new block */
2768 -var STORED = 13; /* i: waiting for stored size (length and complement) */
2769 -var COPY_ = 14; /* i/o: same as COPY below, but only first time in */
2770 -var COPY = 15; /* i/o: waiting for input or output to copy stored block */
2771 -var TABLE = 16; /* i: waiting for dynamic block table lengths */
2772 -var LENLENS = 17; /* i: waiting for code length code lengths */
2773 -var CODELENS = 18; /* i: waiting for length/lit and distance code lengths */
2774 -var LEN_ = 19; /* i: same as LEN below, but only first time in */
2775 -var LEN = 20; /* i: waiting for length/lit/eob code */
2776 -var LENEXT = 21; /* i: waiting for length extra bits */
2777 -var DIST = 22; /* i: waiting for distance code */
2778 -var DISTEXT = 23; /* i: waiting for distance extra bits */
2779 -var MATCH = 24; /* o: waiting for output space to copy string */
2780 -var LIT = 25; /* o: waiting for output space to write literal */
2781 -var CHECK = 26; /* i: waiting for 32-bit check value */
2782 -var LENGTH = 27; /* i: waiting for 32-bit length (gzip) */
2783 -var DONE = 28; /* finished check, done -- remain here until reset */
2784 -var BAD = 29; /* got a data error -- remain here until reset */
2785 -var MEM = 30; /* got an inflate() memory error -- remain here until reset */
2786 -var SYNC = 31; /* looking for synchronization bytes to restart inflate() */
2787 -
2788 -/* Maximum size of the dynamic table. The maximum number of code structures is
2789 - 1444, which is the sum of 852 for literal/length codes and 592 for distance
2790 - codes. These values were found by exhaustive searches using the program
2791 - examples/enough.c found in the zlib distribtution. The arguments to that
2792 - program are the number of symbols, the initial root table size, and the
2793 - maximum bit length of a code. "enough 286 9 15" for literal/length codes
2794 - returns returns 852, and "enough 30 6 15" for distance codes returns 592.
2795 - The initial root table size (9 or 6) is found in the fifth argument of the
2796 - inflate_table() calls in inflate.c and infback.c. If the root table size is
2797 - changed, then these maximum sizes would be need to be recalculated and
2798 - updated. */
2799 -var ENOUGH_LENS = 852;
2800 -var ENOUGH_DISTS = 592;
2801 -var ENOUGH = (ENOUGH_LENS + ENOUGH_DISTS);
2802 -
2803 -/* Type of code to build for inflate_table() */
2804 -var CODES = 0;
2805 -var LENS = 1;
2806 -var DISTS = 2;
2807 -
2808 -
2809 -
2810 -var inflate_table_lbase = [ /* Length codes 257..285 base */
2811 - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
2812 - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0];
2813 -var inflate_table_lext = [ /* Length codes 257..285 extra */
2814 - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
2815 - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 69];
2816 -var inflate_table_dbase = [ /* Distance codes 0..29 base */
2817 - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
2818 - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
2819 - 8193, 12289, 16385, 24577, 0, 0];
2820 -var inflate_table_dext = [ /* Distance codes 0..29 extra */
2821 - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
2822 - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
2823 - 28, 28, 29, 29, 64, 64];
2824 -
2825 -/* inftrees.c -- generate Huffman trees for efficient decoding
2826 - * Copyright (C) 1995-2012 Mark Adler
2827 - * For conditions of distribution and use, see copyright notice in zlib.h
2828 - */
2829 -
2830 -ZLIB.inflate_copyright =
2831 - ' inflate 1.2.6 Copyright 1995-2012 Mark Adler ';
2832 -/*
2833 - If you use the zlib library in a product, an acknowledgment is welcome
2834 - in the documentation of your product. If for some reason you cannot
2835 - include such an acknowledgment, I would appreciate that you keep this
2836 - copyright string in the executable of your product.
2837 - */
2838 -
2839 -/*
2840 - Build a set of tables to decode the provided canonical Huffman code.
2841 - The code lengths are lens[0..codes-1]. The result starts at *table,
2842 - whose indices are 0..2^bits-1. work is a writable array of at least
2843 - lens shorts, which is used as a work area. type is the type of code
2844 - to be generated, CODES, LENS, or DISTS. On return, zero is success,
2845 - -1 is an invalid code, and +1 means that ENOUGH isn't enough. table
2846 - on return points to the next available entry's address. bits is the
2847 - requested root table index bits, and on return it is the actual root
2848 - table index bits. It will differ if the request is greater than the
2849 - longest code or if it is less than the shortest code.
2850 -*/
2851 -function inflate_table(state, type)
2852 -{
2853 - var MAXBITS = 15;
2854 - var table = state.next;
2855 - var bits = (type == DISTS ? state.distbits : state.lenbits);
2856 - var work = state.work;
2857 - var lens = state.lens;
2858 - var lens_offset = (type == DISTS ? state.nlen : 0);
2859 - var state_codes = state.codes;
2860 - var codes;
2861 - if(type == LENS)
2862 - codes = state.nlen;
2863 - else if(type == DISTS)
2864 - codes = state.ndist;
2865 - else // CODES
2866 - codes = 19;
2867 -
2868 - var len; /* a code's length in bits */
2869 - var sym; /* index of code symbols */
2870 - var min, max; /* minimum and maximum code lengths */
2871 - var root; /* number of index bits for root table */
2872 - var curr; /* number of index bits for current table */
2873 - var drop; /* code bits to drop for sub-table */
2874 - var left; /* number of prefix codes available */
2875 - var used; /* code entries in table used */
2876 - var huff; /* Huffman code */
2877 - var incr; /* for incrementing code, index */
2878 - var fill; /* index for replicating entries */
2879 - var low; /* low bits for current root entry */
2880 - var mask; /* mask for low root bits */
2881 - var here; /* table entry for duplication */
2882 - var next; /* next available space in table */
2883 - var base; /* base value table to use */
2884 - var base_offset;
2885 - var extra; /* extra bits table to use */
2886 - var extra_offset;
2887 - var end; /* use base and extra for symbol > end */
2888 - var count = new Array(MAXBITS+1); /* number of codes of each length */
2889 - var offs = new Array(MAXBITS+1); /* offsets in table for each length */
2890 -
2891 - /*
2892 - Process a set of code lengths to create a canonical Huffman code. The
2893 - code lengths are lens[0..codes-1]. Each length corresponds to the
2894 - symbols 0..codes-1. The Huffman code is generated by first sorting the
2895 - symbols by length from short to long, and retaining the symbol order
2896 - for codes with equal lengths. Then the code starts with all zero bits
2897 - for the first code of the shortest length, and the codes are integer
2898 - increments for the same length, and zeros are appended as the length
2899 - increases. For the deflate format, these bits are stored backwards
2900 - from their more natural integer increment ordering, and so when the
2901 - decoding tables are built in the large loop below, the integer codes
2902 - are incremented backwards.
2903 -
2904 - This routine assumes, but does not check, that all of the entries in
2905 - lens[] are in the range 0..MAXBITS. The caller must assure this.
2906 - 1..MAXBITS is interpreted as that code length. zero means that that
2907 - symbol does not occur in this code.
2908 -
2909 - The codes are sorted by computing a count of codes for each length,
2910 - creating from that a table of starting indices for each length in the
2911 - sorted table, and then entering the symbols in order in the sorted
2912 - table. The sorted table is work[], with that space being provided by
2913 - the caller.
2914 -
2915 - The length counts are used for other purposes as well, i.e. finding
2916 - the minimum and maximum length codes, determining if there are any
2917 - codes at all, checking for a valid set of lengths, and looking ahead
2918 - at length counts to determine sub-table sizes when building the
2919 - decoding tables.
2920 - */
2921 -
2922 - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
2923 - for (len = 0; len <= MAXBITS; len++)
2924 - count[len] = 0;
2925 - for (sym = 0; sym < codes; sym++)
2926 - count[lens[lens_offset + sym]]++;
2927 -
2928 - /* bound code lengths, force root to be within code lengths */
2929 - root = bits;
2930 -
2931 - for (max = MAXBITS; max >= 1; max--)
2932 - if (count[max] != 0) break;
2933 - if (root > max) root = max;
2934 - if (max == 0) {
2935 - /* no symbols to code at all */
2936 - /* invalid code marker */
2937 - here = {op:64, bits:1, val:0};
2938 - state_codes[table++] = here; /* make a table to force an error */
2939 - state_codes[table++] = here;
2940 - if(type == DISTS) state.distbits = 1; else state.lenbits = 1; // *bits = 1;
2941 - state.next = table;
2942 - return 0; /* no symbols, but wait for decoding to report error */
2943 - }
2944 - for (min = 1; min < max; min++)
2945 - if (count[min] != 0) break;
2946 - if (root < min) root = min;
2947 -
2948 - /* check for an over-subscribed or incomplete set of lengths */
2949 - left = 1;
2950 - for (len = 1; len <= MAXBITS; len++) {
2951 - left <<= 1;
2952 - left -= count[len];
2953 - if (left < 0) return -1; /* over-subscribed */
2954 - }
2955 - if (left > 0 && (type == CODES || max != 1)) {
2956 - state.next = table;
2957 - return -1; /* incomplete set */
2958 - }
2959 -
2960 - /* generate offsets into symbol table for each length for sorting */
2961 - offs[1] = 0;
2962 - for (len = 1; len < MAXBITS; len++)
2963 - offs[len + 1] = offs[len] + count[len];
2964 -
2965 - /* sort symbols by length, by symbol order within each length */
2966 - for (sym = 0; sym < codes; sym++)
2967 - if (lens[lens_offset + sym] != 0) work[offs[lens[lens_offset + sym]]++] = sym;
2968 -
2969 - /*
2970 - Create and fill in decoding tables. In this loop, the table being
2971 - filled is at next and has curr index bits. The code being used is huff
2972 - with length len. That code is converted to an index by dropping drop
2973 - bits off of the bottom. For codes where len is less than drop + curr,
2974 - those top drop + curr - len bits are incremented through all values to
2975 - fill the table with replicated entries.
2976 -
2977 - root is the number of index bits for the root table. When len exceeds
2978 - root, sub-tables are created pointed to by the root entry with an index
2979 - of the low root bits of huff. This is saved in low to check for when a
2980 - new sub-table should be started. drop is zero when the root table is
2981 - being filled, and drop is root when sub-tables are being filled.
2982 -
2983 - When a new sub-table is needed, it is necessary to look ahead in the
2984 - code lengths to determine what size sub-table is needed. The length
2985 - counts are used for this, and so count[] is decremented as codes are
2986 - entered in the tables.
2987 -
2988 - used keeps track of how many table entries have been allocated from the
2989 - provided *table space. It is checked for LENS and DIST tables against
2990 - the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
2991 - the initial root table size constants. See the comments in inftrees.h
2992 - for more information.
2993 -
2994 - sym increments through all symbols, and the loop terminates when
2995 - all codes of length max, i.e. all codes, have been processed. This
2996 - routine permits incomplete codes, so another loop after this one fills
2997 - in the rest of the decoding tables with invalid code markers.
2998 - */
2999 -
3000 - /* set up for code type */
3001 - switch (type) {
3002 - case CODES:
3003 - base = extra = work; /* dummy value--not used */
3004 - base_offset = 0;
3005 - extra_offset = 0;
3006 - end = 19;
3007 - break;
3008 - case LENS:
3009 - base = inflate_table_lbase;
3010 - base_offset = -257; // base -= 257;
3011 - extra = inflate_table_lext;
3012 - extra_offset = -257; // extra -= 257;
3013 - end = 256;
3014 - break;
3015 - default: /* DISTS */
3016 - base = inflate_table_dbase;
3017 - extra = inflate_table_dext;
3018 - base_offset = 0;
3019 - extra_offset = 0;
3020 - end = -1;
3021 - }
3022 -
3023 - /* initialize state for loop */
3024 - huff = 0; /* starting code */
3025 - sym = 0; /* starting code symbol */
3026 - len = min; /* starting code length */
3027 - next = table; /* current table to fill in */
3028 - curr = root; /* current table index bits */
3029 - drop = 0; /* current bits to drop from code for index */
3030 - low = -1; /* trigger new sub-table when len > root */
3031 - used = 1 << root; /* use root table entries */
3032 - mask = used - 1; /* mask for comparing low */
3033 -
3034 - /* check available table space */
3035 - if ((type == LENS && used >= ENOUGH_LENS) ||
3036 - (type == DISTS && used >= ENOUGH_DISTS)) {
3037 - state.next = table;
3038 - return 1;
3039 - }
3040 -
3041 - /* process all codes and make table entries */
3042 - for (;;) {
3043 - /* create table entry */
3044 - here = {op:0, bits:len - drop, val:0};
3045 - if (work[sym] < end) {
3046 - here.val = work[sym];
3047 - }
3048 - else if (work[sym] > end) {
3049 - here.op = extra[extra_offset + work[sym]];
3050 - here.val = base[base_offset + work[sym]];
3051 - }
3052 - else {
3053 - here.op = 32 + 64; /* end of block */
3054 - }
3055 -
3056 - /* replicate for those indices with low len bits equal to huff */
3057 - incr = 1 << (len - drop);
3058 - fill = 1 << curr;
3059 - min = fill; /* save offset to next table */
3060 - do {
3061 - fill -= incr;
3062 - state_codes[next + (huff >>> drop) + fill] = here;
3063 - } while (fill != 0);
3064 -
3065 - /* backwards increment the len-bit code huff */
3066 - incr = 1 << (len - 1);
3067 - while (huff & incr)
3068 - incr >>>= 1;
3069 - if (incr != 0) {
3070 - huff &= incr - 1;
3071 - huff += incr;
3072 - }
3073 - else
3074 - huff = 0;
3075 -
3076 - /* go to next symbol, update count, len */
3077 - sym++;
3078 - if (--(count[len]) == 0) {
3079 - if (len == max) break;
3080 - len = lens[lens_offset + work[sym]];
3081 - }
3082 -
3083 - /* create new sub-table if needed */
3084 - if (len > root && (huff & mask) != low) {
3085 - /* if first time, transition to sub-tables */
3086 - if (drop == 0)
3087 - drop = root;
3088 -
3089 - /* increment past last table */
3090 - next += min; /* here min is 1 << curr */
3091 -
3092 - /* determine length of next table */
3093 - curr = len - drop;
3094 - left = (1 << curr);
3095 - while (curr + drop < max) {
3096 - left -= count[curr + drop];
3097 - if (left <= 0) break;
3098 - curr++;
3099 - left <<= 1;
3100 - }
3101 -
3102 - /* check for enough space */
3103 - used += 1 << curr;
3104 - if ((type == LENS && used >= ENOUGH_LENS) ||
3105 - (type == DISTS && used >= ENOUGH_DISTS)) {
3106 - state.next = table;
3107 - return 1;
3108 - }
3109 -
3110 - /* point entry in root table to sub-table */
3111 - low = huff & mask;
3112 - state_codes[table + low] = {op:curr, bits:root, val:next - table};
3113 - }
3114 - }
3115 -
3116 - /* fill in remaining table entry if code is incomplete (guaranteed to have
3117 - at most one remaining entry, since if the code is incomplete, the
3118 - maximum code length that was allowed to get this far is one bit) */
3119 - if (huff != 0) {
3120 - state_codes[next + huff] = {op:64, bits:len - drop, val:0};
3121 - }
3122 -
3123 - /* set return parameters */
3124 - state.next = table + used;
3125 - if(type == DISTS) state.distbits = root; else state.lenbits = root; //*bits = root;
3126 - return 0;
3127 -}
3128 -
3129 -/* inffast.c -- fast decoding
3130 - * Copyright (C) 1995-2008, 2010 Mark Adler
3131 - * For conditions of distribution and use, see copyright notice in zlib.h
3132 - */
3133 -
3134 -/*
3135 - Decode literal, length, and distance codes and write out the resulting
3136 - literal and match bytes until either not enough input or output is
3137 - available, an end-of-block is encountered, or a data error is encountered.
3138 - When large enough input and output buffers are supplied to inflate(), for
3139 - example, a 16K input buffer and a 64K output buffer, more than 95% of the
3140 - inflate execution time is spent in this routine.
3141 -
3142 - Entry assumptions:
3143 -
3144 - state->mode == LEN
3145 - strm->avail_in >= 6
3146 - strm->avail_out >= 258
3147 - start >= strm->avail_out
3148 - state->bits < 8
3149 -
3150 - On return, state->mode is one of:
3151 -
3152 - LEN -- ran out of enough output space or enough available input
3153 - TYPE -- reached end of block code, inflate() to interpret next block
3154 - BAD -- error in block data
3155 -
3156 - Notes:
3157 -
3158 - - The maximum input bits used by a length/distance pair is 15 bits for the
3159 - length code, 5 bits for the length extra, 15 bits for the distance code,
3160 - and 13 bits for the distance extra. This totals 48 bits, or six bytes.
3161 - Therefore if strm->avail_in >= 6, then there is enough input to avoid
3162 - checking for available input while decoding.
3163 -
3164 - - The maximum bytes that a single length/distance pair can output is 258
3165 - bytes, which is the maximum length that can be coded. inflate_fast()
3166 - requires strm->avail_out >= 258 for each loop to avoid checking for
3167 - output space.
3168 - */
3169 -function inflate_fast(strm,
3170 - start) /* inflate()'s starting value for strm->avail_out */
3171 -{
3172 - var state;
3173 - var input_data; /* local strm->input_data */
3174 - var next_in; /* zlib.js: index of input_data */
3175 - var last; /* while next_in < last, enough input available */
3176 - var out; /* local strm.next_out */
3177 - var beg; /* inflate()'s initial strm.next_out */
3178 - var end; /* while out < end, enough space available */
3179 -//NOSPRT #ifdef INFLATE_STRICT
3180 -// unsigned dmax; /* maximum distance from zlib header */
3181 -//#endif
3182 - var wsize; /* window size or zero if not using window */
3183 - var whave; /* valid bytes in the window */
3184 - var wnext; /* window write index */
3185 - var window; /* allocated sliding window, if wsize != 0 */
3186 - var hold; /* local strm->hold */
3187 - var bits; /* local strm->bits */
3188 - var codes; /* zlib.js: local state.codes */
3189 - var lcode; /* local strm->lencode */
3190 - var dcode; /* local strm->distcode */
3191 - var lmask; /* mask for first level of length codes */
3192 - var dmask; /* mask for first level of distance codes */
3193 - var here; /* retrieved table entry */
3194 - var op; /* code bits, operation, extra bits, or */
3195 - /* window position, window bytes to copy */
3196 - var len; /* match length, unused bytes */
3197 - var dist; /* match distance */
3198 - // var from; /* where to copy match from */
3199 - var from_window_offset = -1; /* index of window[] */
3200 - var from_out_offset = -1; /* index of next_out[] */
3201 -
3202 - /* copy state to local variables */
3203 - state = strm.state;
3204 - input_data = strm.input_data;
3205 - next_in = strm.next_in;
3206 - last = next_in + strm.avail_in - 5;
3207 - out = strm.next_out;
3208 - beg = out - (start - strm.avail_out);
3209 - end = out + (strm.avail_out - 257);
3210 -//NOSPRT #ifdef INFLATE_STRICT
3211 -// dmax = state->dmax;
3212 -//#endif
3213 - wsize = state.wsize;
3214 - whave = state.whave;
3215 - wnext = state.wnext;
3216 - window = state.window;
3217 - hold = state.hold;
3218 - bits = state.bits;
3219 - codes = state.codes;
3220 - lcode = state.lencode;
3221 - dcode = state.distcode;
3222 - lmask = (1 << state.lenbits) - 1;
3223 - dmask = (1 << state.distbits) - 1;
3224 -
3225 - /* decode literals and length/distances until end-of-block or not enough
3226 - input data or output space */
3227 -loop: do {
3228 - if (bits < 15) {
3229 - hold += (input_data.charCodeAt(next_in++) & 0xff) << bits;
3230 - bits += 8;
3231 - hold += (input_data.charCodeAt(next_in++) & 0xff) << bits;
3232 - bits += 8;
3233 - }
3234 - here = codes[lcode + (hold & lmask)];
3235 - dolen: while(true) {
3236 - op = here.bits;
3237 - hold >>>= op;
3238 - bits -= op;
3239 - op = here.op;
3240 - if (op == 0) { /* literal */
3241 -// Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
3242 -// "inflate: literal '%c'\n" :
3243 -// "inflate: literal 0x%02x\n", here.val));
3244 - strm.output_data += String.fromCharCode(here.val);
3245 - out++;
3246 - }
3247 - else if (op & 16) { /* length base */
3248 - len = here.val;
3249 - op &= 15; /* number of extra bits */
3250 - if (op) {
3251 - if (bits < op) {
3252 - hold += (input_data.charCodeAt(next_in++) & 0xff) << bits;
3253 - bits += 8;
3254 - }
3255 - len += hold & ((1 << op) - 1);
3256 - hold >>>= op;
3257 - bits -= op;
3258 - }
3259 -// Tracevv((stderr, "inflate: length %u\n", len));
3260 - if (bits < 15) {
3261 - hold += (input_data.charCodeAt(next_in++) & 0xff) << bits;
3262 - bits += 8;
3263 - hold += (input_data.charCodeAt(next_in++) & 0xff) << bits;
3264 - bits += 8;
3265 - }
3266 - here = codes[dcode + (hold & dmask)];
3267 - dodist: while(true) {
3268 - op = here.bits;
3269 - hold >>>= op;
3270 - bits -= op;
3271 - op = here.op;
3272 - if (op & 16) { /* distance base */
3273 - dist = here.val;
3274 - op &= 15; /* number of extra bits */
3275 - if (bits < op) {
3276 - hold += (input_data.charCodeAt(next_in++) & 0xff) << bits;
3277 - bits += 8;
3278 - if (bits < op) {
3279 - hold += (input_data.charCodeAt(next_in++) & 0xff) << bits;
3280 - bits += 8;
3281 - }
3282 - }
3283 - dist += hold & ((1 << op) - 1);
3284 -//NOSPRT #ifdef INFLATE_STRICT
3285 -// if (dist > dmax) {
3286 -// strm->msg = (char *)"invalid distance too far back";
3287 -// state->mode = BAD;
3288 -// break loop;
3289 -// }
3290 -//#endif
3291 - hold >>>= op;
3292 - bits -= op;
3293 -// Tracevv((stderr, "inflate: distance %u\n", dist));
3294 - op = out - beg; /* max distance in output */
3295 - if (dist > op) { /* see if copy from window */
3296 - op = dist - op; /* distance back in window */
3297 - if (op > whave) {
3298 - if (state.sane) {
3299 - strm.msg = 'invalid distance too far back';
3300 - state.mode = BAD;
3301 - break loop;
3302 - }
3303 -//NOSPRT #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
3304 -// if (len <= op - whave) {
3305 -// do {
3306 -// PUP(out) = 0;
3307 -// } while (--len);
3308 -// continue;
3309 -// }
3310 -// len -= op - whave;
3311 -// do {
3312 -// PUP(out) = 0;
3313 -// } while (--op > whave);
3314 -// if (op == 0) {
3315 -// from = out - dist;
3316 -// do {
3317 -// PUP(out) = PUP(from);
3318 -// } while (--len);
3319 -// continue;
3320 -// }
3321 -//#endif
3322 - } // if (op > whave)
3323 -
3324 - from_window_offset = 0;
3325 - from_out_offset = -1;
3326 - if (wnext == 0) { /* very common case */
3327 - from_window_offset += wsize - op;
3328 - if (op < len) { /* some from window */
3329 - len -= op;
3330 - strm.output_data += window.substring(from_window_offset, from_window_offset + op);
3331 - out += op;
3332 - op = 0;
3333 - from_window_offset = -1;
3334 - from_out_offset = out - dist; /* rest from output */
3335 - }
3336 - }
3337 -//NOTREACHED else if (wnext < op) { /* wrap around window */
3338 -//NOTREACHED from += wsize + wnext - op;
3339 -//NOTREACHED op -= wnext;
3340 -//NOTREACHED if (op < len) { /* some from end of window */
3341 -//NOTREACHED len -= op;
3342 -//NOTREACHED do {
3343 -//NOTREACHED PUP(out) = PUP(from);
3344 -//NOTREACHED } while (--op);
3345 -//NOTREACHED from = window - OFF;
3346 -//NOTREACHED if (wnext < len) { /* some from start of window */
3347 -//NOTREACHED op = wnext;
3348 -//NOTREACHED len -= op;
3349 -//NOTREACHED do {
3350 -//NOTREACHED PUP(out) = PUP(from);
3351 -//NOTREACHED } while (--op);
3352 -//NOTREACHED from = out - dist; /* rest from output */
3353 -//NOTREACHED }
3354 -//NOTREACHED }
3355 -//NOTREACHED }
3356 - else { /* contiguous in window */
3357 - from_window_offset += wnext - op;
3358 - if (op < len) { /* some from window */
3359 - len -= op;
3360 - strm.output_data += window.substring(from_window_offset, from_window_offset + op);
3361 - out += op;
3362 - from_window_offset = -1;
3363 - from_out_offset = out - dist; /* rest from output */
3364 - }
3365 - }
3366 - }
3367 - else {
3368 - from_window_offset = -1;
3369 - from_out_offset = out - dist; /* copy direct from output */
3370 - }
3371 -
3372 - if (from_window_offset >= 0) {
3373 - strm.output_data += window.substring(from_window_offset, from_window_offset + len);
3374 - out += len;
3375 - from_window_offset += len;
3376 - } else {
3377 - var len_inner = len;
3378 - if(len_inner > out - from_out_offset)
3379 - len_inner = out - from_out_offset;
3380 - strm.output_data += strm.output_data.substring(
3381 - from_out_offset, from_out_offset + len_inner);
3382 - out += len_inner;
3383 - len -= len_inner;
3384 - from_out_offset += len_inner;
3385 - out += len;
3386 - while (len > 2) {
3387 - strm.output_data += strm.output_data.charAt(from_out_offset++);
3388 - strm.output_data += strm.output_data.charAt(from_out_offset++);
3389 - strm.output_data += strm.output_data.charAt(from_out_offset++);
3390 - len -= 3;
3391 - }
3392 - if (len) {
3393 - strm.output_data += strm.output_data.charAt(from_out_offset++);
3394 - if (len > 1)
3395 - strm.output_data += strm.output_data.charAt(from_out_offset++);
3396 - }
3397 - }
3398 - }
3399 - else if ((op & 64) == 0) { /* 2nd level distance code */
3400 - here = codes[dcode + (here.val + (hold & ((1 << op) - 1)))];
3401 - continue dodist; // goto dodist
3402 - }
3403 - else {
3404 - strm.msg = 'invalid distance code';
3405 - state.mode = BAD;
3406 - break loop;
3407 - }
3408 - break dodist; }
3409 - }
3410 - else if ((op & 64) == 0) { /* 2nd level length code */
3411 - here = codes[lcode + (here.val + (hold & ((1 << op) - 1)))];
3412 - continue dolen; // goto dolen;
3413 - }
3414 - else if (op & 32) { /* end-of-block */
3415 - // Tracevv((stderr, "inflate: end of block\n"));
3416 - state.mode = TYPE;
3417 - break loop;
3418 - }
3419 - else {
3420 - strm.msg = 'invalid literal/length code';
3421 - state.mode = BAD;
3422 - break loop;
3423 - }
3424 - break dolen; }
3425 - } while (next_in < last && out < end);
3426 -
3427 - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
3428 - len = bits >>> 3;
3429 - next_in -= len;
3430 - bits -= len << 3;
3431 - hold &= (1 << bits) - 1;
3432 -
3433 - /* update state and return */
3434 - strm.next_in = next_in;
3435 - strm.next_out = out;
3436 - strm.avail_in = (next_in < last ? 5 + (last - next_in) : 5 - (next_in - last));
3437 - strm.avail_out = (out < end ?
3438 - 257 + (end - out) : 257 - (out - end));
3439 - state.hold = hold;
3440 - state.bits = bits;
3441 -}
3442 -
3443 -function new_array(size)
3444 -{
3445 - var i;
3446 - var ary = new Array(size);
3447 - for(i = 0; i < size; i++)
3448 - ary[i] = 0;
3449 - return ary;
3450 -}
3451 -
3452 -function getarg(opts, name, def_value)
3453 -{
3454 - return (opts && (name in opts)) ? opts[name] : def_value;
3455 -}
3456 -
3457 -function checksum_none()
3458 -{
3459 - return 0;
3460 -}
3461 -
3462 -/**
3463 - * z_stream constructor
3464 - * @constructor
3465 - */
3466 -function inflate_state()
3467 -{
3468 - var i;
3469 -
3470 - this.mode = 0; /* current inflate mode */
3471 - this.last = 0; /* true if processing last block */
3472 - this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */
3473 - this.havedict = 0; /* true if dictionary provided */
3474 - this.flags = 0; /* gzip header method and flags (0 if zlib) */
3475 - this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */
3476 - this.check = 0; /* protected copy of check value */
3477 - this.total = 0; /* protected copy of output count */
3478 - this.head = null; /* where to save gzip header information */
3479 - /* sliding window */
3480 - this.wbits = 0; /* log base 2 of requested window size */
3481 - this.wsize = 0; /* window size or zero if not using window */
3482 - this.whave = 0; /* valid bytes in the window */
3483 - this.wnext = 0; /* window write index (TODO remove) */
3484 - this.window = null; /* allocated sliding window, if needed */
3485 - /* bit accumulator */
3486 - this.hold = 0; /* input bit accumulator */
3487 - this.bits = 0; /* number of bits in "in" */
3488 - /* for string and stored block copying */
3489 - this.length = 0; /* literal or length of data to copy */
3490 - this.offset = 0; /* distance back to copy string from */
3491 - /* for table and code decoding */
3492 - this.extra = 0; /* extra bits needed */
3493 - /* fixed and dynamic code tables */
3494 -
3495 - /* zlib.js: modified implementation: lencode, distcode, next are offset of codes[] */
3496 - this.lencode = 0; /* starting table for length/literal codes */
3497 - this.distcode = 0; /* starting table for distance codes */
3498 - this.lenbits = 0; /* index bits for lencode */
3499 - this.distbits = 0; /* index bits for distcode */
3500 - /* dynamic table building */
3501 - this.ncode = 0; /* number of code length code lengths */
3502 - this.nlen = 0; /* number of length code lengths */
3503 - this.ndist = 0; /* number of distance code lengths */
3504 - this.have = 0; /* number of code lengths in lens[] */
3505 - this.next = 0; /* next available space in codes[] */
3506 - this.lens = new_array(320); /* temporary storage for code lengths */
3507 - this.work = new_array(288); /* work area for code table building */
3508 - this.codes = new Array(ENOUGH); /* space for code tables */
3509 - var c = {op:0, bits:0, val:0};
3510 - for(i = 0; i < ENOUGH; i++)
3511 - this.codes[i] = c;
3512 - this.sane = 0; /* if false, allow invalid distance too far */
3513 - this.back = 0; /* bits back of last unprocessed length/lit */
3514 - this.was = 0; /* initial length of match */
3515 -}
3516 -
3517 -ZLIB.inflateResetKeep = function(strm)
3518 -{
3519 - var state;
3520 -
3521 - if (!strm || !strm.state) return ZLIB.Z_STREAM_ERROR;
3522 - state = strm.state;
3523 - strm.total_in = strm.total_out = state.total = 0;
3524 - strm.msg = null;
3525 - if (state.wrap) { /* to support ill-conceived Java test suite */
3526 - strm.adler = state.wrap & 1;
3527 - }
3528 -
3529 - state.mode = HEAD;
3530 - state.last = 0;
3531 - state.havedict = 0;
3532 - state.dmax = 32768;
3533 - state.head = null;
3534 - state.hold = 0;
3535 - state.bits = 0;
3536 - state.lencode = 0;
3537 - state.distcode = 0;
3538 - state.next = 0;
3539 - state.sane = 1;
3540 - state.back = -1;
3541 - return ZLIB.Z_OK;
3542 -};
3543 -
3544 -// Usage: strm = ZLIB.inflateReset(z_stream [, windowBits]);
3545 -ZLIB.inflateReset = function(strm, windowBits)
3546 -{
3547 - var wrap;
3548 - var state;
3549 -
3550 - /* get the state */
3551 - if (!strm || !strm.state) return ZLIB.Z_STREAM_ERROR;
3552 - state = strm.state;
3553 -
3554 - if(typeof windowBits === "undefined")
3555 - windowBits = DEF_WBITS;
3556 -
3557 - /* extract wrap request from windowBits parameter */
3558 - if (windowBits < 0) {
3559 - wrap = 0;
3560 - windowBits = -windowBits;
3561 - }
3562 - else {
3563 - wrap = (windowBits >>> 4) + 1;
3564 - if (windowBits < 48)
3565 - windowBits &= 15;
3566 - }
3567 -
3568 - if(wrap == 1 && (typeof ZLIB.adler32 === 'function')) {
3569 - strm.checksum_function = ZLIB.adler32;
3570 - } else if(wrap == 2 && (typeof ZLIB.crc32 === 'function')) {
3571 - strm.checksum_function = ZLIB.crc32;
3572 - } else {
3573 - strm.checksum_function = checksum_none;
3574 - }
3575 -
3576 - /* set number of window bits, free window if different */
3577 - if (windowBits && (windowBits < 8 || windowBits > 15))
3578 - return ZLIB.Z_STREAM_ERROR;
3579 - if (state.window && state.wbits != windowBits) {
3580 - state.window = null;
3581 - }
3582 -
3583 - /* update state and reset the rest of it */
3584 - state.wrap = wrap;
3585 - state.wbits = windowBits;
3586 - state.wsize = 0;
3587 - state.whave = 0;
3588 - state.wnext = 0;
3589 - return ZLIB.inflateResetKeep(strm);
3590 -};
3591 -
3592 -// Usage: strm = ZLIB.inflateInit([windowBits]);
3593 -ZLIB.inflateInit = function(windowBits)
3594 -{
3595 - var strm = new ZLIB.z_stream();
3596 - strm.state = new inflate_state();
3597 - ZLIB.inflateReset(strm, windowBits);
3598 - return strm;
3599 -};
3600 -
3601 -ZLIB.inflatePrime = function(strm, bits, value)
3602 -{
3603 - var state;
3604 -
3605 - if (!strm || !strm.state) return ZLIB.Z_STREAM_ERROR;
3606 - state = strm.state;
3607 - if (bits < 0) {
3608 - state.hold = 0;
3609 - state.bits = 0;
3610 - return ZLIB.Z_OK;
3611 - }
3612 - if (bits > 16 || state.bits + bits > 32) return ZLIB.Z_STREAM_ERROR;
3613 - value &= (1 << bits) - 1;
3614 - state.hold += value << state.bits;
3615 - state.bits += bits;
3616 - return ZLIB.Z_OK;
3617 -};
3618 -
3619 -var lenfix_ary = null;
3620 -var distfix_ary = null;
3621 -function fixedtables(state)
3622 -{
3623 - var i;
3624 - if (!lenfix_ary) lenfix_ary = [ { op: 96, bits: 7, val: 0 }, { op: 0, bits: 8, val: 80 }, { op: 0, bits: 8, val: 16 }, { op: 20, bits: 8, val: 115 }, { op: 18, bits: 7, val: 31 }, { op: 0, bits: 8, val: 112 }, { op: 0, bits: 8, val: 48 }, { op: 0, bits: 9, val: 192 }, { op: 16, bits: 7, val: 10 }, { op: 0, bits: 8, val: 96 }, { op: 0, bits: 8, val: 32 }, { op: 0, bits: 9, val: 160 }, { op: 0, bits: 8, val: 0 }, { op: 0, bits: 8, val: 128 }, { op: 0, bits: 8, val: 64 }, { op: 0, bits: 9, val: 224 }, { op: 16, bits: 7, val: 6 }, { op: 0, bits: 8, val: 88 }, { op: 0, bits: 8, val: 24 }, { op: 0, bits: 9, val: 144 }, { op: 19, bits: 7, val: 59 }, { op: 0, bits: 8, val: 120 }, { op: 0, bits: 8, val: 56 }, { op: 0, bits: 9, val: 208 }, { op: 17, bits: 7, val: 17 }, { op: 0, bits: 8, val: 104 }, { op: 0, bits: 8, val: 40 }, { op: 0, bits: 9, val: 176 }, { op: 0, bits: 8, val: 8 }, { op: 0, bits: 8, val: 136 }, { op: 0, bits: 8, val: 72 }, { op: 0, bits: 9, val: 240 }, { op: 16, bits: 7, val: 4 }, { op: 0, bits: 8, val: 84 }, { op: 0, bits: 8, val: 20 }, { op: 21, bits: 8, val: 227 }, { op: 19, bits: 7, val: 43 }, { op: 0, bits: 8, val: 116 }, { op: 0, bits: 8, val: 52 }, { op: 0, bits: 9, val: 200 }, { op: 17, bits: 7, val: 13 }, { op: 0, bits: 8, val: 100 }, { op: 0, bits: 8, val: 36 }, { op: 0, bits: 9, val: 168 }, { op: 0, bits: 8, val: 4 }, { op: 0, bits: 8, val: 132 }, { op: 0, bits: 8, val: 68 }, { op: 0, bits: 9, val: 232 }, { op: 16, bits: 7, val: 8 }, { op: 0, bits: 8, val: 92 }, { op: 0, bits: 8, val: 28 }, { op: 0, bits: 9, val: 152 }, { op: 20, bits: 7, val: 83 }, { op: 0, bits: 8, val: 124 }, { op: 0, bits: 8, val: 60 }, { op: 0, bits: 9, val: 216 }, { op: 18, bits: 7, val: 23 }, { op: 0, bits: 8, val: 108 }, { op: 0, bits: 8, val: 44 }, { op: 0, bits: 9, val: 184 }, { op: 0, bits: 8, val: 12 }, { op: 0, bits: 8, val: 140 }, { op: 0, bits: 8, val: 76 }, { op: 0, bits: 9, val: 248 }, { op: 16, bits: 7, val: 3 }, { op: 0, bits: 8, val: 82 }, { op: 0, bits: 8, val: 18 }, { op: 21, bits: 8, val: 163 }, { op: 19, bits: 7, val: 35 }, { op: 0, bits: 8, val: 114 }, { op: 0, bits: 8, val: 50 }, { op: 0, bits: 9, val: 196 }, { op: 17, bits: 7, val: 11 }, { op: 0, bits: 8, val: 98 }, { op: 0, bits: 8, val: 34 }, { op: 0, bits: 9, val: 164 }, { op: 0, bits: 8, val: 2 }, { op: 0, bits: 8, val: 130 }, { op: 0, bits: 8, val: 66 }, { op: 0, bits: 9, val: 228 }, { op: 16, bits: 7, val: 7 }, { op: 0, bits: 8, val: 90 }, { op: 0, bits: 8, val: 26 }, { op: 0, bits: 9, val: 148 }, { op: 20, bits: 7, val: 67 }, { op: 0, bits: 8, val: 122 }, { op: 0, bits: 8, val: 58 }, { op: 0, bits: 9, val: 212 }, { op: 18, bits: 7, val: 19 }, { op: 0, bits: 8, val: 106 }, { op: 0, bits: 8, val: 42 }, { op: 0, bits: 9, val: 180 }, { op: 0, bits: 8, val: 10 }, { op: 0, bits: 8, val: 138 }, { op: 0, bits: 8, val: 74 }, { op: 0, bits: 9, val: 244 }, { op: 16, bits: 7, val: 5 }, { op: 0, bits: 8, val: 86 }, { op: 0, bits: 8, val: 22 }, { op: 64, bits: 8, val: 0 }, { op: 19, bits: 7, val: 51 }, { op: 0, bits: 8, val: 118 }, { op: 0, bits: 8, val: 54 }, { op: 0, bits: 9, val: 204 }, { op: 17, bits: 7, val: 15 }, { op: 0, bits: 8, val: 102 }, { op: 0, bits: 8, val: 38 }, { op: 0, bits: 9, val: 172 }, { op: 0, bits: 8, val: 6 }, { op: 0, bits: 8, val: 134 }, { op: 0, bits: 8, val: 70 }, { op: 0, bits: 9, val: 236 }, { op: 16, bits: 7, val: 9 }, { op: 0, bits: 8, val: 94 }, { op: 0, bits: 8, val: 30 }, { op: 0, bits: 9, val: 156 }, { op: 20, bits: 7, val: 99 }, { op: 0, bits: 8, val: 126 }, { op: 0, bits: 8, val: 62 }, { op: 0, bits: 9, val: 220 }, { op: 18, bits: 7, val: 27 }, { op: 0, bits: 8, val: 110 }, { op: 0, bits: 8, val: 46 }, { op: 0, bits: 9, val: 188 }, { op: 0, bits: 8, val: 14 }, { op: 0, bits: 8, val: 142 }, { op: 0, bits: 8, val: 78 }, { op: 0, bits: 9, val: 252 }, { op: 96, bits: 7, val: 0 }, { op: 0, bits: 8, val: 81 }, { op: 0, bits: 8, val: 17 }, { op: 21, bits: 8, val: 131 }, { op: 18, bits: 7, val: 31 }, { op: 0, bits: 8, val: 113 }, { op: 0, bits: 8, val: 49 }, { op: 0, bits: 9, val: 194 }, { op: 16, bits: 7, val: 10 }, { op: 0, bits: 8, val: 97 }, { op: 0, bits: 8, val: 33 }, { op: 0, bits: 9, val: 162 }, { op: 0, bits: 8, val: 1 }, { op: 0, bits: 8, val: 129 }, { op: 0, bits: 8, val: 65 }, { op: 0, bits: 9, val: 226 }, { op: 16, bits: 7, val: 6 }, { op: 0, bits: 8, val: 89 }, { op: 0, bits: 8, val: 25 }, { op: 0, bits: 9, val: 146 }, { op: 19, bits: 7, val: 59 }, { op: 0, bits: 8, val: 121 }, { op: 0, bits: 8, val: 57 }, { op: 0, bits: 9, val: 210 }, { op: 17, bits: 7, val: 17 }, { op: 0, bits: 8, val: 105 }, { op: 0, bits: 8, val: 41 }, { op: 0, bits: 9, val: 178 }, { op: 0, bits: 8, val: 9 }, { op: 0, bits: 8, val: 137 }, { op: 0, bits: 8, val: 73 }, { op: 0, bits: 9, val: 242 }, { op: 16, bits: 7, val: 4 }, { op: 0, bits: 8, val: 85 }, { op: 0, bits: 8, val: 21 }, { op: 16, bits: 8, val: 258 }, { op: 19, bits: 7, val: 43 }, { op: 0, bits: 8, val: 117 }, { op: 0, bits: 8, val: 53 }, { op: 0, bits: 9, val: 202 }, { op: 17, bits: 7, val: 13 }, { op: 0, bits: 8, val: 101 }, { op: 0, bits: 8, val: 37 }, { op: 0, bits: 9, val: 170 }, { op: 0, bits: 8, val: 5 }, { op: 0, bits: 8, val: 133 }, { op: 0, bits: 8, val: 69 }, { op: 0, bits: 9, val: 234 }, { op: 16, bits: 7, val: 8 }, { op: 0, bits: 8, val: 93 }, { op: 0, bits: 8, val: 29 }, { op: 0, bits: 9, val: 154 }, { op: 20, bits: 7, val: 83 }, { op: 0, bits: 8, val: 125 }, { op: 0, bits: 8, val: 61 }, { op: 0, bits: 9, val: 218 }, { op: 18, bits: 7, val: 23 }, { op: 0, bits: 8, val: 109 }, { op: 0, bits: 8, val: 45 }, { op: 0, bits: 9, val: 186 }, { op: 0, bits: 8, val: 13 }, { op: 0, bits: 8, val: 141 }, { op: 0, bits: 8, val: 77 }, { op: 0, bits: 9, val: 250 }, { op: 16, bits: 7, val: 3 }, { op: 0, bits: 8, val: 83 }, { op: 0, bits: 8, val: 19 }, { op: 21, bits: 8, val: 195 }, { op: 19, bits: 7, val: 35 }, { op: 0, bits: 8, val: 115 }, { op: 0, bits: 8, val: 51 }, { op: 0, bits: 9, val: 198 }, { op: 17, bits: 7, val: 11 }, { op: 0, bits: 8, val: 99 }, { op: 0, bits: 8, val: 35 }, { op: 0, bits: 9, val: 166 }, { op: 0, bits: 8, val: 3 }, { op: 0, bits: 8, val: 131 }, { op: 0, bits: 8, val: 67 }, { op: 0, bits: 9, val: 230 }, { op: 16, bits: 7, val: 7 }, { op: 0, bits: 8, val: 91 }, { op: 0, bits: 8, val: 27 }, { op: 0, bits: 9, val: 150 }, { op: 20, bits: 7, val: 67 }, { op: 0, bits: 8, val: 123 }, { op: 0, bits: 8, val: 59 }, { op: 0, bits: 9, val: 214 }, { op: 18, bits: 7, val: 19 }, { op: 0, bits: 8, val: 107 }, { op: 0, bits: 8, val: 43 }, { op: 0, bits: 9, val: 182 }, { op: 0, bits: 8, val: 11 }, { op: 0, bits: 8, val: 139 }, { op: 0, bits: 8, val: 75 }, { op: 0, bits: 9, val: 246 }, { op: 16, bits: 7, val: 5 }, { op: 0, bits: 8, val: 87 }, { op: 0, bits: 8, val: 23 }, { op: 64, bits: 8, val: 0 }, { op: 19, bits: 7, val: 51 }, { op: 0, bits: 8, val: 119 }, { op: 0, bits: 8, val: 55 }, { op: 0, bits: 9, val: 206 }, { op: 17, bits: 7, val: 15 }, { op: 0, bits: 8, val: 103 }, { op: 0, bits: 8, val: 39 }, { op: 0, bits: 9, val: 174 }, { op: 0, bits: 8, val: 7 }, { op: 0, bits: 8, val: 135 }, { op: 0, bits: 8, val: 71 }, { op: 0, bits: 9, val: 238 }, { op: 16, bits: 7, val: 9 }, { op: 0, bits: 8, val: 95 }, { op: 0, bits: 8, val: 31 }, { op: 0, bits: 9, val: 158 }, { op: 20, bits: 7, val: 99 }, { op: 0, bits: 8, val: 127 }, { op: 0, bits: 8, val: 63 }, { op: 0, bits: 9, val: 222 }, { op: 18, bits: 7, val: 27 }, { op: 0, bits: 8, val: 111 }, { op: 0, bits: 8, val: 47 }, { op: 0, bits: 9, val: 190 }, { op: 0, bits: 8, val: 15 }, { op: 0, bits: 8, val: 143 }, { op: 0, bits: 8, val: 79 }, { op: 0, bits: 9, val: 254 }, { op: 96, bits: 7, val: 0 }, { op: 0, bits: 8, val: 80 }, { op: 0, bits: 8, val: 16 }, { op: 20, bits: 8, val: 115 }, { op: 18, bits: 7, val: 31 }, { op: 0, bits: 8, val: 112 }, { op: 0, bits: 8, val: 48 }, { op: 0, bits: 9, val: 193 }, { op: 16, bits: 7, val: 10 }, { op: 0, bits: 8, val: 96 }, { op: 0, bits: 8, val: 32 }, { op: 0, bits: 9, val: 161 }, { op: 0, bits: 8, val: 0 }, { op: 0, bits: 8, val: 128 }, { op: 0, bits: 8, val: 64 }, { op: 0, bits: 9, val: 225 }, { op: 16, bits: 7, val: 6 }, { op: 0, bits: 8, val: 88 }, { op: 0, bits: 8, val: 24 }, { op: 0, bits: 9, val: 145 }, { op: 19, bits: 7, val: 59 }, { op: 0, bits: 8, val: 120 }, { op: 0, bits: 8, val: 56 }, { op: 0, bits: 9, val: 209 }, { op: 17, bits: 7, val: 17 }, { op: 0, bits: 8, val: 104 }, { op: 0, bits: 8, val: 40 }, { op: 0, bits: 9, val: 177 }, { op: 0, bits: 8, val: 8 }, { op: 0, bits: 8, val: 136 }, { op: 0, bits: 8, val: 72 }, { op: 0, bits: 9, val: 241 }, { op: 16, bits: 7, val: 4 }, { op: 0, bits: 8, val: 84 }, { op: 0, bits: 8, val: 20 }, { op: 21, bits: 8, val: 227 }, { op: 19, bits: 7, val: 43 }, { op: 0, bits: 8, val: 116 }, { op: 0, bits: 8, val: 52 }, { op: 0, bits: 9, val: 201 }, { op: 17, bits: 7, val: 13 }, { op: 0, bits: 8, val: 100 }, { op: 0, bits: 8, val: 36 }, { op: 0, bits: 9, val: 169 }, { op: 0, bits: 8, val: 4 }, { op: 0, bits: 8, val: 132 }, { op: 0, bits: 8, val: 68 }, { op: 0, bits: 9, val: 233 }, { op: 16, bits: 7, val: 8 }, { op: 0, bits: 8, val: 92 }, { op: 0, bits: 8, val: 28 }, { op: 0, bits: 9, val: 153 }, { op: 20, bits: 7, val: 83 }, { op: 0, bits: 8, val: 124 }, { op: 0, bits: 8, val: 60 }, { op: 0, bits: 9, val: 217 }, { op: 18, bits: 7, val: 23 }, { op: 0, bits: 8, val: 108 }, { op: 0, bits: 8, val: 44 }, { op: 0, bits: 9, val: 185 }, { op: 0, bits: 8, val: 12 }, { op: 0, bits: 8, val: 140 }, { op: 0, bits: 8, val: 76 }, { op: 0, bits: 9, val: 249 }, { op: 16, bits: 7, val: 3 }, { op: 0, bits: 8, val: 82 }, { op: 0, bits: 8, val: 18 }, { op: 21, bits: 8, val: 163 }, { op: 19, bits: 7, val: 35 }, { op: 0, bits: 8, val: 114 }, { op: 0, bits: 8, val: 50 }, { op: 0, bits: 9, val: 197 }, { op: 17, bits: 7, val: 11 }, { op: 0, bits: 8, val: 98 }, { op: 0, bits: 8, val: 34 }, { op: 0, bits: 9, val: 165 }, { op: 0, bits: 8, val: 2 }, { op: 0, bits: 8, val: 130 }, { op: 0, bits: 8, val: 66 }, { op: 0, bits: 9, val: 229 }, { op: 16, bits: 7, val: 7 }, { op: 0, bits: 8, val: 90 }, { op: 0, bits: 8, val: 26 }, { op: 0, bits: 9, val: 149 }, { op: 20, bits: 7, val: 67 }, { op: 0, bits: 8, val: 122 }, { op: 0, bits: 8, val: 58 },{ op: 0, bits: 9, val: 213 }, { op: 18, bits: 7, val: 19 }, { op: 0, bits: 8, val: 106 }, { op: 0, bits: 8, val: 42 }, { op: 0, bits: 9, val: 181 }, { op: 0, bits: 8, val: 10 }, { op: 0, bits: 8, val: 138 },{ op: 0, bits: 8, val: 74 }, { op: 0, bits: 9, val: 245 }, { op: 16, bits: 7, val: 5 }, { op: 0, bits: 8, val: 86 }, { op: 0, bits: 8, val: 22 }, { op: 64, bits: 8, val: 0 }, { op: 19, bits: 7, val: 51 },{ op: 0, bits: 8, val: 118 }, { op: 0, bits: 8, val: 54 }, { op: 0, bits: 9, val: 205 }, { op: 17, bits: 7, val: 15 }, { op: 0, bits: 8, val: 102 }, { op: 0, bits: 8, val: 38 }, { op: 0, bits: 9, val: 173 },{ op: 0, bits: 8, val: 6 }, { op: 0, bits: 8, val: 134 }, { op: 0, bits: 8, val: 70 }, { op: 0, bits: 9, val: 237 }, { op: 16, bits: 7, val: 9 }, { op: 0, bits: 8, val: 94 }, { op: 0, bits: 8, val: 30 },{ op: 0, bits: 9, val: 157 }, { op: 20, bits: 7, val: 99 }, { op: 0, bits: 8, val: 126 }, { op: 0, bits: 8, val: 62 }, { op: 0, bits: 9, val: 221 }, { op: 18, bits: 7, val: 27 }, { op: 0, bits: 8, val: 110 }, { op: 0, bits: 8, val: 46 }, { op: 0, bits: 9, val: 189 }, { op: 0, bits: 8, val: 14 }, { op: 0, bits: 8, val: 142 }, { op: 0, bits: 8, val: 78 }, { op: 0, bits: 9, val: 253 }, { op: 96, bits: 7, val: 0 }, { op: 0, bits: 8, val: 81 }, { op: 0, bits: 8, val: 17 }, { op: 21, bits: 8, val: 131 }, { op: 18, bits: 7, val: 31 }, { op: 0, bits: 8, val: 113 }, { op: 0, bits: 8, val: 49 }, { op: 0, bits: 9, val: 195 }, { op: 16, bits: 7, val: 10 }, { op: 0, bits: 8, val: 97 }, { op: 0, bits: 8, val: 33 }, { op: 0, bits: 9, val: 163 }, { op: 0, bits: 8, val: 1 }, { op: 0, bits: 8, val: 129 }, { op: 0, bits: 8, val: 65 }, { op: 0, bits: 9, val: 227 }, { op: 16, bits: 7, val: 6 }, { op: 0, bits: 8, val: 89 }, { op: 0, bits: 8, val: 25 }, { op: 0, bits: 9, val: 147 }, { op: 19, bits: 7, val: 59 }, { op: 0, bits: 8, val: 121 }, { op: 0, bits: 8, val: 57 }, { op: 0, bits: 9, val: 211 }, { op: 17, bits: 7, val: 17 }, { op: 0, bits: 8, val: 105 }, { op: 0, bits: 8, val: 41 }, { op: 0, bits: 9, val: 179 }, { op: 0, bits: 8, val: 9 },{ op: 0, bits: 8, val: 137 }, { op: 0, bits: 8, val: 73 }, { op: 0, bits: 9, val: 243 }, { op: 16, bits: 7, val: 4 }, { op: 0, bits: 8, val: 85 }, { op: 0, bits: 8, val: 21 }, { op: 16, bits: 8, val: 258 },{ op: 19, bits: 7, val: 43 }, { op: 0, bits: 8, val: 117 }, { op: 0, bits: 8, val: 53 }, { op: 0, bits: 9, val: 203 }, { op: 17, bits: 7, val: 13 }, { op: 0, bits: 8, val: 101 }, { op: 0, bits: 8, val: 37 },{ op: 0, bits: 9, val: 171 }, { op: 0, bits: 8, val: 5 }, { op: 0, bits: 8, val: 133 }, { op: 0, bits: 8, val: 69 }, { op: 0, bits: 9, val: 235 }, { op: 16, bits: 7, val: 8 }, { op: 0, bits: 8, val: 93 },{ op: 0, bits: 8, val: 29 }, { op: 0, bits: 9, val: 155 }, { op: 20, bits: 7, val: 83 }, { op: 0, bits: 8, val: 125 }, { op: 0, bits: 8, val: 61 }, { op: 0, bits: 9, val: 219 }, { op: 18, bits: 7, val: 23 },{ op: 0, bits: 8, val: 109 }, { op: 0, bits: 8, val: 45 }, { op: 0, bits: 9, val: 187 }, { op: 0, bits: 8, val: 13 }, { op: 0, bits: 8, val: 141 }, { op: 0, bits: 8, val: 77 }, { op: 0, bits: 9, val: 251 }, { op: 16, bits: 7, val: 3 }, { op: 0, bits: 8, val: 83 }, { op: 0, bits: 8, val: 19 }, { op: 21, bits: 8, val: 195 }, { op: 19, bits: 7, val: 35 }, { op: 0, bits: 8, val: 115 }, { op: 0, bits: 8, val: 51 }, { op: 0, bits: 9, val: 199 }, { op: 17, bits: 7, val: 11 }, { op: 0, bits: 8, val: 99 }, { op: 0, bits: 8, val: 35 }, { op: 0, bits: 9, val: 167 }, { op: 0, bits: 8, val: 3 }, { op: 0, bits: 8, val: 131 }, { op: 0, bits: 8, val: 67 }, { op: 0, bits: 9, val: 231 }, { op: 16, bits: 7, val: 7 }, { op: 0, bits: 8, val: 91 }, { op: 0, bits: 8, val: 27 }, { op: 0, bits: 9, val: 151 }, { op: 20, bits: 7, val: 67 }, { op: 0, bits: 8, val: 123 }, { op: 0, bits: 8, val: 59 }, { op: 0, bits: 9, val: 215 }, { op: 18, bits: 7, val: 19 }, { op: 0, bits: 8, val: 107 }, { op: 0, bits: 8, val: 43 }, { op: 0, bits: 9, val: 183 }, { op: 0, bits: 8, val: 11 }, { op: 0, bits: 8, val: 139 }, { op: 0, bits: 8, val: 75 }, { op: 0, bits: 9, val: 247 }, { op: 16, bits: 7, val: 5 }, { op: 0, bits: 8, val: 87 }, { op: 0, bits: 8, val: 23 }, { op: 64, bits: 8, val: 0 }, { op: 19, bits: 7, val: 51 }, { op: 0, bits: 8, val: 119 }, { op: 0, bits: 8, val: 55 }, { op: 0, bits: 9, val: 207 }, { op: 17, bits: 7, val: 15 }, { op: 0, bits: 8, val: 103 }, { op: 0, bits: 8, val: 39 }, { op: 0, bits: 9, val: 175 }, { op: 0, bits: 8, val: 7 }, { op: 0, bits: 8, val: 135 }, { op: 0, bits: 8, val: 71 }, { op: 0, bits: 9, val: 239 }, { op: 16, bits: 7, val: 9 }, { op: 0, bits: 8, val: 95 }, { op: 0, bits: 8, val: 31 }, { op: 0, bits: 9, val: 159 }, { op: 20, bits: 7, val: 99 }, { op: 0, bits: 8, val: 127 }, { op: 0, bits: 8, val: 63 }, { op: 0, bits: 9, val: 223 }, { op: 18, bits: 7, val: 27 }, { op: 0, bits: 8, val: 111 }, { op: 0, bits: 8, val: 47 }, { op: 0, bits: 9, val: 191 }, { op: 0, bits: 8, val: 15 }, { op: 0, bits: 8, val: 143 }, { op: 0, bits: 8, val: 79 }, { op: 0, bits: 9, val: 255 } ];
3625 - if (!distfix_ary) distfix_ary = [ { op: 16, bits: 5, val: 1 }, { op: 23, bits: 5, val: 257 }, { op: 19, bits: 5, val: 17 }, { op: 27, bits: 5, val: 4097 }, { op: 17, bits: 5, val: 5 }, { op: 25, bits: 5, val: 1025 }, { op: 21, bits: 5, val: 65 }, { op: 29, bits: 5, val: 16385 }, { op: 16, bits: 5, val: 3 }, { op: 24, bits: 5, val: 513 }, { op: 20, bits: 5, val: 33 }, { op: 28, bits: 5, val: 8193 }, { op: 18, bits: 5, val: 9 }, { op: 26, bits: 5, val: 2049 }, { op: 22, bits: 5, val: 129 }, { op: 64, bits: 5, val: 0 }, { op: 16, bits: 5, val: 2 }, { op: 23, bits: 5, val: 385 }, { op: 19, bits: 5, val: 25 }, { op: 27, bits: 5, val: 6145 }, { op: 17, bits: 5, val: 7 }, { op: 25, bits: 5, val: 1537 }, { op: 21, bits: 5, val: 97 }, { op: 29, bits: 5, val: 24577 }, { op: 16, bits: 5, val: 4 }, { op: 24, bits: 5, val: 769 }, { op: 20, bits: 5, val: 49 }, { op: 28, bits: 5, val: 12289 }, { op: 18, bits: 5, val: 13 }, { op: 26, bits: 5, val: 3073 }, { op: 22, bits: 5, val: 193 }, { op: 64, bits: 5, val: 0 } ];
3626 - state.lencode = 0;
3627 - state.distcode = 512;
3628 - for (i = 0; i < 512; i++) { state.codes[i] = lenfix_ary[i]; }
3629 - for (i = 0; i < 32; i++) { state.codes[i + 512] = distfix_ary[i]; }
3630 - state.lenbits = 9;
3631 - state.distbits = 5;
3632 -}
3633 -
3634 -/*
3635 - Update the window with the last wsize (normally 32K) bytes written before
3636 - returning. If window does not exist yet, create it. This is only called
3637 - when a window is already in use, or when output has been written during this
3638 - inflate call, but the end of the deflate stream has not been reached yet.
3639 - It is also called to create a window for dictionary data when a dictionary
3640 - is loaded.
3641 -
3642 - Providing output buffers larger than 32K to inflate() should provide a speed
3643 - advantage, since only the last 32K of output is copied to the sliding window
3644 - upon return from inflate(), and since all distances after the first 32K of
3645 - output will fall in the output data, making match copies simpler and faster.
3646 - The advantage may be dependent on the size of the processor's data caches.
3647 -*/
3648 -function updatewindow(strm)
3649 -{
3650 - var state = strm.state;
3651 - var out = strm.output_data.length;
3652 -
3653 - /* if it hasn't been done already, allocate space for the window */
3654 - if (state.window === null) {
3655 - state.window = '';
3656 - }
3657 -
3658 - /* if window not in use yet, initialize */
3659 - if (state.wsize == 0) {
3660 - state.wsize = 1 << state.wbits;
3661 - }
3662 -
3663 - // zlib.js: Sliding window
3664 - if (out >= state.wsize) {
3665 - state.window = strm.output_data.substring(out - state.wsize);
3666 - } else {
3667 - if(state.whave + out < state.wsize) {
3668 - state.window += strm.output_data;
3669 - } else {
3670 - state.window = state.window.substring(state.whave - (state.wsize - out)) + strm.output_data;
3671 - }
3672 - }
3673 - state.whave = state.window.length;
3674 - if(state.whave < state.wsize) {
3675 - state.wnext = state.whave;
3676 - } else {
3677 - state.wnext = 0;
3678 - }
3679 - return 0;
3680 -}
3681 -
3682 -
3683 -// #ifdef GUNZIP
3684 -function CRC2(strm, word)
3685 -{
3686 - var hbuf = [word & 0xff, (word >>> 8) & 0xff];
3687 - strm.state.check = strm.checksum_function(strm.state.check, hbuf, 0, 2);
3688 -}
3689 -
3690 -function CRC4(strm, word)
3691 -{
3692 - var hbuf = [word & 0xff,
3693 - (word >>> 8) & 0xff,
3694 - (word >>> 16) & 0xff,
3695 - (word >>> 24) & 0xff];
3696 - strm.state.check = strm.checksum_function(strm.state.check, hbuf, 0, 4);
3697 -}
3698 -
3699 -/* Load registers with state in inflate() for speed */
3700 -function LOAD(strm, s)
3701 -{
3702 - s.strm = strm; /* z_stream */
3703 - s.left = strm.avail_out; /* available output */
3704 - s.next = strm.next_in; /* next input */
3705 - s.have = strm.avail_in; /* available input */
3706 - s.hold = strm.state.hold; /* bit buffer */
3707 - s.bits = strm.state.bits; /* bits in bit buffer */
3708 - return s;
3709 -}
3710 -
3711 -/* Restore state from registers in inflate() */
3712 -function RESTORE(s)
3713 -{
3714 - var strm = s.strm;
3715 - strm.next_in = s.next;
3716 - strm.avail_out = s.left;
3717 - strm.avail_in = s.have;
3718 - strm.state.hold = s.hold;
3719 - strm.state.bits = s.bits;
3720 -}
3721 -
3722 -/* Clear the input bit accumulator */
3723 -function INITBITS(s)
3724 -{
3725 - s.hold = 0;
3726 - s.bits = 0;
3727 -}
3728 -
3729 -/* Get a byte of input into the bit accumulator, or return from inflate()
3730 - if there is no input available. */
3731 -function PULLBYTE(s)
3732 -{
3733 - if (s.have == 0) return false;
3734 - s.have--;
3735 - s.hold += (s.strm.input_data.charCodeAt(s.next++) & 0xff) << s.bits;
3736 - s.bits += 8;
3737 - return true;
3738 -}
3739 -
3740 -/* Assure that there are at least n bits in the bit accumulator. If there is
3741 - not enough available input to do that, then return from inflate(). */
3742 -function NEEDBITS(s, n)
3743 -{
3744 - // if(typeof n != 'number') throw 'ERROR';
3745 - while (s.bits < n) {
3746 - if(!PULLBYTE(s))
3747 - return false;
3748 - }
3749 - return true;
3750 -}
3751 -
3752 -/* Return the low n bits of the bit accumulator (n < 16) */
3753 -function BITS(s, n)
3754 -{
3755 - return s.hold & ((1 << n) - 1);
3756 -}
3757 -
3758 -/* Remove n bits from the bit accumulator */
3759 -function DROPBITS(s, n)
3760 -{
3761 - // if(typeof n != 'number') throw 'ERROR';
3762 - s.hold >>>= n;
3763 - s.bits -= n;
3764 -}
3765 -
3766 -/* Remove zero to seven bits as needed to go to a byte boundary */
3767 -function BYTEBITS(s)
3768 -{
3769 - s.hold >>>= s.bits & 7;
3770 - s.bits -= s.bits & 7;
3771 -}
3772 -
3773 -/* Reverse the bytes in a 32-bit value */
3774 -function REVERSE(q)
3775 -{
3776 - return ((q >>> 24) & 0xff) +
3777 - ((q >>> 8) & 0xff00) +
3778 - ((q & 0xff00) << 8) +
3779 - ((q & 0xff) << 24);
3780 -}
3781 -
3782 -/*
3783 - inflate() uses a state machine to process as much input data and generate as
3784 - much output data as possible before returning. The state machine is
3785 - structured roughly as follows:
3786 -
3787 - for (;;) switch (state) {
3788 - ...
3789 - case STATEn:
3790 - if (not enough input data or output space to make progress)
3791 - return;
3792 - ... make progress ...
3793 - state = STATEm;
3794 - break;
3795 - ...
3796 - }
3797 -
3798 - so when inflate() is called again, the same case is attempted again, and
3799 - if the appropriate resources are provided, the machine proceeds to the
3800 - next state. The NEEDBITS() macro is usually the way the state evaluates
3801 - whether it can proceed or should return. NEEDBITS() does the return if
3802 - the requested bits are not available. The typical use of the BITS macros
3803 - is:
3804 -
3805 - NEEDBITS(n);
3806 - ... do something with BITS(n) ...
3807 - DROPBITS(n);
3808 -
3809 - where NEEDBITS(n) either returns from inflate() if there isn't enough
3810 - input left to load n bits into the accumulator, or it continues. BITS(n)
3811 - gives the low n bits in the accumulator. When done, DROPBITS(n) drops
3812 - the low n bits off the accumulator. INITBITS() clears the accumulator
3813 - and sets the number of available bits to zero. BYTEBITS() discards just
3814 - enough bits to put the accumulator on a byte boundary. After BYTEBITS()
3815 - and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
3816 -
3817 - NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
3818 - if there is no input available. The decoding of variable length codes uses
3819 - PULLBYTE() directly in order to pull just enough bytes to decode the next
3820 - code, and no more.
3821 -
3822 - Some states loop until they get enough input, making sure that enough
3823 - state information is maintained to continue the loop where it left off
3824 - if NEEDBITS() returns in the loop. For example, want, need, and keep
3825 - would all have to actually be part of the saved state in case NEEDBITS()
3826 - returns:
3827 -
3828 - case STATEw:
3829 - while (want < need) {
3830 - NEEDBITS(n);
3831 - keep[want++] = BITS(n);
3832 - DROPBITS(n);
3833 - }
3834 - state = STATEx;
3835 - case STATEx:
3836 -
3837 - As shown above, if the next state is also the next case, then the break
3838 - is omitted.
3839 -
3840 - A state may also return if there is not enough output space available to
3841 - complete that state. Those states are copying stored data, writing a
3842 - literal byte, and copying a matching string.
3843 -
3844 - When returning, a "goto inf_leave" is used to update the total counters,
3845 - update the check value, and determine whether any progress has been made
3846 - during that inflate() call in order to return the proper return code.
3847 - Progress is defined as a change in either strm->avail_in or strm->avail_out.
3848 - When there is a window, goto inf_leave will update the window with the last
3849 - output written. If a goto inf_leave occurs in the middle of decompression
3850 - and there is no window currently, goto inf_leave will create one and copy
3851 - output to the window for the next call of inflate().
3852 -
3853 - In this implementation, the flush parameter of inflate() only affects the
3854 - return code (per zlib.h). inflate() always writes as much as possible to
3855 - strm->next_out, given the space available and the provided input--the effect
3856 - documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers
3857 - the allocation of and copying into a sliding window until necessary, which
3858 - provides the effect documented in zlib.h for Z_FINISH when the entire input
3859 - stream available. So the only thing the flush parameter actually does is:
3860 - when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it
3861 - will return Z_BUF_ERROR if it has not reached the end of the stream.
3862 - */
3863 -
3864 -/* permutation of code lengths */
3865 -var inflate_order = [
3866 - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
3867 -ZLIB.inflate = function(strm, flush)
3868 -{
3869 - var state;
3870 - var s;
3871 - var _in, out; /* save starting available input and output */
3872 - var copy; /* number of stored or match bytes to copy */
3873 - var from_window_offset = -1; /* index of window[] */
3874 - var from_out_offset = -1; /* index of next_out[] */
3875 - var here; /* current decoding table entry */
3876 - var last; /* parent table entry */
3877 - var len; /* length to copy for repeats, bits to drop */
3878 - var ret; /* return code */
3879 -
3880 - if (!strm || !strm.state ||
3881 - (!strm.input_data && strm.avail_in != 0))
3882 - return ZLIB.Z_STREAM_ERROR;
3883 -
3884 - state = strm.state;
3885 - if (state.mode == TYPE) state.mode = TYPEDO; /* skip check */
3886 -
3887 - // LOAD
3888 - s = {};
3889 - LOAD(strm, s);
3890 -
3891 - _in = s.have;
3892 - out = s.left;
3893 - ret = ZLIB.Z_OK;
3894 -inf_leave: for (;;) {
3895 - switch (state.mode) {
3896 - case HEAD:
3897 - if (state.wrap == 0) {
3898 - state.mode = TYPEDO;
3899 - break;
3900 - }
3901 - if(!NEEDBITS(s, 16)) break inf_leave;
3902 -// #ifdef GUNZIP
3903 - if ((state.wrap & 2) && s.hold == 0x8b1f) { /* gzip header */
3904 - state.check = strm.checksum_function(0, null, 0, 0);
3905 - CRC2(strm, s.hold);
3906 - INITBITS(s);
3907 - state.mode = FLAGS;
3908 - break;
3909 - }
3910 - state.flags = 0; /* expect zlib header */
3911 - if (state.head !== null)
3912 - state.head.done = -1;
3913 - if (!(state.wrap & 1) || /* check if zlib header allowed */
3914 -//#else
3915 -// if (
3916 -//#endif
3917 - ((BITS(s, 8) << 8) + (s.hold >>> 8)) % 31) {
3918 - strm.msg = 'incorrect header check';
3919 - state.mode = BAD;
3920 - break;
3921 - }
3922 - if (BITS(s, 4) != ZLIB.Z_DEFLATED) {
3923 - strm.msg = 'unknown compression method';
3924 - state.mode = BAD;
3925 - break;
3926 - }
3927 -
3928 - DROPBITS(s, 4);
3929 - len = BITS(s, 4) + 8;
3930 - if (state.wbits == 0)
3931 - state.wbits = len;
3932 - else if (len > state.wbits) {
3933 - strm.msg = 'invalid window size';
3934 - state.mode = BAD;
3935 - break;
3936 - }
3937 - state.dmax = 1 << len;
3938 -// Tracev((stderr, "inflate: zlib header ok\n"));
3939 - strm.adler = state.check = strm.checksum_function(0, null, 0, 0);
3940 - state.mode = s.hold & 0x200 ? DICTID : TYPE;
3941 - INITBITS(s);
3942 - break;
3943 -// #ifdef GUNZIP
3944 - case FLAGS:
3945 - if(!NEEDBITS(s, 16)) break inf_leave;
3946 - state.flags = s.hold;
3947 - if ((state.flags & 0xff) != ZLIB.Z_DEFLATED) {
3948 - strm.msg = "unknown compression method";
3949 - state.mode = BAD;
3950 - break;
3951 - }
3952 - if (state.flags & 0xe000) {
3953 - strm.msg = "unknown header flags set";
3954 - state.mode = BAD;
3955 - break;
3956 - }
3957 - if (state.head !== null)
3958 - state.head.text = (s.hold >>> 8) & 1;
3959 - if (state.flags & 0x0200) {
3960 - CRC2(strm, s.hold);
3961 - }
3962 - INITBITS(s);
3963 - state.mode = TIME;
3964 - case TIME:
3965 - if(!NEEDBITS(s, 32)) break inf_leave;
3966 - if (state.head !== null)
3967 - state.head.time = s.hold;
3968 - if (state.flags & 0x0200) {
3969 - CRC4(strm, s.hold);
3970 - }
3971 - INITBITS(s);
3972 - state.mode = OS;
3973 - case OS:
3974 - if(!NEEDBITS(s, 16)) break inf_leave;
3975 - if (state.head !== null) {
3976 - state.head.xflags = s.hold & 0xff;
3977 - state.head.os = s.hold >>> 8;
3978 - }
3979 - if (state.flags & 0x0200) {
3980 - CRC2(strm, s.hold);
3981 - }
3982 - INITBITS(s);
3983 - state.mode = EXLEN;
3984 - case EXLEN:
3985 - if (state.flags & 0x0400) {
3986 - if(!NEEDBITS(s, 16)) break inf_leave;
3987 - state.length = s.hold;
3988 - if (state.head !== null) {
3989 - state.head.extra_len = s.hold;
3990 - }
3991 - if (state.flags & 0x0200) {
3992 - CRC2(strm, s.hold);
3993 - }
3994 - INITBITS(s);
3995 - state.head.extra = "";
3996 - }
3997 - else if (state.head !== null) {
3998 - state.head.extra = null;
3999 - }
4000 - state.mode = EXTRA;
4001 - case EXTRA:
4002 - if (state.flags & 0x0400) {
4003 - copy = state.length;
4004 - if (copy > s.have) copy = s.have;
4005 - if (copy) {
4006 - if (state.head !== null &&
4007 - state.head.extra !== null) {
4008 - len = state.head.extra_len - state.length;
4009 -/*
4010 - zmemcpy(state->head->extra + len, next,
4011 - len + copy > state->head->extra_max ?
4012 - state->head->extra_max - len : copy);
4013 -*/
4014 - state.head.extra += strm.input_data.substring(
4015 - s.next, s.next + (len + copy > state.head.extra_max ?
4016 - state.head.extra_max - len : copy));
4017 -
4018 - }
4019 - if (state.flags & 0x0200)
4020 - state.check = strm.checksum_function(state.check, strm.input_data, s.next, copy);
4021 - s.have -= copy;
4022 - s.next += copy;
4023 - state.length -= copy;
4024 - }
4025 - if (state.length) break inf_leave;
4026 - }
4027 - state.length = 0;
4028 - state.mode = NAME;
4029 - case NAME:
4030 - if (state.flags & 0x0800) {
4031 - if (s.have == 0) break inf_leave;
4032 - if (state.head !== null && state.head.name === null) {
4033 - state.head.name = "";
4034 - }
4035 - copy = 0;
4036 - // TODO end = strm.input_data.indexOf("\0", s.next);
4037 - // TODO state.length => state.head.name.length
4038 - do {
4039 - len = strm.input_data.charAt(s.next + copy); copy++;
4040 - if(len === "\0")
4041 - break;
4042 - if (state.head !== null &&
4043 - state.length < state.head.name_max) {
4044 - state.head.name += len;
4045 - state.length++;
4046 - }
4047 - } while (copy < s.have);
4048 - if (state.flags & 0x0200) {
4049 - state.check = strm.checksum_function(state.check, strm.input_data, s.next, copy);
4050 - }
4051 - s.have -= copy;
4052 - s.next += copy;
4053 - if (len !== "\0") break inf_leave;
4054 - }
4055 - else if (state.head !== null)
4056 - state.head.name = null;
4057 - state.length = 0;
4058 - state.mode = COMMENT;
4059 - case COMMENT:
4060 - if (state.flags & 0x1000) {
4061 - if (s.have == 0) break inf_leave;
4062 - copy = 0;
4063 - if (state.head !== null && state.head.comment === null) {
4064 - state.head.comment = "";
4065 - }
4066 - // TODO end = strm.input_data.indexOf("\0", s.next);
4067 - // TODO state.length => state.head.comment.length
4068 - do {
4069 - len = strm.input_data.charAt(s.next + copy); copy++;
4070 - if(len === "\0")
4071 - break;
4072 - if (state.head !== null &&
4073 - state.length < state.head.comm_max) {
4074 - state.head.comment += len;
4075 - state.length++;
4076 - }
4077 - } while (copy < s.have);
4078 - if (state.flags & 0x0200)
4079 - state.check = strm.checksum_function(state.check, strm.input_data, s.next, copy);
4080 - s.have -= copy;
4081 - s.next += copy;
4082 - if (len !== "\0") break inf_leave;
4083 - }
4084 - else if (state.head !== null)
4085 - state.head.comment = null;
4086 - state.mode = HCRC;
4087 - case HCRC:
4088 - if (state.flags & 0x0200) {
4089 - if(!NEEDBITS(s, 16)) break inf_leave;
4090 - if (s.hold != (state.check & 0xffff)) {
4091 - strm.msg = "header crc mismatch";
4092 - state.mode = BAD;
4093 - break;
4094 - }
4095 - INITBITS(s);
4096 - }
4097 - if (state.head !== null) {
4098 - state.head.hcrc = (state.flags >>> 9) & 1;
4099 - state.head.done = 1;
4100 - }
4101 - strm.adler = state.check = strm.checksum_function(0, null, 0, 0);
4102 - state.mode = TYPE;
4103 - break;
4104 -//#endif
4105 - case DICTID:
4106 - if(!NEEDBITS(s, 32)) break inf_leave;
4107 - strm.adler = state.check = REVERSE(s.hold);
4108 - INITBITS(s);
4109 - state.mode = DICT;
4110 - case DICT:
4111 - if (state.havedict == 0) {
4112 - RESTORE(s);
4113 - return ZLIB.Z_NEED_DICT;
4114 - }
4115 - strm.adler = state.check = strm.checksum_function(0, null, 0, 0);
4116 - state.mode = TYPE;
4117 - case TYPE:
4118 - if (flush == ZLIB.Z_BLOCK || flush == ZLIB.Z_TREES) break inf_leave;
4119 - case TYPEDO:
4120 - if (state.last) {
4121 - BYTEBITS(s);
4122 - state.mode = CHECK;
4123 - break;
4124 - }
4125 - if(!NEEDBITS(s, 3)) break inf_leave;
4126 - state.last = BITS(s, 1);
4127 - DROPBITS(s, 1);
4128 - switch (BITS(s, 2)) {
4129 - case 0: /* stored block */
4130 -// Tracev((stderr, "inflate: stored block%s\n",
4131 -// state->last ? " (last)" : ""));
4132 - state.mode = STORED;
4133 - break;
4134 - case 1: /* fixed block */
4135 - fixedtables(state);
4136 -// Tracev((stderr, "inflate: fixed codes block%s\n",
4137 -// state->last ? " (last)" : ""));
4138 - state.mode = LEN_; /* decode codes */
4139 - if (flush == ZLIB.Z_TREES) {
4140 - DROPBITS(s, 2);
4141 - break inf_leave;
4142 - }
4143 - break;
4144 - case 2: /* dynamic block */
4145 -// Tracev((stderr, "inflate: dynamic codes block%s\n",
4146 -// state->last ? " (last)" : ""));
4147 - state.mode = TABLE;
4148 - break;
4149 - case 3:
4150 - strm.msg = 'invalid block type';
4151 - state.mode = BAD;
4152 - }
4153 - DROPBITS(s, 2);
4154 - break;
4155 - case STORED:
4156 - BYTEBITS(s); /* go to byte boundary */
4157 - if(!NEEDBITS(s, 32)) break inf_leave;
4158 - if ((s.hold & 0xffff) != (((s.hold >>> 16) & 0xffff) ^ 0xffff)) {
4159 - strm.msg = 'invalid stored block lengths';
4160 - state.mode = BAD;
4161 - break;
4162 - }
4163 - state.length = s.hold & 0xffff;
4164 -// Tracev((stderr, "inflate: stored length %u\n",
4165 -// state->length));
4166 - INITBITS(s);
4167 - state.mode = COPY_;
4168 - if (flush == ZLIB.Z_TREES) break inf_leave;
4169 - case COPY_:
4170 - state.mode = COPY;
4171 - case COPY:
4172 - copy = state.length;
4173 - if (copy) {
4174 - if (copy > s.have) copy = s.have;
4175 - if (copy > s.left) copy = s.left;
4176 - if (copy == 0) break inf_leave;
4177 - strm.output_data += strm.input_data.substring(s.next, s.next + copy);
4178 - strm.next_out += copy;
4179 - s.have -= copy;
4180 - s.next += copy;
4181 - s.left -= copy;
4182 - state.length -= copy;
4183 - break;
4184 - }
4185 -// Tracev((stderr, "inflate: stored end\n"));
4186 - state.mode = TYPE;
4187 - break;
4188 - case TABLE:
4189 - if(!NEEDBITS(s, 14)) break inf_leave;
4190 - state.nlen = BITS(s, 5) + 257;
4191 - DROPBITS(s, 5);
4192 - state.ndist = BITS(s, 5) + 1;
4193 - DROPBITS(s, 5);
4194 - state.ncode = BITS(s, 4) + 4;
4195 - DROPBITS(s, 4);
4196 -//#ifndef PKZIP_BUG_WORKAROUND
4197 - if (state.nlen > 286 || state.ndist > 30) {
4198 - strm.msg = 'too many length or distance symbols';
4199 - state.mode = BAD;
4200 - break;
4201 - }
4202 -//#endif
4203 -// Tracev((stderr, "inflate: table sizes ok\n"));
4204 - state.have = 0;
4205 - state.mode = LENLENS;
4206 - case LENLENS:
4207 - while (state.have < state.ncode) {
4208 - if(!NEEDBITS(s, 3)) break inf_leave;
4209 - var tmp = BITS(s, 3);
4210 - state.lens[inflate_order[state.have++]] = tmp;
4211 - DROPBITS(s, 3);
4212 - }
4213 - while (state.have < 19)
4214 - state.lens[inflate_order[state.have++]] = 0;
4215 - state.next = 0;
4216 - state.lencode = 0;
4217 - state.lenbits = 7;
4218 -
4219 -// ret = inflate_table(CODES, state->lens, 19, &(state->next),
4220 -// &(state->lenbits), state->work);
4221 - ret = inflate_table(state, CODES);
4222 -
4223 - if (ret) {
4224 - strm.msg = 'invalid code lengths set';
4225 - state.mode = BAD;
4226 - break;
4227 - }
4228 -// Tracev((stderr, "inflate: code lengths ok\n"));
4229 - state.have = 0;
4230 - state.mode = CODELENS;
4231 - case CODELENS:
4232 - while (state.have < state.nlen + state.ndist) {
4233 - for (;;) {
4234 - here = state.codes[state.lencode + BITS(s, state.lenbits)];
4235 - if (here.bits <= s.bits) break;
4236 - if(!PULLBYTE(s)) break inf_leave;
4237 - }
4238 - if (here.val < 16) {
4239 - DROPBITS(s, here.bits);
4240 - state.lens[state.have++] = here.val;
4241 - }
4242 - else {
4243 - if (here.val == 16) {
4244 - if(!NEEDBITS(s, here.bits + 2)) break inf_leave;
4245 - DROPBITS(s, here.bits);
4246 - if (state.have == 0) {
4247 - strm.msg = 'invalid bit length repeat';
4248 - state.mode = BAD;
4249 - break;
4250 - }
4251 - len = state.lens[state.have - 1];
4252 - copy = 3 + BITS(s, 2);
4253 - DROPBITS(s, 2);
4254 - }
4255 - else if (here.val == 17) {
4256 - if(!NEEDBITS(s, here.bits + 3)) break inf_leave;
4257 - DROPBITS(s, here.bits);
4258 - len = 0;
4259 - copy = 3 + BITS(s, 3);
4260 - DROPBITS(s, 3);
4261 - }
4262 - else {
4263 - if(!NEEDBITS(s, here.bits + 7)) break inf_leave;
4264 - DROPBITS(s, here.bits);
4265 - len = 0;
4266 - copy = 11 + BITS(s, 7);
4267 - DROPBITS(s, 7);
4268 - }
4269 - if (state.have + copy > state.nlen + state.ndist) {
4270 - strm.msg = 'invalid bit length repeat';
4271 - state.mode = BAD;
4272 - break;
4273 - }
4274 - while (copy--)
4275 - state.lens[state.have++] = len;
4276 - }
4277 - }
4278 -
4279 - /* handle error breaks in while */
4280 - if (state.mode == BAD) break;
4281 -
4282 - /* check for end-of-block code (better have one) */
4283 - if (state.lens[256] == 0) {
4284 - strm.msg = 'invalid code -- missing end-of-block';
4285 - state.mode = BAD;
4286 - break;
4287 - }
4288 -
4289 - /* build code tables -- note: do not change the lenbits or distbits
4290 - values here (9 and 6) without reading the comments in inftrees.h
4291 - concerning the ENOUGH constants, which depend on those values */
4292 - state.next = 0;
4293 - state.lencode = state.next;
4294 - state.lenbits = 9;
4295 -// ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
4296 -// &(state->lenbits), state->work);
4297 - ret = inflate_table(state, LENS);
4298 - if (ret) {
4299 - strm.msg = 'invalid literal/lengths set';
4300 - state.mode = BAD;
4301 - break;
4302 - }
4303 - state.distcode = state.next;
4304 - state.distbits = 6;
4305 -// ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next),
4306 -// &(state->distbits), state->work);
4307 - ret = inflate_table(state, DISTS);
4308 - if (ret) {
4309 - strm.msg = 'invalid distances set';
4310 - state.mode = BAD;
4311 - break;
4312 - }
4313 -// Tracev((stderr, "inflate: codes ok\n"));
4314 - state.mode = LEN_;
4315 - if (flush == ZLIB.Z_TREES) break inf_leave;
4316 - case LEN_:
4317 - state.mode = LEN;
4318 - case LEN:
4319 - if (s.have >= 6 && s.left >= 258) {
4320 - RESTORE(s);
4321 - inflate_fast(strm, out);
4322 - LOAD(strm, s);
4323 - if (state.mode == TYPE)
4324 - state.back = -1;
4325 - break;
4326 - }
4327 - state.back = 0;
4328 - for (;;) {
4329 - here = state.codes[state.lencode + BITS(s, state.lenbits)];
4330 - if (here.bits <= s.bits) break;
4331 - if(!PULLBYTE(s)) break inf_leave;
4332 - }
4333 - if (here.op && (here.op & 0xf0) == 0) {
4334 - last = here;
4335 - for (;;) {
4336 - here = state.codes[state.lencode + last.val +
4337 - (BITS(s, last.bits + last.op) >>> last.bits)];
4338 - if (last.bits + here.bits <= s.bits) break;
4339 - if(!PULLBYTE(s)) break inf_leave;
4340 - }
4341 - DROPBITS(s, last.bits);
4342 - state.back += last.bits;
4343 - }
4344 - DROPBITS(s, here.bits);
4345 - state.back += here.bits;
4346 - state.length = here.val;
4347 - if (here.op == 0) {
4348 -// Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
4349 -// "inflate: literal '%c'\n" :
4350 -// "inflate: literal 0x%02x\n", here.val));
4351 - state.mode = LIT;
4352 - break;
4353 - }
4354 - if (here.op & 32) {
4355 -// Tracevv((stderr, "inflate: end of block\n"));
4356 - state.back = -1;
4357 - state.mode = TYPE;
4358 - break;
4359 - }
4360 - if (here.op & 64) {
4361 - strm.msg = 'invalid literal/length code';
4362 - state.mode = BAD;
4363 - break;
4364 - }
4365 - state.extra = here.op & 15;
4366 - state.mode = LENEXT;
4367 - case LENEXT:
4368 - if (state.extra) {
4369 - if(!NEEDBITS(s, state.extra)) break inf_leave;
4370 - state.length += BITS(s, state.extra);
4371 - DROPBITS(s, state.extra);
4372 - state.back += state.extra;
4373 - }
4374 - //Tracevv((stderr, "inflate: length %u\n", state->length));
4375 - state.was = state.length;
4376 - state.mode = DIST;
4377 - case DIST:
4378 - for (;;) {
4379 - here = state.codes[state.distcode + BITS(s, state.distbits)];
4380 - if (here.bits <= s.bits) break;
4381 - if(!PULLBYTE(s)) break inf_leave;
4382 - }
4383 - if ((here.op & 0xf0) == 0) {
4384 - last = here;
4385 - for (;;) {
4386 - here = state.codes[state.distcode + last.val +
4387 - (BITS(s, last.bits + last.op) >>> last.bits)];
4388 - if ((last.bits + here.bits) <= s.bits) break;
4389 - if(!PULLBYTE(s)) break inf_leave;
4390 - }
4391 - DROPBITS(s, last.bits);
4392 - state.back += last.bits;
4393 - }
4394 - DROPBITS(s, here.bits);
4395 - state.back += here.bits;
4396 - if (here.op & 64) {
4397 - strm.msg = 'invalid distance code';
4398 - state.mode = BAD;
4399 - break;
4400 - }
4401 - state.offset = here.val;
4402 - state.extra = here.op & 15;
4403 - state.mode = DISTEXT;
4404 - case DISTEXT:
4405 - if (state.extra) {
4406 - if(!NEEDBITS(s, state.extra)) break inf_leave;
4407 - state.offset += BITS(s, state.extra);
4408 - DROPBITS(s, state.extra);
4409 - state.back += state.extra;
4410 - }
4411 -//NOSPRT #ifdef INFLATE_STRICT
4412 -// if (state->offset > state->dmax) {
4413 -// strm->msg = (char *)"invalid distance too far back";
4414 -// state->mode = BAD;
4415 -// break;
4416 -// }
4417 -//#endif
4418 -// Tracevv((stderr, "inflate: distance %u\n", state->offset));
4419 - state.mode = MATCH;
4420 - case MATCH:
4421 - if (s.left == 0) break inf_leave;
4422 - copy = out - s.left;
4423 - if (state.offset > copy) { /* copy from window */
4424 - copy = state.offset - copy;
4425 - if (copy > state.whave) {
4426 - if (state.sane) {
4427 - strm.msg = 'invalid distance too far back';
4428 - state.mode = BAD;
4429 - break;
4430 - }
4431 -//NOSPRT #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
4432 -// Trace((stderr, "inflate.c too far\n"));
4433 -// copy -= state->whave;
4434 -// if (copy > state->length) copy = state->length;
4435 -// if (copy > left) copy = left;
4436 -// left -= copy;
4437 -// state->length -= copy;
4438 -// do {
4439 -// *put++ = 0;
4440 -// } while (--copy);
4441 -// if (state->length == 0) state->mode = LEN;
4442 -// break;
4443 -//#endif
4444 - }
4445 - if (copy > state.wnext) {
4446 - copy -= state.wnext;
4447 - // from = state->window + (state->wsize - copy);
4448 - from_window_offset = state.wsize - copy;
4449 - from_out_offset = -1;
4450 - }
4451 - else {
4452 - // from = state->window + (state->wnext - copy);
4453 - from_window_offset = state.wnext - copy;
4454 - from_out_offset = -1;
4455 - }
4456 - if (copy > state.length) copy = state.length;
4457 - }
4458 - else { /* copy from output */
4459 - // from = put - state->offset;
4460 - from_window_offset = -1;
4461 - from_out_offset = strm.next_out - state.offset;
4462 - copy = state.length;
4463 - }
4464 - if (copy > s.left) copy = s.left;
4465 - s.left -= copy;
4466 - state.length -= copy;
4467 - if( from_window_offset >= 0 ) {
4468 - strm.output_data += state.window.substring(from_window_offset, from_window_offset + copy);
4469 - strm.next_out += copy;
4470 - copy = 0;
4471 - } else {
4472 - strm.next_out += copy;
4473 - do {
4474 - strm.output_data += strm.output_data.charAt(from_out_offset++);
4475 - } while (--copy);
4476 - }
4477 - if (state.length == 0) state.mode = LEN;
4478 - break;
4479 - case LIT:
4480 - if (s.left == 0) break inf_leave;
4481 -
4482 - strm.output_data += String.fromCharCode(state.length);
4483 - strm.next_out++;
4484 - //*put++ = (unsigned char)(state->length);
4485 -
4486 - s.left--;
4487 - state.mode = LEN;
4488 - break;
4489 - case CHECK:
4490 - if (state.wrap) {
4491 - if(!NEEDBITS(s, 32)) break inf_leave;
4492 - out -= s.left;
4493 - strm.total_out += out;
4494 - state.total += out;
4495 - if (out)
4496 - strm.adler = state.check =
4497 - strm.checksum_function(state.check, strm.output_data, strm.output_data.length - out, out);
4498 - out = s.left;
4499 - if ((
4500 -// #ifdef GUNZIP
4501 - state.flags ? s.hold :
4502 -//#endif
4503 - REVERSE(s.hold)) != state.check) {
4504 - strm.msg = "incorrect data check";
4505 - state.mode = BAD;
4506 - break;
4507 - }
4508 - INITBITS(s);
4509 -//debug("## inflate: check matches trailer\n");
4510 -// Tracev((stderr, "inflate: check matches trailer\n"));
4511 - }
4512 -//#ifdef GUNZIP
4513 - state.mode = LENGTH;
4514 - case LENGTH:
4515 - if (state.wrap && state.flags) {
4516 - if(!NEEDBITS(s, 32)) break inf_leave;
4517 - if (s.hold != (state.total & 0xffffffff)) {
4518 - strm.msg = 'incorrect length check';
4519 - state.mode = BAD;
4520 - break;
4521 - }
4522 - INITBITS(s);
4523 - //Tracev((stderr, "inflate: length matches trailer\n"));
4524 - }
4525 -//#endif
4526 - state.mode = DONE;
4527 - case DONE:
4528 - ret = ZLIB.Z_STREAM_END;
4529 - break inf_leave;
4530 - case BAD:
4531 - ret = ZLIB.Z_DATA_ERROR;
4532 - break inf_leave;
4533 - case MEM:
4534 - return ZLIB.Z_MEM_ERROR;
4535 - case SYNC:
4536 - default:
4537 - return ZLIB.Z_STREAM_ERROR;
4538 - } }
4539 -
4540 - /*
4541 - Return from inflate(), updating the total counts and the check value.
4542 - If there was no progress during the inflate() call, return a buffer
4543 - error. Call updatewindow() to create and/or update the window state.
4544 - Note: a memory error from inflate() is non-recoverable.
4545 - */
4546 -inf_leave:
4547 - RESTORE(s);
4548 - if (state.wsize || (out != strm.avail_out && state.mode < BAD &&
4549 - (state.mode < CHECK || flush != ZLIB.Z_FINISH)))
4550 - if (updatewindow(strm)) {
4551 - state.mode = MEM;
4552 - return ZLIB.Z_MEM_ERROR;
4553 - }
4554 - _in -= strm.avail_in;
4555 - out -= strm.avail_out;
4556 - strm.total_in += _in;
4557 - strm.total_out += out;
4558 - state.total += out;
4559 - if (state.wrap && out)
4560 - strm.adler = state.check = strm.checksum_function(state.check, strm.output_data, 0, strm.output_data.length);
4561 - strm.data_type = state.bits + (state.last ? 64 : 0) +
4562 - (state.mode == TYPE ? 128 : 0) +
4563 - (state.mode == LEN_ || state.mode == COPY_ ? 256 : 0);
4564 - if (((_in == 0 && out == 0) || flush == ZLIB.Z_FINISH) && ret == ZLIB.Z_OK)
4565 - ret = ZLIB.Z_BUF_ERROR;
4566 - return ret;
4567 -};
4568 -
4569 -ZLIB.inflateEnd = function(strm)
4570 -{
4571 - var state;
4572 - if (!strm || !strm.state )
4573 - return ZLIB.Z_STREAM_ERROR;
4574 - state = strm.state;
4575 - state.window = null;
4576 - strm.state = null;
4577 - // Tracev((stderr, "inflate: end\n"));
4578 - return ZLIB.Z_OK;
4579 -};
4580 -
4581 -ZLIB.z_stream.prototype.inflate = function(input_string, opts)
4582 -{
4583 - var flush;
4584 - var avail_out;
4585 - var DEFAULT_BUFFER_SIZE = 16384;
4586 -
4587 - this.input_data = input_string;
4588 - this.next_in = getarg(opts, 'next_in', 0);
4589 - this.avail_in = getarg(opts, 'avail_in', input_string.length - this.next_in);
4590 -
4591 - flush = getarg(opts, 'flush', ZLIB.Z_SYNC_FLUSH);
4592 - avail_out = getarg(opts, 'avail_out', -1);
4593 -
4594 - var result = '';
4595 - do {
4596 - this.avail_out = (avail_out >= 0 ? avail_out : DEFAULT_BUFFER_SIZE);
4597 - this.output_data = '';
4598 - this.next_out = 0;
4599 - this.error = ZLIB.inflate(this, flush);
4600 - if(avail_out >= 0) {
4601 - return this.output_data;
4602 - }
4603 - result += this.output_data;
4604 - if(this.avail_out > 0) {
4605 - break;
4606 - }
4607 - } while(this.error == ZLIB.Z_OK);
4608 -
4609 - return result;
4610 -};
4611 -
4612 -ZLIB.z_stream.prototype.inflateReset = function(windowBits)
4613 -{
4614 - return ZLIB.inflateReset(this, windowBits);
4615 -};
4616 -
4617 -}());
4618 -/* zlib-adler32.js -- JavaScript implementation for the zlib adler32.
4619 - Version: 0.2.0
4620 - LastModified: Apr 12 2012
4621 - Copyright (C) 2012 Masanao Izumo <iz@onicos.co.jp>
4622 -
4623 - API documentation
4624 -==============================================================================
4625 -Usage: adler = ZLIB.adler32(adler, buf, offset, len);
4626 -
4627 - Update a running Adler-32 checksum with the bytes buf[offset..offset+len-1] and
4628 - return the updated checksum. If buf is null, this function returns the
4629 - required initial value for the checksum.
4630 -
4631 - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
4632 - much faster.
4633 -
4634 - Usage example:
4635 -
4636 - var adler = ZLIB.adler32(0, null, 0, 0);
4637 -
4638 - while (read_buffer(buffer, length) != EOF) {
4639 - adler = ZLIB.adler32(adler, buffer, 0, length);
4640 - }
4641 - if (adler != original_adler) error();
4642 -
4643 -==============================================================================
4644 -Usage: adler = ZLIB.adler32_combine(adler1, adler2, len2);
4645 -
4646 - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
4647 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
4648 - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
4649 - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note
4650 - that the z_off_t type (like off_t) is a signed integer. If len2 is
4651 - negative, the result has no meaning or utility.
4652 -*/
4653 -
4654 -if( typeof ZLIB === 'undefined' ) {
4655 - alert('ZLIB is not defined. SRC zlib.js before zlib-adler32.js')
4656 -}
4657 -
4658 -(function() {
4659 -
4660 -/* adler32.c -- compute the Adler-32 checksum of a data stream
4661 - * Copyright (C) 1995-2011 Mark Adler
4662 - * For conditions of distribution and use, see copyright notice in zlib.h
4663 - */
4664 -
4665 -var BASE = 65521; /* largest prime smaller than 65536 */
4666 -var NMAX = 5552;
4667 -/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
4668 -
4669 -/* ========================================================================= */
4670 -function adler32_string(adler, buf, offset, len)
4671 -{
4672 - var sum2;
4673 - var n;
4674 -
4675 - /* split Adler-32 into component sums */
4676 - sum2 = (adler >>> 16) & 0xffff;
4677 - adler &= 0xffff;
4678 -
4679 - /* in case user likes doing a byte at a time, keep it fast */
4680 - if (len == 1) {
4681 - adler += buf.charCodeAt(offset) & 0xff;
4682 - if (adler >= BASE)
4683 - adler -= BASE;
4684 - sum2 += adler;
4685 - if (sum2 >= BASE)
4686 - sum2 -= BASE;
4687 - return adler | (sum2 << 16);
4688 - }
4689 -
4690 - /* initial Adler-32 value (deferred check for len == 1 speed) */
4691 - if (buf === null)
4692 - return 1;
4693 -
4694 - /* in case short lengths are provided, keep it somewhat fast */
4695 - if (len < 16) {
4696 - while (len--) {
4697 - adler += buf.charCodeAt(offset++) & 0xff;
4698 - sum2 += adler;
4699 - }
4700 - if (adler >= BASE)
4701 - adler -= BASE;
4702 - sum2 %= BASE; /* only added so many BASE's */
4703 - return adler | (sum2 << 16);
4704 - }
4705 -
4706 - /* do length NMAX blocks -- requires just one modulo operation */
4707 - while (len >= NMAX) {
4708 - len -= NMAX;
4709 - n = NMAX >> 4; /* NMAX is divisible by 16 */
4710 - do {
4711 - /* 16 sums unrolled */
4712 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4713 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4714 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4715 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4716 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4717 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4718 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4719 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4720 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4721 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4722 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4723 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4724 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4725 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4726 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4727 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4728 - } while (--n);
4729 - adler %= BASE;
4730 - sum2 %= BASE;
4731 - }
4732 -
4733 - /* do remaining bytes (less than NMAX, still just one modulo) */
4734 - if (len) { /* avoid modulos if none remaining */
4735 - while (len >= 16) {
4736 - len -= 16;
4737 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4738 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4739 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4740 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4741 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4742 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4743 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4744 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4745 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4746 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4747 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4748 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4749 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4750 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4751 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4752 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4753 - }
4754 - while (len--) {
4755 - adler += buf.charCodeAt(offset++) & 0xff; sum2 += adler;
4756 - }
4757 - adler %= BASE;
4758 - sum2 %= BASE;
4759 - }
4760 -
4761 - /* return recombined sums */
4762 - return adler | (sum2 << 16);
4763 -}
4764 -
4765 -/* ========================================================================= */
4766 -function adler32_array(adler, buf, offset, len)
4767 -{
4768 - var sum2;
4769 - var n;
4770 -
4771 - /* split Adler-32 into component sums */
4772 - sum2 = (adler >>> 16) & 0xffff;
4773 - adler &= 0xffff;
4774 -
4775 - /* in case user likes doing a byte at a time, keep it fast */
4776 - if (len == 1) {
4777 - adler += buf[offset];
4778 - if (adler >= BASE)
4779 - adler -= BASE;
4780 - sum2 += adler;
4781 - if (sum2 >= BASE)
4782 - sum2 -= BASE;
4783 - return adler | (sum2 << 16);
4784 - }
4785 -
4786 - /* initial Adler-32 value (deferred check for len == 1 speed) */
4787 - if (buf === null)
4788 - return 1;
4789 -
4790 - /* in case short lengths are provided, keep it somewhat fast */
4791 - if (len < 16) {
4792 - while (len--) {
4793 - adler += buf[offset++];
4794 - sum2 += adler;
4795 - }
4796 - if (adler >= BASE)
4797 - adler -= BASE;
4798 - sum2 %= BASE; /* only added so many BASE's */
4799 - return adler | (sum2 << 16);
4800 - }
4801 -
4802 - /* do length NMAX blocks -- requires just one modulo operation */
4803 - while (len >= NMAX) {
4804 - len -= NMAX;
4805 - n = NMAX >> 4; /* NMAX is divisible by 16 */
4806 - do {
4807 - /* 16 sums unrolled */
4808 - adler += buf[offset++]; sum2 += adler;
4809 - adler += buf[offset++]; sum2 += adler;
4810 - adler += buf[offset++]; sum2 += adler;
4811 - adler += buf[offset++]; sum2 += adler;
4812 - adler += buf[offset++]; sum2 += adler;
4813 - adler += buf[offset++]; sum2 += adler;
4814 - adler += buf[offset++]; sum2 += adler;
4815 - adler += buf[offset++]; sum2 += adler;
4816 - adler += buf[offset++]; sum2 += adler;
4817 - adler += buf[offset++]; sum2 += adler;
4818 - adler += buf[offset++]; sum2 += adler;
4819 - adler += buf[offset++]; sum2 += adler;
4820 - adler += buf[offset++]; sum2 += adler;
4821 - adler += buf[offset++]; sum2 += adler;
4822 - adler += buf[offset++]; sum2 += adler;
4823 - adler += buf[offset++]; sum2 += adler;
4824 - } while (--n);
4825 - adler %= BASE;
4826 - sum2 %= BASE;
4827 - }
4828 -
4829 - /* do remaining bytes (less than NMAX, still just one modulo) */
4830 - if (len) { /* avoid modulos if none remaining */
4831 - while (len >= 16) {
4832 - len -= 16;
4833 - adler += buf[offset++]; sum2 += adler;
4834 - adler += buf[offset++]; sum2 += adler;
4835 - adler += buf[offset++]; sum2 += adler;
4836 - adler += buf[offset++]; sum2 += adler;
4837 - adler += buf[offset++]; sum2 += adler;
4838 - adler += buf[offset++]; sum2 += adler;
4839 - adler += buf[offset++]; sum2 += adler;
4840 - adler += buf[offset++]; sum2 += adler;
4841 - adler += buf[offset++]; sum2 += adler;
4842 - adler += buf[offset++]; sum2 += adler;
4843 - adler += buf[offset++]; sum2 += adler;
4844 - adler += buf[offset++]; sum2 += adler;
4845 - adler += buf[offset++]; sum2 += adler;
4846 - adler += buf[offset++]; sum2 += adler;
4847 - adler += buf[offset++]; sum2 += adler;
4848 - adler += buf[offset++]; sum2 += adler;
4849 - }
4850 - while (len--) {
4851 - adler += buf[offset++]; sum2 += adler;
4852 - }
4853 - adler %= BASE;
4854 - sum2 %= BASE;
4855 - }
4856 -
4857 - /* return recombined sums */
4858 - return adler | (sum2 << 16);
4859 -}
4860 -
4861 -/* ========================================================================= */
4862 -ZLIB.adler32 = function(adler, buf, offset, len)
4863 -{
4864 - if(typeof buf === 'string') {
4865 - return adler32_string(adler, buf, offset, len);
4866 - } else {
4867 - return adler32_array(adler, buf, offset, len);
4868 - }
4869 -};
4870 -
4871 -ZLIB.adler32_combine = function(adler1, adler2, len2)
4872 -{
4873 - var sum1;
4874 - var sum2;
4875 - var rem;
4876 -
4877 - /* for negative len, return invalid adler32 as a clue for debugging */
4878 - if (len2 < 0)
4879 - return 0xffffffff;
4880 -
4881 - /* the derivation of this formula is left as an exercise for the reader */
4882 - len2 %= BASE; /* assumes len2 >= 0 */
4883 - rem = len2;
4884 - sum1 = adler1 & 0xffff;
4885 - sum2 = rem * sum1;
4886 - sum2 %= BASE;
4887 - sum1 += (adler2 & 0xffff) + BASE - 1;
4888 - sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
4889 - if (sum1 >= BASE) sum1 -= BASE;
4890 - if (sum1 >= BASE) sum1 -= BASE;
4891 - if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
4892 - if (sum2 >= BASE) sum2 -= BASE;
4893 - return sum1 | (sum2 << 16);
4894 -}
4895 -
4896 -}());
4897 -/* zlib-adler32.js -- JavaScript implementation for the zlib crc32.
4898 - Version: 0.2.0
4899 - LastModified: Apr 12 2012
4900 - Copyright (C) 2012 Masanao Izumo <iz@onicos.co.jp>
4901 -
4902 - API documentation
4903 -==============================================================================
4904 -Usage: crc = ZLIB.crc32(crc, buf, offset, len);
4905 -
4906 - Update a running CRC-32 with the bytes buf[offset..offset+len-1] and return the
4907 - updated CRC-32. If buf is null, this function returns the required
4908 - initial value for the for the crc. Pre- and post-conditioning (one's
4909 - complement) is performed within this function so it shouldn't be done by the
4910 - application.
4911 -
4912 - Usage example:
4913 -
4914 - var crc = ZLIB.crc32(0, null, 0, 0);
4915 -
4916 - while (read_buffer(buffer, length) != EOF) {
4917 - crc = ZLIB.crc32(crc, buffer, 0, length);
4918 - }
4919 - if (crc != original_crc) error();
4920 -
4921 -==============================================================================
4922 -Usage: crc = crc32_combine(crc1, crc2, len2);
4923 -
4924 - Combine two CRC-32 check values into one. For two sequences of bytes,
4925 - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
4926 - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
4927 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
4928 - len2.
4929 -*/
4930 -
4931 -if( typeof ZLIB === 'undefined' ) {
4932 - alert('ZLIB is not defined. SRC zlib.js before zlib-crc32.js')
4933 -}
4934 -
4935 -(function() {
4936 -
4937 -/* crc32.c -- compute the CRC-32 of a data stream
4938 - * Copyright (C) 1995-2006, 2010, 2011 Mark Adler
4939 - * For conditions of distribution and use, see copyright notice in zlib.h
4940 - *
4941 - * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
4942 - * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
4943 - * tables for updating the shift register in one step with three exclusive-ors
4944 - * instead of four steps with four exclusive-ors. This results in about a
4945 - * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
4946 - */
4947 -
4948 -var crc_table = [
4949 - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
4950 - 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
4951 - 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
4952 - 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
4953 - 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
4954 - 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
4955 - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
4956 - 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
4957 - 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
4958 - 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
4959 - 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
4960 - 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
4961 - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
4962 - 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
4963 - 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
4964 - 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
4965 - 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
4966 - 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
4967 - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
4968 - 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
4969 - 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
4970 - 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
4971 - 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
4972 - 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
4973 - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
4974 - 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
4975 - 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
4976 - 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
4977 - 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
4978 - 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
4979 - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
4980 - 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
4981 - 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
4982 - 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
4983 - 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
4984 - 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
4985 - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
4986 - 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
4987 - 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
4988 - 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
4989 - 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
4990 - 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
4991 - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
4992 - 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
4993 - 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
4994 - 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
4995 - 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
4996 - 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
4997 - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
4998 - 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
4999 - 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,

This file is too large to show in full.