diff --git a/CHANGELOG.md b/CHANGELOG.md
index 91a4ce22e..cb19060bc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+seaweedchan:
+- Fix update checking
+
### 1.1.9 - 2013-05-02
seaweedchan
- Fix boards with previously deleted archives not switching to new archives
@@ -21,7 +24,6 @@ seaweedchan:
- Add paste.installgentoo.com embedding
- Added `Posting Success Notifications` option to make "Post Successful!" and "_____ uploaded" notifications optional
- Added `Allow False Positives` option under Linkification, giving the user more control over what's linkified.
-- Fix URL for update checking
### 1.1.6 - 2013-05-01
seaweedchan:
diff --git a/Gruntfile.coffee b/Gruntfile.coffee
index 0b2d2a714..e3ccf3961 100644
--- a/Gruntfile.coffee
+++ b/Gruntfile.coffee
@@ -42,7 +42,7 @@ module.exports = (grunt) ->
options: concatOptions
files:
'LICENSE': 'src/General/meta/banner.js',
- 'builds/version': 'src/General/meta/version.js'
+ 'latest.js': 'src/General/meta/latest.js'
crx:
options: concatOptions
diff --git a/builds/4chan-X.js b/builds/4chan-X.js
index 4c38bce6c..c0552b108 100644
--- a/builds/4chan-X.js
+++ b/builds/4chan-X.js
@@ -10045,6 +10045,17 @@
obj.callback.isAddon = true;
return Klass.prototype.callbacks.push(obj.callback);
},
+ message: function(e) {
+ var el, version;
+
+ version = e.data.version;
+ if (version && version !== g.VERSION) {
+ el = $.el('span', {
+ innerHTML: "Update: 4chan X v" + version + " is out, get it here."
+ });
+ return new Notification('info', el, 120);
+ }
+ },
checkUpdate: function() {
var freq, items, now;
@@ -10061,27 +10072,12 @@
if (items.lastupdate > now - freq || items.lastchecked > now - $.DAY) {
return;
}
- return $.ajax('https://github.com/seaweedchan/4chan-x/raw/master/builds/version', {
- onload: function() {
- var el, version;
-
- if (this.status !== 200) {
- return;
- }
- version = this.response;
- if (!/^\d\.\d+\.\d+$/.test(version)) {
- return;
- }
- if (g.VERSION === version) {
- $.set('lastupdate', now);
- return;
- }
- $.set('lastchecked', now);
- el = $.el('span', {
- innerHTML: "Update: 4chan X v" + version + " is out, get it here."
- });
- return new Notification('info', el, 120);
- }
+ return $.ready(function() {
+ $.on(window, 'message', Main.message);
+ $.set('lastUpdate', now);
+ return $.add(d.head, $.el('script', {
+ src: 'https://github.com/seaweedchan/4chan-x/raw/master/latest.js'
+ }));
});
});
},
diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js
index c3c2726dc..4b419cfd8 100644
--- a/builds/4chan-X.user.js
+++ b/builds/4chan-X.user.js
@@ -10068,6 +10068,17 @@
obj.callback.isAddon = true;
return Klass.prototype.callbacks.push(obj.callback);
},
+ message: function(e) {
+ var el, version;
+
+ version = e.data.version;
+ if (version && version !== g.VERSION) {
+ el = $.el('span', {
+ innerHTML: "Update: 4chan X v" + version + " is out, get it here."
+ });
+ return new Notification('info', el, 120);
+ }
+ },
checkUpdate: function() {
var freq, items, now;
@@ -10084,27 +10095,12 @@
if (items.lastupdate > now - freq || items.lastchecked > now - $.DAY) {
return;
}
- return $.ajax('https://github.com/seaweedchan/4chan-x/raw/master/builds/version', {
- onload: function() {
- var el, version;
-
- if (this.status !== 200) {
- return;
- }
- version = this.response;
- if (!/^\d\.\d+\.\d+$/.test(version)) {
- return;
- }
- if (g.VERSION === version) {
- $.set('lastupdate', now);
- return;
- }
- $.set('lastchecked', now);
- el = $.el('span', {
- innerHTML: "Update: 4chan X v" + version + " is out, get it here."
- });
- return new Notification('info', el, 120);
- }
+ return $.ready(function() {
+ $.on(window, 'message', Main.message);
+ $.set('lastUpdate', now);
+ return $.add(d.head, $.el('script', {
+ src: 'https://github.com/seaweedchan/4chan-x/raw/master/latest.js'
+ }));
});
});
},
diff --git a/builds/crx/script.js b/builds/crx/script.js
index d305ee0d7..7659ed98f 100644
--- a/builds/crx/script.js
+++ b/builds/crx/script.js
@@ -10049,6 +10049,17 @@
obj.callback.isAddon = true;
return Klass.prototype.callbacks.push(obj.callback);
},
+ message: function(e) {
+ var el, version;
+
+ version = e.data.version;
+ if (version && version !== g.VERSION) {
+ el = $.el('span', {
+ innerHTML: "Update: 4chan X v" + version + " is out, get it here."
+ });
+ return new Notification('info', el, 120);
+ }
+ },
checkUpdate: function() {
var freq, items, now;
@@ -10065,27 +10076,12 @@
if (items.lastupdate > now - freq || items.lastchecked > now - $.DAY) {
return;
}
- return $.ajax('https://github.com/seaweedchan/4chan-x/raw/master/builds/version', {
- onload: function() {
- var el, version;
-
- if (this.status !== 200) {
- return;
- }
- version = this.response;
- if (!/^\d\.\d+\.\d+$/.test(version)) {
- return;
- }
- if (g.VERSION === version) {
- $.set('lastupdate', now);
- return;
- }
- $.set('lastchecked', now);
- el = $.el('span', {
- innerHTML: "Update: 4chan X v" + version + " is out, get it here."
- });
- return new Notification('info', el, 120);
- }
+ return $.ready(function() {
+ $.on(window, 'message', Main.message);
+ $.set('lastUpdate', now);
+ return $.add(d.head, $.el('script', {
+ src: 'https://github.com/seaweedchan/4chan-x/raw/master/latest.js'
+ }));
});
});
},
diff --git a/builds/version b/builds/version
deleted file mode 100644
index a5e428299..000000000
--- a/builds/version
+++ /dev/null
@@ -1 +0,0 @@
-1.1.9
\ No newline at end of file
diff --git a/latest.js b/latest.js
index 7f4f65a1b..da51bff12 100644
--- a/latest.js
+++ b/latest.js
@@ -1 +1 @@
-postMessage({version:'1.1.10'},'*')
+postMessage({version:'1.1.9'},'*')
diff --git a/src/General/Main.coffee b/src/General/Main.coffee
index f2691168e..49b505598 100644
--- a/src/General/Main.coffee
+++ b/src/General/Main.coffee
@@ -286,6 +286,13 @@ Main =
obj.callback.isAddon = true
Klass::callbacks.push obj.callback
+ message: (e) ->
+ {version} = e.data
+ if version and version isnt g.VERSION
+ el = $.el 'span',
+ innerHTML: "Update: <%= meta.name %> v#{version} is out, get it target=_blank>here."
+ new Notification 'info', el, 120
+
checkUpdate: ->
return unless Conf['Check for Updates'] and Main.isThisPageLegit()
# Check for updates after:
@@ -300,18 +307,11 @@ Main =
$.get items, (items) ->
if items.lastupdate > now - freq or items.lastchecked > now - $.DAY
return
- $.ajax '<%= meta.repo %>raw/<%= meta.mainBranch %>/<%= meta.buildsPath %>version', onload: ->
- return unless @status is 200
- version = @response
- return unless /^\d\.\d+\.\d+$/.test version
- if g.VERSION is version
- # Don't check for updates too frequently if there wasn't one in a 'long' time.
- $.set 'lastupdate', now
- return
- $.set 'lastchecked', now
- el = $.el 'span',
- innerHTML: "Update: <%= meta.name %> v#{version} is out, get it target=_blank>here."
- new Notification 'info', el, 120
+ $.ready ->
+ $.on window, 'message', Main.message
+ $.set 'lastUpdate', now
+ $.add d.head, $.el 'script',
+ src: '<%= meta.repo %>raw/<%= meta.mainBranch %>/latest.js'
handleErrors: (errors) ->
unless errors instanceof Array
diff --git a/src/General/meta/latest.js b/src/General/meta/latest.js
new file mode 100644
index 000000000..d4611d0c3
--- /dev/null
+++ b/src/General/meta/latest.js
@@ -0,0 +1 @@
+postMessage({version:'<%= version %>'},'*')
diff --git a/src/General/meta/version.js b/src/General/meta/version.js
deleted file mode 100644
index 9e84c0a2e..000000000
--- a/src/General/meta/version.js
+++ /dev/null
@@ -1 +0,0 @@
-<%= version %>
\ No newline at end of file