var $json = 0; var $playing = false; var $musicon = true; var light = new Array("black", "#CAD3FF", "#FFFFA6"); var dark = new Array("white", "black", "black"); var currentstyle = light; function Client() { } Client.prototype.mobileClients = [ "midp", "240x320", "blackberry", "netfront", "nokia", "panasonic", "portalmmm", "sharp", "sie-", "sonyericsson", "symbian", "windows ce", "benq", "mda", "mot-", "opera mini", "philips", "pocket pc", "sagem", "samsung", "sda", "sgh-", "vodafone", "xda", "iphone", "android" ]; Client.prototype.isMobileClient = function(userAgent) { userAgent=userAgent.toLowerCase(); for (var i in this.mobileClients) { if (userAgent.indexOf(this.mobileClients[i]) != -1) { return true; } } return false; } var $client = new Client(); function StringBuilder(value) { this.strings = new Array(""); this.append(value); }; StringBuilder.prototype.append = function(value) { if (value) { this.strings.push(value); } }; StringBuilder.prototype.clear = function() { this.strings.length = 1; }; StringBuilder.prototype.toString = function() { return this.strings.join(""); }; function buildLinks(columns, JSON) { $("#fsdienst").children().remove(); var counter = 0; for ( var props in JSON) { counter++; } var rows = Math.round(counter / columns); if ((counter % columns) != 0) { rows++; } var ul = new Array(rows); for ( var i = 0; i < rows; i++) { var id = "kwicks" + i; ul[i] = id; var kwicks = ""; $("#fsdienst").append(kwicks); } var row = 0; var i = 1; var number = 1; $.each(JSON, function() { var sb = new StringBuilder(); var id = "kwick" + number; var li = new StringBuilder(); li.append("
  • "); $("#" + ul[row]).append(li.toString()); sb.append("
    "); sb.append(this.title.charAt(0)); sb.append("
    "); sb.append(this.title.slice(1, this.title.length)); sb.append("
    "); $("#" + id).append(sb.toString()); sb.clear(); changeStyle(id); number++; if (i == columns) { i = 1; row++; } else { i++; } }); $().ready(function() { $('.kwicks').kwicks({ max : 205, spacing : 5, sticky : true }); }); }; var audio = new Audio("GN.ogg"); function noise() { if ($musicon) { if (audio.currentTime == 0 || audio.currentTime == audio.duration) { audio.play(); } } }; function changeStyle(id) { var sheet = document.styleSheets[0]; var normal = "#" + id + "{ background-color: " + currentstyle[1] + ";}" sheet.insertRule(normal, 0); var active = "#" + id + ".active { background-color: " + currentstyle[2] + ";}"; sheet.insertRule(active, 0); }; function change() { if ($json == 0) { buildLinks(4, unilinks); document.getElementById("header").innerHTML = "Links zur Universität"; $json = 1; } else if ($json == 1){ buildLinks(3, adminstrationslinks); document.getElementById("header").innerHTML = "Administrative Links"; $json = 2; } else{ buildLinks(4, fachschaftslinks); document.getElementById("header").innerHTML = "Für den Fachschaftsdienst"; $json = 0; } }; function redirect(toUrl) { window.open(toUrl); }; function music() { $musicon = !$musicon; if ($musicon) { document.getElementById('music').setAttribute("style", "background-image: url(soundon.png)"); } else { document.getElementById('music').setAttribute("style", "background-image: url(soundoff.png)"); } }; function view() { currentstyle = dark; buildLinks(4, fachschaftslinks); };