Skip to content

Commit c90afd1

Browse files
committed
Prominence and ContentAttributes added to backend editor
ContentAttributes are shown as raw xml in a textarea
1 parent 9094282 commit c90afd1

1 file changed

Lines changed: 69 additions & 2 deletions

File tree

backend/dvbi.js

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ function addServiceInstance(serviceId, instanceElement) {
5454
inputDiv.classList.add("form-group", "mb-1", "row");
5555
var inputLabel = document.createElement("label");
5656
inputLabel.classList.add("col-6", "col-form-label", "col-form-label-sm", "my-auto");
57+
inputLabel.appendChild(document.createTextNode("Content Attributes (Raw XML)"));
58+
inputDiv.appendChild(inputLabel);
59+
newTextbox = document.createElement("textarea");
60+
newTextbox.classList.add("form-control", "form-control-sm", "col-5", "my-auto");
61+
newTextbox.id = "instance_" + serviceId + "_" + instanceId + "_contentAttributes";
62+
63+
inputDiv.appendChild(newTextbox);
64+
inputLabel = document.createElement("label");
65+
inputLabel.classList.add("col-6", "col-form-label", "col-form-label-sm", "my-auto");
5766
inputLabel.appendChild(document.createTextNode("Source Type"));
5867
inputDiv.appendChild(inputLabel);
5968

@@ -71,7 +80,6 @@ function addServiceInstance(serviceId, instanceElement) {
7180
option.text = sourceTypes[sourceType];
7281
newTextbox.appendChild(option);
7382
}
74-
7583
inputDiv.appendChild(newTextbox);
7684
instanceDiv.appendChild(inputDiv);
7785
var params = document.createElement("div");
@@ -153,6 +161,9 @@ function addServiceInstance(serviceId, instanceElement) {
153161
.getElementsByTagNameNS(TVA_ns, "MediaUri")[0].childNodes[0].nodeValue;
154162
}
155163
}
164+
} else if (children[i].nodeName === "ContentAttributes") {
165+
document.getElementById("instance_" + serviceId + "_" + instanceId + "_contentAttributes").value =
166+
new XMLSerializer().serializeToString(children[i]);
156167
}
157168
}
158169
} else {
@@ -253,6 +264,24 @@ function addService(serviceElement) {
253264
createTextInput("service_" + serviceId + "_parallel_app", "Application with media in parallel")
254265
);
255266

267+
var inputId = "service_" + serviceId + "_prominent";
268+
var inputDiv = document.createElement("div");
269+
inputDiv.classList.add("form-group", "row", "mb-1");
270+
var inputLabel = document.createElement("label");
271+
inputLabel.classList.add("col-6", "col-form-label", "col-form-label-sm", "my-auto");
272+
inputLabel.htmlFor = inputId;
273+
inputLabel.appendChild(document.createTextNode("Prominent service"));
274+
inputDiv.appendChild(inputLabel);
275+
var inputElement = document.createElement("input");
276+
inputElement.classList.add("form-control-sm", "col-5", "my-auto");
277+
inputElement.type = "checkbox";
278+
inputElement.name = inputId;
279+
inputElement.id = inputId;
280+
inputDiv.appendChild(inputElement);
281+
serviceDiv.appendChild(inputDiv);
282+
283+
serviceDiv.appendChild(createTextInput("service_" + serviceId + "_prominent_ranking", "Service prominence ranking"));
284+
256285
var newTextbox1 = document.createElement("a");
257286
newTextbox1.href = "javascript:addServiceInstance('" + serviceId + "')";
258287
newTextbox1.classList.add("btn", "btn-outline-blue", "btn-sm", "mr-1", "mt-2");
@@ -311,6 +340,19 @@ function addService(serviceElement) {
311340
} catch (e) {
312341
console.log("Error reading service instance", e);
313342
}
343+
} else if (children[i].nodeName === "ProminenceList") {
344+
try {
345+
var prominence = children[i].getElementsByTagName("Prominence");
346+
if (prominence.length > 0) {
347+
document.getElementById("service_" + serviceId + "_prominent").checked = true;
348+
var ranking = prominence[0].getAttribute("ranking");
349+
if (ranking) {
350+
document.getElementById("service_" + serviceId + "_prominent_ranking").value = ranking;
351+
}
352+
}
353+
} catch (e) {
354+
console.log(e);
355+
}
314356
}
315357
}
316358
}
@@ -479,6 +521,16 @@ function generateXML() {
479521
propertyElement.appendChild(doc.createTextNode(contentGuideServiceRef));
480522
serviceElement.appendChild(propertyElement);
481523
}
524+
if (document.getElementById(serviceId + "_prominent").checked) {
525+
prominenceListElement = doc.createElement("ProminenceList");
526+
serviceElement.appendChild(prominenceListElement);
527+
prominenceElement = doc.createElement("Prominence");
528+
var ranking = document.getElementById(serviceId + "_prominent_ranking").value;
529+
if (ranking) {
530+
prominenceElement.setAttribute("ranking", ranking);
531+
}
532+
prominenceListElement.appendChild(prominenceElement);
533+
}
482534
doc.documentElement.appendChild(serviceElement);
483535
var lcnValue = document.getElementById(serviceId + "_lcn").value;
484536
if (lcnValue && lcnValue.length > 0) {
@@ -535,7 +587,7 @@ function generateServiceInstance(instance, doc) {
535587
var deliveryParametersElement = doc.createElement("DASHDeliveryParameters");
536588
var locationElement = doc.createElement("UriBasedLocation");
537589
locationElement.setAttribute("contentType", DASH_MIME);
538-
var uriElement = doc.createElement("URI");
590+
var uriElement = doc.createElement("dvbi-types:URI");
539591
uriElement.appendChild(doc.createTextNode(document.getElementById(instanceId + "_dash_uri").value));
540592
locationElement.appendChild(uriElement);
541593
deliveryParametersElement.appendChild(locationElement);
@@ -578,6 +630,21 @@ function generateServiceInstance(instance, doc) {
578630
deliveryParametersElement3.appendChild(parameter2);
579631
instanceElement.appendChild(deliveryParametersElement3);
580632
}
633+
var content_attributes = document.getElementById(instanceId + "_contentAttributes").value;
634+
if (content_attributes && content_attributes.length > 0) {
635+
var parser;
636+
var doc;
637+
638+
if (window.DOMParser) {
639+
parser = new DOMParser();
640+
doc = parser.parseFromString(content_attributes, XML_MIME);
641+
} else {
642+
doc = new ActiveXObject("Microsoft.XMLDOM");
643+
doc.async = false;
644+
doc.loadXML(data);
645+
}
646+
instanceElement.appendChild(doc.documentElement);
647+
}
581648
return instanceElement;
582649
}
583650

0 commit comments

Comments
 (0)