-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
executable file
·140 lines (107 loc) · 3.2 KB
/
index.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
<html>
<head>
<title>pandora exporter</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script>
var loginClicked = function() {
$("#loginBtn").prop("disabled", true);
console.log("clicked");
userid = $("#useridInp").val()
password = $("#passwordInp").val()
doExport(userid, password);
}
var jsonQuerier;
var queryForJson = function() {
jsonQuerier = setInterval(function(){
console.log("periodic...");
var http = new XMLHttpRequest();
var url = "/full.json";
http.open("GET", url, true);
http.onreadystatechange = function() {//Call when state changes.
if(http.readyState == 4 && http.status == 200) {
clearInterval(jsonQuerier);
$("#fullJsonBtn").prop("disabled", false);
$("#neatJsonBtn").prop("disabled", false);
$("#message").html("thumbs-up data fetched, click buttons to download");
}
}
http.send();
}, 16000); // 16 secs
}
var doExport = function(userid, password) {
var http = new XMLHttpRequest();
var url = "/export";
var params = "userid=" + encodeURIComponent(userid) + "&password="
+ encodeURIComponent(password);
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
$('#login').hide()
$("#fetching").show()
console.log("got login resp: " + http.responseText);
queryForJson();
}
}
http.send(params);
}
</script>
<style>
.panel {
padding: 10pt;
border: 1pt black solid;
width: 90%;
margin: auto;
}
.hidden {
display: none;
}
.linkButton a:hover {
text-decoration: none !important;
}
.linkButton {
text-decoration: none !important;
border: none !important;
}
</style>
</head>
<body>
<div class="content">
<h1>pandora exporter</h1>
<div id="fetching" class="panel hidden">
<div id="message">
logged in, fetching thumbs-up...
</div>
<br>
<div style="width: 90%; margin: auto; text-align: center;">
<a href="full.json" download="" class="linkButton" >
<button type="submit" id="fullJsonBtn" disabled="true" >full.json</button>
</a>
<div style="display: inline-block; width: 1em;"></div>
<a href="neat.json" download="" class="linkButton" >
<button type="submit" id="neatJsonBtn" disabled="true" >neat.json</button>
</a>
</div>
</div>
<div id="login" class="panel">
<div>
<table>
<tr>
<td>userid (an email address, probably):</td>
<td><input type="text" id="useridInp" size="40" ></input></td>
</tr>
<tr>
<td>password:</td>
<td><input type="password" id="passwordInp" size="40" /></td>
</tr>
</table>
<br>
<br/>
<div>
<div style="width: 90%; margin: auto; text-align: center;">
<button type="button" id="loginBtn" onClick="loginClicked();">login</button>
</div>
</div>
</div>
<!-- content -->