-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtexPROCESS.html
More file actions
175 lines (167 loc) · 6.14 KB
/
texPROCESS.html
File metadata and controls
175 lines (167 loc) · 6.14 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<title>MI texPROCESS</title>
<script>
(function(window){
window.htmlentities = {
/**
* Converts a string to its html characters completely.
*
* @param {String} str String with unescaped HTML characters
**/
encode : function(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
if(parseInt(str[i].charCodeAt())<0xff){
buf.unshift(str[i]);
}else{
buf.unshift('&#' + str[i].charCodeAt() + ';');
}
}
return buf.join('');
},
/**
* Converts an html characterSet into its original character.
*
* @param {String} str htmlSet entities
**/
decode : function(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
}
};
})(window);
isReadOnly = false;
isCol = false;
function readFile(event, val) {
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
document.getElementById('main-body').innerHTML = e.target.result;
document.getElementById("download-name").value = val.replace("C:\\fakepath\\", "").replace(".mdoc","");
};
reader.readAsText(file);
}
}
function downloadRich() {
var text = document.getElementById("main-body").innerHTML;
var path = document.getElementById("download-name").value + ".mdoc";
var blob = new Blob([text], { type: "text/plain"});
var anchor = document.createElement("a");
anchor.download = path;
anchor.href = window.URL.createObjectURL(blob);
anchor.target ="_blank";
anchor.style.display = "none";
document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);
}
</script>
<body style="overflow: hidden;"></body>
<input type="text" id="download-name" placeholder="Document Name" value="Untitled">
<button onclick="downloadRich()">⭳</button>
<input type="file" id="fileInput" onchange="readFile(event, this.value)">
<button onclick="shareInput=document.getElementById('share');shareInput.style='';shareInput.value='data:text/html,' + encodeURIComponent(window.htmlentities.encode(document.getElementById('main-body').innerHTML))">Share</button>
<input type="text" id="share" style="display:none;">
<br>
Justify:
<button onclick="document.execCommand('justifyLeft', false, null);">
←
</button>
<button onclick="document.execCommand('justifyCenter', false, null);">-</button>
<button onclick="document.execCommand('justifyRight', false, null);">
→</button
>
|
<button onclick="document.execCommand('bold',false,null);"><b>B</b></button>
<button onclick="document.execCommand('italic',false,null);"><i>i</i></button>
<button onclick="document.execCommand('underline',false,null);"><u>u</u></button
>
<button id="foreColButton" style="color:red;" onclick="fore=document.getElementById('foreColor');if(!isCol){fore.style='';isCol=true}else{fore.style='display:none;';isCol=false;document.execCommand('foreColor',false,fore.value);document.getElementById('foreColButton').style='color:'+fore.value+';'}">A</button>
<input type="color" id="foreColor" style="display:none;" value="#ff0000">
<button id="backColButton" style="background-color:red;" onclick="fore=document.getElementById('foreColor');if(!isCol){fore.style='';isCol=true}else{fore.style='display:none;';isCol=false;document.execCommand('backColor',false,fore.value);document.getElementById('backColButton').style='background-color:'+fore.value+';'}">A</button>
|
<select id="paraTypes" onchange="document.execCommand('formatBlock',false,this.value);this.value=''">
<option value="">Paragraph Types</option>
<optgroup label="Headings">
<option value="h1">Title</option>
<option value="h2">Subtitle</option>
<option value="h3">Heading 3</option>
<option value="h4">Heading 4</option>
<option value="h5">Heading 5</option>
<option value="h6">Small Print</option>
</optgroup>
<optgroup label="Body">
<option value="pre">Block-code</option>
<option value="p">Paragraph</option>
</optgroup>
</select>
<button onclick="document.execCommand('insertUnorderedList',false,null)">∙</button>
<button onclick="document.execCommand('insertOrderedList',false,null)">1.</button>
|
<button onclick="document.execCommand('createLink',false,prompt('URL to open: '))">🔗</button>
<button onclick="document.execCommand('insertImage',false,prompt('Image URL: '))">🖼</button>
|
<select id="fonts" onchange="document.execCommand('fontName',false,this.value);this.value='';this.style='font-family:'+this.value;">
<option value="">Fonts</option>
<optgroup label="Basic Fonts">
<option value="sans-serif">Sans-Serif</option>
<option value="serif">Serif</option>
<option value="monospace">Monospace</option>
<option value="cursive">Handwritting</option>
</optgroup>
<optgroup label="Sans-Serif Fonts">
<option value="arial">Arial</option>
<option value="verdana">Verdana</option>
<option value="Arial Black">Arial Black</option>
<option value="BIZ UDPGothic">BIZ UDPGothic</option>
</optgroup>
<optgroup label="Serif Fonts">
<option>Tinos</option>
<option>Noto Serif</option>
<option>Georgia</option>
</optgroup>
</select>
<div
autofocus="true"
id="main-body"
style="
background-color:white;
font-family: serif;
width: 100%;
height: 90vh;
border: black 1px;
border-style: ridge;
overflow: scroll;
"
contenteditable
>Edit me.</div>
<style>
#download-name{
border:none;
}
#download-name:hover{
border:1px lightgrey ridge;
}
#download-name:focus{
border:1px grey ridge;
}
select{
border:none;
background-color:light-grey;
}
button{
height:20;
border:none;
}
button:hover{
background-color:white;
}
button:focus{
background:grey;
}
div:focus{
outline:none;
}
</style>
</body>