mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-03-28 13:39:44 +07:00
* Remove docs folder. This was a redirect from a GitHub pages site that does not appear to be in use. * Rename api folder to api-samples. * Move examples to functional-samples folder. * Move cookbook sample to functional-samples. * Move tutorials to functional-samples folder. * Move mv2 and apps folders to _archive. * Rename tools folder to .repo. * Move reference folder to functional-samples. * Update README. Update README with new relative links for reorg. * Update README.md Co-authored-by: amysteamdev <37001393+AmySteam@users.noreply.github.com> --------- Co-authored-by: amysteamdev <37001393+AmySteam@users.noreply.github.com>
52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
(function() {
|
|
if (!CodeMirror.modeURL) CodeMirror.modeURL = "../mode/%N/%N.js";
|
|
|
|
var loading = {};
|
|
function splitCallback(cont, n) {
|
|
var countDown = n;
|
|
return function() { if (--countDown == 0) cont(); }
|
|
}
|
|
function ensureDeps(mode, cont) {
|
|
var deps = CodeMirror.modes[mode].dependencies;
|
|
if (!deps) return cont();
|
|
var missing = [];
|
|
for (var i = 0; i < deps.length; ++i) {
|
|
if (!CodeMirror.modes.hasOwnProperty(deps[i]))
|
|
missing.push(deps[i]);
|
|
}
|
|
if (!missing.length) return cont();
|
|
var split = splitCallback(cont, missing.length);
|
|
for (var i = 0; i < missing.length; ++i)
|
|
CodeMirror.requireMode(missing[i], split);
|
|
}
|
|
|
|
CodeMirror.requireMode = function(mode, cont) {
|
|
if (typeof mode != "string") mode = mode.name;
|
|
if (CodeMirror.modes.hasOwnProperty(mode)) return ensureDeps(mode, cont);
|
|
if (loading.hasOwnProperty(mode)) return loading[mode].push(cont);
|
|
|
|
var script = document.createElement("script");
|
|
script.src = CodeMirror.modeURL.replace(/%N/g, mode);
|
|
var others = document.getElementsByTagName("script")[0];
|
|
others.parentNode.insertBefore(script, others);
|
|
var list = loading[mode] = [cont];
|
|
var count = 0, poll = setInterval(function() {
|
|
if (++count > 100) return clearInterval(poll);
|
|
if (CodeMirror.modes.hasOwnProperty(mode)) {
|
|
clearInterval(poll);
|
|
loading[mode] = null;
|
|
ensureDeps(mode, function() {
|
|
for (var i = 0; i < list.length; ++i) list[i]();
|
|
});
|
|
}
|
|
}, 200);
|
|
};
|
|
|
|
CodeMirror.autoLoadMode = function(instance, mode) {
|
|
if (!CodeMirror.modes.hasOwnProperty(mode))
|
|
CodeMirror.requireMode(mode, function() {
|
|
instance.setOption("mode", instance.getOption("mode"));
|
|
});
|
|
};
|
|
}());
|