commit: e181041f11f612937299d440ccb090d3a78cf740
parent d740e7384a95c6a7d80e5f492f4dd7edb312175e
Author: Cqoicebordel <Cqoicebordel@users.noreply.github.com>
Date: Tue, 17 Feb 2015 01:07:14 +0100
Ajax loading + Tweaks of CSS
Diffstat:
10 files changed, 141 insertions(+), 47 deletions(-)
diff --git a/searx/static/themes/pix-art/css/style.css b/searx/static/themes/pix-art/css/style.css
@@ -1 +1 @@
-html{font-family:sans-serif;font-size:.9em;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-moz-text-size-adjust:100%;text-size-adjust:100%;color:#444;padding:0;margin:0}body,#container{padding:0;margin:0}canvas{image-rendering:optimizeSpeed;image-rendering:-moz-crisp-edges;image-rendering:-webkit-optimize-contrast;image-rendering:optimize-contrast;image-rendering:pixelated;-ms-interpolation-mode:nearest-neighbor;width:32px;height:32px}#container{width:100%;position:absolute;top:0}.search{padding:0;margin:0}#search_wrapper{position:relative;width:50em;padding:10px}.center #search_wrapper{margin-left:auto;margin-right:auto}.q{background:none repeat scroll 0 0 #fff;border:1px solid #3498db;color:#222;font-size:16px;height:28px;margin:0;outline:medium none;padding:2px;padding-left:8px;padding-right:0 !important;width:100%;z-index:2}#search_submit{position:absolute;top:13px;right:1px;padding:0;border:0;background:url('../img/search-icon-pixel2.png') no-repeat;background-size:24px 24px;opacity:.8;width:24px;height:30px;font-size:0}@media screen and (max-width:50em){#search_wrapper{width:90%;clear:both;overflow:hidden}}.row{max-width:800px;margin:20px auto;text-align:justify}.row h1{font-size:3em;margin-top:50px}.row p{padding:0 10px;max-width:700px}.row h3,.row ul{margin:4px 8px}.hmarg{margin:0 20px;border:1px solid #3498db;padding:4px 10px}a:link.hmarg{color:#3498db}a:visited.hmarg{color:#3498db}a:active.hmarg{color:#3498db}a:hover.hmarg{color:#3498db}.top_margin{margin-top:60px}.center{text-align:center}h1{font-size:5em}div.title{background:url('../img/searx-pixel.png') no-repeat;width:100%;min-height:80px;background-position:center}div.title h1{visibility:hidden}input[type="submit"]{padding:2px 6px;margin:2px 4px;display:inline-block;background:#3498db;color:#fff;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;border:0;cursor:pointer}input[type="checkbox"]{visibility:hidden}fieldset{margin:8px;border:1px solid #3498db}#categories{margin:0 10px;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.checkbox_container{display:inline-block;position:relative;margin:0 3px;padding:0}.checkbox_container input{display:none}.checkbox_container label,.engine_checkbox label{cursor:pointer;padding:4px 10px;margin:0;display:block;text-transform:capitalize;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.checkbox_container input[type="checkbox"]:checked+label{background:#3498db;color:#fff}.engine_checkbox{padding:4px}label.allow{background:#e74c3c;padding:4px 8px;color:#fff;display:none}label.deny{background:#2ecc71;padding:4px 8px;color:#444;display:inline}.engine_checkbox input[type="checkbox"]:checked+label:nth-child(2)+label{display:none}.engine_checkbox input[type="checkbox"]:checked+label.allow{display:inline}a{text-decoration:none;color:#1a11be}a:visited{color:#8e44ad}.engines{color:#888}.small_font{font-size:.8em}.small p{margin:2px 0}.right{float:right}.invisible{display:none}.left{float:left}.highlight{color:#094089}.content .highlight{color:#000}.percentage{position:relative;width:300px}.percentage div{background:#444}table{width:100%}td{padding:0 4px}tr:hover{background:#ddd}#results{margin:auto;padding:0;width:50em;margin-bottom:20px}#search_url{margin-top:8px}#search_url input{border:1px solid #888;padding:4px;color:#444;width:14em;display:block;margin:4px;font-size:.8em}#preferences{top:10px;padding:0;border:0;background:url('../img/preference-icon-pixel.png') no-repeat;background-size:28px 28px;opacity:.8;width:28px;height:30px;display:block}#preferences *{display:none}#pagination{clear:both}#pagination br{clear:both}#apis{margin-top:8px;clear:both}#categories_container{position:relative}@media screen and (max-width:50em){#results{margin:auto;padding:0;width:90%}.checkbox_container{display:block;width:90%}.checkbox_container label{border-bottom:0}.preferences_container{display:none;postion:fixed !important;top:100px;right:0}}@media screen and (max-width:75em){div.title h1{font-size:1em}html.touch #categories{width:95%;height:30px;text-align:left;overflow-x:scroll;overflow-y:hidden;-webkit-overflow-scrolling:touch}html.touch #categories #categories_container{width:1000px;width:-moz-max-content;width:-webkit-max-content;width:max-content}html.touch #categories #categories_container .checkbox_container{display:inline-block;width:auto}#categories{font-size:90%;clear:both}#categories .checkbox_container{margin-top:2px;margin:auto}#categories{font-size:90%;clear:both}#categories .checkbox_container{margin-top:2px;margin:auto}#apis{display:none}#search_url{display:none}}.favicon{float:left;margin-right:4px;margin-top:2px}.preferences_back{background:none repeat scroll 0 0 #3498db;border:0 none;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;cursor:pointer;display:inline-block;margin:2px 4px;padding:4px 6px}.preferences_back a{color:#fff}.hidden{opacity:0;overflow:hidden;font-size:.8em;position:absolute;bottom:-20px;width:100%;text-position:center;background:white;transition:opacity 1s ease}#categories_container:hover .hidden{transition:opacity 1s ease;opacity:.8}
-\ No newline at end of file
+html{font-family:sans-serif;font-size:.9em;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-moz-text-size-adjust:100%;text-size-adjust:100%;color:#444;padding:0;margin:0}body,#container{padding:0;margin:0}canvas{image-rendering:optimizeSpeed;image-rendering:-moz-crisp-edges;image-rendering:-webkit-optimize-contrast;image-rendering:optimize-contrast;image-rendering:pixelated;-ms-interpolation-mode:nearest-neighbor;width:32px;height:32px}#container{width:100%;position:absolute;top:0}.search{padding:0;margin:0}#search_wrapper{position:relative;width:50em;padding:10px}.center #search_wrapper{margin-left:auto;margin-right:auto}.q{background:none repeat scroll 0 0 #fff;border:1px solid #3498db;color:#222;font-size:16px;height:28px;margin:0;outline:medium none;padding:2px;padding-left:8px;padding-right:0 !important;width:100%;z-index:2}#search_submit{position:absolute;top:15px;right:5px;padding:0;border:0;background:url('../img/search-icon-pixel.png') no-repeat;background-size:24px 24px;opacity:.8;width:24px;height:24px;font-size:0}@media screen and (max-width:50em){#search_wrapper{width:90%;clear:both;overflow:hidden}}.row{max-width:800px;margin:20px auto;text-align:justify}.row h1{font-size:3em;margin-top:50px}.row p{padding:0 10px;max-width:700px}.row h3,.row ul{margin:4px 8px}.hmarg{margin:0 20px;border:1px solid #3498db;padding:4px 10px}a:link.hmarg{color:#3498db}a:visited.hmarg{color:#3498db}a:active.hmarg{color:#3498db}a:hover.hmarg{color:#3498db}.top_margin{margin-top:60px}.center{text-align:center}h1{font-size:5em}div.title{background:url('../img/searx-pixel.png') no-repeat;width:100%;min-height:80px;background-position:center}div.title h1{visibility:hidden}input[type="button"]{padding:4px 12px;margin:2px 4px;display:inline-block;background:#3498db;color:#fff;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;border:0;cursor:pointer}input[type="button"]:disabled{cursor:progress}input[type="checkbox"]{visibility:hidden}fieldset{margin:8px;border:1px solid #3498db}#logo{position:absolute;top:13px;left:10px}#categories{margin:0 10px;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.checkbox_container{display:inline-block;position:relative;margin:0 3px;padding:0}.checkbox_container input{display:none}.checkbox_container label,.engine_checkbox label{cursor:pointer;padding:4px 10px;margin:0;display:block;text-transform:capitalize;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.checkbox_container input[type="checkbox"]:checked+label{background:#3498db;color:#fff}.engine_checkbox{padding:4px}label.allow{background:#e74c3c;padding:4px 8px;color:#fff;display:none}label.deny{background:#2ecc71;padding:4px 8px;color:#444;display:inline}.engine_checkbox input[type="checkbox"]:checked+label:nth-child(2)+label{display:none}.engine_checkbox input[type="checkbox"]:checked+label.allow{display:inline}a{text-decoration:none;color:#1a11be}a:visited{color:#8e44ad}.engines{color:#888}.small_font{font-size:.8em}.small p{margin:2px 0}.right{float:right}.invisible{display:none}.left{float:left}.highlight{color:#094089}.content .highlight{color:#000}.percentage{position:relative;width:300px}.percentage div{background:#444}table{width:100%}td{padding:0 4px}tr:hover{background:#ddd}#results{margin:auto;padding:0;width:50em;margin-bottom:20px}#search_url{margin-top:8px}#search_url input{border:1px solid #888;padding:4px;color:#444;width:14em;display:block;margin:4px;font-size:.8em}#preferences{top:10px;padding:0;border:0;background:url('../img/preference-icon-pixel.png') no-repeat;background-size:28px 28px;opacity:.8;width:28px;height:30px;display:block}#preferences *{display:none}#pagination{clear:both;text-align:center}#pagination br{clear:both}#apis{margin-top:8px;clear:both}#categories_container{position:relative}@media screen and (max-width:50em){#results{margin:auto;padding:0;width:90%}.checkbox_container{display:block;width:90%}.checkbox_container label{border-bottom:0}.preferences_container{display:none;postion:fixed !important;top:100px;right:0}}@media screen and (max-width:75em){div.title h1{font-size:1em}html.touch #categories{width:95%;height:30px;text-align:left;overflow-x:scroll;overflow-y:hidden;-webkit-overflow-scrolling:touch}html.touch #categories #categories_container{width:1000px;width:-moz-max-content;width:-webkit-max-content;width:max-content}html.touch #categories #categories_container .checkbox_container{display:inline-block;width:auto}#categories{font-size:90%;clear:both}#categories .checkbox_container{margin-top:2px;margin:auto}#categories{font-size:90%;clear:both}#categories .checkbox_container{margin-top:2px;margin:auto}#apis{display:none}#search_url{display:none}#logo{display:none}}.favicon{float:left;margin-right:4px;margin-top:2px}.preferences_back{background:none repeat scroll 0 0 #3498db;border:0 none;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;cursor:pointer;display:inline-block;margin:2px 4px;padding:4px 6px}.preferences_back a{color:#fff}.hidden{opacity:0;overflow:hidden;font-size:.8em;position:absolute;bottom:-20px;width:100%;text-position:center;background:white;transition:opacity 1s ease}#categories_container:hover .hidden{transition:opacity 1s ease;opacity:.8}
+\ No newline at end of file
diff --git a/searx/static/themes/pix-art/img/searx-pixel-small.png b/searx/static/themes/pix-art/img/searx-pixel-small.png
Binary files differ.
diff --git a/searx/static/themes/pix-art/img/spinner.gif b/searx/static/themes/pix-art/img/spinner.gif
Binary files differ.
diff --git a/searx/static/themes/pix-art/js/searx.js b/searx/static/themes/pix-art/js/searx.js
@@ -47,3 +47,97 @@ if(searx.autocompleter) {
})(window, document);
+var xmlHttp
+
+function GetXmlHttpObject(){
+
+ var xmlHttp = null;
+
+ try {
+ // Firefox, Opera 8.0+, Safari
+ xmlHttp = new XMLHttpRequest();
+ }
+ catch (e) {
+ // Internet Explorer
+ try {
+ xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
+ }
+ catch (e){
+ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ }
+ return xmlHttp;
+}
+
+var timer;
+
+// Calculate the rating
+function load_more(query,page){
+
+ xmlHttp = GetXmlHttpObject();
+ clearTimeout(timer);
+
+ if(xmlHttp == null){
+ alert ("Your browser does not support AJAX!");
+ return;
+ }
+
+ favicons[page] = [];
+
+ xmlHttp.onreadystatechange = function(){
+
+ var loader = document.getElementById('load_more');
+
+ if (xmlHttp.readyState == 4){
+
+ //loader.style.display = 'none';
+ var res = xmlHttp.responseText;
+
+ //loader.style.display = 'block';
+ //loader.innerHTML = '<div class="voted">Vote pris en compte</div>';
+ clearTimeout(timer);
+ timer = setTimeout(function(){},6000);
+
+ var results = document.getElementById('results_list');
+ //results_list.innerHTML += res;
+ var newNode = document.createElement('span');
+ newNode.innerHTML = res;
+ results_list.appendChild(newNode);
+
+ var scripts = newNode.getElementsByTagName('script');
+ for (var ix = 0; ix < scripts.length; ix++) {
+ eval(scripts[ix].text);
+ }
+
+ load_images(page);
+ document.getElementById("load_more").onclick = function() { load_more(query, (page+1)); }
+ loader.removeAttribute("disabled");
+
+ } else {
+ //loader.innerHTML = '<img src="images/rating_loading.gif" alt="loading" />';
+ loader.disabled = 'disabled';
+ }
+ }
+ var url = "/";
+ var params = "q="+query+"&pageno="+page+"&category_general=1&category_files=1&category_images=1&category_it=1&category_map=1&category_music=1&category_news=1&category_social+media=1&category_videos=1";
+ xmlHttp.open("POST",url,true);
+ xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ xmlHttp.setRequestHeader("Content-length", params.length);
+ xmlHttp.setRequestHeader("Connection", "close");
+ xmlHttp.send(params);
+}
+
+function load_images(page){
+ var arrayLength = favicons[page].length;
+ for (var i = 1; i < arrayLength+1; i++) {
+ var img = new Image();
+ img.setAttribute("i",i)
+ img.onload = function () {
+ var id = 'canvas-'+page+'-'+this.getAttribute("i");
+ var can = document.getElementById(id);
+ var ctx = can.getContext("2d");
+ ctx.drawImage(this, 0, 0, 16, 16);
+ };
+ img.src = favicons[page][i];
+ }
+}
+\ No newline at end of file
diff --git a/searx/static/themes/pix-art/less/search.less b/searx/static/themes/pix-art/less/search.less
@@ -35,15 +35,15 @@
#search_submit {
position: absolute;
- top: 13px;
- right: 1px;
+ top: 15px;
+ right: 5px;
padding: 0;
border: 0;
background: url('../img/search-icon-pixel.png') no-repeat;
background-size: 24px 24px;
opacity: 0.8;
width: 24px;
- height: 30px;
+ height: 24px;
font-size: 0;
}
diff --git a/searx/static/themes/pix-art/less/style.less b/searx/static/themes/pix-art/less/style.less
@@ -46,9 +46,6 @@ canvas {
@import "search.less";
-// Autocompleter
-
-
.row {
max-width: 800px;
margin: 20px auto;
@@ -116,8 +113,8 @@ div.title {
}
}
-input[type="submit"] {
- padding: 2px 6px;
+input[type="button"] {
+ padding: 4px 12px;
margin: 2px 4px;
display: inline-block;
background: @color-download-button-background;
@@ -127,6 +124,10 @@ input[type="submit"] {
cursor: pointer;
}
+input[type="button"]:disabled {
+ cursor: progress;
+}
+
input[type="checkbox"] {
visibility: hidden;
}
@@ -136,6 +137,12 @@ fieldset {
border: 1px solid @color-settings-fieldset;
}
+#logo {
+ position: absolute;
+ top: 13px;
+ left: 10px;
+}
+
#categories {
margin: 0 10px;
.user-select;
@@ -299,7 +306,7 @@ tr {
#pagination {
clear: both;
-
+ text-align: center;
br {
clear: both;
}
@@ -346,7 +353,7 @@ tr {
div.title {
h1 {
- font-size: 1em;
+ font-size: 1em;
}
}
@@ -398,6 +405,10 @@ tr {
#search_url {
display: none;
}
+
+ #logo {
+ display: none;
+ }
}
.favicon {
diff --git a/searx/templates/pix-art/base.html b/searx/templates/pix-art/base.html
@@ -14,6 +14,9 @@
{% block meta %}{% endblock %}
{% block head %}
{% endblock %}
+ <script type="text/javascript">
+ var favicons = [[]];
+ </script>
</head>
<body>
<div id="container">
@@ -23,6 +26,9 @@
searx = {};
</script>
<script src="{{ url_for('static', filename='js/searx.js') }}" ></script>
+ <script type="text/javascript">
+ load_images(1);
+ </script>
</div>
</body>
</html>
diff --git a/searx/templates/pix-art/result_templates/default.html b/searx/templates/pix-art/result_templates/default.html
@@ -2,12 +2,5 @@
<canvas id="canvas-{{ pageno }}-{{ index }}" class="icon" width="16" height="16"></canvas>
</a>
<script type="text/javascript">
-var img{{ pageno }}_{{ index }} = new Image();
-img{{ pageno }}_{{ index }}.src = 'http://{{ result.url | extract_domain }}/favicon.ico';
-
-img{{ pageno }}_{{ index }}.onload = function () {
- var can{{ pageno }}_{{ index }} = document.getElementById('canvas-{{ pageno }}-{{ index }}');
- var ctx = can{{ pageno }}_{{ index }}.getContext("2d");
- ctx.drawImage(img{{ pageno }}_{{ index }}, 0, 0, 16, 16);
-};
+favicons[{{ pageno }}][{{ index }}] = 'http://{{ result.url | extract_domain }}/favicon.ico';
</script>
\ No newline at end of file
diff --git a/searx/templates/pix-art/results.html b/searx/templates/pix-art/results.html
@@ -1,44 +1,32 @@
+{% if pageno > 1 %}
+ {% for result in results %}
+ {% set index = loop.index %}
+ {% include 'pix-art/result_templates/default.html' %}
+ {% endfor %}
+{% else %}
{% extends "pix-art/base.html" %}
{% block title %}{{ q }} - {% endblock %}
{% block meta %}{% endblock %}
{% block content %}
+<div id="logo"><a href="./"><img src="{{ url_for('static', filename='img/searx-pixel-small.png') }}" alt="Searx Logo"/></a></div>
<div class="preferences_container right"><a href="{{ url_for('preferences') }}" id="preferences"><span>preferences</span></a></div>
<div class="small search center">
{% include 'pix-art/search.html' %}
</div>
+<script type="text/javascript">
+ favicons[{{ pageno }}] = [];
+</script>
<div id="results">
+ <span id="results_list">
{% for result in results %}
{% set index = loop.index %}
{% include 'pix-art/result_templates/default.html' %}
{% endfor %}
-
- {% if paging %}
+ </span>
<div id="pagination">
- {% if pageno > 1 %}
- <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
- <div class="{% if rtl %}right{% else %}left{% endif %}">
- <input type="hidden" name="q" value="{{ q }}" />
- {% for category in selected_categories %}
- <input type="hidden" name="category_{{ category }}" value="1"/>
- {% endfor %}
- <input type="hidden" name="pageno" value="{{ pageno-1 }}" />
- <input type="submit" value="<< {{ _('previous page') }}" />
- </div>
- </form>
- {% endif %}
- <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
- <div class="{% if rtl %}left{% else %}right{% endif %}">
- {% for category in selected_categories %}
- <input type="hidden" name="category_{{ category }}" value="1"/>
- {% endfor %}
- <input type="hidden" name="q" value="{{ q }}" />
- <input type="hidden" name="pageno" value="{{ pageno+1 }}" />
- <input type="submit" value="{{ _('next page') }} >>" />
- </div>
- </form>
-
<br />
+ <input type="button" onclick="load_more('{{ q }}', {{ pageno+1 }})" id="load_more" value="{{ _('Load more...') }}" />
</div>
- {% endif %}
</div>
{% endblock %}
+{% endif %}
+\ No newline at end of file
diff --git a/searx/templates/pix-art/search.html b/searx/templates/pix-art/search.html
@@ -1,7 +1,7 @@
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" id="search_form">
<div id="search_wrapper">
<input type="text" placeholder="{{ _('Search for...') }}" id="q" class="q" name="q" tabindex="1" size="100" {% if q %}value="{{ q }}"{% endif %}/>
- <input type="submit" value="search" id="search_submit" />
+ <input type="submit" value="" id="search_submit" />
{% for category in categories %}
<input type="hidden" name="category_{{ category }}" value="1"/>
{% endfor %}