User:Changtau2005/wikia.js

/*UI--*/ //Developer's skin toggles on toolbar from var monoBookText = 'Monobook'; importScriptURI('http://dev.wikia.com/index.php?title=SkinSwitchButton/code.js&action=raw&ctype=text/javascript');

//Page controls - Oasis Toolbar Buttons from importScriptURI('http://dev.wikia.com/index.php?title=OasisToolbarButtons/code.js&action=raw&ctype=text/javascript');

/* --- Site JS sandbox --- */

importScriptURI('http://http://kirby.wikia.com/wiki/User:Changtau2005/common.js&action=raw&ctype=text/javascript');

/* DOC */ function initYtIframePlayers { var INSTANCE_HOOK = '.kw-js-yt-iframeapi-hook'; var TRACKID_HOOK = 'kw-js-yt-iframeapi-trackid'; var WIDTH_HOOK = 'kw-js-yt-iframeapi-width'; var HEIGHT_HOOK = 'kw-js-yt-iframeapi-height'; var SANITIZE_HOOK = '.kw-js-sanitize'; var sanitizer = new Sanitize({       elements: [] // Disallow any and all HTML nodes except text nodes    }); var instances; var params; // Gets instances of DOM specified by Template:YoutubePlayer function getInstances { var instances = $(INSTANCE_HOOK); return instances; }   // Gets all sanitized player parameters from specified template parameters function getPlayerParams(instances) { var params = []; for(var i = 0; i < instances.length; i++) { var instanceElem = $(instances[i]); trackIdNode = instanceElem.child(TRACKID_HOOK); widthNode = instanceElem.child(WIDTH_HOOK); heightNode = instanceElem.child(HEIGHT_HOOK); var trackId = $(' ').append(sanitizer.clean_node(trackIdNode)).html; var width = $(' ').append(sanitizer.clean_node(widthNode)).html; var height = $(' ').append(sanitizer.clean_node(heightNode)).html; params.push({               id: trackId,                width: width,                height: height            }) }       return params; }   instances = getInstances; params = getPlayerParams; console.log(instances); console.log(params); function getTrackIds { var elems = $(SANITIZE_HOOK); var trackIds = []; for(var i=0; i < elems.length; i++) { var elem = elems[i]; var cleanElem = sanitizer.clean_node(elem); var trackId = $(' ').append(cleanElem).html; /* Get innerHTML from doc frag */ // console.log(trackId); trackIds.push(trackId); }       return trackIds; }   function loadPlayers { //todo }   //var trackIds = getTrackIds; //console.log(trackIds); }

addOnloadHook(initYtIframePlayers);