This repository was archived by the owner on Feb 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.ts
More file actions
193 lines (165 loc) · 5.49 KB
/
Copy pathrouter.ts
File metadata and controls
193 lines (165 loc) · 5.49 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
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
let cred;
let blue = "#39c0ba";
let gray = "#5b6969";
let continuedWithoutSignIn = false;
function collapseSignPanel() {
$("#nav-collapse1").collapse("hide");
}
function switchToClonePanel() {
console.log("switch to clone panel");
hideAuthenticatePanel();
hideFilePanel();
hideGraphPanel();
displayClonePanel();
}
function switchToMainPanel() {
hideAuthenticatePanel();
hideAddRepositoryPanel();
displayFilePanel();
displayGraphPanel();
}
function checkSignedIn() {
if (continuedWithoutSignIn) {
displayModal("You need to sign in");
// Don't open the repo modal
$('#repo-name').removeAttr("data-target");
} else {
// Ensure repo modal is connected
let butt = document.getElementById("cloneButton");
butt.innerHTML = 'Clone';
butt.setAttribute('class', 'btn btn-primary');
$('#repo-name').attr("data-target", "#repo-modal");
}
}
function switchToAddRepositoryPanelWhenNotSignedIn() {
document.getElementById("avatar").innerHTML= "Sign In" ;
continuedWithoutSignIn = true;
switchToAddRepositoryPanel();
}
function switchToAddRepositoryPanel() {
console.log("Switching to add repo panel");
hideAuthenticatePanel();
hideFilePanel();
hideGraphPanel();
displayAddRepositoryPanel();
displayUsername();
document.getElementById("repoOpen").value = "";
}
function wait(ms) {
var start = new Date().getTime();
var end = start;
while (end < start + ms) {
end = new Date().getTime();
}
}
function displayUsername() {
console.log(getUsername());
let existing_username = document.getElementById("githubname").innerHTML;
if (getUsername() != null && existing_username == null) {
document.getElementById("githubname").innerHTML = getUsername();
}
}
function displayClonePanel() {
document.getElementById("add-repository-panel").style.zIndex = "10";
$("#open-local-repository").hide();
}
function displayFilePanel() {
document.getElementById("file-panel").style.zIndex = "10";
document.getElementById("commit-message-input").style="visibility: visible";
document.getElementById("commit-button").style="visiblity: visible";
document.getElementById("fileEdit-button").style="visiblity: visible";
}
function displayGraphPanel() {
document.getElementById("graph-panel").style.zIndex = "10";
}
function displayAddRepositoryPanel() {
document.getElementById("add-repository-panel").style.zIndex = "10";
$("#open-local-repository").show();
}
function hideFilePanel() {
document.getElementById("file-panel").style.zIndex = "-10";
document.getElementById("commit-message-input").style="visibility: hidden";
document.getElementById("commit-button").style="visibility: hidden";
document.getElementById("fileEdit-button").style="visibility: hidden";
}
function hideGraphPanel() {
document.getElementById("graph-panel").style.zIndex = "-10";
}
function hideAddRepositoryPanel() {
document.getElementById("add-repository-panel").style.zIndex = "-10";
}
function displayDiffPanel() {
document.getElementById("graph-panel").style.width = "60%";
document.getElementById("diff-panel").style.width = "40%";
displayDiffPanelButtons();
}
function hideDiffPanel() {
document.getElementById("diff-panel").style.width = "0";
document.getElementById("graph-panel").style.width = "100%";
disableDiffPanelEditOnHide();
hideDiffPanelButtons();
}
function hideDiffPanelIfNoChange() {
let filename = document.getElementById("diff-panel-file-name") == null ? null : document.getElementById("diff-panel-file-name").innerHTML;
let filePaths = document.getElementsByClassName('file-path');
let nochange = true;
for (let i = 0; i < filePaths.length; i++) {
if (filePaths[i].innerHTML === filename) {
nochange = false;
}
}
if (nochange == true){
hideDiffPanel();
}
filename = null;
}
function hideAuthenticatePanel() {
document.getElementById("authenticate").style.zIndex = "-20";
}
function displayAuthenticatePanel() {
document.getElementById("authenticate").style.zIndex = "20";
}
function displayDiffPanelButtons() {
document.getElementById("save-button").style.visibility = "visible";
document.getElementById("cancel-button").style.visibility = "visible";
}
function hideDiffPanelButtons() {
document.getElementById("save-button").style.visibility = "hidden";
document.getElementById("cancel-button").style.visibility = "hidden";
disableSaveCancelButton();
disableDiffPanelEditOnHide();
}
function disableSaveCancelButton() {
let saveButton = document.getElementById("save-button");
let cancelButton = document.getElementById("cancel-button");
saveButton.disabled = true;
saveButton.style.backgroundColor = gray;
cancelButton.disabled = true;
cancelButton.style.backgroundColor = gray;
}
function enableSaveCancelButton() {
let saveButton = document.getElementById("save-button");
let cancelButton = document.getElementById("cancel-button");
saveButton.disabled = false;
saveButton.style.backgroundColor = blue;
cancelButton.disabled = false;
cancelButton.style.backgroundColor = blue;
}
function disableDiffPanelEditOnHide() {
let doc = document.getElementById("diff-panel-body");
doc.contentEditable = "false";
}
function useSaved() {
let file = 'data.json';
// check if the data.json file exists
fs.exists(file, (exist) => {
if (exist) {
console.log('button has been pressed: logging in with saved credentials');
decrypt();
loginWithSaved(switchToMainPanel);
} else {
// if data,json file doesn't exist show a pop up.
window.alert("No saved credentials exist");
}
});
}