Skip to content

Commit 1a5d810

Browse files
committed
Update filebrowser.js
1 parent 7c436b9 commit 1a5d810

File tree

1 file changed

+40
-59
lines changed

1 file changed

+40
-59
lines changed

filebrowser.js

Lines changed: 40 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -957,47 +957,60 @@ async function clickedOnFileHTML(fileEl, event) {
957957
if (dialogResp === 'return') return;
958958

959959

960-
let commitMessage;
961-
962960
// if ctrl/cmd/shift-clicked on push button
963961
if (!isMobile && (isKeyEventMeta(event) || event.shiftKey)) {
964962

965-
// get selected branch
966-
let selBranch = treeLoc[1].split(':')[1];
967-
968-
// open push screen
969-
commitMessage = prompt('Push \''+ fileEl.innerText + (selBranch ? '\' to branch \'' + selBranch + '\'?' : '\'?'),
970-
'Type commit message...');
971-
972-
// if canceled push, return
973-
if (!commitMessage) return;
974-
975-
// if not specified message
976-
if (commitMessage === 'Type commit message...') {
977-
978-
// show default message
979-
commitMessage = 'Update ' + fileEl.innerText;
980-
981-
}
963+
pushFileWithCommitMessageHTML();
982964

983965
} else {
984966

985-
commitMessage = 'Update ' + fileEl.innerText;
967+
const commitMessage = 'Update ' + fileEl.innerText;
986968

987-
}
969+
// play push animation
970+
playPushAnimation(fileEl.querySelector('.push-wrapper'));
971+
972+
// push file
973+
pushFileFromHTML(fileEl, commitMessage);
988974

989-
990-
// play push animation
991-
playPushAnimation(fileEl.querySelector('.push-wrapper'));
992-
993-
// push file
994-
pushFileFromHTML(fileEl, commitMessage);
975+
}
995976

996977
}
997978

998979
}
999980

1000981

982+
function pushFileWithCommitMessageHTML() {
983+
984+
let commitMessage;
985+
986+
// get selected branch
987+
let selBranch = treeLoc[1].split(':')[1];
988+
989+
// open push screen
990+
commitMessage = prompt('Push \''+ fileEl.innerText + (selBranch ? '\' to branch \'' + selBranch + '\'?' : '\'?'),
991+
'Type commit message...');
992+
993+
// if canceled push, return
994+
if (!commitMessage) return;
995+
996+
// if not specified message
997+
if (commitMessage === 'Type a commit message...') {
998+
999+
// show default message
1000+
commitMessage = 'Update ' + fileEl.innerText;
1001+
1002+
}
1003+
1004+
1005+
// play push animation
1006+
playPushAnimation(fileEl.querySelector('.push-wrapper'));
1007+
1008+
// push file
1009+
pushFileFromHTML(fileEl, commitMessage);
1010+
1011+
}
1012+
1013+
10011014
function openGitHubLogin() {
10021015

10031016
const authURL = 'https://github.com/login/oauth/authorize?client_id=7ede3eed3185e59c042d&scope=repo,user,write:org';
@@ -2400,38 +2413,6 @@ function createNewFileInHTML() {
24002413
clickedOnFileHTML(fileEl, e);
24012414

24022415
})
2403-
2404-
fileEl.querySelector('.push-wrapper')
2405-
.addEventListener('contextmenu', () => {
2406-
2407-
let commitMessage;
2408-
2409-
// get selected branch
2410-
let selBranch = treeLoc[1].split(':')[1];
2411-
2412-
// open push screen
2413-
commitMessage = prompt('Push '+ fileEl.innerText + (selBranch ? ' to branch ' + selBranch + '?' : '?'),
2414-
'Type a push description...');
2415-
2416-
// if canceled push, return
2417-
if (!commitMessage) return;
2418-
2419-
// if not specified message
2420-
if (commitMessage === 'Type a push description...') {
2421-
2422-
// show default message
2423-
commitMessage = 'Update ' + fileEl.innerText;
2424-
2425-
}
2426-
2427-
2428-
// play push animation
2429-
playPushAnimation(fileEl.querySelector('.push-wrapper'));
2430-
2431-
// push file
2432-
pushFileFromHTML(fileEl, commitMessage);
2433-
2434-
})
24352416

24362417
}
24372418

0 commit comments

Comments
 (0)