-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCursor2.js
More file actions
46 lines (40 loc) · 1.47 KB
/
Cursor2.js
File metadata and controls
46 lines (40 loc) · 1.47 KB
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
// Declare an array of kewords for cursor property
// Reference ☞ https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
var cursorTypes = [
["auto", "default", "none"],
["context-menu", "help", "pointer", "progress", "wait"],
["cell", "crosshair", "text", "vertical-text"],
["alias", "copy", "move"],
["no-drop", "not-allowed", "grab", "grabbing"],
["n-resize", "e-resize", "s-resize", "w-resize"],
["ne-resize", "nw-resize", "se-resize", "sw-resize"],
["ew-resize", "ns-resize", "nesw-resize", "nwse-resize"],
["zoom-in", "zoom-out"]
]
// A function to generate span elements with inner text and cursor style
function genBoxes(cursorTypes)
{
// Declare an object to indicate the element where new elements will be appended
var obj = document.getElementById("box")
// Loop for the array cursorTypes
for (r in cursorTypes)
{
for (el in cursorTypes[r])
{
// Test : ok
// console.log(cursorTypes[r][el])
// Generate a box with style
var newBox = document.createElement("span")
// newBox.className = cursorTypes[r][el] // not needed
newBox.innerText = cursorTypes[r][el]
newBox.style.cursor = cursorTypes[r][el]
// Append it
obj.appendChild(newBox)
}
// Line replacement
var br = document.createElement("br")
obj.appendChild(br)
}
}
// Run
genBoxes(cursorTypes)