sharing-mobile.handlebars 138 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511
  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
  7. <meta name="viewport" content="user-scalable=1.0,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0" />
  8. <meta name="format-detection" content="telephone=no" />
  9. <meta name="robots" content="noindex,nofollow">
  10. <link rel="manifest" href="{{{domainurl}}}manifest.json">
  11. <link rel="shortcut icon" href="{{{domainurl}}}favicon.ico" />
  12. <link rel="icon" type="image/png" sizes="16x16" href="{{{domainurl}}}favicon-16x16.png">
  13. <link rel="icon" type="image/png" sizes="32x32" href="{{{domainurl}}}favicon-32x32.png">
  14. <link rel="apple-touch-icon" href="/favicon-303x303.png" />
  15. <link type="text/css" href="styles/xterm.css" media="screen" rel="stylesheet" title="CSS" />
  16. {{{customCSSTags}}}
  17. <meta name="apple-mobile-web-app-capable" content="yes">
  18. <meta name="apple-mobile-web-app-status-bar-style" content="#ffffff">
  19. <meta name="apple-mobile-web-app-title" content="{{{title}}}">
  20. <script type="text/javascript" src="scripts/common-0.0.1{{{min}}}.js"></script>
  21. <script type="text/javascript" src="scripts/meshcentral{{{min}}}.js"></script>
  22. <script type="text/javascript" src="scripts/agent-redir-ws-0.1.1{{{min}}}.js"></script>
  23. <script type="text/javascript" src="scripts/agent-desktop-0.0.2{{{min}}}.js"></script>
  24. <script type="text/javascript" src="scripts/amt-0.2.0{{{min}}}.js"></script>
  25. <script type="text/javascript" src="scripts/amt-redir-ws-0.1.0{{{min}}}.js"></script>
  26. <script type="text/javascript" src="scripts/amt-desktop-0.0.2{{{min}}}.js"></script>
  27. <script type="text/javascript" src="scripts/xterm{{{min}}}.js"></script>
  28. <script type="text/javascript" src="scripts/xterm-addon-fit{{{min}}}.js"></script>
  29. <script type="text/javascript" src="scripts/zlib{{{min}}}.js"></script>
  30. <script type="text/javascript" src="scripts/zlib-inflate{{{min}}}.js"></script>
  31. <script type="text/javascript" src="scripts/zlib-adler32{{{min}}}.js"></script>
  32. <script type="text/javascript" src="scripts/zlib-crc32{{{min}}}.js"></script>
  33. <script keeplink=1 type="text/javascript" src="scripts/filesaver.min.js"></script>
  34. {{{customJSTags}}}
  35. <meta name="msapplication-TileColor" content="#00aba9">
  36. <meta name="theme-color" content="#ffffff">
  37. <title>{{{title}}}</title>
  38. <style>
  39. body {
  40. background-color: white;
  41. }
  42. .night body {
  43. background-color: black;
  44. }
  45. #MxMESH {
  46. color: black;
  47. }
  48. .night #MxMESH {
  49. color: lightgray;
  50. }
  51. .textOverGray { color: black; }
  52. #dialog {
  53. z-index:1000;
  54. background-color:#EEE;
  55. box-shadow:0px 0px 15px #666;
  56. font-family:Arial,Helvetica,sans-serif;
  57. border-radius:5px;
  58. position:fixed;
  59. top:90px;
  60. width:300px;
  61. }
  62. .night #dialog {
  63. color: black;
  64. background-color:#AAA;
  65. }
  66. :focus {
  67. outline: 0;
  68. }
  69. a {
  70. color: #036;
  71. text-decoration: underline;
  72. }
  73. .night a {
  74. color: #99F;
  75. }
  76. #footer a {
  77. color: #fff;
  78. text-decoration: underline;
  79. }
  80. #footer a:hover {
  81. text-decoration: none;
  82. }
  83. .night #footer {
  84. color: gray;
  85. }
  86. .i1 {
  87. background: url(../images/icons50.png) 0px 0px;
  88. background-image: image-set(url(../images/icons50.png) 1x, url(../images/icons100.png) 2x);
  89. height: 50px;
  90. width: 50px;
  91. border: none;
  92. }
  93. .i2 {
  94. background: url(../images/icons50.png) -50px 0px;
  95. background-image: image-set(url(../images/icons50.png) 1x, url(../images/icons100.png) 2x);
  96. height: 50px;
  97. width: 50px;
  98. border: none;
  99. }
  100. .i3 {
  101. background: url(../images/icons50.png) -100px 0px;
  102. background-image: image-set(url(../images/icons50.png) 1x, url(../images/icons100.png) 2x);
  103. height: 50px;
  104. width: 50px;
  105. border: none;
  106. }
  107. .i4 {
  108. background: url(../images/icons50.png) -150px 0px;
  109. background-image: image-set(url(../images/icons50.png) 1x, url(../images/icons100.png) 2x);
  110. height: 50px;
  111. width: 50px;
  112. border: none;
  113. }
  114. .i5 {
  115. background: url(../images/icons50.png) -200px 0px;
  116. background-image: image-set(url(../images/icons50.png) 1x, url(../images/icons100.png) 2x);
  117. height: 50px;
  118. width: 50px;
  119. border: none;
  120. }
  121. .i6 {
  122. background: url(../images/icons50.png) -250px 0px;
  123. background-image: image-set(url(../images/icons50.png) 1x, url(../images/icons100.png) 2x);
  124. height: 50px;
  125. width: 50px;
  126. border: none;
  127. }
  128. .i7 {
  129. background: url(../images/icons50.png) -300px 0px;
  130. background-image: image-set(url(../images/icons50.png) 1x, url(../images/icons100.png) 2x);
  131. height: 50px;
  132. width: 50px;
  133. border: none;
  134. }
  135. .i8 {
  136. background: url(../images/icons50.png) -350px 0px;
  137. background-image: image-set(url(../images/icons50.png) 1x, url(../images/icons100.png) 2x);
  138. height: 50px;
  139. width: 50px;
  140. border: none;
  141. }
  142. .m0 {
  143. background: url(../images/images16.png) -32px 0px;
  144. height: 16px;
  145. width: 16px;
  146. border: none;
  147. float: left;
  148. }
  149. .m1 {
  150. background: url(../images/images16.png) -16px 0px;
  151. height: 16px;
  152. width: 16px;
  153. border: none;
  154. float: left;
  155. }
  156. .m2 {
  157. background: url(../images/images16.png) -96px 0px;
  158. height: 16px;
  159. width: 16px;
  160. border: none;
  161. float: left;
  162. }
  163. .m3 {
  164. background: url(../images/images16.png) -112px 0px;
  165. height: 16px;
  166. width: 16px;
  167. border: none;
  168. float: left;
  169. }
  170. .m4 {
  171. background: url(../images/images16.png) -128px 0px;
  172. height: 16px;
  173. width: 16px;
  174. border: none;
  175. float: left;
  176. }
  177. .gray {
  178. /*filter: url("data:image/svg+xml;utf8,&lt;svg xmlns=\'http://www.w3.org/2000/svg\'&gt;&lt;filter id=\'grayscale\'&gt;&lt;feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/&gt;&lt;/filter&gt;&lt;/svg&gt;#grayscale");*/ /* Firefox 10+, Firefox on Android */
  179. filter: gray; /* IE6-9 */
  180. -webkit-filter: grayscale(100%) opacity(60%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */
  181. }
  182. .DevSt {
  183. padding-left: 5px;
  184. border-bottom-style: solid;
  185. border-bottom-width: 1px;
  186. border-bottom-color: #DDDDDD;
  187. }
  188. .noselect {
  189. -webkit-touch-callout: none;
  190. -webkit-user-select: none;
  191. -khtml-user-select: none;
  192. -moz-user-select: none;
  193. -ms-user-select: none;
  194. user-select: none;
  195. }
  196. .fileIcon1 {
  197. background: url(data:image/gif;base64,R0lGODlhEAAQAJEDAPb49Y2Sj9LT2f///yH5BAEAAAMALAAAAAAQABAAAAImnI+py+1vhJwyUYAzHTL4D3qdlJWaIFJqmKod607sDKIiDUP63hQAOw==);
  198. height: 16px;
  199. width: 16px;
  200. cursor: pointer;
  201. border: none;
  202. float: left;
  203. margin-top: 1px;
  204. }
  205. .fileIcon2 {
  206. background: url(data:image/gif;base64,R0lGODlhEAAQAJEDAM2xV/Xur+XPgP///yH5BAEAAAMALAAAAAAQABAAAAJD3ISZIGHWUGihznesYDYATFVM+D2hJ4lgN1olxALAtAlmPCJvuMmJd6PJckDYwicrHhTD5o7plJmg0Uc0asNMkphHAQA7);
  207. height: 16px;
  208. width: 16px;
  209. cursor: pointer;
  210. border: none;
  211. float: left;
  212. margin-top: 1px;
  213. }
  214. .fileIcon3 {
  215. background: url(data:image/gif;base64,R0lGODlhEAAQAJEDAPb19IGBgbq6uv///yH5BAEAAAMALAAAAAAQABAAAAIy3ISpxgcPH2ouQgFEw1YmxnUXKEaaEZZnVWZk66JwzKpvuwZzwOgwb/C1gIOA8Yg8DgoAOw==);
  216. height: 16px;
  217. width: 16px;
  218. cursor: pointer;
  219. border: none;
  220. float: left;
  221. margin-top: 1px;
  222. }
  223. .fileIcon4 {
  224. background: url(../images/meshicon16.png);
  225. height: 16px;
  226. width: 16px;
  227. cursor: pointer;
  228. border: none;
  229. float: left;
  230. margin-top: 1px;
  231. }
  232. .filelist {
  233. -moz-user-select: none;
  234. -khtml-user-select: none;
  235. -webkit-user-select: none;
  236. -o-user-select: none;
  237. cursor: default;
  238. -khtml-user-drag: element;
  239. clear: both;
  240. }
  241. .style10 {
  242. background-color: #C9C9C9;
  243. color: #000;
  244. }
  245. .night .style10 {
  246. background-color: #888;
  247. }
  248. .meshList {
  249. width:auto;
  250. height:40px;
  251. background-color:lightgray;
  252. margin-top:5px;
  253. margin-bottom:5px;
  254. margin-left:60px;
  255. padding-top:5px;
  256. padding-bottom:5px;
  257. border-radius:8px 0px 0px 8px;
  258. }
  259. .night .meshList {
  260. background-color: gray;
  261. }
  262. .night .devList3 {
  263. background-color: gray;
  264. }
  265. .devList4 {
  266. padding-left: 12px;
  267. padding-top: 2px;
  268. color: black;
  269. }
  270. .devList5 {
  271. padding-left: 12px;
  272. padding-top: 3px;
  273. color: #444
  274. }
  275. .night .devList5 {
  276. color: black;
  277. }
  278. .deskButton {
  279. box-shadow: 0px 0px 10px #000;
  280. border-radius:20px;
  281. position:absolute;
  282. right:10px;
  283. top:10px;
  284. cursor:pointer;
  285. background-color:#AAA;
  286. z-index:1000;
  287. }
  288. .menuButton{
  289. box-shadow: 0px 0px 10px #000;
  290. border-radius:10px;
  291. display:inline-block;
  292. width:120px;
  293. background-color:#AAA;
  294. text-align:center;
  295. padding:8px;
  296. cursor:pointer;
  297. margin:10px;
  298. z-index:1000;
  299. }
  300. #p15statetext {
  301. padding: 4px;
  302. height: 15px;
  303. }
  304. #p15agentConsole {
  305. background: black;
  306. margin: 0;
  307. padding: 0;
  308. color: lightgray;
  309. width: 100%;
  310. position: relative;
  311. }
  312. #p15coreName {
  313. padding: 4px;
  314. display: inline-block;
  315. }
  316. #p15agentConsoleText {
  317. position:absolute;
  318. margin: 0;
  319. padding: 0;
  320. top: 0;
  321. bottom: 0;
  322. left:0;
  323. right: 0;
  324. overflow-y: scroll;
  325. overflow-x: auto;
  326. }
  327. .areaHead {
  328. padding-top: 2px;
  329. padding-bottom: 2px;
  330. background: #C0C0C0;
  331. }
  332. .night .areaHead {
  333. color: #CCC;
  334. background: #333;
  335. }
  336. .areaFoot {
  337. padding-top: 2px;
  338. padding-bottom: 2px;
  339. background: #C0C0C0;
  340. }
  341. .night .areaFoot {
  342. color: #CCC;
  343. background: #333;
  344. }
  345. .toright2 {
  346. float: right;
  347. text-align: right;
  348. }
  349. #consoleTable {
  350. width: 100%;
  351. height: 100%;
  352. padding: 0px;
  353. margin-top: 0px;
  354. }
  355. .night #consoleTable {
  356. color: black;
  357. }
  358. #termTable {
  359. width: 100%;
  360. padding: 0px;
  361. margin-top: 0px;
  362. }
  363. .fulldesk #termTable {
  364. position: absolute;
  365. top: 0;
  366. bottom: 0;
  367. left: 0;
  368. right: 0;
  369. }
  370. #termarea3x {
  371. background: black;
  372. text-align: center;
  373. height: 400px;
  374. position: relative;
  375. }
  376. </style>
  377. </head>
  378. <body id="body" onload="if (typeof(startup) !== 'undefined') startup();" style="overflow-y:hidden;margin:0;padding:0;border:0;font-size:13px;font-family:\'Trebuchet MS\', Arial, Helvetica, sans-serif">
  379. <div id=container>
  380. <div id="notifiyBox" class="notifiyBox" style="display:none"></div>
  381. <div id=mastheadx></div>
  382. <div id=masthead style="background:url(logo.png) 0px 0px;background-size:341px 50px;background-color:#036;background-repeat:no-repeat;height:50px;width:100%;overflow:hidden">
  383. <div style="width:calc(100% - 50px);overflow:hidden">
  384. <div style="float:left;height:66px;color:#c8c8c8;padding-left:10px;padding-top:6px">
  385. <strong><font style="font-size:36px;font-family:Arial,Helvetica,sans-serif">{{{title1}}}</font></strong>
  386. </div>
  387. <div style="float:left;height:66px;color:#c8c8c8;padding-left:5px;padding-top:10px">
  388. <strong><font style="font-size:12px;font-family:Arial,Helvetica,sans-serif">{{{title2}}}</font></strong>
  389. </div>
  390. </div>
  391. </div>
  392. <div id=page_content style="position:absolute;bottom:32px;top:50px;width:100%">
  393. <div id=column_l style="width:100%;padding:0;position:absolute;bottom:0px;top:0px">
  394. <div id=p0 style=display:none;width:100%;height:100%>
  395. <div style="display:flex;align-items:center;width:100%;height:100%">
  396. <div id=p0message style=text-align:center;width:100%><span id="p0span">Server disconnected</span>, <href onclick=reload() style=cursor:pointer><u>click to reconnect</u></href>.</div>
  397. </div>
  398. </div>
  399. <div id=p1 style=display:none;width:100%;height:100%>
  400. <div style="display:flex;align-items:center;width:100%;height:100%">
  401. <div id=p1message style=text-align:center;width:100%></div>
  402. </div>
  403. </div>
  404. <div id=p10 style=display:none;position:absolute;bottom:0;top:0;width:100%;overflow:hidden>
  405. <table id=p10deskTopTable cellspacing=0 style="margin:0;padding:0;border-spacing:0;border:0;position:absolute;top:0">
  406. <tr style=padding:0>
  407. <td>
  408. <div style="margin-left:10px;margin-top:14px;font-size:20px">
  409. <strong><span id=p10deviceName></span></strong>
  410. </div>
  411. </td>
  412. </tr>
  413. </table>
  414. <div id=p10dialog style="z-index:1000;background-color:#EEE;box-shadow:0px 0px 15px #666;font-family:Arial,Helvetica,sans-serif;border-radius:5px;position:fixed;top:30px;width:300px;left:30px;display:none">
  415. <div style="width:100%;background-color:#003366;color:#FFF;border-radius:5px 5px 0 0">
  416. <div style=padding:5px>Keyboard Shortcuts Customization</div>
  417. <div style=width:100%;margin:6px></div>
  418. </div>
  419. <div style="margin-right:16px;margin-left:8px"><div id=p10dialog2 style="margin:auto;margin:3px"></div></div>
  420. <div style="padding:10px;margin-bottom:20px"><input type="button" value="OK" style="float:right;width:80px" onclick="deskCustomizeKeysEx()"></div>
  421. </div>
  422. <img id="deskkeybutton1" src="images/mobile-desk-exit.png" class="deskButton" style="top:10px;display:none" onclick="exitButton()" />
  423. <img id="deskkeybutton3a" src="images/mobile-desk-menu-open.png" class="deskButton" style="top:60px;display:none" onclick="toggleMenu(false)" />
  424. <img id="deskkeybutton3b" src="images/mobile-desk-menu-close.png" class="deskButton" style="top:60px;display:none" onclick="toggleMenu(true)" />
  425. <img id="deskkeybutton4a" src="images/mobile-desk-mouse-left.png" class="deskButton" style="top:110px;display:none" onclick="deskChangeMouseButton(0)" />
  426. <img id="deskkeybutton4b" src="images/mobile-desk-mouse-right.png" class="deskButton" style="top:110px;display:none" onclick="deskChangeMouseButton(1)" />
  427. <img id="deskkeybutton5a" src="images/mobile-desk-scale-out.png" class="deskButton" style="top:160px;display:none" onclick="deskChangeFullscreenZoom()" />
  428. <img id="deskkeybutton5b" src="images/mobile-desk-scale-in.png" class="deskButton" style="top:160px;display:none" onclick="deskChangeFullscreenZoom()" />
  429. <img id="deskkeybutton2a" src="images/mobile-desk-keyboard-open.png" class="deskButton" style="top:210px;display:none" onclick="toggleKeyboard()" />
  430. <img id="deskkeybutton2b" src="images/mobile-desk-keyboard-close.png" class="deskButton" style="top:210px;display:none" onclick="toggleKeyboard()" />
  431. <div style="position:absolute;top:0;left:0;z-index:200;opacity:0;width:1px;height:1px">
  432. <input id="softKeyboard" autocapitalize="off" autocomplete="off" type="text" inputmode="text" spellcheck="false" style="z-index:200;opacity:0;width:1px;height:1px" onfocus="keyboardFocusChange()" onblur="keyboardFocusChange()" />
  433. </div>
  434. <div id="deskButtonMenu" style="display:none;position:absolute;top:10px;left:10px;right:55px;bottom:10px;z-index:1000"></div>
  435. <div id=p10desktop style="overflow:hidden;position:absolute;top:55px;bottom:0px;width:100%;display:none">
  436. <div id=deskarea1 style="position:absolute;top:0px;width:100%;height:32px">
  437. <div style="padding-top:2px;padding-bottom:2px;background:#C0C0C0;height:32px">
  438. <div style="float:right;text-align:right">
  439. <span id="p14power"></span>&nbsp;
  440. <input type=button id=deskFullScreen value="Full Screen" onclick=deskToggleFull(event) onkeypress="return false" onkeydown="return false" disabled="disabled" style="height:28px;margin-right:3px;">
  441. </div>
  442. <div style="margin-left:3px">
  443. <input type=button id=connectbutton1 value="Connect" onclick=connectDesktop(event,3) onkeypress="return false" onkeydown="return false" disabled="disabled" style="height:28px">
  444. <input type=button id=connectbutton1h value="HW Connect" onclick=connectDesktop(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled" style="height:28px">
  445. <input type=button id=disconnectbutton1 value="Disconnect" onclick=connectDesktop(event,0) onkeypress="return false" onkeydown="return false" style="height:28px">
  446. <span id="deskstatus" style="color:black">Disconnected</span>
  447. </div>
  448. </div>
  449. </div>
  450. <div id=deskarea3 style="position:absolute;top:32px;width:100%;height:calc(100% - 64px);background-color:#000;text-align:center">
  451. <div id=DeskParent style="height:100%">
  452. <canvas id=Desk width=640 height=200 style="width:100%;-ms-touch-action:none;margin-left:0px" oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event) onmousewheel=dmousewheel(event)></canvas>
  453. </div>
  454. <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;text-align:left" onclick=p11clearConsoleMsg()></div>
  455. <div id=p11DeskSessionSelector style="display:none;position:absolute;left:30px;top:17px;right:30px;bottom:17px;overflow-y:auto"></div>
  456. </div>
  457. <div id=deskarea4 style="position:absolute;bottom:0px;width:100%;height:32px">
  458. <div style=padding-top:2px;padding-bottom:2px;background:#C0C0C0>
  459. <div style=float:right;text-align:right>
  460. <!--<input id=DeskToolsButton type=button value=Tools onkeypress="return false" onkeydown="return false" onclick="toggleDeskTools()">&nbsp;-->
  461. </div>
  462. <div>
  463. <input type="button" value="Settings" onkeypress="return false" onkeydown="return false" onclick="showDesktopSettings()" style="height:28px">
  464. <input type="button" id="DeskScreens" value="Screens" onkeypress="return false" onkeydown="return false" onclick="deskSelectScreens()" style="display:none;height:28px">
  465. <label><span id="DeskControlSpan" style="display:none"><input id="DeskControl" type="checkbox" onkeypress="return false" onkeydown="return false">Input</span></label>
  466. </div>
  467. </div>
  468. </div>
  469. </div>
  470. <div id="termButtonMenu" style="display:none;position:absolute;top:10px;left:10px;right:55px;bottom:10px;z-index:1000"></div>
  471. <div id=p10terminal style="overflow:hidden;position:absolute;top:55px;bottom:0px;width:100%;display:none;background-color:#333">
  472. <div id=termTable style="position:absolute;top:0;bottom:0;left:0;right:0">
  473. <div id="termarea1">
  474. <div class="areaHead" style="line-height:24px">
  475. <div class="toright2">
  476. <input type=button id=termFullScreen value="Full Screen" onclick=deskToggleFull(event) onkeypress="return false" onkeydown="return false" disabled="disabled" style="height:28px;margin-right:3px;">
  477. <div id="terminalCustomUpperRight" style="float:left;margin-right:6px"></div>
  478. </div>
  479. <div>
  480. <span id="connectbutton2span" style="margin-left:3px"><input type="button" id="connectbutton2" cmenu="termConnectButton" value="Connect" style="height:28px" onclick=connectTerminal(event,1) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
  481. <span id="disconnectbutton2span" style="margin-left:3px"><input type="button" id="disconnectbutton2" value="Disconnect" style="height:28px" onclick=connectTerminal(event,0) onkeypress="return false" onkeydown="return false" /></span>
  482. <span id="termstatus" style="line-height:22px">Disconnected</span><span id="termtitle"></span>
  483. </div>
  484. </div>
  485. </div>
  486. <div id="termarea3" style="width:100%;height: calc(100% - 60px);" cellpadding=0 cellspacing=0>
  487. <div id="termarea3x" style="width:100%;height:100%">
  488. <div style="width:100%;height:100%" id="termarea3xdiv"></div>
  489. </div>
  490. </div>
  491. <div id="termarea4" style="position:relative;height:32px;">
  492. <div class="areaFoot">
  493. <div class="toright2"></div>
  494. <div style="height:28px">
  495. </div>
  496. </div>
  497. </div>
  498. <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>
  499. </div>
  500. </div>
  501. <div id=p10files style="position:absolute;top:55px;bottom:0px;width:100%;display:none">
  502. <table id="p13toolbar" style="width:100%;height:111px" cellpadding="0" cellspacing="0">
  503. <tr>
  504. <td style="background-color:#C0C0C0;border-bottom:2px solid black;padding:2px;line-height:24px">
  505. <div style="float:right;text-align:right">
  506. <div id="filesCustomUpperRight" style="float:left;margin-right:6px"></div>
  507. </div>
  508. <div style="margin-left:2px">
  509. <input id=p13AutoConnect value="AutoConnect" onclick=autoConnectFiles(event) onkeypress="return false" onkeydown="return false" type="button" style="display:none">
  510. <input id=p13Connect value="Connect" onclick=connectFiles(event) onkeypress="return false" onkeydown="return false" type="button">
  511. <span class=textOverGray id=p13Status>Disconnected</span>
  512. </div>
  513. </td>
  514. </tr>
  515. <tr>
  516. <td style="width:100%;background-color:#d3d9d6;text-align:left;padding:4px" valign=bottom>
  517. <div style="width:100%;text-align:center">
  518. <input type=button style="width:calc(100%/5 - 5px)" id=p13FolderUp disabled="disabled" onclick="p13folderup()" value="Up" />
  519. <input type=button style="width:calc(100%/5 - 5px)" id=p13SelectAllButton disabled="disabled" onclick="p13selectallfile()" value="SelectAll" onkeypress="return false" onkeydown="return false" />
  520. <input type=button style="width:calc(100%/5 - 5px)" id=p13RenameFileButton disabled="disabled" value="Rename" onclick="p13renamefile()" onkeypress="return false" onkeydown="return false" />
  521. <input type=button style="width:calc(100%/5 - 5px)" id=p13DeleteFileButton disabled="disabled" value="Delete" onclick="p13deletefile()" onkeypress="return false" onkeydown="return false" />
  522. <input type=button style="width:calc(100%/5 - 5px)" id=p13NewFolderButton disabled="disabled" value="Folder" onclick="p13createfolder()" onkeypress="return false" onkeydown="return false" />
  523. </div>
  524. <div style="width:100%;text-align:center">
  525. <input type=button style="width:calc(100%/5 - 5px)" id=p13UploadButton disabled="disabled" value="Upload" onclick="p13uploadFile()" onkeypress="return false" onkeydown="return false" />
  526. <input type=button style="width:calc(100%/5 - 5px)" id=p13CutButton disabled="disabled" value="Cut" onclick="p13copyFile(1)" onkeypress="return false" onkeydown="return false" />
  527. <input type=button style="width:calc(100%/5 - 5px)" id=p13CopyButton disabled="disabled" value="Copy" onclick="p13copyFile(0)" onkeypress="return false" onkeydown="return false" />
  528. <input type=button style="width:calc(100%/5 - 5px)" id=p13PasteButton disabled="disabled" value="Paste" onclick="p13pasteFile()" onkeypress="return false" onkeydown="return false" />
  529. <input type=button style="width:calc(100%/5 - 5px)" id=p13RefreshButton disabled="disabled" value="Refresh" onclick="p13folderup(9999)" onkeypress="return false" onkeydown="return false" />
  530. </div>
  531. </td>
  532. </tr>
  533. <tr>
  534. <td style="background-color:#E4E9E7;height:28px">
  535. <table style="width:100%">
  536. <tr>
  537. <td id=p13currentpath style="overflow:hidden;padding-left:4px;padding-top:2px;color:black"></td>
  538. <td style="text-align:right;padding-right:4px">
  539. <select id=p13sortdropdown onchange=p13updateFiles()>
  540. <option value=1 selected="selected">Sort by name</option>
  541. <option value=2>Sort by size</option>
  542. <option value=3>Sort by date</option>
  543. <option value=4>Descend by name</option>
  544. <option value=5>Descend by size</option>
  545. <option value=6>Descend by date</option>
  546. </select>
  547. </td>
  548. </tr>
  549. </table>
  550. </td>
  551. </tr>
  552. </table>
  553. <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>
  554. <div id="p13filetable" style="width:100%;height:calc(100% - 133px);overflow:auto;-webkit-user-select:none">
  555. <!--
  556. <div id="p13bigok" style="width:256px;overflow:hidden;position:absolute;left:337px;top:200px;text-align:center;font-size:1600%;color:#AAAAAA;display:none"><b>&checkmark;</b></div>
  557. <div id="p13bigfail" style="width:256px;overflow:hidden;position:absolute;left:337px;top:200px;text-align:center;font-size:1600%;color:#AAAAAA;display:none"><b>&#10007;</b></div>
  558. -->
  559. <span id="p13files"></span>
  560. </div>
  561. <table id="p13toolbarBottom" style="width:100%;height:22px;position:absolute;bottom:0px" cellpadding=0 cellspacing=0>
  562. <tr><td style="text-align:left;padding:3px;text-align:center;background-color:#D3D9D6;color:black">&nbsp;<span id="p13bottomstatus"></span></td></tr>
  563. </table>
  564. </div>
  565. </div>
  566. </div>
  567. </div>
  568. <div id=footer style="height:32px;width:100%;text-align:center;background-color:#113962;position:absolute;bottom:0px">
  569. <table id=footerMenu cellpadding=0 cellspacing=0 style="height:32px;width:100%;color:white;cursor:pointer;table-layout:fixed"></table>
  570. </div>
  571. </div>
  572. <div id=dialog style="display:none">
  573. <div style="width:100%;background-color:#003366;color:#FFF;border-radius:5px 5px 0 0">
  574. <div id=id_dialogclose style=float:right;padding:5px;cursor:pointer onclick=setDialogMode()><b>X</b></div>
  575. <div id=id_dialogtitle style=padding:5px></div>
  576. <div style=width:100%;margin:6px></div>
  577. </div>
  578. <div style="margin-right:16px;margin-left:8px">
  579. <div id=dialog1 style="margin:auto;text-align:center;margin:3px">
  580. <div id=id_dialogMessage style="padding:10px"></div>
  581. </div>
  582. <div id=dialog2 style="margin:auto;margin:3px">
  583. <div id=id_dialogOptions></div>
  584. </div>
  585. <div id=dialog3 style="margin:auto;margin:3px">
  586. <select id="deskkeys" style="width:100%">
  587. <option value=10>Ctrl+Alt+Del</option>
  588. <option value=11>Tab</option>
  589. <option value=5>Win</option>
  590. <option value=0>Win+Down</option>
  591. <option value=1>Win+Up</option>
  592. <option value=2>Win+L</option>
  593. <option value=3>Win+M</option>
  594. <option value=4>Shift+Win+M</option>
  595. <option value=6>Win+R</option>
  596. <option value=7>Alt-F4</option>
  597. <option value=8>Ctrl-W</option>
  598. <option value=9>Alt-Tab</option>
  599. <option value=12>Shift-F10</option>
  600. </select>
  601. </div>
  602. <div id=dialog7 style="margin:auto;margin:3px">
  603. <div id="d7meshkvm">
  604. <h4 style="width:100%;border-bottom:1px solid gray">Agent Remote Desktop</h4>
  605. <table style="width:100%">
  606. <tr>
  607. <td>
  608. Quality
  609. </td>
  610. <td style="width:100px">
  611. <select id="d7bitmapquality" style="float:right;width:200px" dir="rtl"></select>
  612. </td>
  613. </tr>
  614. <tr>
  615. <td>
  616. Scaling
  617. </td>
  618. <td style="width:100px">
  619. <select id="d7bitmapscaling" style="float:right;width:200px" dir="rtl">
  620. <option selected=selected value=1024>100%</option>
  621. <option value=896>87.5%</option>
  622. <option value=768>75%</option>
  623. <option value=640>62.5%</option>
  624. <option value=512>50%</option>
  625. <option value=384>37.5%</option>
  626. <option value=256>25%</option>
  627. <option value=128>12.5%</option>
  628. </select>
  629. </td>
  630. </tr>
  631. <tr>
  632. <td>
  633. Rate
  634. </td>
  635. <td style="width:100px">
  636. <select id="d7framelimiter" style="float:right;width:200px" dir="rtl">
  637. <option selected=selected value=50>Fast</option>
  638. <option value=100>Medium</option>
  639. <option value=400>Slow</option>
  640. <option value=1000>Very slow</option>
  641. </select>
  642. </td>
  643. </tr>
  644. <tr>
  645. <td></td>
  646. <td>
  647. <label style="display:block" id="d7deskAutoLockLabel"><input type="checkbox" id="d7deskAutoLock" />Lock on Disconnect</label>
  648. </td>
  649. </tr>
  650. </table>
  651. </div>
  652. <div id="d7amtkvm">
  653. <h4 style="width:100%;border-bottom:1px solid gray">Intel&reg; AMT Hardware KVM</h4>
  654. <table style="width:100%">
  655. <tr>
  656. <td>Encoding</td>
  657. <td style="width:100px">
  658. <select id="d7desktopmode" style="float:right;width:200px">
  659. <option value="1">RLE8, Fastest</option>
  660. <option value="2">RLE16, Recommended</option>
  661. <option value="3">RAW8, Slow</option>
  662. <option value="4">RAW16, Very Slow</option>
  663. </select>
  664. </td>
  665. </tr>
  666. </table>
  667. </div>
  668. </div>
  669. </div>
  670. <div id="idx_dlgButtonBar" style="padding:10px;margin-bottom:20px">
  671. <input id="idx_dlgCancelButton" type="button" value="Cancel" style="float:right;width:80px;margin-left:5px" onclick="dialogclose(0)">
  672. <input id="idx_dlgOkButton" type="button" value="OK" style="float:right;width:80px" onclick="dialogclose(1)">
  673. <div><input id="idx_dlgDeleteButton" type="button" value="Delete" style="display:none" onclick="dialogclose(2)" /></div>
  674. </div>
  675. </div>
  676. <div id=topMenu style="z-index:1000;background-color:#EEE;box-shadow:0px 0px 15px #666;font-family:Arial,Helvetica,sans-serif;border-radius:0px 0px 5px 5px;position:fixed;top:50px;right:5px;width:170px;display:none">
  677. <div style="padding:12px;border-top:1px solid gray;color:black;cursor:pointer" onclick=topMenu(2)>My Files</div>
  678. <div style="padding:12px;border-top:1px solid gray;color:black;cursor:pointer" onclick=topMenu(1)>My Account</div>
  679. <div id="logoutMenuOption"><a href=/logout><div style="padding:12px;border-top:1px solid gray;color:black;cursor:pointer">Logout</div></a></div>
  680. </div>
  681. <audio id="chimes"><source src="sounds/chimes.mp3" type="audio/mp3" /></audio>
  682. <iframe name="fileUploadFrame" style=display:none></iframe>
  683. <script>
  684. 'use strict';
  685. var random = '{{{randomlength}}}' // Random length string for BREACH mitigation
  686. var args = parseUriArgs();
  687. var urlargs = args;
  688. var sessionTime = parseInt('{{{sessiontime}}}');
  689. var sessionRefreshTimer = null;
  690. var domain = '{{{domain}}}';
  691. var domainUrl = '{{{domainurl}}}';
  692. var authCookie = '{{{authCookie}}}';
  693. var authRelayCookie = '{{{authRelayCookie}}}';
  694. var viewOnly = parseInt('{{{viewOnly}}}');
  695. var authCookieRenewTimer = null;
  696. var serverPublicNamePort = '{{{serverDnsName}}}:{{{serverPublicPort}}}';
  697. var debugmode = false;
  698. var attemptWebRTC = false;
  699. var StatusStrs = ["Disconnected", "Connecting...", "Setup...", "Connected", "Intel&reg; AMT Connected"];
  700. var files;
  701. var terminal;
  702. var sessionActivity = Date.now();
  703. var deskPinchZoom;
  704. var deskKeyboardShortcuts = [];
  705. var xterm = null;
  706. var xtermfit = null;
  707. var xtermResizeTimer = null;
  708. var features = parseInt('{{{features}}}');
  709. var features2 = parseInt('{{{features2}}}');
  710. var nodeName = decodeURIComponent('{{{nodeName}}}');
  711. // Console Message Display Timers
  712. var p11DeskConsoleMsgTimer = null;
  713. var p12TermConsoleMsgTimer = null;
  714. var p13FilesConsoleMsgTimer = null;
  715. // Check if WebP is supported
  716. var webpSupport = false;
  717. check_webp_feature('lossy', function (f, x) { webpSupport = x; });
  718. function startup() {
  719. QH('p10deviceName', nodeName);
  720. if ((features & 32) == 0) {
  721. // Guard against other site's top frames (web bugs).
  722. var loc = null;
  723. try { loc = top.location.toString().toLowerCase(); } catch (e) { }
  724. if (top != self && (loc == null || top.active == false)) { top.location = self.location; return; }
  725. }
  726. if (!args.locale) { var x = getstore('loctag', 0); if ((x != null) && (x != '*')) { args.locale = x; } }
  727. window.onresize = center;
  728. center();
  729. go(10);
  730. // Set the document title
  731. if (nodeName.length > 0) { document.title += ' - ' + nodeName; }
  732. // Document keys
  733. document.onkeypress = ondeskkeypress;
  734. document.onkeydown = ondeskkeydown;
  735. document.onkeyup = ondeskkeyup;
  736. document.onclick = function (e) { if ((xxdialogMode == 999) && (e.target.id != 'topMenuIcon')) { QV('topMenu', false); xxdialogMode = 0; } }
  737. // Load desktop settings
  738. var t = localStorage.getItem('desktopsettings');
  739. if (t != null) { desktopsettings = JSON.parse(t); }
  740. applyDesktopSettings();
  741. attemptWebRTC = false; // For now, default WebRTC off unless we set it in the URL.
  742. if (args.webrtc != null) { attemptWebRTC = (args.webrtc == 1); }
  743. // Set the user's desktop shortcut keys
  744. deskKeyboardShortcuts = [];
  745. var deskKeyboardShortcutsStr = getstore('deskKeyShortcuts', '0x0A002E,0x100000,0x100028,0x100026,0x10004C,0x10004D,0x11004D,0x100052,0x020073,0x080057,0x020009,0x100025,0x100027').split(',');
  746. for (var i in deskKeyboardShortcutsStr) { deskKeyboardShortcuts.push(parseInt(deskKeyboardShortcutsStr[i])); }
  747. updateDeskShortcutKeys();
  748. updateTermShortcutKeys();
  749. updateDesktopButtons();
  750. updateTerminalButtons();
  751. if (features & 2) { currentDevicePanel = 1; } // Goto desktop
  752. else if (features & 1) { currentDevicePanel = 5; } // Goto terminal
  753. else if (features & 4) { currentDevicePanel = 2; } // Goto files
  754. setupDeviceMenu(currentDevicePanel);
  755. }
  756. function setSessionActivity() { sessionActivity = Date.now(); }
  757. function checkIdleSessionTimeout() {
  758. var delta = (Date.now() - sessionActivity);
  759. if (delta > serverinfo.timeout) {
  760. if (desktop != null) { // Disconnect remote desktop
  761. desktop.Stop();
  762. desktopNode = desktop = null;
  763. }
  764. if (terminal != null) { // Disconnect terminal
  765. terminal.Stop();
  766. terminal = null;
  767. }
  768. if (files != null) { // Disconnect files
  769. files.Stop();
  770. files = null;
  771. }
  772. if (serverinfo.logoutonidlesessiontimeout) {
  773. window.location.href = 'logout';
  774. }
  775. }
  776. }
  777. //
  778. // Menu System
  779. //
  780. function updateFooterMenu(options) {
  781. while (options != null && options.length < 3) { options.push({ n: '' }); }
  782. var x = '', prev = '';
  783. if (options != null) { for (var i in options) { x += '<td style="cursor:pointer' + ((prev == '') ? '' : ';border-left:solid 1px white') + (options[i].s ? ';background-color:#487099' : '') + '" onclick="' + options[i].f + '">' + options[i].n; prev = options[i].n; } }
  784. QH('footerMenu', '<tr>' + x);
  785. }
  786. //
  787. // MY DEVICES
  788. //
  789. var gotKeyPressEvent = false;
  790. function ondeskkeypress(e, t) {
  791. setSessionActivity();
  792. if (desktop && !xxdialogMode && (xxcurrentView == 10) && (currentDevicePanel == 1)) {
  793. gotKeyPressEvent = true;
  794. Q('softKeyboard').value = '';
  795. // Check what keys we are allows to send
  796. if (viewOnly == 1) return false;
  797. return desktop.m.handleKeys(e);
  798. }
  799. if (terminal && !xxdialogMode && (xxcurrentView == 10) && (currentDevicePanel == 5) && (t !== 1)) {
  800. if (e.altKey == true) { return true; }
  801. gotKeyPressEvent = true;
  802. Q('softKeyboard').value = '';
  803. var k = 0;
  804. if (e.charCode != 0) { k = e.charCode; } else if (e.keyCode != 0) { k = e.keyCode; }
  805. if (k != 0) {
  806. if (terminal.urlname == 'sshterminalrelay.ashx') {
  807. // SSH
  808. terminal.socket.send('~' + String.fromCharCode(k));
  809. } else {
  810. // Agent
  811. terminal.sendText(String.fromCharCode(k));
  812. }
  813. }
  814. return false;
  815. }
  816. }
  817. function ondeskkeydown(e, t) {
  818. setSessionActivity();
  819. if (desktop && !xxdialogMode && (xxcurrentView == 10) && (currentDevicePanel == 1)) {
  820. gotKeyPressEvent = false;
  821. Q('softKeyboard').value = '';
  822. // Check what keys we are allows to send
  823. if (viewOnly == 1) return false;
  824. return desktop.m.handleKeyDown(e);
  825. }
  826. if (terminal && !xxdialogMode && (xxcurrentView == 10) && (currentDevicePanel == 5) && (t !== 1)) {
  827. if (e.altKey == true) { return true; }
  828. Q('softKeyboard').value = '';
  829. gotKeyPressEvent = false;
  830. var k = 0;
  831. if (e.charCode != 0) { k = e.charCode; } else if (e.keyCode != 0) { k = e.keyCode; }
  832. if (k == 8) { terminal.sendText(String.fromCharCode(k)); } // Enter and backspace
  833. else if (e.ctrlKey && (k >= 64) && (k <= 95)) {
  834. // Ctrl keys
  835. if (terminal.urlname == 'sshterminalrelay.ashx') {
  836. // SSH
  837. terminal.socket.send('~' + String.fromCharCode(k - 64));
  838. } else {
  839. // Agent
  840. terminal.sendText(String.fromCharCode(k - 64));
  841. }
  842. }
  843. }
  844. }
  845. function ondeskkeyup(e, t) {
  846. setSessionActivity();
  847. if (desktop && !xxdialogMode && (xxcurrentView == 10) && (currentDevicePanel == 1)) {
  848. var inputStr = Q('softKeyboard').value;
  849. Q('softKeyboard').value = '';
  850. // Check what keys we are allows to send
  851. if (viewOnly == 1) return;
  852. if ((gotKeyPressEvent == false) && (inputStr.length > 0) && desktop.m.SendKeyUnicode) {
  853. // This is a mobile keyboard, we need to send that is in the input control.
  854. var inputchar = inputStr[inputStr.length - 1].charCodeAt(0);
  855. desktop.m.SendKeyUnicode(desktop.m.KeyAction.DOWN, inputchar);
  856. desktop.m.SendKeyUnicode(desktop.m.KeyAction.UP, inputchar);
  857. } else {
  858. return desktop.m.handleKeyUp(e);
  859. }
  860. }
  861. if (terminal && !xxdialogMode && (xxcurrentView == 10) && (currentDevicePanel == 5) && (gotKeyPressEvent == false) && (t !== 1)) {
  862. if (e.altKey == true) { return true; }
  863. var inputStr = Q('softKeyboard').value;
  864. Q('softKeyboard').value = '';
  865. if (terminal.urlname == 'sshterminalrelay.ashx') {
  866. // SSH
  867. terminal.socket.send('~' + inputStr);
  868. } else {
  869. // Agent
  870. if (inputStr)
  871. terminal.sendText(inputStr);
  872. }
  873. return false;
  874. }
  875. }
  876. //
  877. // MY DEVICE
  878. //
  879. var currentDevicePanel = 0;
  880. function setupDeviceMenu(op, obj) {
  881. if (op != null) { currentDevicePanel = op; }
  882. QV('p10desktop', currentDevicePanel == 1); // Show if we have remote control rights or desktop view only rights
  883. QV('p10files', currentDevicePanel == 2);
  884. QV('p10terminal', currentDevicePanel == 5);
  885. var menus = [];
  886. if (features & 2) { menus.push({ n: "Desktop", f: 'setupDeviceMenu(1)', s: (currentDevicePanel == 1) }); }
  887. if (features & 1) { menus.push({ n: "Terminal", f: 'setupDeviceMenu(5)', s: (currentDevicePanel == 5) }); }
  888. if (features & 4) { menus.push({ n: "Files", f: 'setupDeviceMenu(2)', s: (currentDevicePanel == 2) }); }
  889. updateFooterMenu(menus);
  890. if (currentDevicePanel == 1) { deskAdjust(); }
  891. /*
  892. var meshrights = GetNodeRights(currentNode);
  893. if (op != null) { currentDevicePanel = op; }
  894. QV('p10general', currentDevicePanel == 0);
  895. QV('p10desktop', currentDevicePanel == 1); // Show if we have remote control rights or desktop view only rights
  896. QV('p10files', currentDevicePanel == 2);
  897. QV('p10details', currentDevicePanel == 3);
  898. QV('p10console', currentDevicePanel == 4);
  899. QV('p10terminal', currentDevicePanel == 5);
  900. var menus = [];
  901. if (currentDevicePanel != 0) { menus.push({ n: "General", f: 'setupDeviceMenu(0)' }); }
  902. if ((currentDevicePanel != 1) &&
  903. (currentNode != null) &&
  904. ((meshrights & 8) || (meshrights & 256)) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 65536) == 0)) &&
  905. (((currentNode.agent == null) && (currentNode.intelamt) && ((typeof currentNode.intelamt.sku !== 'number') || ((currentNode.intelamt.sku & 8) != 0))) || (currentNode.agent && (currentNode.agent.caps & 1)))
  906. ) { menus.push({ n: "Desktop", f: 'setupDeviceMenu(1)' }); }
  907. if ((currentDevicePanel != 5) &&
  908. (currentNode != null) &&
  909. ((meshrights & 8) || (meshrights & 256)) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 512) == 0)) &&
  910. (((currentNode.agent == null) && (currentNode.intelamt) && ((typeof currentNode.intelamt.sku !== 'number') || ((currentNode.intelamt.sku & 8) != 0))) || (currentNode.agent && (currentNode.agent.caps & 2)))
  911. ) { menus.push({ n: "Terminal", f: 'setupDeviceMenu(5)' }); }
  912. if ((currentDevicePanel != 2) && (currentNode != null) && (meshrights & 8) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 1024) == 0)) && ((currentNode.mtype != 1) && (currentNode.agent) && (currentNode.agent.caps & 4))) { menus.push({ n: "Files", f: 'setupDeviceMenu(2)' }); }
  913. if ((currentDevicePanel != 3) && (currentNode != null) && (currentNode.mtype < 3) && ((meshrights & 1048576) != 0)) { menus.push({ n: "Details", f: 'setupDeviceMenu(3)' }); }
  914. if ((currentDevicePanel != 4) && (currentNode != null) && (meshrights & 0x00000010) && (currentNode.mtype == 2)) { menus.push({ n: "Console", f: 'setupDeviceMenu(4)' }); }
  915. updateFooterMenu(menus);
  916. if (currentDevicePanel == 1) { deskAdjust(); }
  917. */
  918. }
  919. //
  920. // DESKTOP
  921. //
  922. var desktop;
  923. var desktopNode;
  924. var desktopsettings = { encoding: 2, showfocus: false, showmouse: true, showcad: true, quality: 40, scaling: 1024, framerate: 50, autolock: false };
  925. function setupDesktop() {
  926. // Setup the remote desktop
  927. if ((desktopNode != currentNode) && (desktop != null)) { desktop.Stop(); desktopNode = null; desktop = null; }
  928. // If the device desktop is already connected in multi-desktop, use that.
  929. if ((desktopNode != currentNode) || (desktop == null)) {
  930. // Device is not already connected, just setup a blank canvas
  931. //QH('DeskParent', '<canvas id=Desk width=640 height=200 style="width:100%;-ms-touch-action:none;margin-left:0px" oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event)></canvas>');
  932. desktopNode = currentNode;
  933. // Setup the mouse wheel
  934. Q('Desk').addEventListener('DOMMouseScroll', function (e) { return dmousewheel(e); });
  935. Q('Desk').addEventListener('mousewheel', function (e) { return dmousewheel(e); });
  936. }
  937. desktopNode = currentNode;
  938. updateDesktopButtons();
  939. // On some browsers like IE, we can't save screen shots. Hide the scheenshot/capture buttons.
  940. if (!Q('Desk')['toBlob']) { QV('deskSaveBtn', false); }
  941. }
  942. // Show and enable the right buttons
  943. function updateDesktopButtons() {
  944. var deskState = 0;
  945. if (desktop != null) { deskState = desktop.State; }
  946. // Show the right buttons
  947. QV('disconnectbutton1', (deskState != 0));
  948. QE('deskFullScreen', (deskState != 0));
  949. QV('connectbutton1', (deskState == 0));
  950. QV('connectbutton1h', false);
  951. /*
  952. QV('connectbutton1h',
  953. (deskState == 0) &&
  954. (meshrights & 8) &&
  955. (
  956. ((currentNode.intelamt != null) &&
  957. (currentNode.intelamt.state == 2) &&
  958. (currentNode.intelamt.ver != null) &&
  959. ((currentNode.intelamt.sku == null) ||
  960. ((typeof currentNode.intelamt.sku == 'number') &&
  961. ((currentNode.intelamt.sku & 8) != 0))))
  962. )
  963. );
  964. */
  965. // Show the right settings
  966. QV('d7amtkvm', false);
  967. QV('d7meshkvm', true);
  968. // Enable buttons
  969. QE('connectbutton1', true);
  970. QE('connectbutton1h', false);
  971. }
  972. // Used to translate incoming agent console messages
  973. var agentConsoleMessages = ['', "Waiting for user to grant access...", "Denied", "Failed to start remote terminal session, {0} ({1})", "Timeout", "Received invalid network data"];
  974. function formatAgentConsoleMessage(msg, msgid, msgargs) {
  975. var r;
  976. if (msgargs == null) { msgargs = []; }
  977. while (msgargs.length < 3) { msgargs.push(''); } // We need to call the format function in a way that works with older browsers and minifier, can't use apply() or ...
  978. if (msgid && (msgid < agentConsoleMessages.length)) { r = EscapeHtml(format(agentConsoleMessages[msgid], (msgargs[0]), (msgargs[1]), (msgargs[2]))); } else { r = EscapeHtml(msg); }
  979. return r.split('\n').join('<br />') + '<br /><br />';
  980. }
  981. function connectDesktop(e, contype, tsid, consent) {
  982. setSessionActivity();
  983. QV('p11DeskSessionSelector', false);
  984. p11clearConsoleMsg();
  985. if (desktop == null) {
  986. if (contype == 2) {
  987. // Setup the Intel AMT remote desktop
  988. if ((desktopNode.intelamt.user == null) || (desktopNode.intelamt.user == '')) { editDeviceAmtSettings(desktopNode._id, connectDesktop); return; }
  989. desktop = CreateAmtRedirect(CreateAmtRemoteDesktop('Desk'), authCookie);
  990. desktop.debugmode = debugmode;
  991. desktop.onStateChanged = onDesktopStateChange;
  992. desktop.m.stopInput = (viewOnly == 1);
  993. desktop.m.bpp = (desktopsettings.encoding == 1 || desktopsettings.encoding == 3) ? 1 : 2;
  994. desktop.m.useZRLE = (desktopsettings.encoding < 3);
  995. desktop.m.showmouse = true;
  996. desktop.m.onScreenSizeChange = function (o, x, y) { if (fullscreen) { QS('deskarea3').width = (x * fullscreenzoom) + 'px'; QS('deskarea3').height = (y * fullscreenzoom) + 'px'; } deskAdjust(); }
  997. desktop.Start(desktopNode._id, 16994, '*', '*', 0);
  998. desktop.contype = 2;
  999. } else if ((contype == null) || (contype == 1) || ((contype == 3))) {
  1000. // Setup the Mesh Agent remote desktop
  1001. desktop = CreateAgentRedirect(null, CreateAgentRemoteDesktop('Desk'), serverPublicNamePort, authCookie, null, domainUrl);
  1002. desktop.m.stopInput = (viewOnly == 1);
  1003. desktop.m.mouseCursorActive(true);
  1004. desktop.debugmode = debugmode;
  1005. desktop.m.debugmode = debugmode;
  1006. desktop.attemptWebRTC = attemptWebRTC;
  1007. desktop.options = {};
  1008. if (tsid != null) { desktop.options.tsid = tsid; }
  1009. if (consent != null) { desktop.options.consent = consent; }
  1010. if (desktopsettings.autolock == true) { desktop.options.autolock = true; }
  1011. desktop.onStateChanged = onDesktopStateChange;
  1012. if ((features2 & 0x2000) != 0) desktop.m.stopInput = true;
  1013. desktop.onConsoleMessageChange = function () {
  1014. if (desktop.consoleMessage) {
  1015. Q('p11DeskConsoleMsg').innerHTML += formatAgentConsoleMessage(desktop.consoleMessage, desktop.consoleMessageId, desktop.consoleMessageArgs);
  1016. QV('p11DeskConsoleMsg', true);
  1017. if (p11DeskConsoleMsgTimer != null) { clearTimeout(p11DeskConsoleMsgTimer); }
  1018. if (desktop.consoleMessageTimeout) { p11DeskConsoleMsgTimer = setTimeout(p11clearConsoleMsg, desktop.consoleMessageTimeout * 1000); }
  1019. } else {
  1020. p11clearConsoleMsg();
  1021. }
  1022. }
  1023. desktop.m.ImageType = webpSupport ? 4 : 1; // Send 4 if WebP is supported, otherwise send 1 for JPEG.
  1024. desktop.m.CompressionLevel = desktopsettings.quality; // Number from 1 to 100. 50 or less is best.
  1025. desktop.m.ScalingLevel = desktopsettings.scaling;
  1026. desktop.m.FrameRateTimer = desktopsettings.framerate;
  1027. desktop.m.onDisplayinfo = deskDisplayInfo;
  1028. desktop.m.onScreenSizeChange = function (o, x, y) { if (fullscreen) { QS('deskarea3').width = (x * fullscreenzoom) + 'px'; QS('deskarea3').height = (y * fullscreenzoom) + 'px'; } deskAdjust(); }
  1029. desktop.Start(null);
  1030. desktop.contype = 1;
  1031. } else if (contype == 3) {
  1032. // Ask for user sessions
  1033. //meshserver.send({ action: 'msg', type: 'userSessions', nodeid: currentNode._id, tag: consent });
  1034. }
  1035. } else {
  1036. // Disconnect and clean up the remote desktop
  1037. desktop.Stop();
  1038. desktopNode = desktop = null;
  1039. }
  1040. }
  1041. function p11clearConsoleMsg() { QH('p11DeskConsoleMsg', ''); QV('p11DeskConsoleMsg', false); if (p11DeskConsoleMsgTimer) { clearTimeout(p11DeskConsoleMsgTimer); p11DeskConsoleMsgTimer = null; } }
  1042. function p12clearConsoleMsg() { QH('p12TermConsoleMsg', ''); QV('p12TermConsoleMsg', false); if (p12TermConsoleMsgTimer) { clearTimeout(p12TermConsoleMsgTimer); p12TermConsoleMsgTimer = null; } }
  1043. function p13clearConsoleMsg() { QH('p13FilesConsoleMsg', ''); QV('p13FilesConsoleMsg', false); if (p13FilesConsoleMsgTimer) { clearTimeout(p13FilesConsoleMsgTimer); p13FilesConsoleMsgTimer = null; } }
  1044. function p12setConsoleMsg(msg, timeout) {
  1045. if (msg) {
  1046. Q('p12TermConsoleMsg').innerHTML += msg;
  1047. QV('p12TermConsoleMsg', true);
  1048. if (p12TermConsoleMsgTimer != null) { clearTimeout(p12TermConsoleMsgTimer); }
  1049. if (timeout) { p12TermConsoleMsgTimer = setTimeout(p12clearConsoleMsg, timeout); }
  1050. } else {
  1051. p12clearConsoleMsg();
  1052. }
  1053. }
  1054. function p13setConsoleMsg(msg, timeout) {
  1055. if (msg) {
  1056. Q('p13FilesConsoleMsg').innerHTML += msg;
  1057. QV('p13FilesConsoleMsg', true);
  1058. if (p13FilesConsoleMsgTimer != null) { clearTimeout(p13FilesConsoleMsgTimer); }
  1059. if (timeout) { p13FilesConsoleMsgTimer = setTimeout(p13clearConsoleMsg, timeout); }
  1060. } else {
  1061. p13clearConsoleMsg();
  1062. }
  1063. }
  1064. function onDesktopStateChange(xdesktop, state) {
  1065. var xstate = state;
  1066. if ((xstate == 3) && (xdesktop.contype == 2)) { xstate++; }
  1067. var str = StatusStrs[xstate];
  1068. if ((desktop != null) && (desktop.webRtcActive == true)) { str += ", WebRTC"; }
  1069. //if (desktop.m.stopInput == true) { str += ', Loopback'; }
  1070. QH('deskstatus', str);
  1071. switch (state) {
  1072. case 0:
  1073. // Disconnect and clean up the remote desktop
  1074. desktop.Stop();
  1075. desktopNode = desktop = null;
  1076. QV('DeskScreens', false);
  1077. if (fullscreen == true) { deskToggleFull(); }
  1078. break;
  1079. case 2:
  1080. break;
  1081. default:
  1082. //console.log('Unknown onDesktopStateChange state', state);
  1083. break;
  1084. }
  1085. updateDesktopButtons();
  1086. deskAdjust();
  1087. setTimeout(deskAdjust, 50);
  1088. }
  1089. function showDesktopSettings() {
  1090. if (xxdialogMode) return;
  1091. applyDesktopSettings();
  1092. updateDesktopButtons();
  1093. setDialogMode(7, "Remote Desktop Settings", 3, showDesktopSettingsChanged);
  1094. }
  1095. function showDesktopSettingsChanged() {
  1096. desktopsettings.encoding = d7desktopmode.value;
  1097. desktopsettings.quality = d7bitmapquality.value;
  1098. desktopsettings.scaling = d7bitmapscaling.value;
  1099. desktopsettings.framerate = d7framelimiter.value;
  1100. desktopsettings.autolock = d7deskAutoLock.checked;
  1101. localStorage.setItem('desktopsettings', JSON.stringify(desktopsettings));
  1102. applyDesktopSettings();
  1103. if (desktop) {
  1104. if (desktop.contype == 1) {
  1105. if (desktop.State != 0) { desktop.m.SendCompressionLevel(webpSupport ? 4 : 1, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate); }
  1106. desktop.sendCtrlMsg('{"ctrlChannel":"102938","type":"autolock","value":' + desktopsettings.autolock + '}');
  1107. }
  1108. if (desktop.contype == 2) {
  1109. if (desktop.State != 0) { desktop.Stop(); setTimeout(function () { connectDesktop(null, 2); }, 50); }
  1110. }
  1111. }
  1112. }
  1113. function applyDesktopSettings() {
  1114. var r = '', ops = (features & 512) ? [100, 90, 70, 50, 40, 30, 20, 10, 5, 1] : [50, 40, 30, 20, 10, 5, 1];
  1115. for (var i in ops) { r += '<option value=' + ops[i] + '>' + ops[i] + '%</option>'; }
  1116. QH('d7bitmapquality', r);
  1117. d7desktopmode.value = desktopsettings.encoding;
  1118. d7bitmapquality.value = 40; // Default value
  1119. if (ops.indexOf(parseInt(desktopsettings.quality)) >= 0) { d7bitmapquality.value = desktopsettings.quality; }
  1120. d7bitmapscaling.value = desktopsettings.scaling;
  1121. if (desktopsettings.framerate) { d7framelimiter.value = desktopsettings.framerate; }
  1122. if (desktopsettings.autolock != null) { d7deskAutoLock.checked = desktopsettings.autolock; }
  1123. }
  1124. var keyboardShown = false;
  1125. var keyboardShownTimer = null;
  1126. var fullScreenMode = false;
  1127. function toggleKeyboard() {
  1128. if (xxdialogMode) return;
  1129. if (keyboardShownTimer != null) { clearTimeout(keyboardShownTimer); }
  1130. if (keyboardShown) { Q('softKeyboard').blur(); keyboardShown = false; } else { Q('softKeyboard').focus(); keyboardShown = true; }
  1131. QV('deskkeybutton2a', fullscreen && !keyboardShown);
  1132. QV('deskkeybutton2b', fullscreen && keyboardShown);
  1133. }
  1134. function keyboardFocusChange() {
  1135. keyboardShownTimer = setTimeout(function () {
  1136. keyboardShownTimer = null;
  1137. keyboardShown = (Q('softKeyboard') == document.activeElement);
  1138. QV('deskkeybutton2a', fullscreen && !keyboardShown);
  1139. QV('deskkeybutton2b', fullscreen && keyboardShown);
  1140. }, 10);
  1141. }
  1142. function exitButton() {
  1143. if (xxdialogMode) return;
  1144. QV('deskButtonMenu', false);
  1145. QV('termButtonMenu', false);
  1146. deskToggleFull();
  1147. }
  1148. function deskMenuButton(x) {
  1149. toggleMenu(true);
  1150. deskSendKeys(x);
  1151. }
  1152. //
  1153. // Desktop Shortcut Keys
  1154. //
  1155. function updateDeskShortcutKeys() {
  1156. var x = '<div class="menuButton" onclick="deskMenuButton(-1)">' + "Customize" + '</div>';
  1157. for (var i in deskKeyboardShortcuts) { x += '<div class="menuButton" onclick="deskMenuButton(' + deskKeyboardShortcuts[i] + ')">' + keyShortcutTotext(deskKeyboardShortcuts[i]) + '</div>'; }
  1158. QH('deskButtonMenu', x);
  1159. }
  1160. var keyStrings = { 8: "BackSpace", 9: "Tab", 13: "Enter", 27: "Escape", 44 : "Print Screen", 45: "Insert", 46: "Del", 36: "Home", 35: "End", 33: "Page Up", 34: "Page Down", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 0: "None" }
  1161. function keyShortcutTotext(n) {
  1162. var x = [];
  1163. if (n & 0x010000) { x.push("Shift"); }
  1164. if (n & 0x020000) { x.push("Alt"); }
  1165. if (n & 0x080000) { x.push("Ctrl"); }
  1166. if (n & 0x100000) { x.push("Win"); }
  1167. n = (n & 0xFFFF);
  1168. if ((n >= 112) && (n <= 123)) { x.push('F' + (n - 111)); } // Fx keys
  1169. else if ((n != 0) && (keyStrings[n])) { x.push(keyStrings[n]); }
  1170. else { if (n != 0) { x.push(String.fromCharCode(n)); } }
  1171. return x.join(' + ');
  1172. }
  1173. // Customize keyboard shortcuts
  1174. function deskCustomizeKeys() {
  1175. if (xxdialogMode) return;
  1176. var x = '<div id=d2shortcuts style="width:100%;height:180px;padding:4px;overflow-y:auto;border:1px solid gray"></div><div style=width:100%;padding:5px>';
  1177. x += '<label><input id=d1kshift type=checkbox /> ' + "Shift" + '</label><label> <input id=d1kalt type=checkbox /> ' + "Alt" + '</label><label> <input id=d1kctrl type=checkbox /> ' + "Ctrl" + '</label> <input id=d1kwin type=checkbox /> ' + "Win" + '</label>';
  1178. x += ' <select id=d2keySelect>';
  1179. for (var i in keyStrings) { x += '<option value=' + i + '>' + keyStrings[i] + '</option>'; }
  1180. for (var i = 1; i <= 12; i++) { x += '<option value=' + (i + 111) + '>F' + i + '</option>'; }
  1181. for (var i = 0; i < 10; i++) { x += '<option value=' + (i + 48) + '>' + i + '</option>'; }
  1182. for (var i = 0; i < 26; i++) { x += '<option value=' + (i + 65) + '>' + String.fromCharCode(i + 65) + '</option>'; }
  1183. x += '</select> <input type=button value=' + "Add" + ' onclick=addDeskCustomizeKey() /></div>';
  1184. QH('p10dialog2', x);
  1185. xxdialogMode = 2;
  1186. QV('p10dialog', true);
  1187. deskUpdateShortcutList();
  1188. }
  1189. function deskCustomizeKeysEx() {
  1190. QV('p10dialog', false);
  1191. xxdialogMode = 0;
  1192. putstore('deskKeyShortcuts', deskKeyboardShortcuts.join(','));
  1193. updateDeskShortcutKeys();
  1194. }
  1195. function deskUpdateShortcutList() {
  1196. var x = '';
  1197. for (var i in deskKeyboardShortcuts) {
  1198. var kt = keyShortcutTotext(deskKeyboardShortcuts[i]), orderButtons = '';
  1199. if (i != (deskKeyboardShortcuts.length - 1)) { orderButtons += '<img width=8 height=8 style=float:right;cursor:pointer;padding:3px src="images/c2.png" onclick=deskCustomizeKeyDown(' + deskKeyboardShortcuts[i] + ')>'; }
  1200. if (i != 0) { orderButtons += '<img width=8 height=8 style=float:right;cursor:pointer;padding:3px src="images/c3.png" onclick=deskCustomizeKeyUp(' + deskKeyboardShortcuts[i] + ')>'; }
  1201. x += '<div style="width:100%;background-color:#AAA;border-radius:4px;margin-bottom:4px;padding:4px;text-align:left;box-sizing:border-box" value=' + deskKeyboardShortcuts[i] + '>' + kt + '<img width=10 height=10 style=float:right;cursor:pointer;padding:2px;margin-left:8px src="images/trash.png" onclick=removeDeskCustomizeKey(' + deskKeyboardShortcuts[i] + ')>' + orderButtons + '</div>';
  1202. }
  1203. if (x == '') { x = '<i>' + "No keyboard shortcuts defined" + '</i>'; }
  1204. QH('d2shortcuts', x);
  1205. }
  1206. function deskCustomizeKeyDown(k) {
  1207. var i = deskKeyboardShortcuts.indexOf(k), x = deskKeyboardShortcuts[i + 1];
  1208. deskKeyboardShortcuts[i + 1] = deskKeyboardShortcuts[i];
  1209. deskKeyboardShortcuts[i] = x;
  1210. deskUpdateShortcutList();
  1211. }
  1212. function deskCustomizeKeyUp(k) {
  1213. var i = deskKeyboardShortcuts.indexOf(k), x = deskKeyboardShortcuts[i];
  1214. deskKeyboardShortcuts[i] = deskKeyboardShortcuts[i - 1];
  1215. deskKeyboardShortcuts[i - 1] = x;
  1216. deskUpdateShortcutList();
  1217. }
  1218. function removeDeskCustomizeKey(k) {
  1219. var na = [];
  1220. for (var i in deskKeyboardShortcuts) { if (deskKeyboardShortcuts[i] != k) { na.push(deskKeyboardShortcuts[i]); } }
  1221. deskKeyboardShortcuts = na;
  1222. deskUpdateShortcutList();
  1223. }
  1224. function addDeskCustomizeKey() {
  1225. var k = parseInt(Q('d2keySelect').value);
  1226. if (Q('d1kshift').checked) { k |= 0x010000; }
  1227. if (Q('d1kalt').checked) { k |= 0x020000; }
  1228. if (Q('d1kctrl').checked) { k |= 0x080000; }
  1229. if (Q('d1kwin').checked) { k |= 0x100000; }
  1230. if ((k > 0) && (deskKeyboardShortcuts.indexOf(k) == -1)) { deskKeyboardShortcuts.push(k); deskUpdateShortcutList(); }
  1231. }
  1232. // Remote desktop special key combos for Windows
  1233. function deskSendKeys(ks) {
  1234. if (xxdialogMode || desktop == null || desktop.State != 3) return;
  1235. // Construct the key command
  1236. if (ks == -1) { deskCustomizeKeys(); return; } // Customize
  1237. if (ks == 0x0A002E) { desktop.m.sendcad(); return; } // CTRL-ALT-DEL
  1238. //if ((desktop.contype == 1) && (ks == 0x10004C)) { desktop.sendCtrlMsg('{"action":"lock"}'); return; } // Lock desktop, WIN + L
  1239. var flags = (ks & 0xFF0000) >> 16, key = (ks & 0xFFFF), keyArray = [], keyArray2 = [];
  1240. var amtTranslate = {
  1241. 8: 0xff08, // BackSpace
  1242. 9: 0xff09, // Tab
  1243. 13: 0xff0d, // Return or Enter
  1244. 27: 0xff1b, // Escape
  1245. 45: 0xff63, // Insert
  1246. 46: 0xffff, // Delete
  1247. 36: 0xff50, // Home
  1248. 35: 0xff57, // End
  1249. 33: 0xff55, // Page Up
  1250. 34: 0xff56, // Page Down
  1251. 37: 0xff51, // Left arrow
  1252. 38: 0xff52, // Up arrow
  1253. 39: 0xff53, // Right arrow
  1254. 40: 0xff54, // Down arrow
  1255. 112: 0xffbe, // F1
  1256. 113: 0xffbf, // F2
  1257. 114: 0xffc0, // F3
  1258. 115: 0xffc1, // F4
  1259. 116: 0xffc2, // F5
  1260. 117: 0xffc3, // F6
  1261. 118: 0xffc4, // F7
  1262. 119: 0xffc5, // F8
  1263. 120: 0xffc6, // F9
  1264. 121: 0xffc7, // F10
  1265. 122: 0xffc8, // F11
  1266. 123: 0xffc9 // F12
  1267. }
  1268. // 0x010000 = Shift
  1269. // 0x020000 = Left-Alt
  1270. // 0x080000 = Ctrl
  1271. // 0x100000 = Window
  1272. if (desktop.contype == 2) {
  1273. // Intel AMT
  1274. if (flags & 1) { keyArray.push([0xffe1, 1]); keyArray2.push([0xffe1, 0]); } // Shift
  1275. if (flags & 2) { keyArray.push([0xffe9, 1]); keyArray2.push([0xffe9, 0]); } // Left-alt
  1276. if (flags & 8) { keyArray.push([0xffe3, 1]); keyArray2.push([0xffe3, 0]); } // Ctrl
  1277. if (flags & 16) { keyArray.push([0xffe7, 1]); keyArray2.push([0xffe7, 0]); } // Windows key
  1278. if (amtTranslate[key]) { key = amtTranslate[key]; }
  1279. if ((key >= 65) && (key <= 90)) { key += 32; }
  1280. if (key != 0) { keyArray.push([key, 1]); keyArray2.push([key, 0]); }
  1281. keyArray2.reverse();
  1282. for (var i = 0; i < keyArray2.length; i++) { keyArray.push(keyArray2[i]); }
  1283. desktop.m.sendkey(keyArray);
  1284. } else {
  1285. // Agent desktop
  1286. if (flags & 1) { keyArray.push([desktop.m.KeyAction.DOWN, 16]); keyArray2.push([desktop.m.KeyAction.UP, 16]); } // Shift
  1287. if (flags & 2) { keyArray.push([desktop.m.KeyAction.EXDOWN, 18]); keyArray2.push([desktop.m.KeyAction.EXUP, 18]); } // Left-alt
  1288. if (flags & 8) { keyArray.push([desktop.m.KeyAction.EXDOWN, 17]); keyArray2.push([desktop.m.KeyAction.EXUP, 17]); } // Ctrl
  1289. if (flags & 16) { keyArray.push([desktop.m.KeyAction.EXDOWN, 0x5B]); keyArray2.push([desktop.m.KeyAction.EXUP, 0x5B]); } // Windows key
  1290. if (key != 0) { keyArray.push([desktop.m.KeyAction.DOWN, key]); keyArray2.push([desktop.m.KeyAction.UP, key]); }
  1291. keyArray2.reverse();
  1292. for (var i = 0; i < keyArray2.length; i++) { keyArray.push(keyArray2[i]); }
  1293. desktop.m.SendKeyMsgKC(keyArray);
  1294. }
  1295. }
  1296. function toggleMenu(x) {
  1297. if (xxdialogMode) return;
  1298. QV('deskButtonMenu', fullscreen && !x && (currentDevicePanel == 1));
  1299. QV('termButtonMenu', fullscreen && !x && (currentDevicePanel == 5));
  1300. QV('deskkeybutton3a', fullscreen && x);
  1301. QV('deskkeybutton3b', fullscreen && !x);
  1302. }
  1303. function deskChangeMouseButton(x) {
  1304. if (xxdialogMode) return;
  1305. if (desktop == null) return;
  1306. desktop.m.SwapMouse = !desktop.m.SwapMouse;
  1307. QV('deskkeybutton4a', fullscreen && (!desktop.m.SwapMouse));
  1308. QV('deskkeybutton4b', fullscreen && (desktop.m.SwapMouse));
  1309. }
  1310. function deskChangeFullscreenZoom() {
  1311. if (xxdialogMode) return;
  1312. if (currentDevicePanel == 1) {
  1313. if (desktop == null) return;
  1314. if (fullscreenzoom == 1) { fullscreenzoom = 0.5; } else { fullscreenzoom = 1; }
  1315. QV('deskkeybutton5a', fullscreen && (fullscreenzoom == 1));
  1316. QV('deskkeybutton5b', fullscreen && (fullscreenzoom != 1));
  1317. QS('deskarea3').width = (desktop.m.ScreenWidth * fullscreenzoom) + 'px';
  1318. QS('deskarea3').height = (desktop.m.ScreenHeight * fullscreenzoom) + 'px';
  1319. deskAdjust();
  1320. }
  1321. if (currentDevicePanel == 5) {
  1322. if (terminal == null) return;
  1323. xterm.setOption('fontSize', (xterm.getOption('fontSize') == 15) ? 10 : 15)
  1324. }
  1325. }
  1326. var fullscreen = false;
  1327. var fullscreenzoom = 1;
  1328. function deskToggleFull() {
  1329. fullscreen = !fullscreen;
  1330. QV('mastheadx', !fullscreen);
  1331. QV('masthead', !fullscreen);
  1332. QV('topbar', !fullscreen);
  1333. QV('p11deviceNameHeader', !fullscreen);
  1334. QV('footer', !fullscreen);
  1335. QV('column_l_bottomgap', !fullscreen);
  1336. QV('idx_deskFullBtn2', fullscreen);
  1337. QV('deskFullBtn', !fullscreen);
  1338. QV('p10deskTopTable', !fullscreen);
  1339. QV('deskarea1', !fullscreen);
  1340. QV('deskarea4', !fullscreen);
  1341. QV('termarea1', !fullscreen);
  1342. QV('termarea4', !fullscreen);
  1343. var inputAllowed = (viewOnly == 0);
  1344. // Show full screen buttons if needed
  1345. QV('deskkeybutton1', fullscreen);
  1346. if (currentDevicePanel == 1) { // Desktop panel is being shown (1 = Desktop, 5 = Terminal)
  1347. // Move shortcut key to desktop position
  1348. QS('deskkeybutton2a').top = QS('deskkeybutton2b').top = '210px';
  1349. // Move the zoom button to normal or top position
  1350. QS('deskkeybutton5a').top = QS('deskkeybutton5b').top = (inputAllowed) ? '160px' : '60px'; // Zoom
  1351. QV('deskkeybutton2a', fullscreen && inputAllowed);
  1352. QV('deskkeybutton2b', false);
  1353. QV('deskkeybutton3a', fullscreen && inputAllowed);
  1354. QV('deskkeybutton3b', false);
  1355. QV('deskkeybutton4a', fullscreen && inputAllowed && (!desktop.m.SwapMouse));
  1356. QV('deskkeybutton4b', fullscreen && inputAllowed && (desktop.m.SwapMouse));
  1357. QV('deskkeybutton5a', fullscreen && (fullscreenzoom == 1));
  1358. QV('deskkeybutton5b', fullscreen && (fullscreenzoom != 1));
  1359. }
  1360. if (currentDevicePanel == 5) {
  1361. // Move right buttons to terminal position
  1362. //QS('deskkeybutton3a').top = QS('deskkeybutton3b').top = '60px'; // Shortcuts
  1363. //QS('deskkeybutton5a').top = QS('deskkeybutton5b').top = '110px'; // Zoom
  1364. QS('deskkeybutton2a').top = QS('deskkeybutton2b').top = '110px'; // Keyboard
  1365. QV('deskkeybutton2a', fullscreen);
  1366. QV('deskkeybutton2b', false);
  1367. QV('deskkeybutton3a', fullscreen);
  1368. QV('deskkeybutton3b', false);
  1369. QV('deskkeybutton4a', false);
  1370. QV('deskkeybutton4b', false);
  1371. QV('deskkeybutton5a', false);
  1372. QV('deskkeybutton5a', false);
  1373. //QV('deskkeybutton5a', xterm.getOption('fontSize') == 15);
  1374. //QV('deskkeybutton5b', xterm.getOption('fontSize') != 15);
  1375. }
  1376. if (fullscreen) {
  1377. QS('DeskParent').height = null;
  1378. QS('page_content').top = '0px';
  1379. QS('page_content').bottom = '0px';
  1380. if (currentDevicePanel == 1) {
  1381. QS('p10desktop').top = '0px';
  1382. QS('p10desktop').overflow = 'scroll';
  1383. QS('deskarea3').top = '0px';
  1384. QS('deskarea3').width = (desktop.m.ScreenWidth * fullscreenzoom) + 'px';
  1385. QS('deskarea3').height = (desktop.m.ScreenHeight * fullscreenzoom) + 'px';
  1386. QS('deskarea3')['padding-right'] = '55px';
  1387. }
  1388. if (currentDevicePanel == 5) {
  1389. QS('p10terminal').top = '0px';
  1390. QS('p10terminal').overflow = 'scroll';
  1391. QS('termarea3').top = '0px';
  1392. QS('termarea3').bottom = null;
  1393. QS('termarea3').right = null;
  1394. QS('termarea3')['padding-right'] = '55px';
  1395. QS('termarea3')['height'] = '100%';
  1396. }
  1397. QS('body')['background-color'] = '#000';
  1398. QS('p10')['background-color'] = '#000';
  1399. } else {
  1400. QS('DeskParent').height = '100%';
  1401. QS('page_content').top = '50px';
  1402. QS('page_content').bottom = '32px';
  1403. if (currentDevicePanel == 1) {
  1404. QS('p10desktop').top = '55px';
  1405. QS('p10desktop').overflow = 'hidden';
  1406. QS('deskarea3').top = '32px';
  1407. QS('deskarea3').left = null;
  1408. QS('deskarea3').width = '100%';
  1409. QS('deskarea3').height = 'calc(100% - 64px)';
  1410. QS('deskarea3')['padding-right'] = '';
  1411. QS('DeskParent')['margin-top'] = null;
  1412. QS('DeskParent')['margin-left'] = null;
  1413. }
  1414. if (currentDevicePanel == 5) {
  1415. //xterm.setOption('fontSize', 15)
  1416. QS('p10terminal').top = '55px';
  1417. QS('p10terminal').overflow = 'hidden';
  1418. Q('p10terminal').scrollTop = 0;
  1419. Q('p10terminal').scrollLeft = 0;
  1420. QS('termarea3').top = '32px';
  1421. QS('termarea3').bottom = '32px';
  1422. //QS('termarea3').right = '0px';
  1423. QS('termarea3')['padding-right'] = null;
  1424. QS('termarea3')['height'] = 'calc(100% - 60px)';
  1425. }
  1426. QS('body')['background-color'] = '#FFF';
  1427. QS('p10')['background-color'] = null;
  1428. }
  1429. if (currentDevicePanel == 1) { deskAdjust(); }
  1430. }
  1431. function deskAdjust() {
  1432. if (currentDevicePanel != 1) return; // If not on desktop tab, ignore this.
  1433. if (fullscreen) {
  1434. QS('Desk')['margin-top'] = null;
  1435. QS('Desk')['margin-bottom'] = null;
  1436. QS('Desk').width = '100%';
  1437. QS('Desk').height = '100%';
  1438. var parentH = Q('p10desktop').clientHeight, parentW = Q('p10desktop').clientWidth;
  1439. var deskH = Q('deskarea3').clientHeight, deskW = Q('deskarea3').clientWidth - 55;
  1440. if (parentH > deskH) { QS('deskarea3').top = ((parentH - deskH) / 2) + 'px'; } else { QS('deskarea3').top = null; }
  1441. if (parentW > deskW) { QS('deskarea3').left = ((parentW - deskW) / 2) + 'px'; } else { QS('deskarea3').left = null; }
  1442. } else {
  1443. var parentH = Q('DeskParent').clientHeight, parentW = Q('DeskParent').clientWidth;
  1444. var deskH = Q('Desk').height, deskW = Q('Desk').width;
  1445. var webPageFullScreen = false;
  1446. // Fixed aspect ratio
  1447. if ((parentH / parentW) > (deskH / deskW)) {
  1448. var hNew = ((deskH * parentW) / deskW) + 'px';
  1449. QS('Desk').height = hNew;
  1450. QS('Desk').width = '100%';
  1451. } else {
  1452. var wNew = ((deskW * parentH) / deskH) + 'px';
  1453. QS('Desk').width = wNew;
  1454. QS('Desk').height = '100%';
  1455. }
  1456. QS('DeskParent').overflow = 'hidden';
  1457. // Adjust top/bottom margins
  1458. var x = (Q('DeskParent').clientHeight - Q('Desk').clientHeight) / 2;
  1459. QS('Desk')['margin-top'] = x + 'px';
  1460. QS('Desk')['margin-bottom'] = x + 'px';
  1461. }
  1462. }
  1463. function sendSpecialKeys() {
  1464. if (xxdialogMode || desktop == null || desktop.State != 3) return;
  1465. setDialogMode(3, "Special Keys", 3, deskSendKeys);
  1466. }
  1467. // Save the desktop image to file
  1468. function deskSaveImage() {
  1469. setSessionActivity();
  1470. if (xxdialogMode || desktop == null || desktop.State != 3) return;
  1471. var d = new Date(), n = 'Desktop-' + currentNode.name + '-' + d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2) + '-' + ('0' + d.getHours()).slice(-2) + '-' + ('0' + d.getMinutes()).slice(-2);
  1472. Q('Desk')['toBlob'](function (blob) { saveAs(blob, n + '.png'); });
  1473. }
  1474. function deskSelectScreens() {
  1475. if (xxdialogMode || desktop == null || desktop.State != 3) return;
  1476. var x = '', info = desktop.m.displays;
  1477. for (var i in info) { x += '<option value=' + i + ' ' + ((desktop.m.selectedDisplay == i) ? ' selected' : '') + '>' + info[i] + '</option>'; }
  1478. x = addHtmlValue4("Screen", '<select style=width:100% id=deskdisplays>' + x + '</select>');
  1479. setDialogMode(2, "Screen Selection", 3, deskSelectScreensEx, x);
  1480. }
  1481. function deskSelectScreensEx() {
  1482. if (desktop == null || desktop.State != 3) return;
  1483. desktop.m.SetDisplay(parseInt(Q('deskdisplays').value));
  1484. }
  1485. function deskDisplayInfo(sender, info, selDisplay, selItem) {
  1486. var displayCount = 0;
  1487. for (var x in info) { displayCount++; }
  1488. QV('DeskScreens', displayCount > 1);
  1489. }
  1490. function dmousedown(e) { setSessionActivity(); if ((!xxdialogMode && desktop != null)) { if (fullscreen) { e.addx = Q('p10desktop').scrollLeft * (1 / fullscreenzoom); e.addy = Q('p10desktop').scrollTop * (1 / fullscreenzoom); } desktop.m.mousedown(e); } }
  1491. function dmouseup(e) { setSessionActivity(); if ((!xxdialogMode && desktop != null)) { if (fullscreen) { e.addx = Q('p10desktop').scrollLeft * (1 / fullscreenzoom); e.addy = Q('p10desktop').scrollTop * (1 / fullscreenzoom); } desktop.m.mouseup(e); } }
  1492. function dmousemove(e) { setSessionActivity(); if ((!xxdialogMode && desktop != null)) { if (fullscreen) { e.addx = Q('p10desktop').scrollLeft * (1 / fullscreenzoom); e.addy = Q('p10desktop').scrollTop * (1 / fullscreenzoom); } desktop.m.mousemove(e); } }
  1493. function dmousewheel(e) { setSessionActivity(); if ((!xxdialogMode && desktop != null) && desktop.m.mousewheel) { if (fullscreen) { e.addx = Q('p10desktop').scrollLeft * (1 / fullscreenzoom); e.addy = Q('p10desktop').scrollTop * (1 / fullscreenzoom); } desktop.m.mousewheel(e); haltEvent(e); return true; } return false; }
  1494. function drotate(x) { if (!xxdialogMode && desktop != null) { desktop.m.setRotation(desktop.m.rotation + x); deskAdjust(); } }
  1495. //
  1496. // TERMINAL
  1497. //
  1498. var terminalNode;
  1499. function setupTerminal() {
  1500. // Setup the terminal
  1501. if ((terminalNode != currentNode) && (terminal != null)) { terminal.Stop(); terminal = null; }
  1502. terminalNode = currentNode;
  1503. updateTerminalButtons();
  1504. }
  1505. // Show and enable the right buttons
  1506. function updateTerminalButtons() {
  1507. var termState = ((terminal != null) && (terminal.state != 0));
  1508. QE('termFullScreen', (termState != 0));
  1509. // Show the right buttons
  1510. QV('disconnectbutton2span', termState == true);
  1511. QV('connectbutton2span', termState == false);
  1512. // Enable buttons
  1513. QE('connectbutton2', true);
  1514. }
  1515. // Called when the terminal state changes
  1516. function onTerminalStateChange(xterminal, state) {
  1517. var xstate = state;
  1518. if ((xstate == 3) && (xterminal.contype == 2)) { xstate++; }
  1519. var str = StatusStrs[xstate];
  1520. if (terminal.webRtcActive == true) { str += ", WebRTC"; }
  1521. QH('termstatus', str);
  1522. switch (state) {
  1523. case 0:
  1524. // Disconnected, clear the terminal
  1525. xterm.dispose();
  1526. xterm = null;
  1527. if (terminal != null) { terminal.Stop(); terminal = null; }
  1528. break;
  1529. case 3:
  1530. xterm.focus();
  1531. break;
  1532. default:
  1533. //console.log('Unhandled onTerminalStateChange state', state);
  1534. break;
  1535. }
  1536. updateTerminalButtons();
  1537. }
  1538. // Handles a tunnel to a remote shell
  1539. function CreateRemoteTunnel(onTunnelUpdate, options) {
  1540. var obj = { protocol: 1 };
  1541. if ((options != null) && (typeof options.protocol == 'number')) { obj.protocol = options.protocol; }
  1542. obj.onTunnelUpdate = onTunnelUpdate;
  1543. obj.xxStateChange = function (state) { }
  1544. obj.ProcessBinaryData = function (data) { obj.onTunnelUpdate(data); }
  1545. obj.ProcessData = function (data) { obj.onTunnelUpdate(data); }
  1546. obj.terminalEmulation = 1;
  1547. obj.fxEmulation = 0;
  1548. obj.lineFeed = '\r\n';
  1549. return obj;
  1550. }
  1551. function tunnelUpdate(data) {
  1552. if (xterm.writeUtf8) {
  1553. if (typeof data == 'string') { xterm.writeUtf8(data); } else { xterm.writeUtf8(new Uint8Array(data)); }
  1554. } else {
  1555. if (typeof data == 'string') { xterm.write(data); } else { xterm.write(new Uint8Array(data)); }
  1556. }
  1557. }
  1558. function sshTunnelUpdate(data) {
  1559. if (typeof data == 'string') {
  1560. if (data[0] == '{') {
  1561. var j = JSON.parse(data);
  1562. switch (j.action) {
  1563. case 'sshauth': {
  1564. var x = '';
  1565. x += addHtmlValue("Authentication", '<select id=dp2authmethod style=width:150px onchange=sshAuthUpdate(event)><option value=1 selected>' + "Username & Password" + '</option><option value=2>' + "Username and Key" + '</option></select>')
  1566. x += addHtmlValue("Username", '<input id=dp2user style=width:150px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
  1567. x += '<div id=d2passauth>';
  1568. x += addHtmlValue("Password", '<input type=password id=dp2pass style=width:150px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
  1569. x += '</div><div id=d2keyauth style=display:none>';
  1570. x += addHtmlValue("Key File", '<input type=file id=dp2key style=width:150px maxlength=64 autocomplete=off onchange=sshAuthUpdate(event) />');
  1571. x += addHtmlValue("Key Password", '<input type=password id=dp2keypass style=width:150px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
  1572. x += '</div>';
  1573. x += '<label><input id=dp2keep type=checkbox>' + "Remember credentials" + '</label>';
  1574. x += '<div id=d2keyauth2 style=font-size:x-small><br />' + "Key file must be in OpenSSH format." + '</div>';
  1575. setDialogMode(2, "Authentication", 11, sshConnectEx, x, 'ssh');
  1576. setTimeout(sshAuthUpdate, 50);
  1577. break;
  1578. }
  1579. case 'sshautoauth': {
  1580. terminal.socket.send(JSON.stringify({ action: 'sshautoauth', cols: xterm.cols, rows: xterm.rows, width: Q('termarea3xdiv').offsetWidth, height: Q('termarea3xdiv').offsetHeight }));
  1581. break;
  1582. }
  1583. case 'autherror': { p12setConsoleMsg("Authentication Error", 5000); break; }
  1584. case 'sessionerror': { p12setConsoleMsg("Session expired", 5000); break; }
  1585. case 'sessiontimeout': { p12setConsoleMsg("Session timeout", 5000); break; }
  1586. }
  1587. } else if (data[0] == '~') { xterm.writeUtf8(data.substring(1)); }
  1588. }
  1589. }
  1590. function sshAuthUpdate(e) {
  1591. QV('d2passauth', Q('dp2authmethod').value == 1);
  1592. QV('d2keyauth', Q('dp2authmethod').value == 2);
  1593. QV('d2keyauth2', Q('dp2authmethod').value == 2);
  1594. if (Q('dp2authmethod').value == 1) {
  1595. QE('idx_dlgOkButton', (Q('dp2user').value.length > 0) && (Q('dp2pass').value.length > 0));
  1596. } else {
  1597. QE('idx_dlgOkButton', false);
  1598. var ok = (Q('dp2user').value.length > 0) && (Q('dp2key').files != null) && (Q('dp2key').files.length == 1) && (Q('dp2key').files[0].size < 8000);
  1599. if (ok == true) {
  1600. var reader = new FileReader();
  1601. reader.onload = function (e) {
  1602. var validkey = ((e.target.result.indexOf('-----BEGIN OPENSSH PRIVATE KEY-----') >= 0) && (e.target.result.indexOf('-----END OPENSSH PRIVATE KEY-----') >= 0));
  1603. QE('idx_dlgOkButton', validkey);
  1604. }
  1605. reader.readAsText(Q('dp2key').files[0]);
  1606. }
  1607. }
  1608. }
  1609. function sshConnectEx(b) {
  1610. if (b == 0) {
  1611. if (terminal != null) { connectTerminal(); } // Disconnect
  1612. } else {
  1613. if (Q('dp2authmethod').value == 1) {
  1614. terminal.socket.send(JSON.stringify({ action: 'sshauth', username: Q('dp2user').value, password: Q('dp2pass').value, keep: Q('dp2keep').checked, cols: xterm.cols, rows: xterm.rows, width: Q('termarea3xdiv').offsetWidth, height: Q('termarea3xdiv').offsetHeight }));
  1615. } else {
  1616. var reader = new FileReader(), username = Q('dp2user').value, keypass = Q('dp2keypass').value, keep = Q('dp2keep').checked;
  1617. reader.onload = function (e) { terminal.socket.send(JSON.stringify({ action: 'sshauth', username: username, keypass: keypass, key: e.target.result, keep: keep, cols: xterm.cols, rows: xterm.rows, width: Q('termarea3xdiv').offsetWidth, height: Q('termarea3xdiv').offsetHeight })); }
  1618. reader.readAsText(Q('dp2key').files[0]);
  1619. }
  1620. }
  1621. }
  1622. // Send the new terminal size to the agent
  1623. function xTermSendResize() {
  1624. xtermResizeTimer = null;
  1625. if ((xterm != null) && (terminal != null) && (terminal.sendCtrlMsg != null)) {
  1626. if (terminal.urlname == 'sshterminalrelay.ashx') {
  1627. terminal.socket.send(JSON.stringify({ action: 'resize', cols: xterm.cols, rows: xterm.rows, width: Q('termarea3xdiv').offsetWidth, height: Q('termarea3xdiv').offsetHeight }));
  1628. } else {
  1629. terminal.sendCtrlMsg(JSON.stringify({ ctrlChannel: '102938', type: 'termsize', cols: xterm.cols, rows: xterm.rows }));
  1630. }
  1631. }
  1632. }
  1633. function connectTerminal(e, contype, options) {
  1634. p12clearConsoleMsg();
  1635. if (!terminal) {
  1636. // Terminal setup
  1637. var termoptions = { protocol: ((options != null) && (typeof options.protocol == 'number')) ? options.protocol : 1 };
  1638. if (options && options.requireLogin) { termoptions.requireLogin = true; }
  1639. /*
  1640. if ([1, 2, 3, 4, 21, 22].indexOf(currentNode.agent.id) == -1) {
  1641. if (Q('termSizeList').value == 1) { termoptions.cols = 80; termoptions.rows = 25; termoptions.xterm = true; }
  1642. else if (Q('termSizeList').value == 2) { termoptions.cols = 100; termoptions.rows = 30; termoptions.xterm = true; }
  1643. else if (Q('termSizeList').value == 3) {
  1644. // TODO: Try to improve terminal auto-size.
  1645. termoptions.cols = Math.floor((Q('column_l').clientWidth - 60) / 10);
  1646. termoptions.rows = Math.floor((Q('column_l').clientHeight - 120) / 20);
  1647. termoptions.xterm = true;
  1648. }
  1649. }
  1650. // If shift is pressed
  1651. if ((e && (e.shiftKey == true))) {
  1652. if (currentNode.agent.id > 4) {
  1653. if (termoptions.protocol == 1) { termoptions.protocol = 7; } // Switch to user shell
  1654. } else {
  1655. if (termoptions.protocol == 1) { termoptions.protocol = 6; } // Switch to Powershell
  1656. }
  1657. }
  1658. */
  1659. // If the server requires a shell type
  1660. if ((serverinfo.linuxshell) != null && (currentNode.agent.id > 4)) {
  1661. if (serverinfo.linuxshell == 'root') { termoptions.protocol = 1; delete termoptions.requireLogin; }
  1662. if (serverinfo.linuxshell == 'user') { termoptions.protocol = 8; delete termoptions.requireLogin; }
  1663. if (serverinfo.linuxshell == 'login') { termoptions.protocol = 1; termoptions.requireLogin = true; }
  1664. }
  1665. // Setup a mesh agent xterm terminal
  1666. QV('termarea3xdiv', true);
  1667. // Setup the terminal with auto-fit
  1668. if (xterm != null) { xterm.dispose(); }
  1669. xterm = new Terminal();
  1670. xtermfit = new FitAddon.FitAddon();
  1671. if (xtermfit) { xterm.loadAddon(xtermfit); }
  1672. xterm.setOption('scrollback', 0);
  1673. //xterm.setOption('fontSize', 15);
  1674. xterm.open(Q('termarea3xdiv'));
  1675. xterm.onData(function (data) { if (terminal.urlname == 'sshterminalrelay.ashx') { terminal.socket.send('~' + data); } else { terminal.sendText(data); } })
  1676. if (xtermfit) { xtermfit.fit(); }
  1677. xterm.onResize(function (size) {
  1678. // Despam resize
  1679. if (xtermResizeTimer) clearTimeout(xtermResizeTimer);
  1680. xtermResizeTimer = setTimeout(xTermSendResize, 200);
  1681. });
  1682. // Remove terminal textarea and scrollbar.
  1683. document.getElementsByClassName('xterm-helper-textarea')[0].onfocus = () => { xterm.blur(); if (!fullscreen) toggleKeyboard(); };
  1684. document.getElementsByClassName('xterm-viewport')[0].style.overflow = 'hidden';
  1685. // Setup a terminal tunnel to the agent
  1686. terminal = CreateAgentRedirect(null, CreateRemoteTunnel(tunnelUpdate, options), serverPublicNamePort, authCookie, null, domainUrl);
  1687. terminal.debugmode = debugmode;
  1688. terminal.m.debugmode = debugmode;
  1689. terminal.options = termoptions;
  1690. terminal.options = { cols: xterm.cols, rows: xterm.rows };
  1691. if (termoptions.requireLogin) { terminal.options.requireLogin = true; }
  1692. terminal.Start(null);
  1693. terminal.onStateChanged = onTerminalStateChange;
  1694. terminal.contype = 1;
  1695. terminal.attemptWebRTC = false; // Never do WebRTC on terminal, because of a race condition we can't do it.
  1696. terminal.onConsoleMessageChange = function () { p12setConsoleMsg(terminal.consoleMessage ? formatAgentConsoleMessage(terminal.consoleMessage, terminal.consoleMessageId, terminal.consoleMessageArgs) : null, terminal.consoleMessageTimeout); }
  1697. } else {
  1698. terminal.Stop();
  1699. terminal = null;
  1700. if (fullscreen) { deskToggleFull(); }
  1701. }
  1702. Q('connectbutton2').blur(); // Deselect the connect button so the button does not get key presses.
  1703. }
  1704. //
  1705. // Terminal Shortcut Keys
  1706. //
  1707. function updateTermShortcutKeys() {
  1708. var x = '';
  1709. for (var i = 64; i <= 95; i++) { x += '<div class="menuButton" style="width:70px" onclick="termMenuButton(' + i + ')">' + "Ctrl + " + String.fromCharCode(i) + '</div>'; }
  1710. QH('termButtonMenu', x);
  1711. }
  1712. function termMenuButton(c) {
  1713. toggleMenu(true);
  1714. if (terminal.urlname == 'sshterminalrelay.ashx') {
  1715. // SSH
  1716. terminal.socket.send('~' + String.fromCharCode(c - 64));
  1717. } else {
  1718. // Agent
  1719. terminal.sendText(String.fromCharCode(c - 64));
  1720. }
  1721. }
  1722. //
  1723. // FILES
  1724. //
  1725. function setupFiles() {
  1726. // Setup the files tab
  1727. QE('p13Connect', true);
  1728. p13setActions();
  1729. }
  1730. function onFilesStateChange(xfiles, state) {
  1731. setSessionActivity();
  1732. p13Connect.value = (state == 0) ? "Connect" : "Disconnect";
  1733. var str = StatusStrs[state];
  1734. if (files.webRtcActive == true) { str += ", WebRTC"; }
  1735. Q('p13Status').textContent = str;
  1736. switch (state) {
  1737. case 0:
  1738. // Disconnected, clear the files
  1739. QH('p13files', '');
  1740. p13filetree = null;
  1741. p13filetreelocation = [];
  1742. QH('p13currentpath', '');
  1743. QE('p13FolderUp', false);
  1744. p13setActions();
  1745. if (files != null) { files.Stop(); files = null; }
  1746. if (uploadFile != null) { p13uploadFileTransferDone(); uploadFile = null; }
  1747. break;
  1748. case 3:
  1749. p13filetreelocation = [];
  1750. p13targetpath = '';
  1751. if (files) {
  1752. p13filetreelocation = p13targetpath.split('/');
  1753. files.sendText({ action: 'ls', reqid: 1, path: p13targetpath });
  1754. //if (files.serverIsRecording == true) { QV('filesRecordIcon', true); }
  1755. }
  1756. break;
  1757. default:
  1758. //console.log('Unknown onFilesStateChange state', state);
  1759. break;
  1760. }
  1761. }
  1762. function CreateRemoteFiles(onFileUpdate) {
  1763. var obj = { protocol: 5 };
  1764. obj.onFileUpdate = onFileUpdate;
  1765. obj.xxStateChange = function (state) { }
  1766. obj.ProcessData = function (data) { obj.onFileUpdate(data); }
  1767. return obj;
  1768. }
  1769. // Debug Only
  1770. var autoConnectFilesTimer = null;
  1771. function autoConnectFiles(e) { if (autoConnectFilesTimer == null) { autoConnectFilesTimer = setInterval(connectFiles, 100); } else { clearInterval(autoConnectFilesTimer); autoConnectFilesTimer = null; } }
  1772. function connectFiles(e) {
  1773. p13clearConsoleMsg();
  1774. if (!files) {
  1775. // Setup a mesh agent files
  1776. files = CreateAgentRedirect(null, CreateRemoteFiles(p13gotFiles), serverPublicNamePort, authCookie, null, domainUrl);
  1777. files.attemptWebRTC = attemptWebRTC;
  1778. files.onStateChanged = onFilesStateChange;
  1779. files.onConsoleMessageChange = function () {
  1780. if (files.consoleMessage) {
  1781. Q('p13FilesConsoleMsg').innerHTML += formatAgentConsoleMessage(files.consoleMessage, files.consoleMessageId, files.consoleMessageArgs);
  1782. QV('p13FilesConsoleMsg', true);
  1783. if (p13FilesConsoleMsgTimer != null) { clearTimeout(p13FilesConsoleMsgTimer); }
  1784. if (files.consoleMessageTimeout) { p13FilesConsoleMsgTimer = setTimeout(p13clearConsoleMsg, files.consoleMessageTimeout * 1000); }
  1785. } else {
  1786. p13clearConsoleMsg();
  1787. }
  1788. }
  1789. files.Start(null);
  1790. } else {
  1791. //QH('Term', '');
  1792. files.Stop();
  1793. files = null;
  1794. }
  1795. p13clipboard = p13clipboardFolder = null;
  1796. p13clipboardCut = 0;
  1797. p13updateClipview();
  1798. }
  1799. var p13filetree = null;
  1800. var p13targetpath = null;
  1801. var p13filetreelocation = [];
  1802. function p13gotFiles(data) {
  1803. if ((data.length > 0) && (data.charCodeAt(0) != 123)) { p13gotDownloadBinaryData(data); return; } // This is ok because 4 first bytes is a control value.
  1804. //console.log('p13gotFiles', data);
  1805. try { data = JSON.parse(decode_utf8(data)); } catch (ex) { data = JSON.parse(data); }
  1806. if (data.action == 'download') { p13gotDownloadCommand(data); return; }
  1807. // Process any SSH actions
  1808. switch (data.action) {
  1809. case 'sshauth': {
  1810. var x = '';
  1811. x += addHtmlValue("Authentication", '<select id=dp2authmethod style=width:150px onchange=sshAuthUpdate(event)><option value=1 selected>' + "Username & Password" + '</option><option value=2>' + "Username and Key" + '</option></select>')
  1812. x += addHtmlValue("Username", '<input id=dp2user style=width:150px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
  1813. x += '<div id=d2passauth>';
  1814. x += addHtmlValue("Password", '<input type=password id=dp2pass style=width:150px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
  1815. x += '</div><div id=d2keyauth style=display:none>';
  1816. x += addHtmlValue("Key File", '<input type=file id=dp2key style=width:150px maxlength=64 autocomplete=off onchange=sshAuthUpdate(event) />');
  1817. x += addHtmlValue("Key Password", '<input type=password id=dp2keypass style=width:150px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
  1818. x += '</div>';
  1819. x += '<label><input id=dp2keep type=checkbox>' + "Remember credentials" + '</label>';
  1820. x += '<div id=d2keyauth2 style=font-size:x-small><br />' + "Key file must be in OpenSSH format." + '</div>';
  1821. setDialogMode(2, "Authentication", 11, p13sshConnectEx, x, 'ssh');
  1822. setTimeout(sshAuthUpdate, 50);
  1823. break;
  1824. }
  1825. case 'autherror': { p13setConsoleMsg("Authentication Error", 5000); return; }
  1826. case 'connectionerror': { p13setConsoleMsg("Connection Error", 5000); return; }
  1827. case 'sessionerror': { p13setConsoleMsg("Session expired", 5000); return; }
  1828. case 'sessiontimeout': { p13setConsoleMsg("Session timeout", 5000); return; }
  1829. }
  1830. // Process file upload commands
  1831. if ((data.action != null) && (data.action.startsWith('upload'))) { p13gotUploadData(data); return; }
  1832. if (data.path != null) {
  1833. if (data.dir == null) {
  1834. if (p13targetpath != '') { p13folderup(); }
  1835. } else {
  1836. data.path = data.path.replace(/\//g, '\\');
  1837. if ((p13filetree != null) && (data.path == p13filetree.path)) {
  1838. // This is an update to the same folder
  1839. var checkedNames = p13getCheckedNames();
  1840. p13filetree = data;
  1841. p13updateFiles(checkedNames);
  1842. } else {
  1843. // Make both paths use the same seperator not start with /
  1844. var x1 = data.path.replace(/\//g, '\\'), x2 = p13targetpath.replace(/\//g, '\\');
  1845. while ((x1.length > 0) && (x1[0] == '\\')) { x1 = x1.substring(1); }
  1846. while ((x2.length > 0) && (x2[0] == '\\')) { x2 = x2.substring(1); }
  1847. if ((x1 == x2) || ((data.path == '\\') && (p13targetpath == ''))) {
  1848. // This is a different folder
  1849. p13filetree = data;
  1850. p13updateFiles();
  1851. }
  1852. }
  1853. }
  1854. }
  1855. }
  1856. function p13sshConnectEx(b) {
  1857. if (b == 0) {
  1858. if (files != null) { connectFiles(); } // Disconnect
  1859. } else {
  1860. if (Q('dp2authmethod').value == 1) {
  1861. files.socket.send(JSON.stringify({ action: 'sshauth', username: Q('dp2user').value, password: Q('dp2pass').value, keep: Q('dp2keep').checked }));
  1862. } else {
  1863. var reader = new FileReader(), username = Q('dp2user').value, keypass = Q('dp2keypass').value, keep = Q('dp2keep').checked;
  1864. reader.onload = function (e) { files.socket.send(JSON.stringify({ action: 'sshauth', username: username, keypass: keypass, key: e.target.result, keep: keep })); }
  1865. reader.readAsText(Q('dp2key').files[0]);
  1866. }
  1867. }
  1868. }
  1869. function p13getCheckedNames() {
  1870. // Save all existing checked boxes
  1871. var checkedNames = [], checkboxes = document.getElementsByName('fd');
  1872. for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked) { checkedNames.push(p13filetree.dir[checkboxes[i].value].n) }; }
  1873. return checkedNames;
  1874. }
  1875. function p13updateFiles(checkedNames) {
  1876. var html1 = '', html2 = '', displayPath = '<a style=cursor:pointer;color:black onclick=p13folderup(0)>' + "Root" + '</a>', fullPath = 'Root';
  1877. // Work on parsing the file path
  1878. var x = p13filetree.path.split('\\');
  1879. p13filetreelocation = [];
  1880. for (var i in x) { if (x[i] != '') { p13filetreelocation.push(x[i]); } } // Remove empty spaces
  1881. for (var i in p13filetreelocation) { displayPath += ' / <a style=cursor:pointer;color:black onclick=p13folderup(' + (parseInt(i) + 1) + ')>' + EscapeHtml(p13filetreelocation[i]) + '</a>' } // Setup the path we display
  1882. var newlinkpath = p13filetreelocation.join('/');
  1883. // Sort the files
  1884. var filetreexx = p13sort_files(p13filetree.dir);
  1885. // Display all files and folders at this location
  1886. for (var i in filetreexx) {
  1887. // Figure out the name and shortname
  1888. var f = filetreexx[i], name = f.n, shortname;
  1889. // shortname = name;
  1890. // if (name.length > 70) { shortname = EscapeHtml(name.substring(0, 70)) + "..."; } else { shortname = EscapeHtml(name); }
  1891. // Removed redundant filename length check because we handle it in the CSS
  1892. shortname = EscapeHtml(name);
  1893. // Figure out the size
  1894. var fsize = '';
  1895. if (f.s != null) { fsize = getFileSizeStr(f.s); }
  1896. var h = '';
  1897. if (f.t < 3) {
  1898. var right = '';
  1899. h = '<div class=filelist file=999><input file=999 style=float:left name=fd class=fcb type=checkbox onchange=p13setActions() value=\'' + f.nx + '\'>&nbsp;<span style=float:right>' + right + '</span><span title="' + shortname + '"><div class=fileIcon' + f.t + '></div><a style=cursor:pointer onclick=p13folderset("' + encodeURIComponent(f.nx) + '")>' + shortname + '</a></span></div>';
  1900. } else {
  1901. var link = shortname;
  1902. if (f.s > 0) { link = '<a rel=\"noreferrer noopener\" target=\"_blank\" style=cursor:pointer onclick=\"p13downloadfile(\'' + encodeURIComponent(newlinkpath + '/' + name) + '\',\'' + encodeURIComponent(name) + '\',' + f.s + ')\">' + shortname + '</a>'; }
  1903. h = '<div class=filelist file=3><input file=3 style=float:left name=fd class=fcb type=checkbox onchange=p13setActions() value=\'' + f.nx + '\'>&nbsp;<span style=float:right;padding-right:4px>' + fsize + '</span><span title="' + shortname + '"><div class=fileIcon' + f.t + '></div>' + link + '</span></div>';
  1904. }
  1905. if (f.t < 3) { html1 += h; } else { html2 += h; }
  1906. }
  1907. // Display the files and path
  1908. QH('p13files', html1 + html2);
  1909. QH('p13currentpath', displayPath);
  1910. QE('p13FolderUp', p13filetreelocation.length != 0);
  1911. // Re-check all boxes if needed using names
  1912. if (checkedNames != null) { var checkboxes = document.getElementsByName('fd'); for (var i = 0; i < checkboxes.length; i++) { if (checkedNames.indexOf(p13filetree.dir[checkboxes[i].value].n) >= 0) { checkboxes[i].checked = true; } } }
  1913. // Update the actions buttons
  1914. p13setActions();
  1915. }
  1916. function p13folderset(x) {
  1917. p13targetpath = joinPaths(p13filetree.path, p13filetree.dir[x].n).split('\\').join('/');
  1918. if (files) {
  1919. files.sendText({ action: 'ls', reqid: 1, path: p13targetpath });
  1920. }
  1921. }
  1922. function p13folderup(x) {
  1923. if (x == null) { p13filetreelocation.pop(); } else { while (p13filetreelocation.length > x) { p13filetreelocation.pop(); } }
  1924. p13targetpath = p13filetreelocation.join('/');
  1925. if (files) {
  1926. files.sendText({ action: 'ls', reqid: 1, path: p13targetpath });
  1927. }
  1928. }
  1929. var p13sortorder;
  1930. function p13sort_filename(a, b) { if (a.ln > b.ln) return (1 * p13sortorder); if (a.ln < b.ln) return (-1 * p13sortorder); return 0; }
  1931. function p13sort_timestamp(a, b) { if (a.d > b.d) return (1 * p13sortorder); if (a.d < b.d) return (-1 * p13sortorder); return 0; }
  1932. function p13sort_bysize(a, b) { if (a.s == b.s) return p13sort_filename(a, b); return (((a.s - b.s)) * p13sortorder); }
  1933. function p13sort_files(files) {
  1934. var r = [], sortselection = Q('p13sortdropdown').value;
  1935. for (var i in files) { files[i].nx = i; if (files[i].s == null) { files[i].s = 0; } if (files[i].n == null) { files[i].n = i; } files[i].ln = files[i].n.toLowerCase(); r.push(files[i]); }
  1936. p13sortorder = 1;
  1937. if (sortselection > 3) { p13sortorder = -1; sortselection -= 3; }
  1938. if (sortselection == 1) { r.sort(p13sort_filename); }
  1939. else if (sortselection == 2) { r.sort(p13sort_bysize); }
  1940. else if (sortselection == 3) { r.sort(p13sort_timestamp); }
  1941. return r;
  1942. }
  1943. function p13setActions() {
  1944. var advancedFeatures = true; //((currentNode.agent) && (currentNode.agent.id != 14)); // Reduct file feature on some devices.
  1945. if (p13filetree == null) {
  1946. QE('p13DeleteFileButton', false);
  1947. QE('p13NewFolderButton', false);
  1948. QE('p13UploadButton', false);
  1949. QE('p13RenameFileButton', false);
  1950. QE('p13SelectAllButton', false);
  1951. Q('p13SelectAllButton').value = "All";
  1952. QE('p13RefreshButton', false);
  1953. QE('p13CutButton', false);
  1954. QE('p13CopyButton', false);
  1955. QE('p13PasteButton', false);
  1956. } else {
  1957. var cc = p13getFileSelCount(), tc = p13getFileCount(), sfc = p13getFileSelCount(false); // In order: number of entires selected, number of total entries, number of selected entires that are files (not folders)
  1958. var winAgent = true; //((currentNode.agent.id > 0) && (currentNode.agent.id < 5)) || (currentNode.agent.id == 14) || (currentNode.agent.id == 34);
  1959. QE('p13DeleteFileButton', advancedFeatures && (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false)));
  1960. QE('p13NewFolderButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)));
  1961. QE('p13UploadButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)));
  1962. QE('p13RenameFileButton', advancedFeatures && (cc == 1) && ((p13filetreelocation.length > 0) || (winAgent == false)));
  1963. QE('p13SelectAllButton', tc > 0);
  1964. Q('p13SelectAllButton').value = (cc > 0 ? "None" : "All");
  1965. QE('p13RefreshButton', true);
  1966. //QE('p13FindButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)));
  1967. QE('p13CutButton', advancedFeatures && (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false)));
  1968. QE('p13CopyButton', advancedFeatures && (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false)));
  1969. //QE('p13ZipButton', advancedFeatures && (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false)));
  1970. QE('p13PasteButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)) && ((p13clipboard != null) && (p13clipboard.length > 0)));
  1971. }
  1972. }
  1973. function p13getFileSelCount(includeDirs) { var cc = 0; var checkboxes = document.getElementsByName('fd'); for (var i = 0; i < checkboxes.length; i++) { if ((checkboxes[i].checked) && ((includeDirs != false) || (checkboxes[i].attributes.file.value == '3'))) cc++; } return cc; }
  1974. function p13getFileSelDirCount() { var cc = 0, checkboxes = document.getElementsByName('fd'); for (var i = 0; i < checkboxes.length; i++) { if ((checkboxes[i].checked) && (checkboxes[i].attributes.file.value == '999')) cc++; } return cc; }
  1975. function p13getFileCount() { var cc = 0; var checkboxes = document.getElementsByName('fd'); return checkboxes.length; }
  1976. function p13selectallfile() { var nv = (p13getFileSelCount() == 0), checkboxes = document.getElementsByName('fd'); for (var i = 0; i < checkboxes.length; i++) { checkboxes[i].checked = nv; } p13setActions(); }
  1977. function p13createfolder() { setDialogMode(2, "New Folder", 3, p13createfolderEx, '<input type=text id=p13renameinput maxlength=64 onkeyup=p13fileNameCheck(event) style=width:100% />'); focusTextBox('p13renameinput'); p13fileNameCheck(); }
  1978. function p13createfolderEx() { files.sendText({ action: 'mkdir', reqid: 1, path: p13filetreelocation.join('/') + '/' + Q('p13renameinput').value }); p13folderup(999); }
  1979. function p13deletefile() { var cc = p13getFileSelCount(), rec = (p13getFileSelDirCount() > 0) ? '<br /><br /><label><input type=checkbox id=p13recdeleteinput>' + "Recursive delete" + '</label><br>' : '<input type=checkbox id=p13recdeleteinput style=\'display:none\'>'; setDialogMode(2, "Delete", 3, p13deletefileEx, (cc > 1) ? (format("Delete {0} selected items?", cc) + rec) : ("Delete selected item?" + rec)); }
  1980. function p13deletefileEx() { var delfiles = [], checkboxes = document.getElementsByName('fd'); for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked) { delfiles.push(p13filetree.dir[checkboxes[i].value].n); } } files.sendText({ action: 'rm', reqid: 1, path: p13filetreelocation.join('/'), delfiles: delfiles, rec: Q('p13recdeleteinput').checked }); p13folderup(999); }
  1981. function p13renamefile() { var renamefile, checkboxes = document.getElementsByName('fd'); for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked) { renamefile = p13filetree.dir[checkboxes[i].value].n; } } setDialogMode(2, "Rename", 3, p13renamefileEx, '<input type=text id=p13renameinput maxlength=64 onkeyup=p13fileNameCheck(event) style=width:100% value="' + renamefile + '" />', { action: 'rename', path: p13filetreelocation.join('/'), oldname: renamefile }); focusTextBox('p13renameinput'); p13fileNameCheck(); }
  1982. function p13renamefileEx(b, t) { t.newname = Q('p13renameinput').value; files.sendText(t); p13folderup(999); }
  1983. function p13fileNameCheck(e) { var x = isFilenameValid(Q('p13renameinput').value); QE('idx_dlgOkButton', x); if ((x == true) && (e != null) && (e.keyCode == 13)) { dialogclose(1); } }
  1984. function p13uploadFile() { setDialogMode(2, "Upload File", 3, p13uploadFileEx, '<input type=file name=files id=p13uploadinput style=width:100% multiple=multiple onchange="updateUploadDialogOk(\'p13uploadinput\')" />'); updateUploadDialogOk('p13uploadinput'); }
  1985. function p13uploadFileEx() { p13doUploadFiles(Q('p13uploadinput').files); }
  1986. function p13viewfile() {
  1987. var checkboxes = document.getElementsByName('fd');
  1988. for (var i = 0; i < checkboxes.length; i++) {
  1989. if (checkboxes[i].checked) {
  1990. if (p13filetree.dir[checkboxes[i].value].s <= 204800) {
  1991. p13downloadfile(encodeURIComponent(p13filetreelocation.join('/') + '/' + p13filetree.dir[checkboxes[i].value].n), encodeURIComponent(p13filetree.dir[checkboxes[i].value].n), p13filetree.dir[checkboxes[i].value].s, 'viewer');
  1992. } else { messagebox("File Editor", "Only files less than 200k can be edited."); }
  1993. break;
  1994. }
  1995. }
  1996. }
  1997. var p13clipboard = null, p13clipboardFolder = null, p13clipboardCut = 0;
  1998. function p13copyFile(cut) { var checkboxes = document.getElementsByName('fd'); p13clipboard = []; p13clipboardCut = cut, p13clipboardFolder = p13targetpath; for (var i = 0; i < checkboxes.length; i++) { if ((checkboxes[i].checked) && (checkboxes[i].attributes.file.value == '3')) { p13clipboard.push(p13filetree.dir[checkboxes[i].value].n); } } p13updateClipview(); }
  1999. function p13pasteFile() {
  2000. var x = '';
  2001. if ((p13clipboard != null) && (p13clipboard.length > 0)) {
  2002. if (p13clipboardCut == 0) {
  2003. if (p13clipboard.length > 1) { x = format("Confirm copy of {0} entries's to this location?", p13clipboard.length); } else { x = format("Confirm copy of 1 entrie to this location?"); }
  2004. } else {
  2005. if (p13clipboard.length > 1) { x = format("Confirm move of {0} entries's to this location?", p13clipboard.length); } else { x = format("Confirm move of 1 entrie to this location?"); }
  2006. }
  2007. }
  2008. setDialogMode(2, "Paste", 3, p13pasteFileEx, x);
  2009. }
  2010. function p13pasteFileEx() { files.sendText({ action: (p13clipboardCut == 0 ? 'copy' : 'move'), reqid: 1, scpath: p13clipboardFolder, dspath: p13targetpath, names: p13clipboard }); p13folderup(999); if (p13clipboardCut == 1) { p13clipboard = null, p13clipboardFolder = null, p13clipboardCut = 0; p13updateClipview(); } }
  2011. function p13updateClipview() {
  2012. var x = '';
  2013. if ((p13clipboard != null) && (p13clipboard.length > 0)) {
  2014. if (p13clipboardCut == 0) {
  2015. if (p13clipboard.length > 1) {
  2016. x = format("Holding {0} entries for copy" + ', <a href=# onclick="return p13clearClip()" style=cursor:pointer>' + "Clear" + '</a>.', p13clipboard.length);
  2017. } else {
  2018. x = format("Holding 1 entrie for copy" + ', <a href=# onclick="return p13clearClip()" style=cursor:pointer>' + "Clear" + '</a>.');
  2019. }
  2020. } else {
  2021. if (p13clipboard.length > 1) {
  2022. x = format("Holding {0} entries for move" + ', <a href=# onclick="return p13clearClip()" style=cursor:pointer>' + "Clear" + '</a>.', p13clipboard.length);
  2023. } else {
  2024. x = format("Holding 1 entrie for move" + ', <a href=# onclick="return p13clearClip()" style=cursor:pointer>' + "Clear" + '</a>.');
  2025. }
  2026. }
  2027. }
  2028. QH('p13bottomstatus', x);
  2029. p13setActions();
  2030. }
  2031. function p13clearClip() { p13clipboard = null; p13clipboardFolder = null; p13clipboardCut = 0; p13updateClipview(); return false; } function updateUploadDialogOk(x) { QE('idx_dlgOkButton', Q(x).value != ''); }
  2032. function getFileSelCount(includeDirs) { var cc = 0; var checkboxes = document.getElementsByName('fc'); for (var i = 0; i < checkboxes.length; i++) { if ((checkboxes[i].checked) && ((includeDirs != false) || (checkboxes[i].attributes.file.value == "3"))) cc++; } return cc; }
  2033. function getFileCount() { var cc = 0; var checkboxes = document.getElementsByName('fc'); return checkboxes.length; }
  2034. //
  2035. // FILES DOWNLOAD
  2036. //
  2037. var downloadFile; // Global state for file download
  2038. // Called by the html page to start a download, arguments are: path, file name and file size.
  2039. function p13downloadfile(x, y, z) {
  2040. if (xxdialogMode || downloadFile || !files) return;
  2041. downloadFile = { path: decodeURIComponent(x), file: decodeURIComponent(y), size: z, tsize: 0, data: '', state: 0, id: Math.random() }
  2042. //console.log('p13downloadFileCancel', downloadFile);
  2043. files.sendText({ action: 'download', sub: 'start', id: downloadFile.id, path: downloadFile.path });
  2044. setDialogMode(2, "Download File", 10, p13downloadFileCancel, '<div>' + downloadFile.file + '</div><br /><progress id=d2progressBar style=width:100% value=0 max=' + z + ' />');
  2045. }
  2046. // Called by the html page to cancel the download
  2047. function p13downloadFileCancel() { setDialogMode(0); files.sendText({ action: 'download', sub: 'cancel', id: downloadFile.id }); downloadFile = null; }
  2048. // Called by the transport when download control command is received
  2049. function p13gotDownloadCommand(cmd) {
  2050. //console.log('p13gotDownloadCommand', cmd);
  2051. if ((downloadFile == null) || (cmd.id != downloadFile.id)) return;
  2052. if (cmd.sub == 'start') { downloadFile.state = 1; files.sendText({ action: 'download', sub: 'startack', id: downloadFile.id }); }
  2053. else if (cmd.sub == 'cancel') { downloadFile = null; setDialogMode(0); }
  2054. }
  2055. // Called by the transport when binary data is received
  2056. function p13gotDownloadBinaryData(data) {
  2057. if (!downloadFile || downloadFile.state == 0) return;
  2058. if (data.length > 4) {
  2059. downloadFile.tsize += (data.length - 4); // Add to the total bytes received
  2060. downloadFile.data += data.substring(4); // Append the data
  2061. Q('d2progressBar').value = downloadFile.tsize; // Change the progress bar
  2062. }
  2063. if ((ReadInt(data, 0) & 1) != 0) { // Check end flag
  2064. saveAs(data2blob(downloadFile.data), downloadFile.file); downloadFile = null; setDialogMode(0); // Save the file
  2065. } else {
  2066. files.sendText({ action: 'download', sub: 'ack', id: downloadFile.id }); // Send the ACK
  2067. }
  2068. }
  2069. //
  2070. // FILES UPLOAD
  2071. //
  2072. var uploadFile;
  2073. function p13doUploadFiles(files) {
  2074. if (xxdialogMode) return;
  2075. // Check if we are going to overwrite any files
  2076. var winAgent = true; //((currentNode.agent.id > 0) && (currentNode.agent.id < 5)) || (currentNode.agent.id == 14) || (currentNode.agent.id == 34);
  2077. var targetFiles = [], overWriteCount = 0;
  2078. for (var i in p13filetree.dir) { if (winAgent) { targetFiles.push(p13filetree.dir[i].n.toLowerCase()); } else { targetFiles.push(p13filetree.dir[i].n); } }
  2079. for (var i = 0; i < files.length; i++) {
  2080. if (winAgent) {
  2081. if (targetFiles.indexOf(files[i].name.toLowerCase()) >= 0) { overWriteCount++; }
  2082. } else {
  2083. if (targetFiles.indexOf(files[i].name) >= 0) { overWriteCount++; }
  2084. }
  2085. }
  2086. if (overWriteCount == 0) {
  2087. // If no overwrite, go ahead with upload
  2088. p13uploadFileContinue(1, files);
  2089. } else {
  2090. // Otherwise, prompt for confirmation
  2091. setDialogMode(2, "Upload File", 3, p13uploadFileContinue, format((overWriteCount == 1) ? "Upload will overwrite 1 file. Continue?" : "Upload will overwrite {0} files. Continue?", overWriteCount), files);
  2092. }
  2093. }
  2094. function p13uploadFileContinue(b, files) {
  2095. uploadFile = {};
  2096. uploadFile.xpath = p13filetreelocation.join('/');
  2097. uploadFile.xfiles = files;
  2098. uploadFile.xfilePtr = -1;
  2099. setDialogMode(2, "Upload File", 10, p13uploadFileCancel, '<div id=p13dfileName>' + "Connecting..." + '</div><br /><progress id=d2progressBar style=width:100% value=0 max=0 />');
  2100. p13uploadNextFile();
  2101. }
  2102. // Perform SHA-384 hashing
  2103. const byteToHex = [];
  2104. for (var n = 0; n <= 0xff; ++n) { var hexOctet = n.toString(16).padStart(2, '0'); byteToHex.push(hexOctet); }
  2105. function arrayBufferToHex(arrayBuffer) { return Array.prototype.map.call(new Uint8Array(arrayBuffer), n => byteToHex[n]).join(''); }
  2106. function performHash(data, f) { window.crypto.subtle.digest('SHA-384', data).then(function (v) { f(arrayBufferToHex(v)); }, function () { f(null); }); }
  2107. function performHashOnFile(file, f) {
  2108. // TODO: At some point, try to make this work for files of unlimited size using a digest stream
  2109. var reader = new FileReader();
  2110. reader.onerror = function (err) { f(null); }
  2111. reader.onload = function () { window.crypto.subtle.digest('SHA-384', reader.result).then(function (v) { f(arrayBufferToHex(v)); }, function () { f(null); }); };
  2112. reader.readAsArrayBuffer(file);
  2113. }
  2114. // Push the next file
  2115. function p13uploadNextFile() {
  2116. uploadFile.xfilePtr++;
  2117. if (uploadFile.xfiles.length > uploadFile.xfilePtr) {
  2118. uploadFile.xptr = 0;
  2119. var file = uploadFile.xfiles[uploadFile.xfilePtr];
  2120. QH('p13dfileName', file.name);
  2121. Q('d2progressBar').max = file.size;
  2122. Q('d2progressBar').value = 0;
  2123. if (file.xdata == null) {
  2124. uploadFile.xfile = file;
  2125. // If the remote file already exists and is smaller then our file, see if we can resume the trasfer
  2126. var f = null;
  2127. for (var i in p13filetree.dir) { if (p13filetree.dir[i].n == file.name) { f = p13filetree.dir[i]; } }
  2128. if ((f != null) && (f.s <= uploadFile.xfile.size)) {
  2129. performHashOnFile(uploadFile.xfile, function (hash) { files.sendText(JSON.stringify({ action: 'uploadhash', reqid: uploadFile.xfilePtr, path: uploadFile.xpath, name: file.name, tag: { h: hash.toUpperCase(), s: f.s, skip: f.s == uploadFile.xfile.size } })); });
  2130. } else {
  2131. files.sendText(JSON.stringify({ action: 'upload', reqid: uploadFile.xfilePtr, path: uploadFile.xpath, name: file.name, size: uploadFile.xfile.size }));
  2132. }
  2133. } else {
  2134. // Data already loaded
  2135. uploadFile.xdata = file.xdata;
  2136. files.sendText(JSON.stringify({ action: 'upload', reqid: uploadFile.xfilePtr, path: uploadFile.xpath, name: file.name, size: uploadFile.xdata.byteLength }));
  2137. }
  2138. } else {
  2139. p13uploadFileTransferDone();
  2140. }
  2141. }
  2142. // Used to cancel the entire transfer.
  2143. function p13uploadFileCancel(button, tag) {
  2144. if (uploadFile != null) { files.sendText(JSON.stringify({ action: 'uploadcancel', reqid: uploadFile.xfilePtr })); uploadFile = null; }
  2145. p13uploadFileTransferDone();
  2146. }
  2147. // Used to cancel the entire transfer.
  2148. function p13uploadFileTransferDone() {
  2149. uploadFile = null; // No more files to upload, clean up.
  2150. setDialogMode(0); // Close the dialog box
  2151. p13folderup(9999); // Refresh the current folder
  2152. }
  2153. // Receive upload ack from the mesh agent, use this to keep sending more data
  2154. function p13gotUploadData(cmd) {
  2155. if ((uploadFile == null) || (parseInt(uploadFile.xfilePtr) != parseInt(cmd.reqid))) { return; }
  2156. switch (cmd.action) {
  2157. case 'uploadstart': { uploadFile.xdataPriming = 8; p13uploadNextPart(false); break; } // Send 8 more blocks of 16k to fill the websocket.
  2158. case 'uploadack': { p13uploadNextPart(false); break; }
  2159. case 'uploaddone': { if (uploadFile.xfiles.length > uploadFile.xfilePtr + 1) { p13uploadNextFile(); } else { p13uploadFileTransferDone(); } break; }
  2160. case 'uploaderror': { p13uploadFileCancel(); break; }
  2161. case 'uploadhash': {
  2162. var file = uploadFile.xfiles[uploadFile.xfilePtr];
  2163. if (file) {
  2164. if (cmd.tag.h === cmd.hash) {
  2165. if (cmd.tag.skip) {
  2166. p13uploadNextFile();
  2167. } else {
  2168. uploadFile.xptr = cmd.tag.s;
  2169. files.sendText(JSON.stringify({ action: 'upload', reqid: uploadFile.xfilePtr, path: uploadFile.xpath, name: file.name, size: uploadFile.xfile.size, append: true }));
  2170. }
  2171. } else {
  2172. files.sendText(JSON.stringify({ action: 'upload', reqid: uploadFile.xfilePtr, path: uploadFile.xpath, name: file.name, size: uploadFile.xfile.size, append: false }));
  2173. }
  2174. }
  2175. break;
  2176. }
  2177. }
  2178. }
  2179. // Push the next part of the file into the websocket. If dataPriming is true, push more data only if it's not the last block of the file.
  2180. function p13uploadNextPart(dataPriming) {
  2181. if (uploadFile.xreader != null) return; // Data reading already in process
  2182. if (uploadFile.xptr >= uploadFile.xfile.size) return;
  2183. var end = uploadFile.xptr + 65536;
  2184. if (end > uploadFile.xfile.size) { if (dataPriming == true) { return; } end = uploadFile.xfile.size; }
  2185. uploadFile.xreader = new FileReader();
  2186. uploadFile.xreader.onerror = function (err) { console.log(err); }
  2187. uploadFile.xreader.onload = function () {
  2188. var data = uploadFile.xreader.result;
  2189. delete uploadFile.xreader;
  2190. if (data == null) return;
  2191. var dataslice = new Uint8Array(data)
  2192. if ((dataslice[0] == 123) || (dataslice[0] == 0)) {
  2193. var datapart = new Uint8Array(data.byteLength + 1);
  2194. datapart.set(dataslice, 1); // Add a zero char at the start of the send, this will indicate that it's not a JSON command.
  2195. files.send(datapart);
  2196. } else {
  2197. files.send(dataslice); // The data does not start with 0 or 123 "{" so it can't be confused for JSON.
  2198. }
  2199. uploadFile.xptr = end;
  2200. Q('d2progressBar').value = end;
  2201. if (uploadFile.xptr >= uploadFile.xfile.size) {
  2202. files.sendText(JSON.stringify({ action: 'uploaddone', reqid: uploadFile.xfilePtr }));
  2203. } else {
  2204. if (uploadFile.xdataPriming > 0) { uploadFile.xdataPriming--; p13uploadNextPart(true); }
  2205. }
  2206. };
  2207. uploadFile.xreader.readAsArrayBuffer(uploadFile.xfile.slice(uploadFile.xptr, end));
  2208. }
  2209. //
  2210. // PANELS
  2211. //
  2212. var xxcurrentView = -1;
  2213. function go(x) {
  2214. setSessionActivity();
  2215. if (xxdialogMode || xxcurrentView == x) return;
  2216. updateFooterMenu();
  2217. setDialogMode(0);
  2218. // Edit this line when adding a new screen
  2219. for (var i = 0; i < 32; i++) { QV('p' + i, i == x); }
  2220. xxcurrentView = x;
  2221. }
  2222. //
  2223. // POPUP DIALOG
  2224. //
  2225. // undefined = Hidden, 1 = Generic Message
  2226. var xxdialogMode;
  2227. var xxdialogFunc;
  2228. var xxdialogButtons;
  2229. var xxdialogTag;
  2230. // Display a dialog box
  2231. // Parameters: Dialog Mode (0 = none), Dialog Title, Buttons (1 = OK, 2 = Cancel, 3 = OK & Cancel), Call back function(0 = Cancel, 1 = OK), Dialog Content (Mode 2 only)
  2232. function setDialogMode(x, y, b, f, c, tag) {
  2233. setSessionActivity();
  2234. xxdialogMode = x;
  2235. xxdialogFunc = f;
  2236. xxdialogButtons = b;
  2237. xxdialogTag = tag;
  2238. QE('idx_dlgOkButton', true);
  2239. QV('idx_dlgOkButton', b & 1);
  2240. QV('idx_dlgCancelButton', b & 2);
  2241. QV('id_dialogclose', (b & 2) || (b & 8));
  2242. QV('idx_dlgDeleteButton', b & 4);
  2243. QV('idx_dlgButtonBar', b & 7);
  2244. if (y) QH('id_dialogtitle', y);
  2245. for (var i = 1; i < 24; i++) { QV('dialog' + i, i == x); } // Edit this line when more dialogs are added
  2246. QV('dialog', x);
  2247. if (c) { if (x == 2) { QH('id_dialogOptions', c); } else { QH('id_dialogMessage', c); } }
  2248. }
  2249. function dialogclose(x) {
  2250. setSessionActivity();
  2251. var f = xxdialogFunc;
  2252. var b = xxdialogButtons;
  2253. var t = xxdialogTag;
  2254. setDialogMode();
  2255. if (((b & 8) || x) && f) f(x, t);
  2256. }
  2257. //
  2258. // Generic Methods
  2259. //
  2260. function getNodeAmtVersion(node) { if ((node == null) || (node.intelamt == null) || (typeof node.intelamt.ver != 'string')) return 0; var verSplit = node.intelamt.ver.split('.'); if (verSplit.length < 2) return 0; return parseInt(verSplit[0]) + (parseInt(verSplit[1]) / 100); }
  2261. function putstore(name, val) { try { if ((typeof (localStorage) === 'undefined') || (localStorage.getItem(name) == val)) return; if (val == null) { localStorage.removeItem(name); } else { localStorage.setItem(name, val); } } catch (e) { } if (name[0] != '_') { var s = {}; for (var i = 0, len = localStorage.length; i < len; ++i) { var k = localStorage.key(i); if (k[0] != '_') { s[k] = localStorage.getItem(k); } } } }
  2262. function getstore(name, val) { try { if (typeof (localStorage) === 'undefined') return val; var v = localStorage.getItem(name); if ((v == null) || (v == null)) return val; return v; } catch (e) { return val; } }
  2263. function center() { if (xtermfit) xtermfit.fit(); QS('dialog').left = ((((getDocWidth() - 300) / 2)) + 'px'); deskAdjust(); }
  2264. function messagebox(t, m) { QH('id_dialogMessage', m); setDialogMode(1, t, 1); }
  2265. function statusbox(t, m) { QH('id_dialogMessage', m); setDialogMode(1, t); }
  2266. function getDocWidth() { if (window.innerWidth) return window.innerWidth; if (document.documentElement && document.documentElement.clientWidth && document.documentElement.clientWidth != 0) return document.documentElement.clientWidth; return document.getElementsByTagName('body')[0].clientWidth; }
  2267. function haltEvent(e) { if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; }
  2268. function haltReturn(e) { if (e.keyCode == 13) { haltEvent(e); } }
  2269. function validateEmail(v) { var emailReg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return emailReg.test(v); }
  2270. function reload() { window.location.href = window.location.href; }
  2271. function getNodeFromId(id) { for (var i in nodes) { if (nodes[i]._id == id) return nodes[i]; } return null; }
  2272. function addHtmlValue(t, v) { return '<table><td style=width:120px>' + t + '<td><b>' + v + '</b></table>'; }
  2273. function addHtmlValue2(t, v) { return '<div><div style=display:inline-block;float:right>' + v + '</div><div style=display:inline-block>' + t + '</div></div>'; }
  2274. function addHtmlValue4(t, v) { return '<table style=width:100%><td style=width:120px>' + t + '<td style=text-align:right><b>' + v + '</b></table>'; }
  2275. function addLink(x, f) { return '<a style=cursor:pointer;text-decoration:none onclick=\'' + f + '\'>&diams; ' + x + '</a>'; }
  2276. function addLinkConditional(x, f, c) { if (c) return addLink(x, f); return x; }
  2277. function passwordcheck(p) { var re = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()]).{8,}/; return re.test(p); }
  2278. function getFileSizeStr(size) { if (typeof size != 'number') { size = 0; } if (size == 1) return "1 byte"; return format('{0} bytes', size); }
  2279. function focusTextBox(x) { setTimeout(function () { Q(x).selectionStart = Q(x).selectionEnd = 65535; Q(x).focus(); }, 0); }
  2280. var isFilenameValid = (function () { var x1 = /^[^\\/:\*\?"<>\|]+$/, x2 = /^\./, x3 = /^(nul|prn|con|lpt[0-9]|com[0-9])(\.|$)/i; return function isFilenameValid(fname) { return x1.test(fname) && !x2.test(fname) && !x3.test(fname) && (fname[0] != '.'); } })();
  2281. function printDate(d) { return d.toLocaleDateString(args.locale); }
  2282. function printTime(d) { return d.toLocaleTimeString(args.locale); }
  2283. function printDateTime(d) { return d.toLocaleString(args.locale); }
  2284. function format(format) { var args = Array.prototype.slice.call(arguments, 1); return format.replace(/{(\d+)}/g, function (match, number) { return typeof args[number] != 'undefined' ? args[number] : match; }); };
  2285. function nobreak(x) { return x.split(' ').join('&nbsp;'); }
  2286. function getUserName(userid) { if (users && users[userid] != null) return users[userid].name; return userid.split('/')[2]; }
  2287. function addDetailItem(title, value, state) { return '<table style=width:100%><td>' + nobreak(title) + '<td style=text-align:right>' + value + '</table>'; }
  2288. function isPrivateIP(a) { return (a.startsWith('10.') || a.startsWith('172.16.') || a.startsWith('192.168.')); }
  2289. function encodeURIComponentEx(txt) { return encodeURIComponent(txt).replace(/'/g, '%27'); };
  2290. function safeNewWindow(url, target) { var newWindow = window.open(url, target, 'noopener,noreferrer'); if (newWindow) { newWindow.opener = null; } }
  2291. </script>
  2292. </body>
  2293. </html>