This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
kdenlive-project-analyzer.html
executable file
Β·155 lines (141 loc) Β· 7.2 KB
/
kdenlive-project-analyzer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html>
<!--
Kdenlive Project XML Analyzer
(c) 2016 Harald Albrecht
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<html>
<head>
<title>Kdenlive Project Analyzer</title>
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css"/>
<link rel="stylesheet" href="style/kdenlive-project-analyzer.css"/>
<script type="text/javascript" language="javascript" src="Saxonce/Saxonce.nocache.js"></script>
</head>
<body>
<p id="loader-msg">
<i class="fa fa-spinner fa-pulse fa-fw"/></i> Loading Kdenlive Project Analyzer, please wait...
</p>
<form id="project-form" style="display: none;">
<p><i class="fa fa-file-text-o"> </i><input type="file" name="file" id="file" accept=".kdenlive"></input></p>
</form>
<p id="analyzing-msg" style="display: none;">
<i class="fa fa-spinner fa-pulse fa-fw"></i> Analyzing your Kdenlive project, please wait.
<span id="progress-msg">...</span>
</p>
<div id="analysis-report"></div>
</body>
<script>
//
// Only after the (JavaScript/ECMAScript) XSLT processor has been
// fully loaded, enable the form to select and load a Kdenlive
// project file, and hide the temporary loading message.
//
onSaxonLoad = function() {
console.log("XSLT 2.0 Saxon-CE successfully loaded.");
Saxon.setLogLevel("INFO");
Saxon.setErrorHandler(function(e) {
// called with all kind of error and logging messages...
if ( e.message.includes("KPA:") ) {
document.getElementById("progress-msg").innerHTML =
e.message.replace(/.*\n.*KPA:\s*/, "");
}
});
document.getElementById("loader-msg").style.display = "none";
document.getElementById("project-form").style.display = "block";
}
document.getElementById("file").addEventListener("change", function(evt) {
var projf = evt.target.files[0];
//
// Force a redraw to show the analyzing in progress message. In order
// to force the redraw, we need to query a (document) property that
// needs to enforce layout calculation after un-hiding the progress
// message.
//
document.getElementById("analyzing-msg").style.display = "block";
// force redraw due to recalculation
setTimeout(function() {
document.getElementById("analyzing-msg").height;
}, 0);
console.log("Retrieving project document \"" + projf.name + "\".");
var xmlfr = new FileReader();
xmlfr.onerror = function(evt) {
//
// Project file could not be retrieved. So hide the progress
// message and produce an error message.
//
console.log("Failed to retrieve project document: ",
evt.target.error.name);
document.getElementById("analyzing-msg").style.display = "none";
document.getElementById("analysis-report").innerHTML = "";
document.getElementById("analysis-report").innerHTML =
"<p><b>Error:</b> cannot retrieve Kdenlive project document; reason: "
+ evt.target.error.name
+ "</p>";
};
xmlfr.onload = function(evt) {
console.log("Project document retrieved.");
try {
//
// This is an ugly hack due to the broken Kdenlive project XML
// that isn't valid, so any half-decent XML parser chokes on it.
// As it is, the XSLT transformation engines will choke, so we
// sneak in a fake kdenlive namespace declaration in order to
// make Kdenlive project documents become valid XML.
//
var kdenlive = evt.target.result.replace(/<mlt\s(.*)>/, "<mlt xmlns:kdenlive=\"http://www.kdenlive.org/namespace/borked\" $1>");
var dp = new DOMParser();
var xml = dp.parseFromString(kdenlive, "application/xml");
var xsltr = new XMLHttpRequest();
xsltr.open("GET", "kpa/kpa.xsl", false);
xsltr.send(null);
var xslt = xsltr.responseXML;
//
// Now run the analysis script.
//
console.log("Starting project document analysis.");
var xsltp = new Saxon.newXSLT20Processor(xslt);
xsltp.setParameter(null, "project-name", projf.name);
var analysis = xsltp.transformToFragment(xml, document);
console.log("Analysis finished.");
//
// Hide the analyzing in progress message after we've finished.
// Also hide the form; user can get the form back by simply
// reloading this page.
//
document.getElementById("analyzing-msg").style.display = "none";
document.getElementById("project-form").style.display = "none";
document.getElementById("progress-msg").innerHTML = "";
//
// Copy the analysis report into the HTML document for display.
// Make sure to remove any old, stale report.
//
document.getElementById("analysis-report").innerHTML = "";
document.getElementById("analysis-report").appendChild(
analysis.getElementById("report"));
} catch ( e ) {
//
// Ooops, this didn't work out as expected...
//
console.log("Analysis aborted: " + e.message);
document.getElementById("analyzing-msg").style.display = "none";
document.getElementById("progress-msg").innerHTML = "";
document.getElementById("analysis-report").innerHTML = "";
document.getElementById("analysis-report").innerHTML =
"<p><b>Error:</b> Kdenlive project analysis aborted, reasons: "
+ e.message
+ "</p>";
}
};
xmlfr.readAsText(projf);
}, false)
</script>
</html>