Upload folder using huggingface_hub (part 25)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- pool/shard001/JavaScript/0009980_node-event-delegate.js +60 -0
- pool/shard001/JavaScript/0009983_bootstrap.js +78 -0
- pool/shard001/JavaScript/0009984_scrollPosition.js +15 -0
- pool/shard001/JavaScript/0009994_server.js +25 -0
- pool/shard001/JavaScript/0009998_theme.js +27 -0
- pool/shard001/JavaScript/0010001_jquery.balert.js +76 -0
- pool/shard001/JavaScript/0010004_picker_basic2.js +80 -0
- pool/shard001/JavaScript/0010007_basic-tokenise.js +102 -0
- pool/shard001/JavaScript/0010008_ReviewsController.js +26 -0
- pool/shard001/JavaScript/0010011_nativeImageSource.js +53 -0
- pool/shard001/JavaScript/0010016_mobile.js +40 -0
- pool/shard001/JavaScript/0010017_rook.js +15 -0
- pool/shard001/JavaScript/0010018_demobase.js +93 -0
- pool/shard001/JavaScript/0010019_release-notes-spec.js +71 -0
- pool/shard001/JavaScript/0010026_BigButton.js +73 -0
- pool/shard001/JavaScript/0010027_Admin__Service.js +192 -0
- pool/shard001/JavaScript/0010028_android.js +246 -0
- pool/shard001/JavaScript/0010034_worker.js +160 -0
- pool/shard001/JavaScript/0010035_login.js +30 -0
- pool/shard001/JavaScript/0010036_handlers.js +17 -0
- pool/shard001/JavaScript/0010037_messagebar-attachments.js +34 -0
- pool/shard001/JavaScript/0010039_index.js +16 -0
- pool/shard001/JavaScript/0010041_no-process-env.js +51 -0
- pool/shard001/JavaScript/0010043_temp.js +34 -0
- pool/shard001/JavaScript/0010045_gadget-util.js +35 -0
- pool/shard001/JavaScript/0010048_submissions.js +23 -0
- pool/shard001/JavaScript/0010049_angularService.js +58 -0
- pool/shard001/JavaScript/0010050_index.js +63 -0
- pool/shard001/JavaScript/0010051_sha1-test.js +77 -0
- pool/shard001/JavaScript/0010052_ResultView.js +35 -0
- pool/shard001/JavaScript/0010053_www.js +40 -0
- pool/shard001/JavaScript/0010054_security.js +105 -0
- pool/shard001/JavaScript/0010057_ramp.js +61 -0
- pool/shard001/JavaScript/0010059_FaviconStore.js +48 -0
- pool/shard001/JavaScript/0010060_combined_ast_test.js +181 -0
- pool/shard001/JavaScript/0010062_auth.test.js +42 -0
- pool/shard001/JavaScript/0010064_Functions.js +87 -0
- pool/shard001/JavaScript/0010067_editParticular.js +107 -0
- pool/shard001/JavaScript/0010071_util.js +28 -0
- pool/shard001/JavaScript/0010072_application.js +290 -0
- pool/shard001/JavaScript/0010073_util.js +82 -0
- pool/shard001/JavaScript/0010075_item.js +133 -0
- pool/shard001/JavaScript/0010077_test-http-flush-response-headers.js +27 -0
- pool/shard001/JavaScript/0010078_home.js +31 -0
- pool/shard001/JavaScript/0010083_analytics_interaction_manager.js +111 -0
- pool/shard001/JavaScript/0010085_contributorsModal.js +81 -0
- pool/shard001/JavaScript/0010087_Player1.js +171 -0
- pool/shard001/JavaScript/0010089_demo.js +18 -0
- pool/shard001/JavaScript/0010091_building.js +70 -0
- pool/shard001/JavaScript/0010099_product.js +67 -0
pool/shard001/JavaScript/0009980_node-event-delegate.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
YUI 3.5.0 (build 5089)
|
| 3 |
+
Copyright 2012 Yahoo! Inc. All rights reserved.
|
| 4 |
+
Licensed under the BSD License.
|
| 5 |
+
http://yuilibrary.com/license/
|
| 6 |
+
*/
|
| 7 |
+
YUI.add('node-event-delegate', function(Y) {
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* Functionality to make the node a delegated event container
|
| 11 |
+
* @module node
|
| 12 |
+
* @submodule node-event-delegate
|
| 13 |
+
*/
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* <p>Sets up a delegation listener for an event occurring inside the Node.
|
| 17 |
+
* The delegated event will be verified against a supplied selector or
|
| 18 |
+
* filtering function to test if the event references at least one node that
|
| 19 |
+
* should trigger the subscription callback.</p>
|
| 20 |
+
*
|
| 21 |
+
* <p>Selector string filters will trigger the callback if the event originated
|
| 22 |
+
* from a node that matches it or is contained in a node that matches it.
|
| 23 |
+
* Function filters are called for each Node up the parent axis to the
|
| 24 |
+
* subscribing container node, and receive at each level the Node and the event
|
| 25 |
+
* object. The function should return true (or a truthy value) if that Node
|
| 26 |
+
* should trigger the subscription callback. Note, it is possible for filters
|
| 27 |
+
* to match multiple Nodes for a single event. In this case, the delegate
|
| 28 |
+
* callback will be executed for each matching Node.</p>
|
| 29 |
+
*
|
| 30 |
+
* <p>For each matching Node, the callback will be executed with its 'this'
|
| 31 |
+
* object set to the Node matched by the filter (unless a specific context was
|
| 32 |
+
* provided during subscription), and the provided event's
|
| 33 |
+
* <code>currentTarget</code> will also be set to the matching Node. The
|
| 34 |
+
* containing Node from which the subscription was originally made can be
|
| 35 |
+
* referenced as <code>e.container</code>.
|
| 36 |
+
*
|
| 37 |
+
* @method delegate
|
| 38 |
+
* @param type {String} the event type to delegate
|
| 39 |
+
* @param fn {Function} the callback function to execute. This function
|
| 40 |
+
* will be provided the event object for the delegated event.
|
| 41 |
+
* @param spec {String|Function} a selector that must match the target of the
|
| 42 |
+
* event or a function to test target and its parents for a match
|
| 43 |
+
* @param context {Object} optional argument that specifies what 'this' refers to.
|
| 44 |
+
* @param args* {any} 0..n additional arguments to pass on to the callback function.
|
| 45 |
+
* These arguments will be added after the event object.
|
| 46 |
+
* @return {EventHandle} the detach handle
|
| 47 |
+
* @for Node
|
| 48 |
+
*/
|
| 49 |
+
Y.Node.prototype.delegate = function(type) {
|
| 50 |
+
|
| 51 |
+
var args = Y.Array(arguments, 0, true),
|
| 52 |
+
index = (Y.Lang.isObject(type) && !Y.Lang.isArray(type)) ? 1 : 2;
|
| 53 |
+
|
| 54 |
+
args.splice(index, 0, this._node);
|
| 55 |
+
|
| 56 |
+
return Y.delegate.apply(Y, args);
|
| 57 |
+
};
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
}, '3.5.0' ,{requires:['node-base', 'event-delegate']});
|
pool/shard001/JavaScript/0009983_bootstrap.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Module Dependencies
|
| 3 |
+
*/
|
| 4 |
+
|
| 5 |
+
var Waterline = require('waterline');
|
| 6 |
+
var _ = require('lodash');
|
| 7 |
+
var async = require('async');
|
| 8 |
+
|
| 9 |
+
// Require Fixtures
|
| 10 |
+
var fixtures = {
|
| 11 |
+
PaymentBelongsFixture: require('./fixtures/belongsTo.child.fixture'),
|
| 12 |
+
PaymentBelongsCustomFixture: require('./fixtures/belongsTo.child.customPK.fixture'),
|
| 13 |
+
CustomerBelongsFixture: require('./fixtures/belongsTo.parent.fixture'),
|
| 14 |
+
CustomerBelongsCustomFixture: require('./fixtures/belongsTo.parent.customPK.fixture'),
|
| 15 |
+
PaymentHasManyFixture: require('./fixtures/hasMany.child.fixture'),
|
| 16 |
+
CustomerHasManyFixture: require('./fixtures/hasMany.parent.fixture'),
|
| 17 |
+
ApartmentHasManyFixture: require('./fixtures/hasMany.customPK.fixture'),
|
| 18 |
+
PaymentManyFixture: require('./fixtures/multipleAssociations.fixture').payment,
|
| 19 |
+
CustomerManyFixture: require('./fixtures/multipleAssociations.fixture').customer,
|
| 20 |
+
StadiumFixture: require('./fixtures/hasManyThrough.stadium.fixture'),
|
| 21 |
+
TeamFixture: require('./fixtures/hasManyThrough.team.fixture'),
|
| 22 |
+
VenueFixture: require('./fixtures/hasManyThrough.venue.fixture'),
|
| 23 |
+
TaxiFixture: require('./fixtures/manyToMany.taxi.fixture'),
|
| 24 |
+
DriverFixture: require('./fixtures/manyToMany.driver.fixture'),
|
| 25 |
+
TaxiCustomFixture: require('./fixtures/manyToMany.taxi.customPK.fixture'),
|
| 26 |
+
DriverCustomFixture: require('./fixtures/manyToMany.driver.customPK.fixture'),
|
| 27 |
+
UserOneFixture: require('./fixtures/oneToOne.fixture').user_resource,
|
| 28 |
+
ProfileOneFixture: require('./fixtures/oneToOne.fixture').profile
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
/////////////////////////////////////////////////////
|
| 33 |
+
// TEST SETUP
|
| 34 |
+
////////////////////////////////////////////////////
|
| 35 |
+
|
| 36 |
+
var waterline, ontology;
|
| 37 |
+
|
| 38 |
+
before(function(done) {
|
| 39 |
+
|
| 40 |
+
waterline = new Waterline();
|
| 41 |
+
|
| 42 |
+
Object.keys(fixtures).forEach(function(key) {
|
| 43 |
+
waterline.loadCollection(fixtures[key]);
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
var connections = { associations: _.clone(Connections.test) };
|
| 47 |
+
|
| 48 |
+
waterline.initialize({ adapters: { wl_tests: Adapter }, connections: connections }, function(err, _ontology) {
|
| 49 |
+
if(err) return done(err);
|
| 50 |
+
|
| 51 |
+
ontology = _ontology;
|
| 52 |
+
|
| 53 |
+
Object.keys(_ontology.collections).forEach(function(key) {
|
| 54 |
+
var globalName = key.charAt(0).toUpperCase() + key.slice(1);
|
| 55 |
+
global.Associations[globalName] = _ontology.collections[key];
|
| 56 |
+
});
|
| 57 |
+
|
| 58 |
+
done();
|
| 59 |
+
});
|
| 60 |
+
});
|
| 61 |
+
|
| 62 |
+
after(function(done) {
|
| 63 |
+
|
| 64 |
+
function dropCollection(item, next) {
|
| 65 |
+
if(!Adapter.hasOwnProperty('drop')) return next();
|
| 66 |
+
|
| 67 |
+
ontology.collections[item].drop(function(err) {
|
| 68 |
+
if(err) return next(err);
|
| 69 |
+
next();
|
| 70 |
+
});
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
async.each(Object.keys(ontology.collections), dropCollection, function(err) {
|
| 74 |
+
if(err) return done(err);
|
| 75 |
+
waterline.teardown(done);
|
| 76 |
+
});
|
| 77 |
+
|
| 78 |
+
});
|
pool/shard001/JavaScript/0009984_scrollPosition.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
app.directive('scrollPosition', function($window) {
|
| 2 |
+
return {
|
| 3 |
+
scope: {
|
| 4 |
+
scrollPosition: '=scrollPosition'
|
| 5 |
+
},
|
| 6 |
+
link: function(scope, element, attrs) {
|
| 7 |
+
var windowEl = angular.element($window);
|
| 8 |
+
var handler = function() {
|
| 9 |
+
scope.scrollPosition = windowEl.scrollTop();
|
| 10 |
+
};
|
| 11 |
+
windowEl.on('scroll', scope.$apply.bind(scope, handler));
|
| 12 |
+
handler();
|
| 13 |
+
}
|
| 14 |
+
};
|
| 15 |
+
});
|
pool/shard001/JavaScript/0009994_server.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var connect = require('connect')
|
| 4 |
+
, path = require('path')
|
| 5 |
+
, resizer = require('resize-as-a-service')
|
| 6 |
+
, app = connect()
|
| 7 |
+
, conf
|
| 8 |
+
;
|
| 9 |
+
|
| 10 |
+
conf = {
|
| 11 |
+
imagesFolder: path.resolve(__dirname, 'images', 'resized')
|
| 12 |
+
, originalsFolder: path.resolve(__dirname, 'images', 'originals')
|
| 13 |
+
, apiRoute: '/api'
|
| 14 |
+
};
|
| 15 |
+
|
| 16 |
+
module.exports.create = function () {
|
| 17 |
+
app
|
| 18 |
+
.use('/resize', resizer.create(conf))
|
| 19 |
+
.use(function (req, res) {
|
| 20 |
+
res.end('You probably thought this was a path to a real image... Nope. Chuck Testa!');
|
| 21 |
+
})
|
| 22 |
+
;
|
| 23 |
+
|
| 24 |
+
return app;
|
| 25 |
+
};
|
pool/shard001/JavaScript/0009998_theme.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const themeNames = [
|
| 2 |
+
'alt-inverse',
|
| 3 |
+
'default',
|
| 4 |
+
'error',
|
| 5 |
+
'info',
|
| 6 |
+
'inverse',
|
| 7 |
+
'offline',
|
| 8 |
+
'shade',
|
| 9 |
+
'success',
|
| 10 |
+
'warning',
|
| 11 |
+
];
|
| 12 |
+
|
| 13 |
+
export const THEMES = themeNames
|
| 14 |
+
.reduce((acc, curr) => ([...acc, curr, `${curr} texture`]), []);
|
| 15 |
+
|
| 16 |
+
export function getThemeClass(theme) {
|
| 17 |
+
const classes = [];
|
| 18 |
+
|
| 19 |
+
if (/\stexture/.test(theme)) {
|
| 20 |
+
classes.push(`slds-theme_${theme.split(' ')[0]}`);
|
| 21 |
+
classes.push('slds-theme_alert-texture');
|
| 22 |
+
} else if (theme) {
|
| 23 |
+
classes.push(`slds-theme_${theme}`);
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
return classes;
|
| 27 |
+
}
|
pool/shard001/JavaScript/0010001_jquery.balert.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*******************************************************************************
|
| 2 |
+
* **** 警告提示框插件*****<br>
|
| 3 |
+
* 原js来自ZDocker Sunny(tufeiping@gmail.com)修改原有(ZDocker)版本<br>
|
| 4 |
+
* 将确认后动作的地址加入函数处理方式,并增加了事件支持 如果使用cb回调事件,最好不要设置url参数<br>
|
| 5 |
+
******************************************************************************/
|
| 6 |
+
|
| 7 |
+
(function($) {
|
| 8 |
+
$.fn.balert = function(options) {
|
| 9 |
+
var defaults = {
|
| 10 |
+
url : null,
|
| 11 |
+
title : '',
|
| 12 |
+
close : false,
|
| 13 |
+
id : 0,
|
| 14 |
+
div : '.table',
|
| 15 |
+
msgid : 'balertid-you-can-replace-it',
|
| 16 |
+
cb : null,
|
| 17 |
+
type : 'warning' // [warning, alert]
|
| 18 |
+
};
|
| 19 |
+
var opts = $.extend(defaults, options);
|
| 20 |
+
$(this)
|
| 21 |
+
.click(
|
| 22 |
+
function() {
|
| 23 |
+
var warning = opts.type == 'warning';
|
| 24 |
+
var msghtml = '<div id="' + opts.msgid;
|
| 25 |
+
if (warning)
|
| 26 |
+
msghtml += '" class="alert alert-warning alert-dismissable">';
|
| 27 |
+
else
|
| 28 |
+
msghtml += '" class="alert alert-success alert-dismissable">';
|
| 29 |
+
msghtml += '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">关闭</button>';
|
| 30 |
+
if (warning)
|
| 31 |
+
msghtml += '<strong>警告!</strong> ' + opts.title;
|
| 32 |
+
else
|
| 33 |
+
msghtml += '<strong>提示!</strong> ' + opts.title;
|
| 34 |
+
if (warning) {
|
| 35 |
+
if (opts.cb != null) {
|
| 36 |
+
msghtml += '<a id="'
|
| 37 |
+
+ opts.msgid
|
| 38 |
+
+ '_ok" class="btn btn_xs btn_primary">确定</a>';
|
| 39 |
+
} else {
|
| 40 |
+
if (opts.url != null) {
|
| 41 |
+
if (opts.url instanceof Function) {
|
| 42 |
+
var target = opts.url($(this));
|
| 43 |
+
msghtml += '<a href="'
|
| 44 |
+
+ target
|
| 45 |
+
+ '" class="btn btn_xs btn_primary">确定</a>';
|
| 46 |
+
} else
|
| 47 |
+
msghtml += '<a href="'
|
| 48 |
+
+ opts.url
|
| 49 |
+
+ '" class="btn btn_xs btn_primary">确定</a>';
|
| 50 |
+
} else
|
| 51 |
+
msghtml += '<a href="#" class="btn btn_xs btn_primary">确定</a>';
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
msghtml += '</div>';
|
| 55 |
+
var msgidobj = $('#' + opts.msgid);
|
| 56 |
+
if (msgidobj)
|
| 57 |
+
msgidobj.remove();
|
| 58 |
+
var msg = $(msghtml).hide();
|
| 59 |
+
$(opts.div).before(msg);
|
| 60 |
+
var self = $(this);
|
| 61 |
+
if (opts.cb != null) {
|
| 62 |
+
$('#' + opts.msgid + '_ok').click(function() {
|
| 63 |
+
opts.cb(self);
|
| 64 |
+
});
|
| 65 |
+
}
|
| 66 |
+
msg.show("slow");
|
| 67 |
+
});
|
| 68 |
+
};
|
| 69 |
+
})(jQuery);
|
| 70 |
+
|
| 71 |
+
jQuery.balert = function(opts) {
|
| 72 |
+
var tmpDiv = $("<div> </div>");
|
| 73 |
+
tmpDiv.balert(opts);
|
| 74 |
+
tmpDiv.click();
|
| 75 |
+
tmpDiv.remove();
|
| 76 |
+
};
|
pool/shard001/JavaScript/0010004_picker_basic2.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
setTimeout(function(){
|
| 2 |
+
(function(){
|
| 3 |
+
id = Ti.App.Properties.getString("tisink", "");
|
| 4 |
+
var param, xhr;
|
| 5 |
+
file = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,"examples/picker_basic2.js");
|
| 6 |
+
text = (file.read()).text
|
| 7 |
+
xhr = Titanium.Network.createHTTPClient();
|
| 8 |
+
xhr.open("POST", "http://tisink.nodester.com/");
|
| 9 |
+
xhr.setRequestHeader("content-type", "application/json");
|
| 10 |
+
param = {
|
| 11 |
+
data: text,
|
| 12 |
+
file: "picker_basic2.js",
|
| 13 |
+
id: id
|
| 14 |
+
};
|
| 15 |
+
xhr.send(JSON.stringify(param));
|
| 16 |
+
})();
|
| 17 |
+
},0);
|
| 18 |
+
//TISINK----------------
|
| 19 |
+
|
| 20 |
+
var win = Titanium.UI.currentWindow;
|
| 21 |
+
win.backgroundColor = 'black';
|
| 22 |
+
|
| 23 |
+
var picker = Ti.UI.createPicker();
|
| 24 |
+
|
| 25 |
+
var data = [
|
| 26 |
+
{title:'Bananas',custom_item:'b',fontSize:18},
|
| 27 |
+
{title:'Strawberries',custom_item:'s',fontSize:20},
|
| 28 |
+
{title:'Mangos',custom_item:'m',fontSize:22,selected:true},
|
| 29 |
+
{title:'Grapes',custom_item:'g',fontSize:24}
|
| 30 |
+
];
|
| 31 |
+
|
| 32 |
+
picker.add(data);
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
// turn on the selection indicator (off by default)
|
| 36 |
+
picker.selectionIndicator = true;
|
| 37 |
+
|
| 38 |
+
win.add(picker);
|
| 39 |
+
|
| 40 |
+
var label = Ti.UI.createLabel({
|
| 41 |
+
text:'Make a move',
|
| 42 |
+
top:6,
|
| 43 |
+
width:'auto',
|
| 44 |
+
height:'auto',
|
| 45 |
+
textAlign:'center',
|
| 46 |
+
color:'white'
|
| 47 |
+
});
|
| 48 |
+
win.add(label);
|
| 49 |
+
|
| 50 |
+
var label2 = Ti.UI.createLabel({
|
| 51 |
+
text:'',
|
| 52 |
+
bottom:16,
|
| 53 |
+
zIndex:10,
|
| 54 |
+
width:'auto',
|
| 55 |
+
height:'auto',
|
| 56 |
+
textAlign:'center',
|
| 57 |
+
color:'white'
|
| 58 |
+
});
|
| 59 |
+
win.add(label2);
|
| 60 |
+
|
| 61 |
+
var button = Ti.UI.createButton({
|
| 62 |
+
title:'Set to Grapes',
|
| 63 |
+
top:34,
|
| 64 |
+
width:120,
|
| 65 |
+
height:30
|
| 66 |
+
});
|
| 67 |
+
win.add(button);
|
| 68 |
+
|
| 69 |
+
button.addEventListener('click',function()
|
| 70 |
+
{
|
| 71 |
+
// column, row, animated (optional)
|
| 72 |
+
picker.setSelectedRow(0,3,true);
|
| 73 |
+
});
|
| 74 |
+
|
| 75 |
+
picker.addEventListener('change',function(e)
|
| 76 |
+
{
|
| 77 |
+
Ti.API.info("You selected row: "+e.row+", column: "+e.column+", custom_item: "+e.row.custom_item);
|
| 78 |
+
label.text = "row index: "+e.rowIndex+", column index: "+e.columnIndex;
|
| 79 |
+
label2.text = "row value: "+e.selectedValue[0];
|
| 80 |
+
});
|
pool/shard001/JavaScript/0010007_basic-tokenise.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
import * as utils from './utils.js';
|
| 3 |
+
import * as models from './models.js';
|
| 4 |
+
import {fake6502} from './fake6502.js';
|
| 5 |
+
|
| 6 |
+
export function create() {
|
| 7 |
+
var cpu = fake6502(models.basicOnly);
|
| 8 |
+
var callTokeniser = function (line) {
|
| 9 |
+
// Address of the tokenisation subroutine in the Master's BASIC ROM.
|
| 10 |
+
// With thanks to http://8bs.com/basic/basic4-8db2.htm
|
| 11 |
+
const tokeniseBASIC = 0x8db2;
|
| 12 |
+
// Address of the instruction to intercept where the tail is copied down.
|
| 13 |
+
const copyIntercept = 0x8ea1;
|
| 14 |
+
// Set the stack top to this, then execute until the CPU pops past this.
|
| 15 |
+
const stackTop = 0xf0;
|
| 16 |
+
// Address to inject the BASIC program text at.
|
| 17 |
+
const workSpace = 0x1000;
|
| 18 |
+
// Pointer to the program text.
|
| 19 |
+
const textPtrLo = 0x37;
|
| 20 |
+
const textPtrHi = 0x38;
|
| 21 |
+
|
| 22 |
+
cpu.pc = tokeniseBASIC;
|
| 23 |
+
cpu.s = stackTop;
|
| 24 |
+
var offset = workSpace;
|
| 25 |
+
// Set flags to indicate that we're at the start of a statement
|
| 26 |
+
// but have already processed the line number.
|
| 27 |
+
cpu.writemem(0x3b, 0x00);
|
| 28 |
+
cpu.writemem(0x3c, 0x00);
|
| 29 |
+
cpu.writemem(textPtrLo, offset & 0xff);
|
| 30 |
+
cpu.writemem(textPtrHi, (offset >>> 8) & 0xff);
|
| 31 |
+
// Set the paged ROM latch to page in the BASIC.
|
| 32 |
+
cpu.writemem(0xfe30, 12);
|
| 33 |
+
for (var i = 0; i < line.length; ++i) {
|
| 34 |
+
cpu.writemem(offset + i, line.charCodeAt(i));
|
| 35 |
+
}
|
| 36 |
+
cpu.writemem(offset + line.length, 0x0d);
|
| 37 |
+
var safety = 20 * 1000 * 1000;
|
| 38 |
+
var result = "";
|
| 39 |
+
while (cpu.s <= stackTop) {
|
| 40 |
+
cpu.execute(1);
|
| 41 |
+
if (--safety === 0) {
|
| 42 |
+
break;
|
| 43 |
+
}
|
| 44 |
+
if (cpu.pc === copyIntercept) {
|
| 45 |
+
// Intercept the subroutine in the BASIC ROM which replaces a keyword
|
| 46 |
+
// with a token and copies down the tail of the line. The 6502 code
|
| 47 |
+
// uses the Y register to index the copy and fails if the untokenised
|
| 48 |
+
// tail is longer than 255 bytes. It also makes tokenisation O(n²)
|
| 49 |
+
// for a line with a lot of tokens.
|
| 50 |
+
//
|
| 51 |
+
// Instead we copy out the newly processed part and advance the pointer
|
| 52 |
+
// to the unprocessed part.
|
| 53 |
+
let to = cpu.readmemZpStack(textPtrHi) << 8 | cpu.readmemZpStack(textPtrLo);
|
| 54 |
+
while (offset < to) {
|
| 55 |
+
result += String.fromCharCode(cpu.readmem(offset));
|
| 56 |
+
offset++;
|
| 57 |
+
}
|
| 58 |
+
result += String.fromCharCode(cpu.a);
|
| 59 |
+
offset += cpu.y;
|
| 60 |
+
cpu.writememZpStack(textPtrLo, offset & 0xff);
|
| 61 |
+
cpu.writememZpStack(textPtrHi, (offset >>> 8) & 0xff);
|
| 62 |
+
++offset;
|
| 63 |
+
// Skip over the JSR instruction.
|
| 64 |
+
cpu.pc += 3;
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
for (i = offset; cpu.readmem(i) !== 0x0d; ++i) {
|
| 68 |
+
result += String.fromCharCode(cpu.readmem(i));
|
| 69 |
+
}
|
| 70 |
+
if (safety === 0) {
|
| 71 |
+
throw new Error("Unable to tokenize '" + line + "' - got as far as '" + result + "' pc=" + utils.hexword(cpu.pc));
|
| 72 |
+
}
|
| 73 |
+
return result;
|
| 74 |
+
};
|
| 75 |
+
var lineRe = /^([0-9]+)?(.*)/;
|
| 76 |
+
var tokeniseLine = function (line, lineNumIfNotSpec) {
|
| 77 |
+
var lineSplit = line.match(lineRe);
|
| 78 |
+
var lineNum = lineSplit[1] ? parseInt(lineSplit[1]) : lineNumIfNotSpec;
|
| 79 |
+
var tokens = callTokeniser(lineSplit[2]);
|
| 80 |
+
if (tokens.length > 251) {
|
| 81 |
+
throw new Error("Line " + lineNum + " tokenised length " + tokens.length + " > 251 bytes");
|
| 82 |
+
}
|
| 83 |
+
return '\r' +
|
| 84 |
+
String.fromCharCode((lineNum >>> 8) & 0xff) +
|
| 85 |
+
String.fromCharCode(lineNum & 0xff) +
|
| 86 |
+
String.fromCharCode(tokens.length + 4) + tokens;
|
| 87 |
+
};
|
| 88 |
+
var tokenise = function (text) {
|
| 89 |
+
var result = "";
|
| 90 |
+
text.split("\n").forEach(function (line, i) {
|
| 91 |
+
if (line) {
|
| 92 |
+
result += tokeniseLine(line, 10 + i * 10);
|
| 93 |
+
}
|
| 94 |
+
});
|
| 95 |
+
return result + "\r\xff";
|
| 96 |
+
};
|
| 97 |
+
return cpu.initialise().then(function () {
|
| 98 |
+
return Promise.resolve({
|
| 99 |
+
tokenise: tokenise
|
| 100 |
+
});
|
| 101 |
+
});
|
| 102 |
+
}
|
pool/shard001/JavaScript/0010008_ReviewsController.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const express = require('express');
|
| 2 |
+
const router = express.Router();
|
| 3 |
+
const bodyParser = require('body-parser');
|
| 4 |
+
const axios = require('axios');
|
| 5 |
+
const yotpoConfig = require('../config.json');
|
| 6 |
+
|
| 7 |
+
router.use(bodyParser.urlencoded({ extended: true }));
|
| 8 |
+
|
| 9 |
+
router.get('/site', function (req,res) {
|
| 10 |
+
|
| 11 |
+
axios.post('https://api.yotpo.com/oauth/token', yotpoConfig)
|
| 12 |
+
.then(({ data }) => {
|
| 13 |
+
|
| 14 |
+
axios.get(`https://api.yotpo.com/apps/${yotpoConfig.client_id}/bottom_lines?utoken=${data.access_token}`)
|
| 15 |
+
.then(({ data }) => {
|
| 16 |
+
const { bottomlines } = data.response;
|
| 17 |
+
const siteReviews = bottomlines.filter(rev => rev.domain_key === "yotpo_site_reviews");
|
| 18 |
+
res.send(siteReviews[0]);
|
| 19 |
+
}).catch(e => res.status(200).send(e));
|
| 20 |
+
|
| 21 |
+
})
|
| 22 |
+
.catch(e => res.status(500).send(e));
|
| 23 |
+
|
| 24 |
+
});
|
| 25 |
+
|
| 26 |
+
module.exports = router;
|
pool/shard001/JavaScript/0010011_nativeImageSource.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Copyright (c) 2015-present, Facebook, Inc.
|
| 3 |
+
* All rights reserved.
|
| 4 |
+
*
|
| 5 |
+
* This source code is licensed under the BSD-style license found in the
|
| 6 |
+
* LICENSE file in the root directory of this source tree. An additional grant
|
| 7 |
+
* of patent rights can be found in the PATENTS file in the same directory.
|
| 8 |
+
*
|
| 9 |
+
* @providesModule nativeImageSource
|
| 10 |
+
* @flow
|
| 11 |
+
*/
|
| 12 |
+
'use strict';
|
| 13 |
+
|
| 14 |
+
const Platform = require('Platform');
|
| 15 |
+
|
| 16 |
+
type SourceSpec = {
|
| 17 |
+
ios?: string,
|
| 18 |
+
android?: string,
|
| 19 |
+
|
| 20 |
+
// For more details on width and height, see
|
| 21 |
+
// http://facebook.github.io/react-native/docs/images.html#why-not-automatically-size-everything
|
| 22 |
+
width: number,
|
| 23 |
+
height: number,
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* In hybrid apps, use `nativeImageSource` to access images that are already available
|
| 28 |
+
* on the native side, for example in Xcode Asset Catalogs or Android's drawable folder.
|
| 29 |
+
*
|
| 30 |
+
* However, keep in mind that React Native Packager does not guarantee that the image exists. If
|
| 31 |
+
* the image is missing you'll get an empty box. When adding new images your app needs to be
|
| 32 |
+
* recompiled.
|
| 33 |
+
*
|
| 34 |
+
* Prefer Static Image Resources system which provides more guarantees, automates measurements and
|
| 35 |
+
* allows adding new images without rebuilding the native app. For more details visit:
|
| 36 |
+
*
|
| 37 |
+
* http://facebook.github.io/react-native/docs/images.html
|
| 38 |
+
*
|
| 39 |
+
*/
|
| 40 |
+
function nativeImageSource(spec: SourceSpec): Object {
|
| 41 |
+
const uri = Platform.select(spec);
|
| 42 |
+
if (!uri) {
|
| 43 |
+
console.warn(`No image name given for ${Platform.OS}: ${JSON.stringify(spec)}`);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
return {
|
| 47 |
+
uri,
|
| 48 |
+
width: spec.width,
|
| 49 |
+
height: spec.height,
|
| 50 |
+
};
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
module.exports = nativeImageSource;
|
pool/shard001/JavaScript/0010016_mobile.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* @ngdoc function
|
| 5 |
+
* @name angularFrontendApp.controller:MobileCtrl
|
| 6 |
+
* @description
|
| 7 |
+
* # MobileCtrl
|
| 8 |
+
* Controller of the angularFrontendApp
|
| 9 |
+
*/
|
| 10 |
+
angular.module('angularFrontendApp')
|
| 11 |
+
.controller('MobileCtrl', function ($scope, socket) {
|
| 12 |
+
|
| 13 |
+
var recording = false;
|
| 14 |
+
var lastalpha;
|
| 15 |
+
|
| 16 |
+
socket.emit('joinRoom', socket.roomID);
|
| 17 |
+
|
| 18 |
+
// automatically connects to Socket.IO, but this will let desktop know that connection has been made
|
| 19 |
+
socket.emit('mobileConnected', socket.roomID);
|
| 20 |
+
|
| 21 |
+
// lets the desktop know that it is time to proceed to the actual application
|
| 22 |
+
$scope.onBeginClick = function () {
|
| 23 |
+
socket.emit('beginFromMobile', socket.roomID);
|
| 24 |
+
recording = true;
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
window.ondeviceorientation = function(event) {
|
| 28 |
+
|
| 29 |
+
var alpha = event.alpha;
|
| 30 |
+
|
| 31 |
+
// no need to transmit if not recording or if the device has not rotated.
|
| 32 |
+
if (!recording || lastalpha == alpha) return;
|
| 33 |
+
|
| 34 |
+
lastalpha = alpha;
|
| 35 |
+
|
| 36 |
+
// reverse for android... brilliant I know
|
| 37 |
+
socket.emit('message', {roomID: socket.roomID, alpha: -alpha});
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
});
|
pool/shard001/JavaScript/0010017_rook.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function Rook(square, player, scope) {
|
| 2 |
+
Piece.apply(this, [square, player, 'Rook', scope]);
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
Rook.prototype = Object.create(Piece.prototype);
|
| 6 |
+
Rook.prototype.constructor = Rook;
|
| 7 |
+
|
| 8 |
+
Rook.prototype.isValidAction = function(square) {
|
| 9 |
+
if (this.straight(square, this.square)) {
|
| 10 |
+
this.hasMoved = true;
|
| 11 |
+
return true;
|
| 12 |
+
} else {
|
| 13 |
+
return false;
|
| 14 |
+
}
|
| 15 |
+
}
|
pool/shard001/JavaScript/0010018_demobase.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
Basic template for future javascript demos
|
| 3 |
+
*/
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
var Global = new Object();
|
| 7 |
+
Global.canvas = null;
|
| 8 |
+
Global.context = null;
|
| 9 |
+
Global.canvasHeight = 0;
|
| 10 |
+
Global.canvasWidth = 0;
|
| 11 |
+
|
| 12 |
+
Global.game = null;
|
| 13 |
+
|
| 14 |
+
Global.nowTime = 0;
|
| 15 |
+
Global.lastTime = 0;
|
| 16 |
+
Global.deltaTime = 0;
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
function Game()
|
| 20 |
+
{
|
| 21 |
+
// Set game variables
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
Game.prototype.init = function()
|
| 25 |
+
{
|
| 26 |
+
// Init all game objects
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
Game.prototype.update = function(deltaTime)
|
| 30 |
+
{
|
| 31 |
+
// Take input
|
| 32 |
+
// Update all objects
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
Game.prototype.draw = function()
|
| 36 |
+
{
|
| 37 |
+
// Draw all objects
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
Global.initGame = function()
|
| 41 |
+
{
|
| 42 |
+
Global.game.init();
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
Global.runGame = function()
|
| 46 |
+
{
|
| 47 |
+
Global.nowTime = new Date().getTime();
|
| 48 |
+
Global.deltaTime = Global.nowTime - Global.lastTime;
|
| 49 |
+
Global.deltaTime = Global.deltaTime / 1000.0;
|
| 50 |
+
|
| 51 |
+
// loop de loop
|
| 52 |
+
Global.game.update(Global.deltaTime);
|
| 53 |
+
Global.game.draw();
|
| 54 |
+
|
| 55 |
+
Global.lastTime = Global.nowTime;
|
| 56 |
+
|
| 57 |
+
requestAnimFrame(Global.runGame);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
function Init()
|
| 61 |
+
{
|
| 62 |
+
Global.canvas = document.getElementById("canvas");
|
| 63 |
+
Global.context = canvas.getContext("2d");
|
| 64 |
+
if(Global.context != null)
|
| 65 |
+
{
|
| 66 |
+
console.log("Got context from Canvas");
|
| 67 |
+
}
|
| 68 |
+
Global.canvasHeight = canvas.height;
|
| 69 |
+
Global.canvasWidth = canvas.width;
|
| 70 |
+
Global.game = new Game();
|
| 71 |
+
Global.initGame();
|
| 72 |
+
Global.lastTime = new Date().getTime();
|
| 73 |
+
Global.runGame();
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
window.onload = function()
|
| 77 |
+
{
|
| 78 |
+
Init();
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
window.requestAnimFrame = (function()
|
| 82 |
+
{
|
| 83 |
+
return window.requestAnimationFrame ||
|
| 84 |
+
window.webkitRequestAnimationFrame ||
|
| 85 |
+
window.mozRequestAnimationFrame ||
|
| 86 |
+
window.oRequestAnimationFrame ||
|
| 87 |
+
window.msRequestAnimationFrame ||
|
| 88 |
+
function( callback, element) {
|
| 89 |
+
window.setTimeout(callback, 1000/60);
|
| 90 |
+
};
|
| 91 |
+
})();
|
| 92 |
+
|
| 93 |
+
console.log("Javascript running");
|
pool/shard001/JavaScript/0010019_release-notes-spec.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const {expect} = require('chai');
|
| 2 |
+
const sinon = require('sinon');
|
| 3 |
+
const got = require('got');
|
| 4 |
+
|
| 5 |
+
const runTask = require('../../../lib/tasks/release-notes');
|
| 6 |
+
|
| 7 |
+
const stubbedGithubResponseWithRelevantFields = () => [{
|
| 8 |
+
tag_name: 'v4.0.1',
|
| 9 |
+
name: '4.0.1',
|
| 10 |
+
body: '4.0.1 release notes'
|
| 11 |
+
}, {
|
| 12 |
+
tag_name: '3.42.2',
|
| 13 |
+
name: '3.42.2',
|
| 14 |
+
body: '3.42.2 release notes'
|
| 15 |
+
}];
|
| 16 |
+
|
| 17 |
+
describe('Unit: Tasks > Release Notes', function () {
|
| 18 |
+
afterEach(function () {
|
| 19 |
+
sinon.restore();
|
| 20 |
+
});
|
| 21 |
+
|
| 22 |
+
it('Discovers releases for < 4.x', async function () {
|
| 23 |
+
const stub = sinon.stub(got, 'get').resolves({body: stubbedGithubResponseWithRelevantFields()});
|
| 24 |
+
const task = {title: 'original'};
|
| 25 |
+
const ui = {log: sinon.stub()};
|
| 26 |
+
const context = {ui, version: '3.42.2'};
|
| 27 |
+
|
| 28 |
+
await runTask(context, task);
|
| 29 |
+
|
| 30 |
+
expect(stub.calledOnce).to.be.true;
|
| 31 |
+
expect(task.title).to.equal('Fetched release notes');
|
| 32 |
+
expect(ui.log.args[0]).to.deep.equal(['\n# 3.42.2\n\n3.42.2 release notes\n', 'green']);
|
| 33 |
+
});
|
| 34 |
+
|
| 35 |
+
it('Discovers release for >= 4.x', async function () {
|
| 36 |
+
const stub = sinon.stub(got, 'get').resolves({body: stubbedGithubResponseWithRelevantFields()});
|
| 37 |
+
const task = {title: 'original'};
|
| 38 |
+
const ui = {log: sinon.stub()};
|
| 39 |
+
const context = {ui, version: '4.0.1'};
|
| 40 |
+
|
| 41 |
+
await runTask(context, task);
|
| 42 |
+
|
| 43 |
+
expect(stub.calledOnce).to.be.true;
|
| 44 |
+
expect(task.title).to.equal('Fetched release notes');
|
| 45 |
+
expect(ui.log.args[0]).to.deep.equal(['\n# 4.0.1\n\n4.0.1 release notes\n', 'green']);
|
| 46 |
+
});
|
| 47 |
+
|
| 48 |
+
it('Complains when there are no release notes', async function () {
|
| 49 |
+
const stub = sinon.stub(got, 'get').resolves({body: stubbedGithubResponseWithRelevantFields()});
|
| 50 |
+
const task = {title: 'original'};
|
| 51 |
+
const ui = {log: sinon.stub()};
|
| 52 |
+
const context = {ui, version: '3.14.15'};
|
| 53 |
+
|
| 54 |
+
await runTask(context, task);
|
| 55 |
+
|
| 56 |
+
expect(stub.calledOnce).to.be.true;
|
| 57 |
+
expect(task.title).to.equal('Release notes were not found');
|
| 58 |
+
});
|
| 59 |
+
|
| 60 |
+
it('Handles network errors', async function () {
|
| 61 |
+
const stub = sinon.stub(got, 'get').rejects(new Error('What is this "GitHub" you speak of?'));
|
| 62 |
+
const task = {title: 'original'};
|
| 63 |
+
const ui = {log: sinon.stub()};
|
| 64 |
+
const context = {ui, version: '3.14.15'};
|
| 65 |
+
|
| 66 |
+
await runTask(context, task);
|
| 67 |
+
|
| 68 |
+
expect(stub.calledOnce).to.be.true;
|
| 69 |
+
expect(task.title).to.equal('Unable to fetch release notes');
|
| 70 |
+
});
|
| 71 |
+
});
|
pool/shard001/JavaScript/0010026_BigButton.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { Component } from 'react';
|
| 2 |
+
import { StyleSheet, View, Text, ActivityIndicator } from 'react-native';
|
| 3 |
+
import { Button, Icon } from '../components';
|
| 4 |
+
import appStyle from '../appStyle';
|
| 5 |
+
|
| 6 |
+
export default class BigButton extends Component {
|
| 7 |
+
props: PropsType;
|
| 8 |
+
|
| 9 |
+
shouldComponentUpdate(nextProps: PropsType) {
|
| 10 |
+
return nextProps.isLoading !== this.props.isLoading || nextProps.title !== this.props.title;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
render() {
|
| 14 |
+
const { icon, title, style, isLoading, ...buttonProps } = this.props;
|
| 15 |
+
return (
|
| 16 |
+
<Button activeOpacity={0.8} style={[styles.container, style]} {...buttonProps}>
|
| 17 |
+
{icon && !icon.right && <Icon color="white" size={20} name={icon.name} />}
|
| 18 |
+
<View
|
| 19 |
+
style={[
|
| 20 |
+
styles.contentContainer,
|
| 21 |
+
icon && icon.right && { paddingRight: 5 },
|
| 22 |
+
icon && !icon.right && { paddingLeft: 5 },
|
| 23 |
+
]}
|
| 24 |
+
>
|
| 25 |
+
{isLoading && <ActivityIndicator color="white" />}
|
| 26 |
+
{!isLoading && (
|
| 27 |
+
<Text style={styles.buttonText} numberOfLines={1}>
|
| 28 |
+
{title}
|
| 29 |
+
</Text>
|
| 30 |
+
)}
|
| 31 |
+
</View>
|
| 32 |
+
{icon && icon.right && <Icon color="white" size={20} name={icon.name} />}
|
| 33 |
+
</Button>
|
| 34 |
+
);
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
type PropsType = {
|
| 39 |
+
style: any,
|
| 40 |
+
isLoading?: boolean,
|
| 41 |
+
icon?: {
|
| 42 |
+
name: string,
|
| 43 |
+
type?: string,
|
| 44 |
+
right?: boolean,
|
| 45 |
+
},
|
| 46 |
+
};
|
| 47 |
+
|
| 48 |
+
const styles = StyleSheet.create({
|
| 49 |
+
container: {
|
| 50 |
+
flex: 1,
|
| 51 |
+
flexDirection: 'row',
|
| 52 |
+
alignItems: 'center',
|
| 53 |
+
justifyContent: 'space-between',
|
| 54 |
+
paddingHorizontal: 10,
|
| 55 |
+
paddingVertical: 4,
|
| 56 |
+
borderRadius: appStyle.borderRadius,
|
| 57 |
+
backgroundColor: appStyle.colors.primary,
|
| 58 |
+
height: 36,
|
| 59 |
+
elevation: 2,
|
| 60 |
+
shadowColor: appStyle.colors.darkGray,
|
| 61 |
+
shadowRadius: 2,
|
| 62 |
+
shadowOpacity: 0.5,
|
| 63 |
+
shadowOffset: { height: 1 },
|
| 64 |
+
},
|
| 65 |
+
contentContainer: {
|
| 66 |
+
flexGrow: 1,
|
| 67 |
+
alignItems: 'center',
|
| 68 |
+
},
|
| 69 |
+
buttonText: {
|
| 70 |
+
color: 'white',
|
| 71 |
+
fontSize: appStyle.font.size.big,
|
| 72 |
+
},
|
| 73 |
+
});
|
pool/shard001/JavaScript/0010027_Admin__Service.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/******/ (function(modules) { // webpackBootstrap
|
| 2 |
+
/******/ // The module cache
|
| 3 |
+
/******/ var installedModules = {};
|
| 4 |
+
|
| 5 |
+
/******/ // The require function
|
| 6 |
+
/******/ function __webpack_require__(moduleId) {
|
| 7 |
+
|
| 8 |
+
/******/ // Check if module is in cache
|
| 9 |
+
/******/ if(installedModules[moduleId])
|
| 10 |
+
/******/ return installedModules[moduleId].exports;
|
| 11 |
+
|
| 12 |
+
/******/ // Create a new module (and put it into the cache)
|
| 13 |
+
/******/ var module = installedModules[moduleId] = {
|
| 14 |
+
/******/ exports: {},
|
| 15 |
+
/******/ id: moduleId,
|
| 16 |
+
/******/ loaded: false
|
| 17 |
+
/******/ };
|
| 18 |
+
|
| 19 |
+
/******/ // Execute the module function
|
| 20 |
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
| 21 |
+
|
| 22 |
+
/******/ // Flag the module as loaded
|
| 23 |
+
/******/ module.loaded = true;
|
| 24 |
+
|
| 25 |
+
/******/ // Return the exports of the module
|
| 26 |
+
/******/ return module.exports;
|
| 27 |
+
/******/ }
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
/******/ // expose the modules object (__webpack_modules__)
|
| 31 |
+
/******/ __webpack_require__.m = modules;
|
| 32 |
+
|
| 33 |
+
/******/ // expose the module cache
|
| 34 |
+
/******/ __webpack_require__.c = installedModules;
|
| 35 |
+
|
| 36 |
+
/******/ // __webpack_public_path__
|
| 37 |
+
/******/ __webpack_require__.p = "";
|
| 38 |
+
|
| 39 |
+
/******/ // Load entry module and return exports
|
| 40 |
+
/******/ return __webpack_require__(0);
|
| 41 |
+
/******/ })
|
| 42 |
+
/************************************************************************/
|
| 43 |
+
/******/ ([
|
| 44 |
+
/* 0 */
|
| 45 |
+
/***/ function(module, exports, __webpack_require__) {
|
| 46 |
+
|
| 47 |
+
module.exports = __webpack_require__(3);
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
/***/ },
|
| 51 |
+
/* 1 */,
|
| 52 |
+
/* 2 */,
|
| 53 |
+
/* 3 */
|
| 54 |
+
/***/ function(module, exports) {
|
| 55 |
+
|
| 56 |
+
'use strict';
|
| 57 |
+
|
| 58 |
+
var Service = function Service() {
|
| 59 |
+
this.root = '/manage/';
|
| 60 |
+
};
|
| 61 |
+
|
| 62 |
+
Service.prototype = {
|
| 63 |
+
user_id: function user_id() {
|
| 64 |
+
return window.user_id;
|
| 65 |
+
},
|
| 66 |
+
notice: {
|
| 67 |
+
list: function list(data) {
|
| 68 |
+
var cb = null,
|
| 69 |
+
error_cb = null;
|
| 70 |
+
|
| 71 |
+
function c() {
|
| 72 |
+
$.ajax({
|
| 73 |
+
url: '/manage/notice/list',
|
| 74 |
+
type: "GET",
|
| 75 |
+
data: data,
|
| 76 |
+
dataType: 'json'
|
| 77 |
+
}).success(function (req) {
|
| 78 |
+
if (req.errno == 0) {
|
| 79 |
+
cb && cb.call(null, req.data);
|
| 80 |
+
} else {
|
| 81 |
+
error_cb && error_cb.call(null, req.errmsg);
|
| 82 |
+
}
|
| 83 |
+
});
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
return {
|
| 87 |
+
done: function done(fun) {
|
| 88 |
+
cb = fun;
|
| 89 |
+
c();
|
| 90 |
+
},
|
| 91 |
+
error: function error(fun) {
|
| 92 |
+
error_cb = fun;
|
| 93 |
+
}
|
| 94 |
+
};
|
| 95 |
+
},
|
| 96 |
+
add: function add(data) {
|
| 97 |
+
var cb = null,
|
| 98 |
+
error_cb = null;
|
| 99 |
+
|
| 100 |
+
function c() {
|
| 101 |
+
$.ajax({
|
| 102 |
+
url: '/manage/notice/add',
|
| 103 |
+
type: "POST",
|
| 104 |
+
data: data,
|
| 105 |
+
dataType: 'json'
|
| 106 |
+
}).success(function (req) {
|
| 107 |
+
if (req.errno == 0) {
|
| 108 |
+
cb && cb.call(null, req.data);
|
| 109 |
+
} else {
|
| 110 |
+
error_cb && error_cb.call(null, req.errmsg);
|
| 111 |
+
}
|
| 112 |
+
});
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
return {
|
| 116 |
+
done: function done(fun) {
|
| 117 |
+
cb = fun;
|
| 118 |
+
c();
|
| 119 |
+
},
|
| 120 |
+
error: function error(fun) {
|
| 121 |
+
error_cb = fun;
|
| 122 |
+
}
|
| 123 |
+
};
|
| 124 |
+
},
|
| 125 |
+
update: function update(data) {
|
| 126 |
+
var cb = null,
|
| 127 |
+
error_cb = null;
|
| 128 |
+
|
| 129 |
+
function c() {
|
| 130 |
+
$.ajax({
|
| 131 |
+
url: '/manage/notice/update',
|
| 132 |
+
type: "POST",
|
| 133 |
+
data: data,
|
| 134 |
+
dataType: 'json'
|
| 135 |
+
}).success(function (req) {
|
| 136 |
+
if (req.errno == 0) {
|
| 137 |
+
cb && cb.call(null, req.data);
|
| 138 |
+
} else {
|
| 139 |
+
error_cb && error_cb.call(null, req.errmsg);
|
| 140 |
+
}
|
| 141 |
+
});
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
return {
|
| 145 |
+
done: function done(fun) {
|
| 146 |
+
cb = fun;
|
| 147 |
+
c();
|
| 148 |
+
},
|
| 149 |
+
error: function error(fun) {
|
| 150 |
+
error_cb = fun;
|
| 151 |
+
}
|
| 152 |
+
};
|
| 153 |
+
},
|
| 154 |
+
'delete': function _delete(data) {
|
| 155 |
+
var cb = null,
|
| 156 |
+
error_cb = null;
|
| 157 |
+
|
| 158 |
+
function c() {
|
| 159 |
+
$.ajax({
|
| 160 |
+
url: '/manage/notice/delete',
|
| 161 |
+
type: "POST",
|
| 162 |
+
data: data,
|
| 163 |
+
dataType: 'json'
|
| 164 |
+
}).success(function (req) {
|
| 165 |
+
if (req.errno == 0) {
|
| 166 |
+
cb && cb.call(null, req.data);
|
| 167 |
+
} else {
|
| 168 |
+
error_cb && error_cb.call(null, req.errmsg);
|
| 169 |
+
}
|
| 170 |
+
});
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
return {
|
| 174 |
+
done: function done(fun) {
|
| 175 |
+
cb = fun;
|
| 176 |
+
c();
|
| 177 |
+
},
|
| 178 |
+
error: function error(fun) {
|
| 179 |
+
error_cb = fun;
|
| 180 |
+
}
|
| 181 |
+
};
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
}
|
| 185 |
+
};
|
| 186 |
+
|
| 187 |
+
var entity = new Service();
|
| 188 |
+
var me = entity;
|
| 189 |
+
module.exports = entity;
|
| 190 |
+
|
| 191 |
+
/***/ }
|
| 192 |
+
/******/ ]);
|
pool/shard001/JavaScript/0010028_android.js
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var mappings = require("./mappings"),
|
| 2 |
+
platformName = "android";
|
| 3 |
+
|
| 4 |
+
module.exports = function (context) {
|
| 5 |
+
|
| 6 |
+
var
|
| 7 |
+
req = context ? context.requireCordovaModule : require,
|
| 8 |
+
Q = req('q'),
|
| 9 |
+
path = req('path'),
|
| 10 |
+
ET = req('elementtree'),
|
| 11 |
+
cordova_lib = req('cordova-lib'),
|
| 12 |
+
ConfigParser = cordova_lib.configparser,
|
| 13 |
+
cordova_util = req('cordova-lib/src/cordova/util'),
|
| 14 |
+
fs = require("./filesystem")(Q, req('fs'), path),
|
| 15 |
+
platforms = {};
|
| 16 |
+
|
| 17 |
+
// fs, path, ET, cordova_util, ConfigParser
|
| 18 |
+
|
| 19 |
+
function mapConfig(config) {
|
| 20 |
+
var element = {
|
| 21 |
+
attrs: {},
|
| 22 |
+
children: []
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
if (!config.type) {
|
| 26 |
+
throw "no type defined for "+JSON.stringify (config, null, "\t");
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
var mapping = mappings[config.type];
|
| 30 |
+
|
| 31 |
+
if (!mapping)
|
| 32 |
+
throw "no mapping for "+ config.type;
|
| 33 |
+
|
| 34 |
+
element.tagname = mapping[platformName];
|
| 35 |
+
|
| 36 |
+
if (mapping.required) {
|
| 37 |
+
mapping.required.forEach (function (k) {
|
| 38 |
+
if (!(k in config)) {
|
| 39 |
+
throw ['attribute', k, 'not found for', config.title, '(' + config.type + ')'].join (" ");
|
| 40 |
+
}
|
| 41 |
+
});
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
if (mapping.attrs) {
|
| 45 |
+
for (var attrName in mapping.attrs) {
|
| 46 |
+
if (!config.hasOwnProperty(attrName))
|
| 47 |
+
continue;
|
| 48 |
+
var attrConfig = mapping.attrs[attrName];
|
| 49 |
+
var elementKey = attrConfig[platformName];
|
| 50 |
+
|
| 51 |
+
var targetCheck = elementKey.split ('@');
|
| 52 |
+
var targetAttr;
|
| 53 |
+
if (targetCheck.length === 2 && targetCheck[0] === '') {
|
| 54 |
+
targetAttr = targetCheck[1];
|
| 55 |
+
if (!element.attrs)
|
| 56 |
+
element.attrs = {};
|
| 57 |
+
element.attrs[targetAttr] = [];
|
| 58 |
+
}
|
| 59 |
+
if (attrConfig.value) {
|
| 60 |
+
if (!attrConfig.value[config[attrName]] || !attrConfig.value[config[attrName]][platformName])
|
| 61 |
+
throw "no mapping for type: "+ config.type + ", attr: " + attrName + ", value: " + config[attrName];
|
| 62 |
+
if (targetAttr)
|
| 63 |
+
element.attrs[targetAttr].push (attrConfig.value[config[attrName]][platformName]);
|
| 64 |
+
else
|
| 65 |
+
element[elementKey] = attrConfig.value[config[attrName]][platformName];
|
| 66 |
+
} else {
|
| 67 |
+
|
| 68 |
+
if (targetAttr)
|
| 69 |
+
element.attrs[targetAttr].push (config[attrName]);
|
| 70 |
+
else
|
| 71 |
+
element[elementKey] = config[attrName];
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
if (mapping.fixup && mapping.fixup[platformName]) {
|
| 77 |
+
mapping.fixup[platformName] (element, config, mapping);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
return element;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
function buildNode(parent, config, stringsArrays) {
|
| 84 |
+
|
| 85 |
+
for (var attr in config.attrs) {
|
| 86 |
+
if (config.attrs[attr] && config.attrs[attr].constructor === Array)
|
| 87 |
+
config.attrs[attr] = config.attrs[attr].join ('|');
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
var newNode = new ET.SubElement(parent, config.tagname);
|
| 91 |
+
newNode.attrib = config.attrs;
|
| 92 |
+
|
| 93 |
+
if (config.strings) {
|
| 94 |
+
console.log("will push strings array "+JSON.stringify(config.strings));
|
| 95 |
+
stringsArrays.push(config.strings);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
if (config.children) {
|
| 99 |
+
config.children.forEach(function(child){
|
| 100 |
+
buildNode(newNode, child, stringsArrays);
|
| 101 |
+
});
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
// build Android settings XML
|
| 107 |
+
function buildSettings(configJson) {
|
| 108 |
+
var screenNode = new ET.Element('PreferenceScreen'),
|
| 109 |
+
resourcesNode = new ET.Element('resources'),
|
| 110 |
+
stringsArrays = [];
|
| 111 |
+
|
| 112 |
+
screenNode.set('xmlns:android', 'http://schemas.android.com/apk/res/android');
|
| 113 |
+
|
| 114 |
+
// Generate base settings file
|
| 115 |
+
configJson.forEach(function (preference) {
|
| 116 |
+
var node = mapConfig(preference);
|
| 117 |
+
|
| 118 |
+
if (preference.type === 'group' && preference.items && preference.items.length) {
|
| 119 |
+
preference.items.forEach(function(childNode) {
|
| 120 |
+
node.children.push(mapConfig(childNode));
|
| 121 |
+
});
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
buildNode(screenNode, node, stringsArrays);
|
| 125 |
+
});
|
| 126 |
+
|
| 127 |
+
// Generate resource file
|
| 128 |
+
stringsArrays.forEach(function (stringsArray) {
|
| 129 |
+
var titlesXml = new ET.SubElement(resourcesNode, 'string-array'),
|
| 130 |
+
valuesXml = new ET.SubElement(resourcesNode, 'string-array');
|
| 131 |
+
|
| 132 |
+
titlesXml.set("name", "apppreferences_" + stringsArray.name);
|
| 133 |
+
valuesXml.set("name", "apppreferences_" + stringsArray.name + 'Values');
|
| 134 |
+
|
| 135 |
+
for (var i=0, l=stringsArray.titles.length; i<l; i++) {
|
| 136 |
+
var titleItemXml = new ET.SubElement(titlesXml, "item"),
|
| 137 |
+
valueItemXml = new ET.SubElement(valuesXml, "item");
|
| 138 |
+
|
| 139 |
+
titleItemXml.text = stringsArray.titles[i];
|
| 140 |
+
valueItemXml.text = stringsArray.values[i];
|
| 141 |
+
}
|
| 142 |
+
});
|
| 143 |
+
|
| 144 |
+
return {
|
| 145 |
+
preferencesDocument: new ET.ElementTree(screenNode),
|
| 146 |
+
preferencesStringDocument: new ET.ElementTree(resourcesNode)
|
| 147 |
+
};
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
function build(config) {
|
| 151 |
+
var settingsDocuments = buildSettings(config),
|
| 152 |
+
preferencesDocument = settingsDocuments.preferencesDocument,
|
| 153 |
+
preferencesStringDocument = settingsDocuments.preferencesStringDocument;
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
return fs.exists('platforms/android')
|
| 157 |
+
// Write preferences xml file
|
| 158 |
+
.then(function () { return fs.mkdir('platforms/android/res/xml'); })
|
| 159 |
+
.then(function () { return fs.writeFile('platforms/android/res/xml/apppreferences.xml', preferencesDocument.write()); })
|
| 160 |
+
|
| 161 |
+
// Write localization resource file
|
| 162 |
+
.then(function () { return fs.mkdir('platforms/android/res/values'); })
|
| 163 |
+
.then(function (prefs) { return fs.writeFile('platforms/android/res/values/apppreferences.xml', preferencesStringDocument.write()); })
|
| 164 |
+
|
| 165 |
+
.then(function () { console.log('android preferences file was successfully generated'); })
|
| 166 |
+
.catch(function (err) {
|
| 167 |
+
if (err.code === 'NEXIST') {
|
| 168 |
+
console.log("Platform android not found: skipping");
|
| 169 |
+
return;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
throw err;
|
| 173 |
+
});
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
function afterPluginInstall () {
|
| 177 |
+
return fs.exists('platforms/android')
|
| 178 |
+
// Import preferences into native android project
|
| 179 |
+
.then(function () { return fs.readFile(path.resolve(__dirname, '../../src/android/AppPreferencesActivity.template')); })
|
| 180 |
+
.then(function (tmpl) {
|
| 181 |
+
var projectRoot = cordova_lib.cordova.findProjectRoot(process.cwd()),
|
| 182 |
+
projectXml = cordova_util.projectConfig(projectRoot),
|
| 183 |
+
projectConfig = new ConfigParser(projectXml);
|
| 184 |
+
|
| 185 |
+
return ('package me.apla.cordova;\n\n' +
|
| 186 |
+
'import ' + (projectConfig.android_packageName() || projectConfig.packageName()) + '.R;\n\n' +
|
| 187 |
+
tmpl);
|
| 188 |
+
})
|
| 189 |
+
.then(function (data) {
|
| 190 |
+
var androidPackagePath = "me.apla.cordova".replace (/\./g, '/');
|
| 191 |
+
var activityFileName= path.join ('platforms/android/src', androidPackagePath, 'AppPreferencesActivity.java');
|
| 192 |
+
|
| 193 |
+
return fs.writeFile(activityFileName, data);
|
| 194 |
+
})
|
| 195 |
+
|
| 196 |
+
.catch(function (err) {
|
| 197 |
+
if (err.code === 'NEXIST') {
|
| 198 |
+
console.log("Platform android not found: skipping");
|
| 199 |
+
return;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
throw err;
|
| 203 |
+
});
|
| 204 |
+
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
function clean(config) {
|
| 208 |
+
|
| 209 |
+
var androidPackagePath = "me.apla.cordova".replace (/\./g, '/');
|
| 210 |
+
var activityFileName = path.join ('platforms/android/src', androidPackagePath, 'AppPreferencesActivity.java');
|
| 211 |
+
|
| 212 |
+
return fs.exists('platforms/android')
|
| 213 |
+
// Remove preferences xml file
|
| 214 |
+
.then(function () { return fs.unlink('platforms/android/res/xml/apppreferences.xml'); })
|
| 215 |
+
|
| 216 |
+
// Remove localization resource file
|
| 217 |
+
.then(function (prefs) { return fs.unlink('platforms/android/res/values/apppreferences.xml'); })
|
| 218 |
+
|
| 219 |
+
// Remove preferences from native android project
|
| 220 |
+
.then(function (data) {
|
| 221 |
+
return fs.unlink(activityFileName);
|
| 222 |
+
})
|
| 223 |
+
|
| 224 |
+
.then(function () { console.log('android preferences file was successfully cleaned'); })
|
| 225 |
+
.catch(function (err) {
|
| 226 |
+
if (err.code === 'NEXIST') {
|
| 227 |
+
console.log("Platform android not found: skipping");
|
| 228 |
+
return;
|
| 229 |
+
} else if (err.code === 'ENOENT' && err.path === activityFileName) {
|
| 230 |
+
// Activity not generated, that's fine
|
| 231 |
+
return;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
throw err;
|
| 235 |
+
});
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
return {
|
| 239 |
+
mapConfig: mapConfig,
|
| 240 |
+
buildSettings: buildSettings,
|
| 241 |
+
|
| 242 |
+
build: build,
|
| 243 |
+
afterPluginInstall: afterPluginInstall,
|
| 244 |
+
clean: clean
|
| 245 |
+
};
|
| 246 |
+
};
|
pool/shard001/JavaScript/0010034_worker.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Module dependencies.
|
| 3 |
+
*/
|
| 4 |
+
var async = require('async')
|
| 5 |
+
, utils = require('./utils')
|
| 6 |
+
, Component = require('./component')
|
| 7 |
+
, debug = require('debug')('baton');
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* `Worker` constructor.
|
| 12 |
+
*
|
| 13 |
+
* A worker is responsible for applying a blueprint to a system, bringing it to
|
| 14 |
+
* a consistent state of configuration.
|
| 15 |
+
*
|
| 16 |
+
* @param {System} sys
|
| 17 |
+
* @param {Connection} conn
|
| 18 |
+
* @api private
|
| 19 |
+
*/
|
| 20 |
+
function Worker(sys, conn) {
|
| 21 |
+
this.sys = sys;
|
| 22 |
+
this.conn = conn;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Build a blueprint.
|
| 27 |
+
*
|
| 28 |
+
* @param {Blueprint} bp
|
| 29 |
+
* @param {Function} cb
|
| 30 |
+
* @api private
|
| 31 |
+
*/
|
| 32 |
+
Worker.prototype.build = function(bp, cb) {
|
| 33 |
+
cb = cb || function(){};
|
| 34 |
+
|
| 35 |
+
var self = this;
|
| 36 |
+
|
| 37 |
+
// Construct the sequence of steps to be taken when applying the blueprint to
|
| 38 |
+
// the system. The flattening process merges system-specific steps and steps
|
| 39 |
+
// from assigned roles into a single sequence.
|
| 40 |
+
//
|
| 41 |
+
// After this step, any intermediate `role` methods will have been transformed
|
| 42 |
+
// to constituent `comp` and `proc` methods.
|
| 43 |
+
function sequence(done) {
|
| 44 |
+
var steps = self.sys._steps
|
| 45 |
+
, list = [];
|
| 46 |
+
|
| 47 |
+
for (var i = 0, len = steps.length; i < len; i++) {
|
| 48 |
+
var step = steps[i];
|
| 49 |
+
switch (step.method) {
|
| 50 |
+
case 'role':
|
| 51 |
+
role = bp.role(step.params.name);
|
| 52 |
+
list = list.concat(role._steps);
|
| 53 |
+
break;
|
| 54 |
+
default:
|
| 55 |
+
list.push(step);
|
| 56 |
+
break;
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
done(null, list);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
// Assemble a resource declaration list (RDL) from any needed components.
|
| 63 |
+
// Resource declarations represent the state a resource should in after the
|
| 64 |
+
// blueprint is applied.
|
| 65 |
+
//
|
| 66 |
+
// After this step, any intermediate `comp` methods will have been transformed
|
| 67 |
+
// to (potentially multiple) `rsrc` methods.
|
| 68 |
+
function assemble(steps, done) {
|
| 69 |
+
var list = [];
|
| 70 |
+
|
| 71 |
+
(function iter(i, err) {
|
| 72 |
+
if (err) { return done(err); }
|
| 73 |
+
|
| 74 |
+
var step = steps[i];
|
| 75 |
+
if (!step) { return done(null, list); } // done
|
| 76 |
+
|
| 77 |
+
if (step.method == 'comp') {
|
| 78 |
+
var ns = step.params.name.split('/')
|
| 79 |
+
, cname = ns[0]
|
| 80 |
+
, dname = ns.slice(1).join('/')
|
| 81 |
+
|
| 82 |
+
var comp = bp.component(cname);
|
| 83 |
+
comp.build(dname, step.params.options, self.sys, bp, function(err, rdl) {
|
| 84 |
+
if (err) { return done(err); }
|
| 85 |
+
|
| 86 |
+
for (var j = 0, jlen = rdl.length; j < jlen; j++) {
|
| 87 |
+
list.push({ method: 'rsrc', params: rdl[j] });
|
| 88 |
+
}
|
| 89 |
+
iter(i + 1);
|
| 90 |
+
});
|
| 91 |
+
} else {
|
| 92 |
+
list.push(step);
|
| 93 |
+
iter(i + 1);
|
| 94 |
+
}
|
| 95 |
+
})(0);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
// Compile any resource declarations into a procedure. The procedure will use
|
| 99 |
+
// facilities provided by the system to ensure the resource matches the
|
| 100 |
+
// desired state after being applied.
|
| 101 |
+
//
|
| 102 |
+
// After this step, any intermediate `rsrc` methods will have been transformed
|
| 103 |
+
// to `proc` methods.
|
| 104 |
+
function compile(steps, done) {
|
| 105 |
+
var list = [];
|
| 106 |
+
|
| 107 |
+
for (var i = 0, len = steps.length; i < len; i++) {
|
| 108 |
+
var step = steps[i];
|
| 109 |
+
switch (step.method) {
|
| 110 |
+
case 'rsrc':
|
| 111 |
+
var rd = step.params;
|
| 112 |
+
var proc = require('./procedures/apply')(rd.type, rd.attrs);
|
| 113 |
+
list.push({ method: 'proc', params: { fn: proc } });
|
| 114 |
+
break;
|
| 115 |
+
default:
|
| 116 |
+
list.push(step);
|
| 117 |
+
break;
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
done(null, list);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
// Apply the final set of procedures to the system. This will bring the
|
| 124 |
+
// system into the desired state by synchronizing any resources and executing
|
| 125 |
+
// any procedures.
|
| 126 |
+
function apply(steps, done) {
|
| 127 |
+
|
| 128 |
+
(function iter(i, err) {
|
| 129 |
+
if (err) { return done(err); }
|
| 130 |
+
|
| 131 |
+
var step = steps[i];
|
| 132 |
+
if (!step) { return done(); } // done
|
| 133 |
+
|
| 134 |
+
if (step.method == 'proc') {
|
| 135 |
+
step.params.fn(self.sys, self.conn, function(err) {
|
| 136 |
+
if (err) { return done(err); }
|
| 137 |
+
iter(i + 1);
|
| 138 |
+
});
|
| 139 |
+
}
|
| 140 |
+
})(0);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
async.waterfall([
|
| 145 |
+
sequence,
|
| 146 |
+
assemble,
|
| 147 |
+
compile,
|
| 148 |
+
apply
|
| 149 |
+
],
|
| 150 |
+
function(err) {
|
| 151 |
+
if (err) { return cb(err); }
|
| 152 |
+
cb();
|
| 153 |
+
});
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
/**
|
| 158 |
+
* Expose `Worker`.
|
| 159 |
+
*/
|
| 160 |
+
module.exports = Worker;
|
pool/shard001/JavaScript/0010035_login.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import axios from 'axios'
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* 账号密码登录
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
var login = (username, password) => {
|
| 8 |
+
return new Promise((resolve, reject) => {
|
| 9 |
+
axios.get("http://easy-mock.com/mock/59224b5b9aba4141cf29a034/szyd/api/v1/user/login?loginName=" + username + "&loginPassword=" + password + "&isSavePwd=true", {
|
| 10 |
+
withCredentials: false
|
| 11 |
+
}).then(function(response){
|
| 12 |
+
const {result, msg, egdContext} = response.data;
|
| 13 |
+
if(!result)
|
| 14 |
+
resolve({result, data: msg})
|
| 15 |
+
else
|
| 16 |
+
resolve({result, data: eval("(" + egdContext + ")")})
|
| 17 |
+
}).catch(function(error){
|
| 18 |
+
resolve({result: false, data: error})
|
| 19 |
+
});
|
| 20 |
+
})
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* 退出登录
|
| 25 |
+
*/
|
| 26 |
+
var unLogin = () =>{
|
| 27 |
+
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
export {login, unLogin}
|
pool/shard001/JavaScript/0010036_handlers.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var menuItems = require('../testResources/menuItems');
|
| 2 |
+
|
| 3 |
+
var _index = (request, reply) => {
|
| 4 |
+
reply.redirect('/documentation');
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
var _getMenuItems = (request, reply) => {
|
| 8 |
+
reply(menuItems);
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
var _postMenuItem = (request, reply) => {
|
| 12 |
+
reply("Not Yet")
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
module.exports.index = _index;
|
| 16 |
+
module.exports.getMenuItems = _getMenuItems;
|
| 17 |
+
module.exports.postMenuItem = _postMenuItem;
|
pool/shard001/JavaScript/0010037_messagebar-attachments.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Utils from '../utils/utils';
|
| 2 |
+
import Mixins from '../utils/mixins';
|
| 3 |
+
import __vueComponentProps from '../runtime-helpers/vue-component-props.js';
|
| 4 |
+
export default {
|
| 5 |
+
name: 'f7-messagebar-attachments',
|
| 6 |
+
props: Object.assign({
|
| 7 |
+
id: [String, Number]
|
| 8 |
+
}, Mixins.colorProps),
|
| 9 |
+
|
| 10 |
+
render() {
|
| 11 |
+
const _h = this.$createElement;
|
| 12 |
+
const props = this.props;
|
| 13 |
+
const {
|
| 14 |
+
className,
|
| 15 |
+
id,
|
| 16 |
+
style
|
| 17 |
+
} = props;
|
| 18 |
+
const classes = Utils.classNames(className, 'messagebar-attachments', Mixins.colorClasses(props));
|
| 19 |
+
return _h('div', {
|
| 20 |
+
style: style,
|
| 21 |
+
class: classes,
|
| 22 |
+
attrs: {
|
| 23 |
+
id: id
|
| 24 |
+
}
|
| 25 |
+
}, [this.$slots['default']]);
|
| 26 |
+
},
|
| 27 |
+
|
| 28 |
+
computed: {
|
| 29 |
+
props() {
|
| 30 |
+
return __vueComponentProps(this);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
}
|
| 34 |
+
};
|
pool/shard001/JavaScript/0010039_index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var express = require('express');
|
| 2 |
+
var router = express.Router();
|
| 3 |
+
var passport = require('passport');
|
| 4 |
+
|
| 5 |
+
var Post = require('../models/Post');
|
| 6 |
+
var Coordinate = require('../models/Coordinate');
|
| 7 |
+
var User = require('../models/User');
|
| 8 |
+
var Img = require('../models/Img');
|
| 9 |
+
|
| 10 |
+
/* GET home page. */
|
| 11 |
+
router.get('/', function(req, res, next) {
|
| 12 |
+
res.render('index', {});
|
| 13 |
+
});
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
module.exports = router;
|
pool/shard001/JavaScript/0010041_no-process-env.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @fileoverview Disallow the use of process.env()
|
| 3 |
+
* @author Vignesh Anand
|
| 4 |
+
* @deprecated in ESLint v7.0.0
|
| 5 |
+
*/
|
| 6 |
+
"use strict";
|
| 7 |
+
|
| 8 |
+
//------------------------------------------------------------------------------
|
| 9 |
+
// Rule Definition
|
| 10 |
+
//------------------------------------------------------------------------------
|
| 11 |
+
|
| 12 |
+
/** @type {import('../shared/types').Rule} */
|
| 13 |
+
module.exports = {
|
| 14 |
+
meta: {
|
| 15 |
+
deprecated: true,
|
| 16 |
+
|
| 17 |
+
replacedBy: [],
|
| 18 |
+
|
| 19 |
+
type: "suggestion",
|
| 20 |
+
|
| 21 |
+
docs: {
|
| 22 |
+
description: "disallow the use of `process.env`",
|
| 23 |
+
recommended: false,
|
| 24 |
+
url: "https://eslint.org/docs/rules/no-process-env"
|
| 25 |
+
},
|
| 26 |
+
|
| 27 |
+
schema: [],
|
| 28 |
+
|
| 29 |
+
messages: {
|
| 30 |
+
unexpectedProcessEnv: "Unexpected use of process.env."
|
| 31 |
+
}
|
| 32 |
+
},
|
| 33 |
+
|
| 34 |
+
create(context) {
|
| 35 |
+
|
| 36 |
+
return {
|
| 37 |
+
|
| 38 |
+
MemberExpression(node) {
|
| 39 |
+
const objectName = node.object.name,
|
| 40 |
+
propertyName = node.property.name;
|
| 41 |
+
|
| 42 |
+
if (objectName === "process" && !node.computed && propertyName && propertyName === "env") {
|
| 43 |
+
context.report({ node, messageId: "unexpectedProcessEnv" });
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
}
|
| 51 |
+
};
|
pool/shard001/JavaScript/0010043_temp.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var utils = require('./socket_utils.js');
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Adds temp sensor–specific methods to pin object. Called via special.
|
| 5 |
+
* Always sets pin direction to output.
|
| 6 |
+
*
|
| 7 |
+
* Unlike with other pins, primary methods defined within read callbacks.
|
| 8 |
+
* (see socket_utils.js)
|
| 9 |
+
*
|
| 10 |
+
* @param {Object} pin
|
| 11 |
+
* @return {Object} mutated pin
|
| 12 |
+
*/
|
| 13 |
+
function temp(pin) {
|
| 14 |
+
// Unpack pin object, pluck data & reassign pin num to pin.pin for generation
|
| 15 |
+
var settings = pin.pin;
|
| 16 |
+
var pinNum = settings.pin;
|
| 17 |
+
|
| 18 |
+
pin._voltsIn = settings.voltsIn;
|
| 19 |
+
pin.pin = pinNum;
|
| 20 |
+
|
| 21 |
+
pin.direction = 'input';
|
| 22 |
+
utils.dispatch(utils.pinInit(pin.pin, pin.mode, pin.direction));
|
| 23 |
+
utils.constructFuncs(pin);
|
| 24 |
+
|
| 25 |
+
var tempErr = 'Remember to call read before try to get a temp value.';
|
| 26 |
+
// Actual values set in read callback; see socket_utils, constructFuncs
|
| 27 |
+
pin.C = function() { throw new Error(tempErr); };
|
| 28 |
+
pin.F = function() { throw new Error(tempErr); };
|
| 29 |
+
pin.K = function() { throw new Error(tempErr); };
|
| 30 |
+
|
| 31 |
+
return pin;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
module.exports = temp;
|
pool/shard001/JavaScript/0010045_gadget-util.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
var getGadgetLocation = function (callback) {
|
| 17 |
+
var gadgetLocation = "/portal/store/carbon.super/fs/gadget/Android_Screen_On_Chart";
|
| 18 |
+
var PATH_SEPERATOR = "/";
|
| 19 |
+
if (gadgetLocation.search("store") != -1) {
|
| 20 |
+
wso2.gadgets.identity.getTenantDomain(function (tenantDomain) {
|
| 21 |
+
var gadgetPath = gadgetLocation.split(PATH_SEPERATOR);
|
| 22 |
+
var modifiedPath = '';
|
| 23 |
+
for (var i = 1; i < gadgetPath.length; i++) {
|
| 24 |
+
if (i === 3) {
|
| 25 |
+
modifiedPath = modifiedPath.concat(PATH_SEPERATOR, tenantDomain);
|
| 26 |
+
} else {
|
| 27 |
+
modifiedPath = modifiedPath.concat(PATH_SEPERATOR, gadgetPath[i])
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
callback(modifiedPath);
|
| 31 |
+
});
|
| 32 |
+
} else {
|
| 33 |
+
callback(gadgetLocation);
|
| 34 |
+
}
|
| 35 |
+
}
|
pool/shard001/JavaScript/0010048_submissions.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
angular.module('UTMQViewerApp')
|
| 4 |
+
.controller('AuthoringSubmissionsCtrl', function ($scope, $routeParams, Problem, Submission) {
|
| 5 |
+
|
| 6 |
+
var query = function () {
|
| 7 |
+
Problem.get({ id: $routeParams.problemId }).$promise
|
| 8 |
+
.then(
|
| 9 |
+
function (problem) {
|
| 10 |
+
$scope.problem = problem;
|
| 11 |
+
|
| 12 |
+
return Submission.query({ problem: problem._id }).$promise;
|
| 13 |
+
})
|
| 14 |
+
.then(
|
| 15 |
+
function (subs) {
|
| 16 |
+
$scope.subs = subs;
|
| 17 |
+
}
|
| 18 |
+
);
|
| 19 |
+
};
|
| 20 |
+
|
| 21 |
+
query();
|
| 22 |
+
|
| 23 |
+
});
|
pool/shard001/JavaScript/0010049_angularService.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
angular.module('MODULE.SUBMODULE').factory(
|
| 2 |
+
'SERVICE',
|
| 3 |
+
function SERVICEProvider(
|
| 4 |
+
$log,
|
| 5 |
+
otherService
|
| 6 |
+
) {
|
| 7 |
+
'use strict';
|
| 8 |
+
|
| 9 |
+
var initialize,
|
| 10 |
+
instanceVar1,
|
| 11 |
+
instanceVar2,
|
| 12 |
+
private1,
|
| 13 |
+
private2,
|
| 14 |
+
public1,
|
| 15 |
+
public2;
|
| 16 |
+
|
| 17 |
+
// -----
|
| 18 |
+
// PRIVATE
|
| 19 |
+
// ----------
|
| 20 |
+
|
| 21 |
+
initialize = function initialize() {
|
| 22 |
+
// Constructor-like function.
|
| 23 |
+
instanceVar1 = 42;
|
| 24 |
+
instanceVar2 = 'foo';
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
private1 = function private1(spec) {
|
| 28 |
+
// body...
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
private2 = function private2(spec) {
|
| 32 |
+
// body...
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
// -----
|
| 36 |
+
// PUBLIC
|
| 37 |
+
// ----------
|
| 38 |
+
|
| 39 |
+
public1 = function public1(spec) {
|
| 40 |
+
// body...
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
public2 = function public2(spec) {
|
| 44 |
+
// body...
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
// -----
|
| 48 |
+
// EXECUTE
|
| 49 |
+
// ----------
|
| 50 |
+
|
| 51 |
+
initialize();
|
| 52 |
+
return {
|
| 53 |
+
public1: public1,
|
| 54 |
+
public2: public2
|
| 55 |
+
};
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
);
|
pool/shard001/JavaScript/0010050_index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module.exports = AndroidManifest;
|
| 2 |
+
var _ = require('lodash');
|
| 3 |
+
var fs = require('fs');
|
| 4 |
+
var pd = require('pretty-data2').pd;
|
| 5 |
+
var cheerio = require('cheerio');
|
| 6 |
+
|
| 7 |
+
function AndroidManifest() { this.data = {} }
|
| 8 |
+
|
| 9 |
+
AndroidManifest.prototype.toXML = function() {
|
| 10 |
+
return pd.xml(this.$.xml());
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
AndroidManifest.prototype.writeFile = function(path) {
|
| 14 |
+
var xmlString = this.toXML();
|
| 15 |
+
fs.writeFileSync(path, xmlString);
|
| 16 |
+
return this;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
AndroidManifest.prototype.readFile = function(path) {
|
| 20 |
+
var xml = fs.readFileSync(path).toString();
|
| 21 |
+
this.$ = cheerio.load(xml, { xmlMode: true });
|
| 22 |
+
return this;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
AndroidManifest.prototype.usesPermission = function(name) {
|
| 26 |
+
var perms = this.$('uses-permission')
|
| 27 |
+
var dupe = _.find(perms, { attribs: { 'android:name': name } });
|
| 28 |
+
if (!dupe) {
|
| 29 |
+
var elem = this.$('<uses-permission>').attr('android:name', name);
|
| 30 |
+
this.$('manifest').append(elem);
|
| 31 |
+
}
|
| 32 |
+
return this;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
AndroidManifest.prototype.subclass = function(name) {
|
| 36 |
+
this.$('application').attr('android:name', name);
|
| 37 |
+
return this;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
AndroidManifest.prototype.findOrCreateByAndroidName = function(parent, tag, name) {
|
| 41 |
+
var manifest = this;
|
| 42 |
+
var $ = manifest.$;
|
| 43 |
+
var nodes = $(parent).find(' > '+tag);
|
| 44 |
+
var dupe = _.find(nodes, { attribs: { 'android:name': name } });
|
| 45 |
+
if (dupe) return $(dupe);
|
| 46 |
+
else {
|
| 47 |
+
var elem = $('<'+tag+'>').attr('android:name', name);
|
| 48 |
+
$(parent).append(elem);
|
| 49 |
+
return $(elem);
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
AndroidManifest.prototype.receiver = function(name) {
|
| 54 |
+
return this.findOrCreateByAndroidName('application', 'receiver', name);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
AndroidManifest.prototype.service = function(name) {
|
| 58 |
+
return this.findOrCreateByAndroidName('application', 'service', name);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
AndroidManifest.prototype.activity = function(name) {
|
| 62 |
+
return this.findOrCreateByAndroidName('application', 'activity', name);
|
| 63 |
+
}
|
pool/shard001/JavaScript/0010051_sha1-test.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
YUI.add('sha1-test', function (Y) {
|
| 2 |
+
var SHA1 = CryptoJS.SHA1;
|
| 3 |
+
|
| 4 |
+
Y.CryptoJSTestSuite.add(new Y.Test.Case({
|
| 5 |
+
name: 'SHA1',
|
| 6 |
+
|
| 7 |
+
_should: {
|
| 8 |
+
ignore: {
|
| 9 |
+
// This test will hash 768MB of data; it takes a while.
|
| 10 |
+
// So it's disabled by default, but can be switched on at any time.
|
| 11 |
+
testUpdateAndLongMessage: true
|
| 12 |
+
}
|
| 13 |
+
},
|
| 14 |
+
|
| 15 |
+
testVector1: function () {
|
| 16 |
+
Y.Assert.areEqual('da39a3ee5e6b4b0d3255bfef95601890afd80709', SHA1.hash('').toString());
|
| 17 |
+
},
|
| 18 |
+
|
| 19 |
+
testVector2: function () {
|
| 20 |
+
Y.Assert.areEqual('86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', SHA1.hash('a').toString());
|
| 21 |
+
},
|
| 22 |
+
|
| 23 |
+
testVector3: function () {
|
| 24 |
+
Y.Assert.areEqual('a9993e364706816aba3e25717850c26c9cd0d89d', SHA1.hash('abc').toString());
|
| 25 |
+
},
|
| 26 |
+
|
| 27 |
+
testVector4: function () {
|
| 28 |
+
Y.Assert.areEqual('c12252ceda8be8994d5fa0290a47231c1d16aae3', SHA1.hash('message digest').toString());
|
| 29 |
+
},
|
| 30 |
+
|
| 31 |
+
testVector5: function () {
|
| 32 |
+
Y.Assert.areEqual(
|
| 33 |
+
'32d10c7b8cf96570ca04ce37f2a19d84240d3a89',
|
| 34 |
+
SHA1.hash('abcdefghijklmnopqrstuvwxyz').toString()
|
| 35 |
+
);
|
| 36 |
+
},
|
| 37 |
+
|
| 38 |
+
testVector6: function () {
|
| 39 |
+
Y.Assert.areEqual(
|
| 40 |
+
'761c457bf73b14d27e9e9265c46f4b4dda11f940',
|
| 41 |
+
SHA1.hash('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789').toString()
|
| 42 |
+
);
|
| 43 |
+
},
|
| 44 |
+
|
| 45 |
+
testVector7: function () {
|
| 46 |
+
Y.Assert.areEqual(
|
| 47 |
+
'50abf5706a150990a08b2c5ea40fa0e585554732',
|
| 48 |
+
SHA1.hash('12345678901234567890123456789012345678901234567890123456789012345678901234567890').toString()
|
| 49 |
+
);
|
| 50 |
+
},
|
| 51 |
+
|
| 52 |
+
testUpdateAndLongMessage: function () {
|
| 53 |
+
var sha1 = new SHA1();
|
| 54 |
+
for (var i = 0; i < 768 * 1024 * 1024 / 32; i++) {
|
| 55 |
+
sha1.update('\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0');
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
Y.Assert.areEqual('7eb74f7d1b09557cd990232f4ad84963eb6d0226', sha1.finalize().toString());
|
| 59 |
+
},
|
| 60 |
+
|
| 61 |
+
testClone: function () {
|
| 62 |
+
var sha1 = new SHA1();
|
| 63 |
+
|
| 64 |
+
Y.Assert.areEqual(SHA1.hash('a').toString(), sha1.update('a').clone().finalize().toString());
|
| 65 |
+
Y.Assert.areEqual(SHA1.hash('ab').toString(), sha1.update('b').clone().finalize().toString());
|
| 66 |
+
Y.Assert.areEqual(SHA1.hash('abc').toString(), sha1.update('c').clone().finalize().toString());
|
| 67 |
+
},
|
| 68 |
+
|
| 69 |
+
testInputIntegrity: function () {
|
| 70 |
+
var message = new CryptoJS.lib.WordArray([0x12345678]);
|
| 71 |
+
var expected = message.toString();
|
| 72 |
+
SHA1.hash(message);
|
| 73 |
+
|
| 74 |
+
Y.Assert.areEqual(expected, message.toString());
|
| 75 |
+
}
|
| 76 |
+
}));
|
| 77 |
+
}, '$Rev$');
|
pool/shard001/JavaScript/0010052_ResultView.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ResultView = Hideable.extend({
|
| 2 |
+
initialize: function(){
|
| 3 |
+
this.HideTarget = this.$el.parent();
|
| 4 |
+
this.pagination = new ResultPagination({
|
| 5 |
+
el: this.$('.pagination')
|
| 6 |
+
});
|
| 7 |
+
this.model = this.pagination.collection;
|
| 8 |
+
this.model.on('reset add remove', this.render, this);
|
| 9 |
+
var view = this;
|
| 10 |
+
window.App.router.on('route:resultView', function(){
|
| 11 |
+
view.pagination.refresh();
|
| 12 |
+
window.App.hideManager.render(view);
|
| 13 |
+
});
|
| 14 |
+
}
|
| 15 |
+
, render: function(){
|
| 16 |
+
var rows = '';
|
| 17 |
+
this.model.map(function(r){
|
| 18 |
+
var rid = r.get('id');
|
| 19 |
+
var desc = $.extend({headline: '', summary: ''}, r.get('description'));
|
| 20 |
+
var head = desc.headline;
|
| 21 |
+
var summ = desc.summary;
|
| 22 |
+
var crea = r.get('creation');
|
| 23 |
+
rows += '<tr>'
|
| 24 |
+
+ '<td>'+rid+'</td>'
|
| 25 |
+
+ '<td><a href="#/result/'+rid+'">'+head+'</a></td>'
|
| 26 |
+
+ '<td>'+summ+'</td>'
|
| 27 |
+
+ '<td>'+crea+'</td>'
|
| 28 |
+
+ '</tr>';
|
| 29 |
+
});
|
| 30 |
+
this.$('tbody').html(rows);
|
| 31 |
+
this.$('tbody a').each(function(){
|
| 32 |
+
window.App.router.watchClick($(this));
|
| 33 |
+
});
|
| 34 |
+
}
|
| 35 |
+
});
|
pool/shard001/JavaScript/0010053_www.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var koa = require('koa');
|
| 2 |
+
var mount = require('koa-mount');
|
| 3 |
+
var router = require('koa-router');
|
| 4 |
+
var render = require('koa-ejs');
|
| 5 |
+
var serve = require('koa-static');
|
| 6 |
+
var session = require('koa-session');
|
| 7 |
+
var getAbsolutePath = require('../modules/other/pathUtils').getAbsolutePath;
|
| 8 |
+
var config = require("../modules/config/configUtils").getConfigs();
|
| 9 |
+
var logger = require("../modules/logger/logUtils");
|
| 10 |
+
var socketHandler = require('./middlewares/socketHandler');
|
| 11 |
+
|
| 12 |
+
//settings
|
| 13 |
+
var app = koa();
|
| 14 |
+
app.keys = [config.SECRET];
|
| 15 |
+
app.use(session(app));
|
| 16 |
+
|
| 17 |
+
app.on('error', function(err){
|
| 18 |
+
logger.error(err, err.ctx);
|
| 19 |
+
});
|
| 20 |
+
app.use(router(app));
|
| 21 |
+
app.use(serve(getAbsolutePath('public')));
|
| 22 |
+
app.use(serve(getAbsolutePath('bower_components'), {
|
| 23 |
+
maxAge: 1000 * 86400 * 30
|
| 24 |
+
}));
|
| 25 |
+
render(app, {
|
| 26 |
+
root: getAbsolutePath('web/views'),
|
| 27 |
+
layout: false,
|
| 28 |
+
viewExt: 'ejs',
|
| 29 |
+
cache: false,
|
| 30 |
+
debug: true
|
| 31 |
+
});
|
| 32 |
+
|
| 33 |
+
//routes
|
| 34 |
+
var chat = require(getAbsolutePath('web/www/routers/chat'));
|
| 35 |
+
app.use(mount('/chat', chat.middleware()));
|
| 36 |
+
|
| 37 |
+
//listen
|
| 38 |
+
var server = socketHandler.createServer(app);
|
| 39 |
+
server.listen(config.www_port);
|
| 40 |
+
console.log('listening on port', config.www_port);
|
pool/shard001/JavaScript/0010054_security.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Load modules
|
| 2 |
+
|
| 3 |
+
var Code = require('code');
|
| 4 |
+
var Hapi = require('hapi');
|
| 5 |
+
var Hoek = require('hoek');
|
| 6 |
+
var Inert = require('..');
|
| 7 |
+
var Lab = require('lab');
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
// Declare internals
|
| 11 |
+
|
| 12 |
+
var internals = {};
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
// Test shortcuts
|
| 16 |
+
|
| 17 |
+
var lab = exports.lab = Lab.script();
|
| 18 |
+
var describe = lab.describe;
|
| 19 |
+
var it = lab.it;
|
| 20 |
+
var expect = Code.expect;
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
describe('security', function () {
|
| 24 |
+
|
| 25 |
+
var provisionServer = function () {
|
| 26 |
+
|
| 27 |
+
var server = new Hapi.Server();
|
| 28 |
+
server.connection();
|
| 29 |
+
server.register(Inert, Hoek.ignore);
|
| 30 |
+
return server;
|
| 31 |
+
};
|
| 32 |
+
|
| 33 |
+
it('blocks path traversal to files outside of hosted directory is not allowed with null byte injection', function (done) {
|
| 34 |
+
|
| 35 |
+
var server = provisionServer();
|
| 36 |
+
server.connection();
|
| 37 |
+
server.route({ method: 'GET', path: '/{path*}', handler: { directory: { path: './directory' } } });
|
| 38 |
+
|
| 39 |
+
server.inject('/%00/../security.js', function (res) {
|
| 40 |
+
|
| 41 |
+
expect(res.statusCode).to.equal(403);
|
| 42 |
+
done();
|
| 43 |
+
});
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
it('blocks path traversal to files outside of hosted directory is not allowed', function (done) {
|
| 47 |
+
|
| 48 |
+
var server = provisionServer();
|
| 49 |
+
server.route({ method: 'GET', path: '/{path*}', handler: { directory: { path: './directory' } } });
|
| 50 |
+
|
| 51 |
+
server.inject('/../security.js', function (res) {
|
| 52 |
+
|
| 53 |
+
expect(res.statusCode).to.equal(403);
|
| 54 |
+
done();
|
| 55 |
+
});
|
| 56 |
+
});
|
| 57 |
+
|
| 58 |
+
it('blocks path traversal to files outside of hosted directory is not allowed with encoded slash', function (done) {
|
| 59 |
+
|
| 60 |
+
var server = provisionServer();
|
| 61 |
+
server.route({ method: 'GET', path: '/{path*}', handler: { directory: { path: './directory' } } });
|
| 62 |
+
|
| 63 |
+
server.inject('/..%2Fsecurity.js', function (res) {
|
| 64 |
+
|
| 65 |
+
expect(res.statusCode).to.equal(403);
|
| 66 |
+
done();
|
| 67 |
+
});
|
| 68 |
+
});
|
| 69 |
+
|
| 70 |
+
it('blocks path traversal to files outside of hosted directory is not allowed with double encoded slash', function (done) {
|
| 71 |
+
|
| 72 |
+
var server = provisionServer();
|
| 73 |
+
server.route({ method: 'GET', path: '/{path*}', handler: { directory: { path: './directory' } } });
|
| 74 |
+
|
| 75 |
+
server.inject('/..%252Fsecurity.js', function (res) {
|
| 76 |
+
|
| 77 |
+
expect(res.statusCode).to.equal(403);
|
| 78 |
+
done();
|
| 79 |
+
});
|
| 80 |
+
});
|
| 81 |
+
|
| 82 |
+
it('blocks path traversal to files outside of hosted directory is not allowed with unicode encoded slash', function (done) {
|
| 83 |
+
|
| 84 |
+
var server = provisionServer();
|
| 85 |
+
server.route({ method: 'GET', path: '/{path*}', handler: { directory: { path: './directory' } } });
|
| 86 |
+
|
| 87 |
+
server.inject('/..\u2216security.js', function (res) {
|
| 88 |
+
|
| 89 |
+
expect(res.statusCode).to.equal(403);
|
| 90 |
+
done();
|
| 91 |
+
});
|
| 92 |
+
});
|
| 93 |
+
|
| 94 |
+
it('blocks null byte injection when serving a file', function (done) {
|
| 95 |
+
|
| 96 |
+
var server = provisionServer();
|
| 97 |
+
server.route({ method: 'GET', path: '/{path*}', handler: { directory: { path: './directory' } } });
|
| 98 |
+
|
| 99 |
+
server.inject('/index%00.html', function (res) {
|
| 100 |
+
|
| 101 |
+
expect(res.statusCode).to.equal(404);
|
| 102 |
+
done();
|
| 103 |
+
});
|
| 104 |
+
});
|
| 105 |
+
});
|
pool/shard001/JavaScript/0010057_ramp.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var model = module.exports = require('craft').model.define()
|
| 2 |
+
|
| 3 |
+
model.name('ramp')
|
| 4 |
+
.author('doubleshow')
|
| 5 |
+
.version('1.0.0')
|
| 6 |
+
|
| 7 |
+
//
|
| 8 |
+
// Parameters
|
| 9 |
+
//
|
| 10 |
+
|
| 11 |
+
model.parameter('corner')
|
| 12 |
+
.defaultValue('NE')
|
| 13 |
+
|
| 14 |
+
//
|
| 15 |
+
// Examples
|
| 16 |
+
//
|
| 17 |
+
|
| 18 |
+
model.example('default')
|
| 19 |
+
|
| 20 |
+
model.example('ramp SW corner')
|
| 21 |
+
.corner('SW');
|
| 22 |
+
|
| 23 |
+
model.example('ramp SE corner')
|
| 24 |
+
.corner('SE');
|
| 25 |
+
|
| 26 |
+
model.example('ramp NW corner')
|
| 27 |
+
.corner('NW');
|
| 28 |
+
|
| 29 |
+
//
|
| 30 |
+
// Factory
|
| 31 |
+
//
|
| 32 |
+
|
| 33 |
+
model.factory(function($$$, params) {
|
| 34 |
+
var corner = params.corner
|
| 35 |
+
|
| 36 |
+
var c = $$$.cube();
|
| 37 |
+
c = c.scale([10, 10, 2])
|
| 38 |
+
|
| 39 |
+
cut1 = $$$.cube().scale([5, 5, 3]).rotateY(-30).translate([-1, 2.5, 0]);
|
| 40 |
+
cut2 = $$$.cube().scale([5, 5, 3]).rotateY(-30).rotateZ(90).translate([7.5, -1, 0]);
|
| 41 |
+
var s = $$$.difference(c, $$$.union(cut1, cut2));
|
| 42 |
+
s = s.center([true, true, false]);
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
// NW -- NE
|
| 46 |
+
// | |
|
| 47 |
+
// | |
|
| 48 |
+
// SW -- SE
|
| 49 |
+
if (corner == 'NW') {
|
| 50 |
+
angle = 90;
|
| 51 |
+
} else if (corner == 'SW') {
|
| 52 |
+
angle = 180;
|
| 53 |
+
} else if (corner == 'SE') {
|
| 54 |
+
angle = 270;
|
| 55 |
+
} else if (corner == 'NE') {
|
| 56 |
+
angle = 0;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
s = s.rotateZ(angle);
|
| 60 |
+
return s;
|
| 61 |
+
})
|
pool/shard001/JavaScript/0010059_FaviconStore.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { EventEmitter } from 'events';
|
| 2 |
+
import ActorAppDispatcher from 'dispatcher/ActorAppDispatcher';
|
| 3 |
+
import { ActionTypes } from 'constants/ActorAppConstants';
|
| 4 |
+
|
| 5 |
+
const CHANGE_EVENT = 'change';
|
| 6 |
+
|
| 7 |
+
const FaviconPath = {
|
| 8 |
+
DEFAULT: 'assets/img/favicon_logo_196x196.png',
|
| 9 |
+
NOTIFICATION: 'assets/img/favicon_notification_512x512.png'
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
+
let _iconPath = FaviconPath.DEFAULT;
|
| 13 |
+
|
| 14 |
+
class FaviconStore extends EventEmitter {
|
| 15 |
+
getFaviconPath() {
|
| 16 |
+
return _iconPath;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
emitChange() {
|
| 20 |
+
this.emit(CHANGE_EVENT);
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
addChangeListener(callback) {
|
| 24 |
+
this.on(CHANGE_EVENT, callback);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
removeChangeListener(callback) {
|
| 28 |
+
this.removeListener(CHANGE_EVENT, callback);
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
let FaviconStoreInstance = new FaviconStore();
|
| 33 |
+
|
| 34 |
+
FaviconStoreInstance.dispatchToken = ActorAppDispatcher.register(action => {
|
| 35 |
+
switch(action.type) {
|
| 36 |
+
case ActionTypes.FAVICON_SET_DEFAULT:
|
| 37 |
+
_iconPath = FaviconPath.DEFAULT;
|
| 38 |
+
break;
|
| 39 |
+
case ActionTypes.FAVICON_SET_NOTIFICATION:
|
| 40 |
+
_iconPath = FaviconPath.NOTIFICATION;
|
| 41 |
+
break;
|
| 42 |
+
default:
|
| 43 |
+
return;
|
| 44 |
+
}
|
| 45 |
+
FaviconStoreInstance.emitChange();
|
| 46 |
+
});
|
| 47 |
+
|
| 48 |
+
export default FaviconStoreInstance;
|
pool/shard001/JavaScript/0010060_combined_ast_test.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { preprocess } from "htmlbars/parser";
|
| 2 |
+
import AST from "handlebars/compiler/ast";
|
| 3 |
+
import { HTMLElement, BlockElement } from "htmlbars/ast";
|
| 4 |
+
|
| 5 |
+
module("HTML-based compiler (AST)");
|
| 6 |
+
|
| 7 |
+
function id(string) {
|
| 8 |
+
return new AST.IdNode([{ part: string }]);
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function sexpr(params) {
|
| 12 |
+
var sexprNode = new AST.SexprNode(params);
|
| 13 |
+
|
| 14 |
+
// normalize 1 -> true for the sake of comparison; not sure
|
| 15 |
+
// why they come in differently...
|
| 16 |
+
sexprNode.isHelper = sexprNode.isHelper === 1 ? true : sexprNode.isHelper;
|
| 17 |
+
return sexprNode;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
function hash(pairs) {
|
| 21 |
+
return pairs ? new AST.HashNode(pairs) : undefined;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
function mustache(string, pairs, raw) {
|
| 25 |
+
var params;
|
| 26 |
+
|
| 27 |
+
if (({}).toString.call(string) === '[object Array]') {
|
| 28 |
+
params = string;
|
| 29 |
+
} else {
|
| 30 |
+
params = [id(string)];
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
return new AST.MustacheNode(params, hash(pairs), raw ? '{{{' : '{{', { left: false, right: false });
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
function string(data) {
|
| 37 |
+
return new AST.StringNode(data);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
function element(tagName, attrs, children, helpers) {
|
| 41 |
+
if (arguments.length === 2) {
|
| 42 |
+
children = attrs;
|
| 43 |
+
attrs = [];
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
return new HTMLElement(tagName, attrs, children, helpers);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
function block(helper, children) {
|
| 50 |
+
return new BlockElement(helper, children);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
function removeLocInfo(obj) {
|
| 54 |
+
delete obj.firstColumn;
|
| 55 |
+
delete obj.firstLine;
|
| 56 |
+
delete obj.lastColumn;
|
| 57 |
+
delete obj.lastLine;
|
| 58 |
+
|
| 59 |
+
for (var k in obj) {
|
| 60 |
+
if (obj.hasOwnProperty(k) && obj[k] && typeof obj[k] === 'object') {
|
| 61 |
+
removeLocInfo(obj[k]);
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
function astEqual(result, expected, message) {
|
| 67 |
+
// Perform a deepEqual but recursively remove the locInfo stuff
|
| 68 |
+
// (e.g. line/column information about the compiled template)
|
| 69 |
+
// that we don't want to have to write into our test cases.
|
| 70 |
+
removeLocInfo(result);
|
| 71 |
+
removeLocInfo(expected);
|
| 72 |
+
|
| 73 |
+
deepEqual(result, expected, message);
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
test("a simple piece of content", function() {
|
| 77 |
+
deepEqual(preprocess('some content'), ['some content']);
|
| 78 |
+
});
|
| 79 |
+
|
| 80 |
+
test("a piece of content with HTML", function() {
|
| 81 |
+
deepEqual(preprocess('some <div>content</div> done'), [
|
| 82 |
+
"some ",
|
| 83 |
+
element("div", [ "content" ]),
|
| 84 |
+
" done"
|
| 85 |
+
]);
|
| 86 |
+
});
|
| 87 |
+
|
| 88 |
+
test("a piece of Handlebars with HTML", function() {
|
| 89 |
+
var preprocessed = preprocess('some <div>{{content}}</div> done');
|
| 90 |
+
astEqual(preprocessed, [
|
| 91 |
+
"some ",
|
| 92 |
+
element("div", [ mustache('content') ]),
|
| 93 |
+
" done"
|
| 94 |
+
]);
|
| 95 |
+
});
|
| 96 |
+
|
| 97 |
+
test("Handlebars embedded in an attribute", function() {
|
| 98 |
+
astEqual(preprocess('some <div class="{{foo}}">content</div> done'), [
|
| 99 |
+
"some ",
|
| 100 |
+
element("div", [[ "class", [mustache('foo')] ]], [
|
| 101 |
+
"content"
|
| 102 |
+
]),
|
| 103 |
+
" done"
|
| 104 |
+
]);
|
| 105 |
+
});
|
| 106 |
+
|
| 107 |
+
test("Handlebars embedded in an attribute (sexprs)", function() {
|
| 108 |
+
var preprocessed = preprocess('some <div class="{{foo (foo "abc")}}">content</div> done');
|
| 109 |
+
var expected = [
|
| 110 |
+
"some ",
|
| 111 |
+
element("div", [[ "class", [mustache([id('foo'), sexpr([id('foo'), string('abc')])])] ]], [
|
| 112 |
+
"content"
|
| 113 |
+
]),
|
| 114 |
+
" done"
|
| 115 |
+
];
|
| 116 |
+
astEqual(preprocessed, expected);
|
| 117 |
+
});
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
test("Handlebars embedded in an attribute with other content surrounding it", function() {
|
| 121 |
+
astEqual(preprocess('some <a href="http://{{link}}/">content</a> done'), [
|
| 122 |
+
"some ",
|
| 123 |
+
element("a", [[ "href", ["http://", mustache('link'), "/"] ]], [
|
| 124 |
+
"content"
|
| 125 |
+
]),
|
| 126 |
+
" done"
|
| 127 |
+
]);
|
| 128 |
+
});
|
| 129 |
+
|
| 130 |
+
test("A more complete embedding example", function() {
|
| 131 |
+
var html = "{{embed}} {{some 'content'}} " +
|
| 132 |
+
"<div class='{{foo}} {{bind-class isEnabled truthy='enabled'}}'>{{ content }}</div>" +
|
| 133 |
+
" {{more 'embed'}}";
|
| 134 |
+
|
| 135 |
+
astEqual(preprocess(html), [
|
| 136 |
+
'',
|
| 137 |
+
mustache('embed'), ' ',
|
| 138 |
+
mustache([id('some'), string('content')]), ' ',
|
| 139 |
+
element("div", [
|
| 140 |
+
["class", [mustache('foo'), ' ', mustache([id('bind-class'), id('isEnabled')], [['truthy', string('enabled')]])]]
|
| 141 |
+
], [
|
| 142 |
+
mustache('content')
|
| 143 |
+
]),
|
| 144 |
+
' ', mustache([id('more'), string('embed')]),
|
| 145 |
+
''
|
| 146 |
+
]);
|
| 147 |
+
});
|
| 148 |
+
|
| 149 |
+
test("Simple embedded block helpers", function() {
|
| 150 |
+
var html = "{{#if foo}}<div>{{content}}</div>{{/if}}";
|
| 151 |
+
|
| 152 |
+
astEqual(preprocess(html), ['',
|
| 153 |
+
block(mustache([id('if'), id('foo')]), [
|
| 154 |
+
element('div', [ mustache('content') ])
|
| 155 |
+
]),
|
| 156 |
+
''
|
| 157 |
+
]);
|
| 158 |
+
});
|
| 159 |
+
|
| 160 |
+
test("Involved block helper", function() {
|
| 161 |
+
var html = '<p>hi</p> content {{#testing shouldRender}}<p>Appears!</p>{{/testing}} more <em>content</em> here';
|
| 162 |
+
|
| 163 |
+
astEqual(preprocess(html), [
|
| 164 |
+
element('p', ['hi']),
|
| 165 |
+
' content ',
|
| 166 |
+
block(mustache([id('testing'), id('shouldRender')]), [
|
| 167 |
+
element('p', ['Appears!'])
|
| 168 |
+
]),
|
| 169 |
+
' more ',
|
| 170 |
+
element('em', ['content']),
|
| 171 |
+
' here'
|
| 172 |
+
]);
|
| 173 |
+
});
|
| 174 |
+
|
| 175 |
+
test("Node helpers", function() {
|
| 176 |
+
var html = "<p {{action 'boom'}} class='bar'>Some content</p>";
|
| 177 |
+
|
| 178 |
+
astEqual(preprocess(html), [
|
| 179 |
+
element('p', [['class', ['bar']]], ['Some content'], [mustache([id('action'), string('boom')])])
|
| 180 |
+
]);
|
| 181 |
+
});
|
pool/shard001/JavaScript/0010062_auth.test.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2017 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
|
| 15 |
+
'use strict';
|
| 16 |
+
|
| 17 |
+
const assert = require('assert');
|
| 18 |
+
const path = require('path');
|
| 19 |
+
const {execSync} = require('child_process');
|
| 20 |
+
|
| 21 |
+
const cwd = path.join(__dirname, '..');
|
| 22 |
+
const cmd = 'node auth.js';
|
| 23 |
+
|
| 24 |
+
const BUCKET_NAME = 'long-door-651';
|
| 25 |
+
const GOOGLE_CLOUD_PROJECT = 'long-door-651';
|
| 26 |
+
process.env.GOOGLE_CLOUD_PROJECT = 'long-door-651';
|
| 27 |
+
|
| 28 |
+
it('should load credentials implicitly', () => {
|
| 29 |
+
const output = execSync(`${cmd} auth-cloud-implicit`, {cwd, shell: true});
|
| 30 |
+
assert.strictEqual(output.includes(BUCKET_NAME), true);
|
| 31 |
+
});
|
| 32 |
+
|
| 33 |
+
it('should load credentials explicitly', () => {
|
| 34 |
+
const project = GOOGLE_CLOUD_PROJECT;
|
| 35 |
+
const keyfile = process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
| 36 |
+
console.log(`${cmd} auth-cloud-explicit -p ${project} -k ${keyfile}`);
|
| 37 |
+
const output = execSync(
|
| 38 |
+
`${cmd} auth-cloud-explicit -p ${project} -k ${keyfile}`,
|
| 39 |
+
{cwd, shell: true}
|
| 40 |
+
);
|
| 41 |
+
assert.strictEqual(output.includes(BUCKET_NAME), true);
|
| 42 |
+
});
|
pool/shard001/JavaScript/0010064_Functions.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function DO(string){console.log(string);}
|
| 2 |
+
function set_ping_status(element,string){element.innerHTML=string;}
|
| 3 |
+
function parent_to_best_child_height(_class,extra){
|
| 4 |
+
$Height = 0;
|
| 5 |
+
$mainHolder_children = $(_class).children();
|
| 6 |
+
for(var i = 0; i < $mainHolder_children.length;i++){
|
| 7 |
+
if($Height === 0){
|
| 8 |
+
$Height = $($mainHolder_children[i]).height();
|
| 9 |
+
}else{
|
| 10 |
+
if($($mainHolder_children[i]).height() > $Height){
|
| 11 |
+
$Height = $($mainHolder_children[i]).height();
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
$(_class).height($Height+extra);
|
| 16 |
+
}
|
| 17 |
+
function imageExists(image_url){
|
| 18 |
+
|
| 19 |
+
var http = new XMLHttpRequest();
|
| 20 |
+
|
| 21 |
+
http.open('HEAD', image_url, false);
|
| 22 |
+
http.send();
|
| 23 |
+
|
| 24 |
+
return http.status != 404;
|
| 25 |
+
|
| 26 |
+
}
|
| 27 |
+
function ping_sub(_url,time,element,send_them,place,place2) {
|
| 28 |
+
var url = _url;
|
| 29 |
+
if (url != "") {
|
| 30 |
+
DO('ip is not blank...');
|
| 31 |
+
var image = new Image();
|
| 32 |
+
image.src = url;
|
| 33 |
+
DO(image.src);
|
| 34 |
+
DO('pinging for '+time+' seconds...');
|
| 35 |
+
|
| 36 |
+
setTimeout
|
| 37 |
+
(
|
| 38 |
+
function(){
|
| 39 |
+
if ( !image.complete || !image.naturalWidth ){
|
| 40 |
+
DO("Fail");
|
| 41 |
+
set_ping_status(element,'Ping Failed!');
|
| 42 |
+
location.href = place2;
|
| 43 |
+
}else{
|
| 44 |
+
DO("Success");
|
| 45 |
+
set_ping_status(element,'Ping Success!');
|
| 46 |
+
if(send_them){
|
| 47 |
+
DO('Sending them to '+place);
|
| 48 |
+
location.href = place;
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
},
|
| 53 |
+
(1000*time)
|
| 54 |
+
);
|
| 55 |
+
}else{
|
| 56 |
+
set_ping_status(element,'No Input Was Given');
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
function setup_ping(){
|
| 60 |
+
var input_url = document.getElementById('input_url').value;
|
| 61 |
+
var input_timeout = document.getElementById('input_timeout').value;
|
| 62 |
+
var status_line = document.getElementById('status');
|
| 63 |
+
status_line.innerHTML="status: pinging... "+input_url;
|
| 64 |
+
ping_sub(input_url,input_timeout,status_line,false,"","");
|
| 65 |
+
}
|
| 66 |
+
function test_website(){
|
| 67 |
+
if(document.body.contains(document.getElementById("Home_Message"))){
|
| 68 |
+
// DO("found him");
|
| 69 |
+
var holder = document.getElementById("Home_Message");
|
| 70 |
+
var text = document.getElementById("Home_Message").innerHTML;
|
| 71 |
+
var url = "http://INVALID/Home.html";
|
| 72 |
+
var timeout = 3;
|
| 73 |
+
if(text === "loading..."){
|
| 74 |
+
holder.innerHTML = "Checking to see if better site is online...";
|
| 75 |
+
// DO('got loading...');
|
| 76 |
+
ping_sub(url,timeout,holder,true,"http://INVALID/Home.html","https://steven9smith.github.io/Website.CC/Home.html");
|
| 77 |
+
}else{
|
| 78 |
+
// DO('can\'t get it');
|
| 79 |
+
}
|
| 80 |
+
}else{
|
| 81 |
+
// DO("Could not find him");
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
$(document).ready(function(){
|
| 85 |
+
test_website();
|
| 86 |
+
});
|
| 87 |
+
|
pool/shard001/JavaScript/0010067_editParticular.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* To change this license header, choose License Headers in Project Properties.
|
| 3 |
+
* To change this template file, choose Tools | Templates
|
| 4 |
+
* and open the template in the editor.
|
| 5 |
+
*/
|
| 6 |
+
function loadEditParticular(_confId, _updateUrl) {
|
| 7 |
+
//* Required Scripting
|
| 8 |
+
|
| 9 |
+
$('#innerCutOffDate').datetimepicker({useCurrent: false, pickTime: true, pickDate: true});
|
| 10 |
+
$('#btnEditParticular').on('click', function (e) {
|
| 11 |
+
|
| 12 |
+
$('#innerCutOffDate').data('DateTimePicker').setValue(new Date($('#cutOffValue').html()));
|
| 13 |
+
$('#innerCutOffDate').data('DateTimePicker').setMinDate(new Date());
|
| 14 |
+
var d = new Date($('#beginDate').html());
|
| 15 |
+
d.setDate(d.getDate() - 5);
|
| 16 |
+
$('#innerCutOffDate').data('DateTimePicker').setMaxDate(d);
|
| 17 |
+
$('#innerMinScore > input').val($('#minScoreValue').html());
|
| 18 |
+
$('#innerTicketPrice > input').val($('#ticketPriceValue').html());
|
| 19 |
+
$('#particularEditor').modal({keyboard: false, backdrop: 'static', show: true});
|
| 20 |
+
});
|
| 21 |
+
//* Validation
|
| 22 |
+
$('#confParticularField').formValidation({
|
| 23 |
+
framework: 'bootstrap',
|
| 24 |
+
excluded: ':disabled',
|
| 25 |
+
err: {
|
| 26 |
+
container: 'tooltip'
|
| 27 |
+
},
|
| 28 |
+
icon: {
|
| 29 |
+
valid: 'glyphicon glyphicon-ok',
|
| 30 |
+
invalid: 'glyphicon glyphicon-remove',
|
| 31 |
+
validating: 'glyphicon glyphicon-refresh'
|
| 32 |
+
},
|
| 33 |
+
fields: {
|
| 34 |
+
cutOffDate: {
|
| 35 |
+
validators: {
|
| 36 |
+
date: {
|
| 37 |
+
format: 'DD-MM-YYYY HH:mm',
|
| 38 |
+
message: 'The value is not a valid datetime'
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
},
|
| 42 |
+
minScore: {
|
| 43 |
+
validators: {
|
| 44 |
+
numeric: {
|
| 45 |
+
separator: '.',
|
| 46 |
+
message: 'The value is not a valid numeric'
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
}).on('err.field.fv err.validator.fv', function (e, data) {
|
| 52 |
+
$('#btnSaveConfParticular').prop('disabled', true);
|
| 53 |
+
}).on('success.field.fv', function (e, data) {
|
| 54 |
+
$('#btnSaveConfParticular').prop('disabled', false);
|
| 55 |
+
});
|
| 56 |
+
|
| 57 |
+
//* Save
|
| 58 |
+
$('#btnSaveConfParticular').on('click', function (e) {
|
| 59 |
+
|
| 60 |
+
$.ajax({
|
| 61 |
+
url: _updateUrl,
|
| 62 |
+
data: {
|
| 63 |
+
conf_id: _confId
|
| 64 |
+
,cutOffDate: $("#innerCutOffDate").data("DateTimePicker").getDate().format('DD-MMM-YYYY HH:mm')
|
| 65 |
+
,minScore: $('#innerMinScore > input').val()
|
| 66 |
+
,ticketPrice: $('#innerTicketPrice > input').val()
|
| 67 |
+
},
|
| 68 |
+
type: 'get',
|
| 69 |
+
beforeSend: function () {
|
| 70 |
+
$('#modalMessage').html('Loading...');
|
| 71 |
+
$('#resultModal').modal({
|
| 72 |
+
keyboard: false,
|
| 73 |
+
backdrop: 'static'
|
| 74 |
+
});
|
| 75 |
+
}
|
| 76 |
+
}).done(function (data) {
|
| 77 |
+
//change the current
|
| 78 |
+
if (data.success !== undefined) {
|
| 79 |
+
var message = data.success.numRowUpdated + ' record(s) updated successfully !!!';
|
| 80 |
+
$('#modalMessage').html(message);
|
| 81 |
+
if (data.success.conf !== undefined) {
|
| 82 |
+
//* put back all into front page
|
| 83 |
+
if (data.success.conf.cutoff_time !== undefined && data.success.conf.min_score !== undefined) {
|
| 84 |
+
$('#cutOffValue').html(new moment(data.success.conf.cutoff_time).format('DD-MMM-YYYY HH:mm'));
|
| 85 |
+
$('#minScoreValue').html(data.success.conf.min_score);
|
| 86 |
+
$('#ticketPriceValue').html(data.success.conf.ticket_price);
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
setTimeout(function () {
|
| 91 |
+
$('#resultModal').modal('hide');
|
| 92 |
+
$('#particularEditor').modal('hide');
|
| 93 |
+
}, 1000);
|
| 94 |
+
}).fail(function (data) {
|
| 95 |
+
|
| 96 |
+
if (data.responseJSON !== undefined) {
|
| 97 |
+
if (data.responseJSON.error !== undefined) {
|
| 98 |
+
var message = data.responseJSON.error.type + ' : ' + data.responseJSON.error.message;
|
| 99 |
+
$('#modalMessage').html(message);
|
| 100 |
+
setTimeout(function () {
|
| 101 |
+
$('#resultModal').modal('hide');
|
| 102 |
+
}, 1500);
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
});
|
| 106 |
+
});
|
| 107 |
+
}
|
pool/shard001/JavaScript/0010071_util.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
var getClassName = function (obj) {
|
| 3 |
+
if (obj === null || obj === undefined)
|
| 4 |
+
return 'undefined';
|
| 5 |
+
var constr = obj.constructor.toString();
|
| 6 |
+
var funcStr = 'function ';
|
| 7 |
+
var funcPos = constr.indexOf(funcStr);
|
| 8 |
+
var postFuncPos = funcPos + funcStr.length;
|
| 9 |
+
var n = constr.indexOf('(');
|
| 10 |
+
if (funcPos < 0 || n <= postFuncPos)
|
| 11 |
+
return 'undefined';
|
| 12 |
+
return constr.substring(postFuncPos, n);
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
var generateUUID = function () {
|
| 16 |
+
var d = new Date().getTime();
|
| 17 |
+
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
| 18 |
+
var r = (d + Math.random() * 16) % 16 | 0;
|
| 19 |
+
d = Math.floor(d / 16);
|
| 20 |
+
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
| 21 |
+
});
|
| 22 |
+
return uuid;
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
module.exports = {
|
| 26 |
+
getClassName: getClassName,
|
| 27 |
+
generateUUID: generateUUID
|
| 28 |
+
}
|
pool/shard001/JavaScript/0010072_application.js
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import {Injector, bind, OpaqueToken, Optional} from 'angular2/di';
|
| 2 |
+
import {NumberWrapper, Type, isBlank, isPresent, BaseException,
|
| 3 |
+
assertionsEnabled, print, stringify} from 'angular2/src/facade/lang';
|
| 4 |
+
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
|
| 5 |
+
import {DOM} from 'angular2/src/dom/dom_adapter';
|
| 6 |
+
import {Compiler, CompilerCache} from './compiler/compiler';
|
| 7 |
+
import {Reflector, reflector} from 'angular2/src/reflection/reflection';
|
| 8 |
+
import {Parser, Lexer, ChangeDetection, DynamicChangeDetection, PipeRegistry, defaultPipeRegistry} from 'angular2/change_detection';
|
| 9 |
+
import {ExceptionHandler} from './exception_handler';
|
| 10 |
+
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
| 11 |
+
import {TemplateResolver} from './compiler/template_resolver';
|
| 12 |
+
import {DirectiveMetadataReader} from './compiler/directive_metadata_reader';
|
| 13 |
+
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
| 14 |
+
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
|
| 15 |
+
import {VmTurnZone} from 'angular2/src/core/zone/vm_turn_zone';
|
| 16 |
+
import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
|
| 17 |
+
import {ShadowDomStrategy} from 'angular2/src/render/dom/shadow_dom/shadow_dom_strategy';
|
| 18 |
+
import {EmulatedUnscopedShadowDomStrategy} from 'angular2/src/render/dom/shadow_dom/emulated_unscoped_shadow_dom_strategy';
|
| 19 |
+
import {XHR} from 'angular2/src/services/xhr';
|
| 20 |
+
import {XHRImpl} from 'angular2/src/services/xhr_impl';
|
| 21 |
+
import {EventManager, DomEventsPlugin} from 'angular2/src/render/dom/events/event_manager';
|
| 22 |
+
import {KeyEventsPlugin} from 'angular2/src/render/dom/events/key_events';
|
| 23 |
+
import {HammerGesturesPlugin} from 'angular2/src/render/dom/events/hammer_gestures';
|
| 24 |
+
import {Binding} from 'angular2/src/di/binding';
|
| 25 |
+
import {ComponentUrlMapper} from 'angular2/src/core/compiler/component_url_mapper';
|
| 26 |
+
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
| 27 |
+
import {StyleUrlResolver} from 'angular2/src/render/dom/shadow_dom/style_url_resolver';
|
| 28 |
+
import {StyleInliner} from 'angular2/src/render/dom/shadow_dom/style_inliner';
|
| 29 |
+
import {ComponentRef, DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
|
| 30 |
+
import {TestabilityRegistry, Testability} from 'angular2/src/core/testability/testability';
|
| 31 |
+
import {ViewFactory, VIEW_POOL_CAPACITY} from 'angular2/src/core/compiler/view_factory';
|
| 32 |
+
import {AppViewHydrator} from 'angular2/src/core/compiler/view_hydrator';
|
| 33 |
+
import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
|
| 34 |
+
import {Renderer} from 'angular2/src/render/api';
|
| 35 |
+
import {DirectDomRenderer} from 'angular2/src/render/dom/direct_dom_renderer';
|
| 36 |
+
import * as rc from 'angular2/src/render/dom/compiler/compiler';
|
| 37 |
+
import * as rvf from 'angular2/src/render/dom/view/view_factory';
|
| 38 |
+
import * as rvh from 'angular2/src/render/dom/view/view_hydrator';
|
| 39 |
+
|
| 40 |
+
import {
|
| 41 |
+
appComponentRefToken,
|
| 42 |
+
appChangeDetectorToken,
|
| 43 |
+
appElementToken,
|
| 44 |
+
appComponentAnnotatedTypeToken,
|
| 45 |
+
appDocumentToken,
|
| 46 |
+
} from './application_tokens';
|
| 47 |
+
|
| 48 |
+
var _rootInjector: Injector;
|
| 49 |
+
|
| 50 |
+
// Contains everything that is safe to share between applications.
|
| 51 |
+
var _rootBindings = [
|
| 52 |
+
bind(Reflector).toValue(reflector),
|
| 53 |
+
TestabilityRegistry
|
| 54 |
+
];
|
| 55 |
+
|
| 56 |
+
function _injectorBindings(appComponentType): List<Binding> {
|
| 57 |
+
return [
|
| 58 |
+
bind(appDocumentToken).toValue(DOM.defaultDoc()),
|
| 59 |
+
bind(appComponentAnnotatedTypeToken).toFactory((reader) => {
|
| 60 |
+
// TODO(rado): investigate whether to support bindings on root component.
|
| 61 |
+
return reader.read(appComponentType);
|
| 62 |
+
}, [DirectiveMetadataReader]),
|
| 63 |
+
|
| 64 |
+
bind(appElementToken).toFactory((appComponentAnnotatedType, appDocument) => {
|
| 65 |
+
var selector = appComponentAnnotatedType.annotation.selector;
|
| 66 |
+
var element = DOM.querySelector(appDocument, selector);
|
| 67 |
+
if (isBlank(element)) {
|
| 68 |
+
throw new BaseException(`The app selector "${selector}" did not match any elements`);
|
| 69 |
+
}
|
| 70 |
+
return element;
|
| 71 |
+
}, [appComponentAnnotatedTypeToken, appDocumentToken]),
|
| 72 |
+
bind(appComponentRefToken).toAsyncFactory((dynamicComponentLoader, injector, appElement,
|
| 73 |
+
appComponentAnnotatedType, testability, registry) => {
|
| 74 |
+
|
| 75 |
+
// We need to do this here to ensure that we create Testability and
|
| 76 |
+
// it's ready on the window for users.
|
| 77 |
+
registry.registerApplication(appElement, testability);
|
| 78 |
+
return dynamicComponentLoader.loadIntoNewLocation(appElement, appComponentAnnotatedType.type, null, injector);
|
| 79 |
+
}, [DynamicComponentLoader, Injector, appElementToken, appComponentAnnotatedTypeToken,
|
| 80 |
+
Testability, TestabilityRegistry]),
|
| 81 |
+
|
| 82 |
+
bind(appChangeDetectorToken).toFactory((ref) => ref.hostView.changeDetector,
|
| 83 |
+
[appComponentRefToken]),
|
| 84 |
+
bind(appComponentType).toFactory((ref) => ref.instance,
|
| 85 |
+
[appComponentRefToken]),
|
| 86 |
+
bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(exceptionHandler, null, assertionsEnabled()),[ExceptionHandler]),
|
| 87 |
+
bind(EventManager).toFactory((zone) => {
|
| 88 |
+
var plugins = [new HammerGesturesPlugin(), new KeyEventsPlugin(), new DomEventsPlugin()];
|
| 89 |
+
return new EventManager(plugins, zone);
|
| 90 |
+
}, [VmTurnZone]),
|
| 91 |
+
bind(ShadowDomStrategy).toFactory(
|
| 92 |
+
(styleUrlResolver, doc) => new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head),
|
| 93 |
+
[StyleUrlResolver, appDocumentToken]),
|
| 94 |
+
bind(Renderer).toClass(DirectDomRenderer),
|
| 95 |
+
bind(rc.Compiler).toClass(rc.DefaultCompiler),
|
| 96 |
+
// TODO(tbosch): We need an explicit factory here, as
|
| 97 |
+
// we are getting errors in dart2js with mirrors...
|
| 98 |
+
bind(rvf.ViewFactory).toFactory(
|
| 99 |
+
(capacity, eventManager, shadowDomStrategy) => new rvf.ViewFactory(capacity, eventManager, shadowDomStrategy),
|
| 100 |
+
[rvf.VIEW_POOL_CAPACITY, EventManager, ShadowDomStrategy]
|
| 101 |
+
),
|
| 102 |
+
bind(rvf.VIEW_POOL_CAPACITY).toValue(10000),
|
| 103 |
+
rvh.RenderViewHydrator,
|
| 104 |
+
ProtoViewFactory,
|
| 105 |
+
// TODO(tbosch): We need an explicit factory here, as
|
| 106 |
+
// we are getting errors in dart2js with mirrors...
|
| 107 |
+
bind(ViewFactory).toFactory(
|
| 108 |
+
(capacity, renderer) => new ViewFactory(capacity, renderer),
|
| 109 |
+
[VIEW_POOL_CAPACITY, Renderer]
|
| 110 |
+
),
|
| 111 |
+
bind(VIEW_POOL_CAPACITY).toValue(10000),
|
| 112 |
+
AppViewHydrator,
|
| 113 |
+
Compiler,
|
| 114 |
+
CompilerCache,
|
| 115 |
+
TemplateResolver,
|
| 116 |
+
bind(PipeRegistry).toValue(defaultPipeRegistry),
|
| 117 |
+
bind(ChangeDetection).toClass(DynamicChangeDetection),
|
| 118 |
+
TemplateLoader,
|
| 119 |
+
DirectiveMetadataReader,
|
| 120 |
+
Parser,
|
| 121 |
+
Lexer,
|
| 122 |
+
ExceptionHandler,
|
| 123 |
+
bind(XHR).toValue(new XHRImpl()),
|
| 124 |
+
ComponentUrlMapper,
|
| 125 |
+
UrlResolver,
|
| 126 |
+
StyleUrlResolver,
|
| 127 |
+
StyleInliner,
|
| 128 |
+
DynamicComponentLoader,
|
| 129 |
+
Testability
|
| 130 |
+
];
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
function _createVmZone(givenReporter:Function): VmTurnZone {
|
| 134 |
+
var defaultErrorReporter = (exception, stackTrace) => {
|
| 135 |
+
var longStackTrace = ListWrapper.join(stackTrace, "\n\n-----async gap-----\n");
|
| 136 |
+
print(`${exception}\n\n${longStackTrace}`);
|
| 137 |
+
throw exception;
|
| 138 |
+
};
|
| 139 |
+
|
| 140 |
+
var reporter = isPresent(givenReporter) ? givenReporter : defaultErrorReporter;
|
| 141 |
+
|
| 142 |
+
var zone = new VmTurnZone({enableLongStackTrace: assertionsEnabled()});
|
| 143 |
+
zone.initCallbacks({onErrorHandler: reporter});
|
| 144 |
+
return zone;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
/**
|
| 148 |
+
* Bootstrapping for Angular applications.
|
| 149 |
+
*
|
| 150 |
+
* You instantiate an Angular application by explicitly specifying a component to use as the root component for your
|
| 151 |
+
* application via the `bootstrap()` method.
|
| 152 |
+
*
|
| 153 |
+
* ## Simple Example
|
| 154 |
+
*
|
| 155 |
+
* Assuming this `index.html`:
|
| 156 |
+
*
|
| 157 |
+
* ```html
|
| 158 |
+
* <html>
|
| 159 |
+
* <!-- load Angular script tags here. -->
|
| 160 |
+
* <body>
|
| 161 |
+
* <my-app>loading...</my-app>
|
| 162 |
+
* </body>
|
| 163 |
+
* </html>
|
| 164 |
+
* ```
|
| 165 |
+
*
|
| 166 |
+
* An application is bootstrapped inside an existing browser DOM, typically `index.html`. Unlike Angular 1, Angular 2
|
| 167 |
+
* does not compile/process bindings in `index.html`. This is mainly for security reasons, as well as architectural
|
| 168 |
+
* changes in Angular 2. This means that `index.html` can safely be processed using server-side technologies such as
|
| 169 |
+
* bindings. Bindings can thus use double-curly `{{ syntax }}` without collision from Angular 2 component double-curly
|
| 170 |
+
* `{{ syntax }}`.
|
| 171 |
+
*
|
| 172 |
+
* We can use this script code:
|
| 173 |
+
*
|
| 174 |
+
* ```
|
| 175 |
+
* @Component({
|
| 176 |
+
* selector: 'my-app'
|
| 177 |
+
* })
|
| 178 |
+
* @View({
|
| 179 |
+
* template: 'Hello {{ name }}!'
|
| 180 |
+
* })
|
| 181 |
+
* class MyApp {
|
| 182 |
+
* name:string;
|
| 183 |
+
*
|
| 184 |
+
* constructor() {
|
| 185 |
+
* this.name = 'World';
|
| 186 |
+
* }
|
| 187 |
+
* }
|
| 188 |
+
*
|
| 189 |
+
* main() {
|
| 190 |
+
* return bootstrap(MyApp);
|
| 191 |
+
* }
|
| 192 |
+
* ```
|
| 193 |
+
*
|
| 194 |
+
* When the app developer invokes `bootstrap()` with the root component `MyApp` as its argument, Angular performs the
|
| 195 |
+
* following tasks:
|
| 196 |
+
*
|
| 197 |
+
* 1. It uses the component's `selector` property to locate the DOM element which needs to be upgraded into
|
| 198 |
+
* the angular component.
|
| 199 |
+
* 2. It creates a new child injector (from the primordial injector) and configures the injector with the component's
|
| 200 |
+
* `injectables`. Optionally, you can also override the injector configuration for an app by invoking
|
| 201 |
+
* `bootstrap` with the `componentInjectableBindings` argument.
|
| 202 |
+
* 3. It creates a new [Zone] and connects it to the angular application's change detection domain instance.
|
| 203 |
+
* 4. It creates a shadow DOM on the selected component's host element and loads the template into it.
|
| 204 |
+
* 5. It instantiates the specified component.
|
| 205 |
+
* 6. Finally, Angular performs change detection to apply the initial data bindings for the application.
|
| 206 |
+
*
|
| 207 |
+
*
|
| 208 |
+
* ## Instantiating Multiple Applications on a Single Page
|
| 209 |
+
*
|
| 210 |
+
* There are two ways to do this.
|
| 211 |
+
*
|
| 212 |
+
*
|
| 213 |
+
* ### Isolated Applications
|
| 214 |
+
*
|
| 215 |
+
* Angular creates a new application each time that the `bootstrap()` method is invoked. When multiple applications
|
| 216 |
+
* are created for a page, Angular treats each application as independent within an isolated change detection and
|
| 217 |
+
* [Zone] domain. If you need to share data between applications, use the strategy described in the next
|
| 218 |
+
* section, "Applications That Share Change Detection."
|
| 219 |
+
*
|
| 220 |
+
*
|
| 221 |
+
* ### Applications That Share Change Detection
|
| 222 |
+
*
|
| 223 |
+
* If you need to bootstrap multiple applications that share common data, the applications must share a common
|
| 224 |
+
* change detection and zone. To do that, create a meta-component that lists the application components in its template.
|
| 225 |
+
* By only invoking the `bootstrap()` method once, with the meta-component as its argument, you ensure that only a
|
| 226 |
+
* single change detection zone is created and therefore data can be shared across the applications.
|
| 227 |
+
*
|
| 228 |
+
*
|
| 229 |
+
* ## Primordial Injector
|
| 230 |
+
*
|
| 231 |
+
* When working within a browser window, there are many singleton resources: cookies, title, location, and others.
|
| 232 |
+
* Angular services that represent these resources must likewise be shared across all Angular applications that
|
| 233 |
+
* occupy the same browser window. For this reason, Angular creates exactly one global primordial injector which stores
|
| 234 |
+
* all shared services, and each angular application injector has the primordial injector as its parent.
|
| 235 |
+
*
|
| 236 |
+
* Each application has its own private injector as well. When there are multiple applications on a page, Angular treats
|
| 237 |
+
* each application injector's services as private to that application.
|
| 238 |
+
*
|
| 239 |
+
*
|
| 240 |
+
* # API
|
| 241 |
+
* - [appComponentType]: The root component which should act as the application. This is a reference to a [Type]
|
| 242 |
+
* which is annotated with `@Component(...)`.
|
| 243 |
+
* - [componentInjectableBindings]: An additional set of bindings that can be added to the [Component.injectables] to
|
| 244 |
+
* override default injection behavior.
|
| 245 |
+
* - [errorReporter]: `function(exception:any, stackTrace:string)` a default error reporter for unhandled exceptions.
|
| 246 |
+
*
|
| 247 |
+
* Returns a [Promise] with the application`s private [Injector].
|
| 248 |
+
*
|
| 249 |
+
* @exportedAs angular2/core
|
| 250 |
+
*/
|
| 251 |
+
export function bootstrap(appComponentType: Type,
|
| 252 |
+
componentInjectableBindings: List<Binding> = null,
|
| 253 |
+
errorReporter: Function = null): Promise<ComponentRef> {
|
| 254 |
+
BrowserDomAdapter.makeCurrent();
|
| 255 |
+
var bootstrapProcess = PromiseWrapper.completer();
|
| 256 |
+
|
| 257 |
+
var zone = _createVmZone(errorReporter);
|
| 258 |
+
zone.run(() => {
|
| 259 |
+
// TODO(rado): prepopulate template cache, so applications with only
|
| 260 |
+
// index.html and main.js are possible.
|
| 261 |
+
|
| 262 |
+
var appInjector = _createAppInjector(appComponentType, componentInjectableBindings, zone);
|
| 263 |
+
|
| 264 |
+
PromiseWrapper.then(appInjector.asyncGet(appComponentRefToken),
|
| 265 |
+
(componentRef) => {
|
| 266 |
+
var appChangeDetector = componentRef.hostView.changeDetector;
|
| 267 |
+
// retrieve life cycle: may have already been created if injected in root component
|
| 268 |
+
var lc = appInjector.get(LifeCycle);
|
| 269 |
+
lc.registerWith(zone, appChangeDetector);
|
| 270 |
+
lc.tick(); //the first tick that will bootstrap the app
|
| 271 |
+
|
| 272 |
+
bootstrapProcess.resolve(componentRef);
|
| 273 |
+
},
|
| 274 |
+
|
| 275 |
+
(err) => {
|
| 276 |
+
bootstrapProcess.reject(err)
|
| 277 |
+
});
|
| 278 |
+
});
|
| 279 |
+
|
| 280 |
+
return bootstrapProcess.promise;
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
function _createAppInjector(appComponentType: Type, bindings: List<Binding>, zone: VmTurnZone): Injector {
|
| 284 |
+
if (isBlank(_rootInjector)) _rootInjector = Injector.resolveAndCreate(_rootBindings);
|
| 285 |
+
var mergedBindings = isPresent(bindings) ?
|
| 286 |
+
ListWrapper.concat(_injectorBindings(appComponentType), bindings) :
|
| 287 |
+
_injectorBindings(appComponentType);
|
| 288 |
+
ListWrapper.push(mergedBindings, bind(VmTurnZone).toValue(zone));
|
| 289 |
+
return _rootInjector.resolveAndCreateChild(mergedBindings);
|
| 290 |
+
}
|
pool/shard001/JavaScript/0010073_util.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Vue from 'vue';
|
| 2 |
+
import $ from 'jquery';
|
| 3 |
+
|
| 4 |
+
function type(o) {
|
| 5 |
+
return typeof o;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
function isArr(o) {
|
| 9 |
+
return o instanceof Array;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
function isStr(o) {
|
| 13 |
+
return type(o) == 'string';
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
function destroyVM(vm) {
|
| 18 |
+
if (vm) {
|
| 19 |
+
const el = vm.$el;
|
| 20 |
+
if (el && el.parentNode) {
|
| 21 |
+
$(el).remove();
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
function createAndReplaceElem() {
|
| 27 |
+
const el = document.createElement('div'),
|
| 28 |
+
elBody = document.body,
|
| 29 |
+
oEl = document.getElementById('app');
|
| 30 |
+
if (oEl) {
|
| 31 |
+
$(oEl).remove(oEl);
|
| 32 |
+
}
|
| 33 |
+
elBody.appendChild(el);
|
| 34 |
+
return el;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function createVM(Compo, propsData = {}, mounted) {
|
| 38 |
+
const nPropsData = { ...propsData };
|
| 39 |
+
const el = createAndReplaceElem();
|
| 40 |
+
let VueExtended = Vue;
|
| 41 |
+
if (isStr(Compo)) {
|
| 42 |
+
nPropsData.template = Compo;
|
| 43 |
+
}
|
| 44 |
+
// Component
|
| 45 |
+
else {
|
| 46 |
+
VueExtended = Vue.extend(Vue);
|
| 47 |
+
}
|
| 48 |
+
return new VueExtended(nPropsData).$mount(mounted === false ? null : el);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
function cssTextToObject(txt) {
|
| 52 |
+
const result = {};
|
| 53 |
+
txt.split(';').forEach((term) => {
|
| 54 |
+
const splits = term.split(':');
|
| 55 |
+
if (splits && splits.length == 2) {
|
| 56 |
+
const key = splits[0].trim(),
|
| 57 |
+
value = splits[1].trim();
|
| 58 |
+
result[key] = value;
|
| 59 |
+
}
|
| 60 |
+
});
|
| 61 |
+
return result;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
function genImgSrc() {
|
| 65 |
+
return `img/lenna.png?_t=${Math.floor(Math.random() * 100000)}.${Date.now()}`;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
function genImgList(len) {
|
| 69 |
+
const arr = [];
|
| 70 |
+
while (len--) {
|
| 71 |
+
arr.push(genImgSrc());
|
| 72 |
+
}
|
| 73 |
+
return arr;
|
| 74 |
+
}
|
| 75 |
+
export {
|
| 76 |
+
destroyVM,
|
| 77 |
+
createAndReplaceElem,
|
| 78 |
+
createVM,
|
| 79 |
+
cssTextToObject,
|
| 80 |
+
genImgSrc,
|
| 81 |
+
genImgList,
|
| 82 |
+
};
|
pool/shard001/JavaScript/0010075_item.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import ReactDOM from 'react-dom';
|
| 3 |
+
import Columns from '../columns';
|
| 4 |
+
import Lists from '../stores/Lists';
|
| 5 |
+
import CreateForm from '../components/CreateForm';
|
| 6 |
+
import EditForm from '../components/EditForm';
|
| 7 |
+
import EditFormHeader from '../components/EditFormHeader';
|
| 8 |
+
import FlashMessages from '../components/FlashMessages';
|
| 9 |
+
import Footer from '../components/Footer';
|
| 10 |
+
import MobileNavigation from '../components/MobileNavigation';
|
| 11 |
+
import PrimaryNavigation from '../components/PrimaryNavigation';
|
| 12 |
+
import RelatedItemsList from '../components/RelatedItemsList';
|
| 13 |
+
import SecondaryNavigation from '../components/SecondaryNavigation';
|
| 14 |
+
import { Alert, Container, Spinner } from 'elemental';
|
| 15 |
+
|
| 16 |
+
var ItemView = React.createClass({
|
| 17 |
+
|
| 18 |
+
displayName: 'ItemView',
|
| 19 |
+
|
| 20 |
+
getInitialState () {
|
| 21 |
+
return {
|
| 22 |
+
createIsOpen: false,
|
| 23 |
+
itemData: null,
|
| 24 |
+
};
|
| 25 |
+
},
|
| 26 |
+
|
| 27 |
+
componentDidMount () {
|
| 28 |
+
this.loadItemData();
|
| 29 |
+
},
|
| 30 |
+
|
| 31 |
+
loadItemData () {
|
| 32 |
+
this.props.list.loadItem(this.props.itemId, { drilldown: true }, (err, itemData) => {
|
| 33 |
+
if (err || !itemData) {
|
| 34 |
+
// TODO: nicer error handling
|
| 35 |
+
console.log('Error loading item data', err);
|
| 36 |
+
alert('Error loading data (details logged to console)');
|
| 37 |
+
return;
|
| 38 |
+
}
|
| 39 |
+
this.setState({ itemData });
|
| 40 |
+
});
|
| 41 |
+
},
|
| 42 |
+
|
| 43 |
+
toggleCreate (visible) {
|
| 44 |
+
this.setState({
|
| 45 |
+
createIsOpen: visible,
|
| 46 |
+
});
|
| 47 |
+
},
|
| 48 |
+
|
| 49 |
+
renderRelationships () {
|
| 50 |
+
let { relationships } = this.props.list;
|
| 51 |
+
let keys = Object.keys(relationships);
|
| 52 |
+
if (!keys.length) return;
|
| 53 |
+
return (
|
| 54 |
+
<div>
|
| 55 |
+
<h2>Relationships</h2>
|
| 56 |
+
{keys.map(key => {
|
| 57 |
+
let relationship = relationships[key];
|
| 58 |
+
let refList = Lists[relationship.ref];
|
| 59 |
+
return <RelatedItemsList key={relationship.path} list={this.props.list} refList={refList} relatedItemId={this.props.itemId} relationship={relationship} />;
|
| 60 |
+
})}
|
| 61 |
+
</div>
|
| 62 |
+
);
|
| 63 |
+
},
|
| 64 |
+
|
| 65 |
+
render () {
|
| 66 |
+
if (!this.state.itemData) return <div className="view-loading-indicator"><Spinner size="md" /></div>;
|
| 67 |
+
return (
|
| 68 |
+
<div className="keystone-wrapper">
|
| 69 |
+
<header className="keystone-header">
|
| 70 |
+
<MobileNavigation
|
| 71 |
+
brand={this.props.brand}
|
| 72 |
+
currentListKey={this.props.list.path}
|
| 73 |
+
currentSectionKey={this.props.nav.currentSection.key}
|
| 74 |
+
sections={this.props.nav.sections}
|
| 75 |
+
signoutUrl={this.props.signoutUrl}
|
| 76 |
+
/>
|
| 77 |
+
<PrimaryNavigation
|
| 78 |
+
currentSectionKey={this.props.nav.currentSection.key}
|
| 79 |
+
brand={this.props.brand}
|
| 80 |
+
sections={this.props.nav.sections}
|
| 81 |
+
signoutUrl={this.props.signoutUrl} />
|
| 82 |
+
<SecondaryNavigation
|
| 83 |
+
currentListKey={this.props.list.path}
|
| 84 |
+
lists={this.props.nav.currentSection.lists} />
|
| 85 |
+
</header>
|
| 86 |
+
<div className="keystone-body">
|
| 87 |
+
<EditFormHeader
|
| 88 |
+
list={this.props.list}
|
| 89 |
+
data={this.state.itemData}
|
| 90 |
+
drilldown={this.state.itemDrilldown}
|
| 91 |
+
toggleCreate={this.toggleCreate} />
|
| 92 |
+
<Container>
|
| 93 |
+
<CreateForm
|
| 94 |
+
list={this.props.list}
|
| 95 |
+
isOpen={this.state.createIsOpen}
|
| 96 |
+
onCancel={() => this.toggleCreate(false)} />
|
| 97 |
+
<FlashMessages
|
| 98 |
+
messages={this.props.messages} />
|
| 99 |
+
<EditForm
|
| 100 |
+
list={this.props.list}
|
| 101 |
+
data={this.state.itemData} />
|
| 102 |
+
{this.renderRelationships()}
|
| 103 |
+
</Container>
|
| 104 |
+
</div>
|
| 105 |
+
<Footer
|
| 106 |
+
appversion={this.props.appversion}
|
| 107 |
+
backUrl={this.props.backUrl}
|
| 108 |
+
brand={this.props.brand}
|
| 109 |
+
User={this.props.User}
|
| 110 |
+
user={this.props.user}
|
| 111 |
+
version={this.props.version} />
|
| 112 |
+
</div>
|
| 113 |
+
);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
});
|
| 117 |
+
|
| 118 |
+
ReactDOM.render(
|
| 119 |
+
<ItemView
|
| 120 |
+
appversion={Keystone.appversion}
|
| 121 |
+
backUrl={Keystone.backUrl}
|
| 122 |
+
brand={Keystone.brand}
|
| 123 |
+
itemId={Keystone.itemId}
|
| 124 |
+
list={Lists[Keystone.list.key]}
|
| 125 |
+
messages={Keystone.messages}
|
| 126 |
+
nav={Keystone.nav}
|
| 127 |
+
signoutUrl={Keystone.signoutUrl}
|
| 128 |
+
User={Keystone.User}
|
| 129 |
+
user={Keystone.user}
|
| 130 |
+
version={Keystone.version}
|
| 131 |
+
/>,
|
| 132 |
+
document.getElementById('item-view')
|
| 133 |
+
);
|
pool/shard001/JavaScript/0010077_test-http-flush-response-headers.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
const common = require('../common');
|
| 3 |
+
const assert = require('assert');
|
| 4 |
+
const http = require('http');
|
| 5 |
+
|
| 6 |
+
const server = http.createServer();
|
| 7 |
+
|
| 8 |
+
server.on('request', function(req, res) {
|
| 9 |
+
res.writeHead(200, {'foo': 'bar'});
|
| 10 |
+
res.flushHeaders();
|
| 11 |
+
res.flushHeaders(); // Should be idempotent.
|
| 12 |
+
});
|
| 13 |
+
server.listen(common.PORT, common.localhostIPv4, function() {
|
| 14 |
+
var req = http.request({
|
| 15 |
+
method: 'GET',
|
| 16 |
+
host: common.localhostIPv4,
|
| 17 |
+
port: common.PORT,
|
| 18 |
+
}, onResponse);
|
| 19 |
+
|
| 20 |
+
req.end();
|
| 21 |
+
|
| 22 |
+
function onResponse(res) {
|
| 23 |
+
assert.equal(res.headers['foo'], 'bar');
|
| 24 |
+
res.destroy();
|
| 25 |
+
server.close();
|
| 26 |
+
}
|
| 27 |
+
});
|
pool/shard001/JavaScript/0010078_home.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Template['home'].helpers({
|
| 2 |
+
myFormData: function() {
|
| 3 |
+
return { directoryName: 'images', prefix: this._id, _id: this._id }
|
| 4 |
+
},
|
| 5 |
+
filesToUpload: function() {
|
| 6 |
+
return Uploader.info.get();
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
});
|
| 10 |
+
|
| 11 |
+
Template['uploadedInfo'].helpers({
|
| 12 |
+
src: function() {
|
| 13 |
+
if (this.type.indexOf('image') >= 0) {
|
| 14 |
+
return 'upload/' + this.path;
|
| 15 |
+
} else return 'file_icon.png';
|
| 16 |
+
}
|
| 17 |
+
});
|
| 18 |
+
|
| 19 |
+
Template['uploadedInfo'].events({
|
| 20 |
+
'click .deleteUpload':function() {
|
| 21 |
+
if (confirm('Are you sure?')) {
|
| 22 |
+
Meteor.call('deleteFile', this._id);
|
| 23 |
+
var pics = SessionAmplify.get('pics')
|
| 24 |
+
var index = pics.indexOf(this._id);
|
| 25 |
+
if (index > -1) {
|
| 26 |
+
pics.splice(index, 1);
|
| 27 |
+
}
|
| 28 |
+
SessionAmplify.set('pics',pics);
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
})
|
pool/shard001/JavaScript/0010083_analytics_interaction_manager.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2019 ThoughtWorks, Inc.
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
(function () {
|
| 17 |
+
"use strict";
|
| 18 |
+
|
| 19 |
+
const Requests = require("rails-shared/plugin-endpoint-request-handler");
|
| 20 |
+
const Frame = require("models/shared/frame");
|
| 21 |
+
const Routes = require("gen/js-routes");
|
| 22 |
+
|
| 23 |
+
function Namespace(models, name) {
|
| 24 |
+
const prefix = `${encodeURIComponent(name)}:`;
|
| 25 |
+
|
| 26 |
+
function withPrefix(u) {
|
| 27 |
+
return prefix + u;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
function withoutPrefix(u) {
|
| 31 |
+
return u.split(":").pop();
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function encodeUID(i, p, t, id) {
|
| 35 |
+
return withPrefix(btoa(JSON.stringify({plugin: p, type: t, id, ordinal: i})));
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
function decodeUID(uid) {
|
| 39 |
+
return JSON.parse(atob(withoutPrefix(uid)));
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
this.uid = encodeUID;
|
| 43 |
+
this.unpack = decodeUID;
|
| 44 |
+
|
| 45 |
+
this.group = function group() {
|
| 46 |
+
return name;
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
this.all = function allModelsInNamespace() {
|
| 50 |
+
const result = {};
|
| 51 |
+
for (const k in models) {
|
| 52 |
+
if (k.startsWith(prefix)) { result[k] = models[k]; }
|
| 53 |
+
}
|
| 54 |
+
return result;
|
| 55 |
+
};
|
| 56 |
+
|
| 57 |
+
function toUrl(uid, params={}) {
|
| 58 |
+
const c = decodeUID(uid);
|
| 59 |
+
return Routes.showAnalyticsPath(c.plugin, c.type, c.id, params);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
this.toUrl = toUrl;
|
| 63 |
+
|
| 64 |
+
this.modelFor = function modelFor(uid, extraParams={}) {
|
| 65 |
+
let model = models[uid];
|
| 66 |
+
|
| 67 |
+
if (!model) {
|
| 68 |
+
model = models[uid] = new Frame();
|
| 69 |
+
model.url(toUrl(uid, extraParams));
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
return model;
|
| 73 |
+
};
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* AnalyticsInteractionManager should be a singleton that handles
|
| 78 |
+
* the bootstrapping of parent page communication channel, which
|
| 79 |
+
* includings things like listener definitions and Frame model
|
| 80 |
+
* management.
|
| 81 |
+
*/
|
| 82 |
+
function AnalyticsInteractionManager() {
|
| 83 |
+
const models = {};
|
| 84 |
+
|
| 85 |
+
this.purge = function destroyAll() {
|
| 86 |
+
for (const k in models) {
|
| 87 |
+
delete models[k];
|
| 88 |
+
}
|
| 89 |
+
};
|
| 90 |
+
|
| 91 |
+
this.all = function allModels() {
|
| 92 |
+
// returns the whole world.
|
| 93 |
+
//
|
| 94 |
+
// shallow copy prevents unauthorized writes to
|
| 95 |
+
// `models` internal structure
|
| 96 |
+
return Object.assign({}, models);
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
this.ns = function namespace(name) {
|
| 100 |
+
return new Namespace(models, name);
|
| 101 |
+
};
|
| 102 |
+
|
| 103 |
+
this.ensure = function ensure() {
|
| 104 |
+
Requests.defineLinkHandler();
|
| 105 |
+
Requests.defineFetchAnalyticsHandler(models);
|
| 106 |
+
return this;
|
| 107 |
+
};
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
module.exports = new AnalyticsInteractionManager();
|
| 111 |
+
})();
|
pool/shard001/JavaScript/0010085_contributorsModal.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { Component } from 'react'
|
| 2 |
+
import Modal from 'react-modal'
|
| 3 |
+
import * as request from 'superagent'
|
| 4 |
+
import { queue } from 'd3-queue'
|
| 5 |
+
import { parse, DOM } from 'xml-parse'
|
| 6 |
+
|
| 7 |
+
const initialHowMany = 10
|
| 8 |
+
|
| 9 |
+
class ContributorsModal extends Component {
|
| 10 |
+
state = {
|
| 11 |
+
howMany: initialHowMany,
|
| 12 |
+
loading: false
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
userNames = {}
|
| 16 |
+
|
| 17 |
+
render() {
|
| 18 |
+
const total = this.props.contributors.reduce((prev, contributor) => prev + contributor.contributions, 0)
|
| 19 |
+
return (
|
| 20 |
+
<Modal
|
| 21 |
+
isOpen={this.props.isOpen}
|
| 22 |
+
onRequestClose={this.props.onRequestClose}
|
| 23 |
+
className={this.state.loading ? 'updating' : ''}
|
| 24 |
+
style={this.props.style}>
|
| 25 |
+
<h3>Top {Math.min(this.state.howMany, this.props.contributors.length)} Contributors</h3>
|
| 26 |
+
<a className="close-link" onClick={this.props.onRequestClose}>x</a>
|
| 27 |
+
<ul className="contributors">
|
| 28 |
+
{this.props.contributors.slice(0,this.state.howMany).map(contributor =>
|
| 29 |
+
<li key={contributor.uid}>{this.userNames[contributor.uid]
|
| 30 |
+
? (<a href={"http://hdyc.neis-one.org/?"+this.userNames[contributor.uid]} target="_blank" title="get more infos about this user on hdyc">{this.userNames[contributor.uid]}</a>)
|
| 31 |
+
: '#'+contributor.uid}
|
| 32 |
+
<span className='percentage'>{Math.round(contributor.contributions/total*100) || '<1'}%</span>
|
| 33 |
+
</li>
|
| 34 |
+
)}
|
| 35 |
+
<li>{this.props.contributors.length > this.state.howMany
|
| 36 |
+
? <button onClick={::this.expand}>show more</button>
|
| 37 |
+
: ''}
|
| 38 |
+
</li>
|
| 39 |
+
</ul>
|
| 40 |
+
</Modal>
|
| 41 |
+
)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
componentWillReceiveProps(nextProps) {
|
| 45 |
+
if (!nextProps.isOpen) return
|
| 46 |
+
this.loadUserNamesFor(nextProps.contributors.slice(0,initialHowMany).map(contributor => contributor.uid))
|
| 47 |
+
this.setState({ howMany: initialHowMany })
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
expand() {
|
| 51 |
+
this.loadUserNamesFor(this.props.contributors.slice(this.state.howMany,this.state.howMany+initialHowMany).map(contributor => contributor.uid))
|
| 52 |
+
this.setState({
|
| 53 |
+
howMany: this.state.howMany + initialHowMany
|
| 54 |
+
})
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
loadUserNamesFor(uids) {
|
| 58 |
+
this.setState({ loading: true })
|
| 59 |
+
var q = queue()
|
| 60 |
+
var uidsToRequest = uids.filter(uid => !this.userNames[uid])
|
| 61 |
+
|
| 62 |
+
uidsToRequest.forEach(uid => {
|
| 63 |
+
let req = request.get('https://api.openstreetmap.org/api/0.6/user/'+uid)
|
| 64 |
+
q.defer(req.end.bind(req))
|
| 65 |
+
})
|
| 66 |
+
q.awaitAll(function(err, data) {
|
| 67 |
+
if (err) {
|
| 68 |
+
console.error(err)
|
| 69 |
+
} else {
|
| 70 |
+
uidsToRequest.forEach((uid, idx) => {
|
| 71 |
+
const xmlDOM = new DOM(parse(data[idx].text));
|
| 72 |
+
const user = xmlDOM.document.getElementsByTagName('user')[0];
|
| 73 |
+
this.userNames[uid] = user.attributes.display_name;
|
| 74 |
+
})
|
| 75 |
+
}
|
| 76 |
+
this.setState({ loading: false })
|
| 77 |
+
}.bind(this))
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
export default ContributorsModal
|
pool/shard001/JavaScript/0010087_Player1.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2017 XieJinChi ChenYiXiu
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
|
| 15 |
+
/*const GameCharacter = {
|
| 16 |
+
'BigMan' : 3,
|
| 17 |
+
'FlexMan' : 4,
|
| 18 |
+
'NormalMan' : 5
|
| 19 |
+
}*/
|
| 20 |
+
function Player1(spriteTexture,character){
|
| 21 |
+
this.mPlayer = new SpriteRenderable(spriteTexture)
|
| 22 |
+
//this.mPlayer = new Renderable()
|
| 23 |
+
this.mPlayer.setColor([1, 1, 1, 0])
|
| 24 |
+
this.mPlayer.getXform().setPosition(-30, -15)
|
| 25 |
+
//this.mPlayer.getXform().setSize(8, 8)
|
| 26 |
+
GameObject.call(this, this.mPlayer)
|
| 27 |
+
this.mMoveFric = null
|
| 28 |
+
this.mRotFric = null
|
| 29 |
+
this.mAcc = null
|
| 30 |
+
this.mSkill = false
|
| 31 |
+
this.mSkillFrozenTime = 0
|
| 32 |
+
this.mSkillLastTime = 0
|
| 33 |
+
this.mIsSkilling = false
|
| 34 |
+
this.mInverse = false
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
var r = null
|
| 38 |
+
// new RigidRectangle(this.getXform(), 8, 8)
|
| 39 |
+
|
| 40 |
+
//this.toggleDrawRenderable()
|
| 41 |
+
// alert(character)
|
| 42 |
+
if(character === GameCharacter.BigMan){
|
| 43 |
+
this.mPlayer.getXform().setSize(10, 10)
|
| 44 |
+
r = new RigidRectangle(this.getXform(), 10, 10)
|
| 45 |
+
r.setMass(3)
|
| 46 |
+
this.mAcc = 18
|
| 47 |
+
this.mMoveFric = 0.993
|
| 48 |
+
this.mRotFric = 0.97
|
| 49 |
+
// this.mPlayer.setColor([1, 0, 0, 1])
|
| 50 |
+
}else if(character === GameCharacter.FlexMan){
|
| 51 |
+
this.mPlayer.getXform().setSize(5, 5)
|
| 52 |
+
r = new RigidRectangle(this.getXform(), 5, 5)
|
| 53 |
+
r.setMass(0.5)
|
| 54 |
+
this.mAcc = 50
|
| 55 |
+
this.mMoveFric = 0.982
|
| 56 |
+
this.mRotFric = 0.98
|
| 57 |
+
// this.mPlayer.setColor([1, 1, 0, 1])
|
| 58 |
+
}else{
|
| 59 |
+
this.mPlayer.getXform().setSize(8, 8)
|
| 60 |
+
r = new RigidRectangle(this.getXform(), 8, 8)
|
| 61 |
+
r.autoSetMass()
|
| 62 |
+
r.setMass(1)
|
| 63 |
+
this.mAcc = 35
|
| 64 |
+
this.mMoveFric = 0.991
|
| 65 |
+
this.mRotFric = 0.991
|
| 66 |
+
// r.setMass(1)
|
| 67 |
+
// this.mPlayer.setColor([1, 0, 1, 1])
|
| 68 |
+
}
|
| 69 |
+
this.setRigidBody(r)
|
| 70 |
+
this.mGameCharacter = character
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
gEngine.Core.inheritPrototype(Player1,WASDObj)
|
| 74 |
+
|
| 75 |
+
Player1.prototype.getSkillFrozenTime = function(){
|
| 76 |
+
return this.mSkillFrozenTime
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
Player1.prototype.getGameCharacter = function(){
|
| 80 |
+
return this.mGameCharacter
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
Player1.prototype.getStateString = function(){
|
| 84 |
+
let str = 'Player1:'
|
| 85 |
+
let num = 0
|
| 86 |
+
if(this.mGameCharacter === GameCharacter.BigMan){
|
| 87 |
+
str += 'Backoff'
|
| 88 |
+
num = this.mSkillFrozenTime/Skill.getBigManFrozenTime() * 100
|
| 89 |
+
|
| 90 |
+
}else if(this.mGameCharacter === GameCharacter.FlexMan){
|
| 91 |
+
str += 'Even Faster'
|
| 92 |
+
num = this.mSkillFrozenTime/Skill.getFlexManFrozenTime() * 100
|
| 93 |
+
}else{
|
| 94 |
+
str += 'Puzzle'
|
| 95 |
+
num = this.mSkillFrozenTime/Skill.getNormalManFrozenTime() * 100
|
| 96 |
+
}
|
| 97 |
+
if(num>100) num =100
|
| 98 |
+
num = Math.floor(num)
|
| 99 |
+
str += num.toString()
|
| 100 |
+
str += '%'
|
| 101 |
+
return str
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
Player1.prototype.update = function () {
|
| 105 |
+
if(this.mIsSkilling === false){
|
| 106 |
+
GameObject.prototype.update.call(this)
|
| 107 |
+
this.mSkillFrozenTime += 1
|
| 108 |
+
if(gEngine.Input.isKeyClicked(gEngine.Input.keys.E)){
|
| 109 |
+
if(this.mGameCharacter === GameCharacter.BigMan){
|
| 110 |
+
//alert('big man skill')
|
| 111 |
+
if(Skill.bigManSkill(this.mSkillFrozenTime,this.getRigidBody())){
|
| 112 |
+
this.mSkillFrozenTime = 0
|
| 113 |
+
this.mIsSkilling = true
|
| 114 |
+
this.mRotFric = 1
|
| 115 |
+
this.mAcc /= 5
|
| 116 |
+
}
|
| 117 |
+
}else if(this.mGameCharacter === GameCharacter.FlexMan){
|
| 118 |
+
//alert('speed man skill')
|
| 119 |
+
if(Skill.flexManSkill(this.mSkillFrozenTime,this.getRigidBody())){
|
| 120 |
+
this.mSkillFrozenTime = 0
|
| 121 |
+
this.mIsSkilling = true
|
| 122 |
+
this.mAcc += 70
|
| 123 |
+
|
| 124 |
+
}
|
| 125 |
+
}else{
|
| 126 |
+
//alert('balance man skill')
|
| 127 |
+
if(Skill.normalManSkill(this.mSkillFrozenTime,this.getRigidBody())){
|
| 128 |
+
this.mSkillFrozenTime = 0
|
| 129 |
+
this.mIsSkilling = true
|
| 130 |
+
this.mInverse = true
|
| 131 |
+
}
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
}else{
|
| 135 |
+
this.mSkillLastTime += 1
|
| 136 |
+
GameObject.prototype.update.call(this)
|
| 137 |
+
if(this.mGameCharacter === GameCharacter.BigMan){
|
| 138 |
+
//alert('big man skill')
|
| 139 |
+
|
| 140 |
+
if(Skill.relieveBigManSkill(this.mSkillLastTime,this.getRigidBody())){
|
| 141 |
+
// GameObject.prototype.update.call(this)
|
| 142 |
+
this.mSkillLastTime = 0
|
| 143 |
+
this.mIsSkilling = false
|
| 144 |
+
this.mRotFric = 0.97
|
| 145 |
+
this.mAcc *= 5
|
| 146 |
+
|
| 147 |
+
}
|
| 148 |
+
}else if(this.mGameCharacter === GameCharacter.FlexMan){
|
| 149 |
+
//alert('speed man skill')
|
| 150 |
+
//GameObject.prototype.update.call(this)
|
| 151 |
+
if(Skill.relieveFlexManSkill(this.mSkillLastTime,this.getRigidBody())){
|
| 152 |
+
this.mSkillLastTime = 0
|
| 153 |
+
this.mIsSkilling = false
|
| 154 |
+
this.mAcc -= 70
|
| 155 |
+
}
|
| 156 |
+
}else{
|
| 157 |
+
//alert('balance man skill')
|
| 158 |
+
// GameObject.prototype.update.call(this)
|
| 159 |
+
if(Skill.relieveNormalManSkill(this.mSkillLastTime,this)){
|
| 160 |
+
this.mSkillLastTime = 0
|
| 161 |
+
this.mIsSkilling = false
|
| 162 |
+
this.mInverse = false
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
}
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
Player1.prototype.getInverse = function(){
|
| 170 |
+
return this.mInverse
|
| 171 |
+
}
|
pool/shard001/JavaScript/0010089_demo.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var ResourceManager = require('./index.js').ResourceManager;
|
| 2 |
+
var mgr = new ResourceManager('','test');
|
| 3 |
+
|
| 4 |
+
mgr.upload('test.jpg','./test.jpg',true,function(err,result){
|
| 5 |
+
if (err) {
|
| 6 |
+
console.log(err);
|
| 7 |
+
return;
|
| 8 |
+
}
|
| 9 |
+
console.log(result);
|
| 10 |
+
});
|
| 11 |
+
|
| 12 |
+
mgr.delete('abc.jpg',function(err,result){
|
| 13 |
+
if (err) {
|
| 14 |
+
console.log(err);
|
| 15 |
+
return;
|
| 16 |
+
}
|
| 17 |
+
console.log(result);
|
| 18 |
+
});
|
pool/shard001/JavaScript/0010091_building.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var tools = require('../tools')
|
| 2 |
+
var mongoose = require('mongoose')
|
| 3 |
+
var Mixed = mongoose.Schema.Types.Mixed
|
| 4 |
+
|
| 5 |
+
var buildingSchema = mongoose.Schema({
|
| 6 |
+
address: {
|
| 7 |
+
type: String,
|
| 8 |
+
require: true
|
| 9 |
+
},
|
| 10 |
+
coords: Mixed,
|
| 11 |
+
name: String,
|
| 12 |
+
historicName: String,
|
| 13 |
+
slug: String,
|
| 14 |
+
researchBy: String,
|
| 15 |
+
researchYear: String,
|
| 16 |
+
dateConstructed: String,
|
| 17 |
+
architect: String,
|
| 18 |
+
client: String,
|
| 19 |
+
currentTenant: String,
|
| 20 |
+
era: String,
|
| 21 |
+
stories: String,
|
| 22 |
+
owner: String,
|
| 23 |
+
ownerStatus: String,
|
| 24 |
+
dimensions: String,
|
| 25 |
+
visibleExterior: String,
|
| 26 |
+
accessibleInterior: String,
|
| 27 |
+
explanation: String,
|
| 28 |
+
neighborhood: Mixed,
|
| 29 |
+
tour: Mixed,
|
| 30 |
+
style: Mixed,
|
| 31 |
+
use: Mixed,
|
| 32 |
+
historicUse: Mixed,
|
| 33 |
+
material: Mixed,
|
| 34 |
+
structure: Mixed,
|
| 35 |
+
structuralCondition: String,
|
| 36 |
+
exteriorCondition: String,
|
| 37 |
+
roofType: Mixed,
|
| 38 |
+
roofMaterial: Mixed,
|
| 39 |
+
relatedBuildings: Mixed,
|
| 40 |
+
environment: Mixed,
|
| 41 |
+
images: Mixed,
|
| 42 |
+
structure: String,
|
| 43 |
+
research: String,
|
| 44 |
+
narrative: String,
|
| 45 |
+
threat: String,
|
| 46 |
+
fieldEvaluations: String,
|
| 47 |
+
physical: String,
|
| 48 |
+
streetscape: String,
|
| 49 |
+
social: String,
|
| 50 |
+
history: String,
|
| 51 |
+
addlInfo: String,
|
| 52 |
+
citations: String,
|
| 53 |
+
links: String,
|
| 54 |
+
type: String,
|
| 55 |
+
number: String,
|
| 56 |
+
sortNum: String,
|
| 57 |
+
sortAlpha: String
|
| 58 |
+
}, {
|
| 59 |
+
timestamps: true
|
| 60 |
+
})
|
| 61 |
+
|
| 62 |
+
buildingSchema.pre('save', function(next) {
|
| 63 |
+
if(!this.name)
|
| 64 |
+
this.name = this.address
|
| 65 |
+
this.type = 'building'
|
| 66 |
+
tools.preSave(this)
|
| 67 |
+
next()
|
| 68 |
+
})
|
| 69 |
+
|
| 70 |
+
module.exports = mongoose.model('Building', buildingSchema)
|
pool/shard001/JavaScript/0010099_product.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var mongoose = require('mongoose');
|
| 2 |
+
var User = require("./user");
|
| 3 |
+
var Schema = mongoose.Schema; var nodemailer = require('nodemailer');
|
| 4 |
+
var transporter = nodemailer.createTransport({
|
| 5 |
+
service: 'gmail',
|
| 6 |
+
auth: {
|
| 7 |
+
user: 'myfreakinmailer@gmail.com',
|
| 8 |
+
pass: require("./config").trasportedPW
|
| 9 |
+
}
|
| 10 |
+
});
|
| 11 |
+
|
| 12 |
+
var pro = new Schema({
|
| 13 |
+
"name": {
|
| 14 |
+
"type": String, "required": true
|
| 15 |
+
},
|
| 16 |
+
"description": {
|
| 17 |
+
"type": String, "required": true
|
| 18 |
+
},
|
| 19 |
+
"category": {
|
| 20 |
+
"type": String, "required": false
|
| 21 |
+
},
|
| 22 |
+
"weight": {
|
| 23 |
+
"type": Number, "required": true
|
| 24 |
+
},
|
| 25 |
+
"price": {
|
| 26 |
+
"type": Number, "required": true
|
| 27 |
+
},
|
| 28 |
+
"quantity": {
|
| 29 |
+
"type": Number, "required": true
|
| 30 |
+
},
|
| 31 |
+
"img": {
|
| 32 |
+
"type": [String], "required": false
|
| 33 |
+
},
|
| 34 |
+
"seller": { "type": Schema.ObjectId, "ref": "User" },
|
| 35 |
+
"deleted": { "type": Boolean, "default": false },
|
| 36 |
+
"insertionDate": { "type": Number, "default": Date.now() }
|
| 37 |
+
});
|
| 38 |
+
|
| 39 |
+
pro.pre("save", function (next) {
|
| 40 |
+
if (!this.isNew && this.isModified("quantity") && this.quantity < 5) {
|
| 41 |
+
var mailOptions =
|
| 42 |
+
{
|
| 43 |
+
from: 'myfreakinmailer@gmail.com',
|
| 44 |
+
to: "",
|
| 45 |
+
subject: 'Information',
|
| 46 |
+
text: ""
|
| 47 |
+
};
|
| 48 |
+
User.findById(this.seller).exec(function (error, seller) {
|
| 49 |
+
mailOptions.to = seller.email;
|
| 50 |
+
mailOptions.text = "Dear, " + seller.name + ",we kindly inform you that your buissiness is going well and the remains of " + this.name + " are under 5 units."
|
| 51 |
+
if (require("./config").env==="dev") {
|
| 52 |
+
console.log("Mailing the following after the update: " + mailOptions.to);
|
| 53 |
+
} else {
|
| 54 |
+
transporter.sendMail(mailOptions, function (error, info) {
|
| 55 |
+
if (error) {
|
| 56 |
+
console.log(error);
|
| 57 |
+
}
|
| 58 |
+
});
|
| 59 |
+
}
|
| 60 |
+
});
|
| 61 |
+
}
|
| 62 |
+
next();
|
| 63 |
+
});
|
| 64 |
+
|
| 65 |
+
var Product = mongoose.model('Product', pro);
|
| 66 |
+
|
| 67 |
+
module.exports = Product;
|