Upload folder using huggingface_hub (part 55)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- pool/shard004/JavaScript/0028887_check-style.js +32 -0
- pool/shard004/JavaScript/0028889_duration.js +26 -0
- pool/shard004/JavaScript/0028892_autoheight-96129f09eb119d302b8b936606276fb6acb08fb0d07b8b1c2aee7550795ceced.js +56 -0
- pool/shard004/JavaScript/0028896_user.js +34 -0
- pool/shard004/JavaScript/0028899_defaults-hu_HU.js +44 -0
- pool/shard004/JavaScript/0028906_storage-test.js +99 -0
- pool/shard004/JavaScript/0028912_questionnaire-list.js +70 -0
- pool/shard004/JavaScript/0028915_messages.js +110 -0
- pool/shard004/JavaScript/0028918_main.js +35 -0
- pool/shard004/JavaScript/0028919_LocalisedAmountFormatter.js +71 -0
- pool/shard004/JavaScript/0028920_onAnimationFrame.js +52 -0
- pool/shard004/JavaScript/0028923_MainSection.js +83 -0
- pool/shard004/JavaScript/0028925_categoryActions.js +80 -0
- pool/shard004/JavaScript/0028926_rest-spread.js +58 -0
- pool/shard004/JavaScript/0028927_main.js +63 -0
- pool/shard004/JavaScript/0028930_server.js +63 -0
- pool/shard004/JavaScript/0028935_routes.js +21 -0
- pool/shard004/JavaScript/0028936_backbonedemo1.js +110 -0
- pool/shard004/JavaScript/0028939_CustomMenu.js +45 -0
- pool/shard004/JavaScript/0028941_serveWar.js +98 -0
- pool/shard004/JavaScript/0028942_component.js +141 -0
- pool/shard004/JavaScript/0028944_calculateTransform.js +92 -0
- pool/shard004/JavaScript/0028950_SubWS.js +86 -0
- pool/shard004/JavaScript/0028951_GreetingMaster.js +30 -0
- pool/shard004/JavaScript/0028953_node-details.js +136 -0
- pool/shard004/JavaScript/0028957_redshift.js +65 -0
- pool/shard004/JavaScript/0028959_Program.js +58 -0
- pool/shard004/JavaScript/0028960_app.js +80 -0
- pool/shard004/JavaScript/0028962_Iterator.js +34 -0
- pool/shard004/JavaScript/0028967_standardizeMarriageDate.js +130 -0
- pool/shard004/JavaScript/0028968_hot-code-loading.js +214 -0
- pool/shard004/JavaScript/0028970_PixelRatio.js +21 -0
- pool/shard004/JavaScript/0028972_gulpfile.js +57 -0
- pool/shard004/JavaScript/0028973_SprkAlert.test.js +117 -0
- pool/shard004/JavaScript/0028974_gallery.js +45 -0
- pool/shard004/JavaScript/0028975_List.test.js +22 -0
- pool/shard004/JavaScript/0028977_sdna.js +91 -0
- pool/shard004/JavaScript/0028978_background.js +39 -0
- pool/shard004/JavaScript/0028982_ping.js +44 -0
- pool/shard004/JavaScript/0028985_user.model.js +18 -0
- pool/shard004/JavaScript/0028987_HTMLElement72.js +104 -0
- pool/shard004/JavaScript/0028989_react_jqxscrollview.js +176 -0
- pool/shard004/JavaScript/0028995_test-http-zero-length-write.js +94 -0
- pool/shard004/JavaScript/0028996_habitaciones_test.js +108 -0
- pool/shard004/JavaScript/0028997_BlogPage.js +111 -0
- pool/shard004/JavaScript/0028999_sakugawa_test.js +32 -0
- pool/shard004/JavaScript/0029003_add.js +64 -0
- pool/shard004/JavaScript/0029006_datastream.js +172 -0
- pool/shard004/JavaScript/0029008_install.1.6.js +105 -0
- pool/shard004/JavaScript/0029010_study.js +60 -0
pool/shard004/JavaScript/0028887_check-style.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var ConfigurationLocator = require('./configuration-locator');
|
| 2 |
+
var shell = require('procstreams');
|
| 3 |
+
var DOMParser = require('xmldom').DOMParser;
|
| 4 |
+
var xpath = require('xpath');
|
| 5 |
+
var path = require('path');
|
| 6 |
+
var buildComment = require('./build-comment');
|
| 7 |
+
var assert = require('better-assert');
|
| 8 |
+
|
| 9 |
+
module.exports = function(entry, parameters, complete) {
|
| 10 |
+
assert(parameters.repository().path() !== undefined);
|
| 11 |
+
assert(parameters.configuration().checkstyle() !== undefined);
|
| 12 |
+
|
| 13 |
+
var filePath = path.join(parameters.repository().path(), entry);
|
| 14 |
+
var checkStyle = parameters.configuration().checkstyle();
|
| 15 |
+
var locator = new ConfigurationLocator(checkStyle.xml(), checkStyle.defaultXml());
|
| 16 |
+
var configXml = locator.locate(path.dirname(filePath));
|
| 17 |
+
|
| 18 |
+
// get XML report on STDOUT
|
| 19 |
+
shell('java', ['-jar', checkStyle.jar(), '-c', configXml, '-f', 'xml', filePath]).data(function(err, stdout, stderr) {
|
| 20 |
+
var comments = parameters.review().comments(entry);
|
| 21 |
+
var parser = new DOMParser();
|
| 22 |
+
var doc = parser.parseFromString(stdout.toString());
|
| 23 |
+
var errors = xpath.select('/checkstyle/file/error', doc);
|
| 24 |
+
errors.forEach(function(errorNode) {
|
| 25 |
+
var line = xpath.select1('@line', errorNode).value;
|
| 26 |
+
var message = xpath.select1('@message', errorNode).value;
|
| 27 |
+
var severity = xpath.select1('@severity', errorNode).value;
|
| 28 |
+
comments.push(buildComment(line, severity + ': ' + message));
|
| 29 |
+
});
|
| 30 |
+
complete(null);
|
| 31 |
+
});
|
| 32 |
+
}
|
pool/shard004/JavaScript/0028889_duration.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Adds started_at, ended_at and duration headers to the response
|
| 3 |
+
*/
|
| 4 |
+
const DurationMiddleware = () => ({
|
| 5 |
+
request (request) {
|
| 6 |
+
return request.enhance({
|
| 7 |
+
headers: { 'X-Started-At': Date.now() }
|
| 8 |
+
})
|
| 9 |
+
},
|
| 10 |
+
|
| 11 |
+
response (next) {
|
| 12 |
+
const endedAt = Date.now()
|
| 13 |
+
|
| 14 |
+
return next().then((response) => {
|
| 15 |
+
return response.enhance({
|
| 16 |
+
headers: {
|
| 17 |
+
'X-Started-At': response.request().headers()['x-started-at'],
|
| 18 |
+
'X-Ended-At': endedAt,
|
| 19 |
+
'X-Duration': endedAt - response.request().headers()['x-started-at']
|
| 20 |
+
}
|
| 21 |
+
})
|
| 22 |
+
})
|
| 23 |
+
}
|
| 24 |
+
})
|
| 25 |
+
|
| 26 |
+
export default DurationMiddleware
|
pool/shard004/JavaScript/0028892_autoheight-96129f09eb119d302b8b936606276fb6acb08fb0d07b8b1c2aee7550795ceced.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*******************************************************************************
|
| 2 |
+
* KindEditor - WYSIWYG HTML Editor for Internet
|
| 3 |
+
* Copyright (C) 2006-2011 kindsoft.net
|
| 4 |
+
*
|
| 5 |
+
* @author Roddy <luolonghao@gmail.com>
|
| 6 |
+
* @site http://www.kindsoft.net/
|
| 7 |
+
* @licence http://www.kindsoft.net/license.php
|
| 8 |
+
*******************************************************************************/
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
KindEditor.plugin('autoheight', function(K) {
|
| 12 |
+
var self = this;
|
| 13 |
+
|
| 14 |
+
if (!self.autoHeightMode) {
|
| 15 |
+
return;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
var minHeight;
|
| 19 |
+
|
| 20 |
+
function hideScroll() {
|
| 21 |
+
var edit = self.edit;
|
| 22 |
+
var body = edit.doc.body;
|
| 23 |
+
edit.iframe[0].scroll = 'no';
|
| 24 |
+
body.style.overflowY = 'hidden';
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
function resetHeight() {
|
| 28 |
+
var edit = self.edit;
|
| 29 |
+
var body = edit.doc.body;
|
| 30 |
+
edit.iframe.height(minHeight);
|
| 31 |
+
self.resize(null, Math.max((K.IE ? body.scrollHeight : body.offsetHeight) + 76, minHeight));
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function init() {
|
| 35 |
+
minHeight = K.removeUnit(self.height);
|
| 36 |
+
|
| 37 |
+
self.edit.afterChange(resetHeight);
|
| 38 |
+
hideScroll();
|
| 39 |
+
resetHeight();
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
if (self.isCreated) {
|
| 43 |
+
init();
|
| 44 |
+
} else {
|
| 45 |
+
self.afterCreate(init);
|
| 46 |
+
}
|
| 47 |
+
});
|
| 48 |
+
|
| 49 |
+
/*
|
| 50 |
+
* 如何实现真正的自动高度?
|
| 51 |
+
* 修改编辑器高度之后,再次获取body内容高度时,最小值只会是当前iframe的设置高度,这样就导致高度只增不减。
|
| 52 |
+
* 所以每次获取body内容高度之前,先将iframe的高度重置为最小高度,这样就能获取body的实际高度。
|
| 53 |
+
* 由此就实现了真正的自动高度
|
| 54 |
+
* 测试:chrome、firefox、IE9、IE8
|
| 55 |
+
* */
|
| 56 |
+
;
|
pool/shard004/JavaScript/0028896_user.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var mongoose = require('mongoose')
|
| 2 |
+
var bcrypt = require('bcrypt-nodejs')
|
| 3 |
+
|
| 4 |
+
var UserSchema = new mongoose.Schema({
|
| 5 |
+
name: String,
|
| 6 |
+
username: {type: String, required: true, index: {unique: true}},
|
| 7 |
+
password: {type: String, required: true, select: false}
|
| 8 |
+
})
|
| 9 |
+
|
| 10 |
+
// hash the password before saving
|
| 11 |
+
UserSchema.pre('save', function (next) {
|
| 12 |
+
var user = this
|
| 13 |
+
|
| 14 |
+
if (!user.isModified('password')) {
|
| 15 |
+
return next()
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
bcrypt.hash(user.password, null, null, function (err, hash) {
|
| 19 |
+
if (err) {
|
| 20 |
+
return next(err)
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
user.password = hash
|
| 24 |
+
next()
|
| 25 |
+
})
|
| 26 |
+
})
|
| 27 |
+
|
| 28 |
+
// compare given password with db hash
|
| 29 |
+
UserSchema.methods.comparePassword = function (password) {
|
| 30 |
+
var user = this
|
| 31 |
+
return bcrypt.compareSync(password, user.password)
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
mongoose.model('User', UserSchema)
|
pool/shard004/JavaScript/0028899_defaults-hu_HU.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*!
|
| 2 |
+
* Bootstrap-select v1.12.4 (https://silviomoreto.github.io/bootstrap-select)
|
| 3 |
+
*
|
| 4 |
+
* Copyright 2013-2017 bootstrap-select
|
| 5 |
+
* Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE)
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
(function (root, factory) {
|
| 9 |
+
if (typeof define === 'function' && define.amd) {
|
| 10 |
+
// AMD. Register as an anonymous module unless amdModuleId is set
|
| 11 |
+
define(["jquery"], function (a0) {
|
| 12 |
+
return (factory(a0));
|
| 13 |
+
});
|
| 14 |
+
} else if (typeof module === 'object' && module.exports) {
|
| 15 |
+
// Node. Does not work with strict CommonJS, but
|
| 16 |
+
// only CommonJS-like environments that support module.exports,
|
| 17 |
+
// like Node.
|
| 18 |
+
module.exports = factory(require("jquery"));
|
| 19 |
+
} else {
|
| 20 |
+
factory(root["jQuery"]);
|
| 21 |
+
}
|
| 22 |
+
}(this, function (jQuery) {
|
| 23 |
+
|
| 24 |
+
(function ($) {
|
| 25 |
+
$.fn.selectpicker.defaults = {
|
| 26 |
+
noneSelectedText: 'Válasszon!',
|
| 27 |
+
noneResultsText: 'Nincs találat {0}',
|
| 28 |
+
countSelectedText: function (numSelected, numTotal) {
|
| 29 |
+
return '{0} elem kiválasztva';
|
| 30 |
+
},
|
| 31 |
+
maxOptionsText: function (numAll, numGroup) {
|
| 32 |
+
return [
|
| 33 |
+
'Legfeljebb {n} elem választható',
|
| 34 |
+
'A csoportban legfeljebb {n} elem választható'
|
| 35 |
+
];
|
| 36 |
+
},
|
| 37 |
+
selectAllText: 'Mind',
|
| 38 |
+
deselectAllText: 'Egyik sem',
|
| 39 |
+
multipleSeparator: ', '
|
| 40 |
+
};
|
| 41 |
+
})(jQuery);
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
}));
|
pool/shard004/JavaScript/0028906_storage-test.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Created by Pencroff on 30/01/2015.
|
| 3 |
+
*/
|
| 4 |
+
|
| 5 |
+
var env = process.env.Not_Gulp_Env ? 'src' : 'lib',
|
| 6 |
+
expect = require('chai').expect,
|
| 7 |
+
StorageCtor = require('../' + env + '/Storage');
|
| 8 |
+
|
| 9 |
+
describe('Storage', function () {
|
| 10 |
+
var store;
|
| 11 |
+
beforeEach(function (done) {
|
| 12 |
+
store = new StorageCtor();
|
| 13 |
+
done();
|
| 14 |
+
});
|
| 15 |
+
it('should return all data', function (done) {
|
| 16 |
+
expect(store.getAll()).to.eql({});
|
| 17 |
+
done();
|
| 18 |
+
});
|
| 19 |
+
it('Should return object for any flow', function (done) {
|
| 20 |
+
expect(store.getFlow('Flow1')).to.eql({});
|
| 21 |
+
expect(store.getFlow('Flow2')).to.eql({});
|
| 22 |
+
expect(store.getAll()).to.eql({
|
| 23 |
+
Flow1: {},
|
| 24 |
+
Flow2: {}
|
| 25 |
+
});
|
| 26 |
+
done();
|
| 27 |
+
});
|
| 28 |
+
it('should save data into step', function (done) {
|
| 29 |
+
store.setData('Flow', 'StepA', { some: 'First Object' });
|
| 30 |
+
store.setData('Flow', 'StepB', { some: 'Second Object' });
|
| 31 |
+
expect(store.getAll()).to.eql({
|
| 32 |
+
Flow: {
|
| 33 |
+
StepA: { some: 'First Object' },
|
| 34 |
+
StepB: { some: 'Second Object' }
|
| 35 |
+
}
|
| 36 |
+
});
|
| 37 |
+
done();
|
| 38 |
+
});
|
| 39 |
+
it('should get data for step', function (done) {
|
| 40 |
+
store.setData('Flow', 'StepA', {
|
| 41 |
+
fieldA: 'DataA',
|
| 42 |
+
fieldB: 'DataB'
|
| 43 |
+
});
|
| 44 |
+
expect(store.getStep('Flow', 'StepA')).to.eql({
|
| 45 |
+
fieldA: 'DataA',
|
| 46 |
+
fieldB: 'DataB'
|
| 47 |
+
});
|
| 48 |
+
done();
|
| 49 |
+
});
|
| 50 |
+
it('Should merge data into flow', function (done) {
|
| 51 |
+
store.setData('Flow', 'StepA', {
|
| 52 |
+
fieldA: 'DataA',
|
| 53 |
+
fieldB: 'DataB'
|
| 54 |
+
});
|
| 55 |
+
store.mergeData('Flow', 'StepA', {
|
| 56 |
+
fieldB: 'DataBB',
|
| 57 |
+
fieldC: 'DataC'
|
| 58 |
+
});
|
| 59 |
+
expect(store.getAll()).to.eql({
|
| 60 |
+
Flow: {
|
| 61 |
+
StepA: {
|
| 62 |
+
fieldA: 'DataA',
|
| 63 |
+
fieldB: 'DataBB',
|
| 64 |
+
fieldC: 'DataC'
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
});
|
| 68 |
+
done();
|
| 69 |
+
});
|
| 70 |
+
it('should support undefined or null values', function (done) {
|
| 71 |
+
store.setData('Flow', 'StepA');
|
| 72 |
+
expect(store.getStep('Flow', 'StepA')).to.eql({});
|
| 73 |
+
store.setData('Flow', 'StepA', null);
|
| 74 |
+
expect(store.getStep('Flow', 'StepA')).to.eql({});
|
| 75 |
+
store.mergeData('Flow', 'StepA');
|
| 76 |
+
expect(store.getStep('Flow', 'StepA')).to.eql({});
|
| 77 |
+
store.mergeData('Flow', 'StepA', null);
|
| 78 |
+
expect(store.getStep('Flow', 'StepA')).to.eql({});
|
| 79 |
+
done();
|
| 80 |
+
});
|
| 81 |
+
it('should clear flow data', function (done) {
|
| 82 |
+
store.setData('Flow', 'StepA', {
|
| 83 |
+
fieldA: 'DataA',
|
| 84 |
+
fieldB: 'DataB'
|
| 85 |
+
});
|
| 86 |
+
store.clearFlow('Flow');
|
| 87 |
+
expect(store.getFlow('Flow')).to.eql({});
|
| 88 |
+
done();
|
| 89 |
+
});
|
| 90 |
+
it('should clear flow data', function (done) {
|
| 91 |
+
store.setData('Flow', 'StepA', {
|
| 92 |
+
fieldA: 'DataA',
|
| 93 |
+
fieldB: 'DataB'
|
| 94 |
+
});
|
| 95 |
+
store.clear();
|
| 96 |
+
expect(store.getAll()).to.eql({});
|
| 97 |
+
done();
|
| 98 |
+
});
|
| 99 |
+
});
|
pool/shard004/JavaScript/0028912_questionnaire-list.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { getQuestionnaireList } from 'utils/remote-api';
|
| 2 |
+
import { questionnaireListRemoteToStores } from 'model/remote-to-stores';
|
| 3 |
+
|
| 4 |
+
export const LOAD_QLIST = 'LOAD_QLIST';
|
| 5 |
+
export const LOAD_QLIST_SUCCESS = 'LOAD_QLIST_SUCCESS';
|
| 6 |
+
export const LOAD_QLIST_FAILURE = 'LOAD_QLIST_FAILURE';
|
| 7 |
+
|
| 8 |
+
export const DELETE_QLIST_SUCCESS = 'DELETE_QLIST_SUCCESS';
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Load questionnaire list success
|
| 12 |
+
*
|
| 13 |
+
* It's executed after the remote fetch of a list of questionnaires.
|
| 14 |
+
*
|
| 15 |
+
* The parameter "updateList" is an array of complex object. For each object, entries correspond to reducers,
|
| 16 |
+
* they contain an update to apply to the piece of state handled by the reducer to represent locally the questionnaire.
|
| 17 |
+
*
|
| 18 |
+
* It will update the stores:
|
| 19 |
+
* - questionnaireById
|
| 20 |
+
* - componentById
|
| 21 |
+
* - componentByQuestionnaire
|
| 22 |
+
* - conditionById
|
| 23 |
+
*
|
| 24 |
+
* @param {array} updatesList The new values to update in the different stores affected.
|
| 25 |
+
* @return {object} LOAD_QLIST_SUCCESS action.
|
| 26 |
+
*/
|
| 27 |
+
export const loadQuestionnaireListSuccess = updatesList => ({
|
| 28 |
+
type: LOAD_QLIST_SUCCESS,
|
| 29 |
+
payload: updatesList,
|
| 30 |
+
});
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* Load questionnaire list failure
|
| 34 |
+
*
|
| 35 |
+
* It's executed after the fail of a remote questionnaires list fetch.
|
| 36 |
+
*
|
| 37 |
+
* @param {string} err The error returned for the fetch process.
|
| 38 |
+
* @return {object} LOAD_QLIST_FAILURE action
|
| 39 |
+
*/
|
| 40 |
+
export const loadQuestionnaireListFailure = err => ({
|
| 41 |
+
type: LOAD_QLIST_FAILURE,
|
| 42 |
+
payload: err,
|
| 43 |
+
});
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Load questionnaire list
|
| 47 |
+
*
|
| 48 |
+
* Asyc action that fetch a questionnaires list.
|
| 49 |
+
*
|
| 50 |
+
* @return {function} Thunk which may dispatch LOAD_QLIST_SUCCESS or LOAD_QLIST_FAILURE
|
| 51 |
+
*/
|
| 52 |
+
export const loadQuestionnaireList = (stamp, token) => dispatch => {
|
| 53 |
+
dispatch({
|
| 54 |
+
type: LOAD_QLIST,
|
| 55 |
+
payload: null,
|
| 56 |
+
});
|
| 57 |
+
return getQuestionnaireList(stamp, token)
|
| 58 |
+
.then(qrList =>
|
| 59 |
+
dispatch(
|
| 60 |
+
loadQuestionnaireListSuccess(questionnaireListRemoteToStores(qrList)),
|
| 61 |
+
),
|
| 62 |
+
)
|
| 63 |
+
.catch(err => dispatch(loadQuestionnaireListFailure(err)));
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
export const deleteQuestionnaireList = () => dispatch => {
|
| 67 |
+
dispatch({
|
| 68 |
+
type: DELETE_QLIST_SUCCESS,
|
| 69 |
+
});
|
| 70 |
+
};
|
pool/shard004/JavaScript/0028915_messages.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const Pino = require('pino')
|
| 2 |
+
const moment = require('moment')
|
| 3 |
+
const ip = require('ip')
|
| 4 |
+
|
| 5 |
+
const DynamoDB = require('./dynamodb.js')
|
| 6 |
+
const SQS = require('./sqs.js')
|
| 7 |
+
const Settings = require('./settings')
|
| 8 |
+
|
| 9 |
+
class Messages {
|
| 10 |
+
constructor () {
|
| 11 |
+
this.dynamodb = new DynamoDB()
|
| 12 |
+
this.logger = new Pino({ level: process.env.LOG_LEVEL })
|
| 13 |
+
this.sqs = new SQS()
|
| 14 |
+
this.settings = new Settings()
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
isBotCommand (message) {
|
| 18 |
+
return message.entities && message.entities[0] && message.entities[0].type === 'bot_command'
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
async handleBotCommand (message) {
|
| 22 |
+
const text = message.text
|
| 23 |
+
this.logger.info(text)
|
| 24 |
+
if (text.match(/\/jungHelp/i)) {
|
| 25 |
+
this.logger.info('newMessage jungHelp')
|
| 26 |
+
await this.sqs.sendJungHelpMessage(message)
|
| 27 |
+
}
|
| 28 |
+
if (text.match(/\/topTen/i)) {
|
| 29 |
+
this.logger.info('newMessage topTen')
|
| 30 |
+
await this.sqs.sendTopTenMessage(message)
|
| 31 |
+
}
|
| 32 |
+
if (text.match(/\/topDiver/i)) {
|
| 33 |
+
this.logger.info('newMessage topDiver')
|
| 34 |
+
await this.sqs.sendTopDiverMessage(message)
|
| 35 |
+
}
|
| 36 |
+
if (text.match(/\/allJung/i)) {
|
| 37 |
+
this.logger.info('newMessage allJung')
|
| 38 |
+
await this.sqs.sendAllJungMessage(message)
|
| 39 |
+
}
|
| 40 |
+
if (text.match(/\/enableAllJung/i)) {
|
| 41 |
+
this.logger.info('newMessage enableAllJung')
|
| 42 |
+
await this.sqs.sendEnableAllJungMessage(message)
|
| 43 |
+
}
|
| 44 |
+
if (text.match(/\/disableAllJung/i)) {
|
| 45 |
+
this.logger.info('newMessage disableAllJung')
|
| 46 |
+
await this.sqs.sendDisableAllJungMessage(message)
|
| 47 |
+
}
|
| 48 |
+
// setOffFromWorkTimeUTC
|
| 49 |
+
// Caveat: support only UTC time. Timezone support? ¯\_(ツ)_/¯
|
| 50 |
+
// params:
|
| 51 |
+
// 0000-2345, allow every 15 minutes interval. Get off at 17:48? ¯\_(ツ)_/¯
|
| 52 |
+
// comma seperated string of MON,TUE,WED,THU,FRI,SAT,SUN
|
| 53 |
+
const _handleIncorrectTimeFormat = async () => this.settings.setOffFromWorkTimeUTCIncorrectFormat({
|
| 54 |
+
chatId: message.chat.id,
|
| 55 |
+
chatTitle: message.chat.title
|
| 56 |
+
})
|
| 57 |
+
if (text.match(/\/setOffFromWorkTimeUTC/i)) {
|
| 58 |
+
this.logger.info('newMessage setOffFromWorkTimeUTC')
|
| 59 |
+
const params = text.split(' ')
|
| 60 |
+
if (params.length === 3) {
|
| 61 |
+
const offTime = params[1]
|
| 62 |
+
const rawWorkday = params[2]
|
| 63 |
+
if (offTime.match(/^([0-1]\d|2[0-3])(00|15|30|45)$/) &&
|
| 64 |
+
rawWorkday.match(/^((MON|TUE|WED|THU|FRI|SAT|SUN),?){0,6}(MON|TUE|WED|THU|FRI|SAT|SUN)$/)) {
|
| 65 |
+
// E.g. MON,MON will be considered as MON
|
| 66 |
+
const workday = [...new Set(rawWorkday.split(','))].join(',')
|
| 67 |
+
this.logger.info(`normalised - offTime: ${offTime}, workday: ${workday}`)
|
| 68 |
+
await this.sqs.sendSetOffFromWorkTimeUTC({ message, offTime, workday })
|
| 69 |
+
} else {
|
| 70 |
+
this.logger.info(`offTime: ${offTime}, rawWorkday: ${rawWorkday}`)
|
| 71 |
+
await _handleIncorrectTimeFormat()
|
| 72 |
+
}
|
| 73 |
+
} else {
|
| 74 |
+
await _handleIncorrectTimeFormat()
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
async newMessage (event) {
|
| 80 |
+
this.logger.info(`newMessage start at ${moment().format()}`)
|
| 81 |
+
try {
|
| 82 |
+
const xForwardedFor = event.headers['X-Forwarded-For'] || event.headers['x-forwarded-for']
|
| 83 |
+
const requestIP = xForwardedFor.split(', ')[0]
|
| 84 |
+
// should use WAF
|
| 85 |
+
if (!ip.cidrSubnet('91.108.4.0/22').contains(requestIP) && !ip.cidrSubnet('149.154.160.0/20').contains(requestIP)) {
|
| 86 |
+
this.logger.info(`Not Telegram Bot IP: ${requestIP}`)
|
| 87 |
+
return { statusCode: 403, message: 'Not Telegram Bot IP' }
|
| 88 |
+
}
|
| 89 |
+
const params = JSON.parse(event.body)
|
| 90 |
+
this.logger.trace(`messages.js::newMessage params: ${JSON.stringify(params)}`)
|
| 91 |
+
const message = params.message
|
| 92 |
+
if (!message || !message.chat.type.includes('group')) {
|
| 93 |
+
// handle edited_message and non group
|
| 94 |
+
return { statusCode: 204, message: 'edited_message or non-group' }
|
| 95 |
+
}
|
| 96 |
+
await this.dynamodb.saveMessage({ message })
|
| 97 |
+
if (this.isBotCommand(message)) {
|
| 98 |
+
await this.handleBotCommand(message)
|
| 99 |
+
}
|
| 100 |
+
this.logger.info(`newMessage finish at ${moment().format()}`)
|
| 101 |
+
return { statusCode: 200 }
|
| 102 |
+
} catch (e) {
|
| 103 |
+
this.logger.error(e.message)
|
| 104 |
+
this.logger.info(`newMessage finish with error at ${moment().format()}`)
|
| 105 |
+
return { statusCode: 500 }
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
module.exports = Messages
|
pool/shard004/JavaScript/0028918_main.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
System.register(["angular", "./user.service", "./user-form.component", "./user-list.component", "./user.component"], function(exports_1, context_1) {
|
| 2 |
+
"use strict";
|
| 3 |
+
var __moduleName = context_1 && context_1.id;
|
| 4 |
+
var ng, user_service_1, user_form_component_1, user_list_component_1, user_component_1;
|
| 5 |
+
var moduleName, appRootEl;
|
| 6 |
+
return {
|
| 7 |
+
setters:[
|
| 8 |
+
function (ng_1) {
|
| 9 |
+
ng = ng_1;
|
| 10 |
+
},
|
| 11 |
+
function (user_service_1_1) {
|
| 12 |
+
user_service_1 = user_service_1_1;
|
| 13 |
+
},
|
| 14 |
+
function (user_form_component_1_1) {
|
| 15 |
+
user_form_component_1 = user_form_component_1_1;
|
| 16 |
+
},
|
| 17 |
+
function (user_list_component_1_1) {
|
| 18 |
+
user_list_component_1 = user_list_component_1_1;
|
| 19 |
+
},
|
| 20 |
+
function (user_component_1_1) {
|
| 21 |
+
user_component_1 = user_component_1_1;
|
| 22 |
+
}],
|
| 23 |
+
execute: function() {
|
| 24 |
+
moduleName = "demo";
|
| 25 |
+
ng.module(moduleName, [])
|
| 26 |
+
.service(user_service_1.UserService.serviceName, user_service_1.UserService)
|
| 27 |
+
.component(user_form_component_1.UserFormComponent.controller.componentName, user_form_component_1.UserFormComponent)
|
| 28 |
+
.component(user_component_1.UserComponent.controller.componentName, user_component_1.UserComponent)
|
| 29 |
+
.component(user_list_component_1.UserListComponent.controller.componentName, user_list_component_1.UserListComponent);
|
| 30 |
+
appRootEl = document.querySelector("#app-container") || document.body;
|
| 31 |
+
ng.bootstrap(appRootEl, [moduleName]);
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
});
|
| 35 |
+
//# sourceMappingURL=main.js.map
|
pool/shard004/JavaScript/0028919_LocalisedAmountFormatter.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @module br/presenter/formatter/LocalisedAmountFormatter
|
| 3 |
+
*/
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* @class
|
| 7 |
+
* @alias module:br/presenter/formatter/LocalisedAmountFormatter
|
| 8 |
+
* @implements module:br/presenter/formatter/Formatter
|
| 9 |
+
*
|
| 10 |
+
* @classdesc
|
| 11 |
+
* Formats a number into a localised string representation.
|
| 12 |
+
* <p/>
|
| 13 |
+
* <code>LocalisedAmountFormatter</code> Formats a number to a configuarble number of decimal placess
|
| 14 |
+
* according to current locale of browser. It automatically detects the current locale of the the
|
| 15 |
+
* browser and uses that to format numbers. For example<br/>
|
| 16 |
+
* 1234567.89 = 1,234,567.89 in english locale<br/>
|
| 17 |
+
* 1234567.89 = 1.234.567,89 in french locale<br/>
|
| 18 |
+
* It is typically used with Presenter, but can be invoked programmatically:
|
| 19 |
+
* <p/>
|
| 20 |
+
* <code>br.presenter.formatter.LocalisedAmountFormatter.format(1234567890, {})</code>
|
| 21 |
+
* <code>br.presenter.formatter.LocalisedAmountFormatter.format(1234567890, {dp: 4})</code>
|
| 22 |
+
*/
|
| 23 |
+
br.presenter.formatter.LocalisedAmountFormatter = function()
|
| 24 |
+
{
|
| 25 |
+
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
+
br.Core.implement(br.presenter.formatter.LocalisedAmountFormatter, br.presenter.formatter.Formatter);
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Formats a number into an localised string representation.
|
| 32 |
+
*
|
| 33 |
+
* @param {Variant} vValue the numeric amount (Number type).
|
| 34 |
+
* if a string is passed it is returned unchanged.
|
| 35 |
+
* @param {Map} mAttributes a list of attributes, as specified here and in.
|
| 36 |
+
* dp: number of decinal places to be displayed. Rounding occurs according
|
| 37 |
+
* to standard javascript behaviour.
|
| 38 |
+
* @return the tokenized amount.
|
| 39 |
+
* @type String
|
| 40 |
+
*/
|
| 41 |
+
br.presenter.formatter.LocalisedAmountFormatter.prototype.format = function(vValue, mAttributes) {
|
| 42 |
+
|
| 43 |
+
//the field may want to display a message like "please enter " so
|
| 44 |
+
if (typeof vValue == "string") {
|
| 45 |
+
return vValue;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
if(typeof vValue != "number"){
|
| 49 |
+
throw "LocalisedAmountFormatter.format(value): value must be numeric";
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
if(vValue < 0){
|
| 53 |
+
throw "LocalisedAmountFormatter.format(value): value must be positive ";
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
var oAmount = new Number(vValue);
|
| 58 |
+
var decimalPlaces = mAttributes.dp || 0;
|
| 59 |
+
|
| 60 |
+
var oRounded = new Number(oAmount.toFixed(decimalPlaces));
|
| 61 |
+
var result = oRounded.toLocaleString();
|
| 62 |
+
return result;
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* @private
|
| 68 |
+
*/
|
| 69 |
+
br.presenter.formatter.LocalisedAmountFormatter.prototype.toString = function() {
|
| 70 |
+
return "br.presenter.formatter.LocalisedAmountFormatter";
|
| 71 |
+
};
|
pool/shard004/JavaScript/0028920_onAnimationFrame.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* global
|
| 2 |
+
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout,
|
| 3 |
+
requestAnimationFrame,
|
| 4 |
+
functionFPS,
|
| 5 |
+
ClassQueue
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
//=require shortcuts.js
|
| 9 |
+
//=require function/fps.js
|
| 10 |
+
//=require class/queue.js
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* onAnimationFrame
|
| 14 |
+
*
|
| 15 |
+
* call callback via RequestAnimationFrame
|
| 16 |
+
*
|
| 17 |
+
* @param {function} fn
|
| 18 |
+
*/
|
| 19 |
+
var functionOnAnimationFrame = (function() {
|
| 20 |
+
var queue = new ClassQueue(),
|
| 21 |
+
duration = 0, start, budget, current;
|
| 22 |
+
|
| 23 |
+
function process() {
|
| 24 |
+
start = performance.now();
|
| 25 |
+
budget = (1000 / 60) * (0.2 * (Math.min(60, functionFPS()) / 60));
|
| 26 |
+
|
| 27 |
+
current();
|
| 28 |
+
|
| 29 |
+
duration += performance.now() - start;
|
| 30 |
+
current = current = queue.dequeue();
|
| 31 |
+
|
| 32 |
+
if(duration < budget) {
|
| 33 |
+
current && process();
|
| 34 |
+
} else {
|
| 35 |
+
duration = 0;
|
| 36 |
+
|
| 37 |
+
current && handle();
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
function handle() {
|
| 42 |
+
requestAnimationFrame(process);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
return function functionOnAnimationFrame(fn) {
|
| 46 |
+
queue.enqueue(fn);
|
| 47 |
+
|
| 48 |
+
if(!current && (current = queue.dequeue())) {
|
| 49 |
+
handle();
|
| 50 |
+
}
|
| 51 |
+
};
|
| 52 |
+
}());
|
pool/shard004/JavaScript/0028923_MainSection.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { Component, PropTypes } from 'react';
|
| 2 |
+
import TodoItem from './TodoItem';
|
| 3 |
+
import Footer from './Footer';
|
| 4 |
+
import { SHOW_ALL, SHOW_COMPLETED, SHOW_ACTIVE } from '../constants/TodoFilters';
|
| 5 |
+
|
| 6 |
+
const TODO_FILTERS = {
|
| 7 |
+
[SHOW_ALL]: () => true,
|
| 8 |
+
[SHOW_ACTIVE]: todo => !todo.completed,
|
| 9 |
+
[SHOW_COMPLETED]: todo => todo.completed
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
+
class MainSection extends Component {
|
| 13 |
+
constructor(props, context) {
|
| 14 |
+
super(props, context);
|
| 15 |
+
this.state = { filter: SHOW_ALL };
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
handleClearCompleted() {
|
| 19 |
+
this.props.actions.clearCompleted();
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
handleShow(filter) {
|
| 23 |
+
this.setState({ filter });
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
renderToggleAll(completedCount) {
|
| 27 |
+
const { todos, actions } = this.props;
|
| 28 |
+
if (todos.length > 0) {
|
| 29 |
+
return (
|
| 30 |
+
<input className="toggle-all"
|
| 31 |
+
type="checkbox"
|
| 32 |
+
checked={completedCount === todos.length}
|
| 33 |
+
onChange={actions.completeAll} />
|
| 34 |
+
);
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
renderFooter(completedCount) {
|
| 39 |
+
const { todos } = this.props;
|
| 40 |
+
const { filter } = this.state;
|
| 41 |
+
const activeCount = todos.length - completedCount;
|
| 42 |
+
|
| 43 |
+
if (todos.length) {
|
| 44 |
+
return (
|
| 45 |
+
<Footer completedCount={completedCount}
|
| 46 |
+
activeCount={activeCount}
|
| 47 |
+
filter={filter}
|
| 48 |
+
onClearCompleted={this.handleClearCompleted.bind(this)}
|
| 49 |
+
onShow={this.handleShow.bind(this)} />
|
| 50 |
+
);
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
render() {
|
| 55 |
+
const { todos, actions } = this.props;
|
| 56 |
+
const { filter } = this.state;
|
| 57 |
+
|
| 58 |
+
const filteredTodos = todos.filter(TODO_FILTERS[filter]);
|
| 59 |
+
const completedCount = todos.reduce((count, todo) =>
|
| 60 |
+
todo.completed ? count + 1 : count,
|
| 61 |
+
0
|
| 62 |
+
);
|
| 63 |
+
|
| 64 |
+
return (
|
| 65 |
+
<section className="main">
|
| 66 |
+
{this.renderToggleAll(completedCount)}
|
| 67 |
+
<ul className="todo-list">
|
| 68 |
+
{filteredTodos.map(todo =>
|
| 69 |
+
<TodoItem key={todo.id} todo={todo} {...actions} />
|
| 70 |
+
)}
|
| 71 |
+
</ul>
|
| 72 |
+
{this.renderFooter(completedCount)}
|
| 73 |
+
</section>
|
| 74 |
+
);
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
MainSection.propTypes = {
|
| 79 |
+
todos: PropTypes.array.isRequired,
|
| 80 |
+
actions: PropTypes.object.isRequired
|
| 81 |
+
};
|
| 82 |
+
|
| 83 |
+
export default MainSection;
|
pool/shard004/JavaScript/0028925_categoryActions.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import axios from 'axios';
|
| 2 |
+
import * as actionTypes from '../actions/types';
|
| 3 |
+
|
| 4 |
+
/**
|
| 5 |
+
* Set Categories
|
| 6 |
+
*
|
| 7 |
+
* @description Set the categories in the store
|
| 8 |
+
*
|
| 9 |
+
* @param {object} categories - Payload of categories to dispatch to store
|
| 10 |
+
*
|
| 11 |
+
* @returns {object} action
|
| 12 |
+
*/
|
| 13 |
+
const setCategories = categories =>
|
| 14 |
+
({ type: actionTypes.SET_CATEGORIES, categories });
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Add Category
|
| 18 |
+
*
|
| 19 |
+
* @description Adds a new category to the store
|
| 20 |
+
*
|
| 21 |
+
* @param {object} category - Payload of single category to add to store
|
| 22 |
+
*
|
| 23 |
+
* @returns {object} action
|
| 24 |
+
*/
|
| 25 |
+
const addCategory = category =>
|
| 26 |
+
({ type: actionTypes.ADD_CATEGORY, category });
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Get Categories
|
| 30 |
+
*
|
| 31 |
+
* @description Makes request to the server to get categories
|
| 32 |
+
*
|
| 33 |
+
* @param {void} null - Has no parameter
|
| 34 |
+
*
|
| 35 |
+
* @returns {object} action
|
| 36 |
+
*/
|
| 37 |
+
const fetchCategories = () =>
|
| 38 |
+
dispatch =>
|
| 39 |
+
axios.get('/api/v1/categories')
|
| 40 |
+
.then((res) => {
|
| 41 |
+
dispatch(setCategories(res.data.categories));
|
| 42 |
+
return res.data;
|
| 43 |
+
})
|
| 44 |
+
.catch((err) => {
|
| 45 |
+
dispatch(setCategories([]));
|
| 46 |
+
return err.response.data.message;
|
| 47 |
+
});
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Create/Add Category
|
| 51 |
+
*
|
| 52 |
+
* @description Sends category to be saved to the server
|
| 53 |
+
*
|
| 54 |
+
* @param {object} categoryDetails - Details of the category to be added to the
|
| 55 |
+
* library
|
| 56 |
+
*
|
| 57 |
+
* @returns {object} action
|
| 58 |
+
*/
|
| 59 |
+
const saveCategory = categoryDetails =>
|
| 60 |
+
dispatch =>
|
| 61 |
+
axios.post('/api/v1/category', categoryDetails)
|
| 62 |
+
.then((res) => {
|
| 63 |
+
const { category, message } = res.data;
|
| 64 |
+
category.cat = [];
|
| 65 |
+
dispatch(addCategory(category));
|
| 66 |
+
Materialize.toast(message, 4000, 'green');
|
| 67 |
+
return { res: res.data, isDone: true };
|
| 68 |
+
})
|
| 69 |
+
.catch((err) => {
|
| 70 |
+
Materialize.toast(err.response.data.message, 4000, 'red');
|
| 71 |
+
return {
|
| 72 |
+
isDone: false
|
| 73 |
+
};
|
| 74 |
+
});
|
| 75 |
+
|
| 76 |
+
export {
|
| 77 |
+
fetchCategories,
|
| 78 |
+
setCategories,
|
| 79 |
+
saveCategory,
|
| 80 |
+
};
|
pool/shard004/JavaScript/0028926_rest-spread.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export var tests = {
|
| 2 |
+
|
| 3 |
+
"rest arguments" (test) {
|
| 4 |
+
|
| 5 |
+
((...args) => {
|
| 6 |
+
|
| 7 |
+
test
|
| 8 |
+
._("rest argument is an Array")
|
| 9 |
+
.assert(Array.isArray(args))
|
| 10 |
+
._("rest argument has the correct values")
|
| 11 |
+
.equals(args, [1, 2, 3, 4, 5])
|
| 12 |
+
;
|
| 13 |
+
|
| 14 |
+
})(1, 2, 3, 4, 5);
|
| 15 |
+
},
|
| 16 |
+
|
| 17 |
+
"spread call" (test) {
|
| 18 |
+
|
| 19 |
+
((...args) => {
|
| 20 |
+
|
| 21 |
+
test
|
| 22 |
+
._("arrays can be spread into a function call")
|
| 23 |
+
.equals(args, [1, 2, 3, 4, 5])
|
| 24 |
+
;
|
| 25 |
+
|
| 26 |
+
})(1, ...[2, 3, 4], 5);
|
| 27 |
+
|
| 28 |
+
var set = new Set;
|
| 29 |
+
set.add(2);
|
| 30 |
+
set.add(3);
|
| 31 |
+
set.add(4);
|
| 32 |
+
|
| 33 |
+
((...args) => {
|
| 34 |
+
|
| 35 |
+
test
|
| 36 |
+
._("iterables can be spread into a function call")
|
| 37 |
+
.equals(args, [1, 2, 3, 4, 5])
|
| 38 |
+
;
|
| 39 |
+
|
| 40 |
+
})(1, ...set.values(), 5);
|
| 41 |
+
},
|
| 42 |
+
|
| 43 |
+
"spread in array literals" (test) {
|
| 44 |
+
|
| 45 |
+
var set = new Set;
|
| 46 |
+
set.add(2);
|
| 47 |
+
set.add(3);
|
| 48 |
+
set.add(4);
|
| 49 |
+
|
| 50 |
+
test
|
| 51 |
+
._("with an array")
|
| 52 |
+
.equals([1, ...[2, 3, 4], 5], [1, 2, 3, 4, 5])
|
| 53 |
+
._("with an iterable")
|
| 54 |
+
.equals([1, ...set.values(), 5], [1, 2, 3, 4, 5])
|
| 55 |
+
;
|
| 56 |
+
},
|
| 57 |
+
|
| 58 |
+
};
|
pool/shard004/JavaScript/0028927_main.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
new Script('lib/UI/herlock.min.js').onload = function(){
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
hlk.imports(['lib/UI/layoutmap.min.js']).done(function(){
|
| 6 |
+
|
| 7 |
+
var mLayoutMap = UI.LayoutMap;
|
| 8 |
+
var stage = new Stage( 320, 480 );
|
| 9 |
+
var materials = [
|
| 10 |
+
{
|
| 11 |
+
name: 'image1',
|
| 12 |
+
src: 'assets/images/image.png'
|
| 13 |
+
}, {
|
| 14 |
+
name: 'image2',
|
| 15 |
+
src: 'assets/images/bg_tabbarItem_selected@2x.png'
|
| 16 |
+
}, {
|
| 17 |
+
name: 'image3',
|
| 18 |
+
src: 'assets/images/bg_tabbarItem.png'
|
| 19 |
+
}, {
|
| 20 |
+
name: 'image4',
|
| 21 |
+
src: 'assets/images/bg_tabbarItem_selected@2x.png'
|
| 22 |
+
}
|
| 23 |
+
];
|
| 24 |
+
|
| 25 |
+
var factory = new mLayoutMap.LayoutResolverFactory();
|
| 26 |
+
|
| 27 |
+
//引数はレイアウト名、素材リスト、コールバック
|
| 28 |
+
factory.loadResolver(
|
| 29 |
+
"hlk_1863991900",
|
| 30 |
+
materials,
|
| 31 |
+
function(resolver){
|
| 32 |
+
|
| 33 |
+
var bg = stage.addChild( new Bitmap( new BitmapData( 1, 1, true, 0xffffffff ) ) );
|
| 34 |
+
bg.width = stage.stageWidth;
|
| 35 |
+
bg.height = stage.stageHeight;
|
| 36 |
+
|
| 37 |
+
//ステージに展開
|
| 38 |
+
resolver.addChildrenTo( stage, true );
|
| 39 |
+
|
| 40 |
+
//アイテムを個別に生成する
|
| 41 |
+
//var item = layout.get('test', true);
|
| 42 |
+
//stage.addChild(item);
|
| 43 |
+
//layout.addChildrenTo( stage, true );
|
| 44 |
+
|
| 45 |
+
//各アイテムへのアクセスはstage.getChildByName('hoge')
|
| 46 |
+
|
| 47 |
+
}
|
| 48 |
+
);
|
| 49 |
+
|
| 50 |
+
/*
|
| 51 |
+
//既にレイアウトデータのJSONを読み込んでいるケース
|
| 52 |
+
var data = JSON.parse(jsonText);
|
| 53 |
+
factory.addConfig(data);
|
| 54 |
+
var resolver = factory.createResolver('hlk_1863991900');
|
| 55 |
+
//以下上記CallBack内の処理同様
|
| 56 |
+
*/
|
| 57 |
+
|
| 58 |
+
addLayer( stage );
|
| 59 |
+
|
| 60 |
+
});
|
| 61 |
+
|
| 62 |
+
};
|
| 63 |
+
|
pool/shard004/JavaScript/0028930_server.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import koa from "koa";
|
| 2 |
+
import proxy from "koa-proxy";
|
| 3 |
+
import serve from "koa-static";
|
| 4 |
+
|
| 5 |
+
import React from "react";
|
| 6 |
+
import ReactDOM from "react-dom/server";
|
| 7 |
+
import {RoutingContext, match} from "react-router";
|
| 8 |
+
import {createLocation} from "history";
|
| 9 |
+
import Transmit from "react-transmit";
|
| 10 |
+
|
| 11 |
+
import routes from "./views/routes";
|
| 12 |
+
|
| 13 |
+
const app = koa();
|
| 14 |
+
const hostname = process.env.HOSTNAME || "localhost";
|
| 15 |
+
const port = process.env.PORT || 8000;
|
| 16 |
+
|
| 17 |
+
app.use(serve("static", {defer: true}));
|
| 18 |
+
|
| 19 |
+
app.use(function *(next) {
|
| 20 |
+
const location = createLocation(this.path);
|
| 21 |
+
const webserver = process.env.NODE_ENV === "production" ? "" : "//" + hostname + ":8080";
|
| 22 |
+
|
| 23 |
+
yield ((callback) => {
|
| 24 |
+
match({routes, location}, (error, redirectLocation, renderProps) => {
|
| 25 |
+
if (redirectLocation) {
|
| 26 |
+
this.redirect(redirectLocation.pathname + redirectLocation.search, "/");
|
| 27 |
+
return;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
if (error || !renderProps) {
|
| 31 |
+
callback(error);
|
| 32 |
+
return;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
Transmit.renderToString(RoutingContext, renderProps).then(({reactString, reactData}) => {
|
| 36 |
+
let template = (
|
| 37 |
+
`<!doctype html>
|
| 38 |
+
<html lang="en-us">
|
| 39 |
+
<head>
|
| 40 |
+
<meta charset="utf-8">
|
| 41 |
+
<title>react-isomorphic-starterkit</title>
|
| 42 |
+
<link rel="shortcut icon" href="/favicon.ico">
|
| 43 |
+
</head>
|
| 44 |
+
<body>
|
| 45 |
+
<div id="react-root">${reactString}</div>
|
| 46 |
+
</body>
|
| 47 |
+
</html>`
|
| 48 |
+
);
|
| 49 |
+
|
| 50 |
+
this.type = "text/html";
|
| 51 |
+
this.body = Transmit.injectIntoMarkup(template, reactData, [`${webserver}/dist/client.js`]);
|
| 52 |
+
|
| 53 |
+
callback(null);
|
| 54 |
+
});
|
| 55 |
+
});
|
| 56 |
+
});
|
| 57 |
+
});
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
app.listen(port, () => {
|
| 61 |
+
console.info("==> ✅ Server is listening");
|
| 62 |
+
console.info("==> 🌎 Go to http://%s:%s", hostname, port);
|
| 63 |
+
});
|
pool/shard004/JavaScript/0028935_routes.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module.exports = function(app, config) {
|
| 2 |
+
|
| 3 |
+
//API ROUTES
|
| 4 |
+
var api_url = config.api_url;
|
| 5 |
+
|
| 6 |
+
//Match API Routes
|
| 7 |
+
var matches = require('../app/controllers/matches');
|
| 8 |
+
app.get(api_url+'/match', matches.api_index);
|
| 9 |
+
app.get(api_url+'/match/:matchid', matches.api_get);
|
| 10 |
+
app.put(api_url+'/match',matches.api_update);
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
//Web Aplication Routes - They all use index (the real route will be rendered by the angularjs route system)
|
| 14 |
+
var index = require('../app/controllers/index');
|
| 15 |
+
app.get('/', index.render);
|
| 16 |
+
app.get(/^\/match(?:\/.*)?$/, index.render);
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
//Jade templates for the partial views.
|
| 20 |
+
app.get(/^\/partials\/(.*)$/, index.partials);
|
| 21 |
+
};
|
pool/shard004/JavaScript/0028936_backbonedemo1.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* backbonedemo
|
| 3 |
+
* bbdeno
|
| 4 |
+
*
|
| 5 |
+
* Copyright (c) 2015 adamsilverstein
|
| 6 |
+
* Licensed under the GPLv2+ license.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
( function( $ ) {
|
| 11 |
+
$( document ).ready( function() {
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
window.wp = window.wp || {};
|
| 15 |
+
window.bbdemo = window.bbdemo || {};
|
| 16 |
+
|
| 17 |
+
bbdemo.model = {};
|
| 18 |
+
bbdemo.view = {};
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* ==========================================
|
| 22 |
+
* MODELS
|
| 23 |
+
* ==========================================
|
| 24 |
+
*/
|
| 25 |
+
bbdemo.model.PostModel = Backbone.Model.extend( {
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Override the default sync method to call our custom API endpoint.
|
| 29 |
+
*/
|
| 30 |
+
sync: function( method, model, options ) {
|
| 31 |
+
/**
|
| 32 |
+
* Adjust the sync url: set to our api url, with hard coded post 1 url.
|
| 33 |
+
*/
|
| 34 |
+
options.url = demodata.apiurl + '/posts/16';
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Pass back to the default handler.
|
| 38 |
+
*/
|
| 39 |
+
return Backbone.sync( method, model, options );
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
} );
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* ==========================================
|
| 46 |
+
* VIEWS
|
| 47 |
+
* ==========================================
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* The main post view.
|
| 52 |
+
*/
|
| 53 |
+
bbdemo.view.PostView = wp.Backbone.View.extend( {
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Set the view class and template.
|
| 57 |
+
*/
|
| 58 |
+
className: 'backbonedemo',
|
| 59 |
+
template: wp.template( 'backbonedemo-post' ),
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Initialize the view.
|
| 63 |
+
*/
|
| 64 |
+
initialize: function( model ) {
|
| 65 |
+
var self = this;
|
| 66 |
+
this.model = model;
|
| 67 |
+
this.model.fetch({
|
| 68 |
+
success: function() {
|
| 69 |
+
self.render();
|
| 70 |
+
}
|
| 71 |
+
});
|
| 72 |
+
|
| 73 |
+
},
|
| 74 |
+
|
| 75 |
+
render: function() {
|
| 76 |
+
this.$el.html(
|
| 77 |
+
this.template(
|
| 78 |
+
this.model.attributes
|
| 79 |
+
)
|
| 80 |
+
);
|
| 81 |
+
|
| 82 |
+
return this;
|
| 83 |
+
},
|
| 84 |
+
});
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* ==========================================
|
| 89 |
+
* MAIN APP SETUP
|
| 90 |
+
* ==========================================
|
| 91 |
+
*/
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* Funciton to initialize the application.
|
| 95 |
+
*/
|
| 96 |
+
bbdemo.initialize = function() {
|
| 97 |
+
var postmodel = new bbdemo.model.PostModel();
|
| 98 |
+
bbdemo.view.postview = new bbdemo.view.PostView( postmodel );
|
| 99 |
+
$( 'body' ).append( bbdemo.view.postview.el );
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* Go! Initialize the application one document ready.
|
| 104 |
+
*/
|
| 105 |
+
$( document ).ready( function() {
|
| 106 |
+
bbdemo.initialize();
|
| 107 |
+
});
|
| 108 |
+
|
| 109 |
+
});
|
| 110 |
+
} )( jQuery );
|
pool/shard004/JavaScript/0028939_CustomMenu.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* JavaScript Document
|
| 3 |
+
* @author Amin Ghadersohi
|
| 4 |
+
* @date 2012-4-27
|
| 5 |
+
*
|
| 6 |
+
* This class contains functionality menus that dont disappear on click
|
| 7 |
+
*
|
| 8 |
+
*/
|
| 9 |
+
CCR.xdmod.ui.CustomMenu = function (config) {
|
| 10 |
+
|
| 11 |
+
CCR.xdmod.ui.CustomMenu.superclass.constructor.call(this, config);
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
Ext.extend(CCR.xdmod.ui.CustomMenu, Ext.menu.Menu, {
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
initComponent: function () {
|
| 18 |
+
|
| 19 |
+
Ext.apply(this, {
|
| 20 |
+
|
| 21 |
+
listeners: {
|
| 22 |
+
'beforehide': function (t) {
|
| 23 |
+
if (t.el) {
|
| 24 |
+
var menuBox = t.getBox();
|
| 25 |
+
|
| 26 |
+
var ex = Ext.EventObject.getPageX();
|
| 27 |
+
var ey = Ext.EventObject.getPageY();
|
| 28 |
+
|
| 29 |
+
if (this.temporaryInvisible) {
|
| 30 |
+
this.temporaryInvisible = false;
|
| 31 |
+
return true;
|
| 32 |
+
}
|
| 33 |
+
return (ex > menuBox.x + menuBox.width || ex < menuBox.x ||
|
| 34 |
+
ey > menuBox.y + menuBox.height || ey < menuBox.y);
|
| 35 |
+
}
|
| 36 |
+
return true;
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
});
|
| 40 |
+
|
| 41 |
+
CCR.xdmod.ui.CustomMenu.superclass.initComponent.apply(this, arguments);
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
}
|
| 45 |
+
});
|
pool/shard004/JavaScript/0028941_serveWar.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var cheerio = require('cheerio'), urlM = require("url");
|
| 4 |
+
var liveReloadScriptTmpl = '<script id="livereload" src="//localhost:{liveReloadPort}/livereload.js?snipver=1" async="" defer=""></script>';
|
| 5 |
+
module.exports = function (grunt) {
|
| 6 |
+
var lrProps = grunt.config('lr'),
|
| 7 |
+
props = grunt.config('createWar').props, connect = grunt.config('yeoman').connect,
|
| 8 |
+
url = connect.protocol + "://" + connect.host + ":" + connect.port,
|
| 9 |
+
app = grunt.config('yeoman').app;
|
| 10 |
+
|
| 11 |
+
function makeSrcRelative(source, check) {
|
| 12 |
+
var $ = cheerio.load(source, {
|
| 13 |
+
decodeEntities: false
|
| 14 |
+
}),
|
| 15 |
+
warName = props.warName;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* avoids duplicating of host
|
| 19 |
+
*/
|
| 20 |
+
var checkPath = function (path) {
|
| 21 |
+
if (!check) {
|
| 22 |
+
return true;
|
| 23 |
+
}
|
| 24 |
+
else {
|
| 25 |
+
var u = urlM.parse(path);
|
| 26 |
+
return !(u.hostname === connect.host && u.port === connect.port);
|
| 27 |
+
}
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
$('link').each(function () {
|
| 31 |
+
var $t = $(this), href = $t.attr("href");
|
| 32 |
+
if (href) {
|
| 33 |
+
checkPath(href) && $t.attr("href", url + "/" + href);
|
| 34 |
+
}
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
$('script').each(function () {
|
| 38 |
+
var $t = $(this), src = $t.attr("src");
|
| 39 |
+
if (src) {
|
| 40 |
+
checkPath(src) && $t.attr("src", url + "/" + src);
|
| 41 |
+
}
|
| 42 |
+
});
|
| 43 |
+
|
| 44 |
+
$('img').each(function () {
|
| 45 |
+
var $t = $(this);
|
| 46 |
+
// , src = $t.attr("src");
|
| 47 |
+
// if (src) {
|
| 48 |
+
// checkPath(src) && $t.attr("src", url + "/" + src);
|
| 49 |
+
// }
|
| 50 |
+
|
| 51 |
+
//add fallback directive
|
| 52 |
+
$t.attr("fallback") && $t.attr("fallback", "true");
|
| 53 |
+
});
|
| 54 |
+
|
| 55 |
+
//appending livereload script for live reloading in dev mode
|
| 56 |
+
$("body #livereload").length === 0 &&
|
| 57 |
+
$("body").append(liveReloadScriptTmpl.replace('{liveReloadPort}', connect.livereload));
|
| 58 |
+
|
| 59 |
+
return $.html();
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
grunt.registerTask('serveWar', 'Task to serve war for dev', function () {
|
| 64 |
+
var warName = props.warName,
|
| 65 |
+
vmFile = lrProps.portalDir + '/tomcat-7.0.42/webapps/' + warName + '/templates/portal_normal.vm';
|
| 66 |
+
|
| 67 |
+
function modifyFile(filePath) {
|
| 68 |
+
grunt.log.writeln("Modified file: " + filePath + " : " + grunt.file.isFile(vmFile));
|
| 69 |
+
grunt.log.writeln((app + "\\index.html") + (filePath === app + "\\index.html"));
|
| 70 |
+
|
| 71 |
+
//check for index.html
|
| 72 |
+
if ((filePath === app + "/index.html") || (filePath === app + "\\index.html")) {
|
| 73 |
+
if (grunt.file.isFile(vmFile)) {
|
| 74 |
+
grunt.file.write(vmFile, makeSrcRelative(grunt.file.read(filePath), true));
|
| 75 |
+
grunt.log.ok(warName + " is deployed.");
|
| 76 |
+
}
|
| 77 |
+
else {
|
| 78 |
+
grunt.log.error("Portal normal vm is incorrect.");
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
else {
|
| 82 |
+
// check for other html files
|
| 83 |
+
filePath.indexOf(".html") > -1 &&
|
| 84 |
+
grunt.file.write(filePath, makeSrcRelative(grunt.file.read(filePath), true));
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
grunt.file.recurse(app, function callback(abspath, rootdir, subdir, filename) {
|
| 89 |
+
modifyFile(abspath);
|
| 90 |
+
});
|
| 91 |
+
|
| 92 |
+
grunt.event.on('watch', function (action, filepath, target) {
|
| 93 |
+
grunt.log.writeln(target + ': ' + filepath + ' changed:----- ' + action);
|
| 94 |
+
modifyFile(filepath);
|
| 95 |
+
});
|
| 96 |
+
|
| 97 |
+
});
|
| 98 |
+
};
|
pool/shard004/JavaScript/0028942_component.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, {Component} from 'react'
|
| 2 |
+
import t from 't-component'
|
| 3 |
+
import Timeago from 'lib/site/timeago'
|
| 4 |
+
import userConnector from 'lib/site/connectors/user'
|
| 5 |
+
import CommentReplies from 'lib/site/topic-layout/topic-article/comments/list/comment/replies/component'
|
| 6 |
+
import ValidatedBadge from '../validated-badge/component'
|
| 7 |
+
|
| 8 |
+
export default function CommentsList (props) {
|
| 9 |
+
const comments = props.comments || []
|
| 10 |
+
|
| 11 |
+
return (
|
| 12 |
+
<div className='comments-list'>
|
| 13 |
+
{
|
| 14 |
+
comments.map((item) => {
|
| 15 |
+
const handlers = {
|
| 16 |
+
onUnvote: () => props.onUnvote(item.id),
|
| 17 |
+
onUpvote: () => props.onUpvote(item.id),
|
| 18 |
+
onDownvote: () => props.onDownvote(item.id)
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
return (
|
| 22 |
+
<Comment
|
| 23 |
+
key={item.id}
|
| 24 |
+
comment={item}
|
| 25 |
+
onReply={props.onReply}
|
| 26 |
+
commentsReplying={props.commentsReplying}
|
| 27 |
+
{...handlers}
|
| 28 |
+
forum={props.forum} />
|
| 29 |
+
)
|
| 30 |
+
})
|
| 31 |
+
}
|
| 32 |
+
</div>
|
| 33 |
+
)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
const Comment = userConnector(class extends Component {
|
| 37 |
+
constructor (props) {
|
| 38 |
+
super(props)
|
| 39 |
+
this.state = {
|
| 40 |
+
repliesVisibility: false
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
handleUnvote = (evt) => {
|
| 45 |
+
evt.currentTarget.classList.remove('active')
|
| 46 |
+
this.props.onUnvote()
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
handleUpvote = (evt) => {
|
| 50 |
+
evt.currentTarget.classList.add('active')
|
| 51 |
+
this.props.onUpvote()
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
handleDownvote = (evt) => {
|
| 55 |
+
evt.currentTarget.classList.add('active')
|
| 56 |
+
this.props.onDownvote()
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
handleToggleReplies = () => {
|
| 60 |
+
this.setState({repliesVisibility: !this.state.repliesVisibility})
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
render () {
|
| 64 |
+
const {
|
| 65 |
+
comment,
|
| 66 |
+
user
|
| 67 |
+
} = this.props
|
| 68 |
+
|
| 69 |
+
if (user.state.pending) return null
|
| 70 |
+
|
| 71 |
+
const {upvoted, downvoted} = (comment.currentUser || {})
|
| 72 |
+
const userAttrs = user.state.value || {}
|
| 73 |
+
const isOwner = userAttrs.id === comment.author.id
|
| 74 |
+
|
| 75 |
+
return (
|
| 76 |
+
<article className='comments-list-item' id={`comment-${comment.id}`}>
|
| 77 |
+
<header className='meta'>
|
| 78 |
+
<img
|
| 79 |
+
className='avatar'
|
| 80 |
+
src={comment.author.avatar}
|
| 81 |
+
alt={comment.author.fullName} />
|
| 82 |
+
<h3 className='name'>
|
| 83 |
+
{comment.author.displayName}
|
| 84 |
+
</h3>
|
| 85 |
+
<ValidatedBadge comment={comment} />
|
| 86 |
+
<div className='created-at'>
|
| 87 |
+
<Timeago date={comment.createdAt} />
|
| 88 |
+
</div>
|
| 89 |
+
</header>
|
| 90 |
+
<div
|
| 91 |
+
className='text'
|
| 92 |
+
dangerouslySetInnerHTML={{__html: comment.textHtml}} />
|
| 93 |
+
<footer className='actions'>
|
| 94 |
+
<div className='votes'>
|
| 95 |
+
<span className='score'>
|
| 96 |
+
<span>{comment.score}</span>
|
| 97 |
+
{' '}
|
| 98 |
+
<small>{t('comments.votes')}</small>
|
| 99 |
+
</span>
|
| 100 |
+
{!isOwner && (
|
| 101 |
+
<button
|
| 102 |
+
className={`upvote ${upvoted ? 'active' : ''}`}
|
| 103 |
+
onClick={upvoted ? this.handleUnvote : this.handleUpvote}>
|
| 104 |
+
<i className='icon-like' />
|
| 105 |
+
</button>
|
| 106 |
+
)}
|
| 107 |
+
{!isOwner && (
|
| 108 |
+
<button
|
| 109 |
+
className={`downvote ${downvoted ? 'active' : ''}`}
|
| 110 |
+
onClick={downvoted ? this.handleUnvote : this.handleDownvote}>
|
| 111 |
+
<i className='icon-dislike' />
|
| 112 |
+
</button>
|
| 113 |
+
)}
|
| 114 |
+
</div>
|
| 115 |
+
<div className='replies-score'>
|
| 116 |
+
{!!comment.repliesCount && (
|
| 117 |
+
<span className='score'>
|
| 118 |
+
<span>{comment.repliesCount}</span>
|
| 119 |
+
{' '}
|
| 120 |
+
<small>{t('comments.replies')}</small>
|
| 121 |
+
</span>
|
| 122 |
+
)}
|
| 123 |
+
<button
|
| 124 |
+
className='reply'
|
| 125 |
+
title={t('comments.arguments.reply')}
|
| 126 |
+
onClick={this.handleToggleReplies}>
|
| 127 |
+
<i className='icon-action-redo' />
|
| 128 |
+
</button>
|
| 129 |
+
</div>
|
| 130 |
+
</footer>
|
| 131 |
+
<CommentReplies
|
| 132 |
+
commentId={comment.id}
|
| 133 |
+
replies={comment.replies}
|
| 134 |
+
forum={this.props.forum}
|
| 135 |
+
repliesVisibility={this.state.repliesVisibility}
|
| 136 |
+
onReply={this.props.onReply}
|
| 137 |
+
commentsReplying={this.props.commentsReplying} />
|
| 138 |
+
</article>
|
| 139 |
+
)
|
| 140 |
+
}
|
| 141 |
+
})
|
pool/shard004/JavaScript/0028944_calculateTransform.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Transform } from './transform.js';
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Calculate the transform for a Cornerstone enabled element
|
| 5 |
+
*
|
| 6 |
+
* @param {EnabledElement} enabledElement The Cornerstone Enabled Element
|
| 7 |
+
* @param {Number} [scale] The viewport scale
|
| 8 |
+
* @return {Transform} The current transform
|
| 9 |
+
* @memberof Internal
|
| 10 |
+
*/
|
| 11 |
+
export default function (enabledElement, scale) {
|
| 12 |
+
|
| 13 |
+
const transform = new Transform();
|
| 14 |
+
|
| 15 |
+
// Move to center of canvas
|
| 16 |
+
transform.translate(enabledElement.canvas.width / 2, enabledElement.canvas.height / 2);
|
| 17 |
+
|
| 18 |
+
// Apply the rotation before scaling for non square pixels
|
| 19 |
+
const angle = enabledElement.viewport.rotation;
|
| 20 |
+
|
| 21 |
+
if (angle !== 0) {
|
| 22 |
+
transform.rotate(angle * Math.PI / 180);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
// Apply the scale
|
| 26 |
+
let widthScale = enabledElement.viewport.scale;
|
| 27 |
+
let heightScale = enabledElement.viewport.scale;
|
| 28 |
+
|
| 29 |
+
const width = enabledElement.viewport.displayedArea.brhc.x - (enabledElement.viewport.displayedArea.tlhc.x - 1);
|
| 30 |
+
const height = enabledElement.viewport.displayedArea.brhc.y - (enabledElement.viewport.displayedArea.tlhc.y - 1);
|
| 31 |
+
|
| 32 |
+
if (enabledElement.viewport.displayedArea.presentationSizeMode === 'NONE') {
|
| 33 |
+
if (enabledElement.image.rowPixelSpacing < enabledElement.image.columnPixelSpacing) {
|
| 34 |
+
widthScale *= (enabledElement.image.columnPixelSpacing / enabledElement.image.rowPixelSpacing);
|
| 35 |
+
} else if (enabledElement.image.columnPixelSpacing < enabledElement.image.rowPixelSpacing) {
|
| 36 |
+
heightScale *= (enabledElement.image.rowPixelSpacing / enabledElement.image.columnPixelSpacing);
|
| 37 |
+
}
|
| 38 |
+
} else {
|
| 39 |
+
// These should be good for "TRUE SIZE" and "MAGNIFY"
|
| 40 |
+
widthScale = enabledElement.viewport.displayedArea.columnPixelSpacing;
|
| 41 |
+
heightScale = enabledElement.viewport.displayedArea.rowPixelSpacing;
|
| 42 |
+
|
| 43 |
+
if (enabledElement.viewport.displayedArea.presentationSizeMode === 'SCALE TO FIT') {
|
| 44 |
+
// Fit TRUE IMAGE image (width/height) to window
|
| 45 |
+
const verticalScale = enabledElement.canvas.height / (height * heightScale);
|
| 46 |
+
const horizontalScale = enabledElement.canvas.width / (width * widthScale);
|
| 47 |
+
|
| 48 |
+
// Apply new scale
|
| 49 |
+
widthScale = heightScale = Math.min(horizontalScale, verticalScale);
|
| 50 |
+
|
| 51 |
+
if (enabledElement.viewport.displayedArea.rowPixelSpacing < enabledElement.viewport.displayedArea.columnPixelSpacing) {
|
| 52 |
+
widthScale *= (enabledElement.viewport.displayedArea.columnPixelSpacing / enabledElement.viewport.displayedArea.rowPixelSpacing);
|
| 53 |
+
} else if (enabledElement.viewport.displayedArea.columnPixelSpacing < enabledElement.viewport.displayedArea.rowPixelSpacing) {
|
| 54 |
+
heightScale *= (enabledElement.viewport.displayedArea.rowPixelSpacing / enabledElement.viewport.displayedArea.columnPixelSpacing);
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
transform.scale(widthScale, heightScale);
|
| 60 |
+
|
| 61 |
+
// Unrotate to so we can translate unrotated
|
| 62 |
+
if (angle !== 0) {
|
| 63 |
+
transform.rotate(-angle * Math.PI / 180);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
// Apply the pan offset
|
| 67 |
+
transform.translate(enabledElement.viewport.translation.x, enabledElement.viewport.translation.y);
|
| 68 |
+
|
| 69 |
+
// Rotate again so we can apply general scale
|
| 70 |
+
if (angle !== 0) {
|
| 71 |
+
transform.rotate(angle * Math.PI / 180);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
if (scale !== undefined) {
|
| 75 |
+
// Apply the font scale
|
| 76 |
+
transform.scale(scale, scale);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
// Apply Flip if required
|
| 80 |
+
if (enabledElement.viewport.hflip) {
|
| 81 |
+
transform.scale(-1, 1);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
if (enabledElement.viewport.vflip) {
|
| 85 |
+
transform.scale(1, -1);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
// Move back from center of image
|
| 89 |
+
transform.translate(-width / 2, -height / 2);
|
| 90 |
+
|
| 91 |
+
return transform;
|
| 92 |
+
}
|
pool/shard004/JavaScript/0028950_SubWS.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//logging
|
| 2 |
+
var winston = require('winston');
|
| 3 |
+
|
| 4 |
+
//string resources
|
| 5 |
+
var EMPTY_STRING = '';
|
| 6 |
+
|
| 7 |
+
//namespace
|
| 8 |
+
var SubWS = function (opts) {
|
| 9 |
+
winston.info('SubWS object created');
|
| 10 |
+
this.subscribers = [];
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
function getSocketsById(id, subscribers) {
|
| 14 |
+
var i,
|
| 15 |
+
sockets = [];
|
| 16 |
+
|
| 17 |
+
for (i = 0; i < subscribers.length; i = i + 1) {
|
| 18 |
+
if (subscribers[i].id === id) {
|
| 19 |
+
sockets.push(subscribers[i].socket);
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
return sockets;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
//public function to app.js
|
| 26 |
+
SubWS.prototype.broadcastData = function (json) {
|
| 27 |
+
winston.verbose('SubWS.broadcastData for subscriberid %s', json.data.subscriberid);
|
| 28 |
+
|
| 29 |
+
var socket,
|
| 30 |
+
sockets,
|
| 31 |
+
i;
|
| 32 |
+
|
| 33 |
+
//is there a socket subsscribed for this data?
|
| 34 |
+
sockets = getSocketsById(json.data.subscriberid, this.subscribers);
|
| 35 |
+
winston.verbose(' subscribers found for subscriberid %s: %s', json.data.subscriberid, sockets.length);
|
| 36 |
+
|
| 37 |
+
for (i = 0; i < sockets.length; i = i + 1) {
|
| 38 |
+
socket = sockets[i];
|
| 39 |
+
socket.emit('any-broadcast', json.data);
|
| 40 |
+
}
|
| 41 |
+
return EMPTY_STRING;
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
SubWS.prototype.processConnection = function (socket) {
|
| 45 |
+
winston.verbose('SubWS.processConnection for socket.id: %s', socket.id);
|
| 46 |
+
|
| 47 |
+
socket.emit('SubWS-connect', 'SubWS connection confirmed');
|
| 48 |
+
return EMPTY_STRING;
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
SubWS.prototype.processDisconnect = function (socket) {
|
| 52 |
+
winston.verbose('SubWS.processDisconnect request');
|
| 53 |
+
|
| 54 |
+
return this.unsubscribeSocket(socket);
|
| 55 |
+
};
|
| 56 |
+
|
| 57 |
+
SubWS.prototype.unsubscribeSocket = function (socket) {
|
| 58 |
+
winston.verbose('SubWS.unsubscribeSocket for socket.id: %s', socket.id);
|
| 59 |
+
|
| 60 |
+
var subscription,
|
| 61 |
+
i;
|
| 62 |
+
|
| 63 |
+
for (i = 0; i < this.subscribers.length; i = i + 1) {
|
| 64 |
+
subscription = this.subscribers[i];
|
| 65 |
+
if (subscription.socket === socket) {
|
| 66 |
+
this.subscribers.pop(subscription);
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
return (this.subscribers.length);
|
| 70 |
+
};
|
| 71 |
+
|
| 72 |
+
SubWS.prototype.unsubscribeAll = function () {
|
| 73 |
+
winston.verbose('SubWS.unsubscribeAll');
|
| 74 |
+
|
| 75 |
+
this.subscribers = [];
|
| 76 |
+
return (this.subscribers.length);
|
| 77 |
+
};
|
| 78 |
+
|
| 79 |
+
SubWS.prototype.subscribeSocket = function (socket, data) {
|
| 80 |
+
winston.verbose('SubWS.subscribeSocket %s for subscriberid %s', socket.id, data.subscriberid);
|
| 81 |
+
|
| 82 |
+
this.subscribers.push({'id': data.subscriberid, 'socket': socket});
|
| 83 |
+
return (this.subscribers.length);
|
| 84 |
+
};
|
| 85 |
+
|
| 86 |
+
exports.SubWS = SubWS;
|
pool/shard004/JavaScript/0028951_GreetingMaster.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from "react";
|
| 2 |
+
import { Link } from "react-router";
|
| 3 |
+
|
| 4 |
+
export default function GreetingMaster(props) {
|
| 5 |
+
const { greetings, onAdd } = props;
|
| 6 |
+
const body = greetings.map(greeting => (
|
| 7 |
+
<tr key={greeting.id}>
|
| 8 |
+
<td>{greeting.name}</td>
|
| 9 |
+
<td>{greeting.greeting}</td>
|
| 10 |
+
<td>
|
| 11 |
+
<Link to={`/greet?name=${greeting.name}&greeting=${greeting.greeting}`}>Link</Link>
|
| 12 |
+
</td>
|
| 13 |
+
</tr>
|
| 14 |
+
));
|
| 15 |
+
return (
|
| 16 |
+
<div>
|
| 17 |
+
<table>
|
| 18 |
+
<thead>
|
| 19 |
+
<tr>
|
| 20 |
+
<th>Name</th>
|
| 21 |
+
<th>Greeting</th>
|
| 22 |
+
<th>Link</th>
|
| 23 |
+
</tr>
|
| 24 |
+
</thead>
|
| 25 |
+
<tbody>{body}</tbody>
|
| 26 |
+
</table>
|
| 27 |
+
<button onClick={onAdd}>Add</button>
|
| 28 |
+
</div>
|
| 29 |
+
);
|
| 30 |
+
}
|
pool/shard004/JavaScript/0028953_node-details.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const _ = require('lodash');
|
| 2 |
+
const React = require('react');
|
| 3 |
+
|
| 4 |
+
const NodeDetailsControls = require('./node-details/node-details-controls');
|
| 5 |
+
const NodeDetailsTable = require('./node-details/node-details-table');
|
| 6 |
+
const NodeColorMixin = require('../mixins/node-color-mixin');
|
| 7 |
+
const TitleUtils = require('../utils/title-utils');
|
| 8 |
+
|
| 9 |
+
const NodeDetails = React.createClass({
|
| 10 |
+
|
| 11 |
+
mixins: [
|
| 12 |
+
NodeColorMixin
|
| 13 |
+
],
|
| 14 |
+
|
| 15 |
+
componentDidMount: function() {
|
| 16 |
+
this.updateTitle();
|
| 17 |
+
},
|
| 18 |
+
|
| 19 |
+
componentWillUnmount: function() {
|
| 20 |
+
TitleUtils.resetTitle();
|
| 21 |
+
},
|
| 22 |
+
|
| 23 |
+
renderLoading: function() {
|
| 24 |
+
const node = this.props.nodes.get(this.props.nodeId);
|
| 25 |
+
const nodeColor = this.getNodeColorDark(node.get('rank'), node.get('label_major'));
|
| 26 |
+
const styles = {
|
| 27 |
+
header: {
|
| 28 |
+
'backgroundColor': nodeColor
|
| 29 |
+
}
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
return (
|
| 33 |
+
<div className="node-details">
|
| 34 |
+
<div className="node-details-header" style={styles.header}>
|
| 35 |
+
<div className="node-details-header-wrapper">
|
| 36 |
+
<h2 className="node-details-header-label truncate">
|
| 37 |
+
{node.get('label_major')}
|
| 38 |
+
</h2>
|
| 39 |
+
<div className="node-details-header-label-minor truncate">
|
| 40 |
+
{node.get('label_minor')}
|
| 41 |
+
</div>
|
| 42 |
+
</div>
|
| 43 |
+
</div>
|
| 44 |
+
<div className="node-details-content">
|
| 45 |
+
<div className="node-details-content-loading">
|
| 46 |
+
<span className="fa fa-circle-o-notch fa-spin" />
|
| 47 |
+
</div>
|
| 48 |
+
</div>
|
| 49 |
+
</div>
|
| 50 |
+
);
|
| 51 |
+
},
|
| 52 |
+
|
| 53 |
+
renderNotAvailable: function() {
|
| 54 |
+
return (
|
| 55 |
+
<div className="node-details">
|
| 56 |
+
<div className="node-details-header node-details-header-notavailable">
|
| 57 |
+
<div className="node-details-header-wrapper">
|
| 58 |
+
<h2 className="node-details-header-label">
|
| 59 |
+
n/a
|
| 60 |
+
</h2>
|
| 61 |
+
<div className="node-details-header-label-minor truncate">
|
| 62 |
+
{this.props.nodeId}
|
| 63 |
+
</div>
|
| 64 |
+
</div>
|
| 65 |
+
</div>
|
| 66 |
+
<div className="node-details-content">
|
| 67 |
+
<p className="node-details-content-info">
|
| 68 |
+
This node is not visible to Scope anymore.
|
| 69 |
+
The node will re-appear if it communicates again.
|
| 70 |
+
</p>
|
| 71 |
+
</div>
|
| 72 |
+
</div>
|
| 73 |
+
);
|
| 74 |
+
},
|
| 75 |
+
|
| 76 |
+
render: function() {
|
| 77 |
+
const details = this.props.details;
|
| 78 |
+
const nodeExists = this.props.nodes && this.props.nodes.has(this.props.nodeId);
|
| 79 |
+
|
| 80 |
+
if (!nodeExists) {
|
| 81 |
+
return this.renderNotAvailable();
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
if (!details) {
|
| 85 |
+
return this.renderLoading();
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
const nodeColor = this.getNodeColorDark(details.rank, details.label_major);
|
| 89 |
+
const styles = {
|
| 90 |
+
controls: {
|
| 91 |
+
'backgroundColor': this.brightenColor(nodeColor)
|
| 92 |
+
},
|
| 93 |
+
header: {
|
| 94 |
+
'backgroundColor': nodeColor
|
| 95 |
+
}
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
return (
|
| 99 |
+
<div className="node-details">
|
| 100 |
+
<div className="node-details-header" style={styles.header}>
|
| 101 |
+
<div className="node-details-header-wrapper">
|
| 102 |
+
<h2 className="node-details-header-label truncate" title={details.label_major}>
|
| 103 |
+
{details.label_major}
|
| 104 |
+
</h2>
|
| 105 |
+
<div className="node-details-header-label-minor truncate" title={details.label_minor}>
|
| 106 |
+
{details.label_minor}
|
| 107 |
+
</div>
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
+
|
| 111 |
+
{details.controls && details.controls.length > 0 && <div className="node-details-controls-wrapper" style={styles.controls}>
|
| 112 |
+
<NodeDetailsControls controls={details.controls}
|
| 113 |
+
pending={this.props.controlPending} error={this.props.controlError} />
|
| 114 |
+
</div>}
|
| 115 |
+
|
| 116 |
+
<div className="node-details-content">
|
| 117 |
+
{details.tables.map(function(table) {
|
| 118 |
+
const key = _.snakeCase(table.title);
|
| 119 |
+
return <NodeDetailsTable title={table.title} key={key} rows={table.rows} isNumeric={table.numeric} />;
|
| 120 |
+
})}
|
| 121 |
+
</div>
|
| 122 |
+
</div>
|
| 123 |
+
);
|
| 124 |
+
},
|
| 125 |
+
|
| 126 |
+
componentDidUpdate: function() {
|
| 127 |
+
this.updateTitle();
|
| 128 |
+
},
|
| 129 |
+
|
| 130 |
+
updateTitle: function() {
|
| 131 |
+
TitleUtils.setTitle(this.props.details && this.props.details.label_major);
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
});
|
| 135 |
+
|
| 136 |
+
module.exports = NodeDetails;
|
pool/shard004/JavaScript/0028957_redshift.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var AWSResource = require('../aws-resource')
|
| 2 |
+
, types = require('../types');
|
| 3 |
+
|
| 4 |
+
var Cluster = AWSResource.define('AWS::Redshift::Cluster', {
|
| 5 |
+
AllowVersionUpgrade : { type: types.boolean },
|
| 6 |
+
AutomatedSnapshotRetentionPeriod : { type: types.number },
|
| 7 |
+
AvailabilityZone : { type: types.string },
|
| 8 |
+
ClusterParameterGroupName : { type: types.string },
|
| 9 |
+
ClusterSecurityGroups : { type: types.array(types.string) },
|
| 10 |
+
ClusterSubnetGroupName : { type: types.string },
|
| 11 |
+
ClusterType : { type: types.enum('single-node', 'multi-node'), required: true },
|
| 12 |
+
ClusterVersion : { type: types.string },
|
| 13 |
+
DBName : { type: types.string, required: true },
|
| 14 |
+
ElasticIp : { type: types.string },
|
| 15 |
+
Encrypted : { type: types.boolean },
|
| 16 |
+
HsmClientCertificateIdentifier : { type: types.string },
|
| 17 |
+
HsmConfigurationIdentifier : { type: types.string },
|
| 18 |
+
MasterUsername : { type: types.string, required: true },
|
| 19 |
+
MasterUserPassword : { type: types.string, required: true },
|
| 20 |
+
NodeType : { type: types.string, required: true },
|
| 21 |
+
NumberOfNodes : { type: types.number, required: 'conditional' },
|
| 22 |
+
OwnerAccount : { type: types.string },
|
| 23 |
+
Port : { type: types.number },
|
| 24 |
+
PreferredMaintenanceWindow : { type: types.string },
|
| 25 |
+
PubliclyAccessible : { type: types.boolean },
|
| 26 |
+
SnapshotClusterIdentifier : { type: types.string, required: 'conditional' },
|
| 27 |
+
SnapshotIdentifier : { type: types.string, required: 'conditional' },
|
| 28 |
+
VpcSecurityGroupIds : { type: types.array(types.string) },
|
| 29 |
+
}, {
|
| 30 |
+
validator: function(context) {
|
| 31 |
+
if (context.properties.NumberOfNodes && context.properties.ClusterType === 'single-node') {
|
| 32 |
+
context.addError('NumberOfNodes must be unset if NodeType is single-node');
|
| 33 |
+
}
|
| 34 |
+
},
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
var ClusterParameterGroup = AWSResource.define('AWS::Redshift::ClusterParameterGroup', {
|
| 38 |
+
Description : { type: types.string, required: true },
|
| 39 |
+
ParameterGroupFamily : { type: types.string, required: true },
|
| 40 |
+
Parameters : { type: types.string },
|
| 41 |
+
});
|
| 42 |
+
|
| 43 |
+
var ClusterSecurityGroup = AWSResource.define('AWS::Redshift::ClusterSecurityGroup', {
|
| 44 |
+
Description : { type: types.string, required: true },
|
| 45 |
+
});
|
| 46 |
+
|
| 47 |
+
var ClusterSecurityGroupIngress = AWSResource.define('AWS::Redshift::ClusterSecurityGroupIngress', {
|
| 48 |
+
ClusterSecurityGroupName : { type: types.string, required: true },
|
| 49 |
+
CIDRIP : { type: types.string },
|
| 50 |
+
EC2SecurityGroupName : { type: types.string },
|
| 51 |
+
EC2SecurityGroupOwnerId : { type: types.string, required: 'conditional' },
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
var ClusterSubnetGroup = AWSResource.define('AWS::Redshift::ClusterSubnetGroup', {
|
| 55 |
+
Description : { type: types.string, required: true },
|
| 56 |
+
SubnetIds : { type: types.array(types.string), required: true },
|
| 57 |
+
});
|
| 58 |
+
|
| 59 |
+
module.exports = {
|
| 60 |
+
Cluster: Cluster,
|
| 61 |
+
ClusterParameterGroup: ClusterParameterGroup,
|
| 62 |
+
ClusterSecurityGroup: ClusterSecurityGroup,
|
| 63 |
+
ClusterSecurityGroupIngress: ClusterSecurityGroupIngress,
|
| 64 |
+
ClusterSubnetGroup: ClusterSubnetGroup,
|
| 65 |
+
};
|
pool/shard004/JavaScript/0028959_Program.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var Program = function(gl, vertexShader, fragmentShader) {
|
| 2 |
+
this.gl = gl;
|
| 3 |
+
this.sourceFileNames = {vs:vertexShader.sourceFileName, fs:fragmentShader.sourceFileName};
|
| 4 |
+
this.glProgram = gl.createProgram();
|
| 5 |
+
gl.attachShader(this.glProgram, vertexShader.glShader);
|
| 6 |
+
gl.attachShader(this.glProgram, fragmentShader.glShader);
|
| 7 |
+
|
| 8 |
+
gl.bindAttribLocation(this.glProgram, 0, 'vertexPosition');
|
| 9 |
+
gl.bindAttribLocation(this.glProgram, 1, 'vertexNormal');
|
| 10 |
+
gl.bindAttribLocation(this.glProgram, 2, 'vertexTexCoord');
|
| 11 |
+
|
| 12 |
+
gl.linkProgram(this.glProgram);
|
| 13 |
+
if (!gl.getProgramParameter(this.glProgram, gl.LINK_STATUS))
|
| 14 |
+
throw new Error('Could not link shaders [vertex shader:' + vertexShader.sourceFileName + ']:[fragment shader: ' + fragmentShader.sourceFileName + ']\n' + gl.getProgramInfoLog(this.glProgram));
|
| 15 |
+
|
| 16 |
+
var textureUnitCount=0;
|
| 17 |
+
this.uniforms = {};
|
| 18 |
+
var nUniforms = gl.getProgramParameter(
|
| 19 |
+
this.glProgram, gl.ACTIVE_UNIFORMS);
|
| 20 |
+
for(var i=0; i<nUniforms; i++){
|
| 21 |
+
var glUniform = gl.getActiveUniform(this.glProgram, i);
|
| 22 |
+
var uniform = {
|
| 23 |
+
type : glUniform.type,
|
| 24 |
+
arraySize : glUniform.size || 1,
|
| 25 |
+
location : gl.getUniformLocation(
|
| 26 |
+
this.glProgram, glUniform.name)
|
| 27 |
+
};
|
| 28 |
+
if(glUniform.type === gl.SAMPLER_2D ||
|
| 29 |
+
glUniform.type === gl.SAMPLER_CUBE){
|
| 30 |
+
uniform.textureUnit = textureUnitCount; //Ezt a szamot kapja
|
| 31 |
+
textureUnitCount += uniform.arraySize; //Tombelem kulon egymasutani szamot kap
|
| 32 |
+
}
|
| 33 |
+
this.uniforms[glUniform.name.split('[')[0]] = uniform;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
/* //Vizualiz es kepszint
|
| 38 |
+
var textureUnitCount=0;
|
| 39 |
+
this.uniformLocations = {};
|
| 40 |
+
var nUniforms = gl.getProgramParameter(this.glProgram, gl.ACTIVE_UNIFORMS);
|
| 41 |
+
for(var i=0; i<nUniforms; i++){
|
| 42 |
+
var glUniform = gl.getActiveUniform(this.glProgram, i);
|
| 43 |
+
var uniformName = glUniform.name.split('[')[0];
|
| 44 |
+
this.uniformLocations[uniformName] = gl.getUniformLocation(this.glProgram, glUniform.name);
|
| 45 |
+
var reflectionVariable =
|
| 46 |
+
UniformReflectionFactories.makeVar(gl, glUniform.type, glUniform.size, textureUnitCount);
|
| 47 |
+
Object.defineProperty(this, uniformName, {value: reflectionVariable} );
|
| 48 |
+
if(glUniform.type === gl.SAMPLER_2D || glUniform.type === gl.SAMPLER_CUBE){
|
| 49 |
+
textureUnitCount += glUniform.arraySize;
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
*/
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
Program.prototype.commit = function(){
|
| 56 |
+
this.gl.useProgram(this.glProgram);
|
| 57 |
+
};
|
| 58 |
+
|
pool/shard004/JavaScript/0028960_app.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var fs = require('fs');
|
| 2 |
+
var http = require('http');
|
| 3 |
+
var path = require('path');
|
| 4 |
+
var url = require('url');
|
| 5 |
+
|
| 6 |
+
var PORT = 8080;
|
| 7 |
+
var DATA_DIR = '/opt/data/ncpr';
|
| 8 |
+
|
| 9 |
+
var HEAD_MAP = {};
|
| 10 |
+
var files = fs.readdirSync(DATA_DIR).filter(function(x){return x.match(/^\d{1,4}\.dat/);});
|
| 11 |
+
for (var i = 0; i < files.length; i++) {
|
| 12 |
+
HEAD_MAP[+files[i].split('.')[0]] = fs.readFileSync(path.join(files[i]));
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function deserialize(b1, b2) {
|
| 16 |
+
if ((b1 & 0x80) === 0) {
|
| 17 |
+
return null;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
return [
|
| 21 |
+
(b1 & 0x7c) >> 2,
|
| 22 |
+
((b2 & 0xfe) === 0) ? "0" : [1, 2, 3, 4, 5, 6, 7].filter(function(x){return ((b2 >> x) & 1) === 1;}).join("#"),
|
| 23 |
+
((b2 & 1) === 0) ? "D" : "A",
|
| 24 |
+
b1 & 0x03
|
| 25 |
+
];
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
function binarySearch(key, data, low, high) {
|
| 29 |
+
if (low > high) {
|
| 30 |
+
return null;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
var mid = (low + high) >> 1;
|
| 34 |
+
var midKey = (data[mid * 5 + 1] << 16) | (data[mid * 5 + 2] << 8) | data[mid * 5 + 3];
|
| 35 |
+
|
| 36 |
+
if (key < midKey) {
|
| 37 |
+
return binarySearch(key, data, low, mid - 1);
|
| 38 |
+
} else if (key === midKey) {
|
| 39 |
+
return deserialize(data[mid * 5 + 4], data[mid * 5 + 5]);
|
| 40 |
+
} else {
|
| 41 |
+
return binarySearch(key, data, mid + 1, high);
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function getNumberInfo(number) {
|
| 46 |
+
var h = +number.substring(0, 4);
|
| 47 |
+
var t = +number.substring(4);
|
| 48 |
+
|
| 49 |
+
if (!HEAD_MAP.hasOwnProperty(h)) {
|
| 50 |
+
return null;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
var buffer = HEAD_MAP[h];
|
| 54 |
+
if (buffer[0] === 0) {
|
| 55 |
+
return deserialize(buffer[2 * t + 1], buffer[2 * t + 2]);
|
| 56 |
+
} else {
|
| 57 |
+
return binarySearch(t, buffer, 0, (buffer.length - 1) / 5 - 1);
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
var server = http.createServer(function(req, res) {
|
| 62 |
+
var parsedUrl = url.parse(req.url, true);
|
| 63 |
+
if (req.method !== 'GET' || parsedUrl.pathname !== '/api/v1/status' || !parsedUrl.query.hasOwnProperty('numbers')) {
|
| 64 |
+
return res.end('{}');
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
var result = {};
|
| 68 |
+
var numbers = parsedUrl.query['numbers'].split(',');
|
| 69 |
+
for (var i = 0; i < numbers.length; i++) {
|
| 70 |
+
if (numbers[i].match('^\\d{10}$') === null) {
|
| 71 |
+
continue;
|
| 72 |
+
}
|
| 73 |
+
result[numbers[i]] = getNumberInfo(numbers[i]);
|
| 74 |
+
}
|
| 75 |
+
return res.end(JSON.stringify(result));
|
| 76 |
+
});
|
| 77 |
+
|
| 78 |
+
server.listen(PORT, function() {
|
| 79 |
+
console.log("started listening on port " + PORT);
|
| 80 |
+
});
|
pool/shard004/JavaScript/0028962_Iterator.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var Iterator = function(collection) {
|
| 2 |
+
if(!(collection instanceof Array)) {
|
| 3 |
+
throw "Iterator requires the collection to be an array but '" + collection + "' was given instead"
|
| 4 |
+
}
|
| 5 |
+
this._lastIndex= collection.length - 1;
|
| 6 |
+
this._index = -1;
|
| 7 |
+
this._collection = collection;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
Iterator.prototype.index = function() {
|
| 11 |
+
return this._index
|
| 12 |
+
}
|
| 13 |
+
Iterator.prototype.isFirst = function() {
|
| 14 |
+
return this._index === 0
|
| 15 |
+
}
|
| 16 |
+
Iterator.prototype.isLast = function() {
|
| 17 |
+
return this._index === this._lastIndex
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
Iterator.prototype.current = function() {
|
| 21 |
+
return this._collection[this._index]
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
Iterator.prototype.count = function() {
|
| 25 |
+
return this._collection.length
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
Iterator.prototype.next = function() {
|
| 29 |
+
if(this.isLast()) return false;
|
| 30 |
+
this._index++;
|
| 31 |
+
return true;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
module.exports = Iterator
|
pool/shard004/JavaScript/0028967_standardizeMarriageDate.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var expect = require('chai').expect,
|
| 2 |
+
fsCheck = require('../../lib/index.js').id('standardizeMarriageDate'),
|
| 3 |
+
doc = require('../../docs/util.js'),
|
| 4 |
+
utils = require('../test-utils.js'),
|
| 5 |
+
FS = utils.FS;
|
| 6 |
+
|
| 7 |
+
describe('standardizeMarriageDate', function(){
|
| 8 |
+
|
| 9 |
+
it('should return nothing when the wife or husband is missing', function(){
|
| 10 |
+
var husband,
|
| 11 |
+
wife = FS.createPerson({}),
|
| 12 |
+
marriage = FS.createCouple({
|
| 13 |
+
$husband: husband,
|
| 14 |
+
$wife: wife,
|
| 15 |
+
facts: []
|
| 16 |
+
});
|
| 17 |
+
|
| 18 |
+
var opportunity = fsCheck.check(wife, husband, marriage);
|
| 19 |
+
|
| 20 |
+
expect(opportunity).to.not.exist;
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
it('should return nothing when there is no marriage facts', function() {
|
| 24 |
+
var husband = FS.createPerson({}),
|
| 25 |
+
wife = FS.createPerson({}),
|
| 26 |
+
marriage = FS.createCouple({
|
| 27 |
+
$husband: husband,
|
| 28 |
+
$wife: wife,
|
| 29 |
+
facts: []
|
| 30 |
+
});
|
| 31 |
+
|
| 32 |
+
var opportunity = fsCheck.check(wife, husband, marriage);
|
| 33 |
+
|
| 34 |
+
expect(opportunity).to.not.exist;
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
it('should return nothing when there is multiple marriage facts', function() {
|
| 38 |
+
var husband = FS.createPerson({}),
|
| 39 |
+
wife = FS.createPerson({}),
|
| 40 |
+
marriage = FS.createCouple({
|
| 41 |
+
$husband: husband,
|
| 42 |
+
$wife: wife,
|
| 43 |
+
facts: [
|
| 44 |
+
FS.createFact({
|
| 45 |
+
type: 'http://gedcomx.org/Marriage',
|
| 46 |
+
$date: 'January 1, 1900',
|
| 47 |
+
$formalDate: '+1900-01-01',
|
| 48 |
+
$place: 'Provo, Utah, United States of America'
|
| 49 |
+
}),
|
| 50 |
+
FS.createFact({
|
| 51 |
+
type: 'http://gedcomx.org/Marriage',
|
| 52 |
+
$date: 'January 1, 1900',
|
| 53 |
+
$formalDate: '+1900-01-01',
|
| 54 |
+
$place: 'Provo, Utah, United States of America'
|
| 55 |
+
})
|
| 56 |
+
]
|
| 57 |
+
});
|
| 58 |
+
|
| 59 |
+
var opportunity = fsCheck.check(wife, husband, marriage);
|
| 60 |
+
|
| 61 |
+
expect(opportunity).to.not.exist;
|
| 62 |
+
});
|
| 63 |
+
|
| 64 |
+
it('should return nothing when there is no original date', function() {
|
| 65 |
+
var husband = FS.createPerson({}),
|
| 66 |
+
wife = FS.createPerson({}),
|
| 67 |
+
marriage = FS.createCouple({
|
| 68 |
+
$husband: husband,
|
| 69 |
+
$wife: wife,
|
| 70 |
+
facts: [
|
| 71 |
+
FS.createFact({
|
| 72 |
+
type: 'http://gedcomx.org/Marriage',
|
| 73 |
+
$place: 'Provo, Utah, United States of America'
|
| 74 |
+
})
|
| 75 |
+
]
|
| 76 |
+
});
|
| 77 |
+
|
| 78 |
+
var opportunity = fsCheck.check(wife, husband, marriage);
|
| 79 |
+
|
| 80 |
+
expect(opportunity).to.not.exist;
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
it('should return nothing when there is a formal date', function() {
|
| 84 |
+
var husband = FS.createPerson({}),
|
| 85 |
+
wife = FS.createPerson({}),
|
| 86 |
+
marriage = FS.createCouple({
|
| 87 |
+
$husband: husband,
|
| 88 |
+
$wife: wife,
|
| 89 |
+
facts: [
|
| 90 |
+
FS.createFact({
|
| 91 |
+
type: 'http://gedcomx.org/Marriage',
|
| 92 |
+
$date: 'January 1, 1900',
|
| 93 |
+
$place: 'Provo, Utah, United States of America'
|
| 94 |
+
})
|
| 95 |
+
]
|
| 96 |
+
});
|
| 97 |
+
marriage.facts[0].date.normalized = [{ value: '1 January 1900' }];
|
| 98 |
+
|
| 99 |
+
var opportunity = fsCheck.check(wife, husband, marriage);
|
| 100 |
+
|
| 101 |
+
expect(opportunity).to.not.exist;
|
| 102 |
+
});
|
| 103 |
+
|
| 104 |
+
it('should return an opportunity when there is an original but no formal date', function() {
|
| 105 |
+
var husband = FS.createPerson({}),
|
| 106 |
+
wife = FS.createPerson({}),
|
| 107 |
+
marriage = FS.createCouple({
|
| 108 |
+
$husband: husband,
|
| 109 |
+
$wife: wife,
|
| 110 |
+
facts: [
|
| 111 |
+
FS.createFact({
|
| 112 |
+
type: 'http://gedcomx.org/Marriage',
|
| 113 |
+
$date: 'January 1, 1900',
|
| 114 |
+
$place: 'Provo, Utah, United States of America'
|
| 115 |
+
})
|
| 116 |
+
]
|
| 117 |
+
});
|
| 118 |
+
|
| 119 |
+
marriage.id = 'MMMM-MMM';
|
| 120 |
+
husband.display = { name: 'Elmer Fudd' };
|
| 121 |
+
wife.display = { name: 'Thelma Lousie' };
|
| 122 |
+
|
| 123 |
+
var opportunity = fsCheck.check(wife, husband, marriage);
|
| 124 |
+
|
| 125 |
+
doc('standardizeMarriageDate', opportunity);
|
| 126 |
+
utils.validateSchema(fsCheck, opportunity);
|
| 127 |
+
expect(opportunity.person).to.equal(wife);
|
| 128 |
+
});
|
| 129 |
+
|
| 130 |
+
});
|
pool/shard004/JavaScript/0028968_hot-code-loading.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
var app = require('./fixtures/bootstrap'),
|
| 3 |
+
vows = require('vows'),
|
| 4 |
+
fs = require('fs'),
|
| 5 |
+
assert = require('assert'),
|
| 6 |
+
Multi = require('multi'),
|
| 7 |
+
EventEmitter = require('events').EventEmitter;
|
| 8 |
+
|
| 9 |
+
var before, after;
|
| 10 |
+
|
| 11 |
+
app.on('before_reload', function(spec) {
|
| 12 |
+
before = spec;
|
| 13 |
+
});
|
| 14 |
+
|
| 15 |
+
app.on('after_reload', function(spec) {
|
| 16 |
+
after = spec;
|
| 17 |
+
});
|
| 18 |
+
|
| 19 |
+
var __data, __templates, __envDataLoaded, __envReloadCount = 0;
|
| 20 |
+
|
| 21 |
+
var testHook = app.fullPath('hook/test_hook.js');
|
| 22 |
+
var testHookBuf = fs.readFileSync(testHook, 'utf8');
|
| 23 |
+
var otherHook = app.fullPath('hook/other_hook.js');
|
| 24 |
+
var otherHookDisabled = app.fullPath('other_hook.js');
|
| 25 |
+
|
| 26 |
+
var envFile = app.fullPath('deploy.json');
|
| 27 |
+
var envFile1 = app.fullPath('deploy1.json');
|
| 28 |
+
var envFileTmp = app.fullPath('deploy1.json.tmp');
|
| 29 |
+
|
| 30 |
+
app.on('env_data_loaded', function(data) {
|
| 31 |
+
__envReloadCount++;
|
| 32 |
+
__envDataLoaded = data;
|
| 33 |
+
});
|
| 34 |
+
|
| 35 |
+
vows.describe('Hot Code Loading').addBatch({
|
| 36 |
+
|
| 37 |
+
'Modifying runtime before reload...': function() {
|
| 38 |
+
|
| 39 |
+
// templates
|
| 40 |
+
__templates = app.templates;
|
| 41 |
+
app.templates = {};
|
| 42 |
+
|
| 43 |
+
// data
|
| 44 |
+
__data = app.__data;
|
| 45 |
+
app.__data = {};
|
| 46 |
+
|
| 47 |
+
// hooks
|
| 48 |
+
assert.isUndefined(app.TEST_HOOK);
|
| 49 |
+
app.emit('test_hook');
|
| 50 |
+
assert.equal(app.TEST_HOOK, 'ABCD');
|
| 51 |
+
|
| 52 |
+
assert.isUndefined(app.OTHER_HOOK);
|
| 53 |
+
app.emit('other_hook');
|
| 54 |
+
assert.equal(app.OTHER_HOOK, 'EFGH');
|
| 55 |
+
|
| 56 |
+
// include
|
| 57 |
+
app.filters.testFilterOne = null;
|
| 58 |
+
assert.isNull(app.filters.testFilterOne);
|
| 59 |
+
|
| 60 |
+
// exts
|
| 61 |
+
app.TEST_CONSTANT_A = null;
|
| 62 |
+
assert.isNull(app.TEST_CONSTANT_A);
|
| 63 |
+
|
| 64 |
+
// models
|
| 65 |
+
app.usersModel.blah = 99;
|
| 66 |
+
assert.equal(app.usersModel.blah, 99);
|
| 67 |
+
|
| 68 |
+
// helpers
|
| 69 |
+
app.mainHelper.blah = 100;
|
| 70 |
+
assert.equal(app.mainHelper.blah, 100);
|
| 71 |
+
|
| 72 |
+
// views
|
| 73 |
+
app.views.callbacks.blah = 101;
|
| 74 |
+
assert.equal(app.views.callbacks.blah, 101);
|
| 75 |
+
|
| 76 |
+
// partials
|
| 77 |
+
app.views.partials.main_jade = 102;
|
| 78 |
+
assert.equal(app.views.partials.main_jade, 102);
|
| 79 |
+
|
| 80 |
+
// handlers
|
| 81 |
+
app.handlers.blog = null;
|
| 82 |
+
assert.isNull(app.handlers.blog);
|
| 83 |
+
|
| 84 |
+
// controllers
|
| 85 |
+
app.controllers.main.blah = 103;
|
| 86 |
+
assert.equal(app.controllers.main.blah, 103);
|
| 87 |
+
|
| 88 |
+
// api
|
| 89 |
+
app.api.methodOne = null;
|
| 90 |
+
assert.isNull(app.api.methodOne);
|
| 91 |
+
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
}).addBatch({
|
| 95 |
+
|
| 96 |
+
'Reloading Components...': function() {
|
| 97 |
+
|
| 98 |
+
fs.writeFileSync(testHook, testHookBuf.replace('ABCD', '1234'));
|
| 99 |
+
|
| 100 |
+
fs.renameSync(otherHook, otherHookDisabled);
|
| 101 |
+
|
| 102 |
+
fs.renameSync(envFile, envFileTmp);
|
| 103 |
+
fs.renameSync(envFile1, envFile);
|
| 104 |
+
|
| 105 |
+
assert.deepEqual(app.__data, {});
|
| 106 |
+
|
| 107 |
+
assert.deepEqual(app.templates, {});
|
| 108 |
+
|
| 109 |
+
assert.equal(__envReloadCount, 0);
|
| 110 |
+
|
| 111 |
+
app.reload({
|
| 112 |
+
all: true
|
| 113 |
+
});
|
| 114 |
+
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
}).addBatch({
|
| 118 |
+
|
| 119 |
+
"The reload events are emitted with spec": function() {
|
| 120 |
+
|
| 121 |
+
var spec = {
|
| 122 |
+
assets: false,
|
| 123 |
+
env: true,
|
| 124 |
+
data: true,
|
| 125 |
+
hooks: true,
|
| 126 |
+
controllers: true,
|
| 127 |
+
api: true,
|
| 128 |
+
exts: true,
|
| 129 |
+
static: true,
|
| 130 |
+
helpers: true,
|
| 131 |
+
models: true,
|
| 132 |
+
partials: true,
|
| 133 |
+
templates: true,
|
| 134 |
+
includes: true,
|
| 135 |
+
all: true,
|
| 136 |
+
views: true,
|
| 137 |
+
handlers: true
|
| 138 |
+
};
|
| 139 |
+
|
| 140 |
+
assert.deepEqual(before, spec);
|
| 141 |
+
assert.deepEqual(after, spec);
|
| 142 |
+
|
| 143 |
+
},
|
| 144 |
+
|
| 145 |
+
'Verifying runtime after reload...': function() {
|
| 146 |
+
|
| 147 |
+
// Templates should have changed
|
| 148 |
+
assert.deepEqual(Object.keys(app.templates).sort(), ['sample-template', 'one/two/three', 'test/howdy'].sort());
|
| 149 |
+
for (var tpl in app.templates) {
|
| 150 |
+
assert.instanceOf(app.templates[tpl].engine, protos.lib.engine); // Make sure functions come from engines
|
| 151 |
+
}
|
| 152 |
+
app.templates = __templates; // Restore previous templates
|
| 153 |
+
|
| 154 |
+
// Env data should have changed
|
| 155 |
+
assert.deepEqual({TESTING: true}, protos.env());
|
| 156 |
+
fs.renameSync(envFile, envFile1);
|
| 157 |
+
fs.renameSync(envFileTmp, envFile);
|
| 158 |
+
assert.equal(__envReloadCount, 1);
|
| 159 |
+
app.reload({env: true});
|
| 160 |
+
assert.equal(__envReloadCount, 2);
|
| 161 |
+
assert.strictEqual(app.env(), __envDataLoaded);
|
| 162 |
+
|
| 163 |
+
// Data reloading
|
| 164 |
+
var alphaBuf = fs.readFileSync(app.fullPath('data/alpha.json'), 'utf8'); // Get original contents of alpha
|
| 165 |
+
assert.deepEqual(app.data(), { alpha: { alpha: true }, beta: { beta: true } }); // Compare with actual data
|
| 166 |
+
fs.writeFileSync(app.fullPath('data/alpha.json'), '{\n "alpha": false\n}', 'utf8'); // Modify alpha file
|
| 167 |
+
app.reload({data: true}); // Reload data
|
| 168 |
+
assert.deepEqual(app.data(), { alpha: { alpha: false }, beta: { beta: true } }); // Ensure updated data is read
|
| 169 |
+
fs.writeFileSync(app.fullPath('data/alpha.json'), alphaBuf, 'utf8'); // Restore alpha file
|
| 170 |
+
app.__data = __data; // Restore previous data
|
| 171 |
+
|
| 172 |
+
// Restore hook files
|
| 173 |
+
fs.writeFileSync(testHook, testHookBuf, 'utf8');
|
| 174 |
+
fs.renameSync(otherHookDisabled, otherHook);
|
| 175 |
+
|
| 176 |
+
// hooks - The test_hook should have been modified in place
|
| 177 |
+
app.emit('test_hook');
|
| 178 |
+
assert.equal(app.TEST_HOOK, 1234);
|
| 179 |
+
|
| 180 |
+
// hooks - The other_hook has been removed
|
| 181 |
+
app.emit('other_hook');
|
| 182 |
+
assert.isUndefined(app.hooks.other_hook);
|
| 183 |
+
assert.isUndefined(app._events.other_hook);
|
| 184 |
+
|
| 185 |
+
// includes
|
| 186 |
+
assert.isFunction(app.filters.testFilterOne);
|
| 187 |
+
|
| 188 |
+
// exts
|
| 189 |
+
assert.isNotNull(app.TEST_CONSTANT_A);
|
| 190 |
+
|
| 191 |
+
// models
|
| 192 |
+
assert.isUndefined(app.usersModel.blah);
|
| 193 |
+
|
| 194 |
+
// helpers
|
| 195 |
+
assert.isUndefined(app.mainHelper.blah);
|
| 196 |
+
|
| 197 |
+
// views
|
| 198 |
+
assert.isUndefined(app.views.callbacks.blah);
|
| 199 |
+
|
| 200 |
+
// partials
|
| 201 |
+
assert.isFunction(app.views.partials.main_jade);
|
| 202 |
+
|
| 203 |
+
// handlers
|
| 204 |
+
assert.isNotNull(app.handlers.blog);
|
| 205 |
+
|
| 206 |
+
// controllers
|
| 207 |
+
assert.isUndefined(app.controllers.main.blah);
|
| 208 |
+
|
| 209 |
+
// api
|
| 210 |
+
assert.isFunction(app.api.methodOne);
|
| 211 |
+
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
}).export(module);
|
pool/shard004/JavaScript/0028970_PixelRatio.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Copyright (c) 2004-present, Facebook, Inc.
|
| 3 |
+
*
|
| 4 |
+
* This source code is licensed under the MIT license found in the
|
| 5 |
+
* LICENSE file in the root directory of this source tree.
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
'use strict';
|
| 9 |
+
|
| 10 |
+
const PixelRatio = {
|
| 11 |
+
get: jest.fn().mockReturnValue(2),
|
| 12 |
+
getFontScale: jest.fn(() => PixelRatio.get()),
|
| 13 |
+
getPixelSizeForLayoutSize: jest.fn(layoutSize => Math.round(layoutSize * PixelRatio.get())),
|
| 14 |
+
roundToNearestPixel: jest.fn(layoutSize => {
|
| 15 |
+
const ratio = PixelRatio.get();
|
| 16 |
+
return Math.round(layoutSize * ratio) / ratio;
|
| 17 |
+
}),
|
| 18 |
+
startDetecting: jest.fn(),
|
| 19 |
+
};
|
| 20 |
+
|
| 21 |
+
module.exports = PixelRatio;
|
pool/shard004/JavaScript/0028972_gulpfile.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var gulp = require("gulp");
|
| 2 |
+
var fs = require("fs");
|
| 3 |
+
var rimraf = require("rimraf");
|
| 4 |
+
var plumber = require("gulp-plumber");
|
| 5 |
+
var rename = require("gulp-rename");
|
| 6 |
+
var ejs = require("gulp-ejs");
|
| 7 |
+
var typescript = require("gulp-typescript");
|
| 8 |
+
var runSequence = require("run-sequence");
|
| 9 |
+
var merge = require("event-stream").merge;
|
| 10 |
+
|
| 11 |
+
var DIST_DIR = "./dist";
|
| 12 |
+
|
| 13 |
+
gulp.task("ejs", function(){
|
| 14 |
+
var json = JSON.parse(fs.readFileSync("./src/template/index_ja.json"));
|
| 15 |
+
var json_en = JSON.parse(fs.readFileSync("./src/template/index_en.json"));
|
| 16 |
+
return merge(
|
| 17 |
+
gulp.src("./src/template/index.ejs")
|
| 18 |
+
.pipe(plumber())
|
| 19 |
+
.pipe(ejs(json))
|
| 20 |
+
.pipe(rename("index.html"))
|
| 21 |
+
.pipe(gulp.dest(DIST_DIR)),
|
| 22 |
+
|
| 23 |
+
gulp.src("./src/template/index.ejs")
|
| 24 |
+
.pipe(plumber())
|
| 25 |
+
.pipe(ejs(json_en))
|
| 26 |
+
.pipe(rename("index_en.html"))
|
| 27 |
+
.pipe(gulp.dest(DIST_DIR))
|
| 28 |
+
);
|
| 29 |
+
});
|
| 30 |
+
|
| 31 |
+
gulp.task("cp_static", function(){
|
| 32 |
+
return gulp.src(["./static/**"], {base:"./static"})
|
| 33 |
+
.pipe(gulp.dest(DIST_DIR));
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
gulp.task("cp_widget_js", function(){
|
| 37 |
+
return gulp.src(["./widgets.js"], {base:"./"})
|
| 38 |
+
.pipe(gulp.dest(DIST_DIR));
|
| 39 |
+
});
|
| 40 |
+
|
| 41 |
+
gulp.task("ts", function(){
|
| 42 |
+
return gulp.src("./src/*.ts")
|
| 43 |
+
.pipe(typescript({
|
| 44 |
+
target: "ES5",
|
| 45 |
+
outFile: "freecivcalc.js"
|
| 46 |
+
}))
|
| 47 |
+
.pipe(gulp.dest(DIST_DIR));
|
| 48 |
+
});
|
| 49 |
+
|
| 50 |
+
gulp.task("clean", function(cb){
|
| 51 |
+
rimraf(DIST_DIR, cb);
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
gulp.task("build", function(cb){
|
| 55 |
+
runSequence("clean", ["ts", "ejs", "cp_static", "cp_widget_js"], cb);
|
| 56 |
+
});
|
| 57 |
+
|
pool/shard004/JavaScript/0028973_SprkAlert.test.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* global it expect jest */
|
| 2 |
+
import React from 'react';
|
| 3 |
+
import SprkAlert from './SprkAlert';
|
| 4 |
+
|
| 5 |
+
describe('SprkAlert:', () => {
|
| 6 |
+
it('should display a div element with the correct base class', () => {
|
| 7 |
+
const wrapper = shallow(<SprkAlert message="test" isVisible />);
|
| 8 |
+
expect(wrapper.find('div.sprk-c-Alert').length).toBe(1);
|
| 9 |
+
});
|
| 10 |
+
|
| 11 |
+
it('should display a div element with correct classes when variant is info', () => {
|
| 12 |
+
const wrapper = shallow(<SprkAlert variant="info" message="test" isVisible />);
|
| 13 |
+
expect(wrapper.find('div.sprk-c-Alert').hasClass('sprk-c-Alert--info')).toBe(true);
|
| 14 |
+
});
|
| 15 |
+
|
| 16 |
+
it('should display a div element with correct classes when variant is success', () => {
|
| 17 |
+
const wrapper = shallow(<SprkAlert variant="success" message="test" isVisible />);
|
| 18 |
+
expect(wrapper.find('div.sprk-c-Alert').hasClass('sprk-c-Alert--success')).toBe(true);
|
| 19 |
+
});
|
| 20 |
+
|
| 21 |
+
it('should display a div element with correct classes when variant is fail', () => {
|
| 22 |
+
const wrapper = shallow(<SprkAlert variant="fail" message="test" isVisible />);
|
| 23 |
+
expect(wrapper.find('div.sprk-c-Alert').hasClass('sprk-c-Alert--fail')).toBe(true);
|
| 24 |
+
});
|
| 25 |
+
|
| 26 |
+
it('should hide the dismiss button when isDismissible is set to false', () => {
|
| 27 |
+
const wrapper = shallow(<SprkAlert isDismissible={false} message="test" isVisible />);
|
| 28 |
+
expect(wrapper.find('div.sprk-c-Alert').hasClass('sprk-c-Alert')).toBe(true);
|
| 29 |
+
expect(wrapper.find('button.sprk-c-Alert__icon.sprk-c-Alert__icon--dismiss').length).toBe(0);
|
| 30 |
+
});
|
| 31 |
+
|
| 32 |
+
it('should run onDismiss when the dismiss button is clicked', () => {
|
| 33 |
+
const spyFunc = jest.fn();
|
| 34 |
+
const wrapper = mount(<SprkAlert message="test" isVisible onDismiss={spyFunc} />);
|
| 35 |
+
wrapper
|
| 36 |
+
.find('button.sprk-c-Alert__icon.sprk-c-Alert__icon--dismiss')
|
| 37 |
+
.simulate('click');
|
| 38 |
+
expect(spyFunc.mock.calls.length).toBe(1);
|
| 39 |
+
});
|
| 40 |
+
|
| 41 |
+
it('should not run onDismiss when the dismiss button is clicked and onDismiss is empty', () => {
|
| 42 |
+
const spyFunc = jest.fn();
|
| 43 |
+
const wrapper = mount(<SprkAlert message="test" isVisible />);
|
| 44 |
+
wrapper
|
| 45 |
+
.find('button.sprk-c-Alert__icon.sprk-c-Alert__icon--dismiss')
|
| 46 |
+
.simulate('click');
|
| 47 |
+
expect(spyFunc.mock.calls.length).toBe(0);
|
| 48 |
+
});
|
| 49 |
+
|
| 50 |
+
it('should not render the alert is isVisible is false', () => {
|
| 51 |
+
const wrapper = shallow(<SprkAlert message="test" />);
|
| 52 |
+
expect(wrapper.find('div.sprk-c-Alert').length).toBe(0);
|
| 53 |
+
});
|
| 54 |
+
|
| 55 |
+
it('should display custom success icon when iconNameSuccess has value', () => {
|
| 56 |
+
const wrapper = mount(
|
| 57 |
+
<SprkAlert
|
| 58 |
+
variant="success"
|
| 59 |
+
message="test"
|
| 60 |
+
isVisible
|
| 61 |
+
iconNameSuccess="facebook"
|
| 62 |
+
/>,
|
| 63 |
+
);
|
| 64 |
+
expect(
|
| 65 |
+
wrapper
|
| 66 |
+
.find('svg.sprk-c-Alert__icon use')
|
| 67 |
+
.getDOMNode()
|
| 68 |
+
.getAttribute('xlink:href'),
|
| 69 |
+
).toBe('#facebook');
|
| 70 |
+
});
|
| 71 |
+
|
| 72 |
+
it('should display custom dismiss icon when iconNameDismiss has value', () => {
|
| 73 |
+
const wrapper = mount(
|
| 74 |
+
<SprkAlert
|
| 75 |
+
variant="success"
|
| 76 |
+
message="test"
|
| 77 |
+
isVisible
|
| 78 |
+
iconNameDismiss="instagram"
|
| 79 |
+
/>,
|
| 80 |
+
);
|
| 81 |
+
expect(
|
| 82 |
+
wrapper
|
| 83 |
+
.find('.sprk-c-Alert__icon--dismiss use')
|
| 84 |
+
.getDOMNode()
|
| 85 |
+
.getAttribute('xlink:href'),
|
| 86 |
+
).toBe('#instagram');
|
| 87 |
+
});
|
| 88 |
+
|
| 89 |
+
it('should display custom alert icon when iconNameInfo has value', () => {
|
| 90 |
+
const wrapper = mount(
|
| 91 |
+
<SprkAlert
|
| 92 |
+
variant="info"
|
| 93 |
+
message="test"
|
| 94 |
+
isVisible
|
| 95 |
+
iconNameInfo="twitter"
|
| 96 |
+
/>,
|
| 97 |
+
);
|
| 98 |
+
expect(
|
| 99 |
+
wrapper
|
| 100 |
+
.find('svg.sprk-c-Alert__icon use')
|
| 101 |
+
.getDOMNode()
|
| 102 |
+
.getAttribute('xlink:href'),
|
| 103 |
+
).toBe('#twitter');
|
| 104 |
+
});
|
| 105 |
+
|
| 106 |
+
it('should display custom alert icon when iconNameFail has value', () => {
|
| 107 |
+
const wrapper = mount(
|
| 108 |
+
<SprkAlert variant="fail" message="test" isVisible iconNameFail="camera" />,
|
| 109 |
+
);
|
| 110 |
+
expect(
|
| 111 |
+
wrapper
|
| 112 |
+
.find('svg.sprk-c-Alert__icon use')
|
| 113 |
+
.getDOMNode()
|
| 114 |
+
.getAttribute('xlink:href'),
|
| 115 |
+
).toBe('#camera');
|
| 116 |
+
});
|
| 117 |
+
});
|
pool/shard004/JavaScript/0028974_gallery.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2011 Research In Motion Limited.
|
| 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 |
+
|
| 17 |
+
var world;
|
| 18 |
+
|
| 19 |
+
function showTop() {
|
| 20 |
+
world.className = "normal";
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function showLeft() {
|
| 24 |
+
world.className = "left_to_top";
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
function showBottom() {
|
| 28 |
+
world.className = "bottom_to_top";
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function showRight() {
|
| 32 |
+
world.className = "right_to_top";
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
function doPageLoad() {
|
| 36 |
+
|
| 37 |
+
world = document.getElementById("world");
|
| 38 |
+
|
| 39 |
+
document.getElementById("one").addEventListener('click', showTop, false);
|
| 40 |
+
document.getElementById("two").addEventListener('click', showLeft, false);
|
| 41 |
+
document.getElementById("three").addEventListener('click', showBottom, false);
|
| 42 |
+
document.getElementById("four").addEventListener('click', showRight, false);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
window.addEventListener("load", doPageLoad, false);
|
pool/shard004/JavaScript/0028975_List.test.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import TestUtils from 'react-addons-test-utils';
|
| 3 |
+
import expect from 'expect';
|
| 4 |
+
import List from './List.jsx';
|
| 5 |
+
|
| 6 |
+
describe ('List', function () {
|
| 7 |
+
const items = [];
|
| 8 |
+
const mockedFunction = () => {};
|
| 9 |
+
|
| 10 |
+
it('renders without problems', function () {
|
| 11 |
+
const listTestProps = {
|
| 12 |
+
items: items,
|
| 13 |
+
onItemSet: mockedFunction,
|
| 14 |
+
onItemRemove: mockedFunction
|
| 15 |
+
};
|
| 16 |
+
const list = TestUtils.renderIntoDocument(<List
|
| 17 |
+
{ ...listTestProps }
|
| 18 |
+
/>);
|
| 19 |
+
|
| 20 |
+
expect(list).toExist();
|
| 21 |
+
});
|
| 22 |
+
});
|
pool/shard004/JavaScript/0028977_sdna.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var _sdna = undefined;
|
| 2 |
+
define([
|
| 3 |
+
'../util/util', './parse_sdna', './sdna_code'
|
| 4 |
+
], function(util, parse_sdna, sdna_code) {
|
| 5 |
+
'use strict';
|
| 6 |
+
|
| 7 |
+
//stub
|
| 8 |
+
function startup_report(msg, color) {
|
| 9 |
+
console.log(msg);
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
var exports = _sdna = {};
|
| 13 |
+
var Class = util.Class;
|
| 14 |
+
|
| 15 |
+
//forward parse_sdna's exports
|
| 16 |
+
for (var k in parse_sdna) {
|
| 17 |
+
exports[k] = parse_sdna[k];
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
var SDNA = parse_sdna.SDNA;
|
| 21 |
+
var SDNAParser = parse_sdna.SDNAParser;
|
| 22 |
+
|
| 23 |
+
var SDNASubClass = parse_sdna.SDNASubClass;
|
| 24 |
+
|
| 25 |
+
var _sdna_prototype_idgen = 0;
|
| 26 |
+
|
| 27 |
+
//maps prototype id's to constructors
|
| 28 |
+
var _sdna_prototype_maps = exports._sdna_prototype_maps = {};
|
| 29 |
+
|
| 30 |
+
function makeSDNAClass(stt) {
|
| 31 |
+
var code = [
|
| 32 |
+
"var CLSNAME;",
|
| 33 |
+
|
| 34 |
+
"CLSNAME = util.Class('CLSNAME', SDNASubClass, [",
|
| 35 |
+
" function constructor() {",
|
| 36 |
+
" this._bl_instance_id = parse_sdna.sdna_instance_idgen.next();",
|
| 37 |
+
" }",
|
| 38 |
+
"]);"
|
| 39 |
+
].join("\n").replace(/CLSNAME/g, stt.name);
|
| 40 |
+
|
| 41 |
+
var cls = eval(code);
|
| 42 |
+
|
| 43 |
+
cls.prototype._sdna_prototype_id = _sdna_prototype_idgen++;
|
| 44 |
+
cls.prototype._bl_sdna = stt;
|
| 45 |
+
_sdna_prototype_maps[cls.prototype._sdna_prototype_id] = cls;
|
| 46 |
+
|
| 47 |
+
cls.sdna_write = function() {
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
cls.sdna_read = function(view, off) {
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
cls._bl_sdna = stt;
|
| 54 |
+
return cls;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
var SDNATypeManager = exports.SDNATypeManager = Class('SDNATypeManager', [
|
| 58 |
+
function constructor() {
|
| 59 |
+
this.sdna = undefined;
|
| 60 |
+
this.bases = {};
|
| 61 |
+
},
|
| 62 |
+
|
| 63 |
+
function register(cls) {
|
| 64 |
+
var stt = cls.prototype._bl_sdna;
|
| 65 |
+
var sid = cls.prototype._sdna_prototype_id;
|
| 66 |
+
|
| 67 |
+
_sdna_prototype_maps[sid] = cls;
|
| 68 |
+
this[stt.name] = cls;
|
| 69 |
+
|
| 70 |
+
//startup_report("registered sdna.types." + stt.name, "blue");
|
| 71 |
+
},
|
| 72 |
+
|
| 73 |
+
function load_code(code) {
|
| 74 |
+
var parser = new parse_sdna.SDNAParser();
|
| 75 |
+
var sdna = parser.parse(code, parse_sdna.ENDIAN_LITTLE, 8);
|
| 76 |
+
this.sdna = sdna;
|
| 77 |
+
|
| 78 |
+
for (var k in sdna.structs) {
|
| 79 |
+
this[k] = this.bases[k] = makeSDNAClass(sdna.structs[k]);
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
]);
|
| 83 |
+
|
| 84 |
+
var types = exports.types = new SDNATypeManager();
|
| 85 |
+
var bases = exports.bases = types.bases;
|
| 86 |
+
|
| 87 |
+
startup_report(" parsing sdna structs. . .", "teal");
|
| 88 |
+
types.load_code(sdna_code);
|
| 89 |
+
|
| 90 |
+
return exports;
|
| 91 |
+
});
|
pool/shard004/JavaScript/0028978_background.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
chrome.webRequest.onBeforeRequest.addListener(
|
| 3 |
+
function(details) {
|
| 4 |
+
var request = new XMLHttpRequest();
|
| 5 |
+
request.open('GET', "https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=" + details.url + "/&key=AIzaSyDiX98YEW1zqVMWu8xFxMEmz_jXsAb3sfk", true);
|
| 6 |
+
request.send();
|
| 7 |
+
|
| 8 |
+
request.onload = function() {
|
| 9 |
+
var data = JSON.parse(request.responseText);
|
| 10 |
+
var colour = '#AAAAAA';
|
| 11 |
+
|
| 12 |
+
if (data.score < 50) {
|
| 13 |
+
colour = '#FF4136';
|
| 14 |
+
} else if (data.score < 80) {
|
| 15 |
+
colour = '#FFDC00';
|
| 16 |
+
} else {
|
| 17 |
+
colour = '#2ECC40';
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
var canvas = document.createElement('canvas');
|
| 21 |
+
var context = canvas.getContext('2d');
|
| 22 |
+
context.fillStyle = colour;
|
| 23 |
+
context.fillRect (0, 0, 19, 19);
|
| 24 |
+
context.fill();
|
| 25 |
+
var imageData = context.getImageData(0, 0, 19, 19);
|
| 26 |
+
chrome.browserAction.setIcon({
|
| 27 |
+
imageData: imageData
|
| 28 |
+
});
|
| 29 |
+
|
| 30 |
+
chrome.browserAction.setBadgeText({text: data.score.toString()});
|
| 31 |
+
}
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
urls: [
|
| 35 |
+
"<all_urls>",
|
| 36 |
+
],
|
| 37 |
+
types: ["main_frame"]
|
| 38 |
+
}
|
| 39 |
+
);
|
pool/shard004/JavaScript/0028982_ping.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var five = require("johnny-five"),
|
| 2 |
+
board, ping;
|
| 3 |
+
|
| 4 |
+
board = new five.Board({port:process.argv[2]});
|
| 5 |
+
|
| 6 |
+
board.on("ready", function() {
|
| 7 |
+
|
| 8 |
+
console.log('here');
|
| 9 |
+
|
| 10 |
+
// Create a new `ping` hardware instance.
|
| 11 |
+
ping = new five.Ping(9);
|
| 12 |
+
|
| 13 |
+
console.log('after');
|
| 14 |
+
// Properties
|
| 15 |
+
|
| 16 |
+
// ping.microseconds
|
| 17 |
+
//
|
| 18 |
+
// Roundtrip distance in microseconds
|
| 19 |
+
//
|
| 20 |
+
|
| 21 |
+
// ping.inches
|
| 22 |
+
//
|
| 23 |
+
// Calculated distance to object in inches
|
| 24 |
+
//
|
| 25 |
+
|
| 26 |
+
// ping.cm
|
| 27 |
+
//
|
| 28 |
+
// Calculated distance to object in centimeters
|
| 29 |
+
//
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
// Ping Event API
|
| 33 |
+
|
| 34 |
+
// "data" get the current reading from the ping
|
| 35 |
+
ping.on("data", function(err, value) {
|
| 36 |
+
console.log("data", value);
|
| 37 |
+
});
|
| 38 |
+
|
| 39 |
+
ping.on("change", function(err, value) {
|
| 40 |
+
|
| 41 |
+
console.log(typeof this.inches);
|
| 42 |
+
console.log("Object is " + this.inches + "inches away");
|
| 43 |
+
});
|
| 44 |
+
});
|
pool/shard004/JavaScript/0028985_user.model.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
const users = [{
|
| 4 |
+
id: 1,
|
| 5 |
+
email: 'john@company.com',
|
| 6 |
+
password: 'supersafe',
|
| 7 |
+
name: 'John'
|
| 8 |
+
}, {
|
| 9 |
+
id: 2,
|
| 10 |
+
email: 'jack@company.com',
|
| 11 |
+
password: 'megasafe',
|
| 12 |
+
name: 'Jack'
|
| 13 |
+
}];
|
| 14 |
+
|
| 15 |
+
module.exports = {
|
| 16 |
+
findAll: () => (users.map((user) => ({ id: user.id, email: user.email, name: user.name }))),
|
| 17 |
+
findByEmail: (email) => users.find((user) => user.email === email)
|
| 18 |
+
};
|
pool/shard004/JavaScript/0028987_HTMLElement72.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
Copyright © 2001-2004 World Wide Web Consortium,
|
| 3 |
+
(Massachusetts Institute of Technology, European Research Consortium
|
| 4 |
+
for Informatics and Mathematics, Keio University). All
|
| 5 |
+
Rights Reserved. This work is distributed under the W3C® Software License [1] in the
|
| 6 |
+
hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
| 7 |
+
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
| 8 |
+
|
| 9 |
+
[1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Gets URI that identifies the test.
|
| 14 |
+
* @return uri identifier of test
|
| 15 |
+
*/
|
| 16 |
+
function getTargetURI() {
|
| 17 |
+
return "http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLElement72";
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
var docsLoaded = -1000000;
|
| 21 |
+
var builder = null;
|
| 22 |
+
|
| 23 |
+
//
|
| 24 |
+
// This function is called by the testing framework before
|
| 25 |
+
// running the test suite.
|
| 26 |
+
//
|
| 27 |
+
// If there are no configuration exceptions, asynchronous
|
| 28 |
+
// document loading is started. Otherwise, the status
|
| 29 |
+
// is set to complete and the exception is immediately
|
| 30 |
+
// raised when entering the body of the test.
|
| 31 |
+
//
|
| 32 |
+
function setUpPage() {
|
| 33 |
+
setUpPageStatus = 'running';
|
| 34 |
+
try {
|
| 35 |
+
//
|
| 36 |
+
// creates test document builder, may throw exception
|
| 37 |
+
//
|
| 38 |
+
builder = createConfiguredBuilder();
|
| 39 |
+
|
| 40 |
+
docsLoaded = 0;
|
| 41 |
+
|
| 42 |
+
var docRef = null;
|
| 43 |
+
if (typeof(this.doc) != 'undefined') {
|
| 44 |
+
docRef = this.doc;
|
| 45 |
+
}
|
| 46 |
+
docsLoaded += preload(docRef, "doc", "element");
|
| 47 |
+
|
| 48 |
+
if (docsLoaded == 1) {
|
| 49 |
+
setUpPageStatus = 'complete';
|
| 50 |
+
}
|
| 51 |
+
} catch(ex) {
|
| 52 |
+
catchInitializationError(builder, ex);
|
| 53 |
+
setUpPageStatus = 'complete';
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
//
|
| 58 |
+
// This method is called on the completion of
|
| 59 |
+
// each asychronous load started in setUpTests.
|
| 60 |
+
//
|
| 61 |
+
// When every synchronous loaded document has completed,
|
| 62 |
+
// the page status is changed which allows the
|
| 63 |
+
// body of the test to be executed.
|
| 64 |
+
function loadComplete() {
|
| 65 |
+
if (++docsLoaded == 1) {
|
| 66 |
+
setUpPageStatus = 'complete';
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
*
|
| 72 |
+
The lang attribute specifies the language code defined in RFC 1766.
|
| 73 |
+
|
| 74 |
+
Retrieve the lang attribute of the EM element and examine its value.
|
| 75 |
+
|
| 76 |
+
* @author NIST
|
| 77 |
+
* @author Mary Brady
|
| 78 |
+
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-59132807
|
| 79 |
+
*/
|
| 80 |
+
function HTMLElement72() {
|
| 81 |
+
var success;
|
| 82 |
+
if(checkInitialization(builder, "HTMLElement72") != null) return;
|
| 83 |
+
var nodeList;
|
| 84 |
+
var testNode;
|
| 85 |
+
var vlang;
|
| 86 |
+
var doc;
|
| 87 |
+
|
| 88 |
+
var docRef = null;
|
| 89 |
+
if (typeof(this.doc) != 'undefined') {
|
| 90 |
+
docRef = this.doc;
|
| 91 |
+
}
|
| 92 |
+
doc = load(docRef, "doc", "element");
|
| 93 |
+
nodeList = doc.getElementsByTagName("em");
|
| 94 |
+
assertSize("Asize",1,nodeList);
|
| 95 |
+
testNode = nodeList.item(0);
|
| 96 |
+
vlang = testNode.lang;
|
| 97 |
+
|
| 98 |
+
assertEquals("langLink","en",vlang);
|
| 99 |
+
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
function runTest() {
|
| 103 |
+
HTMLElement72();
|
| 104 |
+
}
|
pool/shard004/JavaScript/0028989_react_jqxscrollview.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
jQWidgets v4.5.0 (2017-Jan)
|
| 3 |
+
Copyright (c) 2011-2017 jQWidgets.
|
| 4 |
+
License: http://jqwidgets.com/license/
|
| 5 |
+
*/
|
| 6 |
+
import React from 'react';
|
| 7 |
+
|
| 8 |
+
let jqxScrollView = React.createClass ({
|
| 9 |
+
getInitialState: function () {
|
| 10 |
+
return { value: '' };
|
| 11 |
+
},
|
| 12 |
+
componentDidMount: function () {
|
| 13 |
+
let options = this.manageAttributes();
|
| 14 |
+
this.createComponent(options);
|
| 15 |
+
},
|
| 16 |
+
manageAttributes: function () {
|
| 17 |
+
let properties = ['animationDuration','bounceEnabled','buttonsOffset','currentPage','disabled','height','moveThreshold','showButtons','slideShow','slideDuration','theme','width'];
|
| 18 |
+
let options = {};
|
| 19 |
+
for(let item in this.props) {
|
| 20 |
+
if(item === 'settings') {
|
| 21 |
+
for(let itemTwo in this.props[item]) {
|
| 22 |
+
options[itemTwo] = this.props[item][itemTwo];
|
| 23 |
+
}
|
| 24 |
+
} else {
|
| 25 |
+
if(properties.indexOf(item) !== -1) {
|
| 26 |
+
options[item] = this.props[item];
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
return options;
|
| 31 |
+
},
|
| 32 |
+
createComponent : function (options) {
|
| 33 |
+
if(!this.style) {
|
| 34 |
+
for (let style in this.props.style) {
|
| 35 |
+
$('#' +this.componentSelector).css(style, this.props.style[style]);
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
if(this.props.className !== undefined) {
|
| 39 |
+
let classes = this.props.className.split(' ');
|
| 40 |
+
for (let i = 0; i < classes.length; i++ ) {
|
| 41 |
+
$('#' +this.componentSelector).addClass(classes[i]);
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
if(!this.template) {
|
| 45 |
+
$('#' +this.componentSelector).html(this.props.template);
|
| 46 |
+
}
|
| 47 |
+
$('#' +this.componentSelector).jqxScrollView(options);
|
| 48 |
+
},
|
| 49 |
+
generateID : function () {
|
| 50 |
+
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
| 51 |
+
},
|
| 52 |
+
setOptions: function (options) {
|
| 53 |
+
$('#' +this.componentSelector).jqxScrollView('setOptions', options);
|
| 54 |
+
},
|
| 55 |
+
getOptions: function () {
|
| 56 |
+
if(arguments.length === 0) {
|
| 57 |
+
throw Error('At least one argument expected in getOptions()!');
|
| 58 |
+
}
|
| 59 |
+
let resultToReturn = {};
|
| 60 |
+
for(let i = 0; i < arguments.length; i++) {
|
| 61 |
+
resultToReturn[arguments[i]] = $('#' +this.componentSelector).jqxScrollView(arguments[i]);
|
| 62 |
+
}
|
| 63 |
+
return resultToReturn;
|
| 64 |
+
},
|
| 65 |
+
on: function (name,callbackFn) {
|
| 66 |
+
$('#' +this.componentSelector).on(name,callbackFn);
|
| 67 |
+
},
|
| 68 |
+
off: function (name) {
|
| 69 |
+
$('#' +this.componentSelector).off(name);
|
| 70 |
+
},
|
| 71 |
+
animationDuration: function (arg) {
|
| 72 |
+
if (arg !== undefined) {
|
| 73 |
+
$("#" +this.componentSelector).jqxScrollView("animationDuration", arg)
|
| 74 |
+
} else {
|
| 75 |
+
return $("#" +this.componentSelector).jqxScrollView("animationDuration");
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
bounceEnabled: function (arg) {
|
| 79 |
+
if (arg !== undefined) {
|
| 80 |
+
$("#" +this.componentSelector).jqxScrollView("bounceEnabled", arg)
|
| 81 |
+
} else {
|
| 82 |
+
return $("#" +this.componentSelector).jqxScrollView("bounceEnabled");
|
| 83 |
+
}
|
| 84 |
+
},
|
| 85 |
+
buttonsOffset: function (arg) {
|
| 86 |
+
if (arg !== undefined) {
|
| 87 |
+
$("#" +this.componentSelector).jqxScrollView("buttonsOffset", arg)
|
| 88 |
+
} else {
|
| 89 |
+
return $("#" +this.componentSelector).jqxScrollView("buttonsOffset");
|
| 90 |
+
}
|
| 91 |
+
},
|
| 92 |
+
currentPage: function (arg) {
|
| 93 |
+
if (arg !== undefined) {
|
| 94 |
+
$("#" +this.componentSelector).jqxScrollView("currentPage", arg)
|
| 95 |
+
} else {
|
| 96 |
+
return $("#" +this.componentSelector).jqxScrollView("currentPage");
|
| 97 |
+
}
|
| 98 |
+
},
|
| 99 |
+
disabled: function (arg) {
|
| 100 |
+
if (arg !== undefined) {
|
| 101 |
+
$("#" +this.componentSelector).jqxScrollView("disabled", arg)
|
| 102 |
+
} else {
|
| 103 |
+
return $("#" +this.componentSelector).jqxScrollView("disabled");
|
| 104 |
+
}
|
| 105 |
+
},
|
| 106 |
+
height: function (arg) {
|
| 107 |
+
if (arg !== undefined) {
|
| 108 |
+
$("#" +this.componentSelector).jqxScrollView("height", arg)
|
| 109 |
+
} else {
|
| 110 |
+
return $("#" +this.componentSelector).jqxScrollView("height");
|
| 111 |
+
}
|
| 112 |
+
},
|
| 113 |
+
moveThreshold: function (arg) {
|
| 114 |
+
if (arg !== undefined) {
|
| 115 |
+
$("#" +this.componentSelector).jqxScrollView("moveThreshold", arg)
|
| 116 |
+
} else {
|
| 117 |
+
return $("#" +this.componentSelector).jqxScrollView("moveThreshold");
|
| 118 |
+
}
|
| 119 |
+
},
|
| 120 |
+
showButtons: function (arg) {
|
| 121 |
+
if (arg !== undefined) {
|
| 122 |
+
$("#" +this.componentSelector).jqxScrollView("showButtons", arg)
|
| 123 |
+
} else {
|
| 124 |
+
return $("#" +this.componentSelector).jqxScrollView("showButtons");
|
| 125 |
+
}
|
| 126 |
+
},
|
| 127 |
+
slideShow: function (arg) {
|
| 128 |
+
if (arg !== undefined) {
|
| 129 |
+
$("#" +this.componentSelector).jqxScrollView("slideShow", arg)
|
| 130 |
+
} else {
|
| 131 |
+
return $("#" +this.componentSelector).jqxScrollView("slideShow");
|
| 132 |
+
}
|
| 133 |
+
},
|
| 134 |
+
slideDuration: function (arg) {
|
| 135 |
+
if (arg !== undefined) {
|
| 136 |
+
$("#" +this.componentSelector).jqxScrollView("slideDuration", arg)
|
| 137 |
+
} else {
|
| 138 |
+
return $("#" +this.componentSelector).jqxScrollView("slideDuration");
|
| 139 |
+
}
|
| 140 |
+
},
|
| 141 |
+
theme: function (arg) {
|
| 142 |
+
if (arg !== undefined) {
|
| 143 |
+
$("#" +this.componentSelector).jqxScrollView("theme", arg)
|
| 144 |
+
} else {
|
| 145 |
+
return $("#" +this.componentSelector).jqxScrollView("theme");
|
| 146 |
+
}
|
| 147 |
+
},
|
| 148 |
+
width: function (arg) {
|
| 149 |
+
if (arg !== undefined) {
|
| 150 |
+
$("#" +this.componentSelector).jqxScrollView("width", arg)
|
| 151 |
+
} else {
|
| 152 |
+
return $("#" +this.componentSelector).jqxScrollView("width");
|
| 153 |
+
}
|
| 154 |
+
},
|
| 155 |
+
back: function () {
|
| 156 |
+
$("#" +this.componentSelector).jqxScrollView("back");
|
| 157 |
+
},
|
| 158 |
+
changePage: function (index) {
|
| 159 |
+
$("#" +this.componentSelector).jqxScrollView("changePage", index);
|
| 160 |
+
},
|
| 161 |
+
forward: function () {
|
| 162 |
+
$("#" +this.componentSelector).jqxScrollView("forward");
|
| 163 |
+
},
|
| 164 |
+
refresh: function () {
|
| 165 |
+
$("#" +this.componentSelector).jqxScrollView("refresh");
|
| 166 |
+
},
|
| 167 |
+
render: function () {
|
| 168 |
+
let id = 'jqxScrollView' + this.generateID() + this.generateID();
|
| 169 |
+
this.componentSelector = id; return (
|
| 170 |
+
<div id={id}>{this.value ? null : this.props.value}{this.props.children}</div>
|
| 171 |
+
)
|
| 172 |
+
}
|
| 173 |
+
});
|
| 174 |
+
|
| 175 |
+
module.exports = jqxScrollView;
|
| 176 |
+
|
pool/shard004/JavaScript/0028995_test-http-zero-length-write.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright Joyent, Inc. and other Node contributors.
|
| 2 |
+
//
|
| 3 |
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
| 4 |
+
// copy of this software and associated documentation files (the
|
| 5 |
+
// "Software"), to deal in the Software without restriction, including
|
| 6 |
+
// without limitation the rights to use, copy, modify, merge, publish,
|
| 7 |
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
| 8 |
+
// persons to whom the Software is furnished to do so, subject to the
|
| 9 |
+
// following conditions:
|
| 10 |
+
//
|
| 11 |
+
// The above copyright notice and this permission notice shall be included
|
| 12 |
+
// in all copies or substantial portions of the Software.
|
| 13 |
+
//
|
| 14 |
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
| 15 |
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 16 |
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
| 17 |
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
| 18 |
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
| 19 |
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
| 20 |
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 21 |
+
|
| 22 |
+
'use strict';
|
| 23 |
+
require('../common');
|
| 24 |
+
const assert = require('assert');
|
| 25 |
+
|
| 26 |
+
const http = require('http');
|
| 27 |
+
|
| 28 |
+
const Stream = require('stream');
|
| 29 |
+
|
| 30 |
+
function getSrc() {
|
| 31 |
+
// An old-style readable stream.
|
| 32 |
+
// The Readable class prevents this behavior.
|
| 33 |
+
const src = new Stream();
|
| 34 |
+
|
| 35 |
+
// Start out paused, just so we don't miss anything yet.
|
| 36 |
+
let paused = false;
|
| 37 |
+
src.pause = function() {
|
| 38 |
+
paused = true;
|
| 39 |
+
};
|
| 40 |
+
src.resume = function() {
|
| 41 |
+
paused = false;
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
const chunks = [ '', 'asdf', '', 'foo', '', 'bar', '' ];
|
| 45 |
+
const interval = setInterval(function() {
|
| 46 |
+
if (paused)
|
| 47 |
+
return;
|
| 48 |
+
|
| 49 |
+
const chunk = chunks.shift();
|
| 50 |
+
if (chunk !== undefined) {
|
| 51 |
+
src.emit('data', chunk);
|
| 52 |
+
} else {
|
| 53 |
+
src.emit('end');
|
| 54 |
+
clearInterval(interval);
|
| 55 |
+
}
|
| 56 |
+
}, 1);
|
| 57 |
+
|
| 58 |
+
return src;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
const expect = 'asdffoobar';
|
| 63 |
+
|
| 64 |
+
const server = http.createServer(function(req, res) {
|
| 65 |
+
let actual = '';
|
| 66 |
+
req.setEncoding('utf8');
|
| 67 |
+
req.on('data', function(c) {
|
| 68 |
+
actual += c;
|
| 69 |
+
});
|
| 70 |
+
req.on('end', function() {
|
| 71 |
+
assert.strictEqual(actual, expect);
|
| 72 |
+
getSrc().pipe(res);
|
| 73 |
+
});
|
| 74 |
+
server.close();
|
| 75 |
+
});
|
| 76 |
+
|
| 77 |
+
server.listen(0, function() {
|
| 78 |
+
const req = http.request({ port: this.address().port, method: 'POST' });
|
| 79 |
+
let actual = '';
|
| 80 |
+
req.on('response', function(res) {
|
| 81 |
+
res.setEncoding('utf8');
|
| 82 |
+
res.on('data', function(c) {
|
| 83 |
+
actual += c;
|
| 84 |
+
});
|
| 85 |
+
res.on('end', function() {
|
| 86 |
+
assert.strictEqual(actual, expect);
|
| 87 |
+
});
|
| 88 |
+
});
|
| 89 |
+
getSrc().pipe(req);
|
| 90 |
+
});
|
| 91 |
+
|
| 92 |
+
process.on('exit', function(c) {
|
| 93 |
+
if (!c) console.log('ok');
|
| 94 |
+
});
|
pool/shard004/JavaScript/0028996_habitaciones_test.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const chai = require("chai")
|
| 2 |
+
chai.config.includeStack = true;
|
| 3 |
+
const expect = chai.expect;
|
| 4 |
+
const assert = chai.expect;
|
| 5 |
+
const actionCreators = require("../src/app/actions/actionCreators")
|
| 6 |
+
|
| 7 |
+
import rooms from '../src/app/data/rooms';
|
| 8 |
+
import guests from '../src/app/data/guests';
|
| 9 |
+
import reservations from '../src/app/data/reservations';
|
| 10 |
+
|
| 11 |
+
import spreadsheet from '../src/app/reducers/spreadsheet'
|
| 12 |
+
import roomsReducer from '../src/app/reducers/rooms'
|
| 13 |
+
import reservationsReducer from '../src/app/reducers/reservations'
|
| 14 |
+
import SpreadsheetStatus from '../constants/SpreadsheetStatus'
|
| 15 |
+
import ReservationStatus from '../constants/ReservationStatus'
|
| 16 |
+
import ReservationBroker from '../src/app/components/pages/spreadsheet/ReservationBroker'
|
| 17 |
+
import RoomTypes from '../constants/RoomTypes'
|
| 18 |
+
|
| 19 |
+
const today = new Date()
|
| 20 |
+
const state = require('../src/app/data/defaultStore.js')
|
| 21 |
+
|
| 22 |
+
describe("Proceso de reservacion de habitacion", function () {
|
| 23 |
+
|
| 24 |
+
it("Abrir dialog para nueva reservacion",function () {
|
| 25 |
+
const newDialogAction = actionCreators.crearNuevaReservacion()
|
| 26 |
+
const newSpreadsheet = spreadsheet(state.spreadsheet, newDialogAction)
|
| 27 |
+
expect(newSpreadsheet).to.be.not.equal(state.spreadsheet)
|
| 28 |
+
expect(newSpreadsheet.status).to.be.equal(SpreadsheetStatus.reservationDialog)
|
| 29 |
+
state.spreadsheet = newSpreadsheet
|
| 30 |
+
|
| 31 |
+
})
|
| 32 |
+
|
| 33 |
+
describe("Reservar habitacion sencilla y luego hacer check in",function () {
|
| 34 |
+
const newReservation = {
|
| 35 |
+
roomIndex: 0,
|
| 36 |
+
startIndex: 3,
|
| 37 |
+
totalDays: 3,
|
| 38 |
+
clientName: "Maria Jose Riera",
|
| 39 |
+
status: ReservationStatus.waiting,
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
const newReservationAction = actionCreators.reservarHabitacion(newReservation, `Jueves, 21 de Agosto`, 1, 1)
|
| 43 |
+
it("spreadsheet cambia a status normal", function() {
|
| 44 |
+
const newSpreadsheet = spreadsheet(state.spreadsheet, newReservationAction)
|
| 45 |
+
expect(newSpreadsheet).to.be.not.equal(state.spreadsheet)
|
| 46 |
+
expect(newSpreadsheet.status).to.be.equal(SpreadsheetStatus.normal)
|
| 47 |
+
state.spreadsheet = newSpreadsheet
|
| 48 |
+
})
|
| 49 |
+
it(" snackbar message muestra informacion de la reservacion realizada",
|
| 50 |
+
function() {
|
| 51 |
+
expect(state.spreadsheet.snackMessage).to.have.string(newReservation.clientName)
|
| 52 |
+
expect(state.spreadsheet.snackMessage).to.have.string(newReservationAction.roomId)
|
| 53 |
+
expect(state.spreadsheet.snackMessage).to.have.string(newReservation.totalDays)
|
| 54 |
+
})
|
| 55 |
+
|
| 56 |
+
it("La nueva reservacion se agrego a la lista del state en la posicion 1",
|
| 57 |
+
function() {
|
| 58 |
+
const newReservations = reservationsReducer(state.reservations, newReservationAction)
|
| 59 |
+
expect(newReservations).to.be.not.equal(state.reservations)
|
| 60 |
+
expect(newReservations.suggestions.length).to.be.equal(0)
|
| 61 |
+
const reservationsArray = newReservations.values
|
| 62 |
+
const expectedReservation = reservationsArray[1]
|
| 63 |
+
expect(expectedReservation.clientName).to.be.equal(newReservation.clientName)
|
| 64 |
+
expect(expectedReservation.startIndex).to.be.equal(newReservation.startIndex)
|
| 65 |
+
expect(expectedReservation.totalDays).to.be.equal(newReservation.totalDays)
|
| 66 |
+
expect(expectedReservation.roomIndex).to.be.equal(newReservation.roomIndex)
|
| 67 |
+
state.reservations = newReservations
|
| 68 |
+
})
|
| 69 |
+
|
| 70 |
+
const newCheckInDialogAction = actionCreators.newCheckIn(3)
|
| 71 |
+
it("Abrir el dialog para hacer CheckIn", function() {
|
| 72 |
+
const newSpreadsheet = spreadsheet(state.spreadsheet, newCheckInDialogAction)
|
| 73 |
+
expect(newSpreadsheet).to.be.not.equal(state.spreadsheet)
|
| 74 |
+
expect(newSpreadsheet.status).to.be.equal(SpreadsheetStatus.checkInDialog)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
})
|
| 78 |
+
|
| 79 |
+
it("Hacer CheckIn con el nombre de la persona de la ultima reservacion", function(){
|
| 80 |
+
let newReservations = reservationsReducer(state.reservations, newCheckInDialogAction)
|
| 81 |
+
expect(newReservations).to.be.not.equal(state.reservations)
|
| 82 |
+
expect(newReservations.suggestions.length).to.be.equal(2)
|
| 83 |
+
state.reservations = newReservations
|
| 84 |
+
|
| 85 |
+
const reservationIndexes = ReservationBroker.
|
| 86 |
+
findTodaysReservationsOfGuest(state.reservations.suggestions, newReservation.clientName)
|
| 87 |
+
const checkInAction = actionCreators.checkIn(reservationIndexes)
|
| 88 |
+
const newSpreadsheet = spreadsheet(state.spreadsheet, checkInAction)
|
| 89 |
+
expect(newSpreadsheet).to.be.not.equal(state.spreadsheet)
|
| 90 |
+
expect(newSpreadsheet.status).to.be.equal(SpreadsheetStatus.normal)
|
| 91 |
+
state.spreadsheet = newSpreadsheet
|
| 92 |
+
|
| 93 |
+
newReservations = reservationsReducer(state.reservations, checkInAction)
|
| 94 |
+
expect(newReservations).to.be.not.equal(state.reservations)
|
| 95 |
+
expect(newReservations.suggestions.length).to.be.equal(0)
|
| 96 |
+
const reservationsArray = newReservations.values
|
| 97 |
+
let reservation = reservationsArray[1] //la nueva reservacion se pone en uno
|
| 98 |
+
expect(reservation.status).to.be.equal(ReservationStatus.checkedIn)
|
| 99 |
+
expect(reservation.clientName).to.be.equal(newReservation.clientName)
|
| 100 |
+
reservation = reservationsArray[4] //la reservaciones estaba en un 3, pero con la nueva suma 4
|
| 101 |
+
expect(reservation.status).to.be.equal(ReservationStatus.checkedIn)
|
| 102 |
+
expect(reservation.clientName).to.be.equal(newReservation.clientName)
|
| 103 |
+
state.reservations = newReservations
|
| 104 |
+
})
|
| 105 |
+
|
| 106 |
+
})
|
| 107 |
+
|
| 108 |
+
});
|
pool/shard004/JavaScript/0028997_BlogPage.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* React Starter Kit (https://www.reactstarterkit.com/)
|
| 3 |
+
*
|
| 4 |
+
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the MIT license found in the
|
| 7 |
+
* LICENSE.txt file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
import React, { Component, PropTypes } from 'react';
|
| 11 |
+
import withStyles from 'isomorphic-style-loader/lib/withStyles';
|
| 12 |
+
import s from './BlogPage.scss';
|
| 13 |
+
import BlogStore from '../../stores/blogstore';
|
| 14 |
+
import BlogForm from './BlogForm';
|
| 15 |
+
import * as BlogActions from '../../actions/BlogActions';
|
| 16 |
+
import IconButton from 'material-ui/IconButton';
|
| 17 |
+
import RefreshButton from 'material-ui/svg-icons/navigation/refresh';
|
| 18 |
+
import FontIcon from 'material-ui/FontIcon';
|
| 19 |
+
import {Observable} from 'rxjs/Observable';
|
| 20 |
+
import 'rxjs/Rx';
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
const title = 'Blog';
|
| 24 |
+
|
| 25 |
+
class BlogPage extends Component {
|
| 26 |
+
|
| 27 |
+
//text_value = 'Hi';
|
| 28 |
+
|
| 29 |
+
constructor(props) {
|
| 30 |
+
super(props);
|
| 31 |
+
|
| 32 |
+
this.getBlogs = this.getBlogs.bind(this);
|
| 33 |
+
this.state = {
|
| 34 |
+
blogs: BlogStore.getAll()
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
// this.s$ = new Observable(orserver => {
|
| 38 |
+
// let count = 0;
|
| 39 |
+
// let interval = setInterval(() => {
|
| 40 |
+
// orserver.next(count++);
|
| 41 |
+
// }, 1000);
|
| 42 |
+
//
|
| 43 |
+
// return () => clearInterval(interval);
|
| 44 |
+
// });
|
| 45 |
+
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
static contextTypes = {
|
| 49 |
+
onSetTitle: PropTypes.func.isRequired,
|
| 50 |
+
};
|
| 51 |
+
|
| 52 |
+
componentWillMount() {
|
| 53 |
+
|
| 54 |
+
this.context.onSetTitle(title);
|
| 55 |
+
|
| 56 |
+
BlogStore.on('change', this.getBlogs);
|
| 57 |
+
|
| 58 |
+
console.log('count', BlogStore.listenerCount('change'));
|
| 59 |
+
|
| 60 |
+
BlogActions.loadBlogs();
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
getBlogs() {
|
| 64 |
+
this.setState({
|
| 65 |
+
blogs: BlogStore.getAll()
|
| 66 |
+
});
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
componentWillUnmount() {
|
| 70 |
+
|
| 71 |
+
BlogStore.removeListener('change', this.getBlogs)
|
| 72 |
+
|
| 73 |
+
// if(this.unsub) this.unsub.unsubscribe();
|
| 74 |
+
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
reloadClick() {
|
| 78 |
+
console.log('Reload clicked ');
|
| 79 |
+
BlogActions.loadBlogs();
|
| 80 |
+
|
| 81 |
+
// this.unsub = this.s$.subscribe( value => console.log(value) );
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
render() {
|
| 86 |
+
|
| 87 |
+
const { blogs } = this.state;
|
| 88 |
+
|
| 89 |
+
const BlogComponents = blogs.map((blog) => {
|
| 90 |
+
return <p key={blog.id}>{blog.text}</p>
|
| 91 |
+
});
|
| 92 |
+
|
| 93 |
+
return (
|
| 94 |
+
<div className={s.container}>
|
| 95 |
+
<h1>{title}</h1>
|
| 96 |
+
<IconButton
|
| 97 |
+
onClick={this.reloadClick.bind(this)}
|
| 98 |
+
tooltip="Reload blogs"
|
| 99 |
+
tooltipPosition="top-center">
|
| 100 |
+
<RefreshButton />
|
| 101 |
+
</IconButton>
|
| 102 |
+
{BlogComponents}
|
| 103 |
+
<BlogForm />
|
| 104 |
+
</div>
|
| 105 |
+
);
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
export default withStyles(BlogPage, s);
|
pool/shard004/JavaScript/0028999_sakugawa_test.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* grunt-sakugawa
|
| 3 |
+
* https://github.com/paazmaya/grunt-sakugawa
|
| 4 |
+
*
|
| 5 |
+
* Copyright (c) Juga Paazmaya <paazmaya@yahoo.com> (https://paazmaya.fi)
|
| 6 |
+
* Licensed under the MIT license.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
const tape = require('tape'),
|
| 12 |
+
grunt = require('grunt');
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
tape('media query separation', (test) => {
|
| 16 |
+
test.plan(2);
|
| 17 |
+
|
| 18 |
+
const expected1 = grunt.file.read('tests/expected/pure-min_1.css');
|
| 19 |
+
const expected2 = grunt.file.read('tests/expected/pure-min_2.css');
|
| 20 |
+
const actual1 = grunt.file.read('tmp/pure-min_1.css');
|
| 21 |
+
const actual2 = grunt.file.read('tmp/pure-min_2.css');
|
| 22 |
+
|
| 23 |
+
test.equal(expected1, actual1);
|
| 24 |
+
test.equal(expected2, actual2);
|
| 25 |
+
});
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
tape('suffix usage', (test) => {
|
| 29 |
+
test.plan(1);
|
| 30 |
+
|
| 31 |
+
test.ok(grunt.file.exists('tmp/suffixdash-split-1.css'));
|
| 32 |
+
});
|
pool/shard004/JavaScript/0029003_add.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
angular.module('yellowpages').controller('AddCtlr', ['$scope', '$http', 'Notification', function($scope, $http, Notification){
|
| 2 |
+
$scope.data = {};
|
| 3 |
+
$scope.cats = {};
|
| 4 |
+
$scope.show = [];
|
| 5 |
+
$scope.files = [];
|
| 6 |
+
$scope.show = "hide";
|
| 7 |
+
$http.get('/api/getcat').success(function(data, status){
|
| 8 |
+
$scope.cats = data;
|
| 9 |
+
});
|
| 10 |
+
$scope.add = function(data){
|
| 11 |
+
data.images = $scope.files;
|
| 12 |
+
data.image = $scope.f;
|
| 13 |
+
console.log(data);
|
| 14 |
+
$scope.show = "show";
|
| 15 |
+
|
| 16 |
+
$http.post('/api/addlisting', data).then(function(){
|
| 17 |
+
$scope.data = {};
|
| 18 |
+
Notification({message: 'Success', title: 'Listing Management'});
|
| 19 |
+
$scope.show = "hide";
|
| 20 |
+
$scope.files = [];
|
| 21 |
+
$scope.f = {};
|
| 22 |
+
$scope.image = '';
|
| 23 |
+
//$location.path('/');
|
| 24 |
+
|
| 25 |
+
}, function(){
|
| 26 |
+
Notification.error("Error Adding Data");
|
| 27 |
+
});
|
| 28 |
+
};
|
| 29 |
+
$scope.change = function(data){
|
| 30 |
+
console.log("start");
|
| 31 |
+
if(data.Plus === true){
|
| 32 |
+
$scope.show = true;
|
| 33 |
+
}
|
| 34 |
+
};
|
| 35 |
+
|
| 36 |
+
$scope.newfile = function(file){
|
| 37 |
+
|
| 38 |
+
var reader = new FileReader();
|
| 39 |
+
reader.onload = function(u){
|
| 40 |
+
//$scope.files.push(u.target.result);
|
| 41 |
+
$scope.$apply(function($scope) {
|
| 42 |
+
$scope.files.push(u.target.result);
|
| 43 |
+
//console.log(u.target.result);
|
| 44 |
+
});
|
| 45 |
+
};
|
| 46 |
+
reader.readAsDataURL(file);
|
| 47 |
+
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
$scope.newfile1 = function(file){
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
var reader = new FileReader();
|
| 54 |
+
reader.onload = function(u){
|
| 55 |
+
//$scope.files.push(u.target.result);
|
| 56 |
+
$scope.$apply(function($scope) {
|
| 57 |
+
$scope.f = u.target.result;
|
| 58 |
+
//console.log(u.target.result);
|
| 59 |
+
});
|
| 60 |
+
};
|
| 61 |
+
reader.readAsDataURL(file);
|
| 62 |
+
|
| 63 |
+
};
|
| 64 |
+
}]);
|
pool/shard004/JavaScript/0029006_datastream.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
var ArrayDataStream;
|
| 4 |
+
|
| 5 |
+
(function(){
|
| 6 |
+
var EOF = -1;
|
| 7 |
+
|
| 8 |
+
/*
|
| 9 |
+
* Take an array of unsigned byte data and present it as a stream with various methods
|
| 10 |
+
* for reading data in different formats.
|
| 11 |
+
*/
|
| 12 |
+
ArrayDataStream = function(data, start, end) {
|
| 13 |
+
this.data = data;
|
| 14 |
+
this.eof = false;
|
| 15 |
+
this.start = start === undefined ? 0 : start;
|
| 16 |
+
this.end = end === undefined ? data.length : end;
|
| 17 |
+
this.pos = this.start;
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Read a single byte from the string and turn it into a JavaScript string (assuming ASCII).
|
| 22 |
+
*
|
| 23 |
+
* @returns String containing one character, or EOF if the end of file was reached (eof flag
|
| 24 |
+
* is set).
|
| 25 |
+
*/
|
| 26 |
+
ArrayDataStream.prototype.readChar = function() {
|
| 27 |
+
if (this.pos < this.end)
|
| 28 |
+
return String.fromCharCode(this.data[this.pos++]);
|
| 29 |
+
|
| 30 |
+
this.eof = true;
|
| 31 |
+
return EOF;
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* Read one unsigned byte from the stream
|
| 36 |
+
*
|
| 37 |
+
* @returns Unsigned byte, or EOF if the end of file was reached (eof flag is set).
|
| 38 |
+
*/
|
| 39 |
+
ArrayDataStream.prototype.readByte = function() {
|
| 40 |
+
if (this.pos < this.end)
|
| 41 |
+
return this.data[this.pos++];
|
| 42 |
+
|
| 43 |
+
this.eof = true;
|
| 44 |
+
return EOF;
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
//Synonym:
|
| 48 |
+
ArrayDataStream.prototype.readU8 = ArrayDataStream.prototype.readByte;
|
| 49 |
+
|
| 50 |
+
ArrayDataStream.prototype.readS8 = function() {
|
| 51 |
+
return signExtend8Bit(this.readByte());
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
ArrayDataStream.prototype.unreadChar = function(c) {
|
| 55 |
+
this.pos--;
|
| 56 |
+
};
|
| 57 |
+
|
| 58 |
+
ArrayDataStream.prototype.peekChar = function() {
|
| 59 |
+
if (this.pos < this.end)
|
| 60 |
+
return String.fromCharCode(this.data[this.pos]);
|
| 61 |
+
|
| 62 |
+
this.eof = true;
|
| 63 |
+
return EOF;
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* Read a (maximally 32-bit) unsigned integer from the stream which was encoded in Variable Byte format.
|
| 68 |
+
*
|
| 69 |
+
* @returns the unsigned integer, or 0 if a valid integer could not be read (EOF was reached or integer format
|
| 70 |
+
* was invalid).
|
| 71 |
+
*/
|
| 72 |
+
ArrayDataStream.prototype.readUnsignedVB = function() {
|
| 73 |
+
var
|
| 74 |
+
i, b,
|
| 75 |
+
shift = 0, result = 0;
|
| 76 |
+
|
| 77 |
+
// 5 bytes is enough to encode 32-bit unsigned quantities
|
| 78 |
+
for (i = 0; i < 5; i++) {
|
| 79 |
+
b = this.readByte();
|
| 80 |
+
|
| 81 |
+
if (b == EOF)
|
| 82 |
+
return 0;
|
| 83 |
+
|
| 84 |
+
result = result | ((b & ~0x80) << shift);
|
| 85 |
+
|
| 86 |
+
// Final byte?
|
| 87 |
+
if (b < 128) {
|
| 88 |
+
/*
|
| 89 |
+
* Force the 32-bit integer to be reinterpreted as unsigned by doing an unsigned right shift, so that
|
| 90 |
+
* the top bit being set doesn't cause it to interpreted as a negative number.
|
| 91 |
+
*/
|
| 92 |
+
return result >>> 0;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
shift += 7;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
// This VB-encoded int is too long!
|
| 99 |
+
return 0;
|
| 100 |
+
};
|
| 101 |
+
|
| 102 |
+
ArrayDataStream.prototype.readSignedVB = function() {
|
| 103 |
+
var unsigned = this.readUnsignedVB();
|
| 104 |
+
|
| 105 |
+
// Apply ZigZag decoding to recover the signed value
|
| 106 |
+
return (unsigned >>> 1) ^ -(unsigned & 1);
|
| 107 |
+
};
|
| 108 |
+
|
| 109 |
+
ArrayDataStream.prototype.readString = function(length) {
|
| 110 |
+
var
|
| 111 |
+
chars = new Array(length),
|
| 112 |
+
i;
|
| 113 |
+
|
| 114 |
+
for (i = 0; i < length; i++) {
|
| 115 |
+
chars[i] = this.readChar();
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
return chars.join("");
|
| 119 |
+
};
|
| 120 |
+
|
| 121 |
+
ArrayDataStream.prototype.readS16 = function() {
|
| 122 |
+
var
|
| 123 |
+
b1 = this.readByte(),
|
| 124 |
+
b2 = this.readByte();
|
| 125 |
+
|
| 126 |
+
return signExtend16Bit(b1 | (b2 << 8));
|
| 127 |
+
};
|
| 128 |
+
|
| 129 |
+
ArrayDataStream.prototype.readU16 = function() {
|
| 130 |
+
var
|
| 131 |
+
b1 = this.readByte(),
|
| 132 |
+
b2 = this.readByte();
|
| 133 |
+
|
| 134 |
+
return b1 | (b2 << 8);
|
| 135 |
+
};
|
| 136 |
+
|
| 137 |
+
ArrayDataStream.prototype.readU32 = function() {
|
| 138 |
+
var
|
| 139 |
+
b1 = this.readByte(),
|
| 140 |
+
b2 = this.readByte(),
|
| 141 |
+
b3 = this.readByte(),
|
| 142 |
+
b4 = this.readByte();
|
| 143 |
+
return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24);
|
| 144 |
+
};
|
| 145 |
+
|
| 146 |
+
/**
|
| 147 |
+
* Search for the string 'needle' beginning from the current stream position up
|
| 148 |
+
* to the end position. Return the offset of the first occurance found.
|
| 149 |
+
*
|
| 150 |
+
* @param needle
|
| 151 |
+
* String to search for
|
| 152 |
+
* @returns Position of the start of needle in the stream, or -1 if it wasn't
|
| 153 |
+
* found
|
| 154 |
+
*/
|
| 155 |
+
ArrayDataStream.prototype.nextOffsetOf = function(needle) {
|
| 156 |
+
var i, j;
|
| 157 |
+
|
| 158 |
+
for (i = this.pos; i <= this.end - needle.length; i++) {
|
| 159 |
+
if (this.data[i] == needle[0]) {
|
| 160 |
+
for (j = 1; j < needle.length && this.data[i + j] == needle[j]; j++)
|
| 161 |
+
;
|
| 162 |
+
|
| 163 |
+
if (j == needle.length)
|
| 164 |
+
return i;
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
return -1;
|
| 169 |
+
};
|
| 170 |
+
|
| 171 |
+
ArrayDataStream.prototype.EOF = EOF;
|
| 172 |
+
}());
|
pool/shard004/JavaScript/0029008_install.1.6.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* @version $Id: install.1.6.js 43 2011-02-16 12:44:29Z stiandidriksen $
|
| 3 |
+
* @category Nooku
|
| 4 |
+
* @package Nooku_Components
|
| 5 |
+
* @subpackage Extensions
|
| 6 |
+
* @copyright Copyright (C) 2010 Timble CVBA and Contributors. (http://www.timble.net)
|
| 7 |
+
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
|
| 8 |
+
* @link http://www.nooku.org
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
Request.Install = new Class({
|
| 12 |
+
|
| 13 |
+
Extends: Request.JSON,
|
| 14 |
+
|
| 15 |
+
initiated: false,
|
| 16 |
+
|
| 17 |
+
options: {
|
| 18 |
+
url: '?option=com_extensions&view=packages&format=json',
|
| 19 |
+
update: 'install'
|
| 20 |
+
},
|
| 21 |
+
|
| 22 |
+
request: function(){
|
| 23 |
+
|
| 24 |
+
this.options.log = $(this.options.update).hasClass('debug') ? new Element('div', {'class': 'log'}).inject($(this.options.update), 'after') : false;
|
| 25 |
+
|
| 26 |
+
this.addEvent('onComplete', function(){
|
| 27 |
+
if(this.options.update && !this.response.text) $(this.options.update).getElement('h2').set('class', 'failed').set('text', 'Failed!');
|
| 28 |
+
|
| 29 |
+
if (this.options.update && this.response.json.html) $(this.options.update).empty().set('html', this.response.json.html);
|
| 30 |
+
(function(){
|
| 31 |
+
this.packages = new Chain;
|
| 32 |
+
|
| 33 |
+
//if ($(this.options.update).hasClass('debug')) alert(this.response.json.toSource());
|
| 34 |
+
|
| 35 |
+
this.response.json.packages.each(function(package, i){
|
| 36 |
+
|
| 37 |
+
var install = new Request.Install({
|
| 38 |
+
|
| 39 |
+
url: this.options.url+'&file='+package,
|
| 40 |
+
|
| 41 |
+
data: {
|
| 42 |
+
file: package,
|
| 43 |
+
i: i+1
|
| 44 |
+
},
|
| 45 |
+
|
| 46 |
+
layout: this.response.json.layouts[i],
|
| 47 |
+
|
| 48 |
+
update: this.options.update,
|
| 49 |
+
|
| 50 |
+
log: this.options.log,
|
| 51 |
+
|
| 52 |
+
packages: this.packages,
|
| 53 |
+
|
| 54 |
+
onRequest: function(){
|
| 55 |
+
$(this.options.update)
|
| 56 |
+
.set('html', this.options.layout)
|
| 57 |
+
.getElement('h2')
|
| 58 |
+
.set('title', (new Date).toLocaleString());
|
| 59 |
+
if(this.options.log)
|
| 60 |
+
{
|
| 61 |
+
this.options.log
|
| 62 |
+
.set('html', this.options.layout + this.options.log.get('html'))
|
| 63 |
+
.getElement('h2')
|
| 64 |
+
.set('title', (new Date).toLocaleString());
|
| 65 |
+
}
|
| 66 |
+
},
|
| 67 |
+
|
| 68 |
+
onComplete: function(){
|
| 69 |
+
if(!this.unpacked){
|
| 70 |
+
this.unpacked = true;
|
| 71 |
+
this.options.layout = this.response.json.html;
|
| 72 |
+
this.get({folder: this.response.json.package});
|
| 73 |
+
row = ($$('#tasks tr').getLast().get('class').substring(3,4) == '1') ? 0 : 1;
|
| 74 |
+
|
| 75 |
+
$('tasks').adopt(
|
| 76 |
+
new Element('tr', {'class': 'row'+row}).adopt([
|
| 77 |
+
new Element('td', {'class': 'key'}).set('text', this.response.json.package_name),
|
| 78 |
+
new Element('td').set('html', this.response.json.package_version)
|
| 79 |
+
])
|
| 80 |
+
);
|
| 81 |
+
|
| 82 |
+
} else {
|
| 83 |
+
this.packages.callChain();
|
| 84 |
+
$(this.options.update).fireEvent('complete').getElement('h2').set('class', 'finished').set('text', 'Done!');
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
}
|
| 88 |
+
});
|
| 89 |
+
this.packages.chain(function(){
|
| 90 |
+
this.get();
|
| 91 |
+
}.bind(install));
|
| 92 |
+
|
| 93 |
+
install.packages = this.packages;
|
| 94 |
+
}.bind(this));
|
| 95 |
+
this.packages.callChain();
|
| 96 |
+
}).bind(this).delay(1000);
|
| 97 |
+
})
|
| 98 |
+
.get();
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
});
|
| 102 |
+
|
| 103 |
+
window.addEvent('domready', function(){
|
| 104 |
+
(new Request.Install).request();
|
| 105 |
+
});
|
pool/shard004/JavaScript/0029010_study.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
function loadTable () {
|
| 3 |
+
$('#list tbody > tr').remove()
|
| 4 |
+
|
| 5 |
+
$.ajax({
|
| 6 |
+
type: 'GET',
|
| 7 |
+
dataType: 'json',
|
| 8 |
+
url: '/hyperstudy/api/studies/' + study,
|
| 9 |
+
cache: false,
|
| 10 |
+
success: function (data) {
|
| 11 |
+
var table = $('#list').find('tbody')
|
| 12 |
+
table.append($('<tr>')
|
| 13 |
+
.append($('<td>').attr('data-attr', 'Label').text(data.Label).dblclick(editCell))
|
| 14 |
+
.append($('<td>').attr('data-attr', 'Varname').text(data.Varname))
|
| 15 |
+
.append($('<td>').attr('data-attr', 'Comment').text(data.Comment).dblclick(editCell)))
|
| 16 |
+
}
|
| 17 |
+
})
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
$(document).ready(function () {
|
| 21 |
+
loadTable()
|
| 22 |
+
})
|
| 23 |
+
|
| 24 |
+
function editCell () {
|
| 25 |
+
var OriginalContent = $(this).text()
|
| 26 |
+
var attr = $(this).attr('data-attr')
|
| 27 |
+
|
| 28 |
+
$(this).addClass('cellEditing')
|
| 29 |
+
$(this).html('<input type="text" value="' + OriginalContent + '"/>')
|
| 30 |
+
$(this).children().first().focus()
|
| 31 |
+
|
| 32 |
+
$(this).children().first().keypress(function (e) {
|
| 33 |
+
if (e.which === 13) {
|
| 34 |
+
var newContent = $(this).val()
|
| 35 |
+
var parent = $(this).parent()
|
| 36 |
+
|
| 37 |
+
$.ajax({
|
| 38 |
+
type: 'PUT',
|
| 39 |
+
url: '/hyperstudy/api/studies/' + study,
|
| 40 |
+
data: { attr: attr, value: newContent },
|
| 41 |
+
cache: false,
|
| 42 |
+
success: function (data) {
|
| 43 |
+
parent.text(newContent)
|
| 44 |
+
parent.removeClass('cellEditing')
|
| 45 |
+
},
|
| 46 |
+
error: function (req, status, err) {
|
| 47 |
+
console.log(status)
|
| 48 |
+
console.log(err)
|
| 49 |
+
parent.text(OriginalContent)
|
| 50 |
+
parent.removeClass('cellEditing')
|
| 51 |
+
}
|
| 52 |
+
})
|
| 53 |
+
}
|
| 54 |
+
})
|
| 55 |
+
|
| 56 |
+
$(this).children().first().blur(function () {
|
| 57 |
+
$(this).parent().text(OriginalContent)
|
| 58 |
+
$(this).parent().removeClass('cellEditing')
|
| 59 |
+
})
|
| 60 |
+
}
|