<?php
/* SPDX-License-Identifier: CC0-1.0 */
/* Copyright (c) 2023 Open Source Automation Development Lab (OSADL) eG <info@osadl.org>, author Carsten Emde */
$json = file_get_contents('http://www.osadl.org/fileadmin/checklists/matrixseqexpl.json');
echo '
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>OSADL Generated Compatibility List of a Given License with Explanations</title>
</head>
<body>
<select id="selectgivenlicense" style="display: inline;" onchange="showlicenses();">
<option selected="selected">Choose a given license</option>
</select>
<select id="selectfilter" style="display: inline;" onchange="showlicenses();">
<option selected="selected">Choose a compatibility filter</option>
</select>
<span id="list"></span>
<script type="text/javascript" language="javascript">
var jsobject;
var givenlicenseselectbox = document.getElementById("selectgivenlicense");
var filterselectbox = document.getElementById("selectfilter");
function showlicenses()
{
var list = document.getElementById("list");
var compatibility;
list.innerHTML = "";
if (givenlicenseselectbox.selectedIndex == 0)
return;
for (license in jsobject.licenses) {
compatibility = jsobject.licenses[givenlicenseselectbox.selectedIndex-1].compatibilities[license].compatibility;
explanation = jsobject.licenses[givenlicenseselectbox.selectedIndex-1].compatibilities[license].explanation;
endspan = "</span></b>";
if (compatibility == "Yes")
startspan = "<br /><b><span style=\"color: green;\">";
else if (compatibility == "No")
startspan = "<br /><b><span style=\"color: red;\">";
else if (compatibility == "Check dependency")
startspan = "<br /><b><span style=\"color: rgb(172, 172, 0);\">";
else {
startspan = "<br /><span style=\"color: black;\">";
endspan ="</span>";
}
if (compatibility != "Same") {
if (filterselectbox.selectedIndex != 0 && compatibility != filter[filterselectbox.selectedIndex - 1])
continue;
list.innerHTML += startspan + jsobject.licenses[license].name + endspan + " ";
list.innerHTML += "(<i>" + explanation + "</i>)<br /> ";
}
}
}
var json = `' . $json . '`;
jsobject = JSON.parse(json);
for (i = 0; i < jsobject.licenses.length; i++) {
var license = jsobject.licenses[i].name;
var eleotherlicense = document.createElement("option");
eleotherlicense.textContent = license;
givenlicenseselectbox.appendChild(eleotherlicense);
}
var filter = ["Yes", "No", "Check dependency", "Unknown"];
for (i = 0; i < filter.length; i++) {
var elefilter = document.createElement("option");
elefilter.textContent = filter[i];
filterselectbox.appendChild(elefilter);
}
</script>
</body>
</html>';
?>