diff --git a/LICENSE b/LICENSE
index df188a291..8c1759202 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,5 +1,5 @@
/*
-* appchan x - Version 2.8.13 - 2014-03-07
+* appchan x - Version 2.8.13 - 2014-03-08
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js
index 3503a81ce..b63f7d763 100644
--- a/builds/appchan-x.user.js
+++ b/builds/appchan-x.user.js
@@ -24,7 +24,7 @@
// ==/UserScript==
/*
-* appchan x - Version 2.8.13 - 2014-03-07
+* appchan x - Version 2.8.13 - 2014-03-08
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@@ -4757,6 +4757,7 @@
innerHTML: "Return Bottom "
});
this.searchInput = $('#index-search', this.navLinks);
+ this.searchTest();
this.hideLabel = $('#hidden-label', this.navLinks);
this.selectMode = $('#index-mode', this.navLinks);
this.selectSort = $('#index-sort', this.navLinks);
@@ -4773,12 +4774,9 @@
$.on(this.selectMode, 'change', this.cb.mode);
$.on(this.selectSort, 'change', this.cb.sort);
$.on(this.selectSize, 'change', this.cb.size);
- this.searchInput = $('#index-search', this.navLinks);
this.currentPage = this.getCurrentPage();
$.on(d, 'scroll', Index.scroll);
$.on(this.pagelist, 'click', this.cb.pageNav);
- $.on(this.searchInput, 'input', this.onSearchInput);
- $.on($('#index-search-clear', this.navLinks), 'click', this.clearSearch);
$.on($('#returnlink a', this.navLinks), 'click', Navigate.navigate);
if (g.VIEW === 'index') {
this.update();
@@ -4962,18 +4960,22 @@
types[(i + 1) % types.length].selected = true;
return $.event('change', null, Index.selectSort);
},
- addCatalogSwitch: function() {
- var a;
- a = $.el('a', {
- href: 'javascript:;',
- textContent: 'Switch to appchan x\'s catalog',
- className: 'btn-wrap'
- });
- $.on(a, 'click', function() {
- $.set('Index Mode', 'catalog');
- return window.location = './';
- });
- return $.add($.id('info'), a);
+ catalogSwitch: function() {
+ var hash;
+ $.set('Index Mode', 'catalog');
+ hash = window.location.hash;
+ return window.location = './' + hash;
+ },
+ searchTest: function() {
+ var hash, match;
+ if (!(hash = window.location.hash)) {
+ return;
+ }
+ if (!(match = hash.match(/s=([\w]+)/))) {
+ return;
+ }
+ this.searchInput.value = match[1];
+ return $.on(d, '4chanXInitFinished', this.onSearchInput);
},
setupNavLinks: function() {
var el, _i, _len, _ref;
@@ -5223,7 +5225,9 @@
} else {
strong = $.el('strong');
}
- a = pagesRoot.children[pageNum];
+ if (!(a = pagesRoot.children[pageNum])) {
+ return;
+ }
$.before(a, strong);
return $.add(strong, a);
},
@@ -16375,9 +16379,6 @@
return;
}
$.addClass(Index.button, 'fa-spin');
- if (Index.isSearching) {
- Index.clearSearch();
- }
_ref = this.pathname.split('/'), _ = _ref[0], boardID = _ref[1], view = _ref[2], threadID = _ref[3];
if ('f' === boardID || 'f' === g.BOARD.ID) {
return;
@@ -16385,6 +16386,9 @@
if (e) {
e.preventDefault();
}
+ if (Index.isSearching) {
+ Index.clearSearch();
+ }
Navigate.title = function() {};
delete Index.pageNum;
$.rmAll(Header.hover);
@@ -16395,7 +16399,7 @@
view = 'index';
}
path = this.pathname;
- if (this.hash) {
+ if (this.hash && view === 'thread') {
path += this.hash;
}
if (this.id !== 'popState') {
@@ -17628,8 +17632,7 @@
}
})();
if (g.VIEW === 'catalog') {
- $.ready(Index.addCatalogSwitch);
- return;
+ return $.ready(Index.catalogSwitch);
}
if (g.VIEW === 'thread') {
g.THREADID = +pathname[3];
diff --git a/builds/crx/script.js b/builds/crx/script.js
index f6172d85b..669bc9cb8 100644
--- a/builds/crx/script.js
+++ b/builds/crx/script.js
@@ -1,6 +1,6 @@
// Generated by CoffeeScript
/*
-* appchan x - Version 2.8.13 - 2014-03-07
+* appchan x - Version 2.8.13 - 2014-03-08
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@@ -4816,6 +4816,7 @@
innerHTML: "Return Bottom "
});
this.searchInput = $('#index-search', this.navLinks);
+ this.searchTest();
this.hideLabel = $('#hidden-label', this.navLinks);
this.selectMode = $('#index-mode', this.navLinks);
this.selectSort = $('#index-sort', this.navLinks);
@@ -4832,12 +4833,9 @@
$.on(this.selectMode, 'change', this.cb.mode);
$.on(this.selectSort, 'change', this.cb.sort);
$.on(this.selectSize, 'change', this.cb.size);
- this.searchInput = $('#index-search', this.navLinks);
this.currentPage = this.getCurrentPage();
$.on(d, 'scroll', Index.scroll);
$.on(this.pagelist, 'click', this.cb.pageNav);
- $.on(this.searchInput, 'input', this.onSearchInput);
- $.on($('#index-search-clear', this.navLinks), 'click', this.clearSearch);
$.on($('#returnlink a', this.navLinks), 'click', Navigate.navigate);
if (g.VIEW === 'index') {
this.update();
@@ -5021,18 +5019,22 @@
types[(i + 1) % types.length].selected = true;
return $.event('change', null, Index.selectSort);
},
- addCatalogSwitch: function() {
- var a;
- a = $.el('a', {
- href: 'javascript:;',
- textContent: 'Switch to appchan x\'s catalog',
- className: 'btn-wrap'
- });
- $.on(a, 'click', function() {
- $.set('Index Mode', 'catalog');
- return window.location = './';
- });
- return $.add($.id('info'), a);
+ catalogSwitch: function() {
+ var hash;
+ $.set('Index Mode', 'catalog');
+ hash = window.location.hash;
+ return window.location = './' + hash;
+ },
+ searchTest: function() {
+ var hash, match;
+ if (!(hash = window.location.hash)) {
+ return;
+ }
+ if (!(match = hash.match(/s=([\w]+)/))) {
+ return;
+ }
+ this.searchInput.value = match[1];
+ return $.on(d, '4chanXInitFinished', this.onSearchInput);
},
setupNavLinks: function() {
var el, _i, _len, _ref;
@@ -5282,7 +5284,9 @@
} else {
strong = $.el('strong');
}
- a = pagesRoot.children[pageNum];
+ if (!(a = pagesRoot.children[pageNum])) {
+ return;
+ }
$.before(a, strong);
return $.add(strong, a);
},
@@ -16395,9 +16399,6 @@
return;
}
$.addClass(Index.button, 'fa-spin');
- if (Index.isSearching) {
- Index.clearSearch();
- }
_ref = this.pathname.split('/'), _ = _ref[0], boardID = _ref[1], view = _ref[2], threadID = _ref[3];
if ('f' === boardID || 'f' === g.BOARD.ID) {
return;
@@ -16405,6 +16406,9 @@
if (e) {
e.preventDefault();
}
+ if (Index.isSearching) {
+ Index.clearSearch();
+ }
Navigate.title = function() {};
delete Index.pageNum;
$.rmAll(Header.hover);
@@ -16415,7 +16419,7 @@
view = 'index';
}
path = this.pathname;
- if (this.hash) {
+ if (this.hash && view === 'thread') {
path += this.hash;
}
if (this.id !== 'popState') {
@@ -17640,8 +17644,7 @@
}
})();
if (g.VIEW === 'catalog') {
- $.ready(Index.addCatalogSwitch);
- return;
+ return $.ready(Index.catalogSwitch);
}
if (g.VIEW === 'thread') {
g.THREADID = +pathname[3];
diff --git a/src/General/Index.coffee b/src/General/Index.coffee
index 4c396433c..6069b305e 100644
--- a/src/General/Index.coffee
+++ b/src/General/Index.coffee
@@ -95,6 +95,9 @@ Index =
innerHTML: <%= importHTML('Features/Index-navlinks') %>
@searchInput = $ '#index-search', @navLinks
+
+ @searchTest()
+
@hideLabel = $ '#hidden-label', @navLinks
@selectMode = $ '#index-mode', @navLinks
@selectSort = $ '#index-sort', @navLinks
@@ -109,14 +112,10 @@ Index =
$.on @selectSort, 'change', @cb.sort
$.on @selectSize, 'change', @cb.size
- @searchInput = $ '#index-search', @navLinks
-
@currentPage = @getCurrentPage()
$.on d, 'scroll', Index.scroll
$.on @pagelist, 'click', @cb.pageNav
- $.on @searchInput, 'input', @onSearchInput
- $.on $('#index-search-clear', @navLinks), 'click', @clearSearch
$.on $('#returnlink a', @navLinks), 'click', Navigate.navigate
if g.VIEW is 'index'
@@ -254,15 +253,16 @@ Index =
types[(i + 1) % types.length].selected = true
$.event 'change', null, Index.selectSort
- addCatalogSwitch: ->
- a = $.el 'a',
- href: 'javascript:;'
- textContent: 'Switch to <%= meta.name %>\'s catalog'
- className: 'btn-wrap'
- $.on a, 'click', ->
- $.set 'Index Mode', 'catalog'
- window.location = './'
- $.add $.id('info'), a
+ catalogSwitch: ->
+ $.set 'Index Mode', 'catalog'
+ {hash} = window.location
+ window.location = './' + hash
+
+ searchTest: ->
+ return unless hash = window.location.hash
+ return unless match = hash.match /s=([\w]+)/
+ @searchInput.value = match[1]
+ $.on d, '4chanXInitFinished', @onSearchInput
setupNavLinks: ->
for el in $$ '.navLinks.desktop > a'
@@ -456,7 +456,7 @@ Index =
$.replace strong, strong.firstChild
else
strong = $.el 'strong'
- a = pagesRoot.children[pageNum]
+ return unless a = pagesRoot.children[pageNum] # If coming in from a Navigate.navigate, this could break.
$.before a, strong
$.add strong, a
diff --git a/src/General/Main.coffee b/src/General/Main.coffee
index dbb56a0e2..5a534ab00 100644
--- a/src/General/Main.coffee
+++ b/src/General/Main.coffee
@@ -15,8 +15,7 @@ Main =
else
'index'
if g.VIEW is 'catalog'
- $.ready Index.addCatalogSwitch
- return
+ return $.ready Index.catalogSwitch
if g.VIEW is 'thread'
g.THREADID = +pathname[3]
diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee
index 22cd4220d..afe252ea1 100644
--- a/src/General/Navigate.coffee
+++ b/src/General/Navigate.coffee
@@ -158,12 +158,12 @@ Navigate =
return
$.addClass Index.button, 'fa-spin'
- Index.clearSearch() if Index.isSearching
[_, boardID, view, threadID] = @pathname.split '/'
return if 'f' in [boardID, g.BOARD.ID]
e.preventDefault() if e
+ Index.clearSearch() if Index.isSearching
Navigate.title = -> return
delete Index.pageNum
@@ -176,7 +176,7 @@ Navigate =
view = 'index' # path is "/boardID/". See the problem?
path = @pathname
- path += @hash if @hash
+ path += @hash if @hash and view is 'thread'
history.pushState null, '', path unless @id is 'popState'
Navigate.path = @pathname