Skip to content

Instantly share code, notes, and snippets.

@deanlandolt
Created April 30, 2010 20:00
Show Gist options
  • Select an option

  • Save deanlandolt/385677 to your computer and use it in GitHub Desktop.

Select an option

Save deanlandolt/385677 to your computer and use it in GitHub Desktop.
query: function(query, options) {
options = options || {};
// FIXME use facets
var defaultRangeLength = config.defaultRangeLength || 25; // TODO get from settings
var slice = function() {
var length,
xquery = "";
if (defaultRangeLength && !(options.start == 0 && options.end == Infinity)) {
options.start = options.start || 0;
options.end = options.end || Infinity;
if ((options.end - options.start) > defaultRangeLength) {
options.end = options.start + defaultRangeLength - 1
}
}
if (options.start >= 0 && options.end) length = options.end - options.start + 1;
if (options.start >= 0) {
xquery = "[" + (options.start + 1) + " to ";
xquery += (options.end !== Infinity && (options.end + 1) || "last()") + "]";
}
// TODO handle empty start
return {
xquery: xquery,
length: length
}
}();
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment