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);
});