renamed a few variables

master
Stefan Naumann 3 years ago
parent d278ca00cb
commit 21a089ff8b
  1. 57
      src/tipuesearch_set.js
  2. 65
      src/tpsearch.js
  3. 57
      src/tpsearch_set.js

@ -1,57 +0,0 @@
/*
Tipue Search 7.1
Copyright (c) 2019 Tipue
Tipue Search is released under the MIT License
http://www.tipue.com/search
*/
/*
Stop words
Stop words list from http://www.ranks.nl/stopwords
*/
var tipuesearch_stop_words = ["a", "above", "after", "again", "against", "all", "am", "an", "and", "any", "are", "aren't", "as", "at", "be", "because", "been", "before", "being", "below", "between", "both", "but", "by", "can't", "cannot", "could", "couldn't", "did", "didn't", "do", "does", "doesn't", "doing", "don't", "down", "during", "each", "few", "for", "from", "further", "had", "hadn't", "has", "hasn't", "have", "haven't", "having", "he", "he'd", "he'll", "he's", "her", "here", "here's", "hers", "herself", "him", "himself", "his", "how", "how's", "i", "i'd", "i'll", "i'm", "i've", "if", "in", "into", "is", "isn't", "it", "it's", "its", "itself", "let's", "me", "more", "most", "mustn't", "my", "myself", "no", "nor", "not", "of", "off", "on", "once", "only", "or", "other", "ought", "our", "ours", "ourselves", "out", "over", "own", "same", "shan't", "she", "she'd", "she'll", "she's", "should", "shouldn't", "so", "some", "such", "than", "that", "that's", "the", "their", "theirs", "them", "themselves", "then", "there", "there's", "these", "they", "they'd", "they'll", "they're", "they've", "this", "those", "through", "to", "too", "under", "until", "up", "very", "was", "wasn't", "we", "we'd", "we'll", "we're", "we've", "were", "weren't", "what", "what's", "when", "when's", "where", "where's", "which", "while", "who", "who's", "whom", "why", "why's", "with", "won't", "would", "wouldn't", "you", "you'd", "you'll", "you're", "you've", "your", "yours", "yourself", "yourselves",
"aber","als","am","an","auch","auf","aus","bei","bin","bis","bist","da","dadurch","daher","darum","das","daß","dass","dein","deine","dem","den","der","des","dessen","deshalb","die","dies","dieser","dieses","doch","dort","du","durch","ein","eine","einem","einen","einer","eines","er","es","euer","eure","für","hatte","hatten","hattest","hattet","hier","hinter","ich","ihr","ihre","im","in","ist","ja","jede","jedem","jeden","jeder","jedes","jener","jenes","jetzt","kann","kannst","können","könnt","machen","mein","meine","mit","muß","mußt","musst","müssen","müßt","nach","nachdem","nein","nicht","nun","oder","seid","sein","seine","sich","sie","sind","soll","sollen","sollst","sollt","sonst","soweit","sowie","und","unser unsere","unter","vom","von","vor","wann","warum","was","weiter","weitere","wenn","wer","werde","werden","werdet","weshalb","wie","wieder","wieso","wir","wird","wirst","wo","woher","wohin","zu","zum","zur","über" ];
// Word replace
var tipuesearch_replace = {'words': [
]};
// Weighting
var tipuesearch_weight = {'weight': [
]};
var tipuesearch_related = { 'Related' : [
{"search": "testwort", "related": "raspberry pi"},
] };
// Stemming
var tipuesearch_stem = {'words': [
]};
// Internal strings
var tipuesearch_string_1 = 'Ohne Titel';
var tipuesearch_string_2 = 'Zeige Resultate für';
var tipuesearch_string_3 = 'Suche stattdessen nach';
var tipuesearch_string_4 = '1 Resultat';
var tipuesearch_string_5 = 'Resultate';
var tipuesearch_string_8 = 'Nichts gefunden';
var tipuesearch_string_9 = 'Häufige Worte werden ignoriert';
var tipuesearch_string_10 = 'Verwandt';
var tipuesearch_string_11 = 'Bitte wenigstens ein Zeichen eingeben';
var tipuesearch_string_12 = 'Bitte wenigstens';
var tipuesearch_string_13 = 'Zeichen oder mehr eingeben';
var tipuesearch_string_14 = 'Sekunden';
var tipuesearch_string_15 = 'Bild öffnen';
var tipuesearch_string_16 = 'Gehe auf Seite ';

@ -3,7 +3,6 @@ tpsearch
Copyright (c) 2020 Stefan Naumann, Tipue (original creators)
This version is released under GPLv3 or newer
Tipue Search was originally released under the MIT License
http://www.tipue.com/search
*/
function setAttr ( x, attr, dflt ) {
@ -26,7 +25,7 @@ function show ( obj ) {
}
}
class TipueSearch {
class tpsearch {
constructor ( options ) {
this.filter_string = setAttr ( options, "filter_string", ".filter_checkbox" );
this.filter_misc_strings = setAttr ( options, "filter_misc", [ "None", "Sonstiges" ] );
@ -81,13 +80,13 @@ class TipueSearch {
if (event.keyCode == "13") {
event.preventDefault();
}
tp.doTipueSearch(0, true);
tp.doTpSearch(0, true);
});
// on every change of the filter boxes
for ( var i = 0; i < this.filter_boxes.length; i++ ) {
this.filter_boxes[i].addEventListener ( "change", function (event) {
tp.doTipueSearch(0, true);
tp.doTpSearch(0, true);
});
}
@ -97,7 +96,7 @@ class TipueSearch {
}
if (this.searchBox.value.length > 0) {
tp.doTipueSearch(0, true);
tp.doTpSearch(0, true);
}
}
@ -158,8 +157,8 @@ class TipueSearch {
}
// do the search from start to finish
doTipueSearch ( start, replace ) {
var found = this.getTipueSearch ( replace );
doTpSearch ( start, replace ) {
var found = this.getTpSearch ( replace );
var repl = found["replace"];
var d = found["d"];
var d_r = found["d_r"];
@ -174,7 +173,7 @@ class TipueSearch {
// - .replace
// - .d
// - .d_r
getTipueSearch(replace) {
getTpSearch(replace) {
hide ( this.outputBox );
var tipuesearch_t_c = 0;
@ -203,8 +202,8 @@ class TipueSearch {
d = "";
for (var i = 0; i < d_w.length; i++) {
var a_w = true;
for (var f = 0; f < tipuesearch_stop_words.length; f++) {
if (d_w[i] == tipuesearch_stop_words[f]) {
for (var f = 0; f < tpsearch_stop_words.length; f++) {
if (d_w[i] == tpsearch_stop_words[f]) {
a_w = false;
show_stop = true;
}
@ -224,9 +223,9 @@ class TipueSearch {
if (replace) {
var d_r = d;
for (var i = 0; i < d_w.length; i++) {
for (var f = 0; f < tipuesearch_replace.words.length; f++) {
if (d_w[i] == tipuesearch_replace.words[f].word) {
d = d.replace(d_w[i], tipuesearch_replace.words[f].replace_with);
for (var f = 0; f < tpsearch_replace.words.length; f++) {
if (d_w[i] == tpsearch_replace.words[f].word) {
d = d.replace(d_w[i], tpsearch_replace.words[f].replace_with);
show_replace = true;
}
}
@ -236,9 +235,9 @@ class TipueSearch {
var d_t = d;
for (var i = 0; i < d_w.length; i++) {
for (var f = 0; f < tipuesearch_stem.words.length; f++) {
if (d_w[i] == tipuesearch_stem.words[f].word) {
d_t = d_t + " " + tipuesearch_stem.words[f].stem;
for (var f = 0; f < tpsearch_stem.words.length; f++) {
if (d_w[i] == tpsearch_stem.words[f].word) {
d_t = d_t + " " + tpsearch_stem.words[f].stem;
}
}
}
@ -277,9 +276,9 @@ class TipueSearch {
}
if (score != 0) {
for (var e = 0; e < tipuesearch_weight.weight.length; e++) {
if (tipuesearch_in.pages[i].url == tipuesearch_weight.weight[e].url) {
score += tipuesearch_weight.weight[e].score;
for (var e = 0; e < tpsearch_weight.weight.length; e++) {
if (tipuesearch_in.pages[i].url == tpsearch_weight.weight[e].url) {
score += tpsearch_weight.weight[e].score;
}
}
}
@ -329,9 +328,9 @@ class TipueSearch {
}
if (score != 0) {
for (var e = 0; e < tipuesearch_weight.weight.length; e++) {
if (tipuesearch_in.pages[i].url == tipuesearch_weight.weight[e].url) {
score += tipuesearch_weight.weight[e].score;
for (var e = 0; e < tpsearch_weight.weight.length; e++) {
if (tipuesearch_in.pages[i].url == tpsearch_weight.weight[e].url) {
score += tpsearch_weight.weight[e].score;
}
}
}
@ -403,7 +402,7 @@ class TipueSearch {
if (f == page) {
pagination += '<span class="pagination_element pagination_element_active">' + (f + 1) + "</span>";
} else {
pagination += '<span><a class="tipue_search_foot_box" data-id="' + f * this.show + "_" + replace + '">' + (f + 1) + "</a></span>";
pagination += '<span><a class="tp_search_foot_box" data-id="' + f * this.show + "_" + replace + '">' + (f + 1) + "</a></span>";
}
}
}
@ -427,10 +426,10 @@ class TipueSearch {
var out = "";
if (c != 0) {
if (c == 1) {
out += '<div id="tipue_search_results_count">' + tipuesearch_string_4 + "</div>";
out += '<div id="tp_search_results_count">' + tpsearch_string_4 + "</div>";
} else {
var c_c = c.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
out += '<div id="tipue_search_results_count">' + c_c + " " + tipuesearch_string_5 + "</div>";
out += '<div id="tp_search_results_count">' + c_c + " " + tpsearch_string_5 + "</div>";
}
out += pagination;
@ -467,20 +466,8 @@ class TipueSearch {
}
out += pagination;
} else {
out += '<div id="tipue_search_warning">' + tipuesearch_string_8 + "</div>";
out += '<div id="tp_search_warning">' + tpsearch_string_8 + "</div>";
}
/*} else {
if (show_stop) {
out += '<div id="tipue_search_warning">' + tipuesearch_string_8 + ". " + tipuesearch_string_9 + "</div>";
} else {
out += '<div id="tipue_search_warning">' + tipuesearch_string_10 + "</div>";
if (set.minimumLength == 1) {
out += '<div id="tipue_search_warning">' + tipuesearch_string_11 + "</div>";
} else {
out += '<div id="tipue_search_warning">' + tipuesearch_string_12 + " " + set.minimumLength + " " + tipuesearch_string_13 + "</div>";
}
}
}*/
this.outputBox.innerHTML = out;
show ( this.outputBox );
@ -492,7 +479,7 @@ class TipueSearch {
var id_v = this.children[0].dataset["id"];
var id_a = id_v.split("_");
doTipueSearch(parseInt(id_a[0]), id_a[1]);
doTpSearch(parseInt(id_a[0]), id_a[1]);
}
});
}

@ -0,0 +1,57 @@
/*
tpsearch
Copyright (c) 2020, Stefan Naumann, tp
Licensed under GPL 3.0 or newer
tp Search was originally released under the MIT License
*/
/*
Stop words, in this case English and German
Stop words list from http://www.ranks.nl/stopwords
*/
var tp_stop_words = ["a", "above", "after", "again", "against", "all", "am", "an", "and", "any", "are", "aren't", "as", "at", "be", "because", "been", "before", "being", "below", "between", "both", "but", "by", "can't", "cannot", "could", "couldn't", "did", "didn't", "do", "does", "doesn't", "doing", "don't", "down", "during", "each", "few", "for", "from", "further", "had", "hadn't", "has", "hasn't", "have", "haven't", "having", "he", "he'd", "he'll", "he's", "her", "here", "here's", "hers", "herself", "him", "himself", "his", "how", "how's", "i", "i'd", "i'll", "i'm", "i've", "if", "in", "into", "is", "isn't", "it", "it's", "its", "itself", "let's", "me", "more", "most", "mustn't", "my", "myself", "no", "nor", "not", "of", "off", "on", "once", "only", "or", "other", "ought", "our", "ours", "ourselves", "out", "over", "own", "same", "shan't", "she", "she'd", "she'll", "she's", "should", "shouldn't", "so", "some", "such", "than", "that", "that's", "the", "their", "theirs", "them", "themselves", "then", "there", "there's", "these", "they", "they'd", "they'll", "they're", "they've", "this", "those", "through", "to", "too", "under", "until", "up", "very", "was", "wasn't", "we", "we'd", "we'll", "we're", "we've", "were", "weren't", "what", "what's", "when", "when's", "where", "where's", "which", "while", "who", "who's", "whom", "why", "why's", "with", "won't", "would", "wouldn't", "you", "you'd", "you'll", "you're", "you've", "your", "yours", "yourself", "yourselves",
"aber","als","am","an","auch","auf","aus","bei","bin","bis","bist","da","dadurch","daher","darum","das","daß","dass","dein","deine","dem","den","der","des","dessen","deshalb","die","dies","dieser","dieses","doch","dort","du","durch","ein","eine","einem","einen","einer","eines","er","es","euer","eure","für","hatte","hatten","hattest","hattet","hier","hinter","ich","ihr","ihre","im","in","ist","ja","jede","jedem","jeden","jeder","jedes","jener","jenes","jetzt","kann","kannst","können","könnt","machen","mein","meine","mit","muß","mußt","musst","müssen","müßt","nach","nachdem","nein","nicht","nun","oder","seid","sein","seine","sich","sie","sind","soll","sollen","sollst","sollt","sonst","soweit","sowie","und","unser unsere","unter","vom","von","vor","wann","warum","was","weiter","weitere","wenn","wer","werde","werden","werdet","weshalb","wie","wieder","wieso","wir","wird","wirst","wo","woher","wohin","zu","zum","zur","über" ];
// Word replace
var tpsearch_replace = {'words': [
]};
// Weighting
var tpsearch_weight = {'weight': [
]};
var tpsearch_related = { 'Related' : [
{"search": "testwort", "related": "raspberry pi"},
] };
// Stemming
var tpsearch_stem = {'words': [
]};
// Internal strings
var tpsearch_string_1 = 'Ohne Titel';
var tpsearch_string_2 = 'Zeige Resultate für';
var tpsearch_string_3 = 'Suche stattdessen nach';
var tpsearch_string_4 = '1 Resultat';
var tpsearch_string_5 = 'Resultate';
var tpsearch_string_8 = 'Nichts gefunden';
var tpsearch_string_9 = 'Häufige Worte werden ignoriert';
var tpsearch_string_10 = 'Verwandt';
var tpsearch_string_11 = 'Bitte wenigstens ein Zeichen eingeben';
var tpsearch_string_12 = 'Bitte wenigstens';
var tpsearch_string_13 = 'Zeichen oder mehr eingeben';
var tpsearch_string_14 = 'Sekunden';
var tpsearch_string_15 = 'Bild öffnen';
var tpsearch_string_16 = 'Gehe auf Seite ';
Loading…
Cancel
Save