Added history traversing and favicon
This commit is contained in:
parent
e944282185
commit
ba629714b8
@ -6,6 +6,7 @@
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<link rel="shortcut icon" href="favicon.png"></link>
|
||||
|
||||
<title>Teascade | blog</title>
|
||||
</head>
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<link rel="shortcut icon" href="favicon.png"></link>
|
||||
|
||||
<title>Teascade | blogtext</title>
|
||||
</head>
|
||||
|
BIN
favicon.png
Normal file
BIN
favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
@ -6,6 +6,7 @@
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<link rel="shortcut icon" href="favicon.png"></link>
|
||||
|
||||
<title>Teascade | games</title>
|
||||
</head>
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<link rel="shortcut icon" href="favicon.png"></link>
|
||||
|
||||
<title>Teascade | about</title>
|
||||
</head>
|
||||
|
41
js/main.js
41
js/main.js
@ -10,23 +10,20 @@ function main(page) {
|
||||
addBlogposts();
|
||||
var search = window.location.search;
|
||||
if (search != "") {
|
||||
search = search.slice(1, -1);
|
||||
var parts = search.split("=");
|
||||
if (parts[0] == "id") {
|
||||
var timestamp = void 0;
|
||||
for (var i in window.blogpostData) {
|
||||
console.log(window.blogpostData[i].source);
|
||||
console.log(search + ".html");
|
||||
if (window.blogpostData[i].source == parts[1] + ".html") {
|
||||
timestamp = new Date(window.blogpostData[i].time).toUTCString();
|
||||
}
|
||||
}
|
||||
setBlogText(parts[1] + ".html", timestamp);
|
||||
setBlogTextOnSearch(search);
|
||||
}
|
||||
window.onpopstate = function () {
|
||||
var page = window.location.pathname.split("/").filter(function (f) { return f != ""; })[0];
|
||||
var search = window.location.search.slice(0, -1);
|
||||
if (page == "blogtext") {
|
||||
setBlogTextOnSearch(search);
|
||||
}
|
||||
openPage(page || "about", page, false);
|
||||
};
|
||||
}
|
||||
function openPage(page, new_url) {
|
||||
function openPage(page, new_url, renew_history) {
|
||||
if (new_url === void 0) { new_url = null; }
|
||||
if (renew_history === void 0) { renew_history = true; }
|
||||
if (page == window.currPage) {
|
||||
return;
|
||||
}
|
||||
@ -42,7 +39,10 @@ function openPage(page, new_url) {
|
||||
targetPg = "";
|
||||
}
|
||||
;
|
||||
if (renew_history) {
|
||||
window.history.pushState(target, target, targetPg + "/");
|
||||
}
|
||||
document.title = "Teascade | " + page;
|
||||
document.getElementsByClassName("stuffarea")[0].scrollTop = 0;
|
||||
slideOpacity(function () {
|
||||
}, 1.5);
|
||||
@ -77,6 +77,21 @@ function addBlogposts() {
|
||||
};
|
||||
});
|
||||
}
|
||||
function setBlogTextOnSearch(search) {
|
||||
search = search.slice(1, -1);
|
||||
var parts = search.split("=");
|
||||
if (parts[0] == "id") {
|
||||
var timestamp = void 0;
|
||||
for (var i in window.blogpostData) {
|
||||
console.log(window.blogpostData[i].source);
|
||||
console.log(search + ".html");
|
||||
if (window.blogpostData[i].source == parts[1] + ".html") {
|
||||
timestamp = new Date(window.blogpostData[i].time).toUTCString();
|
||||
}
|
||||
}
|
||||
setBlogText(parts[1] + ".html", timestamp);
|
||||
}
|
||||
}
|
||||
function setBlogText(source, time) {
|
||||
var xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.onreadystatechange = function () {
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<link rel="shortcut icon" href="favicon.png"></link>
|
||||
|
||||
<title>Teascade | $page$</title>
|
||||
</head>
|
||||
|
43
ts/main.ts
43
ts/main.ts
@ -23,24 +23,21 @@ function main(page: string) {
|
||||
|
||||
let search = window.location.search;
|
||||
if (search != "") {
|
||||
search = search.slice(1, -1);
|
||||
let parts = search.split("=");
|
||||
if (parts[0] == "id") {
|
||||
setBlogTextOnSearch(search);
|
||||
}
|
||||
|
||||
let timestamp: string;
|
||||
for (let i in window.blogpostData) {
|
||||
console.log(window.blogpostData[i].source);
|
||||
console.log(search + ".html");
|
||||
if (window.blogpostData[i].source == parts[1] + ".html") {
|
||||
timestamp = new Date(window.blogpostData[i].time).toUTCString();
|
||||
}
|
||||
}
|
||||
setBlogText(parts[1] + ".html", timestamp);
|
||||
window.onpopstate = () => {
|
||||
let page = window.location.pathname.split("/").filter(f => f != "")[0];
|
||||
let search = window.location.search.slice(0, -1);
|
||||
|
||||
if (page == "blogtext") {
|
||||
setBlogTextOnSearch(search);
|
||||
}
|
||||
openPage(page || "about", page, false);
|
||||
}
|
||||
}
|
||||
|
||||
function openPage(page: string, new_url: string = null) {
|
||||
function openPage(page: string, new_url: string = null, renew_history=true) {
|
||||
if (page == window.currPage) { return; }
|
||||
|
||||
slideOpacity(() => {
|
||||
@ -52,7 +49,10 @@ function openPage(page: string, new_url: string = null) {
|
||||
let targetPg = "/" + target;
|
||||
if (target == "about") { target = ""; targetPg = ""; };
|
||||
|
||||
if (renew_history) {
|
||||
window.history.pushState(target, target, `${targetPg}/`);
|
||||
}
|
||||
document.title = "Teascade | " + page;
|
||||
|
||||
document.getElementsByClassName("stuffarea")[0].scrollTop = 0;
|
||||
|
||||
@ -97,6 +97,23 @@ function addBlogposts() {
|
||||
})
|
||||
}
|
||||
|
||||
function setBlogTextOnSearch(search: string) {
|
||||
search = search.slice(1, -1);
|
||||
let parts = search.split("=");
|
||||
if (parts[0] == "id") {
|
||||
|
||||
let timestamp: string;
|
||||
for (let i in window.blogpostData) {
|
||||
console.log(window.blogpostData[i].source);
|
||||
console.log(search + ".html");
|
||||
if (window.blogpostData[i].source == parts[1] + ".html") {
|
||||
timestamp = new Date(window.blogpostData[i].time).toUTCString();
|
||||
}
|
||||
}
|
||||
setBlogText(parts[1] + ".html", timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
function setBlogText(source: string, time: string) {
|
||||
let xmlhttp = new XMLHttpRequest();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user