webtools-js
Version:
Small vanilla webtools in small vanilla es5.
42 lines (41 loc) • 1.32 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>webtools-js tests</title>
</head>
<body>
<h2>webtools-js test</h2>
<ul>
<li>Open in new tab: <a href="https://shaack.com">chessmail.de</a></li>
<li>Open in same tab: <a href="https://shaack.com" target="_self">chessmail.de</a> (target="_self")</li>
<li>Open in same tab: <a href="/">this page</a></li>
<li><span class="linkable" data-href="https://shaack.com">Linkable</span></li>
</ul>
(more tests in console)
<script src="../src/cookie.js"></script>
<script src="../src/event.js"></script>
<script src="../src/http-request.js"></script>
<script src="../src/link.js"></script>
<script>
console.log(wt)
// write a cookie
wt.Cookie.set("testcookie", "123")
// read a cookie
console.log("Cookie", wt.Cookie.get("testcookie"))
// open all links in a new tab
wt.Link.openExternalLinksBlank()
wt.Link.activateLinkables()
wt.HttpRequest.get("test-request.txt", function (response) {
// success
console.log(response)
}, function (errorMessage) {
// failure
console.error(errorMessage)
})
</script>
</body>
</html>