mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 09:37:17 +00:00
Switch to react, progress
This commit is contained in:
parent
75a691503c
commit
7675aa2a55
22 changed files with 428 additions and 1725 deletions
|
|
@ -1,239 +0,0 @@
|
|||
/*!
|
||||
* CleanSlate
|
||||
* github.com/premasagar/cleanslate
|
||||
*
|
||||
*//*
|
||||
An extreme CSS reset stylesheet, for normalising the styling of a container element and its children.
|
||||
|
||||
by Premasagar Rose
|
||||
dharmafly.com
|
||||
|
||||
license
|
||||
opensource.org/licenses/mit-license.php
|
||||
|
||||
**
|
||||
|
||||
v0.9.3
|
||||
|
||||
*/
|
||||
|
||||
/* == BLANKET RESET RULES == */
|
||||
|
||||
/* HTML 4.01 */
|
||||
#winamp2-js, #winamp2-js h1, #winamp2-js h2, #winamp2-js h3, #winamp2-js h4, #winamp2-js h5, #winamp2-js h6, #winamp2-js p, #winamp2-js td, #winamp2-js dl, #winamp2-js tr, #winamp2-js dt, #winamp2-js ol, #winamp2-js form, #winamp2-js select, #winamp2-js option, #winamp2-js pre, #winamp2-js div, #winamp2-js table, #winamp2-js th, #winamp2-js tbody, #winamp2-js tfoot, #winamp2-js caption, #winamp2-js thead, #winamp2-js ul, #winamp2-js li, #winamp2-js address, #winamp2-js blockquote, #winamp2-js dd, #winamp2-js fieldset, #winamp2-js li, #winamp2-js iframe, #winamp2-js strong, #winamp2-js legend, #winamp2-js em, #winamp2-js s, #winamp2-js cite, #winamp2-js span, #winamp2-js input, #winamp2-js sup, #winamp2-js label, #winamp2-js dfn, #winamp2-js object, #winamp2-js big, #winamp2-js q, #winamp2-js font, #winamp2-js samp, #winamp2-js acronym, #winamp2-js small, #winamp2-js img, #winamp2-js strike, #winamp2-js code, #winamp2-js sub, #winamp2-js ins, #winamp2-js textarea, #winamp2-js var, #winamp2-js a, #winamp2-js abbr, #winamp2-js applet, #winamp2-js del, #winamp2-js kbd, #winamp2-js tt, #winamp2-js b, #winamp2-js i, #winamp2-js hr,
|
||||
|
||||
/* HTML5 */
|
||||
#winamp2-js article, #winamp2-js aside, #winamp2-js dialog, #winamp2-js figure, #winamp2-js footer, #winamp2-js header, #winamp2-js hgroup, #winamp2-js menu, #winamp2-js nav, #winamp2-js section, #winamp2-js time, #winamp2-js mark, #winamp2-js audio, #winamp2-js video {
|
||||
background-attachment:scroll;
|
||||
background-color:transparent;
|
||||
background-image:none; /* This rule affects the use of pngfix JavaScript http://dillerdesign.com/experiment/DD_BelatedPNG for IE6, which is used to force the browser to recognise alpha-transparent PNGs files that replace the IE6 lack of PNG transparency. (The rule overrides the VML image that is used to replace the given CSS background-image). If you don't know what that means, then you probably haven't used the pngfix script, and this comment may be ignored :) */
|
||||
background-position:0 0;
|
||||
background-repeat:repeat;
|
||||
border-color:black;
|
||||
border-color:currentColor; /* `border-color` should match font color. Modern browsers (incl. IE9) allow the use of "currentColor" to match the current font 'color' value <http://www.w3.org/TR/css3-color/#currentcolor>. For older browsers, a default of 'black' is given before this rule. Guideline to support older browsers: if you haven't already declared a border-color for an element, be sure to do so, e.g. when you first declare the border-width. */
|
||||
border-radius:0;
|
||||
border-style:none;
|
||||
border-width:medium;
|
||||
box-sizing:content-box;
|
||||
bottom:auto;
|
||||
clear:none;
|
||||
clip:auto;
|
||||
color:inherit;
|
||||
counter-increment:none;
|
||||
counter-reset:none;
|
||||
cursor:auto;
|
||||
direction:inherit;
|
||||
display:inline;
|
||||
float:none;
|
||||
font-family: inherit; /* As with other inherit values, this needs to be set on the root container element */
|
||||
font-size: inherit;
|
||||
font-style:inherit;
|
||||
font-variant:normal;
|
||||
font-weight:inherit;
|
||||
height:auto;
|
||||
left:auto;
|
||||
letter-spacing:normal;
|
||||
line-height:inherit;
|
||||
list-style-type: inherit; /* Could set list-style-type to none */
|
||||
list-style-position: outside;
|
||||
list-style-image: none;
|
||||
margin:0;
|
||||
max-height:none;
|
||||
max-width:none;
|
||||
min-height:0;
|
||||
min-width:0;
|
||||
opacity:1;
|
||||
outline:invert none medium;
|
||||
overflow:visible;
|
||||
padding:0;
|
||||
position:static;
|
||||
quotes: "" "";
|
||||
right:auto;
|
||||
table-layout:auto;
|
||||
text-align:inherit;
|
||||
text-decoration:inherit;
|
||||
text-indent:0;
|
||||
text-transform:none;
|
||||
top:auto;
|
||||
unicode-bidi:normal;
|
||||
vertical-align:baseline;
|
||||
visibility:inherit;
|
||||
white-space:normal;
|
||||
width:auto;
|
||||
word-spacing:normal;
|
||||
z-index:auto;
|
||||
|
||||
/* Proprietary and draft rules */
|
||||
/* This section needs extending */
|
||||
-moz-border-radius:0;
|
||||
-webkit-border-radius:0;
|
||||
-moz-box-sizing: content-box;
|
||||
-webkit-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
/* == BLOCK-LEVEL == */
|
||||
/* Actually, some of these should be inline-block and other values, but block works fine (TODO: rigorously verify this) */
|
||||
/* HTML 4.01 */
|
||||
#winamp2-js, #winamp2-js h3, #winamp2-js h5, #winamp2-js p, #winamp2-js h1, #winamp2-js dl, #winamp2-js dt, #winamp2-js h6, #winamp2-js ol, #winamp2-js form, #winamp2-js select, #winamp2-js option, #winamp2-js pre, #winamp2-js div, #winamp2-js h2, #winamp2-js caption, #winamp2-js h4, #winamp2-js ul, #winamp2-js address, #winamp2-js blockquote, #winamp2-js dd, #winamp2-js fieldset, #winamp2-js hr,
|
||||
/* HTML5 new elements */
|
||||
#winamp2-js article, #winamp2-js aside, #winamp2-js dialog, #winamp2-js figure, #winamp2-js footer, #winamp2-js header, #winamp2-js hgroup, #winamp2-js menu, #winamp2-js nav, #winamp2-js section {
|
||||
display:block;
|
||||
}
|
||||
|
||||
#winamp2-js textarea {
|
||||
display:inline-block;
|
||||
}
|
||||
|
||||
#winamp2-js table {
|
||||
display: table;
|
||||
}
|
||||
#winamp2-js thead {
|
||||
display: table-header-group;
|
||||
}
|
||||
#winamp2-js tbody {
|
||||
display: table-row-group;
|
||||
}
|
||||
#winamp2-js tfoot {
|
||||
display: table-footer-group;
|
||||
}
|
||||
#winamp2-js tr {
|
||||
display: table-row;
|
||||
}
|
||||
#winamp2-js th, #winamp2-js td {
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
}
|
||||
#winamp2-js td[valign=top] {
|
||||
vertical-align: top
|
||||
}
|
||||
#winamp2-js td[valign=bottom] {
|
||||
vertical-align: bottom
|
||||
}
|
||||
/* == SPECIFIC ELEMENTS == */
|
||||
/* Some of these are browser defaults; some are just useful resets */
|
||||
|
||||
#winamp2-js nav ul, #winamp2-js nav ol {
|
||||
list-style-type:none;
|
||||
}
|
||||
#winamp2-js ul, #winamp2-js menu {
|
||||
list-style-type:disc;
|
||||
}
|
||||
#winamp2-js ol {
|
||||
list-style-type:decimal;
|
||||
}
|
||||
#winamp2-js ol ul, #winamp2-js ul ul, #winamp2-js menu ul, #winamp2-js ol menu, #winamp2-js ul menu, #winamp2-js menu menu {
|
||||
list-style-type:circle;
|
||||
}
|
||||
#winamp2-js ol ol ul, #winamp2-js ol ul ul, #winamp2-js ol menu ul, #winamp2-js ol ol menu, #winamp2-js ol ul menu, #winamp2-js ol menu menu, #winamp2-js ul ol ul, #winamp2-js ul ul ul, #winamp2-js ul menu ul, #winamp2-js ul ol menu, #winamp2-js ul ul menu, #winamp2-js ul menu menu, #winamp2-js menu ol ul, #winamp2-js menu ul ul, #winamp2-js menu menu ul, #winamp2-js menu ol menu, #winamp2-js menu ul menu, #winamp2-js menu menu menu {
|
||||
list-style-type:square;
|
||||
}
|
||||
#winamp2-js li {
|
||||
display:list-item;
|
||||
/* Fixes IE7 issue with positioning of nested bullets */
|
||||
min-height:auto;
|
||||
min-width:auto;
|
||||
}
|
||||
#winamp2-js strong {
|
||||
font-weight:bold;
|
||||
}
|
||||
#winamp2-js em {
|
||||
font-style:italic;
|
||||
}
|
||||
#winamp2-js kbd, #winamp2-js samp, #winamp2-js code {
|
||||
font-family:monospace;
|
||||
}
|
||||
#winamp2-js a, #winamp2-js a *, #winamp2-js input[type=submit], #winamp2-js input[type=radio], #winamp2-js input[type=checkbox], #winamp2-js select {
|
||||
cursor:pointer;
|
||||
}
|
||||
#winamp2-js a:hover {
|
||||
text-decoration:underline;
|
||||
}
|
||||
#winamp2-js button, #winamp2-js input[type=submit] {
|
||||
text-align: center;
|
||||
}
|
||||
#winamp2-js input[type=hidden] {
|
||||
display:none;
|
||||
}
|
||||
#winamp2-js abbr[title], #winamp2-js acronym[title], #winamp2-js dfn[title] {
|
||||
cursor:help;
|
||||
border-bottom-width:1px;
|
||||
border-bottom-style:dotted;
|
||||
}
|
||||
#winamp2-js ins {
|
||||
background-color:#ff9;
|
||||
color:black;
|
||||
}
|
||||
#winamp2-js del {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
#winamp2-js blockquote, #winamp2-js q {
|
||||
quotes:none; /* HTML5 */
|
||||
}
|
||||
#winamp2-js blockquote:before, #winamp2-js blockquote:after, #winamp2-js q:before, #winamp2-js q:after, #winamp2-js li:before, #winamp2-js li:after {
|
||||
content:"";
|
||||
}
|
||||
#winamp2-js input, #winamp2-js select {
|
||||
vertical-align:middle;
|
||||
}
|
||||
#winamp2-js select, #winamp2-js textarea, #winamp2-js input {
|
||||
border:1px solid #ccc;
|
||||
}
|
||||
#winamp2-js table {
|
||||
border-collapse:collapse;
|
||||
border-spacing:0;
|
||||
}
|
||||
#winamp2-js hr {
|
||||
display:block;
|
||||
height:1px;
|
||||
border:0;
|
||||
border-top:1px solid #ccc;
|
||||
margin:1em 0;
|
||||
}
|
||||
#winamp2-js *[dir=rtl] {
|
||||
direction: rtl;
|
||||
}
|
||||
#winamp2-js mark {
|
||||
background-color:#ff9;
|
||||
color:black;
|
||||
font-style:italic;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* == ROOT CONTAINER ELEMENT == */
|
||||
/* This contains default values for child elements to inherit */
|
||||
#winamp2-js {
|
||||
font-size: medium;
|
||||
line-height: 1;
|
||||
direction:ltr;
|
||||
text-align:left;
|
||||
font-family: "Times New Roman", Times, serif; /* Override this with whatever font-family is required */
|
||||
color: black;
|
||||
font-style:normal;
|
||||
font-weight:normal;
|
||||
text-decoration:none;
|
||||
list-style-type:disc;
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
<div id='main-window' class='loading stop'>
|
||||
<div id='loading'>Loading...</div>
|
||||
<div id='title-bar' class='selected'>
|
||||
<div id='option'>
|
||||
<ul id='context-menu'>
|
||||
<li><a href='https://github.com/captbaritone/winamp2-js' target='_blank'>Winamp2-js...</a></li>
|
||||
<li class='hr'><hr /></li>
|
||||
<li id='context-play-file'>Play File...</li>
|
||||
<li class='parent'>
|
||||
<ul>
|
||||
<li id='context-load-skin'>Load Skin...</li>
|
||||
<li class='hr'><hr /></li>
|
||||
<li class='skin-select' data-skin-url='https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/base-2.91.wsz'><Base Skin></li>
|
||||
<li class='skin-select' data-skin-url='https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/MacOSXAqua1-5.wsz'>Mac OSX v1.5 (Aqua)</li>
|
||||
<li class='skin-select' data-skin-url='https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/TopazAmp1-2.wsz'>TopazAmp</li>
|
||||
<li class='skin-select' data-skin-url='https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/Vizor1-01.wsz'>Vizor</li>
|
||||
<li class='skin-select' data-skin-url='https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/XMMS-Turquoise.wsz'>XMMS Turquoise </li>
|
||||
<li class='skin-select' data-skin-url='https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/ZaxonRemake1-0.wsz'>Zaxon Remake</li>
|
||||
</ul>
|
||||
Skins
|
||||
</li>
|
||||
<li class='hr'><hr /></li>
|
||||
<li id='context-exit'>Exit</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id='shade-time'>
|
||||
<div id='shade-minus-sign'></div>
|
||||
<div id='shade-minute-first-digit' class='character'></div>
|
||||
<div id='shade-minute-second-digit' class='character'></div>
|
||||
<div id='shade-second-first-digit' class='character'></div>
|
||||
<div id='shade-second-second-digit' class='character'></div>
|
||||
</div>
|
||||
<div id='minimize'></div>
|
||||
<div id='shade'></div>
|
||||
<div id='close'></div>
|
||||
</div>
|
||||
<div class='status'>
|
||||
<div id='clutter-bar'>
|
||||
<div id='button-o'></div>
|
||||
<div id='button-a'></div>
|
||||
<div id='button-i'></div>
|
||||
<div id='button-d'></div>
|
||||
<div id='button-v'></div>
|
||||
</div>
|
||||
<div id='play-pause'></div>
|
||||
<div id='work-indicator'></div>
|
||||
<div id='time'>
|
||||
<div id='minus-sign'></div>
|
||||
<div id='minute-first-digit'></div>
|
||||
<div id='minute-second-digit'></div>
|
||||
<div id='second-first-digit'></div>
|
||||
<div id='second-second-digit'></div>
|
||||
</div>
|
||||
<canvas id='visualizer' width='152' height='32'></canvas>
|
||||
</div>
|
||||
<div class='media-info'>
|
||||
<div id='song-title' class='text'></div>
|
||||
<div id='kbps'></div>
|
||||
<div id='khz'></div>
|
||||
<div class='mono-stereo'>
|
||||
<div id='mono'></div>
|
||||
<div id='stereo'></div>
|
||||
</div>
|
||||
</div>
|
||||
<input id='volume' type='range' min='0' max='100' step='1' value='50' />
|
||||
<input id='balance' type='range' min='-100' max='100' step='2' value='0' />
|
||||
<div class='windows'>
|
||||
<div id='equalizer-button'></div>
|
||||
<div id='playlist-button'></div>
|
||||
</div>
|
||||
<input id='position' type='range' min='0' max='100' step='1' value='0' />
|
||||
<div class='actions'>
|
||||
<div id='previous'></div>
|
||||
<div id='play'></div>
|
||||
<div id='pause'></div>
|
||||
<div id='stop'></div>
|
||||
<div id='next'></div>
|
||||
</div>
|
||||
<div id='eject'></div>
|
||||
<div class='shuffle-repeat'>
|
||||
<div id="shuffle"></div>
|
||||
<div id="repeat"></div>
|
||||
</div>
|
||||
<a id='about' target='_blank' href='https://github.com/captbaritone/winamp2-js'></a>
|
||||
</div>
|
||||
|
|
@ -11,10 +11,12 @@
|
|||
<meta property="og:url" content="http://jordaneldredge.com/projects/winamp2-js/" />
|
||||
<meta property="og:image" content="http://jordaneldredge.com/projects/winamp2-js/preview.png" />
|
||||
<link rel='stylesheet' type='text/css' href='css/page.css' />
|
||||
<link rel='stylesheet' type='text/css' href='css/winamp.css' />
|
||||
<link rel='stylesheet' type='text/css' href='css/context-menu.css' />
|
||||
<link rel='stylesheet' type='text/css' href='css/main-window.css' />
|
||||
<link rel="shortcut icon" sizes="16x16 32x32" href="favicon.ico">
|
||||
</head>
|
||||
<body>
|
||||
<script src="bundle.js"></script>
|
||||
<div id='winamp2-js'></div>
|
||||
<div id='browser-compatibility'>
|
||||
<p>Your browser does not support the features we need</p>
|
||||
|
|
@ -25,6 +27,7 @@
|
|||
-
|
||||
<a href='https://github.com/captbaritone/winamp2-js'>GitHub</a>
|
||||
</p>
|
||||
<script src="bundle.js"></script>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
|
|
|
|||
20
js/constants/FontLookup.js
Normal file
20
js/constants/FontLookup.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Find the sprite position of a given character
|
||||
|
||||
/* TODO: There are too many " " and "_" characters */
|
||||
var FONT_LOOKUP = {
|
||||
'a': [0, 0], 'b': [0, 1], 'c': [0, 2], 'd': [0, 3], 'e': [0, 4], 'f': [0, 5],
|
||||
'g': [0, 6], 'h': [0, 7], 'i': [0, 8], 'j': [0, 9], 'k': [0, 10],
|
||||
'l': [0, 11], 'm': [0, 12], 'n': [0, 13], 'o': [0, 14], 'p': [0, 15],
|
||||
'q': [0, 16], 'r': [0, 17], 's': [0, 18], 't': [0, 19], 'u': [0, 20],
|
||||
'v': [0, 21], 'w': [0, 22], 'x': [0, 23], 'y': [0, 24], 'z': [0, 25],
|
||||
'"': [0, 26], '@': [0, 27], '0': [1, 0], '1': [1, 1],
|
||||
'2': [1, 2], '3': [1, 3], '4': [1, 4], '5': [1, 5], '6': [1, 6], '7': [1, 7],
|
||||
'8': [1, 8], '9': [1, 9], '_': [1, 11], ':': [1, 12],
|
||||
'(': [1, 13], ')': [1, 14], '-': [1, 15], "'": [1, 16], '!': [1, 17],
|
||||
'+': [1, 19], '\\': [1, 20], '/': [1, 21], '[': [1, 22],
|
||||
']': [1, 23], '^': [1, 24], '&': [1, 25], '%': [1, 26], '.': [1, 27],
|
||||
'=': [1, 28], '$': [1, 29], '#': [1, 30], 'Å': [2, 0], 'Ö': [2, 1],
|
||||
'Ä': [2, 2], '?': [2, 3], '*': [2, 4], ' ': [2, 5], '<': [1, 22],
|
||||
'>': [1, 23], '{': [1, 22], '}': [1, 23]
|
||||
};
|
||||
module.exports = FONT_LOOKUP;
|
||||
25
js/constants/WinampConstants.js
Normal file
25
js/constants/WinampConstants.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
var keyMirror = require('keymirror');
|
||||
|
||||
module.exports = keyMirror({
|
||||
SET_VISUALIZATION_COLORS: null,
|
||||
TOGGLE_CONTEXT_MENU: null,
|
||||
MINIMIZE: null,
|
||||
ENABLE_SHADE: null,
|
||||
CLOSE: null,
|
||||
PREVIOUS: null,
|
||||
PLAY: null,
|
||||
PAUSE: null,
|
||||
STOP: null,
|
||||
NEXT: null,
|
||||
LOAD_FILE: null,
|
||||
SET_BALANCE: null,
|
||||
SET_VOLUME: null,
|
||||
TOGGLE_REPEAT: null,
|
||||
TOGGLE_SHUFFLE: null,
|
||||
TOGGLE_DOUBLE: null,
|
||||
TOGGLE_SHADE: null,
|
||||
MOVE_MAIN_WINDOW: null,
|
||||
STEP_MARQUEE: null,
|
||||
MEDIA_IS_LOADING: null,
|
||||
MEDIA_LOADED: null
|
||||
});
|
||||
3
js/dispatcher/AppDispatcher.js
Normal file
3
js/dispatcher/AppDispatcher.js
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var Dispatcher = require('flux').Dispatcher;
|
||||
|
||||
module.exports = new Dispatcher();
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
define([], function() {
|
||||
function el(tagName, attributes, content) {
|
||||
tagName = tagName || 'div';
|
||||
attributes = attributes || {};
|
||||
content = content || [];
|
||||
var tag = document.createElement(tagName);
|
||||
if (typeof content === 'string') {
|
||||
content = [content];
|
||||
}
|
||||
for (var attr in attributes) {
|
||||
tag.setAttribute(attr, attributes[attr]);
|
||||
}
|
||||
for (var i = 0; i < content.length; i++) {
|
||||
if (typeof content[i] === 'string') {
|
||||
tag.appendChild(document.createTextNode(content[i]));
|
||||
} else {
|
||||
tag.appendChild(content[i]);
|
||||
}
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
return el('div', {id: 'main-window', class: 'loading stop'}, [
|
||||
el('div', {id: 'loading'}, 'Loading...'),
|
||||
el('div', {id: 'title-bar', class: 'selected'}, [
|
||||
el('div', {id: 'option'}, [
|
||||
el('ul', {id: 'context-menu'}, [
|
||||
el('li', {}, [
|
||||
el('a', {href: 'https://github.com/captbaritone/winamp2-js', target: '_blank'}, 'Winamp2-js...')
|
||||
]),
|
||||
el('li', {class: 'hr'}, [ el('hr') ]),
|
||||
el('li', {id: 'context-play-file'}, 'Play File...'),
|
||||
el('li', {class: 'parent'}, [
|
||||
el('ul', {}, [
|
||||
el('li', {id: 'context-load-skin'}, 'Load Skin...'),
|
||||
el('li', {class: 'hr'}, [ el('hr') ]),
|
||||
el('li', {'class': 'skin-select', 'data-skin-url': 'https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/base-2.91.wsz'}, '<Base Skin>'),
|
||||
el('li', {'class': 'skin-select', 'data-skin-url': 'https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/MacOSXAqua1-5.wsz'}, 'Mac OSX v1.5 (Aqua)'),
|
||||
el('li', {'class': 'skin-select', 'data-skin-url': 'https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/TopazAmp1-2.wsz'}, 'TopazAmp'),
|
||||
el('li', {'class': 'skin-select', 'data-skin-url': 'https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/Vizor1-01.wsz'}, 'Vizor'),
|
||||
el('li', {'class': 'skin-select', 'data-skin-url': 'https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/XMMS-Turquoise.wsz'}, 'XMMS Turquoise '),
|
||||
el('li', {'class': 'skin-select', 'data-skin-url': 'https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/ZaxonRemake1-0.wsz'}, 'Zaxon Remake')
|
||||
// More here
|
||||
]),
|
||||
'Skins'
|
||||
]),
|
||||
el('li', {class: 'hr'}, [ el('hr') ]),
|
||||
el('li', {id: 'context-exit'}, 'Exit')
|
||||
])
|
||||
]),
|
||||
el('div', {id: 'shade-time'}, [
|
||||
el('div', {id: 'shade-minus-sign'}),
|
||||
el('div', {id: 'shade-minute-first-digit', class: 'character'}),
|
||||
el('div', {id: 'shade-minute-second-digit', class: 'character'}),
|
||||
el('div', {id: 'shade-second-first-digit', class: 'character'}),
|
||||
el('div', {id: 'shade-second-second-digit', class: 'character'})
|
||||
]),
|
||||
el('div', {id: 'minimize'}),
|
||||
el('div', {id: 'shade'}),
|
||||
el('div', {id: 'close'})
|
||||
]),
|
||||
el('div', {class: 'status'}, [
|
||||
el('div', {id: 'clutter-bar'}, [
|
||||
el('div', {id: 'button-o'}),
|
||||
el('div', {id: 'button-a'}),
|
||||
el('div', {id: 'button-i'}),
|
||||
el('div', {id: 'button-d'}),
|
||||
el('div', {id: 'button-v'})
|
||||
]),
|
||||
el('div', {id: 'play-pause'}),
|
||||
el('div', {id: 'work-indicator'}),
|
||||
el('div', {id: 'time'}, [
|
||||
el('div', {id: 'minus-sign'}),
|
||||
el('div', {id: 'minute-first-digit'}),
|
||||
el('div', {id: 'minute-second-digit'}),
|
||||
el('div', {id: 'second-first-digit'}),
|
||||
el('div', {id: 'second-second-digit'})
|
||||
]),
|
||||
el('canvas', {id: 'visualizer', width: '152', height: '32'})
|
||||
]),
|
||||
el('div', {class: 'media-info'}, [
|
||||
el('div', {id: 'song-title', class: 'text'}),
|
||||
el('div', {id: 'kbps'}),
|
||||
el('div', {id: 'khz'}),
|
||||
el('div', {class: 'mono-stereo'}, [
|
||||
el('div', {id: 'mono'}),
|
||||
el('div', {id: 'stereo'})
|
||||
])
|
||||
]),
|
||||
el('input', {id: 'volume', type: 'range', min: '0', max: '100', step: '1', value: '50'}),
|
||||
el('input', {id: 'balance', type: 'range', min: '-100', max: '100', step: '2', value: '0'}),
|
||||
el('div', {class: 'windows'}, [
|
||||
el('div', {id: 'equalizer-button'}),
|
||||
el('div', {id: 'playlist-button'})
|
||||
]),
|
||||
el('input', {id: 'position', type: 'range', min: '0', max: '100', step: '1', value: '0'}),
|
||||
el('div', {class: 'actions'}, [
|
||||
el('div', {id: 'previous'}),
|
||||
el('div', {id: 'play'}),
|
||||
el('div', {id: 'pause'}),
|
||||
el('div', {id: 'stop'}),
|
||||
el('div', {id: 'next'})
|
||||
]),
|
||||
el('div', {id: 'eject'}),
|
||||
el('div', {class: 'shuffle-repeat'}, [
|
||||
el('div', {id: 'shuffle'}),
|
||||
el('div', {id: 'repeat'})
|
||||
]),
|
||||
el('a', {id: 'about', target: 'blank', href: 'https://github.com/captbaritone/winamp2-js'})
|
||||
]);
|
||||
});
|
||||
|
|
@ -6,43 +6,6 @@ define([
|
|||
Font
|
||||
) {
|
||||
return {
|
||||
init: function(winamp) {
|
||||
this.winamp = winamp;
|
||||
this.nodes = {
|
||||
close: document.getElementById('close'),
|
||||
shade: document.getElementById('shade'),
|
||||
buttonD: document.getElementById('button-d'),
|
||||
position: document.getElementById('position'),
|
||||
volumeMessage: document.getElementById('volume-message'),
|
||||
balanceMessage: document.getElementById('balance-message'),
|
||||
positionMessage: document.getElementById('position-message'),
|
||||
songTitle: document.getElementById('song-title'),
|
||||
time: document.getElementById('time'),
|
||||
shadeTime: document.getElementById('shade-time'),
|
||||
shadeMinusSign: document.getElementById('shade-minus-sign'),
|
||||
visualizer: document.getElementById('visualizer'),
|
||||
previous: document.getElementById('previous'),
|
||||
play: document.getElementById('play'),
|
||||
pause: document.getElementById('pause'),
|
||||
stop: document.getElementById('stop'),
|
||||
next: document.getElementById('next'),
|
||||
eject: document.getElementById('eject'),
|
||||
repeat: document.getElementById('repeat'),
|
||||
shuffle: document.getElementById('shuffle'),
|
||||
volume: document.getElementById('volume'),
|
||||
kbps: document.getElementById('kbps'),
|
||||
khz: document.getElementById('khz'),
|
||||
mono: document.getElementById('mono'),
|
||||
stereo: document.getElementById('stereo'),
|
||||
balance: document.getElementById('balance'),
|
||||
workIndicator: document.getElementById('work-indicator'),
|
||||
titleBar: document.getElementById('title-bar'),
|
||||
window: document.getElementById('main-window')
|
||||
};
|
||||
|
||||
this.handle = document.getElementById('title-bar');
|
||||
this.body = this.nodes.window;
|
||||
|
||||
this.textDisplay = new MultiDisplay(this.nodes.songTitle);
|
||||
this.textDisplay.addRegister('songTitle');
|
||||
this.textDisplay.addRegister('position');
|
||||
|
|
@ -54,41 +17,8 @@ define([
|
|||
|
||||
this.textDisplay.startRegisterMarquee('songTitle');
|
||||
|
||||
this._registerListeners();
|
||||
return this;
|
||||
},
|
||||
|
||||
_registerListeners: function() {
|
||||
var self = this;
|
||||
|
||||
this.nodes.close.onclick = function() {
|
||||
self.winamp.close();
|
||||
};
|
||||
|
||||
this.nodes.shade.onclick = function() {
|
||||
self.nodes.window.classList.toggle('shade');
|
||||
};
|
||||
|
||||
this.nodes.buttonD.onmousedown = function() {
|
||||
if (self.nodes.window.classList.contains('doubled')) {
|
||||
self.textDisplay.setRegisterText('message', 'Disable doublesize mode');
|
||||
} else {
|
||||
self.textDisplay.setRegisterText('message', 'Enable doublesize mode');
|
||||
}
|
||||
self.textDisplay.showRegister('message');
|
||||
};
|
||||
|
||||
this.nodes.buttonD.onmouseup = function() {
|
||||
self.textDisplay.showRegister('songTitle');
|
||||
};
|
||||
|
||||
this.nodes.buttonD.onclick = function() {
|
||||
self.winamp.toggleDoubledMode();
|
||||
};
|
||||
|
||||
this.nodes.play.onclick = function() {
|
||||
self.winamp.play();
|
||||
};
|
||||
|
||||
this.nodes.songTitle.onmousedown = function() {
|
||||
self.textDisplay.pauseRegisterMarquee('songTitle');
|
||||
|
|
|
|||
63
js/media.js
63
js/media.js
|
|
@ -1,16 +1,12 @@
|
|||
var WinampStore = require('./stores/WinampStore');
|
||||
var AppDispatcher = require('./dispatcher/AppDispatcher');
|
||||
var WinampConstants = require('./constants/WinampConstants');
|
||||
|
||||
/* Emulate the native <audio> element with Web Audio API */
|
||||
define({
|
||||
var Media = {
|
||||
_context: new (window.AudioContext || window.webkitAudioContext)(),
|
||||
_source: null,
|
||||
_buffer: null,
|
||||
_callbacks: {
|
||||
waiting: function(){},
|
||||
stopWaiting: function(){},
|
||||
playing: function(){},
|
||||
timeupdate: function(){},
|
||||
visualizerupdate: function(){},
|
||||
ended: function(){}
|
||||
},
|
||||
_startTime: 0,
|
||||
_position: 0,
|
||||
_balance: 0,
|
||||
|
|
@ -81,13 +77,16 @@ define({
|
|||
|
||||
// Load from bufferArray
|
||||
loadBuffer: function(buffer, loadedCallback) {
|
||||
AppDispatcher.dispatch({
|
||||
actionType: WinampConstants.MEDIA_IS_LOADING
|
||||
});
|
||||
this.stop();
|
||||
this._callbacks.waiting();
|
||||
|
||||
var loadAudioBuffer = function(audioBuffer) {
|
||||
this._buffer = audioBuffer;
|
||||
AppDispatcher.dispatch({
|
||||
actionType: WinampConstants.MEDIA_LOADED
|
||||
});
|
||||
loadedCallback();
|
||||
this._callbacks.stopWaiting();
|
||||
if (this.autoPlay) {
|
||||
this.play(0);
|
||||
}
|
||||
|
|
@ -131,8 +130,10 @@ define({
|
|||
if (this._playing) {
|
||||
// So we don't get a race condition with _position getting overwritten
|
||||
this.pause();
|
||||
console.log('pause');
|
||||
}
|
||||
if (this._buffer) {
|
||||
console.log('buffer found');
|
||||
this._source = this._context.createBufferSource();
|
||||
this._source.buffer = this._buffer;
|
||||
this._source.connect(this._analyser);
|
||||
|
|
@ -140,9 +141,9 @@ define({
|
|||
|
||||
this._position = typeof position !== 'undefined' ? position : this._position;
|
||||
this._startTime = this._context.currentTime - this._position;
|
||||
console.log('start!', this._source);
|
||||
this._source.start(0, this._position);
|
||||
this._playing = true;
|
||||
this._callbacks.playing();
|
||||
}
|
||||
},
|
||||
pause: function() {
|
||||
|
|
@ -214,11 +215,6 @@ define({
|
|||
// Implement this when we support playlists
|
||||
},
|
||||
|
||||
/* Listeners */
|
||||
addEventListener: function(event, callback) {
|
||||
this._callbacks[event] = callback;
|
||||
},
|
||||
|
||||
seekToTime: function(time) {
|
||||
// Make sure we are within range
|
||||
time = Math.min(time, this.duration());
|
||||
|
|
@ -231,11 +227,11 @@ define({
|
|||
_draw: function() {
|
||||
if (this._playing) {
|
||||
this._updatePosition();
|
||||
this._callbacks.timeupdate();
|
||||
|
||||
// _updatePosition might have stopped the playing
|
||||
if (this._playing) {
|
||||
this._callbacks.visualizerupdate(this._analyser);
|
||||
update();
|
||||
// TODO(captbaritone): Update visualize
|
||||
}
|
||||
}
|
||||
window.requestAnimationFrame(this._draw.bind(this));
|
||||
|
|
@ -249,8 +245,33 @@ define({
|
|||
this.play(0);
|
||||
} else {
|
||||
this.stop();
|
||||
this._callbacks.ended();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function update() {
|
||||
AppDispatcher.dispatch({
|
||||
actionType: WinampConstants.SET_POSITION,
|
||||
position: Media.percentComplete(),
|
||||
secondsElapsed: Media.timeElapsed(),
|
||||
secondsRemaining: Media.timeRemaining()
|
||||
});
|
||||
}
|
||||
|
||||
WinampStore.addChangeListener(function() {
|
||||
var state = WinampStore.get();
|
||||
|
||||
if (state.playing && !Media._playing) {
|
||||
Media.play();
|
||||
}
|
||||
if (!state.playing && Media._playing) {
|
||||
Media.pause();
|
||||
}
|
||||
if (state.secondsElapsed === 0) {
|
||||
Media.stop();
|
||||
}
|
||||
Media.setVolume(state.volume / 100);
|
||||
Media.setBalance(state.balance);
|
||||
});
|
||||
module.exports = Media;
|
||||
|
|
|
|||
|
|
@ -1,45 +1,44 @@
|
|||
// Custom object representing a file
|
||||
// `File` is already a builtin, so we use `MyFile`
|
||||
define([], function(){
|
||||
return function() {
|
||||
this.reader = new FileReader();
|
||||
this.url = null;
|
||||
this.fileReference = null;
|
||||
this.setUrl = function(url){
|
||||
this.url = url;
|
||||
};
|
||||
this.setFileReference = function(fileReference){
|
||||
this.fileReference = fileReference;
|
||||
};
|
||||
this.processBuffer = function(bufferHandler) {
|
||||
if (this.url) {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('GET', this.url, true);
|
||||
oReq.responseType = 'arraybuffer';
|
||||
|
||||
oReq.onload = function() {
|
||||
var arrayBuffer = oReq.response; // Note: not oReq.responseText
|
||||
bufferHandler(arrayBuffer);
|
||||
};
|
||||
|
||||
oReq.send(null);
|
||||
return true;
|
||||
|
||||
} else if (this.fileReference) {
|
||||
this.reader.onload = function(e) {
|
||||
var arrayBuffer = e.target.result;
|
||||
bufferHandler(arrayBuffer);
|
||||
};
|
||||
this.reader.onerror = function(e) {
|
||||
console.error(e);
|
||||
};
|
||||
|
||||
this.reader.readAsArrayBuffer(this.fileReference);
|
||||
return true;
|
||||
}
|
||||
|
||||
console.error('Tried to process an unpopulated file object');
|
||||
return false;
|
||||
};
|
||||
var MyFile = function() {
|
||||
this.reader = new FileReader();
|
||||
this.url = null;
|
||||
this.fileReference = null;
|
||||
this.setUrl = function(url){
|
||||
this.url = url;
|
||||
};
|
||||
});
|
||||
this.setFileReference = function(fileReference){
|
||||
this.fileReference = fileReference;
|
||||
};
|
||||
this.processBuffer = function(bufferHandler) {
|
||||
if (this.url) {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('GET', this.url, true);
|
||||
oReq.responseType = 'arraybuffer';
|
||||
|
||||
oReq.onload = function() {
|
||||
var arrayBuffer = oReq.response; // Note: not oReq.responseText
|
||||
bufferHandler(arrayBuffer);
|
||||
};
|
||||
|
||||
oReq.send(null);
|
||||
return true;
|
||||
|
||||
} else if (this.fileReference) {
|
||||
this.reader.onload = function(e) {
|
||||
var arrayBuffer = e.target.result;
|
||||
bufferHandler(arrayBuffer);
|
||||
};
|
||||
this.reader.onerror = function(e) {
|
||||
console.error(e);
|
||||
};
|
||||
|
||||
this.reader.readAsArrayBuffer(this.fileReference);
|
||||
return true;
|
||||
}
|
||||
|
||||
console.error('Tried to process an unpopulated file object');
|
||||
return false;
|
||||
};
|
||||
};
|
||||
module.exports = MyFile;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
define([], function() {
|
||||
return [
|
||||
module.exports = [
|
||||
{
|
||||
img: 'BALANCE',
|
||||
sprites: [
|
||||
|
|
@ -144,7 +143,7 @@ define([], function() {
|
|||
{selectors: ['#title-bar #close:active'], x: 18, y: 9, width: 9, height: 9},
|
||||
{selectors: ['#clutter-bar'], x: 304, y: 0, width: 8, height: 43},
|
||||
{selectors: ['#clutter-bar.disabled'], x: 312, y: 0, width: 8, height: 43},
|
||||
{selectors: ['#button-o:active', '#button-0:selected'], x: 304, y: 47, width: 8, height: 8},
|
||||
{selectors: ['#button-o:active', '#button-o:selected'], x: 304, y: 47, width: 8, height: 8},
|
||||
{selectors: ['#button-a:active', '#button-a.selected'], x: 312, y: 55, width: 8, height: 7},
|
||||
{selectors: ['#button-i:active', '#button-i.selected'], x: 320, y: 62, width: 8, height: 7},
|
||||
{selectors: ['#button-d:active', '#button-d.selected'], x: 328, y: 69, width: 8, height: 8},
|
||||
|
|
@ -168,4 +167,3 @@ define([], function() {
|
|||
]
|
||||
}
|
||||
];
|
||||
});
|
||||
|
|
|
|||
220
js/skin.js
220
js/skin.js
|
|
@ -1,119 +1,113 @@
|
|||
// Dynamically set the css background images for all the sprites
|
||||
define([
|
||||
'skin-sprites',
|
||||
'font',
|
||||
'visualizer',
|
||||
'vendor/jszip.2.4.0.min'
|
||||
], function(
|
||||
SKIN_SPRITES,
|
||||
Font,
|
||||
Visualizer,
|
||||
JSZip
|
||||
) {
|
||||
return {
|
||||
font: new Font(),
|
||||
init: function(visualizerNode, analyser) {
|
||||
var AppDispatcher = require('./dispatcher/AppDispatcher');
|
||||
var WinampConstants = require('./constants/WinampConstants');
|
||||
|
||||
var JSZip = require('jszip');
|
||||
var SKIN_SPRITES = require('./skin-sprites.js');
|
||||
|
||||
module.exports = {
|
||||
//font: new Font(),
|
||||
init: function(visualizerNode, analyser) {
|
||||
this._createNewStyleNode();
|
||||
//this.visualizer = Visualizer.init(visualizerNode, analyser);
|
||||
return this;
|
||||
},
|
||||
|
||||
// Given a file of an original Winamp WSZ file, set the current skin
|
||||
setSkinByFile: function(file, completedCallback) {
|
||||
this.completedCallback = completedCallback;
|
||||
file.processBuffer(this._setSkinByBuffer.bind(this));
|
||||
},
|
||||
|
||||
// Given a bufferArray containing a Winamp WSZ file, set the current skin
|
||||
// Gets passed as a callback, so don't have access to `this`
|
||||
_setSkinByBuffer: function(buffer) {
|
||||
var zip = new JSZip(buffer);
|
||||
document.getElementById('time').classList.remove('ex');
|
||||
|
||||
var promisedCssRules = SKIN_SPRITES.map(function(spriteObj) {
|
||||
|
||||
var file = this._findFileInZip(spriteObj.img, zip);
|
||||
if (file) {
|
||||
// CSS has to change if this file is present
|
||||
if (spriteObj.img === 'NUMS_EX') {
|
||||
document.getElementById('time').classList.add('ex');
|
||||
}
|
||||
var src = 'data:image/bmp;base64,' + btoa(file.asBinary());
|
||||
return this._spriteCssRule(src, spriteObj);
|
||||
}
|
||||
}, this);
|
||||
|
||||
// Extract sprite images
|
||||
Promise.all(promisedCssRules).then(function(newCssRules) {
|
||||
this._createNewStyleNode();
|
||||
this.visualizer = Visualizer.init(visualizerNode, analyser);
|
||||
return this;
|
||||
},
|
||||
|
||||
// For sprites that tile, we need to use just the sprite, not the whole image
|
||||
_skinSprites: SKIN_SPRITES,
|
||||
|
||||
// Given a file of an original Winamp WSZ file, set the current skin
|
||||
setSkinByFile: function(file, completedCallback) {
|
||||
this.completedCallback = completedCallback;
|
||||
file.processBuffer(this._setSkinByBuffer.bind(this));
|
||||
},
|
||||
|
||||
// Given a bufferArray containing a Winamp WSZ file, set the current skin
|
||||
// Gets passed as a callback, so don't have access to `this`
|
||||
_setSkinByBuffer: function(buffer) {
|
||||
var zip = new JSZip(buffer);
|
||||
document.getElementById('time').classList.remove('ex');
|
||||
|
||||
var promisedCssRules = this._skinSprites.map(function(spriteObj) {
|
||||
|
||||
var file = this._findFileInZip(spriteObj.img, zip);
|
||||
if (file) {
|
||||
// CSS has to change if this file is present
|
||||
if (spriteObj.img === 'NUMS_EX') {
|
||||
document.getElementById('time').classList.add('ex');
|
||||
}
|
||||
var src = 'data:image/bmp;base64,' + btoa(file.asBinary());
|
||||
return this._spriteCssRule(src, spriteObj);
|
||||
}
|
||||
}, this);
|
||||
|
||||
// Extract sprite images
|
||||
Promise.all(promisedCssRules).then(function(newCssRules) {
|
||||
this._createNewStyleNode();
|
||||
var cssRules = newCssRules.join('\n');
|
||||
this.styleNode.appendChild(document.createTextNode(cssRules));
|
||||
this._parseVisColors(zip);
|
||||
if (this.completedCallback !== void 0) {
|
||||
this.completedCallback();
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_parseVisColors: function(zip) {
|
||||
var entries = this._findFileInZip('VISCOLOR.TXT', zip).asText().split('\n');
|
||||
var regex = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/;
|
||||
var colors = [];
|
||||
// changed to a hard number to deal with empty lines at the end...
|
||||
// plus its only meant to be an exact amount of numbers anywayz
|
||||
// - @PAEz
|
||||
for (var i = 0; i < 24; i++) {
|
||||
var matches = regex.exec(entries[i]);
|
||||
if (matches) {
|
||||
colors[i] = 'rgb(' + matches.slice(1, 4).join(',') + ')';
|
||||
} else {
|
||||
console.error('Error in VISCOLOR.TXT on line', i);
|
||||
}
|
||||
var cssRules = newCssRules.join('\n');
|
||||
this.styleNode.appendChild(document.createTextNode(cssRules));
|
||||
this._parseVisColors(zip);
|
||||
if (this.completedCallback !== void 0) {
|
||||
this.completedCallback();
|
||||
}
|
||||
this.visualizer.setColors(colors);
|
||||
},
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_findFileInZip: function(name, zip) {
|
||||
// Note: "."s in file names are actually treated as wildcards
|
||||
return zip.file(new RegExp('(/|^)' + name, 'i'))[0];
|
||||
},
|
||||
|
||||
_createNewStyleNode: function() {
|
||||
if (this.styleNode) {
|
||||
document.head.removeChild(this.styleNode);
|
||||
_parseVisColors: function(zip) {
|
||||
var entries = this._findFileInZip('VISCOLOR.TXT', zip).asText().split('\n');
|
||||
var regex = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/;
|
||||
var colors = [];
|
||||
// changed to a hard number to deal with empty lines at the end...
|
||||
// plus its only meant to be an exact amount of numbers anywayz
|
||||
// - @PAEz
|
||||
for (var i = 0; i < 24; i++) {
|
||||
var matches = regex.exec(entries[i]);
|
||||
if (matches) {
|
||||
colors[i] = 'rgb(' + matches.slice(1, 4).join(',') + ')';
|
||||
} else {
|
||||
console.error('Error in VISCOLOR.TXT on line', i);
|
||||
}
|
||||
this.styleNode = document.createElement('style');
|
||||
document.head.appendChild(this.styleNode);
|
||||
},
|
||||
|
||||
// Given an image URL and coordinates, returns a data url for a sub-section
|
||||
// of that image
|
||||
_spriteCssRule: function(src, spriteObj) {
|
||||
return new Promise(function(resolve) {
|
||||
var imageObj = new Image();
|
||||
imageObj.src = src;
|
||||
|
||||
imageObj.onload = function() {
|
||||
var skinImage = this;
|
||||
var cssRules = '';
|
||||
var canvas = document.createElement('canvas');
|
||||
spriteObj.sprites.forEach(function(sprite) {
|
||||
canvas.height = sprite.height;
|
||||
canvas.width = sprite.width;
|
||||
|
||||
var context = canvas.getContext('2d');
|
||||
context.drawImage(skinImage, -sprite.x, -sprite.y);
|
||||
var value = 'background-image: url(' + canvas.toDataURL() + ')';
|
||||
sprite.selectors.forEach(function(selector) {
|
||||
cssRules += '#winamp2-js ' + selector + '{' + value + '}\n';
|
||||
});
|
||||
});
|
||||
resolve(cssRules);
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
AppDispatcher.dispatch({
|
||||
actionType: WinampConstants.SET_VISUALIZATION_COLORS,
|
||||
colors: colors
|
||||
});
|
||||
},
|
||||
|
||||
_findFileInZip: function(name, zip) {
|
||||
// Note: "."s in file names are actually treated as wildcards
|
||||
return zip.file(new RegExp('(/|^)' + name, 'i'))[0];
|
||||
},
|
||||
|
||||
_createNewStyleNode: function() {
|
||||
if (this.styleNode) {
|
||||
document.head.removeChild(this.styleNode);
|
||||
}
|
||||
this.styleNode = document.createElement('style');
|
||||
document.head.appendChild(this.styleNode);
|
||||
},
|
||||
|
||||
// Given an image URL and coordinates, returns a data url for a sub-section
|
||||
// of that image
|
||||
_spriteCssRule: function(src, spriteObj) {
|
||||
return new Promise(function(resolve) {
|
||||
var imageObj = new Image();
|
||||
imageObj.src = src;
|
||||
|
||||
imageObj.onload = function() {
|
||||
var skinImage = this;
|
||||
var cssRules = '';
|
||||
var canvas = document.createElement('canvas');
|
||||
spriteObj.sprites.forEach(function(sprite) {
|
||||
canvas.height = sprite.height;
|
||||
canvas.width = sprite.width;
|
||||
|
||||
var context = canvas.getContext('2d');
|
||||
context.drawImage(skinImage, -sprite.x, -sprite.y);
|
||||
var value = 'background-image: url(' + canvas.toDataURL() + ')';
|
||||
sprite.selectors.forEach(function(selector) {
|
||||
cssRules += '#winamp2-js ' + selector + '{' + value + '}\n';
|
||||
});
|
||||
});
|
||||
resolve(cssRules);
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
150
js/stores/WinampStore.js
Normal file
150
js/stores/WinampStore.js
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
var AppDispatcher = require('../dispatcher/AppDispatcher');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var WinampConstants = require('../constants/WinampConstants');
|
||||
var assign = require('object-assign');
|
||||
|
||||
var CHANGE_EVENT = 'change';
|
||||
|
||||
var _winamp = {
|
||||
windows: {
|
||||
main: {
|
||||
offset: {left: 0, top: 0}
|
||||
}
|
||||
},
|
||||
marqueeStep: 0,
|
||||
marqueeMessage: 'Hello Jordan! How is your day going? BAM!',
|
||||
visualizationColors: [],
|
||||
contextMenuOpen: false,
|
||||
position: 0,
|
||||
secondsElapsed: 0,
|
||||
playing: false,
|
||||
loading: false,
|
||||
balance: 0,
|
||||
volume: 50,
|
||||
mediaName: '',
|
||||
mediaFile: null,
|
||||
mediaChannels: 2,
|
||||
doubled: false,
|
||||
closed: false,
|
||||
shade: false,
|
||||
shuffle: false,
|
||||
repeat: false
|
||||
};
|
||||
|
||||
var marqueeWidth = 30;
|
||||
|
||||
var WinampStore = assign({}, EventEmitter.prototype, {
|
||||
get: function() {
|
||||
return _winamp;
|
||||
},
|
||||
emitChange: function() {
|
||||
this.emit(CHANGE_EVENT);
|
||||
},
|
||||
addChangeListener: function(callback) {
|
||||
this.on(CHANGE_EVENT, callback);
|
||||
},
|
||||
|
||||
removeChangeListener: function(callback) {
|
||||
this.removeListener(CHANGE_EVENT, callback);
|
||||
}
|
||||
});
|
||||
|
||||
// Register callback to handle all updates
|
||||
AppDispatcher.register(function(action) {
|
||||
|
||||
switch (action.actionType) {
|
||||
case WinampConstants.SET_VISUALIZATION_COLORS:
|
||||
_winamp.visualizationColors = action.colors;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.PLAY:
|
||||
_winamp.playing = true;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.PAUSE:
|
||||
_winamp.playing = false;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.STOP:
|
||||
_winamp.playing = false;
|
||||
_winamp.position = 0;
|
||||
_winamp.secondsElapsed = 0;
|
||||
_winamp.secondsRemaining = 0;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.SET_POSITION:
|
||||
_winamp.position = action.position;
|
||||
_winamp.secondsElapsed = action.secondsElapsed;
|
||||
_winamp.secondsRemaining = action.secondsRemaing;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.SET_BALANCE:
|
||||
var balance = action.value;
|
||||
if (Math.abs(balance) < 25) {
|
||||
// Snap to center
|
||||
balance = 0;
|
||||
}
|
||||
_winamp.balance = balance;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.SET_VOLUME:
|
||||
_winamp.volume = action.value;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.LOAD_FILE:
|
||||
if (action.file.type === 'audio/mp3') {
|
||||
_winamp.mediaName = action.file.name;
|
||||
_winamp.mediaFile = action.file;
|
||||
} else {
|
||||
}
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.TOGGLE_CONTEXT_MENU:
|
||||
_winamp.contextMenuOpen = !_winamp.contextMenuOpen;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.TOGGLE_DOUBLE:
|
||||
_winamp.doubled = !_winamp.doubled;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.TOGGLE_SHADE:
|
||||
_winamp.shade = !_winamp.shade;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.TOGGLE_SHUFFLE:
|
||||
_winamp.shuffle = !_winamp.shuffle;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.TOGGLE_REPEAT:
|
||||
_winamp.repeat = !_winamp.repeat;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.CLOSE:
|
||||
_winamp.closed = true;
|
||||
_winamp.playing = false;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.MOVE_MAIN_WINDOW:
|
||||
_winamp.windows.main.left = action.left;
|
||||
_winamp.windows.main.top = action.top;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.STEP_MARQUEE:
|
||||
_winamp.marqueeStep = (_winamp.marqueeStep + 1) % marqueeWidth;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.MEDIA_IS_LOADING:
|
||||
_winamp.loading = true;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
case WinampConstants.MEDIA_LOADED:
|
||||
console.log('LOADED');
|
||||
_winamp.loading = false;
|
||||
WinampStore.emitChange();
|
||||
break;
|
||||
default:
|
||||
// no op
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = WinampStore;
|
||||
14
js/vendor/jszip.2.4.0.min.js
vendored
14
js/vendor/jszip.2.4.0.min.js
vendored
File diff suppressed because one or more lines are too long
19
package.json
19
package.json
|
|
@ -9,7 +9,7 @@
|
|||
"scripts": {
|
||||
"test": "qunit-cli test/*.js && npm run lint",
|
||||
"lint": "eslint js/*.js",
|
||||
"build": "r.js -o rjs/bundle.js"
|
||||
"serve": "webpack-dev-server"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
@ -28,8 +28,21 @@
|
|||
},
|
||||
"homepage": "https://github.com/captbaritone/winamp2-js#readme",
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.7.4",
|
||||
"babel-loader": "^6.2.4",
|
||||
"babel-preset-es2015": "^6.6.0",
|
||||
"eslint": "1.*",
|
||||
"qunit-cli": "~0.1.4",
|
||||
"eslint": "1.*"
|
||||
"webpack": "^1.12.14",
|
||||
"webpack-dev-server": "^1.14.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-preset-es2015": "^6.6.0",
|
||||
"babel-preset-react": "^6.5.0",
|
||||
"flux": "^2.1.1",
|
||||
"jszip": "^2.6.0",
|
||||
"keymirror": "^0.1.1",
|
||||
"react": "^0.14.7",
|
||||
"react-dom": "^0.14.7"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
430
rjs/almond.js
430
rjs/almond.js
|
|
@ -1,430 +0,0 @@
|
|||
/**
|
||||
* @license almond 0.3.1 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
|
||||
* Available via the MIT or new BSD license.
|
||||
* see: http://github.com/jrburke/almond for details
|
||||
*/
|
||||
//Going sloppy to avoid 'use strict' string cost, but strict practices should
|
||||
//be followed.
|
||||
/*jslint sloppy: true */
|
||||
/*global setTimeout: false */
|
||||
|
||||
var requirejs, require, define;
|
||||
(function (undef) {
|
||||
var main, req, makeMap, handlers,
|
||||
defined = {},
|
||||
waiting = {},
|
||||
config = {},
|
||||
defining = {},
|
||||
hasOwn = Object.prototype.hasOwnProperty,
|
||||
aps = [].slice,
|
||||
jsSuffixRegExp = /\.js$/;
|
||||
|
||||
function hasProp(obj, prop) {
|
||||
return hasOwn.call(obj, prop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a relative module name, like ./something, normalize it to
|
||||
* a real name that can be mapped to a path.
|
||||
* @param {String} name the relative name
|
||||
* @param {String} baseName a real name that the name arg is relative
|
||||
* to.
|
||||
* @returns {String} normalized name
|
||||
*/
|
||||
function normalize(name, baseName) {
|
||||
var nameParts, nameSegment, mapValue, foundMap, lastIndex,
|
||||
foundI, foundStarMap, starI, i, j, part,
|
||||
baseParts = baseName && baseName.split("/"),
|
||||
map = config.map,
|
||||
starMap = (map && map['*']) || {};
|
||||
|
||||
//Adjust any relative paths.
|
||||
if (name && name.charAt(0) === ".") {
|
||||
//If have a base name, try to normalize against it,
|
||||
//otherwise, assume it is a top-level require that will
|
||||
//be relative to baseUrl in the end.
|
||||
if (baseName) {
|
||||
name = name.split('/');
|
||||
lastIndex = name.length - 1;
|
||||
|
||||
// Node .js allowance:
|
||||
if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
|
||||
name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
|
||||
}
|
||||
|
||||
//Lop off the last part of baseParts, so that . matches the
|
||||
//"directory" and not name of the baseName's module. For instance,
|
||||
//baseName of "one/two/three", maps to "one/two/three.js", but we
|
||||
//want the directory, "one/two" for this normalization.
|
||||
name = baseParts.slice(0, baseParts.length - 1).concat(name);
|
||||
|
||||
//start trimDots
|
||||
for (i = 0; i < name.length; i += 1) {
|
||||
part = name[i];
|
||||
if (part === ".") {
|
||||
name.splice(i, 1);
|
||||
i -= 1;
|
||||
} else if (part === "..") {
|
||||
if (i === 1 && (name[2] === '..' || name[0] === '..')) {
|
||||
//End of the line. Keep at least one non-dot
|
||||
//path segment at the front so it can be mapped
|
||||
//correctly to disk. Otherwise, there is likely
|
||||
//no path mapping for a path starting with '..'.
|
||||
//This can still fail, but catches the most reasonable
|
||||
//uses of ..
|
||||
break;
|
||||
} else if (i > 0) {
|
||||
name.splice(i - 1, 2);
|
||||
i -= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
//end trimDots
|
||||
|
||||
name = name.join("/");
|
||||
} else if (name.indexOf('./') === 0) {
|
||||
// No baseName, so this is ID is resolved relative
|
||||
// to baseUrl, pull off the leading dot.
|
||||
name = name.substring(2);
|
||||
}
|
||||
}
|
||||
|
||||
//Apply map config if available.
|
||||
if ((baseParts || starMap) && map) {
|
||||
nameParts = name.split('/');
|
||||
|
||||
for (i = nameParts.length; i > 0; i -= 1) {
|
||||
nameSegment = nameParts.slice(0, i).join("/");
|
||||
|
||||
if (baseParts) {
|
||||
//Find the longest baseName segment match in the config.
|
||||
//So, do joins on the biggest to smallest lengths of baseParts.
|
||||
for (j = baseParts.length; j > 0; j -= 1) {
|
||||
mapValue = map[baseParts.slice(0, j).join('/')];
|
||||
|
||||
//baseName segment has config, find if it has one for
|
||||
//this name.
|
||||
if (mapValue) {
|
||||
mapValue = mapValue[nameSegment];
|
||||
if (mapValue) {
|
||||
//Match, update name to the new value.
|
||||
foundMap = mapValue;
|
||||
foundI = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundMap) {
|
||||
break;
|
||||
}
|
||||
|
||||
//Check for a star map match, but just hold on to it,
|
||||
//if there is a shorter segment match later in a matching
|
||||
//config, then favor over this star map.
|
||||
if (!foundStarMap && starMap && starMap[nameSegment]) {
|
||||
foundStarMap = starMap[nameSegment];
|
||||
starI = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundMap && foundStarMap) {
|
||||
foundMap = foundStarMap;
|
||||
foundI = starI;
|
||||
}
|
||||
|
||||
if (foundMap) {
|
||||
nameParts.splice(0, foundI, foundMap);
|
||||
name = nameParts.join('/');
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
function makeRequire(relName, forceSync) {
|
||||
return function () {
|
||||
//A version of a require function that passes a moduleName
|
||||
//value for items that may need to
|
||||
//look up paths relative to the moduleName
|
||||
var args = aps.call(arguments, 0);
|
||||
|
||||
//If first arg is not require('string'), and there is only
|
||||
//one arg, it is the array form without a callback. Insert
|
||||
//a null so that the following concat is correct.
|
||||
if (typeof args[0] !== 'string' && args.length === 1) {
|
||||
args.push(null);
|
||||
}
|
||||
return req.apply(undef, args.concat([relName, forceSync]));
|
||||
};
|
||||
}
|
||||
|
||||
function makeNormalize(relName) {
|
||||
return function (name) {
|
||||
return normalize(name, relName);
|
||||
};
|
||||
}
|
||||
|
||||
function makeLoad(depName) {
|
||||
return function (value) {
|
||||
defined[depName] = value;
|
||||
};
|
||||
}
|
||||
|
||||
function callDep(name) {
|
||||
if (hasProp(waiting, name)) {
|
||||
var args = waiting[name];
|
||||
delete waiting[name];
|
||||
defining[name] = true;
|
||||
main.apply(undef, args);
|
||||
}
|
||||
|
||||
if (!hasProp(defined, name) && !hasProp(defining, name)) {
|
||||
throw new Error('No ' + name);
|
||||
}
|
||||
return defined[name];
|
||||
}
|
||||
|
||||
//Turns a plugin!resource to [plugin, resource]
|
||||
//with the plugin being undefined if the name
|
||||
//did not have a plugin prefix.
|
||||
function splitPrefix(name) {
|
||||
var prefix,
|
||||
index = name ? name.indexOf('!') : -1;
|
||||
if (index > -1) {
|
||||
prefix = name.substring(0, index);
|
||||
name = name.substring(index + 1, name.length);
|
||||
}
|
||||
return [prefix, name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a name map, normalizing the name, and using a plugin
|
||||
* for normalization if necessary. Grabs a ref to plugin
|
||||
* too, as an optimization.
|
||||
*/
|
||||
makeMap = function (name, relName) {
|
||||
var plugin,
|
||||
parts = splitPrefix(name),
|
||||
prefix = parts[0];
|
||||
|
||||
name = parts[1];
|
||||
|
||||
if (prefix) {
|
||||
prefix = normalize(prefix, relName);
|
||||
plugin = callDep(prefix);
|
||||
}
|
||||
|
||||
//Normalize according
|
||||
if (prefix) {
|
||||
if (plugin && plugin.normalize) {
|
||||
name = plugin.normalize(name, makeNormalize(relName));
|
||||
} else {
|
||||
name = normalize(name, relName);
|
||||
}
|
||||
} else {
|
||||
name = normalize(name, relName);
|
||||
parts = splitPrefix(name);
|
||||
prefix = parts[0];
|
||||
name = parts[1];
|
||||
if (prefix) {
|
||||
plugin = callDep(prefix);
|
||||
}
|
||||
}
|
||||
|
||||
//Using ridiculous property names for space reasons
|
||||
return {
|
||||
f: prefix ? prefix + '!' + name : name, //fullName
|
||||
n: name,
|
||||
pr: prefix,
|
||||
p: plugin
|
||||
};
|
||||
};
|
||||
|
||||
function makeConfig(name) {
|
||||
return function () {
|
||||
return (config && config.config && config.config[name]) || {};
|
||||
};
|
||||
}
|
||||
|
||||
handlers = {
|
||||
require: function (name) {
|
||||
return makeRequire(name);
|
||||
},
|
||||
exports: function (name) {
|
||||
var e = defined[name];
|
||||
if (typeof e !== 'undefined') {
|
||||
return e;
|
||||
} else {
|
||||
return (defined[name] = {});
|
||||
}
|
||||
},
|
||||
module: function (name) {
|
||||
return {
|
||||
id: name,
|
||||
uri: '',
|
||||
exports: defined[name],
|
||||
config: makeConfig(name)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
main = function (name, deps, callback, relName) {
|
||||
var cjsModule, depName, ret, map, i,
|
||||
args = [],
|
||||
callbackType = typeof callback,
|
||||
usingExports;
|
||||
|
||||
//Use name if no relName
|
||||
relName = relName || name;
|
||||
|
||||
//Call the callback to define the module, if necessary.
|
||||
if (callbackType === 'undefined' || callbackType === 'function') {
|
||||
//Pull out the defined dependencies and pass the ordered
|
||||
//values to the callback.
|
||||
//Default to [require, exports, module] if no deps
|
||||
deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
|
||||
for (i = 0; i < deps.length; i += 1) {
|
||||
map = makeMap(deps[i], relName);
|
||||
depName = map.f;
|
||||
|
||||
//Fast path CommonJS standard dependencies.
|
||||
if (depName === "require") {
|
||||
args[i] = handlers.require(name);
|
||||
} else if (depName === "exports") {
|
||||
//CommonJS module spec 1.1
|
||||
args[i] = handlers.exports(name);
|
||||
usingExports = true;
|
||||
} else if (depName === "module") {
|
||||
//CommonJS module spec 1.1
|
||||
cjsModule = args[i] = handlers.module(name);
|
||||
} else if (hasProp(defined, depName) ||
|
||||
hasProp(waiting, depName) ||
|
||||
hasProp(defining, depName)) {
|
||||
args[i] = callDep(depName);
|
||||
} else if (map.p) {
|
||||
map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
|
||||
args[i] = defined[depName];
|
||||
} else {
|
||||
throw new Error(name + ' missing ' + depName);
|
||||
}
|
||||
}
|
||||
|
||||
ret = callback ? callback.apply(defined[name], args) : undefined;
|
||||
|
||||
if (name) {
|
||||
//If setting exports via "module" is in play,
|
||||
//favor that over return value and exports. After that,
|
||||
//favor a non-undefined return value over exports use.
|
||||
if (cjsModule && cjsModule.exports !== undef &&
|
||||
cjsModule.exports !== defined[name]) {
|
||||
defined[name] = cjsModule.exports;
|
||||
} else if (ret !== undef || !usingExports) {
|
||||
//Use the return value from the function.
|
||||
defined[name] = ret;
|
||||
}
|
||||
}
|
||||
} else if (name) {
|
||||
//May just be an object definition for the module. Only
|
||||
//worry about defining if have a module name.
|
||||
defined[name] = callback;
|
||||
}
|
||||
};
|
||||
|
||||
requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
|
||||
if (typeof deps === "string") {
|
||||
if (handlers[deps]) {
|
||||
//callback in this case is really relName
|
||||
return handlers[deps](callback);
|
||||
}
|
||||
//Just return the module wanted. In this scenario, the
|
||||
//deps arg is the module name, and second arg (if passed)
|
||||
//is just the relName.
|
||||
//Normalize module name, if it contains . or ..
|
||||
return callDep(makeMap(deps, callback).f);
|
||||
} else if (!deps.splice) {
|
||||
//deps is a config object, not an array.
|
||||
config = deps;
|
||||
if (config.deps) {
|
||||
req(config.deps, config.callback);
|
||||
}
|
||||
if (!callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (callback.splice) {
|
||||
//callback is an array, which means it is a dependency list.
|
||||
//Adjust args if there are dependencies
|
||||
deps = callback;
|
||||
callback = relName;
|
||||
relName = null;
|
||||
} else {
|
||||
deps = undef;
|
||||
}
|
||||
}
|
||||
|
||||
//Support require(['a'])
|
||||
callback = callback || function () {};
|
||||
|
||||
//If relName is a function, it is an errback handler,
|
||||
//so remove it.
|
||||
if (typeof relName === 'function') {
|
||||
relName = forceSync;
|
||||
forceSync = alt;
|
||||
}
|
||||
|
||||
//Simulate async callback;
|
||||
if (forceSync) {
|
||||
main(undef, deps, callback, relName);
|
||||
} else {
|
||||
//Using a non-zero value because of concern for what old browsers
|
||||
//do, and latest browsers "upgrade" to 4 if lower value is used:
|
||||
//http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
|
||||
//If want a value immediately, use require('id') instead -- something
|
||||
//that works in almond on the global level, but not guaranteed and
|
||||
//unlikely to work in other AMD implementations.
|
||||
setTimeout(function () {
|
||||
main(undef, deps, callback, relName);
|
||||
}, 4);
|
||||
}
|
||||
|
||||
return req;
|
||||
};
|
||||
|
||||
/**
|
||||
* Just drops the config on the floor, but returns req in case
|
||||
* the config return value is used.
|
||||
*/
|
||||
req.config = function (cfg) {
|
||||
return req(cfg);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose module registry for debugging and tooling
|
||||
*/
|
||||
requirejs._defined = defined;
|
||||
|
||||
define = function (name, deps, callback) {
|
||||
if (typeof name !== 'string') {
|
||||
throw new Error('See almond README: incorrect module build, no module name');
|
||||
}
|
||||
|
||||
//This module may not have dependencies
|
||||
if (!deps.splice) {
|
||||
//deps is not an array, so probably means
|
||||
//an object literal or factory function for
|
||||
//the value. Adjust args.
|
||||
callback = deps;
|
||||
deps = [];
|
||||
}
|
||||
|
||||
if (!hasProp(defined, name) && !hasProp(waiting, name)) {
|
||||
waiting[name] = [name, deps, callback];
|
||||
}
|
||||
};
|
||||
|
||||
define.amd = {
|
||||
jQuery: true
|
||||
};
|
||||
}());
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
({
|
||||
baseUrl: '../js/',
|
||||
name: '../rjs/almond',
|
||||
include: ['main'],
|
||||
out: '../bundle.js',
|
||||
wrap: true,
|
||||
exclude: ['../rjs/normalize'],
|
||||
pragmasOnSave: {
|
||||
excludeRequireCss: true
|
||||
}
|
||||
})
|
||||
|
|
@ -1,235 +0,0 @@
|
|||
define(['require', './normalize'], function(req, normalize) {
|
||||
var cssAPI = {};
|
||||
|
||||
var isWindows = !!process.platform.match(/^win/);
|
||||
|
||||
function compress(css) {
|
||||
if (config.optimizeCss == 'none') {
|
||||
return css;
|
||||
}
|
||||
|
||||
if (typeof process !== "undefined" && process.versions && !!process.versions.node && require.nodeRequire) {
|
||||
try {
|
||||
var csso = require.nodeRequire('csso');
|
||||
}
|
||||
catch(e) {
|
||||
console.log('Compression module not installed. Use "npm install csso -g" to enable.');
|
||||
return css;
|
||||
}
|
||||
var csslen = css.length;
|
||||
try {
|
||||
css = csso.justDoIt(css);
|
||||
}
|
||||
catch(e) {
|
||||
console.log('Compression failed due to a CSS syntax error.');
|
||||
return css;
|
||||
}
|
||||
console.log('Compressed CSS output to ' + Math.round(css.length / csslen * 100) + '%.');
|
||||
return css;
|
||||
}
|
||||
console.log('Compression not supported outside of nodejs environments.');
|
||||
return css;
|
||||
}
|
||||
|
||||
//load file code - stolen from text plugin
|
||||
function loadFile(path) {
|
||||
if (typeof process !== "undefined" && process.versions && !!process.versions.node && require.nodeRequire) {
|
||||
var fs = require.nodeRequire('fs');
|
||||
var file = fs.readFileSync(path, 'utf8');
|
||||
if (file.indexOf('\uFEFF') === 0)
|
||||
return file.substring(1);
|
||||
return file;
|
||||
}
|
||||
else {
|
||||
var file = new java.io.File(path),
|
||||
lineSeparator = java.lang.System.getProperty("line.separator"),
|
||||
input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), 'utf-8')),
|
||||
stringBuffer, line;
|
||||
try {
|
||||
stringBuffer = new java.lang.StringBuffer();
|
||||
line = input.readLine();
|
||||
if (line && line.length() && line.charAt(0) === 0xfeff)
|
||||
line = line.substring(1);
|
||||
stringBuffer.append(line);
|
||||
while ((line = input.readLine()) !== null) {
|
||||
stringBuffer.append(lineSeparator).append(line);
|
||||
}
|
||||
return String(stringBuffer.toString());
|
||||
}
|
||||
finally {
|
||||
input.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function saveFile(path, data) {
|
||||
if (typeof process !== "undefined" && process.versions && !!process.versions.node && require.nodeRequire) {
|
||||
var fs = require.nodeRequire('fs');
|
||||
fs.writeFileSync(path, data, 'utf8');
|
||||
}
|
||||
else {
|
||||
var content = new java.lang.String(data);
|
||||
var output = new java.io.BufferedWriter(new java.io.OutputStreamWriter(new java.io.FileOutputStream(path), 'utf-8'));
|
||||
|
||||
try {
|
||||
output.write(content, 0, content.length());
|
||||
output.flush();
|
||||
}
|
||||
finally {
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//when adding to the link buffer, paths are normalised to the baseUrl
|
||||
//when removing from the link buffer, paths are normalised to the output file path
|
||||
function escape(content) {
|
||||
return content.replace(/(["'\\])/g, '\\$1')
|
||||
.replace(/[\f]/g, "\\f")
|
||||
.replace(/[\b]/g, "\\b")
|
||||
.replace(/[\n]/g, "\\n")
|
||||
.replace(/[\t]/g, "\\t")
|
||||
.replace(/[\r]/g, "\\r");
|
||||
}
|
||||
|
||||
// NB add @media query support for media imports
|
||||
var importRegEx = /@import\s*(url)?\s*(('([^']*)'|"([^"]*)")|\(('([^']*)'|"([^"]*)"|([^\)]*))\))\s*;?/g;
|
||||
var absUrlRegEx = /^([^\:\/]+:\/)?\//;
|
||||
|
||||
// Write Css module definition
|
||||
var writeCSSDefinition = "define('@writecss', function() {return function writeCss(c) {var d=document,a='appendChild',i='styleSheet',s=d.createElement('style');s.type='text/css';d.getElementsByTagName('head')[0][a](s);s[i]?s[i].cssText=c:s[a](d.createTextNode(c));};});";
|
||||
|
||||
var siteRoot;
|
||||
|
||||
var baseParts = req.toUrl('base_url').split('/');
|
||||
baseParts[baseParts.length - 1] = '';
|
||||
var baseUrl = baseParts.join('/');
|
||||
|
||||
var curModule = 0;
|
||||
var config;
|
||||
|
||||
var writeCSSForLayer = true;
|
||||
var layerBuffer = [];
|
||||
var cssBuffer = {};
|
||||
|
||||
cssAPI.load = function(name, req, load, _config) {
|
||||
//store config
|
||||
config = config || _config;
|
||||
|
||||
if (!siteRoot) {
|
||||
siteRoot = path.resolve(config.dir || path.dirname(config.out), config.siteRoot || '.') + '/';
|
||||
if (isWindows)
|
||||
siteRoot = siteRoot.replace(/\\/g, '/');
|
||||
}
|
||||
|
||||
//external URLS don't get added (just like JS requires)
|
||||
if (name.match(absUrlRegEx))
|
||||
return load();
|
||||
|
||||
var fileUrl = req.toUrl(name + '.css');
|
||||
if (isWindows)
|
||||
fileUrl = fileUrl.replace(/\\/g, '/');
|
||||
|
||||
// rebase to the output directory if based on the source directory;
|
||||
// baseUrl points always to the output directory, fileUrl only if
|
||||
// it is not prefixed by a computed path (relative too)
|
||||
var fileSiteUrl = fileUrl;
|
||||
if (fileSiteUrl.indexOf(baseUrl) < 0) {
|
||||
var appRoot = req.toUrl(config.appDir);
|
||||
if (isWindows)
|
||||
appRoot = appRoot.replace(/\\/g, '/');
|
||||
if (fileSiteUrl.indexOf(appRoot) == 0)
|
||||
fileSiteUrl = siteRoot + fileSiteUrl.substring(appRoot.length);
|
||||
}
|
||||
|
||||
//add to the buffer
|
||||
cssBuffer[name] = normalize(loadFile(fileUrl), fileSiteUrl, siteRoot);
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
cssAPI.normalize = function(name, normalize) {
|
||||
if (name.substr(name.length - 4, 4) == '.css')
|
||||
name = name.substr(0, name.length - 4);
|
||||
return normalize(name);
|
||||
}
|
||||
|
||||
cssAPI.write = function(pluginName, moduleName, write, parse) {
|
||||
var cssModule;
|
||||
|
||||
//external URLS don't get added (just like JS requires)
|
||||
if (moduleName.match(absUrlRegEx))
|
||||
return;
|
||||
|
||||
layerBuffer.push(cssBuffer[moduleName]);
|
||||
|
||||
if (!global._requirejsCssData) {
|
||||
global._requirejsCssData = {
|
||||
usedBy: {css: true},
|
||||
css: ''
|
||||
}
|
||||
} else {
|
||||
global._requirejsCssData.usedBy.css = true;
|
||||
}
|
||||
|
||||
if (config.buildCSS != false) {
|
||||
var style = cssBuffer[moduleName];
|
||||
|
||||
if (config.writeCSSModule && style) {
|
||||
if (writeCSSForLayer) {
|
||||
writeCSSForLayer = false;
|
||||
write(writeCSSDefinition);
|
||||
}
|
||||
|
||||
cssModule = 'define(["@writecss"], function(writeCss){\n writeCss("'+ escape(compress(style)) +'");\n})';
|
||||
}
|
||||
else {
|
||||
cssModule = 'define(function(){})';
|
||||
}
|
||||
|
||||
write.asModule(pluginName + '!' + moduleName, cssModule);
|
||||
}
|
||||
}
|
||||
|
||||
cssAPI.onLayerEnd = function(write, data) {
|
||||
if (config.separateCSS && config.IESelectorLimit)
|
||||
throw 'RequireCSS: separateCSS option is not compatible with ensuring the IE selector limit';
|
||||
|
||||
if (config.separateCSS) {
|
||||
var outPath = data.path.replace(/(\.js)?$/, '.css');
|
||||
console.log('Writing CSS! file: ' + outPath + '\n');
|
||||
|
||||
var css = layerBuffer.join('');
|
||||
|
||||
process.nextTick(function() {
|
||||
if (global._requirejsCssData) {
|
||||
css = global._requirejsCssData.css = css + global._requirejsCssData.css;
|
||||
delete global._requirejsCssData.usedBy.css;
|
||||
if (Object.keys(global._requirejsCssData.usedBy).length === 0) {
|
||||
delete global._requirejsCssData;
|
||||
}
|
||||
}
|
||||
|
||||
saveFile(outPath, compress(css));
|
||||
});
|
||||
|
||||
}
|
||||
else if (config.buildCSS != false && config.writeCSSModule != true) {
|
||||
var styles = config.IESelectorLimit ? layerBuffer : [layerBuffer.join('')];
|
||||
for (var i = 0; i < styles.length; i++) {
|
||||
if (styles[i] == '')
|
||||
return;
|
||||
write(
|
||||
"(function(c){var d=document,a='appendChild',i='styleSheet',s=d.createElement('style');s.type='text/css';d.getElementsByTagName('head')[0][a](s);s[i]?s[i].cssText=c:s[a](d.createTextNode(c));})\n"
|
||||
+ "('" + escape(compress(styles[i])) + "');\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
//clear layer buffer for next layer
|
||||
layerBuffer = [];
|
||||
writeCSSForLayer = true;
|
||||
}
|
||||
|
||||
return cssAPI;
|
||||
});
|
||||
169
rjs/css.js
169
rjs/css.js
|
|
@ -1,169 +0,0 @@
|
|||
/*
|
||||
* Require-CSS RequireJS css! loader plugin
|
||||
* 0.1.8
|
||||
* Guy Bedford 2014
|
||||
* MIT
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Usage:
|
||||
* require(['css!./mycssFile']);
|
||||
*
|
||||
* Tested and working in (up to latest versions as of March 2013):
|
||||
* Android
|
||||
* iOS 6
|
||||
* IE 6 - 10
|
||||
* Chome 3 - 26
|
||||
* Firefox 3.5 - 19
|
||||
* Opera 10 - 12
|
||||
*
|
||||
* browserling.com used for virtual testing environment
|
||||
*
|
||||
* Credit to B Cavalier & J Hann for the IE 6 - 9 method,
|
||||
* refined with help from Martin Cermak
|
||||
*
|
||||
* Sources that helped along the way:
|
||||
* - https://developer.mozilla.org/en-US/docs/Browser_detection_using_the_user_agent
|
||||
* - http://www.phpied.com/when-is-a-stylesheet-really-loaded/
|
||||
* - https://github.com/cujojs/curl/blob/master/src/curl/plugin/css.js
|
||||
*
|
||||
*/
|
||||
|
||||
define(function() {
|
||||
//>>excludeStart('excludeRequireCss', pragmas.excludeRequireCss)
|
||||
if (typeof window == 'undefined')
|
||||
return { load: function(n, r, load){ load() } };
|
||||
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
|
||||
var engine = window.navigator.userAgent.match(/Trident\/([^ ;]*)|AppleWebKit\/([^ ;]*)|Opera\/([^ ;]*)|rv\:([^ ;]*)(.*?)Gecko\/([^ ;]*)|MSIE\s([^ ;]*)|AndroidWebKit\/([^ ;]*)/) || 0;
|
||||
|
||||
// use <style> @import load method (IE < 9, Firefox < 18)
|
||||
var useImportLoad = false;
|
||||
|
||||
// set to false for explicit <link> load checking when onload doesn't work perfectly (webkit)
|
||||
var useOnload = true;
|
||||
|
||||
// trident / msie
|
||||
if (engine[1] || engine[7])
|
||||
useImportLoad = parseInt(engine[1]) < 6 || parseInt(engine[7]) <= 9;
|
||||
// webkit
|
||||
else if (engine[2] || engine[8])
|
||||
useOnload = false;
|
||||
// gecko
|
||||
else if (engine[4])
|
||||
useImportLoad = parseInt(engine[4]) < 18;
|
||||
|
||||
//>>excludeEnd('excludeRequireCss')
|
||||
//main api object
|
||||
var cssAPI = {};
|
||||
|
||||
//>>excludeStart('excludeRequireCss', pragmas.excludeRequireCss)
|
||||
cssAPI.pluginBuilder = './css-builder';
|
||||
|
||||
// <style> @import load method
|
||||
var curStyle, curSheet;
|
||||
var createStyle = function () {
|
||||
curStyle = document.createElement('style');
|
||||
head.appendChild(curStyle);
|
||||
curSheet = curStyle.styleSheet || curStyle.sheet;
|
||||
}
|
||||
var ieCnt = 0;
|
||||
var ieLoads = [];
|
||||
var ieCurCallback;
|
||||
|
||||
var createIeLoad = function(url) {
|
||||
curSheet.addImport(url);
|
||||
curStyle.onload = function(){ processIeLoad() };
|
||||
|
||||
ieCnt++;
|
||||
if (ieCnt == 31) {
|
||||
createStyle();
|
||||
ieCnt = 0;
|
||||
}
|
||||
}
|
||||
var processIeLoad = function() {
|
||||
ieCurCallback();
|
||||
|
||||
var nextLoad = ieLoads.shift();
|
||||
|
||||
if (!nextLoad) {
|
||||
ieCurCallback = null;
|
||||
return;
|
||||
}
|
||||
|
||||
ieCurCallback = nextLoad[1];
|
||||
createIeLoad(nextLoad[0]);
|
||||
}
|
||||
var importLoad = function(url, callback) {
|
||||
if (!curSheet || !curSheet.addImport)
|
||||
createStyle();
|
||||
|
||||
if (curSheet && curSheet.addImport) {
|
||||
// old IE
|
||||
if (ieCurCallback) {
|
||||
ieLoads.push([url, callback]);
|
||||
}
|
||||
else {
|
||||
createIeLoad(url);
|
||||
ieCurCallback = callback;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// old Firefox
|
||||
curStyle.textContent = '@import "' + url + '";';
|
||||
|
||||
var loadInterval = setInterval(function() {
|
||||
try {
|
||||
curStyle.sheet.cssRules;
|
||||
clearInterval(loadInterval);
|
||||
callback();
|
||||
} catch(e) {}
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
// <link> load method
|
||||
var linkLoad = function(url, callback) {
|
||||
var link = document.createElement('link');
|
||||
link.type = 'text/css';
|
||||
link.rel = 'stylesheet';
|
||||
if (useOnload)
|
||||
link.onload = function() {
|
||||
link.onload = function() {};
|
||||
// for style dimensions queries, a short delay can still be necessary
|
||||
setTimeout(callback, 7);
|
||||
}
|
||||
else
|
||||
var loadInterval = setInterval(function() {
|
||||
for (var i = 0; i < document.styleSheets.length; i++) {
|
||||
var sheet = document.styleSheets[i];
|
||||
if (sheet.href == link.href) {
|
||||
clearInterval(loadInterval);
|
||||
return callback();
|
||||
}
|
||||
}
|
||||
}, 10);
|
||||
link.href = url;
|
||||
head.appendChild(link);
|
||||
}
|
||||
|
||||
//>>excludeEnd('excludeRequireCss')
|
||||
cssAPI.normalize = function(name, normalize) {
|
||||
if (name.substr(name.length - 4, 4) == '.css')
|
||||
name = name.substr(0, name.length - 4);
|
||||
|
||||
return normalize(name);
|
||||
}
|
||||
|
||||
//>>excludeStart('excludeRequireCss', pragmas.excludeRequireCss)
|
||||
cssAPI.load = function(cssId, req, load, config) {
|
||||
|
||||
(useImportLoad ? importLoad : linkLoad)(req.toUrl(cssId + '.css'), load);
|
||||
|
||||
}
|
||||
|
||||
//>>excludeEnd('excludeRequireCss')
|
||||
return cssAPI;
|
||||
});
|
||||
141
rjs/normalize.js
141
rjs/normalize.js
|
|
@ -1,141 +0,0 @@
|
|||
//>>excludeStart('excludeRequireCss', pragmas.excludeRequireCss)
|
||||
/*
|
||||
* css.normalize.js
|
||||
*
|
||||
* CSS Normalization
|
||||
*
|
||||
* CSS paths are normalized based on an optional basePath and the RequireJS config
|
||||
*
|
||||
* Usage:
|
||||
* normalize(css, fromBasePath, toBasePath);
|
||||
*
|
||||
* css: the stylesheet content to normalize
|
||||
* fromBasePath: the absolute base path of the css relative to any root (but without ../ backtracking)
|
||||
* toBasePath: the absolute new base path of the css relative to the same root
|
||||
*
|
||||
* Absolute dependencies are left untouched.
|
||||
*
|
||||
* Urls in the CSS are picked up by regular expressions.
|
||||
* These will catch all statements of the form:
|
||||
*
|
||||
* url(*)
|
||||
* url('*')
|
||||
* url("*")
|
||||
*
|
||||
* @import '*'
|
||||
* @import "*"
|
||||
*
|
||||
* (and so also @import url(*) variations)
|
||||
*
|
||||
* For urls needing normalization
|
||||
*
|
||||
*/
|
||||
|
||||
define(function() {
|
||||
|
||||
// regular expression for removing double slashes
|
||||
// eg http://www.example.com//my///url/here -> http://www.example.com/my/url/here
|
||||
var slashes = /([^:])\/+/g
|
||||
var removeDoubleSlashes = function(uri) {
|
||||
return uri.replace(slashes, '$1/');
|
||||
}
|
||||
|
||||
// given a relative URI, and two absolute base URIs, convert it from one base to another
|
||||
var protocolRegEx = /[^\:\/]*:\/\/([^\/])*/;
|
||||
var absUrlRegEx = /^(\/|data:)/;
|
||||
function convertURIBase(uri, fromBase, toBase) {
|
||||
if (uri.match(absUrlRegEx) || uri.match(protocolRegEx))
|
||||
return uri;
|
||||
uri = removeDoubleSlashes(uri);
|
||||
// if toBase specifies a protocol path, ensure this is the same protocol as fromBase, if not
|
||||
// use absolute path at fromBase
|
||||
var toBaseProtocol = toBase.match(protocolRegEx);
|
||||
var fromBaseProtocol = fromBase.match(protocolRegEx);
|
||||
if (fromBaseProtocol && (!toBaseProtocol || toBaseProtocol[1] != fromBaseProtocol[1] || toBaseProtocol[2] != fromBaseProtocol[2]))
|
||||
return absoluteURI(uri, fromBase);
|
||||
|
||||
else {
|
||||
return relativeURI(absoluteURI(uri, fromBase), toBase);
|
||||
}
|
||||
};
|
||||
|
||||
// given a relative URI, calculate the absolute URI
|
||||
function absoluteURI(uri, base) {
|
||||
if (uri.substr(0, 2) == './')
|
||||
uri = uri.substr(2);
|
||||
|
||||
// absolute urls are left in tact
|
||||
if (uri.match(absUrlRegEx) || uri.match(protocolRegEx))
|
||||
return uri;
|
||||
|
||||
var baseParts = base.split('/');
|
||||
var uriParts = uri.split('/');
|
||||
|
||||
baseParts.pop();
|
||||
|
||||
while (curPart = uriParts.shift())
|
||||
if (curPart == '..')
|
||||
baseParts.pop();
|
||||
else
|
||||
baseParts.push(curPart);
|
||||
|
||||
return baseParts.join('/');
|
||||
};
|
||||
|
||||
|
||||
// given an absolute URI, calculate the relative URI
|
||||
function relativeURI(uri, base) {
|
||||
|
||||
// reduce base and uri strings to just their difference string
|
||||
var baseParts = base.split('/');
|
||||
baseParts.pop();
|
||||
base = baseParts.join('/') + '/';
|
||||
i = 0;
|
||||
while (base.substr(i, 1) == uri.substr(i, 1))
|
||||
i++;
|
||||
while (base.substr(i, 1) != '/')
|
||||
i--;
|
||||
base = base.substr(i + 1);
|
||||
uri = uri.substr(i + 1);
|
||||
|
||||
// each base folder difference is thus a backtrack
|
||||
baseParts = base.split('/');
|
||||
var uriParts = uri.split('/');
|
||||
out = '';
|
||||
while (baseParts.shift())
|
||||
out += '../';
|
||||
|
||||
// finally add uri parts
|
||||
while (curPart = uriParts.shift())
|
||||
out += curPart + '/';
|
||||
|
||||
return out.substr(0, out.length - 1);
|
||||
};
|
||||
|
||||
var normalizeCSS = function(source, fromBase, toBase) {
|
||||
|
||||
fromBase = removeDoubleSlashes(fromBase);
|
||||
toBase = removeDoubleSlashes(toBase);
|
||||
|
||||
var urlRegEx = /@import\s*("([^"]*)"|'([^']*)')|url\s*\((?!#)\s*(\s*"([^"]*)"|'([^']*)'|[^\)]*\s*)\s*\)/ig;
|
||||
var result, url, source;
|
||||
|
||||
while (result = urlRegEx.exec(source)) {
|
||||
url = result[3] || result[2] || result[5] || result[6] || result[4];
|
||||
var newUrl;
|
||||
newUrl = convertURIBase(url, fromBase, toBase);
|
||||
var quoteLen = result[5] || result[6] ? 1 : 0;
|
||||
source = source.substr(0, urlRegEx.lastIndex - url.length - quoteLen - 1) + newUrl + source.substr(urlRegEx.lastIndex - quoteLen - 1);
|
||||
urlRegEx.lastIndex = urlRegEx.lastIndex + (newUrl.length - url.length);
|
||||
}
|
||||
|
||||
return source;
|
||||
};
|
||||
|
||||
normalizeCSS.convertURIBase = convertURIBase;
|
||||
normalizeCSS.absoluteURI = absoluteURI;
|
||||
normalizeCSS.relativeURI = relativeURI;
|
||||
|
||||
return normalizeCSS;
|
||||
});
|
||||
//>>excludeEnd('excludeRequireCss')
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
RequireJS 2.1.16 Copyright (c) 2010-2015, 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(ba){function G(b){return"[object Function]"===K.call(b)}function H(b){return"[object Array]"===K.call(b)}function v(b,c){if(b){var d;for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);}}function T(b,c){if(b){var d;for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));d-=1);}}function t(b,c){return fa.call(b,c)}function m(b,c){return t(b,c)&&b[c]}function B(b,c){for(var d in b)if(t(b,d)&&c(b[d],d))break}function U(b,c,d,e){c&&B(c,function(c,g){if(d||!t(b,g))e&&"object"===typeof c&&c&&!H(c)&&!G(c)&&!(c instanceof
|
||||
RegExp)?(b[g]||(b[g]={}),U(b[g],c,d,e)):b[g]=c});return b}function u(b,c){return function(){return c.apply(b,arguments)}}function ca(b){throw b;}function da(b){if(!b)return b;var c=ba;v(b.split("."),function(b){c=c[b]});return c}function C(b,c,d,e){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=e;d&&(c.originalError=d);return c}function ga(b){function c(a,k,b){var f,l,c,d,e,g,i,p,k=k&&k.split("/"),h=j.map,n=h&&h["*"];if(a){a=a.split("/");l=a.length-1;j.nodeIdCompat&&
|
||||
Q.test(a[l])&&(a[l]=a[l].replace(Q,""));"."===a[0].charAt(0)&&k&&(l=k.slice(0,k.length-1),a=l.concat(a));l=a;for(c=0;c<l.length;c++)if(d=l[c],"."===d)l.splice(c,1),c-=1;else if(".."===d&&!(0===c||1==c&&".."===l[2]||".."===l[c-1])&&0<c)l.splice(c-1,2),c-=2;a=a.join("/")}if(b&&h&&(k||n)){l=a.split("/");c=l.length;a:for(;0<c;c-=1){e=l.slice(0,c).join("/");if(k)for(d=k.length;0<d;d-=1)if(b=m(h,k.slice(0,d).join("/")))if(b=m(b,e)){f=b;g=c;break a}!i&&(n&&m(n,e))&&(i=m(n,e),p=c)}!f&&i&&(f=i,g=p);f&&(l.splice(0,
|
||||
g,f),a=l.join("/"))}return(f=m(j.pkgs,a))?f:a}function d(a){z&&v(document.getElementsByTagName("script"),function(k){if(k.getAttribute("data-requiremodule")===a&&k.getAttribute("data-requirecontext")===i.contextName)return k.parentNode.removeChild(k),!0})}function e(a){var k=m(j.paths,a);if(k&&H(k)&&1<k.length)return k.shift(),i.require.undef(a),i.makeRequire(null,{skipMap:!0})([a]),!0}function n(a){var k,c=a?a.indexOf("!"):-1;-1<c&&(k=a.substring(0,c),a=a.substring(c+1,a.length));return[k,a]}function p(a,
|
||||
k,b,f){var l,d,e=null,g=k?k.name:null,j=a,p=!0,h="";a||(p=!1,a="_@r"+(K+=1));a=n(a);e=a[0];a=a[1];e&&(e=c(e,g,f),d=m(r,e));a&&(e?h=d&&d.normalize?d.normalize(a,function(a){return c(a,g,f)}):-1===a.indexOf("!")?c(a,g,f):a:(h=c(a,g,f),a=n(h),e=a[0],h=a[1],b=!0,l=i.nameToUrl(h)));b=e&&!d&&!b?"_unnormalized"+(O+=1):"";return{prefix:e,name:h,parentMap:k,unnormalized:!!b,url:l,originalName:j,isDefine:p,id:(e?e+"!"+h:h)+b}}function s(a){var k=a.id,b=m(h,k);b||(b=h[k]=new i.Module(a));return b}function q(a,
|
||||
k,b){var f=a.id,c=m(h,f);if(t(r,f)&&(!c||c.defineEmitComplete))"defined"===k&&b(r[f]);else if(c=s(a),c.error&&"error"===k)b(c.error);else c.on(k,b)}function w(a,b){var c=a.requireModules,f=!1;if(b)b(a);else if(v(c,function(b){if(b=m(h,b))b.error=a,b.events.error&&(f=!0,b.emit("error",a))}),!f)g.onError(a)}function x(){R.length&&(ha.apply(A,[A.length,0].concat(R)),R=[])}function y(a){delete h[a];delete V[a]}function F(a,b,c){var f=a.map.id;a.error?a.emit("error",a.error):(b[f]=!0,v(a.depMaps,function(f,
|
||||
d){var e=f.id,g=m(h,e);g&&(!a.depMatched[d]&&!c[e])&&(m(b,e)?(a.defineDep(d,r[e]),a.check()):F(g,b,c))}),c[f]=!0)}function D(){var a,b,c=(a=1E3*j.waitSeconds)&&i.startTime+a<(new Date).getTime(),f=[],l=[],g=!1,h=!0;if(!W){W=!0;B(V,function(a){var i=a.map,j=i.id;if(a.enabled&&(i.isDefine||l.push(a),!a.error))if(!a.inited&&c)e(j)?g=b=!0:(f.push(j),d(j));else if(!a.inited&&(a.fetched&&i.isDefine)&&(g=!0,!i.prefix))return h=!1});if(c&&f.length)return a=C("timeout","Load timeout for modules: "+f,null,
|
||||
f),a.contextName=i.contextName,w(a);h&&v(l,function(a){F(a,{},{})});if((!c||b)&&g)if((z||ea)&&!X)X=setTimeout(function(){X=0;D()},50);W=!1}}function E(a){t(r,a[0])||s(p(a[0],null,!0)).init(a[1],a[2])}function I(a){var a=a.currentTarget||a.srcElement,b=i.onScriptLoad;a.detachEvent&&!Y?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=i.onScriptError;(!a.detachEvent||Y)&&a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function J(){var a;
|
||||
for(x();A.length;){a=A.shift();if(null===a[0])return w(C("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));E(a)}}var W,Z,i,L,X,j={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},h={},V={},$={},A=[],r={},S={},aa={},K=1,O=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?r[a.map.id]=a.exports:a.exports=r[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(j.config,a.map.id)||{}},exports:a.exports||(a.exports={})}}};Z=function(a){this.events=m($,a.id)||{};this.map=a;this.shim=m(j.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};Z.prototype={init:function(a,b,c,f){f=f||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=u(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=
|
||||
c;this.inited=!0;this.ignore=f.ignore;f.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||[],u(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=
|
||||
this.map.url;S[a]||(S[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 f=this.exports,l=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(G(l)){if(this.events.error&&this.map.isDefine||g.onError!==ca)try{f=i.execCb(c,l,b,f)}catch(d){a=d}else f=i.execCb(c,l,b,f);this.map.isDefine&&void 0===f&&((b=this.module)?f=b.exports:this.usingExports&&
|
||||
(f=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",w(this.error=a)}else f=l;this.exports=f;if(this.map.isDefine&&!this.ignore&&(r[c]=f,g.onResourceLoad))g.onResourceLoad(i,this.map,this.depMaps);y(c);this.defined=!0}this.defining=!1;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=p(a.prefix);this.depMaps.push(d);q(d,"defined",u(this,function(f){var l,d;d=m(aa,this.map.id);var e=this.map.name,P=this.map.parentMap?this.map.parentMap.name:null,n=i.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(f.normalize&&(e=f.normalize(e,function(a){return c(a,P,!0)})||""),f=p(a.prefix+"!"+e,this.map.parentMap),q(f,"defined",u(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),d=m(h,f.id)){this.depMaps.push(f);
|
||||
if(this.events.error)d.on("error",u(this,function(a){this.emit("error",a)}));d.enable()}}else d?(this.map.url=i.nameToUrl(d),this.load()):(l=u(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),l.error=u(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];B(h,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&y(a.map.id)});w(a)}),l.fromText=u(this,function(f,c){var d=a.name,e=p(d),P=M;c&&(f=c);P&&(M=!1);s(e);t(j.config,b)&&(j.config[d]=j.config[b]);try{g.exec(f)}catch(h){return w(C("fromtexteval",
|
||||
"fromText eval for "+b+" failed: "+h,h,[b]))}P&&(M=!0);this.depMaps.push(e);i.completeLoad(d);n([d],l)}),f.load(a.name,n,l,j))}));i.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){V[this.map.id]=this;this.enabling=this.enabled=!0;v(this.depMaps,u(this,function(a,b){var c,f;if("string"===typeof a){a=p(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=m(L,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;q(a,"defined",u(this,function(a){this.defineDep(b,
|
||||
a);this.check()}));this.errback?q(a,"error",u(this,this.errback)):this.events.error&&q(a,"error",u(this,function(a){this.emit("error",a)}))}c=a.id;f=h[c];!t(L,c)&&(f&&!f.enabled)&&i.enable(a,this)}));B(this.pluginMaps,u(this,function(a){var b=m(h,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){v(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};i={config:j,contextName:b,
|
||||
registry:h,defined:r,urlFetched:S,defQueue:A,Module:Z,makeModuleMap:p,nextTick:g.nextTick,onError:w,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=j.shim,c={paths:!0,bundles:!0,config:!0,map:!0};B(a,function(a,b){c[b]?(j[b]||(j[b]={}),U(j[b],a,!0,!0)):j[b]=a});a.bundles&&B(a.bundles,function(a,b){v(a,function(a){a!==b&&(aa[a]=b)})});a.shim&&(B(a.shim,function(a,c){H(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=i.makeShimExports(a);
|
||||
b[c]=a}),j.shim=b);a.packages&&v(a.packages,function(a){var b,a="string"===typeof a?{name:a}:a;b=a.name;a.location&&(j.paths[b]=a.location);j.pkgs[b]=a.name+"/"+(a.main||"main").replace(ia,"").replace(Q,"")});B(h,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=p(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(ba,arguments));return b||a.exports&&da(a.exports)}},makeRequire:function(a,e){function j(c,d,m){var n,
|
||||
q;e.enableBuildCallback&&(d&&G(d))&&(d.__requireJsBuild=!0);if("string"===typeof c){if(G(d))return w(C("requireargs","Invalid require call"),m);if(a&&t(L,c))return L[c](h[a.id]);if(g.get)return g.get(i,c,a,j);n=p(c,a,!1,!0);n=n.id;return!t(r,n)?w(C("notloaded",'Module name "'+n+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):r[n]}J();i.nextTick(function(){J();q=s(p(null,a));q.skipMap=e.skipMap;q.init(c,d,m,{enabled:!0});D()});return j}e=e||{};U(j,{isBrowser:z,toUrl:function(b){var d,
|
||||
e=b.lastIndexOf("."),k=b.split("/")[0];if(-1!==e&&(!("."===k||".."===k)||1<e))d=b.substring(e,b.length),b=b.substring(0,e);return i.nameToUrl(c(b,a&&a.id,!0),d,!0)},defined:function(b){return t(r,p(b,a,!1,!0).id)},specified:function(b){b=p(b,a,!1,!0).id;return t(r,b)||t(h,b)}});a||(j.undef=function(b){x();var c=p(b,a,!0),e=m(h,b);d(b);delete r[b];delete S[c.url];delete $[b];T(A,function(a,c){a[0]===b&&A.splice(c,1)});e&&(e.events.defined&&($[b]=e.events),y(b))});return j},enable:function(a){m(h,a.id)&&
|
||||
s(a).enable()},completeLoad:function(a){var b,c,d=m(j.shim,a)||{},g=d.exports;for(x();A.length;){c=A.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);E(c)}c=m(h,a);if(!b&&!t(r,a)&&c&&!c.inited){if(j.enforceDefine&&(!g||!da(g)))return e(a)?void 0:w(C("nodefine","No define call for "+a,null,[a]));E([a,d.deps||[],d.exportsFn])}D()},nameToUrl:function(a,b,c){var d,e,h;(d=m(j.pkgs,a))&&(a=d);if(d=m(aa,a))return i.nameToUrl(d,b,c);if(g.jsExtRegExp.test(a))d=a+(b||"");else{d=j.paths;
|
||||
a=a.split("/");for(e=a.length;0<e;e-=1)if(h=a.slice(0,e).join("/"),h=m(d,h)){H(h)&&(h=h[0]);a.splice(0,e,h);break}d=a.join("/");d+=b||(/^data\:|\?/.test(d)||c?"":".js");d=("/"===d.charAt(0)||d.match(/^[\w\+\.\-]+:/)?"":j.baseUrl)+d}return j.urlArgs?d+((-1===d.indexOf("?")?"?":"&")+j.urlArgs):d},load:function(a,b){g.load(i,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if("load"===a.type||ja.test((a.currentTarget||a.srcElement).readyState))N=null,a=I(a),i.completeLoad(a.id)},
|
||||
onScriptError:function(a){var b=I(a);if(!e(b.id))return w(C("scripterror","Script error for: "+b.id,a,[b.id]))}};i.require=i.makeRequire();return i}var g,x,y,D,I,E,N,J,s,O,ka=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,la=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,Q=/\.js$/,ia=/^\.\//;x=Object.prototype;var K=x.toString,fa=x.hasOwnProperty,ha=Array.prototype.splice,z=!!("undefined"!==typeof window&&"undefined"!==typeof navigator&&window.document),ea=!z&&"undefined"!==typeof importScripts,ja=
|
||||
z&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,Y="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),F={},q={},R=[],M=!1;if("undefined"===typeof define){if("undefined"!==typeof requirejs){if(G(requirejs))return;q=requirejs;requirejs=void 0}"undefined"!==typeof require&&!G(require)&&(q=require,require=void 0);g=requirejs=function(b,c,d,e){var n,p="_";!H(b)&&"string"!==typeof b&&(n=b,H(c)?(b=c,c=d,d=e):b=[]);n&&n.context&&(p=n.context);(e=m(F,p))||(e=F[p]=g.s.newContext(p));
|
||||
n&&e.configure(n);return e.require(b,c,d)};g.config=function(b){return g(b)};g.nextTick="undefined"!==typeof setTimeout?function(b){setTimeout(b,4)}:function(b){b()};require||(require=g);g.version="2.1.16";g.jsExtRegExp=/^\/|:|\?|\.js$/;g.isBrowser=z;x=g.s={contexts:F,newContext:ga};g({});v(["toUrl","undef","defined","specified"],function(b){g[b]=function(){var c=F._;return c.require[b].apply(c,arguments)}});if(z&&(y=x.head=document.getElementsByTagName("head")[0],D=document.getElementsByTagName("base")[0]))y=
|
||||
x.head=D.parentNode;g.onError=ca;g.createNode=function(b){var c=b.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");c.type=b.scriptType||"text/javascript";c.charset="utf-8";c.async=!0;return c};g.load=function(b,c,d){var e=b&&b.config||{};if(z)return e=g.createNode(e,c,d),e.setAttribute("data-requirecontext",b.contextName),e.setAttribute("data-requiremodule",c),e.attachEvent&&!(e.attachEvent.toString&&0>e.attachEvent.toString().indexOf("[native code"))&&
|
||||
!Y?(M=!0,e.attachEvent("onreadystatechange",b.onScriptLoad)):(e.addEventListener("load",b.onScriptLoad,!1),e.addEventListener("error",b.onScriptError,!1)),e.src=d,J=e,D?y.insertBefore(e,D):y.appendChild(e),J=null,e;if(ea)try{importScripts(d),b.completeLoad(c)}catch(m){b.onError(C("importscripts","importScripts failed for "+c+" at "+d,m,[c]))}};z&&!q.skipDataMain&&T(document.getElementsByTagName("script"),function(b){y||(y=b.parentNode);if(I=b.getAttribute("data-main"))return s=I,q.baseUrl||(E=s.split("/"),
|
||||
s=E.pop(),O=E.length?E.join("/")+"/":"./",q.baseUrl=O),s=s.replace(Q,""),g.jsExtRegExp.test(s)&&(s=I),q.deps=q.deps?q.deps.concat(s):[s],!0});define=function(b,c,d){var e,g;"string"!==typeof b&&(d=c,c=b,b=null);H(c)||(d=c,c=null);!c&&G(d)&&(c=[],d.length&&(d.toString().replace(ka,"").replace(la,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c)));if(M){if(!(e=J))N&&"interactive"===N.readyState||T(document.getElementsByTagName("script"),function(b){if("interactive"===
|
||||
b.readyState)return N=b}),e=N;e&&(b||(b=e.getAttribute("data-requiremodule")),g=F[e.getAttribute("data-requirecontext")])}(g?g.defQueue:R).push([b,c,d])};define.amd={jQuery:!0};g.exec=function(b){return eval(b)};g(q)}})(this);
|
||||
18
webpack.config.js
Normal file
18
webpack.config.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
module.exports = {
|
||||
entry: __dirname,
|
||||
output: {
|
||||
filename: "bundle.js"
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{
|
||||
test: /\.jsx?$/,
|
||||
exclude: /(node_modules|bower_components)/,
|
||||
loader: 'babel', // 'babel-loader' is also a legal name to reference
|
||||
query: {
|
||||
presets: ['react', 'es2015']
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue