main app code and some default modules
This commit is contained in:
parent
eb0285789f
commit
abd2dadb45
7 changed files with 407 additions and 0 deletions
9
www/css/app.css
Normal file
9
www/css/app.css
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
/* Tip: Use "@import" to add styles instead of adding <link>'s in your
|
||||
HTML, and volo will inline it when building for production */
|
||||
|
||||
/* Styles for the installation button */
|
||||
@import "install-button.css";
|
||||
|
||||
/* Your styles here */
|
||||
|
||||
20
www/css/install-button.css
Normal file
20
www/css/install-button.css
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#install-btn {
|
||||
background: #0088cc; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #0088cc 0%, #0055cc 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0088cc), color-stop(100%,#0055cc)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #0088cc 0%,#0055cc 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #0088cc 0%,#0055cc 100%); /* Opera 11.10+ */
|
||||
background: -ms-linear-gradient(top, #0088cc 0%,#0055cc 100%); /* IE10+ */
|
||||
background: linear-gradient(to bottom, #0088cc 0%,#0055cc 100%); /* W3C */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0088cc', endColorstr='#0055cc',GradientType=0 ); /* IE6-9 */
|
||||
|
||||
text-align: center;
|
||||
font-size: 200%;
|
||||
margin: 1em auto;
|
||||
display: block;
|
||||
padding: .5em;
|
||||
color: white;
|
||||
width: 10em;
|
||||
max-width: 80%;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
145
www/js/app.js
Normal file
145
www/js/app.js
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
|
||||
require.config({
|
||||
baseUrl: 'js/lib',
|
||||
paths: {'jquery':
|
||||
['//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min',
|
||||
'jquery']},
|
||||
|
||||
});
|
||||
|
||||
|
||||
// This uses require.js to structure javascript:
|
||||
// http://requirejs.org/docs/api.html#define
|
||||
|
||||
define(function(require) {
|
||||
|
||||
// jQuery
|
||||
var $ = require("jquery");
|
||||
//var $ = require("http://code.jquery.com/jquery-1.7.1.min.js");
|
||||
|
||||
// Need to verify receipts? This library is included by default.
|
||||
// https://github.com/mozilla/receiptverifier
|
||||
require('receiptverifier');
|
||||
|
||||
// Want to install the app locally? This library hooks up the
|
||||
// installation button. See <button class="install-btn"> in
|
||||
// index.html
|
||||
require('./install-button');
|
||||
|
||||
|
||||
// Return the handler on an object in the SVG clock, given its id.
|
||||
function getLayer( id )
|
||||
{
|
||||
console.assert( id != null );
|
||||
console.assert( id != "" );
|
||||
var svgTag = document.getElementById( "clockical" );
|
||||
console.assert( svgTag != null );
|
||||
var svgDoc = svgTag.getSVGDocument();
|
||||
console.assert( svgDoc != null );
|
||||
var layer = svgDoc.getElementById(id);
|
||||
console.assert( layer != null );
|
||||
//console.debug("Layer ",layer);
|
||||
return layer;
|
||||
}
|
||||
|
||||
// Apply a given transformation on a hand (rotation, scale)
|
||||
// and translate it to the center.
|
||||
function updateHand( id, angle, width, scale )
|
||||
{
|
||||
console.assert( id != null );
|
||||
console.assert( id != "" );
|
||||
console.assert( angle >= 0 && angle <= 360 );
|
||||
console.assert( width > 0 );
|
||||
console.assert( scale > 0 );
|
||||
|
||||
// FIXME use the rotation center
|
||||
var offset = width * scale / 2;
|
||||
|
||||
console.debug( "Update", id, "to", angle, "°+", offset, "*", scale );
|
||||
|
||||
var layer = getLayer( id );
|
||||
|
||||
// NOTE: the order of the transformations is important!
|
||||
layer.setAttribute('transform',
|
||||
'translate('+ offset +','+ offset +') '
|
||||
+ 'rotate('+ angle +')'
|
||||
+ 'scale('+ scale +') '
|
||||
);
|
||||
}
|
||||
|
||||
// Apply a scale transformation on all given layers (defaults to the known ones).
|
||||
// Do not scale the hand, this is done in the updateHand function.
|
||||
function scaleAll( scale, layers = ["clock","numbers","glass"] )
|
||||
{
|
||||
console.assert( scale > 0 );
|
||||
console.assert( layers.length >= 1 );
|
||||
|
||||
console.debug( "Scale *",scale, "for", layers );
|
||||
|
||||
for(var i=0,len=layers.length; img=layers[i], i<len; i++) {
|
||||
var layer = getLayer( img );
|
||||
layer.setAttribute('transform', 'scale('+scale+')');
|
||||
} // for img
|
||||
}
|
||||
|
||||
// Change attributes of the clock SVG, given a new theme and size.
|
||||
function loadClock( theme, width, scale )
|
||||
{
|
||||
console.assert( theme != "" );
|
||||
console.assert( width > 0 );
|
||||
console.assert( scale > 0 );
|
||||
|
||||
var offset = width * scale / 2;
|
||||
|
||||
console.debug( "Load clock", theme,"+", offset, "*", scale, "x", width );
|
||||
|
||||
var svgTag = document.getElementById( "clockical" );
|
||||
console.assert( svgTag != null );
|
||||
|
||||
svgTag.setAttribute( 'data', 'img/themes/'+ theme +'.svg' );
|
||||
svgTag.setAttribute( 'style', 'position:absolute;top:'+ offset +'px;left:'+ offset +'px;' );
|
||||
svgTag.setAttribute( 'width', ''+ width * scale );
|
||||
}
|
||||
|
||||
// When document is ready, configure the clock SVG
|
||||
// and add the update function to be called every minute.
|
||||
(function($) {
|
||||
$(document).ready( function() {
|
||||
|
||||
var _width = 100;
|
||||
var _scale = 4;
|
||||
|
||||
function tick()
|
||||
{
|
||||
var now = new Date();
|
||||
var seconds = now.getSeconds();
|
||||
var minutes = now.getMinutes();
|
||||
var hours = now.getHours() + minutes / 60;
|
||||
|
||||
a0 = 90; // angle offset between axis and a clock
|
||||
tn = 24; // ticks number
|
||||
|
||||
console.assert( 0 <= seconds && seconds <= 60 );
|
||||
console.assert( 0 <= minutes && minutes <= 60 );
|
||||
console.assert( 0 <= hours && hours <= 24 );
|
||||
console.assert( 0 <= a0 && a0 <= 360 );
|
||||
console.assert( tn == 12 || tn == 24 );
|
||||
|
||||
console.debug( "===== Tick =====\n", hours, "h ", minutes, "m", seconds, "s /", tn, "@", a0 );
|
||||
|
||||
updateHand("hand_seconds", seconds * 6 - a0, _width, _scale );
|
||||
updateHand("hand_minutes", minutes * 6 - a0, _width, _scale );
|
||||
updateHand("hand_hours", hours * 360/tn - a0, _width, _scale );
|
||||
|
||||
scaleAll( _scale ); // we need to scale every second (not sure to know why)
|
||||
}
|
||||
|
||||
loadClock('default', _width, _scale );
|
||||
//tick(); // FIXME cannot do a first update??
|
||||
setInterval( tick, 1000 ); // every second
|
||||
//setInterval( tick, 60000 ); // every minute
|
||||
|
||||
}); // document ready
|
||||
})(jQuery);
|
||||
});
|
||||
|
||||
5
www/js/init.js
Normal file
5
www/js/init.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
require.config({
|
||||
baseUrl: 'js/lib'
|
||||
});
|
||||
|
||||
requirejs(['../app']);
|
||||
41
www/js/install-button.js
Normal file
41
www/js/install-button.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
define(function(require) {
|
||||
var install = require('install');
|
||||
|
||||
function update() {
|
||||
var btn = document.getElementById('install-btn');
|
||||
if(install.state == 'uninstalled') {
|
||||
btn.style.display = 'block';
|
||||
}
|
||||
else if(install.state == 'installed' || install.state == 'unsupported') {
|
||||
btn.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
var btn = document.getElementById('install-btn');
|
||||
btn.addEventListener('click', function() {
|
||||
install();
|
||||
});
|
||||
|
||||
install.on('change', update);
|
||||
|
||||
install.on('error', function(e, err) {
|
||||
// Feel free to customize this
|
||||
alert('There was an error during installation.');
|
||||
});
|
||||
|
||||
install.on('showiOSInstall', function() {
|
||||
// Feel free to customize this
|
||||
alert('To install, press the forward arrow in Safari ' +
|
||||
'and touch "Add to Home Screen"');
|
||||
});
|
||||
}
|
||||
|
||||
if(!document.getElementById('install-btn')) {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
}
|
||||
else {
|
||||
init();
|
||||
}
|
||||
});
|
||||
153
www/js/lib/install.js
Normal file
153
www/js/lib/install.js
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
/*jslint nomen: true */
|
||||
/*global define, navigator, location, window, chrome */
|
||||
|
||||
define(function (require) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Detects if the current app has been installed.
|
||||
*
|
||||
* See https://github.com/wavysandbox/install/blob/master/README.md
|
||||
* for details on how to use.
|
||||
*
|
||||
*/
|
||||
function install() {
|
||||
var fn = install[install.type + 'Install'];
|
||||
if (fn) {
|
||||
fn();
|
||||
} else {
|
||||
install.trigger('error', 'unsupported install: ' + install.type);
|
||||
}
|
||||
}
|
||||
|
||||
function triggerChange(state) {
|
||||
install.state = state;
|
||||
install.trigger('change', install.state);
|
||||
}
|
||||
|
||||
/**
|
||||
* The install state. Values are:
|
||||
* 'unknown': the code has not tried to detect any state.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
install.state = 'unknown';
|
||||
|
||||
install.check = function () {
|
||||
var apps = navigator.mozApps,
|
||||
request;
|
||||
|
||||
if (navigator.mozApps) {
|
||||
//Mozilla web apps
|
||||
install.type = 'mozilla';
|
||||
request = navigator.mozApps.getSelf();
|
||||
request.onsuccess = function () {
|
||||
if (this.result) {
|
||||
triggerChange('installed');
|
||||
} else {
|
||||
triggerChange('uninstalled');
|
||||
}
|
||||
};
|
||||
|
||||
request.onerror = function (err) {
|
||||
// Just console log it, no need to bother the user.
|
||||
install.error = err;
|
||||
triggerChange('error');
|
||||
};
|
||||
|
||||
} else if (typeof chrome !== 'undefined' &&
|
||||
chrome.webstore &&
|
||||
chrome.app) {
|
||||
//Chrome web apps
|
||||
install.type = 'chromeStore';
|
||||
if (chrome.app.isInstalled) {
|
||||
triggerChange('installed');
|
||||
} else {
|
||||
triggerChange('uninstalled');
|
||||
}
|
||||
} else if (typeof window.navigator.standalone !== 'undefined') {
|
||||
install.type = 'ios';
|
||||
if (window.navigator.standalone) {
|
||||
triggerChange('installed');
|
||||
} else {
|
||||
triggerChange('uninstalled');
|
||||
}
|
||||
} else {
|
||||
install.type = 'unsupported';
|
||||
triggerChange('unsupported');
|
||||
}
|
||||
};
|
||||
|
||||
/* Mozilla/Firefox installation */
|
||||
install.mozillaInstallUrl = location.href + 'manifest.webapp';
|
||||
install.mozillaInstall = function () {
|
||||
var installRequest = navigator.mozApps.install(install.mozillaInstallUrl);
|
||||
|
||||
installRequest.onsuccess = function (data) {
|
||||
triggerChange('installed');
|
||||
};
|
||||
|
||||
installRequest.onerror = function (err) {
|
||||
install.error = err;
|
||||
triggerChange('error');
|
||||
};
|
||||
};
|
||||
|
||||
/* Chrome installation */
|
||||
install.chromeInstallUrl = null;
|
||||
install.chromeInstall = function () {
|
||||
chrome.webstore.install(install.chromeInstallUrl,
|
||||
function () {
|
||||
triggerChange('installed');
|
||||
}, function (err) {
|
||||
install.error = err;
|
||||
triggerChange('error');
|
||||
});
|
||||
};
|
||||
|
||||
/* iOS installation */
|
||||
//Right now, just asks that something show a UI
|
||||
//element mentioning how to install using the Safari
|
||||
//"Add to Home Screen" button.
|
||||
install.iosInstall = function () {
|
||||
install.trigger('showiOSInstall', navigator.platform.toLowerCase());
|
||||
};
|
||||
|
||||
//Allow install to do events.
|
||||
var events = {};
|
||||
|
||||
install.on = function(name, func) {
|
||||
events[name] = (events[name] || []).concat([func]);
|
||||
};
|
||||
|
||||
install.off = function(name, func) {
|
||||
if(events[name]) {
|
||||
var res = [];
|
||||
|
||||
for(var i=0, l=events[name].length; i<l; i++) {
|
||||
var f = events[name][i];
|
||||
if(f != func) {
|
||||
res.push();
|
||||
}
|
||||
}
|
||||
|
||||
events[name] = res;
|
||||
}
|
||||
};
|
||||
|
||||
install.trigger = function(name) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
if(events[name]) {
|
||||
for(var i=0, l=events[name].length; i<l; i++) {
|
||||
events[name][i].apply(this, args);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//Start up the checks
|
||||
install.check();
|
||||
|
||||
return install;
|
||||
});
|
||||
34
www/js/lib/require.js
Normal file
34
www/js/lib/require.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
RequireJS 2.1.0 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
||||
Available via the MIT or new BSD license.
|
||||
see: http://github.com/jrburke/requirejs for details
|
||||
*/
|
||||
var requirejs,require,define;
|
||||
(function(U){function D(b){return M.call(b)==="[object Function]"}function E(b){return M.call(b)==="[object Array]"}function s(b,c){if(b){var d;for(d=0;d<b.length;d+=1)if(b[d]&&c(b[d],d,b))break}}function N(b,c){if(b){var d;for(d=b.length-1;d>-1;d-=1)if(b[d]&&c(b[d],d,b))break}}function F(b,c){for(var d in b)if(b.hasOwnProperty(d)&&c(b[d],d))break}function J(b,c,d,h){c&&F(c,function(c,j){if(d||!G.call(b,j))h&&typeof c!=="string"?(b[j]||(b[j]={}),J(b[j],c,d,h)):b[j]=c});return b}function q(b,c){return function(){return c.apply(b,
|
||||
arguments)}}function V(b){if(!b)return b;var c=U;s(b.split("."),function(b){c=c[b]});return c}function H(b,c,d,h){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=h;if(d)c.originalError=d;return c}function aa(){if(I&&I.readyState==="interactive")return I;N(document.getElementsByTagName("script"),function(b){if(b.readyState==="interactive")return I=b});return I}var h,r,u,y,p,A,I,B,W,X,ba=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ca=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
|
||||
Y=/\.js$/,da=/^\.\//;r=Object.prototype;var M=r.toString,G=r.hasOwnProperty,ea=Array.prototype.splice,v=!!(typeof window!=="undefined"&&navigator&&document),Z=!v&&typeof importScripts!=="undefined",fa=v&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,Q=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",w={},n={},O=[],K=!1;if(typeof define==="undefined"){if(typeof requirejs!=="undefined"){if(D(requirejs))return;n=requirejs;requirejs=void 0}typeof require!=="undefined"&&
|
||||
!D(require)&&(n=require,require=void 0);h=requirejs=function(b,c,d,t){var g,j="_";!E(b)&&typeof b!=="string"&&(g=b,E(c)?(b=c,c=d,d=t):b=[]);if(g&&g.context)j=g.context;(t=w[j])||(t=w[j]=h.s.newContext(j));g&&t.configure(g);return t.require(b,c,d)};h.config=function(b){return h(b)};h.nextTick=typeof setTimeout!=="undefined"?function(b){setTimeout(b,4)}:function(b){b()};require||(require=h);h.version="2.1.0";h.jsExtRegExp=/^\/|:|\?|\.js$/;h.isBrowser=v;r=h.s={contexts:w,newContext:function(b){function c(a,
|
||||
f,x){var e,b,k,c,d,i,g,h=f&&f.split("/");e=h;var j=m.map,l=j&&j["*"];if(a&&a.charAt(0)===".")if(f){e=m.pkgs[f]?h=[f]:h.slice(0,h.length-1);f=a=e.concat(a.split("/"));for(e=0;f[e];e+=1)if(b=f[e],b===".")f.splice(e,1),e-=1;else if(b==="..")if(e===1&&(f[2]===".."||f[0]===".."))break;else e>0&&(f.splice(e-1,2),e-=2);e=m.pkgs[f=a[0]];a=a.join("/");e&&a===f+"/"+e.main&&(a=f)}else a.indexOf("./")===0&&(a=a.substring(2));if(x&&(h||l)&&j){f=a.split("/");for(e=f.length;e>0;e-=1){k=f.slice(0,e).join("/");if(h)for(b=
|
||||
h.length;b>0;b-=1)if(x=j[h.slice(0,b).join("/")])if(x=x[k]){c=x;d=e;break}if(c)break;!i&&l&&l[k]&&(i=l[k],g=e)}!c&&i&&(c=i,d=g);c&&(f.splice(0,d,c),a=f.join("/"))}return a}function d(a){v&&s(document.getElementsByTagName("script"),function(f){if(f.getAttribute("data-requiremodule")===a&&f.getAttribute("data-requirecontext")===i.contextName)return f.parentNode.removeChild(f),!0})}function t(a){var f=m.paths[a];if(f&&E(f)&&f.length>1)return d(a),f.shift(),i.require.undef(a),i.require([a]),!0}function g(a){var f,
|
||||
b=a?a.indexOf("!"):-1;b>-1&&(f=a.substring(0,b),a=a.substring(b+1,a.length));return[f,a]}function j(a,f,b,e){var $,k,d=null,h=f?f.name:null,j=a,m=!0,l="";a||(m=!1,a="_@r"+(M+=1));a=g(a);d=a[0];a=a[1];d&&(d=c(d,h,e),k=o[d]);a&&(d?l=k&&k.normalize?k.normalize(a,function(a){return c(a,h,e)}):c(a,h,e):(l=c(a,h,e),a=g(l),d=a[0],l=a[1],b=!0,$=i.nameToUrl(l)));b=d&&!k&&!b?"_unnormalized"+(N+=1):"";return{prefix:d,name:l,parentMap:f,unnormalized:!!b,url:$,originalName:j,isDefine:m,id:(d?d+"!"+l:l)+b}}function n(a){var f=
|
||||
a.id,b=l[f];b||(b=l[f]=new i.Module(a));return b}function p(a,f,b){var e=a.id,c=l[e];if(G.call(o,e)&&(!c||c.defineEmitComplete))f==="defined"&&b(o[e]);else n(a).on(f,b)}function z(a,f){var b=a.requireModules,e=!1;if(f)f(a);else if(s(b,function(f){if(f=l[f])f.error=a,f.events.error&&(e=!0,f.emit("error",a))}),!e)h.onError(a)}function r(){O.length&&(ea.apply(C,[C.length-1,0].concat(O)),O=[])}function u(a,f,b){var e=a.map.id;a.error?a.emit("error",a.error):(f[e]=!0,s(a.depMaps,function(e,k){var c=e.id,
|
||||
d=l[c];d&&!a.depMatched[k]&&!b[c]&&(f[c]?(a.defineDep(k,o[c]),a.check()):u(d,f,b))}),b[e]=!0)}function w(){var a,f,b,e,c=(b=m.waitSeconds*1E3)&&i.startTime+b<(new Date).getTime(),k=[],h=[],g=!1,j=!0;if(!B){B=!0;F(l,function(b){a=b.map;f=a.id;if(b.enabled&&(a.isDefine||h.push(b),!b.error))if(!b.inited&&c)t(f)?g=e=!0:(k.push(f),d(f));else if(!b.inited&&b.fetched&&a.isDefine&&(g=!0,!a.prefix))return j=!1});if(c&&k.length)return b=H("timeout","Load timeout for modules: "+k,null,k),b.contextName=i.contextName,
|
||||
z(b);j&&s(h,function(a){u(a,{},{})});if((!c||e)&&g)if((v||Z)&&!R)R=setTimeout(function(){R=0;w()},50);B=!1}}function y(a){n(j(a[0],null,!0)).init(a[1],a[2])}function A(a){var a=a.currentTarget||a.srcElement,b=i.onScriptLoad;a.detachEvent&&!Q?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=i.onScriptError;a.detachEvent&&!Q||a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}var B,S,i,L,R,m={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},
|
||||
shim:{}},l={},T={},C=[],o={},P={},M=1,N=1;L={require:function(a){return a.require?a.require:a.require=i.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?a.exports:a.exports=o[a.map.id]={}},module:function(a){return a.module?a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){return m.config&&m.config[a.map.id]||{}},exports:o[a.map.id]}}};S=function(a){this.events=T[a.id]||{};this.map=a;this.shim=m.shim[a.id];this.depExports=[];this.depMaps=[];
|
||||
this.depMatched=[];this.pluginMaps={};this.depCount=0};S.prototype={init:function(a,b,c,e){e=e||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=q(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=c;this.inited=!0;this.ignore=e.ignore;e.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,b){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=b)},fetch:function(){if(!this.fetched){this.fetched=
|
||||
!0;i.startTime=(new Date).getTime();var a=this.map;if(this.shim)i.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],q(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=this.map.url;P[a]||(P[a]=!0,i.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,b,c=this.map.id;b=this.depExports;var e=this.exports,d=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);
|
||||
else{if(!this.defining){this.defining=!0;if(this.depCount<1&&!this.defined){if(D(d)){if(this.events.error)try{e=i.execCb(c,d,b,e)}catch(k){a=k}else e=i.execCb(c,d,b,e);if(this.map.isDefine)if((b=this.module)&&b.exports!==void 0&&b.exports!==this.exports)e=b.exports;else if(e===void 0&&this.usingExports)e=this.exports;if(a)return a.requireMap=this.map,a.requireModules=[this.map.id],a.requireType="define",z(this.error=a)}else e=d;this.exports=e;if(this.map.isDefine&&!this.ignore&&(o[c]=e,h.onResourceLoad))h.onResourceLoad(i,
|
||||
this.map,this.depMaps);delete l[c];this.defined=!0}this.defining=!1;if(this.defined&&!this.defineEmitted)this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,d=j(a.prefix);this.depMaps.push(d);p(d,"defined",q(this,function(e){var d,k;k=this.map.name;var x=this.map.parentMap?this.map.parentMap.name:null,g=i.makeRequire(a.parentMap,{enableBuildCallback:!0,skipMap:!0});if(this.map.unnormalized){if(e.normalize&&
|
||||
(k=e.normalize(k,function(a){return c(a,x,!0)})||""),e=j(a.prefix+"!"+k,this.map.parentMap),p(e,"defined",q(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),k=l[e.id]){this.depMaps.push(e);if(this.events.error)k.on("error",q(this,function(a){this.emit("error",a)}));k.enable()}}else d=q(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),d.error=q(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];F(l,function(a){a.map.id.indexOf(b+
|
||||
"_unnormalized")===0&&delete l[a.map.id]});z(a)}),d.fromText=q(this,function(b,e){var f=a.name,c=j(f),k=K;e&&(b=e);k&&(K=!1);n(c);try{h.exec(b)}catch(x){throw Error("fromText eval for "+f+" failed: "+x);}k&&(K=!0);this.depMaps.push(c);i.completeLoad(f);g([f],d)}),e.load(a.name,g,d,m)}));i.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){this.enabling=this.enabled=!0;s(this.depMaps,q(this,function(a,b){var c,e;if(typeof a==="string"){a=j(a,this.map.isDefine?this.map:this.map.parentMap,!1,
|
||||
!this.skipMap);this.depMaps[b]=a;if(c=L[a.id]){this.depExports[b]=c(this);return}this.depCount+=1;p(a,"defined",q(this,function(a){this.defineDep(b,a);this.check()}));this.errback&&p(a,"error",this.errback)}c=a.id;e=l[c];!L[c]&&e&&!e.enabled&&i.enable(a,this)}));F(this.pluginMaps,q(this,function(a){var b=l[a.id];b&&!b.enabled&&i.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){s(this.events[a],function(a){a(b)});
|
||||
a==="error"&&delete this.events[a]}};i={config:m,contextName:b,registry:l,defined:o,urlFetched:P,defQueue:C,Module:S,makeModuleMap:j,nextTick:h.nextTick,configure:function(a){a.baseUrl&&a.baseUrl.charAt(a.baseUrl.length-1)!=="/"&&(a.baseUrl+="/");var b=m.pkgs,c=m.shim,e=m.paths,d=m.map;J(m,a,!0);m.paths=J(e,a.paths,!0);if(a.map)m.map=J(d||{},a.map,!0,!0);if(a.shim)F(a.shim,function(a,b){E(a)&&(a={deps:a});if(a.exports&&!a.exportsFn)a.exportsFn=i.makeShimExports(a);c[b]=a}),m.shim=c;if(a.packages)s(a.packages,
|
||||
function(a){a=typeof a==="string"?{name:a}:a;b[a.name]={name:a.name,location:a.location||a.name,main:(a.main||"main").replace(da,"").replace(Y,"")}}),m.pkgs=b;F(l,function(a,b){if(!a.inited&&!a.map.unnormalized)a.map=j(b)});if(a.deps||a.callback)i.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(U,arguments));return b||V(a.exports)}},makeRequire:function(a,f){function d(e,c,k){var g,m;if(f.enableBuildCallback&&c&&D(c))c.__requireJsBuild=!0;
|
||||
if(typeof e==="string"){if(D(c))return z(H("requireargs","Invalid require call"),k);if(a&&L[e])return L[e](l[a.id]);if(h.get)return h.get(i,e,a);g=j(e,a,!1,!0);g=g.id;return!G.call(o,g)?z(H("notloaded",'Module name "'+g+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):o[g]}for(r();C.length;)if(g=C.shift(),g[0]===null)return z(H("mismatch","Mismatched anonymous define() module: "+g[g.length-1]));else y(g);i.nextTick(function(){m=n(j(null,a));m.skipMap=f.skipMap;m.init(e,c,k,
|
||||
{enabled:!0});w()});return d}f=f||{};J(d,{isBrowser:v,toUrl:function(b){var f=b.lastIndexOf("."),d=null;f!==-1&&(d=b.substring(f,b.length),b=b.substring(0,f));return i.nameToUrl(c(b,a&&a.id,!0),d)},defined:function(b){b=j(b,a,!1,!0).id;return G.call(o,b)},specified:function(b){b=j(b,a,!1,!0).id;return G.call(o,b)||G.call(l,b)}});if(!a)d.undef=function(b){r();var c=j(b,a,!0),f=l[b];delete o[b];delete P[c.url];delete T[b];if(f){if(f.events.defined)T[b]=f.events;delete l[b]}};return d},enable:function(a){l[a.id]&&
|
||||
n(a).enable()},completeLoad:function(a){var b,c,e=m.shim[a]||{},d=e.exports;for(r();C.length;){c=C.shift();if(c[0]===null){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);y(c)}c=l[a];if(!b&&!o[a]&&c&&!c.inited)if(m.enforceDefine&&(!d||!V(d)))if(t(a))return;else return z(H("nodefine","No define call for "+a,null,[a]));else y([a,e.deps||[],e.exportsFn]);w()},nameToUrl:function(a,b){var c,e,d,g,i,j;if(h.jsExtRegExp.test(a))g=a+(b||"");else{c=m.paths;e=m.pkgs;g=a.split("/");for(i=g.length;i>0;i-=1)if(j=
|
||||
g.slice(0,i).join("/"),d=e[j],j=c[j]){E(j)&&(j=j[0]);g.splice(0,i,j);break}else if(d){c=a===d.name?d.location+"/"+d.main:d.location;g.splice(0,i,c);break}g=g.join("/");g+=b||(/\?/.test(g)?"":".js");g=(g.charAt(0)==="/"||g.match(/^[\w\+\.\-]+:/)?"":m.baseUrl)+g}return m.urlArgs?g+((g.indexOf("?")===-1?"?":"&")+m.urlArgs):g},load:function(a,b){h.load(i,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if(a.type==="load"||fa.test((a.currentTarget||a.srcElement).readyState))I=
|
||||
null,a=A(a),i.completeLoad(a.id)},onScriptError:function(a){var b=A(a);if(!t(b.id))return z(H("scripterror","Script error",a,[b.id]))}};i.require=i.makeRequire();return i}};h({});s(["toUrl","undef","defined","specified"],function(b){h[b]=function(){var c=w._;return c.require[b].apply(c,arguments)}});if(v&&(u=r.head=document.getElementsByTagName("head")[0],y=document.getElementsByTagName("base")[0]))u=r.head=y.parentNode;h.onError=function(b){throw b;};h.load=function(b,c,d){var h=b&&b.config||{},
|
||||
g;if(v)return g=h.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),g.type=h.scriptType||"text/javascript",g.charset="utf-8",g.async=!0,g.setAttribute("data-requirecontext",b.contextName),g.setAttribute("data-requiremodule",c),g.attachEvent&&!(g.attachEvent.toString&&g.attachEvent.toString().indexOf("[native code")<0)&&!Q?(K=!0,g.attachEvent("onreadystatechange",b.onScriptLoad)):(g.addEventListener("load",b.onScriptLoad,!1),g.addEventListener("error",
|
||||
b.onScriptError,!1)),g.src=d,B=g,y?u.insertBefore(g,y):u.appendChild(g),B=null,g;else Z&&(importScripts(d),b.completeLoad(c))};v&&N(document.getElementsByTagName("script"),function(b){if(!u)u=b.parentNode;if(p=b.getAttribute("data-main")){if(!n.baseUrl)A=p.split("/"),W=A.pop(),X=A.length?A.join("/")+"/":"./",n.baseUrl=X,p=W;p=p.replace(Y,"");n.deps=n.deps?n.deps.concat(p):[p];return!0}});define=function(b,c,d){var h,g;typeof b!=="string"&&(d=c,c=b,b=null);E(c)||(d=c,c=[]);!c.length&&D(d)&&d.length&&
|
||||
(d.toString().replace(ba,"").replace(ca,function(b,d){c.push(d)}),c=(d.length===1?["require"]:["require","exports","module"]).concat(c));if(K&&(h=B||aa()))b||(b=h.getAttribute("data-requiremodule")),g=w[h.getAttribute("data-requirecontext")];(g?g.defQueue:O).push([b,c,d])};define.amd={jQuery:!0};h.exec=function(b){return eval(b)};h(n)}})(this);
|
||||
Loading…
Add table
Add a link
Reference in a new issue