X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/4bf43ab9d4e6b724836724c1d514760d164df79a..HEAD:/Plugson/www/static/js/vtoy.js diff --git a/Plugson/www/static/js/vtoy.js b/Plugson/www/static/js/vtoy.js index aee3379..ad82628 100644 --- a/Plugson/www/static/js/vtoy.js +++ b/Plugson/www/static/js/vtoy.js @@ -1,7 +1,23 @@ +function VtoyUTF16HexToAscii(hex) { + var str = ""; + for (var i = 0; i < hex.length; i += 4) { + str += String.fromCharCode(parseInt(hex.substring(i, i + 4), 16)); + } + + return str; +} + function ventoy_replace_slash(str) { var str1 = str.replace(/\\/g, '/'); var str2 = str1.replace(/\/\//g, '/'); + + if (str2 && str2.length > 0) { + if (str2.substr(-1) === "/") { + return str2.substr(0, str2.length - 1); + } + } + return str2; } @@ -17,6 +33,8 @@ function ventoy_get_ulen(str) { function ventoy_common_check_path(path) { + var curdir + if (path.indexOf('//') >= 0) { return false; } @@ -25,7 +43,12 @@ function ventoy_common_check_path(path) { return false; } - if (path.substr(0, g_current_dir.length) != g_current_dir) { + curdir = path.substr(0, g_current_dir.length); + if (curdir.match("^[a-z]:$")) { + curdir = curdir.toUpperCase(); + } + + if (curdir != g_current_dir) { return false; } @@ -281,71 +304,6 @@ String.prototype.endsWith = function(str) { return false; } -window.Message = function() { - var _showMsg = function(type, msg, time) { - var o = {type : type, msg : msg }; - if(time) { - o.time = time; - } - _show(o); - } - - var _show = function(options) { - var ops = { - msg : "æç¤ºå 容", - type: 'S', - time: 3000 - }; - $.extend(ops, options); - - var msg_class = 'alert-success'; - if('S' === ops.type || 's' === ops.type) { - msg_class = 'alert-success'; - } else if ('E' === ops.type || 'e' === ops.type) { - msg_class = 'alert-danger'; - } else if ('W' === ops.type || 'w' === ops.type) { - msg_class = 'alert-warning'; - } else if ('I' === ops.type || 'i' === ops.type) { - msg_class = 'alert-info'; - } else { - alert("æªç¥çç±»åï¼è¯·ä½¿ç¨: w-è¦å;s-æå;e-失败;i-æç¤º"); - return; - } - var $messageContainer = $("#fcss_message"); - if($messageContainer.length === 0) { - $messageContainer = $('
'); - $messageContainer.appendTo($('body')); - } - var $div = $(''); - var $btn = $(''); - $div.append($btn).append(ops.msg).appendTo($messageContainer); - setTimeout(function() { - $div.remove(); - }, ops.time); - } - - var _success = function(msg, time) { - _showMsg('s', msg, time); - } - var _error = function(msg, time) { - _showMsg('e', msg, time || 5000); - } - var _warn = function(msg, time) { - _showMsg('w', msg, time); - } - var _info = function(msg, time) { - _showMsg('i', msg, time); - } - - return { - success : _success, - error : _error, - warn : _warn, - info : _info, - show : _show - } -}(); - var g_vtoy_cur_language_en = { @@ -369,6 +327,7 @@ var g_vtoy_cur_language_en = "STR_OPT_SETTING": "Option Setting", "STR_OPT_DESC": "Option Description", "STR_EDIT": "Edit", + "STR_RESET": "Reset", "STR_FILE": "File", "STR_DIR": "Dir", "STR_SAVE_TIP": "Data in current page has been modified. Do you want to save it?", @@ -429,10 +388,10 @@ var g_vtoy_cur_language_en = "STR_PATH_TOO_LONG": "The path exceeds the maximum supported length, please check!", "STR_INPUT_TOO_LONG": "The string exceeds the maximum supported length, please check!", - "STR_INVALID_FILE_PATH": "Invalid full file path, please check!", - "STR_INVALID_FILE_PATH1": "The 1st file path is invalid!", - "STR_INVALID_FILE_PATH2": "The 2nd file path is invalid!", - "STR_INVALID_NEW_FILE_PATH": "The full file path of new is invalid, please check!", + "STR_INVALID_FILE_PATH": "Invalid or nonexist full file path, please check!", + "STR_INVALID_FILE_PATH1": "The 1st file path is invalid or nonexist!", + "STR_INVALID_FILE_PATH2": "The 2nd file path is invalid or nonexist!", + "STR_INVALID_NEW_FILE_PATH": "The full file path of new is invalid or nonexist, please check!", "STR_INVALID_DIR_PATH": "Invalid directory path, please check!", "STR_INVALID_NUMBER": "Please input valid non-negative integer!", "STR_INVALID_AUTOSEL": "autosel exceeds the length of the list!", @@ -446,7 +405,7 @@ var g_vtoy_cur_language_en = "STR_SET_TIP_FOR_DIR": "Set Menu Tip For Directory", "STR_SET_INJECTION_FOR_FILE": "[image] Set injection for a file", "STR_SET_INJECTION_FOR_DIR": "[parent] Set the same injection for all the files under a directory.", - "STR_INVALID_ARCHIVE_PATH": "Invalid archive file path, please check!", + "STR_INVALID_ARCHIVE_PATH": "Invalid or nonexist archive file path, please check!", "STR_SET_PWD_FOR_FILE": "[file] Set password for a file.", "STR_SET_PWD_FOR_DIR": "[parent] Set the same password for all the files under a directory.", "STR_SET_AUTO_INSTALL_FOR_FILE": "[image] Set auto install template for a file", @@ -479,6 +438,12 @@ var g_vtoy_cur_language_en = "STR_SECURE_BOOT_ENABLE": "Enable", "STR_SECURE_BOOT_DISABLE": "Disable", "STR_SYNTAX_ERROR_TIP": "Syntax error detected in ventoy.json, so the configuration is not loaded!", + "STR_INVALID_CONFIG_TIP": "Invalid configuration detected in ventoy.json, so the configuration is not loaded!", + "STR_CONFIG_SAVE_ERROR_TIP": "Failed to write ventoy.json file. Check VentoyPlugson.log for more details!", + + "STR_JSON_PREVIEW": "JSON Preview", + "STR_JSON_COPY_SUCCESS": "JSON Copy Success", + "STR_JSON_COPY_FAILED": "JSON Copy Failed", "STR_XXX": "xxx" }; @@ -505,6 +470,7 @@ var g_vtoy_cur_language_cn = "STR_OPT_SETTING": "é项设置", "STR_OPT_DESC": "é项说æ", "STR_EDIT": "设置", + "STR_RESET": "éç½®", "STR_FILE": "æä»¶", "STR_DIR": "ç®å½", "STR_SAVE_TIP": "å½å页颿°æ®å·²ç»ä¿®æ¹ï¼æ¯å¦ä¿åï¼", @@ -563,10 +529,10 @@ var g_vtoy_cur_language_cn = "STR_PATH_TOO_LONG": "è·¯å¾è¶ è¿æå¤§æ¯æé¿åº¦ï¼è¯·æ£æ¥ï¼", "STR_INPUT_TOO_LONG": "åç¬¦ä¸²è¶ è¿æå¤§æ¯æé¿åº¦ï¼è¯·æ£æ¥ï¼", - "STR_INVALID_FILE_PATH": "æä»¶è·¯å¾ä¸åæ³ï¼è¯·æ£æ¥ï¼", - "STR_INVALID_FILE_PATH1": "第1个æä»¶è·¯å¾ä¸åæ³ï¼è¯·æ£æ¥ï¼", - "STR_INVALID_FILE_PATH2": "第2个æä»¶è·¯å¾ä¸åæ³ï¼è¯·æ£æ¥ï¼", - "STR_INVALID_NEW_FILE_PATH": "new æä»¶è·¯å¾ä¸åæ³ï¼è¯·æ£æ¥ï¼", + "STR_INVALID_FILE_PATH": "æä»¶è·¯å¾ä¸åæ³æä¸åå¨ï¼è¯·æ£æ¥ï¼", + "STR_INVALID_FILE_PATH1": "第1个æä»¶è·¯å¾ä¸åæ³æä¸åå¨ï¼è¯·æ£æ¥ï¼", + "STR_INVALID_FILE_PATH2": "第2个æä»¶è·¯å¾ä¸åæ³æä¸åå¨ï¼è¯·æ£æ¥ï¼", + "STR_INVALID_NEW_FILE_PATH": "new æä»¶è·¯å¾ä¸åæ³æä¸åå¨ï¼è¯·æ£æ¥ï¼", "STR_INVALID_DIR_PATH": "æä»¶å¤¹è·¯å¾ä¸åæ³ï¼è¯·æ£æ¥ï¼", "STR_INVALID_NUMBER": "请è¾å ¥åæ³çéè´æ´æ°ï¼", "STR_INVALID_AUTOSEL": "autosel çå¼è¶ è¿äºå表å®é é¿åº¦ï¼", @@ -580,7 +546,7 @@ var g_vtoy_cur_language_cn = "STR_SET_TIP_FOR_DIR": "为ç®å½è®¾ç½®èåæç¤ºä¿¡æ¯", "STR_SET_INJECTION_FOR_FILE": "[image] 为æä¸ä¸ªæä»¶è®¾ç½®æ³¨å ¥", "STR_SET_INJECTION_FOR_DIR": "[parent] 为æä¸ªç®å½ä¸çæææä»¶è®¾ç½®ç¸åçæ³¨å ¥", - "STR_INVALID_ARCHIVE_PATH": "Archive æä»¶è·¯å¾éæ³ï¼è¯·æ£æ¥ï¼", + "STR_INVALID_ARCHIVE_PATH": "Archive æä»¶è·¯å¾éæ³æä¸åå¨ï¼è¯·æ£æ¥ï¼", "STR_SET_PWD_FOR_FILE": "[file] 为æå®æä»¶è®¾ç½®å¯ç ", "STR_SET_PWD_FOR_DIR": "[parent] 为æä¸ªç®å½ä¸çæææä»¶è®¾ç½®ç¸åçå¯ç ", "STR_SET_AUTO_INSTALL_FOR_FILE": "[image] 为æä¸ªéåæä»¶è®¾ç½®èªå¨å®è£ èæ¬", @@ -613,8 +579,12 @@ var g_vtoy_cur_language_cn = "STR_SECURE_BOOT_ENABLE": "å¼å¯", "STR_SECURE_BOOT_DISABLE": "æªå¼å¯", "STR_SYNTAX_ERROR_TIP": "ventoy.json æä»¶ä¸åå¨è¯æ³é误ï¼é ç½®æªå è½½!", + "STR_INVALID_CONFIG_TIP": "ventoy.json æä»¶ä¸åå¨é误é ç½®ï¼é ç½®æªå è½½!", + "STR_CONFIG_SAVE_ERROR_TIP": "ventoy.json æä»¶åå ¥å¤±è´¥ï¼è¯¦ç»ä¿¡æ¯è¯·åè VentoyPlugson.log æä»¶!", - + "STR_JSON_PREVIEW": "JSON é¢è§", + "STR_JSON_COPY_SUCCESS": "JSON å 容å¤å¶æå", + "STR_JSON_COPY_FAILED": "JSON å 容å¤å¶å¤±è´¥", "STR_XXX": "xxx" }; @@ -625,12 +595,45 @@ var g_current_language = 'cn'; var g_vtoy_cur_language = g_vtoy_cur_language_cn; var g_vtoy_data_default_index = 6; +var g_bios_postfix = [ "", "_legacy", "_uefi", "_ia32", "_aa64", "_mips" ]; +var g_del_all_path = '4119ae33-98ea-448e-b9c0-569aafcf1fb4'; var g_file_with_extra = false; var g_dir_with_extra = false; var g_file_fuzzy_match = 0; var g_file_modal_callback; var g_dir_modal_callback; +function GetResetTabConfigTipMsg(index, name) { + var msgstr; + + if (g_current_language === 'en') { + msgstr = 'Are you sure to reset all the configurations on the' + name + g_bios_postfix[index] + ' tab ?';
+ } else {
+ msgstr = '确认è¦éç½® ' + name + g_bios_postfix[index] + ' æ ç¾é¡µä¸çææé
ç½®ï¼';
+ }
+
+ return msgstr;
+}
+
+function CommonUpdateTabTitleIcon(exists, id, name) {
+ var exspan = " ";
+ for (var i = 0; i < g_vtoy_data_default_index; i++) {
+ var fid = id + i + '"]';
+ var oldhtml = $(fid).html();
+ var newhtml;
+
+ if (exists[i]) {
+ newhtml = name + g_bios_postfix[i] + exspan;
+ } else {
+ newhtml = name + g_bios_postfix[i];
+ }
+
+ if (newhtml != oldhtml) {
+ $(fid).html(newhtml);
+ }
+ }
+}
+
function ventoy_file_submit(form, extra) {
var filepath = $("#FilePath").val();
var fileextra = $("#FileExtra").val();
@@ -896,6 +899,7 @@ function VtoyCommonChangeLanguage(newlang) {
utfmaxlen: $.validator.format("The string exceeds the maximum supported length"),
start_slash: $.validator.format("Must start with /"),
noquotes: $.validator.format("Can not include double quotes"),
+ filenamepart:$.validator.format("As part of file name, can not include invalid characters"),
printascii: $.validator.format("Can not include non-ascii characters.")
});
@@ -909,6 +913,8 @@ function VtoyCommonChangeLanguage(newlang) {
$(this).text(" Plugin Official Document");
});
+ $('#id_span_copy').text("Copy");
+ $('#id_span_preview').text("Preview");
$('#id_span_language').text("䏿");
$("tr[id=tr_title_desc_cn]").each(function(){
@@ -941,6 +947,7 @@ function VtoyCommonChangeLanguage(newlang) {
utfmaxlen: $.validator.format("è¶
è¿æå¤§é¿åº¦"),
start_slash: $.validator.format("å¿
须以忿 / å¼å¤´"),
noquotes: $.validator.format("ä¸è½å
å«åå¼å·"),
+ filenamepart:$.validator.format("ä½ä¸ºæä»¶åçä¸é¨åï¼ä¸è½å
å«ç¹æ®ç符å·"),
printascii: $.validator.format("ä¸è½å
å«ä¸ææå
¶ä»é ascii å符ã")
});
@@ -954,6 +961,8 @@ function VtoyCommonChangeLanguage(newlang) {
$(this).text(" æä»¶å®ç½ææ¡£");
});
+ $('#id_span_copy').text("å¤å¶");
+ $('#id_span_preview').text("é¢è§");
$('#id_span_language').text("English");
$("tr[id=tr_title_desc_cn]").each(function(){
@@ -990,7 +999,10 @@ function VtoyCommonChangeLanguage(newlang) {
$('#id_span_save').text(g_vtoy_cur_language.STR_SAVE);
$('#id_span_reset').text(g_vtoy_cur_language.STR_RESET);
$('#id_span_donation').text(g_vtoy_cur_language.STR_PLUG_DONATION);
-
+
+ $('span[id=id_btn_span_reset]').each(function(){
+ $(this).text(' ' + g_vtoy_cur_language.STR_RESET);
+ });
$("span[id=id_span_btn_add]").each(function(){
$(this).text(g_vtoy_cur_language.STR_ADD);
});
@@ -1062,13 +1074,13 @@ var g_type_select_validator = $("#TypeSelectForm").validate({
function VtoySelectType(cb, para) {
$('#TypeSelectForm #TypeSelForm_lang_1').text(g_vtoy_cur_language.STR_SELECT);
-
+
if (g_current_language === 'en') {
- $('#SetDirForm #SetDirForm_lang_2').text(" OK");
- $('#SetDirForm #SetDirForm_lang_3').text("Cancel");
+ $('#TypeSelectForm #TypeSelForm_lang_2').text(" OK");
+ $('#TypeSelectForm #TypeSelForm_lang_3').text("Cancel");
} else {
- $('#SetDirForm #SetDirForm_lang_2').text("ç¡®å®");
- $('#SetDirForm #SetDirForm_lang_3').text("åæ¶");
+ $('#TypeSelectForm #TypeSelForm_lang_2').text("ç¡®å®");
+ $('#TypeSelectForm #TypeSelForm_lang_3').text("åæ¶");
}
var $tbl = $("#id_type_select_table tbody");
@@ -1102,7 +1114,8 @@ var g_set_key_validator = $("#SetKeyForm").validate({
},
SetKeyValue : {
required: true,
- utfmaxlen: true
+ utfmaxlen: true,
+ filenamepart: true
}
},
@@ -1130,11 +1143,11 @@ function VtoySetKey(cb, para) {
$('#SetKeyForm #SetKeyForm_lang_3').text(para.title2);
if (g_current_language === 'en') {
- $('#SetDirForm #SetDirForm_lang_4').text(" OK");
- $('#SetDirForm #SetDirForm_lang_5').text("Cancel");
+ $('#SetKeyForm #SetKeyForm_lang_4').text(" OK");
+ $('#SetKeyForm #SetKeyForm_lang_5').text("Cancel");
} else {
- $('#SetDirForm #SetDirForm_lang_4').text("ç¡®å®");
- $('#SetDirForm #SetDirForm_lang_5').text("åæ¶");
+ $('#SetKeyForm #SetKeyForm_lang_4').text("ç¡®å®");
+ $('#SetKeyForm #SetKeyForm_lang_5').text("åæ¶");
}
g_set_key_callback = cb;
@@ -1392,15 +1405,15 @@ function VtoySetDirFile(cb, para) {
$('#SetDirFileModal #SetDirFileForm_label2').text(para.label2);
if (g_current_language === 'en') {
- $('#SetDirFileModal #SetDirFileModal_ok').text(" OK");
- $('#SetDirFileModal #SetDirFileModal_cancel').text("Cancel");
+ $('#SetDirFileModal #SetDirFileForm_ok').text(" OK");
+ $('#SetDirFileModal #SetDirFileForm_cancel').text("Cancel");
$('#SetDirFileModal #id_note_dirfile_cn').hide();
$('#SetDirFileModal #id_note_dirfile_en').show();
} else {
- $('#SetDirFileModal #SetDirFileModal_ok').text("ç¡®å®");
- $('#SetDirFileModal #SetDirFileModal_cancel').text("åæ¶");
+ $('#SetDirFileModal #SetDirFileForm_ok').text("ç¡®å®");
+ $('#SetDirFileModal #SetDirFileForm_cancel').text("åæ¶");
$('#SetDirFileModal #id_note_dirfile_en').hide();
$('#SetDirFileModal #id_note_dirfile_cn').show();