mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
IIFE and CSS Fixes
This commit is contained in:
@ -8,3 +8,40 @@ function setText(elementId, text) {
|
||||
var element = (typeof elementId == 'string' ? document.getElementById(elementId) : elementId);
|
||||
element.textContent = text;
|
||||
}
|
||||
// Leaving this here for now, not removing old functions to avoid breaks until full transition
|
||||
const Utility = () => {
|
||||
return {
|
||||
getText: (elementId) => {
|
||||
const element = (typeof elementId == 'string' ? document.getElementById(elementId) : elementId);
|
||||
return element.textContent;
|
||||
},
|
||||
setText: (elementId, text) => {
|
||||
const element = (typeof elementId == 'string' ? document.getElementById(elementId) : elementId);
|
||||
element.textContent = text;
|
||||
},
|
||||
getValue: (elementId) => {
|
||||
const element = (typeof elementId == 'string' ? document.getElementById(elementId) : elementId);
|
||||
console.log("setting: " + elementId + ": " + element.value);
|
||||
return element.value;
|
||||
},
|
||||
setValue: (elementId, value) => {
|
||||
const element = (typeof elementId == 'string' ? document.getElementById(elementId) : elementId);
|
||||
element.value = value;
|
||||
},
|
||||
//add class .selected to specified element
|
||||
select: (elementId) => {
|
||||
const element = (typeof elementId == 'string' ? document.getElementById(elementId) : elementId);
|
||||
element.classList.add('selected');
|
||||
},
|
||||
//remove .selected class from specified element
|
||||
deselect: (elementId) => {
|
||||
const element = (typeof elementId == 'string' ? document.getElementById(elementId) : elementId);
|
||||
element.classList.remove('selected');
|
||||
},
|
||||
//toggle the status of the .selected class on the specified element
|
||||
toggle: (elementId) => {
|
||||
const element = (typeof elementId == 'string' ? document.getElementById(elementId) : elementId);
|
||||
element.classList.toggle('selected');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user