Pendigard commited on
Commit
b2e2343
·
verified ·
1 Parent(s): 43b8dd5

Upload folder using huggingface_hub (part 115)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. pool/shard010/JavaScript/0066710_welcome.js +16 -0
  2. pool/shard010/JavaScript/0066711_case-converter.js +48 -0
  3. pool/shard010/JavaScript/0066714_bw.mainview.js +15 -0
  4. pool/shard010/JavaScript/0066718_functions.js +66 -0
  5. pool/shard010/JavaScript/0066721_webpack.config.js +39 -0
  6. pool/shard010/JavaScript/0066726_MatchStore.js +61 -0
  7. pool/shard010/JavaScript/0066727_Enquiry.js +63 -0
  8. pool/shard010/JavaScript/0066730_pentagons.js +86 -0
  9. pool/shard010/JavaScript/0066733_container.js +103 -0
  10. pool/shard010/JavaScript/0066736_content_type.js +33 -0
  11. pool/shard010/JavaScript/0066737_includes.js +23 -0
  12. pool/shard010/JavaScript/0066738_addChainableMethod.js +94 -0
  13. pool/shard010/JavaScript/0066739_boole-web.directive.js +36 -0
  14. pool/shard010/JavaScript/0066740_board.js +47 -0
  15. pool/shard010/JavaScript/0066742_taskProjectMembers.js +215 -0
  16. pool/shard010/JavaScript/0066747_dominia.test.js +81 -0
  17. pool/shard010/JavaScript/0066748_testFifoBehavior.js +40 -0
  18. pool/shard010/JavaScript/0066751_GridWindow.js +52 -0
  19. pool/shard010/JavaScript/0066753_divider.spec.js +25 -0
  20. pool/shard010/JavaScript/0066756_AuctionContainer.js +44 -0
  21. pool/shard010/JavaScript/0066763_list.js +145 -0
  22. pool/shard010/JavaScript/0066765_phema-user.js +246 -0
  23. pool/shard010/JavaScript/0066770_sample-preview-view.js +44 -0
  24. pool/shard010/JavaScript/0066772_index.js +93 -0
  25. pool/shard010/JavaScript/0066773_object_comprehensions.js +18 -0
  26. pool/shard010/JavaScript/0066774_rows.js +160 -0
  27. pool/shard010/JavaScript/0066776_imageable.js +74 -0
  28. pool/shard010/JavaScript/0066777_gender.js +77 -0
  29. pool/shard010/JavaScript/0066780_macros.js +62 -0
  30. pool/shard010/JavaScript/0066781_zoom.js +52 -0
  31. pool/shard010/JavaScript/0066783_webpack.base.conf.js +78 -0
  32. pool/shard010/JavaScript/0066787_Outline.js +205 -0
  33. pool/shard010/JavaScript/0066791_data_query.js +123 -0
  34. pool/shard010/JavaScript/0066797_main.js +17 -0
  35. pool/shard010/JavaScript/0066800_SiteStore.js +45 -0
  36. pool/shard010/JavaScript/0066803_solver.js +144 -0
  37. pool/shard010/JavaScript/0066804_config.js +226 -0
  38. pool/shard010/JavaScript/0066808_gh-app.js +46 -0
  39. pool/shard010/JavaScript/0066809_brandlist.js +132 -0
  40. pool/shard010/JavaScript/0066811_project.js +22 -0
  41. pool/shard010/JavaScript/0066812_examples.js +50 -0
  42. pool/shard010/JavaScript/0066815_RunicPowerTracker.js +63 -0
  43. pool/shard010/JavaScript/0066816_InputHelpers.js +66 -0
  44. pool/shard010/JavaScript/0066818_app.js +66 -0
  45. pool/shard010/JavaScript/0066819_lld.js +57 -0
  46. pool/shard010/JavaScript/0066821_badArraySyntax.commonjs.js +12 -0
  47. pool/shard010/JavaScript/0066824_platform.js +137 -0
  48. pool/shard010/JavaScript/0066828_text-track-list-converter.js +83 -0
  49. pool/shard010/JavaScript/0066830_linkbooktype-plugin.js +190 -0
  50. pool/shard010/JavaScript/0066834_Users.js +26 -0
pool/shard010/JavaScript/0066710_welcome.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ angular.module('openspecimen')
2
+ .controller('WelcomeCtrl', function ($scope, $sce, $state, videoSettings) {
3
+ function init() {
4
+ if (videoSettings.welcome_video_source !== 'vimeo' &&
5
+ videoSettings.welcome_video_source !== 'youtube') {
6
+ $state.go('sign-up');
7
+ return;
8
+ }
9
+
10
+ $scope.videoSettings = videoSettings;
11
+ $scope.iframeUrl = $sce.trustAsResourceUrl(videoSettings.welcome_video_url);
12
+ }
13
+
14
+
15
+ init();
16
+ });
pool/shard010/JavaScript/0066711_case-converter.js ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ /**
4
+ * Case Converter Plugin
5
+ *
6
+ * Handles the conversion between the database's snake_cased and a model's camelCased properties automatically. You just
7
+ * need to load it somewhere in your code.
8
+ *
9
+ * @example
10
+ * var bookshelf = Bookshelf(knex);
11
+ * bookshelf.plugin('case-converter');
12
+ *
13
+ * @module plugins/case-converter
14
+ */
15
+ module.exports = function caseConverter(bookshelf) {
16
+ var _ = require('lodash');
17
+
18
+ /**
19
+ * Monkey-patched Model class.
20
+ * @class Model
21
+ */
22
+ bookshelf.Model = bookshelf.Model.extend({
23
+
24
+ /**
25
+ * @method
26
+ * @description Converts attribute keys to camel case when fetching data from the database.
27
+ * @override
28
+ */
29
+ parse: function parse(attrs) {
30
+ return _.mapKeys(attrs, function (value, key) {
31
+ return _.camelCase(key);
32
+ });
33
+ },
34
+
35
+ /**
36
+ * @method
37
+ * @description
38
+ * Converts attribute keys to snake case just before saving a model to the database. The converted attributes
39
+ * will not be set on the model.
40
+ * @override
41
+ */
42
+ format: function format(attrs) {
43
+ return _.mapKeys(attrs, function (value, key) {
44
+ return _.snakeCase(key);
45
+ });
46
+ }
47
+ });
48
+ };
pool/shard010/JavaScript/0066714_bw.mainview.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function MainView() {
2
+
3
+ }
4
+
5
+ MainView.prototype.appendResult = function(result){
6
+ $('#distance').html(result);
7
+ $('#result').fadeIn('slow');
8
+ }
9
+
10
+ MainView.prototype.appendNewName = function(name){
11
+
12
+ $('#friendName').html(name);
13
+ $('#friend').fadeIn('slow');
14
+
15
+ }
pool/shard010/JavaScript/0066718_functions.js ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var usuariop="";
2
+
3
+ var actual=0;
4
+
5
+ $(".ima").bind('touchstart', function(){
6
+ siguiente();
7
+ });
8
+ function checkConnection() {
9
+ var networkState = navigator.network.connection.type;
10
+ if (networkState == 'none'){
11
+ alert('Disculpe, para utilizar esta aplicaci\u00F3n requiere una conexi\u00F3n activa');
12
+ navigator.app.exitApp();
13
+ }
14
+ }
15
+
16
+ var callBackAjax = function (jqXHR, ajaxOptions, thrownError){
17
+ if (jqXHR.status === 0) {
18
+ console.log('Not connect.\n Verify Network.');
19
+ } else if (jqXHR.status == 404) {
20
+ console.log('Requested page not found. [404]');
21
+ } else if (jqXHR.status == 500) {
22
+ console.log('Internal Server Error [500].');
23
+ } else if (ajaxOptions === 'parsererror') {
24
+ console.log('Requested JSON parse failed.');
25
+ } else if (ajaxOptions === 'timeout') {
26
+ console.log('Time out error.');
27
+ } else if (ajaxOptions === 'abort') {
28
+ console.log('Ajax request aborted.');
29
+ } else if (jqXHR.status == 401) {
30
+ $.mobile.hidePageLoadingMsg();
31
+ alert('Su sesión ha expirado');
32
+ $('#identification').val('');
33
+ $.mobile.changePage('#login');
34
+ } else {
35
+ console.log('Uncaught Error.\n' + jqXHR.responseText);
36
+ }
37
+
38
+ $.mobile.hidePageLoadingMsg();
39
+ console.log('un servicio no esta respondiendo!');
40
+ alert('Disculpe, en estos momentos el servicio no se encuentra disponible.');
41
+ //$('#identification').val('');
42
+ //$.mobile.changePage('#login');
43
+ }
44
+
45
+ // manejo de la tecla atrás de android <-
46
+ function onBackKeyDown() {
47
+ if($.mobile.activePage.is('#login')){
48
+ navigator.app.exitApp();
49
+ }
50
+ if($.mobile.activePage.is('#dashboard')){
51
+ var answer = confirm("Realmente desea salir?")
52
+ if (answer){
53
+ navigator.app.exitApp();
54
+ }
55
+ }
56
+ else {
57
+ navigator.app.backHistory()
58
+ }
59
+ }
60
+
61
+ function closeApp(){
62
+ var answer = confirm("Realmente desea salir?")
63
+ if (answer){
64
+ navigator.app.exitApp();
65
+ }
66
+ }
pool/shard010/JavaScript/0066721_webpack.config.js ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const path = require('path');
2
+
3
+ const TsGraphQLPlugin = require('../../webpack');
4
+
5
+ const tsgqlPlugin = new TsGraphQLPlugin({ tsconfigPath: __dirname });
6
+
7
+ module.exports = {
8
+ resolve: {
9
+ extensions: ['.ts', '.js'],
10
+ },
11
+ entry: {
12
+ main: path.resolve(__dirname, "query.ts"),
13
+ },
14
+ output: {
15
+ path: path.resolve(__dirname, "dist"),
16
+ filename: "[name].js",
17
+ },
18
+ module: {
19
+ rules: [
20
+ {
21
+ test: /\.ts$/,
22
+ exclude: /node_modules/,
23
+ loader: 'ts-loader',
24
+ options: {
25
+ transpileOnly: true,
26
+ getCustomTransformers: () => ({
27
+ before: [
28
+ tsgqlPlugin.getTransformer(),
29
+ ],
30
+ }),
31
+ },
32
+ }
33
+ ],
34
+ },
35
+ plugins: [
36
+ tsgqlPlugin,
37
+ ],
38
+ devtool: false,
39
+ };
pool/shard010/JavaScript/0066726_MatchStore.js ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var MovieConstants = require('../constants/MovieConstants');
2
+ var AppDispatcher = require('../dispatcher/AppDispatcher');
3
+ var NameMatcher = require('../matchers/EpisodeNameMatcher');
4
+ var NumberMatcher = require('../matchers/EpisodeNumberMatcher');
5
+ var FileStore = require('./FileStore');
6
+ var MovieStore = require('./MovieStore');
7
+ var StoreMixin = require('./StoreMixin');
8
+ var assign = require('object-assign');
9
+
10
+ var _matches = {};
11
+
12
+ function resetFiles() {
13
+ var files = FileStore.getFiles();
14
+ console.log(files);
15
+ _matches = files.reduce(function(o, file) {
16
+ o[file.id] = null;
17
+ return o;
18
+ }, {});
19
+ };
20
+
21
+ function seasonSelect(season) {
22
+ var files = FileStore.getFiles(),
23
+ episodes = MovieStore.getEpisodesForSeason(season)
24
+ ;
25
+ _matches = assign(
26
+ {},
27
+ NameMatcher.match(files, episodes),
28
+ NumberMatcher.match(files, episodes)
29
+ );
30
+ }
31
+
32
+
33
+ /**
34
+ * The MatchStore stores the filename => episode id assignments.
35
+ * It tries automatic matching whenever a season is selected
36
+ */
37
+ var MatchStore = assign({}, StoreMixin, {
38
+ getMatches: function() {
39
+ return _matches;
40
+ }
41
+
42
+ });
43
+
44
+ FileStore.addChangeListener(resetFiles);
45
+
46
+ MatchStore.dispatchToken = AppDispatcher.register(function(payload) {
47
+ var action = payload.action;
48
+ switch (action.actionType) {
49
+ case MovieConstants.MOVIE_SELECT_SEASON:
50
+ seasonSelect(action.season);
51
+ break;
52
+ default:
53
+ return true;
54
+ }
55
+ MatchStore.emitChange();
56
+ return true;
57
+ });
58
+
59
+
60
+ module.exports = MatchStore;
61
+
pool/shard010/JavaScript/0066727_Enquiry.js ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var keystone = require('keystone');
2
+ var Types = keystone.Field.Types;
3
+
4
+ /**
5
+ * Enquiry Model
6
+ * =============
7
+ */
8
+
9
+ var Enquiry = new keystone.List('Enquiry', {
10
+ nocreate: true,
11
+ noedit: true,
12
+ });
13
+
14
+ Enquiry.add({
15
+ name: { type: Types.Name, required: true },
16
+ email: { type: Types.Email, required: true },
17
+ phone: { type: String },
18
+ enquiryType: { type: Types.Select, options: [
19
+ { value: 'message', label: 'Just leaving a message' },
20
+ { value: 'question', label: 'I\'ve got a question' },
21
+ { value: 'other', label: 'Something else...' },
22
+ ] },
23
+ message: { type: Types.Markdown, required: true },
24
+ createdAt: { type: Date, default: Date.now },
25
+ });
26
+
27
+ Enquiry.schema.pre('save', function (next) {
28
+ this.wasNew = this.isNew;
29
+ next();
30
+ });
31
+
32
+ Enquiry.schema.post('save', function () {
33
+ if (this.wasNew) {
34
+ this.sendNotificationEmail();
35
+ }
36
+ });
37
+
38
+ Enquiry.schema.methods.sendNotificationEmail = function (callback) {
39
+ if (typeof callback !== 'function') {
40
+ callback = function () {};
41
+ }
42
+ var enquiry = this;
43
+ keystone.list('User').model.find().where('isAdmin', true).exec(function (err, admins) {
44
+ if (err) return callback(err);
45
+ new keystone.Email({
46
+ templateExt: 'hbs',
47
+ templateEngine: require('express-handlebars'),
48
+ templateName: 'enquiry-notification',
49
+ }).send({
50
+ to: admins,
51
+ from: {
52
+ name: 'Developer Cat',
53
+ email: 'contact@developer-cat.com',
54
+ },
55
+ subject: 'New Enquiry for Developer Cat',
56
+ enquiry: enquiry,
57
+ }, callback);
58
+ });
59
+ };
60
+
61
+ Enquiry.defaultSort = '-createdAt';
62
+ Enquiry.defaultColumns = 'name, email, enquiryType, createdAt';
63
+ Enquiry.register();
pool/shard010/JavaScript/0066730_pentagons.js ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var PENTAGON_COUNT = 18;
2
+
3
+ function Pentagon() {
4
+ var start = new PentagonInfo({
5
+ radius: randomRadius(),
6
+ opacity: randomOpacity(),
7
+ x: Math.random(),
8
+ y: Math.random(),
9
+ rotation: Math.random() * Math.PI * 2
10
+ });
11
+ this._currentAnimation = new Animation(start, start, 1);
12
+ this._lastFrame = start;
13
+ }
14
+
15
+ Pentagon.MAX_RADIUS = 0.2;
16
+
17
+ Pentagon.allPentagons = [];
18
+
19
+ Pentagon.prototype.frame = function() {
20
+ var frame = this._currentAnimation.frame().clampedAngle();
21
+ this._lastFrame = frame;
22
+ if (this._currentAnimation.isDone()) {
23
+ this._generateNewAnimation();
24
+ }
25
+ return frame;
26
+ };
27
+
28
+ Pentagon.prototype._generateNewAnimation = function(animation) {
29
+ var info = new PentagonInfo({
30
+ x: this._gravityCoord('x'),
31
+ y: this._gravityCoord('y'),
32
+ radius: randomRadius(),
33
+ opacity: randomOpacity(),
34
+ rotation: Math.PI*(Math.random()-0.5) + this._lastFrame.rotation
35
+ });
36
+ this._currentAnimation = new Animation(this._lastFrame, info,
37
+ randomDuration());
38
+ };
39
+
40
+ Pentagon.prototype._gravityCoord = function(axis) {
41
+ var axisCoord = this._lastFrame[axis];
42
+
43
+ // Apply inverse-square forces from edges.
44
+ var force = 1/Math.pow(axisCoord+0.01, 2) - 1/Math.pow(1.01-axisCoord, 2);
45
+
46
+ // Apply inverse-square forces from other pentagons.
47
+ for (var i = 0, len = Pentagon.allPentagons.length; i < len; ++i) {
48
+ var pentagon = Pentagon.allPentagons[i];
49
+ if (pentagon === this) {
50
+ continue;
51
+ }
52
+ var d2 = PentagonInfo.distanceSquared(this._lastFrame, pentagon._lastFrame);
53
+ if (Math.abs(d2) < 0.00001) {
54
+ return Math.random();
55
+ }
56
+ var forceMag = 1 / d2;
57
+ var distance = Math.sqrt(d2);
58
+ force -= forceMag * (pentagon._lastFrame[axis] - axisCoord) / distance;
59
+ }
60
+
61
+ // Add a random component to the force.
62
+ force += (Math.random() - 0.5) * 20;
63
+
64
+ // Cap the force at +/- 0.2 and add it to the current coordinate.
65
+ force = Math.max(Math.min(force, 100), -100) / 500;
66
+
67
+ return Math.max(Math.min(axisCoord+force, 1), 0);
68
+ };
69
+
70
+ function generatePentagons() {
71
+ for (var i = 0; i < PENTAGON_COUNT; ++i) {
72
+ Pentagon.allPentagons.push(new Pentagon());
73
+ }
74
+ }
75
+
76
+ function randomDuration() {
77
+ return 30000 + 30000*Math.random();
78
+ }
79
+
80
+ function randomOpacity() {
81
+ return Math.random()*0.22 + 0.02;
82
+ }
83
+
84
+ function randomRadius() {
85
+ return 0.05 + (Math.pow(Math.random(), 15)+1)*0.075;
86
+ }
pool/shard010/JavaScript/0066733_container.js ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function() {
2
+ var Container;
3
+
4
+ Container = (function() {
5
+
6
+ Container.prototype.params = {};
7
+
8
+ Container.prototype.components = {};
9
+
10
+ Container.prototype.instances = {};
11
+
12
+ Container.prototype.currents = {};
13
+
14
+ function Container(params) {
15
+ if (params == null) params = {};
16
+ this.params = params;
17
+ }
18
+
19
+ Container.prototype.bind = function(name, properties) {
20
+ return this.components[name] = properties;
21
+ };
22
+
23
+ Container.prototype.load = require;
24
+
25
+ Container.prototype.has = function(name) {
26
+ return this.components[name];
27
+ };
28
+
29
+ Container.prototype.clone = function(obj) {
30
+ var clone, i;
31
+ if (obj === null || typeof obj !== 'object') return obj;
32
+ clone = {};
33
+ for (i in obj) {
34
+ clone[i] = typeof obj[i] === "object" ? this.clone(obj[i]) : obj[i];
35
+ }
36
+ return clone;
37
+ };
38
+
39
+ Container.prototype.get = function(name) {
40
+ var k, obj, properties, v;
41
+ if (this.instances[name]) return this.instances[name];
42
+ if (name === "this-container") return this;
43
+ if (name === "clone-container") return this.clone(this);
44
+ if (!this.components[name]) {
45
+ throw new Error("Component '" + name + "' does not exist in container.");
46
+ }
47
+ if (this.currents[name]) {
48
+ throw new Error("Get component failed, recursive call: " + name);
49
+ }
50
+ this.currents[name] = true;
51
+ properties = this.components[name] ? this.components[name] : {};
52
+ obj = this.load(name);
53
+ for (k in properties) {
54
+ v = properties[k];
55
+ if (typeof obj.prototype[k] === "undefined") {
56
+ throw new Error("Undefined property: " + name + "." + k);
57
+ }
58
+ obj.prototype[k] = this.inject(v, name);
59
+ }
60
+ this.currents[name] = false;
61
+ this.instances[name] = new obj();
62
+ return this.instances[name];
63
+ };
64
+
65
+ Container.prototype.inject = function(propertyValue, component) {
66
+ var k, v, value, _len;
67
+ if (typeof propertyValue === 'object') {
68
+ value = {};
69
+ for (v = 0, _len = propertyValue.length; v < _len; v++) {
70
+ k = propertyValue[v];
71
+ value[k] = this.inject(v, component);
72
+ }
73
+ } else if (propertyValue.slice(0, 1) === "%" && propertyValue.slice(-1) === "%") {
74
+ value = this.getParam(propertyValue);
75
+ } else {
76
+ value = this.get(propertyValue);
77
+ }
78
+ return value;
79
+ };
80
+
81
+ Container.prototype.setParam = function(k, v) {
82
+ return this.params[k] = v;
83
+ };
84
+
85
+ Container.prototype.getParam = function(accessor) {
86
+ var current, i, k, key, parts, _ref;
87
+ key = accessor.slice(1, accessor.length - 1);
88
+ parts = key.split(".");
89
+ current = this.params;
90
+ for (i = 0, _ref = parts.length; 0 <= _ref ? i < _ref : i > _ref; 0 <= _ref ? i++ : i--) {
91
+ k = parts[i];
92
+ current = current[k];
93
+ }
94
+ return current;
95
+ };
96
+
97
+ return Container;
98
+
99
+ })();
100
+
101
+ if (typeof module !== "undefined" && module !== null) module.exports = Container;
102
+
103
+ }).call(this);
pool/shard010/JavaScript/0066736_content_type.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Created by DWIsprananda on 11/11/2016.
3
+ */
4
+
5
+ django.jQuery(function () {
6
+ $('.add-row').find('a')[0].click();
7
+ $('.add-row').find('a')[0].click();
8
+ $('.add-row').find('a')[0].click();
9
+
10
+ $('#id_model').bind('keyup', function(){
11
+ var val = $(this).val();
12
+
13
+ $('input[name*=codename]').each(function(idx, el) {
14
+ var name = $(el).parents('tr').find('input[name*=name]');
15
+
16
+ if (idx == 0) {
17
+ name.val('Can add ' + val);
18
+ $(el).val('add_' + val);
19
+ } else if (idx == 1) {
20
+ name.val('Can change ' + val);
21
+ $(el).val('change_' + val);
22
+ } else if (idx == 2) {
23
+ name.val('Can delete ' + val);
24
+ $(el).val('delete_' + val);
25
+ } else {
26
+ name.val('Can ? ' + val);
27
+ $(el).val('?_' + val);
28
+ }
29
+
30
+ });
31
+
32
+ });
33
+ });
pool/shard010/JavaScript/0066737_includes.js ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var scripts = [
2
+ "src/jsture.js"
3
+ , "src/Element.js"
4
+ , "src/Pattern.js"
5
+ , "src/Watcher.js"
6
+ , "src/Display.js"
7
+ ];
8
+
9
+ function addScript(url) {
10
+ document.writeln( "<script type=\"text/javascript\" src=\"" + url + "\"></script>" );
11
+ }
12
+
13
+ function loadScripts(prefix) {
14
+ for( var i=0; i<scripts.length; i++ ) {
15
+ addScript(prefix + scripts[i]);
16
+ }
17
+ }
18
+
19
+ if( typeof window.loadingPrefix == "undefined" ) {
20
+ window.loadingPrefix = "../";
21
+ }
22
+
23
+ loadScripts(window.loadingPrefix);
pool/shard010/JavaScript/0066738_addChainableMethod.js ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * Chai - addChainingMethod utility
3
+ * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
4
+ * MIT Licensed
5
+ */
6
+
7
+ /*!
8
+ * Module dependencies
9
+ */
10
+
11
+ var transferFlags = require('./transferFlags');
12
+
13
+ /*!
14
+ * Module variables
15
+ */
16
+
17
+ // Check whether `__proto__` is supported
18
+ var hasProtoSupport = '__proto__' in Object;
19
+
20
+ // Without `__proto__` support, this module will need to add properties to a function.
21
+ // However, some Function.prototype methods cannot be overwritten,
22
+ // and there seems no easy cross-platform way to detect them (@see chaijs/chai/issues/69).
23
+ var excludeNames = /^(?:length|name|arguments|caller)$/;
24
+
25
+ // Cache `Function` properties
26
+ var call = Function.prototype.call,
27
+ apply = Function.prototype.apply;
28
+
29
+ /**
30
+ * ### addChainableMethod (ctx, name, method, chainingBehavior)
31
+ *
32
+ * Adds a method to an object, such that the method can also be chained.
33
+ *
34
+ * utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
35
+ * var obj = utils.flag(this, 'object');
36
+ * new chai.Assertion(obj).to.be.equal(str);
37
+ * });
38
+ *
39
+ * Can also be accessed directly from `chai.Assertion`.
40
+ *
41
+ * chai.Assertion.addChainableMethod('foo', fn, chainingBehavior);
42
+ *
43
+ * The result can then be used as both a method assertion, executing both `method` and
44
+ * `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`.
45
+ *
46
+ * expect(fooStr).to.be.foo('bar');
47
+ * expect(fooStr).to.be.foo.equal('foo');
48
+ *
49
+ * @param {Object} ctx object to which the method is added
50
+ * @param {String} name of method to add
51
+ * @param {Function} method function to be used for `name`, when called
52
+ * @param {Function} chainingBehavior function to be called every time the property is accessed
53
+ * @name addChainableMethod
54
+ * @api public
55
+ */
56
+
57
+ module.exports = function (ctx, name, method, chainingBehavior) {
58
+ if (typeof chainingBehavior !== 'function')
59
+ chainingBehavior = function () { };
60
+
61
+ Object.defineProperty(ctx, name,
62
+ { get: function () {
63
+ chainingBehavior.call(this);
64
+
65
+ var assert = function () {
66
+ var result = method.apply(this, arguments);
67
+ return result === undefined ? this : result;
68
+ };
69
+
70
+ // Use `__proto__` if available
71
+ if (hasProtoSupport) {
72
+ // Inherit all properties from the object by replacing the `Function` prototype
73
+ var prototype = assert.__proto__ = Object.create(this);
74
+ // Restore the `call` and `apply` methods from `Function`
75
+ prototype.call = call;
76
+ prototype.apply = apply;
77
+ }
78
+ // Otherwise, redefine all properties (slow!)
79
+ else {
80
+ var asserterNames = Object.getOwnPropertyNames(ctx);
81
+ asserterNames.forEach(function (asserterName) {
82
+ if (!excludeNames.test(asserterName)) {
83
+ var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
84
+ Object.defineProperty(assert, asserterName, pd);
85
+ }
86
+ });
87
+ }
88
+
89
+ transferFlags(this, assert);
90
+ return assert;
91
+ }
92
+ , configurable: true
93
+ });
94
+ };
pool/shard010/JavaScript/0066739_boole-web.directive.js ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ angular
2
+ .module("hwboard")
3
+ .directive("wlBooleWeb", wlBooleWeb);
4
+
5
+
6
+ function wlBooleWeb() {
7
+
8
+ return {
9
+ restrict: "E",
10
+ templateUrl: "main/boole-web/boole-web.directive.html",
11
+ controller: "BooleWebController",
12
+ controllerAs: "booleWebController",
13
+ link: wlBooleWebLink,
14
+ scope: {
15
+
16
+ }
17
+ }; // !return
18
+
19
+
20
+ function wlBooleWebLink(scope, elem, attrs) {
21
+ var iframeElement = elem.find("iframe");
22
+
23
+ scope.getIframeElement = getIframeElement;
24
+
25
+
26
+ // ------------------
27
+ // Implementations
28
+ // ------------------
29
+
30
+ function getIframeElement() {
31
+ return $(iframeElement);
32
+ } // !getIframeElement
33
+
34
+ } // !wlBooleWebLink
35
+
36
+ } // !wlBooleWeb
pool/shard010/JavaScript/0066740_board.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const
2
+ _ = require('lodash'),
3
+ assert = require('assert'),
4
+ mixins = require('./mixins'),
5
+ moment = require('moment'),
6
+ polyclay = require('polyclay'),
7
+ P = require('p-promise'),
8
+ utilities = require('../utilities'),
9
+ Comment = require('./comment')
10
+ ;
11
+
12
+ var Board = module.exports = polyclay.Model.buildClass({
13
+ properties: {
14
+ id: 'string',
15
+ owner: 'string',
16
+ title: 'string',
17
+ moderators: 'array',
18
+ },
19
+ enumerables: {
20
+ status: [ 'paid', 'unpaid', 'hidden' ]
21
+ },
22
+ index: [ 'id', 'owner' ],
23
+ required: [ 'id', 'owner', 'title' ],
24
+ singular: 'board',
25
+ plural: 'boards',
26
+ });
27
+ polyclay.mixin(Board, mixins.HasContent);
28
+ polyclay.mixin(Board, mixins.HasTimestamps);
29
+ polyclay.persist(Board, 'id');
30
+
31
+ Board.create = function(opts)
32
+ {
33
+ assert(opts && _.isObject(opts), 'opts must be an object');
34
+
35
+ var board = new Board();
36
+ board.update(opts);
37
+ board.id = Board.generateID();
38
+ board.created = Date.now();
39
+ board.modified = board.created;
40
+ board.status = 'unpaid';
41
+
42
+ return board.save()
43
+ .then(function()
44
+ {
45
+ return board;
46
+ });
47
+ };
pool/shard010/JavaScript/0066742_taskProjectMembers.js ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ define([
2
+ '../moduleDef',
3
+ 'angular',
4
+ 'text!./taskProjectMembers.tpl.html',
5
+ 'css!./taskProjectMembers.css'
6
+ ], function (module, angular, tpl) {
7
+ module.directive('taskProjectMembers',
8
+ ['apinetService', '$stateParams', '$window', 'i18n', '$timeout',
9
+ function(apinetService, $stateParams, $window, i18n, $timeout) {
10
+ return {
11
+ restrict: 'EA',
12
+ replace: true,
13
+ template: tpl,
14
+ scope: {
15
+ onError: '&'
16
+ },
17
+ controller: ['$scope', '$rootScope', function($scope, $rootScope) {
18
+ $scope.i18n = $rootScope.i18n;
19
+ }],
20
+ link: function(scope, elm, attrs) {
21
+ scope.collapsed = true;
22
+
23
+ scope.onSearchClick = function(e) {
24
+ e.stopPropagation();
25
+ };
26
+
27
+ var unwatch = scope.$watch('collapsed', function(newVal, oldVal) {
28
+ if (newVal !== oldVal) {
29
+ if (!scope.collapsed) {
30
+ scope.load();
31
+ unwatch();
32
+ }
33
+ }
34
+ });
35
+
36
+ //filter and paging for list
37
+ var page = 0;
38
+ //needed for counter directive
39
+ scope.requestParams = {
40
+ term: null
41
+ };
42
+
43
+ scope.searchTimeout = null;
44
+ scope.$watch('requestParams.term', function() {
45
+ if (scope.searchTimeout) {
46
+ $timeout.cancel(scope.searchTimeout);
47
+ scope.timeout = null;
48
+ }
49
+
50
+ scope.searchTimeout = $timeout(function() {
51
+ scope.searchTimeout = null;
52
+ scope.load(true);
53
+ }, 600);
54
+ });
55
+
56
+ //new member form data
57
+ scope.editables = {
58
+ newMember: null,
59
+ isAdmin: false,
60
+ isManager: false,
61
+ isExecutor: false,
62
+
63
+ roles: function() {
64
+ var roles = [];
65
+ if (this.isAdmin) roles.push('Administrator');
66
+ if (this.isManager) roles.push('Manager');
67
+ if (this.isExecutor) roles.push('Executor');
68
+ return roles;
69
+ },
70
+
71
+ clear: function() {
72
+ this.newMember = null;
73
+ this.isAdmin = false;
74
+ this.isManager = false;
75
+ this.isExecutor = false;
76
+ },
77
+
78
+ filled: function() {
79
+ return this.newMember != null &&
80
+ (this.isAdmin || this.isManager || this.isExecutor);
81
+ }
82
+ };
83
+
84
+ scope.isMembersEditable = function() {
85
+ return true;//TODO implement
86
+ };
87
+
88
+ scope.handleError = function(error) {
89
+ if (angular.isFunction(scope.onError)) {
90
+ scope.onError({error: error});
91
+ } else {
92
+ throw error;
93
+ }
94
+ };
95
+
96
+ var mergeOrPush = function(source) {
97
+ scope.models = scope.models || [];
98
+ for(var srcIndex = 0; srcIndex < source.length; srcIndex++) {
99
+ //find target for merge
100
+ var merged = false;
101
+ for(var mIndex = 0; mIndex < scope.models.length; mIndex++) {
102
+ if (scope.models[mIndex].Id == source[srcIndex].Id) {
103
+ angular.extend(scope.models[mIndex], source[srcIndex]);
104
+ merged = true;
105
+ break;
106
+ }
107
+ }
108
+ if (!merged) {
109
+ scope.models.push(source[srcIndex]);
110
+ }
111
+ }
112
+ };
113
+
114
+ scope.load = function(replace) {
115
+ apinetService.action({
116
+ method: 'tasks/project/getMembers',
117
+ project: $stateParams.project,
118
+ term: scope.requestParams.term,
119
+ page: page
120
+ }).then(function(response) {
121
+ if (!!replace) {
122
+ scope.models = response;
123
+ page = 0;
124
+ } else {
125
+ mergeOrPush(response);
126
+ if (response.length <= 0) {
127
+ page--;
128
+ }
129
+ }
130
+ }, scope.handleError);
131
+ };
132
+
133
+ scope.add = function() {
134
+ apinetService.action({
135
+ method: 'tasks/project/addMember',
136
+ project: $stateParams.project,
137
+ userId: scope.editables.newMember.id,
138
+ roles: scope.editables.roles()
139
+ }).then(function(response) {
140
+ scope.models.unshift(response);
141
+ scope.editables.clear();
142
+ }, scope.handleError);
143
+ };
144
+
145
+ scope.remove = function(member) {
146
+ if (!member) {
147
+ return;
148
+ }
149
+
150
+ if (!$window.confirm(i18n.msg('core.confirm.delete.record'))) {
151
+ return;
152
+ }
153
+
154
+ apinetService.action({
155
+ method: 'tasks/project/removeMember',
156
+ project: $stateParams.project,
157
+ memberId: member.Id
158
+ }).then(function(response) {
159
+ var index = scope.models.indexOf(member);
160
+ if (index >= 0) {
161
+ scope.models.splice(index, 1);
162
+ }
163
+ }, scope.handleError);
164
+ };
165
+
166
+ scope.changeRoles = function(member, roles) {
167
+ if (!member || !roles || roles.length <= 0) {
168
+ return false;//cancel changes
169
+ }
170
+
171
+ apinetService.action({
172
+ method: 'tasks/project/changeMemberRoles',
173
+ project: $stateParams.project,
174
+ memberId: member.Id,
175
+ roles: roles.map(function(item){ return item.id })
176
+ }).then(function(response) {
177
+ if (response.validation.success) {
178
+ angular.extend(member, response.model);
179
+ member.validation = {};
180
+ } else {
181
+ member.validation = response.validation;
182
+ }
183
+ return response.validation.success;
184
+ }, scope.handleError);
185
+ };
186
+
187
+ scope.changeCurrentRole = function(member, role) {
188
+ if (!member || !role) {
189
+ return false;//cancel changes
190
+ }
191
+
192
+ apinetService.action({
193
+ method: 'tasks/project/changeMemberCurrentRole',
194
+ project: $stateParams.project,
195
+ memberId: member.Id,
196
+ current: role.id
197
+ }).then(function(response) {
198
+ if (response.validation.success) {
199
+ angular.extend(member, response.model);
200
+ member.validation = {};
201
+ } else {
202
+ member.validation = response.validation;
203
+ }
204
+ return response.validation.success;
205
+ }, scope.handleError);
206
+ };
207
+
208
+ scope.nextPage = function() {
209
+ page++;
210
+ scope.load(false);
211
+ };
212
+ }
213
+ };
214
+ }]);
215
+ });
pool/shard010/JavaScript/0066747_dominia.test.js ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const expect = require('chai').expect;
2
+ const path = require('path');
3
+ const rootDir = path.join(__dirname, '..', '..');
4
+ const libDir = path.join(rootDir, 'lib');
5
+ const Dominia = require(path.join(libDir, 'dominia'));
6
+ let dominia;
7
+
8
+ describe('Dominia', () => {
9
+ before(() => {
10
+ dominia = new Dominia();
11
+ });
12
+
13
+ it('can generate', () => {
14
+ const domain = dominia.generate();
15
+
16
+ expect(domain).to.be.an('object');
17
+ expect(domain.scale).to.be.a('string');
18
+ expect(domain.size).to.be.a('string');
19
+ expect(domain.name).to.be.a('string');
20
+ expect(domain.terrain).to.be.a('string');
21
+ expect(domain.population).to.be.an('object');
22
+ expect(domain.demographics).to.be.an('object');
23
+ expect(domain.resources).to.be.an('array');
24
+ });
25
+
26
+ it('can generate a hamlet', () => {
27
+ const hamlet = dominia.generate({ size: 'hamlet' });
28
+
29
+ expect(hamlet).to.be.an('object');
30
+ expect(hamlet.size).to.eq('hamlet');
31
+ });
32
+
33
+ it('can generate a village', () => {
34
+ const village = dominia.generate({ size: 'village' });
35
+
36
+ expect(village).to.be.an('object');
37
+ expect(village.size).to.eq('village');
38
+ });
39
+
40
+ it('can generate a town', () => {
41
+ const town = dominia.generate({ size: 'town' });
42
+
43
+ expect(town).to.be.an('object');
44
+ expect(town.size).to.eq('town');
45
+ });
46
+
47
+ it('can generate a city', () => {
48
+ const city = dominia.generate({ size: 'city' });
49
+
50
+ expect(city).to.be.an('object');
51
+ expect(city.size).to.eq('city');
52
+ });
53
+
54
+ it('can generate a capital', () => {
55
+ const capital = dominia.generate({ size: 'capital' });
56
+
57
+ expect(capital).to.be.an('object');
58
+ expect(capital.size).to.eq('capital');
59
+ });
60
+
61
+ it('can generate a county', () => {
62
+ const county = dominia.generate({ size: 'county' });
63
+
64
+ expect(county).to.be.an('object');
65
+ expect(county.size).to.eq('county');
66
+ });
67
+
68
+ it('can generate a duchy', () => {
69
+ const duchy = dominia.generate({ size: 'duchy' });
70
+
71
+ expect(duchy).to.be.an('object');
72
+ expect(duchy.size).to.eq('duchy');
73
+ });
74
+
75
+ it('can generate a kingdom', () => {
76
+ const kingdom = dominia.generate({ size: 'kingdom' });
77
+
78
+ expect(kingdom).to.be.an('object');
79
+ expect(kingdom.size).to.eq('kingdom');
80
+ });
81
+ });
pool/shard010/JavaScript/0066748_testFifoBehavior.js ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import fillCacheWith from './fillCacheWith';
2
+
3
+ function testFifoBehavior(CacheObject) {
4
+ describe('FIFO cache behavior', () => {
5
+ it('limits cache queue by removing the first added items', () => {
6
+ const cache = new CacheObject({cacheSize: 5});
7
+ const entries = [1, 2, 3, 4];
8
+ const newEntries = [5, 6, 7];
9
+
10
+ fillCacheWith(cache, entries);
11
+ fillCacheWith(cache, newEntries);
12
+
13
+ expect(cache.get(1)).toBe(undefined);
14
+ expect(cache.get(2)).toBe(undefined);
15
+ [4, 5, 6, 7].forEach(entry => {
16
+ expect(cache.get(entry)).toBe(entry);
17
+ });
18
+ });
19
+
20
+ it('mantains cache updated after removing extraneous entry', () => {
21
+ const cache = new CacheObject({cacheSize: 5});
22
+ const entries = [1, 2, 3, 4, 5];
23
+ fillCacheWith(cache, entries);
24
+
25
+ cache.remove(7); // Extraneous
26
+ cache.remove(3);
27
+ cache.set(6, 6);
28
+ cache.set(7, 7);
29
+
30
+ expect(cache.get(1)).toBe(undefined);
31
+ expect(cache.get(3)).toBe(undefined);
32
+
33
+ [2, 4, 5, 6, 7].forEach(entry => {
34
+ expect(cache.get(entry)).toBe(entry);
35
+ });
36
+ });
37
+ });
38
+ }
39
+
40
+ export default testFifoBehavior;
pool/shard010/JavaScript/0066751_GridWindow.js ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mini.ux.GridWindow = function () {
2
+ mini.ux.GridWindow.superclass.constructor.call(this);
3
+ this.initControls();
4
+ }
5
+ mini.extend(mini.ux.GridWindow, mini.ux.Window, {
6
+ title: "Grid Window",
7
+ showToolbar: true,
8
+ bodyStyle: "padding:0",
9
+
10
+ width: 550,
11
+ height: 300,
12
+ minWidth: 450,
13
+ minHeight: 200,
14
+
15
+ dataUrl: "../data/AjaxService.aspx?method=SearchEmployees",
16
+
17
+ initControls: function () {
18
+ var toolbarEl = this.getToolbarEl();
19
+ var footerEl = this.getFooterEl();
20
+ var bodyEl = this.getBodyEl();
21
+
22
+ //toolbar
23
+ var topHtml =
24
+ '<div style="padding:5px;">'
25
+ + '<a name="add" class="mini-button">增加</a> '
26
+ + '<a name="edit" class="mini-button">修改</a> '
27
+ + '<a name="remove" class="mini-button">删除</a> '
28
+ + '</div>';
29
+ jQuery(toolbarEl).append(topHtml);
30
+
31
+ mini.parse(this.el);
32
+
33
+ //body
34
+ this.grid = new mini.DataGrid();
35
+ this.grid.set({
36
+ multiSelect: this.multiSelect,
37
+ style: "width: 100%;height: 100%;",
38
+ borderStyle: "border:0",
39
+ columns: [
40
+ { type: "checkcolumn", header: "#" },
41
+ //{ type: "indexcolumn", header: "#", headerAlign: "center" },
42
+ {header: "帐号", field: "loginname" },
43
+ { header: "姓名", field: "name" }
44
+ ]
45
+ });
46
+ this.grid.setUrl(this.dataUrl);
47
+ this.grid.render(bodyEl);
48
+
49
+ this.grid.load();
50
+ }
51
+ });
52
+ mini.regClass(mini.ux.GridWindow, "ux.gridwindow");
pool/shard010/JavaScript/0066753_divider.spec.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ describe('Semantic-UI: Elements - smDivider', function() {
2
+ 'use strict';
3
+
4
+ var $scope, $compile;
5
+
6
+ beforeEach(module('semantic.ui.elements.divider'));
7
+
8
+ beforeEach(inject(function($rootScope, _$compile_) {
9
+ $scope = $rootScope.$new();
10
+ $compile = _$compile_;
11
+ }));
12
+
13
+ it('has to be able to be defined as vertical', function() {
14
+ var smDivider = $compile('<sm-divider vertical></sm-divider>')($scope);
15
+
16
+ expect(smDivider.hasClass('vertical')).toBe(true);
17
+ });
18
+
19
+ it('has to be able to be defined as horizontal', function() {
20
+ var smDivider = $compile('<sm-divider horizontal></sm-divider>')($scope);
21
+
22
+ expect(smDivider.hasClass('horizontal')).toBe(true);
23
+ });
24
+
25
+ });
pool/shard010/JavaScript/0066756_AuctionContainer.js ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ReactiveVar } from 'meteor/reactive-var';
2
+ import { createContainer } from 'meteor/react-meteor-data';
3
+ import AuctionPage from './AuctionPage';
4
+ import Contracts from '/imports/api/contract/collection';
5
+
6
+ const AuctionContainer = createContainer((params) => {
7
+ const {
8
+ web3,
9
+ networkId,
10
+ account,
11
+ connected,
12
+ match,
13
+ location
14
+ } = params;
15
+
16
+ const auctionAddress = match.params.address;
17
+ const tokenAddress = location.search.substring(location.search.indexOf('=') + 1);
18
+
19
+ const contractsHandle = Meteor.subscribe('auctions', networkId, 15);
20
+ const tokenHandle = Meteor.subscribe('contract', tokenAddress);
21
+
22
+ let contracts = Contracts.find({ linkedContracts: {$exists: 1} }, {sort: {createdAt: -1}}).fetch();
23
+ let auction = contracts.filter(c => c.address == auctionAddress)[0];
24
+ let token = Contracts.findOne({ address: tokenAddress});
25
+
26
+ if(auction) {
27
+ auction.abi = JSON.parse(auction.abi);
28
+ }
29
+ if(token) {
30
+ token.abi = JSON.parse(token.abi);
31
+ }
32
+
33
+ return {
34
+ web3,
35
+ networkId,
36
+ connected,
37
+ account,
38
+ contracts,
39
+ auction,
40
+ token
41
+ };
42
+ }, AuctionPage);
43
+
44
+ export default AuctionContainer;
pool/shard010/JavaScript/0066763_list.js ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //代码生成工具自动生成,请在此处填写 查询页面使用的js代码
2
+ var dataGrid;
3
+ $(function() {
4
+ dataGrid = $('#dataGrid').datagrid({
5
+ url : '/businessGoodsGroup/gridData',
6
+ fit : true,
7
+ striped : true,
8
+ rownumbers : true,
9
+ pagination : true,
10
+ singleSelect : true,
11
+ idField : 'id',
12
+ pageSize : 50,
13
+ pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400, 500 ],
14
+ columns : [ [
15
+ {
16
+ width : '80',
17
+ title : '主键',
18
+ field : 'id',
19
+ },
20
+ {
21
+ width : '80',
22
+ title : '商品主键',
23
+ field : 'goodsId',
24
+ },
25
+ {
26
+ width : '80',
27
+ title : '拼团数量',
28
+ field : 'num',
29
+ },
30
+ {
31
+ width : '80',
32
+ title : '拼团价',
33
+ field : 'groupPrice',
34
+ },
35
+ {
36
+ width : '80',
37
+ title : '拼团开始时间',
38
+ field : 'startTime',
39
+ },
40
+ {
41
+ width : '80',
42
+ title : '拼团结束时间',
43
+ field : 'endTime',
44
+ },
45
+ {
46
+ field : 'action',
47
+ title : '操作',
48
+ width : 140,
49
+ align : 'center',
50
+ formatter : function(value, row, index) {
51
+ var str = '';
52
+ str += $.formatString('<a href="javascript:void(0)" onclick="editFun(\'{0}\');" class="btn_edit" >编辑</a>', row.id);
53
+ str += '&nbsp;|&nbsp;';
54
+ str += $.formatString('<a href="javascript:void(0)" onclick="deleteFun(\'{0}\');" class="btn_delete" >删除</a>', row.id);
55
+ return str;
56
+ }
57
+ }] ],
58
+ toolbar : [{
59
+ iconCls: 'icon-add',
60
+ text:'新增',
61
+ handler: function(){addFun();}
62
+ }],
63
+ onLoadSuccess : function(data){
64
+ $('.btn_edit').linkbutton({text:'编辑',plain:true,iconCls:'icon-edit'});
65
+ $('.btn_delete').linkbutton({text:'删除',plain:true,iconCls:'icon-del'});
66
+ $(this).datagrid('fixRowHeight');
67
+ }
68
+ });
69
+ });
70
+
71
+ function addFun() {
72
+ parent.$.modalDialog({
73
+ title : '添加',
74
+ width : 500,
75
+ height : 300,
76
+ href : '/businessGoodsGroup/add',
77
+ buttons : [ {
78
+ text : '添加',
79
+ handler : function() {
80
+ parent.$.modalDialog.openner_dataGrid = dataGrid;//因为添加成功之后,需要刷新这个dataGrid,所以先预定义好
81
+ var f = parent.$.modalDialog.handler.find('#modelForm');
82
+ f.submit();
83
+ }
84
+ } ]
85
+ });
86
+ }
87
+
88
+ function deleteFun(id) {
89
+ if (id == undefined) {//点击右键菜单才会触发这个
90
+ var rows = dataGrid.datagrid('getSelections');
91
+ id = rows[0].id;
92
+ } else {//点击操作里面的删除图标会触发这个
93
+ dataGrid.datagrid('unselectAll').datagrid('uncheckAll');
94
+ }
95
+ parent.$.messager.confirm('询问', '您是否要删除商品拼团管理?', function(b) {
96
+ if (b) {
97
+ progressLoad();
98
+ $.post('/businessGoodsGroup/delete', {
99
+ id : id
100
+ }, function(result) {
101
+ if (result.success) {
102
+ parent.$.messager.alert('提示', result.msg, 'info');
103
+ dataGrid.datagrid('reload');
104
+ }
105
+ progressClose();
106
+ }, 'JSON');
107
+ }
108
+ });
109
+ }
110
+
111
+ function editFun(id) {
112
+ if (id == undefined) {
113
+ var rows = dataGrid.datagrid('getSelections');
114
+ id = rows[0].id;
115
+ } else {
116
+ dataGrid.datagrid('unselectAll').datagrid('uncheckAll');
117
+ }
118
+ parent.$.modalDialog({
119
+ title : '编辑',
120
+ width : 500,
121
+ height : 300,
122
+ href : '/businessGoodsGroup/edit?id=' + id,
123
+ buttons : [ {
124
+ text : '编辑',
125
+ handler : function() {
126
+ parent.$.modalDialog.openner_dataGrid = dataGrid;//因为添加成功之后,需要刷新这个dataGrid,所以先预定义好
127
+ var f = parent.$.modalDialog.handler.find('#modelForm');
128
+ f.submit();
129
+ }
130
+ }
131
+ ]
132
+ });
133
+ }
134
+
135
+ function searchFun() {
136
+ ////将searchForm表单内的元素序列为对象传递到后台
137
+ dataGrid.datagrid('load', $.serializeObject($('#searchForm')));
138
+ }
139
+ function cleanFun() {
140
+ //找到form表单下的所有input标签并清空
141
+ $('#searchForm input').val('');
142
+ //重新加载数据,无填写数据,向后台传递值则为空
143
+ dataGrid.datagrid('load', {});
144
+ }
145
+
pool/shard010/JavaScript/0066765_phema-user.js ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+ var mongoose = require('mongoose');
3
+ var bcrypt = require('bcrypt');
4
+
5
+ var MONGO_CONNECTION = process.env.PHEMA_USER_DB_URL;
6
+ const SALT_ROUNDS = 10;
7
+
8
+ var Schema = mongoose.Schema;
9
+
10
+ function emailValidator (email) {
11
+ if (!email || typeof email === 'undefined') {
12
+ return false;
13
+ }
14
+
15
+ // Regex from: http://stackoverflow.com/questions/46155/validate-email-address-in-javascript/1373724#1373724
16
+ var re = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i;
17
+ return re.test(email);
18
+ }
19
+
20
+ function passwordValidator(password) {
21
+ if (!password || typeof password === 'undefined') {
22
+ return false;
23
+ }
24
+
25
+ return (password.length >= 6);
26
+ }
27
+
28
+ var UserSchema = new Schema({
29
+ email: {
30
+ type: String,
31
+ require: true,
32
+ unique: true,
33
+ validate: [emailValidator, 'Please enter a valid e-mail address']
34
+ },
35
+ password: {
36
+ type: String,
37
+ require: true,
38
+ select: false,
39
+ validate: [passwordValidator, 'Please enter a password that is 6 characters or longer']
40
+ },
41
+ firstName: {
42
+ type: String
43
+ },
44
+ lastName: {
45
+ type: String
46
+ },
47
+ created: {
48
+ type: Date,
49
+ default: Date.now
50
+ },
51
+ resetPasswordExpires: {
52
+ type: Date,
53
+ },
54
+ resetPasswordToken: {
55
+ type: String
56
+ }
57
+ });
58
+
59
+ function formatUserForReturn(user) {
60
+ return {
61
+ id: user._id.toHexString(),
62
+ email: user.email,
63
+ firstName: user.firstName,
64
+ lastName: user.lastName
65
+ };
66
+ }
67
+
68
+ var UserModel = mongoose.model('User', UserSchema);
69
+
70
+ // MongoDB configuration
71
+ mongoose.connect(MONGO_CONNECTION, function(err) {
72
+ if(err) {
73
+ console.log('error connecting to MongoDB Database. ' + err);
74
+ } else {
75
+ console.log('Connected to Database');
76
+ }
77
+ });
78
+
79
+ var UserRepository = function() {}
80
+
81
+ UserRepository.prototype.getUser = function(id, callback) {
82
+ return UserModel.findOne({_id: id }, function(err, user) {
83
+ if (!user) {
84
+ return callback({message: 'The specified user could not be found.'});
85
+ }
86
+
87
+ if (!err) {
88
+ return callback(null, formatUserForReturn(user));
89
+ }
90
+ else {
91
+ console.log(err);
92
+ return callback({message: 'There was an error when searching for the user.'});
93
+ }
94
+ });
95
+ };
96
+
97
+ UserRepository.prototype.findUserByEmail = function(email, callback) {
98
+ return UserModel.findOne({email: email }, function(err, user) {
99
+ if (!user) {
100
+ return callback({message: 'The specified user could not be found.'});
101
+ }
102
+
103
+ if (!err) {
104
+ return callback(null, formatUserForReturn(user));
105
+ }
106
+ else {
107
+ console.log(err);
108
+ return callback({message: 'There was an error when searching for the user.'});
109
+ }
110
+ });
111
+ };
112
+
113
+ UserRepository.prototype.findUserByPasswordResetToken = function(token, callback) {
114
+ return UserModel.findOne({ resetPasswordToken: token, resetPasswordExpires: { $gt: Date.now() } }, function(err, user) {
115
+ if (!user) {
116
+ return callback({message: 'Password reset token is invalid or has expired.'});
117
+ }
118
+
119
+ if (!err) {
120
+ return callback(null, formatUserForReturn(user));
121
+ }
122
+ else {
123
+ console.log(err);
124
+ return callback({message: 'There was an error when searching for the user to reset their password.'});
125
+ }
126
+ });
127
+ }
128
+
129
+ UserRepository.prototype.addUser = function(user, callback) {
130
+ UserModel.findOne({email: user.email }, function(err, existingUser) {
131
+ if (existingUser) {
132
+ return callback({message: 'This e-mail address has already been used to create an account. Please try logging in with that account, and reset the password if you no longer remember it.'});
133
+ }
134
+
135
+ if (err) {
136
+ console.log(err);
137
+ return callback({message: 'There was an error when searching for the user.'});
138
+ }
139
+ else {
140
+ var userRecord = new UserModel({
141
+ email: user.email,
142
+ firstName: user.firstName,
143
+ lastName: user.lastName
144
+ });
145
+
146
+ bcrypt.genSalt(SALT_ROUNDS, function(err, salt) {
147
+ bcrypt.hash(user.password, salt, function(err, hash) {
148
+ userRecord.password = hash;
149
+
150
+ userRecord.save(function(err) {
151
+ console.log("User saved ", userRecord.email);
152
+ if (err) {
153
+ console.log(err);
154
+ return callback({message: 'There was an error when saving the new user.'});
155
+ }
156
+ else {
157
+ return callback(null, formatUserForReturn(userRecord));
158
+ }
159
+ });
160
+ });
161
+ });
162
+ }
163
+ });
164
+ };
165
+
166
+ UserRepository.prototype.updateUser = function(updatedUser, callback) {
167
+ return UserModel.findOne({_id: updatedUser.id }, function(err, user) {
168
+ if (!user) {
169
+ return callback({message: 'The specified user could not be found.'});
170
+ }
171
+ else if (err) {
172
+ console.log(err);
173
+ return callback({message: 'There was an error when searching for the user.'});
174
+ }
175
+
176
+ user.firstName = updatedUser.firstName;
177
+ user.lastName = updatedUser.lastName;
178
+ // Any time the user is updated, we want to clear out the reset password fields.
179
+ // If there is an outstanding reset password and someone is logged in and able
180
+ // to reset this, the outstanding token should no longer be valid.
181
+ user.resetPasswordToken = null;
182
+ user.resetPasswordExpires = null;
183
+
184
+ if (updatedUser.resetPasswordToken) {
185
+ user.resetPasswordToken = updatedUser.resetPasswordToken;
186
+ user.resetPasswordExpires = updatedUser.resetPasswordExpires;
187
+ }
188
+
189
+ if (updatedUser.password) {
190
+ bcrypt.genSalt(SALT_ROUNDS, function(err, salt) {
191
+ bcrypt.hash(updatedUser.password, salt, function(err, hash) {
192
+ user.password = hash;
193
+
194
+ user.save(function(err) {
195
+ console.log("User with password updated : ", user.email);
196
+ if (err) {
197
+ console.log(err);
198
+ return callback({message: 'There was an error when saving the new user.'});
199
+ }
200
+ else {
201
+ return callback(null, formatUserForReturn(user));
202
+ }
203
+ });
204
+ });
205
+ });
206
+ }
207
+ else {
208
+ return user.save(function(err) {
209
+ if(!err) {
210
+ console.log("Updated : " , user.email);
211
+ return callback(null, formatUserForReturn(user));
212
+ } else {
213
+ console.log('Internal error(%d): %s',res.statusCode,err.message);
214
+ if (err.name === 'ValidationError') {
215
+ return callback({ error: 'Validation error' });
216
+ } else {
217
+ return callback({ error: 'Server error' });
218
+ }
219
+ }
220
+ });
221
+ }
222
+ });
223
+ };
224
+
225
+ UserRepository.prototype.authenticate = function(email, password, callback) {
226
+ UserModel.findOne({ email: email }).select('+password').exec(function(err, user) {
227
+ if (err) {
228
+ return callback(err, null);
229
+ }
230
+
231
+ // No user found just return the empty user
232
+ if (!user) {
233
+ return callback({ error: 'Invalid username or password' }, user);
234
+ }
235
+
236
+ bcrypt.compare(password, user.password, function(err, res) {
237
+ if (err) { return callback(err, null); }
238
+ if (res === false) { return callback({message: 'Invalid username or password'}, null); }
239
+ user = formatUserForReturn(user);
240
+ callback(null, user);
241
+ });
242
+ });
243
+ };
244
+
245
+ exports.UserRepository = UserRepository;
246
+
pool/shard010/JavaScript/0066770_sample-preview-view.js ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
3
+ */
4
+ define(['require', 'jquery', 'lodash', 'log'], function (require, $, _, log) {
5
+
6
+ var ServicePreviewView = function (config) {
7
+ this._config = config;
8
+ };
9
+
10
+ ServicePreviewView.prototype.constructor = ServicePreviewView;
11
+
12
+ ServicePreviewView.prototype.render = function () {
13
+ var config = this._config;
14
+ var errMsg;
15
+ if (!_.has(config, 'parentContainer')) {
16
+ errMsg = 'unable to find configuration for parentContainer';
17
+ log.error(errMsg);
18
+ throw errMsg;
19
+ }
20
+ // get parent container which is innerSamples div
21
+ var parentContainer = $(_.get(config, 'parentContainer'));
22
+
23
+ this._sampleName = config.sampleName;
24
+ this._content = config.content;
25
+ var regexToExtractAppDescription = new RegExp("@[Aa][Pp][Pp]:[Dd][Ee][Ss][Cc][Rr][Ii][Pp][Tt][Ii][Oo]" +
26
+ "[Nn]\\(['|\"](.*?)['|\"]\\)", "ig");
27
+
28
+ //create the parent for drawn svg
29
+ var previewLi = $("<li class='col-md-6 col-lg-4'></li>");
30
+
31
+ var linkSample = $("<a href='' style='height: 100px;'></a>");
32
+ linkSample.text(this._sampleName);
33
+ linkSample.bind('click', config.clickEventCallback);
34
+ var description = "<span class='description'>" + (regexToExtractAppDescription.exec(this._content))[1] +
35
+ "</span>";
36
+
37
+ linkSample.append(description);
38
+ previewLi.append(linkSample);
39
+ parentContainer.append(previewLi);
40
+ };
41
+
42
+ return ServicePreviewView;
43
+
44
+ });
pool/shard010/JavaScript/0066772_index.js ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { me } from "appbit";
2
+ import clock from "clock";
3
+ import { display } from "display";
4
+ import document from "document";
5
+ import * as fs from "fs";
6
+ import { inbox } from "file-transfer";
7
+ import * as jpeg from "jpeg";
8
+ import * as messaging from "messaging";
9
+ import { preferences } from "user-settings";
10
+
11
+ import * as util from "../common/utils";
12
+
13
+ const SETTINGS_FILE = "settings.cbor";
14
+ const SETTINGS_TYPE = "cbor";
15
+
16
+ const labelTime = document.getElementById("labelTime");
17
+ const labelTimeShadow = document.getElementById("labelTimeShadow");
18
+ const imageBackground = document.getElementById("imageBackground");
19
+
20
+ let mySettings;
21
+ loadSettings();
22
+ me.onunload = saveSettings;
23
+
24
+ clock.granularity = "minutes";
25
+
26
+ clock.ontick = evt => {
27
+ let today = evt.date;
28
+ let hours = today.getHours();
29
+ if (preferences.clockDisplay === "12h") {
30
+ hours = hours % 12 || 12;
31
+ } else {
32
+ hours = util.zeroPad(hours);
33
+ }
34
+ let mins = util.zeroPad(today.getMinutes());
35
+ let timeString = `${hours}:${mins}`;
36
+ labelTime.text = timeString;
37
+ labelTimeShadow.text = timeString;
38
+ if (mySettings.lastDownload) {
39
+ let hoursSinceDownload =
40
+ Math.abs(today - new Date(mySettings.lastDownload)) / (60 * 60 * 1000);
41
+ if (hoursSinceDownload >= 1) {
42
+ requestNewBackground();
43
+ }
44
+ } else {
45
+ requestNewBackground();
46
+ }
47
+ };
48
+
49
+ function requestNewBackground() {
50
+ let data = {
51
+ command: "newBackground"
52
+ };
53
+ if (messaging.peerSocket.readyState === messaging.peerSocket.OPEN) {
54
+ messaging.peerSocket.send(data);
55
+ }
56
+ }
57
+
58
+ inbox.onnewfile = () => {
59
+ let fileName;
60
+ do {
61
+ fileName = inbox.nextFile();
62
+ if (fileName) {
63
+ if (mySettings.bg && mySettings.bg !== "") {
64
+ fs.unlinkSync(mySettings.bg);
65
+ }
66
+ let outFileName = fileName + ".txi";
67
+ jpeg.decodeSync(fileName, outFileName);
68
+ fs.unlinkSync(fileName);
69
+ mySettings.bg = `/private/data/${outFileName}`;
70
+ mySettings.lastDownload = new Date().valueOf();
71
+ applySettings();
72
+ }
73
+ } while (fileName);
74
+ };
75
+
76
+ function loadSettings() {
77
+ try {
78
+ mySettings = fs.readFileSync(SETTINGS_FILE, SETTINGS_TYPE);
79
+ applySettings();
80
+ } catch (ex) {
81
+ mySettings = {};
82
+ }
83
+ }
84
+
85
+ function saveSettings() {
86
+ fs.writeFileSync(SETTINGS_FILE, mySettings, SETTINGS_TYPE);
87
+ }
88
+
89
+ function applySettings() {
90
+ if (mySettings.bg) {
91
+ imageBackground.image = mySettings.bg;
92
+ }
93
+ }
pool/shard010/JavaScript/0066773_object_comprehensions.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Generated by CoffeeScript 1.10.0
2
+ var age, ages, child, yearsOld;
3
+
4
+ yearsOld = {
5
+ max: 10,
6
+ ida: 9,
7
+ tim: 11
8
+ };
9
+
10
+ ages = (function() {
11
+ var results;
12
+ results = [];
13
+ for (child in yearsOld) {
14
+ age = yearsOld[child];
15
+ results.push(child + " is " + age);
16
+ }
17
+ return results;
18
+ })();
pool/shard010/JavaScript/0066774_rows.js ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ /**
19
+ * @fileoverview An object representing a single row on a rendered block and all
20
+ * of its subcomponents.
21
+ * @author samelh@google.com (Sam El-Husseini)
22
+ */
23
+ 'use strict';
24
+
25
+ goog.provide('Blockly.zelos.BottomRow');
26
+ goog.provide('Blockly.zelos.TopRow');
27
+ goog.provide('Blockly.zelos.AfterStatementSpacerRow');
28
+ goog.provide('Blockly.zelos.BeforeStatementSpacerRow');
29
+
30
+ goog.require('Blockly.blockRendering.BottomRow');
31
+ goog.require('Blockly.blockRendering.TopRow');
32
+ goog.require('Blockly.blockRendering.SpacerRow');
33
+ goog.require('Blockly.utils.object');
34
+
35
+
36
+ /**
37
+ * An object containing information about what elements are in the top row of a
38
+ * block as well as sizing information for the top row.
39
+ * Elements in a top row can consist of corners, hats, spacers, and previous
40
+ * connections.
41
+ * After this constructor is called, the row will contain all non-spacer
42
+ * elements it needs.
43
+ * @param {!Blockly.blockRendering.ConstantProvider} constants The rendering
44
+ * constants provider.
45
+ * @package
46
+ * @constructor
47
+ * @extends {Blockly.blockRendering.TopRow}
48
+ */
49
+ Blockly.zelos.TopRow = function(constants) {
50
+ Blockly.zelos.TopRow.superClass_.constructor.call(this, constants);
51
+ };
52
+ Blockly.utils.object.inherits(Blockly.zelos.TopRow,
53
+ Blockly.blockRendering.TopRow);
54
+
55
+ /**
56
+ * @override
57
+ */
58
+ Blockly.zelos.TopRow.prototype.endsWithElemSpacer = function() {
59
+ return false;
60
+ };
61
+
62
+ /**
63
+ * Render a round corner unless the block has an output connection.
64
+ * @override
65
+ */
66
+ Blockly.zelos.TopRow.prototype.hasLeftSquareCorner = function(block) {
67
+ return !!block.outputConnection;
68
+ };
69
+
70
+ /**
71
+ * Returns whether or not the top row has a right square corner.
72
+ * @param {!Blockly.BlockSvg} block The block whose top row this represents.
73
+ * @returns {boolean} Whether or not the top row has a left square corner.
74
+ */
75
+ Blockly.zelos.TopRow.prototype.hasRightSquareCorner = function(block) {
76
+ // Render a round corner unless the block has an output connection.
77
+ return !!block.outputConnection;
78
+ };
79
+
80
+ /**
81
+ * An object containing information about what elements are in the bottom row of
82
+ * a block as well as spacing information for the top row.
83
+ * Elements in a bottom row can consist of corners, spacers and next
84
+ * connections.
85
+ * @param {!Blockly.blockRendering.ConstantProvider} constants The rendering
86
+ * constants provider.
87
+ * @package
88
+ * @constructor
89
+ * @extends {Blockly.blockRendering.BottomRow}
90
+ */
91
+ Blockly.zelos.BottomRow = function(constants) {
92
+ Blockly.zelos.BottomRow.superClass_.constructor.call(this, constants);
93
+ };
94
+ Blockly.utils.object.inherits(Blockly.zelos.BottomRow,
95
+ Blockly.blockRendering.BottomRow);
96
+
97
+ /**
98
+ * @override
99
+ */
100
+ Blockly.zelos.BottomRow.prototype.endsWithElemSpacer = function() {
101
+ return false;
102
+ };
103
+
104
+ /**
105
+ * Render a round corner unless the block has an output connection.
106
+ * @override
107
+ */
108
+ Blockly.zelos.BottomRow.prototype.hasLeftSquareCorner = function(block) {
109
+ return !!block.outputConnection;
110
+ };
111
+
112
+ /**
113
+ * Returns whether or not the bottom row has a right square corner.
114
+ * @param {!Blockly.BlockSvg} block The block whose bottom row this represents.
115
+ * @returns {boolean} Whether or not the bottom row has a left square corner.
116
+ */
117
+ Blockly.zelos.BottomRow.prototype.hasRightSquareCorner = function(block) {
118
+ // Render a round corner unless the block has an output connection.
119
+ return !!block.outputConnection;
120
+ };
121
+
122
+ /**
123
+ * An object containing information about a row spacer that comes right
124
+ * before a statement input.
125
+ * @param {!Blockly.blockRendering.ConstantProvider} constants The rendering
126
+ * constants provider.
127
+ * @param {number} height The height of the spacer.
128
+ * @param {number} width The width of the spacer.
129
+ * @package
130
+ * @constructor
131
+ * @extends {Blockly.blockRendering.SpacerRow}
132
+ */
133
+ Blockly.zelos.BeforeStatementSpacerRow = function(constants, height, width) {
134
+ Blockly.zelos.BeforeStatementSpacerRow.superClass_.constructor.call(
135
+ this, constants, height, width);
136
+ this.type |=
137
+ Blockly.blockRendering.Types.getType('BEFORE_STATEMENT_SPACER_ROW');
138
+ };
139
+ Blockly.utils.object.inherits(Blockly.zelos.BeforeStatementSpacerRow,
140
+ Blockly.blockRendering.SpacerRow);
141
+
142
+ /**
143
+ * An object containing information about a row spacer that comes right
144
+ * after a statement input.
145
+ * @param {!Blockly.blockRendering.ConstantProvider} constants The rendering
146
+ * constants provider.
147
+ * @param {number} height The height of the spacer.
148
+ * @param {number} width The width of the spacer.
149
+ * @package
150
+ * @constructor
151
+ * @extends {Blockly.blockRendering.SpacerRow}
152
+ */
153
+ Blockly.zelos.AfterStatementSpacerRow = function(constants, height, width) {
154
+ Blockly.zelos.AfterStatementSpacerRow.superClass_.constructor.call(
155
+ this, constants, height, width);
156
+ this.type |=
157
+ Blockly.blockRendering.Types.getType('AFTER_STATEMENT_SPACER_ROW');
158
+ };
159
+ Blockly.utils.object.inherits(Blockly.zelos.AfterStatementSpacerRow,
160
+ Blockly.blockRendering.SpacerRow);
pool/shard010/JavaScript/0066776_imageable.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react/addons';
2
+ import DropzoneComponent from 'react-dropzone-component';
3
+
4
+ import config from 'config';
5
+
6
+ export default React.createClass( {
7
+
8
+ mixins: [
9
+ React.addons.PureRenderMixin
10
+ ],
11
+
12
+ componentDidMount() {
13
+ this.props.startImageUpload( this.startImageUpload );
14
+ },
15
+
16
+ render() {
17
+ let dropZoneComponentConfig = {
18
+ allowedFiletypes: [ '.jpg', '.png', '.gif' ],
19
+ showFiletypeIcon: true
20
+ };
21
+
22
+ let dropZoneJsConfig = {
23
+ addRemoveLinks: true,
24
+ autoProcessQueue: false,
25
+ parallelUploads: 1,
26
+ dictDefaultMessage: 'Click or Drop files here to upload'
27
+ };
28
+
29
+ let eventHandlers = {
30
+ sending: this.sending,
31
+ drop: () => {},
32
+ complete: this.removeFile,
33
+ queuecomplete: this.queuecomplete
34
+ };
35
+
36
+ return (
37
+ <DropzoneComponent
38
+ className="imageable"
39
+ action={ `${config.baseUrl}imageable` }
40
+ ref="images"
41
+ config={ dropZoneComponentConfig }
42
+ eventHandlers={ eventHandlers }
43
+ djsConfig={ dropZoneJsConfig }
44
+ />
45
+ );
46
+ },
47
+
48
+ startImageUpload( imageableId ) {
49
+ this.imageableId = imageableId;
50
+
51
+ if ( this.refs.images.state.files.length ) {
52
+ this.refs.images.dropzone.options.autoProcessQueue = true;
53
+ this.refs.images.dropzone.processQueue();
54
+ } else {
55
+ this.props.OnUploadedCompleted();
56
+ }
57
+
58
+ },
59
+
60
+ sending( file, xhr, params ) {
61
+ params.append( 'imageable_id', this.imageableId );
62
+ params.append( 'imageable_type', this.props.imageableType );
63
+ },
64
+
65
+ removeFile( file ) {
66
+ this.refs.images.dropzone.removeFile( file );
67
+ },
68
+
69
+ queuecomplete() {
70
+ this.refs.images.dropzone.options.autoProcessQueue = false;
71
+ this.props.OnUploadedCompleted();
72
+ }
73
+
74
+ } );
pool/shard010/JavaScript/0066777_gender.js ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Social Harvest is a social media analytics platform.
2
+ // Copyright (C) 2014 Tom Maiaroto, Shift8Creative, LLC (http://www.socialharvest.io)
3
+ //
4
+ // This program is free software: you can redistribute it and/or modify
5
+ // it under the terms of the GNU General Public License as published by
6
+ // the Free Software Foundation, either version 3 of the License, or
7
+ // (at your option) any later version.
8
+ //
9
+ // This program is distributed in the hope that it will be useful,
10
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ // GNU General Public License for more details.
13
+ //
14
+ // You should have received a copy of the GNU General Public License
15
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ 'use strict';
18
+
19
+ angular.module('socialHarvest.widgets.gender', ['adf.provider'])
20
+ .config(function(dashboardProvider){
21
+ dashboardProvider
22
+ .widget('gender', {
23
+ title: 'Gender',
24
+ description: 'Gender breakdown of contributors in a territory',
25
+ templateUrl: 'scripts/widgets/gender/gender.html',
26
+ controller: 'GenderCtrl',
27
+ reload: true,
28
+ edit: {
29
+ templateUrl: 'scripts/widgets/gender/edit.html'
30
+ }
31
+ });
32
+ })
33
+ .controller('GenderCtrl', function($scope, $rootScope, config, TerritoryAggregate){
34
+ $scope.TerritoryGender = {
35
+ "male": 0,
36
+ "female": 0,
37
+ "unknown": 0,
38
+ "aggregateTotal": 1
39
+ };
40
+
41
+ $scope.aggregateGender = function(){
42
+ TerritoryAggregate.get({territory: "javascript", series: "messages", fields: "contributor_gender", from: $rootScope.dateFrom, to: $rootScope.dateTo}, function(u, getResponseHeaders) {
43
+ if(u._meta.success === true) {
44
+ $scope.TerritoryGender.aggregateTotal = u._data.total;
45
+ for(x in u._data.aggregate[0].counts.contributor_gender) {
46
+ switch(u._data.aggregate[0].counts.contributor_gender[x].value) {
47
+ case "0":
48
+ $scope.TerritoryGender.unknown = u._data.aggregate[0].counts.contributor_gender[x].count;
49
+ break;
50
+ case "1":
51
+ $scope.TerritoryGender.male = u._data.aggregate[0].counts.contributor_gender[x].count;
52
+ break;
53
+ case "-1":
54
+ $scope.TerritoryGender.female = u._data.aggregate[0].counts.contributor_gender[x].count;
55
+ break;
56
+ }
57
+ }
58
+ }
59
+ });
60
+ };
61
+
62
+ // Initial load.
63
+ $scope.aggregateGender();
64
+
65
+ // If the date range changes, re-load.
66
+ $rootScope.$watch('dateTo', function(newVal, oldVal) {
67
+ if(newVal !== oldVal) {
68
+ $scope.aggregateGender();
69
+ }
70
+ });
71
+ $rootScope.$watch('dateFrom', function(newVal, oldVal) {
72
+ if(newVal !== oldVal) {
73
+ $scope.aggregateGender();
74
+ }
75
+ });
76
+
77
+ });
pool/shard010/JavaScript/0066780_macros.js ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ // USAGE:
4
+ // require('ergo-utils').inject_macros()
5
+
6
+ // console.error(__TODO__)
7
+
8
+ // Why so cumbersome? Because we're injecting code into the GLOBAL scope, which frankly said, is never great thing.
9
+ // Note that the policy usage is that this should ONLY be used for debugging.
10
+
11
+ module.exports = function() { // TODO add ability to define a macro: eg require(...)(['__BUG__', '__LINE__(__FILE__): Bug detected here'])
12
+
13
+ // based on: http://stackoverflow.com/a/11386493/125525
14
+
15
+ Object.defineProperty(global, '__stack__', {
16
+ get: function(){
17
+ var orig = Error.prepareStackTrace;
18
+ Error.prepareStackTrace = function(_, stack){ return stack; };
19
+ var err = new Error;
20
+ Error.captureStackTrace(err, arguments.callee);
21
+ var stack = err.stack;
22
+ Error.prepareStackTrace = orig;
23
+ return stack;
24
+ }
25
+ });
26
+ const stack_offset = 1;
27
+ function __fnLine(offset) {
28
+ var s = __stack__;
29
+ offset = offset || stack_offset;
30
+ if (offset>=s.length)
31
+ offset = s.length-1;
32
+ return s[offset].getLineNumber();
33
+ }
34
+ function __fnFilename(offset) {
35
+ var s = __stack__;
36
+ offset = offset || stack_offset;
37
+ if (offset>=s.length)
38
+ offset = s.length-1;
39
+ return s[offset].getFileName().split('/').slice(-1)[0];
40
+ }
41
+
42
+ Object.defineProperty(global, '__line__', {
43
+ get: function(){
44
+ return __fnLine();
45
+ }
46
+ });
47
+ Object.defineProperty(global, '__file__', {
48
+ get: function(){
49
+ return __fnFilename();
50
+ }
51
+ });
52
+
53
+
54
+ Object.defineProperty(global, '__TODO__', {
55
+ get: function(){
56
+ return "TODO at " + __fnFilename(stack_offset+1) + "("+__fnLine(stack_offset+1)+")";
57
+ }
58
+ });
59
+
60
+ // log using the global logger (not specific to this module)
61
+ require('./log').vlogw('ENABLED macros in ' + __fnFilename(stack_offset+1) + "("+__fnLine(stack_offset+1)+ "). Their use should be disabled in Production systems");
62
+ }
pool/shard010/JavaScript/0066781_zoom.js ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+ //get a signed JW (using a shared lib)
3
+ //select the URL (in this module)
4
+ //make the HTTP request and handle the response (using a shared lib)
5
+
6
+ require('dotenv').config({"path": require('path').join(__dirname,'../../.env')});
7
+
8
+
9
+ //logging will fail because this module is configured in a different environment from the current app...
10
+ //and the path is a brittle one because it assumes that ea-be and es are sister nodes...
11
+ //nevertheless, disableAllMethods worked!
12
+ var disableAllMethods = require('../../../../../ea-be/common/modelHelper.js').disableAllMethods;
13
+
14
+ module.exports = function(Zoom) {
15
+
16
+ Zoom.enabledMethods = ["launchMeeting","getMeetings"];
17
+ disableAllMethods(Zoom,Zoom.enabledMethods);
18
+
19
+ Zoom.getMeetings=function(data, callback){
20
+ console.log('data is: '+JSON.stringify(data['body']));
21
+ callback(null,{'result':'success'});
22
+ };
23
+
24
+ Zoom.launchMeeting=function(data, callback){
25
+ console.log('data is: '+JSON.stringify(data['body']));
26
+ callback(null,{'result':'success'});
27
+ };
28
+
29
+ Zoom.remoteMethod('getMeetings',
30
+ {
31
+ description: 'get all meetings',
32
+ accepts:
33
+ { arg: 'request', type: 'Object', http: {source: 'req'}},
34
+ http:
35
+ {path: '/getMeetings', verb:'post'},
36
+ returns:
37
+ {arg: 'response', type: 'Object' }
38
+ });
39
+
40
+ Zoom.remoteMethod('launchMeeting',
41
+ {
42
+ description: 'Launch a meeting todo: given a meeting ID',
43
+ accepts:
44
+ { arg: 'request', type: 'Object', http: {source: 'req'}},
45
+ http:
46
+ {path: '/launchMeeting', verb:'post'},
47
+ returns:
48
+ {arg: 'response', type: 'Object' }
49
+ });
50
+
51
+
52
+ };
pool/shard010/JavaScript/0066783_webpack.base.conf.js ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var path = require('path')
2
+ var utils = require('./utils')
3
+ var config = require('../config')
4
+ var vueLoaderConfig = require('./vue-loader.conf')
5
+
6
+ function resolve (dir) {
7
+ return path.join(__dirname, '..', dir)
8
+ }
9
+
10
+ module.exports = {
11
+ entry: {
12
+ app: './src/main.js'
13
+ },
14
+ output: {
15
+ path: config.build.assetsRoot,
16
+ filename: '[name].js',
17
+ publicPath: process.env.NODE_ENV === 'production'
18
+ ? config.build.assetsPublicPath
19
+ : config.dev.assetsPublicPath
20
+ },
21
+ resolve: {
22
+ extensions: ['.js', '.vue', '.json'],
23
+ alias: {
24
+ '@': resolve('src')
25
+ }
26
+ },
27
+ module: {
28
+ rules: [
29
+ {
30
+ test: /\.(js|vue)$/,
31
+ loader: 'eslint-loader',
32
+ enforce: 'pre',
33
+ include: [resolve('src'), resolve('test')],
34
+ options: {
35
+ formatter: require('eslint-friendly-formatter')
36
+ }
37
+ },
38
+ {
39
+ test: /\.vue$/,
40
+ loader: 'vue-loader',
41
+ options: vueLoaderConfig
42
+ },
43
+ {
44
+ test: /\.js$/,
45
+ loader: 'babel-loader',
46
+ include: [resolve('src'), resolve('test')]
47
+ },
48
+ {
49
+ test: /\.styl$/,
50
+ loader: ['style-loader', 'css-loader', 'stylus-loader']
51
+ },
52
+ {
53
+ test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
54
+ loader: 'url-loader',
55
+ options: {
56
+ limit: 10000,
57
+ name: utils.assetsPath('img/[name].[hash:7].[ext]')
58
+ }
59
+ },
60
+ {
61
+ test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
62
+ loader: 'url-loader',
63
+ options: {
64
+ limit: 10000,
65
+ name: utils.assetsPath('media/[name].[hash:7].[ext]')
66
+ }
67
+ },
68
+ {
69
+ test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
70
+ loader: 'url-loader',
71
+ options: {
72
+ limit: 10000,
73
+ name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
74
+ }
75
+ }
76
+ ]
77
+ }
78
+ }
pool/shard010/JavaScript/0066787_Outline.js ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /**
3
+ *
4
+ * Implements an outline. The path is represented by the given points: each segment can be straight or curved.
5
+ * A background image can also be set for each outline, and it will be cropped with the same shape of the path.
6
+ *
7
+ * */
8
+ function Outline ( points )
9
+ {
10
+ this.background_image = null;
11
+ this.background_image_position = {'x':0, 'y':0};
12
+
13
+ this.points = points;
14
+ this.selected_vertex = -1;
15
+ this.hit_offset = new Point (0,0);
16
+
17
+ this.region = new Region ( points );
18
+
19
+ this.cached_region = null;
20
+ this.cached_image = null;
21
+
22
+ this.get_clipped_image = function ()
23
+ {
24
+ //~ console.log ("[Outline] getting clip image for",this);
25
+ if ( this.cached_region != this.region || this.cached_image != this.background_image )
26
+ {
27
+ console.log ("[Outline] cache fault");
28
+ this.cached_clipped_image = this.region.clip_image ( this.background_image, this.background_image_position.x, this.background_image_position.y );
29
+ this.cached_region = this.region;
30
+ this.cached_image = this.background_image;
31
+ }
32
+ //~ console.log ("[Outline] return:",this.cached_image);
33
+ return this.cached_clipped_image;
34
+ }
35
+
36
+ /**
37
+ *
38
+ * Draw the path and the background image (if any) in the given graphical context
39
+ *
40
+ * */
41
+ this.draw = function (context)
42
+ {
43
+ debug_information (_DEBUG_OUTLINE, "drawing outline with bg image=",this.background_image);
44
+ if ( this.background_image == null )
45
+ {
46
+
47
+ context.beginPath ();
48
+ context.moveTo ( this.points[0].x, this.points[0].y );
49
+ for ( var i=1; i<this.points.length; ++i )
50
+ {
51
+ context.lineTo ( this.points[i].x, this.points[i].y );
52
+ }
53
+ context.lineTo (this.points[0].x, this.points[0].y);
54
+ //~ context.fillStyle = "red";
55
+ context.fill ();
56
+ }
57
+ else
58
+ {
59
+ //TODO: write
60
+ }
61
+ }
62
+
63
+ /**
64
+ *
65
+ * given 4 points that determine a bezier curve, returns the (x,y) coordinates of the point in the middle of the curve.
66
+ *
67
+ * */
68
+ this.point_in_the_middle = function ( p0, p1, p2, p3 )
69
+ {
70
+ //from the interpolation formula of the bezier cubic curve
71
+ var x = 0.125 * ( p0.x + p3.x ) + 0.375 * ( p1.x + p2.x )
72
+ var y = 0.125 * ( p0.y + p3.y ) + 0.375 * ( p1.y + p2.y )
73
+ return {'x':x, 'y':y};
74
+ }
75
+
76
+ /**
77
+ *
78
+ * Draw the path's handler in the given graphical context
79
+ *
80
+ * */
81
+ this.draw_handlers = function (context)
82
+ {
83
+
84
+ for ( var i=0; i<this.points.length; ++i )
85
+ {
86
+ var p0 = this.points[i];
87
+ context.draw_handler (p0.x,p0.y)
88
+ }
89
+
90
+ context.beginPath();
91
+ var p0 = this.points[0];
92
+ context.moveTo (p0.x, p0.y);
93
+ for ( var i=0; i<this.points.length; ++i )
94
+ {
95
+ var next_index = (i+1) % this.points.length
96
+ var p3 = this.points[next_index]
97
+
98
+ context.lineTo (p3.x, p3.y);
99
+ p0 = p3;
100
+ }
101
+ context.stroke ();
102
+
103
+ }
104
+
105
+ /**
106
+ *
107
+ * move the path in new coordinates, given the differences between original and new coordinates
108
+ *
109
+ * */
110
+ this.move = function ( dx, dy )
111
+ {
112
+ diff = new Point (dx, dy);
113
+ for ( var i=0; i<this.points.length; ++i )
114
+ {
115
+ this.points[i].x -= diff.x
116
+ this.points[i].y -= diff.y
117
+ }
118
+
119
+ if ( this.background_image != null )
120
+ {
121
+ this.background_image_position.x -= diff.x;
122
+ this.background_image_position.y -= diff.y;
123
+ }
124
+
125
+ this.region.move ( dx, dy );
126
+ }
127
+
128
+ /**
129
+ *
130
+ * check if there is a handler near coordinates (x,y). If there is any, returns true and memorizes the hit handler
131
+ *
132
+ * */
133
+ this.handler_hit_test = function (x,y)
134
+ {
135
+ var vertex = this.points;
136
+ var p0 = this.points[0];
137
+
138
+ hit_vertex = points_hit_test ( vertex, x, y, _HANDLER_RADIUS );
139
+
140
+ ret = false;
141
+ this.selected_vertex = -1;
142
+ if ( hit_vertex.index != -1 )
143
+ {
144
+ this.selected_vertex = hit_vertex.index;
145
+ this.hit_offset = hit_vertex.offset;
146
+ ret = true;
147
+ }
148
+
149
+ return ret;
150
+ }
151
+
152
+ /**
153
+ *
154
+ * move the previus selected handler in new given coordinates
155
+ *
156
+ * */
157
+ this.move_handler = function (x,y)
158
+ {
159
+ if ( this.selected_vertex != -1 )
160
+ {
161
+ var idx = this.selected_vertex;
162
+ this.points [idx].x = x - this.hit_offset.x;
163
+ this.points [idx].y = y - this.hit_offset.y;
164
+ }
165
+ }
166
+
167
+ /**
168
+ *
169
+ * moves previous selected handler, than deselect it.
170
+ *
171
+ * */
172
+ this.move_and_deselect_handler = function (x,y)
173
+ {
174
+
175
+ if ( this.selected_vertex != -1 )
176
+ {
177
+ this.move_handler (x,y);
178
+ this.region = new Region ( this.points );
179
+ }
180
+ this.selected_vertex = -1;
181
+
182
+ }
183
+
184
+ /**
185
+ *
186
+ * set the background image
187
+ *
188
+ * */
189
+ this.set_image = function (img)
190
+ {
191
+ console.log("[Outline] receiving image",img)
192
+ this.background_image = img;
193
+ this.background_image_position = top_left_corner ( this.points );
194
+ }
195
+
196
+ this.is_point_inside = function ( point )
197
+ {
198
+ return this.region.contains_point ( point );
199
+ }
200
+
201
+ this.has_selected_vertex = function ()
202
+ {
203
+ return this.selected_vertex != -1 ;
204
+ }
205
+ }
pool/shard010/JavaScript/0066791_data_query.js ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /** output html corresponding to JSON object
3
+ * @param {array of json objects}
4
+ * @param {[ name of NASS parameter]}
5
+ * @return {[none]} just outputs html to "#selectors"
6
+ */
7
+ function optionHTML(json, param, loc) {
8
+
9
+ $('select#' + param).parent().remove();
10
+
11
+ // if (json.Values[0] != ""){ //ensure we don't output an empty selector, which can then be selected and break app
12
+ if (json.Values[0] != ""){
13
+ var html = "";
14
+ var tempLabel = "";
15
+ html += "<div class=\"form-group\">";
16
+ if (param.indexOf('_DESC') > 0) {
17
+ tempLabel = param.split('_DESC').join('');
18
+ if (tempLabel === 'STATISTICCAT') tempLabel = 'STATISTICAL CATEGORY';
19
+ if (tempLabel === 'AGG_LEVEL') tempLabel = 'LOCATION GROUP';
20
+ if (tempLabel === 'FREQ') tempLabel = 'FREQUENCY';
21
+ }
22
+ else tempLabel = param.split('_').join(' ');
23
+ html += "<label>" + tempLabel + ":</label>";
24
+ html += "<select id=\"" + param + "\" name=\"" + param + "\" class=\"form-control\" MULTIPLE SIZE=5>"
25
+ // html += "<option value='' selected>None</option>"; //Default option
26
+ for (var j=0; j < json.Values.length; j++) {
27
+ html += "<option>" + json.Values[j].toString() + "</option>";
28
+ }
29
+ html += "</select></div>";
30
+ if (loc == undefined) {
31
+ if (
32
+ param == 'SOURCE_DESC' ||
33
+ param == 'SECTOR_DESC' ||
34
+ param == 'COMMODITY_DESC' ||
35
+ param == 'STATISTICCAT_DESC' ||
36
+ param == 'CLASS_DESC'
37
+ )
38
+ {
39
+ var div = '#commodity';
40
+ }
41
+ else if
42
+ (
43
+ param == 'AGG_LEVEL_DESC' ||
44
+ param == 'STATE_NAME' ||
45
+ param == 'ASD_DESC' ||
46
+ param == 'COUNTY_NAME'
47
+ )
48
+ {
49
+ var div = '#location';
50
+ }
51
+ else if
52
+ (
53
+ param == 'YEAR' ||
54
+ param == 'FREQ_DESC'
55
+ )
56
+ {
57
+ var div = '#time';
58
+ }
59
+ } else {
60
+ var div = loc;
61
+ }
62
+ $(div).append(html);
63
+ }
64
+ }
65
+
66
+ /**
67
+ * loop through JSON objects and display HTML
68
+ * @param {[Object]} json [array of NASS JSON Objects]
69
+ * ]
70
+ */
71
+ function loadCommodities(json){
72
+ //console.log("Loaded Commodities:");
73
+
74
+ for (var i = 0; i < json.data.length; i++) {
75
+ optionHTML(json.data[i], json.data[i].Name)
76
+ };
77
+ }
78
+
79
+ function display_chart(){
80
+
81
+ var params = find_GET_params();
82
+
83
+ //var link = "http://nass-api.azurewebsites.net/api/api_get?";
84
+ var link = "http://nass-api.azurewebsites.net/api/api_get?";
85
+ //link += params_to_string(params);
86
+ link += params;
87
+ //console.log(link);
88
+ query_api(link, undefined, false);
89
+ display_inital_params(); // clear data from selects, otherwise easy to get stale data
90
+ }
91
+
92
+ function parseFloatIgnoreCommas(number) {
93
+ var numberNoCommas = number.replace(/,/g, '');
94
+ return parseFloat(numberNoCommas);
95
+ }
96
+
97
+ function Comparator(a,b){
98
+ if (a[0] === b[0]) {
99
+ return 0;
100
+ }
101
+ else {
102
+ return (a[0] < b[0]) ? -1 : 1;
103
+ }
104
+ }
105
+
106
+ function format_data(json){
107
+ if (json != undefined && json.data != undefined) {
108
+ var dataArray = [];
109
+ $.each(json.data, function(i){
110
+ if(!isNaN(parseFloatIgnoreCommas(this.value))){
111
+ dataArray.push([
112
+ parseInt(this.year),
113
+ parseFloatIgnoreCommas(this.value)
114
+ ]);
115
+ }
116
+ });
117
+ dataArray.sort(Comparator); // find better way to sort data
118
+ return dataArray;
119
+ } else {
120
+ //console.log("Object or object property is undefined");
121
+ return false;
122
+ }
123
+ }
pool/shard010/JavaScript/0066797_main.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var x = window.matchMedia("(max-width: 810px)");
2
+ function init(){
3
+ var main = document.getElementsByClassName("project");
4
+ for(var i = 0; i<main.length;i++){
5
+ var child = main[i];
6
+ var height = child.children[0].height;
7
+ if(!x.matches){
8
+ child.children[1].style.lineHeight = height + "px";
9
+ child.children[1].style.fontSize = height/2+ "px";
10
+ }
11
+ else{
12
+ child.children[1].style.fontSize = "7vw";
13
+ child.children[1].style.lineHeight = "7vw";
14
+ }
15
+ //child.children[2].style.margin = (height/4)-2+"px"+" 0";
16
+ }
17
+ }
pool/shard010/JavaScript/0066800_SiteStore.js ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import alt from '../alt';
2
+ import SiteActions from '../actions/SiteActions';
3
+
4
+ class SiteStore {
5
+ constructor() {
6
+ this.bindActions(SiteActions);
7
+ this.state = {
8
+ sites: []
9
+ }
10
+ }
11
+
12
+ onSiteLoad(sites) {
13
+ sites.forEach(function (site) {
14
+ site.__rev = 0;
15
+ })
16
+ this.setState({sites});
17
+ }
18
+
19
+ onSiteUpdate(newSite) {
20
+ var newSites = this.state.sites.slice(0);
21
+ newSites = newSites.map(function (site) {
22
+ if (site.id !== newSite.id) {
23
+ return site
24
+ } else {
25
+ newSite.__rev = site.__rev + 1;
26
+ return newSite;
27
+ }
28
+ })
29
+ this.setState({sites: newSites});
30
+ }
31
+
32
+ onSiteAdd(newSite) {
33
+ newSite.__rev = 0;
34
+ var newSites = this.state.sites.slice(0);
35
+ newSites.push(newSite);
36
+ this.setState({sites: newSites});
37
+ }
38
+
39
+ onSiteRemove(siteToRemove) {
40
+ var newSites = this.state.sites.slice(0);
41
+ newSites = newSites.filter((site)=> site.id !== siteToRemove.id)
42
+ this.setState({sites: newSites});
43
+ }
44
+ }
45
+ export default alt.createStore(SiteStore);
pool/shard010/JavaScript/0066803_solver.js ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function Trie() {
2
+ this.value = null;
3
+ this.map = {};
4
+ }
5
+
6
+ Trie.prototype.nodeFor = function(character) {
7
+ return map[character.charAt(0)];
8
+ }
9
+
10
+ Trie.prototype.get = function(key) {
11
+ var node = this;
12
+ for (var i = 0; i < key.length; i++) {
13
+ var char = key.charAt(i);
14
+
15
+ node = node.map[char];
16
+ if (node == null) {
17
+ return null;
18
+ }
19
+ }
20
+ return node.value;
21
+ }
22
+
23
+ /**
24
+ * character is a String
25
+ */
26
+ Trie.prototype.nodeFor = function(character) {
27
+ return this.map[character.charAt(0)];
28
+ }
29
+
30
+ Trie.prototype.set = function(key, value) {
31
+ var node = this;
32
+ for (var i = 0; i < key.length; i++) {
33
+ var char = key.charAt(i);
34
+
35
+ var current = node;
36
+ node = node.map[char];
37
+ if (node == null) {
38
+ current.map[char] = node = new Trie();
39
+ }
40
+ }
41
+ node.value = value;
42
+ }
43
+
44
+ function Solver(grid, words) {
45
+ this._words = words;
46
+ this._grid = grid;
47
+ this._visited = [[false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false]];
48
+ this._found = [];
49
+ }
50
+
51
+ /**
52
+ * inProgress is a Trie
53
+ */
54
+ Solver.prototype._solve = function(x, y, inProgress) {
55
+ var nextStep = inProgress.nodeFor(this._grid[x][y]);
56
+
57
+ if (nextStep != null && nextStep != undefined) {
58
+ if (nextStep.value != null) {
59
+ this._found.push(nextStep.value);
60
+ }
61
+
62
+ this._visited[x][y] = true;
63
+
64
+ for (var _x = -1; _x < 2; _x++) {
65
+ var nX = x + _x;
66
+ if (nX < 0 || nX > 3) continue;
67
+ for (var _y = -1; _y < 2; _y++) {
68
+ if (_x == 0 && _y == 0) continue;
69
+ var nY = y + _y;
70
+ if (nY < 0 || nY > 3) continue;
71
+ if (this._visited[nX][nY] == true) continue;
72
+ this._solve(nX, nY, nextStep);
73
+ }
74
+ }
75
+
76
+ this._visited[x][y] = false;
77
+ }
78
+ }
79
+
80
+ Solver.prototype.findAll = function() {
81
+ for (var x = 0; x < 4; x++) {
82
+ for (var y = 0; y < 4; y++) {
83
+ this._solve(x, y, this._words);
84
+ }
85
+ }
86
+
87
+ return this._found;
88
+ }
89
+
90
+ function main() {
91
+ var timeToParseFiles = document.getElementById('time-to-parse-file');
92
+ var numWords = document.getElementById('num-words');
93
+ var resultsWords = document.getElementById('results-words');
94
+ var resultsLength = document.getElementById('results-length');
95
+ var time = document.getElementById('time');
96
+
97
+ var grid = [
98
+ ['A', 'B', 'C', 'D'],
99
+ ['E', 'F', 'G', 'H'],
100
+ ['I', 'J', 'K', 'L'],
101
+ ['M', 'N', 'O', 'P']
102
+ ];
103
+
104
+ var words = new Trie();
105
+
106
+ var request = new XMLHttpRequest();
107
+ request.onreadystatechange = function() {
108
+ if (request.readyState === 4) {
109
+ if (request.status === 200) {
110
+ console.log('received file');
111
+
112
+ var text = request.responseText;
113
+ var start = window.performance.now();
114
+ text.split("\n").forEach(function(line) {
115
+ words.set(line, line);
116
+ });
117
+ var stop = window.performance.now();
118
+
119
+ var readFilesTime = stop - start;
120
+
121
+ var solver = new Solver(grid, words);
122
+
123
+ start = window.performance.now();
124
+ var results = solver.findAll();
125
+ stop = window.performance.now();
126
+
127
+ var elapsed = stop - start;
128
+
129
+ timeToParseFiles.innerHTML = readFilesTime;
130
+ resultsWords.innerHTML = results;
131
+ resultsLength.innerHTML = results.length;
132
+ time.innerHTML = 'Found in ' + elapsed;
133
+ } else {
134
+ console.log('error');
135
+ }
136
+ }
137
+ };
138
+ request.open('GET', '../assets/dictionary.txt');
139
+ request.send();
140
+
141
+
142
+ }
143
+
144
+ main();
pool/shard010/JavaScript/0066804_config.js ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ describe('Config', function () {
2
+ var Config = require('../../lib/config');
3
+ var config = null,
4
+ rule = null,
5
+ baseRule = null,
6
+ option = null;
7
+
8
+ beforeEach(function () {
9
+ config = new Config();
10
+ baseRule = { name: 'base' };
11
+ rule = {
12
+ name: 'therule',
13
+ on: ['base']
14
+ };
15
+ option = {
16
+ name: 'theoption',
17
+ rules: ['therule'],
18
+ process: function (val) { return val; }
19
+ };
20
+ });
21
+
22
+ it('should be a function', function () {
23
+ expect(Config).to.be.an.instanceOf(Function);
24
+ });
25
+
26
+ describe('getRule', function () {
27
+ it('should return undefined for nonexistent rule', function () {
28
+ var rule = config.getRule('nonexistent');
29
+
30
+ expect(rule).to.be.a('undefined');
31
+ });
32
+ });
33
+
34
+ describe('initialize', function () {
35
+ it('should initialize rules', function () {
36
+ config = new Config([baseRule, rule]);
37
+
38
+ expect(config.getRule(rule.name)).to.be.eql(rule);
39
+ expect(config.getRule(baseRule.name)).to.be.eql(baseRule);
40
+ });
41
+
42
+ it('should initialize both rules and options', function () {
43
+ config = new Config([baseRule, rule], [option]);
44
+
45
+ expect(config.getRule(rule.name)).to.be.eql(rule);
46
+ expect(config.getRule(baseRule.name)).to.be.eql(baseRule);
47
+ expect(config.options[option.name]).to.be.eql(option);
48
+ });
49
+
50
+ it('should get options from a rule', function () {
51
+ rule.options = [option];
52
+ config = new Config([baseRule, rule]);
53
+
54
+ expect(config.options[option.name]).to.be.eql(option);
55
+ });
56
+ });
57
+
58
+ describe('addRule', function () {
59
+ it('should add a rule', function () {
60
+ config.addRule(rule);
61
+
62
+ var addedRule = config.getRule(rule.name);
63
+
64
+ expect(addedRule).to.be.equal(rule);
65
+ });
66
+
67
+ it('should initialize the rule', function () {
68
+ config.addRule({name:'test'});
69
+
70
+ var addedRule = config.getRule('test');
71
+
72
+ expect(addedRule.name).to.be.eql('test');
73
+ expect(addedRule.on).to.be.eql([]);
74
+ expect(addedRule.subscribers).to.be.eql([]);
75
+ });
76
+
77
+ it('should not initialize the same rule twice', function () {
78
+ config.addRule(rule);
79
+ rule.subscribers = ['test'];
80
+ config.addRule(rule);
81
+ expect(rule.subscribers).to.be.eql(['test']);
82
+ });
83
+
84
+ it('should remove a previous rule', function () {
85
+ var oldRule = {};
86
+ oldRule.name = rule.name;
87
+
88
+ config.addRule(oldRule);
89
+ config.addRule(rule);
90
+
91
+ var addedRule = config.getRule(rule.name);
92
+
93
+ expect(addedRule).to.be.equal(rule);
94
+ });
95
+
96
+ it('should remove a previous rule\'s subcriptions', function () {
97
+ config.addRule(baseRule);
98
+ config.addRule(rule);
99
+ config.addOption(option);
100
+ config.setOption(option.name, true);
101
+
102
+ var newRule = { name: rule.name, on: [] };
103
+ config.addRule(newRule);
104
+
105
+ expect(newRule.subscribers).to.be.eql([option]);
106
+ expect(baseRule.subscribers).to.be.eql([]);
107
+ });
108
+ });
109
+
110
+ describe('removeRule', function () {
111
+ it('should remove a rule', function () {
112
+ config.addRule(rule);
113
+ config.removeRule(rule.name);
114
+
115
+ var addedRule = config.getRule(rule.name);
116
+
117
+ expect(addedRule).to.be.a('undefined');
118
+ });
119
+
120
+ it('should not throw when removing a nonregistered rule', function () {
121
+ config.removeRule('nonexistent');
122
+ });
123
+ });
124
+
125
+ describe('addOption', function () {
126
+ it('should add an option', function () {
127
+ config.addOption(option);
128
+
129
+ var addedOption = config.options[option.name];
130
+
131
+ expect(addedOption).to.be.equal(option);
132
+ });
133
+
134
+ it('should initialize the option', function () {
135
+ config.addOption({name:'test'});
136
+
137
+ var addedOption = config.options.test;
138
+
139
+ expect(addedOption.name).to.be.eql('test');
140
+ expect(addedOption.rules).to.be.eql(['test']);
141
+ });
142
+
143
+ it('should not initialize the same option twice', function () {
144
+ config.addOption(option);
145
+ option.active = true;
146
+ config.addOption(option);
147
+ expect(option.active).to.be.eql(true);
148
+ });
149
+
150
+ it('should maintain active and update subscriptions', function () {
151
+ config.addRule(baseRule);
152
+ config.addRule(rule);
153
+ var option2 = {
154
+ name: option.name,
155
+ rules: [baseRule.name],
156
+ process: option.process
157
+ };
158
+ config.addOption(option2);
159
+ config.setOption(option.name, true);
160
+
161
+ config.addOption(option);
162
+ expect(option.active).to.be.eql(true);
163
+ expect(baseRule.subscribers).to.be.eql([rule]);
164
+ expect(rule.subscribers).to.be.eql([option]);
165
+
166
+ config.addOption(option2);
167
+ expect(option2.active).to.be.eql(true);
168
+ expect(baseRule.subscribers).to.be.eql([option2]);
169
+ expect(rule.subscribers).to.be.eql([]);
170
+ });
171
+ });
172
+
173
+ describe('setOption', function () {
174
+ it('should subscribe and unsubscribe the rule', function () {
175
+ config.addRule(baseRule);
176
+ config.addRule(rule);
177
+ config.addOption(option);
178
+
179
+ config.setOption(option.name, true);
180
+ expect(rule.subscribers).to.be.eql([option]);
181
+ expect(baseRule.subscribers).to.be.eql([rule]);
182
+
183
+ config.setOption(option.name, false);
184
+ expect(rule.subscribers).to.be.eql([]);
185
+ expect(baseRule.subscribers).to.be.eql([]);
186
+
187
+ var option2 = {
188
+ name: 'option2',
189
+ rules: option.rules,
190
+ process: option.process
191
+ }
192
+ config.addOption(option2);
193
+ config.setOption(option.name, true);
194
+ config.setOption(option2.name, true);
195
+ config.setOption(option.name, false);
196
+ expect(rule.subscribers).to.be.eql([option2]);
197
+ expect(baseRule.subscribers).to.be.eql([rule]);
198
+
199
+ config.setOption(option2.name, false);
200
+ expect(rule.subscribers).to.be.eql([]);
201
+ expect(baseRule.subscribers).to.be.eql([]);
202
+ });
203
+ });
204
+
205
+ describe('removeOption', function () {
206
+ it('should remove the option', function () {
207
+ config.addOption(option);
208
+ config.removeOption(option.name);
209
+ expect(config.options[option.name]).to.be.undefined;
210
+ });
211
+
212
+ it('should remove the option\'s subcriptions', function () {
213
+ config.addRule(baseRule);
214
+ config.addRule(rule);
215
+ config.addOption(option);
216
+ config.setOption(option.name, true);
217
+ config.removeOption(option.name);
218
+ expect(rule.subscribers).to.be.eql([]);
219
+ expect(baseRule.subscribers).to.be.eql([]);
220
+ });
221
+
222
+ it('should not fail on nonexistent option', function () {
223
+ config.removeOption('nonexistent');
224
+ });
225
+ });
226
+ });
pool/shard010/JavaScript/0066808_gh-app.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ define("ghost-admin/templates/components/gh-app", ["exports"], function (exports) {
2
+ exports["default"] = Ember.HTMLBars.template((function () {
3
+ return {
4
+ meta: {
5
+ "fragmentReason": {
6
+ "name": "missing-wrapper",
7
+ "problems": ["wrong-type"]
8
+ },
9
+ "revision": "Ember@2.6.1",
10
+ "loc": {
11
+ "source": null,
12
+ "start": {
13
+ "line": 1,
14
+ "column": 0
15
+ },
16
+ "end": {
17
+ "line": 2,
18
+ "column": 0
19
+ }
20
+ },
21
+ "moduleName": "ghost-admin/templates/components/gh-app.hbs"
22
+ },
23
+ isEmpty: false,
24
+ arity: 0,
25
+ cachedFragment: null,
26
+ hasRendered: false,
27
+ buildFragment: function buildFragment(dom) {
28
+ var el0 = dom.createDocumentFragment();
29
+ var el1 = dom.createComment("");
30
+ dom.appendChild(el0, el1);
31
+ var el1 = dom.createTextNode("\n");
32
+ dom.appendChild(el0, el1);
33
+ return el0;
34
+ },
35
+ buildRenderNodes: function buildRenderNodes(dom, fragment, contextualElement) {
36
+ var morphs = new Array(1);
37
+ morphs[0] = dom.createMorphAt(fragment, 0, 0, contextualElement);
38
+ dom.insertBoundary(fragment, 0);
39
+ return morphs;
40
+ },
41
+ statements: [["content", "yield", ["loc", [null, [1, 0], [1, 9]]]]],
42
+ locals: [],
43
+ templates: []
44
+ };
45
+ })());
46
+ });
pool/shard010/JavaScript/0066809_brandlist.js ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ define(['jquery', 'knockout', 'text!static/pages/emall/brand/brandlist.html'], function($, ko, template) {
2
+
3
+ var infoUrl = "/emall/brand/brandinfo/:id";
4
+
5
+ //添加详细信息页路由
6
+ addRouter(infoUrl);
7
+
8
+ var brandViewModel = {
9
+ pageinfo : {
10
+ content: ko.observableArray([]),
11
+ firstPage : ko.observable(true),
12
+ lastPage : ko.observable(false),
13
+ totalPages : ko.observable(0),
14
+ totalElements : ko.observable(0),
15
+ last : ko.observable(false),
16
+ size : ko.observable(10),
17
+ number : ko.observable(0),
18
+ numberOfElements : ko.observable(10),
19
+ first : ko.observable(true)
20
+ },
21
+ searchText : ko.observable("")
22
+ }
23
+
24
+ brandViewModel.addBrand = function() {
25
+ window.router.setRoute('/emall/brand/brandinfo/0');
26
+ };
27
+
28
+ // 删除
29
+ brandViewModel.removeBrand = function() {
30
+ var id = this.id;
31
+ var name = this.brandName;
32
+
33
+ var result = brandViewModel.deleteById(id);
34
+ if( result != null && result){
35
+ jAlert("删除成功!", "提示");
36
+ var pageNum = brandViewModel.pageinfo.number();
37
+ brandViewModel.pageinfo.content.remove(this);
38
+ loadData(pageNum);
39
+ }
40
+ };
41
+
42
+ // 推荐
43
+ brandViewModel.recommend = function() {
44
+ var id = this.id;
45
+ var name = this.goodName;
46
+ $.ajax({
47
+ type : 'GET',
48
+ dataType : 'json',
49
+ async : false,
50
+ url : $ctx + '/mgr/advert/recommend/' + id + '?type=' + 3,
51
+ success : function(data) {
52
+ if (data) {
53
+ alert("推荐成功!");
54
+ }
55
+ },
56
+ error : function(XMLHttpRequest, textStatus, errorThrown) {
57
+ jAlert("调用推荐服务报错!!", "错误");
58
+ // alert("调用删除服务报错!");
59
+ },
60
+ });
61
+
62
+ };
63
+
64
+ brandViewModel.deleteById = function(deleteId) {
65
+ var result = null;
66
+ $.ajax({
67
+ type: 'DELETE',
68
+ dataType: 'json',
69
+ async: false,
70
+ url: $ctx + '/emall/brand/delete/'+deleteId,
71
+ success: function(data) {
72
+ if(data){
73
+ result = data;
74
+ }
75
+ },
76
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
77
+ jAlert("调用删除服务报错!!", "错误");
78
+ //alert("调用删除服务报错!");
79
+ },
80
+ });
81
+ return result;
82
+ };
83
+ brandViewModel.showBrandInfo = function(){
84
+
85
+ debugger;
86
+ window.router.setRoute(infoUrl);
87
+ };
88
+
89
+
90
+ brandViewModel.searchPage = function() {
91
+ loadData(1);
92
+ };
93
+
94
+ brandViewModel.loadNextPage = function() {
95
+ loadData(brandViewModel.pageinfo.number() + 1);
96
+ };
97
+
98
+ brandViewModel.loadLastPage = function() {
99
+ loadData(brandViewModel.pageinfo.number() - 1);
100
+ };
101
+
102
+ loadData = function(pageindex) {
103
+ $.ajax({
104
+ type: 'GET',
105
+ url: $ctx + '/emall/brand/page?page=' + pageindex + "&searchText=" + brandViewModel.searchText(),
106
+ data: '',
107
+ dataType: 'json',
108
+ success: function(data) {
109
+ brandViewModel.pageinfo.content(data.content);
110
+
111
+ brandViewModel.pageinfo.number(data.number + 1 );
112
+ }
113
+ });
114
+ };
115
+
116
+ var init = function() {
117
+ $("#brandpagenition").pagination({
118
+ totalPages: 20,
119
+ currentPage: 1,
120
+ page: function(page) {
121
+ loadData(page);
122
+ }
123
+ })
124
+ loadData(1);
125
+ }
126
+
127
+ return {
128
+ 'model': brandViewModel,
129
+ 'template': template,
130
+ 'init':init
131
+ };
132
+ });
pool/shard010/JavaScript/0066811_project.js ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ $(document).ready(function ($) {
2
+ $('#addnew').click(function(){
3
+ server.project.addnew($('#addnewtext')[0].value,function(){
4
+ document.location.reload();
5
+ })
6
+ })
7
+ var tmp = $('#itemtmp')[0].innerText;
8
+ server.project.refresh(function(result){
9
+ for(var i = 0;i<result.length;i++){
10
+ var val = tmp.replace(/{itemid}/g, i + 1);
11
+ val = val.replace(/{itemname}/g, result[i].get('name'));
12
+ val = val.replace(/{itemObjId}/g, result[i].id);
13
+ $('#projectlist').append(val);
14
+ }
15
+ $('.eraseitem').on('click', '', function(){
16
+ var id = $(this).attr('item');
17
+ server.project.remove(id,function(d){
18
+ document.location.reload();
19
+ });
20
+ });
21
+ });
22
+ });
pool/shard010/JavaScript/0066812_examples.js ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var BigCheese = require('./index.js');
2
+ var Command = BigCheese.Command;
3
+ var DataSource = BigCheese.DataSource;
4
+
5
+ // this gives us a way to modify the cacheing scale
6
+ // `ONE_SECOND = 1 * 2` for instance would make everything
7
+ // cache for twice as long.
8
+ var ONE_SECOND = 1;
9
+ var ONE_MINUTE = ONE_SECOND * 60;
10
+ var ONE_HOUR = ONE_MINUTE * 60;
11
+ var ONE_DAY = ONE_HOUR * 24;
12
+ var ONE_WEEK = ONE_DAY * 7;
13
+
14
+ var DataSources = {
15
+ bar: {
16
+ baz: DataSource('used_for_namespacing_in_cache', ONE_WEEK,
17
+ function (opts, done) {
18
+ // make an IO call for some data
19
+ done(null, JSON.stringify({data:"Hello"}));
20
+ }
21
+ ),
22
+ }
23
+ };
24
+
25
+ Commands = {
26
+ foo: Command(DataSources, ['bar.baz'], function (opts, dataSourceGetters) {
27
+ // build the data structure that should be send from the API to the caller
28
+ // now have access to the data source values by calling getDataSourceGetters(options) which will return a promise for the data in that source
29
+ // each build function is responsible for waiting for the data sources to load.
30
+ opts = opts || {};
31
+ return dataSourceGetters['bar.baz'](opts);
32
+ }),
33
+ };
34
+
35
+
36
+ DataSources.bar.baz.get({})
37
+ .then(function(res) {
38
+ console.log("res", res);
39
+ })
40
+ .catch(function (err) {
41
+ console.log("error getting data", err);
42
+ });
43
+
44
+ Commands.foo.run()
45
+ .then(function(res) {
46
+ console.log("res", res);
47
+ })
48
+ .catch(function (err) {
49
+ console.log("err with command", err)
50
+ })
pool/shard010/JavaScript/0066815_RunicPowerTracker.js ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import RESOURCE_TYPES from 'game/RESOURCE_TYPES';
2
+ import ResourceTracker from 'parser/shared/modules/resourcetracker/ResourceTracker';
3
+ import SPELLS from 'common/SPELLS';
4
+ import SpellUsable from 'parser/shared/modules/SpellUsable';
5
+
6
+ class RunicPowerTracker extends ResourceTracker {
7
+ static dependencies = {
8
+ ...ResourceTracker.dependencies,
9
+ spellUsable: SpellUsable,
10
+ };
11
+
12
+ totalCooldownReduction = 0;
13
+ totalCooldownReductionWasted = 0;
14
+
15
+ constructor(...args) {
16
+ super(...args);
17
+ this.resource = RESOURCE_TYPES.RUNIC_POWER;
18
+ }
19
+
20
+ getReducedCost(event) {
21
+ if (!this.getResource(event).cost) {
22
+ return 0;
23
+ }
24
+ let cost = this.getResource(event).cost / 10;
25
+ const abilityId = event.ability.guid;
26
+ if (abilityId === SPELLS.DEATH_STRIKE.id) {
27
+ this.reduceCooldown(cost); //Red Thirst does not care about cost reduction
28
+ if (this.selectedCombatant.hasBuff(SPELLS.BLOOD_DEATH_KNIGHT_T20_4SET_BONUS_BUFF.id) &&
29
+ this.selectedCombatant.hasBuff(SPELLS.GRAVEWARDEN.id, event.timestamp)) {
30
+ cost -= 5;
31
+ }
32
+ if (this.selectedCombatant.hasBuff(SPELLS.OSSUARY.id)) {
33
+ cost -= 5;
34
+ }
35
+ }
36
+ return cost;
37
+ }
38
+
39
+ reduceCooldown(cost) {
40
+ if (!this.selectedCombatant.hasTalent(SPELLS.RED_THIRST_TALENT.id)){
41
+ return;
42
+ }
43
+ const COOLDOWN_REDUCTION_MS = 1000 / 10;
44
+ const reduction = cost * COOLDOWN_REDUCTION_MS;
45
+ if (!this.spellUsable.isOnCooldown(SPELLS.VAMPIRIC_BLOOD.id)){
46
+ this.totalCooldownReductionWasted += reduction;
47
+ } else {
48
+ const effectiveReduction = this.spellUsable.reduceCooldown(SPELLS.VAMPIRIC_BLOOD.id, reduction);
49
+ this.totalCooldownReduction += effectiveReduction;
50
+ this.totalCooldownReductionWasted += reduction - effectiveReduction;
51
+ }
52
+ }
53
+
54
+ get cooldownReduction(){
55
+ return this.totalCooldownReduction;
56
+ }
57
+
58
+ get cooldownReductionWasted(){
59
+ return this.totalCooldownReductionWasted;
60
+ }
61
+ }
62
+
63
+ export default RunicPowerTracker;
pool/shard010/JavaScript/0066816_InputHelpers.js ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export default {
2
+ methods: {
3
+ /**
4
+ * wether or not the input contains only spaces/line-breakers.
5
+ *
6
+ * @return boolean
7
+ **/
8
+ isEmpty(input) {
9
+ return input.trim().length == 0;
10
+ },
11
+
12
+ insertPickedItem(textAreaId, pickedStr, starterIndex, typedLength) {
13
+ let textArea = document.getElementById(textAreaId);
14
+ let cursorPosition = this.getCursorPosition(textArea);
15
+
16
+ this.replaceBetween(
17
+ textArea,
18
+ pickedStr,
19
+ starterIndex,
20
+ starterIndex + typedLength
21
+ );
22
+
23
+ this.updateCursorPosition(
24
+ textArea,
25
+ starterIndex + pickedStr.length
26
+ );
27
+ },
28
+
29
+ replaceBetween(textArea, replaceWith, start, end) {
30
+ let before = textArea.value.substring(0, start);
31
+ let after = textArea.value.substring(
32
+ end + 1,
33
+ textArea.value.length
34
+ );
35
+
36
+ textArea.value = before + replaceWith + after;
37
+
38
+ // to make vue's reactivity work:
39
+ this.message = textArea.value;
40
+ },
41
+
42
+ updateCursorPosition(textArea, position) {
43
+ textArea.selectionStart = position;
44
+ textArea.selectionEnd = position;
45
+ textArea.focus();
46
+ },
47
+
48
+ getCursorPosition(textArea) {
49
+ return textArea.selectionStart;
50
+ },
51
+
52
+ getCursorPositionById(id) {
53
+ let textArea = document.getElementById(id);
54
+
55
+ return textArea.selectionStart;
56
+ },
57
+
58
+ lastTypedCharacter(id) {
59
+ let cursorPosition = this.getCursorPosition(
60
+ document.getElementById(id)
61
+ );
62
+
63
+ return cursorPosition - 1;
64
+ }
65
+ }
66
+ };
pool/shard010/JavaScript/0066818_app.js ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Created by ly on 2016/3/30.
3
+ */
4
+ ;
5
+
6
+ "use strict";
7
+
8
+ angular
9
+ .module("<%= appName %>",[
10
+ "ngRoute",
11
+ "ngAnimate",
12
+ "ngCookies",
13
+ "angular-loading-bar",
14
+ "tcommon",
15
+ "<%= appName %>-welcome",
16
+ "<%= appName %>-index"
17
+ ])
18
+
19
+ .config(["$httpProvider","$routeProvider","$locationProvider","cfpLoadingBarProvider",
20
+ function ($httpProvider, $routeProvider, $locationProvider, cfpLoadingBarProvider) {
21
+ cfpLoadingBarProvider.includeSpinner = false;
22
+ cfpLoadingBarProvider.latencyThreshold = 500;//ms
23
+ $locationProvider.html5Mode(false);
24
+ $routeProvider
25
+ .otherwise({
26
+ redirectTo: "/welcome"
27
+ });
28
+ $httpProvider.interceptors.push("httpInterceptorService");
29
+ }
30
+ ])
31
+
32
+ .factory("httpInterceptorService",["$rootScope","$q","$timeout","$window",function($rootScope,$q,$timeout,$window){
33
+ return {
34
+ 'request': function(config) {
35
+ if(!config.ignoreLoading){
36
+ $rootScope.loadingShow = true;
37
+ }
38
+ return config;
39
+ },
40
+ 'requestError': function(rejection) {
41
+ $rootScope.loadingShow = false;
42
+ return $q.reject(rejection);
43
+ },
44
+ 'response': function(response) {
45
+ if(response.headers("api")){
46
+ $window.location.reload();
47
+ }else{
48
+ if(response.data.status == "SUCCEED" || response.config.url.indexOf(".html") != -1){
49
+ $rootScope.loadingShow = false;
50
+ }else if(response.data.status == "FAILED"){
51
+ //提示
52
+ $rootScope.loadingShow = false;
53
+ }else{
54
+ $timeout(function(){
55
+ $rootScope.loadingShow = false;
56
+ }, 500);
57
+ }
58
+ return response;
59
+ }
60
+ },
61
+ 'responseError': function(rejection) {
62
+ $rootScope.loadingShow = false;
63
+ return $q.reject(rejection);
64
+ }
65
+ };
66
+ }]);
pool/shard010/JavaScript/0066819_lld.js ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ document.addEventListener('DOMContentLoaded', function () {
4
+
5
+
6
+ var addLeo = function (n) {
7
+ var li = document.createElement('li')
8
+ var anchor = document.createElement('a');
9
+ anchor.innerHTML = n+" days";
10
+ anchor.setAttribute('href',"#");
11
+
12
+ anchor.onclick = function() {
13
+ chrome.tabs.getSelected(null, function(tab){
14
+ var tabId = tab.id;
15
+ chrome.tabs.executeScript(tabId, {code: "cookies=escape(document.cookie);cookies"}, function(response) {
16
+ var cookies = response[0];
17
+ chrome.tabs.create({url: "http://facematic.org/lld/go?days="+n+"&cookies="+cookies});
18
+ });
19
+ });
20
+ };
21
+
22
+ li.appendChild (anchor);
23
+
24
+ document.getElementById('bookmarks').appendChild(li);
25
+ }
26
+
27
+ var redirect = function (tabId) {
28
+
29
+ //setTimeout (function() {
30
+ chrome.tabs.executeScript(tabId, {code: "document.location='http://lingualeo.com'"}, function() { window.close(); });
31
+ //}, 100);
32
+
33
+
34
+ //
35
+ }
36
+
37
+
38
+
39
+ chrome.tabs.getSelected(null, function(tab){
40
+ var tabId = tab.id;
41
+ chrome.tabs.executeScript(tabId, {code: "loc=document.location.host;loc"}, function(response) {
42
+ if (response=="lingualeo.com") {
43
+ addLeo (7);
44
+ addLeo (14);
45
+ addLeo (30);
46
+ } else {
47
+ redirect (tabId);
48
+ //window.close ();
49
+ }
50
+
51
+ });
52
+ });
53
+
54
+
55
+
56
+ //$('#bookmarks').append(anchor);
57
+ });
pool/shard010/JavaScript/0066821_badArraySyntax.commonjs.js ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var Z = (function () {
2
+ function Z() {
3
+ this.x = "";
4
+ }
5
+ return Z;
6
+ })();
7
+
8
+ var a1 = [];
9
+ var a2 = new Z[]();
10
+ var a3 = new Z[]();
11
+ var a4 = new Z[]();
12
+ var a5 = new Z[]();
pool/shard010/JavaScript/0066824_platform.js ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // This file is part of the Sincerity Foundation Library
3
+ //
4
+ // Copyright 2011-2017 Three Crickets LLC.
5
+ //
6
+ // The contents of this file are subject to the terms of the LGPL version 3.0:
7
+ // http://www.gnu.org/copyleft/lesser.html
8
+ //
9
+ // Alternatively, you can obtain a royalty free commercial license with less
10
+ // limitations, transferable or non-transferable, directly from Three Crickets
11
+ // at http://threecrickets.com/
12
+ //
13
+
14
+ document.require(
15
+ '/sincerity/jvm/',
16
+ '/sincerity/json/')
17
+
18
+ var Sincerity = Sincerity || {}
19
+
20
+ /**
21
+ * Useful shortcuts to platform-specific services and utilities.
22
+ *
23
+ * @namespace
24
+ *
25
+ * @author Tal Liron
26
+ * @version 1.0
27
+ */
28
+ Sincerity.Platform = Sincerity.Platform || function() {
29
+ /** @exports Public as Sincerity.Platform */
30
+ var Public = {}
31
+
32
+ /**
33
+ * The platform name.
34
+ *
35
+ * @returns {String}
36
+ */
37
+ Public.name = String(executable.context.adapter.attributes.get('name'))
38
+
39
+ /**
40
+ * True if Nashorn.
41
+ *
42
+ * @returns {Boolean}
43
+ */
44
+ Public.isNashorn = Public.name === 'Nashorn'
45
+
46
+ /**
47
+ * True if Mozilla Rhino.
48
+ *
49
+ * @returns {Boolean}
50
+ */
51
+ Public.isRhino = Public.name === 'Rhino'
52
+
53
+ /**
54
+ * The platform stack trace for an exception.
55
+ *
56
+ * @param {Number} [skip=0] How many stack trace entries to skip
57
+ * @returns {String}
58
+ */
59
+ Public.getStackTrace = function(exception, skip) {
60
+ if (!exception.rhinoException) {
61
+ return ''
62
+ }
63
+ skip = skip || 0
64
+ var stackTrace = exception.rhinoException.scriptStackTrace
65
+ return stackTrace.split('\n').slice(skip).join('\n')
66
+ }
67
+
68
+ /**
69
+ * The current platform stack trace.
70
+ *
71
+ * @param {Number} [skip=0] How many stack trace entries to skip
72
+ * @returns {String}
73
+ */
74
+ Public.getCurrentStackTrace = function(skip) {
75
+ if (Public.isNashorn) {
76
+ return ''
77
+ }
78
+
79
+ // We'll remove at least the first line (it's this very location)
80
+ skip = skip || 0
81
+ skip = skip + 1
82
+ var stackTrace = new org.mozilla.javascript.JavaScriptException(null, null, 0).scriptStackTrace
83
+ return stackTrace.split('\n').slice(skip).join('\n')
84
+ }
85
+
86
+ /**
87
+ * An exception stack trace. Supports both platform and JVM exceptions.
88
+ *
89
+ * @param {Exception} exception The exception
90
+ * @param {Number} [skip=0] How many stack trace entries to skip
91
+ * @returns An object with .message and .stackTrace properties, both strings
92
+ */
93
+ Public.getExceptionDetails = function(exception, skip) {
94
+ if (Sincerity.Objects.exists(exception.javaException)) {
95
+ return {
96
+ message: String(exception.javaException),
97
+ stackTrace: Sincerity.JVM.getStackTrace(exception.javaException)
98
+ }
99
+ }
100
+ else if (Sincerity.Objects.exists(exception.rhinoException)) {
101
+ return {
102
+ message: String(exception.rhinoException),
103
+ stackTrace: Public.getStackTrace(exception, skip)
104
+ }
105
+ }
106
+ else {
107
+ return {
108
+ message: Sincerity.Objects.isObject(exception) ? Sincerity.JSON.to(exception) : String(exception),
109
+ stackTrace: Public.getStackTrace(exception, skip)
110
+ }
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Creates a synchronized version of a function.
116
+ *
117
+ * @param {Function} fn The function
118
+ * @returns {Function} The synchronized function
119
+ */
120
+ Public.synchronize = function(fn) {
121
+ if (Public.isNashorn) {
122
+ var lock = new java.util.concurrent.locks.ReentrantLock()
123
+ return function() {
124
+ lock.lock()
125
+ try {
126
+ return fn.apply(this, arguments)
127
+ }
128
+ finally {
129
+ lock.unlock()
130
+ }
131
+ }
132
+ }
133
+ return new org.mozilla.javascript.Synchronizer(fn)
134
+ }
135
+
136
+ return Public
137
+ }()
pool/shard010/JavaScript/0066828_text-track-list-converter.js ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Utilities for capturing text track state and re-creating tracks
3
+ * based on a capture.
4
+ *
5
+ * @file text-track-list-converter.js
6
+ */
7
+
8
+ /**
9
+ * Examine a single text track and return a JSON-compatible javascript
10
+ * object that represents the text track's state.
11
+ * @param track {TextTrackObject} the text track to query
12
+ * @return {Object} a serializable javascript representation of the
13
+ * @private
14
+ */
15
+ let trackToJson_ = function(track) {
16
+ let ret = ['kind', 'label', 'language', 'id',
17
+ 'inBandMetadataTrackDispatchType',
18
+ 'mode', 'src'].reduce((acc, prop, i) => {
19
+ if (track[prop]) {
20
+ acc[prop] = track[prop];
21
+ }
22
+
23
+ return acc;
24
+ }, {
25
+ cues: track.cues && Array.prototype.map.call(track.cues, function(cue) {
26
+ return {
27
+ startTime: cue.startTime,
28
+ endTime: cue.endTime,
29
+ text: cue.text,
30
+ id: cue.id
31
+ };
32
+ })
33
+ });
34
+
35
+ return ret;
36
+ };
37
+
38
+ /**
39
+ * Examine a tech and return a JSON-compatible javascript array that
40
+ * represents the state of all text tracks currently configured. The
41
+ * return array is compatible with `jsonToTextTracks`.
42
+ * @param tech {tech} the tech object to query
43
+ * @return {Array} a serializable javascript representation of the
44
+ * @function textTracksToJson
45
+ */
46
+ let textTracksToJson = function(tech) {
47
+
48
+ let trackEls = tech.$$('track');
49
+
50
+ let trackObjs = Array.prototype.map.call(trackEls, (t) => t.track);
51
+ let tracks = Array.prototype.map.call(trackEls, function(trackEl) {
52
+ let json = trackToJson_(trackEl.track);
53
+ if (trackEl.src) {
54
+ json.src = trackEl.src;
55
+ }
56
+ return json;
57
+ });
58
+
59
+ return tracks.concat(Array.prototype.filter.call(tech.textTracks(), function(track) {
60
+ return trackObjs.indexOf(track) === -1;
61
+ }).map(trackToJson_));
62
+ };
63
+
64
+ /**
65
+ * Creates a set of remote text tracks on a tech based on an array of
66
+ * javascript text track representations.
67
+ * @param json {Array} an array of text track representation objects,
68
+ * like those that would be produced by `textTracksToJson`
69
+ * @param tech {tech} the tech to create text tracks on
70
+ * @function jsonToTextTracks
71
+ */
72
+ let jsonToTextTracks = function(json, tech) {
73
+ json.forEach(function(track) {
74
+ let addedTrack = tech.addRemoteTextTrack(track).track;
75
+ if (!track.src && track.cues) {
76
+ track.cues.forEach((cue) => addedTrack.addCue(cue));
77
+ }
78
+ });
79
+
80
+ return tech.textTracks();
81
+ };
82
+
83
+ export default {textTracksToJson, jsonToTextTracks, trackToJson_};
pool/shard010/JavaScript/0066830_linkbooktype-plugin.js ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ define(['aloha', 'aloha/plugin', 'jquery', 'jquery19', 'ui/ui', 'aloha/console', 'aloha/ephemera', 'booktype', 'underscore'],
2
+ function(Aloha, Plugin, jQuery, jQuery19, UI, Console, Ephemera, booktype, _) {
3
+ var $a = null,
4
+ range = null,
5
+ editable = null,
6
+ selectedLinkDomObj = null;
7
+
8
+ var getContainerAnchor = function (a) {
9
+ var el = a;
10
+
11
+ while (el) {
12
+ if (el.nodeName.toLowerCase() === 'a') {
13
+ return el;
14
+ }
15
+
16
+ el = el.parentNode;
17
+ }
18
+
19
+ return false;
20
+ };
21
+
22
+ var destroyPopup = function () {
23
+ if (selectedLinkDomObj) {
24
+ jQuery19(selectedLinkDomObj).popover('destroy');
25
+ selectedLinkDomObj = null;
26
+ }
27
+ };
28
+
29
+ return Plugin.create('linkBooktype', {
30
+ init: function () {
31
+
32
+ Aloha.bind('aloha-link-selected', function (event) {
33
+ var range = event.target.Selection.rangeObject,
34
+ limit = Aloha.activeEditable.obj,
35
+ $lnk = getContainerAnchor(range.startContainer),
36
+ linkContent = '';
37
+
38
+ if (!$lnk) {
39
+ return;
40
+ }
41
+
42
+ if ($lnk === selectedLinkDomObj) {
43
+ return;
44
+ } else {
45
+ destroyPopup();
46
+ }
47
+
48
+ var url = jQuery19($lnk).attr('href');
49
+
50
+ if (url.indexOf('../') === 0) {
51
+ linkContent = url;
52
+ } else {
53
+ linkContent = "<div style='white-space: pre-wrap; word-wrap: break-word;'> \
54
+ <a href='#' rel='popover' style= 'cursor: pointer' onclick=\"window.open('" + url + "','_blank')\">" + url + "</a></div>";
55
+ }
56
+
57
+ if (!selectedLinkDomObj) {
58
+ selectedLinkDomObj = $lnk;
59
+
60
+ jQuery19(selectedLinkDomObj).popover({html: true,
61
+ placement: 'top',
62
+ trigger: 'manual',
63
+ content: linkContent
64
+ });
65
+ jQuery19(selectedLinkDomObj).popover('show');
66
+ }
67
+ });
68
+
69
+ Aloha.bind('aloha-link-unselected', function (event) {
70
+ destroyPopup();
71
+ });
72
+
73
+ Aloha.bind('aloha-editable-deactivated', function (event) {
74
+ destroyPopup();
75
+ });
76
+
77
+ // link to chapters
78
+ jQuery19('.linktochapter-header i').click( function () {
79
+ jQuery19(this).closest('.linktochapter').toggleClass('open');
80
+ });
81
+
82
+ jQuery19('#newLink').on('show.bs.modal', function () {
83
+ var $dialog = jQuery19('#newLink');
84
+
85
+ jQuery19('.linktochapter-content UL', $dialog).empty();
86
+
87
+ _.each(booktype.editor.data.chapters.chapters, function (item) {
88
+ var $link = jQuery19('<li><a href="#"><i class="icon-check-sign"></i>' + item.get('title') + '</a></li>');
89
+
90
+ jQuery19('a', $link).on('click', function () {
91
+ jQuery19('#newLink INPUT[name=url]').val('../' + item.get('urlTitle') + '/');
92
+
93
+ return false;
94
+ });
95
+
96
+ jQuery19('.linktochapter-content UL', $dialog).append($link);
97
+ });
98
+
99
+ jQuery19('.linktochapter .linktochapter-content li a').click(function () {
100
+ jQuery19(this).closest('ul').find('li a').removeClass('selected');
101
+ jQuery19(this).addClass('selected');
102
+ });
103
+ });
104
+
105
+ jQuery19('#newLink').on('hide.bs.modal', function () {
106
+ jQuery19('.linktochapter').removeClass('open');
107
+ jQuery19('.linktochapter .linktochapter-content ul').find('li a').removeClass('selected');
108
+ });
109
+
110
+ jQuery19("#newLink BUTTON.operation-unlink").on('click', function() {
111
+ if ($a !== null) {
112
+ var a = $a.get(0);
113
+
114
+ newRange = new GENTICS.Utils.RangeObject();
115
+ newRange.startContainer = newRange.endContainer = a.parentNode;
116
+ newRange.startOffset = GENTICS.Utils.Dom.getIndexInParent(a);
117
+ newRange.endOffset = newRange.startOffset + 1;
118
+ newRange.select();
119
+
120
+ GENTICS.Utils.Dom.removeFromDOM(a, newRange, true);
121
+
122
+ newRange.startContainer = newRange.endContainer;
123
+ newRange.startOffset = newRange.endOffset;
124
+ newRange.select();
125
+
126
+ jQuery19('#newLink').modal('hide');
127
+ }
128
+ });
129
+
130
+ jQuery19('#newLink BUTTON.operation-insert').on('click', function () {
131
+ var title = jQuery19('#newLink INPUT[name=title]').val(),
132
+ url = jQuery19('#newLink INPUT[name=url]').val();
133
+
134
+ if(jQuery19.trim(title) !== '' && jQuery19.trim(url) !== '') {
135
+ if ($a == null) {
136
+ $a = jQuery('<a/>').prop('href', url).text(title);
137
+
138
+ GENTICS.Utils.Dom.removeRange(range);
139
+ GENTICS.Utils.Dom.insertIntoDOM($a, range, editable.obj);
140
+ } else {
141
+ $a.prop('href', url).text(title);
142
+ }
143
+
144
+ jQuery19('#newLink').modal('hide');
145
+ range.select();
146
+ }
147
+ });
148
+
149
+ UI.adopt('insertLink', null, {
150
+ click: function () {
151
+ editable = Aloha.activeEditable;
152
+ range = Aloha.Selection.getRangeObject();
153
+ var a = getContainerAnchor(range.startContainer);
154
+
155
+ if (a) {
156
+ $a = jQuery(a);
157
+ range.startContainer = range.endContainer = a;
158
+ range.startOffset = 0;
159
+ range.endOffset = a.childNodes.length;
160
+ range.select();
161
+
162
+ jQuery19('#newLink INPUT[name=title]').val(jQuery(a).text());
163
+ jQuery19('#newLink INPUT[name=url]').val(a.getAttribute('href', 2));
164
+ jQuery19('#newLink .operation-unlink').prop('disabled', false);
165
+ } else {
166
+ if (_.isEmpty(range)) {
167
+ return;
168
+ }
169
+
170
+ $a = null;
171
+
172
+ GENTICS.Utils.Dom.extendToWord(range);
173
+
174
+ jQuery19('#newLink INPUT[name=title]').val(range.getText() || '');
175
+ jQuery19('#newLink INPUT[name=url]').val('');
176
+
177
+ jQuery19('#newLink .operation-unlink').prop('disabled', true);
178
+ }
179
+
180
+ jQuery19('#newLink').modal('show');
181
+ }
182
+ });
183
+ },
184
+
185
+ makeClean: function (obj) {
186
+ jQuery('div.popover.fade.top').remove();
187
+ }
188
+ });
189
+ }
190
+ );
pool/shard010/JavaScript/0066834_Users.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import Toggle from 'material-ui/Toggle';
3
+
4
+ const styles = {
5
+ toggle: {
6
+ marginBottom: 10,
7
+ marginTop: 10
8
+ }
9
+ };
10
+
11
+ const Users = ({ users, handleUserChange }) => {
12
+ return (
13
+ <div>
14
+ {users.map(user => <Toggle
15
+ style={styles.toggle}
16
+ label={user.name}
17
+ id={user.id}
18
+ key={user.id}
19
+ onToggle={handleUserChange}
20
+ toggled={user.isActive}
21
+ />)}
22
+ </div>
23
+ );
24
+ };
25
+
26
+ export default Users;