-
Notifications
You must be signed in to change notification settings - Fork 3
/
bigBoard.html
147 lines (140 loc) · 3.8 KB
/
bigBoard.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
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
<!-- By Paul Mazak. Beta version 0.1. -->
<html>
<head>
<style type="text/css">
body {
margin: 4px
}
.drag {
position: relative;
cursor: pointer;
z-index: 100;
background-color: #FFFFDD;
border: 1px solid #000000;
width: 150px;
height: 150px;
overflow-x: hidden;
overflow-y: hidden;
font-weight: bold;
}
.edit {
position: relative;
cursor: pointer;
z-index: 100;
background-color: #DDFFDD;
border: 1px solid #000000;
width: 150px;
height: 150px;
overflow: auto;
font-weight: bold;
}
</style>
<script type="text/javascript" src="https://github.com/pmazak/bigBoard/raw/master/scripts/json.js"></script>
<script type="text/javascript" src="https://github.com/pmazak/bigBoard/raw/master/scripts/cookies.js"></script>
<script type="text/javascript">
/***********************************************
* Drag and Drop Script: © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
var dragobject={
z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : null, dragapproved : 0,
initialize:function(){
document.onmousedown=this.drag
document.onmouseup=function(){this.dragapproved=0}
},
drag:function(e){
var evtobj=window.event? window.event : e
this.targetobj=window.event? event.srcElement : e.target
if (evtobj.ctrlKey==1 && evtobj.altKey==1) {
removePostIt(this.targetobj);
}
else if (evtobj.ctrlKey==1) {
this.targetobj.className=(this.targetobj.className=="drag" ? "edit" : "drag");
}
if (this.targetobj.className=="drag"){
this.dragapproved=1
if (isNaN(parseInt(this.targetobj.style.left))){this.targetobj.style.left=0}
if (isNaN(parseInt(this.targetobj.style.top))){this.targetobj.style.top=0}
this.offsetx=parseInt(this.targetobj.style.left)
this.offsety=parseInt(this.targetobj.style.top)
this.x=evtobj.clientX
this.y=evtobj.clientY
if (evtobj.preventDefault)
evtobj.preventDefault()
document.onmousemove=dragobject.moveit
}
},
moveit:function(e){
var evtobj=window.event? window.event : e
if (this.dragapproved==1){
this.targetobj.style.left=this.offsetx+evtobj.clientX-this.x+"px"
this.targetobj.style.top=this.offsety+evtobj.clientY-this.y+"px"
saveState(this.targetobj);
return false
}
}
};
dragobject.initialize();
function removePostIt(elem)
{
eraseCookie(elem.id);
elem.style.display = "none";
}
function newPostIt()
{
var newPostIt = document.createElement("textarea");
newPostIt.id="a"+(new Date()).getTime();
newPostIt.className="drag";
newPostIt.value = "";
document.body.appendChild(newPostIt);
//TODO:needed?
allIds[allIds.length] = newPostIt.id;
saveState(newPostIt);
}
function saveState(elem)
{
if (!elem.id)
{
return;
}
var cookieText = elem.style.left + COOKIE_DELIMITER + elem.style.top + COOKIE_DELIMITER + elem.value;
createCookie(elem.id, cookieText, 999);
}
function loadState(id)
{
var cookieText = readCookie(id);
if (cookieText)
{
var elem = document.createElement("textarea");
elem.id = id;
elem.className="drag";
var attributes = cookieText.split(COOKIE_DELIMITER);
elem.style.left=attributes[0];
elem.style.top=attributes[1];
elem.value=attributes[2] || "";
document.body.appendChild(elem);
}
}
function save(e){
var evtobj=window.event? window.event : e
var targetobj=window.event? event.srcElement : e.target
saveState(targetobj);
}
document.onkeyup=save;
</script>
</head>
<body>
<table width="100%"><tr>
<td width="33%"><a href="javascript:newPostIt()">new</a></td><td width="33%"><u>edit</u> = Ctrl+click</td><td width="33%"><u>delete</u> = Ctrl+Alt+click</td>
</tr></table>
<hr/>
</body>
<script type="text/javascript">
var allIds = readCookieNames();
for (var i=0; i<allIds.length; i++)
{
loadState(allIds[i]);
}
</script>
</html>