Favicon customization.

This commit is contained in:
Nicolas Stepien 2011-12-07 21:47:19 +01:00
parent 6341f070ba
commit 9460ec715c
3 changed files with 95 additions and 39 deletions

View File

@ -137,6 +137,7 @@
flavors: ['http://iqdb.org/?url=', 'http://google.com/searchbyimage?image_url=', '#http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url=', '#http://3d.iqdb.org/?url=', '#http://regex.info/exif.cgi?imgurl=', '#http://imgur.com/upload?url='].join('\n'),
time: '%m/%d/%y(%a)%H:%M',
backlink: '>>%id',
favicon: 'ferongr',
hotkeys: {
close: 'Esc',
spoiler: 'ctrl+s',
@ -1241,7 +1242,7 @@
}
},
dialog: function() {
var arr, back, checked, description, dialog, hiddenNum, hiddenThreads, indicator, indicators, input, key, li, obj, overlay, ta, time, ul, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4;
var arr, back, checked, description, dialog, favicon, hiddenNum, hiddenThreads, indicator, indicators, input, key, li, obj, option, overlay, ta, time, ul, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref, _ref2, _ref3, _ref4, _ref5;
dialog = ui.dialog('options', '', '\
<div id=optionsbar>\
<div id=credits>\
@ -1297,6 +1298,12 @@
<li>Hour: %k, %H, %l (lowercase L), %I (uppercase i), %p, %P</li>\
<li>Minutes: %M</li>\
</ul>\
<div class=error><code>Unread Count</code> is disabled.</div>\
<select name=favicon>\
<option>ferongr</option>\
<option>None</option>\
</select>\
<span></span>\
</div>\
<input type=radio name=tab hidden id=keybinds_tab>\
<div>\
@ -1362,17 +1369,27 @@
(time = $('[name=time]', dialog)).value = conf['time'];
$.on(back, 'keyup', options.backlink);
$.on(time, 'keyup', options.time);
_ref3 = $$('#keybinds_tab + div input', dialog);
favicon = $('select', dialog);
_ref3 = favicon.options;
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
input = _ref3[_j];
option = _ref3[_j];
if (option.textContent === conf['favicon']) {
option.selected = true;
break;
}
}
$.on(favicon, 'change', options.favicon);
_ref4 = $$('#keybinds_tab + div input', dialog);
for (_k = 0, _len3 = _ref4.length; _k < _len3; _k++) {
input = _ref4[_k];
input.type = 'text';
input.value = conf[input.name];
$.on(input, 'keydown', options.keybind);
}
indicators = {};
_ref4 = $$('.error', dialog);
for (_k = 0, _len3 = _ref4.length; _k < _len3; _k++) {
indicator = _ref4[_k];
_ref5 = $$('.error', dialog);
for (_l = 0, _len4 = _ref5.length; _l < _len4; _l++) {
indicator = _ref5[_l];
key = indicator.firstChild.textContent;
indicator.hidden = conf[key];
indicators[key] = indicator;
@ -1391,8 +1408,9 @@
});
$.add(overlay, dialog);
$.add(d.body, overlay);
options.backlink.call(back);
options.time.call(time);
return options.backlink.call(back);
return options.favicon.call(favicon);
},
clearHidden: function() {
$["delete"]("hiddenReplies/" + g.BOARD + "/");
@ -1405,20 +1423,23 @@
e.stopPropagation();
if ((key = keybinds.keyCode(e)) == null) return;
this.value = key;
$.set(this.name, key);
return conf[this.name] = key;
return $.cb.value.call(this);
},
time: function() {
$.set('time', this.value);
conf['time'] = this.value;
$.cb.value.call(this);
Time.foo();
Time.date = new Date();
return $('#timePreview').textContent = Time.funk(Time);
},
backlink: function() {
$.set('backlink', this.value);
conf['backlink'] = this.value;
$.cb.value.call(this);
return $('#backlinkPreview').textContent = conf['backlink'].replace(/%id/, '123456789');
},
favicon: function() {
$.cb.value.call(this);
Favicon["switch"]();
Favicon.update();
return this.nextElementSibling.innerHTML = "<img src=" + Favicon.unreadSFW + "><img src=" + Favicon.unreadNSFW + "><img src=" + Favicon.unreadDead + ">";
}
};
@ -2712,19 +2733,29 @@
favicon = $('link[rel="shortcut icon"]', d.head);
favicon.type = 'image/x-icon';
href = favicon.href;
Favicon["default"] = href;
return Favicon.unread = /ws/.test(href) ? Favicon.unreadSFW : Favicon.unreadNSFW;
this.SFW = /ws.ico$/.test(href);
this["default"] = href;
return this["switch"]();
},
"switch": function() {
switch (conf['favicon']) {
case 'ferongr':
this.unreadDead = 'data:image/gif;base64,R0lGODlhEAAQAOMHAOgLAnMFAL8AAOgLAukMA/+AgP+rq////////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw==';
this.unreadSFW = 'data:image/gif;base64,R0lGODlhEAAQAOMHAADX8QBwfgC2zADX8QDY8nnl8qLp8v///////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw==';
this.unreadNSFW = 'data:image/gif;base64,R0lGODlhEAAQAOMHAFT+ACh5AEncAFT+AFX/Acz/su7/5v///////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw==';
break;
case 'None':
this.unreadDead = this.unreadSFW = this.unreadNSFW = this["default"];
}
return this.unread = this.SFW ? this.unreadSFW : this.unreadNSFW;
},
empty: 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///9vb2////yH5BAEAAAMALAAAAAAQABAAAAIvnI+pq+D9DBAUoFkPFnbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==',
dead: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAP8AAP///////yH5BAEKAAIALAAAAAAQABAAAAIvlI+pq+D9DAgUoFkPDlbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==',
unreadDead: 'data:image/png;base64,R0lGODlhEAAQAOMHAOgLAnMFAL8AAOgLAukMA/+AgP+rq////////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw==',
unreadSFW: 'data:image/png;base64,R0lGODlhEAAQAOMHAADX8QBwfgC2zADX8QDY8nnl8qLp8v///////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw==',
unreadNSFW: 'data:image/png;base64,R0lGODlhEAAQAOMHAFT+ACh5AEncAFT+AFX/Acz/su7/5v///////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw==',
update: function() {
var clone, favicon, l;
l = unread.replies.length;
favicon = $('link[rel="shortcut icon"]', d.head);
favicon.href = g.dead ? l ? Favicon.unreadDead : Favicon.dead : l ? Favicon.unread : Favicon["default"];
favicon.href = g.dead ? l ? this.unreadDead : this.dead : l ? this.unread : this["default"];
if (engine === "gecko") {
clone = favicon.cloneNode(true);
return $.replace(favicon, clone);
@ -2929,7 +2960,8 @@
innerHTML: "<select id=imageType name=imageType><option>full</option><option>fit width</option><option>fit height</option><option>fit screen</option></select> <label>Expand Images<input type=checkbox id=imageExpand></label>"
});
imageType = $.get('imageType', 'full');
_ref = $$('option', controls);
select = $('select', controls);
_ref = select.options;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i];
if (option.textContent === imageType) {
@ -2937,7 +2969,6 @@
break;
}
}
select = $('select', controls);
imgExpand.cb.typeChange.call(select);
$.on(select, 'change', $.cb.value);
$.on(select, 'change', imgExpand.cb.typeChange);

