1 <div class=
"box box-primary" id=
"control">
2 <div class=
"box-header">
3 <div class=
"col-sm-9" style=
"padding-top:8px;">
4 <i class=
"glyphicon glyphicon-lock"> </i>
5 <h1 class=
"box-title" style=
"font-weight:bold;" id=
"id_h1_page_title"></h1>
7 <div class=
"col-sm-1" style=
"padding-top:2px;">
8 <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>
10 <div class=
"col-sm-2" style=
"font-size:16px;padding-top:8px;">
11 <a id=
"id_a_official_doc" target=
"_blank" href=
"https://www.ventoy.net/en/plugin_password.html"><span class=
"fa fa-link"></span><span id=
"id_span_official_doc">官网文档
</span></a>
16 <div class=
"box-body">
17 <div class=
"nav-tabs-custom">
18 <ul class=
"nav nav-tabs" id=
"id_tab_password">
19 <li class=
""><a href=
"#tab_0" data-toggle=
"tab" aria-expanded=
"false" style=
"font-weight:bold" >password
</a></li>
20 <li class=
""><a href=
"#tab_1" data-toggle=
"tab" aria-expanded=
"false" style=
"font-weight:bold">password_legacy
</a></li>
21 <li class=
""><a href=
"#tab_2" data-toggle=
"tab" aria-expanded=
"false" style=
"font-weight:bold">password_uefi
</a></li>
22 <li class=
""><a href=
"#tab_3" data-toggle=
"tab" aria-expanded=
"false" style=
"font-weight:bold">password_ia32
</a></li>
23 <li class=
""><a href=
"#tab_4" data-toggle=
"tab" aria-expanded=
"false" style=
"font-weight:bold">password_aa64
</a></li>
24 <li class=
""><a href=
"#tab_5" data-toggle=
"tab" aria-expanded=
"false" style=
"font-weight:bold">password_mips
</a></li>
29 <div class=
"box box-primary box-solid">
30 <div class=
"box-header with-border">
31 <h3 class=
"box-title" style=
"font-size: 14px;font-weight: bold;">Common Password
32 <span id=
"id_span_desc_cn"> —— 通用密码
</span></h3>
33 <div class=
"box-tools pull-right">
34 <button class=
"btn btn-box-tool" data-widget=
"collapse"><i class=
"fa fa-minus"></i></button>
35 </div><!-- /.box-tools -->
36 </div><!-- /.box-header -->
37 <div class=
"box-body no-padding">
38 <table id=
"id_common_pwd" class=
"table table-bordered">
41 <th id=
"id_th_pwd_opt" style=
"width: 10%;"></th>
42 <th id=
"id_th_pwd_set" style=
"width: 40%;"></th>
43 <th id=
"id_th_pwd_operate" style=
"width: 10%;"></th>
44 <th id=
"id_th_pwd_notes" style=
"width: 30%;"></th>
54 <div class=
"box box-primary box-solid">
55 <div class=
"box-header with-border">
56 <h3 class=
"box-title" style=
"font-size: 14px;font-weight: bold;">Menu Password
57 <span id=
"id_span_desc_cn"> —— 菜单密码
</span></h3>
58 <div class=
"box-tools pull-right">
59 <button class=
"btn btn-box-tool" data-widget=
"collapse"><i class=
"fa fa-minus"></i></button>
60 </div><!-- /.box-tools -->
61 </div><!-- /.box-header -->
62 <div class=
"box-body no-padding">
63 <table id=
"id_pwd_tbl" class=
"table table-bordered">
66 <th style=
"width: 2%;">#
</th>
67 <th id=
"id_th_pwd_type" style=
"width: 5%;"></th>
68 <th id=
"id_th_pwd_path" style=
"width: 45%;"></th>
69 <th id=
"id_th_status" style=
"width: 5%;"></th>
70 <th id=
"id_th_pwd_pwd" style=
"width: 35%;"></th>
71 <th id=
"id_th_operation" style=
"width: 10%;"></th>
84 <script type=
"text/javascript">
86 function VtoyPageLanguageChange(newlang) {
87 VtoyCommonChangeLanguage(newlang);
88 $('h1[id=id_h1_page_title]').text(g_vtoy_cur_language.STR_PLUG_PASSWORD);
90 $("span[id=id_span_file_exist]").each(function(){
91 $(this).text(g_vtoy_cur_language.STR_FILE_EXIST);
93 $("span[id=id_span_file_nonexist]").each(function(){
94 $(this).text(g_vtoy_cur_language.STR_FILE_NONEXIST);
96 $("span[id=id_span_file_fuzzy]").each(function(){
97 $(this).text(g_vtoy_cur_language.STR_FILE_FUZZY);
100 $("span[id=id_span_dir_exist]").each(function(){
101 $(this).text(g_vtoy_cur_language.STR_DIR_EXIST);
104 $("span[id=id_span_dir_nonexist]").each(function(){
105 $(this).text(g_vtoy_cur_language.STR_DIR_NONEXIST);
108 $("span[id=id_span_edit]").each(function(){
109 $(this).text(' ' + g_vtoy_cur_language.STR_EDIT);
112 $("span[id=id_span_clear]").each(function(){
113 $(this).text(' ' + g_vtoy_cur_language.STR_CLEAR);
116 if (newlang === 'en') {
117 $('#id_th_pwd_path').text('Absolute Path');
118 $('#id_th_pwd_pwd').text('Password');
119 $('#id_th_pwd_type').text('Type');
120 $("th[id=id_th_pwd_opt]").text('Option');
121 $("th[id=id_th_pwd_set]").text('Setting');
122 $("th[id=id_th_pwd_operate]").text('Operation');
123 $("th[id=id_th_pwd_notes]").text('Notes');
125 $("span[id=id_span_desc_cn]").each(function(){
128 $("span[id=id_span_desc_en]").each(function(){
132 $('#id_th_pwd_path').text('绝对路径');
133 $('#id_th_pwd_pwd').text('密码');
134 $('#id_th_pwd_type').text('类型');
135 $("th[id=id_th_pwd_opt]").text('选项');
136 $("th[id=id_th_pwd_set]").text('设置');
137 $("th[id=id_th_pwd_operate]").text('操作');
138 $("th[id=id_th_pwd_notes]").text('说明');
139 $("span[id=id_span_desc_en]").each(function(){
142 $("span[id=id_span_desc_cn]").each(function(){
148 function format_password(pwd, type) {
151 } else if (type ===
1) {
152 return 'md5#' + md5(pwd);
155 var rand = Math.round(Math.random() *
10);
156 if ((rand %
2) ===
0) {
157 salt = ventoy_random_string(
3);
159 salt = ventoy_random_string(
4);
162 return 'md5#' + salt + '#' + md5(salt + pwd);
166 function CommonPasswordEntry(tbl, name, cn, en) {
167 var tr = '
<tr><td>'+name+'
</td><td><input type=
"text" class=
"form-control" id=
"id_'+name+'" disabled=
"disabled"/></td>' +
168 '
<td><button id=
"id_btn_set_'+name+'" class=
"btn btn-primary btn-sm btn-add CommPwdSetBtn"><span class=
"fa fa-edit"></span><span id=
"id_span_edit"></span></button> ' +
169 '
<button id=
"id_btn_clr_'+name+'" class=
"btn btn-danger btn-sm btn-del CommPwdClearBtn"><span class=
"fa fa-trash"></span><span id=
"id_span_clear"></span></button></td>' +
170 '
<td><span id=
"id_span_desc_cn">' + cn + '
</span>' +
171 '
<span id=
"id_span_desc_en">' + en + '
</span></td>' +
176 function FillCommonPassword(data) {
177 var $tbl = $("#id_common_pwd tbody");
180 CommonPasswordEntry($tbl, 'bootpwd', '启动进入 Ventoy 时的密码。', 'Password when Ventoy is booting.');
181 CommonPasswordEntry($tbl, 'isopwd', '所有 .iso 文件的默认密码。', 'Default password for all .iso files.');
182 CommonPasswordEntry($tbl, 'wimpwd', '所有 .wim 文件的默认密码。', 'Default password for all .wim files.');
183 CommonPasswordEntry($tbl, 'imgpwd', '所有 .img 文件的默认密码。', 'Default password for all .img files.');
184 CommonPasswordEntry($tbl, 'vhdpwd', '所有 .vhd(x) 文件的默认密码。', 'Default password for all .vhd(x) files.');
185 CommonPasswordEntry($tbl, 'efipwd', '所有 .efi 文件的默认密码。', 'Default password for all .efi files.');
186 CommonPasswordEntry($tbl, 'vtoypwd', '所有 .vtoy 文件的默认密码。', 'Default password for all .vtoy files.');
188 $('input:text[id=id_bootpwd]').val(data.bootpwd);
189 $('input:text[id=id_isopwd]').val(data.isopwd);
190 $('input:text[id=id_wimpwd]').val(data.wimpwd);
191 $('input:text[id=id_imgpwd]').val(data.imgpwd);
192 $('input:text[id=id_efipwd]').val(data.efipwd);
193 $('input:text[id=id_vhdpwd]').val(data.vhdpwd);
194 $('input:text[id=id_vtoypwd]').val(data.vtoypwd);
197 function FillMenuPwdTable(data) {
198 var addbtn = ventoy_get_xslg_addbtn('MenuPwdAddBtn');
199 var delbtn = ventoy_get_xslg_delbtn('MenuPwdDelBtn');
201 var td1, td2, td3, td4, td5, td6;
202 var $tbl = $("#id_pwd_tbl tbody");
205 for (var i =
0; i < data.length; i++) {
207 td1 = '
<td>' + (i +
1) + '
</td>';
208 td2 = (data[i].type ===
0) ? '
<td>file
</td>' : '
<td>parent
</td>';
209 td3 = '
<td>' + data[i].path + '
</td>';
210 td4 = '
<td>' + ventoy_get_status_line(data[i].type, data[i].valid) + '
</td>';
211 td5 = '
<td>' + data[i].pwd + '
</td>';
212 td6 = '
<td>' + delbtn + '
</td>';
214 $tr = $('
<tr>' + td1 + td2 + td3 + td4 + td5 + td6 + '
</tr>');
216 $tr.data('path', data[i].path);
217 $tr.data('index', i);
221 $tbl.append('
<tr><td></td><td></td><td></td><td></td><td></td><td>' + addbtn + '
</td></tr>');
224 function VtoyFillCurrentPageItem(data) {
225 FillCommonPassword(data);
226 FillMenuPwdTable(data.list);
230 function OnClickMultiModeTab() {
231 var href = $(this).attr('href');
232 var index = parseInt(href.substr(
5,
1));
234 if (index <
0 || index
>= g_vtoy_data_default_index || current_tab_index === index) {
238 current_tab_index = index;
239 VtoyFillCurrentPageItem(m_data_pwd[index]);
242 function VtoyGetCurrentPageItem(data) {
243 data.bootpwd = $('input:text[id=id_bootpwd]').val();
244 data.isopwd = $('input:text[id=id_isopwd]').val();
245 data.wimpwd = $('input:text[id=id_wimpwd]').val();
246 data.imgpwd = $('input:text[id=id_imgpwd]').val();
247 data.efipwd = $('input:text[id=id_efipwd]').val();
248 data.vhdpwd = $('input:text[id=id_vhdpwd]').val();
249 data.vtoypwd = $('input:text[id=id_vtoypwd]').val();
252 function VtoySaveCurrentPage() {
253 VtoyGetCurrentPageItem(m_data_pwd[current_tab_index]);
254 var data = m_data_pwd[current_tab_index];
257 method : 'save_password',
258 index: current_tab_index,
259 bootpwd: data.bootpwd,
261 wimpwd: data.bootpwd,
265 vtoypwd: data.vtoypwd
267 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
271 var m_pwd_file_or_dir;
272 var m_pwd_callback_func;
273 var m_pwd_callback_data;
274 var m_pwd_validator = $("#SetPwdForm").validate({
289 submitHandler: function(form) {
290 var path = $('input:text[id=PwdPath]').val();
291 var pwd = $('input:text[id=PwdPwd]').val();
292 var type = parseInt($('input:radio[name=id_radio_pwd_type]:checked').val());
294 if (m_pwd_validator.settings.rules.PwdPath.required) {
295 path = ventoy_replace_slash(path);
297 if (!ventoy_common_check_path(path)) {
298 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
302 if (path.indexOf("*")
>=
0) {
304 method : 'check_fuzzy',
307 if (data.exist !=
0) {
308 if (typeof(m_pwd_callback_func) === 'function') {
309 m_pwd_callback_func(path, pwd, type, m_pwd_callback_data);
311 $("#SetPwdModal").modal('hide');
313 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
319 method : 'check_path',
320 dir: m_pwd_file_or_dir,
323 if (data.exist ===
1) {
324 if (typeof(m_pwd_callback_func) === 'function') {
325 m_pwd_callback_func(path, pwd, type, m_pwd_callback_data);
327 $("#SetPwdModal").modal('hide');
329 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
334 if (typeof(m_pwd_callback_func) === 'function') {
336 m_pwd_callback_func(path, pwd, type, m_pwd_callback_data);
338 $("#SetPwdModal").modal('hide');
343 function VtoySetPassword(common, type, cb, data) {
345 $('#SetPwdForm #SetPwdForm_title').text(g_vtoy_cur_language.STR_SET_PASSWORD);
348 $('#SetPwdForm #SetPwdForm_path').text(g_vtoy_cur_language.STR_FILE_PATH);
350 $('#SetPwdForm #SetPwdForm_path').text(g_vtoy_cur_language.STR_DIR_PATH);
353 $('#SetPwdForm #SetPwdForm_pwd').text(g_vtoy_cur_language.STR_PASSWORD_VALUE);
354 $('#SetPwdForm #SetPwdForm_type').text(g_vtoy_cur_language.STR_PASSWORD_TYPE);
357 m_pwd_validator.settings.rules.PwdPath.required = false;
358 $('div[id=id_div_pwd_path]').hide();
361 m_pwd_validator.settings.rules.PwdPath.required = true;
362 $('div[id=id_div_pwd_path]').show();
365 if (g_current_language === 'en') {
366 $('div[id=id_note_pwdfile_cn]').hide();
367 $('div[id=id_note_pwdfile_en]').show();
369 $('div[id=id_note_pwdfile_cn]').show();
370 $('div[id=id_note_pwdfile_en]').hide();
372 $('div[id=id_note_pwddir_cn]').hide();
373 $('div[id=id_note_pwddir_en]').hide();
375 $('div[id=id_note_pwdfile_cn]').hide();
376 $('div[id=id_note_pwdfile_en]').hide();
377 if (g_current_language === 'en') {
378 $('div[id=id_note_pwddir_cn]').hide();
379 $('div[id=id_note_pwddir_en]').show();
381 $('div[id=id_note_pwddir_cn]').show();
382 $('div[id=id_note_pwddir_en]').hide();
387 $('input:radio[name=id_radio_pwd_type]')[
0].checked = true;
389 if (g_current_language === 'en') {
390 $('#SetPwdForm #SetPwdForm_ok').text(" OK");
391 $('#SetPwdForm #SetPwdForm_cancel').text("Cancel");
393 $('#SetPwdForm #SetPwdForm_ok').text("确定");
394 $('#SetPwdForm #SetPwdForm_cancel').text("取消");
397 m_pwd_file_or_dir = type;
398 m_pwd_callback_func = cb;
399 m_pwd_callback_data = data;
400 m_pwd_validator.resetForm();
401 $("#SetPwdModal").modal();
414 var current_tab_index =
0;
415 callVtoySync({method : 'get_password'}, function(data) {
419 function set_common_pwd_callback(path, pwd, type, data) {
420 var selector = 'input:text[id=id_'+ data +']';
421 var value = format_password(pwd, type);
423 $(selector).val(value);
424 VtoySaveCurrentPage();
426 $("#id_common_pwd").on('click', '.CommPwdSetBtn', function() {
427 var id = $(this).attr('id');
430 VtoySetPassword(
1,
0, set_common_pwd_callback, id.substr(
11));
432 $("#id_common_pwd").on('click', '.CommPwdClearBtn', function() {
433 var id = $(this).attr('id');
436 var selector = 'input:text[id=id_'+ id.substr(
11) +']';
438 VtoySaveCurrentPage();
441 function set_menu_pwd_callback(path, pwd, type, FileOrDir) {
442 var list = m_data_pwd[current_tab_index].list;
443 var value = format_password(pwd, type);
444 var valid = (path.indexOf("*")
>=
0) ? -
1 :
1;
448 "path": path.substr(g_current_dir.length),
453 for (var i =
0; i < list.length; i++) {
454 if (list[i].path === data.path) {
455 Message.error(g_vtoy_cur_language.STR_DUPLICATE_PATH);
461 method : 'password_add',
462 index: current_tab_index,
468 FillMenuPwdTable(list);
469 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
473 function OnAddMenuPwdBtnClick(sel) {
475 var tip1 = (g_current_os === 'windows') ? '\\ISO\\Windows11.iso' : "/ISO/Ubuntu-
20.04-desktop-amd64.iso";
476 var tip2 = (g_current_os === 'windows') ? '\\ISO\\Windows**.iso' : "/ISO/Ubuntu-*****-desktop-amd64.iso";
478 $('#SetPwdForm #id_span_pwdfile_tip1').text(g_current_dir + tip1);
479 $('#SetPwdForm #id_span_pwdfile_tip2').text(g_current_dir + tip2);
481 VtoySetPassword(
0,
0, set_menu_pwd_callback,
0);
484 var tip = (g_current_os === 'windows') ? '\\ISO\\Windows' : "/ISO/Linux";
485 $('#SetPwdForm #id_span_pwddir_tip').text(g_current_dir + tip);
487 VtoySetPassword(
0,
1, set_menu_pwd_callback,
1);
492 $("#id_pwd_tbl").on('click', '.MenuPwdAddBtn', function() {
496 "tip": g_vtoy_cur_language.STR_SET_PWD_FOR_FILE
500 "tip": g_vtoy_cur_language.STR_SET_PWD_FOR_DIR
504 VtoySelectType(OnAddMenuPwdBtnClick, para);
507 $("#id_pwd_tbl").on('click', '.MenuPwdDelBtn', function() {
508 var $tr = $(this).closest('tr');
509 var path = $tr.data('path');
510 var index = $tr.data('index');
513 method : 'password_del',
514 index: current_tab_index,
517 m_data_pwd[current_tab_index].list.splice(index,
1);
518 FillMenuPwdTable(m_data_pwd[current_tab_index].list);
519 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
523 function VtoySaveCurrentPage() {
524 var bootpwd = $('input:text[id=id_bootpwd]').val();
525 var isopwd = $('input:text[id=id_isopwd]').val();
526 var wimpwd = $('input:text[id=id_wimpwd]').val();
527 var imgpwd = $('input:text[id=id_imgpwd]').val();
528 var vhdpwd = $('input:text[id=id_vhdpwd]').val();
529 var efipwd = $('input:text[id=id_efipwd]').val();
530 var vtoypwd = $('input:text[id=id_vtoypwd]').val();
533 method : 'save_password',
534 index: current_tab_index,
543 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
547 $('input:text[id=id_bootpwd]').change(VtoySaveCurrentPage);
548 $('input:text[id=id_isopwd]').change(VtoySaveCurrentPage);
549 $('input:text[id=id_wimpwd]').change(VtoySaveCurrentPage);
550 $('input:text[id=id_imgpwd]').change(VtoySaveCurrentPage);
551 $('input:text[id=id_vhdpwd]').change(VtoySaveCurrentPage);
552 $('input:text[id=id_efipwd]').change(VtoySaveCurrentPage);
553 $('input:text[id=id_vtoypwd]').change(VtoySaveCurrentPage);
555 $('#id_tab_password a[
href="#tab_0"]').click(OnClickMultiModeTab);
556 $('#id_tab_password a[
href="#tab_1"]').click(OnClickMultiModeTab);
557 $('#id_tab_password a[
href="#tab_2"]').click(OnClickMultiModeTab);
558 $('#id_tab_password a[
href="#tab_3"]').click(OnClickMultiModeTab);
559 $('#id_tab_password a[
href="#tab_4"]').click(OnClickMultiModeTab);
560 $('#id_tab_password a[
href="#tab_5"]').click(OnClickMultiModeTab);
562 function UpdateTabTitleIcon(data) {
563 CommonUpdateTabTitleIcon(data.exist_password, '#id_tab_password a[
href="#tab_', 'password');
565 $('#id_btn_reset').click(function() {
566 Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'password')}).on(function(e) {
569 method : 'password_del',
570 index: current_tab_index,
576 m_data_pwd[current_tab_index].list.length =
0;
577 VtoyFillCurrentPageItem(m_data_pwd[g_vtoy_data_default_index]);
578 VtoySaveCurrentPage();
583 $('#id_tab_password a[
href="#tab_0"]').tab('show');
584 VtoyFillCurrentPageItem(m_data_pwd[
0]);
585 VtoyPageLanguageChange(g_current_language);