-\r
-// Init process to commit the new comment\r
-function startCommitProcess()\r
-{ \r
- if($('#chkSignedOff').is(':checked')){\r
- var numL = preElement.attr("title");\r
- commentLineStart = numL.split('-')[0] - 1; \r
- if(addNewComment) { commentLineStart++; }\r
- commentLineEnd = (commentLineStart + preElement.text().split('\n').length) - 1;\r
- state = true; \r
- replaceComment(updateComment, currentfileContent);\r
- getLastCommit(); \r
- getBaseTree(); \r
- editComment = false;\r
- }\r
- else{\r
- displayMessage('Please sign this commit', 40, 40); \r
- }\r
-}\r
-\r
-function displayLogginModal(){\r
- if ($('.popover').is(':hidden')) { \r
- if(sessionStarted){ getListBranches(); }\r
- $('.popover').show(); \r
- }\r
- else { $('.popover').hide(); } \r
- updateDisplaying();\r
-}\r
-\r
-function updateDisplaying(){\r
- if (checkCookie())\r
- {\r
- userB64 = "Basic " + getUserPass("logginNitdoc"); \r
- $('#loginGit').hide();\r
- $('#passwordGit').hide();\r
- $('#lbpasswordGit').hide(); \r
- $('#lbloginGit').hide(); \r
- $('#repositoryGit').hide();\r
- $('#lbrepositoryGit').hide();\r
- $('#lbbranchGit').hide(); \r
- $('#branchGit').hide();\r
- $('#listBranches').show();\r
- $('#divGitHubRepoDisplay').show();\r
- $("#liGitHub").attr("class", "current");\r
- $("#imgGitHub").attr("src", "resources/icons/github-icon-w.png");\r
- $('#nickName').text(userName);\r
- $('#githubAccount').attr("href", "https://github.com/"+userName);\r
- $('#logginMessage').css({'display' : 'block'});\r
- $('#logginMessage').css({'text-align' : 'center'});\r
- $('.popover').css({'height' : '190px'});\r
- $('#signIn').text("Sign out");\r
- $('#githubRepoDisplay').text(githubRepo);\r
- sessionStarted = true;\r
- reloadComment();\r
- }\r
- else\r
- {\r
- sessionStarted = false;\r
- $('#logginMessage').css({'display' : 'none'});\r
- $("#liGitHub").attr("class", "");\r
- $("#imgGitHub").attr("src", "resources/icons/github-icon.png");\r
- $('#loginGit').val("");\r
- $('#passwordGit').val("");\r
- $('#nickName').text("");\r
- $('.popover').css({'height' : '325px'});\r
- $('#logginMessage').css({'display' : 'none'});\r
- $('#repositoryGit').val($('#repoName').attr('name'));\r
- $('#branchGit').val('wikidoc'); \r
- $('#signIn').text("Sign In");\r
- $('#loginGit').show();\r
- $('#passwordGit').show();\r
- $('#lbpasswordGit').show();\r
- $('#lbloginGit').show(); \r
- $('#repositoryGit').show();\r
- $('#lbrepositoryGit').show();\r
- $('#lbbranchGit').show(); \r
- $('#branchGit').show(); \r
- $('#listBranches').hide();\r
- $('#divGitHubRepoDisplay').hide();\r
- }\r
-}\r
-\r
-function setCookie(c_name, value, exdays)\r
-{\r
- var exdate=new Date();\r
- exdate.setDate(exdate.getDate() + exdays);\r
- var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());\r
- document.cookie=c_name + "=" + c_value;\r
-}\r
-\r
-function del_cookie(c_name)\r
-{\r
- document.cookie = c_name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';\r
-}\r
-\r
-function updateCookie(user, pwd, repo, branch){\r
- if(checkCookie()){\r
- branchName = branch;\r
- setCookie("logginNitdoc", base64.encode(user+':'+pwd+':'+repo+':'+branch), 1);\r
- }\r
-}\r
-\r
-function getCookie(c_name)\r
-{\r
- var c_value = document.cookie;\r
- var c_start = c_value.indexOf(" " + c_name + "=");\r
- if (c_start == -1) { c_start = c_value.indexOf(c_name + "="); }\r
- if (c_start == -1) { c_value = null; }\r
- else\r
- {\r
- c_start = c_value.indexOf("=", c_start) + 1;\r
- var c_end = c_value.indexOf(";", c_start);\r
- if (c_end == -1) { c_end = c_value.length; }\r
- c_value = unescape(c_value.substring(c_start,c_end));\r
- }\r
- return c_value;\r
-}\r
-\r
-function getUserPass(c_name){\r
- var cookie = base64.decode(getCookie(c_name));\r
- return base64.encode(cookie.split(':')[0] + ':' + cookie.split(':')[1]);\r
-}\r
-\r
-function checkCookie()\r
-{\r
- var cookie=getCookie("logginNitdoc");\r
- if (cookie!=null && cookie!="")\r
- {\r
- cookie = base64.decode(cookie);\r
- userName = cookie.split(':')[0];\r
- password = cookie.split(':')[1];\r
- githubRepo = cookie.split(':')[2]; \r
- branchName = cookie.split(':')[3];\r
- return true;\r
- }\r
- else { return false; }\r
-}\r
-\r
-\r
-/*\r
-* Base64\r
-*/\r
-base64 = {};\r
-base64.PADCHAR = '=';\r
-base64.ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\r
-base64.getbyte64 = function(s,i) {\r
- // This is oddly fast, except on Chrome/V8.\r
- // Minimal or no improvement in performance by using a\r
- // object with properties mapping chars to value (eg. 'A': 0)\r
- var idx = base64.ALPHA.indexOf(s.charAt(i));\r
- if (idx == -1) {\r
- throw "Cannot decode base64";\r
- }\r
- return idx;\r
-}\r
-\r
-base64.decode = function(s) {\r
- // convert to string\r
- s = "" + s;\r
- var getbyte64 = base64.getbyte64;\r
- var pads, i, b10;\r
- var imax = s.length\r
- if (imax == 0) {\r
- return s;\r
- }\r
-\r
- if (imax % 4 != 0) {\r
- throw "Cannot decode base64";\r
- }\r
-\r
- pads = 0\r
- if (s.charAt(imax -1) == base64.PADCHAR) {\r
- pads = 1;\r
- if (s.charAt(imax -2) == base64.PADCHAR) {\r
- pads = 2;\r
- }\r
- // either way, we want to ignore this last block\r
- imax -= 4;\r
- }\r
-\r
- var x = [];\r
- for (i = 0; i < imax; i += 4) {\r
- b10 = (getbyte64(s,i) << 18) | (getbyte64(s,i+1) << 12) |\r
- (getbyte64(s,i+2) << 6) | getbyte64(s,i+3);\r
- x.push(String.fromCharCode(b10 >> 16, (b10 >> 8) & 0xff, b10 & 0xff));\r
- }\r
-\r
- switch (pads) {\r
- case 1:\r
- b10 = (getbyte64(s,i) << 18) | (getbyte64(s,i+1) << 12) | (getbyte64(s,i+2) << 6)\r
- x.push(String.fromCharCode(b10 >> 16, (b10 >> 8) & 0xff));\r
- break;\r
- case 2:\r
- b10 = (getbyte64(s,i) << 18) | (getbyte64(s,i+1) << 12);\r
- x.push(String.fromCharCode(b10 >> 16));\r
- break;\r
- }\r
- return x.join('');\r
-}\r
-\r
-base64.getbyte = function(s,i) {\r
- var x = s.charCodeAt(i);\r
- if (x > 255) {\r
- throw "INVALID_CHARACTER_ERR: DOM Exception 5";\r
- }\r
- return x;\r
-}\r
-\r
-\r
-base64.encode = function(s) {\r
- if (arguments.length != 1) {\r
- throw "SyntaxError: Not enough arguments";\r
- }\r
- var padchar = base64.PADCHAR;\r
- var alpha = base64.ALPHA;\r
- var getbyte = base64.getbyte;\r
-\r
- var i, b10;\r
- var x = [];\r
-\r
- // convert to string\r
- s = "" + s;\r
-\r
- var imax = s.length - s.length % 3;\r
-\r
- if (s.length == 0) {\r
- return s;\r
- }\r
- for (i = 0; i < imax; i += 3) {\r
- b10 = (getbyte(s,i) << 16) | (getbyte(s,i+1) << 8) | getbyte(s,i+2);\r
- x.push(alpha.charAt(b10 >> 18));\r
- x.push(alpha.charAt((b10 >> 12) & 0x3F));\r
- x.push(alpha.charAt((b10 >> 6) & 0x3f));\r
- x.push(alpha.charAt(b10 & 0x3f));\r
- }\r
- switch (s.length - imax) {\r
- case 1:\r
- b10 = getbyte(s,i) << 16;\r
- x.push(alpha.charAt(b10 >> 18) + alpha.charAt((b10 >> 12) & 0x3F) +\r
- padchar + padchar);\r
- break;\r
- case 2:\r
- b10 = (getbyte(s,i) << 16) | (getbyte(s,i+1) << 8);\r
- x.push(alpha.charAt(b10 >> 18) + alpha.charAt((b10 >> 12) & 0x3F) +\r
- alpha.charAt((b10 >> 6) & 0x3f) + padchar);\r
- break;\r
- }\r
- return x.join('');\r
-}\r
-\r
-\r
-\r
-function getLastCommit() \r
-{ \r
- var urlHead = '';\r
- if(sessionStarted){ urlHead = "https://api.github.com/repos/"+userName+"/"+githubRepo+"/git/refs/heads/"+branchName;}\r
- else{ \r
- // TODO: get url of the original repo.\r
- return;\r
- }\r
-\r
- $.ajax({\r
- beforeSend: function (xhr) { \r
- if (userB64 != ""){ xhr.setRequestHeader ("Authorization", userB64); }\r
- },\r
- type: "GET",\r
- url: urlHead,\r
- dataType:"json",\r
- async: false,\r
- success: function(success)\r
- { \r
- shaLastCommit = success.object.sha; \r
- }\r
- });\r
-}\r
-\r
-function getBaseTree()\r
-{ \r
- $.ajax({ \r
- beforeSend: function (xhr) { \r
- if (userB64 != ""){ xhr.setRequestHeader ("Authorization", userB64); }\r
- },\r
- type: "GET",\r
- url: "https://api.github.com/repos/"+userName+"/"+githubRepo+"/git/commits/" + shaLastCommit,\r
- dataType:"json",\r
- async: false,\r
- success: function(success)\r
- { \r
- shaBaseTree = success.tree.sha;\r
- if (state){ setBlob(); }\r
- else{ return; } \r
- },\r
- error: function(){\r
- return;\r
- }\r
- }); \r
-}\r
-\r
-function setNewTree()\r
-{\r
- $.ajax({ \r
- beforeSend: function (xhr) { xhr.setRequestHeader ("Authorization", userB64); },\r
- type: "POST",\r
- url: "https://api.github.com/repos/"+userName+"/"+githubRepo+"/git/trees", \r
- async: false,\r
- dataType:'json',\r
- data:'{ "base_tree" : "'+shaBaseTree+'", '+\r
- '"tree":[{ '+\r
- '"path":"'+ pathFile +'",'+\r
- '"mode":"100644",'+\r
- '"type":"blob",'+\r
- '"sha": "'+ shaBlob +'"'+\r
- '}] '+\r
- '}', \r
- success: function(success)\r
- { // si l'appel a bien fonctionné\r
- shaNewTree = success.sha;\r
- setNewCommit(); \r
- },\r
- error: function(){\r
- return;\r
- }\r
- });\r
-}\r
-\r
-function setNewCommit()\r
-{\r
- addSignedOff();\r
- $.ajax({ \r
- beforeSend: function (xhr) { xhr.setRequestHeader ("Authorization", userB64); },\r
- type: "POST",\r
- url: "https://api.github.com/repos/"+userName+"/"+githubRepo+"/git/commits", \r
- async: false,\r
- dataType:'json',\r
- data:'{ "message" : "'+ commitMessage +'", '+\r
- '"parents" :"'+shaLastCommit+'",'+ \r
- '"tree": "'+shaNewTree+'"'+\r
- '}', \r
- success: function(success)\r
- {\r
- shaNewCommit = success.sha;\r
- commit(); \r
- },\r
- error: function(){\r
- return;\r
- }\r
- });\r
-}\r
-\r
-//Create a commit\r
-function commit()\r
-{\r
- $.ajax({ \r
- beforeSend: function (xhr) { xhr.setRequestHeader ("Authorization", userB64); },\r
- type: "POST",\r
- url: "https://api.github.com/repos/"+userName+"/"+githubRepo+"/git/refs/heads/"+branchName, \r
- dataType:'json',\r
- data:'{ "sha" : "'+shaNewCommit+'", '+\r
- '"force" :"true"'+\r
- '}',\r
- success: function(success) { displayMessage('Commit created successfully', 40, 40); },\r
- error:function(error){ displayMessage('Error ' + error.object.message, 40, 40); }\r
- });\r
-}\r
-\r
-// Create a blob\r
-function setBlob()\r
-{\r
- $.ajax({\r
- beforeSend: function (xhr) { xhr.setRequestHeader ("Authorization", userB64); },\r
- type: "POST", \r
- url: "https://api.github.com/repos/"+userName+"/"+githubRepo+"/git/blobs", \r
- async: false,\r
- dataType:'json',\r
- data:'{ "content" : "'+text.replace(/\r?\n/g, '\\n').replace(/\t/g, '\\t').replace(/\"/g,'\\"')+'", '+\r
- '"encoding" :"utf-8"'+\r
- '}',\r
- success: function(success)\r
- { \r
- shaBlob = success.sha;\r
- setNewTree(); \r
- },\r
- error:function(error){ \r
- displayMessage('Error : Problem parsing JSON', 40, 40); \r
- return;\r
- }\r
- });\r
-}\r
-\r
-// Display file content\r
-function getFileContent(urlFile, newComment)\r
-{\r
- $.ajax({\r
- beforeSend: function (xhr) { \r
- xhr.setRequestHeader ("Accept", "application/vnd.github-blob.raw");\r
- if (userB64 != ""){ xhr.setRequestHeader ("Authorization", userB64); }\r
- },\r
- type: "GET", \r
- url: urlFile, \r
- async:false,\r
- success: function(success)\r
- {\r
- state = true;\r
- replaceComment(newComment, success); \r
- }\r
- });\r
-}\r
-\r
-function replaceComment(newComment, fileContent){\r
- var arrayNew = newComment.split('\n'); \r
- var lNew = arrayNew.length;\r
- text = "";\r
- var lines = fileContent.split("\n");\r
- for (var i = 0; i < lines.length; i++) {\r
- if(i == commentLineStart){\r
- if(addNewComment){\r
- for(var indexLine=0; indexLine < lines[i+1].length; indexxLine++){\r
- if(lines[i+1].substr(indexLine,1) == "\t" || lines[i+1].substr(indexLine,1) == "#"){ text += lines[i+1].substr(indexLine,1); }\r
- else{ break;}\r
- }\r
- text += lines[i] + "\n"; \r
- }\r
- // We change the comment\r
- for(var j = 0; j < lNew; j++){\r
- if(commentType == 1){ text += "\t# " + arrayNew[j] + "\n"; }\r
- else{\r
- if(arrayNew[j] == ""){ text += "#"+"\n"; }\r
- else{ text += "# " + arrayNew[j] + "\n"; }\r
- }\r
- }\r
- }\r
- else if(i < commentLineStart || i >= commentLineEnd){\r
- if(i == lines.length-1){ text += lines[i]; }\r
- else{ text += lines[i] + "\n"; }\r
- }\r
- }\r
- if(addNewComment){\r
- addNewComment = false;\r
- }\r
-}\r
-\r
-function getCommentLastCommit(path){\r
- var urlRaw;\r
- getLastCommit();\r
- if(shaLastCommit != ""){\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
-function displayMessage(msg, widthDiv, margModal){\r
- spinner.stop();\r
- $('#modal').hide();\r
- $('#btnCancelBranch').hide(); \r
- $('#modalQuestion').show().prepend('<a class="close"><img src="resources/icons/close.png" class="btnCloseQuestion" title="Close" alt="Close" /></a>');\r
- $('#txtQuestion').text(msg);\r
- $('#btnCreateBranch').text("Ok");\r
- var xModal = $('#modalQuestion').css('width').split('px')[0];\r
- var yModal = $('#modalQuestion').css('height').split('px')[0];\r
- var x = $(document).width/2 - xModal/2;\r
- var y = $(document).height/2 - yModal/2;\r
- var xBtnBranch = $('#btnCreateBranch').css('width').split('px')[0];\r
- $('#modalQuestion').css({'left' : x, 'top' : y});\r
- $('#modalQuestion').show();\r
- $('#btnCreateBranch').css('margin-left', xModal/2 - xBtnBranch);\r
- $('body').append('<div id="fade"></div>');\r
- $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();\r
-}\r
-\r
-function displaySpinner(){\r
- spinner.spin(targetSpinner);\r
- $("#waitCommit").show();\r
-}\r
-\r
-// Check if the repo already exist\r
-function isRepoExisting(){\r
- $.ajax({\r
- beforeSend: function (xhr) { \r
- if (userB64 != "") { xhr.setRequestHeader ("Authorization", userB64); }\r
- },\r
- type: "GET", \r
- url: "https://api.github.com/repos/"+userName+"/"+githubRepo, \r
- async:false,\r
- dataType:'json',\r
- success: function(){ repoExist = true; },\r
- error: function()\r
- {\r
- displayMessage('Repo not found !', 35, 45);\r
- repoExist = false;\r
- }\r
- });\r
-}\r
-\r
-// Check if the branch already exist\r
-function isBranchExisting(){\r
- $.ajax({\r
- beforeSend: function (xhr) {\r
- if (userB64 != "") { xhr.setRequestHeader ("Authorization", userB64); }\r
- },\r
- type: "GET",\r
- url: "https://api.github.com/repos/"+userName+"/"+githubRepo+"/git/refs/heads/"+branchName,\r
- async:false,\r
- dataType:'json',\r
- success: function(){ branchExist = true; },\r
- error: function()\r
- {\r
- branchExist = false;\r
- editComment -= 1;\r
- $('#modal').hide();\r
- $('#txtQuestion').text("Are you sure you want to create that branch ?");\r
- $('#btnCancelBranch').show();\r
- $('#btnCreateBranch').text("Yes");\r
- $('#modalQuestion').show();\r
- $('#modalQuestion').show().prepend('<a class="close"><img src="resources/icons/close.png" class="btnCloseQuestion" title="Close" alt="Close" /></a>');\r
- $('body').append('<div id="fade"></div>');\r
- $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();\r
- }\r
- });\r
-}\r
-\r
-function getMasterSha() \r
-{\r
- $.ajax({\r
- beforeSend: function (xhr) { \r
- if (userB64 != ""){ xhr.setRequestHeader ("Authorization", userB64); }\r
- },\r
- type: "GET",\r
- url: "https://api.github.com/repos/"+userName+"/"+githubRepo+"/git/refs/heads/master",\r
- dataType:"json",\r
- async: false,\r
- success: function(success) { shaMaster = success.object.sha; }\r
- });\r
-}\r
-\r
-function createBranch(){\r
-\r
- getMasterSha();\r
-\r
- $.ajax({ \r
- beforeSend: function (xhr) { xhr.setRequestHeader ("Authorization", userB64); },\r
- type: "POST",\r
- url: "https://api.github.com/repos/"+userName+"/"+githubRepo+"/git/refs", \r
- data:'{ "ref" : "refs/heads/'+branchName+'",'+\r
- '"sha" : "'+shaMaster+'"'+\r
- '}',\r
- success: function(){ return; },\r
- error: function(){\r
- editComment -= 1;\r
- displayMessage('Impossible to create the new branch : ' + branchName, 40, 40);\r
- }\r
- });\r
-}\r
-\r
-$.fn.spin = function(opts) {\r
- this.each(function() {\r
- var $this = $(this),\r
- data = $this.data();\r
-\r
- if (data.spinner) {\r
- data.spinner.stop();\r
- delete data.spinner;\r
- }\r
- if (opts !== false) {\r
- data.spinner = new Spinner($.extend({color: $this.css('color')}, opts)).spin(this);\r
- }\r
- });\r
- return this;\r
-};\r
-\r
-function reloadComment(){\r
- $.when(getCommentLastCommit($('pre[class=text_label]').attr('tag'))).done(function(){\r
- $('pre[class=text_label]').each(function(){ getCommentOfFunction($(this)); });\r
- });\r
-}\r
-\r
-function getCommentOfFunction(element){\r
- var textC = ""; \r
- var numL = element.attr("title");\r
- if(numL != null){ \r
- commentLineStart = numL.split('-')[0] - 1;\r
- commentLineEnd = (commentLineStart + element.text().split('\n').length) - 1;\r
- var lines = currentfileContent.split("\n");\r
- for (var i = 0; i < lines.length; i++) {\r
- if(i >= commentLineStart-1 && i <= commentLineEnd){\r
- if (lines[i].substr(1,1) == "#"){ textC += lines[i].substr(3,lines[i].length) + "\n";}\r
- else if(lines[i].substr(0,1) == '#'){ textC += lines[i].substr(2,lines[i].length) + "\n"; }\r
- }\r
- }\r
- if (textC != ""){ element.text(textC); }\r
- }\r
-}\r
-\r
-// Get list of branches\r
-function getListBranches()\r
-{\r
- cleanListBranches();\r
- $.ajax({\r
- beforeSend: function (xhr) { \r
- if ($("#login").val() != ""){ xhr.setRequestHeader ("Authorization", userB64); }\r
- },\r
- type: "GET", \r
- url: "https://api.github.com/repos/"+userName+"/"+githubRepo+"/branches", \r
- async:false,\r
- dataType:'json',\r
- success: function(success)\r
- { \r
- for(var branch in success) { \r
- var selected = '';\r
- if(branchName == success[branch].name){\r
- selected = 'selected';\r
- }\r
- $('#dropBranches').append('<option value="" '+ selected +'>' + success[branch].name + '</option>');\r
- }\r
- }\r
- });\r
-}\r
-\r
-// Delete all option in the list\r
-function cleanListBranches(){\r
- $('#dropBranches').children("option").remove();\r
-}\r
-\r
-function closeAllCommentInEdtiting(){\r
- $('a[id=cancelBtn]').each(function(){\r
- closeEditing($(this));\r
- });\r
-}\r
-\r
-function closeEditing(tag){\r
- if(editComment > 0){ editComment -= 1; }\r
- // Hide itself\r
- tag.hide();\r
- // Hide commitBtn\r
- tag.next().hide();\r
- // Hide Textarea\r
- tag.prev().hide();\r
- // Show comment\r
- tag.prev().prev().show();\r
-}\r
-\r
-function checkSignIn(){\r
- var response = false;\r
- $.ajax({\r
- beforeSend: function (xhr) {\r
- if ($("#login").val() != ""){ xhr.setRequestHeader ("Authorization", userB64); }\r
- },\r
- type: "GET",\r
- url: "https://api.github.com/repos/"+userName+"/"+githubRepo,\r
- async:false,\r
- dataType:'json',\r
- success: function(success)\r
- {\r
- getUserInfo();\r
- response = true;\r
- displayMessage('You are now logged in');\r
- },\r
- error: function()\r
- {\r
- displayMessage('Error : Wrong username or password');\r
- response = false;\r
- }\r
- });\r
- return response;\r
-}\r
-\r
-function getUserInfo(){\r
- $.ajax({\r
- beforeSend: function (xhr) {\r
- if ($("#login").val() != ""){ xhr.setRequestHeader ("Authorization", userB64); }\r
- },\r
- type: "GET",\r
- url: "https://api.github.com/user/emails",\r
- async:false,\r
- dataType:'json',\r
- success: function(success)\r
- { \r
- userEmail = success;\r
- }\r
- });\r
-}\r
-\r
-function getSignedOff(){\r
- $.ajax({\r
- beforeSend: function (xhr) {\r
- if ($("#login").val() != ""){ xhr.setRequestHeader ("Authorization", userB64); }\r
- },\r
- type: "GET",\r
- url: "https://api.github.com/users/"+userName,\r
- async:false,\r
- dataType:'json',\r
- success: function(success)\r
- {\r
- signedOff = success.name;\r
- }\r
- });\r
-}\r
-\r
-function addSignedOff(){\r
- $.when(getUserInfo()).done(function(){\r
- $.when(getSignedOff()).done(function(){\r
- $('#commitMessage').val($('#commitMessage').val() + "\n\nSigned-off-by: "+signedOff+" <"+userEmail+">");\r
- });\r
- });\r
- resizeTextarea($('#commitMessage'));\r
-}\r
-\r
-function removeSignedOff(){\r
- $('#commitMessage').val(commitMessage); \r
- resizeTextarea($('#commitMessage'));\r
-}\r
-\r
-function resizeTextarea(element){\r
- var nLines = element.val().split('\n').length + 1;\r
- element.attr('rows', nLines);\r
-}\r