1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-14 02:26:20 +02:00

add search inside saved items pane. fixes #26

This commit is contained in:
Kushagra Gour
2017-04-30 20:29:44 +05:30
parent 659588d580
commit b6e463ba4c
4 changed files with 83 additions and 26 deletions

View File

@ -2,9 +2,32 @@
window.DEBUG = document.cookie.indexOf('wmdebug') > -1;
window.$ = document.querySelector.bind(document);
window.$all = document.querySelectorAll.bind(document);
window.$all = (selector) => [...document.querySelectorAll(selector)] ;
var alphaNum = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
/**
* The following 2 functions are supposed to find the next/previous sibling until the
* passed `selector` is matched. But for now it actually finds the next/previous
* element of `this` element in the list of `selector` matched element inside `this`'s
* parent.
* @param Selector that should match for next siblings
* @return element Next element that mathes `selector`
*/
Node.prototype.nextUntil = function (selector) {
var siblings = [...this.parentNode.querySelectorAll(selector)];
var index = siblings.indexOf(this);
return siblings[index + 1];
};
/*
* @param Selector that should match for next siblings
* @return element Next element that mathes `selector`
*/
Node.prototype.previousUntil = function (selector) {
var siblings = [...this.parentNode.querySelectorAll(selector)];
var index = siblings.indexOf(this);
return siblings[index - 1];
};
// https://github.com/substack/semver-compare/blob/master/index.js
function semverCompare(a, b) {
var pa = a.split('.');