-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
78 lines (70 loc) · 2.23 KB
/
script.js
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
"use strict";
$('#menu').load('parts/toolber.html');
let indentSize = Number(localStorage.getItem("DPLA_EDITOR_INDENT_SIZE")) || 2;
$('#editor-file-input').on('change', function(e) {
const file = $(this).files[0];
const fileReader = new FileReader();
fileReader.onload = function() {
codeArea.val(fileReader.result);
}
fileReader.readAsText(file);
});
function myFunction() {
return "null";
}
document.getElementById("codearea").value = 'Lang[“DPLA”]\nEvent[onLaunch]:(\n command_print[“Hello world!”]\n)';
function quit(){
if (window.confirm('Are you sure you want to quit? You will lose your work if you dont save.')){
javascript:window.open('','_self').close();
}
}
document.onkeydown = function(e) {
if (e.ctrlKey && e.which == 81){ //q
quit()
}
}
document.onkeydown = function(e) {
if (e.ctrlKey && e.which == 68){ //d
window.open('https://dpla-s.github.io/assets/DPLA.pdf','_newtab');
}
}
document.onkeydown = function(e) {
if (e.ctrlKey && e.which == 82){ //r
runcode()
}
}
function clearcode(){
if (window.confirm('Are you sure you want to clear your code? You will lose your work if you dont save.')){
document.getElementById("codearea").value = "";
}
}
function soon(){
alert('Coming soon, but thanks for your curiosity.')
}
function textsize(){
var size=prompt('Number')
document.head.innerHTML+="<style>#codearea{font-size:"+size+"px;}</style>"
}
/*Null*/
function download(){
var name = prompt('Name the File')
var text = document.getElementById("codearea").value;
text = text.replace(/\n/g, "\r\n"); // To retain the Line breaks.
var blob = new Blob([text], { type: "text/plain"});
var anchor = document.createElement("a");
anchor.download = ""+name+".dpla";
anchor.href = window.URL.createObjectURL(blob);
anchor.target ="_blank";
anchor.style.display = "none"; // just to be safe!
document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);
}
/*End of Null*/
function runcode(){
var hrefValue = document.getElementById("codearea").value;
window.open('https://dpla-s.github.io/Beta-Editor-CSS/run#'+hrefValue+'', '_newtab');
}
function hidesplash(){
document.getElementById('splash').style.display = 'none';
}