Repository navigation
Expand file tree
/
Copy pathmyscript.js
More file actions
59 lines (54 loc) · 1.65 KB
/
Copy pathmyscript.js
File metadata and controls
59 lines (54 loc) · 1.65 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
var document;
$("textarea").tabby();
$(".toggleButton").hover(function () {
$(this).addClass("hover");
}, function () {
$(this).removeClass("hover");
});
$(".toggleButton").click(function () {
$(this).toggleClass('active');
// console.log($(this).attr("id"));
let name = "#" + $(this).attr("id") + "Area";
if ($(this).hasClass("active")) {
$(name).css("display", "block");
} else {
$(name).css("display", "none");
}
sizing();
});
function sizing() {
var areas = document.querySelectorAll("textarea");
var nams = []
for (let i = 0; i < areas.length; i++) {
nams[i] = areas[i];
}
nams.splice(-1, 0, $("iframe"));
var q = 0;
nams.forEach(function (e) {
if ($(e).css("display") == "block") {
q++;
}
});
nams.forEach(function (x) {
if ($(x).hasClass("active")) {
$(x).removeAttr("class");
$(x).addClass("col-" + 12 / q);
$(x).addClass("active");
} else {
$(x).removeAttr("class");
$(x).addClass("col-" + 12 / q);
}
});
if (q > 1) {
// nams.splice(-1, 1);
nams.forEach(function (x) {
$(x).addClass("textArea2");
});
}
}
$("iframe").contents().find("html").html($("#htmlArea").val());
$("textarea").on("change keyup paste", update);
function update() {
$("iframe").contents().find("html").html("<html><head><style rel='stylesheet'>" + $("#cssArea").val() + "</style></head><body>" + $("#htmlArea").val() + "</body></html>");
document.getElementById("liveArea").contentWindow.eval($("#jsArea").val());
}