From 09a53b0883749177672302d182563f1a24a17bb7 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Sat, 28 Jun 2014 01:04:53 +0200 Subject: [PATCH] the order in which JS and CSS files are included MATTERS! autodetection of themes works, as a first draft. --- detector.js | 7 ++----- index.html | 10 +++++----- uhr.js | 13 ++++++------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/detector.js b/detector.js index 794668c..2e53929 100644 --- a/detector.js +++ b/detector.js @@ -1,13 +1,10 @@ (function($) { 'use strict'; - $(document).ready(function() { - console.log('detector'); var uhrCSSs = $('link[rel=stylesheet][href^=uhr-]'); + var matcher = /^(.*)uhr-(.+).css$/; for (var i = 0; i < uhrCSSs.length; i++) { var name = $(uhrCSSs[i]).attr('href'); - var matcher = /^(.*)uhr-(.+).css$/; var code = name.match(matcher)[2]; - console.log(name+": "+code); + window._uhr.themes.push(code); } - }); })(jQuery); diff --git a/index.html b/index.html index 8874c3b..6f42614 100644 --- a/index.html +++ b/index.html @@ -16,11 +16,6 @@ along with this program. If not, see . Bärneruhr - Die Zeit im Wort - - - - - @@ -28,6 +23,11 @@ along with this program. If not, see . + + + + + diff --git a/uhr.js b/uhr.js index 6982d62..325cbc8 100644 --- a/uhr.js +++ b/uhr.js @@ -21,7 +21,8 @@ along with this program. If not, see . window._uhr = { id: 0, - languages: [] + languages: [], + themes: [] }; $.widget("fritteli.uhr", { options: { @@ -222,12 +223,10 @@ along with this program. If not, see . // theme chooser var themeChooser = $(''); - themeChooser.append(''); - themeChooser.append(''); - themeChooser.append(''); - themeChooser.append(''); - themeChooser.append(''); - themeChooser.append(''); + for (var i = 0; i < window._uhr.themes.length; i++) { + var theme = window._uhr.themes[i]; + themeChooser.append(''); + } e.after(themeChooser); } },