-
Notifications
You must be signed in to change notification settings - Fork 2
/
love.js
97 lines (76 loc) · 2.7 KB
/
love.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
const msg = document.querySelector('.msg');
var changeButton1 = document.getElementById("pet-change1");
var changeButton2 = document.getElementById("pet-change2");
var changeButton3 = document.getElementById("pet-change3");
var changeButton4 = document.getElementById("pet-change4");
var changeButton5 = document.getElementById("pet-change5");
changeButton1.addEventListener('click', onChange1);
changeButton2.addEventListener('click', onChange2);
changeButton3.addEventListener('click', onChange3);
changeButton4.addEventListener('click', onChange4);
changeButton5.addEventListener('click', onChange5);
const changeSubmit = document.getElementById("pet-submit");
var petName = "Ava";
function newMsg(chineseName, image, love){
let newContent="";
newContent+=
`<div>`+
`<h3 id="pet-name"> ${chineseName} </h3>` +
`<img height="100" style="background-position:left" src=${image} />`+`</div>`+
`</div> <div class="row"> <div class="column"> <h1 style="color: red;"> ♥️ </h1> `+
`</div> <div class="column"> <div class="progress-container">`+
`<progress id="love-progress" value=${love} max="100"></progress>`+
`</div></div></div>`;
return newContent;
}
function onChange1(e) {
e.preventDefault();
petName = "Ava";
chineseName = "向晚";
let image = "/images/" + petName + "Pet128.png";
let love = 10;
let newContent = newMsg(chineseName,image,love);
msg.innerHTML = newContent;
}
function onChange2(e) {
e.preventDefault();
petName = "Bella";
chineseName = "贝拉";
let image = "/images/" + petName + "Pet128.png";
let love = 10;
let newContent = newMsg(chineseName,image,love);
msg.innerHTML = newContent;
}
function onChange3(e) {
e.preventDefault();
petName = "Carol";
chineseName = "珈乐";
let image = "/images/" + petName + "Pet128.png";
let love = 10;
let newContent = newMsg(chineseName,image,love);
msg.innerHTML = newContent;
}
function onChange4(e) {
e.preventDefault();
petName = "Diana";
chineseName = "嘉然";
let image = "/images/" + petName + "Pet128.png";
let love = 10;
let newContent = newMsg(chineseName,image,love);
msg.innerHTML = newContent;
}
function onChange5(e) {
e.preventDefault();
petName = "Eileen";
chineseName = "乃琳";
let image = "/images/" + petName + "Pet128.png";
let love = 10;
let newContent = newMsg(chineseName,image,love);
msg.innerHTML = newContent;
}
changeSubmit.onclick= function(e) {
e.preventDefault();
chrome.tabs.query({active: true, currentWindow: true},function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {getName: petName});
});
}