-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.js
76 lines (56 loc) · 1.63 KB
/
controller.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const v = new View();
const mode = new Model();
function loadFromServer() {
let req = new XMLHttpRequest();
req.onreadystatechange = function () {
if(req.readyState === 4 && req.status === 200){
let elem=req.responseText;
callback(elem);
}
};
req.open("GET", "https://devweb2020.cis.strath.ac.uk/~gxb18167/MAD/MAD-GP/note.xml", true);
req.send();
}
function callback(elem) {
mode.newRates(elem)
}
window.addEventListener("load", function() {
console.log("loaded: ");
loadFromServer();
v.PastCases();
});
document.addEventListener('touchstart', handleTouchStart, false);
document.addEventListener('touchmove', handleTouchMove, false);
let xDown = null;
let yDown = null;
function getTouches(evt) {
return evt.touches || // browser API
evt.originalEvent.touches; // jQuery
}
function handleTouchStart(evt) {
const firstTouch = getTouches(evt)[0];
xDown = firstTouch.clientX;
yDown = firstTouch.clientY;
}
function handleTouchMove(evt) {
if ( ! xDown || ! yDown ) {
return;
}
let xUp = evt.touches[0].clientX;
let yUp = evt.touches[0].clientY;
let xDiff = xDown - xUp;
let yDiff = yDown - yUp;
if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/
if ( xDiff > 0 ) {
let OpenState = localStorage.getItem("Open");
if(OpenState === "Nav1"){
v.closeNav1();
}
if(OpenState === "Nav2"){
v.closeNav2();
}
}
/* reset values */
xDown = null;
yDown = null;
}}