Skip to content
Snippets Groups Projects
Commit efab7043 authored by Florent POITTEVIN's avatar Florent POITTEVIN
Browse files

fix: path to JSMol

parent f3d8ba17
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,7 @@ export class MolFileVisualizerService implements AbstractFileVisualizer { ...@@ -62,7 +62,7 @@ export class MolFileVisualizerService implements AbstractFileVisualizer {
const molUrl = URL.createObjectURL(fileInfo.blob); const molUrl = URL.createObjectURL(fileInfo.blob);
const iframe = document.createElement("iframe"); const iframe = document.createElement("iframe");
const html = "<script src=\"/assets/jsmol/JSmol.min.js\" type=\"text/javascript\"></script>" + const html = "<script src=\"./assets/jsmol/JSmol.min.js\" type=\"text/javascript\"></script>" +
"<script>var info = {\n" + "<script>var info = {\n" +
" color: \"#FFFFFF\",\n" + " color: \"#FFFFFF\",\n" +
" height: 450,\n" + " height: 450,\n" +
......
...@@ -4,17 +4,14 @@ ...@@ -4,17 +4,14 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>Portal</title> <title>Portal</title>
<base href="/"> <base href="/">
<script src="/assets/jsmol/JSmol.min.js"
type="text/javascript"
></script>
<script> <script>
var attributeTempSuffix = "-temp"; var attributeTempSuffix = "-temp";
var base = document.getElementsByTagName("base")[0]; var base = document.getElementsByTagName("base")[0];
if (base) { if (base) {
base.href = window.location.pathname.replace(/\/[^\/]+$/, "/"); base.href = window.location.pathname.replace(/\/[^\/]+$/, "/");
base.removeAttribute("href" + attributeTempSuffix); base.removeAttribute("href" + attributeTempSuffix);
} }
</script> </script>
<meta name="viewport" <meta name="viewport"
...@@ -31,44 +28,48 @@ ...@@ -31,44 +28,48 @@
<dlcm-root></dlcm-root> <dlcm-root></dlcm-root>
<noscript>Please enable JavaScript to continue using this application.</noscript> <noscript>Please enable JavaScript to continue using this application.</noscript>
<script> <script>
var ua = window.navigator.userAgent; var ua = window.navigator.userAgent;
var browserUnnsuported; var browserUnnsuported;
var msie = ua.indexOf('MSIE '); var msie = ua.indexOf('MSIE ');
if (msie > -1) { if (msie > -1) {
// IE 10 or older => return version number // IE 10 or older => return version number
browserUnnsuported = "Internet Explorer " + parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10); browserUnnsuported = "Internet Explorer " + parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
} }
var trident = ua.indexOf('Trident/'); var trident = ua.indexOf('Trident/');
if (trident > -1) { if (trident > -1) {
// IE 11 => return version number // IE 11 => return version number
var rv = ua.indexOf('rv:'); var rv = ua.indexOf('rv:');
browserUnnsuported = "Internet Explorer " + parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10); browserUnnsuported = "Internet Explorer " + parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
} }
var edge = ua.indexOf('Edge/'); var edge = ua.indexOf('Edge/');
if (edge > -1) { if (edge > -1) {
// Edge (IE 12+) => return version number // Edge (IE 12+) => return version number
browserUnnsuported = "Edge " + parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); browserUnnsuported = "Edge " + parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
} }
if (browserUnnsuported) { if (browserUnnsuported) {
alert("Your browser " + browserUnnsuported + " is not supported by this application.\nPlease use a browser more recent like Chrome or Firefox."); alert("Your browser " + browserUnnsuported + " is not supported by this application.\nPlease use a browser more recent like Chrome or Firefox.");
document.body.style.display = "none"; document.body.style.display = "none";
} }
</script> </script>
</body> </body>
<script src="./assets/jsmol/JSmol.min.js"
type="text/javascript"
></script>
<script> <script>
function handleTempAttribute(attributeName) { function handleTempAttribute(attributeName) {
document.querySelectorAll("[" + attributeName + attributeTempSuffix + "]") document.querySelectorAll("[" + attributeName + attributeTempSuffix + "]")
.forEach(function (element) { .forEach(function (element) {
element.setAttribute(attributeName, element.getAttribute(attributeName + attributeTempSuffix)); element.setAttribute(attributeName, element.getAttribute(attributeName + attributeTempSuffix));
element.removeAttribute(attributeName + attributeTempSuffix); element.removeAttribute(attributeName + attributeTempSuffix);
}); });
} }
handleTempAttribute("href"); handleTempAttribute("href");
handleTempAttribute("src"); handleTempAttribute("src");
</script> </script>
</html> </html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment