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