User:Jeiara/monaco.js

/** renderGoogleCharts ************************************************************** * * Description: Replaces links to google charts with images of the chart. *              The title and alternate text of the image will be the text of the link. *              If the link is placed inside a element with class="nochart", *              the link won't be touched. * Written by:  w:User:Ciencia Al Poder "Jesús Martínez Novo" */

function renderGoogleCharts{ if (!document.getElementById('bodyContent')) return; var as = document.getElementById('bodyContent').getElementsByTagName('a'); for (var i = as.length-1; i>=0; i--){ if (as[i].href.indexOf('http://chart.apis.google.com/chart?') == 0){ if ((' '+as[i].parentNode.className+' ').indexOf(' nochart ') == -1){ var img = document.createElement('img'); img.src = as[i].href; var content = as[i].textContent || as[i].innerHTML || 'This is a chart' img.alt = content; img.title = content; as[i].parentNode.replaceChild(img, as[i]); } } } }

addOnloadHook(renderGoogleCharts);

/** Create pop-up menu of image tags ************************************************* * Description: Creates a pop-up menu using the Yahoo! User Interface library (YUI). *              Used in conjunction with insertImageTags function below. * Written by: User:Jeiara for http://terminator.wikia.com */

// This script is to be used only for a specific page: Special:MultipleUpload if (wgPageName == "Special:MultipleUpload") {

// Variables for pop-up Menu // Notes: Wikia has YUI Dom and Event already installed, no need to import. //var domevents = 'http://yui.yahooapis.com/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js'; var dragdrop = 'http://yui.yahooapis.com/2.6.0/build/dragdrop/dragdrop-min.js'; var container = 'http://yui.yahooapis.com/2.6.0/build/container/container-min.js'; var container_css = 'http://yui.yahooapis.com/2.6.0/build/container/assets/skins/sam/container.css';

importScriptURI(dragdrop); importScriptURI(container); importStylesheetURI(container_css);

var popMenu; YAHOO.example.panels = function{ popMenu = new YAHOO.widget.Panel("popMenu", 		{ 				width:"450px",                       height:"275px",			close:true,  			visible:false,  			draggable:true,			context:['wiki_logo','tl','br'],			constraintoviewport:true		} 	); popMenu.setHeader('Dynamic!'); popMenu.setBody(" Aliquam ultrices. Nulla dictum, augue et condimentum commodo. "); popMenu.setFooter('Footer'); popMenu.render(document.body); }; YAHOO.util.Event.addListener(window,'load',YAHOO.example.panels);

/** insertImageTags ***************************************************************** * * Description: Inserts a link with the text: "Add Image Tags", that activates a  *               pop-up menu listing image tags that can be added to the summary box. * Written by:  User:Jeiara for http://terminator.wikia.com */

function insertImageTags {

// Add Yahoo styles for pop-up menu by adding class to body YAHOO.util.Dom.addClass('body', 'yui-skin-sam');

// Obtain reference to table containing form inputs var tableRef = document.getElementById('upload').getElementsByTagName('table')[0]; var tRows = tableRef.rows; var num = -1; // Find only the Summary input boxes for (var i=0; i<tRows.length; i++) { var inputElements = tRows[i].getElementsByTagName('input'); for (var j=0; j<inputElements.length; j++) { // Extract only input name of Summary boxes if (inputElements[j].name.split("_")[0] == 'wpUploadDescription') { num++; // Increase uploads description quantity var aRow = tableRef.rows[i]; // Insert "Add Image Tags" link after Summary box var insertLink = document.createElement('a'); insertLink.id = 'insertLink_'+ num; insertLink.href = '#'; insertLink.innerHTML = 'Add Image Tags'; insertLink.onclick = function{ popMenu.show; return false; };			aRow.insertCell(j+1).appendChild(insertLink); }         }              }

}

addOnloadHook(insertImageTags);

} // END if wgPageName == "Special:MultipleUpload"