Skip to content

Commit 8fd3808

Browse files
committed
More work
1 parent 2339be8 commit 8fd3808

1 file changed

Lines changed: 83 additions & 43 deletions

File tree

beta/emuos/assets/js/emuos.js

Lines changed: 83 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,16 @@
350350
self.$desktop = $('.desktop').first();
351351
self.$taskbar = $('.taskbar').first();
352352
self._applyStoredCustomWallpaper();
353+
self.frontend = frontend;
353354

354355
var desktopIcons = self._getDesktopIcons(self.options.icons, self.useFolders);
356+
var renderDesktopIcons = function(iconList) {
357+
self.$desktop.find('a.emuos-desktop-icon').remove();
358+
self._foldersByPath = {};
355359

356-
for (var j in desktopIcons) {
360+
for (var j in iconList) {
357361
// noinspection JSUnfilteredForInLoop,JSDuplicatedDeclaration
358-
var icon_options = desktopIcons[j];
362+
var icon_options = iconList[j];
359363

360364
if (typeof icon_options['requires'] === 'object') {
361365
var reqs = Object.keys(icon_options['requires']);
@@ -560,7 +564,7 @@
560564
title: $(this).data('name'),
561565
credits: $(this).data('credits'),
562566
icon: $(this).data('icon'),
563-
src: frontend,
567+
src: self.frontend,
564568
newtab: $(this).data('newtab'),
565569
width: $(this).data('width'),
566570
height: $(this).data('height')
@@ -571,7 +575,7 @@
571575
self.iframe({
572576
title: $(this).data('name'),
573577
icon: $(this).data('icon'),
574-
src: frontend,
578+
src: self.frontend,
575579
newtab: $(this).data('newtab'),
576580
width: $(this).data('width'),
577581
height: $(this).data('height'),
@@ -713,7 +717,11 @@
713717
}
714718
}
715719
});
716-
}
720+
}
721+
};
722+
723+
self.desktopIcons = desktopIcons;
724+
renderDesktopIcons(self.desktopIcons);
717725

718726
// noinspection JSUnresolvedFunction
719727
self.$taskbar.taskbar({
@@ -1071,45 +1079,58 @@
10711079
}
10721080
});
10731081

