-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.js
86 lines (78 loc) · 1.8 KB
/
functions.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
79
80
81
82
83
84
85
86
/*jshint sub:true*/
/*jslint evil: true */
/*jslint esversion:6 */
/*
FUNCTIONS
*/
_m.constructor.prototype.function = [];
/*
GENERATE UUID
*/
_m.constructor.prototype.uuid = function()
{
return ("" + Math.random().toString(36).substring(2) + Date.now().toString(36) + "").toUpperCase();
};
/*
STRIP HTML
*/
_m.constructor.prototype.stripHtml = function(str)
{
if (str == null) return "";
var div = document.createElement("div");
div.innerHTML = str;
return div.innerText;
};
/*
EVALUATE
*/
_m.constructor.prototype.evaluate = function(str)
{
// VARS
var cuid = _m.uuid();
// CREATE SCRIPT TAG AND POPULATE WITH INSTRUCTIONS
var s = document.createElement('script');
s.setAttribute("id", "ID_" + cuid + "");
s.text = "" + str + "";
// APPEND TO DOM
try
{
document.getElementsByTagName('head')[0].appendChild(s);
}
catch (e)
{}
// REMOVE FROM DOM
var elem = document.querySelector("#ID_" + cuid + "");
elem.parentNode.removeChild(elem);
};
/*
EXTRACT VARIABLES EXPRESSION
*/
_m.constructor.prototype.expressionVar = function(z)
{
// ALL ELEMENT BEWTEEN SINGLE OR DOUBLE QUOTE
// ALL ELEMENT BEWTEEN SINGLE OR SINGLE QUOTE
// ARRAY
// COMMAS
// TRUE-FALSE
// REMOVE ALL WHITE SPACE ONLY WITH ONE WHITE SPACE
z = z.replace(this.regExpressionBig, " ");
// TRIM
z = z.trim();
// EXTRACT WORDS
z = z.match(this.regExpExtract["_WORDS_"]);
// REMOVE ALL NUMBERS
return z.filter(function(el)
{
return el != Number(el);
});
};
/*
GET INDEX OF NODE ON LOCATED ON THE SAME LEVEL
*/
_m.constructor.prototype.getNodeindex = function(elm)
{
var c = elm.parentNode.children,
i = 0;
for (; i < c.length; i++)
if (c[i] == elm) return i;
};