Skip to content

Instantly share code, notes, and snippets.

(ns circuit-slave.ajax.core
(:require goog.net.EventType
goog.net.ErrorCode
goog.net.XhrIo
[goog.Uri.QueryData :as query-data]
[goog.structs :as structs]
[goog.events :as events]
[clojure.string :as str]
[clojure.walk :refer [stringify-keys]]
[cljs.core.async :as async :refer [chan alts! put! close!]]
(defn ajax-request
[{:keys [method api interceptors] :as opts}]
(let [response-format (get-response-format opts)
method (normalize-method method)
[uri body headers] (process-inputs (apply-interceptors :response
(or interecptors @default-interceptors)
opts)
response-format)
handler (base-handler response-format opts)
api (or api (new goog.net.XhrIo))]
$.ajaxSetup({
beforeSend: (xhr, settings) =>
console.log("appending auth headers to request");
Auth.appendAuthHeaders(xhr, settings)
}
);
var ApiUtil = function() {};
ApiUtil.prototype.getProxyUrl = function() {
return "/proxy";
};
ApiUtil.prototype.getApiUrl = function() {
return (window.isOldIE())
? this.getProxyUrl()
: window.CONFIG.apiUrl;
var ApiMixin = {
getProxyUrl: function() {
return "/proxy";
},
getApiUrl: function() {
return (window.isOldIE())
? this.getProxyUrl()
: window.CONFIG.apiUrl;
}
var getApiUrl = function() {
return (window.isOldIE())
? "/proxy"
: window.CONFIG.apiUrl;
};
<!-- assign CommonJS modules to global namespace -->
<script>
window.commonJS = require('dbx_apps_engine/dbx_apps_common');
window.$ = window.jQuery = window.commonJS.jquery;
window._ = window.commonJS.lodash;
window.React = window.commonJS.react;
</script>
<!-- turn it up -->
<script>
/**
* @jsx React.DOM
*/
import { default as React } from "react";
import { Router } from "react-router";
import { history } from "react-router/lib/HashHistory";
import { default as Inner } from "./inner";
import { default as Login } from "./login";
;;; the following env vars have been set in profiles.clj
{:profiles/dev {:env {:sauce-username "xxxxxxxxxxxxxxx"
:sauce-key "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"
:max-sauce-connections 2}
:local-target-test-platforms [{:browser :firefox}]
:sauce-target-test-platforms [{:browser :firefox}
{:browser :chrome}
{:browser :safari}]}}
;;; test runner
<!-- include the browserify-compiled CommonJS module -->
<%= javascript_include_tag 'dbx_apps_engine/dbx_apps_common' %>
<!-- assign CommonJS modules to global namespace -->
<script>
window.commonJS = require('dbx_apps_engine/dbx_apps_common');
window.$ = window.jQuery = window.commonJS.jquery;
window._ = window.commonJS.lodash;
window.React = window.commonJS.react;
</script>