Removed onLoad and checkCompatibility

This commit is contained in:
unsettledgames 2021-07-15 22:26:08 +02:00
parent f76d05bffa
commit 06d9536895
3 changed files with 52 additions and 84 deletions

View File

@ -1,19 +0,0 @@
/////=include libraries/bowser.js
function closeCompatibilityWarning () {
document.getElementById('compatibility-warning').style.visibility = 'hidden';
}
console.log('checking compatibility');
//check browser/version
if ((bowser.msie && bowser.version < 11) ||
(bowser.firefox && bowser.version < 28) ||
(bowser.chrome && bowser.version < 29) ||
(bowser.msedge && bowser.version < 12) ||
(bowser.safari && bowser.version < 9) ||
(bowser.opera && bowser.version < 17) )
//show warning
document.getElementById('compatibility-warning').style.visibility = 'visible';
else alert(bowser.name+' '+bowser.version+' is fine!');

View File

@ -1,64 +0,0 @@
//when the page is done loading, you can get ready to start
window.onload = function () {
featureToggles.onLoad();
currentTool.updateCursor();
//check if there are any url parameters
if (window.location.pathname.replace('/pixel-editor/','').length <= 1) {
console.log('no url parameters were found');
//show splash screen
Dialogue.showDialogue('splash', false);
}
//url parameters were specified
else {
console.log('loading preset from url parameters', window.location.pathname);
let args = window.location.pathname.split('/');
let paletteSlug = args[2];
let dimentions = args[3];
//fetch palette via lospec palette API
fetch('https://lospec.com/palette-list/'+paletteSlug+'.json')
.then(response => response.json())
.then(data => {
//palette loaded successfully
console.log('loaded palette', data);
palettes[paletteSlug] = data;
palettes[paletteSlug].specified = true;
//refresh list of palettes
document.getElementById('palette-menu-splash').refresh();
//if the dimentions were specified
if (dimentions && dimentions.length >= 3 && dimentions.includes('x')) {
let width = dimentions.split('x')[0];
let height = dimentions.split('x')[1];
//create new document
Startup.newPixel(width, height);
}
//dimentions were not specified -- show splash screen with palette preselected
else {
//show splash
Dialogue.showDialogue('new-pixel', false);
}
})
//error fetching url (either palette doesn't exist, or lospec is down)
.catch((error) => {
console.warn('failed to load palette "'+paletteSlug+'"', error);
//proceed to splash screen
Dialogue.showDialogue('splash', false);
});
}
};

View File

@ -64,4 +64,55 @@
//=include _featureToggles.js
// Controls execution of this preset module
PresetModule.instrumentPresetMenu();
PresetModule.instrumentPresetMenu();
//when the page is done loading, you can get ready to start
window.onload = function () {
featureToggles.onLoad();
currentTool.updateCursor();
//check if there are any url parameters
if (window.location.pathname.replace('/pixel-editor/','').length <= 1) {
//show splash screen
Dialogue.showDialogue('splash', false);
}
//url parameters were specified
else {
let args = window.location.pathname.split('/');
let paletteSlug = args[2];
let dimentions = args[3];
//fetch palette via lospec palette API
fetch('https://lospec.com/palette-list/'+paletteSlug+'.json')
.then(response => response.json())
.then(data => {
//palette loaded successfully
palettes[paletteSlug] = data;
palettes[paletteSlug].specified = true;
//refresh list of palettes
document.getElementById('palette-menu-splash').refresh();
//if the dimentions were specified
if (dimentions && dimentions.length >= 3 && dimentions.includes('x')) {
let width = dimentions.split('x')[0];
let height = dimentions.split('x')[1];
//create new document
Startup.newPixel(width, height);
}
//dimentions were not specified -- show splash screen with palette preselected
else {
//show splash
Dialogue.showDialogue('new-pixel', false);
}
})
//error fetching url (either palette doesn't exist, or lospec is down)
.catch((error) => {
console.warn('failed to load palette "'+paletteSlug+'"', error);
//proceed to splash screen
Dialogue.showDialogue('splash', false);
});
}
};