<commit_before>/*
 * Copyright (c) 2016 <NAME> <<EMAIL>>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

function(head, req)
{
	provides("html", function ()
	{
		html = "<!DOCTYPE html><html lang=en><head><title>DDU</title>";
		html += "<style>"
			+ "meter"
			+ "{"
			+	"-webkit-appearance: none;"
			+	"-moz-appearance: none;"
			+	"appearance: none;"
			+	"background: lightgrey;"
			+ "}"
			+ "meter:-moz-meter-optimum::-moz-meter-bar"
			+ "{"
			+	"background: green;"
			+ "}"
			+ "meter:-moz-meter-sub-optimum::-moz-meter-bar"
			+ "{"
			+	"background: yellow;"
			+ "}"
			+ "meter::-webkit-meter-bar"
			+ "{"
			+	"background: lightgrey;"
			+ "}"
			+ "#type-4 meter:-moz-meter-sub-optimum::-moz-meter-bar"
			+ "{"
			+	"background: red;"
			+ "}"
			+ "meter::-webkit-meter-optimum-value"
			+ "{"
			+	"background: green;"
			+ "}"
			+ "meter::-webkit-meter-suboptimum-value"
			+ "{"
			+	"background: yellow;"
			+ "}"
			+ "#type-4 meter::-webkit-meter-suboptimum-value"
			+ "{"
			+	"background: red;"
			+ "}"
			+"</style>";
		html += "</head>";

		// html += "<p>" + JSON.stringify(req) + "</p>";

		function htmltime (datearr)
		{
			var ts = new Date(Date.UTC(datearr[0],
					datearr[1] - 1, datearr[2],
					datearr[3], datearr[4]))
				.toISOString();

			return "<time datetime=" + ts + ">" + ts + "</time>";
		}

		function querystr (qobj)
		{
			qcount = 0;
			qparams = ["semester", "course"];
			qstr = "";

			for (i = 0 ; i < qparams.length ; i++)
			{
				qparam = qparams[i];

				if (qparam in qobj)
				{
					qstr += (!qcount ? "?" : "&amp;");
					qstr += qparam + "=" + qobj[qparam];
					qcount++;
				}
			}

			return qstr;
		}

		function trv_casol (vd)
		{
			return "<td>"
				+ (vd.has_solution_published ? "Yes" : "No")
				+ "</td>";
		}

		function trv_cadu (vd)
		{
			return "<td>" + htmltime(vd.due) + "</td>";
		}

		function trv_casde (vd)
		{
			return trv_casol(vd)
				+ "<td>" + htmltime(vd.delivered) + "</td>";
		}

		function trv_cass (vd)
		{
			frag = "";

			frag += trv_casol(vd);

			if (vd.score_frac)
			{
				frag += "<td><meter min=0"
					+ " max=" + vd.score_frac[1]
					+ " optimum=" + vd.score_frac[1]
					+ " low=" + vd.score_frac[1]
					+ " value=" + vd.score_frac[0] + ">"
					+	vd.score_pct
					+ "</meter></td>";
			}
			else
			{
				frag += "<td>N/A</td>";
			}

			return frag;
		}

		function trv_casdu (vd)
		{
			return trv_casol(vd) + trv_cadu(vd);
		}

		function tr (trv, row)
		{
			frag = "";
			vd = row.value; // View-provided data.

			frag += "<tr>";

			changeq = {};
			if (req.query.course)
			{
				changeq.course = req.query.course;
			}
			if (req.query.semester)
			{
				changeq.semester = req.query.semester;
			}

			if (!req.query.semester)
			{
				changeq.semester = vd.semester;

				frag += "<td><a href='" + req.raw_path
					+ querystr(changeq) + "'>"
						+ vd.semester + "</a></td>";
			}

			frag += "<td>" + vd.course + "</td>";

			frag += "<td><a href=\"" + vd.doc_url + "\">"
				+ vd.title + "</a></td>";

			frag += trv(vd);

			frag += "</tr>";

			return frag;<commit_msg>Pretty-print semester-column.<commit_after>/*
 * Copyright (c) 2016 <NAME> <<EMAIL>>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

function(head, req)
{
	provides("html", function ()
	{
		html = "<!DOCTYPE html><html lang=en><head><title>DDU</title>";
		html += "<style>"
			+ "meter"
			+ "{"
			+	"-webkit-appearance: none;"
			+	"-moz-appearance: none;"
			+	"appearance: none;"
			+	"background: lightgrey;"
			+ "}"
			+ "meter:-moz-meter-optimum::-moz-meter-bar"
			+ "{"
			+	"background: green;"
			+ "}"
			+ "meter:-moz-meter-sub-optimum::-moz-meter-bar"
			+ "{"
			+	"background: yellow;"
			+ "}"
			+ "meter::-webkit-meter-bar"
			+ "{"
			+	"background: lightgrey;"
			+ "}"
			+ "#type-4 meter:-moz-meter-sub-optimum::-moz-meter-bar"
			+ "{"
			+	"background: red;"
			+ "}"
			+ "meter::-webkit-meter-optimum-value"
			+ "{"
			+	"background: green;"
			+ "}"
			+ "meter::-webkit-meter-suboptimum-value"
			+ "{"
			+	"background: yellow;"
			+ "}"
			+ "#type-4 meter::-webkit-meter-suboptimum-value"
			+ "{"
			+	"background: red;"
			+ "}"
			+"</style>";
		html += "</head>";

		// html += "<p>" + JSON.stringify(req) + "</p>";

		function htmltime (datearr)
		{
			var ts = new Date(Date.UTC(datearr[0],
					datearr[1] - 1, datearr[2],
					datearr[3], datearr[4]))
				.toISOString();

			return "<time datetime=" + ts + ">" + ts + "</time>";
		}

		function querystr (qobj)
		{
			qcount = 0;
			qparams = ["semester", "course"];
			qstr = "";

			for (i = 0 ; i < qparams.length ; i++)
			{
				qparam = qparams[i];

				if (qparam in qobj)
				{
					qstr += (!qcount ? "?" : "&amp;");
					qstr += qparam + "=" + qobj[qparam];
					qcount++;
				}
			}

			return qstr;
		}

		function trv_casol (vd)
		{
			return "<td>"
				+ (vd.has_solution_published ? "Yes" : "No")
				+ "</td>";
		}

		function trv_cadu (vd)
		{
			return "<td>" + htmltime(vd.due) + "</td>";
		}

		function trv_casde (vd)
		{
			return trv_casol(vd)
				+ "<td>" + htmltime(vd.delivered) + "</td>";
		}

		function trv_cass (vd)
		{
			frag = "";

			frag += trv_casol(vd);

			if (vd.score_frac)
			{
				frag += "<td><meter min=0"
					+ " max=" + vd.score_frac[1]
					+ " optimum=" + vd.score_frac[1]
					+ " low=" + vd.score_frac[1]
					+ " value=" + vd.score_frac[0] + ">"
					+	vd.score_pct
					+ "</meter></td>";
			}
			else
			{
				frag += "<td>N/A</td>";
			}

			return frag;
		}

		function trv_casdu (vd)
		{
			return trv_casol(vd) + trv_cadu(vd);
		}

		function tr (trv, row)
		{
			frag = "";
			vd = row.value; // View-provided data.

			frag += "<tr>";

			changeq = {};
			if (req.query.course)
			{
				changeq.course = req.query.course;
			}
			if (req.query.semester)
			{
				changeq.semester = req.query.semester;
			}

			if (!req.query.semester)
			{
				changeq.semester = vd.semester;

				sparts = vd.semester.split('/');
				sname = sparts[1].charAt(0).toUpperCase()
					+ sparts[1].slice(1) + " " + sparts[0];

				frag += "<td><a href='" + req.raw_path
					+ querystr(changeq) + "'>"
						+ sname + "</a></td>";
			}

			frag += "<td>" + vd.course + "</td>";

			frag += "<td><a href=\"" + vd.doc_url + "\">"
				+ vd.title + "</a></td>";

			frag += trv(vd);

			frag += "</tr>";

			return frag;
{'fraction_non_alphanumeric': 0.19612152553329024, 'fraction_numerical': 0.005559146735617324, 'mean_word_length': 2.583140342751274, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '522019', 'n_tokens_mistral': 3640, 'n_tokens_neox': 2879, 'n_words': 642}