-
Notifications
You must be signed in to change notification settings - Fork 0
/
dash.html
196 lines (182 loc) · 8.24 KB
/
dash.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../style.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
<title>Dashboard | sync.js</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://script-js.github.io/js-css/browserDetect.js"></script>
<link rel="icon" href="icon.png" />
<script src='https://exactalytics.pages.dev/import.js'></script>
<script>analyticsInit('sync.js','3moxYInXFN6fp')</script>
<style>
body {margin: 0;}
ul.topnav {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: whitesmoke;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
text-align: center;
display: flex;
justify-content: center;
}
ul.topnav li {float: left;}
ul.topnav li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
ul.topnav li a:hover:not(.active) {background-color: #d9d9d9;}
ul.topnav li a.active {background-color: #1a73e8;}
ul.topnav li.right {float: right;}
@media screen and (max-width: 600px) {
ul.topnav li.right,
ul.topnav li {float: none;}
}
.msoBig {
font-size: 35px;
}
@media (prefers-color-scheme: dark) {
ul.topnav {background-color:#3b3b3b}
ul.topnav li a:hover:not(.active) {background-color: #636363;}
.mc1 {background:#212121}
}
@media (prefers-color-scheme: light) {
.mc1 {background:white}
}
</style>
</head>
<body>
<div style="display: none; position: fixed; z-index: 1; left: 0px; top: 0px; width: 100%; height: 100%; overflow: auto; background-color: rgba(0, 0, 0, 0.4);" id="editor"><div style="margin: 15% auto; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); text-align: center; box-sizing: border-box; border-radius: 10px; width: 50%; border: 2px solid blue;padding: 20px;" class="mc1">
<span style="color: red; float: right; font-size: 28px; font-weight: bold; cursor:pointer;" onclick="editor.style.display = 'none'">×</span>
<h1 id="edtext">Something went wrong</h1>
<textarea id="editorText" style="color:black"></textarea>
<br>
<button id="editorSave"><span class="material-symbols-outlined">save</span></button>
</div>
</div>
<ul class="topnav">
<li><a class="active" href="#" id="home" onclick="tabChange(this)"><span class="material-symbols-outlined msoBig" title="Account">account_circle</span></a></li>
<li><a href="#" id="data" onclick="tabChange(this)"><span class="material-symbols-outlined msoBig" title="My Data">folder_open</span></a></li>
<li><a href="#" id="setup" onclick="tabChange(this)"><span class="material-symbols-outlined msoBig" title="Bookmarklets">bookmark</span></a></li>
</ul>
<div style="padding:0 16px;">
<div id="homeC" style="text-align:center"></div>
<div id="dataC" style="display:none">Loading...</div>
<div id="setupC" style="display:none">
<p>Drag this link into your bookmarks bar:</p>
<a href='javascript:try {void(window.open("https://sync-js.pages.dev/backup?fromURL=" + btoa(location.href) + "&data=" + btoa(JSON.stringify(localStorage)).replaceAll("+",atob("JTJC")),"","width=500,height=900"))} catch(error) {alert(error)}'>Back Up</a>
|
<a href='javascript:var sjswin123 = window.open("https://sync-js.pages.dev/get?url=" + btoa(location.href),"","width=500,height=900"); window.addEventListener("message",(event) => {var sjsSYSjson = JSON.parse(event.data); Object.keys(sjsSYSjson).forEach(function (k) {localStorage.setItem(k,sjsSYSjson[k])}); location.reload()},false); '>Restore</a>
</div>
<script src="drive.js"></script>
<script async defer src="https://apis.google.com/js/api.js"
onload="gapiLoaded()"></script>
<script async defer src="https://accounts.google.com/gsi/client"
onload="gisLoaded()"></script>
<script>
var currentTab = "home";
function tabChange(tab) {
tab.classList = "active";
var tabid = tab.id
document.getElementById(tabid + "C").style.display = "block";
if (currentTab != tabid) {
document.getElementById(currentTab + "C").style.display = "none";
document.getElementById(currentTab).classList = "";
}
currentTab = tabid
}
function changeSite(site) {
var siteid = site.id;
if (site.innerHTML.includes("arrow_drop_down")) {
site.innerHTML = site.innerHTML.replace("arrow_drop_down","arrow_drop_up")
document.getElementById(siteid + "C").style.display = "block";
site.classList = "dropdownli dropdownliFocus";
} else if (site.innerHTML.includes("arrow_drop_up")) {
site.innerHTML = site.innerHTML.replace("arrow_drop_up","arrow_drop_down");
document.getElementById(siteid + "C").style.display = "none";
site.classList = "dropdownli";
}
}
</script>
<script>
function listSites(jarray) {
var toadd = "<p></p>";
Object.keys(jarray).forEach(function (k) {
var toadd2 = "";
var arrTemp = jarray[k];
Object.keys(arrTemp).forEach(function (k2) {
toadd2 = toadd2 + "<p>" + k2 + ": " + arrTemp[k2] + "</p>"
});
toadd = toadd + "<a class='dropdownli' onclick='changeSite(this)' id='" + k + "'>" + k + " <span class='material-symbols-outlined'>arrow_drop_down</span></a><button style='width:inherit' onclick='editorOpen(" + '"' + k + '"' + ")'><span class='material-symbols-outlined'>edit</span></button> <button style='width:inherit' onclick='editorDelete(" + '"' + k + '"' + ")'><span class='material-symbols-outlined'>delete</span></button><div style='display:none;padding:0 50px;' id='" + k + "C'>" + toadd2 + "</div><br>";
})
return toadd;
}
async function startup() {
if (getBrowser() == "FIREFOX") {
var extURL = "<a href='https://addons.mozilla.org/en-US/firefox/addon/sync-js/' target='_blank'>Download Firefox Addon</a>"
} else if (getBrowser() == "CHROMIUM") {
var extURL = "<a href='https://chrome.google.com/webstore/detail/syncjs/jobnjgnmbknekedfmaafenkejolhfgje' target='_blank'>Download Chrome Extension</a>"
}
var profile = await (await fetch("https://www.googleapis.com/oauth2/v3/userinfo?access_token=" + gapi.auth.getToken().access_token)).json();
if (!extURL) {
homeC.innerHTML = "<p></p><img src='" + profile.picture + "' width='100' style='border-radius:100%' /><h1>Welcome, " + profile.given_name + "</h1><button onclick='handleSignoutClick()'><span class='material-symbols-outlined'>logout</span></button><p>Select a tab above to get started.</p>";
} else {
homeC.innerHTML = "<p></p><img src='" + profile.picture + "' width='100' style='border-radius:100%' /><h1>Welcome, " + profile.given_name + "</h1><button onclick='handleSignoutClick()'><span class='material-symbols-outlined'>logout</span></button><p>Select a tab above to get started.</p><br><p>" + extURL + "</p>";
}
await findFile().then(async function (fid) {
if (fid == false) {
await uploadFile("{}")
setTimeout(function() {location.reload()},200)
} else {
window.fid = fid
await get_doc(fid).then(function(data2) {
if (data2 != "{}" && data2) {
var data1 = JSON.parse(data2)
dataC.innerHTML = listSites(data1);
window.lstestarr = data1;
} else {
dataC.innerHTML = "<h1 style='text-align:center'>No Data Yet!</h1>"
}
})
}})
}
async function editorOpen(domain) {
await get_doc(fid).then(function(data1) {
var data2 = JSON.parse(data1)[domain]
if (data2 != {} && data2) {
edtext.innerHTML = "Editing JSON: " + domain;
editorText.innerHTML = JSON.stringify(data2);
editorSave.onclick = function() {
try {
var toset = {}
toset[domain] = JSON.parse(editorText.value)
} catch (error) {
alert(error)
}
if (toset) {
addEntries(toset)
alert("Saved Successfully")
startup()
}
}
}
});
editor.style.display = "block"
}
function handleSignoutClick() {
const token = gapi.client.getToken();
if (token !== null) {
google.accounts.oauth2.revoke(token.access_token);
gapi.client.setToken('');
localStorage.setItem("gapi_token","")
location.replace("login")
}
}
</script>
</body>
</html>