2 var $wrapper = $('#wrapper');
5 var theme_match = String(window.location).match(/[?&]theme=([a-z0-9]+)/);
6 var theme = (theme_match && theme_match[1]) || 'default';
7 var themes = ['default','legacy','bootstrap2','bootstrap3'];
8 $('head').append('<link rel="stylesheet" href="css/selectize.' + theme + '.css">');
10 var $themes = $('<div>').addClass('theme-selector').insertAfter('h1');
11 for (var i = 0; i < themes.length; i++) {
12 $themes.append('<a href="?theme=' + themes[i] + '"' + (themes[i] === theme ? ' class="active"' : '') + '>' + themes[i] + '</a>');
15 // display scripts on the page
16 $('script', $wrapper).each(function()
19 if (code && code.length) {
20 var lines = code.split('\n');
23 for (var i = 0; i < lines.length; i++) {
24 if (/^[ ]*$/.test(lines[i])) continue;
26 var lineindent = lines[i].match(/^([ ]+)/);
27 if (!lineindent) break;
28 indent = lineindent[1];
30 lines[i] = lines[i].replace(new RegExp('^' + indent), '');
33 var code = $.trim(lines.join('\n')).replace(/ /g, ' ');
34 var $pre = $('<pre>').addClass('js').text(code);
35 $pre.insertAfter(this);
39 // show current input values
40 $('select.selectized,input.selectized', $wrapper).each(function()
42 var $container = $('<div>').addClass('value').html('Current Value: ');
43 var $value = $('<span>').appendTo($container);
45 var update = function(e) { $value.text(JSON.stringify($input.val())); }
47 $(this).on('change', update);
50 $container.insertAfter($input);