[enh] add simple theme (WIP)

This commit is contained in:
Alexandre Flament 2017-02-12 15:06:01 +01:00
parent 4f6586d808
commit 10a24bdc2c
85 changed files with 11902 additions and 6 deletions

10
.gitattributes vendored Normal file
View File

@ -0,0 +1,10 @@
searx/static/css/bootstrap.min.css -diff
searx/static/js/bootstrap.min.js -diff
searx/static/themes/oscar/css/logicodev.min.css -diff
searx/static/themes/oscar/css/leaflet.min.css -diff
searx/static/themes/oscar/css/pointhi.min.css -diff
searx/static/themes/oscar/js/searx.min.js -diff
searx/static/themes/simple/css/searx.min.css -diff
searx/static/themes/simple/css/searx-rtl.min.css -diff
searx/static/themes/simple/js/searx.min.js -diff
searx/static/themes/simple/js/searx.min.js.map -diff

View File

@ -13,10 +13,11 @@ python:
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- npm install less grunt-cli
- npm install less less-plugin-clean-css grunt-cli
- ( cd searx/static/themes/oscar;npm install; cd - )
- ( cd searx/static/themes/simple;npm install; cd - )
- mkdir -p ~/drivers; export PATH=~/drivers:$PATH;
- GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz";
- GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/v0.14.0/geckodriver-v0.14.0-linux64.tar.gz";
- FILE=`mktemp`; wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C ~/drivers -f $FILE geckodriver; rm $FILE; chmod 777 ~/drivers/geckodriver;
install:
- ./manage.sh update_dev_packages

View File

