Skip to content

Commit

Permalink
Codeit 3.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
benhatsor authored Aug 3, 2022
2 parents 03a5e38 + 2712ebb commit 6cb2e5f
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 156 deletions.
102 changes: 59 additions & 43 deletions filebrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ async function renderSidebarHTML() {
// stop loading
stopLoading();

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


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


// if not logged in
if (gitToken == '') {

const dialogResp = await showDialog(openGitHubLogin, 'Hmm... the repo you\'re\nlooking for can\'t be found.\nTry logging in.', 'Login', true);

// if chosen to log in, return
if (dialogResp == true) return;

} else { // if logged in

await showDialog(hideDialog, 'Hmm... the repo you\'re\nlooking for can\'t be found.', 'OK', true);

}


// change location
treeLoc[1] = '';
treeLoc[2] = '';
Expand Down Expand Up @@ -681,10 +694,20 @@ async function renderSidebarHTML() {
// if repo obj dosen't already exist
if (!modifiedRepos[item.full_name]) {

// get repo data expiration time
// (two months from now)

let expirationDate = new Date();
expirationDate.setDate(expirationDate.getDate() + (2 * 4 * 7));

const twoMonthsTime = expirationDate.getTime();


// create repo obj
repoObj = createRepoObj(item.full_name, item.default_branch, item.default_branch,
(item.permissions.push ?? false),
null, item.private, item.fork, false);
null, item.private, item.fork, false,
twoMonthsTime, 0);

} else {

Expand Down Expand Up @@ -936,13 +959,13 @@ async function clickedOnFileHTML(fileEl, event) {

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

// if canceled push, return
if (!commitMessage) return;

// if not specified message
if (commitMessage === 'Type push description...') {
if (commitMessage === 'Type commit message...') {

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


async function checkPushDialogs() {
function openGitHubLogin() {

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

function openLogin() {
if (isMobile) {

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

if (isMobile) {
} else {

window.location.href = authURL;
window.addEventListener('message', (event) => {

} else {
// if received a git code
if (event.origin === window.location.origin &&
event.data.startsWith('gitCode=')) {

window.addEventListener('message', (event) => {
// hide dialog
hideDialog();

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

// hide dialog
dialogWrapper.classList.remove('visible');
}

showMessage('Logging in...', -1);
});

}
// open login window
window.open(authURL, 'Login with GitHub', 'height=575,width=575');

});
}

// open login window
window.open(authURL, 'Login with Github', 'height=575,width=575');
}

}

}
async function checkPushDialogs() {

showDialog(openLogin, 'Login to save this file.', 'Login');
// if not logged in to git
if (gitToken == '') {

showDialog(openGitHubLogin, 'Login to save this file.', 'Login');

return 'return';

Expand Down Expand Up @@ -1047,7 +1071,7 @@ async function checkPushDialogs() {
async function forkRepo() {

// hide dialog
dialogWrapper.classList.remove('visible');
hideDialog();

// if on mobile,
// change status bar color
Expand Down Expand Up @@ -1129,12 +1153,14 @@ async function checkPushDialogs() {
// for fork

const newRepoObj = createRepoObj((loggedUser + '/' + repoName), repoObj.selBranch, repoObj.defaultBranch,
true, repoObj.branches, repoObj.private, true, false);
true, repoObj.branches, repoObj.private, true, false,
repoObj.repoDataExpiration, repoObj.branchExpiration);

modifiedRepos[loggedUser + '/' + repoName] = newRepoObj;

updateModReposLS();


// change location
treeLoc[0] = loggedUser;
saveTreeLocLS(treeLoc);
Expand All @@ -1151,7 +1177,7 @@ async function checkPushDialogs() {
}

const dialogResult = await showDialog(forkRepo,
'Fork this repository to save your changes.',
'Fork this repository\nto save your changes.',
'Fork');

if (dialogResult === false) return 'return';
Expand Down Expand Up @@ -2076,7 +2102,7 @@ function createNewRepoInHTML() {

// create new repo obj
const repoObj = createRepoObj((loggedUser + '/' + repoName), 'main', 'main',
true, null, repoPrivate, false, true);
true, null, repoPrivate, false, true, 0, 0);

// add repo obj to modified repos
addRepoToModRepos(repoObj);
Expand Down Expand Up @@ -2217,16 +2243,6 @@ function createNewFileInHTML() {

// if file name is empty, use default name
if (fileName === '') fileName = 'new-file';

// replace all special chars in name with dashes

const specialChars = validateString(fileName);

if (specialChars) {

specialChars.forEach(char => { fileName = fileName.replaceAll(char, '-') });

}


// if another file in the current directory
Expand Down
17 changes: 13 additions & 4 deletions full.css
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ body.scroll-enabled .bookmark {
will-change: transform;
transition: .18s var(--ease-function) left,
.4s var(--cubic-function) transform,
.4s var(--cubic-function) padding;
.4s var(--cubic-function) padding,
.18s var(--bounce-function) opacity;
}

.sidebar-toggle::after {
Expand Down Expand Up @@ -592,6 +593,11 @@ body.embed .sidebar-toggle {
display: none;
}

.sidebar-toggle.dialog-visible {
opacity: 0;
pointer-events: none;
}

body.expanded .sidebar-toggle {
transform: translateX(calc(var(--sidebar-width) - 1px));
}
Expand Down Expand Up @@ -1737,8 +1743,6 @@ body.mobile .dialog-background {
border: 1px solid rgb(32 34 37 / 60%);
border-radius: 11.5px;
line-height: 1.5;
max-width: 200px;
width: 194px;
opacity: 0;
padding: 2px;
transition: 0s .18s, .18s var(--bounce-function) opacity;
Expand All @@ -1753,6 +1757,7 @@ body.mobile .dialog-background {

.dialog .title {
padding: 8px 14px;
white-space: pre-wrap;
}

.dialog .button-wrapper {
Expand All @@ -1765,13 +1770,17 @@ body.mobile .dialog-background {
border-radius: 5.75px;
display: flex;
justify-content: center;
width: 50%;
flex: 1;
}

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

.dialog-wrapper.one-button .dialog .cancel {
display: none;
}

.dialog .confirm {
color: var(--rosemary-lighter);
font-weight: 500;
Expand Down
2 changes: 1 addition & 1 deletion git/gitauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ window.onload = async () => {

} else {

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

}

Expand Down
8 changes: 7 additions & 1 deletion lib/plugins/codeit-match-braces.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,18 @@
const cursor = cd.dropper.cursor();

if (cursor && cursor.in('brace')) {

const currentBrace = cursor.getParent();

if (currentBrace.id) {

currentBrace.classList.add('brace-active');
getPartnerBrace(currentBrace).classList.add('brace-active');

const partnerBrace = getPartnerBrace(currentBrace);
if (partnerBrace) partnerBrace.classList.add('brace-active');

}

}

}
Expand Down
1 change: 1 addition & 0 deletions live-view/extensions/markdown-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

html {
background: var(--bg-color);
scroll-padding: 16px;
}

body {
Expand Down
78 changes: 10 additions & 68 deletions live-view/live-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,17 @@ async function setupLiveView() {

// don't transition live view
liveView.classList.add('notransition');

// hide live view
liveView.classList.remove('visible');

// restore transition on next frame

onNextFrame(() => {
liveView.classList.remove('notransition');

// hide live view
liveView.classList.remove('visible');

// restore transition on next frame
onNextFrame(() => {
liveView.classList.remove('notransition');
});

});

}
Expand Down Expand Up @@ -1240,65 +1244,3 @@ async function renderLiveViewMarkdown(file) {

}



// lazy load an external script
function loadScript(src, inEl) {

inEl = inEl ?? document.body;

return new Promise((resolve, reject) => {

let s = document.createElement('script');
s.src = src;
//s.async = true;

s.onload = () => {
inEl.removeChild(s);
resolve();
};

s.onerror = () => {
inEl.removeChild(s);
reject();
};

inEl.appendChild(s);

});

}


// load a stylesheet
function loadStyleSheet(href, inEl) {

inEl = inEl ?? document.head;

return new Promise((resolve, reject) => {

let s = document.createElement('link');
s.href = href;
s.rel = 'stylesheet';

s.onload = () => {
resolve();
};

s.onerror = () => {
reject();
};

inEl.appendChild(s);

});

}



async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
}
Loading

0 comments on commit 6cb2e5f

Please sign in to comment.