<?php
/* SPDX-License-Identifier: CC0-1.0 */
/* Copyright (c) 2022 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 Compatibility Matrix of FOSS Licenses</title>
</head>
<body>
<select id="selectleadinglicense" style="display: inline;" onchange="showcompatibility();">
<option selected="selected">Choose a leading license</option>
</select>
<select id="selectsubordinatelicense" style="display: inline;" onchange="showcompatibility();">
<option selected="selected">Choose a subordinate license</option>
</select>
<span id="result"></span>
<span id="help"></span>
<script type="text/javascript" language="javascript">
var jsobject;
var selectleading = document.getElementById("selectleadinglicense");
var selectsubordinate = document.getElementById("selectsubordinatelicense");
function showcompatibility()
{
var result = document.getElementById("result");
var help = document.getElementById("help");
var compatibility;
if (selectleading.selectedIndex == 0 || selectsubordinate.selectedIndex == 0) {
result.innerHTML = "";
help.innerHTML = "";
return;
}
compatibility = jsobject.licenses[selectleading.selectedIndex-1].compatibilities[selectsubordinate.selectedIndex-1].compatibility;
explanation = jsobject.licenses[selectleading.selectedIndex-1].compatibilities[selectsubordinate.selectedIndex-1].explanation;
result.style.fontWeight = "bold";
if (compatibility == "Yes")
result.style.color = "green";
else if (compatibility == "No")
result.style.color = "red";
else if (compatibility == "Check dependency")
result.style.color = "rgb(172, 172, 0)";
else {
result.style.color = "black";
result.style.fontWeight = "normal";
}
if (compatibility == "Same") {
result.innerHTML = "";
help.innerHTML = "";
} else {
result.innerHTML = "<b>Compatibility:</b> " + compatibility;
help.innerHTML = "<br /><br /><b>Reference:</b><br />" + explanation;
}
}
var json = `' . $json . '`;
jsobject = JSON.parse(json);
for (i = 0; i < jsobject.licenses.length; i++) {
var license = jsobject.licenses[i].name;
var eleleading = document.createElement("option");
var elesubordinate = document.createElement("option");
eleleading.textContent = elesubordinate.textContent = license;
selectleading.appendChild(eleleading);
selectsubordinate.appendChild(elesubordinate);
}</script>
</body>
</html>';
?>