| |
| |
| |
| |
| |
| function generateRandomString(length) { |
| var text=""; |
| var possible="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
| for (var i=0; |
| i < length; |
| i++) { |
| text+=possible.charAt(Math.floor(Math.random() * possible.length)); |
| } |
| return text; |
| } |
| |
| $(document).ready(function () { |
| var string=generateRandomString(10); |
| $("#random_string").text(string); |
| |
| |
| var whichTheme=localStorage.getItem("theme"); |
| |
| |
| var activeTheme=localStorage.getItem("activeTheme"); |
| |
| |
| var panel=$('<li id="switcher" class="dropdown text-center"> \ |
| <label for="theme-control-list-check" class="dropdown-toggle" data-toggle="dropdown" id="theme_dropdown" title="" role="button" data-original-title="Theme" aria-expanded="false"> \ |
| <a class="btn-link" title="Theme Switcher" href="#"><i id="ticon" class="fa fa-fw fa-lightbulb-o"></i><span class="visible-xs-inline">Theme Switcher</span></a> \ |
| </label> \ |
| <ul id="theme" class="dropdown-menu"> \ |
| <li><a id="default" href="#" rel="/assets/client.css?v=e02phpkima0">Default</a></li> \ |
| <li><a id="default dark" href="#" rel="/assets/customcss/default_dark.css">Default Dark</a></li> \ |
| <li><a id="Light Flat" href="#" rel="/assets/customcss/testflat.css">Light Flat</a></li> \ |
| <li><a id="Dark Flat" href="#" rel="/assets/customcss/testflat.css">Dark Flat</a></li> \ |
| <li><a id="Dark Neon Aqua" href="#" rel="/assets/customcss/dark_neon_aqua.css">Dark Neon Aqua</a></li> \ |
| <li><a id="Dark Neon Blue" href="#" rel="assets/customcss/dark_neon_blue.css">Dark Neon Blue</a></li> \ |
| <li><a id="Dark Neon Green" href="#" rel="/assets/customcss/dark_neon_green.css">Dark Neon Green</a></li> \ |
| <li><a id="Dark Neon Solary" href="#" rel="/assets/customcss/dark_neon_solary.css">Dark Neon Solary</a></li> \ |
| <li><a id="Dark Neon White" href="#" rel="/assets/customcss/dark_neon_white.css"">Dark Neon White</a></li> \ |
| <li><a id="Eva 00" href="#" rel="/assets/customcss/eva_00.css">Eva.00</a></li> \ |
| <li><a id="Eva 01" href="#" rel="/assets/customcss/eva_01.css">Eva.01</a></li> \ |
| <li><a id="Eva 01 Purple Green"href="#" rel="/assets/customcss/eva_01_purple_green.css">Eva.01: Purple-Green</a></li> \ |
| <li><a id="Eva 02" href="#" rel="/assets/customcss/eva_02.css">Eva.02: Red-Orange</a></li> \ |
| </ul> \ |
| </div> '); |
| // See if there is an active theme selected in localStorage. If none selected, use the default. If there is a theme in localStorage, use that and apply it |
| // Regarde s'il y a un thème actif sélectionné dans "localStorage". Si aucun n'est sélectionné, utilise la valeur par défaut. |
| // S'il y a un thème dans localStorage, on l'utilise et on l'applique. |
| if (whichTheme) { |
| $("head").append("<link href='" + activeTheme + '?version=' + string + "' type=\"text/css\" rel=\'stylesheet\' />"); |
| } |
| else { |
| |
| |
| } |
| $('ul#logged-in-menu').prepend(panel); |
| $('ul#logged-out-menu').prepend(panel); |
| if (utils.findBootstrapEnvironment()==='xs') { |
| $('#menu').prepend(panel); |
| } |
| $(document).ready(function () { |
| |
| |
| $("#theme li a").on("click change", function () { |
| |
| |
| var thishref=$(this).attr('rel'); |
| $("link[rel=stylesheet]").attr('href', thishref + "?version=" + string + ""); |
| |
| |
| location.reload(); |
| |
| |
| var selected=$(this).attr("id"); |
| |
| |
| var theTheme=$(this).attr("rel"); |
| |
| |
| |
| |
| if (selected==='default') { |
| localStorage.setItem("theme", ""); |
| |
| |
| localStorage.setItem("activeTheme", ""); |
| |
| |
| |
| |
| location.reload(); |
| } |
| |
| |
| else { |
| localStorage.setItem("theme", selected); |
| |
| |
| localStorage.setItem("activeTheme", theTheme); |
| |
| } |
| |
| |
| |
| } |
| ); |
| } |
| ); |
| } |
| |
| ); |
| |
| |
| $(document).on('mouseenter', '#switcher', function() { |
| $('#switcher i').addClass("themeoff"); |
| } |
| |
| ); |
| |
| |
| $(document).on('mouseleave', '#switcher', function() { |
| $('#switcher i').removeClass("themeoff"); |
| } |
| |
| ); |