Difference between revisions of "MediaWiki:Common.js"

From PUBLIC DOMAIN PROJECT MEDIAPOOL
Jump to: navigation, search
(Created page with 'Any JavaScript here will be loaded for all users on every page load.: ** Place in MediaWiki:Common.js ***: function makeRequest(url) { var httpRequest; if (wind…')
 
(updated wikEd)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
/*** Place in MediaWiki:Common.js ****/
 
function makeRequest(url) {
 
  var httpRequest;
 
 
  if (window.XMLHttpRequest) { // Mozilla, Safari, ...
 
      httpRequest = new XMLHttpRequest();
 
  } else if (window.ActiveXObject) { // IE
 
    try {
 
      httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
 
    } catch (e) {
 
      try {
 
        httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
 
      } catch (e) {}
 
    }
 
  }
 
 
  if (!httpRequest) {
 
    alert("Giving up :( Cannot create an XMLHTTP instance");
 
    return false;
 
  }
 
  httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
 
  httpRequest.open("GET", url, true);
 
  httpRequest.send(null);
 
}
 
 
function alertContents(httpRequest) {
 
 
  if (httpRequest.readyState == 4) {
 
    if (httpRequest.status == 200) {
 
        document.getElementById("p-calendar").innerHTML = httpRequest.responseText;
 
    } else {
 
        document.getElementById("p-calendar").innerHTML = "<p>There was a problem with the request.</p>";
 
    }
 
  }
 
}
 
  
 
// install [[Wikipedia:User:Cacycle/wikEd]] in-browser text editor
 
// install [[Wikipedia:User:Cacycle/wikEd]] in-browser text editor
document.write('<script type="text/javascript" src="'
+
importScriptURI('//en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
+ 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
+
+ '&action=raw&ctype=text/javascript');
+ '&action=raw&ctype=text/javascript"></' + 'script>');
 

Latest revision as of 23:11, 24 October 2016

/* Any JavaScript here will be loaded for all users on every page load. */

// install [[Wikipedia:User:Cacycle/wikEd]] in-browser text editor
importScriptURI('//en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
+ '&action=raw&ctype=text/javascript');