@@ -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
0 commit comments