/*================================================== * Timeline API * * This file will load all the Javascript files * necessary to make the standard timeline work. * It also detects the default locale. * * Include this file in your HTML file as follows: * * * *================================================== */ /* window.__simile_api_state = "not-used"; window.setTimeout(function() { try { var div = document.createElement("div"); div.style.fontSize = "12px"; div.style.fontFamily = "sans-serif"; div.style.position = "fixed"; div.style.top = "25px"; div.style.right = "25px"; div.style.width = "20em"; div.style.padding = "2em"; div.style.backgroundColor = "#ffe080"; div.style.zIndex = 1000000; if (window.__simile_api_state == "used") { div.innerHTML = 'Thank you for using SIMILE Timeline. ' + 'However, your page is referencing an old version of Timeline at a location soon to be deprecated. ' + 'Please upgrade to the latest version at the latest location at http://www.simile-widgets.org/timeline/.'; } else { div.innerHTML = 'This web page is referencing an old version of the SIMILE Timeline API but does not make use of it. ' + 'This reference is taxing our bandwidth unnecessarily. Please remove it (and this message will go away). Thank you for your cooperation.'; } document.body.insertBefore(div, document.body.firstChild); } catch (e) { window.setTimeout(arguments.callee, 5000); } }, 10000); */ var Timeline = new Object(); Timeline.Platform = new Object(); /* HACK: We need these 2 things here because we cannot simply append a "); return; } catch (e) { // fall through } } var script = document.createElement("script"); script.type = "text/javascript"; script.language = "JavaScript"; script.src = url; getHead().appendChild(script); }; var includeCssFile = function(url) { if (document.body == null) { try { document.write(""); return; } catch (e) { // fall through } } var link = document.createElement("link"); link.setAttribute("rel", "stylesheet"); link.setAttribute("type", "text/css"); link.setAttribute("href", url); getHead().appendChild(link); } includeJavascriptFiles = function(urlPrefix, filenames) { for (var i = 0; i < filenames.length; i++) { includeJavascriptFile(urlPrefix + filenames[i]); } }; includeCssFiles = function(urlPrefix, filenames) { for (var i = 0; i < filenames.length; i++) { includeCssFile(urlPrefix + filenames[i]); } }; } /* * Include non-localized files */ if (bundle) { includeJavascriptFiles(Timeline.urlPrefix, [ "timeline_files/bundle.js" ]); includeCssFiles(Timeline.urlPrefix, [ "timeline_files/bundle.css" ]); } else { includeJavascriptFiles(Timeline.urlPrefix + "scripts/", javascriptFiles); includeCssFiles(Timeline.urlPrefix + "styles/", cssFiles); } /* * Include localized files */ var loadLocale = []; loadLocale[defaultServerLocale] = true; var tryExactLocale = function(locale) { for (var l = 0; l < supportedLocales.length; l++) { if (locale == supportedLocales[l]) { loadLocale[locale] = true; return true; } } return false; } var tryLocale = function(locale) { if (tryExactLocale(locale)) { return locale; } var dash = locale.indexOf("-"); if (dash > 0 && tryExactLocale(locale.substr(0, dash))) { return locale.substr(0, dash); } return null; } for (var l = 0; l < desiredLocales.length; l++) { tryLocale(desiredLocales[l]); } var defaultClientLocale = defaultServerLocale; var defaultClientLocales = ("language" in navigator ? navigator.language : navigator.browserLanguage).split(";"); for (var l = 0; l < defaultClientLocales.length; l++) { var locale = tryLocale(defaultClientLocales[l]); if (locale != null) { defaultClientLocale = locale; break; } } for (var l = 0; l < supportedLocales.length; l++) { var locale = supportedLocales[l]; if (loadLocale[locale]) { includeJavascriptFiles(Timeline.urlPrefix + "scripts/l10n/" + locale + "/", localizedJavascriptFiles); includeCssFiles(Timeline.urlPrefix + "styles/l10n/" + locale + "/", localizedCssFiles); } } Timeline.Platform.serverLocale = defaultServerLocale; Timeline.Platform.clientLocale = defaultClientLocale; } catch (e) { alert(e); } })();