-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
130 lines (121 loc) · 3.31 KB
/
index.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
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
$(document).ready(function()
{
var step = 1;
var bindkey;
var rawlyrics;
var errorMessage = "Please enter something.";
var device;
var scriptedLyrics;
var rawScriptedLyrics;
var loop;
$("#infolink").click(function()
{
$("#info").slideToggle();
});
if ($("#header").css("font-size") == "96px")
{
$("i").addClass("medium");
device = "desktop";
$("#bottom").remove();
}
else
{
$("i").addClass("small");
device = "mobile";
}
$(function() {
$("form").submit(function() { return false; });
});
$('input').keypress(function(e){
if(e.keyCode==13)
$('.step').click();
});
$(".step").click(function()
{
if (step == 1)
{
if ($(".rawtext").val().length > 0)
{
rawLyrics = $(".rawtext").val();
$(".temptext").html(rawLyrics);
$(".temptext").trigger('autoresize');
rawScriptedLyrics = rawLyrics;
$(".row1").slideUp();
$(".row2").slideDown();
$(".row3").slideUp();
$(".rightcol").slideDown();
step++;
}
else {
$(".rawtext").addClass("invalid");
Materialize.toast(errorMessage, 3000);
}
}
else if (step == 2)
{
if ($("#bindKey").val().length > 0)
{
bindKey = $("#bindKey").val();
$(".temptext").html("<span style=\"color:yellow;\">bind " + bindKey + " \"nextLine\"</span>\r\n" + $(".temptext").html());
$(".temptext").trigger('autoresize');
$(".row1").slideUp();
$(".row2").slideUp();
$(".row3").slideDown();
$(this).fadeOut();
step++;
}
else {
$("#bindKey").addClass("invalid");
Materialize.toast(errorMessage, 3000);
}
}
});
$("#convertBtn").click(function()
{
var lines = rawLyrics.split("\n");
for (var i = 0; i < lines.length; i++)
{
if (lines[i].length <= 0)
{
lines.splice(i, 1);
}
}
scriptedLyrics = "<span style=\"color:yellow;\">alias nextLine \"l0\"</span>";
scriptedLyrics += "\r\n<span style=\"color:yellow;\">bind " + bindKey + " \"nextLine\"</span>";
rawScriptedLyrics = "alias nextLine \"l0\"";
rawScriptedLyrics += "\r\nbind " + bindKey + " \"nextLine\"";
loop = $("#loopbox").is(":checked");
for (let i = 0; i < lines.length; i++)
{
if (i == lines.length - 1) // IF LAST LINE
{
if(loop)
{
scriptedLyrics += "\r\n<span style=\"color:yellow;\">alias l" + i + " \"say </span>" + lines[i] + "<span style=\"color:yellow;\">;alias nextLine l0\"</span>";
rawScriptedLyrics += "\r\nalias l" + i + " \"say " + lines[i] + ";alias nextLine l0\"";
}
else {
scriptedLyrics += "\r\n<span style=\"color:yellow;\">alias l" + i + " \"say </span>" + lines[i] + "\"";
rawScriptedLyrics += "\r\nalias l" + i + " \"say " + lines[i] + "\"";
}
break;
}
scriptedLyrics += "\r\n<span style=\"color:yellow;\">alias l" + i + " \"say </span>" + lines[i] + "<span style=\"color:yellow;\">;alias nextLine l" + (i + 1) + "\"</span>";
rawScriptedLyrics += "\r\nalias l" + i + " \"say " + lines[i] + ";alias nextLine l" + (i + 1) + "\"";
}
$(".temptext").html(scriptedLyrics);
$(".leftcol").slideUp(400, function()
{
$(".rightcol").removeClass("offset-l1");
$(".rightcol").removeClass("hide-on-med-and-down");
$("#temptextTitle").text("Result");
$(".saveBtn").fadeIn();
});
});
$(".saveBtn").click(function()
{
var file = new File([rawScriptedLyrics], "lyrics.cfg");
saveAs(file);
$("#finalInst").show();
});
});