View File

@ -1,5 +1,6 @@
master
- mayhem
multiple unread favicons to chose in the options
quotes are now inserted at the caret position in the QR
quotes also replace the text selection in the QR
open QR focused when using the `Open QR without post number inserted` keybind

View File

@ -66,6 +66,7 @@ config =
].join '\n'
time: '%m/%d/%y(%a)%H:%M'
backlink: '>>%id'
favicon: 'ferongr'
hotkeys:
close: 'Esc'
spoiler: 'ctrl+s'
@ -948,6 +949,12 @@ options =
<li>Hour: %k, %H, %l (lowercase L), %I (uppercase i), %p, %P</li>
<li>Minutes: %M</li>
</ul>
<div class=error><code>Unread Count</code> is disabled.</div>
<select name=favicon>
<option>ferongr</option>
<option>None</option>
</select>
<span></span>
</div>
<input type=radio name=tab hidden id=keybinds_tab>
<div>
@ -1009,6 +1016,12 @@ options =
(time = $ '[name=time]', dialog).value = conf['time']
$.on back, 'keyup', options.backlink
$.on time, 'keyup', options.time
favicon = $ 'select', dialog
for option in favicon.options
if option.textContent is conf['favicon']
option.selected = true
break
$.on favicon, 'change', options.favicon
#keybinds
for input in $$ '#keybinds_tab + div input', dialog
@ -1031,8 +1044,9 @@ options =
$.add overlay, dialog
$.add d.body, overlay
options.time.call time
options.backlink.call back
options.time.call time
options.favicon.call favicon
clearHidden: ->
#'hidden' might be misleading; it's the number of IDs we're *looking* for,
@ -1046,18 +1060,20 @@ options =
e.stopPropagation()
return unless (key = keybinds.keyCode e)?
@value = key
$.set @name, key
conf[@name] = key
$.cb.value.call @
time: ->
$.set 'time', @value
conf['time'] = @value
$.cb.value.call @
Time.foo()
Time.date = new Date()
$('#timePreview').textContent = Time.funk Time
backlink: ->
$.set 'backlink', @value
conf['backlink'] = @value
$.cb.value.call @
$('#backlinkPreview').textContent = conf['backlink'].replace /%id/, '123456789'
favicon: ->
$.cb.value.call @
Favicon.switch()
Favicon.update()
@nextElementSibling.innerHTML = "<img src=#{Favicon.unreadSFW}><img src=#{Favicon.unreadNSFW}><img src=#{Favicon.unreadDead}>"
cooldown =
#TODO merge into qr
@ -2103,14 +2119,22 @@ Favicon =
favicon = $ 'link[rel="shortcut icon"]', d.head
favicon.type = 'image/x-icon'
{href} = favicon
Favicon.default = href
Favicon.unread = if /ws/.test href then Favicon.unreadSFW else Favicon.unreadNSFW
@SFW = /ws.ico$/.test href
@default = href
@switch()
switch: ->
switch conf['favicon']
when 'ferongr'
@unreadDead = 'data:image/gif;base64,R0lGODlhEAAQAOMHAOgLAnMFAL8AAOgLAukMA/+AgP+rq////////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw=='
@unreadSFW = 'data:image/gif;base64,R0lGODlhEAAQAOMHAADX8QBwfgC2zADX8QDY8nnl8qLp8v///////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw=='
@unreadNSFW = 'data:image/gif;base64,R0lGODlhEAAQAOMHAFT+ACh5AEncAFT+AFX/Acz/su7/5v///////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw=='
when 'None'
@unreadDead = @unreadSFW = @unreadNSFW = @default
@unread = if @SFW then @unreadSFW else @unreadNSFW
empty: 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///9vb2////yH5BAEAAAMALAAAAAAQABAAAAIvnI+pq+D9DBAUoFkPFnbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw=='
dead: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAP8AAP///////yH5BAEKAAIALAAAAAAQABAAAAIvlI+pq+D9DAgUoFkPDlbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw=='
unreadDead: 'data:image/png;base64,R0lGODlhEAAQAOMHAOgLAnMFAL8AAOgLAukMA/+AgP+rq////////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw=='
unreadSFW: 'data:image/png;base64,R0lGODlhEAAQAOMHAADX8QBwfgC2zADX8QDY8nnl8qLp8v///////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw=='
unreadNSFW: 'data:image/png;base64,R0lGODlhEAAQAOMHAFT+ACh5AEncAFT+AFX/Acz/su7/5v///////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw=='
update: ->
l = unread.replies.length
@ -2119,14 +2143,14 @@ Favicon =
favicon.href =
if g.dead
if l
Favicon.unreadDead
@unreadDead
else
Favicon.dead
@dead
else
if l
Favicon.unread
@unread
else
Favicon.default
@default
#XXX `favicon.href = href` doesn't work on Firefox
if engine is "gecko"
@ -2255,11 +2279,11 @@ imgExpand =
"<select id=imageType name=imageType><option>full</option><option>fit width</option><option>fit height</option><option>fit screen</option></select>
<label>Expand Images<input type=checkbox id=imageExpand></label>"
imageType = $.get 'imageType', 'full'
for option in $$ 'option', controls
select = $ 'select', controls
for option in select.options
if option.textContent is imageType
option.selected = true
break
select = $ 'select', controls
imgExpand.cb.typeChange.call select
$.on select, 'change', $.cb.value
$.on select, 'change', imgExpand.cb.typeChange