var repoExist = false;\r
var branchExist = false;\r
var githubRepo;\r
+var loginProcess = false; \r
\r
// Spinner vars\r
var opts = {\r
$('a[id=cancelBtn]').hide();\r
// Hide Authenfication form\r
$(".popover").hide();\r
- githubRepo = $('#repoName').attr('name');\r
// Update display\r
updateDisplaying();\r
/*\r
{\r
userName = $('#loginGit').val();\r
password = $('#passwordGit').val();\r
- repoName = $('#repositoryGit').val();\r
+ githubRepo = $('#repositoryGit').val();\r
branchName = $('#branchGit').val();\r
userB64 = "Basic " + base64.encode(userName+':'+password);\r
- setCookie("logginNitdoc", base64.encode(userName+':'+password+':'+repoName+':'+branchName), 1);\r
- $('#loginGit').val("");\r
- $('#passwordGit').val("");\r
- reloadComment();\r
+ // Check if repo exist\r
+ isRepoExisting();\r
+ if(repoExist){ \r
+ $.when(isBranchExisting()).done(function(){ \r
+ loginProcess = true; \r
+ if(branchExist){\r
+ setCookie("logginNitdoc", base64.encode(userName+':'+password+':'+githubRepo+':'+branchName), 1); \r
+ $('#loginGit').val("");\r
+ $('#passwordGit').val("");\r
+ reloadComment();\r
+ }\r
+ });\r
+ } \r
}\r
} \r
else\r
displayMessage("You need to be loggued before commit something", 100, 40);\r
$('.popover').show();\r
return;\r
- } \r
+ }\r
else{ userB64 = "Basic " + getUserPass("logginNitdoc"); }\r
- githubRepo = repoName;\r
// Check if repo exist\r
isRepoExisting();\r
if(repoExist){\r
createBranch();\r
commitMessage = $('#commitMessage').val();\r
if(commitMessage == ""){ commitMessage = "New commit"; }\r
- if(userB64 != ""){ \r
- if ($.trim(updateComment) == ''){ this.value = (this.defaultValue ? this.defaultValue : ''); }\r
- else{ startCommitProcess(); }\r
+ if(userB64 != ""){ \r
+ if(loginProcess){\r
+ setCookie("logginNitdoc", base64.encode(userName+':'+password+':'+githubRepo+':'+branchName), 1); \r
+ $('#loginGit').val("");\r
+ $('#passwordGit').val("");\r
+ loginProcess = false; \r
+ displayLogginModal();\r
+ }\r
+ else{\r
+ if ($.trim(updateComment) == ''){ this.value = (this.defaultValue ? this.defaultValue : ''); }\r
+ else{ startCommitProcess(); }\r
+ } \r
}\r
}\r
else\r
branchName = $(this).text();\r
}\r
});\r
- $.when(updateCookie(userName, password, repoName, branchName)).done(function(){\r
+ $.when(updateCookie(userName, password, githubRepo, branchName)).done(function(){\r
closeAllCommentInEdtiting();\r
reloadComment();\r
});\r
cookie = base64.decode(cookie);\r
userName = cookie.split(':')[0];\r
password = cookie.split(':')[1];\r
- repoName = cookie.split(':')[2]; \r
+ githubRepo = cookie.split(':')[2]; \r
branchName = cookie.split(':')[3];\r
return true;\r
}\r
var urlRaw;\r
getLastCommit();\r
if(shaLastCommit != ""){\r
- if (checkCookie()) { urlRaw="https://rawgithub.com/"+ userName +"/"+ repoName +"/" + shaLastCommit + "/" + path; }\r
- else{ urlRaw="https://rawgithub.com/StefanLage/"+ $('#repoName').attr('name') +"/" + shaLastCommit + "/" + path; }\r
-\r
- $.ajax({ \r
- type: "GET", \r
- url: urlRaw, \r
- async: false,\r
- success: function(success)\r
- {\r
- currentfileContent = success; \r
- }\r
- });\r
+ if (checkCookie()) {\r
+ urlRaw="https://rawgithub.com/"+ userName +"/"+ githubRepo +"/" + shaLastCommit + "/" + path;\r
+ $.ajax({ \r
+ type: "GET",\r
+ url: urlRaw,\r
+ async: false,\r
+ success: function(success)\r
+ {\r
+ currentfileContent = success;\r
+ }\r
+ });\r
+ }\r
}\r
}\r
\r