added get method and language()
This commit is contained in:
parent
ee25012598
commit
4c8fcc4eb1
@ -12,6 +12,7 @@ app.config.update(
|
|||||||
try:
|
try:
|
||||||
with open("save.p", "rb") as f:
|
with open("save.p", "rb") as f:
|
||||||
database = pickle.load(f)
|
database = pickle.load(f)
|
||||||
|
print("Loaded", database)
|
||||||
except (FileNotFoundError) as e:
|
except (FileNotFoundError) as e:
|
||||||
database = {'languages': [],
|
database = {'languages': [],
|
||||||
'phonemes': [],
|
'phonemes': [],
|
||||||
|
|||||||
@ -1,52 +1,76 @@
|
|||||||
var navSelect = "home";
|
var navSelect = "home";
|
||||||
|
var serverURL = "http://0.0.0.0:5000";
|
||||||
|
var data;
|
||||||
|
|
||||||
var navi = [ // Array containing navigation items in form [Font-Awesome class name, Display Text, Onclick function].
|
var navi = [ // Array containing navigation items in form [Font-Awesome class name, Display Text, Onclick function].
|
||||||
["home", "Home", "home"],
|
["home", "Home", "home"],
|
||||||
["bar-chart", "Data Values", "dataValues"],
|
["bar-chart", "Data Values", "dataValues"],
|
||||||
["database", "Database and Files", "files"],
|
["database", "Database and Files", "files"],
|
||||||
["bell", "Updates and Progress", "updates"]
|
["bell", "Updates and Progress", "updates"]
|
||||||
];
|
];
|
||||||
|
|
||||||
for(var i = 0; i < navi.length; i++) { // Create navigation tabs.
|
for (var i = 0; i < navi.length; i++) { // Create navigation tabs.
|
||||||
var side = document.getElementById("sidebar");
|
var side = document.getElementById("sidebar");
|
||||||
var div = document.createElement("div");
|
var div = document.createElement("div");
|
||||||
div.className = "navi transition";
|
div.className = "navi transition";
|
||||||
div.setAttribute("option", navi[i][2]);
|
div.setAttribute("option", navi[i][2]);
|
||||||
div.onclick = function() {
|
div.onclick = function() {
|
||||||
var op = this.getAttribute("option");
|
var op = this.getAttribute("option");
|
||||||
if(navSelect === op) return;
|
if (navSelect === op) return;
|
||||||
updateMain(op);
|
updateMain(op);
|
||||||
};
|
};
|
||||||
var ic = document.createElement("i");
|
var ic = document.createElement("i");
|
||||||
ic.className = "fa fa-"+navi[i][0];
|
ic.className = "fa fa-" + navi[i][0];
|
||||||
ic["aria-hidden"] = true;
|
ic["aria-hidden"] = true;
|
||||||
var p = document.createElement("p");
|
var p = document.createElement("p");
|
||||||
p.appendChild(document.createTextNode(navi[i][1]));
|
p.appendChild(document.createTextNode(navi[i][1]));
|
||||||
div.appendChild(ic);
|
div.appendChild(ic);
|
||||||
div.appendChild(p);
|
div.appendChild(p);
|
||||||
side.appendChild(div);
|
side.appendChild(div);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNav(navSelect);
|
updateNav(navSelect);
|
||||||
|
|
||||||
function updateMain(op) {
|
function updateMain(op) {
|
||||||
updateNav(op);
|
updateNav(op);
|
||||||
document.getElementById(navSelect).style.opacity = "0";
|
document.getElementById(navSelect).style.opacity = "0";
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
document.getElementById(navSelect).style.display = "none";
|
document.getElementById(navSelect).style.display = "none";
|
||||||
document.getElementById(op).style.display = "grid";
|
document.getElementById(op).style.display = "grid";
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
document.getElementById(op).style.opacity = "1";
|
document.getElementById(op).style.opacity = "1";
|
||||||
}, 30);
|
}, 30);
|
||||||
navSelect = op;
|
navSelect = op;
|
||||||
}, 300);
|
}, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateNav(op) {
|
function updateNav(op) {
|
||||||
var oldNav = document.querySelectorAll("[option="+navSelect+"]")[0];
|
var oldNav = document.querySelectorAll("[option=" + navSelect + "]")[0];
|
||||||
var newNav = document.querySelectorAll("[option="+op+"]")[0];
|
var newNav = document.querySelectorAll("[option=" + op + "]")[0];
|
||||||
oldNav.style.backgroundColor = "rgba(0,0,0,0)";
|
oldNav.style.backgroundColor = "rgba(0,0,0,0)";
|
||||||
oldNav.style.color = "white";
|
oldNav.style.color = "white";
|
||||||
newNav.style.backgroundColor = "#F8F3F0";
|
newNav.style.backgroundColor = "#F8F3F0";
|
||||||
newNav.style.color = "#F47922";
|
newNav.style.color = "#F47922";
|
||||||
|
}
|
||||||
|
|
||||||
|
function getData() {
|
||||||
|
$.ajax({
|
||||||
|
url: serverURL + '/server',
|
||||||
|
type: 'GET'
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
function success(incoming) {
|
||||||
|
data = incoming;
|
||||||
|
},
|
||||||
|
function error(e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function language(language) {
|
||||||
|
return data.languages.filter(function(element) {
|
||||||
|
return element.name === language;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,58 +1,61 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
<head>
|
||||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
<meta charset="utf-8">
|
||||||
<title>SmearcarDB</title>
|
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||||
<link rel="icon" href="/static/resources/favicon.ico?v=2">
|
<title>SmearcarDB</title>
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='index.css') }}">
|
<link rel="icon" href="/static/resources/favicon.ico?v=2">
|
||||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet">
|
<link rel="stylesheet" href="{{ url_for('static', filename='index.css') }}">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet">
|
||||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
<script src="{{ url_for('static', filename='velocity.min.js') }}"></script>
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
||||||
<script src="https://use.fontawesome.com/c8d5486cd8.js"></script>
|
<script src="{{ url_for('static', filename='velocity.min.js') }}"></script>
|
||||||
</head>
|
<script src="https://use.fontawesome.com/c8d5486cd8.js"></script>
|
||||||
<body>
|
</head>
|
||||||
<div id="header1" class="colorFade">
|
|
||||||
<h1>/smirkär/</h1>
|
<body>
|
||||||
</div>
|
<div id="header1" class="colorFade">
|
||||||
<div id="header2">
|
<h1>/smirkär/</h1>
|
||||||
</div>
|
</div>
|
||||||
<div id="sidebar">
|
<div id="header2">
|
||||||
</div>
|
</div>
|
||||||
<div id="mainContainer">
|
<div id="sidebar">
|
||||||
<div id="home" class="optionContainer">
|
</div>
|
||||||
<div id="langSelect" class="card">
|
<div id="mainContainer">
|
||||||
</div>
|
<div id="home" class="optionContainer">
|
||||||
<div id="dataInfo" class="card">
|
<div id="langSelect" class="card">
|
||||||
</div>
|
</div>
|
||||||
<div id="dataTable" class="card">
|
<div id="dataInfo" class="card">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div id="dataTable" class="card">
|
||||||
<div id="dataValues" class="optionContainer">
|
</div>
|
||||||
<div id="langSelect" class="card">
|
</div>
|
||||||
</div>
|
<div id="dataValues" class="optionContainer">
|
||||||
<div id="dataInfo" class="card">
|
<div id="langSelect" class="card">
|
||||||
</div>
|
</div>
|
||||||
<div id="dataTable" class="card">
|
<div id="dataInfo" class="card">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div id="dataTable" class="card">
|
||||||
<div id="files" class="optionContainer">
|
</div>
|
||||||
<div id="langSelect" class="card">
|
</div>
|
||||||
</div>
|
<div id="files" class="optionContainer">
|
||||||
<div id="dataInfo" class="card">
|
<div id="langSelect" class="card">
|
||||||
</div>
|
</div>
|
||||||
<div id="dataTable" class="card">
|
<div id="dataInfo" class="card">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div id="dataTable" class="card">
|
||||||
<div id="updates" class="optionContainer">
|
</div>
|
||||||
<div id="langSelect" class="card">
|
</div>
|
||||||
</div>
|
<div id="updates" class="optionContainer">
|
||||||
<div id="dataInfo" class="card">
|
<div id="langSelect" class="card">
|
||||||
</div>
|
</div>
|
||||||
<div id="dataTable" class="card">
|
<div id="dataInfo" class="card">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div id="dataTable" class="card">
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</div>
|
||||||
<script src="{{ url_for('static', filename='index.js') }}"></script>
|
</div>
|
||||||
|
</body>
|
||||||
|
<script src="{{ url_for('static', filename='index.js') }}"></script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user