FANDOM


Nuvola apps important
This script is for PERSONAL use only!
You are free to install this script for yourself, but it is not allowed to be used wiki-wide (e.g., in MediaWiki:Common.js or MediaWiki:Wikia.js), as it would violate FANDOM's Terms of Use.
(See the customization policy)

SnowStorm adds animated, customizable, JavaScript snow on a wiki.

Installation

See also: Help:Including additional CSS and JS, Help:Advanced CSS and JS
  • For personal use, add the code snippet below to your global.js page (for use on all wikis) or your common.js page on your wiki (for use on a single wiki). Note that personal JS must be enabled for your account.
importArticles({
    type: 'script',
    articles: [
        'u:dev:MediaWiki:SnowStorm.js',
    ]
});
importArticles — Best Practices for installing JavaScript on FANDOM

The importArticles statement is designed to combine multiple HTTP requests into a single data transfer, allowing multiple scripts to load and execute faster. If you've been installing several different scripts, your JavaScript file has probably accumulated unnecessary import statements. Click "Expand" to learn how to efficiently batch import scripts to speed up performance and make your code look cleaner. One other approach is by using the MediaWiki:ImportJS.

If your JavaScript file has several lines of code that say importScript, importScriptPage, or importArticles, you may be able to combine them! By batch importing a collection of scripts with a single import, your JavaScript code will load faster and look cleaner. Consider the example below. On the left is an example of what your JavaScript file might currently look like. On the right is how you could improve that code.

Multiple imports — messy and slow One import — clean and efficient
importScriptPage('AjaxRC/code.js','dev');
 
importScript('MediaWiki:localScript.js');
 
importArticle({
  type: 'script',
  article: 'u:dev:FloatingToc/code.js'
});
 
importScriptPage('page1.js', 'wikiname');
 
importScriptPage('page2.js', 'wikiname');
importArticles({
  type: 'script',
  articles: [
    'u:dev:AjaxRC/code.js',
    'MediaWiki:localScript.js',
    'u:dev:FloatingToc/code.js',
    'u:wikiname:page1.js',
    'u:wikiname:page2.js'
  ]
});

Note: In this example, pay close attention to the placement of commas and other punctuation. For people who aren't familiar with programming (and even those who are!), a common mistake when writing code is to accidentally delete, forget, or misplace critical symbols like commas or quotation marks. This can cause a syntax error that breaks the code. Carefully follow the convention shown here when using importArticles.

But there's much more to importArticles than just this! For more examples and advanced usage, see the help page at Help:Including additional JavaScript and CSS.

Configuration

The script can be used as it is, but it does also support these customizable variables that can be added before the import on Common.js. Common.js will run before MediaWiki:ImportJS.

Using configuration options with FANDOM Open Source Library scripts
The instructions on this page describe how to use configuration options with a script. Here on the FANDOM Open Source Library, many scripts provide optional configuration settings as a mean to alter or enhance the default behavior of the script. When installing configuration options in your JavaScript file, please note that they need to go above the import statement in order to work — unless the directions say otherwise. In case MediaWiki:ImportJS is used to load the scripts, it will be executed last.
Configuration options load too late, don't work
Proper placement of configuration options
// 1. AjaxRC import statement
importScriptPage('AjaxRC/code.js','dev');
 
// 2. AjaxRC configuration option
var ajaxRefresh = 30000;
// 1. AjaxRC configuration option
var ajaxRefresh = 30000;
 
// 2. AjaxRC import statement
importScriptPage('AjaxRC/code.js','dev');
Variable Description Default value Type
autoStart Whether the snow should start automatically or not. true boolean
snowCfg_onlyOasis Whether should be run only in Oasis or not. true boolean
excludeMobile Snow is likely to be bad news for mobile phones' CPUs (and batteries.) Enable at your own risk. true boolean
flakesMax Limit total amount of snow made (falling + sticking). 128 number
flakesMaxActive Limit amount of snow falling at once (less = lower CPU use). 64 number
animationInterval Theoretical "milliseconds per frame" measurement. 20 = fast + smooth, but high CPU use. 50 = more conservative, but slower. 35 number
useGPU Enable transform-based hardware acceleration, reduce CPU load. true boolean
className CSS class name for further customization on snow elements. null string
flakeBottom Integer for Y axis snow limit, 0 or null for "full-screen" snow effect. null number
followMouse Snow movement can respond to the user's mouse. true boolean
snowColor Snow color. #fff string
snowCharacter Character to use as snowflake. • () string
snowStick Whether or not snow should "stick" at the bottom. When off, will never collect. true boolean
targetElement Element which snow will be appended to (null = document.body) - can be an element ID eg. 'myDiv', or a DOM node reference. null string
useMeltEffect When recycling fallen snow (or rarely, when falling), have it "melt" and fade out if browser supports it. true boolean
useTwinkleEffect Allow snow to randomly "flicker" in and out of view while falling. false boolean
usePositionFixed true = snow does not shift vertically when scrolling. May increase CPU load, if enabled, used only where supported. false boolean
usePixelPosition Whether to use pixel values for snow top/left vs. percentages. Auto-enabled if body is position:relative or targetElement is specified. false boolean
Less used
freezeOnBlur Only snow when the window is in focus (foreground.) Saves CPU. Note: if the snow randomly speeds up after some time while changing tab focus (especially on Chrome), turning this off should solve the problem. true boolean
flakeLeftOffset Left margin/gutter space on edge of container (eg. browser window.) Bump up these values if seeing horizontal scrollbars. 0 number
flakeWidth Max pixel width reserved for snow element. 8 number
flakeHeight Max pixel height reserved for snow element. 8 number
vMaxX Defines maximum X velocity for the storm; a random value in this range is selected for each snowflake. 5 number
vMaxY Defines maximum Y velocity for the storm; a random value in this range is selected for each snowflake. 4 number
zIndex CSS stacking order applied to each snowflake. 1 number
windOffset 1 number
windMultiplier 2 number
flakeTypes 6 number

Changelog

Date Notes Updated by
December 1st, 2012 First version XD1
May 13th, 2016 Added Rappy 4187
December 2nd, 2016 1) previously you could not set "false" or "null" custom values 2) added "onlyoasis" option 3) made available extra customizations leviathan 89