]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - Plugson/www/plugson_password.html
added Spanish (Latinoamérica) translation (#1865)
[Ventoy.git] / Plugson / www / plugson_password.html
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">&nbsp;</i>
5 <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title"></h1>
6 </div>
7
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>
10 </div>
11 </div>
12 <legend></legend>
13
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>
23 </ul>
24 </div>
25
26
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">
37 <thead>
38 <tr>
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>
43 </tr>
44 </thead>
45 <tbody>
46 </tbody>
47 </table>
48 </div>
49 </div>
50
51
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">
62 <thead>
63 <tr>
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>
70 </tr>
71 </thead>
72 <tbody>
73 </tbody>
74 </table>
75 </div>
76 </div>
77 <br/><br/>
78
79
80 </div>
81 </div>
82 <script type="text/javascript">
83
84 function VtoyPageLanguageChange(newlang) {
85 VtoyCommonChangeLanguage(newlang);
86 $('h1[id=id_h1_page_title]').text(g_vtoy_cur_language.STR_PLUG_PASSWORD);
87
88 $("span[id=id_span_file_exist]").each(function(){
89 $(this).text(g_vtoy_cur_language.STR_FILE_EXIST);
90 });
91 $("span[id=id_span_file_nonexist]").each(function(){
92 $(this).text(g_vtoy_cur_language.STR_FILE_NONEXIST);
93 });
94 $("span[id=id_span_file_fuzzy]").each(function(){
95 $(this).text(g_vtoy_cur_language.STR_FILE_FUZZY);
96 });
97
98 $("span[id=id_span_dir_exist]").each(function(){
99 $(this).text(g_vtoy_cur_language.STR_DIR_EXIST);
100 });
101
102 $("span[id=id_span_dir_nonexist]").each(function(){
103 $(this).text(g_vtoy_cur_language.STR_DIR_NONEXIST);
104 });
105
106 $("span[id=id_span_edit]").each(function(){
107 $(this).text(' ' + g_vtoy_cur_language.STR_EDIT);
108 });
109
110 $("span[id=id_span_clear]").each(function(){
111 $(this).text(' ' + g_vtoy_cur_language.STR_CLEAR);
112 });
113
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');
122
123 $("span[id=id_span_desc_cn]").each(function(){
124 $(this).hide();
125 });
126 $("span[id=id_span_desc_en]").each(function(){
127 $(this).show();
128 });
129 } else {
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(){
138 $(this).hide();
139 });
140 $("span[id=id_span_desc_cn]").each(function(){
141 $(this).show();
142 });
143 }
144 }
145
146 function format_password(pwd, type) {
147 if (type === 0) {
148 return 'txt#' + pwd;
149 } else if (type === 1) {
150 return 'md5#' + md5(pwd);
151 } else {
152 var salt;
153 var rand = Math.round(Math.random() * 10);
154 if ((rand % 2) === 0) {
155 salt = ventoy_random_string(3);
156 } else {
157 salt = ventoy_random_string(4);
158 }
159
160 return 'md5#' + salt + '#' + md5(salt + pwd);
161 }
162 }
163
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>&nbsp;&nbsp;' +
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>' +
170 '</tr>';
171 tbl.append(tr);
172 }
173
174 function FillCommonPassword(data) {
175 var $tbl = $("#id_common_pwd tbody");
176 $tbl.empty();
177
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.');
185
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);
193 }
194
195 function FillMenuPwdTable(data) {
196 var addbtn = ventoy_get_xslg_addbtn('MenuPwdAddBtn');
197 var delbtn = ventoy_get_xslg_delbtn('MenuPwdDelBtn');
198
199 var td1, td2, td3, td4, td5, td6;
200 var $tbl = $("#id_pwd_tbl tbody");
201 $tbl.empty();
202
203 for (var i = 0; i < data.length; i++) {
204 var $tr;
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>';
211
212 $tr = $('<tr>' + td1 + td2 + td3 + td4 + td5 + td6 + '</tr>');
213
214 $tr.data('path', data[i].path);
215 $tr.data('index', i);
216 $tbl.append($tr);
217 }
218
219 $tbl.append('<tr><td></td><td></td><td></td><td></td><td></td><td>' + addbtn + '</td></tr>');
220 }
221
222 function VtoyFillCurrentPageItem(data) {
223 FillCommonPassword(data);
224 FillMenuPwdTable(data.list);
225 }
226
227
228 function OnClickMultiModeTab() {
229 var href = $(this).attr('href');
230 var index = parseInt(href.substr(5, 1));
231
232 if (index < 0 || index >= g_vtoy_data_default_index || current_tab_index === index) {
233 return;
234 }
235
236 current_tab_index = index;
237 VtoyFillCurrentPageItem(m_data_pwd[index].tips);
238 }
239
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();
248 }
249
250 function VtoySaveCurrentPage() {
251 VtoyGetCurrentPageItem(m_data_pwd[current_tab_index]);
252 var data = m_data_pwd[current_tab_index];
253
254 callVtoy({
255 method : 'save_password',
256 index: current_tab_index,
257 bootpwd: data.bootpwd,
258 isopwd: data.isopwd,
259 wimpwd: data.bootpwd,
260 imgpwd: data.imgpwd,
261 efipwd: data.efipwd,
262 vhdpwd: data.vhdpwd,
263 vtoypwd: data.vtoypwd
264 }, function(e) {
265 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
266 });
267 }
268
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({
273 rules: {
274 PwdPath : {
275 required: true,
276 utfmaxlen: true
277 },
278 PwdPwd : {
279 required: true,
280 utfmaxlen: true,
281 noquotes:true,
282 printascii:true,
283 maxlength: 40
284 }
285 },
286
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());
291
292 if (m_pwd_validator.settings.rules.PwdPath.required) {
293 path = ventoy_replace_slash(path);
294
295 if (!ventoy_common_check_path(path)) {
296 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
297 return;
298 }
299
300 if (path.indexOf("*") >= 0) {
301 callVtoySync({
302 method : 'check_fuzzy',
303 path: path
304 }, function(data) {
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);
308 }
309 $("#SetPwdModal").modal('hide');
310 } else {
311 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
312 }
313 });
314 } else {
315
316 callVtoySync({
317 method : 'check_path',
318 dir: m_pwd_file_or_dir,
319 path: path
320 }, function(data) {
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);
324 }
325 $("#SetPwdModal").modal('hide');
326 } else {
327 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
328 }
329 });
330 }
331 } else {
332 if (typeof(m_pwd_callback_func) === 'function') {
333
334 m_pwd_callback_func(path, pwd, type, m_pwd_callback_data);
335 }
336 $("#SetPwdModal").modal('hide');
337 }
338 }
339 });
340
341 function VtoySetPassword(common, type, cb, data) {
342
343 $('#SetPwdForm #SetPwdForm_title').text(g_vtoy_cur_language.STR_SET_PASSWORD);
344
345 if (type === 0) {
346 $('#SetPwdForm #SetPwdForm_path').text(g_vtoy_cur_language.STR_FILE_PATH);
347 } else {
348 $('#SetPwdForm #SetPwdForm_path').text(g_vtoy_cur_language.STR_DIR_PATH);
349 }
350
351 $('#SetPwdForm #SetPwdForm_pwd').text(g_vtoy_cur_language.STR_PASSWORD_VALUE);
352 $('#SetPwdForm #SetPwdForm_type').text(g_vtoy_cur_language.STR_PASSWORD_TYPE);
353
354 if (common) {
355 m_pwd_validator.settings.rules.PwdPath.required = false;
356 $('div[id=id_div_pwd_path]').hide();
357
358 } else {
359 m_pwd_validator.settings.rules.PwdPath.required = true;
360 $('div[id=id_div_pwd_path]').show();
361
362 if (type === 0) {
363 if (g_current_language === 'en') {
364 $('div[id=id_note_pwdfile_cn]').hide();
365 $('div[id=id_note_pwdfile_en]').show();
366 } else {
367 $('div[id=id_note_pwdfile_cn]').show();
368 $('div[id=id_note_pwdfile_en]').hide();
369 }
370 $('div[id=id_note_pwddir_cn]').hide();
371 $('div[id=id_note_pwddir_en]').hide();
372 } else {
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();
378 } else {
379 $('div[id=id_note_pwddir_cn]').show();
380 $('div[id=id_note_pwddir_en]').hide();
381 }
382 }
383 }
384
385 $('input:radio[name=id_radio_pwd_type]')[0].checked = true;
386
387 if (g_current_language === 'en') {
388 $('#SetPwdForm #SetPwdForm_ok').text(" OK");
389 $('#SetPwdForm #SetPwdForm_cancel').text("Cancel");
390 } else {
391 $('#SetPwdForm #SetPwdForm_ok').text("确定");
392 $('#SetPwdForm #SetPwdForm_cancel').text("取消");
393 }
394
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();
400 }
401
402
403
404
405
406
407
408
409
410 //Main process
411 var m_data_pwd;
412 var current_tab_index = 0;
413 callVtoySync({method : 'get_password'}, function(data) {
414 m_data_pwd = data;
415 });
416
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);
420
421 $(selector).val(value);
422 VtoySaveCurrentPage();
423 }
424 $("#id_common_pwd").on('click', '.CommPwdSetBtn', function() {
425 var id = $(this).attr('id');
426
427 //id_btn_set_
428 VtoySetPassword(1, 0, set_common_pwd_callback, id.substr(11));
429 });
430 $("#id_common_pwd").on('click', '.CommPwdClearBtn', function() {
431 var id = $(this).attr('id');
432
433 //id_btn_clr_
434 var selector = 'input:text[id=id_'+ id.substr(11) +']';
435 $(selector).val('');
436 VtoySaveCurrentPage();
437 });
438
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;
443
444 var data = {
445 "type": FileOrDir,
446 "path": path.substr(g_current_dir.length),
447 "valid": valid,
448 "pwd": value
449 };
450
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);
454 return;
455 }
456 }
457
458 callVtoy({
459 method : 'password_add',
460 index: current_tab_index,
461 type: data.type,
462 path: data.path,
463 pwd: data.pwd
464 }, function(e) {
465 list.push(data);
466 FillMenuPwdTable(list);
467 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
468 });
469
470 }
471 function OnAddMenuPwdBtnClick(sel) {
472 if (sel === 0) {
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";
475
476 $('#SetPwdForm #id_span_pwdfile_tip1').text(g_current_dir + tip1);
477 $('#SetPwdForm #id_span_pwdfile_tip2').text(g_current_dir + tip2);
478
479 VtoySetPassword(0, 0, set_menu_pwd_callback, 0);
480
481 } else {
482 var tip = (g_current_os === 'windows') ? '\\ISO\\Windows' : "/ISO/Linux";
483 $('#SetPwdForm #id_span_pwddir_tip').text(g_current_dir + tip);
484
485 VtoySetPassword(0, 1, set_menu_pwd_callback, 1);
486
487 }
488 }
489
490 $("#id_pwd_tbl").on('click', '.MenuPwdAddBtn', function() {
491 var para = [
492 {
493 "selected": true,
494 "tip": g_vtoy_cur_language.STR_SET_PWD_FOR_FILE
495 },
496 {
497 "selected": false,
498 "tip": g_vtoy_cur_language.STR_SET_PWD_FOR_DIR
499 }
500 ];
501
502 VtoySelectType(OnAddMenuPwdBtnClick, para);
503 });
504
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');
509
510 callVtoySync({
511 method : 'password_del',
512 index: current_tab_index,
513 path: path
514 }, function(data) {
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);
518 });
519 });
520
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();
529
530 callVtoy({
531 method : 'save_password',
532 index: current_tab_index,
533 bootpwd: bootpwd,
534 isopwd: isopwd,
535 wimpwd: wimpwd,
536 imgpwd: imgpwd,
537 vhdpwd: vhdpwd,
538 efipwd: efipwd,
539 vtoypwd: vtoypwd
540 }, function(e) {
541 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
542 });
543 }
544
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);
552
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);
559
560 $('#id_tab_password a[href="#tab_0"]').tab('show');
561 VtoyFillCurrentPageItem(m_data_pwd[0]);
562 VtoyPageLanguageChange(g_current_language);
563
564 </script>