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'), 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', time: '%m/%d/%y(%a)%H:%M',
backlink: '>>%id', backlink: '>>%id',
favicon: 'ferongr',
hotkeys: { hotkeys: {
close: 'Esc', close: 'Esc',
spoiler: 'ctrl+s', spoiler: 'ctrl+s',
@ -1241,7 +1242,7 @@
} }
}, },
dialog: function() { 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', '', '\ dialog = ui.dialog('options', '', '\
<div id=optionsbar>\ <div id=optionsbar>\
<div id=credits>\ <div id=credits>\
@ -1297,6 +1298,12 @@
<li>Hour: %k, %H, %l (lowercase L), %I (uppercase i), %p, %P</li>\ <li>Hour: %k, %H, %l (lowercase L), %I (uppercase i), %p, %P</li>\
<li>Minutes: %M</li>\ <li>Minutes: %M</li>\
</ul>\ </ul>\
<div class=error><code>Unread Count</code> is disabled.</div>\
<select name=favicon>\
<option>ferongr</option>\
<option>None</option>\
</select>\
<span></span>\
</div>\ </div>\
<input type=radio name=tab hidden id=keybinds_tab>\ <input type=radio name=tab hidden id=keybinds_tab>\
<div>\ <div>\
@ -1362,17 +1369,27 @@
(time = $('[name=time]', dialog)).value = conf['time']; (time = $('[name=time]', dialog)).value = conf['time'];
$.on(back, 'keyup', options.backlink); $.on(back, 'keyup', options.backlink);
$.on(time, 'keyup', options.time); $.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++) { 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.type = 'text';
input.value = conf[input.name]; input.value = conf[input.name];
$.on(input, 'keydown', options.keybind); $.on(input, 'keydown', options.keybind);
} }
indicators = {}; indicators = {};
_ref4 = $$('.error', dialog); _ref5 = $$('.error', dialog);
for (_k = 0, _len3 = _ref4.length; _k < _len3; _k++) { for (_l = 0, _len4 = _ref5.length; _l < _len4; _l++) {
indicator = _ref4[_k]; indicator = _ref5[_l];
key = indicator.firstChild.textContent; key = indicator.firstChild.textContent;
indicator.hidden = conf[key]; indicator.hidden = conf[key];
indicators[key] = indicator; indicators[key] = indicator;
@ -1391,8 +1408,9 @@
}); });
$.add(overlay, dialog); $.add(overlay, dialog);
$.add(d.body, overlay); $.add(d.body, overlay);
options.backlink.call(back);
options.time.call(time); options.time.call(time);
return options.backlink.call(back); return options.favicon.call(favicon);
}, },
clearHidden: function() { clearHidden: function() {
$["delete"]("hiddenReplies/" + g.BOARD + "/"); $["delete"]("hiddenReplies/" + g.BOARD + "/");
@ -1405,20 +1423,23 @@
e.stopPropagation(); e.stopPropagation();
if ((key = keybinds.keyCode(e)) == null) return; if ((key = keybinds.keyCode(e)) == null) return;
this.value = key; this.value = key;
$.set(this.name, key); return $.cb.value.call(this);
return conf[this.name] = key;
}, },
time: function() { time: function() {
$.set('time', this.value); $.cb.value.call(this);
conf['time'] = this.value;
Time.foo(); Time.foo();
Time.date = new Date(); Time.date = new Date();
return $('#timePreview').textContent = Time.funk(Time); return $('#timePreview').textContent = Time.funk(Time);
}, },
backlink: function() { backlink: function() {
$.set('backlink', this.value); $.cb.value.call(this);
conf['backlink'] = this.value;
return $('#backlinkPreview').textContent = conf['backlink'].replace(/%id/, '123456789'); 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 = $('link[rel="shortcut icon"]', d.head);
favicon.type = 'image/x-icon'; favicon.type = 'image/x-icon';
href = favicon.href; href = favicon.href;
Favicon["default"] = href; this.SFW = /ws.ico$/.test(href);
return Favicon.unread = /ws/.test(href) ? Favicon.unreadSFW : Favicon.unreadNSFW; 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==', empty: 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///9vb2////yH5BAEAAAMALAAAAAAQABAAAAIvnI+pq+D9DBAUoFkPFnbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==',
dead: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAP8AAP///////yH5BAEKAAIALAAAAAAQABAAAAIvlI+pq+D9DAgUoFkPDlbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==', 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() { update: function() {
var clone, favicon, l; var clone, favicon, l;
l = unread.replies.length; l = unread.replies.length;
favicon = $('link[rel="shortcut icon"]', d.head); 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") { if (engine === "gecko") {
clone = favicon.cloneNode(true); clone = favicon.cloneNode(true);
return $.replace(favicon, clone); 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>" 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'); imageType = $.get('imageType', 'full');
_ref = $$('option', controls); select = $('select', controls);
_ref = select.options;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i]; option = _ref[_i];
if (option.textContent === imageType) { if (option.textContent === imageType) {
@ -2937,7 +2969,6 @@
break; break;
} }
} }
select = $('select', controls);
imgExpand.cb.typeChange.call(select); imgExpand.cb.typeChange.call(select);
$.on(select, 'change', $.cb.value); $.on(select, 'change', $.cb.value);
$.on(select, 'change', imgExpand.cb.typeChange); $.on(select, 'change', imgExpand.cb.typeChange);

View File

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

View File

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