Last active
December 26, 2015 00:39
-
-
Save mywaiting/7065426 to your computer and use it in GitHub Desktop.
Quora Require for Browser in 2013-10-20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.require || function(global, undefined) { | |
/** | |
require | |
var module = require("ModuleName"); | |
*/ | |
function require(a) { | |
if (!exported[a]) { | |
rec("loader.require", "Required", a); | |
var b, c = installed[a]; | |
c && (c.id = a, c.exports = b = {}, c(function(b) { | |
return demand(b, a) | |
}, exported[a] = b, c), c.exports && c.exports !== b && (exported[a] = c.exports), rec("loader.require.export" + (c.lazy ? ".lazy" : ""), "Exported", a)) | |
} | |
return exported[a] | |
} | |
function demand(a, b) { | |
return require(a = absolutize(a, b)) || raise(a) | |
} | |
function raise(a) { | |
throw a | |
} | |
function absolutize(a, b) { | |
if (b && /^\./.test(a)) { | |
a = "/" + b + "/../" + a; | |
while (a != (b = a.replace(rel_path_exp, "/"))) a = b | |
} | |
return a.replace(/^\//, "") | |
} | |
function deps(a) { | |
if (!a.unmet) { | |
var b = a + "", | |
c, d = a.unmet = {}; | |
require_exp.lastIndex = 0; | |
while (c = require_exp.exec(b)) d[c[1]] = 1 | |
} | |
return a.unmet | |
} | |
function ready(a) { | |
if (typeof a == "object") return !0; | |
var b, c = {}, | |
d = deps(a), | |
e; | |
for (e in d) exported[e] || installed[e] ? c[e] = 1 : b = 1; | |
for (e in c) delete d[e]; | |
if (b) { | |
log("missing modules:"); | |
for (e in d) log(e) | |
} | |
return !b | |
} | |
function log() { | |
try { | |
var a = global.console; | |
a && a.log.apply(a, arguments) | |
} catch (b) {} | |
} | |
function flushQueue() { | |
if (!flushing) try { | |
while (qhead !== qtail && ready(qhead.next)) flushing = qhead, qhead = qhead.next, delete flushing.next, rec("loader.flushQueue", "Start"), qhead(demand), rec("loader.flushQueue", "Finish") | |
} finally { | |
flushing = 0 | |
} | |
} | |
function rec() { | |
var a = global; | |
return a.log && a.log.enabled && a.log.apply(a.log, arguments), history[history.length] = { | |
time: +(new Date), | |
tags: history.slice.call(arguments) | |
} | |
} | |
var history = [], | |
installed = {}, | |
exported = {}, | |
qhead = {}, | |
qtail = qhead, | |
flushing, | |
require_exp = /require\(['"]([^'"]+)['"]\)/g, | |
rel_path_exp = /\/(\.?|[^\/]+\/\.\.)\//; | |
/** | |
install | |
require.install("ModuleName", function(require,exports,module) { | |
// do something here. | |
}); | |
*/ | |
require.install = function(a, b) { | |
rec("loader.install" + (b.lazy ? ".lazy" : ""), "Installing", a); | |
var c = typeof b == "object" ? exported : installed; | |
c[a] || (c[a] = b, flushQueue()) | |
}, | |
require.installLazy = function(id, code) { | |
var module = function(require, exports, module) { | |
window._evalCallArgs = arguments, eval("(function(require,exports,module){" + code + "//*/\n}).apply(window, window._evalCallArgs)") | |
}; | |
module.lazy = !0, require.install(id, module) | |
}, | |
require.enqueue = function(a) { | |
qtail = qtail.next = a, qhead.next === qtail && ready(a) && flushQueue() | |
}, | |
rec.dump = function() { | |
return history.slice() | |
}, | |
global.rec = rec, | |
global.require = require, | |
rec("loader", "Ready") | |
}(this);; | |
require.install("settings", { | |
revision: "99be23d8daabf3043010c932ca4869ab2f7f77e5", | |
installTime: rec("settings", "install").time, | |
instance: "main", | |
formkey: "78c9577db4c08a4fd6c9864ed77ffd9a", | |
uid: null, | |
controller: "index", | |
action: "index", | |
codebaseType: "production", | |
cookiePrefix: "m", | |
trail: null, | |
actionTrail: null, | |
mobile: false, | |
serverCallUrl: "/webnode2/server_call_POST?__instart__", | |
paraServerCallUrl: "/webnode2/server_call_parallel_POST?__instart__", | |
scribeSampleRate: 0.500000, | |
pageMode: "live" || "live", | |
feedAnchoring: false, | |
requireBase: "https://qsc.is.quoracdn.net/-9547b40429286f29/", | |
debug: false, | |
componentDebug: false, | |
appURL: null, | |
fbAppId: "136609459636", | |
mobileRedirect: false, | |
enableFrameBusting: true, | |
keyboardShortcuts: false, | |
isParallel: true, | |
client_side_js_load_delays_enabled: true, | |
client_side_logging: false, | |
client_side_server_call_error_notifications: false, | |
client_side_server_call_error_logging_percentage: 0, | |
subdomain_name: null, | |
subdomain_suffix: "quora.com", | |
default_uri_subdomain_name: null, | |
force_use_absolute_links: false | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment