Commit c6651076 authored by Stephan Kreutzer's avatar Stephan Kreutzer

'sos-grid-1' prototype added (early work-in-progress stage).

parent 433c18d3
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2018 William Charlton, Stephan Kreutzer
TODO: What could be the license for this example,
consisting of the format and the example text?
Copyright (C) 2018-2019 William Charlton, Stephan Kreutzer
This file is licensed under the GNU Affero General Public License 3
(https://www.gnu.org/licenses/agpl-3.0.html) + any later version and/or
under the Creative Commons Attribution-ShareAlike 4.0 International
(https://creativecommons.org/licenses/by-sa/4.0/legalcode).
The content of this file is supposed to help to determine the potential
licensing of the format it is encoded in. The work consists of the example
text and the format, if copyrightable. The two license options given above
are an interim solution to render the work usable for now, but can be removed,
changed or expanded in the future. No future change in licensing policy will
have an effect on the rights that are granted to you for this version of the
file as originally released and distributed.
-->
<SOS xmlns="http://www.untiednations.com/SOS" xml:lang="en" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.untiednations.com/XML/SOSMeeting1.xsd">
<POI ID="1" Type="Issue">
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2018 William Charlton, Stephan Kreutzer
TODO: What could be the license for this example,
consisting of the format and the example text?
Copyright (C) 2018-2019 William Charlton, Stephan Kreutzer
This file is licensed under the GNU Affero General Public License 3
(https://www.gnu.org/licenses/agpl-3.0.html) + any later version and/or
under the Creative Commons Attribution-ShareAlike 4.0 International
(https://creativecommons.org/licenses/by-sa/4.0/legalcode).
The content of this file is supposed to help to determine the potential
licensing of all sorts of works. This work consists of the example
text and the format, if copyrightable. The two license options given above
are an interim solution to render the work usable for now, but can be removed,
changed or expanded in the future. No future change in licensing policy will
have an effect on the rights that are granted to you for this version of the
file as originally released and distributed.
-->
<SOS xmlns="http://www.untiednations.com/SOS" xml:lang="en" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.untiednations.com/XML/SOSMeeting1.xsd">
<POI ID="1" Type="Effect">
......
Stephan Kreutzer, Bahnhofstraße 71, 74321 Bietigheim-Bissingen, GERMANY (http://hypertext-systems.org, http://publishing-systems.org, https://skreutzer.de, <skreutzer@fsfe.org>).
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html version="-//W3C//DTD XHTML 1.1//EN" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/1999/xhtml http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/>
<!--
Copyright (C) 2018-2019 Stephan Kreutzer, William Charlton
This file is part of SOS Grid Prototype 1.
SOS Grid Prototype 1 is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3 or any later version,
as published by the Free Software Foundation.
SOS Grid Prototype 1 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 3 for more details.
You should have received a copy of the GNU Affero General Public License 3
along with SOS Grid Prototype 1. If not, see <http://www.gnu.org/licenses/>.
-->
<title>SOS Grid Prototype 1</title>
<meta content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" name="viewport"/>
<script type="text/javascript" src="./js/sos-grid-engine.js"></script>
<script type="text/javascript" src="./js/sos-grid-renderer.js"></script>
<script type="text/javascript" src="./js/sos-grid-navigation.js"></script>
<script type="text/javascript">
"use strict";
// As browsers/W3C/WHATWG are incredibly evil, they might ignore the self-declarative
// XML namespace of this document and the given content type in the header, and instead
// assume/render "text/html", which then fails with JavaScript characters that are
// XML/XHTML special characters which need to be escaped, if the file is saved under
// a name that happens to end with ".html" (!!!). Just have the file name end with
// ".xhtml" and it might magically start to work.
// NavigatePoi() with empty ID string: load the "default" (first) POI.
document.addEventListener("DOMContentLoaded", function() { NavigatePoi(""); });
</script>
</head>
<body>
<div id="grid"/>
<!--
As the stupid browser execution environment is sandboxed, local files can't
be dynamically read from disk, and if we're forced to load the entire source
into memory anyway because of this, if it's XML, we could easily put it into
the DOM instead of parsing XML from a JavaScript variable. This interferes
with GUI work in this XHTML file, but if the XML source would need to be
escaped to be a JavaScript string literal, a conversion is unavoidable, so
this file here could just as well be the result of a conversion from the source.
-->
<div id="sos-input" style="display:none;">
<sos:SOS xmlns:sos="http://www.untiednations.com/SOS" xml:lang="en" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.untiednations.com/XML/SOSMeeting1.xsd">
<sos:POI ID="1" Type="Effect">
<sos:Parent Parent-ID="2"/>
<sos:Parent Parent-ID="4"/>
<sos:Parent Parent-ID="5"/>
<sos:Title>Copyright Law</sos:Title>
<sos:Text>Copyright law has been passed in most given jurisdictions.</sos:Text>
</sos:POI>
<sos:POI ID="2" Type="Effect">
<sos:Title>Software multiplies</sos:Title>
<sos:Text>Software like many other types of works is immaterial and not bound to physical limitations/scarcity. Every act of distribution to another entity results in a duplication (copying).</sos:Text>
</sos:POI>
<sos:POI ID="3" Type="Effect">
<sos:Title>Copying technology is cheaply available</sos:Title>
<sos:Text>Most people can afford to buy copying equipment and know how to operate it.</sos:Text>
</sos:POI>
<sos:POI ID="4" Type="Effect">
<sos:Title>Copying is cheap</sos:Title>
<sos:Text>Producing another copy (another unit of the good) is almost gratis, if the producer owns or has access to copying equipment.</sos:Text>
</sos:POI>
<sos:POI ID="5" Type="Effect">
<sos:Parent Parent-ID="2"/>
<sos:Parent Parent-ID="3"/>
<sos:Parent Parent-ID="4"/>
<sos:Title>Selling software is difficult</sos:Title>
<sos:Text>The business model of selling software faces a lot of competition from gratis offers of the identical product.</sos:Text>
</sos:POI>
<sos:POI ID="6" Type="Effect">
<sos:Parent Parent-ID="1"/>
<sos:Parent Parent-ID="5"/>
<sos:Title>Copyright law is enforcable</sos:Title>
<sos:Text>Copyright law can be enforced selectively with severe penalties for infringement against companies and individuals.</sos:Text>
</sos:POI>
<sos:POI ID="7" Type="Effect">
<sos:Parent Parent-ID="2"/>
<sos:Parent Parent-ID="3"/>
<sos:Title>Copyright law isn’t enforcable</sos:Title>
<sos:Text>The state has no mechanisms available to gain knowledge about copyright infringement or interfere with it, other than investigation and after-the-fact persecution.</sos:Text>
</sos:POI>
<sos:POI ID="8" Type="Effect">
<sos:Parent Parent-ID="9"/>
<sos:Title>Binary executables are difficult to modify</sos:Title>
<sos:Text>Software can exist in the form of a binary executable (primitive instructions for a computer processor). It is very expensive and difficult to modify (especially big) applications in this form.</sos:Text>
</sos:POI>
<sos:POI ID="9" Type="Effect">
<sos:Parent Parent-ID="10"/>
<sos:Title>Source code can be compiled into a binary executable</sos:Title>
<sos:Text>A compiler can translate language constructs of software in the form of source code into a binary executable (primitive instructions for a computer processor).</sos:Text>
</sos:POI>
<sos:POI ID="10" Type="Effect">
<sos:Title>Source code is easy to modify</sos:Title>
<sos:Text>Software can exist in the form of source code (high-level instructions in a programming language). It is easy to modify software in this form.</sos:Text>
</sos:POI>
<sos:POI ID="11" Type="Effect">
<sos:Parent Parent-ID="10"/>
<sos:Parent Parent-ID="7"/>
<sos:Title>Software in the form of source code can be run with an interpreter</sos:Title>
<sos:Text>Source code (high-level instructions in a programming language) can be read by a binary executable which is an interpreter, and the interpreter enacts the corresponding primitive processor instructions for each high-level source code instruction.</sos:Text>
</sos:POI>
<sos:POI ID="12" Type="Effect">
<sos:Parent Parent-ID="8"/>
<sos:Title>Software in the form of a binary executable can be run directly</sos:Title>
<sos:Text>Binary executables are comprised of instructions for a particular computer processor, which can run them directly.</sos:Text>
</sos:POI>
<sos:POI ID="13" Type="Effect">
<sos:Parent Parent-ID="6"/>
<sos:Title>The user is allowed to modify the software</sos:Title>
</sos:POI>
<sos:POI ID="14" Type="Effect">
<sos:Parent Parent-ID="6"/>
<sos:Title>The user isn’t allowed to modify the software</sos:Title>
</sos:POI>
<sos:POI ID="15" Type="Effect">
<Parent Parent-ID="11"/>
<sos:Title>The user is enabled to modify the software</sos:Title>
</sos:POI>
<sos:POI ID="16" Type="Effect">
<sos:Parent Parent-ID="8"/>
<sos:Title>The user isn’t enabled to modify the software</sos:Title>
</sos:POI>
</sos:SOS>
</div>
</body>
</html>
/* Copyright (C) 2019 Stephan Kreutzer
*
* This file is part of SOS Grid Prototype 1.
*
* SOS Grid Prototype 1 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 or any later
* version of the license, as published by the Free Software Foundation.
*
* SOS Grid Prototype 1 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 3 for more details.
*
* You should have received a copy of the GNU Affero General Public License 3
* along with SOS Grid Prototype 1. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
function SosGridEngine() {
let that = this;
// Pass the ID of the POI, which is a string. Empty string to get the first,
// default POI. Returns null if POI can't be obtained.
// TODO: When requesting the default, the actual ID of the first POI should
// be in the returned Poi object.
that.getPoiById = function(id) {
if (typeof id !== 'string' && !(id instanceof String)) {
id = "";
}
if (_loaded == false) {
_load();
}
if (_loaded == false) {
throw "Loading failed."
}
let poiSource = null;
if (typeof document.querySelectorAll != "undefined") {
if (id.length <= 0) {
// Evil browsers/web/W3C: no support for namespaces in querySelectorAll().
// See https://www.w3.org/TR/selectors-api/#resolving-namespaces
let result = document.querySelectorAll("POI");
for (let i = 0; i < result.length; i++) {
if (result[i].namespaceURI == "http://www.untiednations.com/SOS") {
poiSource = result[i];
break;
}
}
} else {
// Evil browsers/web/W3C: no support for namespaces in querySelectorAll().
// See https://www.w3.org/TR/selectors-api/#resolving-namespaces
let result = document.querySelectorAll("POI[ID='" + id + "']");
let pois = new Array();
for (let i = 0; i < result.length; i++) {
if (result[i].namespaceURI == "http://www.untiednations.com/SOS") {
pois.push(result[i]);
}
}
if (pois.length <= 0) {
} else if (pois.length > 1) {
throw "'ID' attribute value '" + id + "' of a POI found more than once.";
}
poiSource = pois[0];
}
} else {
if (id.length <= 0) {
if (_poiMapping.length > 0) {
poiSource = _poiMapping[0];
} else {
return null;
}
} else {
if (!(id in _poiMapping)) {
return null;
}
poiSource = _poiMapping[id];
}
}
if (poiSource == null) {
return null;
}
let title = null;
let description = null;
let parents = new Array();
let children = new Array();
for (let i = 0; i < poiSource.children.length; i++) {
let child = poiSource.children[i];
if (child.namespaceURI != "http://www.untiednations.com/SOS") {
continue;
}
if (child.tagName == "sos:Title") {
if (title != null) {
throw "POI contains more than one Title.";
}
title = child.textContent;
} else if (child.tagName == "sos:Text") {
if (description != null) {
throw "POI contains more than one Text.";
}
description = child.textContent;
} else if (child.tagName == "sos:Parent") {
if (child.hasAttribute("Parent-ID") != true) {
throw "Parent of a POI is missing its 'Parent-ID' attribute.";
}
let parentId = child.getAttribute("Parent-ID");
if (parentId.length <= 0) {
throw "'Parent-ID' attribute value is empty.";
}
if (parents.includes(parentId) == true) {
throw "'Parent-ID' attribute value '" + parentId + "' more than once.";
}
if (parentId === id) {
throw "POI with ID '" + id + "' can't be its own parent.";
}
parents.push(parentId);
}
}
return new Poi(title, description, parents, children);
}
function _load() {
if (_loaded != false) {
return true;
}
if (typeof document.querySelectorAll != "undefined") {
_loaded = true;
return true;
}
// Stupid JavaScript/web/browsers: document.getElementsByTagNameNS()
// seems to not work with XML namespace prefixes.
let inputXml = document.getElementsByTagName("sos:SOS");
if (inputXml !== null) {
if (inputXml.length > 0) {
inputXml = inputXml[0].children;
if (inputXml.length > 0) {
for (let i = 0; i < inputXml.length; i++) {
if (inputXml[i].tagName != "sos:POI") {
console.log("Embedded SOS data: Tag '" + inputXml[i].tagName + "' ignored.");
continue;
}
if (inputXml[i].hasAttribute("ID") != true) {
throw "Embedded SOS data: Tag '" + inputXml[i].tagName + "' is missing its 'ID' attribute.";
}
let id = inputXml[i].getAttribute("ID");
if (id.length <= 0) {
throw "Embedded SOS data: Empty 'ID' attribute of '" + inputXml[i].tagName + "'.";
}
if (id in _poiMapping) {
throw "'ID' attribute value '" + id + "' of a '" + inputXml[i].tagName + "' found more than once.";
}
// Note: In contrast to querySelectorAll(), getElementsByTagName() returns a *live*
// HTMLCollection, so changes to the source affect _poiMapping.
_poiMapping[id] = inputXml[i];
}
_loaded = true;
} else {
console.log("Embedded SOS data: Is empty.");
}
}
}
}
let _loaded = false;
let _poiMapping = new Array();
}
function Poi(title, description, parents, children) {
// TODO: Properly check if parents and chilren are Arrays, and throw exception if not.
let that = this;
that.getTitle = function() {
return _title;
}
that.getText = function() {
return _description;
}
that.getParents = function() {
return _parents;
}
let _title = title;
let _description = description;
// IDs (strings).
let _parents = parents;
// IDs (strings).
let _children = children;
}
/* Copyright (C) 2019 Stephan Kreutzer
*
* This file is part of SOS Grid Prototype 1.
*
* SOS Grid Prototype 1 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 or any later
* version of the license, as published by the Free Software Foundation.
*
* SOS Grid Prototype 1 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 3 for more details.
*
* You should have received a copy of the GNU Affero General Public License 3
* along with SOS Grid Prototype 1. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
let currentPoi = null;
let gridEngine = new SosGridEngine();
function NavigatePoi(poiId) {
currentPoi = null;
let poi = gridEngine.getPoiById(poiId);
if (poi == null) {
throw "Loading a POI failed.";
}
if (RenderPoi(poi, "grid") == true) {
currentPoi = poiId;
}
return true;
}
/* Copyright (C) 2019 Stephan Kreutzer
*
* This file is part of SOS Grid Prototype 1.
*
* SOS Grid Prototype 1 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 or any later
* version of the license, as published by the Free Software Foundation.
*
* SOS Grid Prototype 1 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 3 for more details.
*
* You should have received a copy of the GNU Affero General Public License 3
* along with SOS Grid Prototype 1. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
function RenderPoi(poi, targetId) {
let target = document.getElementById(targetId);
if (target == null) {
return false;
}
/*
while (target.hasChildNodes() == true) {
target.removeChild(target.lastChild);
}
*/
let container = document.createElement("div");
let title = document.createTextNode(poi.getTitle() + " ");
container.appendChild(title);
let parents = poi.getParents();
for (let i = 0; i < parents.length; i++) {
let parentNavigation = document.createElement("a");
parentNavigation.setAttribute("href", "#");
// TODO: Prevent injection (any maybe at other places, too).
parentNavigation.setAttribute("onclick", "NavigatePoi(\"" + parents[i] + "\");");
let caption = document.createTextNode(parents[i]);
parentNavigation.appendChild(caption);
container.appendChild(parentNavigation);
container.appendChild(document.createTextNode(" "));
}
container.appendChild(document.createElement("hr"));
target.appendChild(container);
return true;
}
Markdown is supported
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