Commit b74dd250 authored by Zhai Zirun's avatar Zhai Zirun

trying to get require to work

parent c6c30f46
This diff is collapsed.
......@@ -43,7 +43,8 @@ function query(product) {
return console.error(`No product found with the name ${product}`);
}
return !((cd && (1 && dietNum)) || (cm && (2 && dietNum)) || (cc && (4 && dietNum)) || (cg && (8 && dietNum)))
return row.cg
//return !((cd && (1 && dietNum)) || (cm && (2 && dietNum)) || (cc && (4 && dietNum)) || (cg && (8 && dietNum)))
});
db.close();
......@@ -116,10 +117,10 @@ document.addEventListener('mousemove', function (e) {
// srcElement.classList.add(MOUSE_VISITED_CLASSNAME);
// }
// currName = srcElement.srcName;
if (checkAllergen(srcName)) {
if (query(srcName)) {
srcElement.classList.add(MOUSE_VISITED_CLASSNAME); //changes outline of pic
}
if (!checkAllergen(srcName)) {
if (!query(srcName)) {
srcElement.classList.add(MOUSE_VISITED_CLASSNAME_FALSE);
}
//TODO: modify behaviour according to different allergens
......@@ -133,6 +134,6 @@ document.addEventListener('mousemove', function (e) {
if(document){
document.addEventListener("DOMContentLoaded", function() {
document.getElementById("Submit").addEventListener("click", myFunction);
document.getElementById("Submit").addEventListener("click", dietNumInit);
});
}
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
pids
logs
results
npm-debug.log
node_modules/*
\ No newline at end of file
The MIT License (MIT)
Copyright (c) 2013 Mikola Lysenko
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
uniq
====
Removes all duplicates from an array in place.
Usage
=====
First install using npm:
npm install uniq
Then use it as follows:
```javascript
var arr = [1, 1, 2, 2, 3, 5]
require("uniq")(arr)
console.log(arr)
//Prints:
//
// 1,2,3,5
//
```
## `require("uniq")(array[, compare, sorted])`
Removes all duplicates from a sorted array in place.
* `array` is the array to remove items from
* `compare` is an optional comparison function that returns 0 when two items are equal, and something non-zero when they are different. If unspecified, then the default equals will be used.
* `sorted` if true, then assume array is already sorted
**Returns:** A reference to `array`
**Time Complexity:** `O(array.length * log(arra.length))` or `O(array.length)` if `sorted`
## Why use this instead of underscore.uniq[ue]?
A few reasons:
* This library updates the array in place without making an extra copy (and so it is faster for large arrays)
* It also accepts a custom comparison function so you can remove duplicates from arrays containing object
* It is more modular in the sense that it doesn't come with a bazillion other utility grab bag functions.
# Credits
(c) 2013 Mikola Lysenko. MIT License
{
"_from": "uniq",
"_id": "uniq@1.0.1",
"_inBundle": false,
"_integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=",
"_location": "/uniq",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "uniq",
"name": "uniq",
"escapedName": "uniq",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz",
"_shasum": "b31c5ae8254844a3a8281541ce2b04b865a734ff",
"_spec": "uniq",
"_where": "/Users/zirun/Documents/NON-SCHOOL PROJECTS/chrome-groceries-extension",
"author": {
"name": "Mikola Lysenko"
},
"bugs": {
"url": "https://github.com/mikolalysenko/uniq/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "Removes duplicates from a sorted array in place",
"devDependencies": {
"tape": "^2.12.3"
},
"directories": {
"test": "test"
},
"gitHead": "e9828cfcb97e25a351f95b39fdf3c31876ff3985",
"homepage": "https://github.com/mikolalysenko/uniq#readme",
"keywords": [
"array",
"duplicate",
"unique",
"uniq",
"remove",
"sort",
"in",
"place",
"no",
"copy"
],
"license": "MIT",
"main": "uniq.js",
"name": "uniq",
"repository": {
"type": "git",
"url": "git://github.com/mikolalysenko/uniq.git"
},
"scripts": {
"test": "tape test/*.js"
},
"version": "1.0.1"
}
var unique = require("../uniq.js")
require("tape")("unique", function(t) {
t.equals(unique([1,1,2,3,5,5,7]).join(), [1,2,3,5,7].join())
t.equals(unique([]).join(), [].join())
t.equals(unique([1,1,1]).join(), [1].join())
t.equals(unique([1,1,1,2,2,2], function(a,b) { return (a^b)&1 }).join(), [2,1].join())
t.end()
})
\ No newline at end of file
"use strict"
function unique_pred(list, compare) {
var ptr = 1
, len = list.length
, a=list[0], b=list[0]
for(var i=1; i<len; ++i) {
b = a
a = list[i]
if(compare(a, b)) {
if(i === ptr) {
ptr++
continue
}
list[ptr++] = a
}
}
list.length = ptr
return list
}
function unique_eq(list) {
var ptr = 1
, len = list.length
, a=list[0], b = list[0]
for(var i=1; i<len; ++i, b=a) {
b = a
a = list[i]
if(a !== b) {
if(i === ptr) {
ptr++
continue
}
list[ptr++] = a
}
}
list.length = ptr
return list
}
function unique(list, compare, sorted) {
if(list.length === 0) {
return list
}
if(compare) {
if(!sorted) {
list.sort(compare)
}
return unique_pred(list, compare)
}
if(!sorted) {
list.sort()
}
return unique_eq(list)
}
module.exports = unique
......@@ -990,6 +990,11 @@
"integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
"optional": true
},
"uniq": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz",
"integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8="
},
"uri-js": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.0.tgz",
......
......@@ -15,6 +15,7 @@
"license": "ISC",
"dependencies": {
"pg": "^8.3.0",
"sqlite3": "^5.0.0"
"sqlite3": "^5.0.0",
"uniq": "^1.0.1"
}
}
......@@ -4,7 +4,7 @@
<meta charset = "utf-8"/>
<title> clickerance </title>
<link type="text/css" rel="stylesheet" href="style.css"/>
<script src="content.js"></script>
<script src="bundle.js"></script>
</head>
<body>
<div class="Title"></div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment