mirror of
https://github.com/greenshot/greenshot.git
synced 2025-01-08 23:03:03 -08:00
97 lines
3.5 KiB
HTML
97 lines
3.5 KiB
HTML
{% assign latest_release = site.github.releases | where:"prerelease",false | where:"draft",false | first %}
|
|
|
|
<script language="JavaScript">
|
|
var release_blog_posts = new Array();
|
|
{% if latest_release.tag_name %}
|
|
{% for post in site.posts %}{% if post.release_version %}release_blog_posts["{{post.release_version}}"] = "{{post.url}}";
|
|
{% endif %}{% endfor %}
|
|
{% else %}release_blog_posts["1.2.9.129"] = "/2017/01/28/129-bug-bash/";
|
|
{% endif %}
|
|
|
|
</script>
|
|
|
|
<div id="currentVersion" class="alert alert-success collapse" role="alert">
|
|
<i class="fa fa-check-circle"></i> You are using the most recent version of Greenshot.
|
|
<div id="blogPost1" class="collapse">More information about this version can be found <a id="blog1" href="">here</a>.</div>
|
|
</div>
|
|
<div id="oldVersion" class="alert alert-warning collapse" role="alert">
|
|
<i class="fa fa-exclamation-triangle"></i> <strong>You are not using the newest Greenshot version.</strong><br/>
|
|
<div id="blogPost2" class="collapse">More information about the version you are using can be found <a id="blog2" href="">here</a>.</div>
|
|
You might want to download the newest version, which is {{ latest_release.tag_name }}, from <a href="/downloads/">here</a>. Also always make sure to get Greenshot from <a href="https://getgreenshot.org/">getgreenshot.org</a>, .
|
|
</div>
|
|
|
|
<script>
|
|
// The following checks if the passed version in the URL is lower or equal to the known release.
|
|
// Depending on the outcome, it will show a warning or a positive message.
|
|
|
|
// Return 1 if a > b or not checkable
|
|
// Return -1 if a < b
|
|
// Return 0 if a == b
|
|
function compareVersion(a, b) {
|
|
if (a === b) {
|
|
return 0;
|
|
}
|
|
|
|
if (!a || !b) {
|
|
return 1;
|
|
}
|
|
|
|
var a_components = a.split(".");
|
|
var b_components = b.split(".");
|
|
|
|
var len = Math.min(a_components.length, b_components.length);
|
|
|
|
// loop while the components are equal
|
|
for (var i = 0; i < len; i++) {
|
|
// A bigger than B
|
|
if (parseInt(a_components[i]) > parseInt(b_components[i])) {
|
|
return 1;
|
|
}
|
|
|
|
// B bigger than A
|
|
if (parseInt(a_components[i]) < parseInt(b_components[i])) {
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
// If one's a prefix of the other, the longer one is greater.
|
|
if (a_components.length > b_components.length) {
|
|
return 1;
|
|
}
|
|
|
|
if (a_components.length < b_components.length) {
|
|
return -1;
|
|
}
|
|
|
|
// Otherwise they are the same.
|
|
return 0;
|
|
}
|
|
|
|
function checkVersion(installedVersion) {
|
|
var greenshotTag = {% if latest_release.tag_name %}"{{ latest_release.tag_name }}"{% else %}"Greenshot-Test-1.2.9.129"{% endif %};
|
|
var releaseVersion = /.*(\d+\.\d+\.\d+\.\d+)/.exec(greenshotTag)[1];
|
|
var compare=compareVersion(releaseVersion, installedVersion);
|
|
var matchingBlogPost = release_blog_posts[installedVersion];
|
|
if (matchingBlogPost) {
|
|
jQuery('#blog1').prop("href", matchingBlogPost);
|
|
jQuery('#blogPost1').slideToggle();
|
|
jQuery('#blog2').prop("href", matchingBlogPost);
|
|
jQuery('#blogPost2').slideToggle();
|
|
}
|
|
if (compare >= 1) {
|
|
jQuery('#oldVersion').slideDown();
|
|
jQuery('#currentVersion').slideUp();
|
|
} else if (compare == 0) {
|
|
jQuery('#oldVersion').slideUp();
|
|
jQuery('#currentVersion').slideDown();
|
|
}
|
|
}
|
|
|
|
$(document).ready(function () {
|
|
var versionMatch = /version=([^&]+)/.exec(location);
|
|
if (versionMatch) {
|
|
checkVersion(versionMatch[1]);
|
|
}
|
|
});
|
|
|
|
</script> |