Fix noface's code.
This commit is contained in:
parent
2f5f8577ea
commit
715e1fb54e
@ -5189,60 +5189,45 @@
|
|||||||
|
|
||||||
CatalogLinks = {
|
CatalogLinks = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var el, i, nav, _i, _len, _ref;
|
var clone, el, nav, _i, _len, _ref;
|
||||||
el = $.el('span', {
|
el = $.el('span', {
|
||||||
innerHTML: "[<a href=javascript:; title='Toggle Catalog Links " + (!g.CATALOG ? 'on.' : 'off.') + "'>Catalog " + (!g.CATALOG ? 'On' : 'Off') + "</a>]",
|
className: 'toggleCatalog',
|
||||||
id: 'toggleCatalog'
|
innerHTML: '[<a href=javascript:;></a>]'
|
||||||
});
|
});
|
||||||
_ref = ['boardNavDesktop', 'boardNavDesktopFoot'];
|
_ref = ['boardNavDesktop', 'boardNavDesktopFoot'];
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
nav = _ref[_i];
|
nav = _ref[_i];
|
||||||
$.on(el.firstElementChild, 'click', this.toggle);
|
clone = el.cloneNode(true);
|
||||||
$.add($.id(nav), el);
|
$.on(clone.firstElementChild, 'click', this.toggle);
|
||||||
el = $.el('span', {
|
$.add($.id(nav), clone);
|
||||||
innerHTML: el.innerHTML,
|
|
||||||
id: 'toggleCatalogFoot'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if ($.get('CatalogIsToggled')) {
|
|
||||||
i = g.CATALOG ? 0 : 1;
|
|
||||||
while (i < 2) {
|
|
||||||
this.toggle();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (g.CATALOG) {
|
|
||||||
return this.toggle();
|
|
||||||
}
|
}
|
||||||
|
return this.toggle(true);
|
||||||
},
|
},
|
||||||
toggle: function() {
|
toggle: function(onLoad) {
|
||||||
var a, el, isDead, nav, split, _i, _len, _ref;
|
var a, board, nav, root, useCatalog, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
|
if (onLoad === true) {
|
||||||
|
useCatalog = $.get('CatalogIsToggled', g.CATALOG);
|
||||||
|
} else {
|
||||||
|
useCatalog = this.textContent === 'Catalog Off';
|
||||||
|
$.set('CatalogIsToggled', useCatalog);
|
||||||
|
}
|
||||||
_ref = ['boardNavDesktop', 'boardNavDesktopFoot'];
|
_ref = ['boardNavDesktop', 'boardNavDesktopFoot'];
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
nav = _ref[_i];
|
nav = _ref[_i];
|
||||||
a = $.id(nav).firstElementChild;
|
root = $.id(nav);
|
||||||
while (a.href && (split = a.href.split('/'))) {
|
_ref1 = $$('a[href*="boards.4chan.org"]', root);
|
||||||
if (!/^rs|status/.test(split[2])) {
|
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||||
if ((isDead = split[3] === 'f') && g.CATALOG || split[4] === 'catalog') {
|
a = _ref1[_j];
|
||||||
a.href = a.href.replace(/catalog$/, '');
|
board = a.pathname.split('/')[1];
|
||||||
a.title = a.title.replace(/\ -\ Catalog$/, '');
|
if (board === 'f') {
|
||||||
} else if (!isDead) {
|
a.pathname = '/f/';
|
||||||
a.href += 'catalog';
|
continue;
|
||||||
a.title += ' - Catalog';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
a = a.nextElementSibling;
|
a.pathname = "/" + board + "/" + (useCatalog ? 'catalog' : '');
|
||||||
}
|
|
||||||
if (/On$/.test((el = a.parentNode.lastChild.firstElementChild).textContent)) {
|
|
||||||
el.textContent = 'Catalog Off';
|
|
||||||
el.title = 'Turn Catalog Links off.';
|
|
||||||
$.set('CatalogIsToggled', true);
|
|
||||||
} else {
|
|
||||||
el.textContent = 'Catalog On';
|
|
||||||
el.title = 'Turn Catalog Links on.';
|
|
||||||
$["delete"]('CatalogIsToggled');
|
|
||||||
}
|
}
|
||||||
|
a = $('.toggleCatalog', root).firstElementChild;
|
||||||
|
a.textContent = "Catalog " + (useCatalog ? 'On' : 'Off');
|
||||||
|
a.title = "Turn catalog links " + (useCatalog ? 'off' : 'on') + ".";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4197,43 +4197,36 @@ ImageExpand =
|
|||||||
CatalogLinks =
|
CatalogLinks =
|
||||||
init: ->
|
init: ->
|
||||||
el = $.el 'span',
|
el = $.el 'span',
|
||||||
innerHTML:
|
className: 'toggleCatalog'
|
||||||
"[<a href=javascript:; title='Toggle Catalog Links #{unless g.CATALOG then 'on.' else 'off.'}'>Catalog #{unless g.CATALOG then 'On' else 'Off'}</a>]"
|
innerHTML: '[<a href=javascript:;></a>]'
|
||||||
id: 'toggleCatalog'
|
|
||||||
for nav in ['boardNavDesktop', 'boardNavDesktopFoot']
|
for nav in ['boardNavDesktop', 'boardNavDesktopFoot']
|
||||||
$.on el.firstElementChild, 'click', @toggle
|
clone = el.cloneNode true
|
||||||
$.add $.id(nav), el
|
$.on clone.firstElementChild, 'click', @toggle
|
||||||
el = $.el 'span', innerHTML: el.innerHTML, id: 'toggleCatalogFoot'
|
$.add $.id(nav), clone
|
||||||
|
|
||||||
if $.get 'CatalogIsToggled'
|
# Set links on load.
|
||||||
i = if g.CATALOG then 0 else 1
|
@toggle true
|
||||||
while i < 2
|
|
||||||
@toggle()
|
toggle: (onLoad) ->
|
||||||
i++
|
if onLoad is true
|
||||||
return
|
useCatalog = $.get 'CatalogIsToggled', g.CATALOG
|
||||||
@toggle() if g.CATALOG
|
else
|
||||||
|
useCatalog = @textContent is 'Catalog Off'
|
||||||
|
$.set 'CatalogIsToggled', useCatalog
|
||||||
|
|
||||||
toggle: ->
|
|
||||||
for nav in ['boardNavDesktop', 'boardNavDesktopFoot']
|
for nav in ['boardNavDesktop', 'boardNavDesktopFoot']
|
||||||
a = $.id(nav).firstElementChild
|
root = $.id nav
|
||||||
while a.href and split = a.href.split '/'
|
for a in $$ 'a[href*="boards.4chan.org"]', root
|
||||||
unless /^rs|status/.test split[2]
|
board = a.pathname.split('/')[1]
|
||||||
if (isDead = split[3] is 'f') and g.CATALOG or split[4] is 'catalog'
|
if board is 'f'
|
||||||
a.href = a.href.replace /catalog$/, ''
|
# 4chan links to /f/'s catalog even if it doesn't have one.
|
||||||
a.title = a.title.replace /\ -\ Catalog$/, ''
|
a.pathname = '/f/'
|
||||||
else if not isDead
|
continue
|
||||||
a.href += 'catalog'
|
a.pathname = "/#{board}/#{if useCatalog then 'catalog' else ''}"
|
||||||
a.title += ' - Catalog'
|
|
||||||
a = a.nextElementSibling
|
|
||||||
|
|
||||||
if /On$/.test (el = a.parentNode.lastChild.firstElementChild).textContent
|
a = $('.toggleCatalog', root).firstElementChild
|
||||||
el.textContent = 'Catalog Off'
|
a.textContent = "Catalog #{if useCatalog then 'On' else 'Off'}"
|
||||||
el.title = 'Turn Catalog Links off.'
|
a.title = "Turn catalog links #{if useCatalog then 'off' else 'on'}."
|
||||||
$.set 'CatalogIsToggled', true
|
|
||||||
else
|
|
||||||
el.textContent = 'Catalog On'
|
|
||||||
el.title = 'Turn Catalog Links on.'
|
|
||||||
$.delete 'CatalogIsToggled'
|
|
||||||
return
|
return
|
||||||
|
|
||||||
Main =
|
Main =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user