-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
38 lines (35 loc) · 1.2 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function openImage(src){
document.getElementById("imgSrcForm").setAttribute("style","display:none;");
document.getElementById("mainImageEditArea").removeAttribute("style");
document.getElementById("mainImageBackgroundImage").innerHTML = "#mainImage {background-image: url(" + src + ");}";
}
var editValues = [];
var editNames = [];
var editUnits = [];
window.onload = function(){
var allEditInputs = document.getElementById("imageEditing").getElementsByTagName("input");
for(var i = 0;i < allEditInputs.length;i++){
allEditInputs[i].setAttribute("id",i);
editNames.push(allEditInputs[i].getAttribute("class"));
editUnits.push(allEditInputs[i].getAttribute("unit"));
if(allEditInputs[i].value == ""){
allEditInputs[i].value = 0;
}
editValues.push(allEditInputs[i].value);
allEditInputs[i].oninput = function(){
if(this.value == ""){
this.value = 0;
}
editValues[this.getAttribute("id")] = this.value;
updateFilters();
}
}
}
function updateFilters(){
var cssCode = "#mainImage {filter: ";
editValues.forEach(function(item,index){
cssCode += editNames[index] + "(" + item + editUnits[index] + ") ";
});
cssCode += ";}";
document.getElementById("mainImageEdits").innerHTML = cssCode;
}