-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustm.js
152 lines (144 loc) · 4.59 KB
/
custm.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
var dataUri_var = ""
var bgcolor_rgb_set = ""
//data set
/*
var design = {};
design.color = {
bg: 'gray'
};
chrome.storage.local.set(design, function() {
console.log('stored');
});
*/
/*bg button cllick**************************************************/
document.getElementById("bg_red_id").onclick = function(){ //bg_red button click
bgcolor_rgb_set = "red"
}
document.getElementById("bg_orange_id").onclick = function(){
bgcolor_rgb_set = "orange"
}
document.getElementById("bg_yellow_id").onclick = function(){
bgcolor_rgb_set = "yellow"
}
document.getElementById("bg_yellow-green_id").onclick = function(){
bgcolor_rgb_set = "yellow-green"
}
document.getElementById("bg_green_id").onclick = function(){
bgcolor_rgb_set = "green"
}
document.getElementById("bg_melon_id").onclick = function(){
bgcolor_rgb_set = "melon"
}
document.getElementById("bg_light-blue_id").onclick = function(){
bgcolor_rgb_set = "light-blue"
}
document.getElementById("bg_blue_id").onclick = function(){
bgcolor_rgb_set = "blue"
}
document.getElementById("bg_purple_id").onclick = function(){
bgcolor_rgb_set = "purple"
}
document.getElementById("bg_gray_id").onclick = function(){
bgcolor_rgb_set = "gray"
}
document.getElementById("bg_white_id").onclick = function(){
bgcolor_rgb_set = "white"
}
document.getElementById("bg_brack_id").onclick = function(){
bgcolor_rgb_set = "brack"
}
/*bg button cllick end**********************************************/
document.getElementById("picture_set_button").onclick = function(){
var picture = document.getElementById("content_picture_set").value;
document.getElementById("content_picture").innerHTML = '<img id="'+picture+'"src="Imgs/'+picture+'.png"/>';
document.getElementById(picture).ondragstart = function(){onDragStart(event)}
}
/*save**************************************************************/
document.getElementById("save").onclick = function(){
var design = {};
design.color = {
bg: bgcolor_rgb_set, //background color
bg_img: dataUri_var, //background picture
box1:get_id("DropArea1"),
box2:get_id("DropArea2"),
box3:get_id("DropArea3"),
box4:get_id("DropArea4"),
box5:get_id("DropArea5"),
box6:get_id("DropArea6"),
};
chrome.storage.local.set(design, function() {
console.log('stored');
});
location.reload();
}
function get_id(id){
return document.getElementById(id).innerHTML.slice(document.getElementById(id).innerHTML.indexOf('"')+1,document.getElementById(id).innerHTML.indexOf('"',10))
}
/*save end**********************************************************/
//data get
///*
var defaults = {};
defaults.color = {
bg: 'no data',
bg_img: 'no data',
};
chrome.storage.local.get(defaults, function(items) {
console.log(items.color.bg);
var backcolor = document.getElementById('bgcolor');
//bgcolor***********************************/
if(items.color.bg == "red"){
bgcolor_rgb = "#ff0000"
}else
if(items.color.bg == "orange"){
bgcolor_rgb = "#ff8000"
}else
if(items.color.bg == "yellow"){
bgcolor_rgb = "#ffff00"
}else
if(items.color.bg == "yellow-green"){
bgcolor_rgb = "#80ff00"
}else
if(items.color.bg == "green"){
bgcolor_rgb = "#00ff00"
}else
if(items.color.bg == "melon"){
bgcolor_rgb = "#00ff80"
}else
if(items.color.bg == "light-blue"){
bgcolor_rgb = "#00ffff"
}else
if (items.color.bg == "blue"){
bgcolor_rgb = "#0000ff"
}else
if (items.color.bg == "purple"){
bgcolor_rgb = "#ff00ff"
}else
if (items.color.bg == "gray"){
bgcolor_rgb = "#aaaaaa"
}else
if (items.color.bg == "white"){
bgcolor_rgb = "#ffffff"
}else
if (items.color.bg == "black"){
bgcolor_rgb = "#000000"
}else{
bgcolor_rgb = "#000000"
}
backcolor.style.backgroundColor=bgcolor_rgb;//bgcolor style set
backcolor.style.backgroundImage="url("+items.color.bg_img+")";// bgcolor imgs set
/********************************************/
});
//make picture into data uri
document.getElementById( "target" ).addEventListener( "change", function() {
var fileList = this.files ;
for( var blob, i=0,l=fileList.length; l>i; i++ ) {
blob = fileList[i] ;
var fileReader = new FileReader() ;
fileReader.onload = function() {
var dataUri = this.result ;
console.log(dataUri)
dataUri_var = dataUri
}
fileReader.readAsDataURL( fileList[i] ) ;
}
} ) ;