annotate js/loader.js @ 2384:2ddc68898dff

Fix for #81. Browsers which cannot start a Web Audio context will fail with a message listing supported browsers
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Fri, 20 May 2016 14:04:36 +0100
parents
children 464c6c6692d6
rev   line source
nicholas@2384 1 // Script to load the relevant JS files if the system supports it
nicholas@2384 2
nicholas@2384 3 window.onload = function() {
nicholas@2384 4 // First check if the Web Audio API is supported
nicholas@2384 5 if (window.AudioContext == undefined && window.webkitAudioContext == undefined) {
nicholas@2384 6 // Display unsuported error message
nicholas@2384 7 var body = document.getElementsByTagName("body")[0];
nicholas@2384 8 body.innerHTML = "<h1>Sorry! Your browser is not supported :(</h1><p>Your browser does not support the HTML5 Web Audio API. Please use one of the following supported browsers instead.<p>";
nicholas@2384 9 var table = document.createElement("table");
nicholas@2384 10 table.border = "0";
nicholas@2384 11 table.innerHTML = "<tr><td>Chrome</td><td>v10 or newer</td></tr>";
nicholas@2384 12 table.innerHTML += "<tr><td>Firefox</td><td>v25 or newer</td></tr><tr><td>Safari (OSX)</td><td> v6 or newer, OSX only</td></tr>";
nicholas@2384 13 table.innerHTML += "<tr><td>Safari (iOS)</td><td>iOS 6.1 or newer</td></tr>";
nicholas@2384 14 table.innerHTML += "<tr><td>Edge</td><td>12 or newer</td></tr>";
nicholas@2384 15 body.appendChild(table);
nicholas@2384 16 } else {
nicholas@2384 17 var head = document.getElementsByTagName("head")[0];
nicholas@2384 18 var src_list = ['js/specification.js', 'js/core.js', 'js/loudness.js', 'js/xmllint.js', 'js/WAVE.js'];
nicholas@2384 19 for (var i=0; i<src_list.length; i++) {
nicholas@2384 20 var src = src_list[i];
nicholas@2384 21 var script = document.createElement("script");
nicholas@2384 22 script.type = "text/javascript";
nicholas@2384 23 script.async = false;
nicholas@2384 24 script.defer = true;
nicholas@2384 25 script.src = src;
nicholas@2384 26 head.appendChild(script);
nicholas@2384 27 }
nicholas@2384 28 }
nicholas@2384 29 }