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