User:Hippietrail/querytest.js

Hello, you have come here looking for the meaning of the word User:Hippietrail/querytest.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Hippietrail/querytest.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Hippietrail/querytest.js in singular and plural. Everything you need to know about the word User:Hippietrail/querytest.js you have here. The definition of the word User:Hippietrail/querytest.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Hippietrail/querytest.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
// this function attempts to download the data at url.
// if it succeeds, it runs the callback function, passing
// it the data downloaded and the article argument
function download(url, callback, article) {
   var http = window.XMLHttpRequest ? new XMLHttpRequest()
     : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP")
     : false;
  
   if (http) {
      http.onreadystatechange = function() {
         if (http.readyState == 4) {
            callback(http.responseText, article);
         }
      };
      http.open("GET", url, true);
      http.send(null);
   }
}

// convenience function for getting children whose keys are unknown
// such as children of pages subobjects, whose keys are numeric page ids
function anyChild(obj) { 
   for(var key in obj) {
      return obj;
   }
   return null; 
}

// tell the user a page that is linked to from article
function someLink(article) {
   // use format=jsonfm for human-readable output
   var url = "http://en.wiktionary.org/w/query.php?format=json&what=links&titles=" + escape(article);
   download(url, finishSomeLink, article);
}

// the callback, run after the queried data is downloaded
function finishSomeLink(data, article) {
   try {
      // convert the downloaded data into a javascript object
      eval("var queryResult=" + data);
      // we could combine these steps into one line
      var page = anyChild(queryResult.pages);
      var links = page.links;
   } catch (someError) {
      alert("Oh dear, the JSON stuff went awry");
      // do something drastic here
   }
   
   if (links && links.length) {
      alert(links + " is linked from " + article);
   } else {
      alert("No links on " + article + " found");
   }
}

//someLink("User:Hippietrail");