diff --git a/plugins/update-check.user.js b/plugins/update-check.user.js
index e144332d..5267b120 100644
--- a/plugins/update-check.user.js
+++ b/plugins/update-check.user.js
@@ -22,10 +22,22 @@
// use own namespace for plugin
window.plugin.updateCheck = function() {};
-window.plugin.updateCheck.url = 'http://iitc.jonatkins.com/versioncheck.php?build=@@BUILDNAME@@';
window.plugin.updateCheck.versionDataLoading = false;
+window.plugin.updateCheck.getUrl = function(callback) {
+
+ var url = 'http://iitc.jonatkins.com/versioncheck.php'
+ + '?build=@@BUILDNAME@@'
+ + '&mobile='+((typeof android !== 'undefined' && android)?'1':'0');
+
+ if (callback) {
+ url = url + '&callback='+callback
+ }
+
+ return url;
+}
+
window.plugin.updateCheck.versionCompare = function(a,b) {
a = a.split('.');
b = b.split('.');
@@ -51,9 +63,14 @@ window.plugin.updateCheck.loadVersionData = function() {
if (!window.plugin.updateCheck.versionDataLoading) {
window.plugin.updateCheck.versionDataLoading = true;
+//TODO: IITC Mobile-specific parameter, to retrieve the mobile app version rather than the script versions
+//also
+// JSInterface public void updateIitc(String fileUrl)
+//call on the android object to be able to download+install the android app.
+
var s = document.createElement('script');
s.setAttribute('type','text/javascript');
- s.setAttribute('src', window.plugin.updateCheck.url+'&callback=window.plugin.updateCheck.versionDataCallback');
+ s.setAttribute('src', window.plugin.updateCheck.getUrl('window.plugin.updateCheck.versionDataCallback'));
s.setAttribute('id','update-check-script-tag');
document.getElementsByTagName("head")[0].appendChild(s);
@@ -143,16 +160,44 @@ window.plugin.updateCheck.showReport = function(data) {
result += '
IITC update check: '+data.name+'
';
}
- if (data.iitc && window.script_info) {
- var compare = window.plugin.updateCheck.compareDetails(data.iitc, window.script_info);
- result += 'IITC Main script: '+compare.html+'
';
+ if (typeof android !== 'undefined' && android) {
+ // mobile app version check
+ var ourVerCode = android.getVersionCode && android.getVersionCode() || 0;
+ var ourVerName = android.getVersionName && android.getVersionName() || '(unknown)';
- } else {
- if (!data.iitc) {
- result += 'Warning: no version information for main IITC script found in response
';
+ if (data.mobile) {
+ var latestVerCode = parseInt(data.mobile.versioncode);
+ var latestVerName = data.mobile.versionstr;
+
+ if (ourVerCode == latestVerCode) {
+ // up to date
+ result += 'IITC Mobile is up to date - version '+ourVerName+'
';
+ } else if (ourVerCode < latestVerCode) {
+ // out of date
+ result += 'IITC Mobile is out of date. Current version '+ourVerName+', '
+ + 'Available version '+latestVerName+'.
';
+ } else {
+ // local version newer?!
+ result += 'IITC Mobile version newer than latest on server?! Current version '+ourVerName+', '
+ + 'Available version '+latestVerName+'.
';
+ }
+
+ } else {
+ result += 'Warning: no version data for mobile app found in response
';
}
- if (!window.script_info) {
- result += 'Warning: your IITC script does not contain version data
';
+ } else {
+ // desktop userscript version check
+ if (data.iitc && window.script_info) {
+ var compare = window.plugin.updateCheck.compareDetails(data.iitc, window.script_info);
+ result += 'IITC Main script: '+compare.html+'
';
+
+ } else {
+ if (!data.iitc) {
+ result += 'Warning: no version information for main IITC script found in response
';
+ }
+ if (!window.script_info) {
+ result += 'Warning: your IITC script does not contain version data
';
+ }
}
}
@@ -190,17 +235,22 @@ window.plugin.updateCheck.showReport = function(data) {
result += 'Plugins:
';
- var formatRow = function(p) {
+ var formatRow = function(p,weblink,downloadlink) {
var status = p.status;
var name = p.name;
var statustext = p.compare && p.compare.html || '-';
+ var links = [];
+ if (weblink && p.compare && p.compare.webUrl) links.push('web');
+ if (downloadlink && p.compare && p.compare.downloadUrl) links.push('download');
+ //now convert to text
+ links = links && links.join(' ') || '-';
- return ''+name+' | '+statustext+' |
';
+ return ''+name+' | '+statustext+' | '+links+' |
';
}
result += 'Out of date |
';
for (var i in plugins.outOfDate) {
- result += formatRow (plugins.outOfDate[i]);
+ result += formatRow (plugins.outOfDate[i],true,true);
}
if (plugins.outOfDate.length==0) {
result += 'no plugins |
';
@@ -208,7 +258,7 @@ window.plugin.updateCheck.showReport = function(data) {
result += 'Up To Date |
';
for (var i in plugins.upToDate) {
- result += formatRow (plugins.upToDate[i]);
+ result += formatRow (plugins.upToDate[i],true,false);
}
if (plugins.upToDate.length==0) {
result += 'no plugins |
';
@@ -216,7 +266,7 @@ window.plugin.updateCheck.showReport = function(data) {
result += 'Other |
';
for (var i in plugins.other) {
- result += formatRow (plugins.other[i]);
+ result += formatRow (plugins.other[i],true,false);
}
if (plugins.other.length==0) {
result += 'no plugins |
';