-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
115 lines (93 loc) · 3.32 KB
/
index.html
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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Rectangle-Comment Demo</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="rectangle_comment.js"></script>
</head>
<body>
<h1>Rectangle-Comment Demo</h1>
<div class="panel">
<div class="users">
<div>Select user to comment</div>
<div class="user">
<input type="radio" class="user-radio" name="user-select" checked="checked">
<img class="icon" src="img/imaguma.png">
<div class="name">imaguma</div>
</div>
<div class="user">
<input type="radio" class="user-radio" name="user-select">
<img class="icon" src="img/nagata.png">
<div class="name">nagata</div>
</div>
</div>
<div class="resize">
<div>Resize</div>
10%
<input id="resize-range" type="range" name="num" min="10" max="100" step="5" value="100">
100%
</div>
</div>
<div class="img-contanier" style="position: relative">
<img id="example" src="example.jpg">
</div>
<script type="text/javascript">
var userName = "";
var userIcon = "";
function setUserToComment() {
for (var i=0, els=document.getElementsByClassName('user-radio'); i < els.length; i++) {
if (els[i].checked) {
var parentNode = els[i].parentNode
userName = parentNode.getElementsByClassName("name")[0].innerHTML;
userIcon = parentNode.getElementsByClassName("icon")[0].src;
break;
}
}
}
for (var i=0, els=document.getElementsByClassName('user-radio'); i < els.length; i++) {
els[i].addEventListener("click", setUserToComment);
}
setUserToComment();
function formatDate(date) {
ret = "YYYY/MM/DD hh:mm:ss";
ret = ret.replace("YYYY", date.getFullYear());
ret = ret.replace("MM", ('0' + (date.getMonth() + 1)).slice(-2));
ret = ret.replace("DD", ('0' + date.getDate()).slice(-2));
ret = ret.replace("hh", ('0' + date.getHours()).slice(-2));
ret = ret.replace("mm", ('0' + date.getMinutes()).slice(-2));
ret = ret.replace("ss", ('0' + date.getSeconds()).slice(-2));
return ret;
};
var rectangleComment = new RectangleComment("example",
//options
{
resources : {
labelAddButton : "Add"
},
onBeforeRectCreated : function(x, y, width, height, color, number, comment) {
//Persist data if necessary here.
var date = new Date();
return {
userName : userName, //option
userIcon : userIcon, //option
date : formatDate(date) //option
};
},
}
);
//Call addRect() to draw rectangles from persisted date.
rectangleComment.addRect(
50, 50, 100, 100,
"rgba(255,255,255,0.90)",
"Hello!",
"2016/01/07 10:35:24",
"imaguma",
"img/imaguma.png");
//Resize image.
var slidebar = document.getElementById('resize-range');
slidebar.addEventListener('change', function(){
rectangleComment.resizeImage(this.value);
});
</script>
</body>
</html>