<commit_before>/***
 * Öffimonitor - display the Wiener Linien timetable for nearby bus/tram/subway
 * lines on a screen in the Metalab Hauptraum
 *
 * Copyright (C) 2015   <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
// vim: set ts=8 noet: Use tabs, not spaces!
"use strict";

/**** table functions ****/
/* these might be prettier in OO, but I really don't care enough right now */
function make_table(head)
{
	var table = document.createElement('table');
	var thead = document.createElement('thead');
	var tbody = document.createElement('tbody');
	var tr = document.createElement('tr');

	for (var i = 0; i < head.length; i++) {
		var td = document.createElement("td");
		td.appendChild(document.createTextNode(head[i]));
		tr.appendChild(td);
	}

	thead.appendChild(tr);
	table.appendChild(thead);
	table.appendChild(tbody);
	return table;
}

function make_row(table, entry)
{
	var currentTime = new Date().getTime();
	var waitTimeString = formatTime(entry.timestamp);
	var waitMs = entry.timestamp - currentTime;
	var waitMinutes = Math.floor(waitMs / 60000);
	var waitSeconds = ((waitMs % 60000) / 1000).toFixed(0);

	if (waitMs < 0 || waitMs < entry.unreachTime*1000) { return false; }

	var tr = document.createElement("tr");
	var tdTime = document.createElement("td");
	if (waitMs < entry.walkTime * 1000) {
		tdTime.className = "time supersoon";
	} else if (waitMs < (entry.walkTime + 180) * 1000) {
		tdTime.className = "time soon";
	} else {
		tdTime.className = "time";
	}

	var tdTimeString = document.createElement("b");
	tdTimeString.appendChild(document.createTextNode(waitTimeString));
	tdTime.appendChild(tdTimeString);

	tdTime.appendChild(document.createTextNode("\u00A0+" + (waitMinutes < 10 ? '0' : '') + waitMinutes + "m" + /*(waitSeconds < 10 ? '0' : '') + */Math.floor(waitSeconds / 10) + "0s"));
	tr.appendChild(tdTime);

	var tdLine = document.createElement("td");

	if (typeof entry.line === "object") {
		tdLine.appendChild(entry.line);
	} else {
		tdLine.appendChild(document.createTextNode(entry.line));
	}
	tr.appendChild(tdLine);

	var tdStop = document.createElement("td");
	tdStop.appendChild(document.createTextNode(entry.stop));
	tr.appendChild(tdStop);

	var tdTowards = document.createElement("td");
	console.log(capitalizeFirstLetter(entry.towards));
	tdTowards.appendChild(document.createTextNode(capitalizeFirstLetter(entry.towards)));
	tr.appendChild(tdTowards);

	table.lastChild.appendChild(tr);<commit_msg>changed format of the remaining waiting time to HH:MM:SS<commit_after>/***
 * Öffimonitor - display the Wiener Linien timetable for nearby bus/tram/subway
 * lines on a screen in the Metalab Hauptraum
 *
 * Copyright (C) 2015   <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
// vim: set ts=8 noet: Use tabs, not spaces!
"use strict";

/**** table functions ****/
/* these might be prettier in OO, but I really don't care enough right now */
function make_table(head)
{
	var table = document.createElement('table');
	var thead = document.createElement('thead');
	var tbody = document.createElement('tbody');
	var tr = document.createElement('tr');

	for (var i = 0; i < head.length; i++) {
		var td = document.createElement("td");
		td.appendChild(document.createTextNode(head[i]));
		tr.appendChild(td);
	}

	thead.appendChild(tr);
	table.appendChild(thead);
	table.appendChild(tbody);
	return table;
}

function make_row(table, entry)
{
	var currentTime = new Date().getTime();
	var waitTimeString = formatTime(entry.timestamp);
	var waitMs = entry.timestamp - currentTime;
	var waitMinutes = Math.floor(waitMs / 60000);
	var waitHours = Math.floor(waitMinutes / 60);
	if (waitHours) {
		waitMinutes -= 60;
	}
	var waitSeconds = ((waitMs % 60000) / 1000).toFixed(0);

	if (waitMs < 0 || waitMs < entry.unreachTime*1000) { return false; }

	var tr = document.createElement("tr");
	var tdTime = document.createElement("td");
	if (waitMs < entry.walkTime * 1000) {
		tdTime.className = "time supersoon";
	} else if (waitMs < (entry.walkTime + 180) * 1000) {
		tdTime.className = "time soon";
	} else {
		tdTime.className = "time";
	}

	var tdTimeString = document.createElement("b");
	tdTimeString.appendChild(document.createTextNode(waitTimeString));
	tdTime.appendChild(tdTimeString);

	tdTime.appendChild(document.createTextNode("\u00A0+" + (waitHours ? waitHours + 'h' : '') + (waitMinutes < 10 ? '0' : '') + waitMinutes + "m" + /*(waitSeconds < 10 ? '0' : '') + */Math.floor(waitSeconds / 10) + "0s"));
	tr.appendChild(tdTime);

	var tdLine = document.createElement("td");

	if (typeof entry.line === "object") {
		tdLine.appendChild(entry.line);
	} else {
		tdLine.appendChild(document.createTextNode(entry.line));
	}
	tr.appendChild(tdLine);

	var tdStop = document.createElement("td");
	tdStop.appendChild(document.createTextNode(entry.stop));
	tr.appendChild(tdStop);

	var tdTowards = document.createElement("td");
	console.log(capitalizeFirstLetter(entry.towards));
	tdTowards.appendChild(document.createTextNode(capitalizeFirstLetter(entry.towards)));
	tr.appendChild(tdTowards);

	table.lastChild.appendChild(tr);
{'fraction_non_alphanumeric': 0.13363765150322682, 'fraction_numerical': 0.016370218794270423, 'mean_word_length': 4.642984014209591, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6561543', 'n_tokens_mistral': 2095, 'n_tokens_neox': 1938, 'n_words': 572}