How to use the xhr.XMLHttpRequest.prototype function in xhr

To help you get started, we’ve selected a few xhr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github antimatter15 / drag2up / lib / main.js View on Github external
enc2 = key.indexOf(input.charAt(i++));
		  enc3 = key.indexOf(input.charAt(i++));
		  enc4 = key.indexOf(input.charAt(i++));
		  chr1 = (enc1 << 2) | (enc2 >> 4);
		  chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		  chr3 = ((enc3 & 3) << 6) | enc4;
		  output = output + String.fromCharCode(chr1);
		  if (enc3 != 64) output = output + String.fromCharCode(chr2);
		  if (enc4 != 64) output = output + String.fromCharCode(chr3);
	  }
	  return output;
  }

}

XMLHttpRequest.prototype.sendMultipart = function(params) {
  var BOUNDARY = "---------------------------1966284435497298061834782736";
  var rn = "\r\n";
  console.log(params)
  
  var binxhr = !!this.sendAsBinary;
  if(binxhr){
    var req = '', append = function(data){req += data}
  }else{
    var req = new BlobBuilder(), append = function(data){req.append(data)}
  }
  
  append("--" + BOUNDARY);
  
  var file_param = -1;
  var xhr = this;
github antimatter15 / drag2up / lib / main.js View on Github external
const data = require("self").data;
var pageWorkers = require("page-worker");
var pageMod = require("page-mod");
var XMLHttpRequest = require("xhr").XMLHttpRequest;
var tabs = require('tabs');
XMLHttpRequest.prototype.__defineSetter__('onload', function(cb){
  console.log('set onload');
  this.onreadystatechange = function(){
    if(this.readyState == 4){
      console.log('firing clalack');
      cb();
    }
  }
})


pageMod.PageMod({
  include: "*",
  contentScriptWhen: 'ready',
  contentScriptFile: data.url("drag2up.js"),
  onAttach: function(worker){
    console.log('onAttach was triggered');
github antimatter15 / drag2up / build / chrome / data / jetpack.js View on Github external
const data = require("self").data;
var pageWorkers = require("page-worker");
var pageMod = require("page-mod");
var XMLHttpRequest = require("xhr").XMLHttpRequest;
var tabs = require('tabs');


var simpleStorage = require("simple-storage");
var localStorage = simpleStorage.storage;
var setTimeout = require('timer').setTimeout;

XMLHttpRequest.prototype.__defineSetter__('onload', function(cb){
  this.onreadystatechange = function(){
    if(this.readyState == 4) cb();
  }
})

pageMod.PageMod({
  include: data.url("options.html"),
  contentScriptWhen: 'ready',
  contentScript: "var el=document.createElement('input');el.type='hidden';el.id='drag2uplocalstorage';document.body.appendChild(el);var pm = postMessage;el.addEventListener('drag2upsave',function(e){console.log('got message',el.value);pm(el.value)},true);var evt=document.createEvent('Event');evt.initEvent('drag2upread',true,true);onMessage=function(data){el.value=data;el.dispatchEvent(evt);}",
  onAttach: function(worker){
    console.log('onAttach was triggered for options panel');
    worker.on('message', function(data) {
      console.log('recieved message from robot overloards');
      console.log(data)
      if(data == '__get'){
        console.log(JSON.stringify(localStorage));