Merge branch 'v3' of git://github.com/MayhemYDG/4chan-x into v3

Conflicts:
	Gruntfile.js
	src/features.coffee
This commit is contained in:
Zixaphir 2013-04-14 13:41:26 -07:00
commit 85621c4907
7 changed files with 87 additions and 55 deletions

View File

@ -1,3 +1,5 @@
- Fix resurrecting dead quotelinks on HTTP.
### 3.0.6 - *2013-04-14* ### 3.0.6 - *2013-04-14*
- Fix regression concerning thread selection when quoting on the index. - Fix regression concerning thread selection when quoting on the index.

View File

@ -1,15 +1,16 @@
module.exports = (grunt) -> module.exports = (grunt) ->
pkg = grunt.file.readJSON 'package.json' pkg = grunt.file.readJSON 'package.json'
concatOptions =
process:
data: pkg
# Project configuration. # Project configuration.
grunt.initConfig grunt.initConfig
pkg: pkg pkg: pkg
concat: concat:
coffee: coffee:
options: options: concatOptions
process:
data: pkg
src: [ src: [
'src/config.coffee' 'src/config.coffee'
'src/globals.coffee' 'src/globals.coffee'
@ -27,9 +28,7 @@ module.exports = (grunt) ->
dest: 'tmp/script.coffee' dest: 'tmp/script.coffee'
crx: crx:
options: options: concatOptions
process:
data: pkg
files: files:
'builds/crx/manifest.json': 'src/manifest.json' 'builds/crx/manifest.json': 'src/manifest.json'
'builds/crx/script.js': [ 'builds/crx/script.js': [
@ -38,9 +37,7 @@ module.exports = (grunt) ->
] ]
userjs: userjs:
options: options: concatOptions
process:
data: pkg
src: [ src: [
'src/metadata.js' 'src/metadata.js'
'src/banner.js' 'src/banner.js'
@ -49,9 +46,7 @@ module.exports = (grunt) ->
dest: 'builds/<%= pkg.name %>.js' dest: 'builds/<%= pkg.name %>.js'
userscript: userscript:
options: options: concatOptions
process:
data: pkg
files: files:
'builds/<%= pkg.name %>.meta.js': 'src/metadata.js' 'builds/<%= pkg.name %>.meta.js': 'src/metadata.js'
'builds/<%= pkg.name %>.user.js': [ 'builds/<%= pkg.name %>.user.js': [
@ -170,22 +165,29 @@ module.exports = (grunt) ->
grunt.registerTask 'patch', [ grunt.registerTask 'patch', [
'bump' 'bump'
'reloadPkh'
'updcl:3' 'updcl:3'
] ]
grunt.registerTask 'minor', [ grunt.registerTask 'minor', [
'bump:minor' 'bump:minor'
'reloadPkh'
'updcl:2' 'updcl:2'
] ]
grunt.registerTask 'major', [ grunt.registerTask 'major', [
'bump:major' 'bump:major'
'reloadPkh'
'updcl:1' 'updcl:1'
] ]
grunt.registerTask 'updcl', 'Update the changelog', (i) -> grunt.registerTask 'reloadPkg', 'Reload the package', ->
# Update the `pkg` object with the new version. # Update the `pkg` object with the new version.
pkg = grunt.file.readJSON('package.json'); pkg = grunt.file.readJSON('package.json')
concatOptions.process.data = pkg
grunt.log.ok('pkg reloaded.')
grunt.registerTask 'updcl', 'Update the changelog', (i) ->
# i is the number of #s for markdown. # i is the number of #s for markdown.
version = [] version = []
version.length = +i + 1 version.length = +i + 1

View File

@ -865,6 +865,13 @@
}; };
} }
})(), })(),
rmAll: function(root) {
var node;
while (node = root.firstChild) {
$.rm(node);
}
},
tn: function(s) { tn: function(s) {
return d.createTextNode(s); return d.createTextNode(s);
}, },
@ -1224,7 +1231,7 @@
var as, list, nodes; var as, list, nodes;
list = $('#custom-board-list', Header.nav); list = $('#custom-board-list', Header.nav);
list.innerHTML = null; $.rmAll(list);
if (!text) { if (!text) {
return; return;
} }
@ -1603,7 +1610,7 @@
} }
$.addClass($(".tab-" + this.hyphenatedTitle, Settings.dialog), 'tab-selected'); $.addClass($(".tab-" + this.hyphenatedTitle, Settings.dialog), 'tab-selected');
section = $('section', Settings.dialog); section = $('section', Settings.dialog);
section.innerHTML = null; $.rmAll(section);
section.className = "section-" + this.hyphenatedTitle; section.className = "section-" + this.hyphenatedTitle;
this.open(section, g); this.open(section, g);
return section.scrollTop = 0; return section.scrollTop = 0;
@ -1732,7 +1739,7 @@
return; return;
} }
p = $('.imp-exp-result', Settings.dialog); p = $('.imp-exp-result', Settings.dialog);
p.innerHTML = null; $.rmAll(p);
return $.add(p, a); return $.add(p, a);
}, },
"import": function() { "import": function() {
@ -1873,7 +1880,7 @@
div = this.nextElementSibling; div = this.nextElementSibling;
if ((name = this.value) !== 'guide') { if ((name = this.value) !== 'guide') {
div.innerHTML = null; $.rmAll(div);
ta = $.el('textarea', { ta = $.el('textarea', {
name: name, name: name,
className: 'field', className: 'field',
@ -3753,9 +3760,9 @@
case 'vp': case 'vp':
case 'vr': case 'vr':
case 'wsg': case 'wsg':
return "//archive.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; return "https://archive.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID;
case 'u': case 'u':
return "//nsfw.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; return "https://nsfw.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID;
case 'c': case 'c':
case 'int': case 'int':
case 'out': case 'out':
@ -3795,10 +3802,10 @@
case 's4s': case 's4s':
return Redirect.path('//fuuka.warosu.org', 'fuuka', data); return Redirect.path('//fuuka.warosu.org', 'fuuka', data);
case 'diy': case 'diy':
case 'g':
case 'sci': case 'sci':
return Redirect.path('//archive.installgentoo.net', 'fuuka', data); return Redirect.path('//archive.installgentoo.net', 'fuuka', data);
case 'cgl': case 'cgl':
case 'g':
case 'mu': case 'mu':
case 'w': case 'w':
return Redirect.path('//rbt.asia', 'fuuka', data); return Redirect.path('//rbt.asia', 'fuuka', data);
@ -4110,9 +4117,9 @@
clone = post.addClone(context); clone = post.addClone(context);
Main.callbackNodes(Post, [clone]); Main.callbackNodes(Post, [clone]);
nodes = clone.nodes; nodes = clone.nodes;
nodes.root.innerHTML = null; $.rmAll(nodes.root);
$.add(nodes.root, nodes.post); $.add(nodes.root, nodes.post);
root.innerHTML = null; $.rmAll(root);
return $.add(root, nodes.root); return $.add(root, nodes.root);
}, },
fetchedPost: function(req, boardID, threadID, postID, root, context) { fetchedPost: function(req, boardID, threadID, postID, root, context) {
@ -6513,7 +6520,7 @@
nodes.push(div); nodes.push(div);
} }
} }
ThreadWatcher.dialog.innerHTML = ''; $.rmAll(ThreadWatcher.dialog);
$.add(ThreadWatcher.dialog, nodes); $.add(ThreadWatcher.dialog, nodes);
watched = watched[g.BOARD] || {}; watched = watched[g.BOARD] || {};
_ref1 = g.BOARD.threads; _ref1 = g.BOARD.threads;

View File

@ -862,6 +862,13 @@
}; };
} }
})(), })(),
rmAll: function(root) {
var node;
while (node = root.firstChild) {
$.rm(node);
}
},
tn: function(s) { tn: function(s) {
return d.createTextNode(s); return d.createTextNode(s);
}, },
@ -1215,7 +1222,7 @@
var as, list, nodes; var as, list, nodes;
list = $('#custom-board-list', Header.nav); list = $('#custom-board-list', Header.nav);
list.innerHTML = null; $.rmAll(list);
if (!text) { if (!text) {
return; return;
} }
@ -1594,7 +1601,7 @@
} }
$.addClass($(".tab-" + this.hyphenatedTitle, Settings.dialog), 'tab-selected'); $.addClass($(".tab-" + this.hyphenatedTitle, Settings.dialog), 'tab-selected');
section = $('section', Settings.dialog); section = $('section', Settings.dialog);
section.innerHTML = null; $.rmAll(section);
section.className = "section-" + this.hyphenatedTitle; section.className = "section-" + this.hyphenatedTitle;
this.open(section, g); this.open(section, g);
return section.scrollTop = 0; return section.scrollTop = 0;
@ -1723,7 +1730,7 @@
return; return;
} }
p = $('.imp-exp-result', Settings.dialog); p = $('.imp-exp-result', Settings.dialog);
p.innerHTML = null; $.rmAll(p);
return $.add(p, a); return $.add(p, a);
}, },
"import": function() { "import": function() {
@ -1864,7 +1871,7 @@
div = this.nextElementSibling; div = this.nextElementSibling;
if ((name = this.value) !== 'guide') { if ((name = this.value) !== 'guide') {
div.innerHTML = null; $.rmAll(div);
ta = $.el('textarea', { ta = $.el('textarea', {
name: name, name: name,
className: 'field', className: 'field',
@ -3744,9 +3751,9 @@
case 'vp': case 'vp':
case 'vr': case 'vr':
case 'wsg': case 'wsg':
return "//archive.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; return "https://archive.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID;
case 'u': case 'u':
return "//nsfw.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; return "https://nsfw.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID;
case 'c': case 'c':
case 'int': case 'int':
case 'out': case 'out':
@ -3786,10 +3793,10 @@
case 's4s': case 's4s':
return Redirect.path('//fuuka.warosu.org', 'fuuka', data); return Redirect.path('//fuuka.warosu.org', 'fuuka', data);
case 'diy': case 'diy':
case 'g':
case 'sci': case 'sci':
return Redirect.path('//archive.installgentoo.net', 'fuuka', data); return Redirect.path('//archive.installgentoo.net', 'fuuka', data);
case 'cgl': case 'cgl':
case 'g':
case 'mu': case 'mu':
case 'w': case 'w':
return Redirect.path('//rbt.asia', 'fuuka', data); return Redirect.path('//rbt.asia', 'fuuka', data);
@ -4101,9 +4108,9 @@
clone = post.addClone(context); clone = post.addClone(context);
Main.callbackNodes(Post, [clone]); Main.callbackNodes(Post, [clone]);
nodes = clone.nodes; nodes = clone.nodes;
nodes.root.innerHTML = null; $.rmAll(nodes.root);
$.add(nodes.root, nodes.post); $.add(nodes.root, nodes.post);
root.innerHTML = null; $.rmAll(root);
return $.add(root, nodes.root); return $.add(root, nodes.root);
}, },
fetchedPost: function(req, boardID, threadID, postID, root, context) { fetchedPost: function(req, boardID, threadID, postID, root, context) {
@ -6504,7 +6511,7 @@
nodes.push(div); nodes.push(div);
} }
} }
ThreadWatcher.dialog.innerHTML = ''; $.rmAll(ThreadWatcher.dialog);
$.add(ThreadWatcher.dialog, nodes); $.add(ThreadWatcher.dialog, nodes);
watched = watched[g.BOARD] || {}; watched = watched[g.BOARD] || {};
_ref1 = g.BOARD.threads; _ref1 = g.BOARD.threads;

View File

@ -839,6 +839,13 @@
}; };
} }
})(), })(),
rmAll: function(root) {
var node;
while (node = root.firstChild) {
$.rm(node);
}
},
tn: function(s) { tn: function(s) {
return d.createTextNode(s); return d.createTextNode(s);
}, },
@ -1159,7 +1166,7 @@
var as, list, nodes; var as, list, nodes;
list = $('#custom-board-list', Header.nav); list = $('#custom-board-list', Header.nav);
list.innerHTML = null; $.rmAll(list);
if (!text) { if (!text) {
return; return;
} }
@ -1538,7 +1545,7 @@
} }
$.addClass($(".tab-" + this.hyphenatedTitle, Settings.dialog), 'tab-selected'); $.addClass($(".tab-" + this.hyphenatedTitle, Settings.dialog), 'tab-selected');
section = $('section', Settings.dialog); section = $('section', Settings.dialog);
section.innerHTML = null; $.rmAll(section);
section.className = "section-" + this.hyphenatedTitle; section.className = "section-" + this.hyphenatedTitle;
this.open(section, g); this.open(section, g);
return section.scrollTop = 0; return section.scrollTop = 0;
@ -1667,7 +1674,7 @@
return; return;
} }
p = $('.imp-exp-result', Settings.dialog); p = $('.imp-exp-result', Settings.dialog);
p.innerHTML = null; $.rmAll(p);
return $.add(p, a); return $.add(p, a);
}, },
"import": function() { "import": function() {
@ -1808,7 +1815,7 @@
div = this.nextElementSibling; div = this.nextElementSibling;
if ((name = this.value) !== 'guide') { if ((name = this.value) !== 'guide') {
div.innerHTML = null; $.rmAll(div);
ta = $.el('textarea', { ta = $.el('textarea', {
name: name, name: name,
className: 'field', className: 'field',
@ -3688,9 +3695,9 @@
case 'vp': case 'vp':
case 'vr': case 'vr':
case 'wsg': case 'wsg':
return "//archive.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; return "https://archive.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID;
case 'u': case 'u':
return "//nsfw.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; return "https://nsfw.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID;
case 'c': case 'c':
case 'int': case 'int':
case 'out': case 'out':
@ -3730,10 +3737,10 @@
case 's4s': case 's4s':
return Redirect.path('//fuuka.warosu.org', 'fuuka', data); return Redirect.path('//fuuka.warosu.org', 'fuuka', data);
case 'diy': case 'diy':
case 'g':
case 'sci': case 'sci':
return Redirect.path('//archive.installgentoo.net', 'fuuka', data); return Redirect.path('//archive.installgentoo.net', 'fuuka', data);
case 'cgl': case 'cgl':
case 'g':
case 'mu': case 'mu':
case 'w': case 'w':
return Redirect.path('//rbt.asia', 'fuuka', data); return Redirect.path('//rbt.asia', 'fuuka', data);
@ -4045,9 +4052,9 @@
clone = post.addClone(context); clone = post.addClone(context);
Main.callbackNodes(Post, [clone]); Main.callbackNodes(Post, [clone]);
nodes = clone.nodes; nodes = clone.nodes;
nodes.root.innerHTML = null; $.rmAll(nodes.root);
$.add(nodes.root, nodes.post); $.add(nodes.root, nodes.post);
root.innerHTML = null; $.rmAll(root);
return $.add(root, nodes.root); return $.add(root, nodes.root);
}, },
fetchedPost: function(req, boardID, threadID, postID, root, context) { fetchedPost: function(req, boardID, threadID, postID, root, context) {
@ -6453,7 +6460,7 @@
nodes.push(div); nodes.push(div);
} }
} }
ThreadWatcher.dialog.innerHTML = ''; $.rmAll(ThreadWatcher.dialog);
$.add(ThreadWatcher.dialog, nodes); $.add(ThreadWatcher.dialog, nodes);
watched = watched[g.BOARD] || {}; watched = watched[g.BOARD] || {};
_ref1 = g.BOARD.threads; _ref1 = g.BOARD.threads;

View File

@ -143,6 +143,11 @@ $.extend $,
(el) -> el.remove() (el) -> el.remove()
else else
(el) -> el.parentNode?.removeChild el (el) -> el.parentNode?.removeChild el
rmAll: (root) ->
# jsperf.com/emptify-element
while node = root.firstChild
$.rm node
return
tn: (s) -> tn: (s) ->
d.createTextNode s d.createTextNode s
frag: -> frag: ->

View File

@ -88,7 +88,7 @@ Header =
generateBoardList: (text) -> generateBoardList: (text) ->
list = $ '#custom-board-list', Header.nav list = $ '#custom-board-list', Header.nav
list.innerHTML = null $.rmAll list
return unless text return unless text
as = $$('#full-board-list a', Header.nav)[0...-2] # ignore the Settings and Home links as = $$('#full-board-list a', Header.nav)[0...-2] # ignore the Settings and Home links
nodes = text.match(/[\w@]+(-(all|title|full|index|catalog|text:"[^"]+"))*|[^\w@]+/g).map (t) -> nodes = text.match(/[\w@]+(-(all|title|full|index|catalog|text:"[^"]+"))*|[^\w@]+/g).map (t) ->
@ -387,7 +387,7 @@ Settings =
$.rmClass selected, 'tab-selected' $.rmClass selected, 'tab-selected'
$.addClass $(".tab-#{@hyphenatedTitle}", Settings.dialog), 'tab-selected' $.addClass $(".tab-#{@hyphenatedTitle}", Settings.dialog), 'tab-selected'
section = $ 'section', Settings.dialog section = $ 'section', Settings.dialog
section.innerHTML = null $.rmAll section
section.className = "section-#{@hyphenatedTitle}" section.className = "section-#{@hyphenatedTitle}"
@open section, g @open section, g
section.scrollTop = 0 section.scrollTop = 0
@ -473,7 +473,7 @@ Settings =
return return
# XXX Firefox won't let us download automatically. # XXX Firefox won't let us download automatically.
p = $ '.imp-exp-result', Settings.dialog p = $ '.imp-exp-result', Settings.dialog
p.innerHTML = null $.rmAll p
$.add p, a $.add p, a
import: -> import: ->
@nextElementSibling.click() @nextElementSibling.click()
@ -595,7 +595,7 @@ Settings =
selectFilter: -> selectFilter: ->
div = @nextElementSibling div = @nextElementSibling
if (name = @value) isnt 'guide' if (name = @value) isnt 'guide'
div.innerHTML = null $.rmAll div
ta = $.el 'textarea', ta = $.el 'textarea',
name: name name: name
className: 'field' className: 'field'
@ -2084,11 +2084,13 @@ Redirect =
when 'c' when 'c'
"//archive.nyafuu.org/#{boardID}/full_image/#{filename}" "//archive.nyafuu.org/#{boardID}/full_image/#{filename}"
post: (boardID, postID) -> post: (boardID, postID) ->
# XXX foolz had HSTS set for 120 days, which broke XHR+CORS+Redirection when on HTTP.
# Remove necessary HTTPS procotol in September 2013.
switch boardID switch boardID
when 'a', 'co', 'gd', 'jp', 'm', 'q', 'sp', 'tg', 'tv', 'v', 'vg', 'vp', 'vr', 'wsg' when 'a', 'co', 'gd', 'jp', 'm', 'q', 'sp', 'tg', 'tv', 'v', 'vg', 'vp', 'vr', 'wsg'
"//archive.foolz.us/_/api/chan/post/?board=#{boardID}&num=#{postID}" "https://archive.foolz.us/_/api/chan/post/?board=#{boardID}&num=#{postID}"
when 'u' when 'u'
"//nsfw.foolz.us/_/api/chan/post/?board=#{boardID}&num=#{postID}" "https://nsfw.foolz.us/_/api/chan/post/?board=#{boardID}&num=#{postID}"
when 'c', 'int', 'out', 'po' when 'c', 'int', 'out', 'po'
"//archive.thedarkcave.org/_/api/chan/post/?board=#{boardID}&num=#{postID}" "//archive.thedarkcave.org/_/api/chan/post/?board=#{boardID}&num=#{postID}"
# for fuuka-based archives: # for fuuka-based archives:
@ -2104,9 +2106,9 @@ Redirect =
Redirect.path '//archive.thedarkcave.org', 'foolfuuka', data Redirect.path '//archive.thedarkcave.org', 'foolfuuka', data
when 'ck', 'fa', 'lit', 's4s' when 'ck', 'fa', 'lit', 's4s'
Redirect.path '//fuuka.warosu.org', 'fuuka', data Redirect.path '//fuuka.warosu.org', 'fuuka', data
when 'diy', 'sci' when 'diy', 'g', 'sci'
Redirect.path '//archive.installgentoo.net', 'fuuka', data Redirect.path '//archive.installgentoo.net', 'fuuka', data
when 'cgl', 'g', 'mu', 'w' when 'cgl', 'mu', 'w'
Redirect.path '//rbt.asia', 'fuuka', data Redirect.path '//rbt.asia', 'fuuka', data
when 'an', 'fit', 'k', 'mlp', 'r9k', 'toy', 'x' when 'an', 'fit', 'k', 'mlp', 'r9k', 'toy', 'x'
Redirect.path 'http://archive.heinessen.com', 'fuuka', data Redirect.path 'http://archive.heinessen.com', 'fuuka', data
@ -2479,10 +2481,10 @@ Get =
# Get rid of the side arrows. # Get rid of the side arrows.
{nodes} = clone {nodes} = clone
nodes.root.innerHTML = null $.rmAll nodes.root
$.add nodes.root, nodes.post $.add nodes.root, nodes.post
root.innerHTML = null $.rmAll root
$.add root, nodes.root $.add root, nodes.root
fetchedPost: (req, boardID, threadID, postID, root, context) -> fetchedPost: (req, boardID, threadID, postID, root, context) ->
# In case of multiple callbacks for the same request, # In case of multiple callbacks for the same request,
@ -4337,7 +4339,7 @@ ThreadWatcher =
$.add div, [x, $.tn(' '), link] $.add div, [x, $.tn(' '), link]
nodes.push div nodes.push div
ThreadWatcher.dialog.innerHTML = '' $.rmAll ThreadWatcher.dialog
$.add ThreadWatcher.dialog, nodes $.add ThreadWatcher.dialog, nodes
watched = watched[g.BOARD] or {} watched = watched[g.BOARD] or {}