1074-
self.$html.contextmenu({
1075-
delegate: '.emuos-desktop, .emuos-taskbar',
1076-
menu: [{
1077-
title: 'Refresh',
1078-
cmd: 'refresh',
1079-
uiIcon: 'ui-icon-refresh'
1082+
var hasCustomWallpaper = !!self._getCustomWallpaper();
1083+
var desktopMenu = [{
1084+
title: 'Refresh',
1085+
cmd: 'refresh',
1086+
uiIcon: 'ui-icon-refresh'
1087+
} , {
1088+
title: '----'
1089+
} , {
1090+
title: 'Custom Wallpaper',
1091+
cmd: 'custom-wallpaper',
1092+
uiIcon: 'ui-icon-image'
1093+
}];
1094+
1095+
if (hasCustomWallpaper) {
1096+
desktopMenu.push({
1097+
title: 'Remove Custom Wallpaper',
1098+
cmd: 'remove-custom-wallpaper',
1099+
uiIcon: 'ui-icon-trash'
1100+
});
1101+
}
1102+
1103+
desktopMenu = desktopMenu.concat([{
1104+
title: '----'
1105+
} , {
1106+
title: 'Themes',
1107+
children: [{
1108+
title: 'Basic',
1109+
cmd: 'basic'
10801110
} , {
1081-
title: '----'
1111+
title: 'Windows 3.1',
1112+
cmd: 'windows-3'
10821113
} , {
1083-
title: 'Custom Wallpaper...',
1084-
cmd: 'custom-wallpaper',
1085-
uiIcon: 'ui-icon-image'
1114+
title: 'Windows 95',
1115+
cmd: 'windows-95'
10861116
} , {
1087-
title: '----'
1117+
title: 'Windows 98',
1118+
cmd: 'windows-98'
10881119
} , {
1089-
title: 'Themes',
1090-
children: [{
1091-
title: 'Basic',
1092-
cmd: 'basic'
1093-
} , {
1094-
title: 'Windows 3.1',
1095-
cmd: 'windows-3'
1096-
} , {
1097-
title: 'Windows 95',
1098-
cmd: 'windows-95'
1099-
} , {
1100-
title: 'Windows 98',
1101-
cmd: 'windows-98'
1102-
} , {
1103-
title: 'Windows ME',
1104-
cmd: 'windows-me'
1105-
}]
1106-
} , {
1107-
title: '----'
1108-
} , {
1109-
title: 'Use Folders',
1110-
cmd: 'toggle-folders',
1111-
uiIcon: self.useFolders ? 'ui-icon-check' : ''
1112-
}],
1120+
title: 'Windows ME',
1121+
cmd: 'windows-me'
1122+
}]
1123+
} , {
1124+
title: '----'
1125+
} , {
1126+
title: 'Use Folders',
1127+
cmd: 'toggle-folders',
1128+
uiIcon: self.useFolders ? 'ui-icon-check' : ''
1129+
}]);
1130+
1131+
self.$html.contextmenu({
1132+
delegate: '.emuos-desktop, .emuos-taskbar',
1133+
menu: desktopMenu,
11131134
select: function(e, ui) {
11141135
switch (ui.cmd) {
11151136
case 'refresh':
@@ -1119,14 +1140,18 @@
11191140
case 'custom-wallpaper':
11201141
self._promptCustomWallpaper();
11211142
break;
1143+
case 'remove-custom-wallpaper':
1144+
self._clearCustomWallpaper();
1145+
break;
11221146
case 'toggle-folders':
11231147
self.useFolders = !self.useFolders;
11241148

11251149
if (typeof simplestorage !== 'undefined' && typeof simplestorage.set === 'function') {
11261150
simplestorage.set('useFolders', self.useFolders);
11271151
}
11281152

1129-
window.location.reload();
1153+
self.desktopIcons = self._getDesktopIcons(self.options.icons, self.useFolders);
1154+
renderDesktopIcons(self.desktopIcons);
11301155
break;
11311156
case 'basic':
11321157
self.$html.removeClass('theme-windows-3 theme-windows-95 theme-windows-98 theme-windows-me').addClass('theme-basic');
@@ -1227,9 +1252,9 @@
12271252
route = route.slice(0, route.lastIndexOf('?'));
12281253
}
12291254

1230-
for (var j in desktopIcons) {
1255+
for (var j in self.desktopIcons) {
12311256
// noinspection JSUnfilteredForInLoop,JSDuplicatedDeclaration
1232-
var icon_options = desktopIcons[j];
1257+
var icon_options = self.desktopIcons[j];
12331258

12341259
if (typeof icon_options['link'] !== 'undefined') {
12351260
var icon_link = '';
@@ -1290,6 +1315,21 @@
12901315
simplestorage.set('customWallpaper', dataUrl);
12911316
};
12921317

1318+
EmuOS.prototype._clearCustomWallpaper = function() {
1319+
if (typeof simplestorage !== 'undefined' && typeof simplestorage.deleteKey === 'function') {
1320+
simplestorage.deleteKey('customWallpaper');
1321+
} else if (typeof simplestorage !== 'undefined' && typeof simplestorage.set === 'function') {
1322+
simplestorage.set('customWallpaper', '');
1323+
}
1324+
1325+
this.$desktop.css({
1326+
'background-image': '',
1327+
'background-size': '',
1328+
'background-position': '',
1329+
'background-repeat': ''
1330+
});
1331+
};
1332+
12931333
EmuOS.prototype._applyCustomWallpaper = function(dataUrl) {
12941334
if (!dataUrl || typeof dataUrl !== 'string') {
12951335
return;

0 commit comments

Comments
 (0)