Pendigard commited on
Commit
46c3625
·
verified ·
1 Parent(s): 5893f8f

Upload folder using huggingface_hub (part 14)

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/shard000/JavaScript/0001378_gulpfile.js +43 -0
  2. pool/shard000/JavaScript/0001379_urlBarSuggestionsReducerTest.js +94 -0
  3. pool/shard000/JavaScript/0001380_program_association.js +107 -0
  4. pool/shard000/JavaScript/0001383_usersController.js +82 -0
  5. pool/shard000/JavaScript/0001387_dockerService.js +151 -0
  6. pool/shard000/JavaScript/0001389_bundle.repository.js +80 -0
  7. pool/shard000/JavaScript/0001390_aql-queries-geo.js +271 -0
  8. pool/shard000/JavaScript/0001391_index.js +37 -0
  9. pool/shard000/JavaScript/0001392_mysqlModel.js +28 -0
  10. pool/shard000/JavaScript/0001393_SettingsStore.js +59 -0
  11. pool/shard000/JavaScript/0001398_smartphone.js +32 -0
  12. pool/shard000/JavaScript/0001400_PolylineComplex.js +100 -0
  13. pool/shard000/JavaScript/0001411_newtonian.js +134 -0
  14. pool/shard000/JavaScript/0001412_alv-ch-ng.ui-core.directive.collapsible.unit.spec.js +21 -0
  15. pool/shard000/JavaScript/0001417_2d.drawImage.9arg.destsize.worker.js +56 -0
  16. pool/shard000/JavaScript/0001418_anim1.js +34 -0
  17. pool/shard000/JavaScript/0001420_main.js +49 -0
  18. pool/shard000/JavaScript/0001425_event-schedule.js +88 -0
  19. pool/shard000/JavaScript/0001428_userForgot.js +235 -0
  20. pool/shard000/JavaScript/0001432_root.test.js +31 -0
  21. pool/shard000/JavaScript/0001433_profile.js +52 -0
  22. pool/shard000/JavaScript/0001434_table.row.js +89 -0
  23. pool/shard000/JavaScript/0001436_socket.js +61 -0
  24. pool/shard000/JavaScript/0001439_partida.js +25 -0
  25. pool/shard000/JavaScript/0001441_knockout-switch-case.js +209 -0
  26. pool/shard000/JavaScript/0001445_svg-painter.js +200 -0
  27. pool/shard000/JavaScript/0001446_15.4.4.19-4-15.js +36 -0
  28. pool/shard000/JavaScript/0001447_Emails.js +82 -0
  29. pool/shard000/JavaScript/0001450_Rapid.js +133 -0
  30. pool/shard000/JavaScript/0001451_categories-controller.js +35 -0
  31. pool/shard000/JavaScript/0001452_App.js +68 -0
  32. pool/shard000/JavaScript/0001453_index.js +75 -0
  33. pool/shard000/JavaScript/0001454_fadeplugin.js +23 -0
  34. pool/shard000/JavaScript/0001456_index.js +123 -0
  35. pool/shard000/JavaScript/0001461_transform-composed-nodes.js +37 -0
  36. pool/shard000/JavaScript/0001462_test-amp-story-share-menu.js +55 -0
  37. pool/shard000/JavaScript/0001464_dates.js +154 -0
  38. pool/shard000/JavaScript/0001469_PrefetchListPickerEditorController.js +42 -0
  39. pool/shard000/JavaScript/0001473_basic.js +73 -0
  40. pool/shard000/JavaScript/0001482_resultsContent.js +47 -0
  41. pool/shard000/JavaScript/0001484_router.js +25 -0
  42. pool/shard000/JavaScript/0001486_pen.js +22 -0
  43. pool/shard000/JavaScript/0001488_calendar.test.js +173 -0
  44. pool/shard000/JavaScript/0001493_ethPrice.js +27 -0
  45. pool/shard000/JavaScript/0001496_index.js +84 -0
  46. pool/shard000/JavaScript/0001512_notifier.js +69 -0
  47. pool/shard000/JavaScript/0001514_tableViewComponent.js +40 -0
  48. pool/shard000/JavaScript/0001520_build.js +16 -0
  49. pool/shard000/JavaScript/0001521_events.js +176 -0
  50. pool/shard000/JavaScript/0001522_appInfo.test.js +93 -0
