From 06d95368952bd2a914f8056a5304a2998ce8c490 Mon Sep 17 00:00:00 2001 From: unsettledgames <47360416+unsettledgames@users.noreply.github.com> Date: Thu, 15 Jul 2021 22:26:08 +0200 Subject: [PATCH] Removed onLoad and checkCompatibility --- js/_checkCompatibility.js | 19 ------------ js/_onLoad.js | 64 --------------------------------------- js/pixel-editor.js | 53 +++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 84 deletions(-) delete mode 100644 js/_checkCompatibility.js diff --git a/js/_checkCompatibility.js b/js/_checkCompatibility.js deleted file mode 100644 index 9edfb11..0000000 --- a/js/_checkCompatibility.js +++ /dev/null @@ -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!'); diff --git a/js/_onLoad.js b/js/_onLoad.js index 6d649fd..e69de29 100644 --- a/js/_onLoad.js +++ b/js/_onLoad.js @@ -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); - }); - } -}; \ No newline at end of file diff --git a/js/pixel-editor.js b/js/pixel-editor.js index 9cbcb75..91fde5a 100644 --- a/js/pixel-editor.js +++ b/js/pixel-editor.js @@ -64,4 +64,55 @@ //=include _featureToggles.js // Controls execution of this preset module -PresetModule.instrumentPresetMenu(); \ No newline at end of file +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); + }); + } +}; \ No newline at end of file