made frontend bookmarkable

This commit is contained in:
Askill 2020-05-13 11:38:13 +02:00
parent f8f04410ad
commit d03131adf0
2 changed files with 40 additions and 19 deletions

View File

@ -1,15 +1,34 @@
var rl
function checkforURLParam(){
try {
let url = window.location.href
params = url.split("?")[1]
if (params !== undefined){
params = "?" + params
loadRecipes(params)
}
} catch (error) {
console.log(error)
}
}
function loadData() {
// make string of get params for request
getParams = makeGetParamString()
window.location = window.location.href.split("?")[0] + getParams
}
function loadRecipes(getParams){
rl = document.getElementById("recipe-list")
rl.innerHTML = '<div class="loader"></div>'
document.getElementById("main").className += " data-loaded"
// make string of get params for request
getParams = makeGetParamString()
getJSON("/api/v1/recipe/" + getParams,
function (error, data) {
data = data["data"] // remove wrapper

View File

@ -48,7 +48,9 @@
</div>
</div>
<script type="text/javascript">
checkforURLParam()
</script>
</body>