Skip to content

Commit 6cb2e5f

Browse files
authored
Codeit 3.3.5
2 parents 03a5e38 + 2712ebb commit 6cb2e5f

File tree

8 files changed

+181
-156
lines changed

8 files changed

+181
-156
lines changed

filebrowser.js

+59-43
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ async function renderSidebarHTML() {
225225
// stop loading
226226
stopLoading();
227227

228-
alert('Hmm... we can\'t find that repo.\nIf it\'s private, try double checking you\'re on the account with access.');
229-
230228

231229
// get repo obj from local storage
232230
const repoObj = modifiedRepos[user + '/' + repoName];
@@ -240,6 +238,21 @@ async function renderSidebarHTML() {
240238
}
241239

242240

241+
// if not logged in
242+
if (gitToken == '') {
243+
244+
const dialogResp = await showDialog(openGitHubLogin, 'Hmm... the repo you\'re\nlooking for can\'t be found.\nTry logging in.', 'Login', true);
245+
246+
// if chosen to log in, return
247+
if (dialogResp == true) return;
248+
249+
} else { // if logged in
250+
251+
await showDialog(hideDialog, 'Hmm... the repo you\'re\nlooking for can\'t be found.', 'OK', true);
252+
253+
}
254+
255+
243256
// change location
244257
treeLoc[1] = '';
245258
treeLoc[2] = '';
@@ -681,10 +694,20 @@ async function renderSidebarHTML() {
681694
// if repo obj dosen't already exist
682695
if (!modifiedRepos[item.full_name]) {
683696

697+
// get repo data expiration time
698+
// (two months from now)
699+
700+
let expirationDate = new Date();
701+
expirationDate.setDate(expirationDate.getDate() + (2 * 4 * 7));
702+
703+
const twoMonthsTime = expirationDate.getTime();
704+
705+
684706
// create repo obj
685707
repoObj = createRepoObj(item.full_name, item.default_branch, item.default_branch,
686708
(item.permissions.push ?? false),
687-
null, item.private, item.fork, false);
709+
null, item.private, item.fork, false,
710+
twoMonthsTime, 0);
688711

689712
} else {
690713

@@ -936,13 +959,13 @@ async function clickedOnFileHTML(fileEl, event) {
936959

937960
// open push screen
938961
commitMessage = prompt('Push \''+ fileEl.innerText + (selBranch ? '\' to branch \'' + selBranch + '\'?' : '\'?'),
939-
'Type push description...');
962+
'Type commit message...');
940963

941964
// if canceled push, return
942965
if (!commitMessage) return;
943966

944967
// if not specified message
945-
if (commitMessage === 'Type push description...') {
968+
if (commitMessage === 'Type commit message...') {
946969

947970
// show default message
948971
commitMessage = 'Update ' + fileEl.innerText;
@@ -967,44 +990,45 @@ async function clickedOnFileHTML(fileEl, event) {
967990
}
968991

969992

970-
async function checkPushDialogs() {
993+
function openGitHubLogin() {
971994

972-
// if not logged in to git
973-
if (gitToken == '') {
995+
const authURL = 'https://github.com/login/oauth/authorize?client_id=7ede3eed3185e59c042d&scope=repo,user,write:org';
974996

975-
function openLogin() {
997+
if (isMobile) {
976998

977-
const authURL = 'https://github.com/login/oauth/authorize?client_id=7ede3eed3185e59c042d&scope=repo,user,write:org';
999+
window.location.href = authURL;
9781000

979-
if (isMobile) {
1001+
} else {
9801002

981-
window.location.href = authURL;
1003+
window.addEventListener('message', (event) => {
9821004

983-
} else {
1005+
// if received a git code
1006+
if (event.origin === window.location.origin &&
1007+
event.data.startsWith('gitCode=')) {
9841008

985-
window.addEventListener('message', (event) => {
1009+
// hide dialog
1010+
hideDialog();
9861011

987-
// if received a git code
988-
if (event.origin === window.location.origin &&
989-
event.data.startsWith('gitCode=')) {
1012+
showMessage('Logging in...', -1);
9901013

991-
// hide dialog
992-
dialogWrapper.classList.remove('visible');
1014+
}
9931015

994-
showMessage('Logging in...', -1);
1016+
});
9951017

996-
}
1018+
// open login window
1019+
window.open(authURL, 'Login with GitHub', 'height=575,width=575');
9971020

998-
});
1021+
}
9991022

1000-
// open login window
1001-
window.open(authURL, 'Login with Github', 'height=575,width=575');
1023+
}
10021024

1003-
}
10041025

1005-
}
1026+
async function checkPushDialogs() {
10061027

1007-
showDialog(openLogin, 'Login to save this file.', 'Login');
1028+
// if not logged in to git
1029+
if (gitToken == '') {
1030+
1031+
showDialog(openGitHubLogin, 'Login to save this file.', 'Login');
10081032

10091033
return 'return';
10101034

@@ -1047,7 +1071,7 @@ async function checkPushDialogs() {
10471071
async function forkRepo() {
10481072

10491073
// hide dialog
1050-
dialogWrapper.classList.remove('visible');
1074+
hideDialog();
10511075

10521076
// if on mobile,
10531077
// change status bar color
@@ -1129,12 +1153,14 @@ async function checkPushDialogs() {
11291153
// for fork
11301154

11311155
const newRepoObj = createRepoObj((loggedUser + '/' + repoName), repoObj.selBranch, repoObj.defaultBranch,
1132-
true, repoObj.branches, repoObj.private, true, false);
1156+
true, repoObj.branches, repoObj.private, true, false,
1157+
repoObj.repoDataExpiration, repoObj.branchExpiration);
1158+
11331159
modifiedRepos[loggedUser + '/' + repoName] = newRepoObj;
11341160

11351161
updateModReposLS();
1136-
1137-
1162+
1163+
11381164
// change location
11391165
treeLoc[0] = loggedUser;
11401166
saveTreeLocLS(treeLoc);
@@ -1151,7 +1177,7 @@ async function checkPushDialogs() {
11511177
}
11521178

11531179
const dialogResult = await showDialog(forkRepo,
1154-
'Fork this repository to save your changes.',
1180+
'Fork this repository\nto save your changes.',
11551181
'Fork');
11561182

11571183
if (dialogResult === false) return 'return';
@@ -2076,7 +2102,7 @@ function createNewRepoInHTML() {
20762102

20772103
// create new repo obj
20782104
const repoObj = createRepoObj((loggedUser + '/' + repoName), 'main', 'main',
2079-
true, null, repoPrivate, false, true);
2105+
true, null, repoPrivate, false, true, 0, 0);
20802106

20812107
// add repo obj to modified repos
20822108
addRepoToModRepos(repoObj);
@@ -2217,16 +2243,6 @@ function createNewFileInHTML() {
22172243

22182244
// if file name is empty, use default name
22192245
if (fileName === '') fileName = 'new-file';
2220-
2221-
// replace all special chars in name with dashes
2222-
2223-
const specialChars = validateString(fileName);
2224-
2225-
if (specialChars) {
2226-
2227-
specialChars.forEach(char => { fileName = fileName.replaceAll(char, '-') });
2228-
2229-
}
22302246

22312247

22322248
// if another file in the current directory

full.css

+13-4
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,8 @@ body.scroll-enabled .bookmark {
562562
will-change: transform;
563563
transition: .18s var(--ease-function) left,
564564
.4s var(--cubic-function) transform,
565-
.4s var(--cubic-function) padding;
565+
.4s var(--cubic-function) padding,
566+
.18s var(--bounce-function) opacity;
566567
}
567568

568569
.sidebar-toggle::after {
@@ -592,6 +593,11 @@ body.embed .sidebar-toggle {
592593
display: none;
593594
}
594595

596+
.sidebar-toggle.dialog-visible {
597+
opacity: 0;
598+
pointer-events: none;
599+
}
600+
595601
body.expanded .sidebar-toggle {
596602
transform: translateX(calc(var(--sidebar-width) - 1px));
597603
}
@@ -1737,8 +1743,6 @@ body.mobile .dialog-background {
17371743
border: 1px solid rgb(32 34 37 / 60%);
17381744
border-radius: 11.5px;
17391745
line-height: 1.5;
1740-
max-width: 200px;
1741-
width: 194px;
17421746
opacity: 0;
17431747
padding: 2px;
17441748
transition: 0s .18s, .18s var(--bounce-function) opacity;
@@ -1753,6 +1757,7 @@ body.mobile .dialog-background {
17531757

17541758
.dialog .title {
17551759
padding: 8px 14px;
1760+
white-space: pre-wrap;
17561761
}
17571762

17581763
.dialog .button-wrapper {
@@ -1765,13 +1770,17 @@ body.mobile .dialog-background {
17651770
border-radius: 5.75px;
17661771
display: flex;
17671772
justify-content: center;
1768-
width: 50%;
1773+
flex: 1;
17691774
}
17701775

17711776
.dialog .cancel {
17721777
color: hsl(228deg 16% 37%);
17731778
}
17741779

1780+
.dialog-wrapper.one-button .dialog .cancel {
1781+
display: none;
1782+
}
1783+
17751784
.dialog .confirm {
17761785
color: var(--rosemary-lighter);
17771786
font-weight: 500;

git/gitauth.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ window.onload = async () => {
6969

7070
} else {
7171

72-
window.open(authURL, 'Login with Github', 'height=575,width=575');
72+
window.open(authURL, 'Login with GitHub', 'height=575,width=575');
7373

7474
}
7575

lib/plugins/codeit-match-braces.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,18 @@
175175
const cursor = cd.dropper.cursor();
176176

177177
if (cursor && cursor.in('brace')) {
178+
178179
const currentBrace = cursor.getParent();
179180

180181
if (currentBrace.id) {
182+
181183
currentBrace.classList.add('brace-active');
182-
getPartnerBrace(currentBrace).classList.add('brace-active');
184+
185+
const partnerBrace = getPartnerBrace(currentBrace);
186+
if (partnerBrace) partnerBrace.classList.add('brace-active');
187+
183188
}
189+
184190
}
185191

186192
}

live-view/extensions/markdown-dark.css

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
html {
2525
background: var(--bg-color);
26+
scroll-padding: 16px;
2627
}
2728

2829
body {

live-view/live-view.js

+10-68
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,17 @@ async function setupLiveView() {
177177

178178
// don't transition live view
179179
liveView.classList.add('notransition');
180-
181-
// hide live view
182-
liveView.classList.remove('visible');
183-
184-
// restore transition on next frame
180+
185181
onNextFrame(() => {
186-
liveView.classList.remove('notransition');
182+
183+
// hide live view
184+
liveView.classList.remove('visible');
185+
186+
// restore transition on next frame
187+
onNextFrame(() => {
188+
liveView.classList.remove('notransition');
189+
});
190+
187191
});
188192

189193
}
@@ -1240,65 +1244,3 @@ async function renderLiveViewMarkdown(file) {
12401244

12411245
}
12421246

1243-
1244-
1245-
// lazy load an external script
1246-
function loadScript(src, inEl) {
1247-
1248-
inEl = inEl ?? document.body;
1249-
1250-
return new Promise((resolve, reject) => {
1251-
1252-
let s = document.createElement('script');
1253-
s.src = src;
1254-
//s.async = true;
1255-
1256-
s.onload = () => {
1257-
inEl.removeChild(s);
1258-
resolve();
1259-
};
1260-
1261-
s.onerror = () => {
1262-
inEl.removeChild(s);
1263-
reject();
1264-
};
1265-
1266-
inEl.appendChild(s);
1267-
1268-
});
1269-
1270-
}
1271-
1272-
1273-
// load a stylesheet
1274-
function loadStyleSheet(href, inEl) {
1275-
1276-
inEl = inEl ?? document.head;
1277-
1278-
return new Promise((resolve, reject) => {
1279-
1280-
let s = document.createElement('link');
1281-
s.href = href;
1282-
s.rel = 'stylesheet';
1283-
1284-
s.onload = () => {
1285-
resolve();
1286-
};
1287-
1288-
s.onerror = () => {
1289-
reject();
1290-
};
1291-
1292-
inEl.appendChild(s);
1293-
1294-
});
1295-
1296-
}
1297-
1298-
1299-
1300-
async function asyncForEach(array, callback) {
1301-
for (let index = 0; index < array.length; index++) {
1302-
await callback(array[index], index, array);
1303-
}
1304-
}

0 commit comments

Comments
 (0)