-
Notifications
You must be signed in to change notification settings - Fork 0
/
ma_ts.js
214 lines (201 loc) · 8.06 KB
/
ma_ts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
define("ma", ["require", "exports", 'react', './node_modules/angular2/core', './node_modules/angular2/platform/browser', 'reflect-metadata'], function (require, exports, react_1, core_1, browser_1) {
"use strict";
var container = document.getElementById('container');
if (!container) {
console.log('Appending container!');
document.body.innerHTML += '<div id="container"></div';
}
else {
container.innerHTML = '';
}
container = document.getElementById('container');
// console.log(container);
if (module.hot) {
console.log('this module is hot!'); //, module.hot);
module.hot.accept();
}
exports.MyComponent = core_1.Component({
selector: 'my-component',
template: '<div>Hello my name is {{name}}. <button (click)="sayMyName()">Say my name</button></div>'
})
.Class({
constructor: function () {
this.name = 'Max';
},
sayMyName: function () {
console.log('My name is', this.name);
}
});
browser_1.bootstrap(exports.MyComponent);
var assign = require('object.assign/polyfill')();
Object.assign = assign;
var csjs = require('csjs');
var green = '#33aa22';
//const styles = {highlight: {}, panel: {}};
var error = '';
var styles = (_a = ["\n\n @-webkit-keyframes yellow-fade { \n 0% {background: yellow;}\n 100% {background: none;}\n }\n\n @keyframes yellow-fade {\n 0% {background: yellow;}\n 100% {background: none;}\n }\n\n .highlight {\n -webkit-animation: yellow-fade 2s ease-in 1;\n animation: yellow-fade 2s ease-in 1;\n }\n\n .panel {\n border: 1px solid black;\n background-color: ", ";\n }\n .title {\n padding: 4px;\n font-size: 15px;\n }\n\n"], _a.raw = ["\n\n @-webkit-keyframes yellow-fade { \n 0% {background: yellow;}\n 100% {background: none;}\n }\n\n @keyframes yellow-fade {\n 0% {background: yellow;}\n 100% {background: none;}\n }\n\n .highlight {\n -webkit-animation: yellow-fade 2s ease-in 1;\n animation: yellow-fade 2s ease-in 1;\n }\n\n .panel {\n border: 1px solid black;\n background-color: ", ";\n }\n .title {\n padding: 4px;\n font-size: 15px;\n }\n\n"], csjs(_a, green));
var css = csjs.getCss(styles);
var insertCss = require('insert-css');
insertCss(css);
//var sheet = window.document.styleSheets[0];
//sheet.insertRule(css, sheet.cssRules.length);
//console.log(css);
/*
var styles = cssInJS({
button: {
padding: 5,
backgroundColor: 'white'
}
});
*/
var timing = '';
if (window.performance) {
var pageLoadTiming = {};
for (var k in window.performance.timing) {
if (k !== 'toJSON') {
pageLoadTiming[k] = window.performance.timing[k];
}
}
pageLoadTiming.code = (new Date()).valueOf();
timing = JSON.stringify(pageLoadTiming, null, 2);
}
function iOS8Minus() {
if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
return window.performance ? false : true;
}
return false;
}
var iOSBugfix = iOS8Minus();
function foo_(files1, files2, This) {
var size = 0;
if (false && files1) {
try {
var file_blob = files1[0];
size = 1111;
var newFile1 = file_blob.slice(0, 10);
var blob = new Blob([file_blob, "blobText"], { type: "text/plain" });
// size = file_blob.size;
size = newFile1.size;
}
catch (err) {
socket.send(err.message);
}
}
return (<div className={styles.highlight}>
{error}
<pre style={{ fontSize: '10px' }}>{timing}</pre>
{files2 && <h1>Files 2 {files2[0].size}</h1>}
{files1 && <h1>Files 1 {files1[0].size}</h1>}
{window.Worker && <h1>Hello here!</h1>}
<a className={styles.panel} href="#" id="fileSelect" onclick={function (e) {
var fileElem = document.getElementById("files");
fileElem.click();
e.preventDefault();
}}>Select some files</a>
{iOSBugfix &&
(<div>
<input type="file" accept="image/*" multiple id="files" style={{ display: 'none' }} onchange={function () {
g_view = patch(g_view, foo(this.files, files2));
}}/>
<input type="file" accept="image/*" onchange={function () {
// console.log(this.files);
g_view = patch(g_view, foo(files1, this.files));
}}/><br />
<input type="file" accept="video/*" onchange={function () {
// console.log(this.files);
g_view = patch(g_view, foo(files1, this.files));
}}/><br /></div>) ||
(<input type="file" multiple id="files" style={{ display: 'none' }} onchange={function () {
g_view = patch(g_view, foo(this.files, files2));
}}/>)}
<br />
Reloading works<br />
<input type="file" onchange={function () {
// console.log(this.files);
g_view = patch(g_view, foo(files1, this.files));
}}/><br />
</div>);
}
var files = [{ size: 0 }];
var windowURL = window.URL || window.webkitURL;
var createObjectURL = windowURL.createObjectURL;
createObjectURL = createObjectURL.bind(windowURL);
var duration = 0;
function foo() {
var preview = <div></div>;
if (files[0].size) {
// TODO: preview images for most formats
var imageType = /^image\//;
var videoType = /^video\//;
if (imageType.test(files[0].type)) {
preview = <div><img src={createObjectURL(files[0])} height="60" onload={function () {
window.URL.revokeObjectURL(this.src);
}}/>
</div>;
}
else if (videoType.test(files[0].type)) {
/* var reader = new window.FileReader();
reader.onload = function (evt) {
var video = document.getElementById('video1');
video.src = evt.target.result;
};
reader.readAsDataURL(files[0]);
*/
preview = <video id="video1" width="96" height="54" src={windowURL.createObjectURL(files[0])} preload="metadata" onloadedmetadata={function () {
windowURL.revokeObjectURL(this.src);
var was = 0 === duration;
duration = this.duration;
if (was) {
g_view = patch(g_view, foo());
}
}}>
</video>;
}
else {
preview = <div>{files[0].type}</div>;
}
}
return <div className={styles.highlight}>{preview}{files[0].size}<input type="file" id="files" onchange={function () {
if (files[0].size === 0) {
files = this.files;
}
g_view = patch(g_view, foo());
}}/>
Hello!!
{duration}
</div>;
}
var snabbdom = require('snabbdom');
var patch = snabbdom.init([
require('snabbdom/modules/class'),
require('snabbdom/modules/props'),
require('snabbdom/modules/style'),
require('snabbdom/modules/eventlisteners'),
]);
// Patch into empty DOM element - this modifies the DOM as a side effect
var g_view = patch(container, foo());
var _a;
});
/*
var socket = new WebSocket("ws://localhost:8080");
socket.onmessage = function (event) {
if (event.data === 'reload') {
location.reload(true);
console.log('Reloading page....');
}
}
*/
/*
console.log('qqq');
console.log('bbb');
console.log('main starting');
const a = require('./a.js');
const b = require('./b.js');
console.log('in main, a.done=%j, b.done=%j', a.done, b.done);
import styles2 from './aa';
// import { c } from './b';
//import { b } from 'bjsx';
console.log('Hi here!!!');
// a();
*/
//# sourceMappingURL=ma_ts.js.map