Banners.coffee
Move into Miscellaneous from Theming.
This commit is contained in:
parent
f158c839aa
commit
32e5eba15d
@ -14471,6 +14471,132 @@
|
||||
}
|
||||
};
|
||||
|
||||
Banner = {
|
||||
banners: ["0.jpg","1.jpg","2.jpg","4.jpg","6.jpg","7.jpg","8.jpg","9.jpg","10.jpg","11.jpg","12.jpg","13.jpg","14.jpg","16.jpg","17.jpg","18.jpg","19.jpg","20.jpg","21.jpg","22.jpg","24.jpg","25.jpg","26.jpg","28.jpg","29.jpg","33.jpg","38.jpg","39.jpg","43.jpg","44.jpg","45.jpg","46.jpg","47.jpg","52.jpg","54.jpg","57.jpg","59.jpg","60.jpg","61.jpg","64.jpg","66.jpg","67.jpg","69.jpg","71.jpg","72.jpg","76.jpg","77.jpg","81.jpg","82.jpg","83.jpg","84.jpg","88.jpg","90.jpg","91.jpg","96.jpg","98.jpg","99.jpg","100.jpg","104.jpg","106.jpg","116.jpg","119.jpg","137.jpg","140.jpg","148.jpg","149.jpg","150.jpg","154.jpg","156.jpg","157.jpg","158.jpg","159.jpg","161.jpg","162.jpg","164.jpg","165.jpg","166.jpg","167.jpg","168.jpg","169.jpg","170.jpg","171.jpg","172.jpg","173.jpg","174.jpg","175.jpg","176.jpg","178.jpg","179.jpg","180.jpg","181.jpg","182.jpg","183.jpg","186.jpg","189.jpg","190.jpg","192.jpg","193.jpg","194.jpg","197.jpg","198.jpg","200.jpg","201.jpg","202.jpg","203.jpg","205.jpg","206.jpg","207.jpg","208.jpg","210.jpg","213.jpg","214.jpg","215.jpg","216.jpg","218.jpg","219.jpg","220.jpg","221.jpg","222.jpg","223.jpg","224.jpg","227.jpg","0.png","1.png","2.png","3.png","5.png","6.png","9.png","10.png","11.png","12.png","14.png","16.png","19.png","20.png","21.png","22.png","23.png","24.png","26.png","27.png","28.png","29.png","30.png","31.png","32.png","33.png","34.png","37.png","39.png","40.png","41.png","42.png","43.png","44.png","45.png","48.png","49.png","50.png","51.png","52.png","53.png","57.png","58.png","59.png","64.png","66.png","67.png","68.png","69.png","70.png","71.png","72.png","76.png","78.png","81.png","82.png","85.png","86.png","87.png","89.png","95.png","98.png","100.png","101.png","102.png","105.png","106.png","107.png","109.png","110.png","111.png","112.png","113.png","114.png","115.png","116.png","118.png","119.png","120.png","121.png","122.png","123.png","126.png","128.png","130.png","134.png","136.png","138.png","139.png","140.png","142.png","145.png","146.png","149.png","150.png","151.png","152.png","153.png","154.png","155.png","156.png","157.png","158.png","159.png","160.png","163.png","164.png","165.png","166.png","167.png","168.png","169.png","170.png","171.png","172.png","173.png","174.png","178.png","179.png","180.png","181.png","182.png","184.png","186.png","188.png","190.png","192.png","193.png","194.png","195.png","196.png","197.png","198.png","200.png","202.png","203.png","205.png","206.png","207.png","209.png","212.png","213.png","214.png","216.png","217.png","218.png","219.png","220.png","221.png","222.png","223.png","224.png","225.png","226.png","229.png","231.png","232.png","233.png","234.png","235.png","237.png","238.png","239.png","240.png","241.png","242.png","244.png","245.png","246.png","247.png","248.png","249.png","250.png","253.png","254.png","255.png","257.png","258.png","259.png","260.png","262.png","268.png","0.gif","1.gif","2.gif","3.gif","4.gif","5.gif","6.gif","7.gif","8.gif","9.gif","10.gif","12.gif","13.gif","14.gif","15.gif","16.gif","18.gif","19.gif","20.gif","21.gif","22.gif","23.gif","24.gif","28.gif","29.gif","30.gif","33.gif","34.gif","35.gif","36.gif","37.gif","39.gif","40.gif","42.gif","44.gif","45.gif","46.gif","48.gif","50.gif","52.gif","54.gif","55.gif","57.gif","58.gif","59.gif","60.gif","61.gif","62.gif","63.gif","64.gif","66.gif","67.gif","68.gif","69.gif","70.gif","72.gif","73.gif","75.gif","76.gif","77.gif","78.gif","80.gif","81.gif","82.gif","83.gif","86.gif","87.gif","88.gif","92.gif","93.gif","94.gif","95.gif","96.gif","97.gif","98.gif","99.gif","100.gif","101.gif","102.gif","103.gif","104.gif","105.gif","106.gif","108.gif","109.gif","110.gif","111.gif","112.gif","113.gif","115.gif","116.gif","117.gif","118.gif","119.gif","120.gif","122.gif","123.gif","124.gif","127.gif","129.gif","130.gif","131.gif","134.gif","135.gif","136.gif","138.gif","139.gif","141.gif","144.gif","146.gif","148.gif","149.gif","153.gif","154.gif","155.gif","157.gif","158.gif","159.gif","160.gif","161.gif","162.gif","164.gif","166.gif","167.gif","168.gif","169.gif","170.gif","171.gif","172.gif","173.gif","174.gif","175.gif","176.gif","177.gif","178.gif","181.gif","182.gif","183.gif","185.gif","186.gif","187.gif","188.gif","189.gif","190.gif","191.gif","192.gif","193.gif","195.gif","196.gif","197.gif","200.gif","201.gif","202.gif","203.gif","204.gif","205.gif","206.gif","207.gif","208.gif","209.gif","210.gif","211.gif","212.gif","213.gif","214.gif","215.gif","216.gif","217.gif","219.gif","220.gif","221.gif","222.gif","224.gif","225.gif","226.gif","227.gif","228.gif","230.gif","232.gif","233.gif","234.gif","235.gif","238.gif","240.gif","241.gif","243.gif","244.gif","245.gif","246.gif","247.gif","249.gif","250.gif","251.gif","253.gif"],
|
||||
init: function() {
|
||||
$.asap((function() {
|
||||
return d.body;
|
||||
}), function() {
|
||||
return $.asap((function() {
|
||||
return $('hr');
|
||||
}), Banner.ready);
|
||||
});
|
||||
if (g.BOARD.ID !== 'f') {
|
||||
return Main.ready(function() {
|
||||
return $.queueTask(Banner.load);
|
||||
});
|
||||
}
|
||||
},
|
||||
ready: function() {
|
||||
var banner, child, children, i;
|
||||
banner = $(".boardBanner");
|
||||
children = banner.children;
|
||||
if (g.BOARD.ID !== 'f' && g.VIEW === 'thread' && Conf['Remove Thread Excerpt']) {
|
||||
Banner.setTitle(children[1].textContent);
|
||||
}
|
||||
i = 0;
|
||||
while (child = children[i++]) {
|
||||
if (i === 1) {
|
||||
child.title = "Click to change";
|
||||
$.on(child, 'click', Banner.cb.toggle);
|
||||
continue;
|
||||
}
|
||||
if (Conf['Custom Board Titles']) {
|
||||
Banner.custom(child).title = "Ctrl/\u2318+click to edit board " + (i === 3 ? 'sub' : '') + "title";
|
||||
child.spellcheck = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
load: function() {
|
||||
var bannerCnt, img;
|
||||
bannerCnt = $.id('bannerCnt');
|
||||
if (!bannerCnt.firstChild) {
|
||||
img = $.el('img', {
|
||||
alt: '4chan',
|
||||
src: '//s.4cdn.org/image/title/' + bannerCnt.dataset.src
|
||||
});
|
||||
return $.add(bannerCnt, img);
|
||||
}
|
||||
},
|
||||
setTitle: function(title) {
|
||||
if (Unread.title != null) {
|
||||
Unread.title = title;
|
||||
return Unread.update();
|
||||
} else {
|
||||
return d.title = title;
|
||||
}
|
||||
},
|
||||
cb: {
|
||||
toggle: function() {
|
||||
var banner, i, _ref;
|
||||
if (!((_ref = Banner.choices) != null ? _ref.length : void 0)) {
|
||||
Banner.choices = Banner.banners.slice();
|
||||
}
|
||||
i = Math.floor(Banner.choices.length * Math.random());
|
||||
banner = Banner.choices.splice(i, 1);
|
||||
return $('img', this.parentNode).src = "//s.4cdn.org/image/title/" + banner;
|
||||
},
|
||||
click: function(e) {
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
this.contentEditable = true;
|
||||
return this.focus();
|
||||
}
|
||||
},
|
||||
keydown: function(e) {
|
||||
e.stopPropagation();
|
||||
if (!e.shiftKey && e.keyCode === 13) {
|
||||
return this.blur();
|
||||
}
|
||||
},
|
||||
focus: function() {
|
||||
var items, string, string2;
|
||||
string = "" + g.BOARD + "." + this.className;
|
||||
string2 = "" + string + ".orig";
|
||||
items = {
|
||||
title: this.textContent
|
||||
};
|
||||
items[string] = '';
|
||||
items[string2] = false;
|
||||
$.get(items, function(items) {
|
||||
if (!(items[string2] && items.title === items[string])) {
|
||||
return $.set(string2, items.title);
|
||||
}
|
||||
});
|
||||
},
|
||||
blur: function() {
|
||||
this.contentEditable = false;
|
||||
return $.set("" + g.BOARD + "." + this.className, this.textContent);
|
||||
}
|
||||
},
|
||||
custom: function(child) {
|
||||
var cachedTest, string;
|
||||
cachedTest = child.textContent;
|
||||
string = "" + g.BOARD + "." + child.className;
|
||||
$.on(child, 'click keydown focus blur', function(e) {
|
||||
return Banner.cb[e.type].apply(this, [e]);
|
||||
});
|
||||
$.get(string, cachedTest, function(item) {
|
||||
var string2, title;
|
||||
if (!(title = item[string])) {
|
||||
return;
|
||||
}
|
||||
if (Conf['Persistent Custom Board Titles']) {
|
||||
return child.textContent = title;
|
||||
}
|
||||
string2 = "" + string + ".orig";
|
||||
return $.get(string2, cachedTest, function(itemb) {
|
||||
if (cachedTest === itemb[string2]) {
|
||||
return child.textContent = title;
|
||||
} else {
|
||||
$.set(string, cachedTest);
|
||||
return $.set(string2, cachedTest);
|
||||
}
|
||||
});
|
||||
});
|
||||
return child;
|
||||
}
|
||||
};
|
||||
|
||||
CatalogLinks = {
|
||||
init: function() {
|
||||
var el, input;
|
||||
@ -15780,123 +15906,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
Banner = {
|
||||
init: function() {
|
||||
return $.asap((function() {
|
||||
return d.body;
|
||||
}), function() {
|
||||
return $.asap((function() {
|
||||
return $('hr');
|
||||
}), Banner.ready);
|
||||
});
|
||||
},
|
||||
ready: function() {
|
||||
var banner, child, children, i, img, nodes, title, _i, _len;
|
||||
banner = $(".boardBanner");
|
||||
title = $.el("div", {
|
||||
id: "boardTitle"
|
||||
});
|
||||
children = banner.children;
|
||||
nodes = [];
|
||||
for (i = _i = 0, _len = children.length; _i < _len; i = ++_i) {
|
||||
child = children[i];
|
||||
if (i === 0) {
|
||||
$.rm(child);
|
||||
img = $.el('img', {
|
||||
alt: '4chan',
|
||||
title: 'Click to change'
|
||||
});
|
||||
$.on(img, 'click error', Banner.cb.toggle);
|
||||
Banner.cb.toggle.call(img);
|
||||
$.prepend(banner, img);
|
||||
continue;
|
||||
}
|
||||
if (Conf['Custom Board Titles']) {
|
||||
Banner.custom(child).title = "Ctrl+click to edit board " + (i === 2 ? 'sub' : '') + "title";
|
||||
}
|
||||
nodes.push(child);
|
||||
}
|
||||
$.add(title, nodes);
|
||||
$.after(banner, title);
|
||||
},
|
||||
cb: {
|
||||
toggle: (function() {
|
||||
var types;
|
||||
types = {
|
||||
jpg: 227,
|
||||
png: 262,
|
||||
gif: 253
|
||||
};
|
||||
return function() {
|
||||
var num, type;
|
||||
type = Object.keys(types)[Math.floor(3 * Math.random())];
|
||||
num = Math.floor(types[type] * Math.random());
|
||||
return this.src = "//s.4cdn.org/image/title/" + num + "." + type;
|
||||
};
|
||||
})(),
|
||||
click: function(e) {
|
||||
if (e.ctrlKey) {
|
||||
this.contentEditable = true;
|
||||
return this.focus();
|
||||
}
|
||||
},
|
||||
keydown: function(e) {
|
||||
e.stopPropagation();
|
||||
if (!e.shiftKey && e.keyCode === 13) {
|
||||
return this.blur();
|
||||
}
|
||||
},
|
||||
focus: function() {
|
||||
var items, string, string2;
|
||||
this.textContent = this.innerHTML;
|
||||
string = "" + g.BOARD + "." + this.className;
|
||||
string2 = "" + string + ".orig";
|
||||
items = {
|
||||
title: this.innerHTML
|
||||
};
|
||||
items[string] = '';
|
||||
items[string2] = false;
|
||||
$.get(items, function(items) {
|
||||
if (!(items[string2] && items.title === items[string])) {
|
||||
return $.set(string2, items.title);
|
||||
}
|
||||
});
|
||||
},
|
||||
blur: function() {
|
||||
this.innerHTML = this.textContent;
|
||||
this.contentEditable = false;
|
||||
return $.set("" + g.BOARD + "." + this.className, this.textContent);
|
||||
}
|
||||
},
|
||||
custom: function(child) {
|
||||
var cachedTest, string;
|
||||
cachedTest = child.innerHTML;
|
||||
string = "" + g.BOARD + "." + child.className;
|
||||
$.on(child, 'click keydown focus blur', function(e) {
|
||||
return Banner.cb[e.type].apply(this, [e]);
|
||||
});
|
||||
$.get(string, cachedTest, function(item) {
|
||||
var string2, title;
|
||||
if (!(title = item[string])) {
|
||||
return;
|
||||
}
|
||||
if (Conf['Persistent Custom Board Titles']) {
|
||||
return child.innerHTML = title;
|
||||
}
|
||||
string2 = "" + string + ".orig";
|
||||
return $.get(string2, cachedTest, function(itemb) {
|
||||
if (cachedTest === itemb[string2]) {
|
||||
return child.innerHTML = title;
|
||||
} else {
|
||||
$.set(string, cachedTest);
|
||||
return $.set(string2, cachedTest);
|
||||
}
|
||||
});
|
||||
});
|
||||
return child;
|
||||
}
|
||||
};
|
||||
|
||||
GlobalMessage = {
|
||||
init: function() {
|
||||
return $.asap((function() {
|
||||
|
||||
@ -14492,6 +14492,132 @@
|
||||
}
|
||||
};
|
||||
|
||||
Banner = {
|
||||
banners: ["0.jpg","1.jpg","2.jpg","4.jpg","6.jpg","7.jpg","8.jpg","9.jpg","10.jpg","11.jpg","12.jpg","13.jpg","14.jpg","16.jpg","17.jpg","18.jpg","19.jpg","20.jpg","21.jpg","22.jpg","24.jpg","25.jpg","26.jpg","28.jpg","29.jpg","33.jpg","38.jpg","39.jpg","43.jpg","44.jpg","45.jpg","46.jpg","47.jpg","52.jpg","54.jpg","57.jpg","59.jpg","60.jpg","61.jpg","64.jpg","66.jpg","67.jpg","69.jpg","71.jpg","72.jpg","76.jpg","77.jpg","81.jpg","82.jpg","83.jpg","84.jpg","88.jpg","90.jpg","91.jpg","96.jpg","98.jpg","99.jpg","100.jpg","104.jpg","106.jpg","116.jpg","119.jpg","137.jpg","140.jpg","148.jpg","149.jpg","150.jpg","154.jpg","156.jpg","157.jpg","158.jpg","159.jpg","161.jpg","162.jpg","164.jpg","165.jpg","166.jpg","167.jpg","168.jpg","169.jpg","170.jpg","171.jpg","172.jpg","173.jpg","174.jpg","175.jpg","176.jpg","178.jpg","179.jpg","180.jpg","181.jpg","182.jpg","183.jpg","186.jpg","189.jpg","190.jpg","192.jpg","193.jpg","194.jpg","197.jpg","198.jpg","200.jpg","201.jpg","202.jpg","203.jpg","205.jpg","206.jpg","207.jpg","208.jpg","210.jpg","213.jpg","214.jpg","215.jpg","216.jpg","218.jpg","219.jpg","220.jpg","221.jpg","222.jpg","223.jpg","224.jpg","227.jpg","0.png","1.png","2.png","3.png","5.png","6.png","9.png","10.png","11.png","12.png","14.png","16.png","19.png","20.png","21.png","22.png","23.png","24.png","26.png","27.png","28.png","29.png","30.png","31.png","32.png","33.png","34.png","37.png","39.png","40.png","41.png","42.png","43.png","44.png","45.png","48.png","49.png","50.png","51.png","52.png","53.png","57.png","58.png","59.png","64.png","66.png","67.png","68.png","69.png","70.png","71.png","72.png","76.png","78.png","81.png","82.png","85.png","86.png","87.png","89.png","95.png","98.png","100.png","101.png","102.png","105.png","106.png","107.png","109.png","110.png","111.png","112.png","113.png","114.png","115.png","116.png","118.png","119.png","120.png","121.png","122.png","123.png","126.png","128.png","130.png","134.png","136.png","138.png","139.png","140.png","142.png","145.png","146.png","149.png","150.png","151.png","152.png","153.png","154.png","155.png","156.png","157.png","158.png","159.png","160.png","163.png","164.png","165.png","166.png","167.png","168.png","169.png","170.png","171.png","172.png","173.png","174.png","178.png","179.png","180.png","181.png","182.png","184.png","186.png","188.png","190.png","192.png","193.png","194.png","195.png","196.png","197.png","198.png","200.png","202.png","203.png","205.png","206.png","207.png","209.png","212.png","213.png","214.png","216.png","217.png","218.png","219.png","220.png","221.png","222.png","223.png","224.png","225.png","226.png","229.png","231.png","232.png","233.png","234.png","235.png","237.png","238.png","239.png","240.png","241.png","242.png","244.png","245.png","246.png","247.png","248.png","249.png","250.png","253.png","254.png","255.png","257.png","258.png","259.png","260.png","262.png","268.png","0.gif","1.gif","2.gif","3.gif","4.gif","5.gif","6.gif","7.gif","8.gif","9.gif","10.gif","12.gif","13.gif","14.gif","15.gif","16.gif","18.gif","19.gif","20.gif","21.gif","22.gif","23.gif","24.gif","28.gif","29.gif","30.gif","33.gif","34.gif","35.gif","36.gif","37.gif","39.gif","40.gif","42.gif","44.gif","45.gif","46.gif","48.gif","50.gif","52.gif","54.gif","55.gif","57.gif","58.gif","59.gif","60.gif","61.gif","62.gif","63.gif","64.gif","66.gif","67.gif","68.gif","69.gif","70.gif","72.gif","73.gif","75.gif","76.gif","77.gif","78.gif","80.gif","81.gif","82.gif","83.gif","86.gif","87.gif","88.gif","92.gif","93.gif","94.gif","95.gif","96.gif","97.gif","98.gif","99.gif","100.gif","101.gif","102.gif","103.gif","104.gif","105.gif","106.gif","108.gif","109.gif","110.gif","111.gif","112.gif","113.gif","115.gif","116.gif","117.gif","118.gif","119.gif","120.gif","122.gif","123.gif","124.gif","127.gif","129.gif","130.gif","131.gif","134.gif","135.gif","136.gif","138.gif","139.gif","141.gif","144.gif","146.gif","148.gif","149.gif","153.gif","154.gif","155.gif","157.gif","158.gif","159.gif","160.gif","161.gif","162.gif","164.gif","166.gif","167.gif","168.gif","169.gif","170.gif","171.gif","172.gif","173.gif","174.gif","175.gif","176.gif","177.gif","178.gif","181.gif","182.gif","183.gif","185.gif","186.gif","187.gif","188.gif","189.gif","190.gif","191.gif","192.gif","193.gif","195.gif","196.gif","197.gif","200.gif","201.gif","202.gif","203.gif","204.gif","205.gif","206.gif","207.gif","208.gif","209.gif","210.gif","211.gif","212.gif","213.gif","214.gif","215.gif","216.gif","217.gif","219.gif","220.gif","221.gif","222.gif","224.gif","225.gif","226.gif","227.gif","228.gif","230.gif","232.gif","233.gif","234.gif","235.gif","238.gif","240.gif","241.gif","243.gif","244.gif","245.gif","246.gif","247.gif","249.gif","250.gif","251.gif","253.gif"],
|
||||
init: function() {
|
||||
$.asap((function() {
|
||||
return d.body;
|
||||
}), function() {
|
||||
return $.asap((function() {
|
||||
return $('hr');
|
||||
}), Banner.ready);
|
||||
});
|
||||
if (g.BOARD.ID !== 'f') {
|
||||
return Main.ready(function() {
|
||||
return $.queueTask(Banner.load);
|
||||
});
|
||||
}
|
||||
},
|
||||
ready: function() {
|
||||
var banner, child, children, i;
|
||||
banner = $(".boardBanner");
|
||||
children = banner.children;
|
||||
if (g.BOARD.ID !== 'f' && g.VIEW === 'thread' && Conf['Remove Thread Excerpt']) {
|
||||
Banner.setTitle(children[1].textContent);
|
||||
}
|
||||
i = 0;
|
||||
while (child = children[i++]) {
|
||||
if (i === 1) {
|
||||
child.title = "Click to change";
|
||||
$.on(child, 'click', Banner.cb.toggle);
|
||||
continue;
|
||||
}
|
||||
if (Conf['Custom Board Titles']) {
|
||||
Banner.custom(child).title = "Ctrl/\u2318+click to edit board " + (i === 3 ? 'sub' : '') + "title";
|
||||
child.spellcheck = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
load: function() {
|
||||
var bannerCnt, img;
|
||||
bannerCnt = $.id('bannerCnt');
|
||||
if (!bannerCnt.firstChild) {
|
||||
img = $.el('img', {
|
||||
alt: '4chan',
|
||||
src: '//s.4cdn.org/image/title/' + bannerCnt.dataset.src
|
||||
});
|
||||
return $.add(bannerCnt, img);
|
||||
}
|
||||
},
|
||||
setTitle: function(title) {
|
||||
if (Unread.title != null) {
|
||||
Unread.title = title;
|
||||
return Unread.update();
|
||||
} else {
|
||||
return d.title = title;
|
||||
}
|
||||
},
|
||||
cb: {
|
||||
toggle: function() {
|
||||
var banner, i, _ref;
|
||||
if (!((_ref = Banner.choices) != null ? _ref.length : void 0)) {
|
||||
Banner.choices = Banner.banners.slice();
|
||||
}
|
||||
i = Math.floor(Banner.choices.length * Math.random());
|
||||
banner = Banner.choices.splice(i, 1);
|
||||
return $('img', this.parentNode).src = "//s.4cdn.org/image/title/" + banner;
|
||||
},
|
||||
click: function(e) {
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
this.contentEditable = true;
|
||||
return this.focus();
|
||||
}
|
||||
},
|
||||
keydown: function(e) {
|
||||
e.stopPropagation();
|
||||
if (!e.shiftKey && e.keyCode === 13) {
|
||||
return this.blur();
|
||||
}
|
||||
},
|
||||
focus: function() {
|
||||
var items, string, string2;
|
||||
string = "" + g.BOARD + "." + this.className;
|
||||
string2 = "" + string + ".orig";
|
||||
items = {
|
||||
title: this.textContent
|
||||
};
|
||||
items[string] = '';
|
||||
items[string2] = false;
|
||||
$.get(items, function(items) {
|
||||
if (!(items[string2] && items.title === items[string])) {
|
||||
return $.set(string2, items.title);
|
||||
}
|
||||
});
|
||||
},
|
||||
blur: function() {
|
||||
this.contentEditable = false;
|
||||
return $.set("" + g.BOARD + "." + this.className, this.textContent);
|
||||
}
|
||||
},
|
||||
custom: function(child) {
|
||||
var cachedTest, string;
|
||||
cachedTest = child.textContent;
|
||||
string = "" + g.BOARD + "." + child.className;
|
||||
$.on(child, 'click keydown focus blur', function(e) {
|
||||
return Banner.cb[e.type].apply(this, [e]);
|
||||
});
|
||||
$.get(string, cachedTest, function(item) {
|
||||
var string2, title;
|
||||
if (!(title = item[string])) {
|
||||
return;
|
||||
}
|
||||
if (Conf['Persistent Custom Board Titles']) {
|
||||
return child.textContent = title;
|
||||
}
|
||||
string2 = "" + string + ".orig";
|
||||
return $.get(string2, cachedTest, function(itemb) {
|
||||
if (cachedTest === itemb[string2]) {
|
||||
return child.textContent = title;
|
||||
} else {
|
||||
$.set(string, cachedTest);
|
||||
return $.set(string2, cachedTest);
|
||||
}
|
||||
});
|
||||
});
|
||||
return child;
|
||||
}
|
||||
};
|
||||
|
||||
CatalogLinks = {
|
||||
init: function() {
|
||||
var el, input;
|
||||
@ -15801,123 +15927,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
Banner = {
|
||||
init: function() {
|
||||
return $.asap((function() {
|
||||
return d.body;
|
||||
}), function() {
|
||||
return $.asap((function() {
|
||||
return $('hr');
|
||||
}), Banner.ready);
|
||||
});
|
||||
},
|
||||
ready: function() {
|
||||
var banner, child, children, i, img, nodes, title, _i, _len;
|
||||
banner = $(".boardBanner");
|
||||
title = $.el("div", {
|
||||
id: "boardTitle"
|
||||
});
|
||||
children = banner.children;
|
||||
nodes = [];
|
||||
for (i = _i = 0, _len = children.length; _i < _len; i = ++_i) {
|
||||
child = children[i];
|
||||
if (i === 0) {
|
||||
$.rm(child);
|
||||
img = $.el('img', {
|
||||
alt: '4chan',
|
||||
title: 'Click to change'
|
||||
});
|
||||
$.on(img, 'click error', Banner.cb.toggle);
|
||||
Banner.cb.toggle.call(img);
|
||||
$.prepend(banner, img);
|
||||
continue;
|
||||
}
|
||||
if (Conf['Custom Board Titles']) {
|
||||
Banner.custom(child).title = "Ctrl+click to edit board " + (i === 2 ? 'sub' : '') + "title";
|
||||
}
|
||||
nodes.push(child);
|
||||
}
|
||||
$.add(title, nodes);
|
||||
$.after(banner, title);
|
||||
},
|
||||
cb: {
|
||||
toggle: (function() {
|
||||
var types;
|
||||
types = {
|
||||
jpg: 227,
|
||||
png: 262,
|
||||
gif: 253
|
||||
};
|
||||
return function() {
|
||||
var num, type;
|
||||
type = Object.keys(types)[Math.floor(3 * Math.random())];
|
||||
num = Math.floor(types[type] * Math.random());
|
||||
return this.src = "//s.4cdn.org/image/title/" + num + "." + type;
|
||||
};
|
||||
})(),
|
||||
click: function(e) {
|
||||
if (e.ctrlKey) {
|
||||
this.contentEditable = true;
|
||||
return this.focus();
|
||||
}
|
||||
},
|
||||
keydown: function(e) {
|
||||
e.stopPropagation();
|
||||
if (!e.shiftKey && e.keyCode === 13) {
|
||||
return this.blur();
|
||||
}
|
||||
},
|
||||
focus: function() {
|
||||
var items, string, string2;
|
||||
this.textContent = this.innerHTML;
|
||||
string = "" + g.BOARD + "." + this.className;
|
||||
string2 = "" + string + ".orig";
|
||||
items = {
|
||||
title: this.innerHTML
|
||||
};
|
||||
items[string] = '';
|
||||
items[string2] = false;
|
||||
$.get(items, function(items) {
|
||||
if (!(items[string2] && items.title === items[string])) {
|
||||
return $.set(string2, items.title);
|
||||
}
|
||||
});
|
||||
},
|
||||
blur: function() {
|
||||
this.innerHTML = this.textContent;
|
||||
this.contentEditable = false;
|
||||
return $.set("" + g.BOARD + "." + this.className, this.textContent);
|
||||
}
|
||||
},
|
||||
custom: function(child) {
|
||||
var cachedTest, string;
|
||||
cachedTest = child.innerHTML;
|
||||
string = "" + g.BOARD + "." + child.className;
|
||||
$.on(child, 'click keydown focus blur', function(e) {
|
||||
return Banner.cb[e.type].apply(this, [e]);
|
||||
});
|
||||
$.get(string, cachedTest, function(item) {
|
||||
var string2, title;
|
||||
if (!(title = item[string])) {
|
||||
return;
|
||||
}
|
||||
if (Conf['Persistent Custom Board Titles']) {
|
||||
return child.innerHTML = title;
|
||||
}
|
||||
string2 = "" + string + ".orig";
|
||||
return $.get(string2, cachedTest, function(itemb) {
|
||||
if (cachedTest === itemb[string2]) {
|
||||
return child.innerHTML = title;
|
||||
} else {
|
||||
$.set(string, cachedTest);
|
||||
return $.set(string2, cachedTest);
|
||||
}
|
||||
});
|
||||
});
|
||||
return child;
|
||||
}
|
||||
};
|
||||
|
||||
GlobalMessage = {
|
||||
init: function() {
|
||||
return $.asap((function() {
|
||||
|
||||
104
src/Miscellaneous/Banner.coffee
Normal file
104
src/Miscellaneous/Banner.coffee
Normal file
@ -0,0 +1,104 @@
|
||||
Banner =
|
||||
banners: `<%= JSON.stringify(grunt.file.readJSON('src/Miscellaneous/banners.json')) %>`
|
||||
|
||||
init: ->
|
||||
$.asap (-> d.body), ->
|
||||
$.asap (-> $ 'hr'), Banner.ready
|
||||
|
||||
# Let 4chan's JS load the banner if enabled; otherwise, load it ourselves.
|
||||
if g.BOARD.ID isnt 'f'
|
||||
Main.ready -> $.queueTask Banner.load
|
||||
|
||||
ready: ->
|
||||
banner = $ ".boardBanner"
|
||||
{children} = banner
|
||||
|
||||
if g.BOARD.ID isnt 'f' and g.VIEW is 'thread' and Conf['Remove Thread Excerpt']
|
||||
Banner.setTitle children[1].textContent
|
||||
|
||||
i = 0
|
||||
while child = children[i++]
|
||||
if i is 1
|
||||
child.title = "Click to change"
|
||||
$.on child, 'click', Banner.cb.toggle
|
||||
|
||||
continue
|
||||
|
||||
if Conf['Custom Board Titles']
|
||||
Banner.custom(child).title = "Ctrl/\u2318+click to edit board #{if i is 3
|
||||
'sub'
|
||||
else
|
||||
''}title"
|
||||
child.spellcheck = false
|
||||
|
||||
return
|
||||
|
||||
load: ->
|
||||
bannerCnt = $.id 'bannerCnt'
|
||||
unless bannerCnt.firstChild
|
||||
img = $.el 'img',
|
||||
alt: '4chan'
|
||||
src: '//s.4cdn.org/image/title/' + bannerCnt.dataset.src
|
||||
$.add bannerCnt, img
|
||||
|
||||
setTitle: (title) ->
|
||||
if Unread.title?
|
||||
Unread.title = title
|
||||
Unread.update()
|
||||
else
|
||||
d.title = title
|
||||
|
||||
cb:
|
||||
toggle: ->
|
||||
unless Banner.choices?.length
|
||||
Banner.choices = Banner.banners.slice()
|
||||
i = Math.floor(Banner.choices.length * Math.random())
|
||||
banner = Banner.choices.splice i, 1
|
||||
$('img', @parentNode).src = "//s.4cdn.org/image/title/#{banner}"
|
||||
|
||||
click: (e) ->
|
||||
if e.ctrlKey or e.metaKey
|
||||
@contentEditable = true
|
||||
@focus()
|
||||
|
||||
keydown: (e) ->
|
||||
e.stopPropagation()
|
||||
return @blur() if !e.shiftKey and e.keyCode is 13
|
||||
|
||||
focus: ->
|
||||
string = "#{g.BOARD}.#{@className}"
|
||||
string2 = "#{string}.orig"
|
||||
|
||||
items = {title: @textContent}
|
||||
items[string] = ''
|
||||
items[string2] = false
|
||||
|
||||
$.get items, (items) ->
|
||||
unless items[string2] and items.title is items[string]
|
||||
$.set string2, items.title
|
||||
|
||||
return
|
||||
|
||||
blur: ->
|
||||
@contentEditable = false
|
||||
$.set "#{g.BOARD}.#{@className}", @textContent
|
||||
|
||||
custom: (child) ->
|
||||
cachedTest = child.textContent
|
||||
string = "#{g.BOARD}.#{child.className}"
|
||||
|
||||
$.on child, 'click keydown focus blur', (e) -> Banner.cb[e.type].apply @, [e]
|
||||
|
||||
$.get string, cachedTest, (item) ->
|
||||
return unless title = item[string]
|
||||
return child.textContent = title if Conf['Persistent Custom Board Titles']
|
||||
|
||||
string2 = "#{string}.orig"
|
||||
|
||||
$.get string2, cachedTest, (itemb) ->
|
||||
if cachedTest is itemb[string2]
|
||||
child.textContent = title
|
||||
else
|
||||
$.set string, cachedTest
|
||||
$.set string2, cachedTest
|
||||
child
|
||||
1
src/Miscellaneous/banners.json
Normal file
1
src/Miscellaneous/banners.json
Normal file
File diff suppressed because one or more lines are too long
@ -1,99 +0,0 @@
|
||||
Banner =
|
||||
init: ->
|
||||
$.asap (-> d.body), ->
|
||||
$.asap (-> $ 'hr'), Banner.ready
|
||||
|
||||
ready: ->
|
||||
banner = $ ".boardBanner"
|
||||
title = $.el "div",
|
||||
id: "boardTitle"
|
||||
{children} = banner
|
||||
nodes = []
|
||||
|
||||
for child, i in children
|
||||
if i is 0
|
||||
$.rm child
|
||||
img = $.el 'img',
|
||||
alt: '4chan'
|
||||
title: 'Click to change'
|
||||
|
||||
$.on img, 'click error', Banner.cb.toggle
|
||||
Banner.cb.toggle.call img
|
||||
|
||||
$.prepend banner, img
|
||||
|
||||
continue
|
||||
|
||||
if Conf['Custom Board Titles']
|
||||
Banner.custom(child).title = "Ctrl+click to edit board #{if i is 2
|
||||
'sub'
|
||||
else
|
||||
''}title"
|
||||
|
||||
nodes.push child
|
||||
|
||||
$.add title, nodes
|
||||
$.after banner, title
|
||||
return
|
||||
|
||||
cb:
|
||||
toggle: do ->
|
||||
types =
|
||||
jpg: 227
|
||||
png: 262
|
||||
gif: 253
|
||||
|
||||
->
|
||||
type = Object.keys(types)[Math.floor 3 * Math.random()]
|
||||
num = Math.floor types[type] * Math.random()
|
||||
@src = "//s.4cdn.org/image/title/#{num}.#{type}"
|
||||
|
||||
click: (e) ->
|
||||
if e.ctrlKey
|
||||
@contentEditable = true
|
||||
@focus()
|
||||
|
||||
keydown: (e) ->
|
||||
e.stopPropagation()
|
||||
return @blur() if !e.shiftKey and e.keyCode is 13
|
||||
|
||||
focus: ->
|
||||
@textContent = @innerHTML
|
||||
|
||||
string = "#{g.BOARD}.#{@className}"
|
||||
string2 = "#{string}.orig"
|
||||
|
||||
items = {title: @innerHTML}
|
||||
items[string] = ''
|
||||
items[string2] = false
|
||||
|
||||
$.get items, (items) ->
|
||||
unless items[string2] and items.title is items[string]
|
||||
$.set string2, items.title
|
||||
|
||||
return
|
||||
|
||||
blur: ->
|
||||
@innerHTML = @textContent
|
||||
@contentEditable = false
|
||||
$.set "#{g.BOARD}.#{@className}", @textContent
|
||||
|
||||
custom: (child) ->
|
||||
cachedTest = child.innerHTML
|
||||
string = "#{g.BOARD}.#{child.className}"
|
||||
|
||||
$.on child, 'click keydown focus blur', (e) -> Banner.cb[e.type].apply @, [e]
|
||||
|
||||
$.get string, cachedTest, (item) ->
|
||||
return unless title = item[string]
|
||||
return child.innerHTML = title if Conf['Persistent Custom Board Titles']
|
||||
|
||||
string2 = "#{string}.orig"
|
||||
|
||||
$.get string2, cachedTest, (itemb) ->
|
||||
if cachedTest is itemb[string2]
|
||||
child.innerHTML = title
|
||||
else
|
||||
$.set string, cachedTest
|
||||
$.set string2, cachedTest
|
||||
child
|
||||
Loading…
x
Reference in New Issue
Block a user