Pendigard commited on
Commit
9b76a89
·
verified ·
1 Parent(s): 46c3625

Upload folder using huggingface_hub (part 15)

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/0003799_worker-testharness.js +49 -0
  2. pool/shard000/JavaScript/0003801_update.js +69 -0
  3. pool/shard000/JavaScript/0003802_update-feed-widget.js +98 -0
  4. pool/shard000/JavaScript/0003805_budget.js +23 -0
  5. pool/shard000/JavaScript/0003806_seed.js +30 -0
  6. pool/shard000/JavaScript/0003808_app-services.js +98 -0
  7. pool/shard000/JavaScript/0003810_post_image_view.js +118 -0
  8. pool/shard000/JavaScript/0003812_index.js +21 -0
  9. pool/shard000/JavaScript/0003813_lazy-box.js +124 -0
  10. pool/shard000/JavaScript/0003817_jquery.metadata.js +122 -0
  11. pool/shard000/JavaScript/0003819_crawl.js +77 -0
  12. pool/shard000/JavaScript/0003821_platform_viewports.js +112 -0
  13. pool/shard000/JavaScript/0003822_ace_widget.js +245 -0
  14. pool/shard000/JavaScript/0003824_bootstrap-typeahead.js +44 -0
  15. pool/shard000/JavaScript/0003825_orient.test.js +161 -0
  16. pool/shard000/JavaScript/0003826_watcher.js +171 -0
  17. pool/shard000/JavaScript/0003827_Config.js +64 -0
  18. pool/shard000/JavaScript/0003830_context-menu.js +33 -0
  19. pool/shard000/JavaScript/0003831_inject.js +45 -0
  20. pool/shard000/JavaScript/0003832_object-validator.js +276 -0
  21. pool/shard000/JavaScript/0003834_trash.js +233 -0
  22. pool/shard000/JavaScript/0003835_ui-wysiwyg.js +72 -0
  23. pool/shard000/JavaScript/0003836_transitional.js +131 -0
  24. pool/shard000/JavaScript/0003838_cellRendererService.js +102 -0
  25. pool/shard000/JavaScript/0003840_chatobserver.js +33 -0
  26. pool/shard000/JavaScript/0003841_index.js +45 -0
  27. pool/shard000/JavaScript/0003843_DefaultService.js +30 -0
  28. pool/shard000/JavaScript/0003849_updateInPlace.js +53 -0
  29. pool/shard000/JavaScript/0003850_DeliveryController.js +31 -0
  30. pool/shard000/JavaScript/0003852_index.js +77 -0
  31. pool/shard000/JavaScript/0003853_empty-group-filters-extra-view.spec.js +167 -0
  32. pool/shard000/JavaScript/0003856_ember-strap.js +29 -0
  33. pool/shard000/JavaScript/0003859_normalizeType.tests.js +33 -0
  34. pool/shard000/JavaScript/0003860_MD5Sum.spec.js +41 -0
  35. pool/shard000/JavaScript/0003868_Tier19_2set.js +52 -0
  36. pool/shard000/JavaScript/0003869_subnets.js +94 -0
  37. pool/shard000/JavaScript/0003876_document.js +118 -0
  38. pool/shard000/JavaScript/0003880_MainMenu.js +63 -0
  39. pool/shard000/JavaScript/0003881_entryActions.js +172 -0
  40. pool/shard000/JavaScript/0003883_minifier.js +226 -0
  41. pool/shard000/JavaScript/0003888_control-message.js +90 -0
  42. pool/shard000/JavaScript/0003889_number-display.js +140 -0
  43. pool/shard000/JavaScript/0003890_mainline.js +146 -0
  44. pool/shard000/JavaScript/0003895_allowedHosts.js +20 -0
  45. pool/shard000/JavaScript/0003896_slides.js +154 -0
  46. pool/shard000/JavaScript/0003898_xquery_worker.js +81 -0
  47. pool/shard000/JavaScript/0003899_vsync-impl.js +481 -0
  48. pool/shard000/JavaScript/0003903_PostListComponent.js +121 -0
  49. pool/shard000/JavaScript/0003906_async-gen-yield-star-getiter-async-returns-undefined-throw.js +69 -0
  50. pool/shard000/JavaScript/0003908_inner_home.js +23 -0
