Commit 8256f69c by Иван Кубота

react-vanilla first public commit

parents
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.vscode
/.idea
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock.json
sendgrid.env
/public/p
/public/.well-known
/public/.well-known/*
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
async function subscribe() {
if(window.nolive)
return;
let response = {};
try{
response = await fetch( "/[live]" );
}catch( e ){
}
if (response.status === 502) {
} else if (response.status !== 200) {
// An error - let's show it
//debugger
//showMessage(response.statusText);
// Reconnect in one second
} else {
// Get and show the message
try{
let message = await response.text();
let data = JSON.parse( message ),
should = data.filter(live =>
[...document.scripts]
.map((a)=>a.src.replace(location.protocol+'//'+location.host,''))
.indexOf(live.file)>-1
).forEach(a=>{
try{
eval( a.content )
console.log('Reloaded: '+a.file);
}catch(e){
console.error(e)
}
});
}catch(e){
console.error(e)
}
//showMessage(message);
// Call subscribe() again to get the next message
}
setTimeout(subscribe, 1000);
}
setTimeout(subscribe, 10000);
\ No newline at end of file
var Observable = (function(){
'use strict';
var ArraySlice = [].slice;
var Observable = function(){
this._clearListeners();
};
Observable.prototype = {
on: function( k, v ){
( this._listeners[ k ] || ( this._listeners[ k ] = [] ) ).push( v );
var _self = this;
return function ReleaseObservable(){
_self.un( k, v );
};
},
un: function( k, v ){
var list = this._listeners[ k ];
if( list ){
var id = list.indexOf( v );
if( id > -1 ){
list.splice( id, 1 );
}
}
},
fire: function( k ){
//console.log(k)
var listeners = this._listeners[ k ],
listener;
if( listeners === void 0 )
return;
for( var i = 0, _i = listeners.length; i < _i; i++ ){
listener = listeners[ i ];
if( listener ){
listener.apply( this, ArraySlice.call( arguments, 1 ) );
}
}
},
once: function( k, v ){
var _self = this,
wrap = function(){
v.apply( this, arguments );
_self.un( k, wrap )
};
this.on( k, wrap );
},
_clearListeners: function(){
this._listeners = {};
}
};
return Observable;
})();
typeof module === 'object' && (module.exports = Observable);
\ No newline at end of file
function mulberry32(a) {
var out = function() {
var t = a += 0x6D2B79F5;
t = Math.imul(t ^ t >>> 15, t | 1);
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
return ((t ^ t >>> 14) >>> 0) / 4294967296;
};
out.getSeed = function() {
return a;
};
out.setSeed = function(A) {
a = A;
};
out.setStringSeed = function(str) {
str = str.replace(/[^0-9a-z]/g,'').substr(0,12);
if(str.length === 0)str = '1';
a = parseInt(str,36);
};
out.getStringSeed = function() {
return a.toString(36);
};
return out;
}
Math.random.seeded = mulberry32(Math.floor(Math.random()*4294967296));
\ No newline at end of file
This diff is collapsed. Click to expand it.
var Transform = (function() {
'use strict';
var hookAndConvert = function(fn) {
return function(hook, a) {
var type = typeof hook;
var notObject = type !== 'object';
var isHook = !notObject && ('hook' in hook);
if(isHook){
type = 'function'; notObject = true;
}
if(notObject){
if( type === 'function' ){
var last, val;
if(isHook){
return {hook: function(draw) {
return hook.hook(function(arg) {
val = fn(arg, a);
if(last === val)
return;
return draw(last = val);
});
}};
}else{
return function(draw) {
return hook(function(arg) {
val = fn(arg, a);
if(last === val)
return;
return draw(last = val);
});
};
}
}
}else{
return hook;
}
}
};
var Transform = {
toFixed: hookAndConvert(function(val, digits) {
return (val-0).toFixed(digits);
}),
concat: hookAndConvert(function(val, val2) {
return val + val2;
}),
toLowerCase: hookAndConvert(function(val) {
return (val+'').toLowerCase();
})
};
return Transform;
})();
typeof module === 'object' && (module.exports = Transform);
(typeof window === 'object') && (window.T = window.Transform = Transform);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment