3 var sessionStarted
= false;
5 var currentfileContent
= '';
8 var shaLastCommit
= "";
14 var repoExist
= false;
17 * JQuery Case Insensitive :icontains selector
19 $
.expr
[':'].icontains
= function(obj
, index
, meta
, stack
){
20 return (obj
.textContent
.replace(/\
[[0-9]+\
]/g
, "") || obj
.innerText
.replace(/\
[[0-9]+\
]/g
, "") ||
jQuery(obj
).text().replace(/\
[[0-9]+\
]/g
, "") ||
'').toLowerCase().indexOf(meta
[3].toLowerCase()) >= 0;
24 * Quick Search global vars
27 // Current search results preview table
28 var currentTable
= null;
30 //Hightlighted index in search result preview table
31 var currentIndex
= -1;
35 * Add folding and filtering facilities to class description page.
37 $
(document
).ready(function() {
41 $
('a[id=commitBtn]').hide();
42 $
('a[id=cancelBtn]').hide();
43 // Hide Authenfication form
49 * Highlight the spoted element
51 highlightBlock(currentAnchor());
60 $
(document
.createElement("a"))
64 .css("cursor", "pointer")
66 if($
(this).find("a.fold").html() == "+") {
67 $
(this).find("a.fold").html("-");
69 $
(this).find("a.fold").html("+");
71 $
(this).nextAll().toggle();
74 // Insert search field
77 $
(document
.createElement("li"))
79 $
(document
.createElement("form"))
81 $
(document
.createElement("input"))
86 value
: "quick search..."
94 // Select previous result on "Up"
96 // If already on first result, focus search input
97 if(currentIndex
== 0) {
98 $
("#search").val($
(currentTable
.find("tr")[currentIndex]).data("searchDetails").name
);
100 // Else select previous result
101 } else if(currentIndex
> 0) {
102 $
(currentTable
.find("tr")[currentIndex]).removeClass("activeSearchResult");
104 $
(currentTable
.find("tr")[currentIndex]).addClass("activeSearchResult");
105 $
("#search").val($
(currentTable
.find("tr")[currentIndex]).data("searchDetails").name
);
106 $
("#search").focus();
110 // Select next result on "Down"
112 if(currentIndex
< currentTable
.find("tr").length
- 1) {
113 $
(currentTable
.find("tr")[currentIndex]).removeClass("activeSearchResult");
115 $
(currentTable
.find("tr")[currentIndex]).addClass("activeSearchResult");
116 $
("#search").val($
(currentTable
.find("tr")[currentIndex]).data("searchDetails").name
);
117 $
("#search").focus();
120 // Go to url on "Enter"
122 if(currentIndex
> -1) {
123 window
.location
= $
(currentTable
.find("tr")[currentIndex]).data("searchDetails").url
;
126 if($
("#search").val().length
== 0)
129 window
.location
= "full-index.html#q=" + $
("#search").val();
130 if(window
.location
.href
.indexOf("full-index.html") > -1) {
136 // Hide results preview on "Escape"
139 if(currentTable
!= null) {
140 currentTable
.remove();
146 if($
("#search").val().length
== 0) {
150 // Remove previous table
151 if(currentTable
!= null) {
152 currentTable
.remove();
155 // Build results table
157 currentTable
= $
(document
.createElement("table"));
159 // Escape regexp related characters in query
160 var query
= $
("#search").val();
161 query
= query
.replace(/\
[/gi
, "\\[");
162 query
= query
.replace(/\|
/gi
, "\\|");
163 query
= query
.replace(/\*/gi
, "\\*");
164 query
= query
.replace(/\
+/gi
, "\\+");
165 query
= query
.replace(/\\/gi
, "\\\\");
166 query
= query
.replace(/\?/gi
, "\\?");
167 query
= query
.replace(/\
(/gi
, "\\(");
168 query
= query
.replace(/\
)/gi
, "\\)");
171 var regexp
= new RegExp("^" + query
, "i");
172 for(var entry
in entries
) {
176 var result
= entry
.match(regexp
);
177 if(result
!= null && result
.toString().toUpperCase() == $
("#search").val().toUpperCase()) {
178 for(var i
= 0; i
< entries
[entry].length
; i
++) {
183 $
(document
.createElement("tr"))
184 .data("searchDetails", {name
: entry
, url
: entries
[entry][i]["url"]})
185 .data("index", index
)
186 .append($
(document
.createElement("td")).html(entry
))
188 $
(document
.createElement("td"))
189 .addClass("entryInfo")
190 .html(entries
[entry][i]["txt"] + " »"))
191 .mouseover( function() {
192 $
(currentTable
.find("tr")[currentIndex]).removeClass("activeSearchResult");
193 $
(this).addClass("activeSearchResult");
194 currentIndex
= $
(this).data("index");
196 .mouseout( function() {
197 $
(this).removeClass("activeSearchResult");
200 window
.location
= $
(this).data("searchDetails")["url"];
208 // Initialize table properties
209 currentTable
.attr("id", "searchTable");
210 currentTable
.css("position", "absolute");
211 currentTable
.width($
("#search").outerWidth());
212 $
("header").append(currentTable
);
213 currentTable
.offset({left
: $
("#search").offset().left
+ ($
("#search").outerWidth() - currentTable
.outerWidth()), top
: $
("#search").offset().top
+ $
("#search").outerHeight()});
215 // Preselect first entry
216 if(currentTable
.find("tr").length
> 0) {
218 $
(currentTable
.find("tr")[currentIndex]).addClass("activeSearchResult");
219 $
("#search").focus();
224 .focusout(function() {
225 if($
(this).val() == "") {
226 $
(this).addClass("notUsed");
227 $
(this).val("quick search...");
230 .focusin(function() {
231 if($
(this).val() == "quick search...") {
232 $
(this).removeClass("notUsed");
237 .submit( function() {
243 // Close quicksearch list on click
244 $
(document
).click(function(e
) {
245 if(e
.target
!= $
("#search")[0] && e
.target
!= $
("#searchTable")[0]) {
246 if(currentTable
!= null) {
247 currentTable
.remove();
253 // Insert filter field
254 $
("article.filterable h2, nav.filterable h3")
256 $
(document
.createElement("div"))
259 $
(document
.createElement("input"))
266 $
(this).parent().parent().find("ul li:not(:icontains('" + $
(this).val() + "'))").addClass("hide");
267 $
(this).parent().parent().find("ul li:icontains('" + $
(this).val() + "')").removeClass("hide");
269 .focusout(function() {
270 if($
(this).val() == "") {
271 $
(this).addClass("notUsed");
272 $
(this).val("filter...");
275 .focusin(function() {
276 if($
(this).val() == "filter...") {
277 $
(this).removeClass("notUsed");
284 // Filter toggle between H I R in nav porperties list
285 $
("nav.properties.filterable .filter")
287 $
(document
.createElement("a"))
290 title
: "hide inherited properties"
293 if($
(this).hasClass("hidden")) {
294 $
(this).parent().parent().find("li.inherit").show();
296 $
(this).parent().parent().find("li.inherit").hide();
299 $
(this).toggleClass("hidden");
303 $
(document
.createElement("a"))
306 title
: "hide redefined properties"
309 if($
(this).hasClass("hidden")) {
310 $
(this).parent().parent().find("li.redef").show();
312 $
(this).parent().parent().find("li.redef").hide();
315 $
(this).toggleClass("hidden");
319 $
(document
.createElement("a"))
322 title
: "hide introduced properties"
325 if($
(this).hasClass("hidden")) {
326 $
(this).parent().parent().find("li.intro").show();
328 $
(this).parent().parent().find("li.intro").hide();
331 $
(this).toggleClass("hidden");
335 // Filter toggle between I R in
336 $
("article.properties.filterable .filter, article.classes.filterable .filter")
338 $
(document
.createElement("a"))
341 title
: "hide introduced properties"
344 if($
(this).hasClass("hidden")) {
345 $
(this).parent().parent().find("li.intro").show();
347 $
(this).parent().parent().find("li.intro").hide();
350 $
(this).toggleClass("hidden");
354 $
(document
.createElement("a"))
357 title
: "hide redefined properties"
360 if($
(this).hasClass("hidden")) {
361 $
(this).parent().parent().find("li.redef").show();
363 $
(this).parent().parent().find("li.redef").hide();
366 $
(this).toggleClass("hidden");
373 $
("a[href*='#']").click( function() {
374 highlightBlock($
(this).attr("href").split(/#
/)[1]);
377 //Preload filter fields with query string
379 // Hide Authenfication form
380 $
(".popover").hide();
381 // Display Login modal
382 $
("#logGitHub").click(function(){ displayLogginModal(); });
385 // If cookie existing the session is opened
386 if(sessionStarted
){ userB64
= "Basic " + getUserPass("logginNitdoc"); }
388 // Sign In an github user or Log out him
389 $
("#signIn").click(function(){
391 if($
('#loginGit').val() == "" || $
('#passwordGit').val() == ""){ displayMessage('The comment field is empty!', 40, 45); }
394 userName
= $
('#loginGit').val();
395 password
= $
('#passwordGit').val();
396 repoName
= $
('#repositoryGit').val();
397 branchName
= $
('#branchGit').val();
398 userB64
= "Basic " + base64
.encode(userName
+':'+password
);
399 setCookie("logginNitdoc", base64
.encode(userName
+':'+password
+':'+repoName
+':'+branchName
), 1);
400 $
('#loginGit').val("");
401 $
('#passwordGit').val("");
406 // Delete cookie and reset settings
407 del_cookie("logginNitdoc");
409 displayLogginModal();
412 // Activate edit mode
413 $
('pre[class=text_label]').click(function(){
414 // the customer is loggued ?
415 if(!sessionStarted || userName
== ""){
416 // No => nothing happen
420 var arrayNew
= $
(this).text().split('\n');
421 var lNew
= arrayNew
.length
- 1;
424 for (var i
= 0; i
< lNew
; i
++) {
425 adapt
+= arrayNew
[i];
426 if(i
< lNew
-1){ adapt
+= "\n"; }
432 $
(this).next().show();
433 // Show cancel button
434 $
(this).next().next().show();
435 // Show commit button
436 $
(this).next().next().next().show();
437 // Add text in edit box
438 if($
(this).next().val() == ""){ $
(this).next().val(adapt
); }
440 $
(this).next().height($
(this).next().prop("scrollHeight"));
442 $
(this).next().select();
443 preElement
= $
(this);
447 // Disable the edit mode
448 $
('a[id=cancelBtn]').click(function(){
449 if(editComment
> 0){ editComment
-= 1; }
453 $
(this).next().hide();
455 $
(this).prev().hide();
457 $
(this).prev().prev().show();
460 // Display commit form
461 $
('a[id=commitBtn]').click(function(){
462 updateComment
= $
(this).prev().prev().val();
463 commentType
= $
(this).prev().prev().prev().attr('type');
465 if(updateComment
== ""){ displayMessage('The comment field is empty!', 40, 45); }
468 displayMessage("You need to be loggued before commit something", 45, 40);
469 displayLogginModal();
472 $
('#commitMessage').val('New commit');
473 pathFile
= $
(this).prev().prev().prev().attr('tag');
474 $
('#modal').show().prepend('<a class="close"><img src="resources/icons/close.png" class="btn_close" title="Close" alt="Close" /></a>');
475 $
('body').append('<div id="fade"></div>');
476 $
('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
481 $
('.btn_close').click(function(){
483 $
(this).next().hide();
484 if(editComment
> 0){ editComment
-= 1; }
487 //Close Popups and Fade Layer
488 $
('body').on('click', 'a.close, #fade', function() {
489 if(editComment
> 0){ editComment
-= 1; }
490 $
('#fade , #modal').fadeOut(function() {
491 $
('#fade, a.close').remove();
493 $
('#modalQuestion').hide();
496 $
('#loginAction').click(function(){
500 // Look if the customer is logged
502 displayMessage("You need to be loggued before commit something", 100, 40);
503 $
('.popover').show();
506 else{ userB64
= "Basic " + getUserPass("logginNitdoc"); }
507 githubRepo
= repoName
;
508 // Check if repo exist
512 commitMessage
= $
('#commitMessage').val();
513 if(commitMessage
== ""){ commitMessage
= "New commit";}
515 if ($
.trim(updateComment
) == ''){ this.value
= (this.defaultValue ?
this.defaultValue
: ''); }
516 else{ startCommitProcess(); }
518 $
('#modal, #modalQuestion').fadeOut(function() {
520 $
('#password').val("");
521 $
('textarea').hide();
522 $
('textarea').prev().show();
524 $
('a[id=cancelBtn]').hide();
525 $
('a[id=commitBtn]').hide();
527 else{ editComment
-= 1; }
531 /* Parse current URL and return anchor name */
532 function currentAnchor() {
533 var index
= document
.location
.hash
.indexOf("#");
535 return document
.location
.hash
.substring(index
+ 1);
540 /* Prealod filters field using search query */
541 function preloadFilters() {
542 // Parse URL and get query string
543 var search
= currentAnchor();
545 if(search
== null || search
.indexOf("q=") == -1)
548 search
= search
.substring(2, search
.length
);
550 if(search
== "" || search
== "undefined")
553 $
(":text").val(search
);
555 .removeClass("notUsed")
560 /* Hightlight the spoted block */
561 function highlightBlock(a
) {
566 $
(".highlighted").removeClass("highlighted");
568 var target
= $
("#" + a
);
570 if(target
.is("article")) {
571 target
.parent().addClass("highlighted");
574 target
.addClass("highlighted");
578 // Init process to commit the new comment
579 function startCommitProcess()
581 var numL
= preElement
.attr("title");
582 commentLineStart
= numL
.split('-')[0] - 1;
583 commentLineEnd
= (commentLineStart
+ preElement
.text().split('\n').length
) - 1;
585 replaceComment(updateComment
, currentfileContent
);
591 function displayLogginModal(){
592 if ($
('.popover').is(':hidden')) { $
('.popover').show(); }
593 else { $
('.popover').hide(); }
597 function updateDisplaying(){
600 $
('#loginGit').hide();
601 $
('#passwordGit').hide();
602 $
('#lbpasswordGit').hide();
603 $
('#lbloginGit').hide();
604 $
('#repositoryGit').hide();
605 $
('#lbrepositoryGit').hide();
606 $
('#lbbranchGit').hide();
607 $
('#branchGit').hide();
608 $
("#liGitHub").attr("class", "current");
609 $
("#imgGitHub").attr("src", "resources/icons/github-icon-w.png");
610 $
('#nickName').text(userName
);
611 $
('#githubAccount').attr("href", "https://github.com/"+userName
);
612 $
('#logginMessage').css({'display' : 'block'});
613 $
('#logginMessage').css({'text-align' : 'center'});
614 $
('.popover').css({'height' : '80px'});
615 $
('#signIn').text("Sign out");
616 sessionStarted
= true;
620 sessionStarted
= false;
621 $
('#logginMessage').css({'display' : 'none'});
622 $
("#liGitHub").attr("class", "");
623 $
("#imgGitHub").attr("src", "resources/icons/github-icon.png");
624 $
('#loginGit').val("");
625 $
('#passwordGit').val("");
626 $
('#nickName').text("");
627 $
('.popover').css({'height' : '280px'});
628 $
('#logginMessage').css({'display' : 'none'});
629 $
('#repositoryGit').val($
('#repoName').attr('name'));
630 $
('#branchGit').val('wikidoc');
631 $
('#signIn').text("Sign In");
632 $
('#loginGit').show();
633 $
('#passwordGit').show();
634 $
('#lbpasswordGit').show();
635 $
('#lbloginGit').show();
636 $
('#repositoryGit').show();
637 $
('#lbrepositoryGit').show();
638 $
('#lbbranchGit').show();
639 $
('#branchGit').show();
643 function setCookie(c_name
, value
, exdays
)
645 var exdate
=new Date();
646 exdate
.setDate(exdate
.getDate() + exdays
);
647 var c_value
=escape(value
) + ((exdays
==null) ?
"" : "; expires="+exdate
.toUTCString());
648 document
.cookie
=c_name
+ "=" + c_value
;
651 function del_cookie(c_name
)
653 document
.cookie
= c_name
+ '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
656 function getCookie(c_name
)
658 var c_value
= document
.cookie
;
659 var c_start
= c_value
.indexOf(" " + c_name
+ "=");
660 if (c_start
== -1) { c_start
= c_value
.indexOf(c_name
+ "="); }
661 if (c_start
== -1) { c_value
= null; }
664 c_start
= c_value
.indexOf("=", c_start
) + 1;
665 var c_end
= c_value
.indexOf(";", c_start
);
666 if (c_end
== -1) { c_end
= c_value
.length
; }
667 c_value
= unescape(c_value
.substring(c_start
,c_end
));
672 function getUserPass(c_name
){
673 var cookie
= base64
.decode(getCookie(c_name
));
674 return base64
.encode(cookie
.split(':')[0] + ':' + cookie
.split(':')[1]);
677 function checkCookie()
679 var cookie
=getCookie("logginNitdoc");
680 if (cookie
!=null && cookie
!="")
682 cookie
= base64
.decode(cookie
);
683 userName
= cookie
.split(':')[0];
684 repoName
= cookie
.split(':')[2];
685 branchName
= cookie
.split(':')[3];
688 else { return false; }
696 base64
.PADCHAR
= '=';
697 base64
.ALPHA
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
698 base64
.getbyte64
= function(s
,i
) {
699 // This is oddly fast, except on Chrome/V8.
700 // Minimal or no improvement in performance by using a
701 // object with properties mapping chars to value (eg. 'A': 0)
702 var idx
= base64
.ALPHA
.indexOf(s
.charAt(i
));
704 throw "Cannot decode base64";
709 base64
.decode
= function(s
) {
712 var getbyte64
= base64
.getbyte64
;
720 throw "Cannot decode base64";
724 if (s
.charAt(imax
-1) == base64
.PADCHAR
) {
726 if (s
.charAt(imax
-2) == base64
.PADCHAR
) {
729 // either way, we want to ignore this last block
734 for (i
= 0; i
< imax
; i
+= 4) {
735 b10
= (getbyte64(s
,i
) << 18) |
(getbyte64(s
,i
+1) << 12) |
736 (getbyte64(s
,i
+2) << 6) |
getbyte64(s
,i
+3);
737 x
.push(String
.fromCharCode(b10
>> 16, (b10
>> 8) & 0xff, b10
& 0xff));
742 b10
= (getbyte64(s
,i
) << 18) |
(getbyte64(s
,i
+1) << 12) |
(getbyte64(s
,i
+2) << 6)
743 x
.push(String
.fromCharCode(b10
>> 16, (b10
>> 8) & 0xff));
746 b10
= (getbyte64(s
,i
) << 18) |
(getbyte64(s
,i
+1) << 12);
747 x
.push(String
.fromCharCode(b10
>> 16));
753 base64
.getbyte
= function(s
,i
) {
754 var x
= s
.charCodeAt(i
);
756 throw "INVALID_CHARACTER_ERR: DOM Exception 5";
762 base64
.encode
= function(s
) {
763 if (arguments
.length
!= 1) {
764 throw "SyntaxError: Not enough arguments";
766 var padchar
= base64
.PADCHAR
;
767 var alpha
= base64
.ALPHA
;
768 var getbyte
= base64
.getbyte
;
776 var imax
= s
.length
- s
.length
% 3;
781 for (i
= 0; i
< imax
; i
+= 3) {
782 b10
= (getbyte(s
,i
) << 16) |
(getbyte(s
,i
+1) << 8) |
getbyte(s
,i
+2);
783 x
.push(alpha
.charAt(b10
>> 18));
784 x
.push(alpha
.charAt((b10
>> 12) & 0x3F));
785 x
.push(alpha
.charAt((b10
>> 6) & 0x3f));
786 x
.push(alpha
.charAt(b10
& 0x3f));
788 switch (s
.length
- imax
) {
790 b10
= getbyte(s
,i
) << 16;
791 x
.push(alpha
.charAt(b10
>> 18) + alpha
.charAt((b10
>> 12) & 0x3F) +
795 b10
= (getbyte(s
,i
) << 16) |
(getbyte(s
,i
+1) << 8);
796 x
.push(alpha
.charAt(b10
>> 18) + alpha
.charAt((b10
>> 12) & 0x3F) +
797 alpha
.charAt((b10
>> 6) & 0x3f) + padchar
);
803 $
.fn
.spin
= function(opts
) {
804 this.each(function() {
812 if (opts
!== false) {
813 data
.spinner
= new Spinner($
.extend({color
: $
this.css('color')}, opts
)).spin(this);
819 function getLastCommit()
822 if(sessionStarted
){ urlHead
= "https://api.github.com/repos/"+userName
+"/"+githubRepo
+"/git/refs/heads/"+branchName
;}
824 // TODO: get url of the original repo.
829 beforeSend
: function (xhr
) {
830 if (userB64
!= ""){ xhr
.setRequestHeader ("Authorization", userB64
); }
836 success
: function(success
)
838 shaLastCommit
= success
.object
.sha
;
843 function getBaseTree()
846 beforeSend
: function (xhr
) {
847 if (userB64
!= ""){ xhr
.setRequestHeader ("Authorization", userB64
); }
850 url
: "https://api.github.com/repos/"+userName
+"/"+githubRepo
+"/git/commits/" + shaLastCommit
,
853 success
: function(success
)
855 shaBaseTree
= success
.tree
.sha
;
856 if (state
){ setBlob(); }
865 function setNewTree()
868 beforeSend
: function (xhr
) { xhr
.setRequestHeader ("Authorization", userB64
); },
870 url
: "https://api.github.com/repos/"+userName
+"/"+githubRepo
+"/git/trees",
872 data
:'{ "base_tree" : "'+shaBaseTree
+'", '+
874 '"path":"'+ pathFile
+'",'+
877 '"sha": "'+ shaBlob
+'"'+
880 success
: function(success
)
881 { // si l'appel a bien fonctionné
882 shaNewTree
= JSON
.parse(success
).sha
;
891 function setNewCommit()
894 beforeSend
: function (xhr
) { xhr
.setRequestHeader ("Authorization", userB64
); },
896 url
: "https://api.github.com/repos/"+userName
+"/"+githubRepo
+"/git/commits",
898 data
:'{ "message" : "'+ commitMessage
+'", '+
899 '"parents" :"'+shaLastCommit
+'",'+
900 '"tree": "'+shaNewTree
+'"'+
902 success
: function(success
)
904 shaNewCommit
= JSON
.parse(success
).sha
;
917 beforeSend
: function (xhr
) { xhr
.setRequestHeader ("Authorization", userB64
); },
919 url
: "https://api.github.com/repos/"+userName
+"/"+githubRepo
+"/git/refs/heads/"+branchName
,
920 data
:'{ "sha" : "'+shaNewCommit
+'", '+
923 success
: function(success
) { displayMessage('Commit created successfully', 40, 40); },
924 error
:function(error
){ displayMessage('Error ' + JSON
.parse(error
).object
.message
, 40, 40); }
932 beforeSend
: function (xhr
) { xhr
.setRequestHeader ("Authorization", userB64
); },
934 url
: "https://api.github.com/repos/"+userName
+"/"+githubRepo
+"/git/blobs",
936 data
:'{ "content" : "'+text
.replace(/\r?
\n/g
, '\\n').replace(/\t/g
, '\\t').replace(/\"/g
,'\\"')+'", '+
937 '"encoding" :"utf-8"'+
939 success
: function(success
)
941 shaBlob
= JSON
.parse(success
).sha
;
944 error
:function(error
){
945 displayMessage('Error : Problem parsing JSON', 40, 40);
951 // Display file content
952 function getFileContent(urlFile
, newComment
)
955 beforeSend
: function (xhr
) {
956 xhr
.setRequestHeader ("Accept", "application/vnd.github-blob.raw");
957 if (userB64
!= ""){ xhr
.setRequestHeader ("Authorization", userB64
); }
962 success
: function(success
)
965 replaceComment(newComment
, success
);
970 function replaceComment(newComment
, fileContent
){
971 var arrayNew
= newComment
.split('\n');
972 var lNew
= arrayNew
.length
;
974 var lines
= fileContent
.split("\n");
975 for (var i
= 0; i
< lines
.length
; i
++) {
976 if(i
== commentLineStart
){
977 // We change the comment
978 for(var j
= 0; j
< lNew
; j
++){
979 if(commentType
== 1){ text
+= "\t# " + arrayNew
[j] + "\n"; }
981 if(arrayNew
[j] == ""){ text
+= "#"+"\n"; }
982 else{ text
+= "# " + arrayNew
[j] + "\n"; }
986 else if(i
< commentLineStart || i
>= commentLineEnd
){
987 if(i
== lines
.length
-1){ text
+= lines
[i]; }
988 else{ text
+= lines
[i] + "\n"; }
993 function getCommentLastCommit(path
){
996 if(shaLastCommit
!= ""){
997 if (checkCookie()) { urlRaw
="https://rawgithub.com/"+ userName
+"/"+ repoName
+"/" + shaLastCommit
+ "/" + path
; }
998 else{ urlRaw
="https://rawgithub.com/StefanLage/"+ $
('#repoName').attr('name') +"/" + shaLastCommit
+ "/" + path
; }
1004 success
: function(success
)
1006 currentfileContent
= success
;
1012 function displayMessage(msg
, widthDiv
, margModal
){
1014 $
('#btnCreateBranch').css('margin-left',widthDiv
+ '%');
1015 $
('#txtQuestion').text(msg
);
1016 $
('#btnCreateBranch').text("Ok");
1017 $
('#btnCancelBranch').hide();
1018 $
('#modalQuestion').css({'left' : margModal
+ '%'})
1019 $
('#modalQuestion').show();
1020 $
('#modalQuestion').show().prepend('<a class="close"><img src="resources/icons/close.png" class="btnCloseQuestion" title="Close" alt="Close" /></a>');
1021 $
('body').append('<div id="fade"></div>');
1022 $
('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
1025 // Check if the repo already exist
1026 function isRepoExisting(){
1028 beforeSend
: function (xhr
) {
1029 if (userB64
!= "") { xhr
.setRequestHeader ("Authorization", userB64
); }
1032 url
: "https://api.github.com/repos/"+userName
+"/"+githubRepo
,
1035 success
: function(){ repoExist
= true; },
1038 displayMessage('Repo not found !', 35, 45);