1 <div class=
"box box-primary" id=
"control">
2 <div class=
"box-header">
3 <div class=
"col-sm-10" 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>
8 <div class=
"col-sm-2" style=
"font-size:16px;padding-top:8px;">
9 <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>
14 <div class=
"box-body">
15 <div class=
"nav-tabs-custom">
16 <ul class=
"nav nav-tabs" id=
"id_tab_password">
17 <li class=
""><a href=
"#tab_0" data-toggle=
"tab" aria-expanded=
"false" style=
"font-weight:bold" >password
</a></li>
18 <li class=
""><a href=
"#tab_1" data-toggle=
"tab" aria-expanded=
"false" style=
"font-weight:bold">password_legacy
</a></li>
19 <li class=
""><a href=
"#tab_2" data-toggle=
"tab" aria-expanded=
"false" style=
"font-weight:bold">password_uefi
</a></li>
20 <li class=
""><a href=
"#tab_3" data-toggle=
"tab" aria-expanded=
"false" style=
"font-weight:bold">password_ia32
</a></li>
21 <li class=
""><a href=
"#tab_4" data-toggle=
"tab" aria-expanded=
"false" style=
"font-weight:bold">password_aa64
</a></li>
22 <li class=
""><a href=
"#tab_5" data-toggle=
"tab" aria-expanded=
"false" style=
"font-weight:bold">password_mips
</a></li>
27 <div class=
"box box-primary box-solid">
28 <div class=
"box-header with-border">
29 <h3 class=
"box-title" style=
"font-size: 14px;font-weight: bold;">Common Password
30 <span id=
"id_span_desc_cn"> —— 通用密码
</span></h3>
31 <div class=
"box-tools pull-right">
32 <button class=
"btn btn-box-tool" data-widget=
"collapse"><i class=
"fa fa-minus"></i></button>
33 </div><!-- /.box-tools -->
34 </div><!-- /.box-header -->
35 <div class=
"box-body no-padding">
36 <table id=
"id_common_pwd" class=
"table table-bordered">
39 <th id=
"id_th_pwd_opt" style=
"width: 10%;"></th>
40 <th id=
"id_th_pwd_set" style=
"width: 40%;"></th>
41 <th id=
"id_th_pwd_operate" style=
"width: 10%;"></th>
42 <th id=
"id_th_pwd_notes" style=
"width: 30%;"></th>
52 <div class=
"box box-primary box-solid">
53 <div class=
"box-header with-border">
54 <h3 class=
"box-title" style=
"font-size: 14px;font-weight: bold;">Menu Password
55 <span id=
"id_span_desc_cn"> —— 菜单密码
</span></h3>
56 <div class=
"box-tools pull-right">
57 <button class=
"btn btn-box-tool" data-widget=
"collapse"><i class=
"fa fa-minus"></i></button>
58 </div><!-- /.box-tools -->
59 </div><!-- /.box-header -->
60 <div class=
"box-body no-padding">
61 <table id=
"id_pwd_tbl" class=
"table table-bordered">
64 <th style=
"width: 2%;">#
</th>
65 <th id=
"id_th_pwd_type" style=
"width: 5%;"></th>
66 <th id=
"id_th_pwd_path" style=
"width: 45%;"></th>
67 <th id=
"id_th_status" style=
"width: 5%;"></th>
68 <th id=
"id_th_pwd_pwd" style=
"width: 35%;"></th>
69 <th id=
"id_th_operation" style=
"width: 10%;"></th>
82 <script type=
"text/javascript">
84 function VtoyPageLanguageChange(newlang) {
85 VtoyCommonChangeLanguage(newlang);
86 $('h1[id=id_h1_page_title]').text(g_vtoy_cur_language.STR_PLUG_PASSWORD);
88 $("span[id=id_span_file_exist]").each(function(){
89 $(this).text(g_vtoy_cur_language.STR_FILE_EXIST);
91 $("span[id=id_span_file_nonexist]").each(function(){
92 $(this).text(g_vtoy_cur_language.STR_FILE_NONEXIST);
94 $("span[id=id_span_file_fuzzy]").each(function(){
95 $(this).text(g_vtoy_cur_language.STR_FILE_FUZZY);
98 $("span[id=id_span_dir_exist]").each(function(){
99 $(this).text(g_vtoy_cur_language.STR_DIR_EXIST);
102 $("span[id=id_span_dir_nonexist]").each(function(){
103 $(this).text(g_vtoy_cur_language.STR_DIR_NONEXIST);
106 $("span[id=id_span_edit]").each(function(){
107 $(this).text(' ' + g_vtoy_cur_language.STR_EDIT);
110 $("span[id=id_span_clear]").each(function(){
111 $(this).text(' ' + g_vtoy_cur_language.STR_CLEAR);
114 if (newlang === 'en') {
115 $('#id_th_pwd_path').text('Absolute Path');
116 $('#id_th_pwd_pwd').text('Password');
117 $('#id_th_pwd_type').text('Type');
118 $("th[id=id_th_pwd_opt]").text('Option');
119 $("th[id=id_th_pwd_set]").text('Setting');
120 $("th[id=id_th_pwd_operate]").text('Operation');
121 $("th[id=id_th_pwd_notes]").text('Notes');
123 $("span[id=id_span_desc_cn]").each(function(){
126 $("span[id=id_span_desc_en]").each(function(){
130 $('#id_th_pwd_path').text('绝对路径');
131 $('#id_th_pwd_pwd').text('密码');
132 $('#id_th_pwd_type').text('类型');
133 $("th[id=id_th_pwd_opt]").text('选项');
134 $("th[id=id_th_pwd_set]").text('设置');
135 $("th[id=id_th_pwd_operate]").text('操作');
136 $("th[id=id_th_pwd_notes]").text('说明');
137 $("span[id=id_span_desc_en]").each(function(){
140 $("span[id=id_span_desc_cn]").each(function(){
146 function format_password(pwd, type) {
149 } else if (type ===
1) {
150 return 'md5#' + md5(pwd);
153 var rand = Math.round(Math.random() *
10);
154 if ((rand %
2) ===
0) {
155 salt = ventoy_random_string(
3);
157 salt = ventoy_random_string(
4);
160 return 'md5#' + salt + '#' + md5(salt + pwd);
164 function CommonPasswordEntry(tbl, name, cn, en) {
165 var tr = '
<tr><td>'+name+'
</td><td><input type=
"text" class=
"form-control" id=
"id_'+name+'" disabled=
"disabled"/></td>' +
166 '
<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> ' +
167 '
<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>' +
168 '
<td><span id=
"id_span_desc_cn">' + cn + '
</span>' +
169 '
<span id=
"id_span_desc_en">' + en + '
</span></td>' +
174 function FillCommonPassword(data) {
175 var $tbl = $("#id_common_pwd tbody");
178 CommonPasswordEntry($tbl, 'bootpwd', '启动进入 Ventoy 时的密码。', 'Password when Ventoy is booting.');
179 CommonPasswordEntry($tbl, 'isopwd', '所有 .iso 文件的默认密码。', 'Default password for all .iso files.');
180 CommonPasswordEntry($tbl, 'wimpwd', '所有 .wim 文件的默认密码。', 'Default password for all .wim files.');
181 CommonPasswordEntry($tbl, 'imgpwd', '所有 .img 文件的默认密码。', 'Default password for all .img files.');
182 CommonPasswordEntry($tbl, 'vhdpwd', '所有 .vhd(x) 文件的默认密码。', 'Default password for all .vhd(x) files.');
183 CommonPasswordEntry($tbl, 'efipwd', '所有 .efi 文件的默认密码。', 'Default password for all .efi files.');
184 CommonPasswordEntry($tbl, 'vtoypwd', '所有 .vtoy 文件的默认密码。', 'Default password for all .vtoy files.');
186 $('input:text[id=id_bootpwd]').val(data.bootpwd);
187 $('input:text[id=id_isopwd]').val(data.isopwd);
188 $('input:text[id=id_wimpwd]').val(data.wimpwd);
189 $('input:text[id=id_imgpwd]').val(data.imgpwd);
190 $('input:text[id=id_efipwd]').val(data.efipwd);
191 $('input:text[id=id_vhdpwd]').val(data.vhdpwd);
192 $('input:text[id=id_vtoypwd]').val(data.vtoypwd);
195 function FillMenuPwdTable(data) {
196 var addbtn = ventoy_get_xslg_addbtn('MenuPwdAddBtn');
197 var delbtn = ventoy_get_xslg_delbtn('MenuPwdDelBtn');
199 var td1, td2, td3, td4, td5, td6;
200 var $tbl = $("#id_pwd_tbl tbody");
203 for (var i =
0; i < data.length; i++) {
205 td1 = '
<td>' + (i +
1) + '
</td>';
206 td2 = (data[i].type ===
0) ? '
<td>file
</td>' : '
<td>parent
</td>';
207 td3 = '
<td>' + data[i].path + '
</td>';
208 td4 = '
<td>' + ventoy_get_status_line(data[i].type, data[i].valid) + '
</td>';
209 td5 = '
<td>' + data[i].pwd + '
</td>';
210 td6 = '
<td>' + delbtn + '
</td>';
212 $tr = $('
<tr>' + td1 + td2 + td3 + td4 + td5 + td6 + '
</tr>');
214 $tr.data('path', data[i].path);
215 $tr.data('index', i);
219 $tbl.append('
<tr><td></td><td></td><td></td><td></td><td></td><td>' + addbtn + '
</td></tr>');
222 function VtoyFillCurrentPageItem(data) {
223 FillCommonPassword(data);
224 FillMenuPwdTable(data.list);
228 function OnClickMultiModeTab() {
229 var href = $(this).attr('href');
230 var index = parseInt(href.substr(
5,
1));
232 if (index <
0 || index
>= g_vtoy_data_default_index || current_tab_index === index) {
236 current_tab_index = index;
237 VtoyFillCurrentPageItem(m_data_pwd[index].tips);
240 function VtoyGetCurrentPageItem(data) {
241 data.bootpwd = $('input:text[id=id_bootpwd]').val();
242 data.isopwd = $('input:text[id=id_isopwd]').val();
243 data.wimpwd = $('input:text[id=id_wimpwd]').val();
244 data.imgpwd = $('input:text[id=id_imgpwd]').val();
245 data.efipwd = $('input:text[id=id_efipwd]').val();
246 data.vhdpwd = $('input:text[id=id_vhdpwd]').val();
247 data.vtoypwd = $('input:text[id=id_vtoypwd]').val();
250 function VtoySaveCurrentPage() {
251 VtoyGetCurrentPageItem(m_data_pwd[current_tab_index]);
252 var data = m_data_pwd[current_tab_index];
255 method : 'save_password',
256 index: current_tab_index,
257 bootpwd: data.bootpwd,
259 wimpwd: data.bootpwd,
263 vtoypwd: data.vtoypwd
265 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
269 var m_pwd_file_or_dir;
270 var m_pwd_callback_func;
271 var m_pwd_callback_data;
272 var m_pwd_validator = $("#SetPwdForm").validate({
287 submitHandler: function(form) {
288 var path = $('input:text[id=PwdPath]').val();
289 var pwd = $('input:text[id=PwdPwd]').val();
290 var type = parseInt($('input:radio[name=id_radio_pwd_type]:checked').val());
292 if (m_pwd_validator.settings.rules.PwdPath.required) {
293 path = ventoy_replace_slash(path);
295 if (!ventoy_common_check_path(path)) {
296 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
300 if (path.indexOf("*")
>=
0) {
302 method : 'check_fuzzy',
305 if (data.exist !=
0) {
306 if (typeof(m_pwd_callback_func) === 'function') {
307 m_pwd_callback_func(path, pwd, type, m_pwd_callback_data);
309 $("#SetPwdModal").modal('hide');
311 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
317 method : 'check_path',
318 dir: m_pwd_file_or_dir,
321 if (data.exist ===
1) {
322 if (typeof(m_pwd_callback_func) === 'function') {
323 m_pwd_callback_func(path, pwd, type, m_pwd_callback_data);
325 $("#SetPwdModal").modal('hide');
327 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
332 if (typeof(m_pwd_callback_func) === 'function') {
334 m_pwd_callback_func(path, pwd, type, m_pwd_callback_data);
336 $("#SetPwdModal").modal('hide');
341 function VtoySetPassword(common, type, cb, data) {
343 $('#SetPwdForm #SetPwdForm_title').text(g_vtoy_cur_language.STR_SET_PASSWORD);
346 $('#SetPwdForm #SetPwdForm_path').text(g_vtoy_cur_language.STR_FILE_PATH);
348 $('#SetPwdForm #SetPwdForm_path').text(g_vtoy_cur_language.STR_DIR_PATH);
351 $('#SetPwdForm #SetPwdForm_pwd').text(g_vtoy_cur_language.STR_PASSWORD_VALUE);
352 $('#SetPwdForm #SetPwdForm_type').text(g_vtoy_cur_language.STR_PASSWORD_TYPE);
355 m_pwd_validator.settings.rules.PwdPath.required = false;
356 $('div[id=id_div_pwd_path]').hide();
359 m_pwd_validator.settings.rules.PwdPath.required = true;
360 $('div[id=id_div_pwd_path]').show();
363 if (g_current_language === 'en') {
364 $('div[id=id_note_pwdfile_cn]').hide();
365 $('div[id=id_note_pwdfile_en]').show();
367 $('div[id=id_note_pwdfile_cn]').show();
368 $('div[id=id_note_pwdfile_en]').hide();
370 $('div[id=id_note_pwddir_cn]').hide();
371 $('div[id=id_note_pwddir_en]').hide();
373 $('div[id=id_note_pwdfile_cn]').hide();
374 $('div[id=id_note_pwdfile_en]').hide();
375 if (g_current_language === 'en') {
376 $('div[id=id_note_pwddir_cn]').hide();
377 $('div[id=id_note_pwddir_en]').show();
379 $('div[id=id_note_pwddir_cn]').show();
380 $('div[id=id_note_pwddir_en]').hide();
385 $('input:radio[name=id_radio_pwd_type]')[
0].checked = true;
387 if (g_current_language === 'en') {
388 $('#SetPwdForm #SetPwdForm_ok').text(" OK");
389 $('#SetPwdForm #SetPwdForm_cancel').text("Cancel");
391 $('#SetPwdForm #SetPwdForm_ok').text("确定");
392 $('#SetPwdForm #SetPwdForm_cancel').text("取消");
395 m_pwd_file_or_dir = type;
396 m_pwd_callback_func = cb;
397 m_pwd_callback_data = data;
398 m_pwd_validator.resetForm();
399 $("#SetPwdModal").modal();
412 var current_tab_index =
0;
413 callVtoySync({method : 'get_password'}, function(data) {
417 function set_common_pwd_callback(path, pwd, type, data) {
418 var selector = 'input:text[id=id_'+ data +']';
419 var value = format_password(pwd, type);
421 $(selector).val(value);
422 VtoySaveCurrentPage();
424 $("#id_common_pwd").on('click', '.CommPwdSetBtn', function() {
425 var id = $(this).attr('id');
428 VtoySetPassword(
1,
0, set_common_pwd_callback, id.substr(
11));
430 $("#id_common_pwd").on('click', '.CommPwdClearBtn', function() {
431 var id = $(this).attr('id');
434 var selector = 'input:text[id=id_'+ id.substr(
11) +']';
436 VtoySaveCurrentPage();
439 function set_menu_pwd_callback(path, pwd, type, FileOrDir) {
440 var list = m_data_pwd[current_tab_index].list;
441 var value = format_password(pwd, type);
442 var valid = (path.indexOf("*")
>=
0) ? -
1 :
1;
446 "path": path.substr(g_current_dir.length),
451 for (var i =
0; i < list.length; i++) {
452 if (list[i].path === data.path) {
453 Message.error(g_vtoy_cur_language.STR_DUPLICATE_PATH);
459 method : 'password_add',
460 index: current_tab_index,
466 FillMenuPwdTable(list);
467 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
471 function OnAddMenuPwdBtnClick(sel) {
473 var tip1 = (g_current_os === 'windows') ? '\\ISO\\Windows11.iso' : "/ISO/Ubuntu-
20.04-desktop-amd64.iso";
474 var tip2 = (g_current_os === 'windows') ? '\\ISO\\Windows**.iso' : "/ISO/Ubuntu-*****-desktop-amd64.iso";
476 $('#SetPwdForm #id_span_pwdfile_tip1').text(g_current_dir + tip1);
477 $('#SetPwdForm #id_span_pwdfile_tip2').text(g_current_dir + tip2);
479 VtoySetPassword(
0,
0, set_menu_pwd_callback,
0);
482 var tip = (g_current_os === 'windows') ? '\\ISO\\Windows' : "/ISO/Linux";
483 $('#SetPwdForm #id_span_pwddir_tip').text(g_current_dir + tip);
485 VtoySetPassword(
0,
1, set_menu_pwd_callback,
1);
490 $("#id_pwd_tbl").on('click', '.MenuPwdAddBtn', function() {
494 "tip": g_vtoy_cur_language.STR_SET_PWD_FOR_FILE
498 "tip": g_vtoy_cur_language.STR_SET_PWD_FOR_DIR
502 VtoySelectType(OnAddMenuPwdBtnClick, para);
505 $("#id_pwd_tbl").on('click', '.MenuPwdDelBtn', function() {
506 var $tr = $(this).closest('tr');
507 var path = $tr.data('path');
508 var index = $tr.data('index');
511 method : 'password_del',
512 index: current_tab_index,
515 m_data_pwd[current_tab_index].list.splice(index,
1);
516 FillMenuPwdTable(m_data_pwd[current_tab_index].list);
517 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
521 function VtoySaveCurrentPage() {
522 var bootpwd = $('input:text[id=id_bootpwd]').val();
523 var isopwd = $('input:text[id=id_isopwd]').val();
524 var wimpwd = $('input:text[id=id_wimpwd]').val();
525 var imgpwd = $('input:text[id=id_imgpwd]').val();
526 var vhdpwd = $('input:text[id=id_vhdpwd]').val();
527 var efipwd = $('input:text[id=id_efipwd]').val();
528 var vtoypwd = $('input:text[id=id_vtoypwd]').val();
531 method : 'save_password',
532 index: current_tab_index,
541 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
545 $('input:text[id=id_bootpwd]').change(VtoySaveCurrentPage);
546 $('input:text[id=id_isopwd]').change(VtoySaveCurrentPage);
547 $('input:text[id=id_wimpwd]').change(VtoySaveCurrentPage);
548 $('input:text[id=id_imgpwd]').change(VtoySaveCurrentPage);
549 $('input:text[id=id_vhdpwd]').change(VtoySaveCurrentPage);
550 $('input:text[id=id_efipwd]').change(VtoySaveCurrentPage);
551 $('input:text[id=id_vtoypwd]').change(VtoySaveCurrentPage);
553 $('#id_tab_password a[
href="#tab_0"]').click(OnClickMultiModeTab);
554 $('#id_tab_password a[
href="#tab_1"]').click(OnClickMultiModeTab);
555 $('#id_tab_password a[
href="#tab_2"]').click(OnClickMultiModeTab);
556 $('#id_tab_password a[
href="#tab_3"]').click(OnClickMultiModeTab);
557 $('#id_tab_password a[
href="#tab_4"]').click(OnClickMultiModeTab);
558 $('#id_tab_password a[
href="#tab_5"]').click(OnClickMultiModeTab);
560 $('#id_tab_password a[
href="#tab_0"]').tab('show');
561 VtoyFillCurrentPageItem(m_data_pwd[
0]);
562 VtoyPageLanguageChange(g_current_language);