Merge branch 'v3'
Conflicts: LICENSE builds/4chan-X.user.js builds/crx/script.js
This commit is contained in:
commit
c526b89c8d
@ -45,7 +45,6 @@
|
||||
* The QR will now warn you when you are running low on cached captchas while auto-posting.
|
||||
|
||||
**seaweedchan**:
|
||||
<<<<<<< HEAD
|
||||
- Gallery Bugfix: hide thumbnails
|
||||
|
||||
**Zixaphir**:
|
||||
@ -76,12 +75,6 @@
|
||||
*2013-08-21*
|
||||
|
||||
**Zixaphir**:
|
||||
=======
|
||||
- Visual overhaul for gallery mode
|
||||
|
||||
**Zixaphir**:
|
||||
- Fix an issue with the file dialog randomly opening multiple times (with seaweedchan)
|
||||
>>>>>>> v3
|
||||

|
||||
- **New Feature**: `Gallery`.
|
||||
* Disabled by default.
|
||||
|
||||
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* appchan x - Version 2.4.1 - 2013-10-14
|
||||
* appchan x - Version 2.4.1 - 2013-10-16
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
// ==/UserScript==
|
||||
|
||||
/*
|
||||
* appchan x - Version 2.4.1 - 2013-10-14
|
||||
* appchan x - Version 2.4.1 - 2013-10-16
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||
@ -7097,11 +7097,56 @@
|
||||
},
|
||||
MediaCrush: {
|
||||
regExp: /.*(?:mediacru.sh\/)([0-9a-z_]+)/i,
|
||||
style: 'border: 0; width: 640px; height: 480px; resize: both;',
|
||||
style: 'border: 0;',
|
||||
el: function(a) {
|
||||
return $.el('iframe', {
|
||||
src: "https://mediacru.sh/" + a.dataset.uid
|
||||
var el;
|
||||
|
||||
el = $.el('div');
|
||||
$.cache("https://mediacru.sh/" + a.dataset.uid + ".json", function() {
|
||||
var embed, file, files, status, type, _i, _j, _len, _len1, _ref;
|
||||
|
||||
status = this.status;
|
||||
if (![200, 304].contains(status)) {
|
||||
return div.innerHTML = "ERROR " + status;
|
||||
}
|
||||
files = JSON.parse(this.response).files;
|
||||
_ref = ['video/mp4', 'video/ogv', 'image/svg+xml', 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'audio/mpeg'];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
type = _ref[_i];
|
||||
for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
|
||||
file = files[_j];
|
||||
if (file.type === type) {
|
||||
embed = file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (embed) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!embed) {
|
||||
return div.innerHTML = "ERROR: Not a valid filetype";
|
||||
}
|
||||
return el.innerHTML = (function() {
|
||||
switch (embed.type) {
|
||||
case 'video/mp4':
|
||||
case 'video/ogv':
|
||||
return "<video autoplay loop>\n <source src=\"https://mediacru.sh/" + a.dataset.uid + ".mp4\" type=\"video/mp4;\">\n <source src=\"https://mediacru.sh/" + a.dataset.uid + ".ogv\" type=\"video/ogg; codecs='theora, vorbis'\">\n</video>";
|
||||
case 'image/png':
|
||||
case 'image/gif':
|
||||
case 'image/jpeg':
|
||||
return "<a target=_blank href='" + a.dataset.href + "'><img src='https://mediacru.sh/" + file.file + "'></a>";
|
||||
case 'image/svg':
|
||||
case 'image/svg+xml':
|
||||
return "<embed src='https://mediacru.sh/" + file.file + "' type='image/svg+xml' />";
|
||||
case 'audio/mpeg':
|
||||
return "<audio controls><source src='https://mediacru.sh/" + file.file + "'></audio>";
|
||||
default:
|
||||
return "ERROR: No valid filetype.";
|
||||
}
|
||||
})();
|
||||
});
|
||||
return el;
|
||||
}
|
||||
},
|
||||
pastebin: {
|
||||
@ -13237,57 +13282,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
IDColor = {
|
||||
init: function() {
|
||||
if (g.VIEW === 'catalog' || !Conf['Color User IDs']) {
|
||||
return;
|
||||
}
|
||||
this.ids = {};
|
||||
return Post.callbacks.push({
|
||||
name: 'Color User IDs',
|
||||
cb: this.node
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
var rgb, span, style, uid;
|
||||
|
||||
if (this.isClone || !(uid = this.info.uniqueID)) {
|
||||
return;
|
||||
}
|
||||
span = $('.hand', this.nodes.uniqueID);
|
||||
if (!(span && span.nodeName === 'SPAN')) {
|
||||
return;
|
||||
}
|
||||
rgb = IDColor.compute(uid);
|
||||
style = span.style;
|
||||
style.color = rgb[3];
|
||||
style.backgroundColor = "rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + ")";
|
||||
$.addClass(span, 'painted');
|
||||
return span.title = 'Highlight posts by this ID';
|
||||
},
|
||||
compute: function(uid) {
|
||||
var hash, rgb;
|
||||
|
||||
if (IDColor.ids[uid]) {
|
||||
return IDColor.ids[uid];
|
||||
}
|
||||
hash = IDColor.hash(uid);
|
||||
rgb = [(hash >> 24) & 0xFF, (hash >> 16) & 0xFF, (hash >> 8) & 0xFF];
|
||||
rgb[3] = (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 125 ? '#000' : '#fff';
|
||||
return this.ids[uid] = rgb;
|
||||
},
|
||||
hash: function(uid) {
|
||||
var i, msg;
|
||||
|
||||
msg = 0;
|
||||
i = 0;
|
||||
while (i < 8) {
|
||||
msg = (msg << 5) - msg + uid.charCodeAt(i++);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
};
|
||||
|
||||
CustomCSS = {
|
||||
init: function() {
|
||||
if (!Conf['Custom CSS']) {
|
||||
@ -13761,32 +13755,35 @@
|
||||
if (this.isClone || !(uid = this.info.uniqueID)) {
|
||||
return;
|
||||
}
|
||||
span = $('.hand', this.nodes.uniqueID);
|
||||
if (!(span && span.nodeName === 'SPAN')) {
|
||||
return;
|
||||
}
|
||||
rgb = IDColor.compute(uid);
|
||||
span = this.nodes.uniqueID;
|
||||
style = span.style;
|
||||
style.color = rgb[3];
|
||||
style.backgroundColor = "rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + ")";
|
||||
$.addClass(span, 'painted');
|
||||
span.textContent = uid;
|
||||
return span.title = 'Highlight posts by this ID';
|
||||
},
|
||||
compute: function(uniqueID) {
|
||||
compute: function(uid) {
|
||||
var hash, rgb;
|
||||
|
||||
if (uniqueID in IDColor.ids) {
|
||||
return IDColor.ids[uniqueID];
|
||||
if (IDColor.ids[uid]) {
|
||||
return IDColor.ids[uid];
|
||||
}
|
||||
hash = this.hash(uniqueID);
|
||||
hash = IDColor.hash(uid);
|
||||
rgb = [(hash >> 24) & 0xFF, (hash >> 16) & 0xFF, (hash >> 8) & 0xFF];
|
||||
rgb.push((rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 170 ? 'black' : 'white');
|
||||
return this.ids[uniqueID] = rgb;
|
||||
rgb[3] = (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 125 ? '#000' : '#fff';
|
||||
return this.ids[uid] = rgb;
|
||||
},
|
||||
hash: function(uniqueID) {
|
||||
var i, msg, _i, _ref;
|
||||
hash: function(uid) {
|
||||
var i, msg;
|
||||
|
||||
msg = 0;
|
||||
for (i = _i = 0, _ref = uniqueID.length; _i < _ref; i = _i += 1) {
|
||||
msg = (msg << 5) - msg + uniqueID.charCodeAt(i);
|
||||
i = 0;
|
||||
while (i < 8) {
|
||||
msg = (msg << 5) - msg + uid.charCodeAt(i++);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript
|
||||
/*
|
||||
* appchan x - Version 2.4.1 - 2013-10-14
|
||||
* appchan x - Version 2.4.1 - 2013-10-16
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||
@ -7107,11 +7107,56 @@
|
||||
},
|
||||
MediaCrush: {
|
||||
regExp: /.*(?:mediacru.sh\/)([0-9a-z_]+)/i,
|
||||
style: 'border: 0; width: 640px; height: 480px; resize: both;',
|
||||
style: 'border: 0;',
|
||||
el: function(a) {
|
||||
return $.el('iframe', {
|
||||
src: "https://mediacru.sh/" + a.dataset.uid
|
||||
var el;
|
||||
|
||||
el = $.el('div');
|
||||
$.cache("https://mediacru.sh/" + a.dataset.uid + ".json", function() {
|
||||
var embed, file, files, status, type, _i, _j, _len, _len1, _ref;
|
||||
|
||||
status = this.status;
|
||||
if (![200, 304].contains(status)) {
|
||||
return div.innerHTML = "ERROR " + status;
|
||||
}
|
||||
files = JSON.parse(this.response).files;
|
||||
_ref = ['video/mp4', 'video/ogv', 'image/svg+xml', 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'audio/mpeg'];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
type = _ref[_i];
|
||||
for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
|
||||
file = files[_j];
|
||||
if (file.type === type) {
|
||||
embed = file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (embed) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!embed) {
|
||||
return div.innerHTML = "ERROR: Not a valid filetype";
|
||||
}
|
||||
return el.innerHTML = (function() {
|
||||
switch (embed.type) {
|
||||
case 'video/mp4':
|
||||
case 'video/ogv':
|
||||
return "<video autoplay loop>\n <source src=\"https://mediacru.sh/" + a.dataset.uid + ".mp4\" type=\"video/mp4;\">\n <source src=\"https://mediacru.sh/" + a.dataset.uid + ".ogv\" type=\"video/ogg; codecs='theora, vorbis'\">\n</video>";
|
||||
case 'image/png':
|
||||
case 'image/gif':
|
||||
case 'image/jpeg':
|
||||
return "<a target=_blank href='" + a.dataset.href + "'><img src='https://mediacru.sh/" + file.file + "'></a>";
|
||||
case 'image/svg':
|
||||
case 'image/svg+xml':
|
||||
return "<embed src='https://mediacru.sh/" + file.file + "' type='image/svg+xml' />";
|
||||
case 'audio/mpeg':
|
||||
return "<audio controls><source src='https://mediacru.sh/" + file.file + "'></audio>";
|
||||
default:
|
||||
return "ERROR: No valid filetype.";
|
||||
}
|
||||
})();
|
||||
});
|
||||
return el;
|
||||
}
|
||||
},
|
||||
pastebin: {
|
||||
@ -13233,57 +13278,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
IDColor = {
|
||||
init: function() {
|
||||
if (g.VIEW === 'catalog' || !Conf['Color User IDs']) {
|
||||
return;
|
||||
}
|
||||
this.ids = {};
|
||||
return Post.callbacks.push({
|
||||
name: 'Color User IDs',
|
||||
cb: this.node
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
var rgb, span, style, uid;
|
||||
|
||||
if (this.isClone || !(uid = this.info.uniqueID)) {
|
||||
return;
|
||||
}
|
||||
span = $('.hand', this.nodes.uniqueID);
|
||||
if (!(span && span.nodeName === 'SPAN')) {
|
||||
return;
|
||||
}
|
||||
rgb = IDColor.compute(uid);
|
||||
style = span.style;
|
||||
style.color = rgb[3];
|
||||
style.backgroundColor = "rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + ")";
|
||||
$.addClass(span, 'painted');
|
||||
return span.title = 'Highlight posts by this ID';
|
||||
},
|
||||
compute: function(uid) {
|
||||
var hash, rgb;
|
||||
|
||||
if (IDColor.ids[uid]) {
|
||||
return IDColor.ids[uid];
|
||||
}
|
||||
hash = IDColor.hash(uid);
|
||||
rgb = [(hash >> 24) & 0xFF, (hash >> 16) & 0xFF, (hash >> 8) & 0xFF];
|
||||
rgb[3] = (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 125 ? '#000' : '#fff';
|
||||
return this.ids[uid] = rgb;
|
||||
},
|
||||
hash: function(uid) {
|
||||
var i, msg;
|
||||
|
||||
msg = 0;
|
||||
i = 0;
|
||||
while (i < 8) {
|
||||
msg = (msg << 5) - msg + uid.charCodeAt(i++);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
};
|
||||
|
||||
CustomCSS = {
|
||||
init: function() {
|
||||
if (!Conf['Custom CSS']) {
|
||||
@ -13757,32 +13751,35 @@
|
||||
if (this.isClone || !(uid = this.info.uniqueID)) {
|
||||
return;
|
||||
}
|
||||
span = $('.hand', this.nodes.uniqueID);
|
||||
if (!(span && span.nodeName === 'SPAN')) {
|
||||
return;
|
||||
}
|
||||
rgb = IDColor.compute(uid);
|
||||
span = this.nodes.uniqueID;
|
||||
style = span.style;
|
||||
style.color = rgb[3];
|
||||
style.backgroundColor = "rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + ")";
|
||||
$.addClass(span, 'painted');
|
||||
span.textContent = uid;
|
||||
return span.title = 'Highlight posts by this ID';
|
||||
},
|
||||
compute: function(uniqueID) {
|
||||
compute: function(uid) {
|
||||
var hash, rgb;
|
||||
|
||||
if (uniqueID in IDColor.ids) {
|
||||
return IDColor.ids[uniqueID];
|
||||
if (IDColor.ids[uid]) {
|
||||
return IDColor.ids[uid];
|
||||
}
|
||||
hash = this.hash(uniqueID);
|
||||
hash = IDColor.hash(uid);
|
||||
rgb = [(hash >> 24) & 0xFF, (hash >> 16) & 0xFF, (hash >> 8) & 0xFF];
|
||||
rgb.push((rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 170 ? 'black' : 'white');
|
||||
return this.ids[uniqueID] = rgb;
|
||||
rgb[3] = (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 125 ? '#000' : '#fff';
|
||||
return this.ids[uid] = rgb;
|
||||
},
|
||||
hash: function(uniqueID) {
|
||||
var i, msg, _i, _ref;
|
||||
hash: function(uid) {
|
||||
var i, msg;
|
||||
|
||||
msg = 0;
|
||||
for (i = _i = 0, _ref = uniqueID.length; _i < _ref; i = _i += 1) {
|
||||
msg = (msg << 5) - msg + uniqueID.charCodeAt(i);
|
||||
i = 0;
|
||||
while (i < 8) {
|
||||
msg = (msg << 5) - msg + uid.charCodeAt(i++);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
"http": true,
|
||||
"https": true,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["a", "co", "gd", "jp", "m", "q", "sp", "tg", "tv", "v", "vg", "vp", "vr", "wsg"],
|
||||
"files": ["a", "gd", "jp", "m", "q", "tg", "vg", "vp", "vr", "wsg"]
|
||||
"boards": ["a", "co", "gd", "jp", "m", "sp", "tg", "tv", "v", "vg", "vp", "vr", "wsg"],
|
||||
"files": ["a", "gd", "jp", "m", "tg", "vg", "vp", "vr", "wsg"]
|
||||
}, {
|
||||
"uid": 1,
|
||||
"name": "NSFW Foolz",
|
||||
@ -50,8 +50,8 @@
|
||||
"http": true,
|
||||
"https": true,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["b", "con", "e", "h", "hc", "p", "s", "soc", "sp", "u"],
|
||||
"files": ["b", "con", "e", "h", "hc", "p", "s", "soc", "sp", "u"]
|
||||
"boards": ["adv", "b", "cm", "d", "e", "h", "hc", "lgbt", "pol", "r", "s", "s4s", "soc", "trv", "u", "y"],
|
||||
"files": ["b", "cm", "d", "e", "h", "hc", "pol", "r", "s", "s4s", "soc", "u", "y"]
|
||||
}, {
|
||||
"uid": 7,
|
||||
"name": "Install Gentoo",
|
||||
@ -68,8 +68,8 @@
|
||||
"http": true,
|
||||
"https": true,
|
||||
"software": "fuuka",
|
||||
"boards": ["cgl", "con", "g", "mu", "w"],
|
||||
"files": ["cgl", "con", "g", "mu", "w"]
|
||||
"boards": ["cgl", "g", "mu", "w"],
|
||||
"files": ["cgl", "g", "mu", "w"]
|
||||
}, {
|
||||
"uid": 9,
|
||||
"name": "Heinessen",
|
||||
@ -86,8 +86,8 @@
|
||||
"http": true,
|
||||
"https": true,
|
||||
"software": "fuuka",
|
||||
"boards": ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "q", "tg", "vr"],
|
||||
"files": ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "q", "tg", "vr"]
|
||||
"boards": ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"],
|
||||
"files": ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"]
|
||||
}, {
|
||||
"uid": 13,
|
||||
"name": "Foolz Beta",
|
||||
@ -96,6 +96,6 @@
|
||||
"https": true,
|
||||
"withCredentials": true,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["a", "co", "d", "gd", "h", "jp", "m", "mlp", "q", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"],
|
||||
"files": ["a", "d", "gd", "h", "jp", "m", "q", "tg", "u", "vg", "vp", "vr", "wsg"]
|
||||
"boards": ["a", "co", "d", "gd", "h", "jp", "m", "mlp", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"],
|
||||
"files": ["a", "d", "gd", "h", "jp", "m", "tg", "u", "vg", "vp", "vr", "wsg"]
|
||||
}]
|
||||
|
||||
@ -293,33 +293,35 @@ Linkify =
|
||||
|
||||
MediaCrush:
|
||||
regExp: /.*(?:mediacru.sh\/)([0-9a-z_]+)/i
|
||||
style: 'border: 0; width: 640px; height: 480px; resize: both;'
|
||||
style: 'border: 0;'
|
||||
el: (a) ->
|
||||
$.el 'iframe',
|
||||
src: "https://mediacru.sh/#{a.dataset.uid}"
|
||||
# MediaCrush CORS When?
|
||||
#
|
||||
# el = $.el 'div'
|
||||
# $.cache "https://mediacru.sh/#{a.dataset.uid}.json", ->
|
||||
# {status} = @
|
||||
# return unless [200, 304].contains status
|
||||
# {files} = JSON.parse req.response
|
||||
# file = file for file of files when files.hasOwnProperty file
|
||||
# el.innerHTML = switch file.type
|
||||
# when 'video/mp4', 'video/ogv'
|
||||
# """
|
||||
#<video autoplay loop>
|
||||
# <source src="https://mediacru.sh/#{a.dataset.uid}.mp4" type="video/mp4;">
|
||||
# <source src="https://mediacru.sh/#{a.dataset.uid}.ogv" type="video/ogg; codecs='theora, vorbis'">
|
||||
#</video>"""
|
||||
# when 'image/png', 'image/gif', 'image/jpeg'
|
||||
# "<a target=_blank href='#{a.dataset.href}'><img src='https://mediacru.sh/#{file.file}'></a>"
|
||||
# when 'image/svg', 'image/svg+xml'
|
||||
# "<embed src='https://mediacru.sh/#{file.file}' type='image/svg+xml' />"
|
||||
# when 'audio/mpeg'
|
||||
# "<audio controls><source src='https://mediacru.sh/#{file.file}'></audio>"
|
||||
# el
|
||||
|
||||
el = $.el 'div'
|
||||
$.cache "https://mediacru.sh/#{a.dataset.uid}.json", ->
|
||||
{status} = @
|
||||
return div.innerHTML = "ERROR #{status}" unless [200, 304].contains status
|
||||
{files} = JSON.parse @response
|
||||
for type in ['video/mp4', 'video/ogv', 'image/svg+xml', 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'audio/mpeg']
|
||||
for file in files
|
||||
if file.type is type
|
||||
embed = file
|
||||
break
|
||||
break if embed
|
||||
return div.innerHTML = "ERROR: Not a valid filetype" unless embed
|
||||
el.innerHTML = switch embed.type
|
||||
when 'video/mp4', 'video/ogv' then """
|
||||
<video autoplay loop>
|
||||
<source src="https://mediacru.sh/#{a.dataset.uid}.mp4" type="video/mp4;">
|
||||
<source src="https://mediacru.sh/#{a.dataset.uid}.ogv" type="video/ogg; codecs='theora, vorbis'">
|
||||
</video>"""
|
||||
when 'image/png', 'image/gif', 'image/jpeg'
|
||||
"<a target=_blank href='#{a.dataset.href}'><img src='https://mediacru.sh/#{file.file}'></a>"
|
||||
when 'image/svg', 'image/svg+xml'
|
||||
"<embed src='https://mediacru.sh/#{file.file}' type='image/svg+xml' />"
|
||||
when 'audio/mpeg'
|
||||
"<audio controls><source src='https://mediacru.sh/#{file.file}'></audio>"
|
||||
else
|
||||
"ERROR: No valid filetype."
|
||||
el
|
||||
|
||||
pastebin:
|
||||
regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/
|
||||
|
||||
@ -1,41 +0,0 @@
|
||||
IDColor =
|
||||
init: ->
|
||||
return if g.VIEW is 'catalog' or not Conf['Color User IDs']
|
||||
@ids = {}
|
||||
|
||||
Post.callbacks.push
|
||||
name: 'Color User IDs'
|
||||
cb: @node
|
||||
|
||||
node: ->
|
||||
return if @isClone or not uid = @info.uniqueID
|
||||
span = $ '.hand', @nodes.uniqueID
|
||||
return unless span and span.nodeName is 'SPAN'
|
||||
rgb = IDColor.compute uid
|
||||
{style} = span
|
||||
style.color = rgb[3]
|
||||
style.backgroundColor = "rgb(#{rgb[0]},#{rgb[1]},#{rgb[2]})"
|
||||
$.addClass span, 'painted'
|
||||
span.title = 'Highlight posts by this ID'
|
||||
|
||||
compute: (uid) ->
|
||||
return IDColor.ids[uid] if IDColor.ids[uid]
|
||||
|
||||
hash = IDColor.hash uid
|
||||
rgb = [
|
||||
(hash >> 24) & 0xFF
|
||||
(hash >> 16) & 0xFF
|
||||
(hash >> 8) & 0xFF
|
||||
]
|
||||
rgb[3] = if (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 125
|
||||
'#000'
|
||||
else
|
||||
'#fff'
|
||||
@ids[uid] = rgb
|
||||
|
||||
hash: (uid) ->
|
||||
msg = 0
|
||||
i = 0
|
||||
while i < 8
|
||||
msg = (msg << 5) - msg + uid.charCodeAt i++
|
||||
msg
|
||||
33
src/Miscellaneous/IDColor.coffee
Normal file → Executable file
33
src/Miscellaneous/IDColor.coffee
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
IDColor =
|
||||
init: ->
|
||||
return if g.VIEW is 'catalog' or !Conf['Color User IDs']
|
||||
return if g.VIEW is 'catalog' or not Conf['Color User IDs']
|
||||
@ids = {}
|
||||
|
||||
Post.callbacks.push
|
||||
@ -8,33 +8,34 @@ IDColor =
|
||||
cb: @node
|
||||
|
||||
node: ->
|
||||
return if @isClone or !(uid = @info.uniqueID)
|
||||
return if @isClone or not uid = @info.uniqueID
|
||||
span = $ '.hand', @nodes.uniqueID
|
||||
return unless span and span.nodeName is 'SPAN'
|
||||
rgb = IDColor.compute uid
|
||||
span = @nodes.uniqueID
|
||||
{style} = span
|
||||
style.color = rgb[3]
|
||||
style.backgroundColor = "rgb(#{rgb[0]},#{rgb[1]},#{rgb[2]})"
|
||||
$.addClass span, 'painted'
|
||||
span.textContent = uid
|
||||
span.title = 'Highlight posts by this ID'
|
||||
|
||||
compute: (uniqueID) ->
|
||||
if uniqueID of IDColor.ids
|
||||
return IDColor.ids[uniqueID]
|
||||
hash = @hash uniqueID
|
||||
compute: (uid) ->
|
||||
return IDColor.ids[uid] if IDColor.ids[uid]
|
||||
|
||||
hash = IDColor.hash uid
|
||||
rgb = [
|
||||
(hash >> 24) & 0xFF
|
||||
(hash >> 16) & 0xFF
|
||||
(hash >> 8) & 0xFF
|
||||
]
|
||||
rgb.push if (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 170
|
||||
'black'
|
||||
rgb[3] = if (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 125
|
||||
'#000'
|
||||
else
|
||||
'white'
|
||||
@ids[uniqueID] = rgb
|
||||
'#fff'
|
||||
@ids[uid] = rgb
|
||||
|
||||
hash: (uniqueID) ->
|
||||
hash: (uid) ->
|
||||
msg = 0
|
||||
for i in [0...uniqueID.length] by 1
|
||||
msg = (msg << 5) - msg + uniqueID.charCodeAt i
|
||||
msg
|
||||
i = 0
|
||||
while i < 8
|
||||
msg = (msg << 5) - msg + uid.charCodeAt i++
|
||||
msg
|
||||
@ -58,4 +58,3 @@ Time =
|
||||
S: -> Time.zeroPad @getSeconds()
|
||||
y: -> @getFullYear().toString()[2..]
|
||||
Y: -> @getFullYear()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user