| @@ 1-133 (lines=133) @@ | ||
| 1 | "use strict"; |
|
| 2 | ||
| 3 | app.controller('install03Controller', ['$scope', '$q', '$http', '$interval', '$rootScope', '$stateParams', function ($scope, $q, $http, $interval, $rootScope, $stateParams) { |
|
| 4 | $(".release_info").hide(); |
|
| 5 | ||
| 6 | $scope.releaseID = $stateParams.releaseID; |
|
| 7 | ||
| 8 | $scope.mergeContent = function(){ |
|
| 9 | if($scope.latestVersion != null){ |
|
| 10 | var latestRelease = $scope.latestVersion; |
|
| 11 | var tag_name = latestRelease.tag_name; |
|
| 12 | var releaseZipDownloadURL = latestRelease.zipball_url; |
|
| 13 | var releaseTarDownloadURL = latestRelease.tarball_url; |
|
| 14 | ||
| 15 | $("#latest_release_zip").text(tag_name).parent("a").attr("href", releaseZipDownloadURL); |
|
| 16 | $("#latest_release_tar").text(tag_name).parent("a").attr("href", releaseTarDownloadURL); |
|
| 17 | ||
| 18 | $(".loading_info").hide(); |
|
| 19 | ||
| 20 | // convert github release body content from Markdown to HTML |
|
| 21 | var converter = new showdown.Converter(); |
|
| 22 | //converter.setOption('backslashEscapesHTMLTags', 'true'); |
|
| 23 | var markdown = latestRelease.body; |
|
| 24 | ||
| 25 | /* |
|
| 26 | // replace \< to <, \> to > |
|
| 27 | var findStartTag = "\<"; |
|
| 28 | var regularExpressStart = new RegExp(findStartTag, 'g'); |
|
| 29 | var findEndTag = "\>"; |
|
| 30 | var regularExpressEnd = new RegExp(findEndTag, 'g'); |
|
| 31 | markdown = markdown.replace(regularExpressStart, '<'); |
|
| 32 | markdown = markdown.replace(regularExpressEnd, '>'); |
|
| 33 | */ |
|
| 34 | ||
| 35 | // remove all Backslash |
|
| 36 | // 92 is Backslash |
|
| 37 | var findBackslash = String.fromCharCode(92)+String.fromCharCode(92); |
|
| 38 | var regularExpressBackslash = new RegExp(findBackslash, 'g'); |
|
| 39 | markdown = markdown.replace(regularExpressBackslash, ''); |
|
| 40 | ||
| 41 | // encode to html entities |
|
| 42 | // https://stackoverflow.com/questions/18749591/encode-html-entities-in-javascript |
|
| 43 | var encodedStr = markdown.replace(/[\u00A0-\u9999<>\&]/gim, function(i) { |
|
| 44 | return '&#'+i.charCodeAt(0)+';'; |
|
| 45 | }); |
|
| 46 | ||
| 47 | var html = converter.makeHtml(encodedStr); |
|
| 48 | ||
| 49 | latestRelease.html = html; |
|
| 50 | ||
| 51 | /* |
|
| 52 | console.dir(latestRelease) |
|
| 53 | console.dir(converter) |
|
| 54 | console.dir(markdown) |
|
| 55 | console.dir(encodedStr) |
|
| 56 | console.dir(html) |
|
| 57 | console.dir(latestRelease) |
|
| 58 | */ |
|
| 59 | ||
| 60 | $(".release_info").show(); |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||
| 64 | $scope.get_information = function(){ |
|
| 65 | $scope.initial_variable(); |
|
| 66 | ||
| 67 | var getReleaseInfoResule = $scope.get_github_release_info($scope.releaseID); |
|
| 68 | getReleaseInfoResule.then(function(infoObjList) { |
|
| 69 | if(infoObjList.length > 0){ |
|
| 70 | $scope.latestVersion = infoObjList[0]; |
|
| 71 | } |
|
| 72 | }, function(reason) { |
|
| 73 | }); |
|
| 74 | ||
| 75 | $q.all([getReleaseInfoResule]).then(function() { |
|
| 76 | $scope.mergeContent(); |
|
| 77 | }); |
|
| 78 | } |
|
| 79 | $scope.get_github_release_info = function(releaseID){ |
|
| 80 | var arrayList = []; |
|
| 81 | ||
| 82 | var promise = $q(function(resolve, reject) { |
|
| 83 | var array = {text:"commits", amt:"10101", options}; |
|
| 84 | ||
| 85 | $http({ |
|
| 86 | method : "GET", |
|
| 87 | //url : "https://api.github.com/repos/Otaku-Projects/AngularJS-CRUD-PHP/releases/"+releaseID |
|
| 88 | url : "https://api.github.com/repositories/27926807/releases/"+releaseID |
|
| 89 | }).then(function mySuccess(response) { |
|
| 90 | var returnData = response.data; |
|
| 91 | var totalReleasesCount = 0; |
|
| 92 | /* |
|
| 93 | returnData.forEach(function(releasesObj){ |
|
| 94 | arrayList.push(releasesObj); |
|
| 95 | }); |
|
| 96 | */ |
|
| 97 | arrayList.push(returnData); |
|
| 98 | ||
| 99 | resolve(arrayList); |
|
| 100 | }, function myError(response) { |
|
| 101 | reject(new Error('get project release info error')); |
|
| 102 | }); |
|
| 103 | ||
| 104 | }); |
|
| 105 | ||
| 106 | return promise; |
|
| 107 | } |
|
| 108 | $scope.initial_variable = function(){ |
|
| 109 | $scope.latestVersion = null; |
|
| 110 | } |
|
| 111 | function start_milestones(stackObjectList){ |
|
| 112 | $("#milestones").html(""); |
|
| 113 | ||
| 114 | var infoObj = stackObjectList.shift(); |
|
| 115 | var elementContent = infoObj.text; |
|
| 116 | var countUpAmt = infoObj.amt; |
|
| 117 | var options = infoObj.options; |
|
| 118 | $("#milestones").html("<div class='animated'>"+elementContent+"</div>"); |
|
| 119 | $("#milestones div").addClass("fadeInUp"); |
|
| 120 | ||
| 121 | if(!$scope.countUp){ |
|
| 122 | $scope.countUp = new CountUp("count_up_amt", 0, options); |
|
| 123 | $scope.countUp.start(); |
|
| 124 | $("#count_up_amt").hide(); |
|
| 125 | } |
|
| 126 | $("#count_up_amt").show(); |
|
| 127 | $scope.countUp.update(countUpAmt); |
|
| 128 | ||
| 129 | stackObjectList.push(infoObj); |
|
| 130 | } |
|
| 131 | ||
| 132 | $scope.get_information(); |
|
| 133 | }]); |
|
| @@ 1-112 (lines=112) @@ | ||
| 1 | "use strict"; |
|
| 2 | ||
| 3 | app.controller('install02Controller', ['$scope', '$q', '$http', '$interval', '$rootScope', function ($scope, $q, $http, $interval, $rootScope) { |
|
| 4 | $(".release_info").hide(); |
|
| 5 | ||
| 6 | $scope.mergeContent = function(){ |
|
| 7 | if($scope.releaseInfoStack.length > 0){ |
|
| 8 | var latestRelease = $scope.latestVersion; |
|
| 9 | console.dir(latestRelease) |
|
| 10 | var tag_name = latestRelease.tag_name; |
|
| 11 | var releaseZipDownloadURL = latestRelease.zipball_url; |
|
| 12 | var releaseTarDownloadURL = latestRelease.tarball_url; |
|
| 13 | ||
| 14 | // convert github release body content from Markdown to HTML |
|
| 15 | var converter = new showdown.Converter(); |
|
| 16 | var markdown = latestRelease.body; |
|
| 17 | ||
| 18 | // remove all Backslash |
|
| 19 | // 92 is Backslash |
|
| 20 | var findBackslash = String.fromCharCode(92)+String.fromCharCode(92); |
|
| 21 | var regularExpressBackslash = new RegExp(findBackslash, 'g'); |
|
| 22 | markdown = markdown.replace(regularExpressBackslash, ''); |
|
| 23 | ||
| 24 | // encode to html entities |
|
| 25 | // https://stackoverflow.com/questions/18749591/encode-html-entities-in-javascript |
|
| 26 | var encodedStr = markdown.replace(/[\u00A0-\u9999<>\&]/gim, function(i) { |
|
| 27 | return '&#'+i.charCodeAt(0)+';'; |
|
| 28 | }); |
|
| 29 | ||
| 30 | var html = converter.makeHtml(encodedStr); |
|
| 31 | ||
| 32 | latestRelease.html = html; |
|
| 33 | ||
| 34 | $("#latest_release_zip").text(tag_name).parent("a").attr("href", releaseZipDownloadURL); |
|
| 35 | $("#latest_release_tar").text(tag_name).parent("a").attr("href", releaseTarDownloadURL); |
|
| 36 | ||
| 37 | $(".loading_info").hide(); |
|
| 38 | $(".release_info").show(); |
|
| 39 | } |
|
| 40 | } |
|
| 41 | ||
| 42 | $scope.get_information = function(){ |
|
| 43 | $scope.initial_variable(); |
|
| 44 | ||
| 45 | var getReleaseInfoResule = $scope.get_github_release_info(); |
|
| 46 | getReleaseInfoResule.then(function(infoObjList) { |
|
| 47 | $scope.releaseInfoStack = infoObjList; |
|
| 48 | if(infoObjList.length > 0){ |
|
| 49 | $scope.latestVersion = infoObjList[0]; |
|
| 50 | $scope.previousVersion = infoObjList.slice(1); |
|
| 51 | } |
|
| 52 | }, function(reason) { |
|
| 53 | }); |
|
| 54 | ||
| 55 | $q.all([getReleaseInfoResule]).then(function() { |
|
| 56 | $scope.mergeContent(); |
|
| 57 | }); |
|
| 58 | } |
|
| 59 | $scope.get_github_release_info = function(){ |
|
| 60 | var arrayList = []; |
|
| 61 | ||
| 62 | var promise = $q(function(resolve, reject) { |
|
| 63 | var array = {text:"commits", amt:"10101", options}; |
|
| 64 | ||
| 65 | $http({ |
|
| 66 | method : "GET", |
|
| 67 | //url : "https://api.github.com/repos/Otaku-Projects/AngularJS-CRUD-PHP/releases" |
|
| 68 | url : "https://api.github.com/repositories/27926807/releases" |
|
| 69 | }).then(function mySuccess(response) { |
|
| 70 | var returnData = response.data; |
|
| 71 | var totalReleasesCount = 0; |
|
| 72 | returnData.forEach(function(releasesObj){ |
|
| 73 | arrayList.push(releasesObj); |
|
| 74 | }); |
|
| 75 | ||
| 76 | resolve(arrayList); |
|
| 77 | }, function myError(response) { |
|
| 78 | reject(new Error('get project release info error')); |
|
| 79 | }); |
|
| 80 | ||
| 81 | }); |
|
| 82 | ||
| 83 | return promise; |
|
| 84 | } |
|
| 85 | $scope.initial_variable = function(){ |
|
| 86 | $scope.releaseInfoStack = []; |
|
| 87 | $scope.latestVersion = []; |
|
| 88 | $scope.previousVersion = []; |
|
| 89 | } |
|
| 90 | function start_milestones(stackObjectList){ |
|
| 91 | $("#milestones").html(""); |
|
| 92 | ||
| 93 | var infoObj = stackObjectList.shift(); |
|
| 94 | var elementContent = infoObj.text; |
|
| 95 | var countUpAmt = infoObj.amt; |
|
| 96 | var options = infoObj.options; |
|
| 97 | $("#milestones").html("<div class='animated'>"+elementContent+"</div>"); |
|
| 98 | $("#milestones div").addClass("fadeInUp"); |
|
| 99 | ||
| 100 | if(!$scope.countUp){ |
|
| 101 | $scope.countUp = new CountUp("count_up_amt", 0, options); |
|
| 102 | $scope.countUp.start(); |
|
| 103 | $("#count_up_amt").hide(); |
|
| 104 | } |
|
| 105 | $("#count_up_amt").show(); |
|
| 106 | $scope.countUp.update(countUpAmt); |
|
| 107 | ||
| 108 | stackObjectList.push(infoObj); |
|
| 109 | } |
|
| 110 | ||
| 111 | $scope.get_information(); |
|
| 112 | }]); |
|