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