Skip to content

Instantly share code, notes, and snippets.

@megamaddu
Created November 10, 2015 18:02
Show Gist options
  • Save megamaddu/57217b83076d9555820e to your computer and use it in GitHub Desktop.
Save megamaddu/57217b83076d9555820e to your computer and use it in GitHub Desktop.
PureScript + uglifyjs issues
// Generated by psc-bundle 0.7.5.3
var PS = { };
(function(exports) {
/* global exports */
"use strict";
// module Prelude
//- Functor --------------------------------------------------------------------
exports.arrayMap = function (f) {
return function (arr) {
var l = arr.length;
var result = new Array(l);
for (var i = 0; i < l; i++) {
result[i] = f(arr[i]);
}
return result;
};
};
//- Eq -------------------------------------------------------------------------
exports.refEq = function (r1) {
return function (r2) {
return r1 === r2;
};
};
//- Show -----------------------------------------------------------------------
exports.showIntImpl = function (n) {
return n.toString();
};
exports.showStringImpl = function (s) {
return JSON.stringify(s);
};
})(PS["Prelude"] = PS["Prelude"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var $foreign = PS["Prelude"];
var Functor = function (map) {
this.map = map;
};
var Apply = function (__superclass_Prelude$dotFunctor_0, apply) {
this["__superclass_Prelude.Functor_0"] = __superclass_Prelude$dotFunctor_0;
this.apply = apply;
};
var Applicative = function (__superclass_Prelude$dotApply_0, pure) {
this["__superclass_Prelude.Apply_0"] = __superclass_Prelude$dotApply_0;
this.pure = pure;
};
var Bind = function (__superclass_Prelude$dotApply_0, bind) {
this["__superclass_Prelude.Apply_0"] = __superclass_Prelude$dotApply_0;
this.bind = bind;
};
var Monad = function (__superclass_Prelude$dotApplicative_0, __superclass_Prelude$dotBind_1) {
this["__superclass_Prelude.Applicative_0"] = __superclass_Prelude$dotApplicative_0;
this["__superclass_Prelude.Bind_1"] = __superclass_Prelude$dotBind_1;
};
var Eq = function (eq) {
this.eq = eq;
};
var Show = function (show) {
this.show = show;
};
var unit = {};
var showString = new Show($foreign.showStringImpl);
var showInt = new Show($foreign.showIntImpl);
var show = function (dict) {
return dict.show;
};
var pure = function (dict) {
return dict.pure;
};
var $$return = function (__dict_Applicative_2) {
return pure(__dict_Applicative_2);
};
var map = function (dict) {
return dict.map;
};
var $less$dollar$greater = function (__dict_Functor_5) {
return map(__dict_Functor_5);
};
var functorArray = new Functor($foreign.arrayMap);
var eqString = new Eq($foreign.refEq);
var eq = function (dict) {
return dict.eq;
};
var $eq$eq = function (__dict_Eq_7) {
return eq(__dict_Eq_7);
};
var $$const = function (a) {
return function (_3) {
return a;
};
};
var bind = function (dict) {
return dict.bind;
};
var $greater$greater$eq = function (__dict_Bind_24) {
return bind(__dict_Bind_24);
};
var apply = function (dict) {
return dict.apply;
};
var $less$times$greater = function (__dict_Apply_25) {
return apply(__dict_Apply_25);
};
var liftA1 = function (__dict_Applicative_26) {
return function (f) {
return function (a) {
return $less$times$greater(__dict_Applicative_26["__superclass_Prelude.Apply_0"]())(pure(__dict_Applicative_26)(f))(a);
};
};
};
var ap = function (__dict_Monad_30) {
return function (f) {
return function (a) {
return bind(__dict_Monad_30["__superclass_Prelude.Bind_1"]())(f)(function (_2) {
return bind(__dict_Monad_30["__superclass_Prelude.Bind_1"]())(a)(function (_1) {
return $$return(__dict_Monad_30["__superclass_Prelude.Applicative_0"]())(_2(_1));
});
});
};
};
};
exports["Show"] = Show;
exports["Eq"] = Eq;
exports["Monad"] = Monad;
exports["Bind"] = Bind;
exports["Applicative"] = Applicative;
exports["Apply"] = Apply;
exports["Functor"] = Functor;
exports["show"] = show;
exports["=="] = $eq$eq;
exports["eq"] = eq;
exports["ap"] = ap;
exports[">>="] = $greater$greater$eq;
exports["bind"] = bind;
exports["liftA1"] = liftA1;
exports["pure"] = pure;
exports["apply"] = apply;
exports["<$>"] = $less$dollar$greater;
exports["map"] = map;
exports["const"] = $$const;
exports["unit"] = unit;
exports["functorArray"] = functorArray;
exports["eqString"] = eqString;
exports["showInt"] = showInt;
exports["showString"] = showString;;
})(PS["Prelude"] = PS["Prelude"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var Prelude = PS["Prelude"];
var $eq$less$less = function (__dict_Bind_1) {
return function (f) {
return function (m) {
return Prelude[">>="](__dict_Bind_1)(m)(f);
};
};
};
var $less$eq$less = function (__dict_Bind_2) {
return function (f) {
return function (g) {
return function (a) {
return $eq$less$less(__dict_Bind_2)(f)(g(a));
};
};
};
};
exports["<=<"] = $less$eq$less;;
})(PS["Control.Bind"] = PS["Control.Bind"] || {});
(function(exports) {
/* global exports */
"use strict";
exports._unsafeInterleaveAff = function (aff) {
return aff;
}
exports._makeAff = function (cb) {
return function(success, error) {
return cb(function(e) {
return function() {
error(e);
};
})(function(v) {
return function() {
try {
success(v);
} catch (e) {
error(e);
}
};
})();
}
}
exports._pure = function (nonCanceler, v) {
return function(success, error) {
try {
success(v);
} catch (e) {
error(e);
}
return nonCanceler;
};
}
exports._fmap = function (f, aff) {
return function(success, error) {
return aff(function(v) {
try {
success(f(v));
} catch (e) {
error(e);
}
}, error);
};
}
exports._bind = function (alwaysCanceler, aff, f) {
return function(success, error) {
var canceler1, canceler2;
var isCanceled = false;
var requestCancel = false;
var onCanceler = function(){};
canceler1 = aff(function(v) {
if (requestCancel) {
isCanceled = true;
return alwaysCanceler;
} else {
canceler2 = f(v)(success, error);
onCanceler(canceler2);
return canceler2;
}
}, error);
return function(e) {
return function(s, f) {
requestCancel = true;
if (canceler2 !== undefined) {
return canceler2(e)(s, f);
} else {
return canceler1(e)(function(bool) {
if (bool || isCanceled) {
try {
s(true);
} catch (e) {
f(e);
}
} else {
onCanceler = function(canceler) {
canceler(e)(s, f);
};
}
}, f);
}
};
};
};
}
exports._attempt = function (Left, Right, aff) {
return function(success, error) {
return aff(function(v) {
try {
success(Right(v));
} catch (e) {
error(e);
}
}, function(e) {
try {
success(Left(e));
} catch (e) {
error(e);
}
});
};
}
exports._liftEff = function (nonCanceler, e) {
return function(success, error) {
try {
success(e());
} catch (e) {
error(e);
}
return nonCanceler;
};
}
})(PS["Control.Monad.Aff"] = PS["Control.Monad.Aff"] || {});
(function(exports) {
/* global exports */
"use strict";
// module Control.Monad.Eff
exports.returnE = function (a) {
return function () {
return a;
};
};
exports.bindE = function (a) {
return function (f) {
return function () {
return f(a())();
};
};
};
})(PS["Control.Monad.Eff"] = PS["Control.Monad.Eff"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var $foreign = PS["Control.Monad.Eff"];
var Prelude = PS["Prelude"];
var monadEff = new Prelude.Monad(function () {
return applicativeEff;
}, function () {
return bindEff;
});
var bindEff = new Prelude.Bind(function () {
return applyEff;
}, $foreign.bindE);
var applyEff = new Prelude.Apply(function () {
return functorEff;
}, Prelude.ap(monadEff));
var applicativeEff = new Prelude.Applicative(function () {
return applyEff;
}, $foreign.returnE);
var functorEff = new Prelude.Functor(Prelude.liftA1(applicativeEff));
exports["functorEff"] = functorEff;
exports["applyEff"] = applyEff;
exports["applicativeEff"] = applicativeEff;
exports["bindEff"] = bindEff;
exports["monadEff"] = monadEff;;
})(PS["Control.Monad.Eff"] = PS["Control.Monad.Eff"] || {});
(function(exports) {
/* global exports */
"use strict";
exports.error = function (msg) {
return new Error(msg);
};
})(PS["Control.Monad.Eff.Exception"] = PS["Control.Monad.Eff.Exception"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var $foreign = PS["Control.Monad.Eff.Exception"];
var Prelude = PS["Prelude"];
var Control_Monad_Eff = PS["Control.Monad.Eff"];
exports["error"] = $foreign.error;;
})(PS["Control.Monad.Eff.Exception"] = PS["Control.Monad.Eff.Exception"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var Prelude = PS["Prelude"];
var Control_Alt = PS["Control.Alt"];
var Control_Extend = PS["Control.Extend"];
var Data_Bifoldable = PS["Data.Bifoldable"];
var Data_Bifunctor = PS["Data.Bifunctor"];
var Data_Bitraversable = PS["Data.Bitraversable"];
var Data_Foldable = PS["Data.Foldable"];
var Data_Monoid = PS["Data.Monoid"];
var Data_Traversable = PS["Data.Traversable"];
var Left = (function () {
function Left(value0) {
this.value0 = value0;
};
Left.create = function (value0) {
return new Left(value0);
};
return Left;
})();
var Right = (function () {
function Right(value0) {
this.value0 = value0;
};
Right.create = function (value0) {
return new Right(value0);
};
return Right;
})();
var functorEither = new Prelude.Functor(function (f) {
return function (_2) {
if (_2 instanceof Left) {
return new Left(_2.value0);
};
if (_2 instanceof Right) {
return new Right(f(_2.value0));
};
throw new Error("Failed pattern match at Data.Either line 52, column 1 - line 56, column 1: " + [ f.constructor.name, _2.constructor.name ]);
};
});
var either = function (f) {
return function (g) {
return function (_1) {
if (_1 instanceof Left) {
return f(_1.value0);
};
if (_1 instanceof Right) {
return g(_1.value0);
};
throw new Error("Failed pattern match at Data.Either line 28, column 1 - line 29, column 1: " + [ f.constructor.name, g.constructor.name, _1.constructor.name ]);
};
};
};
var applyEither = new Prelude.Apply(function () {
return functorEither;
}, function (_4) {
return function (r) {
if (_4 instanceof Left) {
return new Left(_4.value0);
};
if (_4 instanceof Right) {
return Prelude["<$>"](functorEither)(_4.value0)(r);
};
throw new Error("Failed pattern match at Data.Either line 92, column 1 - line 116, column 1: " + [ _4.constructor.name, r.constructor.name ]);
};
});
var bindEither = new Prelude.Bind(function () {
return applyEither;
}, either(function (e) {
return function (_0) {
return new Left(e);
};
})(function (a) {
return function (f) {
return f(a);
};
}));
var applicativeEither = new Prelude.Applicative(function () {
return applyEither;
}, Right.create);
exports["Left"] = Left;
exports["Right"] = Right;
exports["either"] = either;
exports["functorEither"] = functorEither;
exports["applyEither"] = applyEither;
exports["applicativeEither"] = applicativeEither;
exports["bindEither"] = bindEither;;
})(PS["Data.Either"] = PS["Data.Either"] || {});
(function(exports) {
/* global exports */
"use strict";
exports.mkFn2 = function (fn) {
/* jshint maxparams: 2 */
return function (a, b) {
return fn(a)(b);
};
};
})(PS["Data.Function"] = PS["Data.Function"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var $foreign = PS["Data.Function"];
var Prelude = PS["Prelude"];
exports["mkFn2"] = $foreign.mkFn2;;
})(PS["Data.Function"] = PS["Data.Function"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var $foreign = PS["Control.Monad.Aff"];
var Prelude = PS["Prelude"];
var Control_Alt = PS["Control.Alt"];
var Control_Alternative = PS["Control.Alternative"];
var Control_Monad_Cont_Class = PS["Control.Monad.Cont.Class"];
var Control_Monad_Eff = PS["Control.Monad.Eff"];
var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"];
var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"];
var Control_Monad_Eff_Unsafe = PS["Control.Monad.Eff.Unsafe"];
var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"];
var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"];
var Control_MonadPlus = PS["Control.MonadPlus"];
var Control_Plus = PS["Control.Plus"];
var Data_Either = PS["Data.Either"];
var Data_Function = PS["Data.Function"];
var Data_Monoid = PS["Data.Monoid"];
var makeAff$prime = function (h) {
return $foreign._makeAff(h);
};
var functorAff = new Prelude.Functor(function (f) {
return function (fa) {
return $foreign._fmap(f, fa);
};
});
var attempt = function (aff) {
return $foreign._attempt(Data_Either.Left.create, Data_Either.Right.create, aff);
};
var applyAff = new Prelude.Apply(function () {
return functorAff;
}, function (ff) {
return function (fa) {
return $foreign._bind(alwaysCanceler, ff, function (f) {
return Prelude["<$>"](functorAff)(f)(fa);
});
};
});
var applicativeAff = new Prelude.Applicative(function () {
return applyAff;
}, function (v) {
return $foreign._pure(nonCanceler, v);
});
var nonCanceler = Prelude["const"](Prelude.pure(applicativeAff)(false));
var alwaysCanceler = Prelude["const"](Prelude.pure(applicativeAff)(true));
var liftEff$prime = function (eff) {
return attempt($foreign._unsafeInterleaveAff($foreign._liftEff(nonCanceler, eff)));
};
var makeAff = function (h) {
return makeAff$prime(function (e) {
return function (a) {
return Prelude["<$>"](Control_Monad_Eff.functorEff)(Prelude["const"](nonCanceler))(h(e)(a));
};
});
};
var bindAff = new Prelude.Bind(function () {
return applyAff;
}, function (fa) {
return function (f) {
return $foreign._bind(alwaysCanceler, fa, f);
};
});
exports["nonCanceler"] = nonCanceler;
exports["makeAff'"] = makeAff$prime;
exports["makeAff"] = makeAff;
exports["liftEff'"] = liftEff$prime;
exports["attempt"] = attempt;
exports["functorAff"] = functorAff;
exports["applyAff"] = applyAff;
exports["applicativeAff"] = applicativeAff;
exports["bindAff"] = bindAff;;
})(PS["Control.Monad.Aff"] = PS["Control.Monad.Aff"] || {});
(function(exports) {
/* global exports */
"use strict";
// module Data.Foreign
// jshint maxparams: 3
exports.parseJSONImpl = function (left, right, str) {
try {
return right(JSON.parse(str));
} catch (e) {
return left(e.toString());
}
};
exports.unsafeFromForeign = function (value) {
return value;
};
exports.tagOf = function (value) {
return Object.prototype.toString.call(value).slice(8, -1);
};
})(PS["Data.Foreign"] = PS["Data.Foreign"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var Prelude = PS["Prelude"];
var Control_Alt = PS["Control.Alt"];
var Control_Alternative = PS["Control.Alternative"];
var Control_Extend = PS["Control.Extend"];
var Control_MonadPlus = PS["Control.MonadPlus"];
var Control_Plus = PS["Control.Plus"];
var Data_Functor_Invariant = PS["Data.Functor.Invariant"];
var Data_Monoid = PS["Data.Monoid"];
var Nothing = (function () {
function Nothing() {
};
Nothing.value = new Nothing();
return Nothing;
})();
var Just = (function () {
function Just(value0) {
this.value0 = value0;
};
Just.create = function (value0) {
return new Just(value0);
};
return Just;
})();
var maybe = function (b) {
return function (f) {
return function (_0) {
if (_0 instanceof Nothing) {
return b;
};
if (_0 instanceof Just) {
return f(_0.value0);
};
throw new Error("Failed pattern match at Data.Maybe line 26, column 1 - line 27, column 1: " + [ b.constructor.name, f.constructor.name, _0.constructor.name ]);
};
};
};
var functorMaybe = new Prelude.Functor(function (fn) {
return function (_2) {
if (_2 instanceof Just) {
return new Just(fn(_2.value0));
};
return Nothing.value;
};
});
exports["Nothing"] = Nothing;
exports["Just"] = Just;
exports["maybe"] = maybe;
exports["functorMaybe"] = functorMaybe;;
})(PS["Data.Maybe"] = PS["Data.Maybe"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var $foreign = PS["Data.Foreign"];
var Prelude = PS["Prelude"];
var Data_Either = PS["Data.Either"];
var Data_Maybe = PS["Data.Maybe"];
var Data_Function = PS["Data.Function"];
var Data_Int = PS["Data.Int"];
var Data_String = PS["Data.String"];
var TypeMismatch = (function () {
function TypeMismatch(value0, value1) {
this.value0 = value0;
this.value1 = value1;
};
TypeMismatch.create = function (value0) {
return function (value1) {
return new TypeMismatch(value0, value1);
};
};
return TypeMismatch;
})();
var ErrorAtIndex = (function () {
function ErrorAtIndex(value0, value1) {
this.value0 = value0;
this.value1 = value1;
};
ErrorAtIndex.create = function (value0) {
return function (value1) {
return new ErrorAtIndex(value0, value1);
};
};
return ErrorAtIndex;
})();
var ErrorAtProperty = (function () {
function ErrorAtProperty(value0, value1) {
this.value0 = value0;
this.value1 = value1;
};
ErrorAtProperty.create = function (value0) {
return function (value1) {
return new ErrorAtProperty(value0, value1);
};
};
return ErrorAtProperty;
})();
var JSONError = (function () {
function JSONError(value0) {
this.value0 = value0;
};
JSONError.create = function (value0) {
return new JSONError(value0);
};
return JSONError;
})();
var unsafeReadTagged = function (tag) {
return function (value) {
if (Prelude["=="](Prelude.eqString)($foreign.tagOf(value))(tag)) {
return Prelude.pure(Data_Either.applicativeEither)($foreign.unsafeFromForeign(value));
};
return new Data_Either.Left(new TypeMismatch(tag, $foreign.tagOf(value)));
};
};
var showForeignError = new Prelude.Show(function (_0) {
if (_0 instanceof TypeMismatch) {
return "Type mismatch: expected " + (_0.value0 + (", found " + _0.value1));
};
if (_0 instanceof ErrorAtIndex) {
return "Error at array index " + (Prelude.show(Prelude.showInt)(_0.value0) + (": " + Prelude.show(showForeignError)(_0.value1)));
};
if (_0 instanceof ErrorAtProperty) {
return "Error at property " + (Prelude.show(Prelude.showString)(_0.value0) + (": " + Prelude.show(showForeignError)(_0.value1)));
};
if (_0 instanceof JSONError) {
return "JSON error: " + _0.value0;
};
throw new Error("Failed pattern match: " + [ _0.constructor.name ]);
});
var readString = unsafeReadTagged("String");
var parseJSON = function (json) {
return $foreign.parseJSONImpl(function (_32) {
return Data_Either.Left.create(JSONError.create(_32));
}, Data_Either.Right.create, json);
};
exports["TypeMismatch"] = TypeMismatch;
exports["ErrorAtIndex"] = ErrorAtIndex;
exports["ErrorAtProperty"] = ErrorAtProperty;
exports["JSONError"] = JSONError;
exports["readString"] = readString;
exports["unsafeReadTagged"] = unsafeReadTagged;
exports["parseJSON"] = parseJSON;
exports["showForeignError"] = showForeignError;;
})(PS["Data.Foreign"] = PS["Data.Foreign"] || {});
(function(exports) {
/* global exports */
"use strict";
// module Data.Nullable
exports["null"] = null;
exports.notNull = function(x) {
return x;
};
})(PS["Data.Nullable"] = PS["Data.Nullable"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var $foreign = PS["Data.Nullable"];
var Prelude = PS["Prelude"];
var Data_Maybe = PS["Data.Maybe"];
var Data_Function = PS["Data.Function"];
var toNullable = Data_Maybe.maybe($foreign["null"])($foreign.notNull);
exports["toNullable"] = toNullable;;
})(PS["Data.Nullable"] = PS["Data.Nullable"] || {});
(function(exports) {
/* globals exports JSON*/
"use strict";
// module Global.Unsafe
exports.unsafeStringify = function(x){
return JSON.stringify(x);
};
})(PS["Global.Unsafe"] = PS["Global.Unsafe"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var $foreign = PS["Global.Unsafe"];
exports["unsafeStringify"] = $foreign.unsafeStringify;;
})(PS["Global.Unsafe"] = PS["Global.Unsafe"] || {});
(function(exports) {
/* global exports, window */
'use strict'
// module Jane.Events
exports.getLocation = function () {
if (typeof window === 'undefined' || window == null)
return {}
else
return window.location || {}
}
})(PS["Jane.Events"] = PS["Jane.Events"] || {});
(function(exports) {
/* global exports */
/* global XMLHttpRequest */
/* global module */
"use strict";
// module Network.HTTP.Affjax
// jshint maxparams: 5
exports._ajax = function (mkHeader, options, canceler, errback, callback) {
var platformSpecific = { };
if (typeof module !== "undefined" && module.require) {
// We are on node.js
platformSpecific.newXHR = function () {
var XHR = module.require("xhr2");
return new XHR();
};
platformSpecific.fixupUrl = function (url) {
var urllib = module.require("url");
var u = urllib.parse(url);
u.protocol = u.protocol || "http:";
u.hostname = u.hostname || "localhost";
return urllib.format(u);
};
platformSpecific.getResponse = function (xhr) {
return xhr.response;
};
} else {
// We are in the browser
platformSpecific.newXHR = function () {
return new XMLHttpRequest();
};
platformSpecific.fixupUrl = function (url) {
return url || "/";
};
platformSpecific.getResponse = function (xhr) {
return xhr.response;
};
}
return function () {
var xhr = platformSpecific.newXHR();
var fixedUrl = platformSpecific.fixupUrl(options.url);
xhr.open(options.method || "GET", fixedUrl, true, options.username, options.password);
if (options.headers) {
for (var i = 0, header; (header = options.headers[i]) != null; i++) {
xhr.setRequestHeader(header.field, header.value);
}
}
xhr.onerror = function () {
errback(new Error("AJAX request failed: " + options.method + " " + options.url))();
};
xhr.onload = function () {
callback({
status: xhr.status,
headers: xhr.getAllResponseHeaders().split("\n")
.filter(function (header) {
return header.length > 0;
})
.map(function (header) {
var i = header.indexOf(":");
return mkHeader(header.substring(0, i))(header.substring(i + 2));
}),
response: platformSpecific.getResponse(xhr)
})();
};
xhr.responseType = options.responseType;
xhr.send(options.content);
return canceler(xhr);
};
};
// jshint maxparams: 4
exports._cancelAjax = function (xhr, cancelError, errback, callback) {
return function () {
try { xhr.abort(); } catch (e) { return callback(false)(); }
return callback(true)();
};
};
})(PS["Network.HTTP.Affjax"] = PS["Network.HTTP.Affjax"] || {});
(function(exports) {
"use strict";
// module Unsafe.Coerce
exports.unsafeCoerce = function(x) { return x; }
})(PS["Unsafe.Coerce"] = PS["Unsafe.Coerce"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var $foreign = PS["Unsafe.Coerce"];
exports["unsafeCoerce"] = $foreign.unsafeCoerce;;
})(PS["Unsafe.Coerce"] = PS["Unsafe.Coerce"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var Prelude = PS["Prelude"];
var DOM_File_Types = PS["DOM.File.Types"];
var DOM_Node_Types = PS["DOM.Node.Types"];
var DOM_XHR_Types = PS["DOM.XHR.Types"];
var Unsafe_Coerce = PS["Unsafe.Coerce"];
var Data_ArrayBuffer_Types = PS["Data.ArrayBuffer.Types"];
var Requestable = function (toRequest) {
this.toRequest = toRequest;
};
var toRequest = function (dict) {
return dict.toRequest;
};
var requestableString = new Requestable(Unsafe_Coerce.unsafeCoerce);
exports["Requestable"] = Requestable;
exports["toRequest"] = toRequest;
exports["requestableString"] = requestableString;;
})(PS["Network.HTTP.Affjax.Request"] = PS["Network.HTTP.Affjax.Request"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var Prelude = PS["Prelude"];
var Data_Either = PS["Data.Either"];
var Data_Foreign = PS["Data.Foreign"];
var DOM_File_Types = PS["DOM.File.Types"];
var DOM_Node_Types = PS["DOM.Node.Types"];
var DOM_XHR_Types = PS["DOM.XHR.Types"];
var Data_ArrayBuffer_Types = PS["Data.ArrayBuffer.Types"];
var ArrayBufferResponse = (function () {
function ArrayBufferResponse() {
};
ArrayBufferResponse.value = new ArrayBufferResponse();
return ArrayBufferResponse;
})();
var BlobResponse = (function () {
function BlobResponse() {
};
BlobResponse.value = new BlobResponse();
return BlobResponse;
})();
var DocumentResponse = (function () {
function DocumentResponse() {
};
DocumentResponse.value = new DocumentResponse();
return DocumentResponse;
})();
var JSONResponse = (function () {
function JSONResponse() {
};
JSONResponse.value = new JSONResponse();
return JSONResponse;
})();
var StringResponse = (function () {
function StringResponse() {
};
StringResponse.value = new StringResponse();
return StringResponse;
})();
var Respondable = function (fromResponse, responseType) {
this.fromResponse = fromResponse;
this.responseType = responseType;
};
var responseTypeToString = function (_0) {
if (_0 instanceof ArrayBufferResponse) {
return "arraybuffer";
};
if (_0 instanceof BlobResponse) {
return "blob";
};
if (_0 instanceof DocumentResponse) {
return "document";
};
if (_0 instanceof JSONResponse) {
return "text";
};
if (_0 instanceof StringResponse) {
return "text";
};
throw new Error("Failed pattern match at Network.HTTP.Affjax.Response line 41, column 1 - line 42, column 1: " + [ _0.constructor.name ]);
};
var responseType = function (dict) {
return dict.responseType;
};
var responsableUnit = new Respondable(Prelude["const"](new Data_Either.Right(Prelude.unit)), StringResponse.value);
var fromResponse = function (dict) {
return dict.fromResponse;
};
exports["ArrayBufferResponse"] = ArrayBufferResponse;
exports["BlobResponse"] = BlobResponse;
exports["DocumentResponse"] = DocumentResponse;
exports["JSONResponse"] = JSONResponse;
exports["StringResponse"] = StringResponse;
exports["Respondable"] = Respondable;
exports["fromResponse"] = fromResponse;
exports["responseType"] = responseType;
exports["responseTypeToString"] = responseTypeToString;
exports["responsableUnit"] = responsableUnit;;
})(PS["Network.HTTP.Affjax.Response"] = PS["Network.HTTP.Affjax.Response"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var Prelude = PS["Prelude"];
var DELETE = (function () {
function DELETE() {
};
DELETE.value = new DELETE();
return DELETE;
})();
var GET = (function () {
function GET() {
};
GET.value = new GET();
return GET;
})();
var HEAD = (function () {
function HEAD() {
};
HEAD.value = new HEAD();
return HEAD;
})();
var OPTIONS = (function () {
function OPTIONS() {
};
OPTIONS.value = new OPTIONS();
return OPTIONS;
})();
var PATCH = (function () {
function PATCH() {
};
PATCH.value = new PATCH();
return PATCH;
})();
var POST = (function () {
function POST() {
};
POST.value = new POST();
return POST;
})();
var PUT = (function () {
function PUT() {
};
PUT.value = new PUT();
return PUT;
})();
var MOVE = (function () {
function MOVE() {
};
MOVE.value = new MOVE();
return MOVE;
})();
var COPY = (function () {
function COPY() {
};
COPY.value = new COPY();
return COPY;
})();
var CustomMethod = (function () {
function CustomMethod(value0) {
this.value0 = value0;
};
CustomMethod.create = function (value0) {
return new CustomMethod(value0);
};
return CustomMethod;
})();
var showMethod = new Prelude.Show(function (_3) {
if (_3 instanceof DELETE) {
return "DELETE";
};
if (_3 instanceof GET) {
return "GET";
};
if (_3 instanceof HEAD) {
return "HEAD";
};
if (_3 instanceof OPTIONS) {
return "OPTIONS";
};
if (_3 instanceof PATCH) {
return "PATCH";
};
if (_3 instanceof POST) {
return "POST";
};
if (_3 instanceof PUT) {
return "PUT";
};
if (_3 instanceof MOVE) {
return "MOVE";
};
if (_3 instanceof COPY) {
return "COPY";
};
if (_3 instanceof CustomMethod) {
return "(CustomMethod " + (Prelude.show(Prelude.showString)(_3.value0) + ")");
};
throw new Error("Failed pattern match at Network.HTTP.Method line 29, column 1 - line 41, column 1: " + [ _3.constructor.name ]);
});
var methodToString = function (_0) {
if (_0 instanceof CustomMethod) {
return _0.value0;
};
return Prelude.show(showMethod)(_0);
};
exports["DELETE"] = DELETE;
exports["GET"] = GET;
exports["HEAD"] = HEAD;
exports["OPTIONS"] = OPTIONS;
exports["PATCH"] = PATCH;
exports["POST"] = POST;
exports["PUT"] = PUT;
exports["MOVE"] = MOVE;
exports["COPY"] = COPY;
exports["CustomMethod"] = CustomMethod;
exports["methodToString"] = methodToString;
exports["showMethod"] = showMethod;;
})(PS["Network.HTTP.Method"] = PS["Network.HTTP.Method"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var Prelude = PS["Prelude"];
var mimeTypeToString = function (_0) {
return _0;
};
exports["mimeTypeToString"] = mimeTypeToString;;
})(PS["Network.HTTP.MimeType"] = PS["Network.HTTP.MimeType"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var Prelude = PS["Prelude"];
var Network_HTTP_MimeType = PS["Network.HTTP.MimeType"];
var Accept = (function () {
function Accept(value0) {
this.value0 = value0;
};
Accept.create = function (value0) {
return new Accept(value0);
};
return Accept;
})();
var ContentType = (function () {
function ContentType(value0) {
this.value0 = value0;
};
ContentType.create = function (value0) {
return new ContentType(value0);
};
return ContentType;
})();
var RequestHeader = (function () {
function RequestHeader(value0, value1) {
this.value0 = value0;
this.value1 = value1;
};
RequestHeader.create = function (value0) {
return function (value1) {
return new RequestHeader(value0, value1);
};
};
return RequestHeader;
})();
var requestHeaderValue = function (_1) {
if (_1 instanceof Accept) {
return Network_HTTP_MimeType.mimeTypeToString(_1.value0);
};
if (_1 instanceof ContentType) {
return Network_HTTP_MimeType.mimeTypeToString(_1.value0);
};
if (_1 instanceof RequestHeader) {
return _1.value1;
};
throw new Error("Failed pattern match at Network.HTTP.RequestHeader line 28, column 1 - line 29, column 1: " + [ _1.constructor.name ]);
};
var requestHeaderName = function (_0) {
if (_0 instanceof Accept) {
return "Accept";
};
if (_0 instanceof ContentType) {
return "Content-Type";
};
if (_0 instanceof RequestHeader) {
return _0.value0;
};
throw new Error("Failed pattern match at Network.HTTP.RequestHeader line 23, column 1 - line 24, column 1: " + [ _0.constructor.name ]);
};
exports["Accept"] = Accept;
exports["ContentType"] = ContentType;
exports["RequestHeader"] = RequestHeader;
exports["requestHeaderValue"] = requestHeaderValue;
exports["requestHeaderName"] = requestHeaderName;;
})(PS["Network.HTTP.RequestHeader"] = PS["Network.HTTP.RequestHeader"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var Prelude = PS["Prelude"];
var ResponseHeader = (function () {
function ResponseHeader(value0, value1) {
this.value0 = value0;
this.value1 = value1;
};
ResponseHeader.create = function (value0) {
return function (value1) {
return new ResponseHeader(value0, value1);
};
};
return ResponseHeader;
})();
var responseHeader = function (field) {
return function (value) {
return new ResponseHeader(field, value);
};
};
exports["responseHeader"] = responseHeader;;
})(PS["Network.HTTP.ResponseHeader"] = PS["Network.HTTP.ResponseHeader"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var $foreign = PS["Network.HTTP.Affjax"];
var Prelude = PS["Prelude"];
var Control_Alt = PS["Control.Alt"];
var Control_Bind = PS["Control.Bind"];
var Control_Monad_Aff = PS["Control.Monad.Aff"];
var Control_Monad_Aff_Par = PS["Control.Monad.Aff.Par"];
var Control_Monad_Aff_AVar = PS["Control.Monad.Aff.AVar"];
var Control_Monad_Eff = PS["Control.Monad.Eff"];
var Control_Monad_Eff_Class = PS["Control.Monad.Eff.Class"];
var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"];
var Control_Monad_Eff_Ref = PS["Control.Monad.Eff.Ref"];
var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"];
var Data_Either = PS["Data.Either"];
var Data_Foreign = PS["Data.Foreign"];
var Data_Function = PS["Data.Function"];
var Data_Int = PS["Data.Int"];
var Data_Maybe = PS["Data.Maybe"];
var Data_Nullable = PS["Data.Nullable"];
var DOM_XHR_Types = PS["DOM.XHR.Types"];
var $$Math = PS["Math"];
var Network_HTTP_Affjax_Request = PS["Network.HTTP.Affjax.Request"];
var Network_HTTP_Affjax_Response = PS["Network.HTTP.Affjax.Response"];
var Network_HTTP_Method = PS["Network.HTTP.Method"];
var Network_HTTP_RequestHeader = PS["Network.HTTP.RequestHeader"];
var Network_HTTP_ResponseHeader = PS["Network.HTTP.ResponseHeader"];
var Network_HTTP_StatusCode = PS["Network.HTTP.StatusCode"];
var defaultRequest = {
method: Network_HTTP_Method.GET.value,
url: "/",
headers: [ ],
content: Data_Maybe.Nothing.value,
username: Data_Maybe.Nothing.value,
password: Data_Maybe.Nothing.value
};
var cancelAjax = function (xhr) {
return function (err) {
return Control_Monad_Aff.makeAff(function (eb) {
return function (cb) {
return $foreign._cancelAjax(xhr, err, eb, cb);
};
});
};
};
var affjax$prime = function (__dict_Requestable_1) {
return function (__dict_Respondable_2) {
return function (req) {
return function (eb) {
return function (cb) {
var req$prime = {
method: Network_HTTP_Method.methodToString(req.method),
url: req.url,
headers: Prelude["<$>"](Prelude.functorArray)(function (h) {
return {
field: Network_HTTP_RequestHeader.requestHeaderName(h),
value: Network_HTTP_RequestHeader.requestHeaderValue(h)
};
})(req.headers),
content: Data_Nullable.toNullable(Prelude["<$>"](Data_Maybe.functorMaybe)(Network_HTTP_Affjax_Request.toRequest(__dict_Requestable_1))(req.content)),
responseType: Network_HTTP_Affjax_Response.responseTypeToString(Network_HTTP_Affjax_Response.responseType(__dict_Respondable_2)),
username: Data_Nullable.toNullable(req.username),
password: Data_Nullable.toNullable(req.password)
};
var fromResponse$prime = (function () {
var _32 = Network_HTTP_Affjax_Response.responseType(__dict_Respondable_2);
if (_32 instanceof Network_HTTP_Affjax_Response.JSONResponse) {
return Control_Bind["<=<"](Data_Either.bindEither)(Network_HTTP_Affjax_Response.fromResponse(__dict_Respondable_2))(Control_Bind["<=<"](Data_Either.bindEither)(Data_Foreign.parseJSON)(Data_Foreign.readString));
};
return Network_HTTP_Affjax_Response.fromResponse(__dict_Respondable_2);
})();
var cb$prime = function (res) {
var _35 = Prelude["<$>"](Data_Either.functorEither)(function (_0) {
var _33 = {};
for (var _34 in res) {
if (res.hasOwnProperty(_34)) {
_33[_34] = res[_34];
};
};
_33.response = _0;
return _33;
})(fromResponse$prime(res.response));
if (_35 instanceof Data_Either.Left) {
return eb(Control_Monad_Eff_Exception.error(Prelude.show(Data_Foreign.showForeignError)(_35.value0)));
};
if (_35 instanceof Data_Either.Right) {
return cb(_35.value0);
};
throw new Error("Failed pattern match at Network.HTTP.Affjax line 197, column 1 - line 202, column 1: " + [ _35.constructor.name ]);
};
return $foreign._ajax(Network_HTTP_ResponseHeader.responseHeader, req$prime, cancelAjax, eb, cb$prime);
};
};
};
};
};
var affjax = function (__dict_Requestable_3) {
return function (__dict_Respondable_4) {
return function (_51) {
return Control_Monad_Aff["makeAff'"](affjax$prime(__dict_Requestable_3)(__dict_Respondable_4)(_51));
};
};
};
exports["affjax"] = affjax;
exports["defaultRequest"] = defaultRequest;;
})(PS["Network.HTTP.Affjax"] = PS["Network.HTTP.Affjax"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var Network_HTTP_MimeType = PS["Network.HTTP.MimeType"];
var applicationJSON = "application/json";
exports["applicationJSON"] = applicationJSON;;
})(PS["Network.HTTP.MimeType.Common"] = PS["Network.HTTP.MimeType.Common"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var $foreign = PS["Jane.Events"];
var Prelude = PS["Prelude"];
var Control_Monad_Eff = PS["Control.Monad.Eff"];
var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"];
var Control_Monad_Aff = PS["Control.Monad.Aff"];
var DOM = PS["DOM"];
var Data_Either = PS["Data.Either"];
var Data_Foreign = PS["Data.Foreign"];
var Data_Maybe = PS["Data.Maybe"];
var Global_Unsafe = PS["Global.Unsafe"];
var Network_HTTP_Affjax = PS["Network.HTTP.Affjax"];
var Network_HTTP_Affjax_Request = PS["Network.HTTP.Affjax.Request"];
var Network_HTTP_Affjax_Response = PS["Network.HTTP.Affjax.Response"];
var Network_HTTP_Method = PS["Network.HTTP.Method"];
var Network_HTTP_MimeType_Common = PS["Network.HTTP.MimeType.Common"];
var Network_HTTP_RequestHeader = PS["Network.HTTP.RequestHeader"];
var mkHeaders = function (_4) {
return [ new Network_HTTP_RequestHeader.ContentType(Network_HTTP_MimeType_Common.applicationJSON), new Network_HTTP_RequestHeader.RequestHeader("Location-Protocol", _4.protocol), new Network_HTTP_RequestHeader.RequestHeader("Location-Host", _4.host), new Network_HTTP_RequestHeader.RequestHeader("Location-Path", _4.pathname), new Network_HTTP_RequestHeader.RequestHeader("Location-Query", _4.search), new Network_HTTP_RequestHeader.RequestHeader("Location-Hash", _4.hash) ];
};
var mkEndpoint = function (_3) {
return _3.protocol + ("//" + (_3.host + "/proxy/events"));
};
var mkContent = function (_19) {
return Data_Maybe.Just.create(Global_Unsafe.unsafeStringify(_19));
};
var mkRequest = function (location) {
return function (_5) {
return function (eventData) {
var _11 = {};
for (var _12 in Network_HTTP_Affjax.defaultRequest) {
if (Network_HTTP_Affjax.defaultRequest.hasOwnProperty(_12)) {
_11[_12] = Network_HTTP_Affjax.defaultRequest[_12];
};
};
_11.method = Network_HTTP_Method.POST.value;
_11.headers = mkHeaders(location);
_11.url = mkEndpoint(location) + ("/events/" + _5);
_11.content = mkContent(eventData);
return _11;
};
};
};
var fromEither = function (d) {
return function (_2) {
if (_2 instanceof Data_Either.Left) {
return d;
};
if (_2 instanceof Data_Either.Right) {
return _2.value0;
};
throw new Error("Failed pattern match at Jane.Events line 36, column 1 - line 37, column 1: " + [ d.constructor.name, _2.constructor.name ]);
};
};
var defaultLocation = {
protocol: "https:",
host: "jane.com",
pathname: "/",
search: "",
hash: ""
};
var getLocationLifted = Prelude.bind(Control_Monad_Aff.bindAff)(Control_Monad_Aff["liftEff'"]($foreign.getLocation))(function (_0) {
return Prelude.pure(Control_Monad_Aff.applicativeAff)(fromEither(defaultLocation)(_0));
});
var send = function (eventType) {
return function (eventData) {
return Prelude.bind(Control_Monad_Aff.bindAff)(getLocationLifted)(function (_1) {
return Network_HTTP_Affjax.affjax(Network_HTTP_Affjax_Request.requestableString)(Network_HTTP_Affjax_Response.responsableUnit)(mkRequest(_1)(eventType)(eventData));
});
};
};
exports["send"] = send;
exports["mkRequest"] = mkRequest;
exports["mkContent"] = mkContent;
exports["mkHeaders"] = mkHeaders;
exports["mkEndpoint"] = mkEndpoint;
exports["getLocationLifted"] = getLocationLifted;
exports["fromEither"] = fromEither;
exports["defaultLocation"] = defaultLocation;;
})(PS["Jane.Events"] = PS["Jane.Events"] || {});
(function(exports) {
/* global exports, window */
'use strict'
// module Main
function noop() { }
exports.mkApi = function(send) {
return function() {
var target;
if (typeof window !== 'undefined')
target = window
else if (typeof global !== 'undefined')
target = global
else
throw new Error('Failed to find `window` or `global` to attach to')
target.ja = function(kind, event, success, failure) {
if (typeof kind === 'object') {
failure = success
success = event
event = kind
kind = null
}
if (!event) event = {}
if (!kind) kind = event.eventType || 'not-set'
return send(kind, event)(success || noop, failure || noop)
}
}
}
})(PS["Main"] = PS["Main"] || {});
(function(exports) {
// Generated by psc version 0.7.5.3
"use strict";
var $foreign = PS["Main"];
var Prelude = PS["Prelude"];
var Control_Monad_Eff = PS["Control.Monad.Eff"];
var Data_Function = PS["Data.Function"];
var DOM = PS["DOM"];
var Jane_Events = PS["Jane.Events"];
var main = $foreign.mkApi(Data_Function.mkFn2(Jane_Events.send));
exports["main"] = main;
exports["mkApi"] = $foreign.mkApi;;
})(PS["Main"] = PS["Main"] || {});
PS["Main"].main();
var PS = {};
!function(exports) {
"use strict";
exports.arrayMap = function(f) {
return function(arr) {
for (var l = arr.length, result = new Array(l), i = 0; l > i; i++) result[i] = f(arr[i]);
return result;
};
}, exports.refEq = function(r1) {
return function(r2) {
return r1 === r2;
};
}, exports.showIntImpl = function(n) {
return n.toString();
}, exports.showStringImpl = function(s) {
return JSON.stringify(s);
};
}(PS.Prelude = PS.Prelude || {}), function(exports) {
"use strict";
var $foreign = PS.Prelude, Functor = function(map) {
this.map = map;
}, Apply = function(__superclass_Prelude$dotFunctor_0, apply) {
this["__superclass_Prelude.Functor_0"] = __superclass_Prelude$dotFunctor_0, this.apply = apply;
}, Applicative = function(__superclass_Prelude$dotApply_0, pure) {
this["__superclass_Prelude.Apply_0"] = __superclass_Prelude$dotApply_0, this.pure = pure;
}, Bind = function(__superclass_Prelude$dotApply_0, bind) {
this["__superclass_Prelude.Apply_0"] = __superclass_Prelude$dotApply_0, this.bind = bind;
}, Monad = function(__superclass_Prelude$dotApplicative_0, __superclass_Prelude$dotBind_1) {
this["__superclass_Prelude.Applicative_0"] = __superclass_Prelude$dotApplicative_0,
this["__superclass_Prelude.Bind_1"] = __superclass_Prelude$dotBind_1;
}, Eq = function(eq) {
this.eq = eq;
}, Show = function(show) {
this.show = show;
}, unit = {}, showString = new Show($foreign.showStringImpl), showInt = new Show($foreign.showIntImpl), show = function(dict) {
return dict.show;
}, pure = function(dict) {
return dict.pure;
}, $$return = function(__dict_Applicative_2) {
return pure(__dict_Applicative_2);
}, map = function(dict) {
return dict.map;
}, $less$dollar$greater = function(__dict_Functor_5) {
return map(__dict_Functor_5);
}, functorArray = new Functor($foreign.arrayMap), eqString = new Eq($foreign.refEq), eq = function(dict) {
return dict.eq;
}, $eq$eq = function(__dict_Eq_7) {
return eq(__dict_Eq_7);
}, $$const = function(a) {
return function() {
return a;
};
}, bind = function(dict) {
return dict.bind;
}, $greater$greater$eq = function(__dict_Bind_24) {
return bind(__dict_Bind_24);
}, apply = function(dict) {
return dict.apply;
}, $less$times$greater = function(__dict_Apply_25) {
return apply(__dict_Apply_25);
}, liftA1 = function(__dict_Applicative_26) {
return function(f) {
return function(a) {
return $less$times$greater(__dict_Applicative_26["__superclass_Prelude.Apply_0"]())(pure(__dict_Applicative_26)(f))(a);
};
};
}, ap = function(__dict_Monad_30) {
return function(f) {
return function(a) {
return bind(__dict_Monad_30["__superclass_Prelude.Bind_1"]())(f)(function(_2) {
return bind(__dict_Monad_30["__superclass_Prelude.Bind_1"]())(a)(function(_1) {
return $$return(__dict_Monad_30["__superclass_Prelude.Applicative_0"]())(_2(_1));
});
});
};
};
};
exports.Show = Show, exports.Eq = Eq, exports.Monad = Monad, exports.Bind = Bind,
exports.Applicative = Applicative, exports.Apply = Apply, exports.Functor = Functor,
exports.show = show, exports["=="] = $eq$eq, exports.eq = eq, exports.ap = ap, exports[">>="] = $greater$greater$eq,
exports.bind = bind, exports.liftA1 = liftA1, exports.pure = pure, exports.apply = apply,
exports["<$>"] = $less$dollar$greater, exports.map = map, exports.const = $$const,
exports.unit = unit, exports.functorArray = functorArray, exports.eqString = eqString,
exports.showInt = showInt, exports.showString = showString;
}(PS.Prelude = PS.Prelude || {}), function(exports) {
"use strict";
var Prelude = PS.Prelude, $eq$less$less = function(__dict_Bind_1) {
return function(f) {
return function(m) {
return Prelude[">>="](__dict_Bind_1)(m)(f);
};
};
}, $less$eq$less = function(__dict_Bind_2) {
return function(f) {
return function(g) {
return function(a) {
return $eq$less$less(__dict_Bind_2)(f)(g(a));
};
};
};
};
exports["<=<"] = $less$eq$less;
}(PS["Control.Bind"] = PS["Control.Bind"] || {}), function(exports) {
"use strict";
exports._unsafeInterleaveAff = function(aff) {
return aff;
}, exports._makeAff = function(cb) {
return function(success, error) {
return cb(function(e) {
return function() {
error(e);
};
})(function(v) {
return function() {
try {
success(v);
} catch (e) {
error(e);
}
};
})();
};
}, exports._pure = function(nonCanceler, v) {
return function(success, error) {
try {
success(v);
} catch (e) {
error(e);
}
return nonCanceler;
};
}, exports._fmap = function(f, aff) {
return function(success, error) {
return aff(function(v) {
try {
success(f(v));
} catch (e) {
error(e);
}
}, error);
};
}, exports._bind = function(alwaysCanceler, aff, f) {
return function(success, error) {
var canceler1, canceler2, isCanceled = !1, requestCancel = !1, onCanceler = function() {};
return canceler1 = aff(function(v) {
return requestCancel ? (isCanceled = !0, alwaysCanceler) : (canceler2 = f(v)(success, error),
onCanceler(canceler2), canceler2);
}, error), function(e) {
return function(s, f) {
return requestCancel = !0, void 0 !== canceler2 ? canceler2(e)(s, f) : canceler1(e)(function(bool) {
if (bool || isCanceled) try {
s(!0);
} catch (e) {
f(e);
} else onCanceler = function(canceler) {
canceler(e)(s, f);
};
}, f);
};
};
};
}, exports._attempt = function(Left, Right, aff) {
return function(success, error) {
return aff(function(v) {
try {
success(Right(v));
} catch (e) {
error(e);
}
}, function(e) {
try {
success(Left(e));
} catch (e) {
error(e);
}
});
};
}, exports._liftEff = function(nonCanceler) {
return function(success, error) {
try {
success(e());
} catch (e) {
error(e);
}
return nonCanceler;
};
};
}(PS["Control.Monad.Aff"] = PS["Control.Monad.Aff"] || {}), function(exports) {
"use strict";
exports.returnE = function(a) {
return function() {
return a;
};
}, exports.bindE = function(a) {
return function(f) {
return function() {
return f(a())();
};
};
};
}(PS["Control.Monad.Eff"] = PS["Control.Monad.Eff"] || {}), function(exports) {
"use strict";
var $foreign = PS["Control.Monad.Eff"], Prelude = PS.Prelude, monadEff = new Prelude.Monad(function() {
return applicativeEff;
}, function() {
return bindEff;
}), bindEff = new Prelude.Bind(function() {
return applyEff;
}, $foreign.bindE), applyEff = new Prelude.Apply(function() {
return functorEff;
}, Prelude.ap(monadEff)), applicativeEff = new Prelude.Applicative(function() {
return applyEff;
}, $foreign.returnE), functorEff = new Prelude.Functor(Prelude.liftA1(applicativeEff));
exports.functorEff = functorEff, exports.applyEff = applyEff, exports.applicativeEff = applicativeEff,
exports.bindEff = bindEff, exports.monadEff = monadEff;
}(PS["Control.Monad.Eff"] = PS["Control.Monad.Eff"] || {}), function(exports) {
"use strict";
exports.error = function(msg) {
return new Error(msg);
};
}(PS["Control.Monad.Eff.Exception"] = PS["Control.Monad.Eff.Exception"] || {}),
function(exports) {
"use strict";
var $foreign = PS["Control.Monad.Eff.Exception"];
PS.Prelude, PS["Control.Monad.Eff"], exports.error = $foreign.error;
}(PS["Control.Monad.Eff.Exception"] = PS["Control.Monad.Eff.Exception"] || {}),
function(exports) {
"use strict";
var Prelude = PS.Prelude, Left = (PS["Control.Alt"], PS["Control.Extend"], PS["Data.Bifoldable"],
PS["Data.Bifunctor"], PS["Data.Bitraversable"], PS["Data.Foldable"], PS["Data.Monoid"],
PS["Data.Traversable"], function() {
function Left(value0) {
this.value0 = value0;
}
return Left.create = function(value0) {
return new Left(value0);
}, Left;
}()), Right = function() {
function Right(value0) {
this.value0 = value0;
}
return Right.create = function(value0) {
return new Right(value0);
}, Right;
}(), functorEither = new Prelude.Functor(function(f) {
return function(_2) {
if (_2 instanceof Left) return new Left(_2.value0);
if (_2 instanceof Right) return new Right(f(_2.value0));
throw new Error("Failed pattern match at Data.Either line 52, column 1 - line 56, column 1: " + [ f.constructor.name, _2.constructor.name ]);
};
}), either = function(f) {
return function(g) {
return function(_1) {
if (_1 instanceof Left) return f(_1.value0);
if (_1 instanceof Right) return g(_1.value0);
throw new Error("Failed pattern match at Data.Either line 28, column 1 - line 29, column 1: " + [ f.constructor.name, g.constructor.name, _1.constructor.name ]);
};
};
}, applyEither = new Prelude.Apply(function() {
return functorEither;
}, function(_4) {
return function(r) {
if (_4 instanceof Left) return new Left(_4.value0);
if (_4 instanceof Right) return Prelude["<$>"](functorEither)(_4.value0)(r);
throw new Error("Failed pattern match at Data.Either line 92, column 1 - line 116, column 1: " + [ _4.constructor.name, r.constructor.name ]);
};
}), bindEither = new Prelude.Bind(function() {
return applyEither;
}, either(function(e) {
return function() {
return new Left(e);
};
})(function(a) {
return function(f) {
return f(a);
};
})), applicativeEither = new Prelude.Applicative(function() {
return applyEither;
}, Right.create);
exports.Left = Left, exports.Right = Right, exports.either = either, exports.functorEither = functorEither,
exports.applyEither = applyEither, exports.applicativeEither = applicativeEither,
exports.bindEither = bindEither;
}(PS["Data.Either"] = PS["Data.Either"] || {}), function(exports) {
"use strict";
exports.mkFn2 = function(fn) {
return function(a, b) {
return fn(a)(b);
};
};
}(PS["Data.Function"] = PS["Data.Function"] || {}), function(exports) {
"use strict";
var $foreign = PS["Data.Function"];
PS.Prelude, exports.mkFn2 = $foreign.mkFn2;
}(PS["Data.Function"] = PS["Data.Function"] || {}), function(exports) {
"use strict";
var $foreign = PS["Control.Monad.Aff"], Prelude = PS.Prelude, Control_Monad_Eff = (PS["Control.Alt"],
PS["Control.Alternative"], PS["Control.Monad.Cont.Class"], PS["Control.Monad.Eff"]), Data_Either = (PS["Control.Monad.Eff.Class"],
PS["Control.Monad.Eff.Exception"], PS["Control.Monad.Eff.Unsafe"], PS["Control.Monad.Error.Class"],
PS["Control.Monad.Rec.Class"], PS["Control.MonadPlus"], PS["Control.Plus"], PS["Data.Either"]), makeAff$prime = (PS["Data.Function"],
PS["Data.Monoid"], function(h) {
return $foreign._makeAff(h);
}), functorAff = new Prelude.Functor(function(f) {
return function(fa) {
return $foreign._fmap(f, fa);
};
}), attempt = function(aff) {
return $foreign._attempt(Data_Either.Left.create, Data_Either.Right.create, aff);
}, applyAff = new Prelude.Apply(function() {
return functorAff;
}, function(ff) {
return function(fa) {
return $foreign._bind(alwaysCanceler, ff, function(f) {
return Prelude["<$>"](functorAff)(f)(fa);
});
};
}), applicativeAff = new Prelude.Applicative(function() {
return applyAff;
}, function(v) {
return $foreign._pure(nonCanceler, v);
}), nonCanceler = Prelude.const(Prelude.pure(applicativeAff)(!1)), alwaysCanceler = Prelude.const(Prelude.pure(applicativeAff)(!0)), liftEff$prime = function(eff) {
return attempt($foreign._unsafeInterleaveAff($foreign._liftEff(nonCanceler, eff)));
}, makeAff = function(h) {
return makeAff$prime(function(e) {
return function(a) {
return Prelude["<$>"](Control_Monad_Eff.functorEff)(Prelude.const(nonCanceler))(h(e)(a));
};
});
}, bindAff = new Prelude.Bind(function() {
return applyAff;
}, function(fa) {
return function(f) {
return $foreign._bind(alwaysCanceler, fa, f);
};
});
exports.nonCanceler = nonCanceler, exports["makeAff'"] = makeAff$prime, exports.makeAff = makeAff,
exports["liftEff'"] = liftEff$prime, exports.attempt = attempt, exports.functorAff = functorAff,
exports.applyAff = applyAff, exports.applicativeAff = applicativeAff, exports.bindAff = bindAff;
}(PS["Control.Monad.Aff"] = PS["Control.Monad.Aff"] || {}), function(exports) {
"use strict";
exports.parseJSONImpl = function(left, right, str) {
try {
return right(JSON.parse(str));
} catch (e) {
return left(e.toString());
}
}, exports.unsafeFromForeign = function(value) {
return value;
}, exports.tagOf = function(value) {
return Object.prototype.toString.call(value).slice(8, -1);
};
}(PS["Data.Foreign"] = PS["Data.Foreign"] || {}), function(exports) {
"use strict";
var Prelude = PS.Prelude, Nothing = (PS["Control.Alt"], PS["Control.Alternative"],
PS["Control.Extend"], PS["Control.MonadPlus"], PS["Control.Plus"], PS["Data.Functor.Invariant"],
PS["Data.Monoid"], function() {
function Nothing() {}
return Nothing.value = new Nothing(), Nothing;
}()), Just = function() {
function Just(value0) {
this.value0 = value0;
}
return Just.create = function(value0) {
return new Just(value0);
}, Just;
}(), maybe = function(b) {
return function(f) {
return function(_0) {
if (_0 instanceof Nothing) return b;
if (_0 instanceof Just) return f(_0.value0);
throw new Error("Failed pattern match at Data.Maybe line 26, column 1 - line 27, column 1: " + [ b.constructor.name, f.constructor.name, _0.constructor.name ]);
};
};
}, functorMaybe = new Prelude.Functor(function(fn) {
return function(_2) {
return _2 instanceof Just ? new Just(fn(_2.value0)) : Nothing.value;
};
});
exports.Nothing = Nothing, exports.Just = Just, exports.maybe = maybe, exports.functorMaybe = functorMaybe;
}(PS["Data.Maybe"] = PS["Data.Maybe"] || {}), function(exports) {
"use strict";
var $foreign = PS["Data.Foreign"], Prelude = PS.Prelude, Data_Either = PS["Data.Either"], TypeMismatch = (PS["Data.Maybe"],
PS["Data.Function"], PS["Data.Int"], PS["Data.String"], function() {
function TypeMismatch(value0, value1) {
this.value0 = value0, this.value1 = value1;
}
return TypeMismatch.create = function(value0) {
return function(value1) {
return new TypeMismatch(value0, value1);
};
}, TypeMismatch;
}()), ErrorAtIndex = function() {
function ErrorAtIndex(value0, value1) {
this.value0 = value0, this.value1 = value1;
}
return ErrorAtIndex.create = function(value0) {
return function(value1) {
return new ErrorAtIndex(value0, value1);
};
}, ErrorAtIndex;
}(), ErrorAtProperty = function() {
function ErrorAtProperty(value0, value1) {
this.value0 = value0, this.value1 = value1;
}
return ErrorAtProperty.create = function(value0) {
return function(value1) {
return new ErrorAtProperty(value0, value1);
};
}, ErrorAtProperty;
}(), JSONError = function() {
function JSONError(value0) {
this.value0 = value0;
}
return JSONError.create = function(value0) {
return new JSONError(value0);
}, JSONError;
}(), unsafeReadTagged = function(tag) {
return function(value) {
return Prelude["=="](Prelude.eqString)($foreign.tagOf(value))(tag) ? Prelude.pure(Data_Either.applicativeEither)($foreign.unsafeFromForeign(value)) : new Data_Either.Left(new TypeMismatch(tag, $foreign.tagOf(value)));
};
}, showForeignError = new Prelude.Show(function(_0) {
if (_0 instanceof TypeMismatch) return "Type mismatch: expected " + (_0.value0 + (", found " + _0.value1));
if (_0 instanceof ErrorAtIndex) return "Error at array index " + (Prelude.show(Prelude.showInt)(_0.value0) + (": " + Prelude.show(showForeignError)(_0.value1)));
if (_0 instanceof ErrorAtProperty) return "Error at property " + (Prelude.show(Prelude.showString)(_0.value0) + (": " + Prelude.show(showForeignError)(_0.value1)));
if (_0 instanceof JSONError) return "JSON error: " + _0.value0;
throw new Error("Failed pattern match: " + [ _0.constructor.name ]);
}), readString = unsafeReadTagged("String"), parseJSON = function(json) {
return $foreign.parseJSONImpl(function(_32) {
return Data_Either.Left.create(JSONError.create(_32));
}, Data_Either.Right.create, json);
};
exports.TypeMismatch = TypeMismatch, exports.ErrorAtIndex = ErrorAtIndex, exports.ErrorAtProperty = ErrorAtProperty,
exports.JSONError = JSONError, exports.readString = readString, exports.unsafeReadTagged = unsafeReadTagged,
exports.parseJSON = parseJSON, exports.showForeignError = showForeignError;
}(PS["Data.Foreign"] = PS["Data.Foreign"] || {}), function(exports) {
"use strict";
exports.null = null, exports.notNull = function(x) {
return x;
};
}(PS["Data.Nullable"] = PS["Data.Nullable"] || {}), function(exports) {
"use strict";
var $foreign = PS["Data.Nullable"], Data_Maybe = (PS.Prelude, PS["Data.Maybe"]), toNullable = (PS["Data.Function"],
Data_Maybe.maybe($foreign.null)($foreign.notNull));
exports.toNullable = toNullable;
}(PS["Data.Nullable"] = PS["Data.Nullable"] || {}), function(exports) {
"use strict";
exports.unsafeStringify = function(x) {
return JSON.stringify(x);
};
}(PS["Global.Unsafe"] = PS["Global.Unsafe"] || {}), function(exports) {
"use strict";
var $foreign = PS["Global.Unsafe"];
exports.unsafeStringify = $foreign.unsafeStringify;
}(PS["Global.Unsafe"] = PS["Global.Unsafe"] || {}), function(exports) {
"use strict";
exports.getLocation = function() {
return "undefined" == typeof window || null == window ? {} : window.location || {};
};
}(PS["Jane.Events"] = PS["Jane.Events"] || {}), function(exports) {
"use strict";
exports._ajax = function(mkHeader, options, canceler, errback, callback) {
var platformSpecific = {};
return "undefined" != typeof module && module.require ? (platformSpecific.newXHR = function() {
var XHR = module.require("xhr2");
return new XHR();
}, platformSpecific.fixupUrl = function(url) {
var urllib = module.require("url"), u = urllib.parse(url);
return u.protocol = u.protocol || "http:", u.hostname = u.hostname || "localhost",
urllib.format(u);
}, platformSpecific.getResponse = function(xhr) {
return xhr.response;
}) : (platformSpecific.newXHR = function() {
return new XMLHttpRequest();
}, platformSpecific.fixupUrl = function(url) {
return url || "/";
}, platformSpecific.getResponse = function(xhr) {
return xhr.response;
}), function() {
var xhr = platformSpecific.newXHR(), fixedUrl = platformSpecific.fixupUrl(options.url);
if (xhr.open(options.method || "GET", fixedUrl, !0, options.username, options.password),
options.headers) for (var header, i = 0; null != (header = options.headers[i]); i++) xhr.setRequestHeader(header.field, header.value);
return xhr.onerror = function() {
errback(new Error("AJAX request failed: " + options.method + " " + options.url))();
}, xhr.onload = function() {
callback({
status: xhr.status,
headers: xhr.getAllResponseHeaders().split("\n").filter(function(header) {
return header.length > 0;
}).map(function(header) {
var i = header.indexOf(":");
return mkHeader(header.substring(0, i))(header.substring(i + 2));
}),
response: platformSpecific.getResponse(xhr)
})();
}, xhr.responseType = options.responseType, xhr.send(options.content), canceler(xhr);
};
}, exports._cancelAjax = function(xhr, cancelError, errback, callback) {
return function() {
try {
xhr.abort();
} catch (e) {
return callback(!1)();
}
return callback(!0)();
};
};
}(PS["Network.HTTP.Affjax"] = PS["Network.HTTP.Affjax"] || {}), function(exports) {
"use strict";
exports.unsafeCoerce = function(x) {
return x;
};
}(PS["Unsafe.Coerce"] = PS["Unsafe.Coerce"] || {}), function(exports) {
"use strict";
var $foreign = PS["Unsafe.Coerce"];
exports.unsafeCoerce = $foreign.unsafeCoerce;
}(PS["Unsafe.Coerce"] = PS["Unsafe.Coerce"] || {}), function(exports) {
"use strict";
var Unsafe_Coerce = (PS.Prelude, PS["DOM.File.Types"], PS["DOM.Node.Types"], PS["DOM.XHR.Types"],
PS["Unsafe.Coerce"]), Requestable = (PS["Data.ArrayBuffer.Types"], function(toRequest) {
this.toRequest = toRequest;
}), toRequest = function(dict) {
return dict.toRequest;
}, requestableString = new Requestable(Unsafe_Coerce.unsafeCoerce);
exports.Requestable = Requestable, exports.toRequest = toRequest, exports.requestableString = requestableString;
}(PS["Network.HTTP.Affjax.Request"] = PS["Network.HTTP.Affjax.Request"] || {}),
function(exports) {
"use strict";
var Prelude = PS.Prelude, Data_Either = PS["Data.Either"], ArrayBufferResponse = (PS["Data.Foreign"],
PS["DOM.File.Types"], PS["DOM.Node.Types"], PS["DOM.XHR.Types"], PS["Data.ArrayBuffer.Types"],
function() {
function ArrayBufferResponse() {}
return ArrayBufferResponse.value = new ArrayBufferResponse(), ArrayBufferResponse;
}()), BlobResponse = function() {
function BlobResponse() {}
return BlobResponse.value = new BlobResponse(), BlobResponse;
}(), DocumentResponse = function() {
function DocumentResponse() {}
return DocumentResponse.value = new DocumentResponse(), DocumentResponse;
}(), JSONResponse = function() {
function JSONResponse() {}
return JSONResponse.value = new JSONResponse(), JSONResponse;
}(), StringResponse = function() {
function StringResponse() {}
return StringResponse.value = new StringResponse(), StringResponse;
}(), Respondable = function(fromResponse, responseType) {
this.fromResponse = fromResponse, this.responseType = responseType;
}, responseTypeToString = function(_0) {
if (_0 instanceof ArrayBufferResponse) return "arraybuffer";
if (_0 instanceof BlobResponse) return "blob";
if (_0 instanceof DocumentResponse) return "document";
if (_0 instanceof JSONResponse) return "text";
if (_0 instanceof StringResponse) return "text";
throw new Error("Failed pattern match at Network.HTTP.Affjax.Response line 41, column 1 - line 42, column 1: " + [ _0.constructor.name ]);
}, responseType = function(dict) {
return dict.responseType;
}, responsableUnit = new Respondable(Prelude.const(new Data_Either.Right(Prelude.unit)), StringResponse.value), fromResponse = function(dict) {
return dict.fromResponse;
};
exports.ArrayBufferResponse = ArrayBufferResponse, exports.BlobResponse = BlobResponse,
exports.DocumentResponse = DocumentResponse, exports.JSONResponse = JSONResponse,
exports.StringResponse = StringResponse, exports.Respondable = Respondable, exports.fromResponse = fromResponse,
exports.responseType = responseType, exports.responseTypeToString = responseTypeToString,
exports.responsableUnit = responsableUnit;
}(PS["Network.HTTP.Affjax.Response"] = PS["Network.HTTP.Affjax.Response"] || {}),
function(exports) {
"use strict";
var Prelude = PS.Prelude, DELETE = function() {
function DELETE() {}
return DELETE.value = new DELETE(), DELETE;
}(), GET = function() {
function GET() {}
return GET.value = new GET(), GET;
}(), HEAD = function() {
function HEAD() {}
return HEAD.value = new HEAD(), HEAD;
}(), OPTIONS = function() {
function OPTIONS() {}
return OPTIONS.value = new OPTIONS(), OPTIONS;
}(), PATCH = function() {
function PATCH() {}
return PATCH.value = new PATCH(), PATCH;
}(), POST = function() {
function POST() {}
return POST.value = new POST(), POST;
}(), PUT = function() {
function PUT() {}
return PUT.value = new PUT(), PUT;
}(), MOVE = function() {
function MOVE() {}
return MOVE.value = new MOVE(), MOVE;
}(), COPY = function() {
function COPY() {}
return COPY.value = new COPY(), COPY;
}(), CustomMethod = function() {
function CustomMethod(value0) {
this.value0 = value0;
}
return CustomMethod.create = function(value0) {
return new CustomMethod(value0);
}, CustomMethod;
}(), showMethod = new Prelude.Show(function(_3) {
if (_3 instanceof DELETE) return "DELETE";
if (_3 instanceof GET) return "GET";
if (_3 instanceof HEAD) return "HEAD";
if (_3 instanceof OPTIONS) return "OPTIONS";
if (_3 instanceof PATCH) return "PATCH";
if (_3 instanceof POST) return "POST";
if (_3 instanceof PUT) return "PUT";
if (_3 instanceof MOVE) return "MOVE";
if (_3 instanceof COPY) return "COPY";
if (_3 instanceof CustomMethod) return "(CustomMethod " + (Prelude.show(Prelude.showString)(_3.value0) + ")");
throw new Error("Failed pattern match at Network.HTTP.Method line 29, column 1 - line 41, column 1: " + [ _3.constructor.name ]);
}), methodToString = function(_0) {
return _0 instanceof CustomMethod ? _0.value0 : Prelude.show(showMethod)(_0);
};
exports.DELETE = DELETE, exports.GET = GET, exports.HEAD = HEAD, exports.OPTIONS = OPTIONS,
exports.PATCH = PATCH, exports.POST = POST, exports.PUT = PUT, exports.MOVE = MOVE,
exports.COPY = COPY, exports.CustomMethod = CustomMethod, exports.methodToString = methodToString,
exports.showMethod = showMethod;
}(PS["Network.HTTP.Method"] = PS["Network.HTTP.Method"] || {}), function(exports) {
"use strict";
var mimeTypeToString = (PS.Prelude, function(_0) {
return _0;
});
exports.mimeTypeToString = mimeTypeToString;
}(PS["Network.HTTP.MimeType"] = PS["Network.HTTP.MimeType"] || {}), function(exports) {
"use strict";
var Network_HTTP_MimeType = (PS.Prelude, PS["Network.HTTP.MimeType"]), Accept = function() {
function Accept(value0) {
this.value0 = value0;
}
return Accept.create = function(value0) {
return new Accept(value0);
}, Accept;
}(), ContentType = function() {
function ContentType(value0) {
this.value0 = value0;
}
return ContentType.create = function(value0) {
return new ContentType(value0);
}, ContentType;
}(), RequestHeader = function() {
function RequestHeader(value0, value1) {
this.value0 = value0, this.value1 = value1;
}
return RequestHeader.create = function(value0) {
return function(value1) {
return new RequestHeader(value0, value1);
};
}, RequestHeader;
}(), requestHeaderValue = function(_1) {
if (_1 instanceof Accept) return Network_HTTP_MimeType.mimeTypeToString(_1.value0);
if (_1 instanceof ContentType) return Network_HTTP_MimeType.mimeTypeToString(_1.value0);
if (_1 instanceof RequestHeader) return _1.value1;
throw new Error("Failed pattern match at Network.HTTP.RequestHeader line 28, column 1 - line 29, column 1: " + [ _1.constructor.name ]);
}, requestHeaderName = function(_0) {
if (_0 instanceof Accept) return "Accept";
if (_0 instanceof ContentType) return "Content-Type";
if (_0 instanceof RequestHeader) return _0.value0;
throw new Error("Failed pattern match at Network.HTTP.RequestHeader line 23, column 1 - line 24, column 1: " + [ _0.constructor.name ]);
};
exports.Accept = Accept, exports.ContentType = ContentType, exports.RequestHeader = RequestHeader,
exports.requestHeaderValue = requestHeaderValue, exports.requestHeaderName = requestHeaderName;
}(PS["Network.HTTP.RequestHeader"] = PS["Network.HTTP.RequestHeader"] || {}), function(exports) {
"use strict";
var ResponseHeader = (PS.Prelude, function() {
function ResponseHeader(value0, value1) {
this.value0 = value0, this.value1 = value1;
}
return ResponseHeader.create = function(value0) {
return function(value1) {
return new ResponseHeader(value0, value1);
};
}, ResponseHeader;
}()), responseHeader = function(field) {
return function(value) {
return new ResponseHeader(field, value);
};
};
exports.responseHeader = responseHeader;
}(PS["Network.HTTP.ResponseHeader"] = PS["Network.HTTP.ResponseHeader"] || {}),
function(exports) {
"use strict";
var $foreign = PS["Network.HTTP.Affjax"], Prelude = PS.Prelude, Control_Bind = (PS["Control.Alt"],
PS["Control.Bind"]), Control_Monad_Aff = PS["Control.Monad.Aff"], Control_Monad_Eff_Exception = (PS["Control.Monad.Aff.Par"],
PS["Control.Monad.Aff.AVar"], PS["Control.Monad.Eff"], PS["Control.Monad.Eff.Class"],
PS["Control.Monad.Eff.Exception"]), Data_Either = (PS["Control.Monad.Eff.Ref"],
PS["Control.Monad.Error.Class"], PS["Data.Either"]), Data_Foreign = PS["Data.Foreign"], Data_Maybe = (PS["Data.Function"],
PS["Data.Int"], PS["Data.Maybe"]), Data_Nullable = PS["Data.Nullable"], Network_HTTP_Affjax_Request = (PS["DOM.XHR.Types"],
PS.Math, PS["Network.HTTP.Affjax.Request"]), Network_HTTP_Affjax_Response = PS["Network.HTTP.Affjax.Response"], Network_HTTP_Method = PS["Network.HTTP.Method"], Network_HTTP_RequestHeader = PS["Network.HTTP.RequestHeader"], Network_HTTP_ResponseHeader = PS["Network.HTTP.ResponseHeader"], defaultRequest = (PS["Network.HTTP.StatusCode"],
{
method: Network_HTTP_Method.GET.value,
url: "/",
headers: [],
content: Data_Maybe.Nothing.value,
username: Data_Maybe.Nothing.value,
password: Data_Maybe.Nothing.value
}), cancelAjax = function(xhr) {
return function(err) {
return Control_Monad_Aff.makeAff(function(eb) {
return function(cb) {
return $foreign._cancelAjax(xhr, err, eb, cb);
};
});
};
}, affjax$prime = function(__dict_Requestable_1) {
return function(__dict_Respondable_2) {
return function(req) {
return function(eb) {
return function(cb) {
var req$prime = {
method: Network_HTTP_Method.methodToString(req.method),
url: req.url,
headers: Prelude["<$>"](Prelude.functorArray)(function(h) {
return {
field: Network_HTTP_RequestHeader.requestHeaderName(h),
value: Network_HTTP_RequestHeader.requestHeaderValue(h)
};
})(req.headers),
content: Data_Nullable.toNullable(Prelude["<$>"](Data_Maybe.functorMaybe)(Network_HTTP_Affjax_Request.toRequest(__dict_Requestable_1))(req.content)),
responseType: Network_HTTP_Affjax_Response.responseTypeToString(Network_HTTP_Affjax_Response.responseType(__dict_Respondable_2)),
username: Data_Nullable.toNullable(req.username),
password: Data_Nullable.toNullable(req.password)
}, fromResponse$prime = function() {
var _32 = Network_HTTP_Affjax_Response.responseType(__dict_Respondable_2);
return _32 instanceof Network_HTTP_Affjax_Response.JSONResponse ? Control_Bind["<=<"](Data_Either.bindEither)(Network_HTTP_Affjax_Response.fromResponse(__dict_Respondable_2))(Control_Bind["<=<"](Data_Either.bindEither)(Data_Foreign.parseJSON)(Data_Foreign.readString)) : Network_HTTP_Affjax_Response.fromResponse(__dict_Respondable_2);
}(), cb$prime = function(res) {
var _35 = Prelude["<$>"](Data_Either.functorEither)(function(_0) {
var _33 = {};
for (var _34 in res) res.hasOwnProperty(_34) && (_33[_34] = res[_34]);
return _33.response = _0, _33;
})(fromResponse$prime(res.response));
if (_35 instanceof Data_Either.Left) return eb(Control_Monad_Eff_Exception.error(Prelude.show(Data_Foreign.showForeignError)(_35.value0)));
if (_35 instanceof Data_Either.Right) return cb(_35.value0);
throw new Error("Failed pattern match at Network.HTTP.Affjax line 197, column 1 - line 202, column 1: " + [ _35.constructor.name ]);
};
return $foreign._ajax(Network_HTTP_ResponseHeader.responseHeader, req$prime, cancelAjax, eb, cb$prime);
};
};
};
};
}, affjax = function(__dict_Requestable_3) {
return function(__dict_Respondable_4) {
return function(_51) {
return Control_Monad_Aff["makeAff'"](affjax$prime(__dict_Requestable_3)(__dict_Respondable_4)(_51));
};
};
};
exports.affjax = affjax, exports.defaultRequest = defaultRequest;
}(PS["Network.HTTP.Affjax"] = PS["Network.HTTP.Affjax"] || {}), function(exports) {
"use strict";
var applicationJSON = (PS["Network.HTTP.MimeType"], "application/json");
exports.applicationJSON = applicationJSON;
}(PS["Network.HTTP.MimeType.Common"] = PS["Network.HTTP.MimeType.Common"] || {}),
function(exports) {
"use strict";
var $foreign = PS["Jane.Events"], Prelude = PS.Prelude, Control_Monad_Aff = (PS["Control.Monad.Eff"],
PS["Control.Monad.Eff.Exception"], PS["Control.Monad.Aff"]), Data_Either = (PS.DOM,
PS["Data.Either"]), Data_Maybe = (PS["Data.Foreign"], PS["Data.Maybe"]), Global_Unsafe = PS["Global.Unsafe"], Network_HTTP_Affjax = PS["Network.HTTP.Affjax"], Network_HTTP_Affjax_Request = PS["Network.HTTP.Affjax.Request"], Network_HTTP_Affjax_Response = PS["Network.HTTP.Affjax.Response"], Network_HTTP_Method = PS["Network.HTTP.Method"], Network_HTTP_MimeType_Common = PS["Network.HTTP.MimeType.Common"], Network_HTTP_RequestHeader = PS["Network.HTTP.RequestHeader"], mkHeaders = function(_4) {
return [ new Network_HTTP_RequestHeader.ContentType(Network_HTTP_MimeType_Common.applicationJSON), new Network_HTTP_RequestHeader.RequestHeader("Location-Protocol", _4.protocol), new Network_HTTP_RequestHeader.RequestHeader("Location-Host", _4.host), new Network_HTTP_RequestHeader.RequestHeader("Location-Path", _4.pathname), new Network_HTTP_RequestHeader.RequestHeader("Location-Query", _4.search), new Network_HTTP_RequestHeader.RequestHeader("Location-Hash", _4.hash) ];
}, mkEndpoint = function(_3) {
return _3.protocol + ("//" + (_3.host + "/proxy/events"));
}, mkContent = function(_19) {
return Data_Maybe.Just.create(Global_Unsafe.unsafeStringify(_19));
}, mkRequest = function(location) {
return function(_5) {
return function(eventData) {
var _11 = {};
for (var _12 in Network_HTTP_Affjax.defaultRequest) Network_HTTP_Affjax.defaultRequest.hasOwnProperty(_12) && (_11[_12] = Network_HTTP_Affjax.defaultRequest[_12]);
return _11.method = Network_HTTP_Method.POST.value, _11.headers = mkHeaders(location),
_11.url = mkEndpoint(location) + ("/events/" + _5), _11.content = mkContent(eventData),
_11;
};
};
}, fromEither = function(d) {
return function(_2) {
if (_2 instanceof Data_Either.Left) return d;
if (_2 instanceof Data_Either.Right) return _2.value0;
throw new Error("Failed pattern match at Jane.Events line 36, column 1 - line 37, column 1: " + [ d.constructor.name, _2.constructor.name ]);
};
}, defaultLocation = {
protocol: "https:",
host: "jane.com",
pathname: "/",
search: "",
hash: ""
}, getLocationLifted = Prelude.bind(Control_Monad_Aff.bindAff)(Control_Monad_Aff["liftEff'"]($foreign.getLocation))(function(_0) {
return Prelude.pure(Control_Monad_Aff.applicativeAff)(fromEither(defaultLocation)(_0));
}), send = function(eventType) {
return function(eventData) {
return Prelude.bind(Control_Monad_Aff.bindAff)(getLocationLifted)(function(_1) {
return Network_HTTP_Affjax.affjax(Network_HTTP_Affjax_Request.requestableString)(Network_HTTP_Affjax_Response.responsableUnit)(mkRequest(_1)(eventType)(eventData));
});
};
};
exports.send = send, exports.mkRequest = mkRequest, exports.mkContent = mkContent,
exports.mkHeaders = mkHeaders, exports.mkEndpoint = mkEndpoint, exports.getLocationLifted = getLocationLifted,
exports.fromEither = fromEither, exports.defaultLocation = defaultLocation;
}(PS["Jane.Events"] = PS["Jane.Events"] || {}), function(exports) {
"use strict";
function noop() {}
exports.mkApi = function(send) {
return function() {
var target;
if ("undefined" != typeof window) target = window; else {
if ("undefined" == typeof global) throw new Error("Failed to find `window` or `global` to attach to");
target = global;
}
target.ja = function(kind, event, success, failure) {
return "object" == typeof kind && (failure = success, success = event, event = kind,
kind = null), event || (event = {}), kind || (kind = event.eventType || "not-set"),
send(kind, event)(success || noop, failure || noop);
};
};
};
}(PS.Main = PS.Main || {}), function(exports) {
"use strict";
var $foreign = PS.Main, Data_Function = (PS.Prelude, PS["Control.Monad.Eff"], PS["Data.Function"]), Jane_Events = (PS.DOM,
PS["Jane.Events"]), main = $foreign.mkApi(Data_Function.mkFn2(Jane_Events.send));
exports.main = main, exports.mkApi = $foreign.mkApi;
}(PS.Main = PS.Main || {}), PS.Main.main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment