Added My Files to mobile application
Ylian Saint-Hilaire committed
Jun 18, 2018 at 12:48 UTC
2850340a7df268e77fd0fa64190720e84937baba
2 files changed
+308
-28
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.1.8-d",
3
+ "version": "0.1.8-e",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
views/default-mobile.handlebars
+307
-27
@@ -29,9 +29,9 @@
29
.i4 {background:url(../images/icons50.png) -150px 0px;height:50px;width:50px;border:none;}
30
.i5 {background:url(../images/icons50.png) -200px 0px;height:50px;width:50px;border:none;}
31
.i6 {background:url(../images/icons50.png) -250px 0px; height:50px;width:50px; border:none; }
32
- .m0 {background:url(../images/images16.png) -32px 0px; height:16px;width:16px; border:none;float:left }
33
- .m1 {background:url(../images/images16.png) -16px 0px; height:16px;width:16px; border:none;float:left }
34
- .m2 {background:url(../images/images16.png) -96px 0px; height:16px;width:16px; border:none;float:left }
32
+ .m0 {background:url(../images/images16.png) -32px 0px; height:16px;width:16px; border:none;float:left }
33
+ .m1 {background:url(../images/images16.png) -16px 0px; height:16px;width:16px; border:none;float:left }
34
+ .m2 {background:url(../images/images16.png) -96px 0px; height:16px;width:16px; border:none;float:left }
35
.m3 {background:url(../images/images16.png) -112px 0px; height:16px;width:16px; border:none;float:left }
36
37
.gray {
@@ -167,6 +167,77 @@
167
</div>
168
</div>
169
</div>
170
+ <div id=p5 style=display:none>
171
+ <table cellspacing=0 style="margin:0;padding:0;border-spacing:0;border:0;">
172
+ <tr style=padding:0>
173
+ <td style="padding:0;color:#c8c8c8;text-align:center;cursor:pointer" width=60px valign=top onclick=goBack()>
174
+ <div style="padding:0;background-color:#036;width:10px;height:10px;float:right;border:0">
175
+ <div style="background-color:white;width:10px;height:10px;border-radius:10px 0 0 0;border-right:1px solid white;border-bottom:1px solid white"></div>
176
+ </div>
177
+ <div style="padding:0;font-size:25px;background-color:#036;width:50px;border-radius:0 0 10px 0;height:36px">◀</div>
178
+ </td>
179
+ <td>
180
+ <img src="/images/user-50.png" width=50 height=50 />
181
+ </td>
182
+ <td>
183
+ <div style=margin-left:5px>
184
+ <strong style="font-size:large">My Files</strong><br />
185
+ </div>
186
+ </td>
187
+ </tr>
188
+ </table>
189
+ <div id=p5myfiles style="overflow-y:scroll;position:absolute;top:55px;bottom:0px;width:100%">
190
+ <table id="p5toolbar" style="width:100%;height:78px" cellpadding="0" cellspacing="0">
191
+ <tr>
192
+ <td style="width:100%;background-color:#d3d9d6;text-align:left;padding:4px" valign=bottom>
193
+ <div style="width:100%;text-align:center">
194
+ <input type=button style="width:calc(100%/5 - 5px)" id=p5FolderUp disabled="disabled" onclick="p5folderup()" value="Up" />
195
+ <input type=button style="width:calc(100%/5 - 5px)" id=p5SelectAllButton disabled="disabled" onclick="p5selectallfile()" value="SelectAll" onkeypress="return false" onkeydown="return false" />
196
+ <input type=button style="width:calc(100%/5 - 5px)" id=p5RenameFileButton disabled="disabled" value="Rename" onclick="p5renamefile()" onkeypress="return false" onkeydown="return false" />
197
+ <input type=button style="width:calc(100%/5 - 5px)" id=p5DeleteFileButton disabled="disabled" value="Delete" onclick="p5deletefile()" onkeypress="return false" onkeydown="return false" />
198
+ <input type=button style="width:calc(100%/5 - 5px)" id=p5NewFolderButton disabled="disabled" value="Folder" onclick="p5createfolder()" onkeypress="return false" onkeydown="return false" />
199
+ </div>
200
+ <div style="width:100%;text-align:center">
201
+ <input type=button style="width:calc(100%/5 - 5px)" id=p5UploadButton disabled="disabled" value="Upload" onclick="p5uploadFile()" onkeypress="return false" onkeydown="return false" />
202
+ <input type=button style="width:calc(100%/5 - 5px)" id=p5CutButton disabled="disabled" value="Cut" onclick="p5copyFile(1)" onkeypress="return false" onkeydown="return false" />
203
+ <input type=button style="width:calc(100%/5 - 5px)" id=p5CopyButton disabled="disabled" value="Copy" onclick="p5copyFile(0)" onkeypress="return false" onkeydown="return false" />
204
+ <input type=button style="width:calc(100%/5 - 5px)" id=p5PasteButton disabled="disabled" value="Paste" onclick="p5pasteFile()" onkeypress="return false" onkeydown="return false" />
205
+ <input type=button style="width:calc(100%/5 - 5px)" id=p5RefreshButton value="Refresh" onclick="p5refreshFiles()" onkeypress="return false" onkeydown="return false" />
206
+ </div>
207
+ </td>
208
+ </tr>
209
+ <tr>
210
+ <td style="background-color:#E4E9E7;height:28px">
211
+ <table style="width:100%">
212
+ <tr>
213
+ <td id=p5currentpath style="overflow:hidden;padding-left:4px;padding-top:2px"></td>
214
+ <td style="text-align:right;padding-right:4px">
215
+ <select id=p5sortdropdown onchange=updateFiles()>
216
+ <option value=1 selected="selected">Sort by name</option>
217
+ <option value=2>Sort by size</option>
218
+ <option value=3>Sort by date</option>
219
+ <option value=4>Descend by name</option>
220
+ <option value=5>Descend by size</option>
221
+ <option value=6>Descend by date</option>
222
+ </select>
223
+ </td>
224
+ </tr>
225
+ </table>
226
+ </td>
227
+ </tr>
228
+ </table>
229
+ <div id="p5filetable" style="width:100%;height:calc(100% - 133px);overflow:auto;-webkit-user-select:none">
230
+ <!--
231
+ <div id="p5bigok" style="width:256px;overflow:hidden;position:absolute;left:337px;top:200px;text-align:center;font-size:1600%;color:#AAAAAA;display:none"><b>✓</b></div>
232
+ <div id="p5bigfail" style="width:256px;overflow:hidden;position:absolute;left:337px;top:200px;text-align:center;font-size:1600%;color:#AAAAAA;display:none"><b>✗</b></div>
233
+ -->
234
+ <span id="p5files"></span>
235
+ </div>
236
+ <table id="p5toolbarBottom" style="width:100%;height:22px;position:absolute;bottom:0px" cellpadding=0 cellspacing=0>
237
+ <tr><td style="text-align:left;padding:3px;text-align:center;background-color:#D3D9D6"> <span id="p5bottomstatus"></span></td></tr>
238
+ </table>
239
+ </div>
240
+ </div>
241
<div id=p10 style=display:none;position:absolute;bottom:0;top:0;width:100%;overflow:hidden>
242
<table cellspacing=0 style="margin:0;padding:0;border-spacing:0;border:0;position:absolute;top:0">
243
<tr style=padding:0>
@@ -193,7 +264,7 @@
264
<div id=p10html3></div>
265
</div>
266
<div id=p10desktop style="overflow-y:scroll;position:absolute;top:55px;bottom:0px;width:100%;display:none">
196
- <div id=deskarea1>
267
+ <div id=deskarea1 style="position:absolute;top:0px;width:100%;height:25px">
268
<div style="padding-top:2px;padding-bottom:2px;background:#C0C0C0">
269
<div style="float:right;text-align:right">
270
<span id="p14power"></span>
@@ -206,12 +277,7 @@
277
</div>
278
</div>
279
</div>
209
- <div id=deskarea2>
210
- <div>
211
- <div style=background-color:gray><div id=progressbar style=height:2px;width:0%;background-color:red></div></div>
212
- </div>
213
- </div>
214
- <div id=deskarea3 style="height:calc(100% - 56px)">
280
+ <div id=deskarea3 style="position:absolute;top:25px;width:100%;height:calc(100% - 50px)">
281
<div id=deskarea3x style="background:black;text-align:center;height:100%;position:relative">
282
<div id=DeskParent style="height:100%">
283
<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>
@@ -226,7 +292,7 @@
292
</div>
293
</div>
294
</div>
229
- <div id=deskarea4>
295
+ <div id=deskarea4 style="position:absolute;bottom:0px;width:100%;height:25px">
296
<div style=padding-top:2px;padding-bottom:2px;background:#C0C0C0>
297
<div style=float:right;text-align:right>
298
<select id=termdisplays style=display:none onchange=deskSetDisplay(event) onclick=deskGetDisplayNumbers(event)></select>
@@ -247,9 +313,9 @@
313
<tr>
314
<td style="background-color:#C0C0C0;border-bottom:2px solid black;padding:2px">
315
<div style="float:right;text-align:right">
250
- <input id="filesActionsBtn" type=button title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value=Actions onclick=deviceActionFunction() style=margin-right:3px />
316
+ <input id="filesActionsBtn" type=button title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value=Actions onclick=deviceActionFunction() style=margin-right:2px />
317
</div>
252
- <div>
318
+ <div style="margin-left:2px">
319
<input id=p13AutoConnect value="AutoConnect" onclick=autoConnectFiles(event) onkeypress="return false" onkeydown="return false" type="button" style="display:none">
320
<input id=p13Connect value="Connect" onclick=connectFiles(event) onkeypress="return false" onkeydown="return false" type="button">
321
<span id=p13Status>Disconnected</span>
@@ -276,17 +342,21 @@
342
</tr>
343
<tr>
344
<td style="background-color:#E4E9E7;height:28px">
279
- <div style=float:right>
280
- <select id=p13sortdropdown onchange=p13updateFiles()>
281
- <option value=1 selected="selected">Sort by name</option>
282
- <option value=2>Sort by size</option>
283
- <option value=3>Sort by date</option>
284
- <option value=4>Descend by name</option>
285
- <option value=5>Descend by size</option>
286
- <option value=6>Descend by date</option>
287
- </select>
288
- </div>
289
- <div id=p13currentpath style="white-space:nowrap;overflow:hidden;padding-left:4px;padding-top:2px;max-width:100px"></div>
345
+ <table style="width:100%">
346
+ <tr>
347
+ <td id=p13currentpath style="overflow:hidden;padding-left:4px;padding-top:2px"></td>
348
+ <td style="text-align:right;padding-right:4px">
349
+ <select id=p13sortdropdown onchange=p13updateFiles()>
350
+ <option value=1 selected="selected">Sort by name</option>
351
+ <option value=2>Sort by size</option>
352
+ <option value=3>Sort by date</option>
353
+ <option value=4>Descend by name</option>
354
+ <option value=5>Descend by size</option>
355
+ <option value=6>Descend by date</option>
356
+ </select>
357
+ </td>
358
+ </tr>
359
+ </table>
360
</td>
361
</tr>
362
</table>
@@ -349,6 +419,7 @@
419
</div>
420
</div>
421
<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">
422
+ <div style="padding:12px;border-top:1px solid gray;color:black;cursor:pointer" onclick=topMenu(2)>My Files</div>
423
<div style="padding:12px;border-top:1px solid gray;color:black;cursor:pointer" onclick=topMenu(1)>My Account</div>
424
<a href=/logout><div style="padding:12px;border-top:1px solid gray;color:black;cursor:pointer">Logout</div></a>
425
</div>
@@ -409,7 +480,7 @@
480
// Fetch list of meshes, nodes, files
481
meshserver.send({ action: 'meshes' });
482
meshserver.send({ action: 'nodes' });
412
- //meshserver.send({ action: 'files' });
483
+ meshserver.send({ action: 'files' });
484
if (xxcurrentView < 2) { go(2); }
485
}
486
}
@@ -459,8 +530,8 @@
530
break;
531
}
532
case 'files': {
462
- //filetree = setupBackPointers(message.filetree);
463
- //updateFiles();
533
+ filetree = setupBackPointers(message.filetree);
534
+ updateFiles();
535
//d3updatefiles();
536
break;
537
}
@@ -700,6 +771,7 @@
771
QV('topMenu', false);
772
xxdialogMode = 0;
773
if ((select == 1) && (xxcurrentView != 3)) { goForward('account'); } // My Account
774
+ if ((select == 2) && (xxcurrentView != 5)) { goForward('files'); } // My Files
775
}
776
}
777
@@ -713,6 +785,7 @@
785
if (idtype == 'mesh') { gotoMesh(id); }
786
if (idtype == 'account') { go(3); }
787
if (idtype == 'devices') { go(2); }
788
+ if (idtype == 'files') { go(5); }
789
}
790
791
function updateFooterMenu(options) {
@@ -879,6 +952,213 @@
952
function server_showVersionDlgUpdate() { QE('idx_dlgOkButton', Q('d2updateCheck').checked); }
953
function server_showVersionDlgEx() { meshserver.send({ action: 'serverupdate' }); }
954
955
+ //
956
+ // MY FILES
957
+ //
958
+
959
+ var filetreelinkpath;
960
+ var filetreelocation = [];
961
+
962
+ function p5refreshFiles() { meshserver.send({ action: 'files' }); }
963
+
964
+ function updateFiles() {
965
+ QV('MainMenuMyFiles', ((features & 8) == 0));
966
+ if ((features & 8) != 0) return; // If running on a server without files, exit now.
967
+ var html1 = '', html2 = '', displayPath = '<a style=cursor:pointer onclick=p5folderup(0)>Root</a>', fullPath = 'Root', publicPath, filetreex = filetree, folderdepth = 1;
968
+
969
+ // Navigate to path location, build the paths at the same time
970
+ var filetreelocation2 = [], oldlinkpath = filetreelinkpath, checkedBoxes = [], checkboxes = document.getElementsByName('fc');
971
+ for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked) { checkedBoxes.push(checkboxes[i].value) }; } // Save all existing checked boxes
972
+
973
+ filetreelinkpath = '';
974
+ for (var i in filetreelocation) {
975
+ if ((filetreex.f != null) && (filetreex.f[filetreelocation[i]] != null)) {
976
+ filetreelocation2.push(filetreelocation[i]);
977
+ fullPath += ' / ' + filetreelocation[i];
978
+ if ((folderdepth == 1)) {
979
+ var sp = filetreelocation[i].split('/');
980
+ publicPath = window.location + sp[0] + 'files/' + sp[2];
981
+ //if (filetreelocation[i] === userinfo._id) { filetreelinkpath += 'self'; } else { filetreelinkpath += (sp[0] + '/' + sp[2]); }
982
+ filetreelinkpath += filetreelocation[i];
983
+ } else {
984
+ if (filetreelinkpath != '') { filetreelinkpath += '/' + filetreelocation[i]; if (folderdepth > 2) { publicPath += '/' + filetreelocation[i]; } }
985
+ }
986
+ filetreex = filetreex.f[filetreelocation[i]];
987
+ displayPath += ' / <a style=cursor:pointer onclick=p5folderup(' + folderdepth + ')>' + (filetreex.n != null?filetreex.n:filetreelocation[i]) + '</a>';
988
+ folderdepth++;
989
+ } else {
990
+ break;
991
+ }
992
+ }
993
+ filetreelocation = filetreelocation2; // In case we could not go down the full path, we set the new path location here.
994
+ var publicfolder = fullPath.toLowerCase().startsWith("root / " + userinfo._id + " / public");
995
+
996
+ // Sort the files
997
+ var filetreexx = p5sort_files(filetreex.f);
998
+
999
+ // Display all files and folders at this location
1000
+ for (var i in filetreexx) {
1001
+ // Figure out the name and shortname
1002
+ var f = filetreexx[i], name = f.n, shortname;
1003
+ shortname = name;
1004
+ if (name.length > 40) { shortname = '<span title="' + EscapeHtml(name) + '">' + EscapeHtml(name.substring(0, 40)) + "...</span>"; } else { shortname = EscapeHtml(name); }
1005
+ name = EscapeHtml(name);
1006
+
1007
+ // Figure out the date
1008
+ //var fdatestr = '';
1009
+ //if (f.d != null) { var fdate = new Date(f.d), fdatestr = (fdate.getMonth() + 1) + "/" + (fdate.getDate()) + "/" + fdate.getFullYear() + " " + fdate.toLocaleTimeString() + " "; }
1010
+
1011
+ // Figure out the size
1012
+ var fsize = '';
1013
+ if (f.s != null) { fsize = getFileSizeStr(f.s); }
1014
+
1015
+ var h = '';
1016
+ if (f.t < 3) {
1017
+ var right = (f.t == 1)?p5getQuotabar(f):'', title = '';
1018
+ h = "<div class=filelist file=999><input file=999 style=float:left name=fc class=fcb type=checkbox onchange=p5setActions() value='" + name + "'> <span style=float:right;padding-right:4px title=\"" + title + "\">" + right + "</span><span><div class=fileIcon" + f.t + "></div><a style=cursor:pointer onclick=p5folderset(\"" + encodeURIComponent(f.nx) + "\")>" + shortname + "</a></span></div>";
1019
+ } else {
1020
+ var link = shortname;
1021
+ var publiclink = '';
1022
+ if (publicfolder) { publiclink = ' (<a style=cursor:pointer title=\"Display public link\" onclick=\'p5showPublicLink(\"' + publicPath + '/' + f.nx + '\")\'>Link</a>)'; }
1023
+ if (f.s > 0) { link = "<a target=\"_blank\" href=\"downloadfile.ashx?link=" + encodeURIComponent(filetreelinkpath + '/' + f.nx) + "\">" + shortname + "</a>" + publiclink; }
1024
+ h = "<div class=filelist file=3><input file=3 style=float:left name=fc class=fcb type=checkbox onchange=p5setActions() value='" + f.nx + "'> <span style=float:right;padding-right:4px>" + fsize + "</span><span><div class=fileIcon" + f.t + "></div>" + link + "</span></div>";
1025
+ }
1026
+
1027
+ if (f.t < 3) { html1 += h; } else { html2 += h; }
1028
+ }
1029
+
1030
+ //if (f.parent == null) { }
1031
+ //QH('p5rightOfButtons', p5getQuotabar(filetreex));
1032
+
1033
+ QH('p5files', html1 + html2);
1034
+ QH('p5currentpath', displayPath);
1035
+ QE('p5FolderUp', filetreelocation.length != 0);
1036
+ QV('p5PublicShare', publicfolder);
1037
+
1038
+ // Re-check all boxes if needed
1039
+ if (oldlinkpath == filetreelinkpath) {
1040
+ checkboxes = document.getElementsByName('fc');
1041
+ for (var i = 0; i < checkboxes.length; i++) {
1042
+ checkboxes[i].checked = (checkedBoxes.indexOf(checkboxes[i].value) >= 0);
1043
+ }
1044
+ }
1045
+
1046
+ p5setActions();
1047
+ }
1048
+
1049
+ function p5getQuotabar(f) {
1050
+ while (f.t > 1) { f = f.parent; }
1051
+ if ((f.t != 1) || (f.maxbytes == null)) return '';
1052
+ var tf = Math.floor(f.s / 1024), tq = Math.floor((f.maxbytes - f.s) / 1024);
1053
+ return '<span title="' + tf + "k in " + f.c + " file" + (f.c > 1?'s':'') + ". " + (Math.floor(f.maxbytes / 1024)) + 'k maxinum">' + ((tq < 0)?('Storage limit exceed'):(tq + 'k remaining')) + ' <progress style=height:10px;width:100px value=' + f.s + ' max=' + f.maxbytes + ' /></span>';
1054
+ }
1055
+
1056
+ function p5showPublicLink(u) { setDialogMode(2, "Public Link", 1, null, '<input type=text style=width:100% value="' + u + '" readonly />'); }
1057
+
1058
+ var sortorder;
1059
+ function p5sort_filename(a, b) { if (a.ln > b.ln) return (1 * sortorder); if (a.ln < b.ln) return (-1 * sortorder); return 0; }
1060
+ function p5sort_timestamp(a, b) { if (a.d > b.d) return (1 * sortorder); if (a.d < b.d) return (-1 * sortorder); return 0; }
1061
+ function p5sort_bysize(a, b) { if (a.s == b.s) return p5sort_filename(a, b); return (((a.s - b.s)) * sortorder); }
1062
+
1063
+ function p5sort_files(files) {
1064
+ var r = [], sortselection = Q('p5sortdropdown').value;
1065
+ for (var i in files) { files[i].nx = i; if (files[i].n == null) { files[i].n = i; } files[i].ln = files[i].n.toLowerCase(); r.push(files[i]); }
1066
+ sortorder = 1;
1067
+ if (sortselection > 3) { sortorder = -1; sortselection -= 3; }
1068
+ if (sortselection == 1) { r.sort(p5sort_filename); }
1069
+ else if (sortselection == 2) { r.sort(p5sort_bysize); }
1070
+ else if (sortselection == 3) { r.sort(p5sort_timestamp); }
1071
+ return r;
1072
+ }
1073
+
1074
+ function p5setActions() {
1075
+ var cc = getFileSelCount(), tc = getFileCount(), sfc = getFileSelCount(false); // In order: number of entires selected, number of total entries, number of selected entires that are files (not folders)
1076
+ QE('p5DeleteFileButton', (cc > 0) && (filetreelocation.length > 0));
1077
+ QE('p5NewFolderButton', filetreelocation.length > 0);
1078
+ QE('p5UploadButton', filetreelocation.length > 0);
1079
+ QE('p5RenameFileButton', (cc == 1) && (filetreelocation.length > 0));
1080
+ QE('p5SelectAllButton', tc > 0);
1081
+ Q('p5SelectAllButton').value = (cc > 0 ? 'Select None' : 'Select All');
1082
+ QE('p5CutButton', (sfc > 0) && (cc == sfc));
1083
+ QE('p5CopyButton', (sfc > 0) && (cc == sfc));
1084
+ QE('p5PasteButton', (p5clipboard != null) && (p5clipboard.length > 0));
1085
+ }
1086
+
1087
+ 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; }
1088
+ function getFileCount() { var cc = 0; var checkboxes = document.getElementsByName('fc'); return checkboxes.length; }
1089
+ function p5selectallfile() { var nv = (getFileSelCount() == 0), checkboxes = document.getElementsByName('fc'); for (var i = 0; i < checkboxes.length; i++) { checkboxes[i].checked = nv; } p5setActions(); }
1090
+ function setupBackPointers(x) { if (x.f != null) { var fs = 0, fc = 0; for (var i in x.f) { setupBackPointers(x.f[i]); x.f[i].parent = x; if (x.f[i].s) { fs += x.f[i].s; } if (x.f[i].c) { fc += x.f[i].c; } if (x.f[i].t == 3) { fc++; } } x.s = fs; x.c = fc; } return x; }
1091
+ function getFileSizeStr(size) { if (size == 1) return "1 byte"; return "" + size + " bytes"; }
1092
+ function p5folderup(x) { if (x == null) { filetreelocation.pop(); } else { while (filetreelocation.length > x) { filetreelocation.pop(); } } updateFiles(); }
1093
+ function p5folderset(x) { filetreelocation.push(decodeURIComponent(x)); updateFiles(); }
1094
+ function p5createfolder() { setDialogMode(2, "New Folder", 3, p5createfolderEx, '<input type=text id=p5renameinput maxlength=64 onkeyup=p5fileNameCheck(event) style=width:100% />'); focusTextBox('p5renameinput'); p5fileNameCheck(); }
1095
+ function p5createfolderEx() { meshserver.send({ action: 'fileoperation', fileop: 'createfolder', path: filetreelocation, newfolder: Q('p5renameinput').value}); }
1096
+ function p5deletefile() { var cc = getFileSelCount(); setDialogMode(2, "Delete", 3, p5deletefileEx, (cc > 1)?('Delete ' + cc + ' selected items?'):('Delete selected item?')); }
1097
+ function p5deletefileEx() { var delfiles = [], checkboxes = document.getElementsByName('fc'); for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked) { delfiles.push(checkboxes[i].value); } } meshserver.send({ action: 'fileoperation', fileop: 'delete', path: filetreelocation, delfiles: delfiles}); }
1098
+ function p5renamefile() { var renamefile, checkboxes = document.getElementsByName('fc'); for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked) { renamefile = checkboxes[i].value; } } setDialogMode(2, "Rename", 3, p5renamefileEx, '<input type=text id=p5renameinput maxlength=64 onkeyup=p5fileNameCheck(event) style=width:100% value="' + renamefile + '" />', { action: 'fileoperation', fileop: 'rename', path: filetreelocation, oldname: renamefile}); focusTextBox('p5renameinput'); p5fileNameCheck(); }
1099
+ function p5renamefileEx(b, t) { t.newname = Q('p5renameinput').value; meshserver.send(t); }
1100
+ function p5fileNameCheck(e) { var x = isFilenameValid(Q('p5renameinput').value); QE('idx_dlgOkButton', x); if ((x == true) && (e.keyCode == 13)) { dialogclose(1); } }
1101
+ 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] != '.'); } })();
1102
+ function p5uploadFile() { setDialogMode(2, "Upload File", 3, p5uploadFileEx, '<form method=post enctype=multipart/form-data action=uploadfile.ashx target=fileUploadFrame><input type=text name=link style=display:none id=p5uploadpath value=\"' + encodeURIComponent(filetreelinkpath) + '\" /><input type=file name=files id=p5uploadinput style=width:100% multiple=multiple onchange="updateUploadDialogOk(\'p5uploadinput\')" /><input type=submit id=p5loginSubmit style=display:none /></form>'); updateUploadDialogOk('p5uploadinput'); }
1103
+ function p5uploadFileEx() { Q('p5loginSubmit').click(); }
1104
+ function updateUploadDialogOk(x) { QE('idx_dlgOkButton', Q(x).value != ''); }
1105
+
1106
+ var p5clipboard = null, p5clipboardFolder = null, p5clipboardCut = 0;
1107
+ function p5copyFile(cut) { var checkboxes = document.getElementsByName('fc'); p5clipboard = []; p5clipboardCut = cut, p5clipboardFolder = Clone(filetreelocation); for (var i = 0; i < checkboxes.length; i++) { if ((checkboxes[i].checked) && (checkboxes[i].attributes.file.value == "3")) { p5clipboard.push(checkboxes[i].value); } } p5updateClipview(); }
1108
+ function p5pasteFile() { var x = ''; if ((p5clipboard != null) && (p5clipboard.length > 0)) { x = 'Confim ' + (p5clipboardCut == 0?'copy':'move') + ' of ' + p5clipboard.length + ' entrie' + ((p5clipboard.length > 1)?'s':'') + ' to this location?' } setDialogMode(2, "Paste", 3, p5pasteFileEx, x); }
1109
+ function p5pasteFileEx() { meshserver.send({ action: 'fileoperation', fileop: (p5clipboardCut == 0?'copy':'move'), scpath: p5clipboardFolder, path: filetreelocation, names: p5clipboard }); p5folderup(999); if (p5clipboardCut == 1) { p5clipboard = null, p5clipboardFolder = null, p5clipboardCut = 0; p5updateClipview(); } }
1110
+ function p5updateClipview() { var x = ''; if ((p5clipboard != null) && (p5clipboard.length > 0)) { x = 'Holding ' + p5clipboard.length + ' entrie' + ((p5clipboard.length > 1)?'s':'') + ' for ' + (p5clipboardCut == 0?'copy':'move') + ', <a onclick=p5clearClip() style=cursor:pointer>Clear</a>.' } QH('p5bottomstatus', x); p5setActions(); }
1111
+ function p5clearClip() { p5clipboard = null; p5clipboardFolder = null; p5clipboardCut = 0; p5updateClipview(); }
1112
+
1113
+ function p5fileDragDrop(e) {
1114
+ haltEvent(e);
1115
+ QV('bigfail', false);
1116
+ QV('bigok', false);
1117
+ //QV('p5fileCatchAllInput', false);
1118
+ if (e.dataTransfer == null || e.dataTransfer.files.length == 0 || filetreelocation.length == 0) return;
1119
+ var names = [], sizes = [], types = [], datas = [], readercount = e.dataTransfer.files.length;
1120
+ for (var i = 0; i < e.dataTransfer.files.length; i++) {
1121
+ var reader = new FileReader(), file = e.dataTransfer.files[i];
1122
+ names.push(file.name);
1123
+ sizes.push(file.size);
1124
+ types.push(file.type);
1125
+ reader.onload = function(event) {
1126
+ datas.push(event.target.result);
1127
+ if (--readercount == 0) {
1128
+ Q('p5fileDragName').value = names.join('*');
1129
+ Q('p5fileDragSize').value = sizes.join('*');
1130
+ Q('p5fileDragType').value = types.join('*');
1131
+ Q('p5fileDragData').value = datas.join('*');
1132
+ Q('p5fileDragLink').value = encodeURIComponent(filetreelinkpath);
1133
+ Q('p5loginSubmit2').click();
1134
+ }
1135
+ }
1136
+ reader.readAsDataURL(file);
1137
+ }
1138
+ }
1139
+
1140
+ var p5dragtimer = null;
1141
+ function p5fileDragOver(e) {
1142
+ haltEvent(e);
1143
+ if (p5dragtimer != null) { clearTimeout(p5dragtimer); p5dragtimer = null; }
1144
+ var ac = true; // TODO: Set to true if we can accept the file
1145
+ if (filetreelocation.length == 0) { ac = false; }
1146
+ QV('bigok', ac);
1147
+ QV('bigfail', !ac);
1148
+ //QV('p5fileCatchAllInput', ac);
1149
+ }
1150
+
1151
+ function p5fileDragLeave(e) {
1152
+ haltEvent(e);
1153
+ if (e.target.id != "p5filetable") {
1154
+ QV('bigfail', false);
1155
+ QV('bigok', false);
1156
+ //QV('p5fileCatchAllInput', false);
1157
+ } else {
1158
+ p5dragtimer = setTimeout("QV('bigfail',false);QV('bigok',false);p5dragtimer=null;", 200);
1159
+ }
1160
+ }
1161
+
1162
//
1163
// MY DEVICES
1164
//