From: Marius Gavrilescu Date: Fri, 3 Apr 2015 08:15:51 +0000 (+0300) Subject: Insert javascript-dependent HTML from javascript X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=bdaa8919598cbbd8753fd6795b34b594b1b30805;p=gruntmaster-page.git Insert javascript-dependent HTML from javascript --- diff --git a/js/90-themes.js b/js/90-themes.js index 7221dde..6afd444 100644 --- a/js/90-themes.js +++ b/js/90-themes.js @@ -6,11 +6,19 @@ localStorage.setItem("theme", name); } + var selector; + + function add_themelink(theme, text) { + var link = $('' + text + ''); + link.appendTo(selector.find('ul')).wrap('
  • ').on('click', function () { set_style(theme) }); + } + $( document ).ready(function() { - $('#theme-selector').detach().prependTo($('#sidebar')); - $('#theme_slate' ).on('click', function () { set_style("slate"); }); - $('#theme_cyborg' ).on('click', function () { set_style("cyborg"); }); - $('#theme_readable').on('click', function () { set_style("readable"); }); + selector = $('
    Themes:
      '); + add_themelink('cyborg', 'Black'); + add_themelink('slate', 'Grey'); + add_themelink('readable', 'White'); + $('#sidebar').prepend(selector); }); var theme = localStorage.getItem("theme"); diff --git a/js/90-tracker.js b/js/90-tracker.js index 50ba7d4..1fa4905 100644 --- a/js/90-tracker.js +++ b/js/90-tracker.js @@ -9,6 +9,8 @@ $('.tracker-info').removeClass('tracker-info info'); } + var tracker; + function update_tracker(){ var data = localStorage.getItem('tracker_data'); var user = localStorage.getItem('tracker_username'); @@ -74,7 +76,7 @@ function start_tracking(user){ localStorage.setItem('tracker_username', user); $('#tracker_userlink').attr('href', '/us/' + user).html(user); - $('#tracker_tracking').removeClass('hidden'); + tracker.removeClass('hidden'); update_tracker(); var lastfetch = localStorage.getItem('tracker_lastfetch'); if(Date.now() - lastfetch > 60 * 10 * 1000) @@ -100,11 +102,12 @@ localStorage.removeItem('tracker_username'); localStorage.removeItem('tracker_data'); localStorage.removeItem('tracker_lastfetch'); - $('#tracker_tracking').addClass('hidden'); + tracker.addClass('hidden'); } $( document ).ready(function(){ - $('#tracker').detach().prependTo($('#sidebar')); + tracker = $(''); + tracker.prependTo($('#sidebar')); $('#tracker_stop').on('click', stop_tracking); $('#track_user').on('click', function() { stop_tracking(); start_tracking($(this).data('user')) }); $('#submitform').on('submit', function() { localStorage.removeItem('tracker_lastfetch') }); diff --git a/js/95-login.js b/js/95-login.js index 60ede9d..7f52deb 100644 --- a/js/95-login.js +++ b/js/95-login.js @@ -2,7 +2,7 @@ 'use strict'; $( document ).ready(function(){ - $('#login').detach().prependTo($('#sidebar')).on('click', function(e) { + $('Log in').prependTo($('#sidebar')).wrap('
      ').on('click', function(e) { var xhr = new XMLHttpRequest(); xhr.open('GET', '/login'); xhr.onload = function () { diff --git a/tmpl/skel.en b/tmpl/skel.en index 6ae836a..22411f9 100644 --- a/tmpl/skel.en +++ b/tmpl/skel.en @@ -33,31 +33,6 @@
      Content goes here
      -
      - -
      -Themes: - -
      - -
      - -
      -