Memory Alpha
Advertisement
Memory Alpha
Utilities Utilities → Scripts

This page serves as a central repository for Memory Alpha's scripts and their documentation. Unless otherwise indicated, all scripts shown on this page are available for public use under the terms of the CC BY-NC 4.0 license.

MediaWiki:Common.js[]

Interactive tree script[]

This script allows for the use of collapsible lists. Its main application is for "appearances" lists. It was originally written by User:Bp in 2006 and was completely rewritten by User:Mr. Starfleet Command in 2024. To use this script, simply wrap your list with <div class="appear">...</div>.

// Interactive Tree Script

var smallTreeCount = 3;

$('.appear').each(function(index, currentTree){
  const currentButtonID = 'mainButton-'+index;
  const numberOfSubLists = $(this).find('ul li ul, ol li ol, ul li ol, ol li ul').length;
  const total = $(this).find('ul li, ol li').length - numberOfSubLists;
  const buttonLabel = (total > smallTreeCount) ? 'show all' : 'hide all';
  const button = (numberOfSubLists === 0) ? '' : ' (<a id="'+currentButtonID+'" class="show-hide-button">'+buttonLabel+'</a>)';
  const desc = $('<div>This list includes '+total+' items'+button+'.</div>');

  $(this).prepend(desc);

  $('#'+currentButtonID).click(function(){
    if ($(this).text() === "show all"){
      $(currentTree).find('ul li ul, ol li ol, ul li ol, ol li ul').show();
    } else {
      $(currentTree).find('ul li ul, ol li ol, ul li ol, ol li ul').hide();
    }

    $(this).text(($(this).text() === "show all") ? "hide all" : "show all");
  });
});

$('.appear li ul, .appear li ol').each(function(index, currentTree){
  const currentButtonID = 'pane-'+index++;
  const total = $(this).find('li').length - $(this).find('ul li, ol li').length;
  const button = '<a id="'+currentButtonID+'" class="show-hide-button">'+total+'</a>';

  if (total > smallTreeCount){
    $(currentTree).hide();
  }

  $(this).before('('+button+')');

  $('#'+currentButtonID).click(function(){
    $(currentTree).toggle();
  });
});

Interactive quotes script[]

Memory Alpha:Scripts/interactive quotes

Welcome script[]

Memory Alpha:Scripts/welcome

Copyright notice script[]

Memory Alpha:Scripts/copyright notice

Right rail script[]

Memory Alpha:Scripts/right rail

Namespace prefix script[]

Memory Alpha:Scripts/namespace prefix

Countdown script[]

Memory Alpha:Scripts/countdown

Ogg and PDF scripts[]

Memory Alpha:Scripts/Ogg and PDF

Sidebar tabs script[]

Memory Alpha:Scripts/sidebar tabs

Gadgets[]

Featured videos script[]

Memory Alpha:Scripts/featured videos

Category intersection script[]

Memory Alpha:Scripts/category intersection

Duplicate links script[]

Memory Alpha:Scripts/duplicate links

Edit intro script[]

Memory Alpha:Scripts/edit intro

Purge script[]

Memory Alpha:Scripts/purge

See also[]

Advertisement