Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
80 lines (62 loc) · 1.92 KB
/
Copy pathscript.js
File metadata and controls
80 lines (62 loc) · 1.92 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
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
var note_type = ["Title", "Header", "List", "Paragraph"];
var noteTracker = 0;
function renderTemplate() {
$('form').submit(function () {
if ($('input').val() !== '') {
input_value = $('input').val();
switch (noteTracker) {
case 0:
$('#notes').append('<h1>' + input_value + '</h1>');
break;
case 1:
$('#notes').append('<h2>' + input_value + '</h2>');
break;
case 2:
$('#notes').append('<ul><li>' + input_value + '</li></ul>');
break;
}
} else {
$('input').val('');
return false;
}
});
}
var input_focus = function () {
return document.getElementById("inputbox").focus();
}
function cycleNote() {
if (noteTracker < note_type.length - 1) {
noteTracker++;
} else {
noteTracker = 0;
}
}
function keyPress(e) {
if (e.keyCode == 9) {
e.preventDefault();
cycleNote();
$("div.note_type").html("<h1>" + note_type[noteTracker] + "</h1>");
$("div#test").html("<h1>" + noteTracker + "</h1>");
if (noteTracker === 3) {
$('form').html('<textarea id="inputbox"></textarea>');
} else {
$('form').html('<input id="inputbox" type="text"/>');
}
input_focus();
}
}
$(document).ready(function () {
document.getElementById("inputbox").focus();
$("div#test").html("<h1>" + noteTracker + "</h1>");
$("div.note_type").html("<h1>" + note_type[noteTracker] + "</h1>");
$('body').keydown(keyPress);
renderTemplate();
$("#form").validate({
rules: {
input: {
required: true,
minlength: 10
}
}
});
});S