Ventoy/Plugson/www/plugson_menu_alias.html

267 lines
9.2 KiB
HTML
Raw Normal View History

<div class="box box-primary" id="control">
<div class="box-header">
<div class="col-sm-9" style="padding-top:8px;">
<i class="fa fa-clone">&nbsp;&nbsp;</i>
<h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title">菜单别名插件</h1>
</div>
<div class="col-sm-1" style="padding-top:2px;">
<button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>
</div>
<div class="col-sm-2" style="font-size:16px;padding-top:8px;">
<a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/en/plugin_menualias.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>
</div>
</div>
<legend></legend>
<div class="box-body">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs" id="id_tab_menu_alias">
<li class=""><a href="#tab_0" data-toggle="tab" aria-expanded="false" style="font-weight:bold" >menu_alias</a></li>
<li class=""><a href="#tab_1" data-toggle="tab" aria-expanded="false" style="font-weight:bold">menu_alias_legacy</a></li>
<li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false" style="font-weight:bold">menu_alias_uefi</a></li>
<li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false" style="font-weight:bold">menu_alias_ia32</a></li>
<li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false" style="font-weight:bold">menu_alias_aa64</a></li>
<li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false" style="font-weight:bold">menu_alias_mips</a></li>
</ul>
</div>
<table id="id_alisa_tbl" class="table table-bordered">
<thead>
<tr>
<th style="width: 2%;">#</th>
<th id="id_th_alias_type" style="width: 5%;"></th>
<th id="id_th_alias_path" style="width: 35%;"></th>
<th id="id_th_status" style="width: 5%;"></th>
<th id="id_th_alias_alias" style="width: 40%;"></th>
<th id="id_th_operation" style="width: 5%;"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<script type="text/javascript">
function VtoyPageLanguageChange(newlang) {
VtoyCommonChangeLanguage(newlang);
$('h1[id=id_h1_page_title]').text(g_vtoy_cur_language.STR_PLUG_ALIAS);
$("span[id=id_span_file_exist]").each(function(){
$(this).text(g_vtoy_cur_language.STR_FILE_EXIST);
});
$("span[id=id_span_file_nonexist]").each(function(){
$(this).text(g_vtoy_cur_language.STR_FILE_NONEXIST);
});
$("span[id=id_span_file_fuzzy]").each(function(){
$(this).text(g_vtoy_cur_language.STR_FILE_FUZZY);
});
$("span[id=id_span_dir_exist]").each(function(){
$(this).text(g_vtoy_cur_language.STR_DIR_EXIST);
});
$("span[id=id_span_dir_nonexist]").each(function(){
$(this).text(g_vtoy_cur_language.STR_DIR_NONEXIST);
});
if (newlang === 'en') {
$('#id_th_alias_path').text('Absolute Path');
$('#id_th_alias_alias').text('Alias');
$('#id_th_alias_type').text('Type');
} else {
$('#id_th_alias_path').text('绝对路径');
$('#id_th_alias_alias').text('别名');
$('#id_th_alias_type').text('类型');
}
}
function FillAliasTable(data) {
var addbtn = ventoy_get_xslg_addbtn('AliasAddBtn');
var delbtn = ventoy_get_xslg_delbtn('AliasDelBtn');
var td1, td2, td3, td4, td5, td6;
var $tbl = $("#id_alisa_tbl tbody");
$tbl.empty();
for (var i = 0; i < data.length; i++) {
var $tr;
td1 = '<td>' + (i + 1) + '</td>';
td2 = (data[i].type === 0) ? '<td>image</td>' : '<td>dir</td>';
td3 = '<td>' + data[i].path + '</td>';
td4 = '<td>' + ventoy_get_status_line(data[i].type, data[i].valid) + '</td>';
td5 = '<td>' + data[i].alias + '</td>';
td6 = '<td>' + delbtn + '</td>';
$tr = $('<tr>' + td1 + td2 + td3 + td4 + td5 + td6 + '</tr>');
$tr.data('path', data[i].path);
$tr.data('index', i);
$tbl.append($tr);
}
$tbl.append('<tr><td></td><td></td><td></td><td></td><td></td><td>' + addbtn + '</td></tr>');
}
function VtoyFillCurrentPageItem(data) {
FillAliasTable(data);
}
function OnClickMultiModeTab() {
var href = $(this).attr('href');
var index = parseInt(href.substr(5, 1));
if (index < 0 || index >= g_vtoy_data_default_index || current_tab_index === index) {
return;
}
current_tab_index = index;
VtoyFillCurrentPageItem(m_data_alias[index]);
}
//Main process
var m_data_alias;
var current_tab_index = 0;
callVtoySync({method : 'get_alias'}, function(data) {
m_data_alias = data;
});
function AddAliasEntry(root, type, valid, extra) {
var list = m_data_alias[current_tab_index];
var data = {
"path": root.substr(g_current_dir.length),
"alias": extra,
"type": type,
"valid": valid
};
for (var i = 0; i < list.length; i++) {
if (list[i].path === data.path) {
Message.error(g_vtoy_cur_language.STR_DUPLICATE_PATH);
return;
}
}
callVtoy({
method : 'alias_add',
index: current_tab_index,
path: data.path,
alias: data.alias,
type: type
}, function(e) {
if (e.result === 'success') {
list.push(data);
FillAliasTable(list);
Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
} else if (e.result === 'duplicate') {
Message.error(g_vtoy_cur_language.STR_DUPLICATE_PATH);
}
});
}
function OnAddImageAlias(root, valid, extra) {
AddAliasEntry(root, 0, valid, extra);
}
function OnAddDirAlias(root, extra) {
AddAliasEntry(root, 1, 1, extra);
}
function OnAddAliasBtnClick(sel) {
if (sel === 0) {
var tip1 = (g_current_os === 'windows') ? '\\ISO\\Windows11.iso' : "/ISO/Ubuntu-20.04-desktop-amd64.iso";
var tip2 = (g_current_os === 'windows') ? '\\ISO\\Windows**.iso' : "/ISO/Ubuntu-*****-desktop-amd64.iso";
var para = {
"title": g_vtoy_cur_language.STR_SET_ALIAS,
"fuzzy": 1,
"tip1": g_current_dir + tip1,
"tip2": g_current_dir + tip2,
"tip3": '',
"extra": true,
"extra_title": g_vtoy_cur_language.STR_ALIAS
};
VtoySelectFilePath(OnAddImageAlias, para);
} else {
var tip = (g_current_os === 'windows') ? '\\ISO\\Windows' : "/ISO/Linux";
var para = {
"title": g_vtoy_cur_language.STR_SET_ALIAS,
"tip": g_current_dir + tip,
"tip3": '',
"extra": true,
"extra_title": g_vtoy_cur_language.STR_ALIAS
};
VtoySelectDirPath(OnAddDirAlias, para);
}
}
$("#id_alisa_tbl").on('click', '.AliasAddBtn', function() {
var para = [
{
"selected": true,
"tip": g_vtoy_cur_language.STR_SET_ALIAS_FOR_FILE
},
{
"selected": false,
"tip": g_vtoy_cur_language.STR_SET_ALIAS_FOR_DIR
}
];
VtoySelectType(OnAddAliasBtnClick, para);
});
$("#id_alisa_tbl").on('click', '.AliasDelBtn', function() {
var $tr = $(this).closest('tr');
var path = $tr.data('path');
var index = $tr.data('index');
callVtoySync({
method : 'alias_del',
index: current_tab_index,
path: path
}, function(data) {
m_data_alias[current_tab_index].splice(index, 1);
FillAliasTable(m_data_alias[current_tab_index]);
Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
});
});
$('#id_tab_menu_alias a[href="#tab_0"]').click(OnClickMultiModeTab);
$('#id_tab_menu_alias a[href="#tab_1"]').click(OnClickMultiModeTab);
$('#id_tab_menu_alias a[href="#tab_2"]').click(OnClickMultiModeTab);
$('#id_tab_menu_alias a[href="#tab_3"]').click(OnClickMultiModeTab);
$('#id_tab_menu_alias a[href="#tab_4"]').click(OnClickMultiModeTab);
$('#id_tab_menu_alias a[href="#tab_5"]').click(OnClickMultiModeTab);
function UpdateTabTitleIcon(data) {
CommonUpdateTabTitleIcon(data.exist_menu_alias, '#id_tab_menu_alias a[href="#tab_', 'menu_alias');
}
$('#id_btn_reset').click(function() {
Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'menu_alias')}).on(function(e) {
if (e) {
callVtoySync({
method : 'alias_del',
index: current_tab_index,
path: g_del_all_path
}, function(data) {
});
m_data_alias[current_tab_index].length = 0;
VtoyFillCurrentPageItem(m_data_alias[g_vtoy_data_default_index]);
Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
}
});
});
$('#id_tab_menu_alias a[href="#tab_0"]').tab('show');
VtoyFillCurrentPageItem(m_data_alias[0]);
VtoyPageLanguageChange(g_current_language);
</script>