Difference between revisions of "Dev/Sitemap"

 
(4 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
<link rel="stylesheet" type="text/css" href="https://igem.org/wiki/index.php?title=HQ:Sitemap.css&action=raw&ctype=text/css" />
 
<link rel="stylesheet" type="text/css" href="https://igem.org/wiki/index.php?title=HQ:Sitemap.css&action=raw&ctype=text/css" />
  
 +
<script src="https://igem.org/wiki/index.php?title=HQ:Sitemap.js&action=raw&ctype=text/javascript"></script>
  
  
Line 9: Line 10:
 
var site_name = "2016.igem.org";
 
var site_name = "2016.igem.org";
  
 +
</script>
  
//these script uses "0" to replace special characters for sorting and ordering pages
 
//"Sitemap" is part of the ids to make sure it is appended on the page and not on the menu or anywhere else
 
  
 
 
$(document).ready(function() {
 
 
//check if the user is part of HQ
 
check_user_priviliges();
 
 
// call the function to load the page list
 
load_page_list("http://"+site_name+"/Special:AllPages");
 
 
 
//switching between views
 
 
$(".view_format").click(function() {
 
$(".view_format").removeClass("selected_view");
 
$(".view_format_content").removeClass("selected_content");
 
 
$(this).addClass("selected_view");
 
$("#"+this.id+"_content").addClass("selected_content");
 
});
 
 
 
 
});
 
 
 
 
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
//FUNCTIONS
 
 
function check_user_priviliges (){
 
 
switch ( wgUserName) {
 
 
case "Sifuentes anita":
 
case "Vinoo":
 
case "THaddock":
 
case "Meagan":
 
case "MariaB":
 
$(".HQ_info").show();
 
break;
 
 
default:
 
$(".HQ_info").hide();
 
break;
 
}
 
}
 
 
 
/////////////////////////////////////////////////////////////////////////////////
 
 
 
 
function load_page_list ( page_url ) {
 
 
$.get(page_url).then(function(page_html) {
 
var $link_page = $(page_html);
 
 
$link_page.find('.mw-allpages-chunk li').each(function () {
 
sort_pages( $(this).text(),  $(this).html() );
 
});
 
 
 
var next_page_url = $link_page.find('.mw-allpages-nav a:contains("Next page")').attr('href');
 
 
//if there is another page with more links, run this function again
 
if (next_page_url) {
 
load_page_list(next_page_url);
 
}
 
 
//content is done loading!
 
else {
 
content_is_done_loading();
 
}
 
 
});
 
 
}
 
 
 
/////////////////////////////////////////////////////////////////////////////////
 
 
function content_is_done_loading(){
 
$(".loading").fadeOut("slow");
 
$(".control_button").fadeIn("slow");
 
 
//expand and collapse for team pages can be used now
 
$(".expand_collapse.control_button").click(function(){
 
$(this).next().fadeToggle(400);
 
$(this).toggleClass("less");
 
});
 
 
$("#total_pages_count").append($("#organized_pages li").length + $("#HQ li").length + $("#redirect li").length + $("#team_list li").length + $("#not_sorted li").length );
 
 
$("#wiki_pages_count").append($("#organized_pages li").length);
 
$("#hq_pages_count").append($("#HQ li").length);
 
$("#redirect_pages_count").append($("#redirect li").length);
 
$("#not_sorted_pages_count").append($("#not_sorted li").length);
 
$("#team_pages_count").append($("#team_list li").length);
 
 
}
 
 
 
/////////////////////////////////////////////////////////////////////////////////
 
 
 
function sort_pages ( page_name , page_link ) {
 
 
 
//this stores the id to where the page will appended to
 
var id_to_append_to;
 
 
//this variable will have the page name with only the necessary information for being displayed
 
var page_name_display = page_name.substring(page_name.lastIndexOf("/")+1, page_name.length);
 
 
// clean page name from empty spaces
 
page_name = page_name.replace(/ /g,"_"); 
 
 
//this stores the id for the sublist that is created in order to nest pages in the append_page function
 
var page_sublist_id = "Sitemap0" ;
 
 
 
 
 
// first, check if a page is a redirect or a special case. If not...
 
if ( is_it_a_special_page ( page_name, page_link ) == false ) { 
 
 
// check how many "tiers" (  /  ) the page name has in order to place it appropiately
 
switch  ( (page_name.match( /\//g ) || []).length  ) { 
 
 
 
// this might be a hub or a team page
 
case 0: 
 
if(page_name.substring(0,4) == "Team"){
 
id_to_append_to = "#team_list";
 
page_sublist_id = page_sublist_id + page_name.replace( /:/g , "0");
 
append_main_team_page(id_to_append_to, page_name, page_name_display, page_sublist_id);
 
}
 
else {
 
id_to_append_to = "#organized_pages";
 
page_sublist_id = page_sublist_id + page_name;
 
append_page(id_to_append_to, page_name, page_name_display, page_sublist_id);
 
}
 
break;
 
 
 
//this page is under a hub or under a team page
 
case 1:
 
 
page_sublist_id = page_sublist_id + page_name.replace( /\//g , "0");
 
id_to_append_to = "#Sitemap0"+ page_name.substring(0, page_name.indexOf("/"));
 
 
if(page_name.substring(0,4) == "Team"){
 
id_to_append_to = id_to_append_to.replace( /:/g , "0");
 
page_sublist_id = page_sublist_id.replace( /:/g , "0");
 
}
 
 
append_page(id_to_append_to, page_name, page_name_display, page_sublist_id);
 
 
break;
 
 
 
//this page is under a submenu
 
case 2:
 
 
id_to_append_to = "#" + page_sublist_id + page_name.substring(0, page_name.lastIndexOf("/"));
 
id_to_append_to = id_to_append_to.replace( /\//g , "0");
 
page_sublist_id = page_sublist_id + page_name.replace( /\//g , "0");
 
 
if(page_name.substring(0,4) == "Team"){
 
id_to_append_to = id_to_append_to.replace( /:/g , "0");
 
page_sublist_id = page_sublist_id.replace( /:/g , "0");
 
}
 
 
append_page(id_to_append_to, page_name, page_name_display, page_sublist_id);
 
 
break;
 
 
 
// this page has more than 3 "/"
 
case 3: default:
 
 
//check if this is a team's page, if so, append to a team namespace
 
if(page_name.substring(0,4) == "Team"){
 
id_to_append_to = page_name.substring(0, page_name.indexOf("/"));
 
id_to_append_to = "#Sitemap0" + id_to_append_to.replace( /:/g , "0");
 
page_name_display = page_name.substring( page_name.indexOf("/") +1 , page_name.length);
 
append_page(id_to_append_to, page_name, page_name_display, "");
 
}
 
// hq pages shouldn't go beyond 3 "/" - append to not sorted
 
else {
 
$("#not_sorted").append("<li> <a  href='"+page_name+"'>"+page_name +"</a></li>");
 
}
 
break;
 
 
 
}
 
 
}
 
 
 
}
 
 
 
/////////////////////////////////////////////////////////////////////////////////
 
 
 
//Function to check if the page is a redirect ( a non existing page)
 
function is_it_a_special_page ( page_name, page_link ) {
 
 
 
// is it a HQ page or a Dev page ?
 
if( page_name.substring(0, 2 ) == "HQ"  ||  page_name.substring(0, page_name.indexOf("/") ) == "Dev" ) {
 
$("#HQ").append("<li ><a  href='/"+page_name+"'>"+page_name +"</a> </li>");
 
return true;
 
}
 
 
// is it a redirect?
 
else if( page_link.indexOf("mw-redirect") >= 0)  {
 
 
//if it is a team page redirect, process it as normal team page
 
if(page_name.substring(0,5) == "Team:"){
 
return false;
 
}
 
else {
 
$("#redirect").append("<li >"+ page_link+"</li>" );
 
return true;
 
}
 
}
 
 
//if a page doesn't fall under the menu structure for a specific reason
 
else if (page_name == "Common_Ground" || page_name == "Letter") {
 
$("#HQ").append("<li ><a  href='/"+page_name+"'>"+page_name +"</a> </li>");
 
return true;
 
}
 
 
//if an invisible name is part of the team name (this is a work around a special case with team US AFRL CarrollHS)
 
else if ( page_name.indexOf('&#8203;') > -1) {
 
return true;
 
}
 
 
 
// this page is not a special case, let's sort it!
 
else {
 
return false;
 
}
 
 
}
 
 
 
/////////////////////////////////////////////////////////////////////////////////
 
 
 
function append_page (id_to_append_to, page_name, page_name_display, page_sublist_id ) {
 
 
//check if id_to_append_to exists - if not, let's try to append it to another parent so the page is not orphaned
 
var found_where_to_append = false;
 
 
 
//if it has somewhere to be appended
 
if($(id_to_append_to).length > 0) {
 
found_where_to_append = true;
 
}
 
 
else {
 
 
 
for( i=0; i < (id_to_append_to.match(/0/g) || []).length ; i++){
 
 
//trim to try to find a parent to append to
 
id_to_append_to =  id_to_append_to.substring(0, id_to_append_to.lastIndexOf("0"));
 
 
//check if it has somewhere to append, if so break the loop
 
if($(id_to_append_to).length > 0) {
 
found_where_to_append = true;
 
i = 999;
 
}
 
 
}
 
 
}
 
 
 
// if it didnt have anywhere to append, send it to not sorted
 
if ( found_where_to_append ==  false){
 
id_to_append_to ="#not_sorted";
 
}
 
 
//clean from special chars for the variables using in appending
 
 
console.log(id_to_append_to +""+ "__________"+""+ page_sublist_id);
 
 
 
$(id_to_append_to).append("<li><a href='http://"+site_name+"/"+page_name+"'>"+page_name_display+"</a>  <ol id='"+page_sublist_id+"' ></ol></li>");
 
 
 
}
 
 
 
 
 
/////////////////////////////////////////////////////////////////////////////////
 
 
 
function append_main_team_page (id_to_append_to, page_name, page_name_display, page_sublist_id ) {
 
 
 
$(id_to_append_to).append("<li><a href='http://"+site_name+"/"+page_name+"'>"+page_name_display+"</a><div class='expand_collapse control_button'> </div> <div class='expand_collapse content'><ol id='"+page_sublist_id+"' ></ol> </div>  </li> <div class='clear extra_space'></div> ");
 
 
}
 
 
 
 
/////////////////////////////////////////////////////////////////////////////////
 
 
 
 
 
 
</script>
 
  
  

Latest revision as of 19:42, 19 May 2017

SITEMAP

iGEM is a multifaceted competition with many different components. Our websites have a lot of information, from requirements of the competition to tips on how make fundraising easier. This page is here to help you navigate our site and make sure you have access to all of its content.

PAGE LIST
TEAM PAGES
HQ

TEAMS

Loading all team pages...

HQ

This is the view for iGEM HQ

Total pages Wiki pages HQ pages Redirect pages Not sorted Team pages

...

...

...

...

...

...

HQ pages

Redirects

Not Sorted