]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - Plugson/www/plugson_conf_replace.html
1.0.90 release
[Ventoy.git] / Plugson / www / plugson_conf_replace.html
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="fa fa-retweet">&nbsp;&nbsp;</i>
5 <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title">菜单别名插件</h1>
6 </div>
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>
9 </div>
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_bootconf_replace.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>
12 </div>
13 </div>
14 <legend></legend>
15
16 <div class="box-body">
17 <div class="nav-tabs-custom">
18 <ul class="nav nav-tabs" id="id_tab_conf_replace">
19 <li class=""><a href="#tab_0" data-toggle="tab" aria-expanded="false" style="font-weight:bold" >conf_replace</a></li>
20 <li class=""><a href="#tab_1" data-toggle="tab" aria-expanded="false" style="font-weight:bold">conf_replace_legacy</a></li>
21 <li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false" style="font-weight:bold">conf_replace_uefi</a></li>
22 <li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false" style="font-weight:bold">conf_replace_ia32</a></li>
23 <li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false" style="font-weight:bold">conf_replace_aa64</a></li>
24 <li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false" style="font-weight:bold">conf_replace_mips</a></li>
25 </ul>
26 </div>
27
28 <table id="id_conf_replace_tbl" class="table table-bordered">
29 <thead>
30 <tr>
31 <th style="width: 2%;">#</th>
32 <th id="id_th_conf_path" style="width: 30%;"></th>
33 <th id="id_th_status" style="width: 5%;"></th>
34 <th id="id_th_conf_org" style="width: 20%;"></th>
35 <th id="id_th_conf_new" style="width: 30%;"></th>
36 <th id="id_th_status" style="width: 5%;"></th>
37 <th id="id_th_operation" style="width: 5%;"></th>
38 </tr>
39 </thead>
40 <tbody>
41 </tbody>
42 </table>
43 </div>
44 </div>
45 <script type="text/javascript">
46
47 function VtoyPageLanguageChange(newlang) {
48 VtoyCommonChangeLanguage(newlang);
49 $('h1[id=id_h1_page_title]').text(g_vtoy_cur_language.STR_PLUG_CONF_REPLACE);
50
51 $("span[id=id_span_file_exist]").each(function(){
52 $(this).text(g_vtoy_cur_language.STR_FILE_EXIST);
53 });
54 $("span[id=id_span_file_nonexist]").each(function(){
55 $(this).text(g_vtoy_cur_language.STR_FILE_NONEXIST);
56 });
57 $("span[id=id_span_file_fuzzy]").each(function(){
58 $(this).text(g_vtoy_cur_language.STR_FILE_FUZZY);
59 });
60
61 if (newlang === 'en') {
62 $('#id_th_conf_path').text('Absolute Path');
63 $('#id_th_conf_org').text('org');
64 $('#id_th_conf_new').text('new');
65 } else {
66 $('#id_th_conf_path').text('绝对路径');
67 $('#id_th_conf_org').text('org');
68 $('#id_th_conf_new').text('new');
69
70 }
71 }
72
73 function FillConfReplaceTable(data) {
74 var addbtn = ventoy_get_xslg_addbtn('ConfReplaceAddBtn');
75 var delbtn = ventoy_get_xslg_delbtn('ConfReplaceDelBtn');
76
77 var td1, td2, td3, td4, td5, td6, td7;
78 var $tbl = $("#id_conf_replace_tbl tbody");
79 $tbl.empty();
80
81 for (var i = 0; i < data.length; i++) {
82 var $tr;
83 td1 = '<td>' + (i + 1) + '</td>';
84 td2 = '<td>' + data[i].path + '</td>';
85 td3 = '<td>' + ventoy_get_status_line(0, data[i].valid) + '</td>';
86 td4 = '<td>' + data[i].org + '</td>';
87 td5 = '<td>' + data[i].new + '</td>';
88 td6 = '<td>' + ventoy_get_status_line(0, data[i].new_valid) + '</td>';
89 td7 = '<td>' + delbtn + '</td>';
90
91 $tr = $('<tr>' + td1 + td2 + td3 + td4 + td5 + td6 + td7 + '</tr>');
92
93 $tr.data('path', data[i].path);
94 $tr.data('index', i);
95 $tbl.append($tr);
96 }
97
98 $tbl.append('<tr><td></td><td></td><td></td><td></td><td></td><td></td><td>' + addbtn + '</td></tr>');
99 }
100
101 function VtoyFillCurrentPageItem(data) {
102 FillConfReplaceTable(data);
103 }
104
105
106 function OnClickMultiModeTab() {
107 var href = $(this).attr('href');
108 var index = parseInt(href.substr(5, 1));
109
110 if (index < 0 || index >= g_vtoy_data_default_index || current_tab_index === index) {
111 return;
112 }
113
114 current_tab_index = index;
115 VtoyFillCurrentPageItem(m_data_conf_replace[index]);
116 }
117
118 //Main process
119 var m_conf_iso_path;
120 var m_conf_org_path;
121 var m_conf_new_path;
122 var m_data_conf_replace;
123 var current_tab_index = 0;
124 callVtoySync({method : 'get_conf_replace'}, function(data) {
125 m_data_conf_replace = data;
126 });
127
128 var m_conf_replace_validator = $("#ConfReplaceForm").validate({
129 rules: {
130 IsoPath : {
131 required: true,
132 utfmaxlen: true
133 },
134 OrgPath : {
135 required: true,
136 utfmaxlen: true,
137 start_slash: true
138 },
139 NewPath: {
140 required: true,
141 utfmaxlen: true
142 }
143 },
144
145 submitHandler: function(form) {
146 m_conf_iso_path = $('input:text[id=IsoPath]').val();
147 m_conf_org_path = $('input:text[id=OrgPath]').val();
148 m_conf_new_path = $('input:text[id=NewPath]').val();
149
150 if ((!m_conf_iso_path) || (!m_conf_org_path) || (!m_conf_new_path))
151 {
152 return;
153 }
154
155 m_conf_iso_path = ventoy_replace_slash(m_conf_iso_path);
156 m_conf_new_path = ventoy_replace_slash(m_conf_new_path);
157
158 if (!ventoy_common_check_path(m_conf_iso_path)) {
159 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
160 return;
161 }
162
163 if (!ventoy_common_check_path(m_conf_new_path)) {
164 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
165 return;
166 }
167
168 callVtoy({
169 method : 'check_path2',
170 dir1: 0,
171 fuzzy1: 1,
172 path1: m_conf_iso_path,
173 dir2: 0,
174 fuzzy2: 0,
175 path2: m_conf_new_path
176 }, function(retdata) {
177 if (retdata.exist1 != 0 && retdata.exist2 != 0) {
178 var img = 0;
179 var data = {
180 "path": m_conf_iso_path.substr(g_current_dir.length),
181 "valid": retdata.exist1,
182 "org": m_conf_org_path,
183 "new": m_conf_new_path.substr(g_current_dir.length),
184 "new_valid": 1,
185 "img":0
186 };
187
188 if (m_conf_org_path.substr(0, 8) === '/loader/') {
189 img = 1;
190 data.img = 1;
191 }
192
193 callVtoy({
194 method : 'conf_replace_add',
195 index: current_tab_index,
196 path: data.path,
197 org: data.org,
198 new: data.new,
199 img: img
200 }, function(e) {
201 m_data_conf_replace[current_tab_index].push(data);
202 FillConfReplaceTable(m_data_conf_replace[current_tab_index]);
203 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
204 });
205
206 $("#ConfReplaceModal").modal('hide');
207 } else if (retdata.exist1 === 0) {
208 Message.error(g_vtoy_cur_language.STR_INVALID_FILE_PATH);
209 } else {
210 Message.error(g_vtoy_cur_language.STR_INVALID_NEW_FILE_PATH);
211 }
212 });
213 }
214 });
215
216 $("#id_conf_replace_tbl").on('click', '.ConfReplaceAddBtn', function() {
217 if (g_current_language === 'en') {
218 $('#ConfReplaceForm #ConfReplaceForm_lang_1').text("ISO Path");
219 $('#ConfReplaceForm #ConfReplaceForm_lang_2').text(" OK");
220 $('#ConfReplaceForm #ConfReplaceForm_lang_3').text("Cancel");
221 $('#ConfReplaceForm #id_note_conf_cn').hide();
222 $('#ConfReplaceForm #id_note_conf_en').show();
223 } else {
224 $('#ConfReplaceForm #ConfReplaceForm_lang_1').text("ISO文件路径");
225 $('#ConfReplaceForm #ConfReplaceForm_lang_2').text("确定");
226 $('#ConfReplaceForm #ConfReplaceForm_lang_3').text("取消");
227 $('#ConfReplaceForm #id_note_conf_en').hide();
228 $('#ConfReplaceForm #id_note_conf_cn').show();
229 }
230
231 $('#ConfReplaceForm #id_span_conf_tip1').each(function() {
232 var tip = (g_current_os === 'windows') ? '\\ISO\\Ubuntu-20.04-desktop-amd64.iso' : "/ISO/Ubuntu-20.04-desktop-amd64.iso";
233 $(this).text(g_current_dir + tip);
234 });
235
236 $('#ConfReplaceForm #id_span_conf_tip2').each(function() {
237 var tip = (g_current_os === 'windows') ? '\\ISO\\Ubuntu-*****-desktop-amd64.iso' : "/ISO/Ubuntu-*****-desktop-amd64.iso";
238 $(this).text(g_current_dir + tip);
239 });
240
241 $('#ConfReplaceForm #id_span_conf_tip3').each(function() {
242 var tip = (g_current_os === 'windows') ? '\\ventoy\\grub_new.cfg' : "/ventoy/grub_new.cfg";
243 $(this).text(g_current_dir + tip);
244 });
245
246 m_conf_replace_validator.resetForm();
247 $("#ConfReplaceModal").modal();
248 });
249
250 $("#id_conf_replace_tbl").on('click', '.ConfReplaceDelBtn', function() {
251 var $tr = $(this).closest('tr');
252 var path = $tr.data('path');
253 var index = $tr.data('index');
254
255 callVtoySync({
256 method : 'conf_replace_del',
257 index: current_tab_index,
258 path: path
259 }, function(data) {
260 m_data_conf_replace[current_tab_index].splice(index, 1);
261 FillConfReplaceTable(m_data_conf_replace[current_tab_index]);
262 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
263 });
264 });
265
266
267 $('#id_tab_conf_replace a[href="#tab_0"]').click(OnClickMultiModeTab);
268 $('#id_tab_conf_replace a[href="#tab_1"]').click(OnClickMultiModeTab);
269 $('#id_tab_conf_replace a[href="#tab_2"]').click(OnClickMultiModeTab);
270 $('#id_tab_conf_replace a[href="#tab_3"]').click(OnClickMultiModeTab);
271 $('#id_tab_conf_replace a[href="#tab_4"]').click(OnClickMultiModeTab);
272 $('#id_tab_conf_replace a[href="#tab_5"]').click(OnClickMultiModeTab);
273 function UpdateTabTitleIcon(data) {
274 CommonUpdateTabTitleIcon(data.exist_conf_replace, '#id_tab_conf_replace a[href="#tab_', 'conf_replace');
275 }
276 $('#id_btn_reset').click(function() {
277 Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'conf_replace')}).on(function(e) {
278 if (e) {
279 callVtoySync({
280 method : 'conf_replace_del',
281 index: current_tab_index,
282 path: g_del_all_path
283 }, function(data) {
284
285 });
286
287 m_data_conf_replace[current_tab_index].length = 0;
288 VtoyFillCurrentPageItem(m_data_conf_replace[g_vtoy_data_default_index]);
289 Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);
290 }
291 });
292 });
293
294 $('#id_tab_conf_replace a[href="#tab_0"]').tab('show');
295 VtoyFillCurrentPageItem(m_data_conf_replace[0]);
296 VtoyPageLanguageChange(g_current_language);
297
298 </script>