Message from JavaScript discussions
July 2017
— Hm, I have a challenge
var curData = conf.data;
// Paginate the data
// FIXME: This is completely random as objects are unordered...
if (conf.paged) {
if (!Array.isArray(conf.data)) {
curData = Array.from(conf.data);
}
var pages = Math.ceil(curData.length / conf.elemPerPage);
if (conf.pageNo >= pages) {
curData = curData.slice((conf.pageNo - 1) * conf.elemPerPage, conf.elemPerPage + start);
}
}
— conf.data
is not an Array here, and also that Array.from
will not work on normal objects
— Of course, those were attempts to solve the problem in the FIXME
there
— So the question is, should I throw out the feature, or make it explicitly for arrays only?
— And if I do make it for arrays only, how do I translate that to a tag-tracking system which focuses on singular tags?
— This is the system here, specifically the data
HTML attribute references properties inside data
— For good reference too, the template engine I base my work off of conceptually is jquery-template, where the author has restricted the feature to arrays as well, but their code is much worse to read so I have yet to find how they reconcile this problem
— No docs for methods, only a tiny tiny handful of random comments stating the obvious... and tons of really bulky jQuery code that is so granular it is a pain to read through (that FP interface is a bittersweet thing for code density)
— All I did was look at their template tagging system (with data
attrs) and came up with my own ways of doing it without jQuery, so I never really dove into the source code
— Guys
— I have this function
$(document).ready(function() {