Class Index | File Index

Classes


Class atropa.CreateHtmlDocumentsFromXmlhttp


Version 20130225.
Creates HTML DOM Documents from an XMLHttpRequest object.
Defined in: <node_modules/atropa-CreateHtmlDocumentsFromXmlhttp/src/atropa-CreateHtmlDocumentsFromXmlhttp.js>.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates HTML DOM Documents from an XMLHttpRequest object.
Field Summary
Field Attributes Field Name and Description
 
Queue of documents created by this instance.
Method Summary
Method Attributes Method Name and Description
 
newDocument(method, url, messageBody, callback)
Creates an HTML DOM Document and puts it in the document queue, then executes the callback given.
Class Detail
atropa.CreateHtmlDocumentsFromXmlhttp()
Creates HTML DOM Documents from an XMLHttpRequest object. This was tested on Firefox, it doesn't work on google chrome. Your mileage may vary.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
var method, url, callback, docs;

// HTTP Request method
method = 'get';

// the page to fetch, this page must be accessible
// security restrictions may apply
url = 'docs/jsdoc/symbols/atropa.xpath.html';

// the callback funtion for when a new document is created
callback = function newDocumentHandler(docref) {
    try {
        if (false === docref) {
            // if the document could not be created throw an error
            throw new Error('atropa.CreateHtmlDocumentsFromXmlhttp ' +
                 'Could not create hidden document');
        } else {
            // if the document could be created we'll try to use it
            if(docref.getElementById('index')) {
                // if the document could be used then
                // do something useful with it.
                console.log('success!');
            } else {
                // if the document can not be used throw an error
                throw new Error('atropa.CreateHtmlDocumentsFromXmlhttp ' +
                     'could not use the hidden document');
            }
        }
    } catch (e) {
        // catching any errors thrown and handle them.
    }
    // At this point the work with the document is currently finished
    // the document will live in the documentQueue in case you need it
    // later. This is when you will trigger any function which depends
    // on this hidden document having been created.
    showDocumentQueue();
};

function showDocumentQueue() {
    console.dir(docs.documentQueue);
}

// create an instance of the class
docs = new atropa.CreateHtmlDocumentsFromXmlhttp();
// try to create a new hidden document
docs.newDocument(method, url, null, callback);
Requires:
atropa.Requester
atropa.HTMLParser
atropa.data
Field Detail
{Array} documentQueue
Queue of documents created by this instance.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
Method Detail
{HTML DOM Document|false} newDocument(method, url, messageBody, callback)
Creates an HTML DOM Document and puts it in the document queue, then executes the callback given. Note, this does not work on google chrome.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
Parameters:
{String} method
Any valid method to be used in an XMLHttpRequest.
{String} url
The location of the document's source.
{String} messageBody
null, or a message body.
{Function} callback
The function to execute upon request completion. This function will be given either an HTML DOM Document or false.
Returns:
{HTML DOM Document|false} The return value is given to the callback function.

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Nov 17 2022 14:29:55 GMT-0500 (Eastern Standard Time)