diff --git a/js/ColorModule.js b/js/ColorModule.js index 35ebb05..cbf5fe1 100644 --- a/js/ColorModule.js +++ b/js/ColorModule.js @@ -347,8 +347,8 @@ const ColorModule = (() => { */ function createColorPalette(paletteColors) { //remove current palette - while (colorsMenu.childCount > 0) - colorsMenu.children[0].parentElement.remove(); + while (colorsMenu.childElementCount > 1) + colorsMenu.children[0].remove(); var lightestColor = new Color("hex", '#000000'); var darkestColor = new Color("hex", '#ffffff'); @@ -399,7 +399,7 @@ const ColorModule = (() => { if (!isPixelEmpty(imageData[j])) { let color = imageData[j]+','+imageData[j + 1]+','+imageData[j + 2]; - if (!colors[color]) { + if (!colors[color] && imageData[j + 3] != 0) { colors[color] = new Color("rgb", imageData[j], imageData[j + 1], imageData[j + 2]).rgb; //don't allow more than 256 colors to be added @@ -421,6 +421,8 @@ const ColorModule = (() => { } } + console.log("palette"); + //create palette from colors array createColorPalette(colorPaletteArray); } diff --git a/js/FileManager.js b/js/FileManager.js index c3582b9..194654c 100644 --- a/js/FileManager.js +++ b/js/FileManager.js @@ -1,5 +1,3 @@ -// TODO: the button to load a palette disappeared for some reason, should add it back - const FileManager = (() => { // Binding the browse holder change event to file loading @@ -109,9 +107,8 @@ const FileManager = (() => { // Getting the extension let extension = (fileName.substring(fileName.lastIndexOf('.')+1, fileName.length) || fileName).toLowerCase(); - // I didn't write this check and I have no idea what it does if (browseHolder.files && browseHolder.files[0]) { - // Btw, checking if the extension is supported + // Checking if the extension is supported if (extension == 'png' || extension == 'gif' || extension == 'lpe') { // If it's a Lospec Pixel Editor tm file, I load the project if (extension == 'lpe') { @@ -130,12 +127,14 @@ const FileManager = (() => { function openFile() { //load file var fileReader = new FileReader(); + fileReader.onload = function(e) { var img = new Image(); + img.onload = function() { //create a new pixel with the images dimentions - EditorState.switchMode('Advanced'); Startup.newPixel(this.width, this.height); + EditorState.switchMode('Advanced'); //draw the image onto the canvas currentLayer.context.drawImage(img, 0, 0); diff --git a/js/checkCompatibilityPixelEditor.js b/js/checkCompatibilityPixelEditor.js index b440d25..f4463fa 100644 --- a/js/checkCompatibilityPixelEditor.js +++ b/js/checkCompatibilityPixelEditor.js @@ -9,7 +9,5 @@ if ( (!bowser.mobile && !bowser.tablet) ) console.log("compatibility check passed"); - - //show warning else document.getElementById("compatibility-warning").style.visibility = "visible";