mirror of
https://github.com/msmhq/msm.git
synced 2024-08-30 18:12:35 +00:00
Added dynamic version number for install guide button.
The version number is taken from the largest x.x.x tag for the GitHub project. Also moved scripts into external files and used CDNs where possible.
This commit is contained in:
parent
9a7d368d40
commit
baa9a7d803
69
assets/js/index.js
Normal file
69
assets/js/index.js
Normal file
@ -0,0 +1,69 @@
|
||||
$(function() {
|
||||
var milestonesUrl = "https://api.github.com/repos/marcuswhybrow/minecraft-server-manager/milestones?callback=?",
|
||||
tagsUrl = "https://api.github.com/repos/marcuswhybrow/minecraft-server-manager/tags?callback=?";
|
||||
|
||||
$.getJSON(milestonesUrl, function(result) {
|
||||
var milestones = result.data;
|
||||
|
||||
$.each(milestones, function(i, milestone) {
|
||||
var closedIssues = milestone.closed_issues;
|
||||
var totalIssues = closedIssues + milestone.open_issues;
|
||||
var milestonePercentage = closedIssues / totalIssues * 100;
|
||||
|
||||
var $div = $("<div>").addClass("milestone");
|
||||
var $link =$("<a>")
|
||||
.attr("href", "https://github.com/marcuswhybrow/minecraft-server-manager/issues?state=open&milestone=" + milestone.number)
|
||||
.addClass("ga-track")
|
||||
.appendTo($div);
|
||||
$("<h2>").text(milestone.title).appendTo($link);
|
||||
$("<p>").text(milestone.description).appendTo($div);
|
||||
var $progress = $("<div>").addClass("progress").appendTo($div);
|
||||
var $bar = $("<div>").addClass("bar").css("width", milestonePercentage + "%").appendTo($progress);
|
||||
$(".milestones").append($div);
|
||||
});
|
||||
|
||||
$(".milestones").slideDown();
|
||||
});
|
||||
|
||||
function compareTags(a, b) {
|
||||
if (a[0] > b[0]) return 1;
|
||||
else if (a[0] == b[0] && a[1] > b[1]) return 1;
|
||||
else if (a[0] == b[0] && a[1] == b[1] && a[2] > b[2]) return 1;
|
||||
else if (a[0] == b[0] && a[1] == b[1] && a[2] == b[2]) return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
function matchToTagVersion(match) {
|
||||
return [ parseInt(match[1], 10), parseInt(match[2], 10), parseInt(match[3], 10) ];
|
||||
}
|
||||
|
||||
$.getJSON(tagsUrl, function(result) {
|
||||
var tags = result.data,
|
||||
latestTagVersion = [0, 0, 0],
|
||||
tagVersion, match;
|
||||
|
||||
$.each(tags, function(i, tag) {
|
||||
match = tag.name.match(/^(\d+)\.(\d+)\.(\d+)$/);
|
||||
if (match) {
|
||||
tagVersion = matchToTagVersion(match);
|
||||
if (compareTags(tagVersion, latestTagVersion) == 1)
|
||||
latestTagVersion = tagVersion;
|
||||
}
|
||||
});
|
||||
|
||||
var $installBtnVersion = $('#install-button small');
|
||||
match = $installBtnVersion.text().match(/^\((\d+)\.(\d+)\.(\d+)\)$/);
|
||||
if (match) {
|
||||
tagVersion = matchToTagVersion(match);
|
||||
if (compareTags(latestTagVersion, tagVersion) == 1)
|
||||
$installBtnVersion.text('(' + latestTagVersion.join('.') + ')');
|
||||
}
|
||||
});
|
||||
|
||||
$('.player').tooltip();
|
||||
|
||||
$('a.ga-track').live('click', function() {
|
||||
var $this = $(this);
|
||||
_gaq.push(['_trackEvent', 'External Link', $this.text(), $this.attr('href')]);
|
||||
});
|
||||
});
|
49
index.html
49
index.html
@ -14,44 +14,7 @@
|
||||
<!--[if lt IE 9]>
|
||||
<script type="text/javascript" src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<script type="text/javascript" src="assets/js/jquery-1.7.2.min.js"></script>
|
||||
<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var milestonesUrl = "https://api.github.com/repos/marcuswhybrow/minecraft-server-manager/milestones?callback=?";
|
||||
|
||||
$.getJSON(milestonesUrl, function(result) {
|
||||
var milestones = result.data;
|
||||
|
||||
$.each(milestones, function(i, milestone) {
|
||||
var closedIssues = milestone.closed_issues;
|
||||
var totalIssues = closedIssues + milestone.open_issues;
|
||||
var milestonePercentage = closedIssues / totalIssues * 100;
|
||||
|
||||
var $div = $("<div>").addClass("milestone");
|
||||
var $link =$("<a>")
|
||||
.attr("href", "https://github.com/marcuswhybrow/minecraft-server-manager/issues?state=open&milestone=" + milestone.number)
|
||||
.addClass("ga-track")
|
||||
.appendTo($div);
|
||||
$("<h2>").text(milestone.title).appendTo($link);
|
||||
$("<p>").text(milestone.description).appendTo($div);
|
||||
var $progress = $("<div>").addClass("progress").appendTo($div);
|
||||
var $bar = $("<div>").addClass("bar").css("width", milestonePercentage + "%").appendTo($progress);
|
||||
$(".milestones").append($div);
|
||||
});
|
||||
|
||||
$(".milestones").slideDown();
|
||||
});
|
||||
|
||||
$('.player').tooltip();
|
||||
|
||||
$('a.ga-track').live('click', function() {
|
||||
var $this = $(this);
|
||||
_gaq.push(['_trackEvent', 'External Link', $this.text(), $this.attr('href')]);
|
||||
});
|
||||
});
|
||||
|
||||
// Google Analytics
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-32675598-2']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
@ -72,7 +35,7 @@
|
||||
|
||||
<div class="buttons">
|
||||
<a id="view-button" href="https://github.com/marcuswhybrow/minecraft-server-manager" class="btn btn-primary btn-large" onclick="_gaq.push(['_trackEvent', 'Masthead Actions', 'Github Project', 'View project on GitHub']);">View project on GitHub</a>
|
||||
<a id="install-button" href="https://github.com/marcuswhybrow/minecraft-server-manager/wiki/Installation" class="btn btn-large" onclick="_gaq.push(['_trackEvent', 'Masthead Actions', 'Install']);">Install Guide <small>(0.2.8)</small></a>
|
||||
<a id="install-button" href="https://github.com/marcuswhybrow/minecraft-server-manager/wiki/Installation" class="btn btn-large" onclick="_gaq.push(['_trackEvent', 'Masthead Actions', 'Install']);">Install Guide <small>(0.2.0)</small></a>
|
||||
</div>
|
||||
|
||||
<ul class="quick-links">
|
||||
@ -194,5 +157,15 @@
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.0.3/bootstrap.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
// jquery-1.7.2.min.js local fallback
|
||||
typeof jQuery == 'undefined' && document.write('<script src="/assets/js/jquery-1.7.2.min.js" type="text/javascript"><\/script>');
|
||||
// bootstrap.min.js local fallback
|
||||
typeof jQuery != 'undefined' && typeof jQuery.fn.modal == 'undefined' && document.write('<script src="/assets/js/bootstrap.min.js" type="text/javascript"><\/script>');
|
||||
</script>
|
||||
<script type="text/javascript" src="/assets/js/index.js"></script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user