Team:EPF-Lausanne/Template/script.js
From 2012.igem.org
Line 11: | Line 11: | ||
EPFL.setupProtocols(); | EPFL.setupProtocols(); | ||
EPFL.setupCalendar(); | EPFL.setupCalendar(); | ||
+ | EPFL.setupPlanning(); | ||
$('p') | $('p') | ||
.filter(function(){ | .filter(function(){ | ||
Line 16: | Line 17: | ||
}) | }) | ||
.remove(); | .remove(); | ||
+ | }, | ||
+ | setupPlanning: function(){ | ||
+ | if(location.href.match(/Team:EPF-Lausanne\/Planning/ig)){ | ||
+ | $(".toctext").each(function(){ | ||
+ | var text = $(this).text().trim(); | ||
+ | |||
+ | if(text.substr(0, 1) == "\u2713"){ | ||
+ | $(this).addClass("planning-finished"); | ||
+ | }else{ | ||
+ | var parts = text.split(" - "); | ||
+ | if(parts.length == 1){ | ||
+ | $(this).addClass("planning-todo"); | ||
+ | }else{ | ||
+ | $(this).addClass("planning-taken"); | ||
+ | } | ||
+ | } | ||
+ | }); | ||
+ | } | ||
}, | }, | ||
setupProtocols: function(){ | setupProtocols: function(){ |
Revision as of 09:13, 12 July 2012
//Generate private namespace var EPFL = (function(){ var amp = unescape("%26"); return { registerNewPageButton: function(titleID, buttonID, base, preload){ $(buttonID).click(function(){ window.location.href = "/wiki/index.php?title="+base+"/"+$(titleID).val()+amp+"action=edit"+amp+"preload="+preload; }); }, setup: function(){ EPFL.setupProtocols(); EPFL.setupCalendar(); EPFL.setupPlanning(); $('p') .filter(function(){ return $.trim($(this).text()) === && $.trim($(this).html()).length < 10; }) .remove(); }, setupPlanning: function(){ if(location.href.match(/Team:EPF-Lausanne\/Planning/ig)){ $(".toctext").each(function(){ var text = $(this).text().trim();
if(text.substr(0, 1) == "\u2713"){ $(this).addClass("planning-finished"); }else{ var parts = text.split(" - "); if(parts.length == 1){ $(this).addClass("planning-todo"); }else{ $(this).addClass("planning-taken"); } } }); } }, setupProtocols: function(){ var hide = false; $(".protocol-title").each(function(){ if($.trim($(this).parent().parent().attr("class")) != "protocol-remove-style"){ hide = true; var link = $("<a>") .attr("href", "#") .click( function(){ $(this).parent().parent().children().last().toggle() return false; });
var children = $(this).children().children(); $(this).empty(); link.append(children); $(this).append(link); }else{ var txt = $(this).text(); $(this).empty(); $(this).text(txt); } }); if(hide) $(".protocol-inner-box").hide(); }, setupCalendar: function(){ var toAdd = amp+"preload=Team:EPF-Lausanne/Notebook/Template/NewEntry"; $(".month tr td a") .filter( function(){ return $(this).attr("href").length > 80; }) .each( function(){ $(this).attr("href", $(this).attr("href")+toAdd); } ); } }; }());
runOnloadHook = function(){ EPFL.setup(); };