forked from mkam423/chatApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.html
More file actions
108 lines (100 loc) · 4.02 KB
/
view.html
File metadata and controls
108 lines (100 loc) · 4.02 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
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
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<style>
body{
padding-left: 50px;
padding-right: 50px;
}
textarea{
font-family: "Courier New", monospace;
font size: 14px;
white-space:pre-wrap;
}
.header{
text-align: center;
padding-top: 50px;
padding-bottom: 50px;
font-family: "Courier", monospace;
font-size: 48px;
font-weight: bold;
}
.subheader{
font-family: "Courier", monospace;
font-weight: bold;
}
</style>
</head>
<body>
<h1 class="header"> Viewing {{.Title}}.txt </h1>
<div class="subheader row">
<div class="col"><h2><b>Code</b></h2></div>
<div class="col"><h2><b>Notes</b></h2></div>
</div>
<div class="row">
<textarea class="col" id="response" rows="20" readonly> Pulling updated image...</textarea>
<textarea class="col" id="notes" rows="20" placeholder="Place for notes..." autofocus></textarea>
</div>
<div class="row">
<div class="col">
<div>*Note: If you want to copy any/all of the text being viewed, use button to pause the constant refresh. <br/> </div>
<div><b>Refresh status:</b>
<p id="statusOn" style="color:#3ae500; font-weight: bold;">ON</p>
<p id="statusOff" style="color:#f70300; font-weight: bold;">OFF</p>
</div>
<button class="btn btn-info" id="refreshStatus" onclick="toggleRefresh()" type="button">Pause refresh</button> <br/><br/>
</div>
<div class="col">
<div> Use buttons below to save input to text files. </div>
<button class="btn btn-primary" id="saveCode" onclick="download('code.txt', 'response')" type="button">Save Code</button>
<button class="btn btn-primary" id="saveNotes" onclick="download('notes.txt', 'notes')" type="button">Save Notes</button>
<div id="dl" visibility="none"><a id="link"></a></div>
</div>
</div>
<script>
function download(fileName, bodyId) {
var data = document.getElementById(bodyId).value
var a = document.getElementById("link");
var file = new Blob([data], {type: 'text/plain'});
a.innerText = "Download " + fileName
a.href = URL.createObjectURL(file);
a.download = fileName;
document.getElementById('dl').style.display = "block"
}
function toggleRefresh(){
if (refreshStatus){
refreshStatus = false //Stop refresh
document.getElementById("refreshStatus").innerText = "Resume refresh"
document.getElementById('statusOn').style.display = "none";
document.getElementById('statusOff').style.display = "block";
} else {
refreshStatus = true //Resume refresh
document.getElementById("refreshStatus").innerText = "Pause refresh"
document.getElementById('statusOn').style.display = "block";
document.getElementById('statusOff').style.display = "none";
}
}
function refresh(){
if(refreshStatus){
var xhr = new XMLHttpRequest()
var path = "/refresh/" + {{.Title}}
xhr.onreadystatechange = function() {
if (this.status == 200) {
document.getElementById("response").innerText = this.responseText
}
};
xhr.open("GET", path, true)
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
xhr.send()
}
}
//Startup commands
console.log("Hello in view.html")
document.getElementById('statusOff').style.display = "none";
document.getElementById('dl').style.display = "none";
var refreshStatus=true;
setInterval(refresh, 100)
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
</body>
</html>