-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo.html
366 lines (335 loc) · 11.2 KB
/
demo.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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script
src="https://code.jquery.com/jquery-1.12.4.min.js"
integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ"
crossorigin="anonymous"
type="text/javascript"
></script>
<script>
/**
* jQuery Lined Textarea Plugin
* http://alan.blog-city.com/jquerylinedtextarea.htm
*
* Copyright (c) 2010 Alan Williamson
*
* Version:
* $Id: jquery-linedtextarea.js 464 2010-01-08 10:36:33Z alan $
*
* Released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* Usage:
* Displays a line number count column to the left of the textarea
*
* Class up your textarea with a given class, or target it directly
* with JQuery Selectors
*
* $(".lined").linedtextarea({
* selectedLine: 10,
* selectedClass: 'lineselect'
* });
*
* History:
* - 2010.01.08: Fixed a Google Chrome layout problem
* - 2010.01.07: Refactored code for speed/readability; Fixed horizontal sizing
* - 2010.01.06: Initial Release
*
*/
(function ($) {
$.fn.linedtextarea = function (options) {
// Get the Options
var opts = $.extend({}, $.fn.linedtextarea.defaults, options);
/*
* Helper function to make sure the line numbers are always
* kept up to the current system
*/
var fillOutLines = function (codeLines, h, lineNo) {
while (codeLines.height() - h <= 0) {
if (lineNo == opts.selectedLine)
codeLines.append(
"<div class='lineno lineselect'>" + lineNo + "</div>"
);
else codeLines.append("<div class='lineno'>" + lineNo + "</div>");
lineNo++;
}
return lineNo;
};
/*
* Iterate through each of the elements are to be applied to
*/
return this.each(function () {
var lineNo = 1;
var textarea = $(this);
/* Turn off the wrapping of as we don't want to screw up the line numbers */
textarea.attr("wrap", "off");
textarea.css({ resize: "none" });
var originalTextAreaWidth = textarea.outerWidth();
/* Wrap the text area in the elements we need */
textarea.wrap("<div class='linedtextarea'></div>");
var linedTextAreaDiv = textarea
.parent()
.wrap(
"<div class='linedwrap' style='width:" +
originalTextAreaWidth +
"px'></div>"
);
var linedWrapDiv = linedTextAreaDiv.parent();
linedWrapDiv.prepend(
"<div class='lines' style='width:50px'></div>"
);
var linesDiv = linedWrapDiv.find(".lines");
linesDiv.height(textarea.height() + 6);
/* Draw the number bar; filling it out where necessary */
linesDiv.append("<div class='codelines'></div>");
var codeLinesDiv = linesDiv.find(".codelines");
lineNo = fillOutLines(codeLinesDiv, linesDiv.height(), 1);
/* Move the textarea to the selected line */
if (opts.selectedLine != -1 && !isNaN(opts.selectedLine)) {
var fontSize = parseInt(textarea.height() / (lineNo - 2));
var position =
parseInt(fontSize * opts.selectedLine) - textarea.height() / 2;
textarea[0].scrollTop = position;
}
/* Set the width */
var sidebarWidth = linesDiv.outerWidth();
var paddingHorizontal =
parseInt(linedWrapDiv.css("border-left-width")) +
parseInt(linedWrapDiv.css("border-right-width")) +
parseInt(linedWrapDiv.css("padding-left")) +
parseInt(linedWrapDiv.css("padding-right"));
var linedWrapDivNewWidth =
originalTextAreaWidth - paddingHorizontal;
var textareaNewWidth =
originalTextAreaWidth - sidebarWidth - paddingHorizontal - 20;
textarea.width(textareaNewWidth);
linedWrapDiv.width(linedWrapDivNewWidth);
/* React to the scroll event */
textarea.scroll(function (tn) {
var domTextArea = $(this)[0];
var scrollTop = domTextArea.scrollTop;
var clientHeight = domTextArea.clientHeight;
codeLinesDiv.css({ "margin-top": -1 * scrollTop + "px" });
lineNo = fillOutLines(
codeLinesDiv,
scrollTop + clientHeight,
lineNo
);
});
/* Should the textarea get resized outside of our control */
textarea.resize(function (tn) {
var domTextArea = $(this)[0];
linesDiv.height(domTextArea.clientHeight + 6);
});
});
};
// default options
$.fn.linedtextarea.defaults = {
selectedLine: -1,
selectedClass: "lineselect",
};
})(jQuery);
</script>
<style>
/**
* jQuery Lined Textarea Plugin
* http://alan.blog-city.com/jquerylinedtextarea.htm
*
* Copyright (c) 2010 Alan Williamson
*
* Released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* Usage:
* Displays a line number count column to the left of the textarea
*
* Class up your textarea with a given class, or target it directly
* with JQuery Selectors
*
* $(".lined").linedtextarea({
* selectedLine: 10,
* selectedClass: 'lineselect'
* });
*
*/
.linedwrap {
border: 1px solid #c0c0c0;
padding: 3px;
}
.linedtextarea {
padding: 0px;
margin: 0px;
}
.linedtextarea textarea,
.linedwrap .codelines .lineno {
font-size: 10pt;
font-family: monospace;
line-height: normal !important;
}
.linedtextarea textarea {
padding-right: 0.3em;
padding-top: 0.3em;
border: 0;
}
.linedwrap .lines {
margin-top: 0px;
width: 50px;
float: left;
overflow: hidden;
border-right: 1px solid #c0c0c0;
margin-right: 10px;
}
.linedwrap .codelines {
padding-top: 5px;
}
.linedwrap .codelines .lineno {
color: #aaaaaa;
padding-right: 0.5em;
padding-top: 0em;
text-align: right;
white-space: nowrap;
}
.linedwrap .codelines .lineselect {
color: red;
}
</style>
<style>
:root {
background-color: rgb(49, 54, 52);
color:chartreuse;
margin: 10px;
margin-left: 100px;
margin-right: 100px;
}
.hr {
border: 0;
border-top: 1px dashed #b5e853;
}
.padding-20{
padding: 20px;
}
.padding-10{
padding: 10px;
}
* {
box-sizing: border-box;
}
/* Create two equal columns that floats next to each other */
.column {
float: left;
width: 50%;
padding: 10px;
height: 300px; /* Should be removed. Only for demonstration */
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
textarea {margin: 0;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
</style>
<style>
.btn-group button {
border: 1px solid green; /* Green border */
color: black; /* White text */
padding: 10px 24px; /* Some padding */
cursor: pointer; /* Pointer/hand icon */
float: left; /* Float the buttons side by side */
}
/* Clear floats (clearfix hack) */
.btn-group:after {
content: "";
clear: both;
display: table;
}
.btn-group button:not(:last-child) {
border-right: none; /* Prevent double borders */
}
/* Add a background color on hover */
.btn-group button:hover {
background-color: #b1e7b3;
}
</style>
</head>
<body>
<h1>Sake-JS</h1>
<hr class="hr" />
<div class="padding-10"></div>
<h2>JavaScript Obfuscator</h2>
<!-- <div class="btn-group" style="margin-left: 10px;">
<button style="width:10%" id="obfuscate-tab">Obfuscate</button>
<button style="width:10%" id="result-tab">Result</button>
</div> -->
<div class="row">
<div class="column" >
<textarea class="lined" rows="25" cols="60" charswidth="25">
function main(text){
var a = 5
console.log(text, a)
}
main("hello world")</textarea>
</div>
<div class="column">
<button style="height: 50px;width: 100px;cursor: pointer;" onClick="obfuscate()">Obfuscate</button><br/>
<div class="padding-10"></div>
<input type="checkbox" id="random"> random</input>
<div class="padding-10"></div>
<input type="checkbox" id="custom"> custom <a href="https://nuojs.github.io/sake-js/words.html" style="color: white;" target="_blank">caracter</a>
</input>
<div class="padding-10"></div>
<input type="text" id="input-custom" style="width: 250px;margin-left: 28px"></input>
<div class="padding-20"></div>
<a href="https://github.com/nuojs/sake-js" style="color: white;" target="_blank">github.com/nuojs/sake-js</a>
<br/><br/> <button style="height: 50px;width: 100px;cursor: pointer;" onClick="reset()">Reset</button><br/>
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
$(".lined").linedtextarea(
{selectedLine: 4}
);
});
</script>
<script>
function obfuscate(){
let res = ''
if(!$('#random').is(':checked') && !$('#custom').is(':checked')){
res = SakeJS.obfuscate($('textarea.lined').val())
$('textarea.lined').val(res)
return
}
if($('#random').is(':checked')){
res = SakeJS.obfuscate($('textarea.lined').val(), {random: true})
$('textarea.lined').val(res)
return
}
if($('#custom').is(':checked')){
res = SakeJS.obfuscate($('textarea.lined').val(), {random: false,custom: $('#input-custom').val()})
$('textarea.lined').val(res)
return
}
}
function reset(){
$('textarea.lined').val(`function main(text){
var a = 5
console.log(text, a)
}
main("hello world")`)
}
</script>
<script src="./browser/index.js"></script>
</body>
</html>