2 function ventoy_replace_slash(str
) {
3 var str1
= str
.replace(/\\/g
, '/');
4 var str2
= str1
.replace(/\/\//g, '/');
9 function ventoy_get_ulen(str
) {
10 var c
, b
= 0, l
= str
.length
;
12 c
= str
.charCodeAt(--l
);
13 b
+= (c
< 128) ? 1 : ((c
< 2048) ? 2 : ((c
< 65536) ? 3 : 4));
19 function ventoy_common_check_path(path
) {
20 if (path
.indexOf('//') >= 0) {
24 if (path
.length
<= g_current_dir
.length
) {
28 if (path
.substr(0, g_current_dir
.length
) != g_current_dir
) {
37 function loadContent(page
) {
38 $("#plugson-content").load(page
+ ".html?_=" + (new Date().getTime()), function() {
39 $("body").scrollTop(0);
44 function callVtoyCatchErr(p1
, p2
, p3
) {
45 var url
= '/vtoy/json';
47 var func = function(data
) {};
48 var errfunc = function(xmlHttpRequest
, textStatus
, errorThrown
) {};
50 if (typeof(p1
) === 'string') {
52 } else if (typeof(p1
) === 'object') {
55 if (typeof(p2
) === 'object') {
57 } else if (typeof(p2
) === 'function') {
60 if (typeof(p3
) === 'function') {
64 //vtoy.debug('callVtoy:\t\t\t\t' + JSON.stringify(data));
70 data: JSON
.stringify(data
),
73 complete: function(data
) {
74 //vtoy.debug('callVtoy\'s resp:\t\t' + data.responseText);
80 function callVtoy(p1
, p2
, p3
) {
81 var url
= '/vtoy/json';
83 var func = function(data
) {};
85 if (typeof(p1
) === 'string') {
87 } else if (typeof(p1
) === 'object') {
90 if (typeof(p2
) === 'object') {
92 } else if (typeof(p2
) === 'function') {
95 if (typeof(p3
) === 'function') {
99 //vtoy.debug('callVtoy:\t\t\t\t' + JSON.stringify(data));
105 data: JSON
.stringify(data
),
107 error: function(xmlHttpRequest
, textStatus
, errorThrown
) {
109 if(undefined === errorThrown
)
111 Message
.error(g_vtoy_cur_language
.STR_WEB_REMOTE_ABNORMAL
);
113 else if(undefined === errorThrown
.length
)
117 else if('' == errorThrown
.trim())
126 Message
.error(g_vtoy_cur_language
.STR_WEB_REQUEST_TIMEOUT
);
129 case 'Service Unavailable':
131 Message
.error(g_vtoy_cur_language
.STR_WEB_SERVICE_UNAVAILABLE
);
140 Message
.error(g_vtoy_cur_language
.STR_WEB_COMMUNICATION_ERR
+ errorThrown
);
146 complete: function(data
) {
147 //vtoy.debug('callVtoy\'s resp:\t\t' + data.responseText);
152 function callVtoyASyncTimeout(time
, data
, func
) {
160 data: JSON
.stringify(data
),
162 error: function(xmlHttpRequest
, textStatus
, errorThrown
) {
163 if(undefined === errorThrown
)
166 else if(undefined === errorThrown
.length
)
170 else if('' == errorThrown
.trim())
179 callVtoyASyncTimeout(time
, data
, func
);
182 case 'Service Unavailable':
197 complete: function(data
) {
198 //vtoy.debug('callVtoyASyncTimeout\'s resp:\t' + JSON.stringify(data));
203 function callVtoySync(data
, func
) {
204 //vtoy.debug('callVtoySync:\t\t\t' + JSON.stringify(data));
211 data: JSON
.stringify(data
),
212 success: function VtoyCallFuncWrapper(data
) {
213 if (data
.result
=== 'busy') {
214 var titlestr
= '<span class="fa fa-check-circle" style="color:green; font-weight:bold;"> ' + g_vtoy_cur_language
.STR_INFO
+ '</span>';
215 var msgstr
= '<span style="font-size:14px; font-weight:bold;"> ' + g_vtoy_cur_language
.STR_WEB_SERVICE_BUSY
+ '</span>';
216 Modal
.alert({title:titlestr
, msg:msgstr
, btnok:g_vtoy_cur_language
.STR_BTN_OK
});
221 error: function(xmlHttpRequest
, textStatus
, errorThrown
) {
222 if(undefined === errorThrown
)
224 Message
.error(g_vtoy_cur_language
.STR_WEB_REMOTE_ABNORMAL
);
226 else if(undefined === errorThrown
.length
)
230 else if('' == errorThrown
.trim())
239 Message
.error(g_vtoy_cur_language
.STR_WEB_REQUEST_TIMEOUT
);
242 case 'Service Unavailable':
244 Message
.error(g_vtoy_cur_language
.STR_WEB_SERVICE_UNAVAILABLE
);
253 Message
.error(g_vtoy_cur_language
.STR_WEB_COMMUNICATION_ERR
+ errorThrown
);
259 complete: function(data
) {
260 //vtoy.debug('callVtoySync\'s resp:\t' + JSON.stringify(data));
275 String
.prototype.endsWith = function(str
) {
276 if (str
== null || str
== "" || this.length
== 0 || str
.length
> this.length
)
278 if (this.substring(this.length
- str
.length
) == str
)
284 window
.Message = function() {
285 var _showMsg = function(type
, msg
, time
) {
286 var o
= {type : type
, msg : msg
};
293 var _show = function(options
) {
299 $.extend(ops
, options
);
301 var msg_class
= 'alert-success';
302 if('S' === ops
.type
|| 's' === ops
.type
) {
303 msg_class
= 'alert-success';
304 } else if ('E' === ops
.type
|| 'e' === ops
.type
) {
305 msg_class
= 'alert-danger';
306 } else if ('W' === ops
.type
|| 'w' === ops
.type
) {
307 msg_class
= 'alert-warning';
308 } else if ('I' === ops
.type
|| 'i' === ops
.type
) {
309 msg_class
= 'alert-info';
311 alert("未知的类型,请使用: w-警告;s-成功;e-失败;i-提示");
314 var $messageContainer
= $("#fcss_message");
315 if($messageContainer
.length
=== 0) {
316 $messageContainer
= $('<div id="fcss_message" style="position:fixed; left: 20%; right: 20%; top:0px; z-index:99999999"></div>');
317 $messageContainer
.appendTo($('body'));
319 var $div
= $('<div class="alert ' + msg_class
+ ' alert-dismissible fade in" role="alert" style="margin-bottom: 0; padding-top:10px; padding-bottom: 10px;"></div>');
320 var $btn
= $('<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>');
321 $div
.append($btn
).append(ops
.msg
).appendTo($messageContainer
);
322 setTimeout(function() {
327 var _success = function(msg
, time
) {
328 _showMsg('s', msg
, time
);
330 var _error = function(msg
, time
) {
331 _showMsg('e', msg
, time
|| 5000);
333 var _warn = function(msg
, time
) {
334 _showMsg('w', msg
, time
);
336 var _info = function(msg
, time
) {
337 _showMsg('i', msg
, time
);
350 var g_vtoy_cur_language_en
=
354 "STR_BTN_CANCEL": "Cancel",
356 "STR_RESET": " Reset",
357 "STR_DISCARD": " Discard",
358 "STR_ENABLE": " Enable",
361 "STR_CLEAR": "Clear",
362 "STR_STATUS": "Status",
363 "STR_DEFAULT": "Default",
364 "STR_DEFAULT_SEL": "Default",
365 "STR_RANDOM_SEL": "Random",
366 "STR_OPERATION": "Operation",
367 "STR_VALID": "Valid",
368 "STR_INVALID": "Invalid",
369 "STR_OPT_SETTING": "Option Setting",
370 "STR_OPT_DESC": "Option Description",
374 "STR_SAVE_TIP": "Data in current page has been modified. Do you want to save it?",
375 "STR_SAVE_SUCCESS": "Configuration successfully saved!",
376 "STR_FILE_EXIST": "OK",
377 "STR_FILE_NONEXIST": "Invalid",
378 "STR_FILE_FUZZY": "Fuzzy",
379 "STR_DIR_EXIST": "OK",
380 "STR_DIR_NONEXIST": "Invalid",
381 "STR_DUPLICATE_PATH": "Duplicate path",
382 "STR_DELETE_CONFIRM": "Delete this item, Continue?",
383 "STR_FILE_PATH": "File Path",
384 "STR_DIR_PATH": "Directory Path",
386 "STR_SET_ALIAS": "Set Menu Alias",
387 "STR_ALIAS": "Alias",
388 "STR_SET_TIP": "Set Menu Tip",
390 "STR_SET_CLASS": "Set Menu Class",
391 "STR_CLASS": "Class",
392 "STR_SET_INJECTION": "Set Injection",
393 "STR_SET_AUTO_INS": "Set Auto Install",
394 "STR_SET_AUTO_TEMPLATE": "Template",
396 "STR_SET_PERSISTENCE": "Set Persistence",
397 "STR_SET_PERSISTENCE_DAT": "Dat File",
399 "STR_SET_DUD": "Set DUD",
400 "STR_SET_DUD_FILE": "DUD File",
402 "STR_PASSWORD": "Password",
403 "STR_SET_PASSWORD": "Set Password",
404 "STR_PASSWORD_TYPE": "Password Type",
405 "STR_PASSWORD_VALUE": "Password Value",
408 "STR_WEB_COMMUNICATION_ERR":"Communication error:",
409 "STR_WEB_REMOTE_ABNORMAL":"Communication error: remote abnormal",
410 "STR_WEB_REQUEST_TIMEOUT":"Communication error: Request timed out",
411 "STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
412 "STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
414 "STR_PLUG_DEVICE": "Device Information",
415 "STR_PLUG_CONTROL": "Global Control Plugin",
416 "STR_PLUG_THEME": "Theme Plugin",
417 "STR_PLUG_ALIAS": "Menu Alias Plugin",
418 "STR_PLUG_CLASS": "Menu Class Plugin",
419 "STR_PLUG_TIP": "Menu Tip Plugin",
420 "STR_PLUG_AUTO_INSTALL": "Auto Install Plugin",
421 "STR_PLUG_PERSISTENCE": "Persistence Plugin",
422 "STR_PLUG_INJECTION": "Injection Plugin",
423 "STR_PLUG_CONF_REPLACE": "Boot Conf Replace Plugin",
424 "STR_PLUG_PASSWORD": "Password Plugin",
425 "STR_PLUG_IMAGELIST": "Image List Plugin",
426 "STR_PLUG_AUTO_MEMDISK": "Auto Memdisk Plugin",
427 "STR_PLUG_DUD": "DUD Plugin",
428 "STR_PLUG_DONATION": "Donation",
430 "STR_PATH_TOO_LONG": "The path exceeds the maximum supported length, please check!",
431 "STR_INPUT_TOO_LONG": "The string exceeds the maximum supported length, please check!",
432 "STR_INVALID_FILE_PATH": "Invalid full file path, please check!",
433 "STR_INVALID_FILE_PATH1": "The 1st file path is invalid!",
434 "STR_INVALID_FILE_PATH2": "The 2nd file path is invalid!",
435 "STR_INVALID_NEW_FILE_PATH": "The full file path of new is invalid, please check!",
436 "STR_INVALID_DIR_PATH": "Invalid directory path, please check!",
437 "STR_INVALID_NUMBER": "Please input valid non-negative integer!",
438 "STR_INVALID_AUTOSEL": "autosel exceeds the length of the list!",
439 "STR_INVALID_TIMEOUT": "Please input valid timeout integer!",
440 "STR_INVALID_PERCENT": "Please input integer between 0-100 !",
441 "STR_INVALID_COLOR": "Please input valid color!",
442 "STR_SELECT": "Please Select",
443 "STR_SET_ALIAS_FOR_FILE": "Set Menu Alias For File",
444 "STR_SET_ALIAS_FOR_DIR": "Set Menu Alias For Directory",
445 "STR_SET_TIP_FOR_FILE": "Set Menu Tip For File",
446 "STR_SET_TIP_FOR_DIR": "Set Menu Tip For Directory",
447 "STR_SET_INJECTION_FOR_FILE": "[image] Set injection for a file",
448 "STR_SET_INJECTION_FOR_DIR": "[parent] Set the same injection for all the files under a directory.",
449 "STR_INVALID_ARCHIVE_PATH": "Invalid archive file path, please check!",
450 "STR_SET_PWD_FOR_FILE": "[file] Set password for a file.",
451 "STR_SET_PWD_FOR_DIR": "[parent] Set the same password for all the files under a directory.",
452 "STR_SET_AUTO_INSTALL_FOR_FILE": "[image] Set auto install template for a file",
453 "STR_SET_AUTO_INSTALL_FOR_DIR": "[parent] Set the same auto install template for all the files under a directory.",
455 "STR_SET_CLASS_BY_KEY": "[key] Set menu class by filename keyword.",
456 "STR_SET_CLASS_BY_DIR": "[dir] Set menu class for a directory.",
457 "STR_SET_CLASS_BY_PARENT": "[parent] Set menu class for all the files under a directory.",
458 "STR_SET_IMAGE_PWD": "[file] Set Password For A File",
459 "STR_SET_PARENT_PWD": "[parent] Set the same password for all the files under a directory.",
461 "STR_SET_SEARCH_ROOT": "Set Search Root",
462 "STR_SET_DEFAULT_IMAGE": "Set Default Image",
463 "STR_ADD_THEME": "Add Theme",
464 "STR_ADD_FONT": "Set Font",
465 "STR_ADD_FILE_TO_LIST": "Add File To List",
466 "STR_DEFAULT_SELECT": " Default",
467 "STR_AUTO_TEMPLATE": "Auto Install Template",
468 "STR_ADD_AUTO_TEMPLATE": "Add Auto Install Template",
470 "STR_PERSISTENCE_DAT": "Persistence Dat File",
471 "STR_ADD_PERSISTENCE_DAT": "Add Persistence Dat File",
473 "STR_DUD_FILE": "DUD File",
474 "STR_ADD_DUD_FILE": "Add DUD File",
476 "STR_DEL_LAST": "The entry will be deleted if you delete the this last item. Continue?",
478 "STR_CLOSE_TIP": "Service unavailable, the page will close!",
479 "STR_SECURE_BOOT_ENABLE": "Enable",
480 "STR_SECURE_BOOT_DISABLE": "Disable",
481 "STR_SYNTAX_ERROR_TIP": "Syntax error detected in ventoy.json, so the configuration is not loaded!",
486 var g_vtoy_cur_language_cn
=
490 "STR_BTN_CANCEL": "取消",
493 "STR_DISCARD": " 丢弃",
500 "STR_DEFAULT_SEL": "默认选择",
501 "STR_RANDOM_SEL": "随机选择",
502 "STR_OPERATION": "操作",
505 "STR_OPT_SETTING": "选项设置",
506 "STR_OPT_DESC": "选项说明",
510 "STR_SAVE_TIP": "当前页面数据已经修改,是否保存?",
511 "STR_SAVE_SUCCESS": "配置保存成功!",
512 "STR_FILE_EXIST": "文件存在",
513 "STR_FILE_NONEXIST": "文件无效",
514 "STR_FILE_FUZZY": "模糊匹配",
515 "STR_DIR_EXIST": "目录存在",
516 "STR_DIR_NONEXIST": "目录无效",
517 "STR_DUPLICATE_PATH": "路径不允许重复",
518 "STR_DELETE_CONFIRM": "确定要删除吗?",
519 "STR_FILE_PATH": "文件路径",
520 "STR_DIR_PATH": "目录路径",
522 "STR_SET_ALIAS": "设置菜单别名",
524 "STR_SET_TIP": "设置菜单提示",
526 "STR_SET_CLASS": "设置菜单类型",
528 "STR_SET_INJECTION": "设置文件注入",
529 "STR_SET_AUTO_INS": "设置自动安装",
530 "STR_SET_AUTO_TEMPLATE": "自动安装脚本",
531 "STR_SET_PERSISTENCE": "设置持久化文件",
532 "STR_SET_PERSISTENCE_DAT": "持久化文件",
534 "STR_SET_DUD": "设置 DUD",
535 "STR_SET_DUD_FILE": "DUD 文件",
537 "STR_PASSWORD": "密码",
538 "STR_SET_PASSWORD": "设置密码",
539 "STR_PASSWORD_TYPE": "密码类型",
540 "STR_PASSWORD_VALUE": "密码内容",
542 "STR_WEB_COMMUNICATION_ERR":"通信失败:",
543 "STR_WEB_REMOTE_ABNORMAL":"通信失败:服务端异常",
544 "STR_WEB_REQUEST_TIMEOUT":"通信失败:请求超时",
545 "STR_WEB_SERVICE_UNAVAILABLE":"通信失败:服务不可用",
546 "STR_WEB_SERVICE_BUSY":"后台服务正忙,请稍后重试",
548 "STR_PLUG_DEVICE": "设备信息",
549 "STR_PLUG_CONTROL": "全局控制插件",
550 "STR_PLUG_THEME": "主题插件",
551 "STR_PLUG_ALIAS": "菜单别名插件",
552 "STR_PLUG_CLASS": "菜单类型插件",
553 "STR_PLUG_TIP": "菜单提示插件",
554 "STR_PLUG_AUTO_INSTALL": "自动安装插件",
555 "STR_PLUG_PERSISTENCE": "数据持久化插件",
556 "STR_PLUG_INJECTION": "文件注入插件",
557 "STR_PLUG_CONF_REPLACE": "启动配置替换插件",
558 "STR_PLUG_PASSWORD": "密码插件",
559 "STR_PLUG_IMAGELIST": "文件列表插件",
560 "STR_PLUG_AUTO_MEMDISK": "自动Memdisk插件",
561 "STR_PLUG_DUD": "Driver Update Disk插件",
562 "STR_PLUG_DONATION": "捐助",
564 "STR_PATH_TOO_LONG": "路径超过最大支持长度,请检查!",
565 "STR_INPUT_TOO_LONG": "字符串超过最大支持长度,请检查!",
566 "STR_INVALID_FILE_PATH": "文件路径不合法,请检查!",
567 "STR_INVALID_FILE_PATH1": "第1个文件路径不合法,请检查!",
568 "STR_INVALID_FILE_PATH2": "第2个文件路径不合法,请检查!",
569 "STR_INVALID_NEW_FILE_PATH": "new 文件路径不合法,请检查!",
570 "STR_INVALID_DIR_PATH": "文件夹路径不合法,请检查!",
571 "STR_INVALID_NUMBER": "请输入合法的非负整数!",
572 "STR_INVALID_AUTOSEL": "autosel 的值超过了列表实际长度!",
573 "STR_INVALID_TIMEOUT": "请输入合法的超时秒数!",
574 "STR_INVALID_PERCENT": "请输入 0-100 以内的整数!",
575 "STR_INVALID_COLOR": "请输入合法的颜色!",
577 "STR_SET_ALIAS_FOR_FILE": "为文件设置别名",
578 "STR_SET_ALIAS_FOR_DIR": "为目录设置别名",
579 "STR_SET_TIP_FOR_FILE": "为文件设置菜单提示信息",
580 "STR_SET_TIP_FOR_DIR": "为目录设置菜单提示信息",
581 "STR_SET_INJECTION_FOR_FILE": "[image] 为某一个文件设置注入",
582 "STR_SET_INJECTION_FOR_DIR": "[parent] 为某个目录下的所有文件设置相同的注入",
583 "STR_INVALID_ARCHIVE_PATH": "Archive 文件路径非法,请检查!",
584 "STR_SET_PWD_FOR_FILE": "[file] 为指定文件设置密码",
585 "STR_SET_PWD_FOR_DIR": "[parent] 为某个目录下的所有文件设置相同的密码",
586 "STR_SET_AUTO_INSTALL_FOR_FILE": "[image] 为某个镜像文件设置自动安装脚本",
587 "STR_SET_AUTO_INSTALL_FOR_DIR": "[parent] 为某个目录下的所有文件设置相同的自动安装脚本",
589 "STR_SET_CLASS_BY_KEY": "[key] 通过文件名关键字设置类型",
590 "STR_SET_CLASS_BY_DIR": "[dir] 为某个目录设置类型(只针对该目录本身,不包含里面的文件及子目录)",
591 "STR_SET_CLASS_BY_PARENT": "[parent] 为某个目录下的所有子文件设置类型(只针对文件,不包含目录)",
593 "STR_SET_IMAGE_PWD": "[file] 为某个镜像文件设置密码",
594 "STR_SET_PARENT_PWD": "[parent] 为某个目录下的所有文件设置相同的密码",
598 "STR_SET_SEARCH_ROOT": "设置搜索目录",
599 "STR_SET_DEFAULT_IMAGE": "设置默认镜像文件",
600 "STR_ADD_THEME": "添加主题",
601 "STR_ADD_FONT": "添加字体",
602 "STR_ADD_FILE_TO_LIST": "添加文件",
603 "STR_DEFAULT_SELECT": " 默认选择",
604 "STR_AUTO_TEMPLATE": "自动安装脚本",
605 "STR_ADD_AUTO_TEMPLATE": "添加自动安装脚本",
606 "STR_PERSISTENCE_DAT": "持久化数据文件",
607 "STR_ADD_PERSISTENCE_DAT": "添加持久化数据文件",
608 "STR_DUD_FILE": "DUD 文件",
609 "STR_ADD_DUD_FILE": "添加 DUD 文件",
611 "STR_DEL_LAST": "这是本条目中的最后一项,删除此项将会删除整个条目。是否继续?",
612 "STR_CLOSE_TIP": "后台服务不可用,页面即将关闭!",
613 "STR_SECURE_BOOT_ENABLE": "开启",
614 "STR_SECURE_BOOT_DISABLE": "未开启",
615 "STR_SYNTAX_ERROR_TIP": "ventoy.json 文件中存在语法错误,配置未加载!",
624 var g_current_language
= 'cn';
625 var g_vtoy_cur_language
= g_vtoy_cur_language_cn
;
626 var g_vtoy_data_default_index
= 6;
628 var g_file_with_extra
= false;
629 var g_dir_with_extra
= false;
630 var g_file_fuzzy_match
= 0;
631 var g_file_modal_callback
;
632 var g_dir_modal_callback
;
634 function ventoy_file_submit(form
, extra
) {
635 var filepath
= $("#FilePath").val();
636 var fileextra
= $("#FileExtra").val();
648 filepath
= ventoy_replace_slash(filepath
);
650 if (!ventoy_common_check_path(filepath
)) {
651 Message
.error(g_vtoy_cur_language
.STR_INVALID_FILE_PATH
);
655 if (g_file_fuzzy_match
&& filepath
.indexOf("*") >= 0) {
657 method : 'check_fuzzy',
660 if (data
.exist
!= 0) {
661 if (typeof(g_file_modal_callback
) === 'function') {
662 g_file_modal_callback(filepath
, -1, fileextra
);
664 $("#SetFileModal").modal('hide');
666 Message
.error(g_vtoy_cur_language
.STR_INVALID_FILE_PATH
);
671 method : 'check_path',
675 if (data
.exist
=== 1) {
676 if (typeof(g_file_modal_callback
) === 'function') {
677 g_file_modal_callback(filepath
, 1, fileextra
);
679 $("#SetFileModal").modal('hide');
681 Message
.error(g_vtoy_cur_language
.STR_INVALID_FILE_PATH
);
688 var g_filepath_validator
= $("#SetFileForm").validate({
700 submitHandler: function(form
) {
701 ventoy_file_submit(form
, g_file_with_extra
);
705 var g_dirpath_validator
= $("#SetDirForm").validate({
717 submitHandler: function(form
) {
718 var dirpath
= $("#DirPath").val();
719 var dirextra
= $("#DirExtra").val();
725 if (g_dir_with_extra
) {
731 dirpath
= ventoy_replace_slash(dirpath
);
733 if (dirpath
.length
> 0 && dirpath
.charCodeAt(dirpath
.length
- 1) === 47) {
734 dirpath
= dirpath
.substring(0, dirpath
.length
- 1);
737 if (!ventoy_common_check_path(dirpath
)) {
738 Message
.error(g_vtoy_cur_language
.STR_INVALID_DIR_PATH
);
743 method : 'check_path',
747 if (data
.exist
=== 1) {
748 if (typeof(g_dir_modal_callback
) === 'function') {
749 g_dir_modal_callback(dirpath
, dirextra
);
751 $("#SetDirModal").modal('hide');
753 Message
.error(g_vtoy_cur_language
.STR_INVALID_DIR_PATH
);
759 function VtoySelectFilePath(cb
, para
) {
760 g_file_fuzzy_match
= para
.fuzzy
;
763 $('div[id=id_div_file_extra]').show();
764 $('#SetFileForm_extra').text(para
.extra_title
);
766 $('div[id=id_div_file_extra]').hide();
769 $('span[id=id_span_filepath_tip1]').each(function(){
770 $(this).text(para
.tip1
);
772 $('span[id=id_span_filepath_tip2]').each(function(){
773 $(this).text(para
.tip2
);
775 $('span[id=id_span_filepath_tip3]').each(function(){
776 $(this).text(para
.tip3
);
779 if (g_current_language
=== 'en') {
780 if (para
.title
.length
=== 0) {
781 $('#SetFileForm #SetFileForm_lang_1').text("Set File Path");
783 $('#SetFileForm #SetFileForm_lang_1').text(para
.title
);
786 $('#SetFileForm #SetFileForm_lang_2').text("File Path");
787 $('#SetFileForm #SetFileForm_lang_3').text(" OK");
788 $('#SetFileForm #SetFileForm_lang_4').text("Cancel");
789 $('#SetFileForm #id_note_setfile_cn').hide();
790 $('#SetFileForm #id_note_setfile_en').show();
792 if (para
.title
.length
=== 0) {
793 $('#SetFileForm #SetFileForm_lang_1').text("设置文件路径");
795 $('#SetFileForm #SetFileForm_lang_1').text(para
.title
);
797 $('#SetFileForm #SetFileForm_lang_2').text("文件路径");
798 $('#SetFileForm #SetFileForm_lang_3').text("确定");
799 $('#SetFileForm #SetFileForm_lang_4').text("取消");
800 $('#SetFileForm #id_note_setfile_cn').show();
801 $('#SetFileForm #id_note_setfile_en').hide();
804 if (para
.tip3
.length
> 0) {
805 if (g_current_language
=== 'en') {
806 $('#SetFileForm #id_note_tip3_en').show();
807 $('#SetFileForm #id_note_tip3_cn').hide();
809 $('#SetFileForm #id_note_tip3_cn').show();
810 $('#SetFileForm #id_note_tip3_en').hide();
813 $('#SetFileForm #id_note_tip3_en').hide();
814 $('#SetFileForm #id_note_tip3_cn').hide();
817 g_file_modal_callback
= cb
;
818 g_file_with_extra
= para
.extra
;
819 g_filepath_validator
.settings
.rules
.FileExtra
.required
= g_file_with_extra
;
820 g_filepath_validator
.resetForm();
821 $("#SetFileModal").modal();
825 function VtoySelectDirPath(cb
, para
) {
826 $('span[id=id_span_dirpath_tip]').each(function(){
827 $(this).text(para
.tip
);
829 $('span[id=id_span_dirpath_tip3]').each(function(){
830 $(this).text(para
.tip3
);
834 $('div[id=id_div_dir_extra]').show();
835 $('label[id=SetDirForm_extra]').text(para
.extra_title
);
837 $('div[id=id_div_dir_extra]').hide();
840 if (g_current_language
=== 'en') {
841 if (para
.title
.length
=== 0) {
842 $('#SetDirForm #SetDirForm_lang_1').text("Set Directory Path");
844 $('#SetDirForm #SetDirForm_lang_1').text(para
.title
);
846 $('#SetDirForm #SetDirForm_lang_2').text("Directory Path");
847 $('#SetDirForm #SetDirForm_lang_3').text(" OK");
848 $('#SetDirForm #SetDirForm_lang_4').text("Cancel");
849 $('#SetDirForm #id_note_setfile_cn').hide();
850 $('#SetDirForm #id_note_setfile_en').show();
852 if (para
.title
.length
=== 0) {
853 $('#SetDirForm #SetDirForm_lang_1').text("设置文件夹路径");
855 $('#SetDirForm #SetDirForm_lang_1').text(para
.title
);
857 $('#SetDirForm #SetDirForm_lang_2').text("文件夹路径");
858 $('#SetDirForm #SetDirForm_lang_3').text("确定");
859 $('#SetDirForm #SetDirForm_lang_4').text("取消");
860 $('#SetDirForm #id_note_setfile_cn').show();
861 $('#SetDirForm #id_note_setfile_en').hide();
864 if (para
.tip3
.length
> 0) {
865 if (g_current_language
=== 'en') {
866 $('#SetDirForm #id_note_tip3_en').show();
867 $('#SetDirForm #id_note_tip3_cn').hide();
869 $('#SetDirForm #id_note_tip3_cn').show();
870 $('#SetDirForm #id_note_tip3_en').hide();
873 $('#SetDirForm #id_note_tip3_en').hide();
874 $('#SetDirForm #id_note_tip3_cn').hide();
877 g_dir_modal_callback
= cb
;
878 g_dir_with_extra
= para
.extra
;
879 g_dirpath_validator
.settings
.rules
.DirExtra
.required
= g_dir_with_extra
;
880 g_dirpath_validator
.resetForm();
881 $("#SetDirModal").modal();
884 function VtoyCommonChangeLanguage(newlang
) {
885 if (newlang
=== 'en') {
886 g_vtoy_cur_language
= g_vtoy_cur_language_en
;
887 ;$.extend($.validator
.messages
, {
888 required: "This field is required",
889 remote: "Please modify this field",
890 maxlength: $.validator
.format("You can enter up to {0} characters"),
891 minlength: $.validator
.format("Must enter at least {0} characters"),
892 rangelength: $.validator
.format("Please input {0} to {1} characters"),
893 range: $.validator
.format("The input range is from {0} to {1}"),
894 max: $.validator
.format("Please input a number less than or equal to {0}"),
895 min: $.validator
.format("Please input a number bigger than or equal to {0}"),
896 utfmaxlen: $.validator
.format("The string exceeds the maximum supported length"),
897 start_slash: $.validator
.format("Must start with /"),
898 noquotes: $.validator
.format("Can not include double quotes"),
899 printascii: $.validator
.format("Can not include non-ascii characters.")
902 $("a[id=id_a_official_doc]").each(function(){
903 var oldlink
= $(this).attr('href');
904 var newlink
= oldlink
.replace("/cn/", "/en/");
905 $(this).attr('href', newlink
);
908 $("span[id=id_span_official_doc]").each(function(){
909 $(this).text(" Plugin Official Document");
912 $('#id_span_language').text("中文");
914 $("tr[id=tr_title_desc_cn]").each(function(){
918 $("tr[id=tr_title_desc_en]").each(function(){
922 $("th[id=id_th_file_path]").each(function(){
923 $(this).text("Full File Path");
926 $("span[id=id_span_desc_cn]").each(function(){
931 g_vtoy_cur_language
= g_vtoy_cur_language_cn
;
932 ;$.extend($.validator
.messages
, {
935 maxlength: $.validator
.format("最多可以输入 {0} 个字符"),
936 minlength: $.validator
.format("最少要输入 {0} 个字符"),
937 rangelength: $.validator
.format("请输入长度在 {0} 到 {1} 之间的字符串"),
938 range: $.validator
.format("取值范围{0}到{1}"),
939 max: $.validator
.format("请输入不大于 {0} 的数值"),
940 min: $.validator
.format("请输入不小于 {0} 的数值"),
941 utfmaxlen: $.validator
.format("超过最大长度"),
942 start_slash: $.validator
.format("必须以反斜杠 / 开头"),
943 noquotes: $.validator
.format("不能包含双引号"),
944 printascii: $.validator
.format("不能包含中文或其他非 ascii 字符。")
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
);
953 $("span[id=id_span_official_doc]").each(function(){
954 $(this).text(" 插件官网文档");
957 $('#id_span_language').text("English");
959 $("tr[id=tr_title_desc_cn]").each(function(){
963 $("tr[id=tr_title_desc_en]").each(function(){
967 $("th[id=id_th_file_path]").each(function(){
968 $(this).text("文件路径");
971 $("span[id=id_span_desc_cn]").each(function(){
976 $("span[id=id_span_menu_device]").text(g_vtoy_cur_language
.STR_PLUG_DEVICE
);
977 $("span[id=id_span_menu_control]").text(g_vtoy_cur_language
.STR_PLUG_CONTROL
);
978 $("span[id=id_span_menu_theme]").text(g_vtoy_cur_language
.STR_PLUG_THEME
);
979 $("span[id=id_span_menu_alias]").text(g_vtoy_cur_language
.STR_PLUG_ALIAS
);
980 $("span[id=id_span_menu_tip]").text(g_vtoy_cur_language
.STR_PLUG_TIP
);
981 $("span[id=id_span_menu_class]").text(g_vtoy_cur_language
.STR_PLUG_CLASS
);
982 $("span[id=id_span_menu_auto_install]").text(g_vtoy_cur_language
.STR_PLUG_AUTO_INSTALL
);
983 $("span[id=id_span_menu_persistence]").text(g_vtoy_cur_language
.STR_PLUG_PERSISTENCE
);
984 $("span[id=id_span_menu_injection]").text(g_vtoy_cur_language
.STR_PLUG_INJECTION
);
985 $("span[id=id_span_menu_conf_replace]").text(g_vtoy_cur_language
.STR_PLUG_CONF_REPLACE
);
986 $("span[id=id_span_menu_password]").text(g_vtoy_cur_language
.STR_PLUG_PASSWORD
);
987 $("span[id=id_span_menu_imagelist]").text(g_vtoy_cur_language
.STR_PLUG_IMAGELIST
);
988 $("span[id=id_span_menu_auto_memdisk]").text(g_vtoy_cur_language
.STR_PLUG_AUTO_MEMDISK
);
989 $("span[id=id_span_menu_dud]").text(g_vtoy_cur_language
.STR_PLUG_DUD
);
990 $('#id_span_save').text(g_vtoy_cur_language
.STR_SAVE
);
991 $('#id_span_reset').text(g_vtoy_cur_language
.STR_RESET
);
992 $('#id_span_donation').text(g_vtoy_cur_language
.STR_PLUG_DONATION
);
994 $("span[id=id_span_btn_add]").each(function(){
995 $(this).text(g_vtoy_cur_language
.STR_ADD
);
997 $("span[id=id_span_btn_del]").each(function(){
998 $(this).text(g_vtoy_cur_language
.STR_DEL
);
1001 $("span[id=id_span_enable]").each(function(){
1002 $(this).text(g_vtoy_cur_language
.STR_ENABLE
);
1005 $("th[id=id_th_operation]").each(function(){
1006 $(this).text(g_vtoy_cur_language
.STR_OPERATION
);
1008 $("th[id=id_th_status]").each(function(){
1009 $(this).text(g_vtoy_cur_language
.STR_STATUS
);
1012 $('span [id=id_span_valid').each(function(){
1013 $(this).text(g_vtoy_cur_language
.STR_VALID
);
1015 $('span [id=id_span_invalid').each(function(){
1016 $(this).text(g_vtoy_cur_language
.STR_INVALID
);
1019 $("td[id=td_title_desc]").each(function(){
1020 $(this).text(g_vtoy_cur_language
.STR_OPT_DESC
);
1023 $("td[id=td_title_setting]").each(function(){
1024 $(this).text(g_vtoy_cur_language
.STR_OPT_SETTING
);
1029 function ventoy_get_status_line(dir
, exist
) {
1032 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>';
1034 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>';
1038 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>';
1039 } else if (exist
=== 1) {
1040 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>';
1042 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>';
1049 var g_type_select_callback
;
1051 var g_type_select_validator
= $("#TypeSelectForm").validate({
1052 submitHandler: function(form
) {
1053 var sel
= parseInt($('input:radio[name=name_select_type_radio]:checked').val());
1054 if (typeof(g_type_select_callback
) === 'function') {
1055 g_type_select_callback(sel
);
1058 $("#TypeSelectModal").modal('hide');
1062 function VtoySelectType(cb
, para
) {
1064 $('#TypeSelectForm #TypeSelForm_lang_1').text(g_vtoy_cur_language
.STR_SELECT
);
1066 if (g_current_language
=== 'en') {
1067 $('#SetDirForm #SetDirForm_lang_2').text(" OK");
1068 $('#SetDirForm #SetDirForm_lang_3').text("Cancel");
1070 $('#SetDirForm #SetDirForm_lang_2').text("确定");
1071 $('#SetDirForm #SetDirForm_lang_3').text("取消");
1074 var $tbl
= $("#id_type_select_table tbody");
1077 for (var i
= 0; i
< para
.length
; i
++) {
1080 if (para
[i
].selected
) {
1081 $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>');
1083 $tr
= $('<tr><td><label class="radio-inline"><input type="radio" name="name_select_type_radio" value="' + i
+ '"/>' + para
[i
].tip
+ '</label></td></tr>');
1089 g_type_select_callback
= cb
;
1090 g_type_select_validator
.resetForm();
1091 $("#TypeSelectModal").modal();
1095 var g_set_key_callback
;
1097 var g_set_key_validator
= $("#SetKeyForm").validate({
1109 submitHandler: function(form
) {
1110 var key
= $('input:text[id=SetKeyKey]').val();
1111 var val
= $('input:text[id=SetKeyValue]').val();
1113 if ((!key
) || (!val
))
1118 if (typeof(g_set_key_callback
) === 'function') {
1119 g_set_key_callback(key
, val
);
1122 $("#SetKeyModal").modal('hide');
1126 function VtoySetKey(cb
, para
) {
1128 $('#SetKeyForm #SetKeyForm_lang_1').text(para
.title
);
1129 $('#SetKeyForm #SetKeyForm_lang_2').text(para
.title1
);
1130 $('#SetKeyForm #SetKeyForm_lang_3').text(para
.title2
);
1132 if (g_current_language
=== 'en') {
1133 $('#SetDirForm #SetDirForm_lang_4').text(" OK");
1134 $('#SetDirForm #SetDirForm_lang_5').text("Cancel");
1136 $('#SetDirForm #SetDirForm_lang_4').text("确定");
1137 $('#SetDirForm #SetDirForm_lang_5').text("取消");
1140 g_set_key_callback
= cb
;
1141 g_set_key_validator
.resetForm();
1142 $("#SetKeyModal").modal();
1145 var g_valid_color_name
= [
1164 function ventoy_check_color(color
) {
1165 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
)) {
1168 for (var i
= 0; i
< g_valid_color_name
.length
; i
++) {
1169 if (g_valid_color_name
[i
] === color
) {
1178 function ventoy_check_percent(percent
) {
1179 if (percent
.length
> 0) {
1187 function ventoy_check_file_path(isopath
, fuzzy
, cb
) {
1188 if (fuzzy
&& isopath
.indexOf("*") >= 0) {
1190 method : 'check_fuzzy',
1193 if (data
.exist
!= 0) {
1194 if (typeof(cb
) === 'function') {
1198 Message
.error(g_vtoy_cur_language
.STR_INVALID_FILE_PATH
);
1203 method : 'check_path',
1207 if (data
.exist
=== 1) {
1208 if (typeof(cb
) === 'function') {
1212 Message
.error(g_vtoy_cur_language
.STR_INVALID_FILE_PATH
);
1218 function ventoy_random_string(e
) {
1219 var t
= "abcdefhijkmnprstwxyz2345678";
1224 for (i
= 0; i
< e
; i
++) n
+= t
.charAt(Math
.floor(Math
.random() * a
));
1229 var g_set_filefile_callback
;
1231 var g_set_filefile_validator
= $("#SetFileFileForm").validate({
1243 submitHandler: function(form
) {
1244 var path1
= $('input:text[id=FileFilePath1]').val();
1245 var path2
= $('input:text[id=FileFilePath2]').val();
1247 if ((!path1
) || (!path2
))
1252 path1
= ventoy_replace_slash(path1
);
1254 if (!ventoy_common_check_path(path1
)) {
1255 Message
.error(g_vtoy_cur_language
.STR_INVALID_FILE_PATH1
);
1259 path2
= ventoy_replace_slash(path2
);
1261 if (!ventoy_common_check_path(path2
)) {
1262 Message
.error(g_vtoy_cur_language
.STR_INVALID_FILE_PATH2
);
1267 method : 'check_path2',
1274 }, function(retdata
) {
1275 if (retdata
.exist1
!= 0 && retdata
.exist2
!= 0) {
1276 if (typeof(g_set_filefile_callback
) === 'function') {
1277 g_set_filefile_callback(retdata
.exist1
, path1
, path2
);
1280 $("#SetFileFileModal").modal('hide');
1281 } else if (retdata
.exist1
=== 0) {
1282 Message
.error(g_vtoy_cur_language
.STR_INVALID_FILE_PATH1
);
1284 Message
.error(g_vtoy_cur_language
.STR_INVALID_FILE_PATH2
);
1290 function VtoySetFileFile(cb
, para
) {
1292 $('#SetFileFileForm #SetFileFileForm_title').text(para
.title
);
1293 $('#SetFileFileForm #SetFileFileForm_label1').text(para
.label1
);
1294 $('#SetFileFileForm #SetFileFileForm_label2').text(para
.label2
);
1296 if (g_current_language
=== 'en') {
1297 $('#SetFileFileForm #SetFileFileForm_ok').text(" OK");
1298 $('#SetFileFileForm #SetFileFileForm_cancel').text("Cancel");
1300 $('#SetFileFileForm #id_note_filefile_cn').hide();
1301 $('#SetFileFileForm #id_note_filefile_en').show();
1304 $('#SetFileFileForm #SetFileFileForm_ok').text("确定");
1305 $('#SetFileFileForm #SetFileFileForm_cancel').text("取消");
1307 $('#SetFileFileForm #id_note_filefile_en').hide();
1308 $('#SetFileFileForm #id_note_filefile_cn').show();
1311 $('span[id=id_span_filefile_tip1]').each(function(){
1312 $(this).text(para
.tip1
);
1314 $('span[id=id_span_filefile_tip2]').each(function(){
1315 $(this).text(para
.tip2
);
1317 $('span[id=id_span_filefile_tip3]').each(function(){
1318 $(this).text(para
.tip3
);
1321 g_set_filefile_callback
= cb
;
1322 g_set_filefile_validator
.resetForm();
1323 $("#SetFileFileModal").modal();
1327 var g_set_dirfile_callback
;
1329 var g_set_dirfile_validator
= $("#SetDirFileForm").validate({
1341 submitHandler: function(form
) {
1342 var path1
= $('input:text[id=DirFilePath1]').val();
1343 var path2
= $('input:text[id=DirFilePath2]').val();
1345 if ((!path1
) || (!path2
))
1350 path1
= ventoy_replace_slash(path1
);
1352 if (!ventoy_common_check_path(path1
)) {
1353 Message
.error(g_vtoy_cur_language
.STR_INVALID_FILE_PATH1
);
1357 path2
= ventoy_replace_slash(path2
);
1359 if (!ventoy_common_check_path(path2
)) {
1360 Message
.error(g_vtoy_cur_language
.STR_INVALID_FILE_PATH2
);
1365 method : 'check_path2',
1372 }, function(retdata
) {
1373 if (retdata
.exist1
!= 0 && retdata
.exist2
!= 0) {
1374 if (typeof(g_set_dirfile_callback
) === 'function') {
1375 g_set_dirfile_callback(path1
, path2
);
1378 $("#SetDirFileModal").modal('hide');
1379 } else if (retdata
.exist1
=== 0) {
1380 Message
.error(g_vtoy_cur_language
.STR_INVALID_DIR_PATH
);
1382 Message
.error(g_vtoy_cur_language
.STR_INVALID_FILE_PATH2
);
1388 function VtoySetDirFile(cb
, para
) {
1390 $('#SetDirFileModal #SetDirFileForm_title').text(para
.title
);
1391 $('#SetDirFileModal #SetDirFileForm_label1').text(para
.label1
);
1392 $('#SetDirFileModal #SetDirFileForm_label2').text(para
.label2
);
1394 if (g_current_language
=== 'en') {
1395 $('#SetDirFileModal #SetDirFileModal_ok').text(" OK");
1396 $('#SetDirFileModal #SetDirFileModal_cancel').text("Cancel");
1398 $('#SetDirFileModal #id_note_dirfile_cn').hide();
1399 $('#SetDirFileModal #id_note_dirfile_en').show();
1402 $('#SetDirFileModal #SetDirFileModal_ok').text("确定");
1403 $('#SetDirFileModal #SetDirFileModal_cancel').text("取消");
1405 $('#SetDirFileModal #id_note_dirfile_en').hide();
1406 $('#SetDirFileModal #id_note_dirfile_cn').show();
1409 $('span[id=id_span_dirfile_tip1]').each(function(){
1410 $(this).text(para
.tip1
);
1412 $('span[id=id_span_dirfile_tip2]').each(function(){
1413 $(this).text(para
.tip2
);
1416 g_set_dirfile_callback
= cb
;
1417 g_set_dirfile_validator
.resetForm();
1418 $("#SetDirFileModal").modal();
1421 function ventoy_get_xslg_addbtn(mclass
) {
1422 return '<button class="btn btn-xs btn-lg btn-success btn-add ' + mclass
+ '"><span class="fa fa-plus"> </span><span id="id_span_btn_add">'+g_vtoy_cur_language
.STR_ADD
+'</span></button>';
1425 function ventoy_get_xslg_delbtn(mclass
) {
1426 return '<button class="btn btn-xs btn-lg btn-danger btn-del '+mclass
+'"><span class="fa fa-trash"> </span><span id="id_span_btn_del">'+g_vtoy_cur_language
.STR_DEL
+'</span></button>';
1429 function ventoy_get_addbtn(mclass
) {
1430 return '<button class="btn btn-success btn-add ' + mclass
+ '"><span class="fa fa-plus"> </span><span id="id_span_btn_add">'+g_vtoy_cur_language
.STR_ADD
+'</span></button>';
1433 function ventoy_get_delbtn(mclass
) {
1434 return '<button class="btn btn-danger btn-del '+mclass
+'"><span class="fa fa-trash"> </span><span id="id_span_btn_del">'+g_vtoy_cur_language
.STR_DEL
+'</span></button>';
1437 function ventoy_confirm(title
, cb
, data1
, data2
) {
1438 Modal
.confirm({msg:g_vtoy_cur_language
.STR_DEL_LAST
}).on(function(e
) {
1440 if (typeof(cb
) === 'function') {