Exit Saving Changes
Exit Discarding Changes
diff --git a/desktop.js b/desktop.js
index 57fa771..c029bfd 100755
--- a/desktop.js
+++ b/desktop.js
@@ -2136,34 +2136,51 @@ let apps = {
shownotice('duplication file name');
return;
}
- name_1 = name_.split('.');
-
- if (type == 'file') {
- if (name_1[1] == 'txt') {
- icon_ = 'icon/files/txt.png';
- if (command == '')
- command = 'openapp(\'notepad\')';
- }
- else if (name_1[1] == 'png' || name_1[1] == 'jpg' | name_1[1] == 'bmp') {
- icon_ = 'icon/files/picture.png';
- }
- else {
- icon_ = 'icon/files/none.png';
- }
- //这边可以适配更多的文件类型
- if (icon != '') {
+
+ // 检查是否是文件夹
+ if (type === 'folder') {
+ if (icon !== '') {
icon_ = icon;
+ } else {
+ icon_ = 'icon/folder.png';
}
try {
- tmp.file.push({ name: name_, ico: icon_, command: command });
+ tmp.folder[name_] = { folder: {}, file: [] };
+ } catch {
+ tmp = { folder: {}, file: [] };
+ tmp.folder[name_] = { folder: {}, file: [] };
}
- catch {
- tmp.push(file);
- tmp.file.push({ name: name_, ico: icon_, command: command });
+ return;
+ }
+
+ // 处理文件
+ const name_1 = name_.split('.');
+ if (name_1.length < 2) {
+ icon_ = 'icon/files/none.png';
+ }
+ else if (name_1[1] === 'txt') {
+ icon_ = 'icon/files/txt.png';
+ if (command === '') {
+ command = 'openapp(\'notepad\')';
}
}
+ else if (['png', 'jpg', 'bmp'].includes(name_1[1])) {
+ icon_ = 'icon/files/picture.png';
+ }
else {
- tmp.folder[name_] = { folder: {}, file: [] };
+ icon_ = 'icon/files/none.png';
+ }
+
+ if (icon !== '') {
+ icon_ = icon;
+ }
+
+ try {
+ tmp.file.push({ name: name_, ico: icon_, command: command });
+ }
+ catch {
+ tmp = { folder: {}, file: [] };
+ tmp.file = [{ name: name_, ico: icon_, command: command }];
}
apps.explorer.goto(path);
apps.explorer.rename(path + '/' + name_);
@@ -2214,13 +2231,13 @@ let apps = {
pathl.forEach(name => {
tmp = tmp['folder'][name];
});
- tmp_file = tmp['file'];
+ let tmp_file = tmp['file'];
for (var i = 0; i < tmp_file.length; i++) {
if (tmp_file[i]['name'] == name) {
tmp_file.splice(i, 1);
}
}
- tmp_files = tmp['folder'];
+ let tmp_files = tmp['folder'];
delete tmp_files[name];
apps.explorer.goto(pathl.join('/'));
apps.explorer.history.forEach(item => {
diff --git a/scripts/bios_kernel.js b/scripts/bios_kernel.js
index 1e56062..0c7d1c1 100755
--- a/scripts/bios_kernel.js
+++ b/scripts/bios_kernel.js
@@ -1,11 +1,13 @@
function addZero(i) {
- return i < 10 ? ('0' + i) : i;
+ return i < 10 ? `0${i}` : i;
}
+
function timeChange() {
- d = new Date();
- $('#time')[0].innerText = '[' + addZero(d.getHours()) + ':' + addZero(d.getMinutes()) + ':' + addZero(d.getSeconds()) + ']';
- $('#date')[0].innerText = '[' + d.getDate() + '/' + (d.getMonth() + 1) + '/' + d.getFullYear() + ']';
+ const d = new Date();
+ $('#time')[0].innerText = `[${addZero(d.getHours())}:${addZero(d.getMinutes())}:${addZero(d.getSeconds())}]`;
+ $('#date')[0].innerText = `[${d.getDate()}/${d.getMonth() + 1}/${d.getFullYear()}]`;
}
+
function toBoot() {
setTimeout(() => {
$('#body').html('');
@@ -13,8 +15,9 @@ function toBoot() {
}, 500);
setTimeout(() => {
location.href = './boot.html';
- }, 1000); //Boot延迟
+ }, 1000);
}
+
function BIOS_confirm(tit, func) {
$('#confirm-tit')[0].innerText = tit;
$('#confirmContainer').css('display', 'flex');
@@ -22,120 +25,214 @@ function BIOS_confirm(tit, func) {
$('#confirm>.btns>*:first-child').attr('click', func);
$('#confirm>.btns>*:first-child').attr('ontouchstart', func);
}
-setTimeout(() => {
- timeChange();
- setInterval(timeChange, 1000);
-}, 1000 - (new Date()).getMilliseconds());
-var tab = 0, tab_back = tab;
-var btn = 0, btn_back = btn;
-var foc = 0, foc_back = foc;
-timeChange();
function changePage(t) {
$('.tab.show').removeClass('show');
$('.tab.foc').removeClass('foc');
- $('.tab' + t).addClass('show');
- $('.tab' + t).addClass('foc');
+ $(`.tab${t}`).addClass('show');
+ $(`.tab${t}`).addClass('foc');
$('.page.show').removeClass('show');
- $('.page' + t).addClass('show');
+ $(`.page${t}`).addClass('show');
tab = t;
}
-changePage(0);
-document.oncontextmenu = function () {
- return false;
+
+let tab = 0;
+let btn = 0;
+let foc = 0;
+let tab_back = tab;
+let btn_back = btn;
+let foc_back = foc;
+let subFoc = -1;
+
+timeChange();
+
+// Add configuration state
+const biosConfig = {
+ cpuHyperThreading: true,
+ cpuTurboBoost: true,
+ cpuCoreRatio: 'Auto',
+ memoryFrequency: 'Auto',
+ memoryTimingMode: 'Auto',
+ xmpProfile: false,
+ fastBoot: true,
+ bootMode: 'UEFI',
+ secureBoot: true,
+ tpmState: true
};
-var tabs = ['main', 'exit'];
-window.onkeydown = function (event) {
- event = event || window.event;
- tab_back = tab;
- if ($('#confirm').attr('data-show') != 'true') {
- if (event.keyCode == 9) {
- tab++;
+
+function toggleOption(optionElement) {
+ const currentValue = optionElement.innerText;
+ if (currentValue.includes('Enabled')) {
+ optionElement.innerText = '[Disabled]';
+ return false;
+ }
+ if (currentValue.includes('Disabled')) {
+ optionElement.innerText = '[Enabled]';
+ return true;
+ }
+ if (currentValue.includes('Auto')) {
+ optionElement.innerText = '[Manual]';
+ return 'Manual';
+ }
+ if (currentValue.includes('Manual')) {
+ optionElement.innerText = '[Auto]';
+ return 'Auto';
+ }
+ return currentValue;
+}
+
+function handleExitOption(option) {
+ const action = $(option).attr('click');
+ if (action.includes('toBoot()')) {
+ toBoot();
+ } else if (action.includes('BIOS_confirm')) {
+ const match = action.match(/BIOS_confirm\('([^']+)',\s*'([^']+)'\)/);
+ if (match) {
+ const [_, message, callback] = match;
+ BIOS_confirm(message, callback);
+ }
+ }
+}
+
+function updateFocus() {
+ // Clear all focus states first
+ $('.option').css('background-color', '#aaaaaa');
+ $('.option').css('color', '#0100a2');
+ $('.exit').css('color', '#0100a2');
+
+ const currentPage = $(`.page${tab}`);
+
+ if (tab === tabs.length - 1) { // Exit page
+ const exitOptions = currentPage.find('.exit');
+ if (foc > 0 && foc <= exitOptions.length) {
+ $(exitOptions[foc - 1]).css('color', '#ffffff');
+ }
+ } else { // Other pages
+ const options = currentPage.find('.option');
+ if (foc > 0 && options.length > 0) {
+ const focusedOption = options[Math.min(foc - 1, options.length - 1)];
+ if (focusedOption) {
+ $(focusedOption).css('background-color', '#0100a2');
+ $(focusedOption).css('color', '#ffffff');
+ }
+ }
+ }
+}
+
+// Update tabs array
+const tabs = ['main', 'advanced', 'boot', 'security', 'exit'];
+
+changePage(0);
+document.oncontextmenu = () => false;
+
+window.onkeydown = (evt) => {
+ const event = evt || window.event;
+
+ if ($('#confirm').attr('data-show') !== 'true') {
+ if (event.keyCode === 9) { // Tab
+ event.preventDefault();
+ tab = (tab + 1) % tabs.length;
foc = 0;
- tab = tab % 2;
changePage(tab);
}
- if (event.keyCode == 121/*F10=退出*/) {
- eval($('#e1').attr('click'));
+ else if (event.keyCode === 121) { // F10
+ toBoot();
}
- if (event.keyCode == 39) {
+ else if (event.keyCode === 39) { // Right
event.preventDefault();
- tab++;
- } else if (event.keyCode == 37) {
- event.preventDefault();
- tab--;
- }
- if (tab + 1 > 0 && tab + 1 <= tabs.length && foc == 0) {
- if ([37, 39].includes(event.keyCode)) {
+ if (tab < tabs.length - 1) {
+ tab++;
+ foc = 0;
changePage(tab);
}
- } else {
- tab = tab_back;
}
- foc_back = foc;
- if (event.keyCode == 40) {
- event.preventDefault();
- foc++;
- } else if (event.keyCode == 38) {
+ else if (event.keyCode === 37) { // Left
event.preventDefault();
- foc--;
+ if (tab > 0) {
+ tab--;
+ foc = 0;
+ changePage(tab);
+ }
}
- if (tab == 1 && foc <= 3 && foc >= 0) {
- if (!foc) { //0
- if (tab)
- $('#exit').addClass('foc');
- else
- $('#main').addClass('foc');
- for (var i = 1; i <= 3; i++)
- $('#e' + i).css('color', '#0100a2');
- } else {
- if (tab) {
- $('#exit').removeClass('foc');
+ else if (event.keyCode === 40) { // Down
+ event.preventDefault();
+ const currentPage = $(`.page${tab}`);
+ if (tab === tabs.length - 1) { // Exit page
+ const exitOptions = currentPage.find('.exit');
+ if (exitOptions.length > 0) {
+ foc = Math.min(foc + 1, exitOptions.length);
+ updateFocus();
}
- else {
- $('#main').removeClass('foc');
+ } else {
+ const options = currentPage.find('.option');
+ if (options.length > 0) {
+ foc = Math.min(foc + 1, options.length);
+ updateFocus();
}
- for (var i = 1; i <= 3; i++) {
- $('#e' + i).css('color', '#0100a2');
+ }
+ }
+ else if (event.keyCode === 38) { // Up
+ event.preventDefault();
+ if (foc > 0) {
+ foc--;
+ updateFocus();
+ }
+ }
+ else if (event.keyCode === 13) { // Enter
+ const currentPage = $(`.page${tab}`);
+ if (tab === tabs.length - 1) { // Exit page
+ const exitOptions = currentPage.find('.exit');
+ if (foc > 0 && foc <= exitOptions.length) {
+ const focusedOption = exitOptions[foc - 1];
+ handleExitOption(focusedOption);
}
- $('#e' + foc).css('color', '#ffffff');
- if (event.keyCode == 13) {
- eval($('#e' + foc).attr('click'));
+ } else {
+ const options = currentPage.find('.option');
+ if (foc > 0 && foc <= options.length) {
+ const focusedOption = options[foc - 1];
+ const newValue = toggleOption(focusedOption);
+ const optionId = $(focusedOption).attr('data-option');
+ if (optionId) {
+ biosConfig[optionId] = newValue;
+ }
}
}
- } else {
- foc = foc_back;
}
} else {
- btn_back = btn;
- if (event.keyCode == 39) {
- event.preventDefault();
- btn++;
- } else if (event.keyCode == 37) {
+ // Confirm dialog navigation
+ if (event.keyCode === 39 || event.keyCode === 37) { // Right/Left
event.preventDefault();
- btn--;
- }
- if ([0, 1].includes(btn)) {
- if (btn) {//1
+ btn = btn ? 0 : 1;
+ if (btn) {
$('#cancel-btn').css('cssText', 'background-color: #000; color: #fff;');
$('#ok-btn').css('cssText', 'color: #000; background-color: #fff;');
- } else {//0
+ } else {
$('#ok-btn').css('cssText', 'background-color: #000;color: #fff;');
$('#cancel-btn').css('cssText', 'color: #000;background-color: #fff;');
}
- } else {
- btn = btn_back;
}
- if (event.keyCode == 13) {
+ else if (event.keyCode === 13) { // Enter
event.preventDefault();
if (btn) {
- eval($('#cancel-btn').attr('click'));
+ $('#confirmContainer').css('display', 'none');
+ $('#confirm').attr('data-show', 'false');
} else {
- eval($('#ok-btn').attr('click'));
+ toBoot();
}
btn = 0;
$('#ok-btn').css('cssText', 'background-color: #000;color: #fff;');
$('#cancel-btn').css('cssText', 'color: #000;background-color: #fff;');
}
}
-};
\ No newline at end of file
+};
+
+// Add click handlers for options
+for (const option of document.querySelectorAll('.option')) {
+ option.addEventListener('click', function() {
+ const newValue = toggleOption(this);
+ const optionId = this.getAttribute('data-option');
+ if (optionId) {
+ biosConfig[optionId] = newValue;
+ }
+ });
+}
\ No newline at end of file
diff --git a/scripts/boot_kernel.js b/scripts/boot_kernel.js
index db7e34c..505c469 100755
--- a/scripts/boot_kernel.js
+++ b/scripts/boot_kernel.js
@@ -1,23 +1,23 @@
function setProgress(n) {
- $('#load').css('width', (400 / 20 * n) + 'px');
- $('#back').css('width', (400 / 20 * (20 - n)) + 'px');
+ $('#load').css('width', `${(400 / 20 * n)}px`);
+ $('#back').css('width', `${(400 / 20 * (20 - n))}px`);
}
setProgress(0);
-var i = 0;
-var progress = [0, 0, 1, 3, 7, 17, 20];
-var timer;
-timer = setInterval(function () {
+let i = 0;
+const progress = [0, 0, 1, 3, 7, 17, 20];
+const timer = setInterval(() => {
setProgress(progress[i]);
i++;
if (i >= progress.length) {
- if (timer != undefined) {
+ if (timer !== undefined) {
clearInterval(timer);
}
window.location.href = './desktop.html';
}
}, 300);
+
function toBIOS() {
- if (timer != undefined) {
+ if (timer !== undefined) {
clearInterval(timer);
}
setTimeout(() => {
@@ -28,12 +28,12 @@ function toBIOS() {
window.location.href = './bios.html';
}, 1000);
}
+
window.onkeydown = (event) => {
- if (event.keyCode == 113) {
+ if (event.keyCode === 113 || event.key === 'F2') {
toBIOS();
}
};
+
window.ontouchstart = toBIOS;
-document.oncontextmenu = function () {
- return false;
-};
+document.oncontextmenu = () => false;