Vulcan/packages/telescope-update-prompt/lib/client/update.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

2014-09-13 13:52:29 +09:00
compareVersions = function (v1, v2) { // return true if v2 is newer than v1
var v1Array = v1.split('.');
var v2Array = v2.split('.');
// go through each segment of v2 and stop if we find one that's higher
// than the equivalent segment of v1; else return false
return v2Array.some( function (value, index) {
return value > v1Array[index];
});
return false;
}
2014-09-08 17:29:55 +09:00
Meteor.startup(function () {
2014-09-16 09:12:26 +09:00
Session.set('updateVersion', null);
2014-09-08 17:29:55 +09:00
if(Meteor.user() && isAdmin(Meteor.user())){
2014-09-15 21:32:57 +09:00
var url = 'http://version.telescopeapp.org/';
2014-09-13 13:52:29 +09:00
HTTP.get(url, {
2014-09-15 21:32:57 +09:00
params: {
2014-09-13 13:52:29 +09:00
currentVersion: telescopeVersion,
siteTitle: getSetting('title'),
siteUrl: getSiteUrl()
}
}, function (error, result) {
if(result){
2014-09-15 21:32:57 +09:00
// console.log(result);
2014-09-13 13:52:29 +09:00
var currentVersion = telescopeVersion;
2014-09-15 21:32:57 +09:00
var newVersion = result.content;
2014-09-13 13:52:29 +09:00
var message = "";
if (compareVersions(currentVersion, newVersion)){
Session.set('updateVersion', newVersion);
}
}
});
2014-09-08 17:29:55 +09:00
}
});
heroModules.push({
template: 'updateBanner'
});