Adapt code for PVMT and fix ga
Change-Id: I06a51f47d67ec801920b7d38cbadc1ac7d430f6e
Signed-off-by: Philippe DUL <philippe.dul@thalesgroup.com>
diff --git a/addons.html b/addons.html
index 84f7791..a142143 100644
--- a/addons.html
+++ b/addons.html
@@ -169,13 +169,24 @@
document.getElementById(divId).innerHTML += "<div><h1>" + title + "</h1>" + desc + "</div>";
}
- function addAddonSection(data, addon, divId) {
- let keys = Object.keys(addon.download);
- let fragment = addon.fragment != undefined ? addon.fragment : addon.key;
- let links = keys.map(function(k) {
- let icon = data.lang[k].icon ? '<i class="pl-2 {0}" aria-hidden="true"></i>'.format(data.lang[k].icon) : "";
- return '<a href="{0}" target="{1}" onClick="ga("send", "event", "Capella", "{2}", "{3}");">{4}{5}</a>'.format(addon.download[k], data.lang[k].target, data.versionBranch, addon.key, data.lang[k].text, icon);
+ function createKeysLinks(data, addon, download, icons) {
+ let keys = Object.keys(download).filter(x => x != "notes");
+ let links = keys.map(function(k) {
+ let icon = icons == undefined && data.lang[k].icon ? '<i class="pl-2 {0}" aria-hidden="true"></i>'.format(data.lang[k].icon) : "";
+ if (data.lang[k].target == "_expand") {
+ return '<a data-toggle="collapse" data-target="#collapse-notes-{3}">{4}{5}</a>'.format(download[k], data.lang[k].target, data.versionBranch, addon.key, data.lang[k].text, icon);
+ } else if (Array.isArray(download[k])) {
+ let value = download[k];
+ return data.lang[k].text + "s"+ icon + " (" + value.map(x => '<a href="{0}" onClick="ga(\'send\', \'event\', \'Capella\', \'{1}\', \'{2}\');">{3}</a>'.format(x.url, data.versionBranch, addon.key, x.name)).join(" + ")+")";
+ }
+ return '<a href="{0}" {1} onClick="ga(\'send\', \'event\', \'Capella\', \'{2}\', \'{3}\');">{4}{5}</a>'.format(download[k], data.lang[k].target == undefined ? "" : 'target="'+data.lang[k].target+'}"', data.versionBranch, addon.key, data.lang[k].text, icon);
}).join(" - ");
+ return links;
+ }
+
+ function addAddonSection(data, addon, divId) {
+ let keys = Object.keys(addon.download);
+ let links = createKeysLinks(data, addon, addon.download);
let header = [];
if (addon.contact) {
header.push("Contact: "+addon.contact);
@@ -194,12 +205,18 @@
let compatible = addon.compatibleWithCurrentVersion === false ? '<button role="button" class="fa fa-exclamation-triangle btn-link btn-xs alert-compatibility" data-toggle="tooltip" data-placement="bottom" title="{0}" ></button>'.format(data.lang.compatibility.text) : "";
let addonName = addon.isViewpoint ? addon.name + " Viewpoint" : addon.name;
-
+ let fragment = addon.fragment != undefined ? addon.fragment : addon.key;
+
let dropdown = '<div class="accordion-heading"><a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion2" href="#{0}"><h3>{1}</h3><span class="fa fa-caret-down txt_yellow"> </span><span class="descr txt_lightest_grey">{2}</span></a></div>'.format(fragment, addonName, header);
- let content = '<div id="{0}" class="accordion-body collapse" style="height: 0px;"><div class="accordion-inner">{1}<p>{2}{3}</p></div></div>'.format(fragment, addon.description, compatible, links);
- let result = '<div class="accordion-group">{0}{1}</div>'.format(dropdown, content);
+ let sections = keys.filter(k => data.lang[k].target == "_expand").map(function(k) {
+ let div = '<div class="collapse notes-section" id="collapse-notes-'+addon.key+'"><h3>'+data.lang[k].text+'</h3>'+createKeysLinks(data, addon, addon.download[k])+addon.download[k]["notes"]+'</div>';
+ return div;
+ }).join("");
+ let content = '<div id="{0}" class="accordion-body collapse" style="height: 0px;"><div class="accordion-inner">{1}<p>{2}{3}</p>{4}</div></div>'.format(fragment, addon.description, compatible, links, sections);
+ let result = '<div class="accordion-group">{0}{1}</div>'.format(dropdown, content);
+
document.getElementById(divId).innerHTML += result;
$('[data-toggle="popover"]').popover( { html: true, container: 'body' });
diff --git a/css/main.css b/css/main.css
index 3cdfc6e..fd710c0 100644
--- a/css/main.css
+++ b/css/main.css
@@ -1029,4 +1029,29 @@
border: 1px solid #292253;
background-color: #292253;
color:#FBBF52;
+}
+
+
+.notes-section {
+ text-align: left;
+ padding: 12px;
+ border: 1px solid #CCCCCC;
+ border-radius: 6px;
+ background-color: #FFFFFF;
+}
+.notes-section p, .notes-section a, .notes-section li {
+ font-size: 12px;
+}
+.notes-section h3 {
+ font-size: 16px;
+}
+.notes-section ul {
+ padding-left: 14px;
+}
+.notes-section h4 {
+ font-size: 14px;
+}
+.notes-section h1, .notes-section h2, .notes-section h3, .notes-section h4, .notes-section h5, .notes-section h6 {
+ margin-top: 6px !important;
+ color: #292253;
}
\ No newline at end of file
diff --git a/download.html b/download.html
index 696a568..a91446c 100644
--- a/download.html
+++ b/download.html
@@ -268,6 +268,21 @@
document.getElementById(platformLinksId).innerHTML += lis;
}
+ function createKeysLinks(data, addon, download, icons) {
+ let keys = Object.keys(download).filter(x => x != "notes");
+ let links = keys.map(function(k) {
+ let icon = icons == undefined && data.lang[k].icon ? '<i class="pl-2 {0}" aria-hidden="true"></i>'.format(data.lang[k].icon) : "";
+ if (data.lang[k].target == "_expand") {
+ return '<a data-toggle="collapse" data-target="#collapse-notes-{3}">{4}{5}</a>'.format(download[k], data.lang[k].target, data.versionBranch, addon.key, data.lang[k].text, icon);
+ } else if (Array.isArray(download[k])) {
+ let value = download[k];
+ return data.lang[k].text + "s"+ icon + " (" + value.map(x => '<a href="{0}" onClick="ga(\'send\', \'event\', \'Capella\', \'{1}\', \'{2}\');">{3}</a>'.format(x.url, data.versionBranch, addon.key, x.name)).join(" + ")+")";
+ }
+ return '<a href="{0}" {1} onClick="ga(\'send\', \'event\', \'Capella\', \'{2}\', \'{3}\');">{4}{5}</a>'.format(download[k], data.lang[k].target == undefined ? "" : 'target="'+data.lang[k].target+'}"', data.versionBranch, addon.key, data.lang[k].text, icon);
+ }).join(" - ");
+ return links;
+ }
+
function updateAddonLinks(data) {
let addons = "";
let sample = "";
@@ -275,12 +290,8 @@
for (i in filteredAddons) {
let addon = filteredAddons[i];
let keys = Object.keys(addon.download);
- let links = keys.map(function(k) {
- let icon = ""; //data.lang[k].icon ? `<i class="pl-2 ${data.lang[k].icon}" aria-hidden="true"></i>` : "";
- return '<a href="{0}" onClick="ga(\'send\', \'event\', \'Capella\', \'{1}\', \'{2}\');">{3}{4}</a>'.format(addon.download[k], data.versionBranch, addon.key, data.lang[k].text, icon);
- }).join(" - ");
-
- let header = [];
+ let links = createKeysLinks(data, addon, addon.download, false);
+ let header = [];
if (addon.contact) {
header.push('Contact: '+addon.contact);
}
@@ -294,7 +305,13 @@
let information2 = '<button role="button" class="fa fa-info-circle btn-link btn-xs " data-toggle="popover" data-trigger="focus" data-placement="bottom" title="{0}" data-content="{1}"></button>'.format(addon.name, information);
let addonName = addon.isViewpoint ? addon.name + " Viewpoint" : addon.name;
- let result = '<p class="wow fadeInUp animated" data-wow-delay=".3s">{0} {1}<br/><span class="small pl-2">{2}{3}</span></p><br/>'.format(addonName, information2, compatible, links);
+
+ let sections = keys.filter(k => data.lang[k].target == "_expand").map(function(k) {
+ let div = '<div class="collapse notes-section" id="collapse-notes-'+addon.key+'"><h3>'+data.lang[k].text+'</h3>'+createKeysLinks(data, addon, addon.download[k])+addon.download[k]["notes"]+'</div>';
+ return div;
+ }).join("");
+
+ let result = '<p class="wow fadeInUp animated" data-wow-delay=".3s">{0} {1}<br/><span class="small pl-2">{2}{3}</span></p>{4}<br/>'.format(addonName, information2, compatible, links, sections);
if (addon.isSample) {
sample += result;
diff --git a/json/download.schema.json b/json/download.schema.json
index ce7ac5d..48961cc 100644
--- a/json/download.schema.json
+++ b/json/download.schema.json
@@ -47,21 +47,36 @@
"download": {
"additionalProperties": false,
"properties": {
- "dropin": { "type": "string" },
- "updateSite": { "type": "string" },
+ "dropin": { "anyOf": [
+ { "type": "string" },
+ { "type": "array", "items": { "$ref" : "#/definitions/download-item" } }
+ ] },
+ "updateSite": { "anyOf": [
+ { "type": "string" },
+ { "type": "array", "items": { "$ref" : "#/definitions/download-item" } }
+ ] },
"installAddon": { "type": "string" },
+ "installNotes": { "type": "string" },
"dandi": { "type": "string" },
"learnMore": { "type": "string" },
"release": { "type": "string" },
"userManual": { "type": "string" }
}
},
+ "download-item": {
+ "additionalProperties": false,
+ "properties": {
+ "name": { "type": "string" },
+ "url": { "type": "string" }
+ }
+ },
"lang": {
"additionalProperties": false,
"properties": {
"dropin": { "$ref" : "#/definitions/langitem" },
"updateSite": { "$ref" : "#/definitions/langitem" },
"installAddon": { "$ref" : "#/definitions/langitem" },
+ "installNotes": { "$ref" : "#/definitions/langitem" },
"dandi": { "$ref" : "#/definitions/langitem" },
"learnMore": { "$ref" : "#/definitions/langitem" },
"main": { "$ref" : "#/definitions/langitem" },