-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
55 lines (50 loc) · 1.68 KB
/
script.js
File metadata and controls
55 lines (50 loc) · 1.68 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
var srcTxt = document.querySelector("#src");
var csTxt = document.querySelector("#cs");
var jsTxt = document.querySelector("#js");
var jsLintTxt = document.querySelector("#jsLint");
srcTxt.onkeyup = function () {
var srcValue = new String();
if (srcTxt.value.trim() === "") {
csTxt.value = "";
jsTxt.value = "";
jsLintTxt.value = "";
}
srcTxt.value.trim().replace(/"/g, "'").split('\n').forEach(function (line) {
if (line.length > 0 && line.trim().length > 0) {
if (line[0] == '+')
{ }
else {
if (line[0] == '-') {
srcValue += line.substring(1, line.length) + "\n";
} else
srcValue += line + "\n";
format(srcValue);
}
}
});
};
var format = function (srcValue) {
csTxt.value = ('@"' + srcValue.substring(0, srcValue.length - 1) + '"');
var jstxt = new String();
srcValue.split('\n').forEach(function (line) {
jstxt += '"' + line + '"+\n';
});
jsTxt.value = jstxt.substring(0, jstxt.length - 6);
var jslinttxt = "var fetchXML = new String();\n";
srcValue.split('\n').forEach(function (line) {
jslinttxt += 'fetchXML += ' + '"' + line + '";\n';
});
jsLintTxt.value = jslinttxt.substring(0, jslinttxt.length - 18) + ";";
};
function copied() {
this.parentElement.dataset.balloon = "Copied!";
};
function restoreCopied() {
this.parentElement.dataset.balloon = "Click To Copy.";
};
csTxt.onclick = copied;
csTxt.onmouseout = restoreCopied;
jsTxt.onclick = copied;
jsTxt.onmouseout = restoreCopied;
jsLintTxt.onclick = copied;
jsLintTxt.onmouseout = restoreCopied;