pool/shard000/JavaScript/0003799_worker-testharness.js ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * worker-test-harness should be considered a temporary polyfill around
3
+ * testharness.js for supporting Service Worker based tests. It should not be
4
+ * necessary once the test harness is able to drive worker based tests natively.
5
+ * See https://github.com/w3c/testharness.js/pull/82 for status of effort to
6
+ * update upstream testharness.js. Once the upstreaming is complete, tests that
7
+ * reference worker-test-harness should be updated to directly import
8
+ * testharness.js.
9
+ */
10
+
11
+ importScripts('/resources/testharness.js');
12
+
13
+ (function() {
14
+ var next_cache_index = 1;
15
+
16
+ // Returns a promise that resolves to a newly created Cache object. The
17
+ // returned Cache will be destroyed when |test| completes.
18
+ function create_temporary_cache(test) {
19
+ var uniquifier = String(++next_cache_index);
20
+ var cache_name = self.location.pathname + '/' + uniquifier;
21
+
22
+ test.add_cleanup(function() {
23
+ self.caches.delete(cache_name);
24
+ });
25
+
26
+ return self.caches.delete(cache_name)
27
+ .then(function() {
28
+ return self.caches.open(cache_name);
29
+ });
30
+ }
31
+
32
+ self.create_temporary_cache = create_temporary_cache;
33
+ })();
34
+
35
+ // Runs |test_function| with a temporary unique Cache passed in as the only
36
+ // argument. The function is run as a part of Promise chain owned by
37
+ // promise_test(). As such, it is expected to behave in a manner identical (with
38
+ // the exception of the argument) to a function passed into promise_test().
39
+ //
40
+ // E.g.:
41
+ // cache_test(function(cache) {
42
+ // // Do something with |cache|, which is a Cache object.
43
+ // }, "Some Cache test");
44
+ function cache_test(test_function, description) {
45
+ promise_test(function(test) {
46
+ return create_temporary_cache(test)
47
+ .then(test_function);
48
+ }, description);
49
+ }
pool/shard000/JavaScript/0003801_update.js ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ module.exports = function (wikifs, fixture, promise, test, isBinary) {
4
+ var updates = isBinary ? fixture.binaryFiles : fixture.textFiles;
5
+ var p = promise.then(function () {
6
+ return wikifs.createFile(
7
+ updates[0].path, updates[0].content, updates[0].commit_message,
8
+ updates[0].user_defined, isBinary
9
+ );
10
+ }).then(wikifs.readFile).catch(function (err) {
11
+ console.error(err); test.ok(false);
12
+ });
13
+
14
+ // update wikifs and assert it's attributes in sequence.
15
+ updates.forEach(function (update, index) {
16
+ // updates[0] was used to create a file
17
+ if (index === 0) {
18
+ return;
19
+ }
20
+
21
+ p = p.then(function (file) {
22
+ return wikifs.updateFile(
23
+ file.id, update.content, file.version,
24
+ update.commit_message
25
+ );
26
+ }).then(function (id) {
27
+ return wikifs.readFile(id).then(function (file) {
28
+ test.deepEqual(
29
+ file.content,
30
+ update.content
31
+ );
32
+ test.deepEqual(file.commit_message, update.commit_message);
33
+ // when created, version already 1.
34
+ test.equal(file.version, index + 1);
35
+ return file;
36
+ });
37
+ }).catch(function (err) { console.error(err); test.ok(false); });
38
+ });
39
+
40
+ // read old version and compare it
41
+ updates.forEach(function (update, index) {
42
+ p = p.then(function () {
43
+ return wikifs.readFile(updates[0].path, index + 1);
44
+ }).then(function (file) {
45
+ test.deepEqual(file.content, update.content);
46
+ test.deepEqual(file.commit_message, update.commit_message);
47
+ test.equal(file.version, index + 1);
48
+ }).catch(function (err) {
49
+ console.error(err); test.ok(false); });
50
+ });
51
+
52
+ // read history data.
53
+ p = p.then(function () {
54
+ return wikifs.readFileHistory(updates[0].path).then(function (history) {
55
+ history.forEach(function (commit, index) {
56
+ if (index === 0) {
57
+ return;
58
+ }
59
+ test.deepEqual(
60
+ commit.commit_message,
61
+ updates[index].commit_message
62
+ );
63
+ test.equal(commit.size, updates[index].content.length);
64
+ });
65
+ }).catch(function (err) { console.error(err); test.ok(false); });
66
+ });
67
+ p.then(function () { test.done(); wikifs.disconnect(); });
68
+ };
69
+
pool/shard000/JavaScript/0003802_update-feed-widget.js ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Template } from 'meteor/templating';
2
+ import { Tracker } from 'meteor/tracker';
3
+ import SimpleSchema from 'simpl-schema';
4
+ import { moment } from 'meteor/momentjs:moment';
5
+ import { _ } from 'meteor/erasaur:meteor-lodash';
6
+ import { Roles } from 'meteor/alanning:roles';
7
+ import { Feeds } from '../../../api/feed/FeedCollection';
8
+ import { updateMethod } from '../../../api/base/BaseCollection.methods';
9
+ import { Semesters } from '../../../api/semester/SemesterCollection.js';
10
+ import { Courses } from '../../../api/course/CourseCollection.js';
11
+ import { Opportunities } from '../../../api/opportunity/OpportunityCollection.js';
12
+ import * as FormUtils from '../form-fields/form-field-utilities.js';
13
+ import { ROLE } from '../../../api/role/Role';
14
+
15
+ const updateSchema = new SimpleSchema({
16
+ description: { type: String, optional: true },
17
+ picture: { type: String, optional: true },
18
+ users: { type: Array }, 'users.$': String,
19
+ opportunity: { type: String, optional: true },
20
+ course: { type: String, optional: true },
21
+ semester: { type: String, optional: true },
22
+ retired: Boolean,
23
+ }, { tracker: Tracker });
24
+
25
+ Template.Update_Feed_Widget.onCreated(function onCreated() {
26
+ FormUtils.setupFormWidget(this, updateSchema);
27
+ });
28
+
29
+ Template.Update_Feed_Widget.helpers({
30
+ semesters() {
31
+ return Semesters.findNonRetired({}, { sort: { semesterNumber: 1 } });
32
+ },
33
+ feedTypes() {
34
+ return [
35
+ Feeds.NEW_COURSE,
36
+ Feeds.NEW_OPPORTUNITY,
37
+ Feeds.VERIFIED_OPPORTUNITY,
38
+ Feeds.NEW_COURSE_REVIEW,
39
+ Feeds.NEW_OPPORTUNITY_REVIEW,
40
+ Feeds.NEW_USER,
41
+ Feeds.NEW_LEVEL,
42
+ ];
43
+ },
44
+ timestamp() {
45
+ const feed = Feeds.findDoc(Template.currentData().updateID.get());
46
+ return moment(feed.timestamp).format();
47
+ },
48
+ feed() {
49
+ return Feeds.findDoc(Template.currentData().updateID.get());
50
+ },
51
+ opportunities() {
52
+ return Opportunities.find({}, { sort: { name: 1 } });
53
+ },
54
+ courses() {
55
+ return Courses.findNonRetired({}, { sort: { number: 1 } });
56
+ },
57
+ users() {
58
+ const students = Roles.getUsersInRole([ROLE.STUDENT]).fetch();
59
+ const sorted = _.sortBy(students, 'lastName');
60
+ return sorted;
61
+ },
62
+ falseValueRetired() {
63
+ const plan = Feeds.findDoc(Template.currentData()
64
+ .updateID
65
+ .get());
66
+ return !plan.retired;
67
+ },
68
+ trueValueRetired() {
69
+ const plan = Feeds.findDoc(Template.currentData()
70
+ .updateID
71
+ .get());
72
+ return plan.retired;
73
+ },
74
+ });
75
+
76
+ Template.Update_Feed_Widget.events({
77
+ submit(event, instance) {
78
+ event.preventDefault();
79
+ const updateData = FormUtils.getSchemaDataFromEvent(updateSchema, event);
80
+ instance.context.reset();
81
+ updateSchema.clean(updateData, { mutate: true });
82
+ updateData.retired = updateData.retired === 'true';
83
+ instance.context.validate(updateData);
84
+ if (instance.context.isValid()) {
85
+ updateData.id = instance.data.updateID.get();
86
+ updateMethod.call({ collectionName: Feeds.getCollectionName(), updateData }, (error) => {
87
+ if (error) {
88
+ FormUtils.indicateError(instance, error);
89
+ } else {
90
+ FormUtils.indicateSuccess(instance, event);
91
+ }
92
+ });
93
+ } else {
94
+ FormUtils.indicateError(instance);
95
+ }
96
+ },
97
+ 'click .jsCancel': FormUtils.processCancelButtonClick,
98
+ });
pool/shard000/JavaScript/0003805_budget.js ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var Mystique = require('mystique');
2
+
3
+ var BudgetTransformer = Mystique.Transformer.extend({
4
+ resourceName: 'budget',
5
+ mapOut: function(budget) {
6
+ return {
7
+ id: budget.id,
8
+ name: budget.name,
9
+ startDate: budget.startDate,
10
+ remaining: budget.remaining,
11
+ };
12
+ },
13
+
14
+ mapIn(req) {
15
+ return {
16
+ name: req.body.budget.name,
17
+ startDate: req.body.budget.startDate,
18
+ remaining: req.body.budget.remaining,
19
+ };
20
+ },
21
+ });
22
+
23
+ Mystique.registerTransformer('Budget', BudgetTransformer);
pool/shard000/JavaScript/0003806_seed.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var mongoose = require('mongoose'),
2
+ Course = require('./../models/course.js'),
3
+ User = require('./../models/user.js');
4
+
5
+ exports.init = function(connectionString, cb) {
6
+ mongoose.connect(connectionString);
7
+ var user = new User({_id: '11e42af15f9b16241a4a80f8', name : "chibolo pulpin"});
8
+ user.save(function(err) {
9
+ if (err) return cb(err);
10
+ var fm = '{"isEditable":false,"decimals":2,"label":null,"bounds":{"upper":20,"lower":0},"trunk":0,"deleteMin":0,"children":[{"isEditable":true,"decimals":2,"label":null,"bounds":{"upper":20,"lower":0},"trunk":0,"deleteMin":0,"children":[]},{"isEditable":true,"decimals":2,"label":null,"bounds":{"upper":20,"lower":0},"trunk":0,"deleteMin":0,"children":[]}]}';
11
+ var coursesNames = ['Fisica 1','Calculo 1','Quimica 1','Teología','Mate basicas'];
12
+ var userId = user._id;
13
+ for (var i = 0; i < coursesNames.length; i++) {
14
+
15
+ //console.log("formula",fm);
16
+ Course.create({name: coursesNames[i],
17
+ formula: '{"isEditable":false,"decimals":2,"label":null,"bounds":{"upper":20,"lower":0},"trunk":0,"deleteMin":0,"children":[{"isEditable":true,"decimals":2,"label":null,"bounds":{"upper":20,"lower":0},"trunk":0,"deleteMin":0,"children":[]},{"isEditable":true,"decimals":2,"label":null,"bounds":{"upper":20,"lower":0},"trunk":0,"deleteMin":0,"children":[]}]}',
18
+ userId: userId},
19
+ function(err, course) {
20
+ if (err) return cb(err);
21
+ Course.share({
22
+ courseId: course._id,
23
+ userId: '11e42af15f9b16241a4a80f8'
24
+ }, function(err) {
25
+ if (err) return cb(err);
26
+ })
27
+ });
28
+ }
29
+ });
30
+ }
pool/shard000/JavaScript/0003808_app-services.js ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (window, angular, console) {
2
+
3
+ 'use strict';
4
+
5
+ /* Services */
6
+
7
+
8
+ // Demonstrate how to register services
9
+ // In this case it is a simple value service.
10
+ angular.module('myApp.services', []).value('version', '0.1').factory('admin', ['$rootScope',
11
+ function ($rootScope) {
12
+ return {
13
+ allowed: function (menu) {
14
+ if ($rootScope.user.roles.indexOf('_admin') === -1 && $rootScope.user.roles.indexOf('sys') === -1 && menu === "delete") {
15
+ return false;
16
+ }
17
+ return true;
18
+ }
19
+ };
20
+ }
21
+ ]).factory('auth', ['$q', '$http', 'md5', '$rootScope',
22
+ function ($q, $http, md5, $rootScope) {
23
+ $rootScope.profile = null;
24
+ var avatar = function (user, $route) {
25
+ $rootScope.profile = {
26
+ user: user,
27
+ hash: md5.createHash(user.name)
28
+ };
29
+ checkOrganization();
30
+ $http.jsonp("http://www.gravatar.com/" + $rootScope.profile.hash + ".json?callback=JSON_CALLBACK").
31
+ success(function (data, status, headers, config) {
32
+ if (data.entry && data.entry.length > 0 && data.entry[0].name && data.entry[0].name.formatted) {
33
+ $rootScope.profile.gravatar = data.entry[0].name.formatted;
34
+ }
35
+ }).
36
+ error(function (data, status, headers, config) {
37
+ $rootScope.profile.gravatar = "";
38
+ });
39
+ };
40
+ var checkOrganization = function () {
41
+ $rootScope.admin = $rootScope.profile.user.roles.indexOf('_admin') !== -1 || $rootScope.profile.user.roles.indexOf('sys') !== -1;
42
+ if ($rootScope.organizationId) {
43
+ for (var i = 0; i < $rootScope.profile.user.organizations.length; i++) {
44
+ var organization = $rootScope.profile.user.organizations[i];
45
+ if (organization.id === $rootScope.organizationId) {
46
+ $rootScope.organization = organization;
47
+ $rootScope.admin =
48
+ $rootScope.profile.user.roles.indexOf('_admin') !== -1 || $rootScope.profile.user.roles.indexOf('sys') !== -1 || $rootScope.profile.user.roles.indexOf('admin_' + organization.id) !== -1;
49
+ break;
50
+ }
51
+ }
52
+ }
53
+ };
54
+ return {
55
+ getUser: function () {
56
+ var deferred = $q.defer();
57
+ if ($rootScope.profile) {
58
+ checkOrganization();
59
+ return true;
60
+ } else {
61
+ $http.get("/api/session").
62
+ success(function (data, status, headers, config) {
63
+ console.log(data);
64
+ avatar(data.user);
65
+ deferred.resolve();
66
+ }).
67
+ error(function (data, status, headers, config) {
68
+ deferred.reject();
69
+ });
70
+ }
71
+ return deferred.promise;
72
+ },
73
+ setUser: function (data) {
74
+ avatar(data);
75
+ },
76
+ authorize: function () {
77
+ var deferred = $q.defer();
78
+ /**if ($rootScope.profile) {
79
+ checkOrganization();
80
+ window.setTimeout(function () {
81
+ deferred.resolve();
82
+ }, 0);
83
+ } else {*/
84
+ $http.get("/api/session").
85
+ success(function (data, status, headers, config) {
86
+ console.log(data);
87
+ avatar(data.user);
88
+ deferred.resolve();
89
+ }).
90
+ error(function (data, status, headers, config) {
91
+ deferred.reject();
92
+ });
93
+ //}
94
+ return deferred.promise;
95
+ }
96
+ };
97
+ }]);
98
+ })(this, this.angular, this.console);
pool/shard000/JavaScript/0003810_post_image_view.js ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var args = arguments[0] || {};
2
+
3
+
4
+ var photoData;
5
+
6
+ var setImageEvent = "setImage";
7
+
8
+ function showCamera() {
9
+
10
+ Titanium.Media.showCamera({
11
+ success : function(event) {
12
+ Ti.API.debug("picture was taken");
13
+ //imageView.image = event.media;
14
+ photoData = event.media;
15
+ $.photo.image = event.media;
16
+ $.trigger(setImageEvent,{photo : photoData});
17
+ },
18
+ cancel : function() {
19
+
20
+ },
21
+ error : function(error) {
22
+ var a = Titanium.UI.createAlertDialog({
23
+ title : 'Camera'
24
+ });
25
+ if (error.code == Titanium.Media.NO_CAMERA) {
26
+ //a.setMessage('No camera');
27
+ //a.show();
28
+ showGallery();
29
+ } else {
30
+ a.setMessage('Unexpected error: ' + error.code);
31
+ a.show();
32
+ }
33
+ },
34
+ //overlay : overlay,
35
+ saveToPhotoGallery:false,
36
+ mediaTypes : Ti.Media.MEDIA_TYPE_PHOTO,
37
+ allowEditing : true
38
+ });
39
+ }
40
+
41
+ function showGallery(){
42
+ Titanium.Media.openPhotoGallery({
43
+ success : function(event) {
44
+ photoData = event.media;
45
+ $.photo.image = event.media;
46
+ $.trigger(setImageEvent,{photo : photoData});
47
+ }
48
+ });
49
+ }
50
+
51
+ function postData(data) {
52
+ if (Ti.Platform.name === 'iPhone OS'){
53
+ style = Ti.UI.iPhone.ActivityIndicatorStyle.PLAIN;
54
+ }
55
+ else {
56
+ style = Ti.UI.ActivityIndicatorStyle.PLAIN;
57
+ }
58
+ var activityIndicator = Ti.UI.createActivityIndicator({
59
+ color: 'white',
60
+ font: {fontFamily:'Helvetica Neue', fontSize:26, fontWeight:'bold'},
61
+ message: 'Uploading...',
62
+ indicatorDiameter : "50dp",
63
+ style:style,
64
+ height:Ti.UI.SIZE,
65
+ width:Ti.UI.SIZE
66
+ });
67
+ var currentWindow = Alloy.Globals.naviCon.getCurrentWindow();
68
+ var coverWindow = Ti.UI.createWindow({
69
+ backgroundColor: '#555555',
70
+ fullscreen : true,
71
+ opacity : 0.6
72
+ });
73
+ var indicatorWindow = Ti.UI.createWindow({
74
+ fullscreen: true
75
+ });
76
+ indicatorWindow.add(activityIndicator);
77
+ indicatorWindow.addEventListener("open",function(){
78
+ activityIndicator.show();
79
+ });
80
+ coverWindow.open();
81
+ indicatorWindow.open();
82
+
83
+ Alloy.Globals.api.postManager.post(photoData,data,function(result){
84
+ indicatorWindow.close();
85
+ coverWindow.close();
86
+ activityIndicator.hide();
87
+
88
+ if(result){
89
+ Alloy.Globals.lastPost = result;
90
+ Alloy.Globals.post = result;
91
+ var dialog = Titanium.UI.createAlertDialog({
92
+ title : "投稿完了",
93
+ message : '投稿ありがとうございます。'
94
+ });
95
+ Alloy.Globals.naviCon.home();
96
+ dialog.show();
97
+ }else{
98
+ var dialog = Titanium.UI.createAlertDialog({
99
+ title : "投稿失敗",
100
+ message : '投稿に失敗しました。ネットワークを確認して、再度投稿してください'
101
+ });
102
+ dialog.show();
103
+
104
+ }
105
+
106
+ });
107
+
108
+
109
+ }
110
+
111
+ exports.showCamera = showCamera;
112
+ exports.showGallery = showGallery;
113
+ exports.postData = postData;
114
+
115
+ /*
116
+ $.post_image_view.addEventListener("open",function(){
117
+ showCamera();
118
+ });*/
pool/shard000/JavaScript/0003812_index.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function createReducer (initialState, handlers) {
2
+ return function (state, action) {
3
+ if (state === undefined) {
4
+ state = initialState
5
+ }
6
+ if (action === undefined) {
7
+ action = {}
8
+ }
9
+
10
+ if ('type' in action) {
11
+ return handlers[action.type]
12
+ ? handlers[action.type](state, action)
13
+ : state
14
+ }
15
+
16
+ return state
17
+ }
18
+ }
19
+
20
+ module.exports = createReducer
21
+
pool/shard000/JavaScript/0003813_lazy-box.js ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ function safeAutorun(f){
3
+ return Tracker.nonreactive(function(){
4
+ return Tracker.autorun(f);
5
+ });
6
+ }
7
+
8
+
9
+ LazyBox = function (func, equals) {
10
+ var self = this;
11
+
12
+ // state tracking
13
+ self.stopped = false;
14
+
15
+ self.func = func;
16
+ self.equals = equals;
17
+
18
+ self.curResult = null;
19
+
20
+ self.dep = new Tracker.Dependency;
21
+
22
+ // Don't initialise a computation until required.
23
+ self.resultComputation = null;
24
+
25
+ // bind functions so they're only created once
26
+ self._computation = self._computation.bind(self);
27
+ self._onInvalidate = self._onInvalidate.bind(self);
28
+ self._pauseAfterFlush = self._pauseAfterFlush.bind(self);
29
+ };
30
+
31
+ LazyBox.prototype._computation = function (c) {
32
+ var self = this;
33
+ var func = self.func;
34
+
35
+ var newResult = func();
36
+
37
+ if (! c.firstRun) {
38
+ var equals = self.equals;
39
+ var oldResult = self.curResult;
40
+
41
+ if (equals ? equals(newResult, oldResult) :
42
+ newResult === oldResult) {
43
+ // same as last time
44
+ return;
45
+ }
46
+ }
47
+
48
+ self.curResult = newResult;
49
+ self.dep.changed();
50
+ };
51
+
52
+ LazyBox.prototype._onInvalidate = function(){
53
+ var self = this;
54
+ if (self.stopped){
55
+ return;
56
+ }
57
+ // when it's invalidated, Tracker will flush to recompute
58
+ Tracker.afterFlush(self._pauseAfterFlush);
59
+ };
60
+
61
+ LazyBox.prototype._pauseAfterFlush = function(){
62
+ var self = this;
63
+ if (self.stopped || self.resultComputation == null){
64
+ return;
65
+ }
66
+ if (!self.dep.hasDependents()){
67
+ // pause
68
+ self.resultComputation.stop();
69
+ self.resultComputation = null;
70
+ }
71
+ };
72
+
73
+ LazyBox.prototype.depend = function(){
74
+ var self = this;
75
+ if (!Tracker.active){
76
+ // TODO: Warn users calling LazyBox.get without a current computation. Will cause a lot of stop/starting.
77
+ if (!self.dep.hasDependents()){
78
+ self.resultComputation.stop();
79
+ self.resultComputation = null;
80
+ }
81
+ return;
82
+ }
83
+ if (self.dep.depend()) {
84
+ Tracker.currentComputation.onInvalidate(self._onInvalidate);
85
+ }
86
+ };
87
+
88
+ LazyBox.prototype.stop = function () {
89
+ var self = this;
90
+ if (self.stopped){
91
+ return;
92
+ }
93
+ if (self.resultComputation != null) {
94
+ self.resultComputation.stop();
95
+ self.resultComputation = null;
96
+ }
97
+ self.func = null;
98
+ self.equals = null;
99
+ self.curResult = null;
100
+ self.dep = null;
101
+ self._computation = null;
102
+ self._onInvalidate = null;
103
+ self._pauseAfterFlush = null;
104
+ self.stopped = true;
105
+ };
106
+
107
+ LazyBox.prototype.get = function () {
108
+ var self = this;
109
+ if (self.stopped){
110
+ throw new Error('LazyBox#get() called after stopped.');
111
+ }
112
+ // Check if the computation is running
113
+ if (self.resultComputation == null){
114
+ // restart as necessary
115
+ self.resultComputation = safeAutorun(self._computation);
116
+ } else if (self.resultComputation.invalidated) {
117
+ // or recompute if invalidated
118
+ self.resultComputation._recompute();
119
+ }
120
+
121
+ self.depend();
122
+
123
+ return self.curResult;
124
+ };
pool/shard000/JavaScript/0003817_jquery.metadata.js ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Metadata - jQuery plugin for parsing metadata from elements
3
+ *
4
+ * Copyright (c) 2006 John Resig, Yehuda Katz, J�örn Zaefferer, Paul McLanahan
5
+ *
6
+ * Dual licensed under the MIT and GPL licenses:
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ * http://www.gnu.org/licenses/gpl.html
9
+ *
10
+ * Revision: $Id: jquery.metadata.js,v 1.1 2009-09-02 20:58:49 hexbinary Exp $
11
+ *
12
+ */
13
+
14
+ /**
15
+ * Sets the type of metadata to use. Metadata is encoded in JSON, and each property
16
+ * in the JSON will become a property of the element itself.
17
+ *
18
+ * There are three supported types of metadata storage:
19
+ *
20
+ * attr: Inside an attribute. The name parameter indicates *which* attribute.
21
+ *
22
+ * class: Inside the class attribute, wrapped in curly braces: { }
23
+ *
24
+ * elem: Inside a child element (e.g. a script tag). The
25
+ * name parameter indicates *which* element.
26
+ *
27
+ * The metadata for an element is loaded the first time the element is accessed via jQuery.
28
+ *
29
+ * As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
30
+ * matched by expr, then redefine the metadata type and run another $(expr) for other elements.
31
+ *
32
+ * @name $.metadata.setType
33
+ *
34
+ * @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
35
+ * @before $.metadata.setType("class")
36
+ * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
37
+ * @desc Reads metadata from the class attribute
38
+ *
39
+ * @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
40
+ * @before $.metadata.setType("attr", "data")
41
+ * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
42
+ * @desc Reads metadata from a "data" attribute
43
+ *
44
+ * @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
45
+ * @before $.metadata.setType("elem", "script")
46
+ * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
47
+ * @desc Reads metadata from a nested script element
48
+ *
49
+ * @param String type The encoding type
50
+ * @param String name The name of the attribute to be used to get metadata (optional)
51
+ * @cat Plugins/Metadata
52
+ * @descr Sets the type of encoding to be used when loading metadata for the first time
53
+ * @type undefined
54
+ * @see metadata()
55
+ */
56
+
57
+ (function($) {
58
+
59
+ $.extend({
60
+ metadata : {
61
+ defaults : {
62
+ type: 'class',
63
+ name: 'metadata',
64
+ cre: /({.*})/,
65
+ single: 'metadata'
66
+ },
67
+ setType: function( type, name ){
68
+ this.defaults.type = type;
69
+ this.defaults.name = name;
70
+ },
71
+ get: function( elem, opts ){
72
+ var settings = $.extend({},this.defaults,opts);
73
+ // check for empty string in single property
74
+ if ( !settings.single.length ) settings.single = 'metadata';
75
+
76
+ var data = $.data(elem, settings.single);
77
+ // returned cached data if it already exists
78
+ if ( data ) return data;
79
+
80
+ data = "{}";
81
+
82
+ if ( settings.type == "class" ) {
83
+ var m = settings.cre.exec( elem.className );
84
+ if ( m )
85
+ data = m[1];
86
+ } else if ( settings.type == "elem" ) {
87
+ if( !elem.getElementsByTagName )
88
+ return undefined;
89
+ var e = elem.getElementsByTagName(settings.name);
90
+ if ( e.length )
91
+ data = $.trim(e[0].innerHTML);
92
+ } else if ( elem.getAttribute != undefined ) {
93
+ var attr = elem.getAttribute( settings.name );
94
+ if ( attr )
95
+ data = attr;
96
+ }
97
+
98
+ if ( data.indexOf( '{' ) <0 )
99
+ data = "{" + data + "}";
100
+
101
+ data = eval("(" + data + ")");
102
+
103
+ $.data( elem, settings.single, data );
104
+ return data;
105
+ }
106
+ }
107
+ });
108
+
109
+ /**
110
+ * Returns the metadata object for the first member of the jQuery object.
111
+ *
112
+ * @name metadata
113
+ * @descr Returns element's metadata object
114
+ * @param Object opts An object contianing settings to override the defaults
115
+ * @type jQuery
116
+ * @cat Plugins/Metadata
117
+ */
118
+ $.fn.metadata = function( opts ){
119
+ return $.metadata.get( this[0], opts );
120
+ };
121
+
122
+ })(jQuery);
pool/shard000/JavaScript/0003819_crawl.js ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2015 IBM Corp. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
+ * use this file except in compliance with the License. You may obtain a copy of
6
+ * 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, WITHOUT
12
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ * License for the specific language governing permissions and limitations under
14
+ * the License.
15
+ */
16
+
17
+ const TwitterCrawler = require('../lib/twitter-crawler');
18
+ const fs = require('fs');
19
+ const log = require('winston');
20
+ const Promise = require('bluebird');
21
+
22
+ const getEnvCredentials = () =>
23
+ process.env.TWITTER_CREDENTIALS ? JSON.parse(process.env.TWITTER_CREDENTIALS) : [];
24
+
25
+ const credentials = [
26
+ {
27
+ consumer_key : "<consumer_key>",
28
+ consumer_secret : "<consumer_secret>",
29
+ access_token_key : "<access_token_key>",
30
+ access_token_secret : "<access_token_secret>",
31
+ enabled : false
32
+ }
33
+ ].concat(getEnvCredentials());
34
+
35
+
36
+ const bind = (object, method) => object[method].bind(object);
37
+
38
+ function saveOutput(obj, filename) {
39
+ fs.writeFile(`${__dirname}/output/${filename}`, JSON.stringify(obj, null, ' '));
40
+ }
41
+
42
+
43
+ const crawler = new TwitterCrawler(credentials);
44
+ const crawlList = [
45
+ 'ladygaga',
46
+ '19397785',
47
+ 'KingJames'
48
+ ];
49
+
50
+
51
+ module.exports = Promise.all(crawlList.map((twitterHandle) => {
52
+ // Get user
53
+ log.info(`Obtaining user with id ${twitterHandle}...`);
54
+ return crawler.getUser(twitterHandle)
55
+ .then((user) => {
56
+ log.info(
57
+ `Obtained info for user ${user.name} (${user.id}). ` +
58
+ `Storing in output/${twitterHandle}_user.json`
59
+ );
60
+
61
+ saveOutput(user, `${twitterHandle}_user.json`);
62
+
63
+ // Crawl tweets
64
+ log.info('Obtaining tweets...');
65
+ return crawler.getTweets(twitterHandle, { min_tweets: 50, limit : 300 })
66
+ .then((tweets) => {
67
+ log.info(
68
+ `Obtained ${tweets.length} tweets for user ${user.name} (${user.id}). ` +
69
+ `Storing in output/${twitterHandle}_tweets.json`
70
+ );
71
+
72
+ saveOutput(tweets, `${twitterHandle}_tweets.json`);
73
+ log.info('Crawling finished.');
74
+ });
75
+ })
76
+ .catch(bind(log, 'error'));
77
+ }));
pool/shard000/JavaScript/0003821_platform_viewports.js ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Mongo } from 'meteor/mongo';
2
+ import { SimpleSchema } from 'meteor/aldeed:simple-schema';
3
+ import { Auth } from '../auth.js';
4
+ import { ChangeTracker } from '../change_tracker/change_tracker.js';
5
+ import { SchemaHelpers } from '../schema_helpers.js';
6
+
7
+ /**
8
+ * ============================================================================
9
+ * PlatformViewports
10
+ * ============================================================================
11
+ */
12
+ export const PlatformViewport = new SimpleSchema({
13
+ // Link to the project to which this test belongs
14
+ projectId : {
15
+ type : String,
16
+ denyUpdate: true
17
+ },
18
+ // Link to the project version to which this test belongs
19
+ projectVersionId: {
20
+ type : String,
21
+ denyUpdate: true
22
+ },
23
+ // Link to the platform configuration record
24
+ platformId : {
25
+ type : String,
26
+ denyUpdate: true
27
+ },
28
+ title : {
29
+ type: String,
30
+ },
31
+ width : {
32
+ type : Number,
33
+ defaultValue: 1024
34
+ },
35
+ height : {
36
+ type : Number,
37
+ defaultValue: 768
38
+ },
39
+ aspectRatio : {
40
+ type : Number,
41
+ decimal: true,
42
+ optional: true
43
+ },
44
+ // Mark the default viewport for a platform
45
+ default: {
46
+ type: Boolean,
47
+ defaultValue: false
48
+ },
49
+ // Standard tracking fields
50
+ dateCreated : {
51
+ type : Date,
52
+ autoValue : SchemaHelpers.autoValueDateCreated,
53
+ denyUpdate: true
54
+ },
55
+ createdBy : {
56
+ type : String,
57
+ autoValue : SchemaHelpers.autoValueCreatedBy,
58
+ denyUpdate: true
59
+ },
60
+ dateModified : {
61
+ type : Date,
62
+ autoValue: SchemaHelpers.autoValueDateModified
63
+ },
64
+ modifiedBy : {
65
+ type : String,
66
+ autoValue: SchemaHelpers.autoValueModifiedBy
67
+ }
68
+ });
69
+
70
+ export const PlatformViewports = new Mongo.Collection("platform_viewports");
71
+ PlatformViewports.attachSchema(PlatformViewport);
72
+ PlatformViewports.deny(Auth.ruleSets.deny.ifNotTester);
73
+ PlatformViewports.allow(Auth.ruleSets.allow.ifAuthenticated);
74
+ ChangeTracker.TrackChanges(PlatformViewports, "platform_viewports");
75
+
76
+ // Listed for changes and update the aspect ratio
77
+ if (Meteor.isServer) {
78
+ // Maintain the aspect ratio
79
+ PlatformViewports.before.insert(function (userId, doc) {
80
+ doc.aspectRatio = doc.width / doc.height;
81
+ });
82
+ PlatformViewports.before.update(function (userId, doc, changedFields, modifier) {
83
+ modifier.$set = modifier.$set || {};
84
+ if (_.contains(changedFields, 'width') || _.contains(changedFields, 'height')) {
85
+ let width = modifier.$set.width || doc.width,
86
+ height = modifier.$set.height || doc.height;
87
+ console.log("PlatformViewports.before.update setting aspectRatio:", width / height);
88
+ modifier.$set.aspectRatio = width / height;
89
+ }
90
+ });
91
+
92
+ // Maintain the default flag
93
+ PlatformViewports.after.update(function (userId, doc, changedFields, modifier) {
94
+ // If the default flag is set to true
95
+ if (_.contains(changedFields, 'default') && doc.default == true) {
96
+ // Set the other viewports for this platform to default = false
97
+ PlatformViewports.find({
98
+ _id: { $ne: doc._id },
99
+ platformId: doc.platformId,
100
+ default: true
101
+ }).forEach((viewport) => {
102
+ console.log("Setting default from true to false:", viewport);
103
+ PlatformViewports.update({_id: viewport._id}, {$set: {default: false}});
104
+ });
105
+ }
106
+ });
107
+ }
108
+
109
+ /**
110
+ * Helpers
111
+ */
112
+ PlatformViewports.helpers({});
pool/shard000/JavaScript/0003822_ace_widget.js ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ $(function(){
2
+ var EDITOR_DICT = {};
3
+
4
+ var set_santa_clara_text_editor = function(jq_object){
5
+ var ta_id=jq_object.data("ta_id");
6
+ var name=jq_object.data("ta_name");
7
+ var santa_clara_text_editor_id=jq_object.attr("id");
8
+
9
+ var editor=ace.edit(santa_clara_text_editor_id);
10
+ var jq_editor_box=jq_object.parent();
11
+
12
+ EDITOR_DICT[santa_clara_text_editor_id]=editor;
13
+
14
+ editor.setTheme("ace/theme/eclipse");
15
+ editor.getSession().setMode("ace/mode/plain_text");
16
+
17
+ editor.getSession().setUseWrapMode(true);
18
+ editor.setShowPrintMargin(false);
19
+
20
+ editor.on("change",function(event){
21
+ jq_editor_box.addClass("santa_clara_text_editor_box_modified");
22
+ });
23
+
24
+ editor.commands.addCommand({
25
+ name: 'Move to cursor to the start of the current line.',
26
+ bindKey: {win: 'Ctrl-B', mac: 'Command-B'},
27
+ exec: function(editor) {
28
+ editor.navigateLineStart();
29
+ editor.focus();
30
+ },
31
+ readOnly: false // false if this command should not apply in readOnly mode
32
+ });
33
+
34
+ editor.commands.addCommand({
35
+ name: 'Move to cursor to the end of the current line.',
36
+ bindKey: {win: 'Ctrl-E', mac: 'Command-E'},
37
+ exec: function(editor) {
38
+ editor.navigateLineEnd();
39
+ editor.focus();
40
+ },
41
+ readOnly: false // false if this command should not apply in readOnly mode
42
+ });
43
+
44
+ editor.commands.addCommand({
45
+ name: 'Move to cursor to the end of the current file.',
46
+ bindKey: {win: 'Ctrl-G', mac: 'Command-G'},
47
+ exec: function(editor) {
48
+ editor.gotoLine(editor.getSession().getLength());
49
+ editor.focus();
50
+ },
51
+ readOnly: false // false if this command should not apply in readOnly mode
52
+ });
53
+
54
+ editor.commands.addCommand({
55
+ name: 'Move to cursor to the start of the current file.',
56
+ bindKey: {win: 'Ctrl-<', mac: 'Command-<'},
57
+ exec: function(editor) {
58
+ editor.gotoLine(0);
59
+ editor.focus();
60
+ },
61
+ readOnly: false // false if this command should not apply in readOnly mode
62
+ });
63
+
64
+ editor.commands.addCommand({
65
+ name: 'Remove to line end.',
66
+ bindKey: {win: 'Ctrl-k', mac: 'Command-k'},
67
+ exec: function(editor) {
68
+ editor.removeToLineEnd();
69
+ editor.focus();
70
+ },
71
+ readOnly: false // false if this command should not apply in readOnly mode
72
+ });
73
+
74
+ editor.commands.addCommand({
75
+ name: 'Remove word right.',
76
+ bindKey: {win: 'Alt-d', mac: 'Alt-d'},
77
+ exec: function(editor) {
78
+ editor.removeWordRight();
79
+ editor.focus();
80
+ },
81
+ readOnly: false // false if this command should not apply in readOnly mode
82
+ });
83
+
84
+ var form=jq_object.closest("form");
85
+ var ta_name=jq_object.data("ta_name");
86
+ var ta_id=jq_object.data("ta_id");
87
+
88
+ form.submit( function(event){
89
+ var text=editor.getSession().toString();
90
+ var ta_html="<textarea name=\""+ta_name+"\"";
91
+ ta_html+=" id=\""+ta_id+"\">";
92
+ ta_html+=text;
93
+ ta_html+="</textarea>";
94
+ $(this).append(ta_html);
95
+ $(this).find('#'+ta_id).hide();
96
+ return true;
97
+ });
98
+ };
99
+
100
+ var action_santa_clara_text_editor_button_simple=function(jq_object,event){
101
+ var tag=jq_object.data("tag");
102
+ var parent=jq_object.parent();
103
+ var santa_clara_text_editor_id=parent.data("santa_clara_text_editor_id");
104
+ var editor=EDITOR_DICT[santa_clara_text_editor_id];
105
+
106
+ var range=editor.getSelectionRange();
107
+
108
+ editor.clearSelection();
109
+
110
+ editor.moveCursorTo(range.end.row,range.end.column,true);
111
+ editor.insert("[/"+tag+"]");
112
+
113
+ editor.moveCursorTo(range.start.row,range.start.column,true);
114
+ editor.insert("["+tag+"]");
115
+
116
+ editor.moveCursorTo(range.end.row,range.end.column+5+2*tag.length,true);
117
+ editor.focus();
118
+ };
119
+
120
+ var action_santa_clara_text_editor_button_single=function(jq_object,event){
121
+ var tag=jq_object.data("tag");
122
+ var parent=jq_object.parent();
123
+ var santa_clara_text_editor_id=parent.data("santa_clara_text_editor_id");
124
+ var editor=EDITOR_DICT[santa_clara_text_editor_id];
125
+ editor.insert("["+tag+"/]");
126
+ editor.focus();
127
+ };
128
+
129
+ var action_santa_clara_text_editor_button_function=function(jq_object,event){
130
+ var tag=jq_object.data("tag");
131
+ var parent=jq_object.parent();
132
+ var santa_clara_text_editor_id=parent.data("santa_clara_text_editor_id");
133
+ var editor=EDITOR_DICT[santa_clara_text_editor_id];
134
+ switch (tag) {
135
+ case "action_upper":
136
+ editor.toUpperCase();
137
+ break;
138
+ case "action_lower":
139
+ editor.toLowerCase();
140
+ break;
141
+ case "action_bracket":
142
+ var range=editor.getSelectionRange();
143
+ editor.clearSelection();
144
+ editor.moveCursorTo(range.end.row,range.end.column,true);
145
+ editor.insert("]]");
146
+ editor.moveCursorTo(range.start.row,range.start.column,true);
147
+ editor.insert("[[");
148
+ editor.moveCursorTo(range.end.row,range.end.column+4,true);
149
+ editor.focus();
150
+ }
151
+ };
152
+
153
+ /**/
154
+
155
+ $(".santa_clara_text_editor").each(function(){
156
+ set_santa_clara_text_editor($(this));
157
+ });
158
+
159
+ $(".santa_clara_text_editor_button_simple").click(function(event){
160
+ event.preventDefault();
161
+ action_santa_clara_text_editor_button_simple($(this),event);
162
+ });
163
+
164
+ $(".santa_clara_text_editor_button_single").click(function(event){
165
+ event.preventDefault();
166
+ action_santa_clara_text_editor_button_single($(this),event);
167
+ });
168
+
169
+ $(".santa_clara_text_editor_button_function").click(function(event){
170
+ event.preventDefault();
171
+ action_santa_clara_text_editor_button_function($(this),event);
172
+ });
173
+
174
+
175
+
176
+ /**/
177
+
178
+ var replace_prefix_in_data = function (object,data_key,new_prefix) {
179
+ var old_val=object.data(data_key);
180
+ var new_val=old_val.replace('__prefix__',new_prefix);
181
+ object.data(data_key,new_val);
182
+ };
183
+
184
+ var mutationHandler = function (mutationRecords) {
185
+ mutationRecords.forEach ( function (mutation) {
186
+ if (mutation.type!="childList") return;
187
+ if (mutation.addedNodes.length==0) return;
188
+
189
+ $(mutation.addedNodes).each(function(){
190
+
191
+ $(this).find(".santa_clara_text_editor_box").each(function(){
192
+ var box_id=$(this).attr("id");
193
+ var ta_id_temp=$(this).data("ta_id");
194
+ var ta_name_temp=$(this).data("ta_name");
195
+ var ta_id_real=box_id.replace(/^santa_clara_text_editor_box_/,'');
196
+ var rexp=RegExp('^'+ta_id_temp.replace('__prefix__','(.*)')+'$');
197
+ var prefix_real=ta_id_real.replace(rexp,'$1');
198
+ replace_prefix_in_data($(this),"ta_id",prefix_real);
199
+ replace_prefix_in_data($(this),"ta_name",prefix_real);
200
+ $(this).find(".santa_clara_text_editor_button_bar").each(function(){
201
+ replace_prefix_in_data($(this),"santa_clara_text_editor_box_id",prefix_real);
202
+ replace_prefix_in_data($(this),"santa_clara_text_editor_id",prefix_real);
203
+ });
204
+ $(this).find(".santa_clara_text_editor").each(function(){
205
+ replace_prefix_in_data($(this),"ta_id",prefix_real);
206
+ replace_prefix_in_data($(this),"ta_name",prefix_real);
207
+ });
208
+ });
209
+
210
+ $(this).find(".santa_clara_text_editor").each(function(){
211
+ set_santa_clara_text_editor($(this));
212
+ });
213
+
214
+ $(this).find(".santa_clara_text_editor_button_simple").click(function(event){
215
+ event.preventDefault();
216
+ action_santa_clara_text_editor_button_simple($(this),event);
217
+ });
218
+
219
+ $(this).find(".santa_clara_text_editor_button_single").click(function(event){
220
+ event.preventDefault();
221
+ action_santa_clara_text_editor_button_single($(this),event);
222
+ });
223
+
224
+ $(this).find(".santa_clara_text_editor_button_function").click(function(event){
225
+ event.preventDefault();
226
+ action_santa_clara_text_editor_button_function($(this),event);
227
+ });
228
+
229
+ });
230
+
231
+ });
232
+ };
233
+
234
+ var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
235
+ var myObserver = new MutationObserver (mutationHandler);
236
+ var obsConfig = { childList: true, characterData: true, attributes: true, subtree: true };
237
+
238
+ $("form").each( function () {
239
+ myObserver.observe (this, obsConfig);
240
+ });
241
+
242
+
243
+
244
+ });
245
+
pool/shard000/JavaScript/0003824_bootstrap-typeahead.js ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ define(function(require) {
2
+ 'use strict';
3
+
4
+ var $ = require('jquery');
5
+ require('bootstrap');
6
+
7
+ /**
8
+ * This customization allows to define own click, render, show functions for Typeahead
9
+ */
10
+ var Typeahead;
11
+ var origTypeahead = $.fn.typeahead.Constructor;
12
+ var origFnTypeahead = $.fn.typeahead;
13
+
14
+ Typeahead = function(element, options) {
15
+ var opts = $.extend({}, $.fn.typeahead.defaults, options);
16
+ this.click = opts.click || this.click;
17
+ this.render = opts.render || this.render;
18
+ this.show = opts.show || this.show;
19
+ this.hide = opts.hide || this.hide;
20
+ this.$holder = $(opts.holder || '');
21
+ origTypeahead.apply(this, arguments);
22
+ };
23
+
24
+ Typeahead.prototype = origTypeahead.prototype;
25
+ Typeahead.prototype.constructor = Typeahead;
26
+
27
+ $.fn.typeahead = function(option) {
28
+ return this.each(function() {
29
+ var $this = $(this);
30
+ var data = $this.data('typeahead');
31
+ var options = typeof option === 'object' && option;
32
+ if (!data) {
33
+ $this.data('typeahead', (data = new Typeahead(this, options)));
34
+ }
35
+ if (typeof option === 'string') {
36
+ data[option]();
37
+ }
38
+ });
39
+ };
40
+
41
+ $.fn.typeahead.defaults = origFnTypeahead.defaults;
42
+ $.fn.typeahead.Constructor = Typeahead;
43
+ $.fn.typeahead.noConflict = origFnTypeahead.noConflict;
44
+ });
pool/shard000/JavaScript/0003825_orient.test.js ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import _ol_geom_flat_orient_ from '../../../../../src/ol/geom/flat/orient.js';
2
+
3
+
4
+ describe('ol.geom.flat.orient', function() {
5
+
6
+ describe('ol.geom.flat.orient.linearRingIsClockwise()', function() {
7
+
8
+ it('identifies clockwise rings', function() {
9
+ const flatCoordinates = [0, 1, 1, 4, 4, 3, 3, 0];
10
+ const isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
11
+ flatCoordinates, 0, flatCoordinates.length, 2);
12
+ expect(isClockwise).to.be(true);
13
+ });
14
+
15
+ it('identifies anti-clockwise rings', function() {
16
+ const flatCoordinates = [2, 2, 3, 2, 3, 3, 2, 3];
17
+ const isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
18
+ flatCoordinates, 0, flatCoordinates.length, 2);
19
+ expect(isClockwise).to.be(false);
20
+ });
21
+
22
+ });
23
+
24
+ describe('ol.geom.flat.orient.linearRingsAreOriented()', function() {
25
+ const oriented = _ol_geom_flat_orient_.linearRingsAreOriented;
26
+
27
+ const rightCoords = [
28
+ -180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
29
+ -100, -45, -100, 45, 100, 45, 100, -45, -100, -45
30
+ ];
31
+
32
+ const leftCoords = [
33
+ -180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
34
+ -100, -45, 100, -45, 100, 45, -100, 45, -100, -45
35
+ ];
36
+
37
+ const ends = [10, 20];
38
+
39
+ it('checks for left-hand orientation by default', function() {
40
+ expect(oriented(rightCoords, 0, ends, 2)).to.be(false);
41
+ expect(oriented(leftCoords, 0, ends, 2)).to.be(true);
42
+ });
43
+
44
+ it('can check for right-hand orientation', function() {
45
+ expect(oriented(rightCoords, 0, ends, 2, true)).to.be(true);
46
+ expect(oriented(leftCoords, 0, ends, 2, true)).to.be(false);
47
+ });
48
+
49
+ });
50
+
51
+ describe('ol.geom.flat.orient.linearRingssAreOriented()', function() {
52
+ const oriented = _ol_geom_flat_orient_.linearRingssAreOriented;
53
+
54
+ const rightCoords = [
55
+ -180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
56
+ -100, -45, -100, 45, 100, 45, 100, -45, -100, -45,
57
+ -180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
58
+ -100, -45, -100, 45, 100, 45, 100, -45, -100, -45
59
+ ];
60
+
61
+ const leftCoords = [
62
+ -180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
63
+ -100, -45, 100, -45, 100, 45, -100, 45, -100, -45,
64
+ -180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
65
+ -100, -45, 100, -45, 100, 45, -100, 45, -100, -45
66
+ ];
67
+
68
+ const ends = [[10, 20], [30, 40]];
69
+
70
+ it('checks for left-hand orientation by default', function() {
71
+ expect(oriented(rightCoords, 0, ends, 2)).to.be(false);
72
+ expect(oriented(leftCoords, 0, ends, 2)).to.be(true);
73
+ });
74
+
75
+ it('can check for right-hand orientation', function() {
76
+ expect(oriented(rightCoords, 0, ends, 2, true)).to.be(true);
77
+ expect(oriented(leftCoords, 0, ends, 2, true)).to.be(false);
78
+ });
79
+
80
+ });
81
+
82
+ describe('ol.geom.flat.orient.orientLinearRings()', function() {
83
+ const orient = _ol_geom_flat_orient_.orientLinearRings;
84
+
85
+ const rightCoords = [
86
+ -180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
87
+ -100, -45, -100, 45, 100, 45, 100, -45, -100, -45
88
+ ];
89
+
90
+ const leftCoords = [
91
+ -180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
92
+ -100, -45, 100, -45, 100, 45, -100, 45, -100, -45
93
+ ];
94
+
95
+ const ends = [10, 20];
96
+
97
+ it('orients using the left-hand rule by default', function() {
98
+ const rightClone = rightCoords.slice();
99
+ orient(rightClone, 0, ends, 2);
100
+ expect(rightClone).to.eql(leftCoords);
101
+
102
+ const leftClone = leftCoords.slice();
103
+ orient(leftClone, 0, ends, 2);
104
+ expect(leftClone).to.eql(leftCoords);
105
+ });
106
+
107
+ it('can orient using the right-hand rule', function() {
108
+ const rightClone = rightCoords.slice();
109
+ orient(rightClone, 0, ends, 2, true);
110
+ expect(rightClone).to.eql(rightCoords);
111
+
112
+ const leftClone = leftCoords.slice();
113
+ orient(leftClone, 0, ends, 2, true);
114
+ expect(leftClone).to.eql(rightCoords);
115
+ });
116
+
117
+ });
118
+
119
+ describe('ol.geom.flat.orient.orientLinearRingss()', function() {
120
+ const orient = _ol_geom_flat_orient_.orientLinearRingss;
121
+
122
+ const rightCoords = [
123
+ -180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
124
+ -100, -45, -100, 45, 100, 45, 100, -45, -100, -45,
125
+ -180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
126
+ -100, -45, -100, 45, 100, 45, 100, -45, -100, -45
127
+ ];
128
+
129
+ const leftCoords = [
130
+ -180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
131
+ -100, -45, 100, -45, 100, 45, -100, 45, -100, -45,
132
+ -180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
133
+ -100, -45, 100, -45, 100, 45, -100, 45, -100, -45
134
+ ];
135
+
136
+ const ends = [[10, 20], [30, 40]];
137
+
138
+ it('orients using the left-hand rule by default', function() {
139
+ const rightClone = rightCoords.slice();
140
+ orient(rightClone, 0, ends, 2);
141
+ expect(rightClone).to.eql(leftCoords);
142
+
143
+ const leftClone = leftCoords.slice();
144
+ orient(leftClone, 0, ends, 2);
145
+ expect(leftClone).to.eql(leftCoords);
146
+ });
147
+
148
+ it('can orient using the right-hand rule', function() {
149
+ const rightClone = rightCoords.slice();
150
+ orient(rightClone, 0, ends, 2, true);
151
+ expect(rightClone).to.eql(rightCoords);
152
+
153
+ const leftClone = leftCoords.slice();
154
+ orient(leftClone, 0, ends, 2, true);
155
+ expect(leftClone).to.eql(rightCoords);
156
+ });
157
+
158
+ });
159
+
160
+
161
+ });
pool/shard000/JavaScript/0003826_watcher.js ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { join, relative } from 'path'
2
+ import chalk from 'chalk'
3
+ import { FSWatcher } from 'chokidar'
4
+ import _debug from 'debug'
5
+ import Builder from './builder'
6
+
7
+ const debug = _debug('api:watch')
8
+ debug.color = 2 // Green
9
+
10
+ const watchers = []
11
+
12
+ export default class Watcher {
13
+ constructor (builder) {
14
+ /* istanbul ignore if */
15
+ if (!(builder instanceof Builder)) {
16
+ throw new TypeError('Usage: new Watcher(builder: Builder)')
17
+ }
18
+
19
+ debug.enabled = true
20
+
21
+ this.builder = builder
22
+ this.router = builder.router
23
+
24
+ this.isWatched = false
25
+
26
+ // Chokidar instance
27
+ this.fsWatcher = new FSWatcher({ ignoreInitial: true })
28
+
29
+ // Dependents from transformed files
30
+ this.dependents = {}
31
+
32
+ // Extra files to watch from imports
33
+ this.extraWatches = {}
34
+ }
35
+
36
+ static closeAll () {
37
+ for (let watcher of watchers) {
38
+ watcher.close()
39
+ }
40
+ }
41
+
42
+ close () {
43
+ this.fsWatcher.close()
44
+ }
45
+
46
+ async watch () {
47
+ /* istanbul ignore if */
48
+ if (this.isWatched) {
49
+ return
50
+ }
51
+
52
+ watchers.push(this)
53
+ this.isWatched = true
54
+
55
+ const listeners = [{
56
+ event: 'add',
57
+ verb: 'created',
58
+ callback: this._add
59
+ }, {
60
+ event: 'unlink',
61
+ verb: 'removed',
62
+ callback: this._unlink
63
+ }, {
64
+ event: 'change',
65
+ verb: 'modified',
66
+ callback: this._change
67
+ }]
68
+
69
+ listeners.forEach(({ event, verb, callback }) => {
70
+ this.fsWatcher.on(event, filename => {
71
+ debug(chalk`{magenta ${relative(this.router.options.src, filename)}} has been {red ${verb}}.`)
72
+ callback.call(this, filename)
73
+ })
74
+ })
75
+
76
+ const exts = this.builder.extensions.join('|')
77
+ const watchDir = join(this.router.options.entry, `**/*.@(${exts})`)
78
+ this.fsWatcher.add(watchDir)
79
+
80
+ // Update route handle if file is under `entry`, otherwise watching changes of it
81
+ this.builder.plugin('afterFetch', (filename, exports) => {
82
+ if (filename.startsWith(this.router.options.entry)) {
83
+ this.router.set(relative(this.router.options.entry, filename), exports)
84
+ } else {
85
+ this._watchFile(filename)
86
+ }
87
+ })
88
+
89
+ // Save dependent if request is not a module
90
+ this.builder.plugin('afterTransform', (filename, result) => {
91
+ result.imports.forEach(value => {
92
+ /* istanbul ignore else */
93
+ if (value[0] === '~' || value[0] === '.') {
94
+ const from = this.router.resolve(value, filename)
95
+ this.dependents[from] = this.dependents[from] || []
96
+ this.dependents[from].push(filename)
97
+ }
98
+ })
99
+ })
100
+
101
+ // TODO Better dev message
102
+ debug('Start watching [ \'%s\' ]', relative(this.router.options.src, watchDir))
103
+ }
104
+
105
+ _watchFile (filename) {
106
+ const exists = this.extraWatches[filename]
107
+
108
+ if (!exists) {
109
+ this.fsWatcher.add(filename)
110
+ this.extraWatches[filename] = true
111
+ }
112
+
113
+ return this
114
+ }
115
+
116
+ _unwatchFile (filename) {
117
+ const exists = this.extraWatches[filename]
118
+
119
+ /* istanbul ignore else */
120
+ if (exists) {
121
+ this.fsWatcher.unwatch(filename)
122
+ delete this.extraWatches[filename]
123
+ }
124
+
125
+ return this
126
+ }
127
+
128
+ _add (filename) {
129
+ this.builder.fetch(filename)
130
+ }
131
+
132
+ _unlink (filename) {
133
+ const refetchList = this._purge(filename)
134
+
135
+ if (filename.startsWith(this.router.options.entry)) {
136
+ this.router.unset(relative(this.router.options.entry, filename))
137
+ } else {
138
+ this._unwatchFile(filename)
139
+ }
140
+
141
+ if (refetchList[0] === filename) {
142
+ refetchList.shift()
143
+ }
144
+
145
+ refetchList.forEach(filename => this.builder.fetch(filename))
146
+ }
147
+
148
+ _change (filename) {
149
+ this._unlink(filename)
150
+ this.builder.fetch(filename)
151
+ }
152
+
153
+ _purge (filename, refetchList = []) {
154
+ const dependents = this.dependents[filename]
155
+
156
+ if (dependents !== undefined) {
157
+ dependents.forEach(dependent => {
158
+ this._purge(dependent, refetchList)
159
+ })
160
+ delete this.dependents[filename]
161
+ }
162
+
163
+ delete this.builder.handles[filename]
164
+
165
+ if (filename.startsWith(this.router.options.entry)) {
166
+ refetchList.push(filename)
167
+ }
168
+
169
+ return refetchList
170
+ }
171
+ }
pool/shard000/JavaScript/0003827_Config.js ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (c) 2015, YourNameHere. All rights reserved.
3
+ *
4
+ * This source code is licensed under the MIT-style license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ "use strict";
8
+ /* global module,require,__filename */
9
+
10
+ var loadJson = require('./JsonLoader'),
11
+ logError = require('./LogError')(__filename);
12
+
13
+ var validateKeyName = name => {
14
+ if (['load', 'assign', 'merge'].indexOf(name) > -1) {
15
+ throw logError('Configuration key "' + name + '" is reserved and can\'t be used as root config key.', new Error('Configuration Reserved Keyword Error'));
16
+ } else {
17
+ return true;
18
+ }
19
+ };
20
+
21
+ var Config = {
22
+ load: (jsonFileName, defaultConfig) => {
23
+ jsonFileName = jsonFileName || 'config.json';
24
+ defaultConfig = defaultConfig || {};
25
+ return loadJson(jsonFileName).then(json => {
26
+ Config.merge(defaultConfig);
27
+ for (var name in json) {
28
+ if (json.hasOwnProperty(name)) {
29
+ if (validateKeyName(name)) {
30
+ Config[name] = json[name];
31
+ }
32
+ }
33
+ }
34
+
35
+ return Config;
36
+ });
37
+ },
38
+ assign: (dest, conf) => {
39
+ conf = conf || {};
40
+ dest = dest || {};
41
+ for (var name in conf) {
42
+ if (conf.hasOwnProperty(name)) {
43
+ var val = conf[name];
44
+ if (val && typeof val === 'object') {
45
+ dest[name] = Config.assign(dest[name], val);
46
+ } else {
47
+ dest[name] = conf[name];
48
+ }
49
+ }
50
+ }
51
+ return dest;
52
+ },
53
+ merge: conf => {
54
+ conf = conf || {};
55
+ for (var name in conf) {
56
+ if (conf.hasOwnProperty(name)) {
57
+ validateKeyName(name);
58
+ }
59
+ }
60
+ return Config.assign(Config, conf);
61
+ }
62
+ };
63
+
64
+ module.exports = Config;
pool/shard000/JavaScript/0003830_context-menu.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const {Menu} = require('electron')
2
+
3
+ module.exports =
4
+ class ContextMenu {
5
+ constructor (template, atomWindow) {
6
+ this.atomWindow = atomWindow
7
+ this.createClickHandlers(template)
8
+ const menu = Menu.buildFromTemplate(template)
9
+ menu.popup(this.atomWindow.browserWindow, {async: true})
10
+ }
11
+
12
+ // It's necessary to build the event handlers in this process, otherwise
13
+ // closures are dragged across processes and failed to be garbage collected
14
+ // appropriately.
15
+ createClickHandlers (template) {
16
+ template.forEach(item => {
17
+ if (item.command) {
18
+ if (!item.commandDetail) item.commandDetail = {}
19
+ item.commandDetail.contextCommand = true
20
+ item.commandDetail.atomWindow = this.atomWindow
21
+ item.click = () => {
22
+ global.atomApplication.sendCommandToWindow(
23
+ item.command,
24
+ this.atomWindow,
25
+ item.commandDetail
26
+ )
27
+ }
28
+ } else if (item.submenu) {
29
+ this.createClickHandlers(item.submenu)
30
+ }
31
+ })
32
+ }
33
+ }
pool/shard000/JavaScript/0003831_inject.js ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* globals Inject */
2
+
3
+ // Inject.rawBody('page-loading', `
4
+ // <div id="initial-page-loading" class="page-loading">
5
+ // <div class="spinner">
6
+ // <div class="rect1"></div>
7
+ // <div class="rect2"></div>
8
+ // <div class="rect3"></div>
9
+ // <div class="rect4"></div>
10
+ // <div class="rect5"></div>
11
+ // </div>
12
+ // </div>`
13
+ // );
14
+ // Inject.rawModHtml('moveScriptsToBottom', function(html) {
15
+ // console.log("moveScriptsToBottom callled");
16
+ // // get all scripts
17
+ // var scripts = html.match(/<script type="text\/javascript" src.*"><\/script>\n/g);
18
+ // // remove all scripts
19
+ // html = html.replace(/<script type="text\/javascript" src.*"><\/script>\n/g, '');
20
+ // // add scripts to the bottom
21
+ // return html.replace(/<\/body>/, scripts.join('') + '\n</body>');
22
+ // });
23
+
24
+ CaoLiao.settings.get('Site_Url', function() {
25
+ Meteor.defer(function() {
26
+ let baseUrl;
27
+ if (__meteor_runtime_config__.ROOT_URL_PATH_PREFIX && __meteor_runtime_config__.ROOT_URL_PATH_PREFIX.trim() !== '') {
28
+ baseUrl = __meteor_runtime_config__.ROOT_URL_PATH_PREFIX;
29
+ } else {
30
+ baseUrl = '/';
31
+ }
32
+ if (/\/$/.test(baseUrl) === false) {
33
+ baseUrl += '/';
34
+ }
35
+ Inject.rawHead('base', `<base href="${baseUrl}">`);
36
+ });
37
+ });
38
+
39
+ CaoLiao.settings.get('GoogleSiteVerification_id', function(key, value) {
40
+ if (value) {
41
+ Inject.rawHead('google-site-verification', `<meta name="google-site-verification" content="${value}" />`);
42
+ } else {
43
+ Inject.rawHead('google-site-verification', '');
44
+ }
45
+ });
pool/shard000/JavaScript/0003832_object-validator.js ADDED
@@ -0,0 +1,276 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ const logger = require('utils/logger').utils,
4
+ errors = require('errors'),
5
+ validator = require('validator'),
6
+ _ = require('lodash');
7
+
8
+ /**
9
+ * Encapsulates validation chain for one object.
10
+ *
11
+ * @class _ValidatorChain
12
+ * @param testObj
13
+ * @constructor
14
+ */
15
+ class ValidatorChain {
16
+
17
+ /**
18
+ * Constructs new validator chain
19
+ * @param testObj object to validate
20
+ */
21
+ constructor(testObj, options) {
22
+ this._options = options || {};
23
+ this._testObj = testObj;
24
+ this._fieldErrors = [];
25
+ this._fieldProperty = undefined;
26
+ this._fieldOptional = false;
27
+ this._fieldValid = false;
28
+ this._prefixStack = [];
29
+ }
30
+
31
+ /**
32
+ * Sets field to chain validators and sanitizers to
33
+ * Example:
34
+ *
35
+ * objectValidator = require('object-validator');
36
+ *
37
+ * objectValidator.createValidator(req.body)
38
+ * .field('vehicleLocation')
39
+ * .isNotEmpty('Vehicle location is required.')
40
+ * .validate();
41
+ *
42
+ * @param {string} property name of field to validate
43
+ * @param optional must be true for optional fields
44
+ * @return {object}
45
+ */
46
+
47
+ field(property) {
48
+ if (!property) {
49
+ logger.error('ValidatorChain.field -> is empty');
50
+ throw new errors.InternalServerError('object-validator->ValidatorChain.field is empty');
51
+ }
52
+ this._fieldProperty = property;
53
+ this._fieldValid = true;
54
+ this._fieldOptional = false;
55
+
56
+ return this;
57
+ }
58
+
59
+
60
+ /**
61
+ * Sets optional property of field to true
62
+ * @returns {ValidatorChain}
63
+ */
64
+ optional() {
65
+ this._fieldOptional = true;
66
+
67
+ return this;
68
+ }
69
+
70
+ /**
71
+ * Sets field that is array of complex objects to chain validators and sanitizers to inner properties
72
+ * Example:
73
+ *
74
+ * .array('damages',
75
+ * validator => validator
76
+ * .field('damageRegion')
77
+ * .isNotEmpty('Damage region is required.')
78
+ * .field('damageType')
79
+ * .isNotEmpty('Damage type is required.')
80
+ * .field('coverageType')
81
+ * .isNotEmpty('Coverage type is required.'))
82
+ * Valid scheme: {'damages': [{
83
+ * 'damageRegion': 'some region',
84
+ * 'damageType': 'some type',
85
+ * 'coverageType': 'some type'}]}
86
+ * @param {string} property name of array field to validate
87
+ * @param arrayValidator function that validate objects in array
88
+ * @return {object}
89
+ */
90
+ array(property, arrayValidator) {
91
+
92
+ if (!property) {
93
+ logger.error('ValidatorChain.array -> is empty');
94
+ throw new errors.InternalServerError('object-validator->ValidatorChain.array is empty');
95
+ }
96
+ _.get(this._testObj, _makePath(this._prefixStack, property)).forEach((item, index) => {
97
+ this._prefixStack.push({name: property, index: index});
98
+ this._fieldProperty = item;
99
+ this._fieldValid = true;
100
+ arrayValidator(this);
101
+ this._prefixStack.pop();
102
+ }, this);
103
+
104
+ return this;
105
+ }
106
+
107
+ /**
108
+ * Throws ValidationError if chain contains field errors
109
+ *
110
+ * @method validate
111
+ * @param {string} message error message for ValidationError (don't path for default)
112
+ * @return {object}
113
+ */
114
+ validate(message) {
115
+ if (!_.isEmpty(this._fieldErrors)) {
116
+ logger.debug('ValidatorChain.validate -> invalid', this._fieldErrors);
117
+ throw new errors.ValidationError(message ? message : 'Invalid data found', this._fieldErrors);
118
+ }
119
+ }
120
+ }
121
+
122
+ //additional custom validators
123
+ validator.extend('isExist', str => str !== undefined);
124
+ validator.extend('isNotEmpty', str => str.length > 0);
125
+ validator.extend('isDate', val => val.match(/^[0-9]{4}-(1[0-2]|0[0-9])-([0-2][0-9]|3[0-1])T[0-1][0-9]|2[0-3]:[0-5][0-9]:[0-5][0-9].[0-9]{3}Z$/));
126
+ validator.extend('isInteger', val => val.match(/^[0-9]+$/));
127
+ validator.extend('isShorterThan', (str, length) => str.length < length);
128
+ validator.extend('isBase64Image',
129
+ val => val.match(/data:image\/png;base64,/i) || val.match(/data:image\/jpg;base64,/i) ||
130
+ val.match(/data:image\/jpeg;base64,/i));
131
+ validator.extend('isEmail', val => val.match(/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/));
132
+ // validators and sanitizers not prefixed with is/to
133
+ var additionalValidators = ['includes', 'equals', 'matches'];
134
+ var additionalSanitizers = ['trim', 'ltrim', 'rtrim', 'escape', 'stripLow', 'whitelist', 'blacklist', 'normalizeEmail'];
135
+
136
+ // _.set validators and sanitizers as prototype methods on corresponding chains
137
+ _.forEach(validator, (method, methodName) => {
138
+ if (methodName.match(/^is/) || _.includes(additionalValidators, methodName)) {
139
+ ValidatorChain.prototype[methodName] = _makeValidator(methodName, validator);
140
+ }
141
+
142
+ if (methodName.match(/^to/) || _.includes(additionalSanitizers, methodName)) {
143
+ ValidatorChain.prototype[methodName] = _makeSanitizer(methodName, validator);
144
+ }
145
+ });
146
+
147
+ /**
148
+ * Creates validator/sanitizer for passed object
149
+ * @param testObj
150
+ * @returns {ValidatorChain}
151
+ */
152
+ function createValidator(testObj, options) {
153
+ return new ValidatorChain(testObj, options);
154
+ }
155
+
156
+ /**
157
+ * Creates field errors in validator format for one custom errors
158
+ * @param field field name
159
+ * @param message errors message
160
+ * @returns {*[]}
161
+ */
162
+ function createFieldErrors(field, message) {
163
+ var subs;
164
+
165
+ if (arguments.length > 2) {
166
+ subs = Array.prototype.slice.call(arguments, 2);
167
+ }
168
+
169
+ return [{
170
+ name: field,
171
+ message: message,
172
+ substitutions: subs ? subs : []
173
+ }];
174
+ }
175
+
176
+ /**
177
+ * Validates and handles errors, return instance of itself to allow for chaining
178
+ *
179
+ * @method _makeValidator
180
+ * @param {string} methodName
181
+ * @return {function}
182
+ */
183
+ function _makeValidator(methodName) {
184
+
185
+ return function (message) {
186
+
187
+ if (!this._fieldValid) {
188
+ logger.debug('ValidatorChain.field: previous validation failed -> skip validation');
189
+ return this;
190
+ }
191
+
192
+ var validatorArgs = [];
193
+ validatorArgs.push(_.get(this._testObj, _makePath(this._prefixStack, this._fieldProperty)) + '');
194
+ validatorArgs = validatorArgs.concat(_.slice(arguments, 1));
195
+
196
+ var isValid;
197
+ if (this._options.allowUndefined || this._fieldOptional) {
198
+ if (_.get(this._testObj, _makePath(this._prefixStack, this._fieldProperty)) === undefined) {
199
+ isValid = true;
200
+ }
201
+ else if ((_.get(this._testObj, _makePath(this._prefixStack, this._fieldProperty)) === '') && this._fieldOptional) {
202
+ isValid = true;
203
+ }
204
+ else {
205
+ isValid = validator[methodName].apply(validator, validatorArgs);
206
+ }
207
+ }
208
+ else {
209
+ isValid = validator[methodName].apply(validator, validatorArgs);
210
+ }
211
+
212
+
213
+ if (!isValid) {
214
+ this._fieldErrors.push({name: _makePath(this._prefixStack, this._fieldProperty), message: message});
215
+ this._fieldValid = false;
216
+ }
217
+
218
+ return this;
219
+ };
220
+ }
221
+
222
+ /**
223
+ * Modifies field value as required by the rule of the sanitizer, return instance of itself to allow for chaining
224
+ *
225
+ * @method _makeSanitizer
226
+ * @param {string} methodName
227
+ * @return {function}
228
+ */
229
+
230
+ function _makeSanitizer(methodName) {
231
+
232
+ return function () {
233
+
234
+ if (!this._fieldValid) {
235
+ return this;
236
+ }
237
+ if (this._fieldOptional && _.get(this._testObj, _makePath(this._prefixStack, this._fieldProperty)) === undefined) {
238
+ return this;
239
+ }
240
+
241
+ var validatorArgs = [];
242
+ validatorArgs.push(_.get(this._testObj, _makePath(this._prefixStack, this._fieldProperty)));
243
+ validatorArgs = validatorArgs.concat(arguments);
244
+
245
+ try {
246
+ _.set(this._testObj, _makePath(this._prefixStack, this._fieldProperty),
247
+ validator[methodName].apply(validator, validatorArgs));
248
+ }
249
+ catch (error) {
250
+ logger.debug('ValidatorChain.%s: sanitizer -> errors', methodName, error);
251
+ throw new errors.InternalServerError(error);
252
+ }
253
+
254
+ return this;
255
+ };
256
+ }
257
+
258
+ /**
259
+ * Iterates throw prefixStack, concat elements adding '.' as delimiter, and add field name to result
260
+ *
261
+ * @method _makePath
262
+ * @param {Array} prefixStack
263
+ * @param {string} fieldName
264
+ * @return {string} absolute path to given field
265
+ */
266
+
267
+ function _makePath(prefixStack, fieldName) {
268
+ let prefix = _.reduce(prefixStack, (result, item) => result += item.name + '[' + item.index + '].', '');
269
+ return prefix + fieldName;
270
+ }
271
+
272
+ module.exports = {
273
+ createValidator: createValidator,
274
+ createFieldErrors: createFieldErrors
275
+ };
276
+
pool/shard000/JavaScript/0003834_trash.js ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //*客户JS函数
2
+ //*作者:唐有炜
3
+ //*时间:2014年09月24日
4
+
5
+
6
+ var trash_grid;
7
+ $(function () {
8
+ InitGrid();
9
+ $("#muti-del").on("click", (function () {
10
+ var ids = get_selected_ids("trash-grid-data");
11
+ //console.log(ids);
12
+ if (ids == '') {
13
+ showMsg("请先选择应用在卸载!");
14
+ return;
15
+ }
16
+ //alert(ids);
17
+ del(ids);
18
+ }));
19
+ });
20
+
21
+ function InitGrid() {
22
+
23
+ /// <summary>
24
+ /// Initializes the trash_grid.
25
+ /// </summary>
26
+ trash_grid = $("#trash-grid-data").bootgrid({
27
+ ajax: true,
28
+ post: function () {
29
+ /* To accumulate custom parameter with the request object */
30
+ return {
31
+ compNum: $("#CompNum").val()
32
+ };
33
+ },
34
+ url: "/api/crm/customer/getAllCustomers/",
35
+ selection: true,
36
+ multiSelect: true,
37
+ rowSelect: true,
38
+ keepSelection: true,
39
+ rowCount: [10, 30, 50],
40
+ templates: {
41
+ header: "<div id=\"{{ctx.id}}\" class=\"{{css.header}}\"><div class=\"row\"><div class=\"col-sm-12 actionBar\"><div class=\"btn-group\" style=\"float:left;\"><button class=\"btn btn-default tip\" title=\"批量还原客户\" onclick=\" add_contact(" + $("#cus_id").val() + ") \"><span class=\"glyphicon glyphicon-share-alt\"></span>还原</button><button id=\"muti-del\" class=\"btn btn-default tip\" title=\"批量彻底删除客户\" ><span class=\"glyphicon glyphicon glyphicon glyphicon-trash\"></span>彻底删除</button></div>" +
42
+ "<div class=\"search form-group\"><div class=\"input-group\"><span class=\"icon glyphicon input-group-addon glyphicon-search\"></span> <input type=\"text\" class=\"search-field form-control\" placeholder=\"输入关键字\"></div></div>"
43
+ + "<p class=\"{{css.actions}}\"></p></div></div></div>"
44
+ },
45
+ labels: {
46
+ all: "all", //checkbox全选的值
47
+ search: "请输入客户名称",
48
+ loading: "加载中...",
49
+ noResults: "对不起,暂无符合条件的记录!",
50
+ refresh: "刷新",
51
+ infos: "从{{ctx.start}} 到 {{ctx.end}},共{{ctx.total}} 条记录"
52
+ },
53
+ formatters: {
54
+ "con_is_main": function (column, row) {
55
+ if (!row.con_is_main) {
56
+ return "否";
57
+ } else {
58
+ return "是";
59
+ }
60
+ },
61
+ "commands": function (column, row) {
62
+ return "<button type=\"button\" class=\"btn btn-link btn-sm btn-cmd tip\" onclick=\"edit_contact(0," + row.id + ");\" title=\"还原客户【" + row.con_name + "】\"><span class=\"glyphicon glyphicon-share-alt\"></span></button>" +
63
+ "<button type=\"button\" class=\"btn btn-link btn-sm btn-cmd tip\" onclick=\"del(" + row.id + ")\" title=\"彻底删除客户【" + row.con_name + "】\"><span class=\"glyphicon glyphicon-remove\"></span></button>";
64
+ }
65
+ }
66
+ }).on("loaded.rs.jquery.bootgrid", function (e) {
67
+ //按钮提示
68
+ $('.tip').tooltip();
69
+ //按钮气泡
70
+ $('.pop').popover({ html: true, trigger: "hover" });
71
+ //showMsg("字段加载成功!", "Success");
72
+ });
73
+ }
74
+
75
+
76
+ /**
77
+ *还原客户
78
+ *如果客户customer_id为空直接还原客户,不为空,则还原当前客户对应的客户
79
+ *@author terwer
80
+ *@version 1.0 2014/09/24
81
+ *@param customer_id 客户id(可为空)
82
+ *@return 无返回值
83
+ */
84
+ function add_contact(customer_id) {
85
+ //关闭客户详情窗口
86
+ //parent.dialog.list["show_view"].close();
87
+ //设置当前窗口id,便于后续管理
88
+ var win_id = "show_add_contact";
89
+ //设置不同请求的url
90
+ var show_url = "/Apps/CRM/Contact/Add";
91
+ if (customer_id != undefined) {
92
+ show_url += "?cus_id=" + customer_id;
93
+ }
94
+ showTopWindow(win_id, show_url, "还原客户", 800, 360, function () {
95
+ //调用iframe方法验证表单
96
+ var flag = window.top.document.getElementById("frm_" + win_id).contentWindow.form_valid();
97
+ if (!flag) {
98
+ return false;
99
+ }
100
+ //获取iframe表单序列化之后的数据
101
+ var form_contact = $(window.top.frames["frm_" + win_id].document).find("#form_contact");
102
+ var data = $(form_contact).serialize();
103
+
104
+ var url = "/api/crm/contact/addContact/";
105
+ //console.log(data);
106
+ //console.log(url);
107
+ //return false;
108
+ //提交数据
109
+ $.ajax({
110
+ type: "post",
111
+ cache: false,
112
+ url: url,
113
+ data: data,
114
+ dataType: "json",
115
+ beforeSend: function () {
116
+ showMsg("还原中,请稍后...", "Success");
117
+ },
118
+ success: function (result) {
119
+ //toLowerCase报错
120
+ //var status = result.Status.toLowerCase();
121
+ var status = result.Status;
122
+ if (status == true || status == "true" || status == "True") {
123
+ //在iframe里面打开弹出框并自动关闭
124
+ showMsg(result.Msg, "Success");
125
+ //刷新数据
126
+ trash_grid.bootgrid("reload");
127
+ } else {
128
+ showMsg(result.Msg, "Error");
129
+ }
130
+ },
131
+ error: function () {
132
+ showMsg("系统异常!");
133
+ }
134
+ });
135
+
136
+ });
137
+ }
138
+
139
+
140
+ /**
141
+ *修改客户
142
+ *如果客户customer_id为空直接修改客户,不为空,则修改当前客户对应的客户
143
+ *@author terwer
144
+ *@version 1.0 2014/09/24
145
+ *@param customer_id 客户id(可为空)
146
+ *@return 无返回值
147
+ */
148
+ function edit_contact(customer_id, contact_id) {
149
+ //关闭客户详情窗口
150
+ //parent.dialog.list["show_view"].close();
151
+ //设置当前窗口id,便于后续管理
152
+ var win_id = "show_edit_contact";
153
+ //设置不同请求的url
154
+ var show_url = "/Apps/CRM/Contact/Edit/" + contact_id;
155
+ showTopWindow(win_id, show_url, "修改客户", 800, 360, function () {
156
+ //调用iframe方法验证表单
157
+ var flag = window.top.document.getElementById("frm_" + win_id).contentWindow.form_valid();
158
+ if (!flag) {
159
+ return false;
160
+ }
161
+ //获取iframe表单序列化之后的数据
162
+ var form_contact = $(window.top.frames["frm_" + win_id].document).find("#form_contact");
163
+ var data = $(form_contact).serialize();
164
+
165
+ var url = "/api/crm/contact/editContact/";
166
+ //console.log(data);
167
+ //console.log(url);
168
+ //return false;
169
+ //提交数据
170
+ $.ajax({
171
+ type: "post",
172
+ cache: false,
173
+ url: url,
174
+ data: data,
175
+ dataType: "json",
176
+ beforeSend: function () {
177
+ showMsg("修改中,请稍后...", "Success");
178
+ },
179
+ success: function (result) {
180
+ //toLowerCase报错
181
+ //var status = result.Status.toLowerCase();
182
+ var status = result.Status;
183
+ if (status == true || status == "true" || status == "True") {
184
+ //在iframe里面打开弹出框并自动关闭
185
+ showMsg(result.Msg, "Success");
186
+ //刷新数据
187
+ trash_grid.bootgrid("reload");
188
+ } else {
189
+ showMsg(result.Msg, "Error");
190
+ }
191
+ },
192
+ error: function () {
193
+ showMsg("系统异常!");
194
+ }
195
+ });
196
+
197
+ });
198
+ }
199
+
200
+ //删除(放入回收站)
201
+ function del(ids) {
202
+
203
+ var del_tips = "确认删除该客户吗?";
204
+ try {
205
+ if (ids.toString().indexOf(",") > 0) {
206
+ var del_tips = "确认批量删除选中客户吗?";
207
+ }
208
+ } catch (e) {
209
+ //console.warn(e.message);
210
+ }
211
+ showDialog(del_tips, function () {
212
+ $.ajax({
213
+ url: "/api/crm/contact/toTrash",
214
+ cache: false,
215
+ type: "get",
216
+ data: { ids: ids, rnd: Math.random() },
217
+ success: function (result) {
218
+ var status = result.Status;
219
+ if (status == true || status == "true" || status == "True") {
220
+ showMsg("删除成功!", "Success");
221
+ trash_grid.bootgrid("reload");
222
+ } else {
223
+ showMsg("删除失败!", "Error");
224
+ }
225
+ },
226
+ error: function () {
227
+ showMsg("操作失败!", "Error");
228
+ }
229
+ });
230
+ });
231
+
232
+
233
+ }
pool/shard000/JavaScript/0003835_ui-wysiwyg.js ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function($) {
2
+
3
+ if (!window.tinymce)
4
+ return;
5
+
6
+ var plugins = [ 'code', 'link' ],
7
+ toolbar = Keystone.wysiwyg.options.overrideToolbar ? '' : 'bold italic | alignleft aligncenter alignright | bullist numlist | outdent indent | link',
8
+ skin = Keystone.wysiwyg.options.skin,
9
+ menubar = Keystone.wysiwyg.options.menubar || false;
10
+
11
+ if (Keystone.wysiwyg.options.enableImages) {
12
+ plugins.push('image');
13
+ toolbar += ' | image';
14
+ }
15
+
16
+ if (Keystone.wysiwyg.options.enableCloudinaryUploads) {
17
+ plugins.push('uploadimage');
18
+ toolbar += (Keystone.wysiwyg.options.enableImages) ? ' uploadimage' : ' | uploadimage';
19
+ }
20
+
21
+ if (Keystone.wysiwyg.options.additionalButtons) {
22
+ var additionalButtons = Keystone.wysiwyg.options.additionalButtons.split(',');
23
+ for (var i=0; i<additionalButtons.length; i++) {
24
+ toolbar += (' | ' + additionalButtons[i]);
25
+ }
26
+ }
27
+ if (Keystone.wysiwyg.options.additionalPlugins) {
28
+ var additionalPlugins = Keystone.wysiwyg.options.additionalPlugins.split(',');
29
+ for (var i=0; i<additionalPlugins.length; i++) {
30
+ plugins.push(additionalPlugins[i]);
31
+ }
32
+ }
33
+ toolbar += ' | code';
34
+
35
+ //init editable wysiwygs
36
+ var tinymceOptions = {
37
+ selector: 'textarea.wysiwyg',
38
+ menubar: menubar,
39
+ plugins: plugins,
40
+ toolbar: toolbar,
41
+ skin: skin,
42
+ uploadimage_form_url: '/keystone/api/cloudinary/upload'
43
+ };
44
+
45
+ if (Keystone.wysiwyg.options.additionalOptions){
46
+ $.extend(tinymceOptions,Keystone.wysiwyg.options.additionalOptions);
47
+ }
48
+
49
+ tinymce.init(tinymceOptions);
50
+
51
+ console.log(tinymceOptions);
52
+
53
+ //init non-editable wysiwygs
54
+ var tinymceOptionsNonEditable = {
55
+ selector: 'textarea.wysiwyg-noedit',
56
+ mode: 'textareas',
57
+ readonly: true,
58
+ menubar: false,
59
+ plugins: plugins,
60
+ toolbar: 'code',
61
+ statusbar: false,
62
+ skin: 'keystone'
63
+ };
64
+
65
+ if (Keystone.wysiwyg.options.additionalOptions){
66
+ $.extend(tinymceOptionsNonEditable,Keystone.wysiwyg.options.additionalOptions);
67
+ }
68
+
69
+
70
+ tinymce.init(tinymceOptionsNonEditable);
71
+
72
+ });
pool/shard000/JavaScript/0003836_transitional.js ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ $(window).scroll(function() {
2
+ $('#two').each(function(){
3
+ var imagePos = $(this).offset().top;
4
+
5
+ var topOfWindow = $(window).scrollTop();
6
+ if (imagePos < topOfWindow+400) {
7
+ $(this).addClass("slideUp");
8
+ }
9
+ });
10
+ });
11
+
12
+ $(window).scroll(function() {
13
+ $('#animation').each(function(){
14
+ var imagePos = $(this).offset().top;
15
+
16
+ var topOfWindow = $(window).scrollTop();
17
+ if (imagePos < topOfWindow+400) {
18
+ $(this).addClass("slideUp");
19
+ }
20
+ });
21
+ });
22
+
23
+ $(window).scroll(function() {
24
+ $('#paragrahone_down').each(function(){
25
+ var imagePos = $(this).offset().top;
26
+
27
+ var topOfWindow = $(window).scrollTop();
28
+ if (imagePos < topOfWindow+400) {
29
+ $(this).addClass("slideUp");
30
+ }
31
+ });
32
+ });
33
+
34
+ $(window).scroll(function() {
35
+ $('#p2').each(function(){
36
+ var imagePos = $(this).offset().top;
37
+
38
+ var topOfWindow = $(window).scrollTop();
39
+ if (imagePos < topOfWindow+400) {
40
+ $(this).addClass("slideUp");
41
+ }
42
+ });
43
+ });
44
+
45
+ $(window).scroll(function() {
46
+ $('#washer').each(function(){
47
+ var imagePos = $(this).offset().top;
48
+
49
+ var topOfWindow = $(window).scrollTop();
50
+ if (imagePos < topOfWindow+400) {
51
+ $(this).addClass("slideRight");
52
+ }
53
+ });
54
+ });
55
+
56
+ $(window).scroll(function() {
57
+ $('#header').each(function(){
58
+ var imagePos = $(this).offset().top;
59
+
60
+ var topOfWindow = $(window).scrollTop();
61
+ if (imagePos < topOfWindow+400) {
62
+ $(this).addClass("fadeIn");
63
+ }
64
+ });
65
+ });
66
+
67
+ $(window).scroll(function() {
68
+ $('#goup').each(function(){
69
+ var imagePos = $(this).offset().top;
70
+
71
+ var topOfWindow = $(window).scrollTop();
72
+ if (imagePos < topOfWindow+400) {
73
+ $(this).addClass("slideUp");
74
+ }
75
+ });
76
+ });
77
+
78
+ $(window).scroll(function() {
79
+ $('#goup2').each(function(){
80
+ var imagePos = $(this).offset().top;
81
+
82
+ var topOfWindow = $(window).scrollTop();
83
+ if (imagePos < topOfWindow+400) {
84
+ $(this).addClass("slideLeft");
85
+ }
86
+ });
87
+ });
88
+
89
+ $(window).scroll(function() {
90
+ $('#goup3').each(function(){
91
+ var imagePos = $(this).offset().top;
92
+
93
+ var topOfWindow = $(window).scrollTop();
94
+ if (imagePos < topOfWindow+400) {
95
+ $(this).addClass("slideUp");
96
+ }
97
+ });
98
+ });
99
+
100
+ $(window).scroll(function() {
101
+ $('#goup4').each(function(){
102
+ var imagePos = $(this).offset().top;
103
+
104
+ var topOfWindow = $(window).scrollTop();
105
+ if (imagePos < topOfWindow+400) {
106
+ $(this).addClass("slideLeft");
107
+ }
108
+ });
109
+ });
110
+
111
+ $(window).scroll(function() {
112
+ $('#goup5').each(function(){
113
+ var imagePos = $(this).offset().top;
114
+
115
+ var topOfWindow = $(window).scrollTop();
116
+ if (imagePos < topOfWindow+400) {
117
+ $(this).addClass("stretchRight");
118
+ }
119
+ });
120
+ });
121
+
122
+ $(window).scroll(function() {
123
+ $('#goup6').each(function(){
124
+ var imagePos = $(this).offset().top;
125
+
126
+ var topOfWindow = $(window).scrollTop();
127
+ if (imagePos < topOfWindow+400) {
128
+ $(this).addClass("slideRight");
129
+ }
130
+ });
131
+ });
pool/shard000/JavaScript/0003838_cellRendererService.js ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * ag-grid - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
3
+ * @version v5.0.0-alpha.2
4
+ * @link http://www.ag-grid.com/
5
+ * @license MIT
6
+ */
7
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
8
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
12
+ };
13
+ var __metadata = (this && this.__metadata) || function (k, v) {
14
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
15
+ };
16
+ var utils_1 = require("../utils");
17
+ var context_1 = require("../context/context");
18
+ var cellRendererFactory_1 = require("./cellRendererFactory");
19
+ /** Class to use a cellRenderer. */
20
+ var CellRendererService = (function () {
21
+ function CellRendererService() {
22
+ }
23
+ /** Uses a cellRenderer, and returns the cellRenderer object if it is a class implementing ICellRenderer.
24
+ * @cellRendererKey: The cellRenderer to use. Can be: a) a class that we call 'new' on b) a function we call
25
+ * or c) a string that we use to look up the cellRenderer.
26
+ * @params: The params to pass to the cell renderer if it's a function or a class.
27
+ * @eTarget: The DOM element we will put the results of the html element into *
28
+ * @return: If options a, it returns the created class instance */
29
+ CellRendererService.prototype.useCellRenderer = function (cellRendererKey, eTarget, params) {
30
+ var cellRenderer = this.lookUpCellRenderer(cellRendererKey);
31
+ if (utils_1.Utils.missing(cellRenderer)) {
32
+ // this is a bug in users config, they specified a cellRenderer that doesn't exist,
33
+ // the factory already printed to console, so here we just skip
34
+ return;
35
+ }
36
+ var resultFromRenderer;
37
+ var iCellRendererInstance = null;
38
+ this.checkForDeprecatedItems(cellRenderer);
39
+ // we check if the class has the 'getGui' method to know if it's a component
40
+ var rendererIsAComponent = this.doesImplementICellRenderer(cellRenderer);
41
+ // if it's a component, we create and initialise it
42
+ if (rendererIsAComponent) {
43
+ var CellRendererClass = cellRenderer;
44
+ iCellRendererInstance = new CellRendererClass();
45
+ this.context.wireBean(iCellRendererInstance);
46
+ if (iCellRendererInstance.init) {
47
+ iCellRendererInstance.init(params);
48
+ }
49
+ resultFromRenderer = iCellRendererInstance.getGui();
50
+ }
51
+ else {
52
+ // otherwise it's a function, so we just use it
53
+ var cellRendererFunc = cellRenderer;
54
+ resultFromRenderer = cellRendererFunc(params);
55
+ }
56
+ if (resultFromRenderer === null || resultFromRenderer === '') {
57
+ return;
58
+ }
59
+ if (utils_1.Utils.isNodeOrElement(resultFromRenderer)) {
60
+ // a dom node or element was returned, so add child
61
+ eTarget.appendChild(resultFromRenderer);
62
+ }
63
+ else {
64
+ // otherwise assume it was html, so just insert
65
+ eTarget.innerHTML = resultFromRenderer;
66
+ }
67
+ return iCellRendererInstance;
68
+ };
69
+ CellRendererService.prototype.checkForDeprecatedItems = function (cellRenderer) {
70
+ if (cellRenderer && cellRenderer.renderer) {
71
+ console.warn('ag-grid: colDef.cellRenderer should not be an object, it should be a string, function or class. this ' +
72
+ 'changed in v4.1.x, please check the documentation on Cell Rendering, or if you are doing grouping, look at the grouping examples.');
73
+ }
74
+ };
75
+ CellRendererService.prototype.doesImplementICellRenderer = function (cellRenderer) {
76
+ // see if the class has a prototype that defines a getGui method. this is very rough,
77
+ // but javascript doesn't have types, so is the only way!
78
+ return cellRenderer.prototype && 'getGui' in cellRenderer.prototype;
79
+ };
80
+ CellRendererService.prototype.lookUpCellRenderer = function (cellRendererKey) {
81
+ if (typeof cellRendererKey === 'string') {
82
+ return this.cellRendererFactory.getCellRenderer(cellRendererKey);
83
+ }
84
+ else {
85
+ return cellRendererKey;
86
+ }
87
+ };
88
+ __decorate([
89
+ context_1.Autowired('cellRendererFactory'),
90
+ __metadata('design:type', cellRendererFactory_1.CellRendererFactory)
91
+ ], CellRendererService.prototype, "cellRendererFactory", void 0);
92
+ __decorate([
93
+ context_1.Autowired('context'),
94
+ __metadata('design:type', context_1.Context)
95
+ ], CellRendererService.prototype, "context", void 0);
96
+ CellRendererService = __decorate([
97
+ context_1.Bean('cellRendererService'),
98
+ __metadata('design:paramtypes', [])
99
+ ], CellRendererService);
100
+ return CellRendererService;
101
+ })();
102
+ exports.CellRendererService = CellRendererService;
pool/shard000/JavaScript/0003840_chatobserver.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export default class ChatObserver{
2
+ constructor(){
3
+ this.observer = new MutationObserver(this.onMutated.bind(this));
4
+ this.observer.observe(this.getTarget(), {
5
+ childList: true,
6
+ subtree: true,
7
+ });
8
+ }
9
+
10
+ getTarget(){
11
+ return document.getElementById('logmain');
12
+ }
13
+
14
+ onMutated(records){
15
+ for(let record of records){
16
+ this.processMutation(record);
17
+ }
18
+ }
19
+
20
+ processMutation(record){
21
+ if(record.type !== 'childList' || record.addedNodes.length === 0){
22
+ return;
23
+ }
24
+ let node = record.addedNodes[0];
25
+ if(node.tagName !== 'LI' || !node.id.startsWith('log')){
26
+ return;
27
+ }
28
+ this.processChatNode(node);
29
+ }
30
+
31
+ processChatNode(node){
32
+ }
33
+ }
pool/shard000/JavaScript/0003841_index.js ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ var path = process.cwd();
4
+ var Graphriend = require(path + '/app/controllers/Graphriend.server.js');
5
+ var sess;
6
+
7
+ module.exports = function (app) {
8
+
9
+ function isLoggedIn (req, res, next) {
10
+ sess = req.session;
11
+ if (sess.user || req.url === '/') {
12
+ return next();
13
+ } else {
14
+ res.redirect('/');
15
+ }
16
+ }
17
+
18
+ var graPhriend = new Graphriend();
19
+
20
+ // Index view
21
+ app.route('/')
22
+ .get(isLoggedIn, function (req, res) {
23
+ res.render('main', { user: sess.user, page: 'index' });
24
+ });
25
+
26
+ // All users view
27
+ app.route('/all')
28
+ .get(isLoggedIn, graPhriend.showAll);
29
+
30
+ // My friends view
31
+ app.route('/my')
32
+ .get(isLoggedIn, graPhriend.showMy);
33
+
34
+ // Access API REST
35
+ app.post('/api/signup', graPhriend.signUp);
36
+ app.post('/api/login', graPhriend.logIn);
37
+ app.get('/api/logout', graPhriend.logOut);
38
+
39
+ // Friends API REST
40
+ app.route('/api/users/:username/friends')
41
+ .get(isLoggedIn, graPhriend.getFriend)
42
+ .post(isLoggedIn, graPhriend.addFriend)
43
+ .delete(isLoggedIn, graPhriend.delFriend);
44
+
45
+ };
pool/shard000/JavaScript/0003843_DefaultService.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ exports.rootGET = function(args, res, next) {
4
+ /**
5
+ *
6
+ * no response value expected for this operation
7
+ **/
8
+ res.end();
9
+ }
10
+
11
+ exports.rootPOST = function(args, res, next) {
12
+ /**
13
+ *
14
+ * name String name (optional)
15
+ * year String year (optional)
16
+ * no response value expected for this operation
17
+ **/
18
+ res.end();
19
+ }
20
+
21
+ exports.test_pathIdGET = function(args, res, next) {
22
+ /**
23
+ *
24
+ * id String ID
25
+ * no response value expected for this operation
26
+ **/
27
+ //res.end();
28
+ res.end(args.id.value);
29
+ }
30
+
pool/shard000/JavaScript/0003849_updateInPlace.js ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * name : updateInPlace.js
3
+ * Location : /norris/test/businessLayer/mapChartController
4
+ *
5
+ * History :
6
+ * Version Date Programmer
7
+ * =================================================
8
+ * 0.0.1 2015/05/13 Meneguzzo Francesco
9
+ * -------------------------------------------------
10
+ * Codifica modulo
11
+ * =================================================
12
+ */
13
+
14
+ 'use strict';
15
+ var proxyquire = require('proxyquire');
16
+ var should = require('should');
17
+
18
+ var resourcesStub = [];
19
+ resourcesStub[2] = { _id: 2, _points: [{id: "id", latitude:10, longitude:10}]};
20
+ var updateCheck = undefined;
21
+
22
+ var stub = {
23
+ './ActiveResourcesController.js' : {
24
+ retrieveGraph: function(id) { return resourcesStub[id]}
25
+ },
26
+ './SocketController.js': {
27
+ sendUpdate: function(id, options) { updateCheck = {}; updateCheck.id = id;
28
+ updateCheck.options = options; }
29
+ }
30
+ };
31
+
32
+ var mapChartController = proxyquire('../../../../lib/businessLayer/MapChartController.js', stub);
33
+
34
+ describe('TU11 - mapChartController.updateInPlace()', function() {
35
+
36
+ it('Should fail when called with an invalid id', function() {
37
+ mapChartController.updateInPlace(2, "invalid id", 15, 15);
38
+ should.not.exist(updateCheck);
39
+ });
40
+
41
+ it('Should execute correctly when called with a valid id', function() {
42
+ mapChartController.updateInPlace(2, "id", 15, 15);
43
+ should.exist(updateCheck);
44
+ updateCheck.id.should.be.exactly(2);
45
+ updateCheck.options.type.should.be.exactly("inPlace");
46
+ updateCheck.options.id.should.be.exactly("id");
47
+ updateCheck.options.latitude.should.be.exactly(15);
48
+ updateCheck.options.longitude.should.be.exactly(15);
49
+ resourcesStub[2]._points[0].id.should.be.exactly("id");
50
+ resourcesStub[2]._points[0].latitude.should.be.exactly(15);
51
+ resourcesStub[2]._points[0].longitude.should.be.exactly(15);
52
+ });
53
+ });
pool/shard000/JavaScript/0003850_DeliveryController.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ 'use strict';
3
+
4
+ define(['app'], function (app) {
5
+
6
+ var deliveryController = function ($scope, $location) {
7
+ var appTitle = 'Delivery';
8
+ $scope.appTitle = appTitle;
9
+ $scope.highlight = function (path) {
10
+ return $location.path().substr(0, path.length) == path;
11
+ };
12
+ $("#banner_delivery").backstretch("./img/registro_fondo.jpg");
13
+ //$("#contenido").css("height", "300");
14
+ var $window = $(window).on('resize', function() {
15
+ //alert($(window).width())
16
+ if ($(window).width() <= 767) {
17
+ $('#contenido').height(
18
+ ($(window).height() - $('#header').height() - $('#footer').height() - 20) / 2
19
+ );
20
+ } else {
21
+ $('#contenido').height(
22
+ $(window).height() - $('#header').height() - $('#footer').height() - 150
23
+ );
24
+ }
25
+ $("#banner_delivery").backstretch("./img/registro_fondo.jpg");
26
+ }).trigger('resize'); //on page load
27
+ };
28
+
29
+ app.register.controller('DeliveryController', ['$scope', '$location', deliveryController]);
30
+
31
+ });
pool/shard000/JavaScript/0003852_index.js ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Settings Lib
3
+ * A collection of utilities for handling settings including a cache
4
+ */
5
+ const events = require('../../lib/common/events');
6
+ const models = require('../../models');
7
+ const labs = require('../../../shared/labs');
8
+ const SettingsCache = require('../../../shared/settings-cache');
9
+ const SettingsBREADService = require('./settings-bread-service');
10
+ const {obfuscatedSetting, isSecretSetting, hideValueIfSecret} = require('./settings-utils');
11
+
12
+ /**
13
+ * @returns {SettingsBREADService} instance of the PostsService
14
+ */
15
+ const getSettingsBREADServiceInstance = () => {
16
+ return new SettingsBREADService({
17
+ SettingsModel: models.Settings,
18
+ settingsCache: SettingsCache,
19
+ labsService: labs
20
+ });
21
+ };
22
+
23
+ module.exports = {
24
+ /**
25
+ * Initialize the cache, used in boot and in testing
26
+ */
27
+ async init() {
28
+ const settingsCollection = await models.Settings.populateDefaults();
29
+ SettingsCache.init(events, settingsCollection);
30
+ },
31
+
32
+ /**
33
+ * Shutdown the cache, used in force boot during testing
34
+ */
35
+ shutdown() {
36
+ SettingsCache.reset(events);
37
+ },
38
+
39
+ /**
40
+ * Handles synchronization of routes.yaml hash loaded in the frontend with
41
+ * the value stored in the settings table.
42
+ * getRoutesHash is a function to allow keeping "frontend" decoupled from settings
43
+ *
44
+ * @param {function} getRoutesHash function fetching currently loaded routes file hash
45
+ */
46
+ async syncRoutesHash(getRoutesHash) {
47
+ const currentRoutesHash = await getRoutesHash();
48
+
49
+ if (SettingsCache.get('routes_hash') !== currentRoutesHash) {
50
+ return await models.Settings.edit([{
51
+ key: 'routes_hash',
52
+ value: currentRoutesHash
53
+ }], {context: {internal: true}});
54
+ }
55
+ },
56
+
57
+ /**
58
+ * Handles email setting synchronization when email has been verified per instance
59
+ *
60
+ * @param {boolean} configValue current email verification value from local config
61
+ */
62
+ async syncEmailSettings(configValue) {
63
+ const isEmailDisabled = SettingsCache.get('email_verification_required');
64
+
65
+ if (configValue === true && isEmailDisabled) {
66
+ return await models.Settings.edit([{
67
+ key: 'email_verification_required',
68
+ value: false
69
+ }], {context: {internal: true}});
70
+ }
71
+ },
72
+
73
+ obfuscatedSetting,
74
+ isSecretSetting,
75
+ hideValueIfSecret,
76
+ getSettingsBREADServiceInstance
77
+ };
pool/shard000/JavaScript/0003853_empty-group-filters-extra-view.spec.js ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const $ = require('jquery');
2
+ const EmptyGroupFiltersExtraView = require('dashboard/views/organization/groups-admin/filters/empty-group-filters-extra-view');
3
+ const UserModel = require('dashboard/data/user-model');
4
+ const GroupModel = require('dashboard/data/group-model');
5
+ const OrganizationModel = require('dashboard/data/organization-model');
6
+ const PasswordValidatedForm = require('dashboard/helpers/password-validated-form');
7
+ const configModel = require('fixtures/dashboard/config-model.fixture');
8
+
9
+ const PASSWORD = 'password';
10
+
11
+ describe('organization/groups_admin/empty_group_filters_extra_view', function () {
12
+ beforeEach(function () {
13
+ spyOn(PasswordValidatedForm, 'showPasswordModal').and.callFake(
14
+ function (options) {
15
+ options.onPasswordTyped && options.onPasswordTyped(PASSWORD);
16
+ }
17
+ );
18
+
19
+ this.organization = new OrganizationModel({
20
+ id: 'org-id',
21
+ users: [{
22
+ id: 'ou-1',
23
+ username: 'paco'
24
+ },
25
+ {
26
+ id: 'ou-2',
27
+ username: 'pepe'
28
+ }]
29
+ }, { configModel });
30
+
31
+ this.user = new UserModel({
32
+ id: 'user-id',
33
+ username: 'pepe',
34
+ actions: {},
35
+ needs_password_confirmation: true
36
+ });
37
+ this.user.setOrganization(this.organization);
38
+
39
+ this.group = new GroupModel({
40
+ id: 'g1',
41
+ organization: this.user.organization,
42
+ users: [{
43
+ id: 'gu-1',
44
+ username: 'pachi'
45
+ }]
46
+ }, { configModel });
47
+
48
+ this.groupUsers = this.group.users;
49
+ spyOn(this.groupUsers, 'addInBatch');
50
+
51
+ this.orgUsers = this.user.organization.users;
52
+
53
+ this.view = new EmptyGroupFiltersExtraView({
54
+ groupUsers: this.groupUsers,
55
+ orgUsers: this.orgUsers,
56
+ userModel: this.user
57
+ });
58
+ this.view.render();
59
+ });
60
+
61
+ afterEach(function () {
62
+ // The Dialog closing action occurs within a 120ms delay, so we
63
+ // remove it manually instead of waiting for the dialog to close
64
+ var dialog = document.querySelector('.Dialog');
65
+
66
+ if (dialog) {
67
+ dialog.remove();
68
+ }
69
+ });
70
+
71
+ it('should not have leaks', function () {
72
+ expect(this.view).toHaveNoLeaks();
73
+ });
74
+
75
+ it('should show the add-users button disabled', function () {
76
+ expect(this.view.$('.js-add-users').hasClass('is-disabled')).toBe(true);
77
+ });
78
+
79
+ it('should do nothing on click add-button', function () {
80
+ this.view.$('.js-add-users').click();
81
+ expect(this.groupUsers.addInBatch).not.toHaveBeenCalled();
82
+ });
83
+
84
+ describe('when at least one user is selected', function () {
85
+ beforeEach(function () {
86
+ this.orgUsers.first().set('selected', true);
87
+ });
88
+
89
+ it('should change the subheader to show add button', function () {
90
+ expect(this.view.$('.js-add-users').hasClass('is-disabled')).toBe(false);
91
+ });
92
+
93
+ describe('when click add', function () {
94
+ beforeEach(function () {
95
+ jasmine.clock().install(); // due to modal animations
96
+ this.jqXHR = $.Deferred();
97
+ this.groupUsers.addInBatch.and.returnValue(this.jqXHR);
98
+ this.view.$('.js-add-users').click();
99
+ jasmine.clock().tick(1000);
100
+ });
101
+
102
+ afterEach(function () {
103
+ jasmine.clock().uninstall();
104
+ });
105
+
106
+ it('should require password confirmation if needed', function () {
107
+ expect(PasswordValidatedForm.showPasswordModal).toHaveBeenCalled();
108
+ });
109
+
110
+ it('should bypass password confirmation when needs_password_validation is false', function () {
111
+ PasswordValidatedForm.showPasswordModal.calls.reset();
112
+
113
+ const userModel = new UserModel({
114
+ needs_password_confirmation: false
115
+ });
116
+
117
+ this.view = new EmptyGroupFiltersExtraView({
118
+ groupUsers: this.groupUsers,
119
+ orgUsers: this.orgUsers,
120
+ userModel
121
+ });
122
+
123
+ expect(PasswordValidatedForm.showPasswordModal).not.toHaveBeenCalled();
124
+ });
125
+
126
+ it('should call group users collection to add them in batch', function () {
127
+ expect(this.group.users.addInBatch).toHaveBeenCalled();
128
+ expect(this.group.users.addInBatch).toHaveBeenCalledWith(jasmine.any(Array), jasmine.any(String));
129
+ expect(this.group.users.addInBatch).toHaveBeenCalledWith(['ou-1'], PASSWORD);
130
+ });
131
+
132
+ it('should show removing users loader in a modal', function () {
133
+ expect($('.Dialog').text()).toContain('Adding');
134
+ });
135
+
136
+ describe('when users are added', function () {
137
+ beforeEach(function () {
138
+ this.jqXHR.resolve();
139
+ jasmine.clock().tick(1000);
140
+ });
141
+
142
+ it('should close loading modal', function () {
143
+ expect($('.Dialog').length).toEqual(0);
144
+ });
145
+ });
146
+
147
+ describe('when fails to add users', function () {
148
+ beforeEach(function () {
149
+ this.jqXHR.reject();
150
+ jasmine.clock().tick(1000);
151
+ });
152
+
153
+ it('should close loading modal', function () {
154
+ expect($('.Dialog').text()).not.toContain('Adding');
155
+ });
156
+
157
+ it('should show error modal', function () {
158
+ expect($('.Dialog').text()).toContain('error');
159
+ });
160
+ });
161
+ });
162
+ });
163
+
164
+ afterEach(function () {
165
+ this.view.clean();
166
+ });
167
+ });
pool/shard000/JavaScript/0003856_ember-strap.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Ember from 'ember';
2
+ import 'ember-strap/router-dsl-ext';
3
+ import { registerKeywords } from 'ember-strap/ember-internals';
4
+ registerKeywords();
5
+
6
+ let hackScrollSpy = function() {
7
+ // Allows scroll spy to work without change URL fragment
8
+ Ember.$(document).on('click', function(e) {
9
+ Ember.$('[data-spy="scroll"]').each(function() {
10
+ let spyTarget = Ember.$(this).data('target');
11
+ let $target = Ember.$(e.target);
12
+ if ($target.closest(spyTarget).length) {
13
+ e.preventDefault();
14
+ let $anchor = Ember.$($target.attr('href'));
15
+ if ($anchor.length) {
16
+ Ember.$(this).scrollTop($anchor.offset().top);
17
+ }
18
+ }
19
+ });
20
+ });
21
+ };
22
+
23
+ export default {
24
+ name: "ember-strap",
25
+
26
+ initialize: function() {
27
+ hackScrollSpy();
28
+ }
29
+ };
pool/shard000/JavaScript/0003859_normalizeType.tests.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ var _ = require('lodash');
4
+ var expect = require('chai').expect;
5
+
6
+ describe('normalizeType', function(){
7
+ var sut = require('../../src/utils/normalizeType');
8
+
9
+ it('will return "Information" by default', function(){
10
+ expect(sut()).to.equal("Information");
11
+ });
12
+
13
+
14
+ it('will return "Error" for strings that begin with "e"', function(){
15
+ expect(sut("E")).to.equal("Error");
16
+ });
17
+
18
+
19
+ it('will return "Warning" for strings that begin with "w"', function(){
20
+ expect(sut("W")).to.equal("Warning");
21
+ });
22
+
23
+
24
+ it('will return "SuccessAudit" for strings that begin with "s"', function(){
25
+ expect(sut("S")).to.equal("SuccessAudit");
26
+ });
27
+
28
+
29
+ it('will return "FailureAudit" for strings that begin with "f"', function(){
30
+ expect(sut("F")).to.equal("FailureAudit");
31
+ });
32
+
33
+ });
pool/shard000/JavaScript/0003860_MD5Sum.spec.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const assert = require('assert');
2
+ const DummyRequest = require('../../utils/DummyRequest');
3
+ const MD5Sum = require('../../../lib/s3middleware/MD5Sum');
4
+ const constants = require('../../../lib/constants');
5
+
6
+ function consume(stream) {
7
+ stream.on('data', () => { });
8
+ }
9
+
10
+ function testMD5(payload, expectedMD5, done) {
11
+ const dummy = new DummyRequest({}, payload);
12
+ const md5summer = new MD5Sum();
13
+ md5summer.on('hashed', () => {
14
+ assert.strictEqual(md5summer.completedHash, expectedMD5);
15
+ done();
16
+ });
17
+ dummy.pipe(md5summer);
18
+ consume(md5summer);
19
+ }
20
+
21
+ describe('utilities.MD5Sum', () => {
22
+ it('should work on empty request', done => {
23
+ testMD5('', constants.emptyFileMd5, done);
24
+ });
25
+
26
+ it('should work on SAY GRRRR!!! request', done => {
27
+ testMD5('SAY GRRRR!!!', '986eb4a201192e8b1723a42c1468fb4e', done);
28
+ });
29
+
30
+ it('should work on multiple MiB data stream', done => {
31
+ /*
32
+ * relies on a zero filled buffer and
33
+ * split content in order to get multiple calls of _transform()
34
+ * md5sum computed by hand with:
35
+ * $ dd if=/dev/zero of=/dev/stdout bs=1M count=16 2>/dev/null | md5sum
36
+ */
37
+ const buffer = Buffer.alloc(4 * 1024 * 1024);
38
+ testMD5([buffer, buffer, buffer, buffer],
39
+ '2c7ab85a893283e98c931e9511add182', done);
40
+ });
41
+ });
pool/shard000/JavaScript/0003868_Tier19_2set.js ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import SPELLS from 'common/SPELLS';
2
+
3
+ import Module from 'Parser/Core/Module';
4
+ import calculateEffectiveHealing from 'Parser/Core/calculateEffectiveHealing';
5
+
6
+ import { ABILITIES_AFFECTED_BY_HEALING_INCREASES } from '../../Constants';
7
+
8
+ const debug = false;
9
+
10
+ const HEALING_INCREASE = 0.3;
11
+
12
+ class Tier19_2set extends Module {
13
+ healing = 0;
14
+
15
+ on_initialized() {
16
+ if (!this.owner.error) {
17
+ this.active = this.owner.selectedCombatant.hasBuff(SPELLS.DISC_PRIEST_T19_2SET_BONUS_BUFF.id);
18
+ }
19
+ }
20
+
21
+ on_byPlayer_heal(event) {
22
+ this.registerHeal(event);
23
+ }
24
+ on_byPlayer_absorbed(event) {
25
+ const spellId = event.ability.guid;
26
+ if (spellId === SPELLS.POWER_WORD_SHIELD.id) {
27
+ // PW:S gets applied but the initial application doesn't get buffed. Since it's an abosrb, any followup absorbs do NOT benefit from the set bonus, but they do occur as the buff is still up. This has to be excluded.
28
+ return;
29
+ }
30
+ this.registerHeal(event);
31
+ }
32
+ registerHeal(event) {
33
+ const spellId = event.ability.guid;
34
+ if (ABILITIES_AFFECTED_BY_HEALING_INCREASES.indexOf(spellId) === -1) {
35
+ return;
36
+ }
37
+ const combatant = this.owner.combatants.players[event.targetID];
38
+ if (!combatant) {
39
+ // If combatant doesn't exist it's probably a pet.
40
+ debug && console.log('Skipping event since combatant couldn\'t be found:', event);
41
+ return;
42
+ }
43
+ const hasBuff = combatant.hasBuff(SPELLS.POWER_WORD_SHIELD.id, event.timestamp);
44
+ if (!hasBuff) {
45
+ return;
46
+ }
47
+
48
+ this.healing += calculateEffectiveHealing(event, HEALING_INCREASE);
49
+ }
50
+ }
51
+
52
+ export default Tier19_2set;
pool/shard000/JavaScript/0003869_subnets.js ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const makePipConnections = require("./pips").connect;
2
+ const sortSubnets = require("../util").sortSubnets;
3
+ const sh = require("shorthash");
4
+
5
+ const makeDiagId = id => {
6
+ return "id" + sh.unique(id);
7
+ };
8
+
9
+ const matchSourceAddressPrefix = (source, prefix) => {
10
+ //console.log(`todo: more sophisticated match: prefix ${prefix} source ${source}`)
11
+ return prefix === source;
12
+ };
13
+
14
+ const connectCidrSubnets = (rule, armData, id) => {
15
+ let result = "";
16
+ Object.values(armData.subnetMap).forEach(subnet => {
17
+ const sid = makeDiagId(subnet.id);
18
+ if (
19
+ id !== sid &&
20
+ matchSourceAddressPrefix(
21
+ subnet.properties.addressPrefix,
22
+ rule.properties.sourceAddressPrefix
23
+ )
24
+ )
25
+ result += `${id} <- ${sid} : ${rule.name} (port ${rule.properties
26
+ .destinationPortRange})
27
+ `;
28
+ });
29
+ return result;
30
+ };
31
+
32
+ const connectAllSubnets = (rule, armData, id) => {
33
+ let result = "";
34
+ Object.values(armData.subnetMap).forEach(subnet => {
35
+ const sid = makeDiagId(subnet.id);
36
+ if (id !== sid)
37
+ result += `${id} <- ${sid} : ${rule.name} (port ${rule.properties
38
+ .destinationPortRange})
39
+ `;
40
+ });
41
+ return result;
42
+ };
43
+
44
+ const connectSubnets = armData => {
45
+ let result = "";
46
+ sortSubnets(Object.values(armData.subnetMap)).forEach(subnet => {
47
+ const id = makeDiagId(subnet.id);
48
+ // todo: ensure there are explicit deny rules and/or sane default deny rules
49
+ // iterate on rules
50
+ if (!subnet.properties.networkSecurityGroup) {
51
+ result += connectAllSubnets(
52
+ {
53
+ name: "WARNING:\\nno subnet NSG\\nall ports open to vnet\\n",
54
+ properties: { destinationPortRange: "*" }
55
+ },
56
+ armData,
57
+ id
58
+ );
59
+ return; //bail - this subnet has no NSG
60
+ }
61
+ const nsg = armData.nsgMap[subnet.properties.networkSecurityGroup.id];
62
+ if (!nsg || !nsg.properties.securityRules) {
63
+ console.log(
64
+ "WARNING, no nsg rules for " + subnet.properties.networkSecurityGroup.id
65
+ );
66
+ return;
67
+ }
68
+ const rules = nsg.properties.securityRules;
69
+
70
+ result += `
71
+ note over ${id}: ${nsg.name}
72
+ `
73
+
74
+ rules.filter(rule => rule.properties.access.toUpperCase() !== "DENY").forEach(rule => {
75
+ if (rule.properties.sourceAddressPrefix.toUpperCase() === "VIRTUALNETWORK") {
76
+ // map to ALL other subnets
77
+ result += connectAllSubnets(rule, armData, id);
78
+ } else if (rule.properties.sourceAddressPrefix === "*") {
79
+ result += makePipConnections(rule, armData, id, subnet);
80
+ result += connectAllSubnets(rule, armData, id);
81
+ } else if (rule.properties.sourceAddressPrefix.toUpperCase() === "INTERNET") {
82
+ // connect pips to subnets and lbs
83
+ result += makePipConnections(rule, armData, id, subnet);
84
+ } else {
85
+ // map to other subnets that match the cidr pattern
86
+ result += connectCidrSubnets(rule, armData, id);
87
+ }
88
+ });
89
+ });
90
+
91
+ return Array.from(new Set(result.split("\n"))).join("\n"); //no dupes
92
+ };
93
+
94
+ exports["connect"] = connectSubnets;
pool/shard000/JavaScript/0003876_document.js ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module.exports = function(context){
2
+
3
+ var stdout = context.stdout;
4
+ var stderr = context.stderr;
5
+ var config = context.config;
6
+ var db = context.db;
7
+ var app = context.app;
8
+ var channel = context.channel;
9
+ var trigger = context.trigger;
10
+
11
+ var uuid = require('node-uuid');
12
+
13
+ stdout('Initializing document API ... ');
14
+
15
+ var moment = require('moment'); require('twix');
16
+
17
+ /* Get object including data (potentially large JSON) */
18
+ app.get('/api/:collection/:id/raw', function (req, res) {
19
+ var collection = db.collection(req.params.collection);
20
+ collection.findOne({ _id: req.params.id }, function (err, data) {
21
+ if(err) { stderr(err); res.status(500).end(); return; }
22
+ if(!data) { res.status(404).end(); return; }
23
+ res.send(data);
24
+ });
25
+ });
26
+
27
+ /* Get object */
28
+ app.get('/api/:collection/:id', function (req, res) {
29
+ var collection = db.collection(req.params.collection);
30
+ collection.findOne({ _id: req.params.id }, { _data: false }, function (err, data) {
31
+ if(err) { stderr(err); res.status(500).end(); return; }
32
+ if(!data) { res.status(404).end(); return; }
33
+ res.send(data);
34
+ });
35
+ });
36
+
37
+ /* Create object */
38
+ app.post('/api/:collection', function (req, res) {
39
+ var object = req.body;
40
+ var collection = db.collection(req.params.collection);
41
+ collection.insert(object, function(err, data){
42
+ if(err || !data) { stderr(err); res.status(500).end(); return; }
43
+ res.status(200).end();
44
+ var ref = req.params.collection;
45
+ trigger(ref, 'update');
46
+ return;
47
+ });
48
+ });
49
+
50
+ /* Update object */
51
+ app.put('/api/:collection/:id', function (req, res) {
52
+ if(req.body._id) delete req.body._id;
53
+ req.body._update = moment().format();
54
+ var collection = db.collection(req.params.collection);
55
+ collection.update({ _id: req.params.id }, { $set: req.body }, { upsert: false }, function(err, data){
56
+ if(err || !data) { stderr(err); res.status(500).end(); return; }
57
+ res.status(200).end();
58
+ var ref = req.params.collection + '/' + req.params.id;
59
+ trigger(ref, 'update'); // should be array of names of values changed...
60
+ return;
61
+ });
62
+ });
63
+
64
+ /* Insert *or* update object */
65
+ app.post('/api/:collection/:id', function (req, res) {
66
+ if(req.body._id) delete req.body._id;
67
+ req.body._update = moment().format();
68
+ var collection = db.collection(req.params.collection);
69
+ collection.update({ _id: req.params.id }, { $set: req.body }, { upsert: true }, function(err, data){
70
+ if(err || !data) { stderr(err); res.status(500).end(); return; }
71
+ res.status(200).end();
72
+ var ref = req.params.collection + '/' + req.params.id;
73
+ trigger(ref, 'update'); // should be array of names of values changed...
74
+ return;
75
+ });
76
+ });
77
+
78
+ /* Delete object */
79
+ app.delete('/api/:collection/:id', function (req, res) {
80
+ var collection = db.collection(req.params.collection);
81
+ collection.remove({ _id: req.params.id }, function(err, data){
82
+ if(err || !data) { stderr(err); res.status(500).end(); return; }
83
+ res.status(200).end();
84
+ });
85
+ var ref = req.params.collection;
86
+ trigger(ref, 'update'); // should be array of names of values changed...
87
+ });
88
+
89
+ /* Create public shared object */
90
+ app.post('/api/:collection/:id/public', function (req, res) {
91
+
92
+ var publicId = uuid.v4();
93
+ var object = {
94
+ _id: publicId,
95
+ collection: req.params.collection,
96
+ id: req.params.id
97
+ }
98
+
99
+ var collection = db.collection('public');
100
+ collection.insert(object, function(err, data){
101
+ if(err || !data) { stderr(err); res.status(500).end(); return; }
102
+ res.status(200).send(publicId);
103
+ return;
104
+ });
105
+
106
+ });
107
+
108
+ /* Delete public shared object */
109
+ app.delete('/api/:collection/:id/public', function (req, res) {
110
+ var collection = db.collection('public');
111
+ collection.remove({ id: req.params.id, collection: req.params.collection }, function(err, data){
112
+ if(err || !data) { stderr(err); res.status(500).end(); return; }
113
+ res.status(200).end();
114
+ });
115
+ });
116
+
117
+
118
+ };
pool/shard000/JavaScript/0003880_MainMenu.js ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ TubyFlaps.MainMenu = function (game) {
3
+ this.game = game;
4
+ };
5
+
6
+ TubyFlaps.MainMenu.prototype = {
7
+ create: function () {
8
+
9
+ this.game.highscore = (this.game.score > this.game.highscore) ? this.game.score : this.game.highscore;
10
+ this.city = this.game.add.tileSprite(0, this.game.world.height-188, this.game.world.width, 140, 'city');
11
+
12
+ this.tubes = this.game.add.group();
13
+ this.tubey = new Tube('2', this.game, this.tubes);
14
+
15
+ var text = "Pres UP to play!\n\nHighscore: " + this.game.highscore;
16
+ this.game.stage.backgroundColor = '#AFD8FA';
17
+ this.text = game.add.text(this.game.world.width/2, this.game.world.height/2 + 15, text, {
18
+ font: "28px Arial",
19
+ fill: "#000000",
20
+ align: "center"
21
+ });
22
+
23
+ this.keylocked = true;
24
+ this.text.anchor.setTo(0.5, 0.5);
25
+
26
+ var logo = this.game.add.sprite(this.game.world.width/2, 75, 'logo');
27
+ logo.scale.y = 0.75;
28
+ logo.scale.x = 0.75;
29
+ logo.anchor.setTo(0.5, 0.5);
30
+
31
+ this.land = this.game.add.tileSprite(0, this.game.world.height-48, this.game.world.width, 48, 'ground');
32
+
33
+ },
34
+
35
+ update: function () {
36
+ if(!this.keylocked &&
37
+ (this.game.input.keyboard.isDown(Phaser.Keyboard.UP) ||
38
+ this.game.input.pointer1.isDown ||
39
+ this.game.input.mousePointer.isDown)
40
+ ) {
41
+ this.startGame();
42
+ }
43
+
44
+ if (this.game.input.keyboard.downDuration(Phaser.Keyboard.UP, 3000) || this.game.input.pointer1.isUp || this.game.input.mousePointer.isUp) {
45
+ this.keylocked = false;
46
+ }
47
+
48
+ this.tubey.update();
49
+
50
+ if (!this.tubey.isAlive) {
51
+ this.tubey.up(-700);
52
+ this.tubey.isAlive = true;
53
+ }
54
+
55
+ this.land.tilePosition.x -= 2.5;
56
+ this.city.tilePosition.x -= 0.75;
57
+ },
58
+
59
+ startGame: function (pointer) {
60
+ //this.music.stop();
61
+ this.game.state.start('Game');
62
+ }
63
+ };
pool/shard000/JavaScript/0003881_entryActions.js ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react'
2
+ import { push } from 'react-router-redux'
3
+ import graphFetcher from 'utils/graphFetcher'
4
+ import formatFields from 'utils/formatFields'
5
+ import { getSlugFromId } from 'utils/helpers'
6
+ import { newToast, errorToasts } from './uiActions'
7
+
8
+ export const REQUEST_ENTRIES = 'REQUEST_ENTRIES'
9
+ export const RECEIVE_ENTRIES = 'RECEIVE_ENTRIES'
10
+ export const NEW_ENTRY = 'NEW_ENTRY'
11
+ export const UPDATE_ENTRY = 'UPDATE_ENTRY'
12
+ export const DELETE_ENTRY = 'DELETE_ENTRY'
13
+ export const ENTRY_DETAILS = 'ENTRY_DETAILS'
14
+
15
+ /**
16
+ * Creates a new Entry
17
+ * @param {string} title
18
+ * @param {string} section
19
+ * @param {string} status
20
+ * @param {string} dateCreated
21
+ * @param {object} rawOptions
22
+ */
23
+ export function newEntry (title, section, status, dateCreated, rawOptions) {
24
+ return async (dispatch, getState) => {
25
+ const { fields, sections, user } = getState()
26
+ const options = await formatFields(rawOptions, fields.fields)
27
+
28
+ const query = `mutation ($data: EntriesInput!) {
29
+ addEntry(data: $data) {
30
+ _id
31
+ title
32
+ slug
33
+ status
34
+ fields {
35
+ fieldId
36
+ handle
37
+ value
38
+ }
39
+ section
40
+ author {
41
+ username
42
+ }
43
+ dateCreated
44
+ }
45
+ }`
46
+
47
+ const variables = {
48
+ data: {
49
+ title,
50
+ section,
51
+ status,
52
+ dateCreated,
53
+ fields: options,
54
+ author: user._id
55
+ }
56
+ }
57
+
58
+ return graphFetcher(query, variables)
59
+ .then((json) => {
60
+ const { addEntry } = json.data.data
61
+
62
+ dispatch({ type: NEW_ENTRY, addEntry })
63
+ dispatch(newToast({
64
+ message: <span><b>{addEntry.title}</b> has been created!</span>,
65
+ style: 'success'
66
+ }))
67
+ const sectionSlug = getSlugFromId(sections.sections, addEntry.section)
68
+ dispatch(push(`/entries/${sectionSlug}/${addEntry._id}`))
69
+ })
70
+ .catch(errorToasts)
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Saves updates of an existing Entry
76
+ * @param {string} _id
77
+ * @param {object} data
78
+ */
79
+ export function updateEntry (_id, data) {
80
+ return async (dispatch, getState) => {
81
+ const state = getState()
82
+ const { title, status, dateCreated, ...fields } = data
83
+ const options = await formatFields(fields, state.fields.fields)
84
+
85
+ const query = `mutation ($_id: ID!, $data: EntriesInput!) {
86
+ updateEntry(_id: $_id, data: $data) {
87
+ _id
88
+ title
89
+ status
90
+ fields {
91
+ fieldId
92
+ handle
93
+ value
94
+ }
95
+ }
96
+ }`
97
+
98
+ const variables = {
99
+ _id,
100
+ data: {
101
+ title,
102
+ status,
103
+ dateCreated,
104
+ fields: options
105
+ }
106
+ }
107
+
108
+ return graphFetcher(query, variables)
109
+ .then((json) => {
110
+ const updatedEntry = json.data.data.updateEntry
111
+ dispatch({ type: UPDATE_ENTRY, updateEntry: updatedEntry })
112
+ dispatch(newToast({
113
+ message: <span><b>{updatedEntry.title}</b> has been updated!</span>,
114
+ style: 'success'
115
+ }))
116
+ })
117
+ .catch(errorToasts)
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Posts to GraphQL to delete an Entry
123
+ * @param {string} _id
124
+ * @param {boolean} [redirect=false] - Redirect to the entries page after deleting the entry
125
+ */
126
+ export function deleteEntry (_id, redirect = false) {
127
+ return (dispatch) => {
128
+ const query = `mutation ($_id:ID!) {
129
+ removeEntry(_id: $_id) {
130
+ _id
131
+ title
132
+ }
133
+ }`
134
+
135
+ return graphFetcher(query, { _id })
136
+ .then((json) => {
137
+ const { removeEntry } = json.data.data
138
+ if (redirect) dispatch(push('/entries'))
139
+ dispatch({ type: DELETE_ENTRY, id: removeEntry._id })
140
+ dispatch(newToast({
141
+ message: <span><b>{removeEntry.title}</b> has been deleted.</span>,
142
+ style: 'success'
143
+ }))
144
+ })
145
+ .catch(errorToasts)
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Gets the details (fields object) of an Entry
151
+ * @param {string} _id - Mongo ID of Entry.
152
+ */
153
+ export function entryDetails (_id) {
154
+ return (dispatch) => {
155
+ const query = `query ($_id:ID!) {
156
+ entry (_id: $_id) {
157
+ fields {
158
+ fieldId
159
+ handle
160
+ value
161
+ }
162
+ }
163
+ }`
164
+
165
+ return graphFetcher(query, { _id })
166
+ .then((json) => {
167
+ const { entry } = json.data.data
168
+ dispatch({ type: UPDATE_ENTRY, updateEntry: { _id, ...entry } })
169
+ })
170
+ .catch(errorToasts)
171
+ }
172
+ }
pool/shard000/JavaScript/0003883_minifier.js ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var fs = require('fs');
2
+ var path = require('path');
3
+ var fileutil = require('fileutil');
4
+ var minifier = require('../lib/minifier');
5
+
6
+ describe('minifier is a minifier tool for frontend dev', function(){
7
+
8
+
9
+ it("REGEXP_BACKGROUND should match background", function(){
10
+ var regexp = minifier.REGEXP_BACKGROUND;
11
+ var cases = [
12
+ 'button{background:url(icon.png)}',
13
+ 'button(background:url("icon.png")}',
14
+ 'button(background:url(\'icon.png\')}',
15
+ 'button{background: url ( icon.png ) }',
16
+ 'button(background: url ( "icon.png" ) }',
17
+ 'button(background: url ( \'icon.png\' ) }',
18
+ 'button{background: url ( icon.png ); }',
19
+ 'button(background: url ( "icon.png" ); }',
20
+ 'button(background: url ( \'icon.png\' ); }',
21
+ 'button{background: url ( assets/icon.png ) }',
22
+ 'button(background: url ( "assets/icon.png" ) }',
23
+ 'button(background: url ( \'assets/icon.png\' ) }',
24
+ 'button(background: url ( \'icon.png\' ); }',
25
+ 'button{background-image: url ( assets/icon.png ) }',
26
+ 'button(background-image: url ( "assets/icon.png" ) }',
27
+ 'button(-webkit-background-image: url ( \'assets/icon.png\' ) }',
28
+ '.cursor{cursor: url ( assets/icon.cur ) }',
29
+ '.cursor(cursor: url ( "assets/icon.cur" ) }',
30
+ '.cursor(bcursor: url ( \'assets/icon.cur\' ) }',
31
+ '.canvas{background-image: url(url.png), url(two.png)}',
32
+ '.canvas{background-image: url(one.png), url(two.png);}',
33
+ '.canvas{background: url(one.png) center bottom no-repeat, url(two.png) left top no-repeat;}',
34
+ '.canvas{color:#fff;background: url(one.png) center bottom no-repeat, url(two.png) left top no-repeat}',
35
+ '.add{background: url(../../img/add.png) no-repeat 0 50%;}',
36
+ '.image{background: #00FF00 url(bgimage.gif) no-repeat fixed top;}',
37
+ '.list .new::after{content: url(../../img/hot.png);}'
38
+ ];
39
+
40
+ cases.forEach(function(item){
41
+ var matches = item.match(regexp);
42
+ matches.should.be.ok;
43
+ });
44
+
45
+ cases = [
46
+ 'button{background:url(data:image/png;base64,iVB==);}',
47
+ 'button{background:url( data:image/png;base64,iVB==) }',
48
+ '.list .new::after{background: url(data:image/png;base64,iVB==);}'
49
+ ]
50
+
51
+ cases.forEach(function(item){
52
+ var matches = item.match(regexp) == null;
53
+ matches.should.be.true;
54
+ });
55
+ });
56
+
57
+ it("REGEXP_IMAGE should match URL", function(){
58
+ var regexp = minifier.REGEXP_IMAGE;
59
+ var cases = [
60
+ 'button{background:url(icon.png)}',
61
+ 'button(background:url("icon.png")}',
62
+ 'button(background:url(\'icon.png\')}',
63
+ 'button{background: url ( icon.png ) }',
64
+ 'button(background: url ( "icon.png" ) }',
65
+ 'button(background: url ( \'icon.png\' ) }',
66
+ 'button{background: url ( icon.png ); }',
67
+ 'button(background: url ( "icon.png" ); }',
68
+ 'button(background: url ( \'icon.png\' ); }',
69
+ 'button{background: url ( assets/icon.png ) }',
70
+ 'button(background: url ( "assets/icon.png" ) }',
71
+ 'button(background: url ( \'assets/icon.png\' ) }',
72
+ 'button(background: url ( \'icon.png\' ); }',
73
+ 'button{background-image: url ( assets/icon.png ) }',
74
+ 'button(background-image: url ( "assets/icon.png" ) }',
75
+ 'button(-webkit-background-image: url ( \'assets/icon.png\' ) }',
76
+ '.cursor{cursor: url ( assets/icon.cur ) }',
77
+ '.cursor(cursor: url ( "assets/icon.cur" ) }',
78
+ '.cursor(bcursor: url ( \'assets/icon.cur\' ) }',
79
+ '.canvas{background-image: url(url.png), url(two.png)}',
80
+ '.canvas{background-image: url(one.png), url(two.png);}',
81
+ '.canvas{background: url(one.png) center bottom no-repeat, url(two.png) left top no-repeat;}',
82
+ '.canvas{color:#fff;background: url(one.png) center bottom no-repeat, url(two.png) left top no-repeat}',
83
+ '.add{background: url(../../img/add.png) no-repeat 0 50%;}',
84
+ '.image{background: #00FF00 url(bgimage.gif) no-repeat fixed top;}',
85
+ '.list .new::after{content: url(../../img/hot.png);}'
86
+ ];
87
+
88
+ cases.forEach(function(item){
89
+ var matches = item.match(regexp);
90
+ matches.should.be.ok;
91
+ });
92
+ });
93
+
94
+ it('minifyJS should minify js content', function(){
95
+ var content = fileutil.read(__dirname + "/test.js");
96
+
97
+ //默认压缩,去log,保留版权信息
98
+ var m_content = minifier.minifyJS(content);
99
+ var noConsole = m_content.match(/console/) == null;
100
+
101
+ noConsole.should.be.ok;
102
+
103
+ noConsole = m_content.match(/\/\*![.\s\S]+\*\//) != null;
104
+ noConsole.should.be.ok;
105
+
106
+ //设置保留log
107
+ m_content = minifier.minifyJS(content, {remove:[]});
108
+ noConsole = m_content.match(/console/) != null;
109
+ noConsole.should.be.ok;
110
+
111
+ //设置去除版权信息
112
+ m_content = minifier.minifyJS(content, {copyright:false});
113
+ noConsole = m_content.match(/\/\*![^(\*\/)]+\*\//) == null;
114
+ noConsole.should.be.ok;
115
+
116
+ });
117
+
118
+
119
+ it('minifyJS can custom banner & footer', function(){
120
+ var content = 'var a=1;';
121
+ var banner = 'define(function(require, exports, module){';
122
+ var footer = '});';
123
+ var realJS = minifier.minifyJS(content, {banner:banner, footer: footer});
124
+ var hasBanner = realJS.indexOf(banner) >= -1;
125
+ hasBanner.should.be.true;
126
+ var hasFooter = realJS.indexOf(footer) >= -1;
127
+ hasFooter.should.be.true;
128
+ });
129
+
130
+ it('minifyJS should keep the exports, define, require, $ keyword reserved.', function(){
131
+ var content = fileutil.read(__dirname + "/test.js");
132
+
133
+ //默认保留define, exports, require, $
134
+ var m_content = minifier.minifyJS(content);
135
+
136
+ var matched = m_content.match(/exports/) != null;
137
+ matched.should.be.ok;
138
+
139
+ matched = m_content.match(/define/) != null;
140
+ matched.should.be.ok;
141
+
142
+ matched = m_content.match(/require/) != null;
143
+ matched.should.be.ok;
144
+
145
+ matched = m_content.match(/exports/) != null;
146
+ matched.should.be.ok;
147
+
148
+ matched = m_content.match(/\$/) != null;
149
+ matched.should.be.ok;
150
+
151
+ m_content = minifier.minifyJS(content);
152
+ });
153
+
154
+ it('minifyJSON should minify json text', function(){
155
+ var content = '{"a": "b", "c": \n [1, 2, 3]}';
156
+ var exceptContent = '{"a":"b","c":[1,2,3]}';
157
+ var realContent = minifier.minifyJSON(content);
158
+ (realContent == exceptContent).should.be.true;
159
+ });
160
+
161
+ it("datauri should convert the image to Base64 in css files", function(){
162
+ var file = __dirname + "/test.css";
163
+ var content = minifier.datauri(fileutil.read(file), {
164
+ input: file
165
+ });
166
+ var match = content.match(/url\(\"data:.+;base64,(.+)\"\);/);
167
+ match[1].should.be.ok;
168
+ var base64 = fs.readFileSync(__dirname + "/m.gif").toString('base64');
169
+ base64.should.be.equal(match[1]);
170
+ });
171
+
172
+ it("optimage should optimize jpg locally", function(done){
173
+ var input = __dirname + "/test.jpg";
174
+ var output = __dirname + "/test.min.jpg";
175
+ minifier.optimage(input, output, function(err, data){
176
+ fileutil.delete(output);
177
+ data.should.be.a('object');
178
+ (data.saved > 0).should.be.ok;
179
+ done();
180
+ });
181
+ });
182
+
183
+ xit("optimage should optimize png locally", function(done){
184
+ var input = __dirname + "/test.png";
185
+ var output = __dirname + "/test.min.png";
186
+ minifier.optimage(input, output, function(err, data){
187
+ fileutil.delete(output);
188
+ data.should.be.a('object');
189
+ (data.saved > 0).should.be.ok;
190
+ done();
191
+ });
192
+ });
193
+
194
+ it("optimage should optimize gif locally", function(done){
195
+ var input = __dirname + "/test.gif";
196
+ var output = __dirname + "/test.min.gif";
197
+ minifier.optimage(input, output, function(err, data){
198
+ fileutil.delete(output);
199
+ data.should.be.a('object');
200
+ (data.saved > 0).should.be.ok;
201
+ done();
202
+ });
203
+ });
204
+
205
+ xit("smushit should optimize image by cloud server", function(done){
206
+ var input = __dirname + "/test.jpg";
207
+ var output = __dirname + "/test.min.jpg";
208
+ minifier.smushit(input, output, function(err, data){
209
+ fileutil.delete(output);
210
+ data.should.be.a('object');
211
+ (data.saved >= 0).should.be.ok;
212
+ done();
213
+ });
214
+ });
215
+
216
+ it("minifyImage should optimize image, first by local manner, if error, then by cloud manner", function(done){
217
+ var input = __dirname + "/test.jpg";
218
+ var output = __dirname + "/test.min.jpg";
219
+ minifier.minifyImage(input, output, function(err, data){
220
+ fileutil.delete(output);
221
+ data.should.be.a('object');
222
+ (data.saved >= 0).should.be.ok;
223
+ done()
224
+ });
225
+ });
226
+ });
pool/shard000/JavaScript/0003888_control-message.js ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // vendor
2
+ import without from 'lodash.without'
3
+ import findKey from 'lodash.findkey'
4
+ import indexOf from 'lodash.indexof'
5
+
6
+ // modules
7
+ import { isEqual } from './utilities'
8
+ import { input_channel_params, main_output_bus_params, misc_params } from './kmix-control-messages'
9
+
10
+ let messages = [input_channel_params, main_output_bus_params, misc_params];
11
+
12
+ function findControl(value, eventType, bank, options){
13
+ return findKey(options, function(o) {
14
+ return findIndex(eventType, o.type) != -1 && isEqual(o[bank], value);
15
+ });
16
+ }
17
+
18
+ function findIndex(value, array){
19
+ return indexOf(array, value);
20
+ }
21
+
22
+ function findBank(banks, channel, options){
23
+ return banks[indexOf(options['midi-channels'], channel + 1)];
24
+ }
25
+
26
+ function getControlType(control){
27
+ let controlType = '', controlSplit = ''
28
+ // raw, raw-control, control, input, main, misc, preset
29
+ if(Array.isArray(control)){ // raw
30
+ controlType = 'raw'
31
+ } else {
32
+ controlSplit = control.split(':')
33
+ if(control === 'control'){ // raw-control
34
+ controlType = 'raw-control'
35
+ } else if(controlSplit[0] === 'control'){ // control
36
+ controlType = 'control'
37
+ } else if(control === 'expander'){ // raw-expander
38
+ controlType = 'raw-expander'
39
+ } else if(controlSplit[0] === 'expander'){ // expander
40
+ controlType = 'expander'
41
+ } else if(!isNaN(controlSplit[1])){ // input
42
+ controlType = 'input'
43
+ } else { // main, misc, preset
44
+ controlType = controlSplit[0]
45
+ }
46
+ }
47
+
48
+ return controlType
49
+ }
50
+
51
+ function controlMessage(control, value, messageType = 'input'){
52
+ let messageTypes = ['input', 'main', 'misc', 'preset'],
53
+ channelTypes = [1, 9, 10, 1],
54
+ controlSplit = control.split(':'),
55
+ controlName,
56
+ inputChannel,
57
+ type, cc;
58
+
59
+ if(messageType === 'input'){
60
+ controlName = controlSplit[0]
61
+ inputChannel = +controlSplit[1]
62
+ } else {
63
+ controlName = controlSplit[1]
64
+ }
65
+
66
+ if(control === 'preset'.toLowerCase()){
67
+ type = 192
68
+ cc = null
69
+ messageType = 'preset'
70
+ } else {
71
+ type = 176
72
+ cc = messages[messageTypes.indexOf(messageType)][controlName];
73
+ }
74
+
75
+ let channel = (messageType === 'input') ? inputChannel : channelTypes[messageTypes.indexOf(messageType)];
76
+
77
+ type = type + channel - 1;
78
+
79
+ let message = [type, cc, value];
80
+
81
+ return without(message, undefined, null);
82
+ }
83
+
84
+ export {
85
+ controlMessage,
86
+ findControl,
87
+ getControlType,
88
+ findBank,
89
+ messages
90
+ }
pool/shard000/JavaScript/0003889_number-display.js ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ ## Number Display Widget
3
+
4
+ Includes: [Base Mixin](#base-mixin)
5
+
6
+ A display of a single numeric value.
7
+
8
+ Examples:
9
+
10
+ * [Test Example](http://dc-js.github.io/dc.js/examples/number.html)
11
+
12
+ #### dc.numberDisplay(parent[, chartGroup])
13
+ Create a Number Display instance and attach it to the given parent element.
14
+
15
+ Unlike other charts, you do not need to set a dimension. Instead a group object must be provided and
16
+ a valueAccessor that returns a single value.
17
+
18
+ Parameters:
19
+
20
+ * parent : string | node | selection - any valid
21
+ [d3 single selector](https://github.com/mbostock/d3/wiki/Selections#selecting-elements) specifying
22
+ a dom block element such as a div; or a dom element or d3 selection.
23
+ * chartGroup : string (optional) - name of the chart group this chart instance should be placed in.
24
+ The number display widget will only react to filter changes in the chart group.
25
+
26
+ Returns:
27
+ A newly created number display instance
28
+
29
+ ```js
30
+ // create a number display under #chart-container1 element using the default global chart group
31
+ var display1 = dc.numberDisplay("#chart-container1");
32
+ ```
33
+
34
+ **/
35
+ dc.numberDisplay = function (parent, chartGroup) {
36
+ var SPAN_CLASS = 'number-display';
37
+ var _formatNumber = d3.format(".2s");
38
+ var _chart = dc.baseMixin({});
39
+ var _html = {one:"",some:"",none:""};
40
+
41
+ // dimension not required
42
+ _chart._mandatoryAttributes(['group']);
43
+
44
+ /**
45
+ #### .html([object])
46
+ Gets or sets an optional object specifying HTML templates to use depending on the number
47
+ displayed. The text `%number` will be replaced with the current value.
48
+ - one: HTML template to use if the number is 1
49
+ - zero: HTML template to use if the number is 0
50
+ - some: HTML template to use otherwise
51
+
52
+ ```js
53
+ numberWidget.html({
54
+ one:"%number record",
55
+ some:"%number records",
56
+ none:"no records"})
57
+ ```
58
+ **/
59
+
60
+ _chart.html = function(s) {
61
+ if (!arguments.length) return _html;
62
+ if(s.none)
63
+ _html.none = s.none;//if none available
64
+ else if(s.one)
65
+ _html.none = s.one;//if none not available use one
66
+ else if(s.some)
67
+ _html.none = s.some;//if none and one not available use some
68
+ if(s.one)
69
+ _html.one = s.one;//if one available
70
+ else if(s.some)
71
+ _html.one = s.some;//if one not available use some
72
+ if(s.some)
73
+ _html.some = s.some;//if some available
74
+ else if(s.one)
75
+ _html.some = s.one;//if some not available use one
76
+ return _chart;
77
+ };
78
+
79
+ /**
80
+ #### .value()
81
+ Calculate and return the underlying value of the display
82
+ **/
83
+
84
+ _chart.value = function () {
85
+ return _chart.data();
86
+ };
87
+
88
+ _chart.data(function (group) {
89
+ var valObj = group.value ? group.value() : group.top(1)[0];
90
+ return _chart.valueAccessor()(valObj);
91
+ });
92
+
93
+ _chart.transitionDuration(250); // good default
94
+
95
+ _chart._doRender = function () {
96
+ var newValue = _chart.value(),
97
+ span = _chart.selectAll("."+SPAN_CLASS);
98
+
99
+ if(span.empty())
100
+ span = span.data([0])
101
+ .enter()
102
+ .append("span")
103
+ .attr("class", SPAN_CLASS);
104
+
105
+ span.transition()
106
+ .duration(_chart.transitionDuration())
107
+ .ease('quad-out-in')
108
+ .tween("text", function () {
109
+ var interp = d3.interpolateNumber(this.lastValue || 0, newValue);
110
+ this.lastValue = newValue;
111
+ return function (t) {
112
+ var html = null, num = _chart.formatNumber()(interp(t));
113
+ if(newValue===0 && (_html.none!==""))
114
+ html = _html.none;
115
+ else if(newValue===1 &&(_html.one!==""))
116
+ html = _html.one;
117
+ else if(_html.some!=="")
118
+ html = _html.some;
119
+ this.innerHTML = html ? html.replace("%number", num) : num;
120
+ };
121
+ });
122
+ };
123
+
124
+ _chart._doRedraw = function(){
125
+ return _chart._doRender();
126
+ };
127
+
128
+ /**
129
+ #### .formatNumber([formatter])
130
+ Get or set a function to format the value for the display. By default `d3.format(".2s");` is used.
131
+
132
+ **/
133
+ _chart.formatNumber = function (_) {
134
+ if (!arguments.length) return _formatNumber;
135
+ _formatNumber = _;
136
+ return _chart;
137
+ };
138
+
139
+ return _chart.anchor(parent, chartGroup);
140
+ };
pool/shard000/JavaScript/0003890_mainline.js ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (c) 2012, Martin Borho.
3
+ * Licensed under the Affero General Public License version 3 or later.
4
+ * See LICENSE for details.
5
+ */
6
+ var Mainline = function(data, combined) {
7
+ this.docs = data.docs;
8
+ this.rendered = data.html;
9
+ this.combined = combined;
10
+ this.expanded = true;
11
+ this.count = 0;
12
+ this.pushed = 0;
13
+ this.container = $('#mainline');
14
+ this.container.unbind("click");
15
+ this.container.click(function(e) {
16
+ var target = $(e.target),
17
+ nextBox = false,
18
+ href = false;
19
+ if(target.is('img')) {
20
+ var parent = target.parent();
21
+ if(parent[0] !== undefined) {
22
+ target = $(parent[0]);
23
+ }
24
+ }
25
+ if(target.is('a') && !target.hasClass('ignore') && !target.attr('onclick')) {
26
+ href = target.attr('href');
27
+ window.open(href, '', '');
28
+ return false;
29
+ }
30
+ // handle the next-click
31
+ if(target.is('#box-next')) {
32
+ nextBox = target;
33
+ } else {
34
+ var parentNext = target.parents("#box-next");
35
+ if(parentNext[0] != undefined) {
36
+ nextBox = $(parentNext[0]);
37
+ }
38
+ }
39
+ if(nextBox) {
40
+ Controller.getNextItems([parseInt(nextBox.attr('data-next-time')), nextBox.attr('data-next-id')]);
41
+ }
42
+ });
43
+ };
44
+
45
+ Mainline.prototype.clear = function() {
46
+ this.container.html('');
47
+ this.showSpinner();
48
+ };
49
+
50
+ Mainline.prototype.addPushed = function() {
51
+ var div = $('#pushedBox');
52
+ if(div.length == 0) {
53
+ this.pushed = 0;
54
+ div = $('<div class="well line-item-more" id="pushedBox">');
55
+ div.click(function(e) {
56
+ var hidden = $('.hidden')
57
+ hidden.removeClass('line-item-more');
58
+ hidden.addClass('line-item');
59
+ hidden.fadeIn();
60
+ hidden.removeClass('hidden');
61
+ $(this).remove();
62
+ $('#delete-button').attr('data-active','true');
63
+ });
64
+ this.container.prepend(div);
65
+ }
66
+ this.pushed++;
67
+ div.html('<h3>+'+this.pushed+' new</h3>');
68
+ div.glow('#97B5FF',500);
69
+ };
70
+
71
+ Mainline.prototype.addDoc = function(doc, pushed) {
72
+ var box = $(doc.html);
73
+ if(this.combined !== true) {
74
+ box.find('.line-source').remove();
75
+ }
76
+ if(!this.expanded && box.hasClass('news')) {
77
+ box.find('.line-body').hide();
78
+ }
79
+ this.count++;
80
+ this.container.prepend(box);
81
+ if(pushed === true) {
82
+ box.addClass('hidden');
83
+ this.addPushed();
84
+ } else {
85
+ box.fadeIn();
86
+ }
87
+ };
88
+
89
+ Mainline.prototype.hideDocs = function(docs) {
90
+ if(docs.length == 1) {
91
+ $('#box-'+docs[0]._id).fadeOut(null, function() {
92
+ $(this).remove()
93
+ });
94
+ } else {
95
+ docs.forEach(function(doc) {
96
+ $('#box-'+doc._id).remove();
97
+ });
98
+ }
99
+ };
100
+
101
+ Mainline.prototype.append = function(data) {
102
+ $('#box-next').remove();
103
+ var newItems = $(data.html);
104
+ if(!this.expanded) {
105
+ newItems.filter('.news').find('.line-body').hide();
106
+ }
107
+ this.container.append(newItems);
108
+ this.count = this.count + data.docs.length;
109
+ };
110
+
111
+ Mainline.prototype.render = function() {
112
+ var max = this.docs.length,
113
+ box = false;
114
+ this.hideSpinner();
115
+ if(this.rendered != undefined) {
116
+ this.count = this.count + max;
117
+ this.container.html(this.rendered);
118
+ }
119
+ };
120
+
121
+ Mainline.prototype.showSpinner = function() {
122
+ this.container.html('<div class="grid-10 line-item well spinning" id="main-spinner">&#160;</div>');
123
+ };
124
+
125
+ Mainline.prototype.hideSpinner = function() {
126
+ $('#main-spinner').remove();
127
+ };
128
+
129
+ Mainline.prototype.showNextSpinner = function() {
130
+ $('#box-next').html('').addClass('spinning');
131
+
132
+ };
133
+
134
+ Mainline.prototype.toggleExpand = function() {
135
+ if(this.expanded) {
136
+ this.container.find('.news .line-body').fadeOut();
137
+ this.expanded = false;
138
+ } else {
139
+ this.container.find('.news .line-body').show();
140
+ this.expanded = true;
141
+ }
142
+ }
143
+
144
+ define('mainline', [], function() {
145
+ return Mainline;
146
+ });
pool/shard000/JavaScript/0003895_allowedHosts.js ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os from 'os';
2
+
3
+ const hosts = new Set();
4
+ const interfaces = os.networkInterfaces();
5
+
6
+ // Add local hosts
7
+ hosts.add( 'localhost' );
8
+ hosts.add( '127.0.0.1' );
9
+ hosts.add( '0.0.0.0' );
10
+ hosts.add( '::1' );
11
+
12
+ Object
13
+ .keys( interfaces )
14
+ .forEach( ( name ) =>
15
+ interfaces[ name ]
16
+ .filter( i => ! i.internal && i.family === 'IPv4' )
17
+ .forEach( i => hosts.add( i.address ) )
18
+ );
19
+
20
+ export default Array.from( hosts );
pool/shard000/JavaScript/0003896_slides.js ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Slides = new Meteor.Collection('slides');
2
+ SlideElements = new Meteor.Collection('slideElements');
3
+
4
+ Meteor.methods({
5
+
6
+ /**
7
+ * Adds a slide to an existing slideshow
8
+ *
9
+ * @param id : the slide's id
10
+ * @param slideshowId : the destination slideshow's id
11
+ * @return :
12
+ */
13
+ addSlideshow: function(id, slideshowId) {
14
+ console.log('addSlideShow');
15
+ },
16
+
17
+ /**
18
+ * Removes a slide from an existing slideshow
19
+ *
20
+ * @param id : the slide's id
21
+ * @param slideshowId : id of the slideshow we want to remove the slide from
22
+ * @return :
23
+ */
24
+ removeSlideshow: function(id, slideshowId) {
25
+ console.log('removeSlideshow');
26
+ },
27
+
28
+ /**
29
+ * Adds a new element to a slide
30
+ *
31
+ * @param id : the slide's id
32
+ * @param element : json object containing the parameters required to create a new element
33
+ * @return :
34
+ */
35
+ addSlideElement: function(id, element) {
36
+ console.log('addSlideElement');
37
+ },
38
+
39
+ /**
40
+ * Removes an element from a slide
41
+ *
42
+ * @param id : the slide's id
43
+ * @param elementId : id of the element we want to remove from the slide
44
+ * @return :
45
+ */
46
+ removeSlideElement: function(id, elementId) {
47
+ console.log('removeSlideElement');
48
+ },
49
+
50
+ /**
51
+ * Updates a slide
52
+ *
53
+ * @param slide : the slide we want to update
54
+ * @return : modified slide's id
55
+ */
56
+ updateSlide: function(slide, edition) {
57
+ console.log('updateSlide');
58
+
59
+ var slideId = slide._id;
60
+
61
+ console.log(slideId);
62
+
63
+ Slides.update(slideId,
64
+ {$set: {
65
+ title: edition.title,
66
+ content: edition.content,
67
+ slug: edition.slug
68
+ }}
69
+ );
70
+
71
+ return slideId;
72
+ },
73
+
74
+ /**
75
+ * Deletes a slide
76
+ *
77
+ * @param id : id of the slide we want to delete
78
+ * @return :
79
+ */
80
+ deleteSlide: function(id) {
81
+ console.log('deleteSlide');
82
+
83
+ Slides.remove({_id: id});
84
+ },
85
+
86
+ /**
87
+ * Increases the position of a slide inside a slideshow
88
+ *
89
+ * @param id : the slide's id
90
+ * @param slideshowId : id of the slideshow the slide belongs to
91
+ * @return : id of the moved slide
92
+ */
93
+ slideUp: function(id, slideshowId) {
94
+ console.log('slideUp');
95
+
96
+ var check = userCheck(slideshowId);
97
+
98
+ if(check == 401) {
99
+ throw new Meteor.Error(401, "You need to login to reorganize slides.");
100
+ } else if(check == 302) {
101
+ throw new Meteor.Error(302, "You can't reorganize the slides of a slideshow you haven't created");
102
+ }
103
+
104
+ var slide = Slides.findOne(id);
105
+
106
+ if(slide.position == 0) {
107
+ throw new Meteor.Error(302, "This slide is already the first in the slideshow");
108
+ } else {
109
+ var newPosition = slide.position - 1;
110
+
111
+ var previousSlide = Slides.findOne({slideshows: slideshowId, position: newPosition})
112
+
113
+ Slides.update({_id: previousSlide._id}, {$set: {position: slide.position}});
114
+ Slides.update({_id: id}, {$set: {position: newPosition}});
115
+
116
+ return slide._id;
117
+ }
118
+ },
119
+
120
+ /**
121
+ * Decreases the position of a slide inside a slideshow
122
+ *
123
+ * @param id : the slide's id
124
+ * @param slideshowId : id of the slideshow the slide belongs to
125
+ * @return : id of the moved slide
126
+ */
127
+ slideDown: function(id, slideshowId) {
128
+ console.log('slideDown');
129
+
130
+ var check = userCheck(slideshowId);
131
+
132
+ if(check == 401) {
133
+ throw new Meteor.Error(401, "You need to login to reorganize slides.");
134
+ } else if(check == 302) {
135
+ throw new Meteor.Error(302, "You can't reorganize the slides of a slideshow you haven't created");
136
+ }
137
+
138
+ var slide = Slides.findOne(id);
139
+ var slideshow = Slideshows.findOne(slideshowId);
140
+
141
+ var newPosition = slide.position + 1;
142
+
143
+ if(newPosition == slideshow.slides.length) {
144
+ throw new Meteor.Error(302, "This slide is already the last in the slideshow");
145
+ } else {
146
+ var nextSlide = Slides.findOne({slideshows: slideshowId, position: newPosition})
147
+
148
+ Slides.update({_id: nextSlide._id}, {$set: {position: slide.position}});
149
+ Slides.update({_id: id}, {$set: {position: newPosition}});
150
+
151
+ return slide._id;
152
+ }
153
+ }
154
+ });
pool/shard000/JavaScript/0003898_xquery_worker.js ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ***** BEGIN LICENSE BLOCK *****
2
+ * Distributed under the BSD license:
3
+ *
4
+ * Copyright (c) 2010, Ajax.org B.V.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ * * Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * * Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ * * Neither the name of Ajax.org B.V. nor the
15
+ * names of its contributors may be used to endorse or promote products
16
+ * derived from this software without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ *
29
+ * ***** END LICENSE BLOCK ***** */
30
+
31
+ define(function(require, exports, module) {
32
+ "use strict";
33
+
34
+ var oop = require("../lib/oop");
35
+ var Mirror = require("../worker/mirror").Mirror;
36
+ var JSONParseTreeHandler = require("./xquery/JSONParseTreeHandler").JSONParseTreeHandler;
37
+ var XQueryParser = require("./xquery/XQueryParser").XQueryParser;
38
+ var SemanticHighlighter = require("./xquery/visitors/SemanticHighlighter").SemanticHighlighter;
39
+
40
+ var XQueryWorker = exports.XQueryWorker = function(sender) {
41
+ Mirror.call(this, sender);
42
+ this.setTimeout(200);
43
+ };
44
+
45
+ oop.inherits(XQueryWorker, Mirror);
46
+
47
+ (function() {
48
+
49
+ this.onUpdate = function() {
50
+ this.sender.emit("start");
51
+ var value = this.doc.getValue();
52
+ var h = new JSONParseTreeHandler(value);
53
+ var parser = new XQueryParser(value, h);
54
+ try {
55
+ parser.parse_XQuery();
56
+ this.sender.emit("ok");
57
+ var ast = h.getParseTree();
58
+ var highlighter = new SemanticHighlighter(ast, value);
59
+ var tokens = highlighter.getTokens();
60
+ this.sender.emit("highlight", { tokens: tokens, lines: highlighter.lines });
61
+ } catch(e) {
62
+ if(e instanceof parser.ParseException) {
63
+ var prefix = value.substring(0, e.getBegin());
64
+ var line = prefix.split("\n").length;
65
+ var column = e.getBegin() - prefix.lastIndexOf("\n");
66
+ var message = parser.getErrorMessage(e);
67
+ this.sender.emit("error", {
68
+ row: line - 1,
69
+ column: column,
70
+ text: message,
71
+ type: "error"
72
+ });
73
+ } else {
74
+ throw e;
75
+ }
76
+ }
77
+ };
78
+
79
+ }).call(XQueryWorker.prototype);
80
+
81
+ });
pool/shard000/JavaScript/0003899_vsync-impl.js ADDED
@@ -0,0 +1,481 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2015 The AMP HTML Authors. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS-IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {Deferred} from '../utils/promise';
18
+ import {JankMeter} from './jank-meter';
19
+ import {Pass} from '../pass';
20
+ import {Services} from '../services';
21
+ import {cancellation} from '../error';
22
+ import {dev, rethrowAsync} from '../log';
23
+ import {getService, registerServiceBuilder} from '../service';
24
+ import {installTimerService} from './timer-impl';
25
+
26
+ /** @const {time} */
27
+ const FRAME_TIME = 16;
28
+
29
+ /**
30
+ * @typedef {!Object<string, *>}
31
+ */
32
+ let VsyncStateDef;
33
+
34
+ /**
35
+ * @typedef {{
36
+ * measure: (function(!VsyncStateDef)|undefined),
37
+ * mutate: (function(!VsyncStateDef)|undefined)
38
+ * }}
39
+ */
40
+ let VsyncTaskSpecDef;
41
+
42
+
43
+ /**
44
+ * Abstraction over requestAnimationFrame (rAF) that batches DOM read (measure)
45
+ * and write (mutate) tasks in a single frame, to eliminate layout thrashing.
46
+ *
47
+ * NOTE: If the document is invisible due to prerendering (this includes
48
+ * application-level prerendering where the doc is rendered in a hidden
49
+ * iframe or webview), then no frame will be scheduled.
50
+ * @package Visible for type.
51
+ */
52
+ export class Vsync {
53
+
54
+ /**
55
+ * @param {!Window} win
56
+ */
57
+ constructor(win) {
58
+ /** @const {!Window} */
59
+ this.win = win;
60
+
61
+ /** @private @const {!./ampdoc-impl.AmpDocService} */
62
+ this.ampdocService_ = Services.ampdocServiceFor(this.win);
63
+
64
+ /** @private @const {!./document-state.DocumentState} */
65
+ this.docState_ = Services.documentStateFor(this.win);
66
+
67
+ /** @private @const {function(function())} */
68
+ this.raf_ = this.getRaf_();
69
+
70
+ /**
71
+ * Tasks to run in the next frame.
72
+ * @private {!Array<!VsyncTaskSpecDef>}
73
+ */
74
+ this.tasks_ = [];
75
+
76
+ /**
77
+ * Double buffer for tasks.
78
+ * @private {!Array<!VsyncTaskSpecDef>}
79
+ */
80
+ this.nextTasks_ = [];
81
+
82
+ /**
83
+ * States for tasks in the next frame in the same order.
84
+ * @private {!Array<!VsyncStateDef>}
85
+ */
86
+ this.states_ = [];
87
+
88
+ /**
89
+ * Double buffer for states.
90
+ * @private {!Array<!VsyncStateDef>}
91
+ */
92
+ this.nextStates_ = [];
93
+
94
+ /**
95
+ * Whether a new animation frame has been scheduled.
96
+ * @private {boolean}
97
+ */
98
+ this.scheduled_ = false;
99
+
100
+ /** @private {?Promise} */
101
+ this.nextFramePromise_ = null;
102
+
103
+ /** @private {?function()} */
104
+ this.nextFrameResolver_ = null;
105
+
106
+ /** @const {!Function} */
107
+ this.boundRunScheduledTasks_ = this.runScheduledTasks_.bind(this);
108
+
109
+ /**
110
+ * If the doc is invisible we use this instead of rAF because rAF
111
+ * does not run in that scenario.
112
+ * However, we only do this for non-animation tasks as running
113
+ * animations doesn't make sense when not visible.
114
+ * @const {!Pass}
115
+ */
116
+ this.invisiblePass_ = new Pass(this.win, this.boundRunScheduledTasks_,
117
+ FRAME_TIME);
118
+
119
+ /**
120
+ * Similar to this.invisiblePass_, but backing up a real rAF call. If we
121
+ * somehow failed to know that we are throttled we use a timer (which
122
+ * may also be throttled but at least runs eventually) to make sure
123
+ * we continue to get work done.
124
+ * @const {!Pass}
125
+ */
126
+ this.backupPass_ = new Pass(this.win, this.boundRunScheduledTasks_,
127
+ // We cancel this when rAF fires and really only want it to fire
128
+ // if rAF doesn't work at all.
129
+ FRAME_TIME * 2.5);
130
+
131
+ /** @private {?./viewer-impl.Viewer} */
132
+ this.singleDocViewer_ = null;
133
+
134
+ // When the document changes visibility, vsync has to reschedule the queue
135
+ // processing.
136
+ const boundOnVisibilityChanged = this.onVisibilityChanged_.bind(this);
137
+ if (this.ampdocService_.isSingleDoc()) {
138
+ // In a single-doc mode, the visibility of the doc == global visibility.
139
+ // Thus, it's more efficient to only listen to it once.
140
+ Services.viewerPromiseForDoc(this.ampdocService_.getAmpDoc())
141
+ .then(viewer => {
142
+ this.singleDocViewer_ = viewer;
143
+ viewer.onVisibilityChanged(boundOnVisibilityChanged);
144
+ });
145
+ } else {
146
+ // In multi-doc mode, we track separately the global visibility and
147
+ // per-doc visibility when necessary.
148
+ this.docState_.onVisibilityChanged(boundOnVisibilityChanged);
149
+ }
150
+
151
+ /** @private {!JankMeter} */
152
+ this.jankMeter_ = new JankMeter(this.win);
153
+ }
154
+
155
+ /** @private */
156
+ onVisibilityChanged_() {
157
+ if (this.scheduled_) {
158
+ this.forceSchedule_();
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Runs vsync task: measure followed by mutate.
164
+ *
165
+ * If state is not provided, the value passed to the measure and mutate
166
+ * will be undefined.
167
+ *
168
+ * @param {!VsyncTaskSpecDef} task
169
+ * @param {!VsyncStateDef=} opt_state
170
+ */
171
+ run(task, opt_state) {
172
+ this.tasks_.push(task);
173
+ this.states_.push(opt_state || undefined);
174
+ this.schedule_();
175
+ }
176
+
177
+ /**
178
+ * Runs vsync task: measure followed by mutate. Returns the promise that
179
+ * will be resolved as soon as the task has been completed.
180
+ *
181
+ * If state is not provided, the value passed to the measure and mutate
182
+ * will be undefined.
183
+ *
184
+ * @param {!VsyncTaskSpecDef} task
185
+ * @param {!VsyncStateDef=} opt_state
186
+ * @return {!Promise}
187
+ */
188
+ runPromise(task, opt_state) {
189
+ this.run(task, opt_state);
190
+ if (this.nextFramePromise_) {
191
+ return this.nextFramePromise_;
192
+ }
193
+ const deferred = new Deferred();
194
+ this.nextFrameResolver_ = deferred.resolve;
195
+ return this.nextFramePromise_ = deferred.promise;
196
+ }
197
+
198
+ /**
199
+ * Creates a function that will call {@link run} method.
200
+ * @param {!VsyncTaskSpecDef} task
201
+ * @return {function(!VsyncStateDef=)}
202
+ */
203
+ createTask(task) {
204
+ return /** @type {function(!VsyncStateDef=)} */ (opt_state => {
205
+ this.run(task, opt_state);
206
+ });
207
+ }
208
+
209
+ /**
210
+ * Runs the mutate operation via vsync.
211
+ * @param {function()} mutator
212
+ */
213
+ mutate(mutator) {
214
+ this.run({
215
+ measure: undefined, // For uniform hidden class.
216
+ mutate: mutator,
217
+ });
218
+ }
219
+
220
+ /**
221
+ * Runs `mutate` wrapped in a promise.
222
+ * @param {function()} mutator
223
+ * @return {!Promise}
224
+ */
225
+ mutatePromise(mutator) {
226
+ return this.runPromise({
227
+ measure: undefined,
228
+ mutate: mutator,
229
+ });
230
+ }
231
+
232
+ /**
233
+ * Runs the measure operation via vsync.
234
+ * @param {function()} measurer
235
+ */
236
+ measure(measurer) {
237
+ this.run({
238
+ measure: measurer,
239
+ mutate: undefined, // For uniform hidden class.
240
+ });
241
+ }
242
+
243
+ /**
244
+ * Runs `measure` wrapped in a promise.
245
+ * @param {function():TYPE} measurer
246
+ * @return {!Promise<TYPE>}
247
+ * @template TYPE
248
+ */
249
+ measurePromise(measurer) {
250
+ return new Promise(resolve => {
251
+ this.measure(() => {
252
+ resolve(measurer());
253
+ });
254
+ });
255
+ }
256
+
257
+ /**
258
+ * Whether the runtime is allowed to animate at this time.
259
+ * @param {!Node} contextNode
260
+ * @return {boolean}
261
+ */
262
+ canAnimate(contextNode) {
263
+ return this.canAnimate_(dev().assert(contextNode));
264
+ }
265
+
266
+ /**
267
+ * @param {!Node=} opt_contextNode
268
+ * @return {boolean}
269
+ * @private
270
+ */
271
+ canAnimate_(opt_contextNode) {
272
+ // Window level: animations allowed only when global window is visible.
273
+ if (this.docState_.isHidden()) {
274
+ return false;
275
+ }
276
+
277
+ // Single doc: animations allowed when single doc is visible.
278
+ if (this.singleDocViewer_) {
279
+ return this.singleDocViewer_.isVisible();
280
+ }
281
+
282
+ // Multi-doc: animations depend on the state of the relevant doc.
283
+ if (opt_contextNode) {
284
+ const ampdoc = this.ampdocService_.getAmpDoc(opt_contextNode);
285
+ return Services.viewerForDoc(ampdoc).isVisible();
286
+ }
287
+
288
+ return true;
289
+ }
290
+
291
+ /**
292
+ * Runs the animation vsync task. This operation can only run when animations
293
+ * are allowed. Otherwise, this method returns `false` and exits.
294
+ * @param {!Node} contextNode
295
+ * @param {!VsyncTaskSpecDef} task
296
+ * @param {!VsyncStateDef=} opt_state
297
+ * @return {boolean}
298
+ */
299
+ runAnim(contextNode, task, opt_state) {
300
+ // Do not request animation frames when the document is not visible.
301
+ if (!this.canAnimate_(contextNode)) {
302
+ dev().warn('VSYNC', 'Did not schedule a vsync request, because' +
303
+ ' document was invisible');
304
+ return false;
305
+ }
306
+ this.run(task, opt_state);
307
+ return true;
308
+ }
309
+
310
+ /**
311
+ * Creates an animation vsync task. This operation can only run when
312
+ * animations are allowed. Otherwise, this closure returns `false` and exits.
313
+ * @param {!Node} contextNode
314
+ * @param {!VsyncTaskSpecDef} task
315
+ * @return {function(!VsyncStateDef=):boolean}
316
+ */
317
+ createAnimTask(contextNode, task) {
318
+ return /** @type {function(!VsyncStateDef=):boolean} */ (
319
+ opt_state => {
320
+ return this.runAnim(contextNode, task, opt_state);
321
+ });
322
+ }
323
+
324
+ /**
325
+ * Runs the series of mutates until the mutator returns a false value.
326
+ * @param {!Node} contextNode
327
+ * @param {function(time, time, !VsyncStateDef):boolean} mutator The
328
+ * mutator callback. Only expected to do DOM writes, not reads. If the
329
+ * returned value is true, the vsync task will be repeated, otherwise it
330
+ * will be completed. The arguments are: timeSinceStart:time,
331
+ * timeSincePrev:time and state:VsyncStateDef.
332
+ * @param {number=} opt_timeout Optional timeout that will force the series
333
+ * to complete and reject the promise.
334
+ * @return {!Promise} Returns the promise that will either resolve on when
335
+ * the vsync series are completed or reject in case of failure, such as
336
+ * timeout.
337
+ */
338
+ runAnimMutateSeries(contextNode, mutator, opt_timeout) {
339
+ if (!this.canAnimate_(contextNode)) {
340
+ return Promise.reject(cancellation());
341
+ }
342
+ return new Promise((resolve, reject) => {
343
+ const startTime = Date.now();
344
+ let prevTime = 0;
345
+ const task = this.createAnimTask(contextNode, {
346
+ mutate: state => {
347
+ const timeSinceStart = Date.now() - startTime;
348
+ const res = mutator(timeSinceStart, timeSinceStart - prevTime, state);
349
+ if (!res) {
350
+ resolve();
351
+ } else if (opt_timeout && timeSinceStart > opt_timeout) {
352
+ reject(new Error('timeout'));
353
+ } else {
354
+ prevTime = timeSinceStart;
355
+ task(state);
356
+ }
357
+ },
358
+ });
359
+ task({});
360
+ });
361
+ }
362
+
363
+ /** @private */
364
+ schedule_() {
365
+ if (this.scheduled_) {
366
+ return;
367
+ }
368
+ // Schedule actual animation frame and then run tasks.
369
+ this.scheduled_ = true;
370
+ this.jankMeter_.onScheduled();
371
+ this.forceSchedule_();
372
+ }
373
+
374
+ /** @private */
375
+ forceSchedule_() {
376
+ if (this.canAnimate_()) {
377
+ this.raf_(this.boundRunScheduledTasks_);
378
+ this.backupPass_.schedule();
379
+ } else {
380
+ this.invisiblePass_.schedule();
381
+ }
382
+ }
383
+
384
+ /**
385
+ * Runs all scheduled tasks. This is typically called in an RAF
386
+ * callback. Tests may call this method to force execution of
387
+ * tasks without waiting.
388
+ * @private
389
+ */
390
+ runScheduledTasks_() {
391
+ this.backupPass_.cancel();
392
+ this.scheduled_ = false;
393
+ this.jankMeter_.onRun();
394
+
395
+ const {
396
+ tasks_: tasks,
397
+ states_: states,
398
+ nextFrameResolver_: resolver,
399
+ } = this;
400
+ this.nextFrameResolver_ = null;
401
+ this.nextFramePromise_ = null;
402
+ // Double buffering
403
+ this.tasks_ = this.nextTasks_;
404
+ this.states_ = this.nextStates_;
405
+ for (let i = 0; i < tasks.length; i++) {
406
+ if (tasks[i].measure) {
407
+ if (!callTaskNoInline(tasks[i].measure, states[i])) {
408
+ // Ensure that the mutate is not executed when measure fails.
409
+ tasks[i].mutate = undefined;
410
+ }
411
+ }
412
+ }
413
+ for (let i = 0; i < tasks.length; i++) {
414
+ if (tasks[i].mutate) {
415
+ callTaskNoInline(tasks[i].mutate, states[i]);
416
+ }
417
+ }
418
+ // Swap last arrays into double buffer.
419
+ this.nextTasks_ = tasks;
420
+ this.nextStates_ = states;
421
+ this.nextTasks_.length = 0;
422
+ this.nextStates_.length = 0;
423
+ if (resolver) {
424
+ resolver();
425
+ }
426
+ }
427
+
428
+ /**
429
+ * @return {function(function())} requestAnimationFrame or polyfill.
430
+ */
431
+ getRaf_() {
432
+ const raf = this.win.requestAnimationFrame
433
+ || this.win.webkitRequestAnimationFrame;
434
+ if (raf) {
435
+ return raf.bind(this.win);
436
+ }
437
+ let lastTime = 0;
438
+ return fn => {
439
+ const now = Date.now();
440
+ // By default we take 16ms between frames, but if the last frame is say
441
+ // 10ms ago, we only want to wait 6ms.
442
+ const timeToCall = Math.max(0, FRAME_TIME - (now - lastTime));
443
+ lastTime = now + timeToCall;
444
+ this.win.setTimeout(fn, timeToCall);
445
+ };
446
+ }
447
+ }
448
+
449
+
450
+ /**
451
+ * For optimization reasons to stop try/catch from blocking optimization.
452
+ * @param {function(!VsyncStateDef)|undefined} callback
453
+ * @param {!VsyncStateDef} state
454
+ */
455
+ function callTaskNoInline(callback, state) {
456
+ dev().assert(callback);
457
+ try {
458
+ callback(state);
459
+ } catch (e) {
460
+ rethrowAsync(e);
461
+ return false;
462
+ }
463
+ return true;
464
+ }
465
+
466
+ /**
467
+ * @param {!Window} window
468
+ * @return {!Vsync}
469
+ */
470
+ export function vsyncForTesting(window) {
471
+ installVsyncService(window);
472
+ return getService(window, 'vsync');
473
+ }
474
+
475
+ /**
476
+ * @param {!Window} window
477
+ */
478
+ export function installVsyncService(window) {
479
+ installTimerService(window);
480
+ registerServiceBuilder(window, 'vsync', Vsync);
481
+ }
pool/shard000/JavaScript/0003903_PostListComponent.js ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* eslint-disable */
2
+ var React = require('react');
3
+ var Col = require('react-bootstrap/lib/Col');
4
+ var Row = require('react-bootstrap/lib/Row');
5
+ var Panel = require('react-bootstrap/lib/Panel');
6
+ var Glyphicon = require('react-bootstrap/lib/Glyphicon');
7
+ import PostList from './PostList'
8
+ import PostForm from './PostForm'
9
+ import PostLink from './PostLink'
10
+ import PostAlert from './PostAlert'
11
+
12
+ var PostListComponent = React.createClass({
13
+ getInitialState: function() {
14
+ return {
15
+ showPostBox: false,
16
+ showPostLink: true,
17
+ postContent: null,
18
+ showAlert: false,
19
+ alertMessage: null,
20
+ alertClass: null };
21
+ },
22
+ render: function() {
23
+ return(
24
+ <Row>
25
+ <Col sm={12}>
26
+ {this.props.header ? <PostHeader headerContent={this.props.header} /> : null }
27
+ <PostList posts={this.props.posts} showSeparator={this.props.showSeparator} defaultText={this.props.defaultText} />
28
+ { this.state.showAlert ? <PostAlert alertMessage={this.state.alertMessage} alertClass={this.state.alertClass } handleClose={this.hideAlert} /> : null }
29
+ { this.state.showPostBox && this.props.userToken ? <PostForm postText={this.props.postText} placeholderText={this.props.placeholderText} handlePost={this.handleSubmit} /> : null }
30
+ { !(this.state.showPostBox && this.props.userToken) ?
31
+ <PostLink
32
+ anchorText={this.props.anchorText}
33
+ handleClick={this.showPostBox}
34
+ userToken={this.props.userToken}
35
+ noUserAnchorHref={this.props.noUserAnchorHref}
36
+ noUserAnchorText={this.props.noUserAnchorText} /> : null }
37
+ </Col>
38
+ </Row>
39
+ );
40
+ },
41
+ showPostBox: function(e) {
42
+ this.setState({ showPostBox: true, showPostLink: false });
43
+ e.preventDefault();
44
+ },
45
+ /*
46
+ handleSubmit: function(data, e) {
47
+ var postContent = data.postContent;
48
+ var postData = {
49
+ parentId: this.props.parentId,
50
+ content: postContent,
51
+ userid: this.props.userid
52
+ };
53
+
54
+ this.setState({ postContent: postContent });
55
+
56
+ $.ajax({
57
+ type: "POST",
58
+ url: this.props.endpointUrl,
59
+ data: postData,
60
+ success: this.handleSubmitSuccess,
61
+ error: this.handleSubmitFailure,
62
+ dataType: 'json'
63
+ });
64
+
65
+ e.preventDefault();
66
+ },*/
67
+ handleSubmit: function(e, postValue) {
68
+ console.log('Handling submit');
69
+ this.props.handleSubmit(e, postValue, this.handleSubmitSwitch);
70
+ },
71
+ handleSubmitSwitch: function(data) {
72
+ console.log('SUBMIT!')
73
+ this.setState({
74
+ alertMessage: this.props.successMessage || 'Post submitted' ,
75
+ alertClass: 'alert-box success radius',
76
+ showAlert: true,
77
+ showPostBox: false,
78
+ showPostLink: true
79
+ });
80
+ },
81
+ handleSubmitSuccess: function(data){
82
+ if(data.status == 'ok') {
83
+ var posts = this.props.posts || [];
84
+ posts.push(data.object)
85
+
86
+ this.setState({
87
+ alertMessage: this.props.successMessage || 'Post submitted' ,
88
+ alertClass: 'alert-box success radius',
89
+ showAlert: true,
90
+ posts: posts,
91
+ showPostBox: false,
92
+ showPostLink: true
93
+ });
94
+ }
95
+ else{
96
+ this.setState({
97
+ alertMessage: data.message || 'There was an error submitting your post' ,
98
+ alertClass: 'alert-box alert radius',
99
+ showAlert: true
100
+ });
101
+ }
102
+ },
103
+ handleSubmitFailure: function(xhr, ajaxOptions, thrownError){
104
+ this.setState({
105
+ alertMessage: thrownError || 'There was an error submitting your post' ,
106
+ alertClass: 'alert-box alert radius',
107
+ showAlert: true
108
+ });
109
+ },
110
+ /*hideAlert: function(e)
111
+ {
112
+ this.setState({
113
+ alertMessage: null,
114
+ alertClass: null,
115
+ showAlert: false
116
+ });
117
+ e.preventDefault();
118
+ }*/
119
+ });
120
+
121
+ module.exports = PostListComponent;
pool/shard000/JavaScript/0003906_async-gen-yield-star-getiter-async-returns-undefined-throw.js ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file was procedurally generated from the following sources:
2
+ // - src/async-generators/yield-star-getiter-async-returns-undefined-throw.case
3
+ // - src/async-generators/default/async-obj-method.template
4
+ /*---
5
+ description: Non object returned by [Symbol.asyncIterator]() - undefined (Async generator method)
6
+ esid: prod-AsyncGeneratorMethod
7
+ features: [Symbol.iterator, Symbol.asyncIterator, async-iteration]
8
+ flags: [generated, async]
9
+ info: |
10
+ Async Generator Function Definitions
11
+
12
+ AsyncGeneratorMethod :
13
+ async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
14
+
15
+
16
+ YieldExpression: yield * AssignmentExpression
17
+
18
+ 1. Let exprRef be the result of evaluating AssignmentExpression.
19
+ 2. Let value be ? GetValue(exprRef).
20
+ 3. Let generatorKind be ! GetGeneratorKind().
21
+ 4. Let iterator be ? GetIterator(value, generatorKind).
22
+ ...
23
+
24
+ GetIterator ( obj [ , hint ] )
25
+
26
+ ...
27
+ 3. If hint is async,
28
+ a. Set method to ? GetMethod(obj, @@asyncIterator).
29
+ ...
30
+ 6. Let iterator be ? Call(method, obj).
31
+ 7. If Type(iterator) is not Object, throw a TypeError exception.
32
+ ...
33
+
34
+ ---*/
35
+ var obj = {
36
+ get [Symbol.iterator]() {
37
+ throw new Test262Error('it should not get Symbol.iterator');
38
+ },
39
+ [Symbol.asyncIterator]() {
40
+ return undefined;
41
+ }
42
+ };
43
+
44
+
45
+ var callCount = 0;
46
+
47
+ var gen = {
48
+ async *method() {
49
+ callCount += 1;
50
+ yield* obj;
51
+ throw new Test262Error('abrupt completion closes iter');
52
+
53
+ }
54
+ }.method;
55
+
56
+ var iter = gen();
57
+
58
+ iter.next().then(() => {
59
+ throw new Test262Error('Promise incorrectly fulfilled.');
60
+ }, v => {
61
+ assert.sameValue(v.constructor, TypeError, "TypeError");
62
+
63
+ iter.next().then(({ done, value }) => {
64
+ assert.sameValue(done, true, 'the iterator is completed');
65
+ assert.sameValue(value, undefined, 'value is undefined');
66
+ }).then($DONE, $DONE);
67
+ }).catch($DONE);
68
+
69
+ assert.sameValue(callCount, 1);
pool/shard000/JavaScript/0003908_inner_home.js ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //In inner_home.js
2
+ iris.screen(
3
+ function (self) {
4
+ self.create = function () {
5
+ console.log("Inner Home Screen Created");
6
+ self.tmpl(iris.path.inner_home.html);
7
+ };
8
+
9
+ self.awake = function (params) {
10
+ console.log("Inner Home Screen Awakened");
11
+ self.get("year_parameter").text("The value of the year parameter is: " + self.params.year);
12
+ };
13
+
14
+ self.sleep = function () {
15
+ console.log("Inner Home Screen Asleep");
16
+ };
17
+
18
+ self.destroy = function () {
19
+ console.log("Inner Home Screen Destroyed");
20
+ };
21
+ },
22
+ iris.path.inner_home.js
23
+ );