MediaWiki:Common.js

From dataZoa Wiki
Revision as of 06:54, 26 September 2016 by RB (Talk | contribs) (Created page with "Any JavaScript here will be loaded for all users on every page load.: $( function () { //the below doesn't work, or, I don't know how to call the function var hello_fr...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences
/* Any JavaScript here will be loaded for all users on every page load. */
 
$( function ()  {
 
//the below doesn't work, or, I don't know how to call the function
var hello_friend = function() {
	window.alert("hello friend!");
	}
 
//the below does work!!
$(document).ready(function(){
$("h2").click(function(){
alert("The h2 was clicked.");
});
});
 
 
//here's a try at JQuery load
$(document).ready(function(){
    $("button").click(function(){ //when the button is clicked
        $("#loadjs").load("demo_test.txt"); //replace whatever is in div1 with the contents of demo_test.txt
    });
});
	// Paste snippet here.
	// Paste as many as you like, only one "$( function () { ... } );" wrapper is needed!
} );
 
//testing to see whether I can load any function
 
function someAlert() {
alert("this is a javascript function being called!");
}
 
//my JQuery_Test_Load as a function
 
function testLoad() {
$(document).ready(function(){ 
                                        jQuery.ajax({
    					url:'http://wordaroundtown.com/wiki/index.php?title=Test_Origin_Text',
    					type:'get',
    					dataType:'html',
    					success:function(data)
   						{ 
   					var _html= jQuery(data);
       					list = _html.find('li'); // gets me an object (maybe?) with four elements
       					for (i = 0; i <= list.length; i++) {
    						console.log(list[i].innerHTML); //I get an error on HTML but it still seems to output correctly
    					        var node = document.createElement("li"); // create a <li> node
    						var textnode = document.createTextNode(list[i].innerHTML); //create a text node
    						node.appendChild(textnode); // append text to li
    						document.getElementById("myList").appendChild(node); // append li to ul with id="myList"
						}
   						}
					});
					//console.log(myList.html());
				});
}