@ -22,7 +22,7 @@ check_geckodriver() {
if [ -z $NOTFOUND ]; then
return
fi
GECKODRIVER_VERSION="v0.11.1"
GECKODRIVER_VERSION="v0.14.0"
PLATFORM=`python -c "import platform; print platform.system().lower(), platform.architecture()[0]"`
case $PLATFORM in
"linux 32bit" | "linux2 32bit") ARCH="linux32";;
@ -49,7 +49,7 @@ pep8_check() {
# ignored rules:
# E402 module level import not at top of file
# W503 line break before binary operator
pep8 --max-line-length=120 --ignore "E402,W503" "$SEARX_DIR" "$BASE_DIR/tests"
pep8 --exclude=searx/static --max-line-length=120 --ignore "E402,W503" "$SEARX_DIR" "$BASE_DIR/tests"
}
unit_tests() {
@ -79,7 +79,8 @@ tests() {
}
build_style() {
lessc -x "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
# lessc -x "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
lessc --clean-css="--s1 --advanced --compatibility=ie9" "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
}
styles() {
@ -92,10 +93,13 @@ styles() {
build_style themes/oscar/less/pointhi/oscar.less themes/oscar/css/pointhi.min.css
build_style themes/oscar/less/logicodev/oscar.less themes/oscar/css/logicodev.min.css
build_style themes/pix-art/less/style.less themes/pix-art/css/style.css
build_style themes/simple/less/style.less themes/simple/css/searx.min.css
build_style themes/simple/less/style-rtl.less themes/simple/css/searx-rtl.min.css
}
grunt_build() {
grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js"
grunt --gruntfile "$SEARX_DIR/static/themes/simple/gruntfile.js"
}
locales() {

View File

@ -7,6 +7,7 @@ regex = re.compile(r'10\.\d{4,9}/[^\s]+')
name = gettext('DOAI rewrite')
description = gettext('Avoid paywalls by redirecting to open-access versions of publications when available')
default_on = False
preference_section = 'privacy'
def extract_doi(url):

View File

@ -31,6 +31,7 @@ if sys.version_info[0] == 3:
name = "HTTPS rewrite"
description = gettext('Rewrite HTTP links to HTTPS if possible')
default_on = True
preference_section = 'privacy'
if 'SEARX_HTTPS_REWRITE_PATH' in environ:
rules_path = environ['SEARX_rules_path']

View File

@ -3,6 +3,7 @@ from flask_babel import gettext
name = gettext('Infinite scroll')
description = gettext('Automatically load next page when scrolling to bottom of current page')
default_on = False
preference_section = 'ui'
js_dependencies = ('plugins/js/infinite_scroll.js',)
css_dependencies = ('plugins/css/infinite_scroll.css',)

View File

@ -19,5 +19,6 @@ name = gettext('Search on category select')
description = gettext('Perform search immediately if a category selected. '
'Disable to select multiple categories. (JavaScript required)')
default_on = True
preference_section = 'ui'
js_dependencies = ('plugins/js/search_on_category_select.js',)

View File

@ -26,6 +26,7 @@ regexes = {re.compile(r'utm_[^&]+&?'),
name = gettext('Tracker URL remover')
description = gettext('Remove trackers arguments from the returned URL')
default_on = True
preference_section = 'privacy'
def on_result(request, search, result):

View File

@ -0,0 +1 @@
js/searx_src/autocomplete.js

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,134 @@
/* Generated by grunt-webfont */
@font-face {
font-family:"ion";
src:url("../fonts/ion.eot?94af7082ea096aefe3a7b6642834716e");
src:url("../fonts/ion.eot?#iefix") format("embedded-opentype"),
url("../fonts/ion.woff2?94af7082ea096aefe3a7b6642834716e") format("woff2"),
url("../fonts/ion.woff?94af7082ea096aefe3a7b6642834716e") format("woff"),
url("../fonts/ion.ttf?94af7082ea096aefe3a7b6642834716e") format("truetype"),
url("../fonts/ion.svg?94af7082ea096aefe3a7b6642834716e#ion") format("svg");
font-weight:normal;
font-style:normal;
}
.ion-icon {
font-family:"ion";
display:inline-block;
vertical-align:middle;
line-height:1;
font-weight:normal;
font-style:normal;
speak:none;
text-decoration:inherit;
text-transform:none;
text-rendering:auto;
-webkit-font-smoothing:antialiased;
-moz-osx-font-smoothing:grayscale;
}
/* Icons */
.ion-navicon-round:before {
content:"\f101";
}
.ion-search:before {
content:"\f102";
}
.ion-play:before {
content:"\f103";
}
.ion-link:before {
content:"\f104";
}
.ion-chevron-up:before {
content:"\f105";
}
.ion-chevron-left:before {
content:"\f106";
}
.ion-chevron-right:before {
content:"\f107";
}
.ion-arrow-down-a:before {
content:"\f108";
}
.ion-arrow-up-a:before {
content:"\f109";
}
.ion-arrow-swap:before {
content:"\f10a";
}
.ion-arrow-dropdown:before {
content:"\f10b";
}
.ion-globe:before {
content:"\f10c";
}
.ion-time:before {
content:"\f10d";
}
.ion-location:before {
content:"\f10e";
}
.ion-warning:before {
content:"\f10f";
}
.ion-error:before {
content:"\f110";
}
.ion-film-outline:before {
content:"\f111";
}
.ion-music-note:before {
content:"\f112";
}
.ion-more-vertical:before {
content:"\f113";
}
.ion-magnet:before {
content:"\f114";
}

Binary file not shown.

View File

@ -0,0 +1,261 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ion</title>
<style>
body {
margin:0;
padding:10px 20px;
background:#fff;
color:#222;
}
h1, div, footer {
font-family:"Helvetica Neue", Arial, sans-serif;
}
h1 {
margin:0 0 20px;
font-size:32px;
font-weight:normal;
}
h1 small {
font-size: 0.8em;
padding-left: 2em;
}
.icons {
margin-bottom:40px;
-webkit-column-count:5;
-moz-column-count:5;
column-count:5;
-webkit-column-gap:20px;
-moz-column-gap:20px;
column-gap:20px;
}
.icons__item,
.icons__item i {
line-height:2em;
cursor:pointer;
overflow:hidden;
}
.icons__item:hover {
color:#3c90be;
}
.icons__item i {
display:inline-block;
width:32px;
text-align:center;
}
.icons__item:hover i {
-webkit-transform:scale(1.5);
transform:scale(1.5);
}
footer {
margin-top:40px;
font-size:14px;
color:#999;
}
/* Generated by grunt-webfont */
@font-face {
font-family:"ion";
src:url("ion.eot?94af7082ea096aefe3a7b6642834716e");
src:url("ion.eot?#iefix") format("embedded-opentype"),
url("ion.woff2?94af7082ea096aefe3a7b6642834716e") format("woff2"),
url("ion.woff?94af7082ea096aefe3a7b6642834716e") format("woff"),
url("ion.ttf?94af7082ea096aefe3a7b6642834716e") format("truetype"),
url("ion.svg?94af7082ea096aefe3a7b6642834716e#ion") format("svg");
font-weight:normal;
font-style:normal;
}
.ion-icon {
font-family:"ion";
display:inline-block;
vertical-align:middle;
line-height:1;
font-weight:normal;
font-style:normal;
speak:none;
text-decoration:inherit;
text-transform:none;
text-rendering:auto;
-webkit-font-smoothing:antialiased;
-moz-osx-font-smoothing:grayscale;
}
/* Icons */
.ion-navicon-round:before {
content:"\f101";
}
.ion-search:before {
content:"\f102";
}
.ion-play:before {
content:"\f103";
}
.ion-link:before {
content:"\f104";
}
.ion-chevron-up:before {
content:"\f105";
}
.ion-chevron-left:before {
content:"\f106";
}
.ion-chevron-right:before {
content:"\f107";
}
.ion-arrow-down-a:before {
content:"\f108";
}
.ion-arrow-up-a:before {
content:"\f109";
}
.ion-arrow-swap:before {
content:"\f10a";
}
.ion-arrow-dropdown:before {
content:"\f10b";
}
.ion-globe:before {
content:"\f10c";
}
.ion-time:before {
content:"\f10d";
}
.ion-location:before {
content:"\f10e";
}
.ion-warning:before {
content:"\f10f";
}
.ion-error:before {
content:"\f110";
}
.ion-film-outline:before {
content:"\f111";
}
.ion-music-note:before {
content:"\f112";
}
.ion-more-vertical:before {
content:"\f113";
}
.ion-magnet:before {
content:"\f114";
}
</style>
</head>
<body>
<h1>ion</h1>
<div class="icons" id="icons">
<div class="icons__item" data-name="navicon-round"><i class="ion-icon ion-navicon-round"></i> ion-navicon-round</div>
<div class="icons__item" data-name="search"><i class="ion-icon ion-search"></i> ion-search</div>
<div class="icons__item" data-name="play"><i class="ion-icon ion-play"></i> ion-play</div>
<div class="icons__item" data-name="link"><i class="ion-icon ion-link"></i> ion-link</div>
<div class="icons__item" data-name="chevron-up"><i class="ion-icon ion-chevron-up"></i> ion-chevron-up</div>
<div class="icons__item" data-name="chevron-left"><i class="ion-icon ion-chevron-left"></i> ion-chevron-left</div>
<div class="icons__item" data-name="chevron-right"><i class="ion-icon ion-chevron-right"></i> ion-chevron-right</div>
<div class="icons__item" data-name="arrow-down-a"><i class="ion-icon ion-arrow-down-a"></i> ion-arrow-down-a</div>
<div class="icons__item" data-name="arrow-up-a"><i class="ion-icon ion-arrow-up-a"></i> ion-arrow-up-a</div>
<div class="icons__item" data-name="arrow-swap"><i class="ion-icon ion-arrow-swap"></i> ion-arrow-swap</div>
<div class="icons__item" data-name="arrow-dropdown"><i class="ion-icon ion-arrow-dropdown"></i> ion-arrow-dropdown</div>
<div class="icons__item" data-name="globe"><i class="ion-icon ion-globe"></i> ion-globe</div>
<div class="icons__item" data-name="time"><i class="ion-icon ion-time"></i> ion-time</div>
<div class="icons__item" data-name="location"><i class="ion-icon ion-location"></i> ion-location</div>
<div class="icons__item" data-name="warning"><i class="ion-icon ion-warning"></i> ion-warning</div>
<div class="icons__item" data-name="error"><i class="ion-icon ion-error"></i> ion-error</div>
<div class="icons__item" data-name="film-outline"><i class="ion-icon ion-film-outline"></i> ion-film-outline</div>
<div class="icons__item" data-name="music-note"><i class="ion-icon ion-music-note"></i> ion-music-note</div>
<div class="icons__item" data-name="more-vertical"><i class="ion-icon ion-more-vertical"></i> ion-more-vertical</div>
<div class="icons__item" data-name="magnet"><i class="ion-icon ion-magnet"></i> ion-magnet</div>
</div>
<h1>Usage</h1>
<pre><code>&lt;i class=&quot;ion-icon ion-<span id="name">name</span>&quot;&gt;&lt;/i&gt;</code></pre>
<footer>Generated by <a href="https://github.com/sapegin/grunt-webfont">grunt-webfont</a>.</footer>
<script>
(function() {
document.getElementById('icons').onclick = function(e) {
e = e || window.event;
var name = e.target.getAttribute('data-name') || e.target.parentNode.getAttribute('data-name');
document.getElementById('name').innerHTML = name;
}
})();
</script>
</body>
</html>

View File

@ -0,0 +1,97 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<!--
2017-5-26: Created.
-->
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>
Created by FontForge 20120731 at Fri May 26 22:22:55 2017
By alexandre,,,
</metadata>
<defs>
<font id="ion" horiz-adv-x="512" >
<font-face
font-family="ion"
font-weight="500"
font-stretch="normal"
units-per-em="512"
panose-1="2 0 6 9 0 0 0 0 0 0"
ascent="448"
descent="-64"
bbox="31.9799 -31.9632 479.993 415.9"
underline-thickness="25.6"
underline-position="-51.2"
unicode-range="U+F101-F114"
/>
<missing-glyph />
<glyph glyph-name="arrow-down-a" unicode="&#xf108;"
d="M256.5 -0.5l-192 192h112v192h160v-192h112z" />
<glyph glyph-name="arrow-dropdown" unicode="&#xf10b;"
d="M128 256h256l-128 -128z" />
<glyph glyph-name="arrow-swap" unicode="&#xf10a;"
d="M64 120c0 4.40039 3.59961 7.99999 8 7.99999h248v64l128 -96l-128 -96v64h-248c-4.40039 0 -8 3.59961 -8 8v48zM448 264c0 -4.40039 -3.59961 -8 -8 -8h-248v-64l-128 96l128 96v-64h248c4.40039 0 8 -3.59961 8 -8v-48z" />
<glyph glyph-name="arrow-up-a" unicode="&#xf109;"
d="M256.5 383.5l192 -192h-112v-192h-160v192h-112z" />
<glyph glyph-name="chevron-left" unicode="&#xf106;"
d="M213.7 192l167.2 -174.2c4.19922 -4.2998 4.09961 -11.3994 -0.200195 -15.7998l-29.9004 -30.5996c-4.2998 -4.40039 -11.2998 -4.5 -15.5 -0.200191l-204.2 212.7c-2.09961 2.19922 -3.09961 5.09961 -3 8.09961c-0.199219 2.90039 0.800781 5.90039 3 8.09961
l204.2 212.601c4.2002 4.2998 11.2002 4.2002 15.5 -0.200195l29.9004 -30.5996c4.2998 -4.40039 4.39941 -11.5 0.200195 -15.8008l-167.2 -174.1v0v0z" />
<glyph glyph-name="chevron-right" unicode="&#xf107;"
d="M298.3 192v0v0l-167.2 174.1c-4.19922 4.30078 -4.09961 11.4004 0.200195 15.8008l29.9004 30.5996c4.2998 4.40039 11.2998 4.5 15.5 0.200195l204.2 -212.7c2.19922 -2.2002 3.19922 -5.2002 3 -8.09961c0.0996094 -3 -0.900391 -5.90039 -3 -8.10059l-204.2 -212.6
c-4.2002 -4.29981 -11.2002 -4.2002 -15.5 0.200191l-29.9004 30.5996c-4.2998 4.40039 -4.39941 11.5 -0.200195 15.7998z" />
<glyph glyph-name="chevron-up" unicode="&#xf105;"
d="M256 234.3l-174.2 -167.2c-4.2998 -4.19922 -11.3994 -4.09961 -15.7998 0.200195l-30.5996 29.9004c-4.40039 4.2998 -4.5 11.2998 -0.200195 15.5l212.7 204.2c2.19922 2.09961 5.09961 3.09961 8.09961 3c2.90039 0.199219 5.90039 -0.800781 8.09961 -3l212.7 -204.2
c4.2998 -4.2002 4.20016 -11.2002 -0.200226 -15.5l-30.5996 -29.9004c-4.40039 -4.2998 -11.5 -4.39941 -15.7998 -0.200195l-174.2 167.2v0v0z" />
<glyph glyph-name="error" unicode="&#xf110;"
d="M256 400c114.4 0 208 -93.6006 208 -208c0 -114.399 -93.5996 -208 -208 -208s-208 93.6006 -208 208c0 114.399 93.5996 208 208 208zM280 88v40h-48v-40h48zM280 176v128h-48v-128h48z" />
<glyph glyph-name="film-outline" unicode="&#xf111;"
d="M56 360h400v-336h-400v336zM128 40v48h-56v-48h56zM128 104v48h-56v-48h56zM128 168v48h-56v-48h56zM128 232v48h-56v-48h56zM128 296v48h-56v-48h56zM368 40v144h-224v-144h224zM368 200v144h-224v-144h224zM440 40v48h-56v-48h56zM440 104v48h-56v-48h56zM440 168v48
h-56v-48h56zM440 232v48h-56v-48h56zM440 296v48h-56v-48h56z" />
<glyph glyph-name="globe" unicode="&#xf10c;"
d="M256 400c114.875 0 208 -93.125 208 -208c0 -114.875 -93.125 -208 -208 -208c-114.876 0 -208 93.125 -208 208c0 114.875 93.124 208 208 208zM234.451 15.001c6.04297 15.0449 19.9453 28.6484 7.27342 39.1172c-8.17285 6.75 -15.6123 13.6279 -23.1104 21.125
c-2.47461 2.47363 -9.9082 19.7109 -8.35156 22.3916c5.10254 8.78613 5.76367 14.8613 8.12988 24.7236c2.94336 12.2627 -3.33398 15.4434 -13.3828 21.8389c-15.2256 9.68848 -28.9629 22.4844 -43.3223 33.4941c-7.11621 5.45508 -17.4355 10.0986 -20.0186 18.9521
c-2.64062 9.05078 -3.97363 20.2598 -9.40039 28.0781c-13.9277 20.0752 -11.5791 34.9678 -9.93945 58.7627c0.449219 6.52637 -1.30371 15.6572 -2.01367 24.1748c-27.5654 -32.2354 -42.6016 -72.7891 -42.6016 -115.659c0 -47.6221 18.5439 -92.3926 52.2178 -126.067
c28.541 -28.54 65.0557 -46.2061 104.52 -50.9316zM382.067 65.9326c23.0352 23.0381 38.9873 51.2695 46.7686 82.0527c-8.34668 -1.19141 -18.3838 2.22754 -18.3838 2.22754s-21.7363 23.707 -23.5244 44.5723c-1.85645 21.667 0.498047 38.3945 -2.89551 56.8105
c-2.87988 15.624 -19.2803 31.5 -26.6729 46.3018c-6.92188 13.8555 -13.7334 27.7031 -20.2646 41.7451c2.25098 -0.848633 4.90039 -1.40234 6.96484 -2.62305c4.99902 0.636719 9.43066 1.22949 13.4629 1.59082c-22.5381 15.6758 -48.2725 25.8418 -75.5225 29.7998
v-8.33887l3.55273 -9.27734l-13.7793 -12.9951l-8.6748 2.79492l-9.92383 10.2334l-9.94434 11.8008l-14.084 5.66016c-15.7227 -2.36133 -30.9336 -6.78711 -45.3096 -13.1523c0.360352 -2.30762 0.662109 -4.64453 0.662109 -7.13281
c7.17383 2.98926 15.2764 5.04883 22.4502 8.03906c2.96289 1.23438 12.7529 -7.1748 15.6221 -8.96777c-4.0957 -4.70996 -20.5576 -15.4434 -21.3574 -21.3574c-0.317383 -2.33984 6.50586 -6.06348 6.45117 -9.69141
c-0.0878906 -5.74609 -0.173828 -11.4912 -0.259766 -17.2373c3.24414 2.76172 20.0332 20.3672 21.9404 20.8594c12.7256 3.2832 34.3916 -17.7646 36.249 -25.1934c1.8584 -7.42871 -21.6514 -23.6826 -32.6113 -34.0469
c-8.39941 -7.94434 -24.8086 -12.5137 -19.8037 -24.2285c1.62695 -3.80957 10.0498 -20.0156 5.21191 -24.0586c-5.92188 -4.94824 -14.7686 8.97656 -17.3418 12.0938c-8.1543 9.87695 -25.626 6.02539 -37.9082 6.47852c0 -17.4209 -0.757812 -31.1885 14.9219 -42.9971
c15.1953 -11.4434 29.5977 -24.7061 47.0781 -32.3389c12.7637 -5.57129 35.7158 6.53613 47.0205 -1.41699c15.8672 -11.165 29.3066 -21.624 47.1611 -29.375c7.93359 -3.44531 32.418 -19.8828 25.3525 -30.7812c-4.96582 -7.66211 -9.87305 -14.8848 -13.5771 -23.2168
c-3.70703 -8.34375 -12.5957 -18.876 -19.6924 -24.3525c-8.15918 -6.29199 -16.9551 -17.1455 -21.8955 -29.3623c34.8574 6.5957 66.9229 23.4482 92.5566 49.0811z" />
<glyph glyph-name="link" unicode="&#xf104;"
d="M256.5 240h-0.5v0h0.5zM368.5 288c44.2002 0 79.5 -35.2998 79.5 -79.5v-32c0 -44.2002 -35.2998 -80.5 -79.5 -80.5h-112c-32.7002 0 -61 19.7998 -73.5996 48c-4.40039 10 -6.90039 21 -6.90039 32.5v31.5h48v-31.5c0 -17.5996 14.9004 -32.5 32.5 -32.5h112
c17.5996 0 31.5 14.9004 31.5 32.5v32c0 17.5996 -13.9004 31.5 -31.5 31.5h-0.5h-16.4004c-5.59961 31 -31.5996 48 -31.5996 48h48.5zM329.6 240c4.10059 -9.59961 6.40039 -20.2998 6.40039 -31.5v-32v-0.5h-48v0.5v32c0 17.5996 -13.9004 31.5 -31.5 31.5h-0.5h-111.5
c-17.5996 0 -32.5 -13.9004 -32.5 -31.5v-32c0 -17.5996 14.9004 -32.5 32.5 -32.5h15.4004c6.2998 -31 32.0996 -48 32.0996 -48h-47.5c-44.2002 0 -80.5 36.2998 -80.5 80.5v32c0 44.2002 36.2998 79.5 80.5 79.5h112c33 0 61 -19.7002 73.0996 -48z" />
<glyph glyph-name="location" unicode="&#xf10e;"
d="M256 384c65.9004 0 119.3 -53.7002 119.3 -120c0 -114.6 -119.3 -264 -119.3 -264s-119.3 149.4 -119.3 264c0 66.2998 53.3994 120 119.3 120zM256 205.8c31.2002 0 56.4004 25.4004 56.4004 56.7002c0 31.4004 -25.2002 56.7998 -56.4004 56.7998
c-31.0996 0 -56.4004 -25.5 -56.4004 -56.7998s25.2002 -56.7002 56.4004 -56.7002z" />
<glyph glyph-name="magnet" unicode="&#xf114;"
d="M270.208 177.19h0.0126953v87.8721c0.345703 4.8125 -3.85254 22.8994 -14.0674 35.1738c-10.4697 12.5312 -23.6543 22.3496 -51.3662 22.7588c-27.7246 -0.396484 -40.8955 -10.2275 -51.3789 -22.7588c-10.1895 -12.2744 -14.4131 -30.3486 -14.0674 -35.1738
v-87.8848h-64v87.8848c0.371094 21.8369 7.83398 48.7422 27.8271 74.7773c19.6865 25.7666 55.2188 47.6035 101.645 47.207c46.3877 0.421875 81.9199 -21.415 101.619 -47.1943c19.9941 -26.0352 27.4434 -52.9277 27.8018 -74.7646v-87.8975h-64.0254zM334.233 99.3789
h0.0253906l-64.0508 -0.0126953v65.0244h64.0254v-65.0117zM75.3408 99.3662v65.0244h64v-65.0244h-64z" />
<glyph glyph-name="more-vertical" unicode="&#xf113;"
d="M296 312c0 -22.002 -17.998 -40 -40 -40s-40 17.998 -40 40s17.998 40 40 40s40 -17.998 40 -40zM296 72c0 -22.002 -17.998 -40 -40 -40s-40 17.998 -40 40s17.998 40 40 40s40 -17.998 40 -40zM296 192c0 -22.002 -17.998 -40 -40 -40s-40 17.998 -40 40
s17.998 40 40 40s40 -17.998 40 -40z" />
<glyph glyph-name="music-note" unicode="&#xf112;"
d="M426 415.9c12.0996 0 22 -9.5 22.0996 -21.2002v-302.8c0 -24.7002 -3 -42.9004 -12 -54.9004h-0.199219c-9.10059 -15 -25 -21 -43.2002 -21h-37.2002c-28.2998 0 -51.2002 19.9004 -51.2002 48s22.9004 48 51.2002 48h60.5v192l-208 -38v-232
c0 -8.2998 -3.40039 -27 -13 -41.0996c-1 -1.80078 -2.09961 -3.40039 -3.40039 -5c-0.5 -0.600586 -0.899414 -1.5 -1.5 -2.10059c-0.0996094 -0.0996094 -0.299805 -0.0996103 -0.399414 -0.200196c-9.40039 -10.5996 -23 -17.5 -38.2998 -17.5h-36.2002
c-28.2002 0 -51.2998 20 -51.2998 48s23.0996 48 51.0996 48v-0.0996094h61v286.5c1 14.5 13.5 27.9004 27.2998 31.5996l217.601 33.2002s2.89941 0.600586 5.09961 0.600586z" />
<glyph glyph-name="navicon-round" unicode="&#xf101;"
d="M417.4 224c16.8994 0 30.5996 -14.2998 30.5996 -32s-13.7002 -32 -30.5996 -32h-322.801c-16.8994 0 -30.5996 14.2998 -30.5996 32s13.7002 32 30.5996 32h322.801zM417.4 352c16.8994 0 30.5996 -14.2998 30.5996 -32s-13.7002 -32 -30.5996 -32h-322.801
c-16.8994 0 -30.5996 14.2998 -30.5996 32s13.7002 32 30.5996 32h322.801zM417.4 96c16.8994 0 30.5996 -14.2998 30.5996 -32s-13.7002 -32 -30.5996 -32h-322.801c-16.8994 0 -30.5996 14.2998 -30.5996 32s13.7002 32 30.5996 32h322.801z" />
<glyph glyph-name="play" unicode="&#xf103;"
d="M405.2 215.1c6.59961 -5.59961 10.7998 -13.7998 10.7998 -23.0996s-4.2002 -17.5996 -10.7998 -23.0996l-278.101 -165.5c-3.69922 -2 -7.09962 -3.40039 -11.1992 -3.40039c-10.9004 0 -19.8008 9 -19.8008 20h-0.0996094v344h0.0996094c0 11 8.90039 20 19.8008 20
c4 0 7.49999 -1.2002 10.8994 -3.2002z" />
<glyph glyph-name="search" unicode="&#xf102;"
d="M445 61.2998c4 -4 4 -10.3994 0 -14.5l-43.2998 -43.7998c-1.90039 -2 -4.60059 -3.09961 -7.2998 -3.09961c-2.7002 0 -5.40039 1.19922 -7.30078 3.09961l-84.3994 85.5996c-24.6006 -14.6992 -52.2002 -22.3994 -80.1006 -22.3994
c-87.3994 0 -158.6 71.2998 -158.6 158.899c0 87.6006 71.2002 158.9 158.6 158.9c87.4004 0 158.601 -71.2998 158.601 -158.9c0 -27 -7.2002 -53.7998 -21 -77.8994zM222.6 322.1c-53.3994 0 -96.7998 -43.5 -96.7998 -97s43.4004 -97 96.7998 -97
c53.4004 0 96.8008 43.5 96.8008 97s-43.4004 97 -96.8008 97z" />
<glyph glyph-name="time" unicode="&#xf10d;"
d="M256 405c117.149 0 213 -95.8506 213 -213c0 -117.149 -94.7891 -213 -213 -213s-213 95.8506 -213 213c0 117.149 94.7891 213 213 213zM256 21.5996c93.7178 0 170.4 76.6826 170.4 170.4s-76.6826 170.4 -170.4 170.4s-170.4 -76.6836 -170.4 -170.4
s76.6826 -170.4 170.4 -170.4zM266.65 298.5v-111.824l95.8496 -56.4434l-15.9746 -26.625l-111.825 67.0928v127.8h31.9502z" />
<glyph glyph-name="warning" unicode="&#xf10f;"
d="M476.7 25.7998c2.7998 -4.89941 4.7998 -13 1.7998 -17.8994c-2.90039 -4.90039 -8.20016 -7.90039 -14 -7.90039h-417.1c-5.80078 0 -11.1006 3 -14 7.90039c-2.90039 4.89941 -0.900391 12.8994 1.89941 17.8994l206.601 349.5c2.7998 5 8.1992 8.7002 14.0996 8.7002
c5.7998 0 11.2002 -3.7002 14.0996 -8.7002zM288 48v48h-64v-48h64zM288 128v144h-64v-144h64z" />
</font>
</defs></svg>

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,150 @@
module.exports = function(grunt) {
const path = require('path');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
scripts: {
files: ['<%= jshint.files %>', 'less/*.less'],
tasks: ['jshint', 'concat', 'uglify', 'webfont', 'less:development', 'less:production']
}
},
concat: {
options: {
separator: ';'
},
dist: {
src: ['js/searx_src/*.js'],
dest: 'js/searx.js'
}
},
uglify: {
options: {
banner: '/*! simple/searx.min.js | <%= grunt.template.today("dd-mm-yyyy") %> | https://github.com/asciimoo/searx */\n',
preserveComments: 'some',
sourceMap: true
},
dist: {
files: {
'js/searx.min.js': ['<%= concat.dist.dest %>']
}
}
},
jshint: {
files: ['js/searx_src/*.js'],
options: {
proto: true,
// options here to override JSHint defaults
globals: {
browser: true,
jQuery: false,
devel: true
}
}
},
less: {
development: {
options: {
paths: ["less"],
banner: '/*! searx | <%= grunt.template.today("dd-mm-yyyy") %> | https://github.com/asciimoo/searx */\n'
},
files: {
"css/searx.css": "less/style.less",
"css/searx-rtl.css": "less/style-rtl.less"
}
},
production: {
options: {
paths: ["less"],
plugins: [
new (require('less-plugin-clean-css'))({
advanced: true,
compatibility: 'ie8'
})
],
banner: '/*! searx | <%= grunt.template.today("dd-mm-yyyy") %> | https://github.com/asciimoo/searx */\n'
},
files: {
"css/searx.min.css": "less/style.less",
"css/searx-rtl.min.css": "less/style-rtl.less"
}
},
},
webfont: {
icons: {
// src: 'node_modules/ionicons-npm/src/*.svg',
src: [
'node_modules/ionicons-npm/src/navicon-round.svg',
'node_modules/ionicons-npm/src/search.svg',
'node_modules/ionicons-npm/src/play.svg',
'node_modules/ionicons-npm/src/link.svg',
'node_modules/ionicons-npm/src/chevron-up.svg',
'node_modules/ionicons-npm/src/chevron-left.svg',
'node_modules/ionicons-npm/src/chevron-right.svg',
'node_modules/ionicons-npm/src/arrow-down-a.svg',
'node_modules/ionicons-npm/src/arrow-up-a.svg',
'node_modules/ionicons-npm/src/arrow-swap.svg',
'node_modules/ionicons-npm/src/telephone.svg',
'node_modules/ionicons-npm/src/android-arrow-dropdown.svg',
'node_modules/ionicons-npm/src/android-globe.svg',
'node_modules/ionicons-npm/src/android-time.svg',
'node_modules/ionicons-npm/src/location.svg',
'node_modules/ionicons-npm/src/alert-circled.svg',
'node_modules/ionicons-npm/src/android-alert.svg',
'node_modules/ionicons-npm/src/ios-film-outline.svg',
'node_modules/ionicons-npm/src/music-note.svg',
'node_modules/ionicons-npm/src/ion-close-round.svg',
'node_modules/ionicons-npm/src/android-more-vertical.svg',
'magnet.svg'
],
dest: 'fonts',
destLess: 'less',
options: {
font: 'ion',
hashes : true,
syntax: 'bem',
styles : 'font,icon',
types : 'eot,woff2,woff,ttf,svg',
order : 'eot,woff2,woff,ttf,svg',
stylesheets : ['css', 'less'],
relativeFontPath : '../fonts/',
autoHint : false,
normalize : false,
// ligatures : true,
optimize : true,
// fontHeight : 400,
rename : function(name) {
basename = path.basename(name);
if (basename === 'android-alert.svg') {
return 'error.svg';
}
if (basename === 'alert-circled.svg') {
return 'warning.svg';
}
if (basename === 'ion-close-round.svg') {
return 'close.svg';
}
return basename.replace(/(ios|md|android)-/i, '');
},
templateOptions: {
baseClass: 'ion-icon',
classPrefix: 'ion-'
}
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-webfont');
grunt.registerTask('test', ['jshint']);
grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'less:development', 'less:production']);
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,203 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="744.09448819"
height="1052.3622047"
id="svg2"
version="1.1"
inkscape:version="0.48.4 r9939"
sodipodi:docname="searx_logo.svg"
inkscape:export-filename="/home/a/magnif.png"
inkscape:export-xdpi="203.1774"
inkscape:export-ydpi="203.1774">
<defs
id="defs4">
<linearGradient
inkscape:collect="always"
id="linearGradient3857">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop3859" />
<stop
style="stop-color:#ffffff;stop-opacity:0;"
offset="1"
id="stop3861" />
</linearGradient>
<linearGradient
id="linearGradient3790">
<stop
style="stop-color:#a9a9a9;stop-opacity:1;"
offset="0"
id="stop3792" />
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="1"
id="stop3794" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3790"
id="radialGradient3798"
cx="294.45947"
cy="208.37973"
fx="294.45947"
fy="208.37973"
r="107.58125"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3857"
id="linearGradient3865"
x1="120.68947"
y1="239.61774"
x2="120.68947"
y2="602.17517"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3790"
id="linearGradient3912"
x1="186.74416"
y1="354.42426"
x2="255.84358"
y2="254.35953"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.2227304,0,0,0.89945099,-289.31433,113.40259)" />
<filter
inkscape:collect="always"
id="filter4024"
x="-0.12996517"
width="1.2599303"
y="-0.14709377"
height="1.2941875">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="6.4759344"
id="feGaussianBlur4026" />
</filter>
<filter
inkscape:collect="always"
id="filter3983"
x="-1.0608404"
width="3.1216809"
y="-0.31017202"
height="1.620344">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="9.392858"
id="feGaussianBlur3985" />
</filter>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.979899"
inkscape:cx="30.708726"
inkscape:cy="948.08556"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1364"
inkscape:window-height="663"
inkscape:window-x="0"
inkscape:window-y="30"
inkscape:window-maximized="0"
showguides="true"
inkscape:guide-bbox="true" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 70.523181,34.870671 c -7.11959,15.242893 -10.17798,31.779192 -8.22563,48.814566 5.01677,43.774133 41.675309,79.324503 91.536109,95.162893 -6.62576,-22.40752 -5.34093,-44.9362 2.6395,-65.84431 C 108.73618,98.821131 74.828141,70.195435 70.523181,34.870671 z"
id="path3814-0-7"
inkscape:connector-curvature="0" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 303.77876,36.21406 c 7.11959,15.242893 10.17798,31.779192 8.22563,48.814566 -5.01677,43.774134 -41.67531,79.324504 -91.53611,95.162894 6.62576,-22.40752 5.34093,-44.9362 -2.6395,-65.84431 47.73698,-14.18269 81.64502,-42.808386 85.94998,-78.13315 z"
id="path3814-0"
inkscape:connector-curvature="0" />
<path
transform="matrix(0.6556593,-0.75505688,0.75505688,0.6556593,0,0)"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m -5.0905523,259.06055 18.4167573,0 c 6.220455,0 11.228257,16.68196 11.228257,37.40349 l 0,172.83701 c 0,20.72153 -5.007802,37.40349 -11.228257,37.40349 l -18.4167573,0 c -6.2204547,0 -11.2282577,-16.68196 -11.2282577,-37.40349 l 0,-172.83701 c 0,-20.72153 5.007803,-37.40349 11.2282577,-37.40349 z"
id="rect3804" />
<path
sodipodi:type="arc"
style="fill:url(#radialGradient3798);fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path2987"
sodipodi:cx="294.45947"
sodipodi:cy="208.37973"
sodipodi:rx="107.58125"
sodipodi:ry="107.58125"
d="m 402.04073,208.37973 a 107.58125,107.58125 0 1 1 -215.16251,0 107.58125,107.58125 0 1 1 215.16251,0 z"
transform="translate(-107.07617,-60.609153)" />
<path
sodipodi:type="arc"
style="fill:url(#linearGradient3865);fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path3757"
sodipodi:cx="131.82491"
sodipodi:cy="299.29346"
sodipodi:rx="101.52033"
sodipodi:ry="101.52033"
d="m 233.34524,299.29346 a 101.52033,101.52033 0 1 1 -203.040667,0 101.52033,101.52033 0 1 1 203.040667,0 z"
transform="matrix(0.76865672,0,0,0.76865672,85.80266,-82.535889)" />
<path
sodipodi:type="arc"
style="fill:#1a1a1a;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path3800"
sodipodi:cx="183.34268"
sodipodi:cy="156.35687"
sodipodi:rx="27.274118"
sodipodi:ry="27.274118"
d="m 210.6168,156.35687 a 27.274118,27.274118 0 1 1 -54.54824,0 27.274118,27.274118 0 1 1 54.54824,0 z"
transform="translate(5,-7.1428572)" />
<path
sodipodi:type="arc"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path3802"
sodipodi:cx="197.9899"
sodipodi:cy="203.32896"
sodipodi:rx="5.5558391"
sodipodi:ry="5.5558391"
d="m 203.54574,203.32896 a 5.5558391,5.5558391 0 1 1 -11.11168,0 5.5558391,5.5558391 0 1 1 11.11168,0 z"
transform="translate(1.4847712,-63.564549)" />
<rect
style="fill:#ffffff;fill-opacity:0.82211531000000004;fill-rule:nonzero;stroke:none;filter:url(#filter4024)"
id="rect3916"
width="2.2392972"
height="159.43797"
x="19.525793"
y="337.8396"
rx="2.8666623"
ry="9.0007057"
transform="matrix(0.74466525,-0.84318084,0.84318084,0.74466525,-35.543204,-26.349917)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.1 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,155 @@
/**
* searx is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* searx is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with searx. If not, see < http://www.gnu.org/licenses/ >.
*
* (C) 2017 by Alexandre Flament, <alex@al-f.net>
*
*/
(function(w, d, searx) {
'use strict';
// not invented here tookit with bugs fixed elsewhere
// purposes : be just good enough and as small as possible
// from https://plainjs.com/javascript/events/live-binding-event-handlers-14/
if (w.Element) {
(function(ElementPrototype) {
ElementPrototype.matches = ElementPrototype.matches ||
ElementPrototype.matchesSelector ||
ElementPrototype.webkitMatchesSelector ||
ElementPrototype.msMatchesSelector ||
function(selector) {
var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1;
while (nodes[++i] && nodes[i] != node);
return !!nodes[i];
};
})(Element.prototype);
}
function callbackSafe(callback, el, e) {
try {
callback.call(el, e);
} catch (exception) {
console.log(exception);
}
}
searx = searx || {};
searx.on = function(obj, eventType, callback, useCapture) {
useCapture = useCapture || false;
if (typeof obj !== 'string') {
// obj HTMLElement, HTMLDocument
obj.addEventListener(eventType, callback, useCapture);
} else {
// obj is a selector
d.addEventListener(eventType, function(e) {
var el = e.target || e.srcElement, found = false;
while (el && el.matches && el !== d && !(found = el.matches(obj))) el = el.parentElement;
if (found) callbackSafe(callback, el, e);
}, useCapture);
}
};
searx.ready = function(callback) {
if (document.readyState != 'loading') {
callback.call(w);
} else {
w.addEventListener('DOMContentLoaded', callback.bind(w));
}
};
searx.http = function(method, url, callback) {
var req = new XMLHttpRequest(),
resolve = function() {},
reject = function() {},
promise = {
then: function(callback) { resolve = callback; return promise; },
catch: function(callback) { reject = callback; return promise; }
};
try {
req.open(method, url, true);
// On load
req.onload = function() {
if (req.status == 200) {
resolve(req.response, req.responseType);
} else {
reject(Error(req.statusText));
}
};
// Handle network errors
req.onerror = function() {
reject(Error("Network Error"));
};
req.onabort = function() {
reject(Error("Transaction is aborted"));
};
// Make the request
req.send();
} catch (ex) {
reject(ex);
}
return promise;
};
searx.loadStyle = function(src) {
var path = searx.staticPath + src,
id = "style_" + src.replace('.', '_'),
s = d.getElementById(id);
if (s === null) {
s = d.createElement('link');
s.setAttribute('id', id);
s.setAttribute('rel', 'stylesheet');
s.setAttribute('type', 'text/css');
s.setAttribute('href', path);
d.body.appendChild(s);
}
};
searx.loadScript = function(src, callback) {
var path = searx.staticPath + src,
id = "script_" + src.replace('.', '_'),
s = d.getElementById(id);
if (s === null) {
s = d.createElement('script');
s.setAttribute('id', id);
s.setAttribute('src', path);
s.onload = callback;
s.onerror = function() {
s.setAttribute('error', '1');
};
d.body.appendChild(s);
} else if (!s.hasAttribute('error')) {
try {
callback.apply(s, []);
} catch (exception) {
console.log(exception);
}
} else {
console.log("callback not executed : script '" + path + "' not loaded.");
}
};
searx.on('.close', 'click', function(e) {
var el = e.target || e.srcElement;
this.parentNode.style.display="None";
});
return searx;
})(window, document, window.searx);

View File

@ -0,0 +1,536 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.AutoComplete = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/*
* @license MIT
*
* Autocomplete.js v2.6.3
* Developed by Baptiste Donaux
* http://autocomplete-js.com
*
* (c) 2017, Baptiste Donaux
*/
"use strict";
var ConditionOperator;
(function (ConditionOperator) {
ConditionOperator[ConditionOperator["AND"] = 0] = "AND";
ConditionOperator[ConditionOperator["OR"] = 1] = "OR";
})(ConditionOperator || (ConditionOperator = {}));
var EventType;
(function (EventType) {
EventType[EventType["KEYDOWN"] = 0] = "KEYDOWN";
EventType[EventType["KEYUP"] = 1] = "KEYUP";
})(EventType || (EventType = {}));
/**
* Core
*
* @class
* @author Baptiste Donaux <baptiste.donaux@gmail.com> @baptistedonaux
*/
var AutoComplete = (function () {
// Constructor
function AutoComplete(params, selector) {
if (params === void 0) { params = {}; }
if (selector === void 0) { selector = "[data-autocomplete]"; }
if (Array.isArray(selector)) {
selector.forEach(function (s) {
new AutoComplete(params, s);
});
}
else if (typeof selector == "string") {
var elements = document.querySelectorAll(selector);
Array.prototype.forEach.call(elements, function (input) {
new AutoComplete(params, input);
});
}
else {
var specificParams = AutoComplete.merge(AutoComplete.defaults, params, {
DOMResults: document.createElement("div")
});
AutoComplete.prototype.create(specificParams, selector);
return specificParams;
}
}
AutoComplete.prototype.create = function (params, element) {
params.Input = element;
if (params.Input.nodeName.match(/^INPUT$/i) && (params.Input.hasAttribute("type") === false || params.Input.getAttribute("type").match(/^TEXT|SEARCH$/i))) {
params.Input.setAttribute("autocomplete", "off");
params._Position(params);
params.Input.parentNode.appendChild(params.DOMResults);
params.$Listeners = {
blur: params._Blur.bind(params),
destroy: AutoComplete.prototype.destroy.bind(null, params),
focus: params._Focus.bind(params),
keyup: AutoComplete.prototype.event.bind(null, params, EventType.KEYUP),
keydown: AutoComplete.prototype.event.bind(null, params, EventType.KEYDOWN),
position: params._Position.bind(params)
};
for (var event in params.$Listeners) {
params.Input.addEventListener(event, params.$Listeners[event]);
}
}
};
AutoComplete.prototype.getEventsByType = function (params, type) {
var mappings = {};
for (var key in params.KeyboardMappings) {
var event = EventType.KEYUP;
if (params.KeyboardMappings[key].Event !== undefined) {
event = params.KeyboardMappings[key].Event;
}
if (event == type) {
mappings[key] = params.KeyboardMappings[key];
}
}
return mappings;
};
AutoComplete.prototype.event = function (params, type, event) {
var eventIdentifier = function (condition) {
if ((match === true && mapping.Operator == ConditionOperator.AND) || (match === false && mapping.Operator == ConditionOperator.OR)) {
condition = AutoComplete.merge({
Not: false
}, condition);
if (condition.hasOwnProperty("Is")) {
if (condition.Is == event.keyCode) {
match = !condition.Not;
}
else {
match = condition.Not;
}
}
else if (condition.hasOwnProperty("From") && condition.hasOwnProperty("To")) {
if (event.keyCode >= condition.From && event.keyCode <= condition.To) {
match = !condition.Not;
}
else {
match = condition.Not;
}
}
}
};
for (var name in AutoComplete.prototype.getEventsByType(params, type)) {
var mapping = AutoComplete.merge({
Operator: ConditionOperator.AND
}, params.KeyboardMappings[name]), match = ConditionOperator.AND == mapping.Operator;
mapping.Conditions.forEach(eventIdentifier);
if (match === true) {
mapping.Callback.call(params, event);
}
}
};
AutoComplete.prototype.makeRequest = function (params, callback) {
var propertyHttpHeaders = Object.getOwnPropertyNames(params.HttpHeaders), request = new XMLHttpRequest(), method = params._HttpMethod(), url = params._Url(), queryParams = params._Pre(), queryParamsStringify = encodeURIComponent(params._QueryArg()) + "=" + encodeURIComponent(queryParams);
if (method.match(/^GET$/i)) {
if (url.indexOf("?") !== -1) {
url += "&" + queryParamsStringify;
}
else {
url += "?" + queryParamsStringify;
}
}
request.open(method, url, true);
for (var i = propertyHttpHeaders.length - 1; i >= 0; i--) {
request.setRequestHeader(propertyHttpHeaders[i], params.HttpHeaders[propertyHttpHeaders[i]]);
}
request.onreadystatechange = function () {
if (request.readyState == 4 && request.status == 200) {
params.$Cache[queryParams] = request.response;
callback(request.response);
}
};
return request;
};
AutoComplete.prototype.ajax = function (params, request, timeout) {
if (timeout === void 0) { timeout = true; }
if (params.$AjaxTimer) {
window.clearTimeout(params.$AjaxTimer);
}
if (timeout === true) {
params.$AjaxTimer = window.setTimeout(AutoComplete.prototype.ajax.bind(null, params, request, false), params.Delay);
}
else {
if (params.Request) {
params.Request.abort();
}
params.Request = request;
params.Request.send(params._QueryArg() + "=" + params._Pre());
}
};
AutoComplete.prototype.cache = function (params, callback) {
var response = params._Cache(params._Pre());
if (response === undefined) {
var request = AutoComplete.prototype.makeRequest(params, callback);
AutoComplete.prototype.ajax(params, request);
}
else {
callback(response);
}
};
AutoComplete.prototype.destroy = function (params) {
for (var event in params.$Listeners) {
params.Input.removeEventListener(event, params.$Listeners[event]);
}
params.DOMResults.parentNode.removeChild(params.DOMResults);
};
return AutoComplete;
}());
AutoComplete.merge = function () {
var merge = {}, tmp;
for (var i = 0; i < arguments.length; i++) {
for (tmp in arguments[i]) {
merge[tmp] = arguments[i][tmp];
}
}
return merge;
};
AutoComplete.defaults = {
Delay: 150,
EmptyMessage: "No result here",
Highlight: {
getRegex: function (value) {
return new RegExp(value, "ig");
},
transform: function (value) {
return "<strong>" + value + "</strong>";
}
},
HttpHeaders: {
"Content-type": "application/x-www-form-urlencoded"
},
Limit: 0,
MinChars: 0,
HttpMethod: "GET",
QueryArg: "q",
Url: null,
KeyboardMappings: {
"Enter": {
Conditions: [{
Is: 13,
Not: false
}],
Callback: function (event) {
if (this.DOMResults.getAttribute("class").indexOf("open") != -1) {
var liActive = this.DOMResults.querySelector("li.active");
if (liActive !== null) {
event.preventDefault();
this._Select(liActive);
this.DOMResults.setAttribute("class", "autocomplete");
}
}
},
Operator: ConditionOperator.AND,
Event: EventType.KEYDOWN
},
"KeyUpAndDown_down": {
Conditions: [{
Is: 38,
Not: false
},
{
Is: 40,
Not: false
}],
Callback: function (event) {
event.preventDefault();
},
Operator: ConditionOperator.OR,
Event: EventType.KEYDOWN
},
"KeyUpAndDown_up": {
Conditions: [{
Is: 38,
Not: false
},
{
Is: 40,
Not: false
}],
Callback: function (event) {
event.preventDefault();
var first = this.DOMResults.querySelector("li:first-child:not(.locked)"), last = this.DOMResults.querySelector("li:last-child:not(.locked)"), active = this.DOMResults.querySelector("li.active");
if (active) {
var currentIndex = Array.prototype.indexOf.call(active.parentNode.children, active), position = currentIndex + (event.keyCode - 39), lisCount = this.DOMResults.getElementsByTagName("li").length;
if (position < 0) {
position = lisCount - 1;
}
else if (position >= lisCount) {
position = 0;
}
active.classList.remove("active");
active.parentElement.children.item(position).classList.add("active");
}
else if (last && event.keyCode == 38) {
last.classList.add("active");
}
else if (first) {
first.classList.add("active");
}
},
Operator: ConditionOperator.OR,
Event: EventType.KEYUP
},
"AlphaNum": {
Conditions: [{
Is: 13,