diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-17 12:12:22 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-17 12:12:22 +0300 |
| commit | 68fc9e55e538e03f94509731ab41a0c8cf96710f (patch) | |
| tree | 3edb1e81864ac3eb35ba0fe8087ed24da1b812bf /html/assets/js/require/require.slim.js | |
| parent | 84b2da85a1b452922dadb6a609533b9945afe51d (diff) | |
| download | classroom-68fc9e55e538e03f94509731ab41a0c8cf96710f.tar.gz classroom-68fc9e55e538e03f94509731ab41a0c8cf96710f.tar.bz2 classroom-68fc9e55e538e03f94509731ab41a0c8cf96710f.zip | |
setup a real server environment (apache DocumentRoot=/var/www/public)
Diffstat (limited to 'html/assets/js/require/require.slim.js')
| -rw-r--r-- | html/assets/js/require/require.slim.js | 492 |
1 files changed, 0 insertions, 492 deletions
diff --git a/html/assets/js/require/require.slim.js b/html/assets/js/require/require.slim.js deleted file mode 100644 index f42cea6..0000000 --- a/html/assets/js/require/require.slim.js +++ /dev/null @@ -1,492 +0,0 @@ -(function (requireFiles) { - var require, _helpers = { - isFunction: function (obj) { - return typeof (obj) == 'function'; - }, - isArray: isArraylike - }; - if (typeof (window.require) != 'undefined') { - return; - } - - function isArraylike(obj) { - return Array.isArray(obj); - } - - function ModulesConfiguration(versions, modules) { - this.modules = modules || {}; - this.modulePaths = {}; - - for (var i = 0; i < versions.length; i++) { - var v = versions[i]; - for (var k in v) { - var moduleName = k; - var url = v[k]; - if (typeof (url) == 'object') { - this.modulePaths[moduleName] = url.Url; - continue; - } - this.modulePaths[moduleName] = url; - } - } - this.updateState = function (state, moduleDependencies, callback) { - var config = this, i = 0; - if (!Array.isArray(moduleDependencies)) { - moduleDependencies = [moduleDependencies]; - } - state.moduleDependencies = moduleDependencies; - state.dependencies = moduleDependencies.filter(function (x) { - return x && x.indexOf('exports') === -1 && x.indexOf('require') === -1; - }).map(function (x) { - return config.getOrCreateState(x); - }); - state.loaded = true; - state.readyCallback = function () { - state.ready = true; - if (callback && typeof callback === 'function') { - state.object = invokeCallback(callback, state.moduleDependencies, state.name); - document.dispatchEvent(new CustomEvent("require.moduleLoaded", { detail: state })); - } - }; - - state.readyCheck && state.readyCheck(); - if (state.dependencies.length) { - for (; i < state.dependencies.length; i++) { - state.dependencies[i].callbacks.push(function () { - state.readyCheck && state.readyCheck(); - }); - } - require( - state.dependencies.map(function (x) { return x.name }), - function () { - state.readyCheck && state.readyCheck(); - } - ); - } - } - - this.getOrCreateState = function (moduleName, ignoreWarnings) { - var state = window.define.amd.getProp(moduleName); - if (!state) { - window.define.amd[moduleName] = state = this.createState(moduleName, ignoreWarnings); - } - - return state; - } - this.createState = function (moduleName, ignoreWarnings) { - var url = this.modulePaths.getProp(this.modules[moduleName] || moduleName); - if (!url && !ignoreWarnings) { - console.warn( - "%c Module '%s' path is not present. Define it using the global '__requireFiles' variable", - [ 'background: orange', 'color: black', 'display: block', 'text-align: center', 'font-size: 14px', 'font-weight: 600'].join(';'), - moduleName - ); - } - return { - url: this.modulePaths.getProp(this.modules[moduleName] || moduleName), - name: moduleName, - loaded: false, - callbacks: [], - ready: false, - dependencies: [], - doCallBacks: function () { - for (var i = 0; i < this.callbacks.length; i++) { - this.callbacks[i].apply(this, []); - } - this.callbacks = []; - }, - removeReadyDependencies: function () { - this.dependencies = this.dependencies.filter(function (x) { return !x.ready; }); - }, - readyCheck: function () { - this.removeReadyDependencies(); - if (!this.dependencies.length && this.loaded) { - if (!this.ready) { - if (this.readyCallback) { - this.readyCallback.apply(this, []); - } else { - this.ready = true; - } - this.doCallBacks(); - } - } - }, - hasUrl: function () { - if (!this.url) { - return false; - } - return true; - }, - callPending: function () { - this.pending = true; - }, - callDone: function () { - if (!this.loaded) { - completeDefine(this.name); - if (!this.loaded) { - console.warn('should be loaded'); - } - } - } - }; - } - } - - var debug = false; - var config = new ModulesConfiguration( - requireFiles || [] - ); - - Object.defineProperty(Object.prototype, "getProp", { - value: function (prop) { - if (!prop || (typeof (prop) !== typeof ('') && !(prop instanceof String))) { - console.warn('invalid property access', prop, this); - return null; - } - var key, self = this; - for (key in self) { - if (key.toLowerCase() === prop.toLowerCase()) { - return self[key]; - } - } - }, - //this keeps jquery happy - enumerable: false - }); - - - - function invokeCallback(callback, moduleNames, exportsName) { - var callbackArguments = [], - resultFactory = function (r) { return r; }, - e, i = 0, state, result; - for (; i < moduleNames.length; i++) { - switch (moduleNames[i]) { - case 'exports': - if (!window.exports) { - window.exports = {}; - } - e = window.exports[exportsName]; - if (!e) { - e = window.exports[exportsName] = {}; - } - resultFactory = function () { return e; }; - callbackArguments.push(e); - break; - case 'require': - callbackArguments.push(require); - break; - default: - state = config.getOrCreateState(moduleNames[i]); - callbackArguments.push(state.object); - } - } - result = callback.apply(window, callbackArguments); - return resultFactory(result); - } - - function TaskWatcher(callback, moduleNames) { - var self = this; - //moduleNames = config.bundle(moduleNames); - this.pendingModules = getPendingStates(moduleNames); - this.check = function () { - if (this.finished) { - return true; - } - if (!this.pendingModules.filter(function (x) { return !x.ready; }).length) { - this.done(); - return true; - } - return false; - }; - this.done = function () { - var s = moduleNames.map(function (x) { return config.getOrCreateState(x); }), - i = 0, - state; - this.finished = true; - for (; i < s.length; i++) { - state = s[i]; - state.readyCheck && state.readyCheck(); - } - callback(); - if (debug) { - console.debug('done', moduleNames); - } - } - - function getPendingStates(moduleNames) { - var pendingStates = [], script, state, i = 0; - for (; i < moduleNames.length; i++) { - script = moduleNames[i]; - state = config.getOrCreateState(script); - if (!state.ready) { - state.callbacks.push(function () { - self.check(); - }); - pendingStates.push(state); - } - } - return pendingStates; - } - } - - - function getScriptCached (url, callback) { - var d = document, t = 'script', - o = d.createElement(t), - s = d.getElementsByTagName(t)[0]; - o.src = url; - o.defer = true; - if (callback) { - o.addEventListener('load', function (e) { - if (debug) { - console.debug('loaded script', url, e); - } - callback(null, e); - }, false); - } else { - console.warn('loading script without callback', url); - } - - s.parentNode.insertBefore(o, s); - } - - window.require = require = function require (moduleNames, callback) { - var i = 0, watcher, pendingStates; - if (typeof (moduleNames) === typeof ('') || moduleNames instanceof String) { - moduleNames = [moduleNames]; - } - callback = (function (cb, moduleNames) { - return function () { - invokeCallback(cb, moduleNames); - } - })(callback, moduleNames); - watcher = new TaskWatcher(callback, moduleNames); - if (watcher.check()) { - return; - } - - pendingStates = watcher.pendingModules.filter(function (x) { return x.hasUrl() && !x.pending }); - if (!pendingStates.length) { - return; - } - - for (; i < pendingStates.length; i++) { - fetchIfNeeded(pendingStates[i]); - } - - function fetchIfNeeded(state){ - if (state.loaded && !state.ready) { - state.callbacks.push(function () { - watcher.check(); - }); - } else { - state.callPending(); - getScriptCached(state.url, function () { - state.callDone(); - }); - } - } - - }; - - require.getScriptCached = getScriptCached; - - require.getStyleSheet = function getStyleSheet(path, fn, scope) { - var head = document.getElementsByTagName('head')[0], // reference to document.head for appending/ removing link nodes - link = document.createElement('link'); // create the link node - link.setAttribute('href', path); - link.setAttribute('rel', 'stylesheet'); - link.setAttribute('type', 'text/css'); - - var sheet, cssRules; - // get the correct properties to check for depending on the browser - if ('sheet' in link) { - sheet = 'sheet'; cssRules = 'cssRules'; - } else { - sheet = 'styleSheet'; cssRules = 'rules'; - } - - var interval_id = setInterval(function () { // start checking whether the style sheet has successfully loaded - try { - if (link[sheet] && link[sheet][cssRules].length) { // SUCCESS! our style sheet has loaded - clearInterval(interval_id); // clear the counters - clearTimeout(timeout_id); - fn.call(scope || window, true, link); // fire the callback with success == true - } - } catch (e) { } finally { } - }, 10), // how often to check if the stylesheet is loaded - timeout_id = setTimeout(function () { // start counting down till fail - clearInterval(interval_id); // clear the counters - clearTimeout(timeout_id); - head.removeChild(link); // since the style sheet didn't load, remove the link node from the DOM - fn.call(scope || window, false, link); // fire the callback with success == false - }, 15000); // how long to wait before failing - - head.appendChild(link); // insert the link node into the DOM and start loading the style sheet - - return link; // return the link node; - } - - require.resource = function (scripts, callback) { - if (!_helpers.isArray(scripts)) { - scripts = [scripts]; - } - function flattenArray(arr) { - if (!_helpers.isArray(arr)) { - return arr; - } - - return arr.map(function (n) { - return flattenArray(n) - }); - } - scripts = flattenArray(scripts).reverse(); - if (typeof (scripts) == 'undefined') { - console.error('require.resource called without scripts', arguments); - return; - } - function next() { - if (!scripts.length) { - callback && callback(); - return; - } - - if (!_helpers.loadedScripts) { - _helpers.loadedScripts = []; - } - if (!_helpers.loadingScriptCallbacks) { - _helpers.loadingScriptCallbacks = {}; - } - - var script = scripts.pop(); - var css = script.indexOf('.css') !== -1; - - var originalScript = script; - if (script.indexOf('~/') === 0) { - script = script.replace('~/', $siteRoot()); - } - - if (_helpers.loadingScriptCallbacks[script]) { - _helpers.loadingScriptCallbacks[script].push(function () { - next(); - }); - return; - } - - if (!css) { - if (document.querySelector('script[src="' + script + '"]') || _helpers.loadedScripts.indexOf(script) !== -1) { - next(); - return; - } - } else { - if (document.querySelector('link[href="' + script + '"]') || _helpers.loadedScripts.indexOf(script) !== -1) { - next(); - return; - } - } - - _helpers.loadingScriptCallbacks[script] = [function () { - next(); - }]; - - function done() { - _helpers.loadedScripts.push(script); - document.dispatchEvent(new CustomEvent("require.scriptLoaded", { detail: originalScript })); - for (var i = 0; i < _helpers.loadingScriptCallbacks[script].length; i++) { - _helpers.loadingScriptCallbacks[script][i](); - } - delete _helpers.loadingScriptCallbacks[script]; - } - - if (css) { - require.getStyleSheet(script, function () { - done(); - }); - } - else { - require.getScriptCached(script, function () { - done(); - }); - } - } - next(); - }; - - function getModuleName(url) { - var u = url; - u = u.substring(u.lastIndexOf('/') + 1); - u = u.substring(0, u.lastIndexOf('.')); - return u; - } - - function completeDefine(moduleName) { - if (typeof (_helpers._pendingDefinition) === 'undefined') { - define(moduleName, [], function () { }); - return; - } - var moduleDependencies = _helpers._pendingDefinition.moduleDependencies; - var callback = _helpers._pendingDefinition.callback; - delete _helpers._pendingDefinition; - var state = config.getOrCreateState(moduleName, true); - config.updateState(state, moduleDependencies, callback); - } - - window.define = function (moduleName, moduleDependencies, callback) { - if (typeof (moduleName) === "string") { - if (_helpers.isFunction(moduleDependencies)) { - callback = moduleDependencies; - moduleDependencies = []; - } - } else if (_helpers.isArray(moduleName)) { - callback = moduleDependencies; - moduleDependencies = moduleName; - moduleName = null; - } else if (_helpers.isFunction(moduleName)) { - callback = moduleName; - moduleDependencies = []; - moduleName = null; - } - if (debug) - console.log('define', moduleName, moduleDependencies); - - _helpers._pendingDefinition = { - moduleDependencies: moduleDependencies, - callback: callback - }; - // if (moduleName == null && document.currentScript){ - // try { - // moduleName = getModuleName(document.currentScript.src); - // if (moduleName.indexOf(".min") === moduleName.length - 4){ - // moduleName = moduleName.substring(0, moduleName.length - 4); - // } - // } catch (e) { - // console && console.warn("Could not resolve current script"); - // } - // - // } - if (moduleName != null) { - completeDefine(moduleName); - } - - - } - window.define.amd = window.define && window.define.amd ? window.define.amd : {}; - - window.define.pendingModules = function () { - var states = []; - for (var k in window.define.amd) { - states.push(window.define.amd[k]); - } - - return { - blocked: states.filter(function (x) { - return (x.pending && !x.ready) || - (x.dependencies || []).filter(function (d) { return !d.ready; }).length; - }), - missing: states.filter(function (x) { - return !x.loaded; - }) - }; - } -})(window.__requireFiles);
\ No newline at end of file |
