Sha256: 7ea3189fc6f21b502eab96bf6eb818a0032b974f3784923766bdbfb3e3288f77

Contents?: true

Size: 1.78 KB

Versions: 20

Compression:

Stored size: 1.78 KB

Contents

/*
 * based on code from:
 *
 * @license RequireJS text 0.25.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
 * Available via the MIT or new BSD license.
 * see: http://github.com/jrburke/requirejs for details
 */
define(function(require, exports, module) {
"use strict";

var useragent = require("./useragent");

exports.get = function (url, callback) {
    var xhr = exports.createXhr();
    xhr.open('GET', url, true);
    xhr.onreadystatechange = function (evt) {
        //Do not explicitly handle errors, those should be
        //visible via console output in the browser.
        if (xhr.readyState === 4) {
            callback(xhr.responseText);
        }
    };
    xhr.send(null);
};

var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];

exports.createXhr = function() {
    //Would love to dump the ActiveX crap in here. Need IE 6 to die first.
    var xhr, i, progId;
    if (typeof XMLHttpRequest !== "undefined") {
        return new XMLHttpRequest();
    } else {
        for (i = 0; i < 3; i++) {
            progId = progIds[i];
            try {
                xhr = new ActiveXObject(progId);
            } catch (e) {}

            if (xhr) {
                progIds = [progId];  // so faster next time
                break;
            }
        }
    }

    if (!xhr) {
        throw new Error("createXhr(): XMLHttpRequest not available");
    }

    return xhr;
};

exports.loadScript = function(path, callback) {
    var head = document.getElementsByTagName('head')[0];
    var s = document.createElement('script');

    s.src = path;
    head.appendChild(s);

    if (useragent.isOldIE)
        s.onreadystatechange = function () {
            this.readyState == 'loaded' && callback();
        };
    else
        s.onload = callback;
};

});

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
gollum-3.1.2 lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-3.1.1 lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-3.1.0 lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-3.0.0 lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.7.0 lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.6.0 lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.5.2 lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.5.1 lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.5.0 lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.4.15 lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.4.14 lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.4.13 lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.4.12 lib/gollum/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.4.11 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.4.10 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.4.9 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.4.8 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.4.7 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.4.6 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/net.js
gollum-2.4.5 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/net.js