Moto APP

Ride with us.

by marakoss

HTML

<template>
  <item>
  <header>
  <datetime>
  <span>
  <date></date>
  <time></time>
  </span>
  </datetime>
  <title></title>
  <length></length>
  </header>
  </item>
</template>
<loading></loading>
<list>

</list>
<map>
<iframe>
</iframe>
</map>

CSS

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  line-height: 1;
  font-family: sans-serif;
  font-weight: 200;
 }

list, item {
  display: block;
  margin: 0;
  padding: 0;
}

list {
  max-width: 18em;
  position: relative;
  z-index: 2;
  display: inline-block;
}

list:before {
  content: "";
  display: block;
  position: absolute;
  z-index: 1;
  left: 0;
  top: 0;
  width: 3.5em;
  height: 100%;
  background: #3a4;
  background: linear-gradient(to bottom, #006700 0%, #008a00 30%, #52b152 70%, #83c783 100%);
  opacity: 0;
  animation: 2s fadeIn;
  animation-fill-mode: forwards;
  animation-delay: 2s;
}

item {
  position: relative;
  z-index: 1;
  min-height: 10vh;
  cursor: pointer;
  border-bottom: 1px solid #eee;
}

a {
  display: block;
}

map {
  position: fixed;
  top: 0;
  left: 18em;
  right: 0;
  bottom: 0;
  z-index: 1;
  background: #eee;
  box-shadow: inset 10px 0px 10px rgba(0, 0, 0, 0.1);
}

h1, h2, h3, h4, h5, h6 {
  font-size: 100%;
  font-weight: normal;
  padding: 0;
  margin: 0;
}

header {
  margin-left: 3.5em;
  background: #fff;
  transition: all 0.15s ease;
}

header:hover {
  background: #f0fff5;
}

title {
  display: block;
  padding: 10px;
  font-size: 90%;
  font-weight: 400;
  line-height: 1.2;
  min-height: 10vh;
}

.old datetime {
  background: rgba(80, 80, 80, 0.9);
}

datetime {
  display: flex;
  position: absolute;
  align-items: center;
  text-align: center;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3.5em;
  color: #fff;
  background: rgba(0, 0, 0, 0.1);
}

date {
  width: 100%;
  display: inline-block;
  font-weight: 800;
}

time {
  font-size: 70%;
}

length {
  display: block;
  width: 100%;
  font-size: 70%;
  padding: 0 10px 10px 10px;
  margin: 0;
  text-align: right;
}

iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: none;
  display: none;
}

.show {
  display: block;
}

loading {
  display: inline-block;
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 999;
  width:...

JavaScript

var url = 'https://script.googleusercontent.com/macros/echo?user_content_key=xImgc0CgTkUQY28yNUiTPvYbIVxg6qwBYe4gNusJW1tbsv4IyIoqcRQYkTcdUWe6LlgPAelUXqJpprsfrvJUfAkoxp56utcmm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnAZD-N8SueqPwGZREMLrB-0aTrPaenDlP_KzR-zAm5o3tfpDrlaQBy_gSjXx2R-FXdveWPraiRQB&lib=MB1qlcCCsYnDGoju2zxiHH94OpwxjUQjM';

function createTemplate() {
var temp = document.getElementsByTagName("template")[0];
  return temp.content.cloneNode(true);
}



function handle(response) {
	var list = document.getElementsByTagName("list")[0];
  
	document.querySelector('loading').style.display = "none";
  
//  console.log(response);
  for (var row in response) {

		var template = createTemplate();
    var item = template.querySelector('item');

    var datetime = new Date(response[row][1]);
    // skip older items
    if (datetime < new Date()){
    	item.classList.add("old"); 
    }

    var url = response[row][3];
		item.setAttribute("data-url", url);
		item.onclick = function() {
			var frame = document.querySelector("iframe");
      var url = this.getAttribute('data-url');
			frame.setAttribute('src', url);
    	frame.classList.add("show"); 
    };

		if (url == '') {
				document.querySelector("iframe").classList.remove("show");
		}

  	template.querySelector('title').innerHTML = response[row][2];
    template.querySelector('length').innerHTML = response[row][4]+'km';
		template.querySelector('date').innerHTML = datetime.getDate()+'.&nbsp;'+(datetime.getMonth()+1);
		template.querySelector('time').innerHTML = datetime.getHours()+':'+(datetime.getMinutes()<10?'0':'') + datetime.getMinutes();

  	list.appendChild(template);
    
  }
}

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
			handle(       JSON.parse(xhttp.responseText));
    }
};
xhttp.open("GET", url, true);
xhttp.send();