-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c2c852
commit 980b662
Showing
3 changed files
with
23 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,45 @@ | ||
function search(searchOBJS,input) { | ||
|
||
if (searchOBJS.includes('#')) {/*Checks that the second arguement is a class .*/ | ||
function search_debug(searchOBJS,sOBJS,inputLc,input) { | ||
if (searchOBJS.includes('#')) {/*Checks that the first arguement is a class .*/ | ||
console.error('search.js: search function only accepts an class as second argument') | ||
return false | ||
} | ||
|
||
let sOBJS = document.querySelectorAll(searchOBJS) | ||
if (sOBJS[0] == undefined) { | ||
console.warning('search.js: The given class does not have any elements associated with it .') | ||
console.warn('search.js: The given class does not have any elements associated with it .') | ||
return false | ||
} | ||
|
||
if (inputLc == undefined) { | ||
console.error('search.js: The given id for the input does not have a element associated with it .') | ||
return false | ||
} | ||
|
||
console.log('search.js :No errors in the arguments .') | ||
|
||
} | ||
|
||
function search(searchOBJS,input,options={debug:true}) { | ||
|
||
let sOBJS = document.querySelectorAll(searchOBJS) | ||
let inputLc = document.querySelectorAll(input)[0] /*Lc stands for local*/ | ||
if (inputLc == undefined) { | ||
console.error('search.js: The given id for the input does not have a input associated with it .') | ||
|
||
if (options.debug) { | ||
return search_debug(searchOBJS,sOBJS,inputLc,input) | ||
} | ||
|
||
console.log('Search :No errors in the arguments .') | ||
inputLc.addEventListener('input',()=>{ | ||
for(var i = 0 ; i < sOBJS.length ; i++ ){ | ||
if (!(sOBJS[i].innerHTML.includes(inputLc.value))) { | ||
sOBJS[i].style.position = 'absolute' | ||
sOBJS[i].style.visibility = 'hidden' | ||
console.log(`${sOBJS[i].innerHTML} and input is ${inputLc.value} `) | ||
|
||
}else { | ||
sOBJS[i].style.position = 'relative' | ||
sOBJS[i].style.visibility = 'visible' | ||
} | ||
} | ||
|
||
}) | ||
} | ||
} | ||
|