|
|
Line 356: |
Line 356: |
| $(document).ready(function() { | | $(document).ready(function() { |
| | | |
− | | + | function get_team_info ( ); |
− | | + | |
− | load_page_list ( ); | + | |
− | | + | |
− | $(".list_view").delay( 500 ).fadeIn('slow');
| + | |
− | $("#display_as_list").addClass("selected");
| + | |
− | | + | |
− | $(".collapse_control").click(function() {
| + | |
− | | + | |
− | $(this).next(".collapse_content").toggleClass( "hide_content");
| + | |
− |
| + | |
− | if( $(this).next(".collapse_content").hasClass("hide_content") ) {
| + | |
− | $(this).find(".collapse_icon").addClass("triangle_hide").removeClass("triangle_show");
| + | |
− | }
| + | |
− | else {
| + | |
− | $(this).find(".collapse_icon").addClass("triangle_show").removeClass("triangle_hide");
| + | |
− | }
| + | |
− | });
| + | |
− |
| + | |
− | | + | |
− | | + | |
− | | + | |
− | $("#display_as_list").click(function() {
| + | |
− | | + | |
− | $(this).addClass("selected");
| + | |
− | $("#display_as_bucket").removeClass("selected");
| + | |
− | $(".list_view").fadeIn('slow');
| + | |
− | $(".bucket_view").hide();
| + | |
− | | + | |
− | });
| + | |
− | | + | |
− | $("#display_as_bucket").click(function() {
| + | |
− | | + | |
− | $(this).addClass("selected");
| + | |
− | $("#display_as_list").removeClass("selected");
| + | |
− | $(".bucket_view").fadeIn('slow');
| + | |
− | $(".list_view").hide();
| + | |
− | | + | |
− | });
| + | |
| | | |
| }); | | }); |
| | | |
| | | |
| + | function get_team_info ( ) { |
| | | |
| + | $.ajax({ |
| + | url: "https://2016.igem.org/wiki/api.php?action=query&list=allpages&format=json&aplimit=5000", |
| + | type: "GET", |
| + | dataType: "json", |
| + | timeout: 4000, |
| | | |
− | function load_page_list () {
| + | error: function( ) { |
− |
| + | alert ("no :c "); |
− | $("#complete_list_of_pages").load( "https://2016.igem.org/Special:AllPages .mw-allpages-chunk", function() { | + | }, |
− | | + | |
− | $('ul.mw-allpages-chunk li').each(function () { | + | |
− | sort_pages( $(this).text(), $(this).html() ); //sort each page
| + | |
− | });
| + | |
− | | + | |
− | // Wiki counters
| + | |
− | $(".total_number_of_pages").html( $( 'ul.mw-allpages-chunk li').length );
| + | |
− |
| + | |
− | $(".total_number_of_our_wiki_pages").html( $( 'ul.mw-allpages-chunk li').length - ( $("#HQ_Hub").children().length + $("#redirect").children().length + $("#not_sorted").children().length) );
| + | |
− | | + | |
− | $(".total_number_of_hq_pages").html( $("#HQ_Hub").children().length );
| + | |
− | | + | |
− | $(".total_number_of_redirect_pages").html( $("#redirect").children().length );
| + | |
− | | + | |
− | $(".total_number_of_not_sorted_pages").html( $("#not_sorted").children().length );
| + | |
− | | + | |
− | }); | + | |
− | | + | |
− | | + | |
− | | + | |
− | }
| + | |
− | | + | |
− | | + | |
− | function sort_pages ( page_name , page_link ) {
| + | |
− |
| + | |
− | if ( is_it_a_special_page ( page_name, page_link ) == false ) { // check if a page is a redirect
| + | |
− |
| + | |
− | | + | |
− | page_name = page_name.replace(/ /g,"_").replace(/:/g, "_"); // clean string from empty spaces
| + | |
− | | + | |
− | | + | |
− | switch ( (page_name.match( /\//g ) || []).length ) { // check how many "tiers" ( / ) the page name has in order to nest it
| + | |
− | | + | |
− | case 0: // this might be a hub or an unassigned page
| + | |
− | append_tier_one ( page_name );
| + | |
− | break;
| + | |
− | | + | |
− | case 1: //this page is likely to have a hub to append to
| + | |
− | append_tier_two ( page_name );
| + | |
− | break;
| + | |
− | | + | |
− | case 2: //this page might be a subpage inside a page in a hub list
| + | |
− | append_tier_three ( page_name );
| + | |
− | break;
| + | |
− | | + | |
− | case 3: //this page might be a subpage inside a page in a hub list
| + | |
− | append_to_not_sorted (page_name );
| + | |
− | break;
| + | |
− | }
| + | |
| | | |
| + | success: function( ) { |
| + | alert ("success!"); |
| } | | } |
− | | + | }); |
− |
| + | |
− | } | + | |
− | | + | |
− | //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_Hub").append("<li ><a href='/"+page_name+"'>"+page_name +"</a> </li>");
| + | |
− | return true;
| + | |
− | }
| + | |
− | | + | |
− | // is this a page from a team ?
| + | |
− | | + | |
− | else if ( page_name.substring(0, 4 ) == "Team") {
| + | |
− | | + | |
− | console.log (page_name);
| + | |
− | | + | |
− | if ( page_name.substring(5, 12 ) == "Example" ) {
| + | |
− | if ( page_name.substring(5, 13 ) != "Example2") {
| + | |
− | //return false; // if it is from team example it is fine
| + | |
− | | + | |
− | | + | |
− | var page_help = page_name.replace(/:/g, "_");
| + | |
− | | + | |
− | if ( page_name == "Team:Example") {
| + | |
− | $("#Team_Hub").append("<div id='"+page_name+"_wrapper'><a href='/"+page_name+"'>"+page_name+"</a> <ol class='turquoise_link' id='" +page_help+"' ></ol> </div>");
| + | |
− | $("#main_container").append("<div id='"+page_name+"_wrapper'><a href='/"+page_name+"'>"+page_name+"</a> <ol class='turquoise_link' id='main_"+page_help+"' ></ol> </div>");
| + | |
− | }
| + | |
− | | + | |
− | else {
| + | |
− | console.log(page_name);
| + | |
− | $("#"+page_help.substring(0, page_help.indexOf("/") ) ).append("<li><a href='/"+page_name+"'> "+page_name.substring( page_name.indexOf("/")+1, page_name.length )+"</a> <ul id='"+page_help+"'> </ul></li>");
| + | |
− | | + | |
− | $("#main_"+page_help.substring(0, page_help.indexOf("/") ) ).append("<li><a href='/"+page_name+"'> "+page_name.substring( page_name.indexOf("/")+1, page_name.length )+"</a> <ul id='main_"+page_help+"'> </ul></li>");
| + | |
− | | + | |
− | }
| + | |
− | | + | |
− | return true; // page sorted, done!
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | else {
| + | |
− | return true; // this is a page from a team, ignore
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | // is it a redirect?
| + | |
− | else if( page_link.indexOf("mw-redirect") >= 0) {
| + | |
− | $("#redirect").append("<li >"+ page_link+"</li>" );
| + | |
− | return true;
| + | |
− | }
| + | |
− | else {
| + | |
− | return false;
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | | + | |
− | function append_to_not_sorted (page_name) {
| + | |
− | | + | |
− | $("#not_sorted").append("<li> <a href='"+page_name+"'>"+page_name +"</a></li>");
| + | |
− | | + | |
− | }
| + | |
− | | + | |
− | | + | |
− | function append_tier_one ( page_name ) {
| + | |
− | var categories_for_links = ["About", "Community", "Requirements", "Calendar", "Judging", "Safety", "Tracks", "Human_Practices", "Giant_Jamboree", "Resources", "Sponsors" ];
| + | |
− | var was_page_placed = false;
| + | |
− | var no_underscores_name = page_name.replace( /_/g , " ");
| + | |
− | | + | |
− | | + | |
− | | + | |
− | for ( i =0; i< categories_for_links.length; i++) {
| + | |
− | // if the page name has that specific category
| + | |
− | | + | |
− | if ( page_name.substring( 0 ,categories_for_links[i].length) == categories_for_links[i] ) {
| + | |
− | | + | |
− |
| + | |
− | $("#"+categories_for_links[i]+"_Hub").append("<div id='"+page_name+"_wrapper'><a href='"+page_name+"'>"+no_underscores_name+"</a> <ol class='turquoise_link' id='" +page_name+"' ></ol> </div>");
| + | |
− | | + | |
− | | + | |
− | $("#main_container").append("<div id='"+page_name+"_wrapper'><a href='"+page_name+"'>"+no_underscores_name+"</a> <ol class='turquoise_link' id='main_"+page_name+"' ></ol> </div>");
| + | |
− | | + | |
− | | + | |
− | was_page_placed = true;
| + | |
− | | + | |
− | }
| + | |
| } | | } |
− |
| |
− | if ( was_page_placed == false ) {
| |
− | append_to_not_sorted (page_name);
| |
− | }
| |
− |
| |
− | }
| |
− |
| |
− |
| |
− |
| |
− |
| |
− |
| |
− | function append_tier_two (page_name ) {
| |
− |
| |
− |
| |
− | var clean_name = page_name.replace( /\//g , "-");
| |
− | var no_underscores_name = page_name.replace( /_/g , " ");
| |
− |
| |
− |
| |
− |
| |
− |
| |
− | // for bucket
| |
− | $("#"+page_name.substring(0, page_name.indexOf("/") ) ).append("<li><a href='"+page_name+"'> "+no_underscores_name.substring( page_name.indexOf("/")+1, page_name.length )+"</a> <ul id='"+clean_name+"'> </ul></li>");
| |
− |
| |
− |
| |
− |
| |
− | //for list
| |
− | $("#main_"+page_name.substring(0, page_name.indexOf("/") ) ).append("<li><a href='"+page_name+"'> "+no_underscores_name.substring( page_name.indexOf("/")+1, page_name.length )+"</a> <ul id='main_"+clean_name+"'> </ul></li>");
| |
− |
| |
− |
| |
− |
| |
− | }
| |
− |
| |
− |
| |
− |
| |
− | function append_tier_three (page_name ) {
| |
− |
| |
− | var clean_name = page_name.replace( /\//g , "-");
| |
− | var no_underscores_name = page_name.replace( /_/g , " ");
| |
− |
| |
− | //for bucket
| |
− | $("#"+clean_name.substring(0, clean_name.lastIndexOf("-") ) ).append("<li id='"+page_name+"'><a href='"+page_name+"'>"+no_underscores_name.substring( page_name.lastIndexOf("/")+1, page_name.length )+"</a></li>");
| |
− |
| |
− | //for list
| |
− | $("#main_"+clean_name.substring(0, clean_name.lastIndexOf("-") ) ).append("<li id='"+page_name+"'><a href='"+page_name+"'>"+no_underscores_name.substring( page_name.lastIndexOf("/")+1, page_name.length )+"</a></li>");
| |
− |
| |
− |
| |
− | }
| |
− |
| |
− |
| |
− |
| |
− |
| |
− |
| |
− |
| |
− | switch ( wgUserName) {
| |
− |
| |
− | case "Sifuentes anita":
| |
− | case "Vinoo":
| |
− | case "THaddock":
| |
− | case "Meagan":
| |
− | $(".HQ_info").delay( 800 ).fadeIn('slow');
| |
− | break;
| |
− |
| |
− | default:
| |
− | $(".HQ_info").hide();
| |
− | break;
| |
− |
| |
− |
| |
− |
| |
− | }
| |
− |
| |
− |
| |
− |
| |
− |
| |
− |
| |
− |
| |
− |
| |
− |
| |
− |
| |
| | | |
| | | |