source: t29-www/shared/js-v6/modules/log.js @ 347

Last change on this file since 347 was 347, checked in by sven, 11 years ago

Diverse Verbesserungen am Homepagesystem, die bereits lange anstanden.

  • Die Suche ist endlich implementiert, wenngleich auch relativ unschoen mittels einer eingebundenen Google-Suche.

Bugfixes:

  • de/news.php: Syntaxfehler im Neuigkeiten-Menü

Backend-Aenderungen:

  • Englischsprachige Benutzer, die auf die deutsche Seite kommen oder andersrum erhalten einen Hinweis, dass es die andere Sprachversion gibt (noch nicht vollständig implementiert)
  • Es gibt ein besseres Logging-System, welches Client- und Serverausgaben verbindet
  • Das System generiert jetzt selbst Clean-URLs direkt (zumindest aus Menue/Template, Inhalte werden nicht touchiert). Das reduziert die Anzahl der Zugriffe erheblich.
  • Ein paar CSS-Details
  • navigation.xml: "#DUMME-VERLINKUNG"-Einträge entfernt
File size: 2.4 KB
Line 
1/**
2 * t29v6 Logging subsystem
3 *
4 * Logging on client side is splitted in two parts:
5 *   1. Javascript console.log calls which won't offend the user
6 *   2. the t29.log class to notify the user.
7 *
8 * Considering console.log, the code is borrowed by HTML5 Boilerplate
9 *
10 *
11 **/
12
13// usage: log('inside coolFunc', this, arguments);
14// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
15window.log = function(){
16  log.history = log.history || [];   // store logs to an array for reference
17  log.history.push(arguments);
18  if(this.console) {
19    arguments.callee = arguments.callee.caller;
20    var newarr = [].slice.call(arguments);
21    (typeof console.log === 'object' ? log.apply.call(console.log, console, newarr) : console.log.apply(console, newarr));
22  }
23};
24
25// make it safe to use console.log always
26(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,timeStamp,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();){b[a]=b[a]||c}})((function(){try
27{console.log();return window.console;}catch(err){return window.console={};}})());
28
29
30if(!t29) window.t29 = {}; // the t29 namespace
31t29.log = {}; // the t29.log namespace
32
33t29.log.setup = function() {
34        // setup our spaces
35        t29.log.$panel = $(".messages.panel");
36        t29.log.$end = $(".messages.footer");
37       
38        // find end messages and push them to the first
39        if((end_li = t29.log.$end.find("li")).length) {
40                end_li.appendTo(t29.log.$panel);
41                t29.log.$end.hide(); // hide bottom panel
42                t29.log.$panel.removeClass("empty"); // show top panel
43        }
44       
45        // setup some functions
46        levels = ["emerg", "alert", "crit", "error", "warn", "notice", "info"];
47        $.each(levels, function() {
48                level = this;
49                t29.log[level] = function(msg) { t29.log.append(level, msg) }
50        });
51}
52
53t29.log.append = function(level, msg) {
54        // tell the panel that it's now not empty (thus it will become CSS visible)
55        t29.log.$panel.removeClass("empty");
56       
57        if(jQuery.type(msg) == "string")
58                s = msg;
59        else {
60                s = "";
61                if(msg.dismissable) s += "<button class='close'>&times;</button>";
62                if(msg.heading) s += "<h5>"+msg.heading+"</h5>";
63                if(msg.text) s += "<p>"+msg.text+"</p>";
64        }
65        infoelement = $("<li>", {"class": level}).html(s).hide().appendTo(t29.log.$panel).slideDown();
66       
67        // fill eventual close button with action
68        $(infoelement).find("button.close").click(function(){
69                $(this).closest("li").slideUp();
70        });
71}
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License