X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/c57717aea24be2ff4ed8c9b095ae74f3a3220de1..HEAD:/Plugson/www/static/js/vtoy.js diff --git a/Plugson/www/static/js/vtoy.js b/Plugson/www/static/js/vtoy.js index 21f71b4..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?", @@ -480,6 +439,11 @@ var g_vtoy_cur_language_en = "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" }; @@ -506,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": "当前页面数据已经修改,是否保存?", @@ -615,8 +580,11 @@ var g_vtoy_cur_language_cn = "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" }; @@ -627,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(); @@ -912,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(){ @@ -958,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(){ @@ -994,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); });