pool/shard000/JavaScript/0001378_gulpfile.js ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var gulp = require('gulp'),
2
+ tap = require('gulp-tap'),
3
+ rename = require('gulp-rename'),
4
+ browserify = require('browserify');
5
+
6
+ var bundler = function (file) {
7
+ var opts = {
8
+ entries: [file.path],
9
+ paths: ['./node_modules', './src'],
10
+ debug: true
11
+ }
12
+
13
+ file.contents = browserify(opts)
14
+ .transform("babelify", {presets: ["es2015"], plugins: ["syntax-jsx", "transform-h-jsx"]})
15
+ .bundle();
16
+ }
17
+
18
+ gulp.task('example:router', function () {
19
+ return gulp.src('examples/router/app.js', {read: false})
20
+ .pipe(tap(bundler))
21
+ .pipe(rename('app.bundle.js'))
22
+ .pipe(gulp.dest('examples/router'));
23
+ });
24
+
25
+ gulp.task('example:rest', function () {
26
+ return gulp.src('examples/rest/app.js', {read: false})
27
+ .pipe(tap(bundler))
28
+ .pipe(rename('app.bundle.js'))
29
+ .pipe(gulp.dest('examples/rest'));
30
+ });
31
+
32
+ gulp.task('example:todomvc', function () {
33
+ return gulp.src('examples/todomvc/src/app.js', {read: false})
34
+ .pipe(tap(bundler))
35
+ .pipe(rename('app.bundle.js'))
36
+ .pipe(gulp.dest('examples/todomvc'));
37
+ });
38
+
39
+ gulp.task('default', [
40
+ 'example:router',
41
+ 'example:rest',
42
+ 'example:todomvc'
43
+ ]);
pool/shard000/JavaScript/0001379_urlBarSuggestionsReducerTest.js ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* global describe, it, before, after, afterEach */
2
+ const mockery = require('mockery')
3
+ const sinon = require('sinon')
4
+ const Immutable = require('immutable')
5
+ const assert = require('assert')
6
+
7
+ const appConstants = require('../../../../../js/constants/appConstants')
8
+ require('../../../braveUnit')
9
+
10
+ describe('urlBarSuggestionsReducer', function () {
11
+ let urlBarSuggestionsReducer
12
+ before(function () {
13
+ mockery.enable({
14
+ warnOnReplace: false,
15
+ warnOnUnregistered: false,
16
+ useCleanCache: true
17
+ })
18
+
19
+ this.siteSuggestionsStub = {
20
+ init: sinon.stub(),
21
+ add: sinon.stub()
22
+ }
23
+ mockery.registerMock('../../common/lib/siteSuggestions', this.siteSuggestionsStub)
24
+
25
+ this.suggestionStub = {
26
+ generateNewSuggestionsList: sinon.stub(),
27
+ generateNewSearchXHRResults: sinon.stub()
28
+ }
29
+ mockery.registerMock('../../common/lib/suggestion', this.suggestionStub)
30
+
31
+ urlBarSuggestionsReducer = require('../../../../../app/browser/reducers/urlBarSuggestionsReducer')
32
+ })
33
+
34
+ after(function () {
35
+ mockery.disable()
36
+ })
37
+
38
+ afterEach(function () {
39
+ this.siteSuggestionsStub.init.reset()
40
+ this.siteSuggestionsStub.add.reset()
41
+ this.suggestionStub.generateNewSuggestionsList.reset()
42
+ this.suggestionStub.generateNewSearchXHRResults.reset()
43
+ })
44
+
45
+ const site1 = {
46
+ location: 'https://brave.com'
47
+ }
48
+
49
+ const initState = Immutable.fromJS({
50
+ sites: {
51
+ 'key': site1
52
+ }
53
+ })
54
+
55
+ describe('APP_SET_STATE', function () {
56
+ it('inits the suggestions lib with sites', function () {
57
+ urlBarSuggestionsReducer(Immutable.Map(), {actionType: appConstants.APP_SET_STATE, appState: initState})
58
+ const callCount = this.siteSuggestionsStub.init.calledOnce
59
+ assert.equal(callCount, 1)
60
+ assert.deepEqual(this.siteSuggestionsStub.init.args[0][0], [site1])
61
+ })
62
+ })
63
+ describe('APP_ADD_SITE', function () {
64
+ it('adds a site in the suggestions lib', function () {
65
+ const newState = urlBarSuggestionsReducer(initState, {actionType: appConstants.APP_ADD_SITE, siteDetail: site1})
66
+ const callCount = this.siteSuggestionsStub.add.calledOnce
67
+ assert.equal(callCount, 1)
68
+ assert.deepEqual(this.siteSuggestionsStub.add.args[0][0], site1)
69
+ assert.deepEqual(newState, initState)
70
+ })
71
+ })
72
+ describe('APP_URL_BAR_TEXT_CHANGED', function () {
73
+ it('regenerates suggestions', function () {
74
+ const windowId = 1
75
+ const tabId = 42
76
+ const input = 'hello world'
77
+ const newState = urlBarSuggestionsReducer(initState, {actionType: appConstants.APP_URL_BAR_TEXT_CHANGED, tabId, windowId, input})
78
+ const callCount = this.suggestionStub.generateNewSuggestionsList.calledOnce
79
+ assert.equal(callCount, 1)
80
+ assert.deepEqual(this.suggestionStub.generateNewSuggestionsList.args[0][0], initState)
81
+ assert.deepEqual(this.suggestionStub.generateNewSuggestionsList.args[0][1], windowId)
82
+ assert.deepEqual(this.suggestionStub.generateNewSuggestionsList.args[0][2], tabId)
83
+ assert.deepEqual(this.suggestionStub.generateNewSuggestionsList.args[0][3], input)
84
+ assert.deepEqual(newState, initState)
85
+
86
+ const xhrCallCount = this.suggestionStub.generateNewSearchXHRResults.calledOnce
87
+ assert.equal(xhrCallCount, 1)
88
+ assert.deepEqual(this.suggestionStub.generateNewSearchXHRResults.args[0][0], initState)
89
+ assert.deepEqual(this.suggestionStub.generateNewSearchXHRResults.args[0][1], windowId)
90
+ assert.deepEqual(this.suggestionStub.generateNewSearchXHRResults.args[0][2], tabId)
91
+ assert.deepEqual(this.suggestionStub.generateNewSearchXHRResults.args[0][3], input)
92
+ })
93
+ })
94
+ })
pool/shard000/JavaScript/0001380_program_association.js ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ const TsCrc32 = require("../crc32");
4
+ const TsReader = require("../reader");
5
+ const TsWriter = require("../writer");
6
+ const TsSectionBase = require("./base");
7
+
8
+ class TsSectionProgramAssociation extends TsSectionBase {
9
+ constructor(buffer, pid) {
10
+ super(buffer, pid);
11
+ }
12
+
13
+ decode() {
14
+ const reader = new TsReader(this._buffer);
15
+ const objSection = {};
16
+
17
+ objSection.table_id = reader.uimsbf(8);
18
+ objSection.section_syntax_indicator = reader.bslbf(1);
19
+ reader.next(1); // '0'
20
+ reader.next(2); // reserved
21
+ objSection.section_length = reader.uimsbf(12);
22
+ objSection.transport_stream_id = reader.uimsbf(16);
23
+ reader.next(2); // reserved
24
+ objSection.version_number = reader.uimsbf(5);
25
+ objSection.current_next_indicator = reader.bslbf(1);
26
+ objSection.section_number = reader.uimsbf(8);
27
+ objSection.last_section_number = reader.uimsbf(8);
28
+
29
+ objSection.programs = [];
30
+
31
+ for (const l = 3 + objSection.section_length - 4; reader.position >> 3 < l; ) {
32
+ const program = {};
33
+
34
+ program.program_number = reader.uimsbf(16);
35
+ reader.next(3); // reserved
36
+ if (program.program_number === 0) {
37
+ program.network_PID = reader.uimsbf(13);
38
+ } else {
39
+ program.program_map_PID = reader.uimsbf(13);
40
+ }
41
+
42
+ objSection.programs.push(program);
43
+ }
44
+
45
+ objSection.CRC_32 = reader.readBytes(4);
46
+
47
+ return objSection;
48
+ }
49
+
50
+ encode(objSection) {
51
+ const buffer = Buffer.alloc(0x400);
52
+
53
+ const writer = new TsWriter(buffer);
54
+
55
+ writer.uimsbf(8, objSection.table_id);
56
+ writer.bslbf(1, objSection.section_syntax_indicator);
57
+ writer.bslbf(1, 0); // '0'
58
+ writer.bslbf(2, 0b11); // reserved
59
+ writer.uimsbf(12, 5 + objSection.programs.length * 4 + 4);
60
+ writer.uimsbf(16, objSection.transport_stream_id);
61
+ writer.bslbf(2, 0b11); // reserved
62
+ writer.uimsbf(5, objSection.version_number);
63
+ writer.bslbf(1, objSection.current_next_indicator);
64
+ writer.uimsbf(8, objSection.section_number);
65
+ writer.uimsbf(8, objSection.last_section_number);
66
+
67
+ objSection.programs.forEach(program => {
68
+ writer.uimsbf(16, program.program_number);
69
+ writer.bslbf(3, 0); // reserved
70
+ if (program.program_number === 0) {
71
+ writer.uimsbf(13, program.network_PID);
72
+ } else {
73
+ writer.uimsbf(13, program.program_map_PID);
74
+ }
75
+ });
76
+
77
+ writer.writeBytes(4, TsCrc32.calcToBuffer(buffer.slice(0, writer.position >> 3)));
78
+
79
+ this._buffer = buffer.slice(0, writer.position >> 3);
80
+ }
81
+
82
+ checkCrc32() {
83
+ return TsCrc32.calc(this._buffer) === 0;
84
+ }
85
+
86
+ getTransportStreamId() {
87
+ return this._buffer[3] << 8 | this._buffer[4];
88
+ }
89
+
90
+ getVersionNumber() {
91
+ return (this._buffer[5] & 0x3E) >> 1;
92
+ }
93
+
94
+ getCurrentNextIndicator() {
95
+ return this._buffer[5] & 0x01;
96
+ }
97
+
98
+ getSectionNumber() {
99
+ return this._buffer[6];
100
+ }
101
+
102
+ getLastSectionNumber() {
103
+ return this._buffer[7];
104
+ }
105
+ }
106
+
107
+ module.exports = TsSectionProgramAssociation;
pool/shard000/JavaScript/0001383_usersController.js ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var User = require('../models/usersModel');
2
+ var jwt = require('jsonwebtoken');
3
+ var secret = "A super secret key";
4
+
5
+ module.exports = {
6
+ userController: {
7
+ create: function (req, res) {
8
+ var user = new User(req.body);
9
+
10
+ user.save(function (err, user) {
11
+ if (err) {res.json(err);}
12
+ else {res.json(user);}
13
+ });
14
+ },
15
+ all: function (req, res) {
16
+ User.find({}, function(err, users) {
17
+ if (err) res.json(err);
18
+ res.json(users);
19
+ })
20
+ },
21
+ single: function (req, res) {
22
+ var id = req.params.id;
23
+
24
+ User.findOne({_id: id}, function (err, user) {
25
+ if (err) res.json(err);
26
+ res.json(user);
27
+ })
28
+ },
29
+ update: function (req, res) {
30
+ var id = req.params.id;
31
+
32
+ User.findOne({_id: id}, function (err, user) {
33
+ if (err) res.json(err);
34
+
35
+ if (req.body.email) {user.email = req.body.email;}
36
+ if (req.body.password) {user.password = req.body.password;}
37
+
38
+ user.save(function (err, response) {
39
+ if (err) res.json(err);
40
+ res.json(response);
41
+ })
42
+ })
43
+ },
44
+ destroy: function (req, res) {
45
+ var id = req.params.id;
46
+
47
+ User.remove({_id: id}, function (err, user) {
48
+ if (err) res.json(err);
49
+
50
+ res.json({message: "Deleted User!"})
51
+ })
52
+ },
53
+ signIn: function (req, res) {
54
+ User.findOne({email: req.body.email}, function (err, user) {
55
+ // console.log("Going to sign in");
56
+ if (err) res.json(err);
57
+
58
+ if (user) {
59
+ console.log("Found user");
60
+ if (user.comparePassword(req.body.password)) {
61
+ // console.log("Creating token");
62
+ var token = jwt.sign({email: user.email, id: user._id, admin: user.admin},
63
+ secret,
64
+ {expiresInMinutes: 1440});
65
+ // console.log("Sending token");
66
+ res.json({
67
+ success: true,
68
+ message: 'Successfully logged in!',
69
+ token: token
70
+ });
71
+ } else {
72
+ // console.log("Password does not match");
73
+ res.json({message: "password does not match"})
74
+ }
75
+ } else {
76
+ // console.log("Did not find user");
77
+ res.json({message: "user does not exist"})
78
+ }
79
+ })
80
+ }
81
+ }
82
+ };
pool/shard000/JavaScript/0001387_dockerService.js ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2015 Caleb Brose, Chris Fogerty, Rob Sheehy, Zach Taylor, Nick Miller
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /*
18
+ * docker/dockerService.js
19
+ * Main entrypoint for all controllers requesting Docker instance info.
20
+ */
21
+
22
+ var _ = require('lodash');
23
+ var oboe = require('oboe');
24
+
25
+ function dockerService($http, actions, flux, alertService, configService) {
26
+ 'use strict';
27
+
28
+ // Utility for creating a Docker endpoint object
29
+ function ep(_verb, _template, _action) {
30
+ return {
31
+ verb: _verb,
32
+ template: _template,
33
+ action: _action
34
+ };
35
+ }
36
+
37
+ // Endpoint -> (verb, action)
38
+ var endpoints = {
39
+ 'containers': {
40
+ 'inspect': ep('GET', '/containers/{id}/json', actions.inspectContainer),
41
+ 'create': ep('POST', '/containers/create', actions.createContainer),
42
+ 'list': ep('GET', '/containers/json', actions.listContainers),
43
+ 'logs': ep('GET', '/containers/{id}/logs', actions.inspectContainerLogs),
44
+ 'start': ep('POST', '/containers/{id}/start', actions.startContainer),
45
+ 'stop': ep('POST', '/containers/{id}/stop', actions.stopContainer),
46
+ 'restart': ep('POST', '/containers/{id}/restart', actions.restartContainer),
47
+ 'pause': ep('POST', '/containers/{id}/pause', actions.pauseContainer),
48
+ 'unpause': ep('POST', '/containers/{id}/unpause', actions.unpauseContainer)
49
+ },
50
+ 'images': {
51
+ 'list': ep('GET', '/images/json', actions.listImages),
52
+ 'search': ep('GET', '/images/search', actions.searchImages),
53
+ 'pull': ep('POST', '/images/create', actions.pullImage),
54
+ 'remove': ep('DELETE', '/images/{id}', actions.removeImage)
55
+ }
56
+ };
57
+
58
+ /*
59
+ * prepareUrl()
60
+ * @param {string, required} url: docker API call
61
+ * @param {string, required} host: targeted docker instance
62
+ * @param {string} id: container/image id located on host
63
+ */
64
+ function prepareUrl(url, host, id) {
65
+ var request = [configService.api.base, 'd/', encodeURIComponent(host)];
66
+
67
+ if (id && (url.indexOf('{id}') > -1)) {
68
+ request.push(url.replace('{id}', id));
69
+ }
70
+ else {
71
+ request.push(url);
72
+ }
73
+
74
+ return request.join('');
75
+ }
76
+
77
+ /*
78
+ * docker()
79
+ * Main entrypoint.
80
+ * Prepares a Docker request and dispatches the appropriate flux action upon success.
81
+ *
82
+ * @param {string, required} namespace: namespace representation of a Docker API call (i.e. 'containers.inspect')
83
+ * @param {object, required} request: object representation of a Docker API call.
84
+ * Allowed keys:
85
+ * {string, required} host: lighthouse alias for targeted Docker instance
86
+ * {string} id: image or container id (generated by Docker)
87
+ * {object} query: map of query parameter keys and values
88
+ * {*} data: body data for POST/PUT requests
89
+ */
90
+ function d(namespace, request) {
91
+ var ns = namespace.split('.');
92
+ var endpoint = endpoints[ns[0]][ns[1]];
93
+
94
+ var config = {
95
+ method: endpoint.verb,
96
+ url: prepareUrl(endpoint.template, request.host, request.id),
97
+ params: request.query,
98
+ data: request.data ? {'Payload': request.data} : null,
99
+ responseType: request.responseType || 'json',
100
+ headers: {
101
+ 'Content-Type': 'application/json'
102
+ }
103
+ };
104
+
105
+ $http(config).then(
106
+ // success
107
+ function (response) {
108
+ flux.dispatch(endpoint.action,
109
+ {'id': request.id, 'host': request.host, 'response': response.data});
110
+ }
111
+ );
112
+ }
113
+
114
+ function stream(namespace, request) {
115
+ var ns = namespace.split('.');
116
+ var endpoint = endpoints[ns[0]][ns[1]];
117
+
118
+ var oboeStream = oboe({
119
+ method: endpoint.verb,
120
+ url: prepareUrl(endpoint.template, request.host, request.id) + '?' + $.param(request.query),
121
+ body: request.body
122
+ });
123
+
124
+ _.reduce(request.patterns, function(stream, pattern) {
125
+ return stream.node(pattern, function(item) {
126
+ flux.dispatch(endpoint.action, {
127
+ 'id': request.id,
128
+ 'host': request.host,
129
+ 'response': item,
130
+ 'pattern': pattern,
131
+ 'meta': request
132
+ });
133
+ });
134
+ }, oboeStream);
135
+
136
+ oboeStream.fail(function() {
137
+ alertService.create({
138
+ message: namespace + ' call failed...',
139
+ type: 'danger'
140
+ });
141
+ });
142
+ }
143
+
144
+ return {
145
+ 'd': d,
146
+ 'stream': stream
147
+ };
148
+ }
149
+
150
+ dockerService.$inject = ['$http', 'actions', 'flux', 'alertService', 'configService'];
151
+ module.exports = dockerService;
pool/shard000/JavaScript/0001389_bundle.repository.js ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2011-2013 Lp digital system
3
+ *
4
+ * This file is part of BackBee.
5
+ *
6
+ * BackBee is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * BackBee is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with BackBee. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ define(
20
+ [
21
+ 'Core/DriverHandler',
22
+ 'Core/RestDriver',
23
+ 'jquery',
24
+ 'jsclass'
25
+ ],
26
+ function (CoreDriverHandler, CoreRestDriver, jQuery) {
27
+
28
+ 'use strict';
29
+
30
+ /**
31
+ * Bundle repository class
32
+ * @type {Object} JS.Class
33
+ */
34
+ var BundleRepository = new JS.Class({
35
+
36
+ TYPE: 'bundle',
37
+
38
+ DEFAULT_DRIVER_KEY: 'rest',
39
+
40
+ /**
41
+ * Initialize of Bundle repository
42
+ */
43
+ initialize: function () {
44
+ CoreDriverHandler.addDriver(this.DEFAULT_DRIVER_KEY, CoreRestDriver);
45
+ },
46
+
47
+ /**
48
+ * List bundles
49
+ * @param {Function} callback
50
+ */
51
+ list: function () {
52
+ var self = this,
53
+ dfd = jQuery.Deferred();
54
+
55
+ if (this.bundleList === undefined) {
56
+
57
+ CoreDriverHandler.read(this.TYPE).done(function (data) {
58
+ self.bundleList = data;
59
+ dfd.resolve(self.bundleList);
60
+ });
61
+ } else {
62
+ dfd.resolve(this.bundleList);
63
+ }
64
+
65
+ return dfd.promise();
66
+ },
67
+
68
+ /**
69
+ * Set the activation of bundle
70
+ * @param {Boolean} active
71
+ * @param {String} bundleId
72
+ */
73
+ active: function (active, bundleId) {
74
+ return CoreDriverHandler.patch(this.TYPE, {'enable': active}, {'id': bundleId});
75
+ }
76
+ });
77
+
78
+ return new JS.Singleton(BundleRepository);
79
+ }
80
+ );
pool/shard000/JavaScript/0001390_aql-queries-geo.js ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*jshint globalstrict:false, strict:false, maxlen: 500 */
2
+ /*global assertEqual */
3
+
4
+ ////////////////////////////////////////////////////////////////////////////////
5
+ /// @brief tests for query language, geo queries
6
+ ///
7
+ /// @file
8
+ ///
9
+ /// DISCLAIMER
10
+ ///
11
+ /// Copyright 2010-2012 triagens GmbH, Cologne, Germany
12
+ ///
13
+ /// Licensed under the Apache License, Version 2.0 (the "License");
14
+ /// you may not use this file except in compliance with the License.
15
+ /// You may obtain a copy of the License at
16
+ ///
17
+ /// http://www.apache.org/licenses/LICENSE-2.0
18
+ ///
19
+ /// Unless required by applicable law or agreed to in writing, software
20
+ /// distributed under the License is distributed on an "AS IS" BASIS,
21
+ /// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ /// See the License for the specific language governing permissions and
23
+ /// limitations under the License.
24
+ ///
25
+ /// Copyright holder is triAGENS GmbH, Cologne, Germany
26
+ ///
27
+ /// @author Jan Steemann
28
+ /// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
29
+ ////////////////////////////////////////////////////////////////////////////////
30
+
31
+ var jsunity = require("jsunity");
32
+ var db = require("@arangodb").db;
33
+ var errors = require("@arangodb").errors;
34
+ var helper = require("@arangodb/aql-helper");
35
+ var getQueryResults = helper.getQueryResults;
36
+ var assertQueryError = helper.assertQueryError;
37
+
38
+ ////////////////////////////////////////////////////////////////////////////////
39
+ /// @brief test suite
40
+ ////////////////////////////////////////////////////////////////////////////////
41
+
42
+ function ahuacatlGeoTestSuite () {
43
+ var locations = null;
44
+ var locationsNon = null;
45
+
46
+ function runQuery (query) {
47
+ var result = getQueryResults(query);
48
+
49
+ result = result.map(function(row) {
50
+ var r;
51
+ if (row !== null && typeof row === 'object') {
52
+ for (r in row) {
53
+ if (row.hasOwnProperty(r)) {
54
+ var value = row[r];
55
+ if (typeof(value) === "number") {
56
+ if (value !== parseFloat(parseInt(value))) {
57
+ row[r] = Number(value).toFixed(5);
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
+ return row;
65
+ });
66
+
67
+ return result;
68
+ }
69
+
70
+ return {
71
+
72
+ ////////////////////////////////////////////////////////////////////////////////
73
+ /// @brief set up
74
+ ////////////////////////////////////////////////////////////////////////////////
75
+
76
+ setUp : function () {
77
+ var lat, lon;
78
+ db._drop("UnitTestsAhuacatlLocations");
79
+ db._drop("UnitTestsAhuacatlLocationsNon");
80
+
81
+ locations = db._create("UnitTestsAhuacatlLocations");
82
+ for (lat = -40; lat <= 40; ++lat) {
83
+ for (lon = -40; lon <= 40; ++lon) {
84
+ locations.save({"latitude" : lat, "longitude" : lon });
85
+ }
86
+ }
87
+
88
+ locations.ensureGeoIndex("latitude", "longitude");
89
+
90
+ locationsNon = db._create("UnitTestsAhuacatlLocationsNon");
91
+
92
+ for (lat = -40; lat <= 40; ++lat) {
93
+ for (lon = -40; lon <= 40; ++lon) {
94
+ locationsNon.save({"latitude" : lat, "longitude" : lon });
95
+ }
96
+ }
97
+ },
98
+
99
+ ////////////////////////////////////////////////////////////////////////////////
100
+ /// @brief tear down
101
+ ////////////////////////////////////////////////////////////////////////////////
102
+
103
+ tearDown : function () {
104
+ db._drop("UnitTestsAhuacatlLocations");
105
+ db._drop("UnitTestsAhuacatlLocationsNon");
106
+ },
107
+
108
+ ////////////////////////////////////////////////////////////////////////////////
109
+ /// @brief test near function
110
+ ////////////////////////////////////////////////////////////////////////////////
111
+
112
+ testNear1 : function () {
113
+ var expected = [ { "distance" : "111194.92664", "latitude" : -1, "longitude" : 0 }, { "distance" : "111194.92664", "latitude" : 0, "longitude" : -1 }, { "distance" : "111194.92664", "latitude" : 0, "longitude" : 1 }, { "distance" : "111194.92664", "latitude" : 1, "longitude" : 0 }, { "distance" : 0, "latitude" : 0, "longitude" : 0 } ];
114
+ var actual = runQuery("FOR x IN NEAR(" + locations.name() + ", 0, 0, 5, \"distance\") SORT x.distance DESC, x.latitude, x.longitude RETURN x");
115
+ assertEqual(expected, actual);
116
+ },
117
+
118
+ ////////////////////////////////////////////////////////////////////////////////
119
+ /// @brief test near function
120
+ ////////////////////////////////////////////////////////////////////////////////
121
+
122
+ testNear2 : function () {
123
+ var expected = [ { "latitude" : -10, "longitude" : 24 }, { "latitude" : -10, "longitude" : 25 }, { "latitude" : -10, "longitude" : 26 } ];
124
+ var actual = runQuery("FOR x IN NEAR(" + locations.name() + ", -10, 25, 3) SORT x.latitude, x.longitude RETURN x");
125
+ assertEqual(expected, actual);
126
+ },
127
+
128
+ ////////////////////////////////////////////////////////////////////////////////
129
+ /// @brief test near function
130
+ ////////////////////////////////////////////////////////////////////////////////
131
+
132
+ testNear3 : function () {
133
+ var expected = [ { "distance" : "14891044.54146", "latitude" : 40, "longitude" : -40 }, { "distance" : "14853029.30724", "latitude" : 40, "longitude" : -39 }, { "distance" : "14815001.47646", "latitude" : 40, "longitude" : -38 } ];
134
+ var actual = runQuery("FOR x IN NEAR(" + locations.name() + ", -70, 70, 10000, \"distance\") SORT x.distance DESC LIMIT 3 RETURN x");
135
+ assertEqual(expected, actual);
136
+
137
+ expected = [ {"distance" : "4487652.12954", "latitude" : -37, "longitude" : 26 }, { "distance" : "4485565.93668", "latitude" : -39, "longitude" : 20 }, { "distance" : "4484371.86154" , "latitude" : -38, "longitude" : 23 } ];
138
+ actual = runQuery("FOR x IN NEAR(" + locations.name() + ", -70, 70, null, \"distance\") SORT x.distance DESC LIMIT 3 RETURN x");
139
+ assertEqual(expected, actual);
140
+ },
141
+
142
+ ////////////////////////////////////////////////////////////////////////////////
143
+ /// @brief test near function
144
+ ////////////////////////////////////////////////////////////////////////////////
145
+
146
+ testNear4 : function () {
147
+ var expected = [ {"latitude" : -40, "longitude" : 40 }, { "latitude" : -40, "longitude" : 39 }, { "latitude" : -40, "longitude" : 38 } ];
148
+ var actual = runQuery("FOR x IN NEAR(" + locations.name() + ", -70, 70, null) SORT x.latitude, x.longitude DESC LIMIT 3 RETURN x");
149
+ assertEqual(expected, actual);
150
+
151
+ expected = [ { "latitude" : -40, "longitude" : 40 }, { "latitude" : -40, "longitude" : 39 } ];
152
+ actual = runQuery("FOR x IN NEAR(" + locations.name() + ", -70, 70, 2) SORT x.latitude, x.longitude DESC LIMIT 3 RETURN x");
153
+ assertEqual(expected, actual);
154
+ },
155
+
156
+ ////////////////////////////////////////////////////////////////////////////////
157
+ /// @brief test within function
158
+ ////////////////////////////////////////////////////////////////////////////////
159
+
160
+ testWithin1 : function () {
161
+ var expected = [ { "distance" : 0, "latitude" : 0, "longitude" : 0 } ];
162
+ var actual = runQuery("FOR x IN WITHIN(" + locations.name() + ", 0, 0, 10000, \"distance\") SORT x.latitude, x.longitude RETURN x");
163
+ assertEqual(expected, actual);
164
+ },
165
+
166
+ ////////////////////////////////////////////////////////////////////////////////
167
+ /// @brief test within function
168
+ ////////////////////////////////////////////////////////////////////////////////
169
+
170
+ testWithin2 : function () {
171
+ var expected = [ { "distance" : "111194.92664", "latitude" : -1, "longitude" : 0 }, { "distance" : "111194.92664", "latitude" : 0, "longitude" : -1 }, { "distance" : 0, "latitude" : 0, "longitude" : 0 }, { "distance" : "111194.92664", "latitude" : 0, "longitude" : 1 }, { "distance" : "111194.92664", "latitude" : 1, "longitude" : 0 } ];
172
+ var actual = runQuery("FOR x IN WITHIN(" + locations.name() + ", 0, 0, 150000, \"distance\") SORT x.latitude, x.longitude RETURN x");
173
+ assertEqual(expected, actual);
174
+ },
175
+
176
+ ////////////////////////////////////////////////////////////////////////////////
177
+ /// @brief test within function
178
+ ////////////////////////////////////////////////////////////////////////////////
179
+
180
+ testWithin3 : function () {
181
+ var expected = [ { "latitude" : -10, "longitude" : 25 } ];
182
+ var actual = runQuery("FOR x IN WITHIN(" + locations.name() + ", -10, 25, 10000) SORT x.latitude, x.longitude RETURN x");
183
+ assertEqual(expected, actual);
184
+ },
185
+
186
+ ////////////////////////////////////////////////////////////////////////////////
187
+ /// @brief test within function
188
+ ////////////////////////////////////////////////////////////////////////////////
189
+
190
+ testWithin4 : function () {
191
+ var expected = [
192
+ { "latitude" : -11, "longitude" : 25 },
193
+ { "latitude" : -10, "longitude" : 24 },
194
+ { "latitude" : -10, "longitude" : 25 },
195
+ { "latitude" : -10, "longitude" : 26 },
196
+ { "latitude" : -9, "longitude" : 25 }
197
+ ];
198
+
199
+ var actual = runQuery("FOR x IN WITHIN(" + locations.name() + ", -10, 25, 150000) SORT x.latitude, x.longitude RETURN x");
200
+ assertEqual(expected, actual);
201
+ },
202
+
203
+ ////////////////////////////////////////////////////////////////////////////////
204
+ /// @brief test within function
205
+ ////////////////////////////////////////////////////////////////////////////////
206
+
207
+ testWithin5 : function () {
208
+ var expected = [ ];
209
+ var actual = runQuery("FOR x IN WITHIN(" + locations.name() + ", -90, 90, 10000) SORT x.latitude, x.longitude RETURN x");
210
+ assertEqual(expected, actual);
211
+ },
212
+
213
+ ////////////////////////////////////////////////////////////////////////////////
214
+ /// @brief test without geo index available
215
+ ////////////////////////////////////////////////////////////////////////////////
216
+
217
+ testNonIndexed : function () {
218
+ assertQueryError(errors.ERROR_QUERY_GEO_INDEX_MISSING.code, "RETURN NEAR(" + locationsNon.name() + ", 0, 0, 10)");
219
+ assertQueryError(errors.ERROR_QUERY_GEO_INDEX_MISSING.code, "RETURN WITHIN(" + locationsNon.name() + ", 0, 0, 10)");
220
+ },
221
+
222
+ ////////////////////////////////////////////////////////////////////////////////
223
+ /// @brief test invalid NEAR arguments count
224
+ ////////////////////////////////////////////////////////////////////////////////
225
+
226
+ testInvalidNearArgument : function () {
227
+ assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN NEAR(\"" + locationsNon.name() + "\", 0, 0, \"foo\")");
228
+ assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN NEAR(\"" + locationsNon.name() + "\", 0, 0, true)");
229
+ assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN NEAR(\"" + locationsNon.name() + "\", 0, 0, 10, true)");
230
+ },
231
+
232
+ ////////////////////////////////////////////////////////////////////////////////
233
+ /// @brief test invalid WITHIN arguments count
234
+ ////////////////////////////////////////////////////////////////////////////////
235
+
236
+ testInvalidWithinArgument : function () {
237
+ assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN WITHIN(\"" + locationsNon.name() + "\", 0, 0, \"foo\")");
238
+ assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN WITHIN(\"" + locationsNon.name() + "\", 0, 0, true)");
239
+ assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN WITHIN(\"" + locationsNon.name() + "\", 0, 0, 0, true)");
240
+ assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN WITHIN(\"" + locationsNon.name() + "\", 0, 0, 0, [ ])");
241
+ },
242
+
243
+ ////////////////////////////////////////////////////////////////////////////////
244
+ /// @brief test invalid collection parameter
245
+ ////////////////////////////////////////////////////////////////////////////////
246
+
247
+ testInvalidCollectionArgument : function () {
248
+ assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN WITHIN(1234, 0, 0, 10)");
249
+ assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN WITHIN(false, 0, 0, 10)");
250
+ assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN WITHIN(true, 0, 0, 10)");
251
+ assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN WITHIN([ ], 0, 0, 10)");
252
+ assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN WITHIN({ }, 0, 0, 10)");
253
+ assertQueryError(errors.ERROR_ARANGO_COLLECTION_NOT_FOUND.code, "RETURN WITHIN(@name, 0, 0, 10)", { name: "foobarbazcoll" });
254
+ assertQueryError(errors.ERROR_QUERY_BIND_PARAMETER_MISSING.code, "RETURN WITHIN(@name, 0, 0, 10)");
255
+ }
256
+
257
+ };
258
+ }
259
+
260
+ ////////////////////////////////////////////////////////////////////////////////
261
+ /// @brief executes the test suite
262
+ ////////////////////////////////////////////////////////////////////////////////
263
+
264
+ jsunity.run(ahuacatlGeoTestSuite);
265
+
266
+ return jsunity.done();
267
+
268
+ // Local Variables:
269
+ // mode: outline-minor
270
+ // outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
271
+ // End:
pool/shard000/JavaScript/0001391_index.js ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {parseHeaders, isUndefined, isFunction, XMLHttpRequest, Promise, Error, assign} from 'j0';
2
+ import Request from '../../-request/j0polyfill/index.js';
3
+ import Response from '../../-response/j0polyfill/index.js';
4
+
5
+ export default function fetch(input, init, cb) {
6
+ const xhr = new XMLHttpRequest();
7
+ return assign(
8
+ new Promise((resolve, reject) => {
9
+ const request = new Request(input, init);
10
+ if (isFunction(cb)) {
11
+ cb(xhr);
12
+ }
13
+ assign(xhr, {
14
+ onload() {
15
+ const {status, statusText} = xhr;
16
+ const headers = parseHeaders(xhr.getAllResponseHeaders() || '');
17
+ const url = 'responseURL' in xhr ? xhr.responseURL : headers.get('X-Request-URL');
18
+ const body = 'response' in xhr ? xhr.response : xhr.responseText;
19
+ resolve(new Response(body, {status, statusText, headers, url}));
20
+ },
21
+ onabort: (event) => reject(assign(event.error || event || new Error('Aborted'), {code: 'EABORTED'})),
22
+ onerror: (event) => reject(event.error || event || new Error('Network request failed')),
23
+ ontimeout: (event) => reject(assign(event.error || event || new Error('Timeout'), {code: 'ETIMEOUT'})),
24
+ })
25
+ .open(request.method, request.url, true);
26
+ if (request.credentials === 'include') {
27
+ xhr.withCredentials = true;
28
+ }
29
+ xhr.responseType = 'blob';
30
+ for (const [name, value] of request.headers.entries()) {
31
+ xhr.setRequestHeader(name, value);
32
+ }
33
+ xhr.send(isUndefined(request.bodyInit) ? null : request.bodyInit);
34
+ }),
35
+ {xhr, abort: () => xhr.abort()}
36
+ );
37
+ }
pool/shard000/JavaScript/0001392_mysqlModel.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var graphlib = require('graphlib');
2
+ var Promise = require('promise');
3
+
4
+ function Collection(node)
5
+ {
6
+ this.select = '*';
7
+ this.from = node.id;
8
+ this.where = null;
9
+ this.groupBy = null;
10
+ this.orderBy = null;
11
+ }
12
+
13
+ Collection.prototype.with = function (params)
14
+ {
15
+
16
+ };
17
+
18
+ function MysqlModel(pool, nodes)
19
+ {
20
+ this.context = pool;
21
+ this.tables = new graphlib.Graph();
22
+ this.tables.nodes = nodes;
23
+
24
+ nodes.forEach(function (n)
25
+ {
26
+ this[n.id] = new Collection(n);
27
+ }, this);
28
+ }
pool/shard000/JavaScript/0001393_SettingsStore.js ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var AppDispatcher = require('../dispatcher/AppDispatcher'),
2
+ EventEmitter = require('events').EventEmitter,
3
+ assign = require('react/lib/Object.assign'),
4
+ Constants = require('../Constants'),
5
+ socket = require('socket'),
6
+
7
+ CHANGE_EVENT = 'change',
8
+ API = {
9
+ GET_SETTINGS : 'plugins.ns-awards.getSettings',
10
+ SAVE_SETTINGS: 'plugins.ns-awards.saveSettings'
11
+ },
12
+ _settings = {};
13
+
14
+ var SettingsStore = assign({}, EventEmitter.prototype, {
15
+ addChangeListener: function (listener) {
16
+ this.on(CHANGE_EVENT, listener);
17
+ },
18
+
19
+ emitChange: function () {
20
+ this.emit(CHANGE_EVENT);
21
+ },
22
+
23
+ getSettings: function () {
24
+ return _settings;
25
+ },
26
+
27
+ removeChangeListener: function (listener) {
28
+ this.removeListener(CHANGE_EVENT, listener);
29
+ }
30
+ });
31
+
32
+ AppDispatcher.register(function (action) {
33
+ switch (action.actionType) {
34
+ case Constants.EVENT_GET_SETTINGS:
35
+ socket.emit(API.GET_SETTINGS, {}, function (error, settings) {
36
+ if (error) {
37
+ console.error(error);
38
+ }
39
+ _settings = settings;
40
+ SettingsStore.emitChange();
41
+ });
42
+ break;
43
+ case Constants.EVENT_SAVE_SETTINGS:
44
+ socket.emit(API.SAVE_SETTINGS, {
45
+ settings: action.settings
46
+ }, function (error, settings) {
47
+ if (error) {
48
+ console.error(error);
49
+ }
50
+ _settings = settings;
51
+ SettingsStore.emitChange();
52
+ });
53
+ break;
54
+ default:
55
+ return true;
56
+ }
57
+ });
58
+
59
+ module.exports = SettingsStore;
pool/shard000/JavaScript/0001398_smartphone.js ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _react = require('react');
8
+
9
+ var _react2 = _interopRequireDefault(_react);
10
+
11
+ var _pure = require('recompose/pure');
12
+
13
+ var _pure2 = _interopRequireDefault(_pure);
14
+
15
+ var _SvgIcon = require('../../SvgIcon');
16
+
17
+ var _SvgIcon2 = _interopRequireDefault(_SvgIcon);
18
+
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+
21
+ var HardwareSmartphone = function HardwareSmartphone(props) {
22
+ return _react2.default.createElement(
23
+ _SvgIcon2.default,
24
+ props,
25
+ _react2.default.createElement('path', { d: 'M17 1.01L7 1c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99zM17 19H7V5h10v14z' })
26
+ );
27
+ };
28
+ HardwareSmartphone = (0, _pure2.default)(HardwareSmartphone);
29
+ HardwareSmartphone.displayName = 'HardwareSmartphone';
30
+ HardwareSmartphone.muiName = 'SvgIcon';
31
+
32
+ exports.default = HardwareSmartphone;
pool/shard000/JavaScript/0001400_PolylineComplex.js ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import _ from "lodash";
3
+ import PropTypes from "prop-types";
4
+ import { FormProps, wrapWithForm } from "../../../../hocs/WrapWithForm";
5
+ import { Polyline } from "../../../../../modules/polyline/Polyline";
6
+ import { GoogleMap } from "../../../../../modules/google-map/GoogleMap";
7
+
8
+ export const pageName = "Complex Example";
9
+
10
+ const enhancer = wrapWithForm();
11
+
12
+ const getPath = _.flow(
13
+ x => _.get(x, ["routes", 0, "overview_path"]),
14
+ JSON.stringify,
15
+ JSON.parse,
16
+ );
17
+
18
+ class PolylineComplex extends React.Component {
19
+ static contextTypes = {
20
+ maps: PropTypes.object.isRequired,
21
+ center: PropTypes.object.isRequired,
22
+ styles: PropTypes.object.isRequired,
23
+ };
24
+
25
+ static propTypes = {
26
+ origin: FormProps.oneOf("Origin", [
27
+ "san jose, ca",
28
+ "palo alto, ca",
29
+ "gilroy, ca",
30
+ "salinas, ca",
31
+ "monterey, ca",
32
+ ]),
33
+
34
+ destination: FormProps.oneOf("Destination", [
35
+ "san jose, ca",
36
+ "palo alto, ca",
37
+ "gilroy, ca",
38
+ "salinas, ca",
39
+ "monterey, ca",
40
+ ]),
41
+ };
42
+
43
+ static defaultProps = {
44
+ origin: "san jose, ca",
45
+ destination: "gilroy, ca",
46
+ };
47
+
48
+ constructor(props, context) {
49
+ super(props, context);
50
+
51
+ const { maps: { DirectionsService } } = context;
52
+
53
+ this.state = { path: null };
54
+ this.service = new DirectionsService();
55
+ }
56
+
57
+ componentDidMount() {
58
+ const { origin, destination } = this.props;
59
+
60
+ this.fetchDirections(origin, destination);
61
+ }
62
+
63
+ componentDidUpdate(prevProps) {
64
+ const { origin, destination } = this.props;
65
+
66
+ if (origin !== prevProps.origin || destination !== prevProps.destination) {
67
+ this.fetchDirections(origin, destination);
68
+ }
69
+ }
70
+
71
+ fetchDirections(origin, destination) {
72
+ if (origin && destination) {
73
+ this.setState({ path: null });
74
+
75
+ this.service.route(
76
+ { origin, destination, travelMode: "DRIVING" },
77
+ (result, status) => {
78
+ if (status === "OK") {
79
+ this.setState({ path: getPath(result) });
80
+ } else {
81
+ this.setState({ path: null });
82
+ }
83
+ },
84
+ );
85
+ }
86
+ }
87
+
88
+ render() {
89
+ const { path } = this.state;
90
+ const { maps, styles, center } = this.context;
91
+
92
+ return (
93
+ <GoogleMap zoom={8} maps={maps} style={styles.map} center={center}>
94
+ {path && <Polyline path={path} />}
95
+ </GoogleMap>
96
+ );
97
+ }
98
+ }
99
+
100
+ export default enhancer(PolylineComplex);
pool/shard000/JavaScript/0001411_newtonian.js ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * class NewtonianBehavior < Behavior
3
+ *
4
+ * `Physics.behavior('newtonian')`.
5
+ *
6
+ * Newtonian attraction between bodies (inverse square law).
7
+ *
8
+ * Additional options include:
9
+ * - strength: The strength of the interaction between bodies. (default: `1`)
10
+ * - max: The maximum distance between bodies at which to apply the behavior. (default: `false`... infinite)
11
+ * - min: The minimum distance between bodies at which to apply the behavior. (default: `false`... autocalculate)
12
+ **/
13
+ Physics.behavior('newtonian', function( parent ){
14
+
15
+ var defaults = {
16
+
17
+ strength: 1,
18
+ // max distance to apply it to
19
+ max: false, // infinite
20
+ // min distance to apply it to
21
+ min: false // auto calc
22
+ };
23
+
24
+ return {
25
+
26
+ // extended
27
+ init: function( options ){
28
+
29
+ var self = this;
30
+ // call parent init method
31
+ parent.init.call( this );
32
+ this.options.defaults( defaults );
33
+ this.options.onChange(function( opts ){
34
+ self._maxDistSq = opts.max === false ? Infinity : opts.max * opts.max;
35
+ self._minDistSq = opts.min ? opts.min * opts.min : 100 * opts.strength;
36
+ });
37
+ this.options( options );
38
+ },
39
+
40
+ calcPotential: function( posA, posB, out ){
41
+
42
+ var strength = this.options.strength
43
+ ,minDistSq = this._minDistSq
44
+ ,maxDistSq = this._maxDistSq
45
+ ,normsq
46
+ ,g
47
+ ,pos
48
+ ;
49
+
50
+ pos = out || new Physics.vector();
51
+
52
+ // clone the position
53
+ pos.clone( posB ).vsub( posA );
54
+ // get the square distance
55
+ normsq = pos.normSq();
56
+
57
+ if (normsq > minDistSq && normsq < maxDistSq){
58
+
59
+ g = strength / normsq;
60
+ return pos.normalize().mult( g );
61
+ }
62
+
63
+ return pos.zero();
64
+ },
65
+
66
+ // extended
67
+ behave: function( data ){
68
+
69
+ var bodies = this.getTargets()
70
+ ,body
71
+ ,other
72
+ ,scratch = Physics.scratchpad()
73
+ ,potential = scratch.vector()
74
+ ,comp
75
+ ,bodyA
76
+ ,bodyB
77
+ ,posA = scratch.vector()
78
+ ,posB = scratch.vector()
79
+ ,i, j, k, m, l, ll, lll
80
+ ;
81
+
82
+ for ( j = 0, l = bodies.length; j < l; j++ ){
83
+
84
+ body = bodies[ j ];
85
+
86
+ for ( i = j + 1; i < l; i++ ){
87
+
88
+ other = bodies[ i ];
89
+
90
+ if ( body.name === 'compound' ){
91
+ comp = body;
92
+ } else if ( other.name === 'compound' ){
93
+ comp = other;
94
+ other = body;
95
+ }
96
+
97
+ if ( comp ){
98
+ if ( other.name === 'compound' ){
99
+ for ( k = 0, ll = comp.children.length; k < ll; k++ ){
100
+ bodyA = comp.children[ k ];
101
+ comp.toWorldCoords( posA.clone( bodyA.state.pos ).vadd( comp.offset ) );
102
+ for ( m = 0, lll = other.children.length; m < lll; m++ ){
103
+ bodyB = other.children[ m ];
104
+ other.toWorldCoords( posB.clone( bodyB.state.pos ).vadd( other.offset ) );
105
+ this.calcPotential( posA, posB, potential );
106
+ comp.accelerate( potential.mult( bodyB.mass ) );
107
+ other.accelerate( potential.mult( bodyA.mass/bodyB.mass ).negate() );
108
+ }
109
+ }
110
+ } else {
111
+ for ( k = 0, ll = comp.children.length; k < ll; k++ ){
112
+ bodyA = comp.children[ k ];
113
+ comp.toWorldCoords( posA.clone( bodyA.state.pos ).vadd( comp.offset ) );
114
+ this.calcPotential( posA, other.state.pos, potential );
115
+ comp.accelerate( potential.mult( other.mass ) );
116
+ other.accelerate( potential.mult( bodyA.mass/other.mass ).negate() );
117
+ }
118
+ }
119
+
120
+ } else {
121
+
122
+ this.calcPotential( body.state.pos, other.state.pos, potential );
123
+ body.accelerate( potential.mult( other.mass ) );
124
+ other.accelerate( potential.mult( body.mass/other.mass ).negate() );
125
+ }
126
+
127
+ comp = null;
128
+ }
129
+ }
130
+
131
+ scratch.done();
132
+ }
133
+ };
134
+ });
pool/shard000/JavaScript/0001412_alv-ch-ng.ui-core.directive.collapsible.unit.spec.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ;(function() {
2
+
3
+ describe("collapsible directive", function() {
4
+
5
+ beforeEach(module('alv-ch-ng.ui-core', function() {
6
+
7
+ }));
8
+
9
+ it('adds the necessary classes and attributes.', function() {
10
+ inject(function ($compile, $rootScope) {
11
+ var scope = $rootScope.$new();
12
+ var elem = angular.element('<div><div collapsible>testContent</div></div>');
13
+ $compile(elem)(scope);
14
+ expect(elem.html()).toEqual('<div collapsible="" class="pointer" data-toggle="collapse" data-target="">testContent</div>');
15
+ });
16
+
17
+ });
18
+
19
+ });
20
+
21
+ }());
pool/shard000/JavaScript/0001417_2d.drawImage.9arg.destsize.worker.js ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // DO NOT EDIT! This test has been generated by /offscreen-canvas/tools/gentest.py.
2
+ // OffscreenCanvas test in a worker:2d.drawImage.9arg.destsize
3
+ // Description:
4
+ // Note:
5
+
6
+ importScripts("/resources/testharness.js");
7
+ importScripts("/2dcontext/resources/canvas-tests.js");
8
+
9
+ var t = async_test("");
10
+ var t_pass = t.done.bind(t);
11
+ var t_fail = t.step_func(function(reason) {
12
+ throw reason;
13
+ });
14
+ t.step(function() {
15
+
16
+ var offscreenCanvas = new OffscreenCanvas(100, 50);
17
+ var ctx = offscreenCanvas.getContext('2d');
18
+
19
+ ctx.fillStyle = '#f00';
20
+ ctx.fillRect(0, 0, 100, 50);
21
+ var promise1 = new Promise(function(resolve, reject) {
22
+ var xhr = new XMLHttpRequest();
23
+ xhr.open("GET", '/images/red.png');
24
+ xhr.responseType = 'blob';
25
+ xhr.send();
26
+ xhr.onload = function() {
27
+ resolve(xhr.response);
28
+ };
29
+ });
30
+ var promise2 = new Promise(function(resolve, reject) {
31
+ var xhr = new XMLHttpRequest();
32
+ xhr.open("GET", '/images/green.png');
33
+ xhr.responseType = 'blob';
34
+ xhr.send();
35
+ xhr.onload = function() {
36
+ resolve(xhr.response);
37
+ };
38
+ });
39
+ Promise.all([promise1, promise2]).then(function(response1, response2) {
40
+ var promise3 = createImageBitmap(response1);
41
+ var promise4 = createImageBitmap(response2);
42
+ Promise.all([promise3, promise4]).then(function(bitmap1, bitmap2) {
43
+ ctx.drawImage(bitmap2, 1, 1, 1, 1, 0, 0, 100, 50);
44
+ ctx.drawImage(bitmap1, 0, 0, 100, 50, -50, 0, 50, 50);
45
+ ctx.drawImage(bitmap1, 0, 0, 100, 50, 100, 0, 50, 50);
46
+ ctx.drawImage(bitmap1, 0, 0, 100, 50, 0, -25, 100, 25);
47
+ ctx.drawImage(bitmap1, 0, 0, 100, 50, 0, 50, 100, 25);
48
+ _assertPixelApprox(offscreenCanvas, 0,0, 0,255,0,255, "0,0", "0,255,0,255", 2);
49
+ _assertPixelApprox(offscreenCanvas, 99,0, 0,255,0,255, "99,0", "0,255,0,255", 2);
50
+ _assertPixelApprox(offscreenCanvas, 0,49, 0,255,0,255, "0,49", "0,255,0,255", 2);
51
+ _assertPixelApprox(offscreenCanvas, 99,49, 0,255,0,255, "99,49", "0,255,0,255", 2);
52
+ }, t_fail);
53
+ }).then(t_pass, t_fail);
54
+
55
+ });
56
+ done();
pool/shard000/JavaScript/0001418_anim1.js ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ engine.ImportExtension("qt.core");
2
+ engine.ImportExtension("qt.gui");
3
+
4
+ var label = new QLabel();
5
+ label.objectName = "InfoLabel";
6
+ label.setStyleSheet("QLabel#InfoLabel { padding: 10px; background-color: rgba(230,230,230,10); border: 1px solid black; font-size: 16px; }");
7
+ label.text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\n\
8
+ tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim\n\
9
+ veniam, quis nostrudexercitation ullamco laboris nisi ut aliquip ex ea\n\
10
+ commodo consequat. Duis aute irure dolor in reprehenderit in voluptate\n\
11
+ velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint\n\
12
+ occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit\n\
13
+ anim id est laborum.";
14
+
15
+ var proxy = ui.AddWidgetToScene(label);
16
+
17
+ proxy.windowFlags = 0;
18
+ proxy.visible = true;
19
+ proxy.focusPolicy = Qt.NoFocus;
20
+ proxy.x = 400;
21
+ proxy.y = 300;
22
+
23
+ frame.Updated.connect(OnFrameUpdate);
24
+ function OnFrameUpdate()
25
+ {
26
+ var alpha = (Math.sin(frame.WallClockTime()*5)*0.5 + 0.5) * 255;
27
+ // label.setStyleSheet("QLabel#InfoLabel { padding: 10px; background-color: rgba(230,230,230," + alpha + "); border: 1px solid black; font-size: 16px; }");
28
+ label.resize(600 + Math.sin(frame.WallClockTime()) * 30, 300 + Math.cos(frame.WallClockTime()) * 100);
29
+ }
30
+
31
+ function OnScriptDestroyed()
32
+ {
33
+ label.deleteLater();
34
+ }
pool/shard000/JavaScript/0001420_main.js ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var express = require('express');
2
+ var app = express();
3
+
4
+ app.use(express.bodyParser()); // Populate req.body
5
+
6
+ // // basic auth not enabled for this route
7
+ // app.get('/', function(req, res) {
8
+ // res.send('Unathorized request made');
9
+ // });
10
+ // // basic auth not enabled for this route
11
+ // app.get('/testget', function(req, res) {
12
+ // //res.send('Request made with get to test');
13
+ // var Message = Parse.Object.extend("Message");
14
+ // var message = new Message();
15
+ // message.save({
16
+ // text: req.body.text
17
+ // }).then(function(message) {
18
+ // res.send('Success saving the var' + req.body.text);
19
+ // }, function(error) {
20
+ // res.status(500);
21
+ // res.send('Error');
22
+ // });
23
+ // });
24
+
25
+ // basic auth is enabled for this route
26
+ app.post('/test',
27
+ // express.basicAuth('username', 'password'),
28
+
29
+ function(req, res) {
30
+ console.log("Body is: "+req.body);
31
+ console.log("Body Name is: "+req.param('message'));
32
+ if (req.body.message == "hello") {
33
+ var Message = Parse.Object.extend("Message");
34
+ var message = new Message();
35
+ message.save({
36
+ username: req.body.message
37
+ }).then(function(message) {
38
+ res.send('Success saving the user: ' +req.body.message);
39
+ }, function(error) {
40
+ res.status(500);
41
+ res.send('Error');
42
+ });
43
+ }else{
44
+ res.status(406);
45
+ res.send('Bad username');
46
+ }
47
+ });
48
+
49
+ app.listen();
pool/shard000/JavaScript/0001425_event-schedule.js ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ export default class Widget {
4
+ constructor(selector) {
5
+ this.$root = $(selector);
6
+ this.locals = this._getDom();
7
+
8
+ const $firstLink = this.locals.$links.first();
9
+ this._setInitialValues();
10
+ this.filterListByLink($firstLink);
11
+ this._assignEvents();
12
+ }
13
+
14
+ _getDom() {
15
+ return {
16
+ $links: this.$root.find('[data-upevent-link]'),
17
+ $total: this.$root.find('[data-upevent-total]'),
18
+ $now: this.$root.find('[data-upevent-now]'),
19
+ $items: this.$root.find('.b-eventfut'),
20
+ $text: this.$root.find('[data-upevent-text]'),
21
+ $switcher: this.$root.find('[data-schedule-switcher]')
22
+ };
23
+ }
24
+
25
+ _setInitialValues(){
26
+ const locals = this.locals;
27
+ const currentCount = locals.$items.filter('.current').length;
28
+
29
+ locals.$total.text(locals.$items.length);
30
+ locals.$now.text(locals.$items.filter('.current').length);
31
+
32
+ switch (currentCount) {
33
+ case 0:
34
+ locals.$switcher.hide();
35
+ break;
36
+ case 1:
37
+ locals.$text.text('is running now');
38
+ break;
39
+ default:
40
+ locals.$text.text('are running now');
41
+ break;
42
+ }
43
+ }
44
+
45
+ _assignEvents() {
46
+ this.$root.on('click', '[data-upevent-link]', this._onClickFilter.bind(this));
47
+ }
48
+
49
+ _onClickFilter(e){
50
+ e.preventDefault();
51
+ const $link = $(e.target).closest('[data-upevent-link]');
52
+
53
+ if ($link.hasClass('state_active')) return;
54
+ this.filterListByLink($link);
55
+ }
56
+
57
+ filterListByLink($el){
58
+ const locals = this.locals;
59
+ const filterClass = $el.data('upevent-link');
60
+ const $filtered = filterClass? locals.$items.filter('.' + filterClass): null ;
61
+
62
+ locals.$items.removeClass('b-eventfut_state_disabled');
63
+ if ($filtered) {
64
+ locals.$items.addClass('b-eventfut_state_disabled');
65
+ $filtered.removeClass('b-eventfut_state_disabled');
66
+ }
67
+
68
+ locals.$links.removeClass('state_active');
69
+ $el.addClass('state_active');
70
+ }
71
+
72
+ // static
73
+ static plugin(selector) {
74
+ const $elems = $(selector);
75
+ if (!$elems.length) return;
76
+
77
+ return $elems.each(function (index, el) {
78
+ let $element = $(el);
79
+ let data = $element.data('hmt.events.upcoming');
80
+
81
+ if (!data) {
82
+ data = new Widget(el);
83
+ $element.data('widget', data);
84
+ }
85
+ })
86
+ }
87
+ }
88
+
pool/shard000/JavaScript/0001428_userForgot.js ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function __processArg(obj, key) {
2
+ var arg = null;
3
+ if (obj) {
4
+ arg = obj[key] || null;
5
+ delete obj[key];
6
+ }
7
+ return arg;
8
+ }
9
+
10
+ function Controller() {
11
+ require("alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments));
12
+ this.__controllerPath = "userForgot";
13
+ if (arguments[0]) {
14
+ {
15
+ __processArg(arguments[0], "__parentSymbol");
16
+ }
17
+ {
18
+ __processArg(arguments[0], "$model");
19
+ }
20
+ {
21
+ __processArg(arguments[0], "__itemTemplate");
22
+ }
23
+ }
24
+ var $ = this;
25
+ var exports = {};
26
+ var __defers = {};
27
+ $.__views.userForgot = Ti.UI.createWindow({
28
+ backgroundColor: "#FFF",
29
+ opacity: 1,
30
+ width: Ti.UI.FILL,
31
+ height: Ti.UI.FILL,
32
+ layout: "vertical",
33
+ navBarHidden: true,
34
+ id: "userForgot"
35
+ });
36
+ $.__views.userForgot && $.addTopLevelView($.__views.userForgot);
37
+ $.__views.__alloyId32 = Ti.UI.createView({
38
+ height: Ti.UI.SIZE,
39
+ width: Ti.UI.FILL,
40
+ backgroundColor: Alloy.CFG.Colors.MainColor,
41
+ top: 0,
42
+ id: "__alloyId32"
43
+ });
44
+ $.__views.userForgot.add($.__views.__alloyId32);
45
+ $.__views.AppWrapper = Ti.UI.createView({
46
+ height: Ti.UI.SIZE,
47
+ id: "AppWrapper"
48
+ });
49
+ $.__views.__alloyId32.add($.__views.AppWrapper);
50
+ $.__views.mainTitle = Ti.UI.createLabel({
51
+ font: {
52
+ fontSize: 20,
53
+ fontFamily: "Monda-Regular"
54
+ },
55
+ height: 44.4,
56
+ color: "#FFF",
57
+ left: "30",
58
+ id: "mainTitle",
59
+ text: "Forgot Password"
60
+ });
61
+ $.__views.AppWrapper.add($.__views.mainTitle);
62
+ closeWindow ? $.__views.mainTitle.addEventListener("click", closeWindow) : __defers["$.__views.mainTitle!click!closeWindow"] = true;
63
+ $.__views.imgBack = Ti.UI.createImageView({
64
+ left: 5,
65
+ width: 30,
66
+ height: 30,
67
+ right: 5,
68
+ id: "imgBack"
69
+ });
70
+ $.__views.AppWrapper.add($.__views.imgBack);
71
+ closeWindow ? $.__views.imgBack.addEventListener("click", closeWindow) : __defers["$.__views.imgBack!click!closeWindow"] = true;
72
+ $.__views.forgotPasswordView = Ti.UI.createScrollView({
73
+ layout: "vertical",
74
+ left: 15,
75
+ right: 15,
76
+ top: 5,
77
+ id: "forgotPasswordView"
78
+ });
79
+ $.__views.userForgot.add($.__views.forgotPasswordView);
80
+ $.__views.__alloyId33 = Ti.UI.createView({
81
+ layout: "horizontal",
82
+ width: Ti.UI.SIZE,
83
+ height: Ti.UI.SIZE,
84
+ top: 5,
85
+ left: "0",
86
+ id: "__alloyId33"
87
+ });
88
+ $.__views.forgotPasswordView.add($.__views.__alloyId33);
89
+ $.__views.imgEmailForgot = Ti.UI.createImageView({
90
+ top: 15,
91
+ width: 15,
92
+ height: 15,
93
+ left: 5,
94
+ right: 5,
95
+ id: "imgEmailForgot"
96
+ });
97
+ $.__views.__alloyId33.add($.__views.imgEmailForgot);
98
+ $.__views.lblEmail = Ti.UI.createLabel({
99
+ font: {
100
+ fontSize: 17,
101
+ fontFamily: "Monda-Regular",
102
+ fontWeight: "bold"
103
+ },
104
+ height: Ti.UI.SIZE,
105
+ textAlign: "left",
106
+ text: "Email",
107
+ top: "9",
108
+ color: "#464646",
109
+ id: "lblEmail"
110
+ });
111
+ $.__views.__alloyId33.add($.__views.lblEmail);
112
+ $.__views.txtEmailForgot = Ti.UI.createTextField({
113
+ top: 5,
114
+ width: "98%",
115
+ left: "1%",
116
+ right: "1%",
117
+ borderWidth: 1,
118
+ borderColor: Alloy.CFG.Colors.MainColor,
119
+ backgroundColor: "#EEE",
120
+ color: "#222",
121
+ font: {
122
+ fontFamily: "Monda-Regular"
123
+ },
124
+ borderRadius: 7,
125
+ id: "txtEmailForgot",
126
+ hintText: "Email"
127
+ });
128
+ $.__views.forgotPasswordView.add($.__views.txtEmailForgot);
129
+ $.__views.btnRequest = Ti.UI.createButton({
130
+ font: {
131
+ fontSize: 13,
132
+ fontFamily: "Monda-Regular"
133
+ },
134
+ height: 33.3,
135
+ top: 20,
136
+ bottom: 10,
137
+ width: "98%",
138
+ left: "1%",
139
+ right: "1%",
140
+ backgroundColor: Alloy.CFG.Colors.MainColor,
141
+ backgroundSelectedColor: Alloy.CFG.Colors.MainColor_Dark,
142
+ borderColor: Alloy.CFG.Colors.MainPressedColor,
143
+ color: Alloy.CFG.Colors.TextColor,
144
+ backgroundImage: "null",
145
+ selectedColor: "#AAA",
146
+ id: "btnRequest",
147
+ title: " Request "
148
+ });
149
+ $.__views.forgotPasswordView.add($.__views.btnRequest);
150
+ forgotProcess ? $.__views.btnRequest.addEventListener("click", forgotProcess) : __defers["$.__views.btnRequest!click!forgotProcess"] = true;
151
+ exports.destroy = function() {};
152
+ _.extend($, $.__views);
153
+ arguments[0] || {};
154
+ var __ = require("platformSupport");
155
+ var myAnimation = require("animation");
156
+ var loader = require("loader");
157
+ var validation = require("validationRules");
158
+ var dialogBox = require("psdialog");
159
+ var changeFlag = 0;
160
+ var fontIconLoader = require("icomoonlib");
161
+ var changeFlag = 0;
162
+ var loadingWindow = require("loadingWindow");
163
+ loadingWindow.endLoading();
164
+ __.isiOS7Plus() && ($.AppWrapper.top = 20);
165
+ var closeWindow = function() {
166
+ myAnimation.out($.userForgot);
167
+ };
168
+ var forgotProcess = function() {
169
+ if (validationForgotChecking()) if (true == Titanium.Network.online) {
170
+ loadingWindow.startLoading();
171
+ var loaderArgs = {
172
+ callbackFunction: forgotPasswordSent,
173
+ url: Alloy.CFG.Urls.BaseURL + ALloy.CFG.Urls.getForgotPassword + $.txtEmailForgot.value.toLowerCase()
174
+ };
175
+ loader.get(loaderArgs);
176
+ } else dialogBox.loadCustomDialog("Forgot Password", Alloy.CFG.Languages.offlineMessage);
177
+ };
178
+ var forgotPasswordSent = function(feeds) {
179
+ loadingWindow.endLoading();
180
+ if (feeds.success) {
181
+ dialogBox.loadCustomDialog("Forgot Password", Alloy.CFG.Languages.forgotPasswordMessage);
182
+ closeWindow();
183
+ }
184
+ };
185
+ var validationForgotChecking = function() {
186
+ if ("" == $.txtEmailForgot.value) {
187
+ validation.validationFailAction($.txtEmailForgot);
188
+ changeFlag = 0;
189
+ return false;
190
+ }
191
+ if (!validation.validateEmail($.txtEmailForgot.value)) {
192
+ validation.validationFailAction($.txtEmailForgot);
193
+ changeFlag = 0;
194
+ return false;
195
+ }
196
+ return true;
197
+ };
198
+ $.txtEmailForgot.addEventListener("change", function() {
199
+ if (0 == changeFlag) {
200
+ validation.backToNormal($.txtEmailForgot);
201
+ changeFlag = 1;
202
+ }
203
+ });
204
+ var loadIcon = function() {
205
+ var emailIcon = fontIconLoader.getIcon("panacea", "envelope", 35, {
206
+ color: Alloy.CFG.Colors.IconColor
207
+ });
208
+ $.imgEmailForgot.image = emailIcon;
209
+ var backIcon = fontIconLoader.getIcon("panacea", "back", 35, {
210
+ color: Alloy.CFG.Colors.IconWhite
211
+ });
212
+ $.imgBack.image = backIcon;
213
+ };
214
+ var loadLanguage = function() {
215
+ $.lblEmail.text = Alloy.CFG.Languages.lblEmail;
216
+ $.btnRequest.title = Alloy.CFG.Languages.btnRequest;
217
+ };
218
+ var init = function() {
219
+ loadIcon();
220
+ loadLanguage();
221
+ myAnimation.slowlyAppear($.forgotPasswordView);
222
+ };
223
+ $.userForgot.addEventListener("open", function() {
224
+ loadingWindow.endLoading();
225
+ init();
226
+ });
227
+ __defers["$.__views.mainTitle!click!closeWindow"] && $.__views.mainTitle.addEventListener("click", closeWindow);
228
+ __defers["$.__views.imgBack!click!closeWindow"] && $.__views.imgBack.addEventListener("click", closeWindow);
229
+ __defers["$.__views.btnRequest!click!forgotProcess"] && $.__views.btnRequest.addEventListener("click", forgotProcess);
230
+ _.extend($, exports);
231
+ }
232
+
233
+ var Alloy = require("alloy"), Backbone = Alloy.Backbone, _ = Alloy._;
234
+
235
+ module.exports = Controller;
pool/shard000/JavaScript/0001432_root.test.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import expect from "expect";
3
+ import { shallow } from 'enzyme';
4
+
5
+ import Root from "./root";
6
+ import Header from "./header";
7
+
8
+ describe("/components/root", () => {
9
+
10
+ let root;
11
+
12
+ beforeEach(() => {
13
+ root = shallow(<Root/>);
14
+ });
15
+
16
+ it("should render", () => {
17
+ expect(root).toExist();
18
+ });
19
+
20
+ it("should contains one Header element", () => {
21
+ const header = root.find(Header);
22
+ expect(header.length).toEqual(1);
23
+ });
24
+
25
+ it("should render children component", () => {
26
+ root = shallow(<Root><p>any child</p></Root>);
27
+ const question = root.find("p");
28
+ expect(question.length).toEqual(1);
29
+ });
30
+
31
+ });
pool/shard000/JavaScript/0001433_profile.js ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+
3
+ import { Button, Checkbox } from 'react-bootstrap';
4
+
5
+ import './styles.scss';
6
+
7
+ class Profile extends React.Component {
8
+ constructor(props) {
9
+ super(props);
10
+ this.state = {
11
+ showDetails: false,
12
+ count: 0,
13
+ };
14
+ this.handleClick = this.handleClick.bind(this);
15
+ this.handleChangeSelection = this.handleChangeSelection.bind(this);
16
+ }
17
+ handleClick() {
18
+ global.console.log('button clicked');
19
+ this.setState({
20
+ showDetails: true,
21
+ });
22
+ }
23
+ handleChangeSelection() {
24
+ this.setState({
25
+ showDetails: !this.state.showDetails,
26
+ count: this.state.count + 1,
27
+ });
28
+ }
29
+ render() {
30
+ const { showDetails } = this.state;
31
+ let name = this.props.name;
32
+ return (
33
+ <div className='profile'>
34
+ <h1>{name}</h1>
35
+ <Checkbox checked={showDetails} onChange={this.handleChangeSelection}>
36
+ Mostrar detalhes (<span>{this.state.count}</span>)
37
+ </Checkbox>
38
+ <Button bsStyle='success' onClick={this.handleClick}>Success</Button>
39
+ </div>
40
+ );
41
+ }
42
+ }
43
+
44
+ Profile.propTypes = {
45
+ name: React.PropTypes.string,
46
+ };
47
+
48
+ Profile.defaultProps = {
49
+ name: 'unnamed',
50
+ };
51
+
52
+ export default Profile;
pool/shard000/JavaScript/0001434_table.row.js ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ // Register `phoneList` component, along with its associated controller and template
4
+ angular.
5
+ module('raceConditions').controller('tableRowController', function tableController($location,$scope,$rootScope,$timeout,$interval,$http) {
6
+ //INTERVAL
7
+ var init = function (){
8
+ if(!$rootScope.registered){
9
+ $location.url('/login');
10
+ }
11
+ }
12
+ init();
13
+
14
+ var timer;
15
+ $scope.count = 0;
16
+ timer = $interval(getTableAsync,2500);
17
+
18
+ var getTableSuccess = function(responseData){
19
+ $scope.done=false;
20
+ console.log("getTableSuccess");
21
+ console.log(responseData.data);
22
+ if(responseData.data.status == "error"){
23
+ $rootScope.registered = false;
24
+ $location.url('/login');
25
+ }
26
+ $scope.table = responseData.data.ret;
27
+ }
28
+
29
+ var getTableError = function(error){
30
+ console.log("getTableError");
31
+ console.log(error);
32
+ }
33
+
34
+ var getTableAsync= function () {
35
+ var data = JSON.stringify({
36
+ "tableInfoKey": $rootScope.tableKey
37
+ });
38
+ $http.post($rootScope.RCURL+"/tableAPI/v1/getTable",data,$rootScope.requestConfig).then(getTableSuccess,getTableError);
39
+ }
40
+ getTableAsync();
41
+
42
+ var inputChangedPromise;
43
+ $scope.inputChanged = function(){
44
+ $interval.cancel(timer);
45
+ if(inputChangedPromise){
46
+ $timeout.cancel(inputChangedPromise);
47
+ }
48
+ inputChangedPromise = $timeout(updateValues,1000);
49
+ }
50
+
51
+ var updateValuesSuccess = function(responseData){
52
+
53
+ console.log("updateValuesSuccess");
54
+ console.log(responseData.data);
55
+ if(responseData.data.status == "error"){
56
+ $rootScope.registered = false;
57
+ $location.url('/login');
58
+ }
59
+ timer = $interval(getTableAsync,2500);
60
+ }
61
+
62
+ var updateValuesError = function(error){
63
+ console.log("updateValuesError");
64
+ console.log(error);
65
+ }
66
+
67
+ var updateValues = function(){
68
+ var data = JSON.stringify({
69
+ "tableInfoKey": $scope.table.tableInfoKey,
70
+ "columnKey": $scope.id,
71
+ "columnNames": [
72
+ $scope.table.columnNames[$scope.index]
73
+ ],
74
+ "columnValues": [
75
+ $scope.model[$scope.id + $scope.index]
76
+ ]
77
+ });
78
+ $http.post($rootScope.RCURL+"/tableAPI/v1/modifyRow",data,$rootScope.requestConfig).then(updateValuesSuccess,updateValuesError);
79
+ }
80
+
81
+ $scope.eEditable= -1;
82
+ $scope.eElement;
83
+ $scope.model={};
84
+ $scope.editing = function (id, index) {
85
+ $scope.id =id;
86
+ $scope.index =index;
87
+ $scope.eEditable = index;
88
+ }
89
+ });
pool/shard000/JavaScript/0001436_socket.js ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * carcassonne-scoreboard-client
3
+ *
4
+ * @author Andrea Sonny <andreasonny83@gmail.com>
5
+ * @license MIT
6
+ *
7
+ * https://andreasonny.mit-license.org/
8
+ *
9
+ */
10
+ (function() {
11
+ 'use strict';
12
+
13
+ angular
14
+ .module('socket', [])
15
+ .factory('socket', factory);
16
+
17
+ factory.$inject = ['$rootScope', 'serverApp'];
18
+
19
+ /* @ngInject */
20
+ function factory($rootScope, serverApp) {
21
+ // server url
22
+ var socket = io(serverApp.server + ':' + serverApp.port);
23
+
24
+ function on(eventName, callback) {
25
+ // prevent creating multiple listeners
26
+ if ( socket._callbacks['$'+eventName] ) {
27
+ socket._callbacks['$'+eventName] = [];
28
+ }
29
+
30
+ socket.on(eventName, function () {
31
+ var args = arguments;
32
+
33
+ $rootScope.$apply(function () {
34
+ callback.apply(socket, args);
35
+ });
36
+ });
37
+ }
38
+
39
+ function emit(eventName, data, callback) {
40
+ // prevent creating multiple listeners
41
+ if ( socket._callbacks['$'+eventName] ) {
42
+ socket._callbacks['$'+eventName] = [];
43
+ }
44
+
45
+ socket.emit(eventName, data, function () {
46
+ var args = arguments;
47
+
48
+ $rootScope.$apply(function () {
49
+ if (callback) {
50
+ callback.apply(socket, args);
51
+ }
52
+ });
53
+ });
54
+ }
55
+
56
+ return {
57
+ on: on,
58
+ emit: emit
59
+ };
60
+ }
61
+ })();
pool/shard000/JavaScript/0001439_partida.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ module.exports = function(sequelize, DataTypes) {
4
+ var Partida = sequelize.define('partida', {
5
+ id: {type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true, unique: true},
6
+ data: DataTypes.DATE
7
+ }, {
8
+ freezeTableName: true,
9
+ underscored: true,
10
+ classMethods: {
11
+ associate: function(models) {
12
+ Partida.hasOne(models.time, {
13
+ as : 'timeA',
14
+ foreignKey : 'fk_partida_time_a'
15
+ });
16
+ Partida.hasOne(models.time, {
17
+ as : 'timeB',
18
+ foreignKey : 'fk_partida_time_b'
19
+ });
20
+ Partida.hasOne(models.local);
21
+ }
22
+ }
23
+ });
24
+ return Partida;
25
+ }
pool/shard000/JavaScript/0001441_knockout-switch-case.js ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license SWITCH/CASE binding for Knockout http://knockoutjs.com/
3
+ * (c) Michael Best
4
+ * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
+ * Version 2.1.0
6
+ */
7
+
8
+ (function (root, factory) {
9
+ if (typeof define === 'function' && define.amd) {
10
+ // AMD. Register as an anonymous module.
11
+ define(['knockout'], factory);
12
+ } else {
13
+ // Browser globals
14
+ factory(root.ko);
15
+ }
16
+ }(this, function (ko) {
17
+
18
+ var undefined;
19
+
20
+ if (!ko.virtualElements)
21
+ throw Error('Switch-case requires at least Knockout 2.1');
22
+
23
+ var ko_virtualElements = ko.virtualElements;
24
+ var ko_bindingFlags = ko.bindingFlags || {};
25
+ var ko_bindingRewriteValidators = ko.bindingRewriteValidators || ko.jsonExpressionRewriting.bindingRewriteValidators;
26
+ var ko_unwrap = ko.utils.unwrapObservable;
27
+ var ko_bindingHandlers = ko.bindingHandlers;
28
+
29
+ var defaultvalue = {};
30
+ ko_bindingHandlers['switch'] = {
31
+ flags: ko_bindingFlags.contentBind | ko_bindingFlags.canUseVirtual | ko_bindingFlags.noValue,
32
+ init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
33
+ var switchSkipNextArray = [],
34
+ switchBindings = {
35
+ // these properties are internal
36
+ $switchSkipNextArray: switchSkipNextArray,
37
+ $switchValueAccessor: valueAccessor,
38
+ $switchDefault: ko.observable(true),
39
+ // these properties are public
40
+ $default: defaultvalue,
41
+ $else: defaultvalue
42
+ },
43
+ contexts = [];
44
+
45
+ // Update $value in each context when it changes
46
+ ko.computed(function () {
47
+ var value = ko_unwrap(valueAccessor());
48
+ switchBindings.$value = value;
49
+ ko.utils.arrayForEach(contexts, function (context) {
50
+ context.$value = value;
51
+ });
52
+ }, null, { disposeWhenNodeIsRemoved: element });
53
+
54
+ // Each child element gets a new binding context so it can set its own $switchIndex property.
55
+ // The other properties will be shared since they're objects.
56
+ var node, nextInQueue = ko_virtualElements.firstChild(element);
57
+ while (node = nextInQueue) {
58
+ nextInQueue = ko_virtualElements.nextSibling(node);
59
+ switch (node.nodeType) {
60
+ case 1: case 8:
61
+ var newContext = bindingContext.extend(switchBindings);
62
+ // Set initial value of context.$switchIndex to undefined
63
+ newContext.$switchIndex = undefined;
64
+ ko.applyBindings(newContext, node);
65
+ // Add the context to the list to be updated if this section contained a case binding
66
+ if (newContext.$switchIndex !== undefined) {
67
+ contexts.push(newContext);
68
+ }
69
+ break;
70
+ }
71
+ }
72
+
73
+ return { controlsDescendantBindings: true };
74
+ },
75
+ preprocess: function (value) {
76
+ return value || 'true';
77
+ }
78
+ };
79
+ ko_bindingRewriteValidators['switch'] = false; // Can't rewrite control flow bindings
80
+ ko_virtualElements.allowedBindings['switch'] = true;
81
+
82
+ function checkCase(value, bindingContext) {
83
+ // Check value and determine result:
84
+ // If the control value is boolean, the result is the matching truthiness of the value
85
+ // If value is boolean, the result is the value (allows expressions instead of just simple matching)
86
+ // If value is an array, the result is true if the control value matches (strict) an item in the array
87
+ // Otherwise, the result is true if value matches the control value (loose)
88
+ var switchValue = ko_unwrap(bindingContext.$switchValueAccessor());
89
+ return (typeof switchValue == 'boolean')
90
+ ? (value ? switchValue : !switchValue)
91
+ : (typeof value == 'boolean')
92
+ ? value
93
+ : (value instanceof Array)
94
+ ? (ko.utils.arrayIndexOf(value, switchValue) !== -1)
95
+ : (value == switchValue);
96
+ }
97
+
98
+ function checkNotCase(value, bindingContext) {
99
+ return !checkCase(value, bindingContext);
100
+ }
101
+
102
+ function defaultMakeValueAccessor(ifValue) {
103
+ return function () { return ifValue };
104
+ }
105
+
106
+ function makeCaseHandler(binding, isNot, makeValueAccessor) {
107
+ var checkFunction = isNot ? checkNotCase : checkCase;
108
+ binding || (binding = 'if');
109
+ makeValueAccessor || (makeValueAccessor = defaultMakeValueAccessor);
110
+
111
+ return {
112
+ // Inherit flags from the binding we're wrapping
113
+ flags: ko_bindingHandlers[binding].flags,
114
+
115
+ init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
116
+ if (!bindingContext.$switchSkipNextArray)
117
+ throw Error("case binding must only be used with a switch binding");
118
+ if (bindingContext.$switchIndex !== undefined)
119
+ throw Error("case binding cannot be nested");
120
+ // Initialize $switchIndex and push a new observable to $switchSkipNextArray
121
+ bindingContext.$switchIndex = bindingContext.$switchSkipNextArray.push(ko.observable(false)) - 1;
122
+
123
+ bindingContext.$caseValue = ko.observable();
124
+
125
+ ko.computed(function () {
126
+ var index = bindingContext.$switchIndex,
127
+ isLast = (index === bindingContext.$switchSkipNextArray.length - 1),
128
+ result, skipNext, noDefault;
129
+
130
+ if (index && bindingContext.$switchSkipNextArray[index - 1]()) {
131
+ // An earlier case binding matched: skip this one (and subsequent ones)
132
+ result = false;
133
+ skipNext = true;
134
+ } else {
135
+ var value = ko_unwrap(valueAccessor());
136
+ if (value === bindingContext.$else) {
137
+ // If value is the special object $else, the result depends on the other case values.
138
+ // If we're the last *case* item, the value must be true. $switchDefault will get
139
+ // updated to *true* below, but that won't necessarily update us because it would
140
+ // require a recursive update.
141
+ result = bindingContext.$switchDefault() || isLast;
142
+ skipNext = false;
143
+ } else {
144
+ // If result is true, we will skip the subsequent cases (and any default cases)
145
+ noDefault = skipNext = result = checkFunction(value, bindingContext);
146
+ }
147
+ }
148
+
149
+ // Set the observable used by the wrapped binding function
150
+ bindingContext.$caseValue(result);
151
+
152
+ // Update the observable "skip next" value; if the value is changed, this will update the
153
+ // subsequent case item.
154
+ bindingContext.$switchSkipNextArray[index](skipNext);
155
+
156
+ // Update $switchDefault to false if a non-default case item has matched.
157
+ // Update it to true if we're the last item and none of items have matched.
158
+ // (Initially, every item will be the last, but it doesn't matter.)
159
+ if (noDefault)
160
+ bindingContext.$switchDefault(false);
161
+ else if (!skipNext && isLast)
162
+ bindingContext.$switchDefault(true);
163
+ },
164
+ null, { disposeWhenNodeIsRemoved: element });
165
+
166
+ // Call init with the observable result value
167
+ if (ko_bindingHandlers[binding].init) {
168
+ return ko_bindingHandlers[binding].init(element,
169
+ makeValueAccessor(bindingContext.$caseValue), allBindings, viewModel, bindingContext);
170
+ }
171
+ },
172
+
173
+ update: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
174
+ // Call update with the observable result value
175
+ if (ko_bindingHandlers[binding].update) {
176
+ return ko_bindingHandlers[binding].update(element,
177
+ makeValueAccessor(bindingContext.$caseValue), allBindings, viewModel, bindingContext);
178
+ }
179
+ }
180
+ };
181
+ }
182
+ // Support dynamically creating new case binding when using Punches plugin
183
+ function getNamespacedHandler(bindingName, namespace, bindingKey) {
184
+ if (ko_virtualElements.allowedBindings[bindingName])
185
+ ko_virtualElements.allowedBindings[bindingKey] = true;
186
+ return makeCaseHandler(bindingName, namespace === 'casenot');
187
+ }
188
+ // Support dynamically creating new case binding when using key.subkey plugin
189
+ function makeSubkeyHandler(baseKey, subKey, bindingKey) {
190
+ return getNamespacedHandler(subKey, baseKey, bindingKey);
191
+ }
192
+
193
+ function makeBaseHandler(name, isNot) {
194
+ ko_bindingHandlers[name] = makeCaseHandler('if', isNot);
195
+ ko_bindingRewriteValidators[name] = false; // Can't rewrite control flow bindings
196
+ ko_virtualElements.allowedBindings[name] = true;
197
+ ko_bindingHandlers[name].makeSubkeyHandler = makeSubkeyHandler;
198
+ ko_bindingHandlers[name].getNamespacedHandler = getNamespacedHandler;
199
+ }
200
+
201
+ makeBaseHandler('case');
202
+ makeBaseHandler('casenot', true /*isNot*/);
203
+
204
+ ko_bindingHandlers['case.visible'] = makeCaseHandler('visible');
205
+ ko_bindingHandlers['casenot.visible'] = makeCaseHandler('visible', true /*isNot*/);
206
+
207
+ ko_bindingHandlers['switch'].makeCaseHandler = makeCaseHandler;
208
+
209
+ }));
pool/shard000/JavaScript/0001445_svg-painter.js ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ;var svgPainter = ( function( $, window, document, undefined ) {
2
+
3
+ 'use strict';
4
+
5
+ $(document).ready( function() {
6
+
7
+ // detection for browser SVG capability
8
+ if ( document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#Image', '1.1' ) ) {
9
+ document.body.className = document.body.className.replace( 'no-svg', 'svg' );
10
+ }
11
+
12
+ svgPainter.init();
13
+
14
+ });
15
+
16
+ return {
17
+
18
+ elements : [],
19
+
20
+ init : function() {
21
+
22
+ this.adminMenu = $( '#adminmenu' );
23
+
24
+ this.setColors();
25
+ this.findElements();
26
+ this.paint();
27
+
28
+ },
29
+
30
+ setColors : function( colors ) {
31
+
32
+ if ( typeof colors === 'undefined' && typeof mp6_color_scheme !== 'undefined' ) {
33
+ var colors = mp6_color_scheme;
34
+ }
35
+
36
+ this.colorscheme = colors;
37
+
38
+ },
39
+
40
+ findElements : function() {
41
+
42
+ this.adminMenu.find( '.wp-menu-image' ).each(function() {
43
+
44
+ var bgimg = $(this).css( 'background-image' );
45
+
46
+ if ( bgimg.indexOf( 'data:image/svg+xml;base64' ) != -1 ) {
47
+ svgPainter.elements.push( $(this) );
48
+ }
49
+
50
+ });
51
+
52
+ },
53
+
54
+ paint : function() {
55
+
56
+ // loop through all elements
57
+ $.each( this.elements, function( index, $element ) {
58
+
59
+ var $menuitem = $element.parent().parent();
60
+
61
+ if ( $menuitem.hasClass( 'current' ) || $menuitem.hasClass( 'wp-has-current-submenu' ) ) {
62
+
63
+ // paint icon in 'current' color
64
+ svgPainter.paintElement( $element, svgPainter.colorscheme.icons.current );
65
+
66
+ } else {
67
+
68
+ // paint icon in base color
69
+ svgPainter.paintElement( $element, svgPainter.colorscheme.icons.base );
70
+
71
+ // set hover callbacks
72
+ $menuitem.hover(
73
+ function() { svgPainter.paintElement( $element, svgPainter.colorscheme.icons.focus ); },
74
+ function() { svgPainter.paintElement( $element, svgPainter.colorscheme.icons.base ); }
75
+ );
76
+
77
+ }
78
+
79
+ });
80
+
81
+ },
82
+
83
+ paintElement : function( $element, color ) {
84
+
85
+ // only accept hex colors: #101 or #101010
86
+ if ( ! color.match( /^(#[0-9a-f]{3}|#[0-9a-f]{6})$/i ) )
87
+ return;
88
+
89
+ var xml = $element.data( 'mp6-svg-' + color );
90
+
91
+ if ( ! xml ) {
92
+
93
+ var base64 = $element.css( 'background-image' ).match( /.+data:image\/svg\+xml;base64,(.+)\)/ );
94
+
95
+ if ( ! base64 )
96
+ return;
97
+
98
+ try {
99
+ var xml = window.atob( base64[1] );
100
+ } catch ( e ) {
101
+ var xml = $.base64.atob( base64[1] );
102
+ }
103
+
104
+ // replace `fill` attributes
105
+ xml = xml.replace( /fill="(.+?)"/g, 'fill="' + color + '"');
106
+
107
+ // replace `style` attributes
108
+ xml = xml.replace( /style="(.+?)"/g, 'style="fill:' + color + '"');
109
+
110
+ // replace `fill` properties in `<style>` tags
111
+ xml = xml.replace( /fill:.*?;/g, 'fill: ' + color + ';');
112
+
113
+ xml = window.btoa( xml );
114
+
115
+ $element.data( 'mp6-svg-' + color, xml );
116
+
117
+ }
118
+
119
+ $element.attr( 'style', "background-image: url('data:image/svg+xml;base64," + xml + "') !important;" );
120
+
121
+ }
122
+
123
+ };
124
+
125
+ })( jQuery, window, document );
126
+
127
+ /*!
128
+ * Customized for MP6
129
+ *
130
+ * Based on jquery.base64.js 0.0.3 - https://github.com/yckart/jquery.base64.js
131
+ *
132
+ * Based upon: https://gist.github.com/Yaffle/1284012
133
+ *
134
+ * Copyright (c) 2012 Yannick Albert (http://yckart.com)
135
+ * Licensed under the MIT license
136
+ * http://www.opensource.org/licenses/mit-license.php
137
+ **/
138
+ ;(function($) {
139
+
140
+ var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
141
+ a256 = '',
142
+ r64 = [256],
143
+ r256 = [256],
144
+ i = 0;
145
+
146
+ while(i < 256) {
147
+ var c = String.fromCharCode(i);
148
+ a256 += c;
149
+ r256[i] = i;
150
+ r64[i] = b64.indexOf(c);
151
+ ++i;
152
+ }
153
+
154
+ function code(s, discard, alpha, beta, w1, w2) {
155
+ s = String(s);
156
+ var buffer = 0,
157
+ i = 0,
158
+ length = s.length,
159
+ result = '',
160
+ bitsInBuffer = 0;
161
+
162
+ while(i < length) {
163
+ var c = s.charCodeAt(i);
164
+ c = c < 256 ? alpha[c] : -1;
165
+
166
+ buffer = (buffer << w1) + c;
167
+ bitsInBuffer += w1;
168
+
169
+ while(bitsInBuffer >= w2) {
170
+ bitsInBuffer -= w2;
171
+ var tmp = buffer >> bitsInBuffer;
172
+ result += beta.charAt(tmp);
173
+ buffer ^= tmp << bitsInBuffer;
174
+ }
175
+ ++i;
176
+ }
177
+ if(!discard && bitsInBuffer > 0) result += beta.charAt(buffer << (w2 - bitsInBuffer));
178
+ return result;
179
+ }
180
+
181
+ var Plugin = $.base64 = function(dir, input, encode) {
182
+ return input ? Plugin[dir](input, encode) : dir ? null : this;
183
+ };
184
+
185
+ $.base64.btoa = function(plain) {
186
+ plain = code(plain, false, r256, b64, 8, 6);
187
+ return plain + '===='.slice((plain.length % 4) || 4);
188
+ };
189
+
190
+ $.base64.atob = function(coded, utf8decode) {
191
+ coded = coded.replace(/[^A-Za-z0-9\+\/\=]/g, "");
192
+ coded = String(coded).split('=');
193
+ var i = coded.length;
194
+ do {--i;
195
+ coded[i] = code(coded[i], true, r64, a256, 6, 8);
196
+ } while (i > 0);
197
+ coded = coded.join('');
198
+ return coded;
199
+ };
200
+ }(jQuery));
pool/shard000/JavaScript/0001446_15.4.4.19-4-15.js ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /// Copyright (c) 2012 Ecma International. All rights reserved.
2
+ /**
3
+ * @path ch15/15.4/15.4.4/15.4.4.19/15.4.4.19-4-15.js
4
+ * @description Array.prototype.map - calling with no callbackfn is the same as passing undefined for callbackfn
5
+ */
6
+
7
+
8
+ function testcase() {
9
+
10
+ var obj = { 10: 10 };
11
+ var lengthAccessed = false;
12
+ var loopAccessed = false;
13
+
14
+ Object.defineProperty(obj, "length", {
15
+ get: function () {
16
+ lengthAccessed = true;
17
+ return 20;
18
+ },
19
+ configurable: true
20
+ });
21
+ Object.defineProperty(obj, "0", {
22
+ get: function () {
23
+ loopAccessed = true;
24
+ return 10;
25
+ },
26
+ configurable: true
27
+ });
28
+
29
+ try {
30
+ Array.prototype.map.call(obj);
31
+ return false;
32
+ } catch (e) {
33
+ return e instanceof TypeError && lengthAccessed && !loopAccessed;
34
+ }
35
+ }
36
+ runTestCase(testcase);
pool/shard000/JavaScript/0001447_Emails.js ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ (C) 2014 by Daniel Brunkhorst <daniel.brunkhorst@web.de>
3
+ Heinz Knutzen <heinz.knutzen@gmail.com>
4
+
5
+ https://github.com/hknutzen/Netspoc-Web
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ Ext.define(
20
+ 'PolicyWeb.view.panel.grid.Emails',
21
+ {
22
+ extend : 'PolicyWeb.view.panel.grid.Abstract',
23
+ alias : 'widget.emaillist',
24
+ controllers : [ 'Service', 'Account' ],
25
+ store : 'Emails',
26
+ flex : 1,
27
+ border : false,
28
+ hideHeaders : true,
29
+ title_prefix : 'Verantwortliche', // custom option
30
+ split : true,
31
+ height : 68,
32
+ tools : [
33
+ {
34
+ type : 'print',
35
+ scope : this,
36
+ callback : function ( panel ) {
37
+ panel.printview();
38
+ }
39
+ }
40
+ ],
41
+ columns : [
42
+ {
43
+ dataIndex : 'email',
44
+ renderer : function(value) {
45
+ return Ext.String.format(
46
+ '<a href="mailto:{0}">{1}</a>', value, value);
47
+ }
48
+ }
49
+ ],
50
+ viewConfig : {
51
+ selectedRowClass : 'x-grid3-row-over'
52
+ },
53
+ show : function(owner) {
54
+ if (! owner) {
55
+ this.clear();
56
+ return;
57
+ }
58
+ var store = this.getStore();
59
+ var active_owner = appstate.getOwner();
60
+ var history = appstate.getHistory();
61
+ var lastOptions = store.lastOptions;
62
+ if ( lastOptions &&
63
+ lastOptions.params &&
64
+ lastOptions.params.owner === owner &&
65
+ lastOptions.params.history === history &&
66
+ lastOptions.params.active_owner === active_owner &&
67
+ store.getCount() // Reload if data was removed previously.
68
+ )
69
+ {
70
+ return;
71
+ }
72
+ store.load ({ params : { owner : owner } });
73
+ this.setTitle(this.title_prefix + ' f&uuml;r ' + owner);
74
+ },
75
+
76
+ clear : function() {
77
+ this.setTitle('');
78
+ this.getStore().removeAll();
79
+ }
80
+ }
81
+ );
82
+
pool/shard000/JavaScript/0001450_Rapid.js ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ /**
4
+ * eWAY Rapid SDK module.
5
+ *
6
+ * @module Rapid
7
+ * @see module:Rapid
8
+ */
9
+
10
+ var Client = require('./Rapid/Client'),
11
+ Model = require('./Rapid/Model'),
12
+ locales = {};
13
+
14
+ // <editor-fold desc="Internal Functions">
15
+
16
+ function getLocale(lang) {
17
+ lang = lang.toLowerCase();
18
+ if (!locales.hasOwnProperty(lang)) {
19
+ locales[lang] = {};
20
+ try {
21
+ locales[lang] = require('../locale/' + lang);
22
+ } catch (err) {
23
+ if (lang !== 'en') {
24
+ return getLocale('en');
25
+ }
26
+ // This is not reachable, unless someone deletes ../locale/en.json
27
+ throw err;
28
+ }
29
+ }
30
+
31
+ return locales[lang];
32
+ }
33
+
34
+ function getMessageFromFile(code, lang) {
35
+ var locale = getLocale(lang);
36
+
37
+ if (!locale.hasOwnProperty(code)) {
38
+ return code;
39
+ }
40
+
41
+ return locale[code];
42
+ }
43
+
44
+ // </editor-fold>
45
+
46
+ /**
47
+ * Use this namespace: __`var Rapid = require('eway-rapid');`__
48
+ *
49
+ * @namespace
50
+ */
51
+ var Rapid = {};
52
+
53
+ /**
54
+ * Create client with API Key, Password and (optional) Endpoint
55
+ *
56
+ * @param {String} key API Key
57
+ * @param {String} password API Password
58
+ * @param {String} [endpoint=sandbox] API Endpoint, can be production/sandbox/actual URL
59
+ * @return {module:Rapid/Client~Client} Rapid Client
60
+ */
61
+ Rapid.createClient = function (key, password, endpoint) {
62
+ endpoint = typeof endpoint !== 'undefined' ? endpoint : Client.MODE_SANDBOX;
63
+ return new Client(key, password, endpoint);
64
+ };
65
+
66
+ /**
67
+ * Get user friendly message
68
+ *
69
+ * @param {String} code Message code
70
+ * @param {String} [lang=en] Language code
71
+ * @return {String} Message
72
+ */
73
+ Rapid.getMessage = function (code, lang) {
74
+ lang = lang || 'en';
75
+ return getMessageFromFile(code, lang);
76
+ };
77
+
78
+ /**
79
+ * Class Client
80
+ *
81
+ * @type {module:Rapid/Client~Client}
82
+ */
83
+ Rapid.Client = Client;
84
+
85
+ /**
86
+ * @namespace
87
+ */
88
+ Rapid.Enum = {
89
+
90
+ /**
91
+ * Enum API Method
92
+ *
93
+ * @type {module:Rapid/Enum/Method~Method}
94
+ */
95
+ Method: require('./Rapid/Enum/Method'),
96
+
97
+ /**
98
+ * Enum Payment Method
99
+ *
100
+ * @type {module:Rapid/Enum/Payment~Payment}
101
+ */
102
+ Payment: require('./Rapid/Enum/Payment'),
103
+
104
+ /**
105
+ * Enum Shipping Method
106
+ *
107
+ * @type {module:Rapid/Enum/Shipping~Shipping}
108
+ */
109
+ Shipping: require('./Rapid/Enum/Shipping'),
110
+
111
+ /**
112
+ * Enum Transaction Type
113
+ *
114
+ * @type {module:Rapid/Enum/TransactionType~TransactionType}
115
+ */
116
+ TransactionType: require('./Rapid/Enum/TransactionType'),
117
+
118
+ /**
119
+ * Enum Settlement Report Mode
120
+ *
121
+ * @type {module:Rapid/Enum/SettlementReportMode~SettlementReportMode}
122
+ */
123
+ SettlementReportMode: require('./Rapid/Enum/SettlementReportMode')
124
+ };
125
+
126
+ /**
127
+ * Class Model
128
+ *
129
+ * @type {module:Rapid/Model~Model}
130
+ */
131
+ Rapid.Model = Model;
132
+
133
+ module.exports = Rapid;
pool/shard000/JavaScript/0001451_categories-controller.js ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function() {
2
+ 'use strict';
3
+
4
+ angular
5
+ .module('Startkicker.controllers')
6
+ .controller('CategoriesController', CategoriesController);
7
+
8
+ CategoriesController.$inject = ['categories', 'notifier'];
9
+
10
+ function CategoriesController(categories, notifier) {
11
+ var vm = this;
12
+
13
+ vm.categories = categories.getCachedCategories();
14
+ vm.newCategoryName = '';
15
+
16
+ vm.addCategory = function(categoryName) {
17
+ categories
18
+ .add({ name: categoryName })
19
+ .then(function(response) {
20
+ vm.categories.push(response);
21
+ vm.newCategoryName = '';
22
+ notifier.success('New category added successfully!');
23
+ });
24
+ };
25
+
26
+ vm.removeCategory = function(categoryId, index) {
27
+ categories
28
+ .remove(categoryId, index)
29
+ .then(function(response) {
30
+ vm.categories.splice(index, 1);
31
+ notifier.success(response);
32
+ });
33
+ };
34
+ }
35
+ }());
pool/shard000/JavaScript/0001452_App.js ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { connect } from 'react-redux'
2
+ import { withRouter } from 'react-router'
3
+ import App from '../components/App'
4
+ import { load as performSearch } from '../actions/SearchActions'
5
+ import { isSearching, getSearchResults } from '../reducers/search'
6
+ import {
7
+ isLoadingModule,
8
+ isLoggingIn,
9
+ isLoggedIn,
10
+ getLoginErrorMessage,
11
+ getUsername,
12
+ getLastLogin,
13
+ isLoadingUserData,
14
+ isUpdateAvailable
15
+ } from '../reducers/application'
16
+ import { login, logout, userdata, hideReload } from '../actions/ApplicationActions'
17
+ import { createAthleteLink, createClubLink, createVenueLink } from '../utils/linkGenerator'
18
+
19
+ const mapStateToProps = (state, props) => ({
20
+ loadingModule: isLoadingModule(state),
21
+ searching: isSearching(state),
22
+ searchResults: getSearchResults(state),
23
+ loggedIn: isLoggedIn(state),
24
+ loggingIn: isLoggingIn(state),
25
+ loginErrorMessage: getLoginErrorMessage(state),
26
+ register: () => {
27
+ const router = props.router
28
+ router.push({
29
+ pathname: '/registrieren'
30
+ })
31
+ },
32
+ username: getUsername(state),
33
+ lastLogin: getLastLogin(state),
34
+ loadingUserData: isLoadingUserData(state),
35
+ updateAvailable: isUpdateAvailable(state),
36
+ reload: () => location.reload(),
37
+ onSelectSearchResult: (item, value) => {
38
+ const router = props.router
39
+ let link
40
+ switch (value.get('type')) {
41
+ case 'athlete':
42
+ link = createAthleteLink(value.get('athlete'))
43
+ break
44
+ case 'club':
45
+ link = createClubLink(value.get('club'))
46
+ break
47
+ case 'location':
48
+ link = createVenueLink(value.get('location'))
49
+ break
50
+ // no default
51
+ }
52
+ if (link) {
53
+ router.push({
54
+ pathname: link
55
+ })
56
+ }
57
+ }
58
+ })
59
+
60
+ const mapDispatchToProps = {
61
+ performSearch,
62
+ login: login.load,
63
+ logout,
64
+ getUserData: userdata.load,
65
+ hideReload
66
+ }
67
+
68
+ export default withRouter(connect(mapStateToProps, mapDispatchToProps)(App))
pool/shard000/JavaScript/0001453_index.js ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const app_utils_1 = require("../../utilities/app-utils");
4
+ const dynamic_path_parser_1 = require("../../utilities/dynamic-path-parser");
5
+ const config_1 = require("../../models/config");
6
+ const stringUtils = require('ember-cli-string-utils');
7
+ const Blueprint = require('../../ember-cli/lib/models/blueprint');
8
+ const getFiles = Blueprint.prototype.files;
9
+ exports.default = Blueprint.extend({
10
+ name: 'class',
11
+ description: '',
12
+ aliases: ['cl'],
13
+ availableOptions: [
14
+ {
15
+ name: 'spec',
16
+ type: Boolean,
17
+ description: 'Specifies if a spec file is generated.'
18
+ },
19
+ {
20
+ name: 'app',
21
+ type: String,
22
+ aliases: ['a'],
23
+ description: 'Specifies app name to use.'
24
+ }
25
+ ],
26
+ normalizeEntityName: function (entityName) {
27
+ const appConfig = app_utils_1.getAppFromConfig(this.options.app);
28
+ const dynamicPathOptions = {
29
+ project: this.project,
30
+ entityName: entityName.split('.')[0],
31
+ appConfig,
32
+ dryRun: this.options.dryRun
33
+ };
34
+ const parsedPath = dynamic_path_parser_1.dynamicPathParser(dynamicPathOptions);
35
+ this.dynamicPath = parsedPath;
36
+ return parsedPath.name;
37
+ },
38
+ locals: function (options) {
39
+ const rawName = options.args[1];
40
+ const nameParts = rawName.split('.')
41
+ .filter(part => part.length !== 0);
42
+ const classType = nameParts[1];
43
+ this.fileName = stringUtils.dasherize(options.entity.name);
44
+ if (classType) {
45
+ this.fileName += '.' + classType.toLowerCase();
46
+ }
47
+ options.spec = options.spec !== undefined ?
48
+ options.spec : config_1.CliConfig.getValue('defaults.class.spec');
49
+ return {
50
+ dynamicPath: this.dynamicPath.dir,
51
+ flat: options.flat,
52
+ fileName: this.fileName
53
+ };
54
+ },
55
+ files: function () {
56
+ let fileList = getFiles.call(this);
57
+ if (this.options && !this.options.spec) {
58
+ fileList = fileList.filter(p => p.indexOf('__name__.spec.ts') < 0);
59
+ }
60
+ return fileList;
61
+ },
62
+ fileMapTokens: function () {
63
+ // Return custom template variables here.
64
+ return {
65
+ __path__: () => {
66
+ this.generatePath = this.dynamicPath.dir;
67
+ return this.generatePath;
68
+ },
69
+ __name__: () => {
70
+ return this.fileName;
71
+ }
72
+ };
73
+ }
74
+ });
75
+ //# sourceMappingURL=/users/hansl/sources/angular-cli/blueprints/class/index.js.map
pool/shard000/JavaScript/0001454_fadeplugin.js ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Phaser.Plugin.FadePlugin = function (game, parent) {
2
+ Phaser.Plugin.call(this, game, parent);
3
+ };
4
+
5
+ Phaser.Plugin.FadePlugin.prototype = Object.create(Phaser.Plugin.prototype);
6
+ Phaser.Plugin.FadePlugin.prototype.constructor = Phaser.Plugin.FadePlugin;
7
+
8
+ Phaser.Plugin.FadePlugin.prototype.fadeAndPlay = function (style,time,nextState,music,resume) {
9
+ this.crossFadeBitmap = this.game.make.bitmapData(this.game.width, this.game.height);
10
+ this.crossFadeBitmap.rect(0, 0, this.game.width, this.game.height, style);
11
+ this.overlay = this.game.add.sprite(0,0, this.crossFadeBitmap);
12
+ this.overlay.alpha = 0;
13
+ var fadeTween = this.game.add.tween(this.overlay);
14
+ fadeTween.to({alpha:1},time*1000);
15
+ fadeTween.onComplete.add(function(){
16
+ if(music){
17
+ if(!resume) music.play();
18
+ else music.resume();
19
+ }
20
+ this.game.state.start(nextState);
21
+ },this);
22
+ fadeTween.start();
23
+ };
pool/shard000/JavaScript/0001456_index.js ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @module byte-size
3
+ */
4
+
5
+ let defaultOptions = {}
6
+ const _options = new WeakMap()
7
+
8
+ const referenceTables = {
9
+ metric: [
10
+ { from: 0, to: 1e3, unit: 'B', long: 'bytes' },
11
+ { from: 1e3, to: 1e6, unit: 'kB', long: 'kilobytes' },
12
+ { from: 1e6, to: 1e9, unit: 'MB', long: 'megabytes' },
13
+ { from: 1e9, to: 1e12, unit: 'GB', long: 'gigabytes' },
14
+ { from: 1e12, to: 1e15, unit: 'TB', long: 'terabytes' },
15
+ { from: 1e15, to: 1e18, unit: 'PB', long: 'petabytes' },
16
+ { from: 1e18, to: 1e21, unit: 'EB', long: 'exabytes' },
17
+ { from: 1e21, to: 1e24, unit: 'ZB', long: 'zettabytes' },
18
+ { from: 1e24, to: 1e27, unit: 'YB', long: 'yottabytes' }
19
+ ],
20
+ metric_octet: [
21
+ { from: 0, to: 1e3, unit: 'o', long: 'octets' },
22
+ { from: 1e3, to: 1e6, unit: 'ko', long: 'kilooctets' },
23
+ { from: 1e6, to: 1e9, unit: 'Mo', long: 'megaoctets' },
24
+ { from: 1e9, to: 1e12, unit: 'Go', long: 'gigaoctets' },
25
+ { from: 1e12, to: 1e15, unit: 'To', long: 'teraoctets' },
26
+ { from: 1e15, to: 1e18, unit: 'Po', long: 'petaoctets' },
27
+ { from: 1e18, to: 1e21, unit: 'Eo', long: 'exaoctets' },
28
+ { from: 1e21, to: 1e24, unit: 'Zo', long: 'zettaoctets' },
29
+ { from: 1e24, to: 1e27, unit: 'Yo', long: 'yottaoctets' }
30
+ ],
31
+ iec: [
32
+ { from: 0, to: Math.pow(1024, 1), unit: 'B', long: 'bytes' },
33
+ { from: Math.pow(1024, 1), to: Math.pow(1024, 2), unit: 'KiB', long: 'kibibytes' },
34
+ { from: Math.pow(1024, 2), to: Math.pow(1024, 3), unit: 'MiB', long: 'mebibytes' },
35
+ { from: Math.pow(1024, 3), to: Math.pow(1024, 4), unit: 'GiB', long: 'gibibytes' },
36
+ { from: Math.pow(1024, 4), to: Math.pow(1024, 5), unit: 'TiB', long: 'tebibytes' },
37
+ { from: Math.pow(1024, 5), to: Math.pow(1024, 6), unit: 'PiB', long: 'pebibytes' },
38
+ { from: Math.pow(1024, 6), to: Math.pow(1024, 7), unit: 'EiB', long: 'exbibytes' },
39
+ { from: Math.pow(1024, 7), to: Math.pow(1024, 8), unit: 'ZiB', long: 'zebibytes' },
40
+ { from: Math.pow(1024, 8), to: Math.pow(1024, 9), unit: 'YiB', long: 'yobibytes' }
41
+ ],
42
+ iec_octet: [
43
+ { from: 0, to: Math.pow(1024, 1), unit: 'o', long: 'octets' },
44
+ { from: Math.pow(1024, 1), to: Math.pow(1024, 2), unit: 'Kio', long: 'kibioctets' },
45
+ { from: Math.pow(1024, 2), to: Math.pow(1024, 3), unit: 'Mio', long: 'mebioctets' },
46
+ { from: Math.pow(1024, 3), to: Math.pow(1024, 4), unit: 'Gio', long: 'gibioctets' },
47
+ { from: Math.pow(1024, 4), to: Math.pow(1024, 5), unit: 'Tio', long: 'tebioctets' },
48
+ { from: Math.pow(1024, 5), to: Math.pow(1024, 6), unit: 'Pio', long: 'pebioctets' },
49
+ { from: Math.pow(1024, 6), to: Math.pow(1024, 7), unit: 'Eio', long: 'exbioctets' },
50
+ { from: Math.pow(1024, 7), to: Math.pow(1024, 8), unit: 'Zio', long: 'zebioctets' },
51
+ { from: Math.pow(1024, 8), to: Math.pow(1024, 9), unit: 'Yio', long: 'yobioctets' }
52
+ ]
53
+ }
54
+
55
+ class ByteSize {
56
+ constructor (bytes, options) {
57
+ options = Object.assign({
58
+ units: 'metric',
59
+ precision: 1,
60
+ locale: undefined // Default to the user's system locale
61
+ }, defaultOptions, options)
62
+ _options.set(this, options)
63
+
64
+ Object.assign(referenceTables, options.customUnits)
65
+
66
+ const prefix = bytes < 0 ? '-' : ''
67
+ bytes = Math.abs(bytes)
68
+ const table = referenceTables[options.units]
69
+ if (table) {
70
+ const units = table.find(u => bytes >= u.from && bytes < u.to)
71
+ if (units) {
72
+ const defaultFormat = new Intl.NumberFormat(options.locale, {
73
+ style: 'decimal',
74
+ minimumFractionDigits: options.precision,
75
+ maximumFractionDigits: options.precision
76
+ })
77
+ const value = units.from === 0
78
+ ? prefix + bytes
79
+ : prefix + defaultFormat.format(bytes / units.from)
80
+ this.value = value
81
+ this.unit = units.unit
82
+ this.long = units.long
83
+ } else {
84
+ this.value = prefix + bytes
85
+ this.unit = ''
86
+ this.long = ''
87
+ }
88
+ } else {
89
+ throw new Error(`Invalid units specified: ${options.units}`)
90
+ }
91
+ }
92
+
93
+ toString () {
94
+ const options = _options.get(this)
95
+ return options.toStringFn ? options.toStringFn.bind(this)() : `${this.value} ${this.unit}`
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Returns an object with the spec `{ value: string, unit: string, long: string }`. The returned object defines a `toString` method meaning it can be used in any string context.
101
+ * @param {number} - The bytes value to convert.
102
+ * @param [options] {object} - Optional config.
103
+ * @param [options.precision] {number} - Number of decimal places. Defaults to `1`.
104
+ * @param [options.units] {string} - Specify `'metric'`, `'iec'`, `'metric_octet'`, `'iec_octet'` or the name of a property from the custom units table in `options.customUnits`. Defaults to `metric`.
105
+ * @param [options.customUnits] {object} - An object containing one or more custom unit lookup tables.
106
+ * @param [options.toStringFn] {function} - A `toString` function to override the default.
107
+ * @param [options.locale] {string|string[]} - *Node >=13 or modern browser only - on earlier platforms this option is ignored*. The locale to use for number formatting (e.g. `'de-DE'`). Defaults to your system locale. Passed directed into [Intl.NumberFormat()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat).
108
+ * @returns {object}
109
+ * @alias module:byte-size
110
+ */
111
+ function byteSize (bytes, options) {
112
+ return new ByteSize(bytes, options)
113
+ }
114
+
115
+ /**
116
+ * Set the default `byteSize` options for the duration of the process.
117
+ * @param options {object} - A `byteSize` options object.
118
+ */
119
+ byteSize.defaultOptions = function (options) {
120
+ defaultOptions = options
121
+ }
122
+
123
+ export default byteSize
pool/shard000/JavaScript/0001461_transform-composed-nodes.js ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var async = require('async');
2
+
3
+ module.exports =
4
+ function transformComposedNodes(source, target, iterator, callback) {
5
+ var comps = this.compositions;
6
+ var compKeys = Object.keys(comps);
7
+ async.map(compKeys, function(compKey, callback) {
8
+ var opts = comps[compKey];
9
+ var objects = source[compKey];
10
+
11
+ if (!objects) return callback();
12
+
13
+ //make sure it's an array, we can unwrap it later if it wasn't
14
+ objects = Array.isArray(objects) ? objects : [ objects ];
15
+
16
+ async.map(objects, function(object, callback) {
17
+ iterator(opts, object, objects.indexOf(object), callback);
18
+ }, function(err, transformedObjects) {
19
+ if (err) return callback(err);
20
+
21
+ if (transformedObjects.length == 1 && !opts.many) {
22
+ transformedObjects = transformedObjects[0];
23
+ }
24
+
25
+ callback(null, transformedObjects);
26
+ });
27
+ }, function(err, transformedComps) {
28
+ if (err) return callback(err);
29
+
30
+ transformedComps.forEach(function(object, i) {
31
+ if (!object) return;
32
+ target[compKeys[i]] = object;
33
+ });
34
+
35
+ callback(null, target);
36
+ });
37
+ };
pool/shard000/JavaScript/0001462_test-amp-story-share-menu.js ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {sleep} from '#testing/helpers';
2
+ import {Key} from '#testing/helpers/types';
3
+
4
+ describes.endtoend(
5
+ 'amp story share menu',
6
+ {
7
+ fixture: 'amp-story/amp-story.amp.html',
8
+ browsers: ['chrome'],
9
+ environments: ['single'],
10
+ deviceName: 'iPhone X',
11
+ },
12
+ (env) => {
13
+ /** @type {SeleniumWebDriverController} */
14
+ let controller;
15
+
16
+ beforeEach(() => {
17
+ controller = env.controller;
18
+ });
19
+
20
+ it.skip('should copy the link using the browser share menu', async () => {
21
+ // copy link
22
+ const systemLayerHost = await controller.findElement(
23
+ '.i-amphtml-system-layer-host'
24
+ );
25
+ await controller.switchToShadowRoot(systemLayerHost);
26
+ const shareButton = await controller.findElement(
27
+ '.i-amphtml-story-share-control'
28
+ );
29
+ await controller.click(shareButton);
30
+ await controller.switchToLight();
31
+
32
+ const shareMenuHost = await controller.findElement(
33
+ 'amp-story-share-menu'
34
+ );
35
+ await controller.switchToShadowRoot(shareMenuHost);
36
+ const getLinkButton = await controller.findElement(
37
+ '.i-amphtml-story-share-icon-link'
38
+ );
39
+ await controller.click(getLinkButton);
40
+ await controller.switchToLight();
41
+
42
+ // paste link
43
+ const input = await controller.findElement('.input-field');
44
+ await controller.click(input);
45
+ await sleep(500);
46
+ await controller.type(input, Key.CtrlV);
47
+ await sleep(500);
48
+
49
+ const output = await controller.getElementProperty(input, 'value');
50
+ await expect(output).to.equal(
51
+ 'http://localhost:8000/test/manual/amp-story/amp-story.amp.html'
52
+ );
53
+ });
54
+ }
55
+ );
pool/shard000/JavaScript/0001464_dates.js ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ openerp.web.dates = function(instance) {
3
+
4
+ /**
5
+ * Converts a string to a Date javascript object using OpenERP's
6
+ * datetime string format (exemple: '2011-12-01 15:12:35').
7
+ *
8
+ * The time zone is assumed to be UTC (standard for OpenERP 6.1)
9
+ * and will be converted to the browser's time zone.
10
+ *
11
+ * @param {String} str A string representing a datetime.
12
+ * @returns {Date}
13
+ */
14
+ instance.web.str_to_datetime = function(str) {
15
+ if(!str) {
16
+ return str;
17
+ }
18
+ var regex = /^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)(?:\.\d+)?$/;
19
+ var res = regex.exec(str);
20
+ if ( !res ) {
21
+ throw new Error("'" + str + "' is not a valid datetime");
22
+ }
23
+ var obj = Date.parseExact(res[1] + " UTC", 'yyyy-MM-dd HH:mm:ss zzz');
24
+ if (! obj) {
25
+ throw new Error("'" + str + "' is not a valid datetime");
26
+ }
27
+ return obj;
28
+ };
29
+
30
+ /**
31
+ * Converts a string to a Date javascript object using OpenERP's
32
+ * date string format (exemple: '2011-12-01').
33
+ *
34
+ * As a date is not subject to time zones, we assume it should be
35
+ * represented as a Date javascript object at 00:00:00 in the
36
+ * time zone of the browser.
37
+ *
38
+ * @param {String} str A string representing a date.
39
+ * @returns {Date}
40
+ */
41
+ instance.web.str_to_date = function(str) {
42
+ if(!str) {
43
+ return str;
44
+ }
45
+ var regex = /^\d\d\d\d-\d\d-\d\d$/;
46
+ var res = regex.exec(str);
47
+ if ( !res ) {
48
+ throw new Error("'" + str + "' is not a valid date");
49
+ }
50
+ var obj = Date.parseExact(str, 'yyyy-MM-dd');
51
+ if (! obj) {
52
+ throw new Error("'" + str + "' is not a valid date");
53
+ }
54
+ return obj;
55
+ };
56
+
57
+ /**
58
+ * Converts a string to a Date javascript object using OpenERP's
59
+ * time string format (exemple: '15:12:35').
60
+ *
61
+ * The OpenERP times are supposed to always be naive times. We assume it is
62
+ * represented using a javascript Date with a date 1 of January 1970 and a
63
+ * time corresponding to the meant time in the browser's time zone.
64
+ *
65
+ * @param {String} str A string representing a time.
66
+ * @returns {Date}
67
+ */
68
+ instance.web.str_to_time = function(str) {
69
+ if(!str) {
70
+ return str;
71
+ }
72
+ var regex = /^(\d\d:\d\d:\d\d)(?:\.\d+)?$/;
73
+ var res = regex.exec(str);
74
+ if ( !res ) {
75
+ throw new Error("'" + str + "' is not a valid time");
76
+ }
77
+ var obj = Date.parseExact("1970-01-01 " + res[1], 'yyyy-MM-dd HH:mm:ss');
78
+ if (! obj) {
79
+ throw new Error("'" + str + "' is not a valid time");
80
+ }
81
+ return obj;
82
+ };
83
+
84
+ /*
85
+ * Left-pad provided arg 1 with zeroes until reaching size provided by second
86
+ * argument.
87
+ *
88
+ * @param {Number|String} str value to pad
89
+ * @param {Number} size size to reach on the final padded value
90
+ * @returns {String} padded string
91
+ */
92
+ var zpad = function(str, size) {
93
+ str = "" + str;
94
+ return new Array(size - str.length + 1).join('0') + str;
95
+ };
96
+
97
+ /**
98
+ * Converts a Date javascript object to a string using OpenERP's
99
+ * datetime string format (exemple: '2011-12-01 15:12:35').
100
+ *
101
+ * The time zone of the Date object is assumed to be the one of the
102
+ * browser and it will be converted to UTC (standard for OpenERP 6.1).
103
+ *
104
+ * @param {Date} obj
105
+ * @returns {String} A string representing a datetime.
106
+ */
107
+ instance.web.datetime_to_str = function(obj) {
108
+ if (!obj) {
109
+ return false;
110
+ }
111
+ return zpad(obj.getUTCFullYear(),4) + "-" + zpad(obj.getUTCMonth() + 1,2) + "-"
112
+ + zpad(obj.getUTCDate(),2) + " " + zpad(obj.getUTCHours(),2) + ":"
113
+ + zpad(obj.getUTCMinutes(),2) + ":" + zpad(obj.getUTCSeconds(),2);
114
+ };
115
+
116
+ /**
117
+ * Converts a Date javascript object to a string using OpenERP's
118
+ * date string format (exemple: '2011-12-01').
119
+ *
120
+ * As a date is not subject to time zones, we assume it should be
121
+ * represented as a Date javascript object at 00:00:00 in the
122
+ * time zone of the browser.
123
+ *
124
+ * @param {Date} obj
125
+ * @returns {String} A string representing a date.
126
+ */
127
+ instance.web.date_to_str = function(obj) {
128
+ if (!obj) {
129
+ return false;
130
+ }
131
+ return zpad(obj.getFullYear(),4) + "-" + zpad(obj.getMonth() + 1,2) + "-"
132
+ + zpad(obj.getDate(),2);
133
+ };
134
+
135
+ /**
136
+ * Converts a Date javascript object to a string using OpenERP's
137
+ * time string format (exemple: '15:12:35').
138
+ *
139
+ * The OpenERP times are supposed to always be naive times. We assume it is
140
+ * represented using a javascript Date with a date 1 of January 1970 and a
141
+ * time corresponding to the meant time in the browser's time zone.
142
+ *
143
+ * @param {Date} obj
144
+ * @returns {String} A string representing a time.
145
+ */
146
+ instance.web.time_to_str = function(obj) {
147
+ if (!obj) {
148
+ return false;
149
+ }
150
+ return zpad(obj.getHours(),2) + ":" + zpad(obj.getMinutes(),2) + ":"
151
+ + zpad(obj.getSeconds(),2);
152
+ };
153
+
154
+ };
pool/shard000/JavaScript/0001469_PrefetchListPickerEditorController.js ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // controller used by datatype editor
2
+
3
+ angular
4
+ .module("umbraco")
5
+ .controller("nuPickers.Shared.PrefetchListPicker.PrefetchListPickerEditorController",
6
+ ['$scope',
7
+ function ($scope) {
8
+
9
+ // setup filtering
10
+ if ($scope.model.config.prefetchListPicker.enableFiltering) {
11
+
12
+ // re-get all options so that we have a reference to restore them
13
+ $scope.getEditorOptions().then(function (response) {
14
+
15
+ var allSelectableOptions = response.data;
16
+
17
+ $scope.$watch('filter', function (newValue, oldValue) {
18
+
19
+ // if the filter is empty then just return all items
20
+ if (newValue == null || newValue.length == 0) {
21
+ return $scope.selectableOptions = allSelectableOptions;
22
+ }
23
+
24
+ newValue = newValue.toLowerCase();
25
+ var filteredSelectableOptions = allSelectableOptions.filter(function (item) {
26
+ // strip html before searching
27
+ return String(item.label).replace(/(<([^>]+)>)/gm, '').toLowerCase().indexOf(newValue) != -1;
28
+ });
29
+
30
+ if (filteredSelectableOptions.length > 0) {
31
+ return $scope.selectableOptions = filteredSelectableOptions;
32
+ }
33
+ else {
34
+ $scope.filter = oldValue;
35
+ }
36
+
37
+ });
38
+
39
+ });
40
+ }
41
+
42
+ }]);
pool/shard000/JavaScript/0001473_basic.js ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var helper = require("../../../helper");
2
+ var Manager = require("../../../../src/etl/dim/dim-order-type-etl-manager");
3
+ var instanceManager = null;
4
+ var should = require("should");
5
+ var sqlHelper = require("../../../sql-helper");
6
+
7
+ before("#00. connect db", function (done) {
8
+ Promise.all([helper, sqlHelper])
9
+ .then((result) => {
10
+ var db = result[0];
11
+ var sql = result[1];
12
+ db.getDb().then((db) => {
13
+ instanceManager = new Manager(db, {
14
+ username: "unit-test"
15
+ }, sql);
16
+ done();
17
+ })
18
+ .catch((e) => {
19
+ done(e);
20
+ });
21
+ });
22
+ });
23
+
24
+ it("#01. should success when create etl for dim-order-type", function (done) {
25
+ instanceManager.run()
26
+ .then(() => {
27
+ done();
28
+ })
29
+ .catch((e) => {
30
+ done(e);
31
+ });
32
+ });
33
+
34
+ // it("#02. should success when transforming data for dim-category", function(done) {
35
+ // var data = [{}, {}];
36
+ // instanceManager.transform(data)
37
+ // .then(() => {
38
+ // done();
39
+ // })
40
+ // .catch((e) => {
41
+ // done(e);
42
+ // });
43
+ // });
44
+
45
+ // // it("#03. should error when load empty data", function (done) {
46
+ // // instanceManager.load({})
47
+ // // .then(id => {
48
+ // // done("should error when create with empty data");
49
+ // // })
50
+ // // .catch(e => {
51
+ // // try {
52
+ // // done();
53
+ // // }
54
+ // // catch (ex) {
55
+ // // done(ex);
56
+ // // }
57
+ // // });
58
+ // // });
59
+
60
+ // it("#04. should error when insert empty data", function (done) {
61
+ // instanceManager.insertQuery(this.sql, "")
62
+ // .then((id) => {
63
+ // done("should error when create with empty data");
64
+ // })
65
+ // .catch((e) => {
66
+ // try {
67
+ // done();
68
+ // }
69
+ // catch (ex) {
70
+ // done(ex);
71
+ // }
72
+ // });
73
+ // });
pool/shard000/JavaScript/0001482_resultsContent.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function(module){
2
+ resultsContent = {};
3
+ var template = Handlebars.compile($('#incident-template').text());
4
+
5
+ resultsContent.render = function(incident) {
6
+ return template(incident);
7
+ };
8
+
9
+ //this needs to do anything to draw the results page that happens before the police AJAX call comes back
10
+ //notably, this needs to draw the google map centered at the user's position
11
+ resultsContent.index = function() {
12
+ console.log('resultsContent.index called');
13
+ userPositionMarkerOptions = maps.userPositionMarkerOptions;
14
+ maps.buildMap([+mapHolderController.searchParams.lat, +mapHolderController.searchParams.lng]);
15
+ maps.addMarker([+mapHolderController.searchParams.lat, +mapHolderController.searchParams.lng], false, userPositionMarkerOptions);
16
+ };
17
+
18
+ //this builds the articles and map markers for both the overview and results pages
19
+ resultsContent.renderArticlesAndMapMarkers = function(incidents){
20
+ console.log('resultsContent.renderArticlesAndMapMarkers called');
21
+ var $resultsHandlebarsHere = $('#results-handlebars-here');
22
+ $resultsHandlebarsHere.empty();
23
+ incidents.forEach(function(thisIncident) {
24
+ maps.addMarker([+thisIncident.latitude, +thisIncident.longitude], true, {}, thisIncident);
25
+ $resultsHandlebarsHere.append(resultsContent.render(thisIncident));
26
+ });
27
+ resultsContent.attachReadOnListenerAndHide();
28
+ };
29
+
30
+
31
+ resultsContent.attachReadOnListenerAndHide = function(){
32
+ $('#results-handlebars-here li:nth-of-type(n+6)').hide();
33
+ $('#resultsReadOn').on('click', function(e){
34
+ event.preventDefault();
35
+ resultsContent.readOn();
36
+ });
37
+ };
38
+
39
+
40
+ resultsContent.readOn = function() {
41
+ $('#results-handlebars-here li:nth-of-type(n+6)').show();
42
+ $('#resultsReadOn').hide();
43
+ };
44
+
45
+
46
+ module.resultsContent = resultsContent;
47
+ })(window);
pool/shard000/JavaScript/0001484_router.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Router.configure({
2
+ layoutTemplate: 'layout'
3
+ });
4
+
5
+ Router.map(function() {
6
+ this.route('home', { path: "/" });
7
+ this.route('play', {
8
+ path: "/game/:_id",
9
+ data: function () {
10
+ var game = Games.findOne(this.params._id);
11
+
12
+ if (game) {
13
+ game.player = game.players[Meteor.userId()];
14
+ game.yourTurn = game.currentTurn[0] === Meteor.userId();
15
+
16
+ var otherId = game.currentTurn[game.yourTurn ? 1 : 0];
17
+ game.otherPlayer = Meteor.users.findOne(otherId).username
18
+ return game;
19
+ }
20
+ return {}
21
+ }
22
+ });
23
+ });
24
+
25
+
pool/shard000/JavaScript/0001486_pen.js ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react'
2
+ import Icon from 'react-icon-base';
3
+ import style from './pen.less';
4
+ import cx from 'classnames';
5
+
6
+ const Pen = props => {
7
+
8
+ let theme = props.theme || 'default';
9
+ let size = props.size || 'md';
10
+
11
+ return (
12
+ <Icon viewBox="0 0 17 17" {...props} className={cx(style[theme], style[size])}>
13
+ <path d="M16.4,4.1l-3.5-3.5c-0.8-0.8-2.1-0.8-2.8,0L1.6,9.1l-1.4,7.1l0.7,0.7l7.1-1.4l8.5-8.5C17.2,6.2,17.2,4.9,16.4,4.1z
14
+ M6.9,13.6l-4.4,0.9l0.9-4.4L11.5,2L15,5.5L6.9,13.6z"/>
15
+ <rect x="3.1" y="11" transform="matrix(0.7071 0.7071 -0.7071 0.7071 9.9631 -0.966)" width="6" height="1"/>
16
+ <rect x="1.1" y="13.4" transform="matrix(0.7071 0.7071 -0.7071 0.7071 10.9276 2.3624)" width="3" height="2"/>
17
+ <rect x="9.2" y="2.3" transform="matrix(0.7071 0.7071 -0.7071 0.7071 7.9986 -4.7087)" width="1" height="10"/>
18
+ </Icon>
19
+ )
20
+ };
21
+
22
+ export default Pen;
pool/shard000/JavaScript/0001488_calendar.test.js ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright © Magento, Inc. All rights reserved.
3
+ * See COPYING.txt for license details.
4
+ */
5
+
6
+ /* eslint-disable max-nested-callbacks */
7
+ define([
8
+ 'jquery',
9
+ 'jquery/ui',
10
+ 'mage/calendar'
11
+ ], function ($) {
12
+ 'use strict';
13
+
14
+ describe('mage/calendar', function () {
15
+ describe('Check calendar', function () {
16
+ var calendarSelector = '#calendar';
17
+
18
+ beforeEach(function () {
19
+ var $calendar = $('<input type="text" id="calendar" />');
20
+
21
+ $('body').append($calendar);
22
+ });
23
+
24
+ afterEach(function () {
25
+ $(calendarSelector).remove();
26
+ $(calendarSelector).calendar('destroy');
27
+ });
28
+
29
+ it('Check that calendar inited', function () {
30
+ var $calendar = $(calendarSelector).calendar();
31
+
32
+ expect($calendar.is(':mage-calendar')).toBe(true);
33
+ });
34
+
35
+ it('Check configuration merge', function () {
36
+ var $calendar;
37
+
38
+ $.extend(true, $, {
39
+ calendarConfig: {
40
+ showOn: 'button',
41
+ showAnim: '',
42
+ buttonImageOnly: true,
43
+ showButtonPanel: true,
44
+ showWeek: true,
45
+ timeFormat: '',
46
+ showTime: false,
47
+ showHour: false,
48
+ showMinute: false
49
+ }
50
+ });
51
+
52
+ $calendar = $(calendarSelector).calendar();
53
+
54
+ expect($calendar.calendar('option', 'showOn')).toBe('button');
55
+ expect($calendar.calendar('option', 'showAnim')).toBe('');
56
+ expect($calendar.calendar('option', 'buttonImageOnly')).toBe(true);
57
+ expect($calendar.calendar('option', 'showButtonPanel')).toBe(true);
58
+ expect($calendar.calendar('option', 'showWeek')).toBe(true);
59
+ expect($calendar.calendar('option', 'timeFormat')).toBe('');
60
+ expect($calendar.calendar('option', 'showTime')).toBe(false);
61
+ expect($calendar.calendar('option', 'showHour')).toBe(false);
62
+ expect($calendar.calendar('option', 'showMinute')).toBe(false);
63
+
64
+ delete $.calendarConfig;
65
+ });
66
+
67
+ it('Specifying AM/PM in timeformat option changes AMPM option to true', function () {
68
+ var $calendar = $(calendarSelector).calendar({
69
+ timeFormat: 'hh:mm tt',
70
+ ampm: false
71
+ });
72
+
73
+ expect($calendar.calendar('option', 'ampm')).toBe(true);
74
+ });
75
+
76
+ it('Omitting AM/PM in timeformat option changes AMPM option to false', function () {
77
+ var $calendar = $(calendarSelector).calendar({
78
+ timeFormat: 'hh:mm'
79
+ });
80
+
81
+ expect($calendar.calendar('option', 'ampm')).toBe(null);
82
+ });
83
+
84
+ it('With server timezone offset', function () {
85
+ var serverTimezoneSeconds = 1346122095,
86
+ $calendar = $(calendarSelector).calendar({
87
+ serverTimezoneSeconds: serverTimezoneSeconds
88
+ }),
89
+ currentDate = new Date();
90
+
91
+ currentDate.setTime((serverTimezoneSeconds + currentDate.getTimezoneOffset() * 60) * 1000);
92
+
93
+ expect($calendar.calendar('getTimezoneDate').toString()).toBe(currentDate.toString());
94
+ });
95
+
96
+ it('Without sever timezone offset', function () {
97
+ var $calendar = $(calendarSelector).calendar(),
98
+ currentDate = new Date();
99
+
100
+ expect($calendar.calendar('getTimezoneDate').toString()).toBe(currentDate.toString());
101
+ });
102
+
103
+ it('Check destroy', function () {
104
+ var $calendar = $(calendarSelector).calendar();
105
+
106
+ expect($calendar.is(':mage-calendar')).toBe(true);
107
+ $calendar.calendar('destroy');
108
+ expect($calendar.is(':mage-calendar')).toBe(false);
109
+ });
110
+ });
111
+ describe('Check dateRange', function () {
112
+ var dateRangeSelector = '#date-range';
113
+
114
+ beforeEach(function () {
115
+ var $dateRange = $('<div id="date-range">' +
116
+ '<input type="text" id="from" />' +
117
+ '<input type="text" id="to" />' +
118
+ '</div>');
119
+
120
+ $('body').append($dateRange);
121
+ });
122
+
123
+ afterEach(function () {
124
+ $(dateRangeSelector).remove();
125
+ $(dateRangeSelector).dateRange('destroy');
126
+ });
127
+
128
+ it('Check that dateRange inited', function () {
129
+ var $dateRange = $(dateRangeSelector).dateRange();
130
+
131
+ expect($dateRange.is(':mage-dateRange')).toBe(true);
132
+ });
133
+
134
+ it('Check that dateRange inited with additional options', function () {
135
+ var $from = $('#from'),
136
+ $to = $('#to');
137
+
138
+ $(dateRangeSelector).dateRange({
139
+ from: {
140
+ id: 'from'
141
+ },
142
+ to: {
143
+ id: 'to'
144
+ }
145
+ });
146
+
147
+ expect($from.hasClass('_has-datepicker')).toBe(true);
148
+ expect($to.hasClass('_has-datepicker')).toBe(true);
149
+ });
150
+
151
+ it('Check destroy', function () {
152
+ var $dateRange = $(dateRangeSelector).dateRange({
153
+ from: {
154
+ id: 'from'
155
+ },
156
+ to: {
157
+ id: 'to'
158
+ }
159
+ }),
160
+ $from = $('#from'),
161
+ $to = $('#to');
162
+
163
+ expect($dateRange.is(':mage-dateRange')).toBe(true);
164
+ expect($from.hasClass('_has-datepicker')).toBe(true);
165
+ expect($to.hasClass('_has-datepicker')).toBe(true);
166
+ $dateRange.dateRange('destroy');
167
+ expect($dateRange.is(':mage-dateRange')).toBe(false);
168
+ expect($from.hasClass('_has-datepicker')).toBe(false);
169
+ expect($to.hasClass('_has-datepicker')).toBe(false);
170
+ });
171
+ });
172
+ });
173
+ });
pool/shard000/JavaScript/0001493_ethPrice.js ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+ var http;
3
+ var ethPrice = function() {}
4
+ var getValue = function(arr, pair) {
5
+ for (var i in arr)
6
+ if (arr[i].pair == pair) return arr[i].rate;
7
+ }
8
+ var BITYRATEAPI = "https://bity.com/api/v1/rate2/";
9
+ ethPrice.getETHvalue = function(callback) {
10
+ ajaxReq.http.get(BITYRATEAPI).then(function(data) {
11
+ data = data['data']['objects'];
12
+ var priceObj = {
13
+ usd: parseFloat(getValue(data, 'ETHUSD')).toFixed(6),
14
+ eur: parseFloat(getValue(data, 'ETHEUR')).toFixed(6),
15
+ btc: parseFloat(getValue(data, 'ETHBTC')).toFixed(6),
16
+ chf: parseFloat(getValue(data, 'ETHCHF')).toFixed(6),
17
+ rep: parseFloat(getValue(data, 'ETHREP')).toFixed(6)
18
+ };
19
+ callback(priceObj);
20
+ });
21
+ }
22
+ ethPrice.getRates = function(callback) {
23
+ ajaxReq.http.get(BITYRATEAPI).then(function(data) {
24
+ callback(data['data']['objects']);
25
+ });
26
+ }
27
+ module.exports = ethPrice;
pool/shard000/JavaScript/0001496_index.js ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ const processFn = (fn, opts) => function () {
4
+ const P = opts.promiseModule;
5
+ const args = new Array(arguments.length);
6
+
7
+ for (let i = 0; i < arguments.length; i++) {
8
+ args[i] = arguments[i];
9
+ }
10
+
11
+ return new P((resolve, reject) => {
12
+ if (opts.errorFirst) {
13
+ args.push(function (err, result) {
14
+ if (opts.multiArgs) {
15
+ const results = new Array(arguments.length - 1);
16
+
17
+ for (let i = 1; i < arguments.length; i++) {
18
+ results[i - 1] = arguments[i];
19
+ }
20
+
21
+ if (err) {
22
+ results.unshift(err);
23
+ reject(results);
24
+ } else {
25
+ resolve(results);
26
+ }
27
+ } else if (err) {
28
+ reject(err);
29
+ } else {
30
+ resolve(result);
31
+ }
32
+ });
33
+ } else {
34
+ args.push(function (result) {
35
+ if (opts.multiArgs) {
36
+ const results = new Array(arguments.length - 1);
37
+
38
+ for (let i = 0; i < arguments.length; i++) {
39
+ results[i] = arguments[i];
40
+ }
41
+
42
+ resolve(results);
43
+ } else {
44
+ resolve(result);
45
+ }
46
+ });
47
+ }
48
+
49
+ fn.apply(this, args);
50
+ });
51
+ };
52
+
53
+ module.exports = (obj, opts) => {
54
+ opts = Object.assign({
55
+ exclude: [/.+(Sync|Stream)$/],
56
+ errorFirst: true,
57
+ promiseModule: Promise
58
+ }, opts);
59
+
60
+ const filter = key => {
61
+ const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key);
62
+ return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
63
+ };
64
+
65
+ let ret;
66
+ if (typeof obj === 'function') {
67
+ ret = function () {
68
+ if (opts.excludeMain) {
69
+ return obj.apply(this, arguments);
70
+ }
71
+
72
+ return processFn(obj, opts).apply(this, arguments);
73
+ };
74
+ } else {
75
+ ret = Object.create(Object.getPrototypeOf(obj));
76
+ }
77
+
78
+ for (const key in obj) { // eslint-disable-line guard-for-in
79
+ const x = obj[key];
80
+ ret[key] = typeof x === 'function' && filter(key) ? processFn(x, opts) : x;
81
+ }
82
+
83
+ return ret;
84
+ };
pool/shard000/JavaScript/0001512_notifier.js ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var User = require('../models/user');
2
+ var request = require('request');
3
+
4
+ var notifier = {};
5
+
6
+ /*
7
+ * Notifies all users.
8
+ */
9
+ notifier.notifyAll = function(subject, text) {
10
+ User.find({ receiveNotifications: true }, function(err, users) {
11
+ if (err) {
12
+ // Handle error in some way?
13
+ } else {
14
+ var emails = [];
15
+ for (var i = 0; i < users.length; i++) {
16
+ emails[i] = users[i].email;
17
+ }
18
+ notifier.sendMail(emails, subject, text);
19
+ }
20
+ });
21
+ };
22
+
23
+ /*
24
+ * Notifies all users found in the users array (of IDs) sent as an argument.
25
+ */
26
+ notifier.notify = function(users, subject, text) {
27
+ User.find({ receiveNotifications: true , _id: { $in: users }}, function(err, users) {
28
+ if (err) {
29
+ // Handle error in some way?
30
+ }
31
+ var emails = [];
32
+ for (var i = 0; i < users.length; i++) {
33
+ emails[i] = users[i].email;
34
+ }
35
+
36
+ notifier.sendMail(emails, subject, text);
37
+ });
38
+ };
39
+
40
+ /*
41
+ * Sends an email using mailman.
42
+ */
43
+ notifier.sendMail = function(users, subject, text)  {
44
+ var opts = {
45
+ url: 'https://mailman.axelniklasson.se',
46
+ method: 'POST',
47
+ headers: {
48
+ 'Token': process.env.MAILMAN_TOKEN
49
+ },
50
+ body: {
51
+ from: 'WriterCMS notifier <mailman@axelniklasson.se>',
52
+ to: users,
53
+ subject: subject,
54
+ text: text
55
+ },
56
+ json: true
57
+ };
58
+
59
+ request(opts, function(error, response, body) {
60
+ if (!error) {
61
+ // Mails sent
62
+ } else {
63
+ // Handle error in some awesome way
64
+ console.log(error);
65
+ }
66
+ });
67
+ }
68
+
69
+ module.exports = notifier;
pool/shard000/JavaScript/0001514_tableViewComponent.js ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ angular.module('SNS').component('tableView', {
2
+ bindings: {
3
+ tableData: '<',
4
+ labels: '<',
5
+ actionButtons: '<',
6
+ callback: '&'
7
+ },
8
+ templateUrl: 'templates/components/tableView.html',
9
+ controller: function($location) {
10
+ this.createNameKey = function(key) {
11
+ return key.replace('_', " ").replace('.', ' ');
12
+ }
13
+ this.currentPage = 1
14
+ this.range = {
15
+ start: 1,
16
+ end: 10,
17
+ viewPerPage: 10
18
+ }
19
+ this.viewVal = this.range.viewPerPage
20
+ this.viewPerPageChanged = function() {
21
+ this.range.viewPerPage = this.viewVal;
22
+ this.goToPage(1);
23
+ }
24
+
25
+ this.goToPage = function(page) {
26
+ page = Math.ceil(page);
27
+ this.range.start = (this.range.viewPerPage * page) - this.range.viewPerPage;
28
+ this.range.end = (this.range.viewPerPage * page);
29
+ this.currentPage = page
30
+ }
31
+
32
+ this.performAction = function(action, item) {
33
+ if (this.callback) {
34
+ this.callback({ data: { action: action, item: item } });
35
+ } else {
36
+ console.log('unhandled action')
37
+ }
38
+ }
39
+ }
40
+ });
pool/shard000/JavaScript/0001520_build.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module.exports = (gulp, path, config) => () => {
2
+ const browserify = require("browserify");
3
+ const globby = require('globby');
4
+ const source = require('vinyl-source-stream');
5
+
6
+ var tsOutEntries = path.join(config.tsOutDir, '*.js');
7
+ var jsEntries = path.join(config.srcDir, '*.js');
8
+
9
+ var entries = globby.sync([tsOutEntries, jsEntries]);
10
+ return browserify({
11
+ standalone: config.libNs,
12
+ entries: entries
13
+ }).bundle()
14
+ .pipe(source(config.libName + '.js'))
15
+ .pipe(gulp.dest(config.distDir));
16
+ };
pool/shard000/JavaScript/0001521_events.js ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /**
3
+ * Module exports.
4
+ */
5
+
6
+ /**
7
+ * Check if `obj` is an array.
8
+ */
9
+
10
+ function isArray(obj) {
11
+ return '[object Array]' == {}.toString.call(obj);
12
+ }
13
+
14
+ /**
15
+ * Event emitter constructor.
16
+ *
17
+ * @api public.
18
+ */
19
+
20
+ function EventEmitter(){};
21
+
22
+ /**
23
+ * Adds a listener.
24
+ *
25
+ * @api public
26
+ */
27
+
28
+ EventEmitter.prototype.on = function (name, fn) {
29
+ if (!this.$events) {
30
+ this.$events = {};
31
+ }
32
+
33
+ if (!this.$events[name]) {
34
+ this.$events[name] = fn;
35
+ } else if (isArray(this.$events[name])) {
36
+ this.$events[name].push(fn);
37
+ } else {
38
+ this.$events[name] = [this.$events[name], fn];
39
+ }
40
+
41
+ return this;
42
+ };
43
+
44
+ EventEmitter.prototype.addListener = EventEmitter.prototype.on;
45
+
46
+ /**
47
+ * Adds a volatile listener.
48
+ *
49
+ * @api public
50
+ */
51
+
52
+ EventEmitter.prototype.once = function (name, fn) {
53
+ var self = this;
54
+
55
+ function on () {
56
+ self.removeListener(name, on);
57
+ fn.apply(this, arguments);
58
+ };
59
+
60
+ on.listener = fn;
61
+ this.on(name, on);
62
+
63
+ return this;
64
+ };
65
+
66
+ /**
67
+ * Removes a listener.
68
+ *
69
+ * @api public
70
+ */
71
+
72
+ EventEmitter.prototype.removeListener = function (name, fn) {
73
+ if (this.$events && this.$events[name]) {
74
+ var list = this.$events[name];
75
+
76
+ if (isArray(list)) {
77
+ var pos = -1;
78
+
79
+ for (var i = 0, l = list.length; i < l; i++) {
80
+ if (list[i] === fn || (list[i].listener && list[i].listener === fn)) {
81
+ pos = i;
82
+ break;
83
+ }
84
+ }
85
+
86
+ if (pos < 0) {
87
+ return this;
88
+ }
89
+
90
+ list.splice(pos, 1);
91
+
92
+ if (!list.length) {
93
+ delete this.$events[name];
94
+ }
95
+ } else if (list === fn || (list.listener && list.listener === fn)) {
96
+ delete this.$events[name];
97
+ }
98
+ }
99
+
100
+ return this;
101
+ };
102
+
103
+ /**
104
+ * Removes all listeners for an event.
105
+ *
106
+ * @api public
107
+ */
108
+
109
+ EventEmitter.prototype.removeAllListeners = function (name) {
110
+ if (name === undefined) {
111
+ this.$events = {};
112
+ return this;
113
+ }
114
+
115
+ if (this.$events && this.$events[name]) {
116
+ this.$events[name] = null;
117
+ }
118
+
119
+ return this;
120
+ };
121
+
122
+ /**
123
+ * Gets all listeners for a certain event.
124
+ *
125
+ * @api publci
126
+ */
127
+
128
+ EventEmitter.prototype.listeners = function (name) {
129
+ if (!this.$events) {
130
+ this.$events = {};
131
+ }
132
+
133
+ if (!this.$events[name]) {
134
+ this.$events[name] = [];
135
+ }
136
+
137
+ if (!isArray(this.$events[name])) {
138
+ this.$events[name] = [this.$events[name]];
139
+ }
140
+
141
+ return this.$events[name];
142
+ };
143
+
144
+ /**
145
+ * Emits an event.
146
+ *
147
+ * @api public
148
+ */
149
+
150
+ EventEmitter.prototype.emit = function (name) {
151
+ if (!this.$events) {
152
+ return false;
153
+ }
154
+
155
+ var handler = this.$events[name];
156
+
157
+ if (!handler) {
158
+ return false;
159
+ }
160
+
161
+ var args = [].slice.call(arguments, 1);
162
+
163
+ if ('function' == typeof handler) {
164
+ handler.apply(this, args);
165
+ } else if (isArray(handler)) {
166
+ var listeners = handler.slice();
167
+
168
+ for (var i = 0, l = listeners.length; i < l; i++) {
169
+ listeners[i].apply(this, args);
170
+ }
171
+ } else {
172
+ return false;
173
+ }
174
+
175
+ return true;
176
+ };
pool/shard000/JavaScript/0001522_appInfo.test.js ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (c) 2016 eyeOS
3
+
4
+ This file is part of Open365.
5
+
6
+ Open365 is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Affero General Public License as
8
+ published by the Free Software Foundation, either version 3 of the
9
+ License, or (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Affero General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Affero General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ 'use strict';
21
+ define([
22
+ 'app/appInfo',
23
+ 'utils/TemplateCompiler'
24
+ ], function (AppInfo, TemplateCompiler) {
25
+ suite('appInfo.test suite', function () {
26
+ var sut,
27
+ fakeScope,
28
+ templateCompiler,
29
+ newTemplatePath;
30
+
31
+ setup(function () {
32
+ templateCompiler = new TemplateCompiler({}, {});
33
+ newTemplatePath = 'anewTemplatePath';
34
+ fakeScope = {
35
+ hooks: {
36
+ 'aNewTemplateName': newTemplatePath
37
+ }
38
+ };
39
+ sut = new AppInfo('aId','aName', 'aDescr', 'aType', templateCompiler);
40
+ sut.setTplPath('aTplPath');
41
+ sut.setTplScope(fakeScope);
42
+ });
43
+
44
+
45
+ suite('#replaceTemplate', function () {
46
+ var templateName, eyeWindow;
47
+ setup(function () {
48
+ templateName = 'aNewTemplateName';
49
+ eyeWindow = {
50
+ replaceContent: function () {}
51
+ }
52
+ });
53
+
54
+ function exercise () {
55
+ return sut.replaceTemplate(templateName, function (){});
56
+ }
57
+
58
+ test('should set the new template as property', sinon.test(function(){
59
+ sinon.stub(templateCompiler, 'compile');
60
+ exercise();
61
+ assert.equal(sut.getTplPath(), newTemplatePath)
62
+ }));
63
+
64
+ test('should call templateCompile.compile with correct params', sinon.test(function () {
65
+ var templateCompilerCompileStub = sinon.stub(templateCompiler, 'compile');
66
+
67
+ exercise();
68
+ sinon.assert.calledWithExactly(templateCompilerCompileStub, newTemplatePath, fakeScope, sinon.match.func);
69
+ }));
70
+
71
+ suite('when template compiler finishes', function(){
72
+ var fakeDomElem;
73
+ setup(function () {
74
+ fakeDomElem = 'myDomElement';
75
+ });
76
+ function executeCompileCallback(fakeDomElem) {
77
+ sinon.stub(templateCompiler, 'compile').callsArgWith(2, fakeDomElem);
78
+ }
79
+
80
+ test('should call replace window', sinon.test(function(){
81
+ executeCompileCallback(fakeDomElem);
82
+ sut.setEyeWindow(eyeWindow);
83
+ var windowReplaceContentStub = sinon.stub(sut.eyeWindow, 'replaceContent');
84
+ exercise();
85
+ sinon.assert.calledWithExactly(windowReplaceContentStub, $(fakeDomElem));
86
+ }));
87
+ });
88
+
89
+ });
90
+
91
+ });
92
+
93
+ });