mirror of
https://github.com/AleziaKurdis/Overte-community-apps.git
synced 2025-08-21 03:27:45 +02:00
222 lines
No EOL
5.7 KiB
HTML
222 lines
No EOL
5.7 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Applications Metadata Generator ("metadata.js")</title>
|
|
</head>
|
|
<script type="text/javascript" src="../applications/metadata.js"></script>
|
|
<style>
|
|
h1 {
|
|
font-size: 24px;
|
|
color: #CFB538;
|
|
font-weight: 800;
|
|
text-decoration: none;
|
|
font-style: normal;
|
|
font-variant: normal;
|
|
text-transform: none;
|
|
}
|
|
|
|
font.error {
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
font-size: 16px;
|
|
color: #FF0000;
|
|
font-weight: 700;
|
|
text-decoration: none;
|
|
font-style: normal;
|
|
font-variant: normal;
|
|
text-transform: none;
|
|
}
|
|
|
|
input {
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
font-size: 12px;
|
|
color: #000000;
|
|
font-weight: 500;
|
|
text-decoration: none;
|
|
font-style: normal;
|
|
font-variant: normal;
|
|
text-transform: none;
|
|
}
|
|
|
|
textarea {
|
|
width: 100%;
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
font-size: 12px;
|
|
color: #000000;
|
|
font-weight: 500;
|
|
text-decoration: none;
|
|
font-style: normal;
|
|
font-variant: normal;
|
|
text-transform: none;
|
|
}
|
|
|
|
textarea.output {
|
|
background: #ffff66;
|
|
width: 100%;
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
font-size: 12px;
|
|
color: #000000;
|
|
font-weight: 700;
|
|
text-decoration: none;
|
|
font-style: normal;
|
|
font-variant: normal;
|
|
text-transform: none;
|
|
}
|
|
|
|
|
|
body {
|
|
background: #3E415E;
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
font-size: 12px;
|
|
color: #FFFFFF;
|
|
font-weight: 600;
|
|
text-decoration: none;
|
|
font-style: normal;
|
|
font-variant: normal;
|
|
text-transform: none;
|
|
}
|
|
|
|
input[type="button"]:disabled {
|
|
color: #bbbbbb;
|
|
}
|
|
|
|
</style>
|
|
<body>
|
|
<h1>Applications Metadata Generator ("metadata.js")</h1>
|
|
<form name = 'gen'>
|
|
Directory name: <input type = 'text' size = '60' maxlength="50" name='directory'> (without any path.)<br><br><br>
|
|
|
|
|
|
|
|
Application Name: <input type = 'text' size = '60' maxlength="50" name='name'><br><br>
|
|
|
|
|
|
Application Description: <br><textarea name ='description' rows = '6' style = 'width:90%;' maxlength="1000"></textarea><br><br><br>
|
|
|
|
|
|
Main javascript file name: <input type = 'text' size = '60' maxlength="60" name='jsfilename'> (without any path.)<br><br><br>
|
|
|
|
Icon file name: <input type = 'text' size = '60' maxlength="60" name='icon'> (without any path.)<br>
|
|
Caption: <input type = 'text' size = '30' maxlength="12" name='caption'><br><br><br>
|
|
|
|
|
|
|
|
<input name = 'generate' type = 'button' onclick = 'genCode();' value ='Generate'><br><br>
|
|
<div id = 'errormessage'><font class = 'error'> </font></div><br><br>
|
|
<hr><br>INSTRUCTIONS:<br><br>
|
|
1- The file "metadata.js" must replace the current one in the "applications" folder. (The one where all the application's subfolders are stored)<br><br><br>
|
|
|
|
<input name = 'dlapp' type = 'button' onclick = 'downloadFile(document.gen.appCode.value, "metadata.js", "application/javascript");' value ='Download metadata.js'><br><br>
|
|
<textarea class = 'output' name ='appCode' rows = '12' style='width:90%;' readonly></textarea>
|
|
|
|
|
|
|
|
</form>
|
|
<script>
|
|
|
|
String.prototype.escapeJSON = function() {
|
|
var result = "";
|
|
for (var i = 0; i < this.length; i++)
|
|
{
|
|
var ch = this[i];
|
|
switch (ch)
|
|
{
|
|
case "\\": ch = "\\\\"; break;
|
|
case "\'": ch = "\\'"; break;
|
|
case "\"": ch = '\\"'; break;
|
|
case "\&": ch = "\\&"; break;
|
|
case "\t": ch = "\\t"; break;
|
|
case "\n": ch = "\\n"; break;
|
|
case "\r": ch = "\\r"; break;
|
|
case "\b": ch = "\\b"; break;
|
|
case "\f": ch = "\\f"; break;
|
|
case "\v": ch = "\\v"; break;
|
|
default: break;
|
|
}
|
|
|
|
result += ch;
|
|
}
|
|
|
|
return result;
|
|
};
|
|
|
|
function CheckAllowedChar(str){
|
|
var allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";
|
|
var ii;
|
|
for(ii = 0; ii < str.length; ii = ii + 1 ){
|
|
if(allowed.indexOf(str.charAt(ii)) == -1){
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function downloadFile(theContent, filename, type) {
|
|
var element = document.createElement('a');
|
|
element.href = window.URL.createObjectURL(new Blob([theContent], {type: '' + type }));
|
|
element.download = filename;
|
|
// Append anchor to body.
|
|
document.body.appendChild(element);
|
|
element.click();
|
|
|
|
// Remove anchor from body
|
|
document.body.removeChild(element);
|
|
}
|
|
|
|
|
|
document.gen.dlapp.disabled = true;
|
|
|
|
|
|
function genCode(){
|
|
var errormessage = " ";
|
|
var name = document.gen.name.value;
|
|
var description = document.gen.description.value;
|
|
var jsfilename = document.gen.jsfilename.value;
|
|
var icon = document.gen.icon.value;
|
|
var caption = document.gen.caption.value;
|
|
var directory = document.gen.directory.value;
|
|
var appJsCode = "";
|
|
var metaJsCode = "";
|
|
document.gen.dlapp.disabled = true;
|
|
|
|
|
|
caption = caption.toUpperCase();
|
|
|
|
if (directory == "" || name == "" || description == "" || jsfilename == "" || icon == "" || caption == ""){
|
|
errormessage = "Error: Something is missing. All the fields are mandatory.";
|
|
}else{
|
|
if (CheckAllowedChar(directory) == false){
|
|
errormessage = "Error: The directory name must not contain spce or special characters. (Allowed: a-z, A-Z, 0-9, -, _ )";
|
|
}else{
|
|
appJsCode = {
|
|
"directory": directory,
|
|
"name": name.escapeJSON(),
|
|
"description": description.escapeJSON(),
|
|
"jsfile": directory + "/" + jsfilename,
|
|
"icon": directory + "/" + icon,
|
|
"caption": caption.escapeJSON()
|
|
};
|
|
|
|
|
|
}
|
|
|
|
//add entry to current metadata
|
|
var newMetadata = JSON.parse(JSON.stringify(metadata));
|
|
newMetadata.applications.push(appJsCode);
|
|
|
|
metaJsCode = "var metadata = " + JSON.stringify(newMetadata) + ";";
|
|
|
|
document.gen.dlapp.disabled = false;
|
|
|
|
|
|
}
|
|
document.gen.appCode.value = metaJsCode;
|
|
|
|
|
|
document.getElementById("errormessage").innerHTML = "<font class = 'error'>" + errormessage + "</font>";
|
|
|
|
}
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html> |