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