Holy shit loops
This commit is contained in:
parent
282a2338d8
commit
4c09eed4cd
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 4chan X - Version 1.4.1 - 2014-03-20
|
||||
* 4chan X - Version 1.4.1 - 2014-03-21
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
// ==/UserScript==
|
||||
|
||||
/*
|
||||
* 4chan X - Version 1.4.1 - 2014-03-20
|
||||
* 4chan X - Version 1.4.1 - 2014-03-21
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||
@ -3363,37 +3363,32 @@
|
||||
return Post.callbacks.execute(posts);
|
||||
},
|
||||
buildCatalogViews: function() {
|
||||
var catalogThreads, i, nodes, thread, _i, _len, _ref;
|
||||
var catalogThreads, i, nodes, root, size, thread;
|
||||
catalogThreads = [];
|
||||
_ref = Index.sortedThreads;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
thread = _ref[_i];
|
||||
nodes = [];
|
||||
i = 0;
|
||||
size = Conf['Index Size'] === 'small' ? 150 : 250;
|
||||
while (thread = Index.sortedThreads[i++]) {
|
||||
if (!thread.catalogView) {
|
||||
catalogThreads.push(new CatalogThread(Build.catalogThread(thread), thread));
|
||||
}
|
||||
root = thread.catalogView.nodes.root;
|
||||
Index.sizeSingleCatalogNode(root, size);
|
||||
nodes.push(root);
|
||||
}
|
||||
CatalogThread.callbacks.execute(catalogThreads);
|
||||
nodes = [];
|
||||
i = 0;
|
||||
while (thread = Index.sortedThreads[i++]) {
|
||||
nodes.push(thread.catalogView.nodes.root);
|
||||
}
|
||||
return nodes;
|
||||
},
|
||||
sizeCatalogViews: function(nodes) {
|
||||
var height, node, ratio, size, thumb, width, _i, _len, _ref;
|
||||
size = Conf['Index Size'] === 'small' ? 150 : 250;
|
||||
for (_i = 0, _len = nodes.length; _i < _len; _i++) {
|
||||
node = nodes[_i];
|
||||
thumb = node.firstElementChild;
|
||||
_ref = thumb.dataset, width = _ref.width, height = _ref.height;
|
||||
if (!width) {
|
||||
continue;
|
||||
}
|
||||
ratio = size / Math.max(width, height);
|
||||
thumb.style.width = width * ratio + 'px';
|
||||
thumb.style.height = height * ratio + 'px';
|
||||
sizeSingleCatalogNode: function(node, size) {
|
||||
var height, ratio, thumb, width, _ref;
|
||||
thumb = node.firstElementChild;
|
||||
_ref = thumb.dataset, width = _ref.width, height = _ref.height;
|
||||
if (!width) {
|
||||
return;
|
||||
}
|
||||
ratio = size / Math.max(width, height);
|
||||
thumb.style.width = width * ratio + 'px';
|
||||
return thumb.style.height = height * ratio + 'px';
|
||||
},
|
||||
sort: function() {
|
||||
var i, liveData, sortedThreadIDs, sortedThreads, thread, threadID;
|
||||
@ -3512,7 +3507,6 @@
|
||||
break;
|
||||
case 'catalog':
|
||||
nodes = Index.buildCatalogViews();
|
||||
Index.sizeCatalogViews(nodes);
|
||||
break;
|
||||
default:
|
||||
nodes = [];
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript
|
||||
/*
|
||||
* 4chan X - Version 1.4.1 - 2014-03-20
|
||||
* 4chan X - Version 1.4.1 - 2014-03-21
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/Spittie/4chan-x/blob/master/LICENSE
|
||||
@ -3422,37 +3422,32 @@
|
||||
return Post.callbacks.execute(posts);
|
||||
},
|
||||
buildCatalogViews: function() {
|
||||
var catalogThreads, i, nodes, thread, _i, _len, _ref;
|
||||
var catalogThreads, i, nodes, root, size, thread;
|
||||
catalogThreads = [];
|
||||
_ref = Index.sortedThreads;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
thread = _ref[_i];
|
||||
nodes = [];
|
||||
i = 0;
|
||||
size = Conf['Index Size'] === 'small' ? 150 : 250;
|
||||
while (thread = Index.sortedThreads[i++]) {
|
||||
if (!thread.catalogView) {
|
||||
catalogThreads.push(new CatalogThread(Build.catalogThread(thread), thread));
|
||||
}
|
||||
root = thread.catalogView.nodes.root;
|
||||
Index.sizeSingleCatalogNode(root, size);
|
||||
nodes.push(root);
|
||||
}
|
||||
CatalogThread.callbacks.execute(catalogThreads);
|
||||
nodes = [];
|
||||
i = 0;
|
||||
while (thread = Index.sortedThreads[i++]) {
|
||||
nodes.push(thread.catalogView.nodes.root);
|
||||
}
|
||||
return nodes;
|
||||
},
|
||||
sizeCatalogViews: function(nodes) {
|
||||
var height, node, ratio, size, thumb, width, _i, _len, _ref;
|
||||
size = Conf['Index Size'] === 'small' ? 150 : 250;
|
||||
for (_i = 0, _len = nodes.length; _i < _len; _i++) {
|
||||
node = nodes[_i];
|
||||
thumb = node.firstElementChild;
|
||||
_ref = thumb.dataset, width = _ref.width, height = _ref.height;
|
||||
if (!width) {
|
||||
continue;
|
||||
}
|
||||
ratio = size / Math.max(width, height);
|
||||
thumb.style.width = width * ratio + 'px';
|
||||
thumb.style.height = height * ratio + 'px';
|
||||
sizeSingleCatalogNode: function(node, size) {
|
||||
var height, ratio, thumb, width, _ref;
|
||||
thumb = node.firstElementChild;
|
||||
_ref = thumb.dataset, width = _ref.width, height = _ref.height;
|
||||
if (!width) {
|
||||
return;
|
||||
}
|
||||
ratio = size / Math.max(width, height);
|
||||
thumb.style.width = width * ratio + 'px';
|
||||
return thumb.style.height = height * ratio + 'px';
|
||||
},
|
||||
sort: function() {
|
||||
var i, liveData, sortedThreadIDs, sortedThreads, thread, threadID;
|
||||
@ -3571,7 +3566,6 @@
|
||||
break;
|
||||
case 'catalog':
|
||||
nodes = Index.buildCatalogViews();
|
||||
Index.sizeCatalogViews(nodes);
|
||||
break;
|
||||
default:
|
||||
nodes = [];
|
||||
|
||||
@ -653,26 +653,25 @@ Index =
|
||||
|
||||
buildCatalogViews: ->
|
||||
catalogThreads = []
|
||||
for thread in Index.sortedThreads when !thread.catalogView
|
||||
catalogThreads.push new CatalogThread Build.catalogThread(thread), thread
|
||||
CatalogThread.callbacks.execute catalogThreads
|
||||
nodes = []
|
||||
i = 0
|
||||
size = if Conf['Index Size'] is 'small' then 150 else 250
|
||||
while thread = Index.sortedThreads[i++]
|
||||
nodes.push thread.catalogView.nodes.root
|
||||
if !thread.catalogView
|
||||
catalogThreads.push new CatalogThread Build.catalogThread(thread), thread
|
||||
{root} = thread.catalogView.nodes
|
||||
Index.sizeSingleCatalogNode root, size
|
||||
nodes.push root
|
||||
CatalogThread.callbacks.execute catalogThreads
|
||||
return nodes
|
||||
|
||||
sizeCatalogViews: (nodes) ->
|
||||
# XXX When browsers support CSS3 attr(), use it instead.
|
||||
size = if Conf['Index Size'] is 'small' then 150 else 250
|
||||
for node in nodes
|
||||
thumb = node.firstElementChild
|
||||
{width, height} = thumb.dataset
|
||||
continue unless width
|
||||
ratio = size / Math.max width, height
|
||||
thumb.style.width = width * ratio + 'px'
|
||||
thumb.style.height = height * ratio + 'px'
|
||||
return
|
||||
sizeSingleCatalogNode: (node, size) ->
|
||||
thumb = node.firstElementChild
|
||||
{width, height} = thumb.dataset
|
||||
return unless width
|
||||
ratio = size / Math.max width, height
|
||||
thumb.style.width = width * ratio + 'px'
|
||||
thumb.style.height = height * ratio + 'px'
|
||||
|
||||
sort: ->
|
||||
sortedThreads = []
|
||||
@ -758,7 +757,6 @@ Index =
|
||||
|
||||
when 'catalog'
|
||||
nodes = Index.buildCatalogViews()
|
||||
Index.sizeCatalogViews nodes
|
||||
|
||||
else
|
||||
nodes = []
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user