]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - Plugson/www/static/js/vtoy.js
1.0.82 release
[Ventoy.git] / Plugson / www / static / js / vtoy.js
1
2 function ventoy_replace_slash(str) {
3 var str1 = str.replace(/\\/g, '/');
4 var str2 = str1.replace(/\/\//g, '/');
5
6 if (str2 && str2.length > 0) {
7 if (str2.substr(-1) === "/") {
8 return str2.substr(0, str2.length - 1);
9 }
10 }
11
12 return str2;
13 }
14
15
16 function ventoy_get_ulen(str) {
17 var c, b = 0, l = str.length;
18 while(l) {
19 c = str.charCodeAt(--l);
20 b += (c < 128) ? 1 : ((c < 2048) ? 2 : ((c < 65536) ? 3 : 4));
21 };
22 return b;
23 }
24
25
26 function ventoy_common_check_path(path) {
27 if (path.indexOf('//') >= 0) {
28 return false;
29 }
30
31 if (path.length <= g_current_dir.length) {
32 return false;
33 }
34
35 if (path.substr(0, g_current_dir.length) != g_current_dir) {
36 return false;
37 }
38
39 return true;
40 }
41
42
43 // 加载子页面内容
44 function loadContent(page) {
45 $("#plugson-content").load(page + ".html?_=" + (new Date().getTime()), function() {
46 $("body").scrollTop(0);
47 });
48 }
49
50 // 包装ajax请求
51 function callVtoyCatchErr(p1, p2, p3) {
52 var url = '/vtoy/json';
53 var data = {};
54 var func = function(data) {};
55 var errfunc = function(xmlHttpRequest, textStatus, errorThrown) {};
56
57 if (typeof(p1) === 'string') {
58 url = p1;
59 } else if (typeof(p1) === 'object') {
60 data = p1;
61 }
62 if (typeof(p2) === 'object') {
63 data = p2;
64 } else if (typeof(p2) === 'function') {
65 func = p2;
66 }
67 if (typeof(p3) === 'function') {
68 errfunc = p3;
69 }
70
71 //vtoy.debug('callVtoy:\t\t\t\t' + JSON.stringify(data));
72 $.ajax({
73 url: url,
74 type: 'post',
75 cache: false,
76 dataType: 'json',
77 data: JSON.stringify(data),
78 success: func,
79 error: errfunc,
80 complete: function(data) {
81 //vtoy.debug('callVtoy\'s resp:\t\t' + data.responseText);
82 }
83 });
84 }
85
86 // 包装ajax请求
87 function callVtoy(p1, p2, p3) {
88 var url = '/vtoy/json';
89 var data = {};
90 var func = function(data) {};
91
92 if (typeof(p1) === 'string') {
93 url = p1;
94 } else if (typeof(p1) === 'object') {
95 data = p1;
96 }
97 if (typeof(p2) === 'object') {
98 data = p2;
99 } else if (typeof(p2) === 'function') {
100 func = p2;
101 }
102 if (typeof(p3) === 'function') {
103 func = p3;
104 }
105
106 //vtoy.debug('callVtoy:\t\t\t\t' + JSON.stringify(data));
107 $.ajax({
108 url: url,
109 type: 'post',
110 cache: false,
111 dataType: 'json',
112 data: JSON.stringify(data),
113 success: func,
114 error: function(xmlHttpRequest, textStatus, errorThrown) {
115
116 if(undefined === errorThrown)
117 {
118 Message.error(g_vtoy_cur_language.STR_WEB_REMOTE_ABNORMAL);
119 }
120 else if(undefined === errorThrown.length)
121 {
122
123 }
124 else if('' == errorThrown.trim())
125 {
126 }
127 else
128 {
129 switch(errorThrown)
130 {
131 case 'timeout':
132 {
133 Message.error(g_vtoy_cur_language.STR_WEB_REQUEST_TIMEOUT);
134 break;
135 }
136 case 'Service Unavailable':
137 {
138 Message.error(g_vtoy_cur_language.STR_WEB_SERVICE_UNAVAILABLE);
139 break;
140 }
141 case 'abort':
142 {
143 break;
144 }
145 default:
146 {
147 Message.error(g_vtoy_cur_language.STR_WEB_COMMUNICATION_ERR + errorThrown);
148 break;
149 }
150 }
151 }
152 },
153 complete: function(data) {
154 //vtoy.debug('callVtoy\'s resp:\t\t' + data.responseText);
155 }
156 });
157 }
158
159 function callVtoyASyncTimeout(time, data, func) {
160 $.ajax({
161 url: '/vtoy/json',
162 type: 'post',
163 cache: false,
164 dataType: 'json',
165 async: true,
166 timeout: time,
167 data: JSON.stringify(data),
168 success: func,
169 error: function(xmlHttpRequest, textStatus, errorThrown) {
170 if(undefined === errorThrown)
171 {
172 }
173 else if(undefined === errorThrown.length)
174 {
175
176 }
177 else if('' == errorThrown.trim())
178 {
179 }
180 else
181 {
182 switch(errorThrown)
183 {
184 case 'timeout':
185 {
186 callVtoyASyncTimeout(time, data, func);
187 break;
188 }
189 case 'Service Unavailable':
190 {
191 break;
192 }
193 case 'abort':
194 {
195 break;
196 }
197 default:
198 {
199 break;
200 }
201 }
202 }
203 },
204 complete: function(data) {
205 //vtoy.debug('callVtoyASyncTimeout\'s resp:\t' + JSON.stringify(data));
206 }
207 });
208 }
209
210 function callVtoySync(data, func) {
211 //vtoy.debug('callVtoySync:\t\t\t' + JSON.stringify(data));
212 $.ajax({
213 url: '/vtoy/json',
214 type: 'post',
215 cache: false,
216 dataType: 'json',
217 async: false,
218 data: JSON.stringify(data),
219 success: function VtoyCallFuncWrapper(data) {
220 if (data.result === 'busy') {
221 var titlestr = '<span class="fa fa-check-circle" style="color:green; font-weight:bold;"> ' + g_vtoy_cur_language.STR_INFO + '</span>';
222 var msgstr = '<span style="font-size:14px; font-weight:bold;"> ' + g_vtoy_cur_language.STR_WEB_SERVICE_BUSY + '</span>';
223 Modal.alert({title:titlestr, msg:msgstr, btnok:g_vtoy_cur_language.STR_BTN_OK });
224 }else {
225 func(data);
226 }
227 },
228 error: function(xmlHttpRequest, textStatus, errorThrown) {
229 if(undefined === errorThrown)
230 {
231 Message.error(g_vtoy_cur_language.STR_WEB_REMOTE_ABNORMAL);
232 }
233 else if(undefined === errorThrown.length)
234 {
235
236 }
237 else if('' == errorThrown.trim())
238 {
239 }
240 else
241 {
242 switch(errorThrown)
243 {
244 case 'timeout':
245 {
246 Message.error(g_vtoy_cur_language.STR_WEB_REQUEST_TIMEOUT);
247 break;
248 }
249 case 'Service Unavailable':
250 {
251 Message.error(g_vtoy_cur_language.STR_WEB_SERVICE_UNAVAILABLE);
252 break;
253 }
254 case 'abort':
255 {
256 break;
257 }
258 default:
259 {
260 Message.error(g_vtoy_cur_language.STR_WEB_COMMUNICATION_ERR + errorThrown);
261 break;
262 }
263 }
264 }
265 },
266 complete: function(data) {
267 //vtoy.debug('callVtoySync\'s resp:\t' + JSON.stringify(data));
268 }
269 });
270 }
271
272 var vtoy = {
273 baseurl : '',
274 status: '',
275 scan: {
276 time: 3,
277 ret: []
278 }
279 }
280
281 //
282 String.prototype.endsWith = function(str) {
283 if (str == null || str == "" || this.length == 0 || str.length > this.length)
284 return false;
285 if (this.substring(this.length - str.length) == str)
286 return true;
287 else
288 return false;
289 }
290
291
292 var g_vtoy_cur_language_en =
293 {
294 "STR_INFO": "Info",
295 "STR_BTN_OK": "OK",
296 "STR_BTN_CANCEL": "Cancel",
297 "STR_SAVE": " Save",
298 "STR_RESET": " Reset",
299 "STR_DISCARD": " Discard",
300 "STR_ENABLE": " Enable",
301 "STR_ADD": "Add",
302 "STR_DEL": "Delete",
303 "STR_CLEAR": "Clear",
304 "STR_STATUS": "Status",
305 "STR_DEFAULT": "Default",
306 "STR_DEFAULT_SEL": "Default",
307 "STR_RANDOM_SEL": "Random",
308 "STR_OPERATION": "Operation",
309 "STR_VALID": "Valid",
310 "STR_INVALID": "Invalid",
311 "STR_OPT_SETTING": "Option Setting",
312 "STR_OPT_DESC": "Option Description",
313 "STR_EDIT": "Edit",
314 "STR_RESET": "Reset",
315 "STR_FILE": "File",
316 "STR_DIR": "Dir",
317 "STR_SAVE_TIP": "Data in current page has been modified. Do you want to save it?",
318 "STR_SAVE_SUCCESS": "Configuration successfully saved!",
319 "STR_FILE_EXIST": "OK",
320 "STR_FILE_NONEXIST": "Invalid",
321 "STR_FILE_FUZZY": "Fuzzy",
322 "STR_DIR_EXIST": "OK",
323 "STR_DIR_NONEXIST": "Invalid",
324 "STR_DUPLICATE_PATH": "Duplicate path",
325 "STR_DELETE_CONFIRM": "Delete this item, Continue?",
326 "STR_FILE_PATH": "File Path",
327 "STR_DIR_PATH": "Directory Path",
328
329 "STR_SET_ALIAS": "Set Menu Alias",
330 "STR_ALIAS": "Alias",
331 "STR_SET_TIP": "Set Menu Tip",
332 "STR_TIP": "Tip",
333 "STR_SET_CLASS": "Set Menu Class",
334 "STR_CLASS": "Class",
335 "STR_SET_INJECTION": "Set Injection",
336 "STR_SET_AUTO_INS": "Set Auto Install",
337 "STR_SET_AUTO_TEMPLATE": "Template",
338
339 "STR_SET_PERSISTENCE": "Set Persistence",
340 "STR_SET_PERSISTENCE_DAT": "Dat File",
341
342 "STR_SET_DUD": "Set DUD",
343 "STR_SET_DUD_FILE": "DUD File",
344
345 "STR_PASSWORD": "Password",
346 "STR_SET_PASSWORD": "Set Password",
347 "STR_PASSWORD_TYPE": "Password Type",
348 "STR_PASSWORD_VALUE": "Password Value",
349
350
351 "STR_WEB_COMMUNICATION_ERR":"Communication error:",
352 "STR_WEB_REMOTE_ABNORMAL":"Communication error: remote abnormal",
353 "STR_WEB_REQUEST_TIMEOUT":"Communication error: Request timed out",
354 "STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
355 "STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
356
357 "STR_PLUG_DEVICE": "Device Information",
358 "STR_PLUG_CONTROL": "Global Control Plugin",
359 "STR_PLUG_THEME": "Theme Plugin",
360 "STR_PLUG_ALIAS": "Menu Alias Plugin",
361 "STR_PLUG_CLASS": "Menu Class Plugin",
362 "STR_PLUG_TIP": "Menu Tip Plugin",
363 "STR_PLUG_AUTO_INSTALL": "Auto Install Plugin",
364 "STR_PLUG_PERSISTENCE": "Persistence Plugin",
365 "STR_PLUG_INJECTION": "Injection Plugin",
366 "STR_PLUG_CONF_REPLACE": "Boot Conf Replace Plugin",
367 "STR_PLUG_PASSWORD": "Password Plugin",
368 "STR_PLUG_IMAGELIST": "Image List Plugin",
369 "STR_PLUG_AUTO_MEMDISK": "Auto Memdisk Plugin",
370 "STR_PLUG_DUD": "DUD Plugin",
371 "STR_PLUG_DONATION": "Donation",
372
373 "STR_PATH_TOO_LONG": "The path exceeds the maximum supported length, please check!",
374 "STR_INPUT_TOO_LONG": "The string exceeds the maximum supported length, please check!",
375 "STR_INVALID_FILE_PATH": "Invalid or nonexist full file path, please check!",
376 "STR_INVALID_FILE_PATH1": "The 1st file path is invalid or nonexist!",
377 "STR_INVALID_FILE_PATH2": "The 2nd file path is invalid or nonexist!",
378 "STR_INVALID_NEW_FILE_PATH": "The full file path of new is invalid or nonexist, please check!",
379 "STR_INVALID_DIR_PATH": "Invalid directory path, please check!",
380 "STR_INVALID_NUMBER": "Please input valid non-negative integer!",
381 "STR_INVALID_AUTOSEL": "autosel exceeds the length of the list!",
382 "STR_INVALID_TIMEOUT": "Please input valid timeout integer!",
383 "STR_INVALID_PERCENT": "Please input integer between 0-100 !",
384 "STR_INVALID_COLOR": "Please input valid color!",
385 "STR_SELECT": "Please Select",
386 "STR_SET_ALIAS_FOR_FILE": "Set Menu Alias For File",
387 "STR_SET_ALIAS_FOR_DIR": "Set Menu Alias For Directory",
388 "STR_SET_TIP_FOR_FILE": "Set Menu Tip For File",
389 "STR_SET_TIP_FOR_DIR": "Set Menu Tip For Directory",
390 "STR_SET_INJECTION_FOR_FILE": "[image] Set injection for a file",
391 "STR_SET_INJECTION_FOR_DIR": "[parent] Set the same injection for all the files under a directory.",
392 "STR_INVALID_ARCHIVE_PATH": "Invalid or nonexist archive file path, please check!",
393 "STR_SET_PWD_FOR_FILE": "[file] Set password for a file.",
394 "STR_SET_PWD_FOR_DIR": "[parent] Set the same password for all the files under a directory.",
395 "STR_SET_AUTO_INSTALL_FOR_FILE": "[image] Set auto install template for a file",
396 "STR_SET_AUTO_INSTALL_FOR_DIR": "[parent] Set the same auto install template for all the files under a directory.",
397
398 "STR_SET_CLASS_BY_KEY": "[key] Set menu class by filename keyword.",
399 "STR_SET_CLASS_BY_DIR": "[dir] Set menu class for a directory.",
400 "STR_SET_CLASS_BY_PARENT": "[parent] Set menu class for all the files under a directory.",
401 "STR_SET_IMAGE_PWD": "[file] Set Password For A File",
402 "STR_SET_PARENT_PWD": "[parent] Set the same password for all the files under a directory.",
403
404 "STR_SET_SEARCH_ROOT": "Set Search Root",
405 "STR_SET_DEFAULT_IMAGE": "Set Default Image",
406 "STR_ADD_THEME": "Add Theme",
407 "STR_ADD_FONT": "Set Font",
408 "STR_ADD_FILE_TO_LIST": "Add File To List",
409 "STR_DEFAULT_SELECT": " Default",
410 "STR_AUTO_TEMPLATE": "Auto Install Template",
411 "STR_ADD_AUTO_TEMPLATE": "Add Auto Install Template",
412
413 "STR_PERSISTENCE_DAT": "Persistence Dat File",
414 "STR_ADD_PERSISTENCE_DAT": "Add Persistence Dat File",
415
416 "STR_DUD_FILE": "DUD File",
417 "STR_ADD_DUD_FILE": "Add DUD File",
418
419 "STR_DEL_LAST": "The entry will be deleted if you delete the this last item. Continue?",
420
421 "STR_CLOSE_TIP": "Service unavailable, the page will close!",
422 "STR_SECURE_BOOT_ENABLE": "Enable",
423 "STR_SECURE_BOOT_DISABLE": "Disable",
424 "STR_SYNTAX_ERROR_TIP": "Syntax error detected in ventoy.json, so the configuration is not loaded!",
425 "STR_INVALID_CONFIG_TIP": "Invalid configuration detected in ventoy.json, so the configuration is not loaded!",
426 "STR_CONFIG_SAVE_ERROR_TIP": "Failed to write ventoy.json file. Check VentoyPlugson.log for more details!",
427
428 "STR_JSON_PREVIEW": "JSON Preview",
429 "STR_JSON_COPY_SUCCESS": "JSON Copy Success",
430 "STR_JSON_COPY_FAILED": "JSON Copy Failed",
431
432 "STR_XXX": "xxx"
433 };
434
435 var g_vtoy_cur_language_cn =
436 {
437 "STR_INFO": "提醒",
438 "STR_BTN_OK": "确定",
439 "STR_BTN_CANCEL": "取消",
440 "STR_SAVE": " 保存",
441 "STR_RESET": " 重置",
442 "STR_DISCARD": " 丢弃",
443 "STR_ENABLE": " 使能",
444 "STR_ADD": "新增",
445 "STR_DEL": "删除",
446 "STR_CLEAR": "清除",
447 "STR_STATUS": "状态",
448 "STR_DEFAULT": "默认",
449 "STR_DEFAULT_SEL": "默认选择",
450 "STR_RANDOM_SEL": "随机选择",
451 "STR_OPERATION": "操作",
452 "STR_VALID": "有效",
453 "STR_INVALID": "无效",
454 "STR_OPT_SETTING": "选项设置",
455 "STR_OPT_DESC": "选项说明",
456 "STR_EDIT": "设置",
457 "STR_RESET": "重置",
458 "STR_FILE": "文件",
459 "STR_DIR": "目录",
460 "STR_SAVE_TIP": "当前页面数据已经修改,是否保存?",
461 "STR_SAVE_SUCCESS": "配置保存成功!",
462 "STR_FILE_EXIST": "文件存在",
463 "STR_FILE_NONEXIST": "文件无效",
464 "STR_FILE_FUZZY": "模糊匹配",
465 "STR_DIR_EXIST": "目录存在",
466 "STR_DIR_NONEXIST": "目录无效",
467 "STR_DUPLICATE_PATH": "路径不允许重复",
468 "STR_DELETE_CONFIRM": "确定要删除吗?",
469 "STR_FILE_PATH": "文件路径",
470 "STR_DIR_PATH": "目录路径",
471
472 "STR_SET_ALIAS": "设置菜单别名",
473 "STR_ALIAS": "别名",
474 "STR_SET_TIP": "设置菜单提示",
475 "STR_TIP": "提示",
476 "STR_SET_CLASS": "设置菜单类型",
477 "STR_CLASS": "类型",
478 "STR_SET_INJECTION": "设置文件注入",
479 "STR_SET_AUTO_INS": "设置自动安装",
480 "STR_SET_AUTO_TEMPLATE": "自动安装脚本",
481 "STR_SET_PERSISTENCE": "设置持久化文件",
482 "STR_SET_PERSISTENCE_DAT": "持久化文件",
483
484 "STR_SET_DUD": "设置 DUD",
485 "STR_SET_DUD_FILE": "DUD 文件",
486
487 "STR_PASSWORD": "密码",
488 "STR_SET_PASSWORD": "设置密码",
489 "STR_PASSWORD_TYPE": "密码类型",
490 "STR_PASSWORD_VALUE": "密码内容",
491
492 "STR_WEB_COMMUNICATION_ERR":"通信失败:",
493 "STR_WEB_REMOTE_ABNORMAL":"通信失败:服务端异常",
494 "STR_WEB_REQUEST_TIMEOUT":"通信失败:请求超时",
495 "STR_WEB_SERVICE_UNAVAILABLE":"通信失败:服务不可用",
496 "STR_WEB_SERVICE_BUSY":"后台服务正忙,请稍后重试",
497
498 "STR_PLUG_DEVICE": "设备信息",
499 "STR_PLUG_CONTROL": "全局控制插件",
500 "STR_PLUG_THEME": "主题插件",
501 "STR_PLUG_ALIAS": "菜单别名插件",
502 "STR_PLUG_CLASS": "菜单类型插件",
503 "STR_PLUG_TIP": "菜单提示插件",
504 "STR_PLUG_AUTO_INSTALL": "自动安装插件",
505 "STR_PLUG_PERSISTENCE": "数据持久化插件",
506 "STR_PLUG_INJECTION": "文件注入插件",
507 "STR_PLUG_CONF_REPLACE": "启动配置替换插件",
508 "STR_PLUG_PASSWORD": "密码插件",
509 "STR_PLUG_IMAGELIST": "文件列表插件",
510 "STR_PLUG_AUTO_MEMDISK": "自动Memdisk插件",
511 "STR_PLUG_DUD": "Driver Update Disk插件",
512 "STR_PLUG_DONATION": "捐助",
513
514 "STR_PATH_TOO_LONG": "路径超过最大支持长度,请检查!",
515 "STR_INPUT_TOO_LONG": "字符串超过最大支持长度,请检查!",
516 "STR_INVALID_FILE_PATH": "文件路径不合法或不存在,请检查!",
517 "STR_INVALID_FILE_PATH1": "第1个文件路径不合法或不存在,请检查!",
518 "STR_INVALID_FILE_PATH2": "第2个文件路径不合法或不存在,请检查!",
519 "STR_INVALID_NEW_FILE_PATH": "new 文件路径不合法或不存在,请检查!",
520 "STR_INVALID_DIR_PATH": "文件夹路径不合法,请检查!",
521 "STR_INVALID_NUMBER": "请输入合法的非负整数!",
522 "STR_INVALID_AUTOSEL": "autosel 的值超过了列表实际长度!",
523 "STR_INVALID_TIMEOUT": "请输入合法的超时秒数!",
524 "STR_INVALID_PERCENT": "请输入 0-100 以内的整数!",
525 "STR_INVALID_COLOR": "请输入合法的颜色!",
526 "STR_SELECT": "请选择",
527 "STR_SET_ALIAS_FOR_FILE": "为文件设置别名",
528 "STR_SET_ALIAS_FOR_DIR": "为目录设置别名",
529 "STR_SET_TIP_FOR_FILE": "为文件设置菜单提示信息",
530 "STR_SET_TIP_FOR_DIR": "为目录设置菜单提示信息",
531 "STR_SET_INJECTION_FOR_FILE": "[image] 为某一个文件设置注入",
532 "STR_SET_INJECTION_FOR_DIR": "[parent] 为某个目录下的所有文件设置相同的注入",
533 "STR_INVALID_ARCHIVE_PATH": "Archive 文件路径非法或不存在,请检查!",
534 "STR_SET_PWD_FOR_FILE": "[file] 为指定文件设置密码",
535 "STR_SET_PWD_FOR_DIR": "[parent] 为某个目录下的所有文件设置相同的密码",
536 "STR_SET_AUTO_INSTALL_FOR_FILE": "[image] 为某个镜像文件设置自动安装脚本",
537 "STR_SET_AUTO_INSTALL_FOR_DIR": "[parent] 为某个目录下的所有文件设置相同的自动安装脚本",
538
539 "STR_SET_CLASS_BY_KEY": "[key] 通过文件名关键字设置类型",
540 "STR_SET_CLASS_BY_DIR": "[dir] 为某个目录设置类型(只针对该目录本身,不包含里面的文件及子目录)",
541 "STR_SET_CLASS_BY_PARENT": "[parent] 为某个目录下的所有子文件设置类型(只针对文件,不包含目录)",
542
543 "STR_SET_IMAGE_PWD": "[file] 为某个镜像文件设置密码",
544 "STR_SET_PARENT_PWD": "[parent] 为某个目录下的所有文件设置相同的密码",
545
546
547
548 "STR_SET_SEARCH_ROOT": "设置搜索目录",
549 "STR_SET_DEFAULT_IMAGE": "设置默认镜像文件",
550 "STR_ADD_THEME": "添加主题",
551 "STR_ADD_FONT": "添加字体",
552 "STR_ADD_FILE_TO_LIST": "添加文件",
553 "STR_DEFAULT_SELECT": " 默认选择",
554 "STR_AUTO_TEMPLATE": "自动安装脚本",
555 "STR_ADD_AUTO_TEMPLATE": "添加自动安装脚本",
556 "STR_PERSISTENCE_DAT": "持久化数据文件",
557 "STR_ADD_PERSISTENCE_DAT": "添加持久化数据文件",
558 "STR_DUD_FILE": "DUD 文件",
559 "STR_ADD_DUD_FILE": "添加 DUD 文件",
560
561 "STR_DEL_LAST": "这是本条目中的最后一项,删除此项将会删除整个条目。是否继续?",
562 "STR_CLOSE_TIP": "后台服务不可用,页面即将关闭!",
563 "STR_SECURE_BOOT_ENABLE": "开启",
564 "STR_SECURE_BOOT_DISABLE": "未开启",
565 "STR_SYNTAX_ERROR_TIP": "ventoy.json 文件中存在语法错误,配置未加载!",
566 "STR_INVALID_CONFIG_TIP": "ventoy.json 文件中存在错误配置,配置未加载!",
567 "STR_CONFIG_SAVE_ERROR_TIP": "ventoy.json 文件写入失败,详细信息请参考 VentoyPlugson.log 文件!",
568
569 "STR_JSON_PREVIEW": "JSON 预览",
570 "STR_JSON_COPY_SUCCESS": "JSON 内容复制成功",
571 "STR_JSON_COPY_FAILED": "JSON 内容复制失败",
572
573 "STR_XXX": "xxx"
574 };
575
576 var g_current_dir;
577 var g_current_os;
578 var g_current_language = 'cn';
579 var g_vtoy_cur_language = g_vtoy_cur_language_cn;
580 var g_vtoy_data_default_index = 6;
581
582 var g_bios_postfix = [ "", "_legacy", "_uefi", "_ia32", "_aa64", "_mips" ];
583 var g_del_all_path = '4119ae33-98ea-448e-b9c0-569aafcf1fb4';
584 var g_file_with_extra = false;
585 var g_dir_with_extra = false;
586 var g_file_fuzzy_match = 0;
587 var g_file_modal_callback;
588 var g_dir_modal_callback;
589
590 function GetResetTabConfigTipMsg(index, name) {
591 var msgstr;
592
593 if (g_current_language === 'en') {
594 msgstr = 'Are you sure to reset all the configurations on the <code>' + name + g_bios_postfix[index] + '</code> tab ?';
595 } else {
596 msgstr = '确认要重置 <code>' + name + g_bios_postfix[index] + '</code> 标签页下的所有配置?';
597 }
598
599 return msgstr;
600 }
601
602 function CommonUpdateTabTitleIcon(exists, id, name) {
603 var exspan = " <span id='tab_0_icon' class='fa fa-circle' style='color:red;'></span>";
604 for (var i = 0; i < g_vtoy_data_default_index; i++) {
605 var fid = id + i + '"]';
606 var oldhtml = $(fid).html();
607 var newhtml;
608
609 if (exists[i]) {
610 newhtml = name + g_bios_postfix[i] + exspan;
611 } else {
612 newhtml = name + g_bios_postfix[i];
613 }
614
615 if (newhtml != oldhtml) {
616 $(fid).html(newhtml);
617 }
618 }
619 }
620
621 function ventoy_file_submit(form, extra) {
622 var filepath = $("#FilePath").val();
623 var fileextra = $("#FileExtra").val();
624
625 if (!filepath) {
626 return;
627 }
628
629 if (extra) {
630 if (!fileextra) {
631 return;
632 }
633 }
634
635 filepath = ventoy_replace_slash(filepath);
636
637 if (!ventoy_common_check_path(filepath)) {
638 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
639 return;
640 }
641
642 if (g_file_fuzzy_match && filepath.indexOf("*") >= 0) {
643 callVtoySync({
644 method : 'check_fuzzy',
645 path: filepath
646 }, function(data) {
647 if (data.exist != 0) {
648 if (typeof(g_file_modal_callback) === 'function') {
649 g_file_modal_callback(filepath, -1, fileextra);
650 }
651 $("#SetFileModal").modal('hide');
652 } else {
653 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
654 }
655 });
656 } else {
657 callVtoySync({
658 method : 'check_path',
659 dir: 0,
660 path: filepath
661 }, function(data) {
662 if (data.exist === 1) {
663 if (typeof(g_file_modal_callback) === 'function') {
664 g_file_modal_callback(filepath, 1, fileextra);
665 }
666 $("#SetFileModal").modal('hide');
667 } else {
668 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
669 }
670 });
671 }
672 }
673
674
675 var g_filepath_validator = $("#SetFileForm").validate({
676 rules: {
677 FilePath : {
678 required: true,
679 utfmaxlen: true,
680 noquotes: true
681 },
682 FileExtra : {
683 required: false,
684 utfmaxlen: true
685 }
686 },
687 submitHandler: function(form) {
688 ventoy_file_submit(form, g_file_with_extra);
689 }
690 });
691
692 var g_dirpath_validator = $("#SetDirForm").validate({
693 rules: {
694 DirPath : {
695 required: true,
696 utfmaxlen: true,
697 noquotes: true
698 },
699 DirExtra : {
700 required: false,
701 utfmaxlen: true
702 }
703 },
704 submitHandler: function(form) {
705 var dirpath = $("#DirPath").val();
706 var dirextra = $("#DirExtra").val();
707
708 if (!dirpath) {
709 return;
710 }
711
712 if (g_dir_with_extra) {
713 if (!dirextra) {
714 return;
715 }
716 }
717
718 dirpath = ventoy_replace_slash(dirpath);
719
720 if (dirpath.length > 0 && dirpath.charCodeAt(dirpath.length - 1) === 47) {
721 dirpath = dirpath.substring(0, dirpath.length - 1);
722 }
723
724 if (!ventoy_common_check_path(dirpath)) {
725 Message.error(g_vtoy_cur_language.STR_INVALID_DIR_PATH);
726 return;
727 }
728
729 callVtoySync({
730 method : 'check_path',
731 dir: 1,
732 path: dirpath
733 }, function(data) {
734 if (data.exist === 1) {
735 if (typeof(g_dir_modal_callback) === 'function') {
736 g_dir_modal_callback(dirpath, dirextra);
737 }
738 $("#SetDirModal").modal('hide');
739 } else {
740 Message.error(g_vtoy_cur_language.STR_INVALID_DIR_PATH);
741 }
742 });
743 }
744 });
745
746 function VtoySelectFilePath(cb, para) {
747 g_file_fuzzy_match = para.fuzzy;
748
749 if (para.extra) {
750 $('div[id=id_div_file_extra]').show();
751 $('#SetFileForm_extra').text(para.extra_title);
752 } else {
753 $('div[id=id_div_file_extra]').hide();
754 }
755
756 $('span[id=id_span_filepath_tip1]').each(function(){
757 $(this).text(para.tip1);
758 });
759 $('span[id=id_span_filepath_tip2]').each(function(){
760 $(this).text(para.tip2);
761 });
762 $('span[id=id_span_filepath_tip3]').each(function(){
763 $(this).text(para.tip3);
764 });
765
766 if (g_current_language === 'en') {
767 if (para.title.length === 0) {
768 $('#SetFileForm #SetFileForm_lang_1').text("Set File Path");
769 } else {
770 $('#SetFileForm #SetFileForm_lang_1').text(para.title);
771 }
772
773 $('#SetFileForm #SetFileForm_lang_2').text("File Path");
774 $('#SetFileForm #SetFileForm_lang_3').text(" OK");
775 $('#SetFileForm #SetFileForm_lang_4').text("Cancel");
776 $('#SetFileForm #id_note_setfile_cn').hide();
777 $('#SetFileForm #id_note_setfile_en').show();
778 } else {
779 if (para.title.length === 0) {
780 $('#SetFileForm #SetFileForm_lang_1').text("设置文件路径");
781 } else {
782 $('#SetFileForm #SetFileForm_lang_1').text(para.title);
783 }
784 $('#SetFileForm #SetFileForm_lang_2').text("文件路径");
785 $('#SetFileForm #SetFileForm_lang_3').text("确定");
786 $('#SetFileForm #SetFileForm_lang_4').text("取消");
787 $('#SetFileForm #id_note_setfile_cn').show();
788 $('#SetFileForm #id_note_setfile_en').hide();
789 }
790
791 if (para.tip3.length > 0) {
792 if (g_current_language === 'en') {
793 $('#SetFileForm #id_note_tip3_en').show();
794 $('#SetFileForm #id_note_tip3_cn').hide();
795 } else {
796 $('#SetFileForm #id_note_tip3_cn').show();
797 $('#SetFileForm #id_note_tip3_en').hide();
798 }
799 } else {
800 $('#SetFileForm #id_note_tip3_en').hide();
801 $('#SetFileForm #id_note_tip3_cn').hide();
802 }
803
804 g_file_modal_callback = cb;
805 g_file_with_extra = para.extra;
806 g_filepath_validator.settings.rules.FileExtra.required = g_file_with_extra;
807 g_filepath_validator.resetForm();
808 $("#SetFileModal").modal();
809 }
810
811
812 function VtoySelectDirPath(cb, para) {
813 $('span[id=id_span_dirpath_tip]').each(function(){
814 $(this).text(para.tip);
815 });
816 $('span[id=id_span_dirpath_tip3]').each(function(){
817 $(this).text(para.tip3);
818 });
819
820 if (para.extra) {
821 $('div[id=id_div_dir_extra]').show();
822 $('label[id=SetDirForm_extra]').text(para.extra_title);
823 } else {
824 $('div[id=id_div_dir_extra]').hide();
825 }
826
827 if (g_current_language === 'en') {
828 if (para.title.length === 0) {
829 $('#SetDirForm #SetDirForm_lang_1').text("Set Directory Path");
830 } else {
831 $('#SetDirForm #SetDirForm_lang_1').text(para.title);
832 }
833 $('#SetDirForm #SetDirForm_lang_2').text("Directory Path");
834 $('#SetDirForm #SetDirForm_lang_3').text(" OK");
835 $('#SetDirForm #SetDirForm_lang_4').text("Cancel");
836 $('#SetDirForm #id_note_setfile_cn').hide();
837 $('#SetDirForm #id_note_setfile_en').show();
838 } else {
839 if (para.title.length === 0) {
840 $('#SetDirForm #SetDirForm_lang_1').text("设置文件夹路径");
841 } else {
842 $('#SetDirForm #SetDirForm_lang_1').text(para.title);
843 }
844 $('#SetDirForm #SetDirForm_lang_2').text("文件夹路径");
845 $('#SetDirForm #SetDirForm_lang_3').text("确定");
846 $('#SetDirForm #SetDirForm_lang_4').text("取消");
847 $('#SetDirForm #id_note_setfile_cn').show();
848 $('#SetDirForm #id_note_setfile_en').hide();
849 }
850
851 if (para.tip3.length > 0) {
852 if (g_current_language === 'en') {
853 $('#SetDirForm #id_note_tip3_en').show();
854 $('#SetDirForm #id_note_tip3_cn').hide();
855 } else {
856 $('#SetDirForm #id_note_tip3_cn').show();
857 $('#SetDirForm #id_note_tip3_en').hide();
858 }
859 } else {
860 $('#SetDirForm #id_note_tip3_en').hide();
861 $('#SetDirForm #id_note_tip3_cn').hide();
862 }
863
864 g_dir_modal_callback = cb;
865 g_dir_with_extra = para.extra;
866 g_dirpath_validator.settings.rules.DirExtra.required = g_dir_with_extra;
867 g_dirpath_validator.resetForm();
868 $("#SetDirModal").modal();
869 }
870
871 function VtoyCommonChangeLanguage(newlang) {
872 if (newlang === 'en') {
873 g_vtoy_cur_language = g_vtoy_cur_language_en;
874 ;$.extend($.validator.messages, {
875 required: "This field is required",
876 remote: "Please modify this field",
877 maxlength: $.validator.format("You can enter up to {0} characters"),
878 minlength: $.validator.format("Must enter at least {0} characters"),
879 rangelength: $.validator.format("Please input {0} to {1} characters"),
880 range: $.validator.format("The input range is from {0} to {1}"),
881 max: $.validator.format("Please input a number less than or equal to {0}"),
882 min: $.validator.format("Please input a number bigger than or equal to {0}"),
883 utfmaxlen: $.validator.format("The string exceeds the maximum supported length"),
884 start_slash: $.validator.format("Must start with /"),
885 noquotes: $.validator.format("Can not include double quotes"),
886 filenamepart:$.validator.format("As part of file name, can not include invalid characters"),
887 printascii: $.validator.format("Can not include non-ascii characters.")
888 });
889
890 $("a[id=id_a_official_doc]").each(function(){
891 var oldlink = $(this).attr('href');
892 var newlink = oldlink.replace("/cn/", "/en/");
893 $(this).attr('href', newlink);
894 });
895
896 $("span[id=id_span_official_doc]").each(function(){
897 $(this).text(" Plugin Official Document");
898 });
899
900 $('#id_span_copy').text("Copy");
901 $('#id_span_preview').text("Preview");
902 $('#id_span_language').text("中文");
903
904 $("tr[id=tr_title_desc_cn]").each(function(){
905 $(this).hide();
906 });
907
908 $("tr[id=tr_title_desc_en]").each(function(){
909 $(this).show();
910 });
911
912 $("th[id=id_th_file_path]").each(function(){
913 $(this).text("Full File Path");
914 });
915
916 $("span[id=id_span_desc_cn]").each(function(){
917 $(this).hide();
918 });
919
920 } else {
921 g_vtoy_cur_language = g_vtoy_cur_language_cn;
922 ;$.extend($.validator.messages, {
923 required: "这是必填字段",
924 remote: "请修正此字段",
925 maxlength: $.validator.format("最多可以输入 {0} 个字符"),
926 minlength: $.validator.format("最少要输入 {0} 个字符"),
927 rangelength: $.validator.format("请输入长度在 {0} 到 {1} 之间的字符串"),
928 range: $.validator.format("取值范围{0}到{1}"),
929 max: $.validator.format("请输入不大于 {0} 的数值"),
930 min: $.validator.format("请输入不小于 {0} 的数值"),
931 utfmaxlen: $.validator.format("超过最大长度"),
932 start_slash: $.validator.format("必须以反斜杠 / 开头"),
933 noquotes: $.validator.format("不能包含双引号"),
934 filenamepart:$.validator.format("作为文件名的一部分,不能包含特殊的符号"),
935 printascii: $.validator.format("不能包含中文或其他非 ascii 字符。")
936 });
937
938 $("a[id=id_a_official_doc]").each(function(){
939 var oldlink = $(this).attr('href');
940 var newlink = oldlink.replace("/en/", "/cn/");
941 $(this).attr('href', newlink);
942 });
943
944 $("span[id=id_span_official_doc]").each(function(){
945 $(this).text(" 插件官网文档");
946 });
947
948 $('#id_span_copy').text("复制");
949 $('#id_span_preview').text("预览");
950 $('#id_span_language').text("English");
951
952 $("tr[id=tr_title_desc_cn]").each(function(){
953 $(this).show();
954 });
955
956 $("tr[id=tr_title_desc_en]").each(function(){
957 $(this).hide();
958 });
959
960 $("th[id=id_th_file_path]").each(function(){
961 $(this).text("文件路径");
962 });
963
964 $("span[id=id_span_desc_cn]").each(function(){
965 $(this).show();
966 });
967 }
968
969 $("span[id=id_span_menu_device]").text(g_vtoy_cur_language.STR_PLUG_DEVICE);
970 $("span[id=id_span_menu_control]").text(g_vtoy_cur_language.STR_PLUG_CONTROL);
971 $("span[id=id_span_menu_theme]").text(g_vtoy_cur_language.STR_PLUG_THEME);
972 $("span[id=id_span_menu_alias]").text(g_vtoy_cur_language.STR_PLUG_ALIAS);
973 $("span[id=id_span_menu_tip]").text(g_vtoy_cur_language.STR_PLUG_TIP);
974 $("span[id=id_span_menu_class]").text(g_vtoy_cur_language.STR_PLUG_CLASS);
975 $("span[id=id_span_menu_auto_install]").text(g_vtoy_cur_language.STR_PLUG_AUTO_INSTALL);
976 $("span[id=id_span_menu_persistence]").text(g_vtoy_cur_language.STR_PLUG_PERSISTENCE);
977 $("span[id=id_span_menu_injection]").text(g_vtoy_cur_language.STR_PLUG_INJECTION);
978 $("span[id=id_span_menu_conf_replace]").text(g_vtoy_cur_language.STR_PLUG_CONF_REPLACE);
979 $("span[id=id_span_menu_password]").text(g_vtoy_cur_language.STR_PLUG_PASSWORD);
980 $("span[id=id_span_menu_imagelist]").text(g_vtoy_cur_language.STR_PLUG_IMAGELIST);
981 $("span[id=id_span_menu_auto_memdisk]").text(g_vtoy_cur_language.STR_PLUG_AUTO_MEMDISK);
982 $("span[id=id_span_menu_dud]").text(g_vtoy_cur_language.STR_PLUG_DUD);
983 $('#id_span_save').text(g_vtoy_cur_language.STR_SAVE);
984 $('#id_span_reset').text(g_vtoy_cur_language.STR_RESET);
985 $('#id_span_donation').text(g_vtoy_cur_language.STR_PLUG_DONATION);
986
987 $('span[id=id_btn_span_reset]').each(function(){
988 $(this).text(' ' + g_vtoy_cur_language.STR_RESET);
989 });
990 $("span[id=id_span_btn_add]").each(function(){
991 $(this).text(g_vtoy_cur_language.STR_ADD);
992 });
993 $("span[id=id_span_btn_del]").each(function(){
994 $(this).text(g_vtoy_cur_language.STR_DEL);
995 });
996
997 $("span[id=id_span_enable]").each(function(){
998 $(this).text(g_vtoy_cur_language.STR_ENABLE);
999 });
1000
1001 $("th[id=id_th_operation]").each(function(){
1002 $(this).text(g_vtoy_cur_language.STR_OPERATION);
1003 });
1004 $("th[id=id_th_status]").each(function(){
1005 $(this).text(g_vtoy_cur_language.STR_STATUS);
1006 });
1007
1008 $('span [id=id_span_valid').each(function(){
1009 $(this).text(g_vtoy_cur_language.STR_VALID);
1010 });
1011 $('span [id=id_span_invalid').each(function(){
1012 $(this).text(g_vtoy_cur_language.STR_INVALID);
1013 });
1014
1015 $("td[id=td_title_desc]").each(function(){
1016 $(this).text(g_vtoy_cur_language.STR_OPT_DESC);
1017 });
1018
1019 $("td[id=td_title_setting]").each(function(){
1020 $(this).text(g_vtoy_cur_language.STR_OPT_SETTING);
1021 });
1022 }
1023
1024
1025 function ventoy_get_status_line(dir, exist) {
1026 if (dir) {
1027 if (exist === 0) {
1028 return '<span id="id_span_dir_nonexist" style="line-height: 1.5;" class="label pull-left bg-red">' + g_vtoy_cur_language.STR_DIR_NONEXIST + '</span>';
1029 } else {
1030 return '<span id="id_span_dir_exist" style="line-height: 1.5;" class="label pull-left bg-green">' + g_vtoy_cur_language.STR_DIR_EXIST + '</span>';
1031 }
1032 } else {
1033 if (exist === -1) {
1034 return '<span id="id_span_file_fuzzy" style="line-height: 1.5;" class="label pull-left bg-yellow">' + g_vtoy_cur_language.STR_FILE_FUZZY + '</span>';
1035 } else if (exist === 1) {
1036 return '<span id="id_span_file_exist" style="line-height: 1.5;" class="label pull-left bg-green">' + g_vtoy_cur_language.STR_FILE_EXIST + '</span>';
1037 } else {
1038 return '<span id="id_span_file_nonexist" style="line-height: 1.5;" class="label pull-left bg-red">' + g_vtoy_cur_language.STR_FILE_NONEXIST + '</span>';
1039 }
1040 }
1041 }
1042
1043
1044
1045 var g_type_select_callback;
1046
1047 var g_type_select_validator = $("#TypeSelectForm").validate({
1048 submitHandler: function(form) {
1049 var sel = parseInt($('input:radio[name=name_select_type_radio]:checked').val());
1050 if (typeof(g_type_select_callback) === 'function') {
1051 g_type_select_callback(sel);
1052 }
1053
1054 $("#TypeSelectModal").modal('hide');
1055 }
1056 });
1057
1058 function VtoySelectType(cb, para) {
1059
1060 $('#TypeSelectForm #TypeSelForm_lang_1').text(g_vtoy_cur_language.STR_SELECT);
1061
1062 if (g_current_language === 'en') {
1063 $('#TypeSelectForm #TypeSelForm_lang_2').text(" OK");
1064 $('#TypeSelectForm #TypeSelForm_lang_3').text("Cancel");
1065 } else {
1066 $('#TypeSelectForm #TypeSelForm_lang_2').text("确定");
1067 $('#TypeSelectForm #TypeSelForm_lang_3').text("取消");
1068 }
1069
1070 var $tbl = $("#id_type_select_table tbody");
1071 $tbl.empty();
1072
1073 for (var i = 0; i < para.length; i++) {
1074 var $tr;
1075
1076 if (para[i].selected) {
1077 $tr = $('<tr><td><label class="radio-inline"><input type="radio" checked="checked" name="name_select_type_radio" value="' + i + '"/>' + para[i].tip + '</label></td></tr>');
1078 } else {
1079 $tr = $('<tr><td><label class="radio-inline"><input type="radio" name="name_select_type_radio" value="' + i + '"/>' + para[i].tip + '</label></td></tr>');
1080 }
1081
1082 $tbl.append($tr);
1083 }
1084
1085 g_type_select_callback = cb;
1086 g_type_select_validator.resetForm();
1087 $("#TypeSelectModal").modal();
1088 }
1089
1090
1091 var g_set_key_callback;
1092
1093 var g_set_key_validator = $("#SetKeyForm").validate({
1094 rules: {
1095 SetKeyKey : {
1096 required: true,
1097 utfmaxlen: true
1098 },
1099 SetKeyValue : {
1100 required: true,
1101 utfmaxlen: true,
1102 filenamepart: true
1103 }
1104 },
1105
1106 submitHandler: function(form) {
1107 var key = $('input:text[id=SetKeyKey]').val();
1108 var val = $('input:text[id=SetKeyValue]').val();
1109
1110 if ((!key) || (!val))
1111 {
1112 return;
1113 }
1114
1115 if (typeof(g_set_key_callback) === 'function') {
1116 g_set_key_callback(key, val);
1117 }
1118
1119 $("#SetKeyModal").modal('hide');
1120 }
1121 });
1122
1123 function VtoySetKey(cb, para) {
1124
1125 $('#SetKeyForm #SetKeyForm_lang_1').text(para.title);
1126 $('#SetKeyForm #SetKeyForm_lang_2').text(para.title1);
1127 $('#SetKeyForm #SetKeyForm_lang_3').text(para.title2);
1128
1129 if (g_current_language === 'en') {
1130 $('#SetKeyForm #SetKeyForm_lang_4').text(" OK");
1131 $('#SetKeyForm #SetKeyForm_lang_5').text("Cancel");
1132 } else {
1133 $('#SetKeyForm #SetKeyForm_lang_4').text("确定");
1134 $('#SetKeyForm #SetKeyForm_lang_5').text("取消");
1135 }
1136
1137 g_set_key_callback = cb;
1138 g_set_key_validator.resetForm();
1139 $("#SetKeyModal").modal();
1140 }
1141
1142 var g_valid_color_name = [
1143 "black",
1144 "blue",
1145 "green",
1146 "cyan",
1147 "red",
1148 "magenta",
1149 "brown",
1150 "light-gray",
1151 "dark-gray",
1152 "light-blue",
1153 "light-green",
1154 "light-cyan",
1155 "light-red",
1156 "light-magenta",
1157 "yellow",
1158 "white"
1159 ];
1160
1161 function ventoy_check_color(color) {
1162 if (/^#[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]$/.test(color)) {
1163 return true;
1164 } else {
1165 for (var i = 0; i < g_valid_color_name.length; i++) {
1166 if (g_valid_color_name[i] === color) {
1167 return true;
1168 }
1169 }
1170 }
1171
1172 return false;
1173 }
1174
1175 function ventoy_check_percent(percent) {
1176 if (percent.length > 0) {
1177 return true;
1178 } else {
1179 return false;
1180 }
1181 }
1182
1183
1184 function ventoy_check_file_path(isopath, fuzzy, cb) {
1185 if (fuzzy && isopath.indexOf("*") >= 0) {
1186 callVtoySync({
1187 method : 'check_fuzzy',
1188 path: isopath
1189 }, function(data) {
1190 if (data.exist != 0) {
1191 if (typeof(cb) === 'function') {
1192 cb(data.exist);
1193 }
1194 } else {
1195 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
1196 }
1197 });
1198 } else {
1199 callVtoySync({
1200 method : 'check_path',
1201 dir: 0,
1202 path: isopath
1203 }, function(data) {
1204 if (data.exist === 1) {
1205 if (typeof(cb) === 'function') {
1206 cb(data.exist);
1207 }
1208 } else {
1209 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
1210 }
1211 });
1212 }
1213 }
1214
1215 function ventoy_random_string(e) { 
1216 var t = "abcdefhijkmnprstwxyz2345678";
1217 var a = t.length;
1218 var n = "";
1219
1220 e = e || 4;
1221    for (i = 0; i < e; i++) n += t.charAt(Math.floor(Math.random() * a));
1222    return n
1223 }
1224
1225
1226 var g_set_filefile_callback;
1227
1228 var g_set_filefile_validator = $("#SetFileFileForm").validate({
1229 rules: {
1230 FileFilePath1 : {
1231 required: true,
1232 utfmaxlen: true
1233 },
1234 FileFilePath2 : {
1235 required: true,
1236 utfmaxlen: true
1237 }
1238 },
1239
1240 submitHandler: function(form) {
1241 var path1 = $('input:text[id=FileFilePath1]').val();
1242 var path2 = $('input:text[id=FileFilePath2]').val();
1243
1244 if ((!path1) || (!path2))
1245 {
1246 return;
1247 }
1248
1249 path1 = ventoy_replace_slash(path1);
1250
1251 if (!ventoy_common_check_path(path1)) {
1252 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH1);
1253 return;
1254 }
1255
1256 path2 = ventoy_replace_slash(path2);
1257
1258 if (!ventoy_common_check_path(path2)) {
1259 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH2);
1260 return;
1261 }
1262
1263 callVtoy({
1264 method : 'check_path2',
1265 dir1: 0,
1266 fuzzy1: 1,
1267 path1: path1,
1268 dir2: 0,
1269 fuzzy2: 0,
1270 path2: path2
1271 }, function(retdata) {
1272 if (retdata.exist1 != 0 && retdata.exist2 != 0) {
1273 if (typeof(g_set_filefile_callback) === 'function') {
1274 g_set_filefile_callback(retdata.exist1, path1, path2);
1275 }
1276
1277 $("#SetFileFileModal").modal('hide');
1278 } else if (retdata.exist1 === 0) {
1279 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH1);
1280 } else {
1281 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH2);
1282 }
1283 });
1284 }
1285 });
1286
1287 function VtoySetFileFile(cb, para) {
1288
1289 $('#SetFileFileForm #SetFileFileForm_title').text(para.title);
1290 $('#SetFileFileForm #SetFileFileForm_label1').text(para.label1);
1291 $('#SetFileFileForm #SetFileFileForm_label2').text(para.label2);
1292
1293 if (g_current_language === 'en') {
1294 $('#SetFileFileForm #SetFileFileForm_ok').text(" OK");
1295 $('#SetFileFileForm #SetFileFileForm_cancel').text("Cancel");
1296
1297 $('#SetFileFileForm #id_note_filefile_cn').hide();
1298 $('#SetFileFileForm #id_note_filefile_en').show();
1299
1300 } else {
1301 $('#SetFileFileForm #SetFileFileForm_ok').text("确定");
1302 $('#SetFileFileForm #SetFileFileForm_cancel').text("取消");
1303
1304 $('#SetFileFileForm #id_note_filefile_en').hide();
1305 $('#SetFileFileForm #id_note_filefile_cn').show();
1306 }
1307
1308 $('span[id=id_span_filefile_tip1]').each(function(){
1309 $(this).text(para.tip1);
1310 });
1311 $('span[id=id_span_filefile_tip2]').each(function(){
1312 $(this).text(para.tip2);
1313 });
1314 $('span[id=id_span_filefile_tip3]').each(function(){
1315 $(this).text(para.tip3);
1316 });
1317
1318 g_set_filefile_callback = cb;
1319 g_set_filefile_validator.resetForm();
1320 $("#SetFileFileModal").modal();
1321 }
1322
1323
1324 var g_set_dirfile_callback;
1325
1326 var g_set_dirfile_validator = $("#SetDirFileForm").validate({
1327 rules: {
1328 DirFilePath1 : {
1329 required: true,
1330 utfmaxlen: true
1331 },
1332 DirFilePath2 : {
1333 required: true,
1334 utfmaxlen: true
1335 }
1336 },
1337
1338 submitHandler: function(form) {
1339 var path1 = $('input:text[id=DirFilePath1]').val();
1340 var path2 = $('input:text[id=DirFilePath2]').val();
1341
1342 if ((!path1) || (!path2))
1343 {
1344 return;
1345 }
1346
1347 path1 = ventoy_replace_slash(path1);
1348
1349 if (!ventoy_common_check_path(path1)) {
1350 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH1);
1351 return;
1352 }
1353
1354 path2 = ventoy_replace_slash(path2);
1355
1356 if (!ventoy_common_check_path(path2)) {
1357 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH2);
1358 return;
1359 }
1360
1361 callVtoy({
1362 method : 'check_path2',
1363 dir1: 1,
1364 fuzzy1: 0,
1365 path1: path1,
1366 dir2: 0,
1367 fuzzy2: 0,
1368 path2: path2
1369 }, function(retdata) {
1370 if (retdata.exist1 != 0 && retdata.exist2 != 0) {
1371 if (typeof(g_set_dirfile_callback) === 'function') {
1372 g_set_dirfile_callback(path1, path2);
1373 }
1374
1375 $("#SetDirFileModal").modal('hide');
1376 } else if (retdata.exist1 === 0) {
1377 Message.error(g_vtoy_cur_language.STR_INVALID_DIR_PATH);
1378 } else {
1379 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH2);
1380 }
1381 });
1382 }
1383 });
1384
1385 function VtoySetDirFile(cb, para) {
1386
1387 $('#SetDirFileModal #SetDirFileForm_title').text(para.title);
1388 $('#SetDirFileModal #SetDirFileForm_label1').text(para.label1);
1389 $('#SetDirFileModal #SetDirFileForm_label2').text(para.label2);
1390
1391 if (g_current_language === 'en') {
1392 $('#SetDirFileModal #SetDirFileForm_ok').text(" OK");
1393 $('#SetDirFileModal #SetDirFileForm_cancel').text("Cancel");
1394
1395 $('#SetDirFileModal #id_note_dirfile_cn').hide();
1396 $('#SetDirFileModal #id_note_dirfile_en').show();
1397
1398 } else {
1399 $('#SetDirFileModal #SetDirFileForm_ok').text("确定");
1400 $('#SetDirFileModal #SetDirFileForm_cancel').text("取消");
1401
1402 $('#SetDirFileModal #id_note_dirfile_en').hide();
1403 $('#SetDirFileModal #id_note_dirfile_cn').show();
1404 }
1405
1406 $('span[id=id_span_dirfile_tip1]').each(function(){
1407 $(this).text(para.tip1);
1408 });
1409 $('span[id=id_span_dirfile_tip2]').each(function(){
1410 $(this).text(para.tip2);
1411 });
1412
1413 g_set_dirfile_callback = cb;
1414 g_set_dirfile_validator.resetForm();
1415 $("#SetDirFileModal").modal();
1416 }
1417
1418 function ventoy_get_xslg_addbtn(mclass) {
1419 return '<button class="btn btn-xs btn-lg btn-success btn-add ' + mclass + '"><span class="fa fa-plus">&nbsp;&nbsp;</span><span id="id_span_btn_add">'+g_vtoy_cur_language.STR_ADD+'</span></button>';
1420 }
1421
1422 function ventoy_get_xslg_delbtn(mclass) {
1423 return '<button class="btn btn-xs btn-lg btn-danger btn-del '+mclass+'"><span class="fa fa-trash">&nbsp;&nbsp;</span><span id="id_span_btn_del">'+g_vtoy_cur_language.STR_DEL+'</span></button>';
1424 }
1425
1426 function ventoy_get_addbtn(mclass) {
1427 return '<button class="btn btn-success btn-add ' + mclass + '"><span class="fa fa-plus">&nbsp;&nbsp;</span><span id="id_span_btn_add">'+g_vtoy_cur_language.STR_ADD+'</span></button>';
1428 }
1429
1430 function ventoy_get_delbtn(mclass) {
1431 return '<button class="btn btn-danger btn-del '+mclass+'"><span class="fa fa-trash">&nbsp;&nbsp;</span><span id="id_span_btn_del">'+g_vtoy_cur_language.STR_DEL+'</span></button>';
1432 }
1433
1434 function ventoy_confirm(title, cb, data1, data2) {
1435 Modal.confirm({msg:g_vtoy_cur_language.STR_DEL_LAST}).on(function(e) {
1436 if (e) {
1437 if (typeof(cb) === 'function') {
1438 cb(data1, data2);
1439 }
1440 }
1441 });
1442 }