Web Interface for Crawler
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mongodb.*;
|
||||
|
||||
|
||||
public class CurrentSearch {
|
||||
public static JsonObject getCurrentSearch() {
|
||||
MongoClient mongo = new MongoClient(new MongoClientURI(Settings.MONGOURL.getContent()));
|
||||
DB mongoDB = mongo.getDB(Settings.DBSEARCH.getContent());
|
||||
DBCollection collection = mongoDB.getCollection(Settings.COLLECTIONCURRENTSEARCH.getContent());
|
||||
BasicDBObject obj = new BasicDBObject();
|
||||
BasicDBObject result = (BasicDBObject) collection.findOne(obj);
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject toReturn;
|
||||
if (result == null) {
|
||||
toReturn = new JsonObject();
|
||||
toReturn.addProperty("Search", "");
|
||||
} else {
|
||||
toReturn = (JsonObject) parser.parse(result.toJson());
|
||||
toReturn.remove("_id");
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static void changeCurrentSearch(String search) {
|
||||
MongoClient mongo = new MongoClient(new MongoClientURI(Settings.MONGOURL.getContent()));
|
||||
DB mongoDB = mongo.getDB(Settings.DBSEARCH.getContent());
|
||||
DBCollection collection = mongoDB.getCollection(Settings.COLLECTIONCURRENTSEARCH.getContent());
|
||||
BasicDBObject obj = new BasicDBObject();
|
||||
BasicDBObject result = (BasicDBObject) collection.findOne(obj);
|
||||
|
||||
if (result != null) {
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject json = (JsonObject) parser.parse(result.toJson());
|
||||
String doneSearch = json.get("Search").getAsString();
|
||||
if (!doneSearch.equals("")) {
|
||||
DoneSearch.add(doneSearch);
|
||||
}
|
||||
collection.remove(result);
|
||||
}
|
||||
|
||||
|
||||
result = new BasicDBObject("Search", search);
|
||||
collection.insert(result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mongodb.*;
|
||||
|
||||
public class DoneSearch {
|
||||
public static JsonObject getDoneSearch() {
|
||||
MongoClient mongo = new MongoClient(new MongoClientURI(Settings.MONGOURL.getContent()));
|
||||
DB mongoDB = mongo.getDB(Settings.DBSEARCH.getContent());
|
||||
DBCollection collection = mongoDB.getCollection(Settings.COLLECTIONDONESEARCH.getContent());
|
||||
DBCursor cursor = collection.find();
|
||||
if (cursor == null) {
|
||||
JsonObject toReturn = new JsonObject();
|
||||
toReturn.addProperty("Search", "");
|
||||
return toReturn;
|
||||
}
|
||||
BasicDBObject result = null;
|
||||
if (cursor.hasNext()) {
|
||||
result = (BasicDBObject) cursor.next();
|
||||
}
|
||||
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject toReturn;
|
||||
if (result == null) {
|
||||
toReturn = new JsonObject();
|
||||
toReturn.addProperty("Search", "");
|
||||
} else {
|
||||
toReturn = (JsonObject) parser.parse(result.toJson());
|
||||
toReturn.remove("_id");
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static void add(String done) {
|
||||
MongoClient mongo = new MongoClient(new MongoClientURI(Settings.MONGOURL.getContent()));
|
||||
DB mongoDB = mongo.getDB(Settings.DBSEARCH.getContent());
|
||||
DBCollection collection = mongoDB.getCollection(Settings.COLLECTIONDONESEARCH.getContent());
|
||||
DBCursor cursor = collection.find();
|
||||
BasicDBObject result = null;
|
||||
if (cursor.hasNext()) {
|
||||
result = (BasicDBObject) collection.find().next();
|
||||
}
|
||||
String doneSearch = null;
|
||||
if (result == null) {
|
||||
doneSearch = done;
|
||||
} else {
|
||||
doneSearch = result.getString("Search");
|
||||
doneSearch = doneSearch.trim() + " ; " + done;
|
||||
collection.remove(result);
|
||||
}
|
||||
result = new BasicDBObject("Search", doneSearch);
|
||||
collection.insert(result);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new WosCrawlerAndImporter();
|
||||
//Crawler
|
||||
startUSPTOCrawler();
|
||||
startWOSCrawler();
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mongodb.*;
|
||||
|
||||
public class PendingSearch {
|
||||
|
||||
public static JsonObject getPendingSearch() {
|
||||
MongoClient mongo = new MongoClient(new MongoClientURI(Settings.MONGOURL.getContent()));
|
||||
DB mongoDB = mongo.getDB(Settings.DBSEARCH.getContent());
|
||||
DBCollection collection = mongoDB.getCollection(Settings.COLLECTONPENDINGSEARCH.getContent());
|
||||
BasicDBObject obj = new BasicDBObject();
|
||||
BasicDBObject result = (BasicDBObject) collection.findOne(obj);
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject toReturn;
|
||||
if (result == null) {
|
||||
toReturn = new JsonObject();
|
||||
toReturn.addProperty("Search", "");
|
||||
} else {
|
||||
toReturn = (JsonObject) parser.parse(result.toJson());
|
||||
toReturn.remove("_id");
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static String getAndDeleteFistPendingSearch() {
|
||||
MongoClient mongo = new MongoClient(new MongoClientURI(Settings.MONGOURL.getContent()));
|
||||
DB mongoDB = mongo.getDB(Settings.DBSEARCH.getContent());
|
||||
DBCollection collection = mongoDB.getCollection(Settings.COLLECTONPENDINGSEARCH.getContent());
|
||||
BasicDBObject obj = new BasicDBObject();
|
||||
BasicDBObject result = (BasicDBObject) collection.findOne(obj);
|
||||
if (result == null) {
|
||||
return "";
|
||||
}
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject toReturn = (JsonObject) parser.parse(result.toJson());
|
||||
|
||||
String a = toReturn.get("Search").getAsString();
|
||||
collection.remove(result);
|
||||
if (a.indexOf(';') == -1) {
|
||||
result.put("Search", "");
|
||||
collection.insert(result);
|
||||
return a;
|
||||
} else {
|
||||
result.put("Search", a.substring(a.indexOf(';')).trim());
|
||||
collection.insert(result);
|
||||
return a.substring(0, a.indexOf(';') - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void addPendingSearch(String search) {
|
||||
MongoClient mongo = new MongoClient(new MongoClientURI(Settings.MONGOURL.getContent()));
|
||||
DB mongoDB = mongo.getDB(Settings.DBSEARCH.getContent());
|
||||
DBCollection collection = mongoDB.getCollection(Settings.COLLECTONPENDINGSEARCH.getContent());
|
||||
BasicDBObject obj = new BasicDBObject();
|
||||
BasicDBObject result = (BasicDBObject) collection.findOne(obj);
|
||||
if (result == null) {
|
||||
result = new BasicDBObject();
|
||||
result.put("Search", "");
|
||||
}
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject json = (JsonObject) parser.parse(result.toJson());
|
||||
String pendingSearches = json.get("Search").getAsString();
|
||||
if (pendingSearches.equals("")) {
|
||||
pendingSearches = search;
|
||||
} else {
|
||||
pendingSearches = pendingSearches.trim() + " ; " + search;
|
||||
}
|
||||
|
||||
|
||||
collection.remove(result);
|
||||
result = new BasicDBObject("Search", pendingSearches);
|
||||
collection.insert(result);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ public enum SearchMode {
|
||||
KEYWORD(1),
|
||||
RESEARCHAREA(2),
|
||||
TOPIC(3),
|
||||
COMPLEX(4),
|
||||
|
||||
;
|
||||
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.sun.net.httpserver.Headers;
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
import org.openqa.selenium.json.JsonException;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
public class Server {
|
||||
Server() {
|
||||
try {
|
||||
HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
|
||||
server.createContext("/query", new QueryHandler());
|
||||
server.createContext("/searches", new SearchHandler());
|
||||
server.setExecutor(null);
|
||||
server.start();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Server();
|
||||
//new WosCrawlerAndImporter();
|
||||
}
|
||||
|
||||
|
||||
static class SearchHandler implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange t) throws IOException {
|
||||
//Handlers
|
||||
this.setResponseHandlers(t);
|
||||
|
||||
//Response
|
||||
JsonObject resultJson = null;
|
||||
if (t.getRequestMethod().equals("OPTIONS")) {
|
||||
resultJson = new JsonObject();
|
||||
}
|
||||
|
||||
if (t.getRequestMethod().equals("POST")) {
|
||||
String s = t.getRequestHeaders().getFirst("Content-type");
|
||||
if (s.equals("application/json")) {
|
||||
InputStream inputStream = t.getRequestBody();
|
||||
BufferedInputStream bis = new BufferedInputStream(inputStream);
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
int result = bis.read();
|
||||
while (result != -1) {
|
||||
buf.write((byte) result);
|
||||
result = bis.read();
|
||||
}
|
||||
String json = buf.toString("UTF-8");
|
||||
|
||||
|
||||
try {
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject jsonObject = (JsonObject) parser.parse(json);
|
||||
String search = jsonObject.get("Search").getAsString();
|
||||
if (search.equals("done")) {
|
||||
resultJson = DoneSearch.getDoneSearch();
|
||||
|
||||
}
|
||||
if (search.equals("current")) {
|
||||
resultJson = CurrentSearch.getCurrentSearch();
|
||||
}
|
||||
if (search.equals("pending")) {
|
||||
resultJson = PendingSearch.getPendingSearch();
|
||||
}
|
||||
if (resultJson == null) {
|
||||
resultJson = new JsonObject();
|
||||
resultJson.addProperty("Search", "");
|
||||
}
|
||||
|
||||
} catch (JsonException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
byte[] response = resultJson.toString().getBytes();
|
||||
t.sendResponseHeaders(200, response.length);
|
||||
OutputStream os = t.getResponseBody();
|
||||
os.write(response);
|
||||
os.flush();
|
||||
os.close();
|
||||
}
|
||||
|
||||
private void setResponseHandlers(HttpExchange t) {
|
||||
final Headers hds = t.getResponseHeaders();
|
||||
hds.set("Access-Control-Allow-Origin", "*");
|
||||
hds.set("Content-Type", "application/json");
|
||||
hds.set("Access-Control-Allow-Headers", "Access-Control-Allow-Methods, Content-Type, Access-Control-Allow-Origin");
|
||||
|
||||
hds.set("Access-Control-Allow-Methods", "POST");
|
||||
}
|
||||
}
|
||||
|
||||
static class QueryHandler implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange t) throws IOException {
|
||||
//Handlers
|
||||
this.setResponseHandlers(t);
|
||||
|
||||
//Response
|
||||
if (t.getRequestMethod().equals("OPTIONS")) {
|
||||
|
||||
}
|
||||
|
||||
if (t.getRequestMethod().equals("POST")) {
|
||||
String s = t.getRequestHeaders().getFirst("Content-type");
|
||||
if (s.equals("application/json")) {
|
||||
InputStream inputStream = t.getRequestBody();
|
||||
BufferedInputStream bis = new BufferedInputStream(inputStream);
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
int result = bis.read();
|
||||
while (result != -1) {
|
||||
buf.write((byte) result);
|
||||
result = bis.read();
|
||||
}
|
||||
String json = buf.toString("UTF-8");
|
||||
|
||||
|
||||
try {
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject jsonObject = (JsonObject) parser.parse(json);
|
||||
String search = jsonObject.get("Search").getAsString();
|
||||
PendingSearch.addPendingSearch(search);
|
||||
if (CurrentSearch.getCurrentSearch().get("Search").getAsString().equals("")) {
|
||||
search = PendingSearch.getAndDeleteFistPendingSearch();
|
||||
CurrentSearch.changeCurrentSearch(search);
|
||||
new WosCrawlerAndImporter();
|
||||
}
|
||||
//
|
||||
|
||||
} catch (JsonException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
byte[] response = "Response".getBytes();
|
||||
t.sendResponseHeaders(200, response.length);
|
||||
OutputStream os = t.getResponseBody();
|
||||
os.write(response);
|
||||
os.flush();
|
||||
os.close();
|
||||
}
|
||||
|
||||
private void setResponseHandlers(HttpExchange t) {
|
||||
final Headers hds = t.getResponseHeaders();
|
||||
hds.set("Access-Control-Allow-Origin", "*");
|
||||
hds.set("Content-Type", "application/json");
|
||||
hds.set("Access-Control-Allow-Headers", "Access-Control-Allow-Methods, Content-Type, Access-Control-Allow-Origin");
|
||||
|
||||
hds.set("Access-Control-Allow-Methods", "POST");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,11 @@ public enum Settings {
|
||||
DBPATENT("Patent"),
|
||||
COLLECTIONPATENT("Patent"),
|
||||
|
||||
DBSEARCH("Search"),
|
||||
COLLECTIONCURRENTSEARCH("Current"),
|
||||
COLLECTIONDONESEARCH("Done"),
|
||||
COLLECTONPENDINGSEARCH("Pending"),
|
||||
|
||||
//Überspringt wait() --> Kann selbst fehler verursachen
|
||||
DEBUG("NO"),
|
||||
;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class WoSCrawler {
|
||||
private int start;
|
||||
|
||||
|
||||
public WoSCrawler(String search, SearchMode mode, int start) {
|
||||
public WoSCrawler(String search, SearchMode mode, int start) throws Exception {
|
||||
try {
|
||||
currentSearch = search;
|
||||
this.start = start;
|
||||
@@ -32,13 +32,15 @@ public class WoSCrawler {
|
||||
break;
|
||||
case TOPIC:
|
||||
searchComplex("TS = (" + currentSearch + ")");
|
||||
break;
|
||||
case COMPLEX:
|
||||
searchComplex(currentSearch);
|
||||
break;
|
||||
}
|
||||
startMain();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new Exception(e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private synchronized void searchByTopic() throws InterruptedException {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
public class WosCrawlerAndImporter {
|
||||
WosCrawlerAndImporter() {
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String search = CurrentSearch.getCurrentSearch().get("Search").getAsString();
|
||||
if (search.equals("")) {
|
||||
search = PendingSearch.getAndDeleteFistPendingSearch();
|
||||
if (search.equals("")) {
|
||||
return;
|
||||
}
|
||||
CurrentSearch.changeCurrentSearch(search);
|
||||
}
|
||||
try {
|
||||
new WoSCrawler(search, SearchMode.COMPLEX, 1);
|
||||
new WOSImporter();
|
||||
CurrentSearch.changeCurrentSearch(PendingSearch.getAndDeleteFistPendingSearch());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
.body {
|
||||
font-family: "Lato", sans-serif;
|
||||
margin:0px;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.nav-wrapper {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 38px;
|
||||
}
|
||||
|
||||
.left-side {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-wrapper > .left-side > div {
|
||||
margin-right: 20px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.nav-link-wrapper{
|
||||
height: 22px;
|
||||
border-bottom: 1px solid transparent;
|
||||
transition: border-bottom 0.5s;
|
||||
}
|
||||
|
||||
.nav-link-wrapper a {
|
||||
color :#8a8a8a;
|
||||
text-decoration: none;
|
||||
transition: color 0.5s;
|
||||
}
|
||||
|
||||
.nav-link-wrapper:hover {
|
||||
border-bottom: 1px solid black;
|
||||
}
|
||||
|
||||
.nav-link-wrapper:hover a {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.active-nav-link a {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.active-nav-link {
|
||||
border-bottom: 1px solid black;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
xhrCurrent = new XMLHttpRequest();
|
||||
url ='http://localhost:8000/searches';
|
||||
xhrCurrent.open("POST",url,true);
|
||||
xhrCurrent.setRequestHeader('Access-Control-Allow-Methods','POST');
|
||||
xhrCurrent.setRequestHeader("Content-Type","application/json");
|
||||
xhrCurrent.onerror = function()
|
||||
{
|
||||
alert("Fehler");
|
||||
}
|
||||
xhrCurrent.onreadystatechange = function () {
|
||||
if (xhrCurrent.readyState === 4 && xhrCurrent.status === 200) {
|
||||
var parent = document.getElementById("currentSearch");
|
||||
var child = parent.lastElementChild;
|
||||
while(child)
|
||||
{
|
||||
parent.removeChild(child);
|
||||
child = parent.lastElementChild;
|
||||
}
|
||||
var textField = document.createElement("p");
|
||||
var json = JSON.parse(xhrCurrent.response);
|
||||
var output = json.Search;
|
||||
textField.innerHTML = output;
|
||||
document.getElementById("currentSearch").appendChild(textField);
|
||||
}
|
||||
};
|
||||
|
||||
// Converting JSON data to string
|
||||
var data = JSON.stringify({ "Search" : "current"});
|
||||
|
||||
// Sending data with the request
|
||||
xhrCurrent.send(data);
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
xhrDone = new XMLHttpRequest();
|
||||
let url ='http://localhost:8000/searches';
|
||||
xhrDone.open("POST",url,true);
|
||||
xhrDone.setRequestHeader('Access-Control-Allow-Methods','POST');
|
||||
xhrDone.setRequestHeader("Content-Type","application/json");
|
||||
xhrDone.onerror = function()
|
||||
{
|
||||
alert("Fehler");
|
||||
}
|
||||
xhrDone.onreadystatechange = function () {
|
||||
if (xhrDone.readyState === 4 && xhrDone.status === 200) {
|
||||
var parent = document.getElementById("doneSearches");
|
||||
var child = parent.lastElementChild;
|
||||
while(child)
|
||||
{
|
||||
parent.removeChild(child);
|
||||
child = parent.lastElementChild;
|
||||
}
|
||||
var resp = xhrDone.response;
|
||||
var json = JSON.parse(resp);
|
||||
var output = json.Search;
|
||||
var array = [];
|
||||
if(output == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
while(output.indexOf(';')!=-1)
|
||||
{
|
||||
var a = output.substring(0,output.indexOf(";")-1);
|
||||
output = output.substring(output.indexOf(";")+1);
|
||||
array.push(a.trim());
|
||||
}
|
||||
array.push(output.trim());
|
||||
for(var i = 0;i<array.length;i++)
|
||||
{
|
||||
var button = document.createElement("button");
|
||||
var text = array[i];
|
||||
button.innerText = text;
|
||||
document.getElementById("doneSearches").appendChild(button);
|
||||
button.addEventListener = function (text){
|
||||
//GOTO ANALYSIS
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Converting JSON data to string
|
||||
var data = JSON.stringify({ "Search" : "done"});
|
||||
|
||||
// Sending data with the request
|
||||
xhrDone.send(data);
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Analyse</title>
|
||||
<link href="commonStyles.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="nav-wrapper">
|
||||
<div class="left-side">
|
||||
<div class="nav-link-wrapper active-nav-link">
|
||||
<a href="index.html">Analyse</a>
|
||||
</div>
|
||||
|
||||
<div class="nav-link-wrapper">
|
||||
<a href="search.html">Suche</a>
|
||||
</div>
|
||||
|
||||
<div class="nav-link-wrapper">
|
||||
<a href="log.html">Logs</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Analyse</title>
|
||||
<link href="commonStyles.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="nav-wrapper">
|
||||
<div class="left-side">
|
||||
<div class="nav-link-wrapper">
|
||||
<a href="index.html">Analyse</a>
|
||||
</div>
|
||||
|
||||
<div class="nav-link-wrapper">
|
||||
<a href="search.html">Suche</a>
|
||||
</div>
|
||||
|
||||
<div class="nav-link-wrapper active-nav-link">
|
||||
<a href="log.html">Logs</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,51 @@
|
||||
xhrPending = new XMLHttpRequest();
|
||||
url ='http://localhost:8000/searches';
|
||||
xhrPending.open("POST",url,true);
|
||||
xhrPending.setRequestHeader('Access-Control-Allow-Methods','POST');
|
||||
xhrPending.setRequestHeader("Content-Type","application/json");
|
||||
xhrPending.onerror = function()
|
||||
{
|
||||
alert("Fehler");
|
||||
}
|
||||
xhrPending.onreadystatechange = function () {
|
||||
if (xhrPending.readyState === 4 && xhrPending.status === 200) {
|
||||
var parent = document.getElementById("pendingSearch");
|
||||
var child = parent.lastElementChild;
|
||||
while(child)
|
||||
{
|
||||
parent.removeChild(child);
|
||||
child = parent.lastElementChild;
|
||||
}
|
||||
var resp = xhrPending.response;
|
||||
var json = JSON.parse(resp);
|
||||
var output = json.Search;
|
||||
var array = [];
|
||||
if(output == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
while(output.indexOf(';')!=-1)
|
||||
{
|
||||
var a = output.substring(0,output.indexOf(";")-1);
|
||||
output = output.substring(output.indexOf(";")+1);
|
||||
array.push(a.trim());
|
||||
}
|
||||
array.push(output.trim());
|
||||
for(var i = 0;i<array.length;i++)
|
||||
{
|
||||
var textField = document.createElement("p");
|
||||
var text = array[i];
|
||||
textField.innerText = text;
|
||||
document.getElementById("pendingSearch").appendChild(textField);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Converting JSON data to string
|
||||
var data = JSON.stringify({ "Search" : "pending"});
|
||||
|
||||
// Sending data with the request
|
||||
xhrPending.send(data);
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Suche</title>
|
||||
<link href="commonStyles.css" rel="stylesheet">
|
||||
<link href="searchStyles.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="nav-wrapper">
|
||||
<div class="left-side">
|
||||
<div class="nav-link-wrapper">
|
||||
<a href="index.html">Analyse</a>
|
||||
</div>
|
||||
|
||||
<div class="nav-link-wrapper active-nav-link">
|
||||
<a href="search.html">Suche</a>
|
||||
</div>
|
||||
|
||||
<div class="nav-link-wrapper">
|
||||
<a href="log.html">Logs</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="search-wrapper">
|
||||
<div class="searchBar-wrapper">
|
||||
<div class="searchBar">
|
||||
<label>Suche: </label>
|
||||
<input id="idSearchBar" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="checkBoxes-wrapper">
|
||||
<div class="checkBoxes">
|
||||
<div class="checkBox">
|
||||
<label>Topic</label>
|
||||
<input id="checkBoxTopic" type="checkbox">
|
||||
</div>
|
||||
|
||||
<div class="checkBox">
|
||||
<label>Author Keywords</label>
|
||||
<input id="checkBoxAK" type="checkbox">
|
||||
</div>
|
||||
|
||||
<div class="checkBox">
|
||||
<label>Keywords Plus</label>
|
||||
<input id="checkBoxKP" type="checkbox">
|
||||
</div>
|
||||
|
||||
<div class="checkBox">
|
||||
<label>Research Area</label>
|
||||
<input id="checkBoxRA" type="checkbox">
|
||||
</div>
|
||||
|
||||
<div class="checkBox">
|
||||
<label>WoS Category</label>
|
||||
<input id="checkBoxWOSCategory" type="checkbox">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="submitSearch">
|
||||
<input id="submitSearch" type="submit" value="Starte Suche">
|
||||
<script src="searchScript.js"></script>
|
||||
<script src="currentSearchScript.js"></script>
|
||||
<script src="pendingSearchScript.js"></script>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="doneSearchWrapper">
|
||||
<label> Ausgeführte Suchen:</label>
|
||||
<div class="doneSearchr" id="doneSearches">
|
||||
<script src="doneSearchesScript.js"></script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="currentSearchWrapper">
|
||||
<label> Jetzige Suche:</label>
|
||||
<div class="currentSearch" id="currentSearch">
|
||||
<script src="currentSearchScript.js"></script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pendingSearchWrapper">
|
||||
<label> Pending Suche:</label>
|
||||
<div class="pendingSearch" id="pendingSearch">
|
||||
<script src="pendingSearchScript.js"></script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
document.getElementById("submitSearch").onclick = function() {search()}
|
||||
|
||||
function search() {
|
||||
var searchString = document.getElementById("idSearchBar").value;
|
||||
if(searchString == "")
|
||||
{
|
||||
alert("Suche ist leer");
|
||||
return;
|
||||
}
|
||||
|
||||
var search = new String();
|
||||
|
||||
if(document.getElementById('checkBoxTopic').checked == true)
|
||||
{
|
||||
if(search.length>0)
|
||||
{
|
||||
search = search +" OR ";
|
||||
}
|
||||
search = search + "TS=('" + searchString + "')"
|
||||
}
|
||||
|
||||
if(document.getElementById('checkBoxAK').checked == true)
|
||||
{
|
||||
if(search.length>0)
|
||||
{
|
||||
search = search +" OR ";
|
||||
}
|
||||
search = search + "AK=('" + searchString + "')"
|
||||
}
|
||||
|
||||
if(document.getElementById('checkBoxKP').checked == true)
|
||||
{
|
||||
if(search.length>0)
|
||||
{
|
||||
search = search +" OR ";
|
||||
}
|
||||
search = search + "KP=('" + searchString + "')"
|
||||
}
|
||||
|
||||
if(document.getElementById('checkBoxRA').checked == true)
|
||||
{
|
||||
if(search.length>0)
|
||||
{
|
||||
search = search +" OR ";
|
||||
}
|
||||
search = search + "SU=('" + searchString + "')"
|
||||
}
|
||||
|
||||
if(document.getElementById('checkBoxWOSCategory').checked == true)
|
||||
{
|
||||
if(search.length>0)
|
||||
{
|
||||
search = search +" OR ";
|
||||
}
|
||||
search = search + "WC=('" + searchString + "')"
|
||||
}
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
let url ='http://localhost:8000/query';
|
||||
xhr.open("POST",url,true);
|
||||
xhr.setRequestHeader('Access-Control-Allow-Methods','POST');
|
||||
xhr.setRequestHeader("Content-Type","application/json");
|
||||
xhr.onerror = function()
|
||||
{
|
||||
alert("Fehler");
|
||||
}
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Converting JSON data to string
|
||||
var data = JSON.stringify({ "Search" : search});
|
||||
|
||||
// Sending data with the request
|
||||
xhr.send(data);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
.searchBar-wrapper {
|
||||
padding: 20px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.searchBar {
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.checkBoxes-wrapper {
|
||||
padding: 20px;
|
||||
|
||||
}
|
||||
|
||||
.checkBoxes {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.checkBox {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.submitSearch {
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.search-wrapper {
|
||||
padding: 20px;
|
||||
display: grid;
|
||||
border: 1px solid;
|
||||
}
|
||||
|
||||
.doneSearchWrapper {
|
||||
padding:20px;
|
||||
display: grid;
|
||||
border: 1px solid;
|
||||
}
|
||||
|
||||
.currentSearchWrapper {
|
||||
padding:20px;
|
||||
display: grid;
|
||||
border: 1px solid;
|
||||
}
|
||||
|
||||
.pendingSearchWrapper {
|
||||
padding:20px;
|
||||
display: grid;
|
||||
border: 1px solid;
|
||||
}
|
||||
|
||||
.pendingSearchWrapper p {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user