mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Added Color class
- Added Color class to make color representation and convertions more uniform - Replaced standard convertions with Color.convertion - Removed _algorithms.js, _deleteColor.js, ajax.js and the other convertion files - Fixed bug in ColorModule, moved replaceAllOfColor to ColorModule as well as deleteColor
This commit is contained in:
16
js/Util.js
16
js/Util.js
@ -1,5 +1,11 @@
|
||||
// Acts as a public static class
|
||||
class Util {
|
||||
/** Returns elementOrElementId if the argument is already an element, otherwise it finds
|
||||
* the element by its ID (given by the argument) and returns it
|
||||
*
|
||||
* @param {*} elementOrElementId The element to return, or the ID of the element to return
|
||||
* @returns The desired element
|
||||
*/
|
||||
static getElement(elementOrElementId) {
|
||||
if (typeof(elementOrElementId) == "object") {
|
||||
return elementOrElementId;
|
||||
@ -11,25 +17,29 @@ class Util {
|
||||
console.log("Type not supported: " + typeof(elementOrElementId));
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the text content of the element with ID elementId
|
||||
static getText(elementId) {
|
||||
return Util.getElement(elementId).textContent;
|
||||
}
|
||||
|
||||
// Sets the text content of the element with ID elementId
|
||||
static setText(elementId, text) {
|
||||
Util.getElement(elementId).textContent = text;
|
||||
}
|
||||
|
||||
// Gets the value of the element with ID elementId
|
||||
static getValue(elementId) {
|
||||
return Util.getElement(elementId).value;
|
||||
}
|
||||
|
||||
// Sets the value of the element with ID elementId
|
||||
static setValue(elementId, value) {
|
||||
Util.getElement(elementId).value = value;
|
||||
}
|
||||
|
||||
//add class .selected to specified element
|
||||
static select(elementId) {
|
||||
Util.getElement(elementId).classList.add('selected');
|
||||
}
|
||||
|
||||
//remove .selected class from specified element
|
||||
static deselect(elementId) {
|
||||
Util.getElement(elementId).classList.remove('selected');
|
||||
|
Reference in New Issue
Block a user