Difference between revisions of "Widget:RAPID-Transclude"

From Open Energy Information

(remove commented out code)
(add function to change overview pages on tech/jur/topic pages)
Line 2: Line 2:
 
This template performs an ajax request for [[RAPID]] Tech/Jurisdiction/Topic pages, based on their related [[RAPID/Roadmap|Roadmap Overview]] page.  It is called by [[:Template:RAPID-Overview(Tech-Jurisdiction-Topic).  See [[RAPID/Geothermal/California/Land Use]] as an example.
 
This template performs an ajax request for [[RAPID]] Tech/Jurisdiction/Topic pages, based on their related [[RAPID/Roadmap|Roadmap Overview]] page.  It is called by [[:Template:RAPID-Overview(Tech-Jurisdiction-Topic).  See [[RAPID/Geothermal/California/Land Use]] as an example.
  
The template "transcludes" information from the right column, the overview and the narrative from pages like [[RAPID/Roadmap/3]] and imports it to the page using the above template (such as [[RAPID/Geothermal/California/Land Use]]).  It also removes any links/buttons that are not related to the current page's jurisdiction.
+
The template "[[https://www.mediawiki.org/wiki/Transclusion transcludes]]" information from the right column, the overview and the narrative from pages like [[RAPID/Roadmap/3]] and imports it to the page using the above template (such as [[RAPID/Geothermal/California/Land Use]]).  It also removes any links/buttons that are not related to the current page's jurisdiction.
 
[[Category:RAPID Widgets]]
 
[[Category:RAPID Widgets]]
 
</noinclude><includeonly>
 
</noinclude><includeonly>
Line 243: Line 243:
  
 
   //fetch the content from the defined overview page and populate the appropriate sections
 
   //fetch the content from the defined overview page and populate the appropriate sections
           $.ajax({  
+
           $.ajax({
 
             url: mwhost+"/wiki/"+roadmapPage, cache: 'false', dataType: 'html', success: function(response) {
 
             url: mwhost+"/wiki/"+roadmapPage, cache: 'false', dataType: 'html', success: function(response) {
               $('#warpSummary').html(jQuery(response).find('#roadmapOverview').html());  
+
               $('#warpSummary').html(jQuery(response).find('#roadmapOverview').html());
               $('#warpNarrative').html(jQuery(response).find('#narrativeDescription').html());  
+
               $('#warpNarrative').html(jQuery(response).find('#narrativeDescription').html());
 
             },
 
             },
 
             complete: function(collapser){
 
             complete: function(collapser){
Line 270: Line 270:
 
                 }
 
                 }
 
               });
 
               });
             
+
 
 
               //Expand all narrative-blocks for print pdf option
 
               //Expand all narrative-blocks for print pdf option
 
               var printPDF = location.href.indexOf("print=pdf");
 
               var printPDF = location.href.indexOf("print=pdf");
Line 283: Line 283:
 
                   }
 
                   }
 
               });
 
               });
               
+
 
 
               //use abbr to remove buttons and content for non-matching states
 
               //use abbr to remove buttons and content for non-matching states
 
               $('.btn-state').each(function(){
 
               $('.btn-state').each(function(){
Line 295: Line 295:
 
                 }
 
                 }
 
               });
 
               });
               $('.state-label').remove();  
+
               $('.state-label').remove();
  
  
Line 306: Line 306:
 
                   $(this).remove();
 
                   $(this).remove();
 
                 }
 
                 }
 +
              });
 +
 +
              $('.btn-overview').each(function(){
 +
                initialLink = $(this).children('a').attr('href');
 +
                newTopic = initialLink.split('/').slice(-1).pop();
 +
                if(newTopic.indexOf('FD')>-1){
 +
                  return;
 +
                }
 +
                if(newTopic.length > 2){
 +
                  newTopic = newTopic.replace(/_\(\d\)/,'');
 +
                }
 +
                $(this).children('a').remove();
 +
 +
                newLink = $('#left-nav li[data-nav--topic="'+newTopic+'"] a').attr('href');
 +
                newTitle = $('#left-nav [data-nav--topic="'+newTopic+'"] a').attr('title');
 +
                newText = $('#left-nav [data-nav--topic="'+newTopic+'"] a').text();
 +
                newBtn = '<a href="'+newLink+'" title="'+newTitle+'">'+locationMapper+' '+techMapper+' '+newText+' ('+newTopic+'-'+overviewAbbr+')</a>';
 +
 +
                $(this).append(newBtn);
 +
                $(this).removeClass('btn-overview').addClass('btn-state no-star').css('margin-left','calc((100% - 350px)/2)');
 
               });
 
               });
  

Revision as of 15:12, 7 March 2019

This template performs an ajax request for RAPID Tech/Jurisdiction/Topic pages, based on their related Roadmap Overview page. It is called by [[:Template:RAPID-Overview(Tech-Jurisdiction-Topic). See RAPID/Geothermal/California/Land Use as an example.

The template "[transcludes]" information from the right column, the overview and the narrative from pages like RAPID/Roadmap/3 and imports it to the page using the above template (such as RAPID/Geothermal/California/Land Use). It also removes any links/buttons that are not related to the current page's jurisdiction.