Commit 2646f9aa authored by Alexandra Rogova's avatar Alexandra Rogova

new gui, some other stuff

parent feb459b4
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
}) })
.declareMethod("remove_css", function(body){ .declareMethod("remove_css", function(body){
/*var doc = new DOMParser().parseFromString(body, "text/html");
return doc.body.textContent || "";*/
var regEx = new RegExp('(style="(.*?)"|style=&quot(.*?)&quot)', 'gi'); var regEx = new RegExp('(style="(.*?)"|style=&quot(.*?)&quot)', 'gi');
return body.replace(regEx, ""); return body.replace(regEx, "");
}); });
......
...@@ -9,8 +9,10 @@ ...@@ -9,8 +9,10 @@
<link rel="stylesheet" type="text/css" href="result.css"> <link rel="stylesheet" type="text/css" href="result.css">
</head> </head>
<body> <body>
<div id ="mynij"><img src="./logo.png"></div>
<ul id="mynij-results"> <ul id="mynij-results">
</ul> </ul>
<div id ="google"><img src="./logo_google.png"></div>
<ul id="searx-results"> <ul id="searx-results">
</ul> </ul>
</body> </body>
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
title, title,
link, link,
link_par, link_par,
body; body,
gadget = this;
list = document.getElementById("mynij-results"); list = document.getElementById("mynij-results");
list_item = document.createElement("LI"); list_item = document.createElement("LI");
...@@ -21,33 +22,39 @@ ...@@ -21,33 +22,39 @@
title.href = item.link; title.href = item.link;
list_item.appendChild(title); list_item.appendChild(title);
link = document.createElement("a"); return this.cut_link(item.link)
link.appendChild(document.createTextNode(item.link)); .push(function(cut_link){
link.href = item.link; link = document.createElement("a");
link.className = "link"; link.appendChild(document.createTextNode(cut_link));
link_par = document.createElement('p'); link.href = item.link;
link_par.appendChild(link); link.className = "link";
list_item.appendChild(link_par); link_par = document.createElement('p');
link_par.appendChild(link);
body = document.createElement('p'); list_item.appendChild(link_par);
body.className = "body"; })
if (key === ""){ .push(function(){
body.innerHTML = ""; body = document.createElement('p');
list.appendChild(list_item); body.className = "body";
} else { item.body = new DOMParser().parseFromString(item.body, "text/html").body.textContent || "";
return this.cut_description(item.body, key) if (key === "" || item.body === ""){
.push(function (result){ body.innerHTML = "";
var array = [...result.matchAll(key)], list.appendChild(list_item);
i; } else {
for (i=0; i<array.length; i+=1){ return gadget.cut_description(item.body, key)
result = result.slice(0, array[i].index) + "<b>" + result.slice(array[i].index, array[i].index+array[i][0].length+1) + "</b>" + result.slice(array[i].index+array[i][0].length+1); .push(function (result){
} var array = [...result.matchAll(key)],
body.innerHTML = result; i;
list_item.appendChild(body); for (i=0; i<array.length; i+=1){
list.appendChild(list_item); result = result.slice(0, array[i].index) + "<b>" + result.slice(array[i].index, array[i].index+array[i][0].length+1) + "</b>" + result.slice(array[i].index+array[i][0].length+1);
}
body.innerHTML = result;
list_item.appendChild(body);
list.appendChild(list_item);
});
}
}); });
}
}) })
.declareMethod("show_searx_result", function(item, key){ .declareMethod("show_searx_result", function(item, key){
...@@ -77,7 +84,7 @@ ...@@ -77,7 +84,7 @@
body = document.createElement("p"); body = document.createElement("p");
body.className = "body"; body.className = "body";
if (item.querySelector('p.result-content') !== null) body.innerHTML = item.querySelector('p.result-content').textContent; if (item.querySelector('p.result-content') !== null) body.innerHTML = item.querySelector('p.result-content').outerHTML;
else body.innerHTML = ""; else body.innerHTML = "";
list_item.appendChild(body); list_item.appendChild(body);
...@@ -96,14 +103,19 @@ ...@@ -96,14 +103,19 @@
}) })
.declareMethod("cut_description", function(body, key){ .declareMethod("cut_description", function(body, key){
var regEx, var result = new RegExp('[^.?!]*' + ' ' + key + ' ' + '[^.?!]*[.?!]', 'gm').exec(body);
result;
regEx = new RegExp('[^.?!]*' + ' ' + key + ' ' + '[^.?!]*[.?!]', 'gm');
result = regEx.exec(body);
if (result === null) { if (result === null) {
return new RegExp('[^.?!]*[.?!]').exec(body)[0]; result = new RegExp('[^.?!]*[.?!]').exec(body);
if (result === null) return "";
else return result[0];
} }
else return result[0].slice(1); else return result[0];
})
.declareMethod("cut_link", function(link){
if (link === undefined) return "";
if (link.length > 70) return link.slice(0,70) + "...";
else return link;
}); });
}(window, RSVP, rJS, jIO)); }(window, RSVP, rJS, jIO));
\ No newline at end of file
...@@ -4,12 +4,13 @@ body { ...@@ -4,12 +4,13 @@ body {
height: 100vh; height: 100vh;
width: 100%; width: 100%;
background: #fff; background: #fff;
font-family: arial,sans-serif;
} }
form{ form{
position: relative; position: relative;
top: 3%; top: 3%;
left: 10%; margin : auto;
width: 86%; width: 86%;
max-width: 50em; max-width: 50em;
height: 5%; height: 5%;
...@@ -96,27 +97,3 @@ input{ ...@@ -96,27 +97,3 @@ input{
padding-bottom:0.2%; padding-bottom:0.2%;
} }
/*
#mynij{
position: fixed;
left: 1.5%;
top: 3.5%;
font-size: 250%;
font-family: "Roboto", Geneva, "Lucida Console", sans-serif;
font-weight: 500;
color: #485a67;
line-height: 38px;
letter-spacing: -1px;
}
*/
#mynij{
position: fixed;
left: 1.5%;
top: 1.5%;
}
#mynij img {
height: 5em;
}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
} }
#mynij-results, #searx-results{ #mynij-results, #searx-results{
margin-top : 4%; margin-top : 10%;
text-align: left; text-align: left;
} }
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
list-style-type: none; list-style-type: none;
position: relative; position: relative;
display: table; display: table;
margin-left: 10%; margin-left: 50%;
margin-top: 1%; margin-top: 2%;
padding-top: 1%; padding-top: 1%;
padding-bottom: 1%; padding-bottom: 1%;
padding-left : 1%; padding-left : 1%;
...@@ -46,8 +46,12 @@ ...@@ -46,8 +46,12 @@
#mynij-results > a, #searx-results > a { #mynij-results > a, #searx-results > a {
position: relative; position: relative;
} }
.highlight {
font-weight: bold;
}
#mynij-results > a:after , #searx-results > a:after{ #mynij-results > a:after , #searx-results > a:after{
content: ''; content: '';
position: absolute; position: absolute;
...@@ -73,4 +77,22 @@ ...@@ -73,4 +77,22 @@
opacity: .3; opacity: .3;
font-weight: 100; font-weight: 100;
font-size: .8em; font-size: .8em;
}
#mynij, #google {
margin-top : 4%;
margin-left : 30%;
position: absolute;
}
#google {
margin-left : 65%;
}
#mynij img {
height: 5em;
}
#google img {
height : 5em;
} }
\ No newline at end of file
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
<link rel="stylesheet" type="text/css" href="mynij.css"> <link rel="stylesheet" type="text/css" href="mynij.css">
</head> </head>
<body> <body>
<!-- <div id ="mynij">Mynij</div> -->
<div id ="mynij"><img src="./logo.png" height="3em"></div>
<form id = "search_bar"> <form id = "search_bar">
<input type="search" required> <input type="search" required>
</form> </form>
......
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