Revert "So I heard you like Javascript....."

This reverts commit 5e5ca1a5c2.
This commit is contained in:
IK3I
2018-01-25 23:56:08 -06:00
parent 5e5ca1a5c2
commit 124a043e99
3 changed files with 51 additions and 46 deletions
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>Save Instructions</title>
</head>
<body>
<h2>Save Instructions</h2>
Due to the primitive nature of IE8, this file must be saved manually. To do so, simply follow these steps. (() indicates windows specific instuctions)
<ol>
<li>Click anywhere below the line</li>
<li>Use the Select All shortcut (ctrl+A)</li>
<li>Use the Copy shortcut (ctrl+C)</li>
<li>Create a new text document (right click desktop or explorer -> new text document)</li>
<li>Click the document and paste to it (ctrl+v)</li>
<li>Save the document with the extension .html instead of .txt</li>
</ol>
<hr>
</body>
</html>
+31 -46
View File
@@ -871,40 +871,19 @@ $(function() {
setCookie('pingdisabled', (opts.pingDisabled ? 'true' : 'false'), 365);
});
$('#saveLog').click(function(e) { //note that this will only work in browsers supporting CORS (IE 8+ and literally every alternative)
var makeHaste = function(txt) { //creates a haste and returns the url
if (window.XMLHttpRequest) {
hasteRequest = new XMLHttpRequest();
} else {
hasteRequest = new ActiveXObject("Microsoft.XMLHTTP");
$('#saveLog').click(function(e) {
var openWindow = function (content) { //opens a window
var win;
try {
win = window.open('', 'RAW Chat Log', 'toolbar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, width=1200, height=800, top='+(screen.height-400)+', left='+(screen.width-840));
} catch (e) {
return;
}
hasteRequest.open('POST', 'http://localhost:7777/documents', true);
hasteRequest.onerror = function () {
internalOutput('Error in CORS request.');
};
hasteRequest.onreadystatechange = function() {
if(hasteRequest.readyState == XMLHttpRequest.DONE) {
if(hasteRequest.responseText != '') {
var data = JSON.parse(hasteRequest.responseText);
if(data.key) {
var d = new Date();
var timestamp = d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate()+' '+
d.getHours()+':'+d.getMinutes()+':'+d.getSeconds();
internalOutput('Chat log generated. Please click the link below to view the raw data.');
internalOutput('To save your log: Open it, right click anywhere on the page, then select Save As.<br> \
For best results, save the file as [name].html then open it in any browser.');
internalOutput('<a href="http://localhost:7777/raw/'+data.key+'">Chat Log: '+timestamp+'</a>');
} else {
internalOutput('Error in CORS Response, no key provided Response: '+JSON.stringify(hasteRequest.responseText));
}
} else {
internalOutput('Error in CORS Response, null sting recieved')
}
}
};
hasteRequest.send(txt);
}
if (win && win.document && window.document.body) {
win.document.body.innerHTML = content;
return win;
}
};
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
@@ -914,30 +893,36 @@ $(function() {
// synchronous requests are depricated in modern browsers
xmlHttp.open('GET', 'browserOutput.css', true);
xmlHttp.onload = function () {
if (xmlHttp.status == 200) { // request successful
xmlHttp.onload = function (e) {
if (xmlHttp.status === 200) { // request successful
// Generate Log
var saved = '<style>'+xmlHttp.responseText+'</style>';
saved += $messages.html();
saved = saved.replace(/&/g, '&amp;');
saved = saved.replace(/</g, '&lt;');
//Tell the user something is happening
internalOutput('Generating Chat Log, Note that size can affect prep time.');
// Generate final output and send off to hastebin
var finalText = '<head><title>Chat Log</title></head>' + saved
makeHaste(finalText);
// Generate final output and open the window
var finalText = '<head><title>Chat Log</title></head> \
<iframe src="saveInstructions.html" id="instructions" style="border:none;" height="220" width="100%"></iframe>'+
saved
openWindow(finalText);
} else { // request returned http error
internalOutput('Style Doc Retrieve Error: '+xmlHttp.statusText);
openWindow('Style Doc Retrieve Error: '+xmlHttp.statusText);
}
}
// Request error handler
xmlHttp.onerror = function () {
internalOutput('XMLHttpRequest Error: '+xmlHttp.statusText);
// timeout and request errors
xmlHttp.timeout = 300;
xmlHttp.ontimeout = function (e) {
openWindow('XMLHttpRequest Timeout');
}
xmlHttp.onerror = function (e) {
openWindow('XMLHttpRequest Error: '+xmlHttp.statusText);
}
// css needs special headers
xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlHttp.send(null);
xmlHttp.send(null);
});
$('#highlightTerm').click(function(e) {
+1
View File
@@ -12,6 +12,7 @@ var/list/chatResources = list(
"goon/browserassets/css/font-awesome.css",
"goon/browserassets/css/browserOutput.css",
"goon/browserassets/json/unicode_9_annotations.json",
"goon/browserassets/html/saveInstructions.html"
)
/var/savefile/iconCache = new /savefile("data/iconCache.sav")