-
Notifications
You must be signed in to change notification settings - Fork 0
/
teacheredit.html
64 lines (59 loc) · 2.57 KB
/
teacheredit.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
<html>
<link href="style.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery-ui.min.js"></script>
<script src="jquery-highlighttextarea-master/jquery.highlighttextarea.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/theme/jquery-ui.min.css">
<link rel="stylesheet" href="jquery-highlighttextarea-master/jquery.highlighttextarea.min.css">
<body>
<textarea class="orange-border" cols="60" rows="20" readonly=readonly id=text></textarea>
<p>
<button class="edit-button" type="button" id="Thesis">Thesis</button>
<button class="big-orange edit-button" type="button" id="Argument">Argument</button>
<button class="big-orange edit-button" type="button" id="Evidence">Evidence</button>
<ul id="results">
</ul>
<form action="teacherdocuments.html" method="GET">
<input type="submit" value="Post">
</form>
<script>
function parse(val) {
var result = "Not found",
tmp = [];
location.search
.substr(1)
.split("&")
.forEach(function (item) {
tmp = item.split("=");
if (tmp[0] === val) result = decodeURIComponent(tmp[1]);
});
return result.replace(/\+/g, " ");
}
function getTextFieldSelection() {
var textField = document.getElementById("text");
return document.getElementById("text").value.substring(textField.selectionStart, textField.selectionEnd);
}
function getHighlighted(buttonName, theColor) {
var node = document.createElement("LI");
var textNode = document.createTextNode(buttonName + ": " + getTextFieldSelection());
node.appendChild(textNode);
document.getElementById("results").appendChild(node);
var start = document.getElementById("text").selectionStart;
var end = document.getElementById("text").selectionEnd;
document.ranges.push({color: theColor, start: start, end: end});
console.log(document.ranges);
$("#text").highlightTextarea("destroy");
$("#text").highlightTextarea({
ranges: document.ranges
});
}
document.addEventListener("DOMContentLoaded", function(event) {
document.getElementById("text").value = parse("paste");
document.getElementById("Evidence").addEventListener("click", function(){getHighlighted("Evidence", "#66CCCC");});
document.getElementById("Argument").addEventListener("click", function(){getHighlighted("Argument", "#458B00");});
document.getElementById("Thesis").addEventListener("click", function(){getHighlighted("Thesis", "#FF7518");});
document.ranges = [];
});
</script>
</body>
</html>