Commit e173f76e authored by Michael Ochmann's avatar Michael Ochmann
Browse files

new functions to smallQ

parent e2bc7aef
......@@ -14,7 +14,7 @@
<header>
<a href=#>Zurück</a>
<h2 class=title>HeightTracker</h2>
<a href=#>Info</a>
<a href=# id=about>Info</a>
</header>
<main class=view>
<canvas id=heightmap style="width: 100%; height: 99%; box-sizing: border-box;">
......
......@@ -5,7 +5,6 @@ import Std from "./Std.js";
class App {
constructor() {
if (!navigator.geolocation)
alert("Your browser does not support geo data!");
......@@ -18,6 +17,10 @@ class App {
setInterval(() => {
this.capture();
}, 1000);
$("#about").click(event => {
alert("HeighTracker\n\nTracking GEO height of courses\nin a simple webapp\n\n© 2018, Michael Ochmann");
});
}
capture() {
......
class smallQ {
constructor(selector) {
this.elements = document.querySelectorAll(selector);
if (selector.constructor.name !== "String")
this.elements = [selector];
else
this.elements = document.querySelectorAll(selector);
}
get(id = 0) {
......@@ -26,6 +29,35 @@ class smallQ {
return this;
}
on(event, callback) {
for (let element of this.elements)
element.addEventListener(event, callback);
return this;
}
click(callback) {
return this.on("click", callback);
}
addClass(className) {
for (let element of this.elements)
element.classList.add(className);
return this;
}
removeClass(className) {
for (let element of this.elements)
element.classList.remove(className);
}
each(callback) {
for (let element of this.elements)
callback(new smallQ(element));
}
static $(selector) {
return new smallQ(selector);
}
......
......@@ -18,6 +18,7 @@ body, html {
height: 100%;
-webkit-user-select: none;
user-select: none;
overflow: hidden;
}
body {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment