Upload folder using huggingface_hub (part 85)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- pool/shard007/JavaScript/0047834_Adjustor.js +115 -0
- pool/shard007/JavaScript/0047836_checkbox.js +36 -0
- pool/shard007/JavaScript/0047837_passify.js +39 -0
- pool/shard007/JavaScript/0047840_SAXTreeBuilder.js +126 -0
- pool/shard007/JavaScript/0047847_Cube.js +54 -0
- pool/shard007/JavaScript/0047850_reserveLoad.js +171 -0
- pool/shard007/JavaScript/0047853_response.js +196 -0
- pool/shard007/JavaScript/0047857_pointer_events_polyfill.js +88 -0
- pool/shard007/JavaScript/0047859_user-access-right-task-collection-level-drop-spec.js +277 -0
- pool/shard007/JavaScript/0047862_html_actuator.js +140 -0
- pool/shard007/JavaScript/0047863_howter.js +89 -0
- pool/shard007/JavaScript/0047865_blogPost.js +119 -0
- pool/shard007/JavaScript/0047872_login.js +24 -0
- pool/shard007/JavaScript/0047873_tickets.js +74 -0
- pool/shard007/JavaScript/0047875_app.js +70 -0
- pool/shard007/JavaScript/0047877_qa_annotation_listing.js +69 -0
- pool/shard007/JavaScript/0047880_app.js +59 -0
- pool/shard007/JavaScript/0047883_2010002.js +91 -0
- pool/shard007/JavaScript/0047885_test.controller.js +20 -0
- pool/shard007/JavaScript/0047889_CompositeSprite.js +51 -0
- pool/shard007/JavaScript/0047898_queensland.js +121 -0
- pool/shard007/JavaScript/0047899_product.js +19 -0
- pool/shard007/JavaScript/0047900_users.js +71 -0
- pool/shard007/JavaScript/0047904_InvoiceSettingsApi.spec.js +63 -0
- pool/shard007/JavaScript/0047908_race-participant-detail.controller.js +20 -0
- pool/shard007/JavaScript/0047909_app.js +67 -0
- pool/shard007/JavaScript/0047911_ProfileAddressForm.js +202 -0
- pool/shard007/JavaScript/0047923_users.js +30 -0
- pool/shard007/JavaScript/0047924_ScreenWithToolbar.spec.js +29 -0
- pool/shard007/JavaScript/0047926_plugin.js +108 -0
- pool/shard007/JavaScript/0047932_SelectFilter2.js +252 -0
- pool/shard007/JavaScript/0047934_gfycat.js +109 -0
- pool/shard007/JavaScript/0047936_store.js +145 -0
- pool/shard007/JavaScript/0047938_file-system-blob-store-spec.js +126 -0
- pool/shard007/JavaScript/0047942_regular_expression.js +52 -0
- pool/shard007/JavaScript/0047944_SVGPan.js +282 -0
- pool/shard007/JavaScript/0047945_platform.js +43 -0
- pool/shard007/JavaScript/0047947_buildHtml_test.js +105 -0
- pool/shard007/JavaScript/0047948_delete-entry.js +51 -0
- pool/shard007/JavaScript/0047951_i18n.js +52 -0
- pool/shard007/JavaScript/0047952_client.js +26 -0
- pool/shard007/JavaScript/0047954_tfsConnectionConfiguration.js +21 -0
- pool/shard007/JavaScript/0047955_repo_v2_fallback.js +21 -0
- pool/shard007/JavaScript/0047956_Object_create.js +25 -0
- pool/shard007/JavaScript/0047965_Pool.js +162 -0
- pool/shard007/JavaScript/0047969_test.js +114 -0
- pool/shard007/JavaScript/0047970_superfish.js +122 -0
- pool/shard007/JavaScript/0047972_size_report.js +161 -0
- pool/shard007/JavaScript/0047975_bug970427.js +15 -0
- pool/shard007/JavaScript/0047976_index.js +44 -0
pool/shard007/JavaScript/0047834_Adjustor.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var Adjustor = {};
|
| 2 |
+
|
| 3 |
+
Adjustor.UP = 38;
|
| 4 |
+
Adjustor.DOWN = 40;
|
| 5 |
+
|
| 6 |
+
Adjustor.nudge = function (input, event, format){
|
| 7 |
+
|
| 8 |
+
// when replacing the nudged value, tells us where to start and
|
| 9 |
+
// how far to go (like substr(repl.start, repl.length))
|
| 10 |
+
var repl = { start: 0, length: 0 };
|
| 11 |
+
|
| 12 |
+
// record the original position of the cursor
|
| 13 |
+
var cursor = input.selectionStart;
|
| 14 |
+
|
| 15 |
+
// determine which direction we're nudging
|
| 16 |
+
var direction = event.keyCode;
|
| 17 |
+
if (direction != Adjustor.UP && direction != Adjustor.DOWN){
|
| 18 |
+
return;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
// since we'll sometimes prevent the cursor from moving, we
|
| 22 |
+
// should always prevent the cursor from moving
|
| 23 |
+
event.preventDefault();
|
| 24 |
+
|
| 25 |
+
function parse(){
|
| 26 |
+
var value = input.value,
|
| 27 |
+
p = cursor,
|
| 28 |
+
start;
|
| 29 |
+
|
| 30 |
+
function isNumeric(value){
|
| 31 |
+
return !isNaN(parseInt(value));
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
while (start == undefined){
|
| 35 |
+
|
| 36 |
+
var left = isNumeric(value[p - 1]),
|
| 37 |
+
right = isNumeric(value[p]);
|
| 38 |
+
|
| 39 |
+
// if there's no digit left or right, bail
|
| 40 |
+
if (!left && !right){
|
| 41 |
+
return;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
// if there's no digit left but a digit right, we've found our start
|
| 45 |
+
else if (!left && right){
|
| 46 |
+
start = p;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
// if there's a digit left, regardless of a digit right, move left
|
| 50 |
+
else if (left){
|
| 51 |
+
p--;
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
var parsed = parseInt(value.substr(start));
|
| 56 |
+
|
| 57 |
+
// record the start and the length to replace this value later
|
| 58 |
+
repl.start = start;
|
| 59 |
+
repl.length = parsed.toString().length;
|
| 60 |
+
|
| 61 |
+
return parsed;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* Replaces the currently matched substring with another value, based on
|
| 66 |
+
* the start and length found by parse() (i.e., call that first). Returns
|
| 67 |
+
* the new string.
|
| 68 |
+
*
|
| 69 |
+
* @param string
|
| 70 |
+
* @return string
|
| 71 |
+
*/
|
| 72 |
+
function replace(value){
|
| 73 |
+
var min = 0, max;
|
| 74 |
+
|
| 75 |
+
// determine the maximum value for this...value
|
| 76 |
+
if (format == Color.RGB){
|
| 77 |
+
max = 255;
|
| 78 |
+
} else {
|
| 79 |
+
|
| 80 |
+
// if we're looking at hue, then there will be no digits to the
|
| 81 |
+
// left of the start position
|
| 82 |
+
max = /\d/.test(input.value.substr(0, repl.start)) ? 100 : 359;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
value = Math.max(min, Math.min(max, value));
|
| 86 |
+
|
| 87 |
+
var chunks = input.value.split("");
|
| 88 |
+
chunks.splice(repl.start, repl.length, value);
|
| 89 |
+
return chunks.join("");
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/**
|
| 93 |
+
* Provides the offset to add to the current value, based on whether
|
| 94 |
+
* we're nudging up or down (which arrow key) and big or small (whether
|
| 95 |
+
* the Option key was being held).
|
| 96 |
+
*
|
| 97 |
+
* @return int
|
| 98 |
+
*/
|
| 99 |
+
function adjustment(){
|
| 100 |
+
return (direction == Adjustor.UP ? 1 : -1) * (event.altKey ? 10 : 1);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
var parsed = parse();
|
| 104 |
+
|
| 105 |
+
if (parsed == undefined){
|
| 106 |
+
return;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
input.value = replace(parsed + adjustment());
|
| 110 |
+
|
| 111 |
+
// put the cursor in the right spot
|
| 112 |
+
input.selectionStart = input.selectionEnd = cursor;
|
| 113 |
+
|
| 114 |
+
return input.value;
|
| 115 |
+
};
|
pool/shard007/JavaScript/0047836_checkbox.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
angular.module('angularify.semantic.checkbox', [])
|
| 4 |
+
.directive('checkbox', function() {
|
| 5 |
+
return {
|
| 6 |
+
restrict: 'E',
|
| 7 |
+
replace: true,
|
| 8 |
+
transclude: true,
|
| 9 |
+
scope: {
|
| 10 |
+
checked: '&?',
|
| 11 |
+
disabled: '&?',
|
| 12 |
+
ngModel: '=ngModel'
|
| 13 |
+
},
|
| 14 |
+
controller: function() {
|
| 15 |
+
var vm = this;
|
| 16 |
+
|
| 17 |
+
// TODO: assert this is usefull ?
|
| 18 |
+
// if(angular.isUndefined(vm.ngModel)) { vm.ngModel = !!vm.ngModel; }
|
| 19 |
+
|
| 20 |
+
if(angular.isFunction(vm.checked)) { vm.ngModel = !!vm.checked(); }
|
| 21 |
+
|
| 22 |
+
vm.toggle = function() {
|
| 23 |
+
if(angular.isFunction(vm.disabled) && vm.disabled()) return;
|
| 24 |
+
vm.ngModel = !vm.ngModel;
|
| 25 |
+
}
|
| 26 |
+
},
|
| 27 |
+
controllerAs: 'vm',
|
| 28 |
+
bindToController: true,
|
| 29 |
+
require: 'ngModel',
|
| 30 |
+
template: '<div class="ui checkbox">' +
|
| 31 |
+
'<input type="checkbox" ng-model="vm.ngModel" ng-disabled="vm.disabled()"/>' +
|
| 32 |
+
'<label ng-click="vm.toggle()" ng-transclude></label>' +
|
| 33 |
+
'</div>',
|
| 34 |
+
link: function() { }
|
| 35 |
+
};
|
| 36 |
+
});
|
pool/shard007/JavaScript/0047837_passify.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var passify = require('../index');
|
| 2 |
+
|
| 3 |
+
describe('Passify', function() {
|
| 4 |
+
describe('Create', function() {
|
| 5 |
+
var passwordDefault = passify.create();
|
| 6 |
+
var passwordCustom = passify.create(11);
|
| 7 |
+
|
| 8 |
+
it('should result in an 8 character [0-9][A-Z][a-z] string', function() {
|
| 9 |
+
passwordDefault.length.should.equal(8);
|
| 10 |
+
});
|
| 11 |
+
it('should result in an 11 character [0-9][A-Z][a-z] string', function() {
|
| 12 |
+
passwordCustom.length.should.equal(11);
|
| 13 |
+
});
|
| 14 |
+
});
|
| 15 |
+
|
| 16 |
+
describe('Hash', function() {
|
| 17 |
+
it('should create a hash for the password "secret".', function(cb) {
|
| 18 |
+
passify.hash('secret', function(err, hash) {
|
| 19 |
+
hash.should.be.ok;
|
| 20 |
+
cb();
|
| 21 |
+
});
|
| 22 |
+
});
|
| 23 |
+
});
|
| 24 |
+
|
| 25 |
+
describe('Compare', function() {
|
| 26 |
+
it('should return false when comparing a password to a wrong hash.', function(cb) {
|
| 27 |
+
passify.compare('secret', '123', function(err, bool) {
|
| 28 |
+
bool.should.be.false;
|
| 29 |
+
cb();
|
| 30 |
+
});
|
| 31 |
+
});
|
| 32 |
+
it('should return true when comparing a password to a correct hash.', function(cb) {
|
| 33 |
+
passify.compare('secret', '$2a$05$uwnq6r5LxGIMjFGjHwKBWuMgcH/XcazHPG6b/xj3Yze5DRd6NmNGO', function(err, bool) {
|
| 34 |
+
bool.should.be.true;
|
| 35 |
+
cb();
|
| 36 |
+
});
|
| 37 |
+
});
|
| 38 |
+
});
|
| 39 |
+
});
|
pool/shard007/JavaScript/0047840_SAXTreeBuilder.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
System.register(["./TreeBuilder", "./Characters", "./Comment", "./Document", "./DocumentFragment", "./DTD", "./Element", "./getAttribute"], function (exports_1, context_1) {
|
| 2 |
+
"use strict";
|
| 3 |
+
var __extends = (this && this.__extends) || (function () {
|
| 4 |
+
var extendStatics = Object.setPrototypeOf ||
|
| 5 |
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
| 6 |
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
| 7 |
+
return function (d, b) {
|
| 8 |
+
extendStatics(d, b);
|
| 9 |
+
function __() { this.constructor = d; }
|
| 10 |
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
| 11 |
+
};
|
| 12 |
+
})();
|
| 13 |
+
var __moduleName = context_1 && context_1.id;
|
| 14 |
+
var TreeBuilder_1, Characters_1, Comment_1, Document_1, DocumentFragment_1, DTD_1, Element_1, getAttribute_1, SAXTreeBuilder;
|
| 15 |
+
return {
|
| 16 |
+
setters: [
|
| 17 |
+
function (TreeBuilder_1_1) {
|
| 18 |
+
TreeBuilder_1 = TreeBuilder_1_1;
|
| 19 |
+
},
|
| 20 |
+
function (Characters_1_1) {
|
| 21 |
+
Characters_1 = Characters_1_1;
|
| 22 |
+
},
|
| 23 |
+
function (Comment_1_1) {
|
| 24 |
+
Comment_1 = Comment_1_1;
|
| 25 |
+
},
|
| 26 |
+
function (Document_1_1) {
|
| 27 |
+
Document_1 = Document_1_1;
|
| 28 |
+
},
|
| 29 |
+
function (DocumentFragment_1_1) {
|
| 30 |
+
DocumentFragment_1 = DocumentFragment_1_1;
|
| 31 |
+
},
|
| 32 |
+
function (DTD_1_1) {
|
| 33 |
+
DTD_1 = DTD_1_1;
|
| 34 |
+
},
|
| 35 |
+
function (Element_1_1) {
|
| 36 |
+
Element_1 = Element_1_1;
|
| 37 |
+
},
|
| 38 |
+
function (getAttribute_1_1) {
|
| 39 |
+
getAttribute_1 = getAttribute_1_1;
|
| 40 |
+
}
|
| 41 |
+
],
|
| 42 |
+
execute: function () {
|
| 43 |
+
SAXTreeBuilder = (function (_super) {
|
| 44 |
+
__extends(SAXTreeBuilder, _super);
|
| 45 |
+
function SAXTreeBuilder() {
|
| 46 |
+
return _super.call(this) || this;
|
| 47 |
+
}
|
| 48 |
+
SAXTreeBuilder.prototype.start = function (tokenizer) {
|
| 49 |
+
this.document = new Document_1.Document(this.tokenizer);
|
| 50 |
+
};
|
| 51 |
+
SAXTreeBuilder.prototype.end = function () {
|
| 52 |
+
this.document.endLocator = this.tokenizer;
|
| 53 |
+
};
|
| 54 |
+
SAXTreeBuilder.prototype.insertDoctype = function (name, publicId, systemId) {
|
| 55 |
+
var doctype = new DTD_1.DTD(this.tokenizer, name, publicId, systemId);
|
| 56 |
+
doctype.endLocator = this.tokenizer;
|
| 57 |
+
this.document.appendChild(doctype);
|
| 58 |
+
};
|
| 59 |
+
SAXTreeBuilder.prototype.createElement = function (namespaceURI, localName, attributes) {
|
| 60 |
+
var element = new Element_1.Element(this.tokenizer, namespaceURI, localName, localName, attributes || []);
|
| 61 |
+
return element;
|
| 62 |
+
};
|
| 63 |
+
SAXTreeBuilder.prototype.insertComment = function (data, parent) {
|
| 64 |
+
if (!parent)
|
| 65 |
+
parent = this.currentStackItem();
|
| 66 |
+
var comment = new Comment_1.Comment(this.tokenizer, data);
|
| 67 |
+
parent.appendChild(comment);
|
| 68 |
+
};
|
| 69 |
+
SAXTreeBuilder.prototype.appendCharacters = function (parent, data) {
|
| 70 |
+
var text = new Characters_1.Characters(this.tokenizer, data);
|
| 71 |
+
parent.appendChild(text);
|
| 72 |
+
};
|
| 73 |
+
SAXTreeBuilder.prototype.insertText = function (data) {
|
| 74 |
+
if (this.redirectAttachToFosterParent && this.openElements.top.isFosterParenting()) {
|
| 75 |
+
var tableIndex = this.openElements.findIndex('table');
|
| 76 |
+
var tableItem = this.openElements.item(tableIndex);
|
| 77 |
+
var table = tableItem.node;
|
| 78 |
+
if (tableIndex === 0) {
|
| 79 |
+
return this.appendCharacters(table, data);
|
| 80 |
+
}
|
| 81 |
+
var text = new Characters_1.Characters(this.tokenizer, data);
|
| 82 |
+
var parent = table.parentNode;
|
| 83 |
+
if (parent) {
|
| 84 |
+
parent.insertBetween(text, table.previousSibling, table);
|
| 85 |
+
return;
|
| 86 |
+
}
|
| 87 |
+
var stackParent = this.openElements.item(tableIndex - 1).node;
|
| 88 |
+
stackParent.appendChild(text);
|
| 89 |
+
return;
|
| 90 |
+
}
|
| 91 |
+
this.appendCharacters(this.currentStackItem().node, data);
|
| 92 |
+
};
|
| 93 |
+
SAXTreeBuilder.prototype.attachNode = function (node, parent) {
|
| 94 |
+
parent.appendChild(node);
|
| 95 |
+
};
|
| 96 |
+
SAXTreeBuilder.prototype.attachNodeToFosterParent = function (child, table, stackParent) {
|
| 97 |
+
var parent = table.parentNode;
|
| 98 |
+
if (parent)
|
| 99 |
+
parent.insertBetween(child, table.previousSibling, table);
|
| 100 |
+
else
|
| 101 |
+
stackParent.appendChild(child);
|
| 102 |
+
};
|
| 103 |
+
SAXTreeBuilder.prototype.detachFromParent = function (element) {
|
| 104 |
+
element.detach();
|
| 105 |
+
};
|
| 106 |
+
SAXTreeBuilder.prototype.reparentChildren = function (oldParent, newParent) {
|
| 107 |
+
newParent.appendChildren(oldParent.firstChild);
|
| 108 |
+
};
|
| 109 |
+
SAXTreeBuilder.prototype.getFragment = function () {
|
| 110 |
+
var fragment = new DocumentFragment_1.DocumentFragment();
|
| 111 |
+
this.reparentChildren(this.openElements.rootNode, fragment);
|
| 112 |
+
return fragment;
|
| 113 |
+
};
|
| 114 |
+
SAXTreeBuilder.prototype.addAttributesToElement = function (element, attributes) {
|
| 115 |
+
for (var i = 0; i < attributes.length; i++) {
|
| 116 |
+
var attribute = attributes[i];
|
| 117 |
+
if (!getAttribute_1.getAttribute(element, attribute.nodeName))
|
| 118 |
+
element.attributes.push(attribute);
|
| 119 |
+
}
|
| 120 |
+
};
|
| 121 |
+
return SAXTreeBuilder;
|
| 122 |
+
}(TreeBuilder_1.TreeBuilder));
|
| 123 |
+
exports_1("SAXTreeBuilder", SAXTreeBuilder);
|
| 124 |
+
}
|
| 125 |
+
};
|
| 126 |
+
});
|
pool/shard007/JavaScript/0047847_Cube.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import THREE from 'three';
|
| 2 |
+
|
| 3 |
+
export default class Cube {
|
| 4 |
+
|
| 5 |
+
constructor(config) {
|
| 6 |
+
if(config === undefined) {
|
| 7 |
+
config = {};
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
let radius = config.radius || 70;
|
| 11 |
+
|
| 12 |
+
this.rotationX = config.rotationX || 0;
|
| 13 |
+
this.rotationY = config.rotationY || 0;
|
| 14 |
+
|
| 15 |
+
// Create a group
|
| 16 |
+
this.group = new THREE.Group
|
| 17 |
+
this.widthSegments = config.widthSegments || 16;
|
| 18 |
+
this.heightSegments = config.heightSegments || 16
|
| 19 |
+
|
| 20 |
+
// this.geometry = new THREE.SphereGeometry(radius, this.widthSegments, this.heightSegments);
|
| 21 |
+
this.geometry = new THREE.BoxGeometry(radius, radius, radius);
|
| 22 |
+
this.material = new THREE.MeshBasicMaterial({
|
| 23 |
+
color: config.color || 0xffaa00,
|
| 24 |
+
opacity: config.opacity || 0.3,
|
| 25 |
+
transparent: true,
|
| 26 |
+
wireframe: config.wireframe || false,
|
| 27 |
+
wireframeLinewidth: config.wireframeLinewidth || 1
|
| 28 |
+
});
|
| 29 |
+
|
| 30 |
+
// Create a cube
|
| 31 |
+
this.cube = new THREE.Mesh(this.geometry, this.material);
|
| 32 |
+
|
| 33 |
+
// Cube positions
|
| 34 |
+
this.cube.position.x = config.positionX || 0;
|
| 35 |
+
this.cube.position.y = config.positionY || 0;
|
| 36 |
+
this.cube.position.z = 100;
|
| 37 |
+
|
| 38 |
+
// Group position
|
| 39 |
+
this.group.position.x = -window.innerWidth / 2 - 60;
|
| 40 |
+
// this.group.position.y = -window.innerHeight / 2 + 200;
|
| 41 |
+
|
| 42 |
+
this.group.add(this.cube);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
render() {
|
| 46 |
+
this.cube.rotation.x += this.rotationX;
|
| 47 |
+
this.cube.rotation.y += this.rotationY;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
getObject() {
|
| 51 |
+
return this.group;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
}
|
pool/shard007/JavaScript/0047850_reserveLoad.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
/*!
|
| 4 |
+
* reserveLoad.js, version 0.4.1, 2013/10/27
|
| 5 |
+
* Dynamic JavaScript/CSS loader, and load JavaScript with reserve URL.
|
| 6 |
+
* https://github.com/zensh/reserveLoad.js
|
| 7 |
+
* (c) admin@zensh.com 2013
|
| 8 |
+
* License: MIT
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
(function (global) {
|
| 12 |
+
var doc = global.document,
|
| 13 |
+
_define = global.define,
|
| 14 |
+
location = doc.location,
|
| 15 |
+
head = doc.getElementsByTagName('head')[0] || doc.documentElement,
|
| 16 |
+
baseElement = head.getElementsByTagName('base')[0],
|
| 17 |
+
slice = [].slice,
|
| 18 |
+
validCSS = /\.css(?:\?|$)/i,
|
| 19 |
+
validState = /^(?:loaded|complete|undefined)$/,
|
| 20 |
+
currentlyAddingScript = null,
|
| 21 |
+
scripts = {}; // 缓存已加载脚本
|
| 22 |
+
|
| 23 |
+
// 入口函数
|
| 24 |
+
var reserveLoad = global.reserveLoad = function () {
|
| 25 |
+
startLoad(slice.call(arguments));
|
| 26 |
+
};
|
| 27 |
+
reserveLoad.version = 'v0.4.0';
|
| 28 |
+
|
| 29 |
+
// 获取原始define函数,从而支持reserveLoad覆盖
|
| 30 |
+
_define = isFunction(_define) ? (_define._originalDefine ? _define._originalDefine : _define) : null;
|
| 31 |
+
// 封装define,从而兼容requirejs的define等
|
| 32 |
+
var define = global.define = function (name, deps, callback) {
|
| 33 |
+
callback = isFunction(callback) ? callback : isFunction(deps) ? deps : isFunction(name) ? name : noop;
|
| 34 |
+
if (currentlyAddingScript) {
|
| 35 |
+
scripts[currentlyAddingScript] = callback();
|
| 36 |
+
currentlyAddingScript = null;
|
| 37 |
+
} else if (_define) {
|
| 38 |
+
_define(name, deps, callback);
|
| 39 |
+
}
|
| 40 |
+
};
|
| 41 |
+
// 保存原始define
|
| 42 |
+
define._originalDefine = _define;
|
| 43 |
+
|
| 44 |
+
function noop() {}
|
| 45 |
+
|
| 46 |
+
function isArray(obj) {
|
| 47 |
+
return Array.isArray ? Array.isArray(obj) : Object.prototype.toString.call(obj) === '[object Array]';
|
| 48 |
+
}
|
| 49 |
+
function isFunction(fn) {
|
| 50 |
+
return typeof fn === 'function';
|
| 51 |
+
}
|
| 52 |
+
function each(array, iterator, context) {
|
| 53 |
+
for (var i = 0, l = array.length; i < l; i++) {
|
| 54 |
+
iterator.call(context, array[i], i, array);
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
// 逐步执行函数
|
| 58 |
+
function eachThen(array, iterator, context) {
|
| 59 |
+
var i = -1,
|
| 60 |
+
end = array.length - 1;
|
| 61 |
+
function next() {
|
| 62 |
+
i += 1;
|
| 63 |
+
iterator.call(context, i < end ? next : null, array[i], i, array);
|
| 64 |
+
}
|
| 65 |
+
return next();
|
| 66 |
+
}
|
| 67 |
+
// 获取当前url地址对应的JS
|
| 68 |
+
function getScript(context, exports, url) {
|
| 69 |
+
var value = null;
|
| 70 |
+
if (url) {
|
| 71 |
+
if (scripts[url]) {
|
| 72 |
+
value = scripts[url];
|
| 73 |
+
} else if (isFunction(exports)) {
|
| 74 |
+
value = exports();
|
| 75 |
+
scripts[url] = value;
|
| 76 |
+
} else if (exports && typeof exports === 'string') {
|
| 77 |
+
value = context || global;
|
| 78 |
+
each(exports.split('.'), function (part) {
|
| 79 |
+
if (value) {
|
| 80 |
+
value = value[part];
|
| 81 |
+
}
|
| 82 |
+
});
|
| 83 |
+
scripts[url] = value;
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
return value;
|
| 87 |
+
}
|
| 88 |
+
// 加载JS或CSS
|
| 89 |
+
function request(url, exports, callback) {
|
| 90 |
+
var isCSS = validCSS.test(url),
|
| 91 |
+
node = doc.createElement(isCSS ? 'link' : 'script'),
|
| 92 |
+
success = isCSS || !exports;
|
| 93 |
+
|
| 94 |
+
if (!url || (!isCSS && getScript(global, exports, url))) {
|
| 95 |
+
return;
|
| 96 |
+
}
|
| 97 |
+
node.onload = node.onerror = node.onreadystatechange = function () {
|
| 98 |
+
if (validState.test(node.readyState + '')) {
|
| 99 |
+
if (!isCSS) {
|
| 100 |
+
head.removeChild(node);
|
| 101 |
+
}
|
| 102 |
+
node = node.onload = node.onerror = node.onreadystatechange = null;
|
| 103 |
+
callback(success || !! getScript(global, exports, url));
|
| 104 |
+
}
|
| 105 |
+
};
|
| 106 |
+
if (isCSS) {
|
| 107 |
+
node.rel = 'stylesheet';
|
| 108 |
+
node.href = url;
|
| 109 |
+
} else {
|
| 110 |
+
node.async = 1;
|
| 111 |
+
node.src = url;
|
| 112 |
+
}
|
| 113 |
+
currentlyAddingScript = url;
|
| 114 |
+
head[baseElement ? 'insertBefore' : 'appendChild'](node, baseElement);
|
| 115 |
+
}
|
| 116 |
+
// 主函数
|
| 117 |
+
function startLoad(list) {
|
| 118 |
+
var count = 0,
|
| 119 |
+
total = list.length,
|
| 120 |
+
scriptList = [], // 当前加载器脚本清单
|
| 121 |
+
callback = list[total - 1];
|
| 122 |
+
// 检测是否完成加载
|
| 123 |
+
function checkLoaded(next, url) {
|
| 124 |
+
if (url || count === total) {
|
| 125 |
+
each(scriptList, function (key, index) {
|
| 126 |
+
scriptList[index] = scripts[key] || key;
|
| 127 |
+
});
|
| 128 |
+
scriptList.unshift(url);
|
| 129 |
+
return callback.apply(null, scriptList);
|
| 130 |
+
} else if (isFunction(next)) {
|
| 131 |
+
return next();
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
function load(array, nextLoad) {
|
| 135 |
+
function get(url, fnName, next) {
|
| 136 |
+
request(url, fnName, function (success) {
|
| 137 |
+
count += +success;
|
| 138 |
+
if (!success && next) {
|
| 139 |
+
next();
|
| 140 |
+
} else {
|
| 141 |
+
scriptList.push(url);
|
| 142 |
+
checkLoaded(nextLoad, success ? null : url);
|
| 143 |
+
}
|
| 144 |
+
});
|
| 145 |
+
}
|
| 146 |
+
if (isArray(array)) {
|
| 147 |
+
var checkFn;
|
| 148 |
+
if (array.length > 1) {
|
| 149 |
+
checkFn = array.pop();
|
| 150 |
+
}
|
| 151 |
+
eachThen(array, function (next, x) {
|
| 152 |
+
get(x, checkFn, next);
|
| 153 |
+
});
|
| 154 |
+
} else if (array && typeof array === 'string') {
|
| 155 |
+
get(array, null);
|
| 156 |
+
} else {
|
| 157 |
+
count += 1;
|
| 158 |
+
checkLoaded(nextLoad, null);
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
if (isFunction(callback)) {
|
| 162 |
+
total -= 1;
|
| 163 |
+
list.pop();
|
| 164 |
+
} else {
|
| 165 |
+
callback = noop;
|
| 166 |
+
}
|
| 167 |
+
eachThen(list, function (next, x) {
|
| 168 |
+
load(x, next);
|
| 169 |
+
});
|
| 170 |
+
}
|
| 171 |
+
})(window);
|
pool/shard007/JavaScript/0047853_response.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
/**
|
| 3 |
+
* response.js
|
| 4 |
+
*
|
| 5 |
+
* Response class provides content decoding
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
var http = require('http');
|
| 9 |
+
var convert = require('encoding').convert;
|
| 10 |
+
var Headers = require('./headers');
|
| 11 |
+
|
| 12 |
+
module.exports = Response;
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Response class
|
| 16 |
+
*
|
| 17 |
+
* @param Stream body Readable stream
|
| 18 |
+
* @param Object opts Response options
|
| 19 |
+
* @return Void
|
| 20 |
+
*/
|
| 21 |
+
function Response(body, opts) {
|
| 22 |
+
|
| 23 |
+
opts = opts || {};
|
| 24 |
+
|
| 25 |
+
this.url = opts.url;
|
| 26 |
+
this.status = opts.status;
|
| 27 |
+
this.statusText = http.STATUS_CODES[this.status];
|
| 28 |
+
this.headers = new Headers(opts.headers);
|
| 29 |
+
this.body = body;
|
| 30 |
+
this.bodyUsed = false;
|
| 31 |
+
this.size = opts.size;
|
| 32 |
+
this.ok = this.status >= 200 && this.status < 300;
|
| 33 |
+
this.timeout = opts.timeout;
|
| 34 |
+
this.res = opts.res;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* Decode response as json
|
| 39 |
+
*
|
| 40 |
+
* @return Promise
|
| 41 |
+
*/
|
| 42 |
+
Response.prototype.json = function() {
|
| 43 |
+
|
| 44 |
+
return this._decode().then(function(text) {
|
| 45 |
+
return JSON.parse(text);
|
| 46 |
+
});
|
| 47 |
+
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* Decode response as text
|
| 52 |
+
*
|
| 53 |
+
* @return Promise
|
| 54 |
+
*/
|
| 55 |
+
Response.prototype.text = function() {
|
| 56 |
+
|
| 57 |
+
return this._decode();
|
| 58 |
+
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Decode buffers into utf-8 string
|
| 63 |
+
*
|
| 64 |
+
* @return Promise
|
| 65 |
+
*/
|
| 66 |
+
Response.prototype._decode = function() {
|
| 67 |
+
|
| 68 |
+
var self = this;
|
| 69 |
+
|
| 70 |
+
if (this.bodyUsed) {
|
| 71 |
+
return Response.Promise.reject(new Error('body used already for: ' + this.url));
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
this.bodyUsed = true;
|
| 75 |
+
this._bytes = 0;
|
| 76 |
+
this._abort = false;
|
| 77 |
+
this._raw = [];
|
| 78 |
+
|
| 79 |
+
return new Response.Promise(function(resolve, reject) {
|
| 80 |
+
var resTimeout;
|
| 81 |
+
|
| 82 |
+
// allow timeout on slow response body
|
| 83 |
+
if (self.timeout) {
|
| 84 |
+
resTimeout = setTimeout(function() {
|
| 85 |
+
self._abort = true;
|
| 86 |
+
reject(new Error('response timeout at ' + self.url + ' over limit: ' + self.timeout));
|
| 87 |
+
}, self.timeout);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
// handle stream error, such as incorrect content-encoding
|
| 91 |
+
self.body.on('error', function(err) {
|
| 92 |
+
reject(new Error('invalid response body at: ' + self.url + ' reason: ' + err.message));
|
| 93 |
+
});
|
| 94 |
+
|
| 95 |
+
self.body.on('data', function(chunk) {
|
| 96 |
+
if (self._abort || chunk === null) {
|
| 97 |
+
return;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
if (self.size && self._bytes + chunk.length > self.size) {
|
| 101 |
+
self._abort = true;
|
| 102 |
+
reject(new Error('content size at ' + self.url + ' over limit: ' + self.size));
|
| 103 |
+
return;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
self._bytes += chunk.length;
|
| 107 |
+
self._raw.push(chunk);
|
| 108 |
+
});
|
| 109 |
+
|
| 110 |
+
self.body.on('end', function() {
|
| 111 |
+
if (self._abort) {
|
| 112 |
+
return;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
clearTimeout(resTimeout);
|
| 116 |
+
resolve(self._convert());
|
| 117 |
+
});
|
| 118 |
+
});
|
| 119 |
+
|
| 120 |
+
};
|
| 121 |
+
|
| 122 |
+
/**
|
| 123 |
+
* Detect buffer encoding and convert to target encoding
|
| 124 |
+
* ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding
|
| 125 |
+
*
|
| 126 |
+
* @param String encoding Target encoding
|
| 127 |
+
* @return String
|
| 128 |
+
*/
|
| 129 |
+
Response.prototype._convert = function(encoding) {
|
| 130 |
+
|
| 131 |
+
encoding = encoding || 'utf-8';
|
| 132 |
+
|
| 133 |
+
var charset = 'utf-8';
|
| 134 |
+
var res, str;
|
| 135 |
+
|
| 136 |
+
// header
|
| 137 |
+
if (this.headers.has('content-type')) {
|
| 138 |
+
res = /charset=([^;]*)/i.exec(this.headers.get('content-type'));
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
// no charset in content type, peek at response body
|
| 142 |
+
if (!res && this._raw.length > 0) {
|
| 143 |
+
if (this.headers.get('transfer-encoding') === 'chunked') {
|
| 144 |
+
var buf, index = 0, length = 0;
|
| 145 |
+
while(length < 1024 && (buf = this._raw[index])) {
|
| 146 |
+
length += buf.length;
|
| 147 |
+
index++;
|
| 148 |
+
}
|
| 149 |
+
str = this._raw.slice(0,index).join('');
|
| 150 |
+
} else {
|
| 151 |
+
str = this._raw[0].toString();
|
| 152 |
+
}
|
| 153 |
+
str = str.substr(0, 1024);
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
// html5
|
| 157 |
+
if (!res && str) {
|
| 158 |
+
res = /<meta.+?charset=(['"])(.+?)\1/i.exec(str);
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
// html4
|
| 162 |
+
if (!res && str) {
|
| 163 |
+
res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str);
|
| 164 |
+
|
| 165 |
+
if (res) {
|
| 166 |
+
res = /charset=(.*)/i.exec(res.pop());
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
// xml
|
| 171 |
+
if (!res && str) {
|
| 172 |
+
res = /<\?xml.+?encoding=(['"])(.+?)\1/i.exec(str);
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
// found charset
|
| 176 |
+
if (res) {
|
| 177 |
+
charset = res.pop();
|
| 178 |
+
|
| 179 |
+
// prevent decode issues when sites use incorrect encoding
|
| 180 |
+
// ref: https://hsivonen.fi/encoding-menu/
|
| 181 |
+
if (charset === 'gb2312' || charset === 'gbk') {
|
| 182 |
+
charset = 'gb18030';
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
// turn raw buffers into utf-8 string
|
| 187 |
+
return convert(
|
| 188 |
+
Buffer.concat(this._raw)
|
| 189 |
+
, encoding
|
| 190 |
+
, charset
|
| 191 |
+
).toString();
|
| 192 |
+
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
// expose Promise
|
| 196 |
+
Response.Promise = global.Promise;
|
pool/shard007/JavaScript/0047857_pointer_events_polyfill.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Pointer Events Polyfill: Adds support for the style attribute
|
| 3 |
+
* "pointer-events: none" to browsers without this feature (namely, IE).
|
| 4 |
+
* (c) 2013, Kent Mewhort, licensed under BSD. See LICENSE.txt for details.
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
// constructor
|
| 8 |
+
function PointerEventsPolyfill(options) {
|
| 9 |
+
// set defaults
|
| 10 |
+
this.options = {
|
| 11 |
+
selector: '*',
|
| 12 |
+
mouseEvents: ['click', 'dblclick', 'mousedown', 'mouseup'],
|
| 13 |
+
usePolyfillIf: function() {
|
| 14 |
+
if (navigator.appName == 'Microsoft Internet Explorer')
|
| 15 |
+
{
|
| 16 |
+
/* jshint ignore:start */
|
| 17 |
+
var agent = navigator.userAgent;
|
| 18 |
+
if (agent.match(/MSIE ([0-9]{1,}[\.0-9]{0,})/) != null) {
|
| 19 |
+
var version = parseFloat(RegExp.$1);
|
| 20 |
+
if (version < 11)
|
| 21 |
+
return true;
|
| 22 |
+
}
|
| 23 |
+
/* jshint ignore:end */
|
| 24 |
+
}
|
| 25 |
+
return false;
|
| 26 |
+
}
|
| 27 |
+
};
|
| 28 |
+
if (options) {
|
| 29 |
+
var obj = this;
|
| 30 |
+
$.each(options, function(k, v) {
|
| 31 |
+
obj.options[k] = v;
|
| 32 |
+
});
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
if (this.options.usePolyfillIf())
|
| 36 |
+
this.register_mouse_events();
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* singleton initializer
|
| 42 |
+
*
|
| 43 |
+
* @param {object} options Polyfill options.
|
| 44 |
+
* @return {object} The polyfill object.
|
| 45 |
+
*/
|
| 46 |
+
|
| 47 |
+
PointerEventsPolyfill.initialize = function(options) {
|
| 48 |
+
/* jshint ignore:start */
|
| 49 |
+
if (PointerEventsPolyfill.singleton == null)
|
| 50 |
+
PointerEventsPolyfill.singleton = new PointerEventsPolyfill(options);
|
| 51 |
+
/* jshint ignore:end */
|
| 52 |
+
return PointerEventsPolyfill.singleton;
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* handle mouse events w/ support for pointer-events: none
|
| 58 |
+
*/
|
| 59 |
+
PointerEventsPolyfill.prototype.register_mouse_events = function() {
|
| 60 |
+
// register on all elements (and all future elements) matching the selector
|
| 61 |
+
$(document).on(
|
| 62 |
+
this.options.mouseEvents.join(' '),
|
| 63 |
+
this.options.selector,
|
| 64 |
+
function(e) {
|
| 65 |
+
if ($(this).css('pointer-events') == 'none') {
|
| 66 |
+
// peak at the element below
|
| 67 |
+
var origDisplayAttribute = $(this).css('display');
|
| 68 |
+
$(this).css('display', 'none');
|
| 69 |
+
|
| 70 |
+
var underneathElem = document.elementFromPoint(
|
| 71 |
+
e.clientX,
|
| 72 |
+
e.clientY);
|
| 73 |
+
|
| 74 |
+
if (origDisplayAttribute)
|
| 75 |
+
$(this)
|
| 76 |
+
.css('display', origDisplayAttribute);
|
| 77 |
+
else
|
| 78 |
+
$(this).css('display', '');
|
| 79 |
+
|
| 80 |
+
// fire the mouse event on the element below
|
| 81 |
+
e.target = underneathElem;
|
| 82 |
+
$(underneathElem).trigger(e);
|
| 83 |
+
|
| 84 |
+
return false;
|
| 85 |
+
}
|
| 86 |
+
return true;
|
| 87 |
+
});
|
| 88 |
+
};
|
pool/shard007/JavaScript/0047859_user-access-right-task-collection-level-drop-spec.js
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* jshint globalstrict:true, strict:true, maxlen: 5000 */
|
| 2 |
+
/* global describe, before, after, it, require*/
|
| 3 |
+
|
| 4 |
+
// //////////////////////////////////////////////////////////////////////////////
|
| 5 |
+
// / @brief tests for user access rights
|
| 6 |
+
// /
|
| 7 |
+
// / @file
|
| 8 |
+
// /
|
| 9 |
+
// / DISCLAIMER
|
| 10 |
+
// /
|
| 11 |
+
// / Copyright 2017 ArangoDB GmbH, Cologne, Germany
|
| 12 |
+
// /
|
| 13 |
+
// / Licensed under the Apache License, Version 2.0 (the "License");
|
| 14 |
+
// / you may not use this file except in compliance with the License.
|
| 15 |
+
// / You may obtain a copy of the License at
|
| 16 |
+
// /
|
| 17 |
+
// / http://www.apache.org/licenses/LICENSE-2.0
|
| 18 |
+
// /
|
| 19 |
+
// / Unless required by applicable law or agreed to in writing, software
|
| 20 |
+
// / distributed under the License is distributed on an "AS IS" BASIS,
|
| 21 |
+
// / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 22 |
+
// / See the License for the specific language governing permissions and
|
| 23 |
+
// / limitations under the License.
|
| 24 |
+
// /
|
| 25 |
+
// / Copyright holder is ArangoDB GmbH, Cologne, Germany
|
| 26 |
+
// /
|
| 27 |
+
// / @author Michael Hackstein
|
| 28 |
+
// / @author Mark Vollmary
|
| 29 |
+
// / @author Copyright 2017, ArangoDB GmbH, Cologne, Germany
|
| 30 |
+
// //////////////////////////////////////////////////////////////////////////////
|
| 31 |
+
|
| 32 |
+
'use strict';
|
| 33 |
+
|
| 34 |
+
const expect = require('chai').expect;
|
| 35 |
+
const users = require('@arangodb/users');
|
| 36 |
+
const helper = require('@arangodb/user-helper');
|
| 37 |
+
const tasks = require('@arangodb/tasks');
|
| 38 |
+
const pu = require('@arangodb/process-utils');
|
| 39 |
+
const download = require('internal').download;
|
| 40 |
+
const dbName = helper.dbName;
|
| 41 |
+
const colName = helper.colName;
|
| 42 |
+
const rightLevels = helper.rightLevels;
|
| 43 |
+
const errors = require('@arangodb').errors;
|
| 44 |
+
const keySpaceId = 'task_collection_level_drop_keyspace';
|
| 45 |
+
|
| 46 |
+
const userSet = helper.userSet;
|
| 47 |
+
const systemLevel = helper.systemLevel;
|
| 48 |
+
const dbLevel = helper.dbLevel;
|
| 49 |
+
const colLevel = helper.colLevel;
|
| 50 |
+
|
| 51 |
+
const arango = require('internal').arango;
|
| 52 |
+
const db = require('internal').db;
|
| 53 |
+
for (let l of rightLevels) {
|
| 54 |
+
systemLevel[l] = new Set();
|
| 55 |
+
dbLevel[l] = new Set();
|
| 56 |
+
colLevel[l] = new Set();
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
const switchUser = (user, dbname) => {
|
| 60 |
+
arango.reconnect(arango.getEndpoint(), dbname, user, '');
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
const wait = (keySpaceId, key) => {
|
| 64 |
+
for (let i = 0; i < 200; i++) {
|
| 65 |
+
if (getKey(keySpaceId, key)) break;
|
| 66 |
+
require('internal').wait(0.1);
|
| 67 |
+
}
|
| 68 |
+
};
|
| 69 |
+
|
| 70 |
+
const createKeySpace = (keySpaceId) => {
|
| 71 |
+
return executeJS(`return global.KEYSPACE_CREATE('${keySpaceId}', 128, true);`).body === 'true';
|
| 72 |
+
};
|
| 73 |
+
|
| 74 |
+
const dropKeySpace = (keySpaceId) => {
|
| 75 |
+
executeJS(`global.KEYSPACE_DROP('${keySpaceId}');`);
|
| 76 |
+
};
|
| 77 |
+
|
| 78 |
+
const getKey = (keySpaceId, key) => {
|
| 79 |
+
return executeJS(`return global.KEY_GET('${keySpaceId}', '${key}');`).body === 'true';
|
| 80 |
+
};
|
| 81 |
+
|
| 82 |
+
const setKey = (keySpaceId, name) => {
|
| 83 |
+
return executeJS(`global.KEY_SET('${keySpaceId}', '${name}', false);`);
|
| 84 |
+
};
|
| 85 |
+
|
| 86 |
+
const executeJS = (code) => {
|
| 87 |
+
let httpOptions = pu.makeAuthorizationHeaders({
|
| 88 |
+
username: 'root',
|
| 89 |
+
password: ''
|
| 90 |
+
});
|
| 91 |
+
httpOptions.method = 'POST';
|
| 92 |
+
httpOptions.timeout = 1800;
|
| 93 |
+
httpOptions.returnBodyOnError = true;
|
| 94 |
+
return download(arango.getEndpoint().replace('tcp', 'http') + `/_db/${dbName}/_admin/execute?returnAsJSON=true`,
|
| 95 |
+
code,
|
| 96 |
+
httpOptions);
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
switchUser('root', '_system');
|
| 100 |
+
helper.removeAllUsers();
|
| 101 |
+
|
| 102 |
+
describe('User Rights Management', () => {
|
| 103 |
+
before(helper.generateAllUsers);
|
| 104 |
+
after(helper.removeAllUsers);
|
| 105 |
+
|
| 106 |
+
it('should check if all users are created', () => {
|
| 107 |
+
switchUser('root', '_system');
|
| 108 |
+
expect(userSet.size).to.equal(helper.userCount);
|
| 109 |
+
for (let name of userSet) {
|
| 110 |
+
expect(users.document(name), `Could not find user: ${name}`).to.not.be.undefined;
|
| 111 |
+
}
|
| 112 |
+
});
|
| 113 |
+
|
| 114 |
+
it('should test rights for', () => {
|
| 115 |
+
for (let name of userSet) {
|
| 116 |
+
let canUse = false;
|
| 117 |
+
try {
|
| 118 |
+
switchUser(name, dbName);
|
| 119 |
+
canUse = true;
|
| 120 |
+
} catch (e) {
|
| 121 |
+
canUse = false;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
if (canUse) {
|
| 125 |
+
describe(`user ${name}`, () => {
|
| 126 |
+
before(() => {
|
| 127 |
+
switchUser(name, dbName);
|
| 128 |
+
expect(createKeySpace(keySpaceId)).to.equal(true, 'keySpace creation failed!');
|
| 129 |
+
});
|
| 130 |
+
|
| 131 |
+
after(() => {
|
| 132 |
+
dropKeySpace(keySpaceId);
|
| 133 |
+
});
|
| 134 |
+
|
| 135 |
+
describe('update on collection level', () => {
|
| 136 |
+
const rootTestCollection = (switchBack = true) => {
|
| 137 |
+
switchUser('root', dbName);
|
| 138 |
+
let col = db._collection(colName);
|
| 139 |
+
if (switchBack) {
|
| 140 |
+
switchUser(name, dbName);
|
| 141 |
+
}
|
| 142 |
+
return col !== null;
|
| 143 |
+
};
|
| 144 |
+
|
| 145 |
+
const rootPrepareCollection = () => {
|
| 146 |
+
if (rootTestCollection(false)) {
|
| 147 |
+
db._collection(colName).truncate();
|
| 148 |
+
db._collection(colName).save({_key: '123'});
|
| 149 |
+
db._collection(colName).save({_key: '456'});
|
| 150 |
+
}
|
| 151 |
+
switchUser(name, dbName);
|
| 152 |
+
};
|
| 153 |
+
|
| 154 |
+
describe('remove a document', () => {
|
| 155 |
+
before(() => {
|
| 156 |
+
db._useDatabase(dbName);
|
| 157 |
+
rootPrepareCollection();
|
| 158 |
+
});
|
| 159 |
+
|
| 160 |
+
it('by key', () => {
|
| 161 |
+
expect(rootTestCollection()).to.equal(true, 'Precondition failed, the collection does not exist.');
|
| 162 |
+
setKey(keySpaceId, name);
|
| 163 |
+
const taskId = 'task_collection_level_drop_by_key' + name;
|
| 164 |
+
const task = {
|
| 165 |
+
id: taskId,
|
| 166 |
+
name: taskId,
|
| 167 |
+
command: `(function (params) {
|
| 168 |
+
try {
|
| 169 |
+
const db = require('@arangodb').db;
|
| 170 |
+
db._collection('${colName}').remove('123');
|
| 171 |
+
global.KEY_SET('${keySpaceId}', '${name}_status', true);
|
| 172 |
+
} catch (e) {
|
| 173 |
+
global.KEY_SET('${keySpaceId}', '${name}_status', false);
|
| 174 |
+
} finally {
|
| 175 |
+
global.KEY_SET('${keySpaceId}', '${name}', true);
|
| 176 |
+
}
|
| 177 |
+
})(params);`
|
| 178 |
+
};
|
| 179 |
+
if (dbLevel['rw'].has(name)) {
|
| 180 |
+
if ((dbLevel['rw'].has(name) || dbLevel['ro'].has(name)) &&
|
| 181 |
+
colLevel['rw'].has(name)) {
|
| 182 |
+
let col = db._collection(colName);
|
| 183 |
+
expect(col.document('123')._key).to.equal('123', 'Precondition failed, document does not exist.');
|
| 184 |
+
tasks.register(task);
|
| 185 |
+
wait(keySpaceId, name);
|
| 186 |
+
expect(getKey(keySpaceId, `${name}_status`)).to.equal(true, `${name} could not drop the document with sufficient rights`);
|
| 187 |
+
try {
|
| 188 |
+
col.document('123');
|
| 189 |
+
expect(true).to.be(false, `${name} could not drop the document with sufficient rights`);
|
| 190 |
+
} catch (e) {}
|
| 191 |
+
} else {
|
| 192 |
+
let hasReadAccess = ((dbLevel['rw'].has(name) || dbLevel['ro'].has(name)) &&
|
| 193 |
+
(colLevel['rw'].has(name) || colLevel['ro'].has(name)));
|
| 194 |
+
if (hasReadAccess) {
|
| 195 |
+
let col = db._collection(colName);
|
| 196 |
+
expect(col.document('123')._key).to.equal('123', 'Precondition failed, document does not exist.');
|
| 197 |
+
}
|
| 198 |
+
tasks.register(task);
|
| 199 |
+
wait(keySpaceId, name);
|
| 200 |
+
expect(getKey(keySpaceId, `${name}_status`)).to.not.equal(true, `${name} managed to remove the document with insufficient rights`);
|
| 201 |
+
if (hasReadAccess) {
|
| 202 |
+
let col = db._collection(colName);
|
| 203 |
+
try {
|
| 204 |
+
expect(col.document('123')._key).to.equal('123', `${name} managed to remove the document with insufficient rights`);
|
| 205 |
+
} catch (e) {}
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
} else {
|
| 209 |
+
try {
|
| 210 |
+
tasks.register(task);
|
| 211 |
+
expect(false).to.equal(true, `${name} managed to register a task with insufficient rights`);
|
| 212 |
+
} catch (e) {
|
| 213 |
+
expect(e.errorNum).to.equal(errors.ERROR_FORBIDDEN.code);
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
+
});
|
| 217 |
+
|
| 218 |
+
it('by aql', () => {
|
| 219 |
+
expect(rootTestCollection()).to.equal(true, 'Precondition failed, the collection does not exist');
|
| 220 |
+
let q = `REMOVE '456' IN ${colName} RETURN OLD`;
|
| 221 |
+
setKey(keySpaceId, name);
|
| 222 |
+
const taskId = 'task_collection_level_drop_by_key' + name;
|
| 223 |
+
const task = {
|
| 224 |
+
id: taskId,
|
| 225 |
+
name: taskId,
|
| 226 |
+
command: `(function (params) {
|
| 227 |
+
try {
|
| 228 |
+
const db = require('@arangodb').db;
|
| 229 |
+
db._query("${q}");
|
| 230 |
+
global.KEY_SET('${keySpaceId}', '${name}_status', true);
|
| 231 |
+
} catch (e) {
|
| 232 |
+
global.KEY_SET('${keySpaceId}', '${name}_status', false);
|
| 233 |
+
}finally {
|
| 234 |
+
global.KEY_SET('${keySpaceId}', '${name}', true);
|
| 235 |
+
}
|
| 236 |
+
})(params);`
|
| 237 |
+
};
|
| 238 |
+
if (dbLevel['rw'].has(name)) {
|
| 239 |
+
if ((dbLevel['rw'].has(name) || dbLevel['ro'].has(name)) &&
|
| 240 |
+
colLevel['rw'].has(name)) {
|
| 241 |
+
let col = db._collection(colName);
|
| 242 |
+
tasks.register(task);
|
| 243 |
+
wait(keySpaceId, name);
|
| 244 |
+
expect(getKey(keySpaceId, `${name}_status`)).to.equal(true, `${name} could not drop the document with sufficient rights`);
|
| 245 |
+
try {
|
| 246 |
+
col.document('456');
|
| 247 |
+
expect(true).to.be(false, 'Document still in collection after remove');
|
| 248 |
+
} catch (e) {}
|
| 249 |
+
} else {
|
| 250 |
+
let hasReadAccess = ((dbLevel['rw'].has(name) || dbLevel['ro'].has(name)) &&
|
| 251 |
+
(colLevel['rw'].has(name) || colLevel['ro'].has(name)));
|
| 252 |
+
tasks.register(task);
|
| 253 |
+
wait(keySpaceId, name);
|
| 254 |
+
expect(getKey(keySpaceId, `${name}_status`)).to.not.equal(true, `${name} managed to remove the document with insufficient rights`);
|
| 255 |
+
if (hasReadAccess) {
|
| 256 |
+
let col = db._collection(colName);
|
| 257 |
+
try {
|
| 258 |
+
expect(col.document('456')._key).to.equal('456', `${name} managed to remove the document with insufficient rights`);
|
| 259 |
+
} catch (e) {}
|
| 260 |
+
}
|
| 261 |
+
}
|
| 262 |
+
} else {
|
| 263 |
+
try {
|
| 264 |
+
tasks.register(task);
|
| 265 |
+
expect(false).to.equal(true, `${name} managed to register a task with insufficient rights`);
|
| 266 |
+
} catch (e) {
|
| 267 |
+
expect(e.errorNum).to.equal(errors.ERROR_FORBIDDEN.code);
|
| 268 |
+
}
|
| 269 |
+
}
|
| 270 |
+
});
|
| 271 |
+
});
|
| 272 |
+
});
|
| 273 |
+
});
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
});
|
| 277 |
+
});
|
pool/shard007/JavaScript/0047862_html_actuator.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function HTMLActuator() {
|
| 2 |
+
this.tileContainer = document.querySelector(".tile-container");
|
| 3 |
+
this.scoreContainer = document.querySelector(".score-container");
|
| 4 |
+
this.bestContainer = document.querySelector(".best-container");
|
| 5 |
+
this.messageContainer = document.querySelector(".game-message");
|
| 6 |
+
|
| 7 |
+
this.score = 0;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
HTMLActuator.prototype.actuate = function (grid, metadata, callback) {
|
| 11 |
+
var self = this;
|
| 12 |
+
|
| 13 |
+
window.requestAnimationFrame(function () {
|
| 14 |
+
self.clearContainer(self.tileContainer);
|
| 15 |
+
|
| 16 |
+
grid.cells.forEach(function (column) {
|
| 17 |
+
column.forEach(function (cell) {
|
| 18 |
+
if (cell) {
|
| 19 |
+
self.addTile(cell);
|
| 20 |
+
}
|
| 21 |
+
});
|
| 22 |
+
});
|
| 23 |
+
|
| 24 |
+
self.updateScore(metadata.score);
|
| 25 |
+
self.updateBestScore(metadata.bestScore);
|
| 26 |
+
|
| 27 |
+
if (metadata.terminated) {
|
| 28 |
+
if (metadata.over) {
|
| 29 |
+
self.message(false); // You lose
|
| 30 |
+
} else if (metadata.won) {
|
| 31 |
+
self.message(true); // You win!
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
if(callback) callback();
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
// Continues the game (both restart and keep playing)
|
| 40 |
+
HTMLActuator.prototype.continueGame = function () {
|
| 41 |
+
this.clearMessage();
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
HTMLActuator.prototype.clearContainer = function (container) {
|
| 45 |
+
while (container.firstChild) {
|
| 46 |
+
container.removeChild(container.firstChild);
|
| 47 |
+
}
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
HTMLActuator.prototype.addTile = function (tile) {
|
| 51 |
+
var self = this;
|
| 52 |
+
|
| 53 |
+
var wrapper = document.createElement("div");
|
| 54 |
+
var inner = document.createElement("div");
|
| 55 |
+
var position = tile.previousPosition || { x: tile.x, y: tile.y };
|
| 56 |
+
var positionClass = this.positionClass(position);
|
| 57 |
+
|
| 58 |
+
// We can't use classlist because it somehow glitches when replacing classes
|
| 59 |
+
var classes = ["tile", "tile-" + tile.value, positionClass];
|
| 60 |
+
|
| 61 |
+
if (tile.value > 2048) classes.push("tile-super");
|
| 62 |
+
|
| 63 |
+
this.applyClasses(wrapper, classes);
|
| 64 |
+
|
| 65 |
+
inner.classList.add("tile-inner");
|
| 66 |
+
inner.textContent = tile.value;
|
| 67 |
+
|
| 68 |
+
if (tile.previousPosition) {
|
| 69 |
+
// Make sure that the tile gets rendered in the previous position first
|
| 70 |
+
window.requestAnimationFrame(function () {
|
| 71 |
+
classes[2] = self.positionClass({ x: tile.x, y: tile.y });
|
| 72 |
+
self.applyClasses(wrapper, classes); // Update the position
|
| 73 |
+
});
|
| 74 |
+
} else if (tile.mergedFrom) {
|
| 75 |
+
classes.push("tile-merged");
|
| 76 |
+
this.applyClasses(wrapper, classes);
|
| 77 |
+
|
| 78 |
+
// Render the tiles that merged
|
| 79 |
+
tile.mergedFrom.forEach(function (merged) {
|
| 80 |
+
self.addTile(merged);
|
| 81 |
+
});
|
| 82 |
+
} else {
|
| 83 |
+
classes.push("tile-new");
|
| 84 |
+
this.applyClasses(wrapper, classes);
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
// Add the inner part of the tile to the wrapper
|
| 88 |
+
wrapper.appendChild(inner);
|
| 89 |
+
|
| 90 |
+
// Put the tile on the board
|
| 91 |
+
this.tileContainer.appendChild(wrapper);
|
| 92 |
+
};
|
| 93 |
+
|
| 94 |
+
HTMLActuator.prototype.applyClasses = function (element, classes) {
|
| 95 |
+
element.setAttribute("class", classes.join(" "));
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
HTMLActuator.prototype.normalizePosition = function (position) {
|
| 99 |
+
return { x: position.x + 1, y: position.y + 1 };
|
| 100 |
+
};
|
| 101 |
+
|
| 102 |
+
HTMLActuator.prototype.positionClass = function (position) {
|
| 103 |
+
position = this.normalizePosition(position);
|
| 104 |
+
return "tile-position-" + position.x + "-" + position.y;
|
| 105 |
+
};
|
| 106 |
+
|
| 107 |
+
HTMLActuator.prototype.updateScore = function (score) {
|
| 108 |
+
this.clearContainer(this.scoreContainer);
|
| 109 |
+
|
| 110 |
+
var difference = score - this.score;
|
| 111 |
+
this.score = score;
|
| 112 |
+
|
| 113 |
+
this.scoreContainer.textContent = this.score;
|
| 114 |
+
|
| 115 |
+
if (difference > 0) {
|
| 116 |
+
var addition = document.createElement("div");
|
| 117 |
+
addition.classList.add("score-addition");
|
| 118 |
+
addition.textContent = "+" + difference;
|
| 119 |
+
|
| 120 |
+
this.scoreContainer.appendChild(addition);
|
| 121 |
+
}
|
| 122 |
+
};
|
| 123 |
+
|
| 124 |
+
HTMLActuator.prototype.updateBestScore = function (bestScore) {
|
| 125 |
+
this.bestContainer.textContent = bestScore;
|
| 126 |
+
};
|
| 127 |
+
|
| 128 |
+
HTMLActuator.prototype.message = function (won) {
|
| 129 |
+
var type = won ? "game-won" : "game-over";
|
| 130 |
+
var message = won ? "You win!" : "Game over!";
|
| 131 |
+
|
| 132 |
+
this.messageContainer.classList.add(type);
|
| 133 |
+
this.messageContainer.getElementsByTagName("p")[0].textContent = message;
|
| 134 |
+
};
|
| 135 |
+
|
| 136 |
+
HTMLActuator.prototype.clearMessage = function () {
|
| 137 |
+
// IE only takes one value to remove at a time.
|
| 138 |
+
this.messageContainer.classList.remove("game-won");
|
| 139 |
+
this.messageContainer.classList.remove("game-over");
|
| 140 |
+
};
|
pool/shard007/JavaScript/0047863_howter.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*jslint ass: true, forin: true, plusplus: true, regexp: true */
|
| 2 |
+
(function (global) {
|
| 3 |
+
|
| 4 |
+
'use strict';
|
| 5 |
+
|
| 6 |
+
var h = global.Howter || {},
|
| 7 |
+
routes = {},
|
| 8 |
+
routesCount = 0,
|
| 9 |
+
shared = {};
|
| 10 |
+
|
| 11 |
+
// Ember.js inspired root
|
| 12 |
+
// (http://emberjs.com/guides/routing/#toc_specifying-a-root-url).
|
| 13 |
+
h.root = h.root || '';
|
| 14 |
+
|
| 15 |
+
// Dispatch a path.
|
| 16 |
+
h.dispatch = function (path) {
|
| 17 |
+
var name;
|
| 18 |
+
|
| 19 |
+
// Trailing slashes are not meaningful.
|
| 20 |
+
path = path.replace(/\/$/, '');
|
| 21 |
+
|
| 22 |
+
for (name in routes) {
|
| 23 |
+
routes[name].test(path);
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
return this;
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
// Laravel inspired route prefixing
|
| 30 |
+
// (http://laravel.com/docs/routing#route-prefixing).
|
| 31 |
+
h.prefix = function (prefix, callback) {
|
| 32 |
+
var oldRoot = this.root;
|
| 33 |
+
|
| 34 |
+
this.root += prefix;
|
| 35 |
+
|
| 36 |
+
callback.call(this);
|
| 37 |
+
|
| 38 |
+
this.root = oldRoot;
|
| 39 |
+
|
| 40 |
+
return this;
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
// Get a route or set a new one.
|
| 44 |
+
h.route = function (paths, callback, name) {
|
| 45 |
+
var i;
|
| 46 |
+
|
| 47 |
+
// Getter...
|
| 48 |
+
if (callback === undefined) {
|
| 49 |
+
name = paths;
|
| 50 |
+
|
| 51 |
+
return routes[name];
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
// ... or setter.
|
| 55 |
+
if (paths.constructor !== Array) {
|
| 56 |
+
paths = [paths];
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
for (i = 0; i < paths.length; i++) {
|
| 60 |
+
if (paths[i].constructor === String) {
|
| 61 |
+
paths[i] = this.root + paths[i];
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
name = name || routesCount;
|
| 66 |
+
routes[name] = new h.Route(paths, callback);
|
| 67 |
+
|
| 68 |
+
routesCount++;
|
| 69 |
+
|
| 70 |
+
return this;
|
| 71 |
+
};
|
| 72 |
+
|
| 73 |
+
// Universal data sharing.
|
| 74 |
+
h.share = function (key, data) {
|
| 75 |
+
// Getter...
|
| 76 |
+
if (data === undefined) {
|
| 77 |
+
return shared[key];
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
// ... or setter.
|
| 81 |
+
shared[key] = data;
|
| 82 |
+
|
| 83 |
+
return this;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
// Export.
|
| 87 |
+
global.Howter = h;
|
| 88 |
+
|
| 89 |
+
}(this));
|
pool/shard007/JavaScript/0047865_blogPost.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from "react";
|
| 2 |
+
import Link from "gatsby-link";
|
| 3 |
+
import Helmet from "react-helmet";
|
| 4 |
+
import { DiscussionEmbed } from "disqus-react";
|
| 5 |
+
|
| 6 |
+
import styles from "../styles/Post.module.css";
|
| 7 |
+
|
| 8 |
+
export default function Template({ data }) {
|
| 9 |
+
// this prop will be injected by the GraphQL query below.
|
| 10 |
+
const { markdownRemark, allMarkdownRemark } = data; // data.markdownRemark holds our post data
|
| 11 |
+
const { frontmatter, html } = markdownRemark;
|
| 12 |
+
const post = markdownRemark.frontmatter;
|
| 13 |
+
|
| 14 |
+
const disqusShortname = "mateoolarte";
|
| 15 |
+
|
| 16 |
+
const disqusConfig = {
|
| 17 |
+
url: post.url,
|
| 18 |
+
identifier: post.id.toString(),
|
| 19 |
+
title: post.title
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
const currentPostTitle = frontmatter.title;
|
| 23 |
+
const postsShuffled = allMarkdownRemark.edges
|
| 24 |
+
.map(a => [Math.random(), a])
|
| 25 |
+
.sort((a, b) => a[0] - b[0])
|
| 26 |
+
.map(a => a[1]);
|
| 27 |
+
let otherPosts = [];
|
| 28 |
+
|
| 29 |
+
postsShuffled.forEach((edge, index) => {
|
| 30 |
+
if (edge.node.frontmatter.title !== currentPostTitle) {
|
| 31 |
+
if (otherPosts.length !== 3) {
|
| 32 |
+
otherPosts.push(edge);
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
return otherPosts;
|
| 37 |
+
});
|
| 38 |
+
|
| 39 |
+
return (
|
| 40 |
+
<article className={styles.post}>
|
| 41 |
+
<Helmet title={frontmatter.title} />
|
| 42 |
+
<header className={styles.postHeader}>
|
| 43 |
+
<h1 className={styles.postTitle}>{frontmatter.title}</h1>
|
| 44 |
+
<h2 className={styles.postDate}>{frontmatter.date}</h2>
|
| 45 |
+
<figure className={styles.postHeaderImg}>
|
| 46 |
+
<img
|
| 47 |
+
src={frontmatter.cover}
|
| 48 |
+
alt={frontmatter.title}
|
| 49 |
+
/>
|
| 50 |
+
{frontmatter.copyright.length > 0 && (
|
| 51 |
+
<figcaption className={styles.postHeaderCaption}>Tomado de: <a href={frontmatter.copyright}>{frontmatter.copyright}</a></figcaption>
|
| 52 |
+
)}
|
| 53 |
+
</figure>
|
| 54 |
+
</header>
|
| 55 |
+
<div
|
| 56 |
+
className={styles.postContent}
|
| 57 |
+
dangerouslySetInnerHTML={{ __html: markdownRemark.html }}
|
| 58 |
+
/>
|
| 59 |
+
{allMarkdownRemark.edges.length > 2 && (
|
| 60 |
+
<footer className={styles.postOthers}>
|
| 61 |
+
<h3 className={`${styles.postOthersHeading} heading`}>
|
| 62 |
+
También te puede interesar
|
| 63 |
+
</h3>
|
| 64 |
+
<div className={styles.postOthersContainer}>
|
| 65 |
+
{otherPosts.map((post, i) => {
|
| 66 |
+
return (
|
| 67 |
+
<Link
|
| 68 |
+
to={post.node.frontmatter.path}
|
| 69 |
+
className={styles.postOthersItem}
|
| 70 |
+
key={i}
|
| 71 |
+
>
|
| 72 |
+
<img
|
| 73 |
+
src={post.node.frontmatter.thumbnail}
|
| 74 |
+
className={styles.postOthersImage}
|
| 75 |
+
alt={post.node.frontmatter.title}
|
| 76 |
+
/>
|
| 77 |
+
<h5 className={styles.postOthersTitle}>
|
| 78 |
+
{post.node.frontmatter.title}
|
| 79 |
+
</h5>
|
| 80 |
+
</Link>
|
| 81 |
+
);
|
| 82 |
+
})}
|
| 83 |
+
</div>
|
| 84 |
+
</footer>
|
| 85 |
+
)}
|
| 86 |
+
<DiscussionEmbed shortname={disqusShortname} config={disqusConfig} />
|
| 87 |
+
</article>
|
| 88 |
+
);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
export const pageQuery = graphql`
|
| 92 |
+
query IndexQueryAndBlogPostByPath($path: String!) {
|
| 93 |
+
markdownRemark(frontmatter: { path: { eq: $path } }) {
|
| 94 |
+
html
|
| 95 |
+
frontmatter {
|
| 96 |
+
id
|
| 97 |
+
url
|
| 98 |
+
date(formatString: "MMMM DD, YYYY")
|
| 99 |
+
path
|
| 100 |
+
title
|
| 101 |
+
thumbnail
|
| 102 |
+
cover
|
| 103 |
+
copyright
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
allMarkdownRemark(limit: 10) {
|
| 108 |
+
edges {
|
| 109 |
+
node {
|
| 110 |
+
frontmatter {
|
| 111 |
+
path
|
| 112 |
+
title
|
| 113 |
+
thumbnail
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
`;
|
pool/shard007/JavaScript/0047872_login.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
app
|
| 3 |
+
.component('login',
|
| 4 |
+
{
|
| 5 |
+
templateUrl: 'spa/src/components/login/login.html',
|
| 6 |
+
controller: function ($scope, $state, LoginService, SweetAlert) {
|
| 7 |
+
const $ctrl = this;
|
| 8 |
+
$ctrl.title = 'Login';
|
| 9 |
+
$ctrl.logIn = (username, password) => LoginService.login(username, password)
|
| 10 |
+
.then(response => {
|
| 11 |
+
if (response.status === 200) {
|
| 12 |
+
angular.copy(response, $scope.token);
|
| 13 |
+
$state.go('dashboard');
|
| 14 |
+
}
|
| 15 |
+
if (response.status === 404) {
|
| 16 |
+
SweetAlert.swal("Email or passwrod incorect");
|
| 17 |
+
$ctrl.password = '';
|
| 18 |
+
$ctrl.username = '';
|
| 19 |
+
}
|
| 20 |
+
});
|
| 21 |
+
$ctrl.signUp = () => $state.go('sign-up');
|
| 22 |
+
$ctrl.goToHome = () => $state.go('dashboard');
|
| 23 |
+
}
|
| 24 |
+
});
|
pool/shard007/JavaScript/0047873_tickets.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
$(document).on('turbolinks:load', function() {
|
| 2 |
+
|
| 3 |
+
// Next Ticket button functionality
|
| 4 |
+
$(function () {
|
| 5 |
+
$("#js-next").on("click", function() {
|
| 6 |
+
var nextId = parseInt($("#js-next").attr("data-id")) + 1;
|
| 7 |
+
$.getJSON(`/tickets/${nextId}`, function(data){
|
| 8 |
+
|
| 9 |
+
// Updates Ticket information after "Next Ticket" is clicked
|
| 10 |
+
$(".ticketTitle").text(data["title"]);
|
| 11 |
+
$(".ticketId").text(data["id"]);
|
| 12 |
+
var date = new Date(data["due_date"])
|
| 13 |
+
$(".ticketDueDate").text(`${date.getMonth()+1}/${date.getDate()}/${date.getFullYear()}`);
|
| 14 |
+
$(".ticketLocation").text(data["user_tickets"][0]["location"]);
|
| 15 |
+
$(".ticketStatus").text(data["status"]);
|
| 16 |
+
$("#js-next").attr("data-id", data["id"]);
|
| 17 |
+
window.history.replaceState( {}, null, `${data["id"]}`); // Updates browser URL to visible Ticket
|
| 18 |
+
|
| 19 |
+
// Edit and Delete Tickets button attributes are updated when Next Ticket is pressed.
|
| 20 |
+
$("#edit-ticket-button").attr("href", `/tickets/${data["id"]}/edit`);
|
| 21 |
+
$("#delete-ticket-button").attr({
|
| 22 |
+
"data-confirm": "Are you sure?",
|
| 23 |
+
"class": "btn btn-danger btn-xs",
|
| 24 |
+
"rel": "nofollow",
|
| 25 |
+
"data-method": "delete",
|
| 26 |
+
"href": `/tickets/${data["id"]}`
|
| 27 |
+
});
|
| 28 |
+
|
| 29 |
+
// Updates Issues information after "Next Ticket" is clicked.
|
| 30 |
+
$(".list-group").text("") // Clears out visible issues.
|
| 31 |
+
data["issues"].forEach(function(el) {
|
| 32 |
+
var li = document.createElement('li');
|
| 33 |
+
li.setAttribute('class', 'list-group-item')
|
| 34 |
+
li.innerHTML = `<span class="badge">${el["status"]}</span><a href="/tickets/${el["ticket_id"]}/issues/${el["id"]}">${el["title"]}</a>`;
|
| 35 |
+
$(".list-group").append(li);
|
| 36 |
+
});
|
| 37 |
+
|
| 38 |
+
// Add Issue button href is updated when Next Ticket is pressed"
|
| 39 |
+
$("#add-issue-button").attr("href", `/tickets/${data["id"]}/issues/new`);
|
| 40 |
+
});
|
| 41 |
+
});
|
| 42 |
+
});
|
| 43 |
+
|
| 44 |
+
// New Issue Form is Serialized and Posted. New Issue Section is cleared out.
|
| 45 |
+
$(function () {
|
| 46 |
+
$("#add-issue-button").on("click", function(e) {
|
| 47 |
+
$addIssueButton = $("a#add-issue-button")
|
| 48 |
+
$("a#add-issue-button").remove(); // Removes the Add Issue button
|
| 49 |
+
|
| 50 |
+
$.get(this.href).success(function(response) { // Goes out and grabs HTML from this.href
|
| 51 |
+
$("#new-issue-form").html(response); // Add the New Issue Form to #new-issue-form element in HTML
|
| 52 |
+
|
| 53 |
+
// New Issue Form is loaded and adds new Issue to <li> after Submitted.
|
| 54 |
+
$('form').submit(function(e){
|
| 55 |
+
var values = $(this).serialize();
|
| 56 |
+
var action = $('form').attr("action");
|
| 57 |
+
var posting = $.post(action, values);
|
| 58 |
+
|
| 59 |
+
posting.done(function(data) {
|
| 60 |
+
var li = document.createElement('li');
|
| 61 |
+
li.setAttribute('class', 'list-group-item')
|
| 62 |
+
li.innerHTML = `<span class="badge">${data["status"]}</span><a href="/tickets/${data["ticket_id"]}/issues/${data["id"]}">${data["title"]}</a>`;
|
| 63 |
+
$(".list-group").append(li); // Append new issue to <li>
|
| 64 |
+
$("div.jumbotron").append($addIssueButton); // Append the Add Issue back
|
| 65 |
+
});
|
| 66 |
+
$("#new-issue-section").text("") //clears out New Issue form html
|
| 67 |
+
e.preventDefault();
|
| 68 |
+
});
|
| 69 |
+
});
|
| 70 |
+
e.preventDefault();
|
| 71 |
+
});
|
| 72 |
+
});
|
| 73 |
+
|
| 74 |
+
});
|
pool/shard007/JavaScript/0047875_app.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var express = require('express');
|
| 2 |
+
var path = require('path');
|
| 3 |
+
var favicon = require('static-favicon');
|
| 4 |
+
var logger = require('morgan');
|
| 5 |
+
var cookieParser = require('cookie-parser');
|
| 6 |
+
var bodyParser = require('body-parser');
|
| 7 |
+
|
| 8 |
+
var routes = require('./routes/index');
|
| 9 |
+
var users = require('./routes/users');
|
| 10 |
+
var json = require('./routes/json');
|
| 11 |
+
var getallbids = require('./routes/getallbids');
|
| 12 |
+
var getbids = require('./routes/getbids');
|
| 13 |
+
var makebid = require('./routes/makebid');
|
| 14 |
+
var createuser = require('./routes/createuser');
|
| 15 |
+
|
| 16 |
+
var app = express();
|
| 17 |
+
|
| 18 |
+
// view engine setup
|
| 19 |
+
app.set('views', path.join(__dirname, 'views'));
|
| 20 |
+
app.set('view engine', 'jade');
|
| 21 |
+
|
| 22 |
+
app.use(favicon());
|
| 23 |
+
app.use(logger('dev'));
|
| 24 |
+
app.use(bodyParser.json());
|
| 25 |
+
app.use(bodyParser.urlencoded());
|
| 26 |
+
app.use(cookieParser());
|
| 27 |
+
app.use(require('stylus').middleware(path.join(__dirname, 'public')));
|
| 28 |
+
app.use(express.static(path.join(__dirname, 'public')));
|
| 29 |
+
|
| 30 |
+
app.use('/', routes);
|
| 31 |
+
app.use('/users', users);
|
| 32 |
+
app.use('/json', json);
|
| 33 |
+
app.use('/getallbids', getallbids);
|
| 34 |
+
app.use('/getbids', getbids);
|
| 35 |
+
app.use('/makebid', makebid);
|
| 36 |
+
app.use('/createuser', createuser);
|
| 37 |
+
|
| 38 |
+
/// catch 404 and forwarding to error handler
|
| 39 |
+
app.use(function (req, res, next) {
|
| 40 |
+
var err = new Error('Not Found 404');
|
| 41 |
+
err.status = 404;
|
| 42 |
+
next(err);
|
| 43 |
+
});
|
| 44 |
+
|
| 45 |
+
/// error handlers
|
| 46 |
+
|
| 47 |
+
// development error handler
|
| 48 |
+
// will print stacktrace
|
| 49 |
+
if (app.get('env') === 'development') {
|
| 50 |
+
app.use(function (err, req, res, next) {
|
| 51 |
+
res.status(err.status || 500);
|
| 52 |
+
res.render('error', {
|
| 53 |
+
message: err.message,
|
| 54 |
+
error: err
|
| 55 |
+
});
|
| 56 |
+
});
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
// production error handler
|
| 60 |
+
// no stacktraces leaked to user
|
| 61 |
+
app.use(function (err, req, res, next) {
|
| 62 |
+
res.status(err.status || 500);
|
| 63 |
+
res.render('error', {
|
| 64 |
+
message: err.message,
|
| 65 |
+
error: {}
|
| 66 |
+
});
|
| 67 |
+
});
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
module.exports = app;
|
pool/shard007/JavaScript/0047877_qa_annotation_listing.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
dc.ui.QAAnnotationListing = dc.ui.BaseAnnotationListing.extend({
|
| 2 |
+
|
| 3 |
+
showApprove: true,
|
| 4 |
+
showReject: true,
|
| 5 |
+
|
| 6 |
+
initialize: function() {
|
| 7 |
+
dc.ui.BaseAnnotationListing.prototype.initialize.apply(this, arguments);
|
| 8 |
+
|
| 9 |
+
this.events['click .approve_item'] = 'handleApprove';
|
| 10 |
+
this.events['click .reject_item'] = 'handleReject';
|
| 11 |
+
this.events['click .point_note'] = 'handleEditNote';
|
| 12 |
+
},
|
| 13 |
+
|
| 14 |
+
render : function() {
|
| 15 |
+
dc.ui.BaseAnnotationListing.prototype.render.apply(this, arguments);
|
| 16 |
+
|
| 17 |
+
this.$('.clone_item').hide();
|
| 18 |
+
this.$('.delete_item').hide();
|
| 19 |
+
|
| 20 |
+
if( this.model.get('approved') ) { this.setApprove(); }
|
| 21 |
+
if( this.model.get('qa_reject_note') != null ){ this.setReject(); }
|
| 22 |
+
|
| 23 |
+
return this;
|
| 24 |
+
},
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
//setApprove: Sets UI to approved
|
| 28 |
+
setApprove: function(){
|
| 29 |
+
this.$('.approve_item').hide();
|
| 30 |
+
this.$('.point_note').hide();
|
| 31 |
+
this.$('.row_status').removeClass('incomplete');
|
| 32 |
+
this.$('.row_status').removeClass('rejected');
|
| 33 |
+
this.$('.row_status').addClass('complete');
|
| 34 |
+
this.$('.reject_item').show().css('display', 'inline-block');
|
| 35 |
+
},
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
//setReject: Sets UI to rejected
|
| 39 |
+
setReject: function(){
|
| 40 |
+
this.$('.reject_item').hide();
|
| 41 |
+
this.$('.row_status').removeClass('incomplete');
|
| 42 |
+
this.$('.row_status').removeClass('complete');
|
| 43 |
+
this.$('.row_status').addClass('rejected');
|
| 44 |
+
this.$('.approve_item').show().css('display', 'inline-block');
|
| 45 |
+
this.$('.point_note').show().css('display', 'inline-block');
|
| 46 |
+
},
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
handleApprove: function(){
|
| 50 |
+
this.model.set({approved: true, qa_reject_note: null});
|
| 51 |
+
this.setApprove(false);
|
| 52 |
+
this.trigger('qaAddress', this);
|
| 53 |
+
},
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
handleReject: function(){
|
| 57 |
+
var _thisView = this;
|
| 58 |
+
dc.ui.QARejectDialog.open(_thisView.model, false, function(){
|
| 59 |
+
_thisView.setReject();
|
| 60 |
+
_thisView.trigger('qaAddress', _thisView);
|
| 61 |
+
});
|
| 62 |
+
},
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
handleEditNote: function(){
|
| 66 |
+
var _thisView = this;
|
| 67 |
+
dc.ui.QARejectDialog.open(_thisView.model, function(){});
|
| 68 |
+
}
|
| 69 |
+
});
|
pool/shard007/JavaScript/0047880_app.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Express from 'express';
|
| 2 |
+
import compression from 'compression';
|
| 3 |
+
import http from 'http';
|
| 4 |
+
import favicon from 'serve-favicon';
|
| 5 |
+
import Path from 'path';
|
| 6 |
+
import chalk from 'chalk';
|
| 7 |
+
import httpProxy from 'http-proxy';
|
| 8 |
+
import { default as routes } from '../routes';
|
| 9 |
+
import { checkAuth, RenderPage } from '../../../common/server/middleware';
|
| 10 |
+
import {getConfig} from '../../../common/utils/helpers';
|
| 11 |
+
|
| 12 |
+
const {apiPort} = getConfig().default;
|
| 13 |
+
|
| 14 |
+
const proxy = httpProxy.createServer({
|
| 15 |
+
target: `http://127.0.0.1:${apiPort}/api`
|
| 16 |
+
});
|
| 17 |
+
|
| 18 |
+
proxy.on('error', (error, req, res) => {
|
| 19 |
+
let json;
|
| 20 |
+
if (error.code !== 'ECONNRESET') {
|
| 21 |
+
console.error('proxy error', error);
|
| 22 |
+
}
|
| 23 |
+
if (!res.headersSent) {
|
| 24 |
+
res.writeHead(500, {'content-type': 'application/json'});
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
json = {error: 'proxy_error', reason: error.message};
|
| 28 |
+
res.end(JSON.stringify(json));
|
| 29 |
+
});
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
const renderPage = RenderPage({ routes });
|
| 33 |
+
const app = new Express();
|
| 34 |
+
const server = new http.Server(app);
|
| 35 |
+
const serverPort = process.env.PORT;
|
| 36 |
+
const staticRoot = Path.join(__dirname, '../../../../', `statics/${__APPNAME__}`);
|
| 37 |
+
|
| 38 |
+
app.use(compression());
|
| 39 |
+
app.use(favicon(Path.join(staticRoot, 'favicon_.ico')));
|
| 40 |
+
app.use(Express.static(staticRoot));
|
| 41 |
+
|
| 42 |
+
app.use('/api', (req, res) => {
|
| 43 |
+
proxy.web(req, res)
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
app.use(checkAuth, renderPage);
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
app.use((req, res, next)=>{
|
| 51 |
+
console.log('sss');
|
| 52 |
+
res.status(404).send('not_found');
|
| 53 |
+
});
|
| 54 |
+
|
| 55 |
+
server.listen(serverPort, (err) => {
|
| 56 |
+
if (err)
|
| 57 |
+
return console.render(chalk.red(err));
|
| 58 |
+
console.log(chalk.green('Server is running on port:'), serverPort);
|
| 59 |
+
});
|
pool/shard007/JavaScript/0047883_2010002.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
This file is part of the OdinMS Maple Story Server
|
| 3 |
+
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
| 4 |
+
Matthias Butz <matze@odinms.de>
|
| 5 |
+
Jan Christian Meyer <vimes@odinms.de>
|
| 6 |
+
|
| 7 |
+
This program is free software: you can redistribute it and/or modify
|
| 8 |
+
it under the terms of the GNU Affero General Public License version 3
|
| 9 |
+
as published by the Free Software Foundation. You may not use, modify
|
| 10 |
+
or distribute this program under any other version of the
|
| 11 |
+
GNU Affero General Public License.
|
| 12 |
+
|
| 13 |
+
This program is distributed in the hope that it will be useful,
|
| 14 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 16 |
+
GNU Affero General Public License for more details.
|
| 17 |
+
|
| 18 |
+
You should have received a copy of the GNU Affero General Public License
|
| 19 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
/* Franz the Owner
|
| 23 |
+
Orbis VIP Eye Change.
|
| 24 |
+
*/
|
| 25 |
+
var status = 0;
|
| 26 |
+
var beauty = 0;
|
| 27 |
+
var price = 1000000;
|
| 28 |
+
var mface = Array(20000, 20001, 20002, 20003, 20004, 20005, 20006, 20007, 20008, 20012, 20014);
|
| 29 |
+
var fface = Array(21000, 21001, 21002, 21003, 21004, 21005, 21006, 21007, 21008, 21012, 21014);
|
| 30 |
+
var facenew = Array();
|
| 31 |
+
|
| 32 |
+
function start() {
|
| 33 |
+
status = -1;
|
| 34 |
+
action(1, 0, 0);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function action(mode, type, selection) {
|
| 38 |
+
if (mode == -1) {
|
| 39 |
+
cm.dispose();
|
| 40 |
+
} else {
|
| 41 |
+
if (mode == 0 && status == 0) {
|
| 42 |
+
cm.dispose();
|
| 43 |
+
return;
|
| 44 |
+
}
|
| 45 |
+
if (mode == 1)
|
| 46 |
+
status++;
|
| 47 |
+
else
|
| 48 |
+
status--;
|
| 49 |
+
if (status == 0) {
|
| 50 |
+
cm.sendSimple("Well well well, welcome to the Orbis Plastic Surgery! Would you like to transform your face into something new? With a #b#t5152005##k, you can let us take care of the rest and have the face you've always wanted~!\r\n#L1#I would like to buy a #b#t5152005##k for " + price + " mesos, please!#l\r\n\#L2#I already have a Coupon!#l");
|
| 51 |
+
} else if (status == 1) {
|
| 52 |
+
if (selection == 1) {
|
| 53 |
+
if(cm.getMeso() >= price) {
|
| 54 |
+
cm.gainMeso(-price);
|
| 55 |
+
cm.gainItem(5152005, 1);
|
| 56 |
+
cm.sendOk("Enjoy!");
|
| 57 |
+
} else {
|
| 58 |
+
cm.sendOk("You don't have enough mesos to buy a coupon!");
|
| 59 |
+
}
|
| 60 |
+
cm.dispose();
|
| 61 |
+
} else if (selection == 2) {
|
| 62 |
+
facenew = Array();
|
| 63 |
+
if (cm.getPlayer().getGender() == 0) {
|
| 64 |
+
for(var i = 0; i < mface.length; i++) {
|
| 65 |
+
facenew.push(mface[i] + cm.getPlayer().getFace()
|
| 66 |
+
% 1000 - (cm.getPlayer().getFace()
|
| 67 |
+
% 100));
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
if (cm.getPlayer().getGender() == 1) {
|
| 71 |
+
for(var i = 0; i < fface.length; i++) {
|
| 72 |
+
facenew.push(fface[i] + cm.getPlayer().getFace()
|
| 73 |
+
% 1000 - (cm.getPlayer().getFace()
|
| 74 |
+
% 100));
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
cm.sendStyle("I can totally transform your face into something new... how about giving us a try? For #b#t5152005##k, you can get the face of your liking...take your time in choosing the face of your preference.", facenew);
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
else if (status == 2){
|
| 81 |
+
cm.dispose();
|
| 82 |
+
if (cm.haveItem(5152005) == true){
|
| 83 |
+
cm.gainItem(5152005, -1);
|
| 84 |
+
cm.setFace(facenew[selection]);
|
| 85 |
+
cm.sendOk("Enjoy your new and improved face!");
|
| 86 |
+
} else {
|
| 87 |
+
cm.sendOk("Hmm ... it looks like you don't have the coupon specifically for this place. Sorry to say this, but without the coupon, there's no plastic surgery for you...");
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
}
|
pool/shard007/JavaScript/0047885_test.controller.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function () {
|
| 2 |
+
'use strict';
|
| 3 |
+
|
| 4 |
+
angular
|
| 5 |
+
.module('jfy')
|
| 6 |
+
.controller('TestController', TestController);
|
| 7 |
+
|
| 8 |
+
/** @ngInject */
|
| 9 |
+
function TestController($scope, ImportExportToExcel) {
|
| 10 |
+
var vm = this;
|
| 11 |
+
|
| 12 |
+
vm.tableData = [{a: 1, b: 10}, {a: 2, b: 20}];
|
| 13 |
+
vm.export = function () {
|
| 14 |
+
ImportExportToExcel.exportToExcel('test', vm.tableData);
|
| 15 |
+
};
|
| 16 |
+
$scope.$on('import-excel-data', function (e, v) {
|
| 17 |
+
console.log('excel-data:', v)
|
| 18 |
+
});
|
| 19 |
+
}
|
| 20 |
+
})();
|
pool/shard007/JavaScript/0047889_CompositeSprite.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
This file is part of Ext JS 4.2
|
| 3 |
+
|
| 4 |
+
Copyright (c) 2011-2013 Sencha Inc
|
| 5 |
+
|
| 6 |
+
Contact: http://www.sencha.com/contact
|
| 7 |
+
|
| 8 |
+
Commercial Usage
|
| 9 |
+
Licensees holding valid commercial licenses may use this file in accordance with the Commercial
|
| 10 |
+
Software License Agreement provided with the Software or, alternatively, in accordance with the
|
| 11 |
+
terms contained in a written agreement between you and Sencha.
|
| 12 |
+
|
| 13 |
+
If you are unsure which license is appropriate for your use, please contact the sales department
|
| 14 |
+
at http://www.sencha.com/contact.
|
| 15 |
+
|
| 16 |
+
Build date: 2013-09-18 17:18:59 (940c324ac822b840618a3a8b2b4b873f83a1a9b1)
|
| 17 |
+
*/
|
| 18 |
+
/**
|
| 19 |
+
* @class Ext.fx.target.CompositeSprite
|
| 20 |
+
|
| 21 |
+
This class represents a animation target for a {@link Ext.draw.CompositeSprite}. It allows
|
| 22 |
+
each {@link Ext.draw.Sprite} in the group to be animated as a whole. In general this class will not be
|
| 23 |
+
created directly, the {@link Ext.draw.CompositeSprite} will be passed to the animation and
|
| 24 |
+
and the appropriate target will be created.
|
| 25 |
+
|
| 26 |
+
* @markdown
|
| 27 |
+
*/
|
| 28 |
+
|
| 29 |
+
Ext.define('Ext.fx.target.CompositeSprite', {
|
| 30 |
+
|
| 31 |
+
/* Begin Definitions */
|
| 32 |
+
|
| 33 |
+
extend: 'Ext.fx.target.Sprite',
|
| 34 |
+
|
| 35 |
+
/* End Definitions */
|
| 36 |
+
|
| 37 |
+
getAttr: function(attr, val) {
|
| 38 |
+
var out = [],
|
| 39 |
+
sprites = [].concat(this.target.items),
|
| 40 |
+
length = sprites.length,
|
| 41 |
+
i,
|
| 42 |
+
sprite;
|
| 43 |
+
|
| 44 |
+
for (i = 0; i < length; i++) {
|
| 45 |
+
sprite = sprites[i];
|
| 46 |
+
out.push([sprite, val != undefined ? val : this.getFromPrim(sprite, attr)]);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
return out;
|
| 50 |
+
}
|
| 51 |
+
});
|
pool/shard007/JavaScript/0047898_queensland.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
import { REQUEST_TIMEOUT } from '../lib/constants';
|
| 4 |
+
import { default as baseRequest } from 'request';
|
| 5 |
+
import _ from 'lodash';
|
| 6 |
+
import { default as moment } from 'moment-timezone';
|
| 7 |
+
import cheerio from 'cheerio';
|
| 8 |
+
import { removeUnwantedParameters } from '../lib/utils';
|
| 9 |
+
const request = baseRequest.defaults({timeout: REQUEST_TIMEOUT});
|
| 10 |
+
|
| 11 |
+
exports.name = 'queensland';
|
| 12 |
+
|
| 13 |
+
exports.fetchData = function (source, cb) {
|
| 14 |
+
request(source.url, function (err, res, body) {
|
| 15 |
+
if (err || res.statusCode !== 200) {
|
| 16 |
+
return cb(err || res);
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
try {
|
| 20 |
+
var data = formatData(body, source);
|
| 21 |
+
var result = {
|
| 22 |
+
name: 'unused',
|
| 23 |
+
measurements: _.flatten(data)
|
| 24 |
+
};
|
| 25 |
+
|
| 26 |
+
result.measurements = removeUnwantedParameters(result.measurements);
|
| 27 |
+
return cb(null, result);
|
| 28 |
+
} catch (e) {
|
| 29 |
+
return cb({message: 'Unknown adapter error.'});
|
| 30 |
+
}
|
| 31 |
+
});
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
const renameParameter = function (parameter) {
|
| 35 |
+
switch (parameter) {
|
| 36 |
+
case 'Nitrogen Dioxide':
|
| 37 |
+
return 'no2';
|
| 38 |
+
case 'Sulfur Dioxide':
|
| 39 |
+
return 'so2';
|
| 40 |
+
case 'Carbon Monoxide':
|
| 41 |
+
return 'co';
|
| 42 |
+
case 'Particle PM2.5':
|
| 43 |
+
return 'pm25';
|
| 44 |
+
case 'Ozone':
|
| 45 |
+
return 'o3';
|
| 46 |
+
case 'Particle PM10':
|
| 47 |
+
return 'pm10';
|
| 48 |
+
default:
|
| 49 |
+
return parameter;
|
| 50 |
+
}
|
| 51 |
+
};
|
| 52 |
+
|
| 53 |
+
const getParameterUnit = function (parameter) {
|
| 54 |
+
switch (parameter) {
|
| 55 |
+
case 'pm25':
|
| 56 |
+
case 'pm10':
|
| 57 |
+
case 'bc':
|
| 58 |
+
return 'µg/m³';
|
| 59 |
+
case 'no2':
|
| 60 |
+
case 'so2':
|
| 61 |
+
case 'o3':
|
| 62 |
+
case 'co':
|
| 63 |
+
return 'ppm';
|
| 64 |
+
default:
|
| 65 |
+
return '?';
|
| 66 |
+
}
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
// hardcoded coordinates for locations with no coordinates from source
|
| 70 |
+
var locationCoordinates = {
|
| 71 |
+
'Miles Airport': { latitude: -26.8088, longitude: 150.1799 },
|
| 72 |
+
'Hopeland': { latitude: -26.8637, longitude: 150.5028 }
|
| 73 |
+
};
|
| 74 |
+
|
| 75 |
+
var formatData = function (data, source) {
|
| 76 |
+
var $ = cheerio.load(data, {xmlMode: true});
|
| 77 |
+
|
| 78 |
+
var dateStr = $('category').attr('measurementdate') + $('category').attr('measurementhour');
|
| 79 |
+
var date = moment.tz(dateStr, 'YYYY-MM-DDHH', 'Australia/Queensland');
|
| 80 |
+
var dates = {utc: date.toDate(), local: date.format()};
|
| 81 |
+
|
| 82 |
+
var measurements = [];
|
| 83 |
+
|
| 84 |
+
$('measurement').each(function (i, elem) {
|
| 85 |
+
var location = $(this).parent().attr('name');
|
| 86 |
+
var param = renameParameter($(this).attr('name'));
|
| 87 |
+
|
| 88 |
+
var m = {
|
| 89 |
+
date: dates,
|
| 90 |
+
parameter: param,
|
| 91 |
+
location: location,
|
| 92 |
+
value: Number($(this).text()),
|
| 93 |
+
unit: getParameterUnit(param),
|
| 94 |
+
city: $(this).parent().parent().attr('name'),
|
| 95 |
+
attribution: [{
|
| 96 |
+
name: 'The State of Queensland (Department of Environment and Science)',
|
| 97 |
+
url: source.sourceURL
|
| 98 |
+
}, {
|
| 99 |
+
name: 'The State of Queensland (Department of Environment and Science)',
|
| 100 |
+
url: $(this).parent().attr('information')
|
| 101 |
+
}],
|
| 102 |
+
averagingPeriod: {'value': 1, 'unit': 'hours'}
|
| 103 |
+
};
|
| 104 |
+
|
| 105 |
+
// Add coordinates if they're available
|
| 106 |
+
if ($(this).parent().attr('latitude') && $(this).parent().attr('longitude') && Number($(this).parent().attr('latitude')) !== 0 && Number($(this).parent().attr('longitude')) !== 0) {
|
| 107 |
+
m.coordinates = {
|
| 108 |
+
latitude: Number($(this).parent().attr('latitude')),
|
| 109 |
+
longitude: Number($(this).parent().attr('longitude'))
|
| 110 |
+
};
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
if (!m.coordinates && locationCoordinates[m.location]) {
|
| 114 |
+
m.coordinates = locationCoordinates[m.location];
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
measurements.push(m);
|
| 118 |
+
});
|
| 119 |
+
|
| 120 |
+
return measurements;
|
| 121 |
+
};
|
pool/shard007/JavaScript/0047899_product.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
const ProductCtrl = require('../ctrl/product');
|
| 4 |
+
|
| 5 |
+
module.exports = class ProductRoutes {
|
| 6 |
+
static init(router) {
|
| 7 |
+
|
| 8 |
+
router
|
| 9 |
+
.route('/api/v1/products')
|
| 10 |
+
.get(ProductCtrl.list)
|
| 11 |
+
.post(ProductCtrl.save);
|
| 12 |
+
|
| 13 |
+
router
|
| 14 |
+
.route('/api/v1/products/:id')
|
| 15 |
+
.get(ProductCtrl.getWithCartNumb)
|
| 16 |
+
.delete(ProductCtrl.delete);
|
| 17 |
+
|
| 18 |
+
}
|
| 19 |
+
}
|
pool/shard007/JavaScript/0047900_users.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var express = require('express');
|
| 2 |
+
var router = express.Router();
|
| 3 |
+
var User = require('../models/User');
|
| 4 |
+
|
| 5 |
+
/* GET users listing. */
|
| 6 |
+
router.get('/', function(req, res, next) {
|
| 7 |
+
res.send('respond with a resource');
|
| 8 |
+
});
|
| 9 |
+
|
| 10 |
+
router.get('/check',function (req, res, next) {
|
| 11 |
+
console.log('get usercheck---');
|
| 12 |
+
res.end()
|
| 13 |
+
});
|
| 14 |
+
|
| 15 |
+
router.post('/reg', function(req,res,next) {
|
| 16 |
+
var data = req.body;
|
| 17 |
+
|
| 18 |
+
// 这个回调黑洞真是要命!!! 想用Promise!!!!想用await!!!
|
| 19 |
+
User.findOne({user_name: data.user_name},function(err,user){
|
| 20 |
+
if (err) {
|
| 21 |
+
res.send(new Error(err));
|
| 22 |
+
} else {
|
| 23 |
+
if (user) {
|
| 24 |
+
console.log('user---',user);
|
| 25 |
+
res.send({msg:"exist"})
|
| 26 |
+
} else {
|
| 27 |
+
|
| 28 |
+
User.findOne({email: data.email}, function(err,user){
|
| 29 |
+
if (err) {
|
| 30 |
+
res.send(new Error(err));
|
| 31 |
+
} else {
|
| 32 |
+
if (user) {res.send({msg: 'email_exist'})} else {
|
| 33 |
+
var newUser = new User({
|
| 34 |
+
user_name: data.user_name,
|
| 35 |
+
email: data.email,
|
| 36 |
+
password: data.password,
|
| 37 |
+
});
|
| 38 |
+
newUser.save();
|
| 39 |
+
res.send({msg: 'success'})
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
})
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
})
|
| 46 |
+
|
| 47 |
+
});
|
| 48 |
+
|
| 49 |
+
router.post('/login', function(req, res, next) {
|
| 50 |
+
var data = req.body;
|
| 51 |
+
console.log('data---',data);
|
| 52 |
+
User.findOne({email: data.email},function(err,user){
|
| 53 |
+
console.log('err',err,'user',user);
|
| 54 |
+
if (err) {
|
| 55 |
+
res.send(new Error(err))
|
| 56 |
+
} else {
|
| 57 |
+
if (user) {
|
| 58 |
+
if (user.password == data.password) {
|
| 59 |
+
// 登录成功的后端操作 todo
|
| 60 |
+
res.send({msg:'success',token:user._id});
|
| 61 |
+
} else {
|
| 62 |
+
res.send({msg: 'pass_err'})
|
| 63 |
+
}
|
| 64 |
+
} else {
|
| 65 |
+
res.send({msg:'not_exist'})
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
})
|
| 69 |
+
});
|
| 70 |
+
|
| 71 |
+
module.exports = router;
|
pool/shard007/JavaScript/0047904_InvoiceSettingsApi.spec.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* AvaTax Brazil
|
| 3 |
+
* The Avatax-Brazil API exposes the most commonly services available for interacting with the AvaTax-Brazil services, allowing calculation of taxes, issuing electronic invoice documents and modifying existing transactions when allowed by tax authorities. This API is exclusively for use by business with a physical presence in Brazil.
|
| 4 |
+
*
|
| 5 |
+
* OpenAPI spec version: 1.0
|
| 6 |
+
*
|
| 7 |
+
*
|
| 8 |
+
* NOTE: This class is auto generated by the swagger code generator program.
|
| 9 |
+
* https://github.com/swagger-api/swagger-codegen.git
|
| 10 |
+
* Do not edit the class manually.
|
| 11 |
+
*
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
(function(root, factory) {
|
| 15 |
+
if (typeof define === 'function' && define.amd) {
|
| 16 |
+
// AMD.
|
| 17 |
+
define(['expect.js', '../../src/index'], factory);
|
| 18 |
+
} else if (typeof module === 'object' && module.exports) {
|
| 19 |
+
// CommonJS-like environments that support module.exports, like Node.
|
| 20 |
+
factory(require('expect.js'), require('../../src/index'));
|
| 21 |
+
} else {
|
| 22 |
+
// Browser globals (root is window)
|
| 23 |
+
factory(root.expect, root.AvaTaxBrazil);
|
| 24 |
+
}
|
| 25 |
+
}(this, function(expect, AvaTaxBrazil) {
|
| 26 |
+
'use strict';
|
| 27 |
+
|
| 28 |
+
var instance;
|
| 29 |
+
|
| 30 |
+
beforeEach(function() {
|
| 31 |
+
instance = new AvaTaxBrazil.InvoiceSettingsApi();
|
| 32 |
+
});
|
| 33 |
+
|
| 34 |
+
var getProperty = function(object, getter, property) {
|
| 35 |
+
// Use getter method if present; otherwise, get the property directly.
|
| 36 |
+
if (typeof object[getter] === 'function')
|
| 37 |
+
return object[getter]();
|
| 38 |
+
else
|
| 39 |
+
return object[property];
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
var setProperty = function(object, setter, property, value) {
|
| 43 |
+
// Use setter method if present; otherwise, set the property directly.
|
| 44 |
+
if (typeof object[setter] === 'function')
|
| 45 |
+
object[setter](value);
|
| 46 |
+
else
|
| 47 |
+
object[property] = value;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
describe('InvoiceSettingsApi', function() {
|
| 51 |
+
describe('invoiceSettings', function() {
|
| 52 |
+
it('should call invoiceSettings successfully', function(done) {
|
| 53 |
+
//uncomment below and update the code to test invoiceSettings
|
| 54 |
+
//instance.invoiceSettings(function(error) {
|
| 55 |
+
// if (error) throw error;
|
| 56 |
+
//expect().to.be();
|
| 57 |
+
//});
|
| 58 |
+
done();
|
| 59 |
+
});
|
| 60 |
+
});
|
| 61 |
+
});
|
| 62 |
+
|
| 63 |
+
}));
|
pool/shard007/JavaScript/0047908_race-participant-detail.controller.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function() {
|
| 2 |
+
'use strict';
|
| 3 |
+
|
| 4 |
+
angular
|
| 5 |
+
.module('gpmrApp')
|
| 6 |
+
.controller('RaceParticipantDetailController', RaceParticipantDetailController);
|
| 7 |
+
|
| 8 |
+
RaceParticipantDetailController.$inject = ['$scope', '$rootScope', '$stateParams', 'entity', 'RaceParticipant'];
|
| 9 |
+
|
| 10 |
+
function RaceParticipantDetailController($scope, $rootScope, $stateParams, entity, RaceParticipant) {
|
| 11 |
+
var vm = this;
|
| 12 |
+
vm.raceParticipant = entity;
|
| 13 |
+
|
| 14 |
+
var unsubscribe = $rootScope.$on('gpmrApp:raceParticipantUpdate', function(event, result) {
|
| 15 |
+
vm.raceParticipant = result;
|
| 16 |
+
});
|
| 17 |
+
$scope.$on('$destroy', unsubscribe);
|
| 18 |
+
|
| 19 |
+
}
|
| 20 |
+
})();
|
pool/shard007/JavaScript/0047909_app.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var express = require('express');
|
| 2 |
+
var path = require('path');
|
| 3 |
+
var pogg = require('pogg').globalize();
|
| 4 |
+
|
| 5 |
+
var routes = require('./routes/index');
|
| 6 |
+
|
| 7 |
+
var app = express();
|
| 8 |
+
|
| 9 |
+
// view engine setup
|
| 10 |
+
app.set('views', path.join(__dirname, 'views'));
|
| 11 |
+
app.set('view engine', 'ejs');
|
| 12 |
+
app.set('title', '<%= name %>');
|
| 13 |
+
logg.big.green(app.get('title'));
|
| 14 |
+
|
| 15 |
+
app.use(express.static(path.join(__dirname, 'public')));
|
| 16 |
+
|
| 17 |
+
app.use('/', routes);
|
| 18 |
+
|
| 19 |
+
// catch 404 and forward to error handler
|
| 20 |
+
app.use(function (req, res, next) {
|
| 21 |
+
var err = new Error('Not Found');
|
| 22 |
+
err.status = 404;
|
| 23 |
+
next(err);
|
| 24 |
+
});
|
| 25 |
+
|
| 26 |
+
// error handlers
|
| 27 |
+
|
| 28 |
+
// development error handler
|
| 29 |
+
// will print stacktrace
|
| 30 |
+
if (app.get('env') === 'development') {
|
| 31 |
+
app.use(function (err, req, res, next) {
|
| 32 |
+
res.status(err.status || 500);
|
| 33 |
+
res.render('error', {
|
| 34 |
+
message: err.message,
|
| 35 |
+
error: err
|
| 36 |
+
});
|
| 37 |
+
});
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
// production error handler
|
| 41 |
+
// no stacktraces leaked to user
|
| 42 |
+
app.use(function (err, req, res, next) {
|
| 43 |
+
res.status(err.status || 500);
|
| 44 |
+
res.render('error', {
|
| 45 |
+
message: err.message,
|
| 46 |
+
error: {}
|
| 47 |
+
});
|
| 48 |
+
});
|
| 49 |
+
|
| 50 |
+
//Set port to env.Port or default to 1337
|
| 51 |
+
app.set('port', process.env.PORT || 1337);
|
| 52 |
+
//Listen to port for connections
|
| 53 |
+
app.listen(app.get('port'), function () {
|
| 54 |
+
// delay so these info show after the big title log
|
| 55 |
+
setTimeout(function () {
|
| 56 |
+
logg.green('> port: ' + app.get('port'));
|
| 57 |
+
logg.green('> pid: ' + process.pid);
|
| 58 |
+
logg.green('> env: ' + process.env.NODE_ENV);
|
| 59 |
+
}, 10);
|
| 60 |
+
});
|
| 61 |
+
|
| 62 |
+
process.on('SIGTERM', function () {
|
| 63 |
+
console.log('Connection terminated');
|
| 64 |
+
});
|
| 65 |
+
|
| 66 |
+
module.exports = app;
|
| 67 |
+
|
pool/shard007/JavaScript/0047911_ProfileAddressForm.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import PropTypes from 'prop-types';
|
| 3 |
+
import { compose, branch, renderComponent, setPropTypes, pure } from 'recompose';
|
| 4 |
+
import Yup from 'yup';
|
| 5 |
+
import { withFormik } from 'formik';
|
| 6 |
+
import get from 'lodash/get';
|
| 7 |
+
import ActivityIndicator from '@ui/ActivityIndicator';
|
| 8 |
+
import * as Inputs from '@ui/inputs';
|
| 9 |
+
import TableView from '@ui/TableView';
|
| 10 |
+
import PaddedView from '@ui/PaddedView';
|
| 11 |
+
import withUser from '@data/withUser';
|
| 12 |
+
import Button from '@ui/Button';
|
| 13 |
+
import { H6 } from '@ui/typography';
|
| 14 |
+
import styled from '@ui/styled';
|
| 15 |
+
import { withFieldValueHandler, withFieldTouchedHandler } from './formikSetters';
|
| 16 |
+
|
| 17 |
+
const Status = styled({ textAlign: 'center' })(H6);
|
| 18 |
+
|
| 19 |
+
const enhance = compose(
|
| 20 |
+
setPropTypes({
|
| 21 |
+
createFieldTouchedHandler: PropTypes.func,
|
| 22 |
+
handleSubmit: PropTypes.func,
|
| 23 |
+
countries: PropTypes.arrayOf(
|
| 24 |
+
PropTypes.shape({
|
| 25 |
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
| 26 |
+
label: PropTypes.string,
|
| 27 |
+
}),
|
| 28 |
+
),
|
| 29 |
+
states: PropTypes.arrayOf(
|
| 30 |
+
PropTypes.shape({
|
| 31 |
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
| 32 |
+
label: PropTypes.string,
|
| 33 |
+
}),
|
| 34 |
+
),
|
| 35 |
+
values: PropTypes.shape({
|
| 36 |
+
street1: PropTypes.string,
|
| 37 |
+
street2: PropTypes.string,
|
| 38 |
+
countryId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
| 39 |
+
city: PropTypes.string,
|
| 40 |
+
stateId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
| 41 |
+
zip: PropTypes.string,
|
| 42 |
+
}),
|
| 43 |
+
createFieldValueHandler: PropTypes.func,
|
| 44 |
+
errors: PropTypes.shape({
|
| 45 |
+
street1: PropTypes.string,
|
| 46 |
+
street2: PropTypes.string,
|
| 47 |
+
countryId: PropTypes.string,
|
| 48 |
+
city: PropTypes.string,
|
| 49 |
+
stateId: PropTypes.string,
|
| 50 |
+
zip: PropTypes.string,
|
| 51 |
+
}),
|
| 52 |
+
touched: PropTypes.shape({
|
| 53 |
+
street1: PropTypes.bool,
|
| 54 |
+
street2: PropTypes.bool,
|
| 55 |
+
countryId: PropTypes.bool,
|
| 56 |
+
city: PropTypes.bool,
|
| 57 |
+
stateId: PropTypes.bool,
|
| 58 |
+
zip: PropTypes.bool,
|
| 59 |
+
}),
|
| 60 |
+
isSubmitting: PropTypes.bool,
|
| 61 |
+
isValid: PropTypes.bool,
|
| 62 |
+
status: PropTypes.string,
|
| 63 |
+
}),
|
| 64 |
+
);
|
| 65 |
+
|
| 66 |
+
export const ProfileAddressFormWithoutData = enhance(
|
| 67 |
+
({
|
| 68 |
+
createFieldTouchedHandler,
|
| 69 |
+
handleSubmit,
|
| 70 |
+
values,
|
| 71 |
+
countries,
|
| 72 |
+
states,
|
| 73 |
+
createFieldValueHandler,
|
| 74 |
+
errors,
|
| 75 |
+
touched,
|
| 76 |
+
isSubmitting,
|
| 77 |
+
isValid,
|
| 78 |
+
status,
|
| 79 |
+
}) => {
|
| 80 |
+
const isUSOrCanada = values.countryId === 'US' || values.countryId === 'CA';
|
| 81 |
+
return (
|
| 82 |
+
<PaddedView horizontal={false}>
|
| 83 |
+
<TableView>
|
| 84 |
+
<PaddedView>
|
| 85 |
+
<Inputs.Text
|
| 86 |
+
label="Street"
|
| 87 |
+
value={values.street1}
|
| 88 |
+
onChangeText={createFieldValueHandler('street1')}
|
| 89 |
+
onBlur={createFieldTouchedHandler('street1')}
|
| 90 |
+
error={touched.street1 && errors.street1}
|
| 91 |
+
/>
|
| 92 |
+
<Inputs.Text
|
| 93 |
+
label="Street 2 (Optional)"
|
| 94 |
+
value={values.street2}
|
| 95 |
+
onChangeText={createFieldValueHandler('street2')}
|
| 96 |
+
onBlur={createFieldTouchedHandler('street2')}
|
| 97 |
+
error={touched.street2 && errors.street2}
|
| 98 |
+
/>
|
| 99 |
+
<Inputs.Picker
|
| 100 |
+
label="Country"
|
| 101 |
+
value={values.countryId}
|
| 102 |
+
displayValue={get(
|
| 103 |
+
countries.find(country => country.id === values.countryId),
|
| 104 |
+
'label',
|
| 105 |
+
)}
|
| 106 |
+
onValueChange={createFieldValueHandler('countryId')}
|
| 107 |
+
error={touched.countryId && errors.countryId}
|
| 108 |
+
>
|
| 109 |
+
{countries.map(({ label, id }) => (
|
| 110 |
+
<Inputs.PickerItem label={label} value={id} key={id} />
|
| 111 |
+
))}
|
| 112 |
+
</Inputs.Picker>
|
| 113 |
+
<Inputs.Text
|
| 114 |
+
label="City"
|
| 115 |
+
value={values.city}
|
| 116 |
+
onChangeText={createFieldValueHandler('city')}
|
| 117 |
+
onBlur={createFieldTouchedHandler('city')}
|
| 118 |
+
error={touched.city && errors.city}
|
| 119 |
+
/>
|
| 120 |
+
{isUSOrCanada && (
|
| 121 |
+
<Inputs.Picker
|
| 122 |
+
label="State/Territory"
|
| 123 |
+
value={values.stateId}
|
| 124 |
+
displayValue={get(states.find(state => state.id === values.stateId), 'label')}
|
| 125 |
+
onValueChange={createFieldValueHandler('stateId')}
|
| 126 |
+
error={touched.stateId && errors.stateId}
|
| 127 |
+
>
|
| 128 |
+
{states.map(({ label, id }) => (
|
| 129 |
+
<Inputs.PickerItem label={label} value={id} key={id} />
|
| 130 |
+
))}
|
| 131 |
+
</Inputs.Picker>
|
| 132 |
+
)}
|
| 133 |
+
<Inputs.Text
|
| 134 |
+
label="Zip"
|
| 135 |
+
value={values.zip}
|
| 136 |
+
onChangeText={createFieldValueHandler('zip')}
|
| 137 |
+
onBlur={createFieldTouchedHandler('zip')}
|
| 138 |
+
error={touched.zip && errors.zip}
|
| 139 |
+
/>
|
| 140 |
+
</PaddedView>
|
| 141 |
+
</TableView>
|
| 142 |
+
{status ? <Status>{status}</Status> : null}
|
| 143 |
+
<PaddedView>
|
| 144 |
+
<Button onPress={handleSubmit} title="Save" disabled={!isValid} loading={isSubmitting} />
|
| 145 |
+
</PaddedView>
|
| 146 |
+
</PaddedView>
|
| 147 |
+
);
|
| 148 |
+
},
|
| 149 |
+
);
|
| 150 |
+
|
| 151 |
+
const validationSchema = Yup.object().shape({
|
| 152 |
+
street1: Yup.string(),
|
| 153 |
+
street2: Yup.string().nullable(),
|
| 154 |
+
city: Yup.string(),
|
| 155 |
+
stateId: Yup.string(),
|
| 156 |
+
countryId: Yup.string(),
|
| 157 |
+
zip: Yup.string(),
|
| 158 |
+
});
|
| 159 |
+
|
| 160 |
+
const mapPropsToValues = props => ({
|
| 161 |
+
street1: get(props, 'user.home.street1', ''),
|
| 162 |
+
street2: get(props, 'user.home.street2', ''),
|
| 163 |
+
city: get(props, 'user.home.city', ''),
|
| 164 |
+
stateId: get(props, 'user.home.state') || 'SC',
|
| 165 |
+
countryId: get(props, 'user.home.country') || 'US',
|
| 166 |
+
zip: get(props, 'user.home.zip', ''),
|
| 167 |
+
});
|
| 168 |
+
|
| 169 |
+
const ProfileAddressForm = compose(
|
| 170 |
+
pure,
|
| 171 |
+
withUser,
|
| 172 |
+
branch(({ isLoading }) => isLoading, renderComponent(ActivityIndicator)),
|
| 173 |
+
withFormik({
|
| 174 |
+
mapPropsToValues,
|
| 175 |
+
validationSchema,
|
| 176 |
+
handleSubmit: async (values, { props, setSubmitting, setStatus }) => {
|
| 177 |
+
setSubmitting(true);
|
| 178 |
+
try {
|
| 179 |
+
await props.updateHomeAddress({
|
| 180 |
+
id: props.person.home.id,
|
| 181 |
+
street1: values.street1,
|
| 182 |
+
street2: values.street2,
|
| 183 |
+
countryId: values.countryId,
|
| 184 |
+
city: values.city,
|
| 185 |
+
stateId: values.stateId,
|
| 186 |
+
zip: values.zip,
|
| 187 |
+
});
|
| 188 |
+
setStatus('Your address was updated.');
|
| 189 |
+
} catch (e) {
|
| 190 |
+
setStatus('There was an error. Please try again.');
|
| 191 |
+
}
|
| 192 |
+
setSubmitting(false);
|
| 193 |
+
},
|
| 194 |
+
isInitialValid(props) {
|
| 195 |
+
return validationSchema.isValidSync(mapPropsToValues(props));
|
| 196 |
+
},
|
| 197 |
+
}),
|
| 198 |
+
withFieldValueHandler,
|
| 199 |
+
withFieldTouchedHandler,
|
| 200 |
+
)(ProfileAddressFormWithoutData);
|
| 201 |
+
|
| 202 |
+
export default ProfileAddressForm;
|
pool/shard007/JavaScript/0047923_users.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module.exports = function(setData, onError) {
|
| 3 |
+
|
| 4 |
+
var client = Ti.Network.createHTTPClient({
|
| 5 |
+
onload:function() {
|
| 6 |
+
//Ti.API.error(this.responseText);
|
| 7 |
+
|
| 8 |
+
var result = JSON.parse(this.responseText);
|
| 9 |
+
|
| 10 |
+
if (result.status = 'ok') {
|
| 11 |
+
setData(result.data);
|
| 12 |
+
} else {
|
| 13 |
+
alert(result.message);
|
| 14 |
+
}
|
| 15 |
+
},
|
| 16 |
+
onerror:function(e) {
|
| 17 |
+
Ti.API.error('error de conexión');
|
| 18 |
+
onError();
|
| 19 |
+
},
|
| 20 |
+
timeout:15000
|
| 21 |
+
});
|
| 22 |
+
Alloy = require('alloy');
|
| 23 |
+
client.open('POST', Alloy.CFG.url + '/users/json');
|
| 24 |
+
|
| 25 |
+
client.send({
|
| 26 |
+
w:Ti.Platform.displayCaps.platformWidth,
|
| 27 |
+
h:Ti.Platform.displayCaps.platformHeight
|
| 28 |
+
});
|
| 29 |
+
|
| 30 |
+
}
|
pool/shard007/JavaScript/0047924_ScreenWithToolbar.spec.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { Component } from 'react';
|
| 2 |
+
import { View, Text } from 'react-native';
|
| 3 |
+
import renderer from 'react-test-renderer';
|
| 4 |
+
import ScreenWithToolbar from './ScreenWithToolbar';
|
| 5 |
+
|
| 6 |
+
describe('<ScreenWithToolbar />', () => {
|
| 7 |
+
let props;
|
| 8 |
+
const screenWithToolbar = (children) => renderer.create(<ScreenWithToolbar {...props}>{children}</ScreenWithToolbar>);
|
| 9 |
+
|
| 10 |
+
beforeEach(() => {
|
| 11 |
+
props = {
|
| 12 |
+
title: undefined,
|
| 13 |
+
navigation: undefined
|
| 14 |
+
};
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
it('should render correctly', () => {
|
| 18 |
+
props.title = 'Schedule';
|
| 19 |
+
props.navigation = { navigate: () => {} };
|
| 20 |
+
expect(screenWithToolbar(<SomeChild />)).toMatchSnapshot();
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
const SomeChild = () => {
|
| 24 |
+
return <View>
|
| 25 |
+
<Text>hi</Text>
|
| 26 |
+
</View>
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
});
|
pool/shard007/JavaScript/0047926_plugin.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
|
| 3 |
+
For licensing, see LICENSE.html or http://ckeditor.com/license
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* @file Preview plugin.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
(function()
|
| 11 |
+
{
|
| 12 |
+
var previewCmd =
|
| 13 |
+
{
|
| 14 |
+
modes : { wysiwyg:1, source:1 },
|
| 15 |
+
canUndo : false,
|
| 16 |
+
exec : function( editor )
|
| 17 |
+
{
|
| 18 |
+
var sHTML,
|
| 19 |
+
config = editor.config,
|
| 20 |
+
baseTag = config.baseHref ? '<base href="' + config.baseHref + '"/>' : '',
|
| 21 |
+
isCustomDomain = CKEDITOR.env.isCustomDomain();
|
| 22 |
+
|
| 23 |
+
if ( config.fullPage )
|
| 24 |
+
{
|
| 25 |
+
sHTML = editor.getData()
|
| 26 |
+
.replace( /<head>/, '$&' + baseTag )
|
| 27 |
+
.replace( /[^>]*(?=<\/title>)/, editor.lang.preview );
|
| 28 |
+
}
|
| 29 |
+
else
|
| 30 |
+
{
|
| 31 |
+
var bodyHtml = '<body ',
|
| 32 |
+
body = editor.document && editor.document.getBody();
|
| 33 |
+
|
| 34 |
+
if ( body )
|
| 35 |
+
{
|
| 36 |
+
if ( body.getAttribute( 'id' ) )
|
| 37 |
+
bodyHtml += 'id="' + body.getAttribute( 'id' ) + '" ';
|
| 38 |
+
if ( body.getAttribute( 'class' ) )
|
| 39 |
+
bodyHtml += 'class="' + body.getAttribute( 'class' ) + '" ';
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
bodyHtml += '>';
|
| 43 |
+
|
| 44 |
+
sHTML =
|
| 45 |
+
editor.config.docType +
|
| 46 |
+
'<html dir="' + editor.config.contentsLangDirection + '">' +
|
| 47 |
+
'<head>' +
|
| 48 |
+
baseTag +
|
| 49 |
+
'<title>' + editor.lang.preview + '</title>' +
|
| 50 |
+
CKEDITOR.tools.buildStyleHtml( editor.config.contentsCss ) +
|
| 51 |
+
'</head>' + bodyHtml +
|
| 52 |
+
editor.getData() +
|
| 53 |
+
'</body></html>';
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
var iWidth = 640, // 800 * 0.8,
|
| 57 |
+
iHeight = 420, // 600 * 0.7,
|
| 58 |
+
iLeft = 80; // (800 - 0.8 * 800) /2 = 800 * 0.1.
|
| 59 |
+
try
|
| 60 |
+
{
|
| 61 |
+
var screen = window.screen;
|
| 62 |
+
iWidth = Math.round( screen.width * 0.8 );
|
| 63 |
+
iHeight = Math.round( screen.height * 0.7 );
|
| 64 |
+
iLeft = Math.round( screen.width * 0.1 );
|
| 65 |
+
}
|
| 66 |
+
catch ( e ){}
|
| 67 |
+
|
| 68 |
+
var sOpenUrl = '';
|
| 69 |
+
if ( isCustomDomain )
|
| 70 |
+
{
|
| 71 |
+
window._cke_htmlToLoad = sHTML;
|
| 72 |
+
sOpenUrl = 'javascript:void( (function(){' +
|
| 73 |
+
'document.open();' +
|
| 74 |
+
'document.domain="' + document.domain + '";' +
|
| 75 |
+
'document.write( window.opener._cke_htmlToLoad );' +
|
| 76 |
+
'document.close();' +
|
| 77 |
+
'window.opener._cke_htmlToLoad = null;' +
|
| 78 |
+
'})() )';
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
var oWindow = window.open( sOpenUrl, null, 'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' +
|
| 82 |
+
iWidth + ',height=' + iHeight + ',left=' + iLeft );
|
| 83 |
+
|
| 84 |
+
if ( !isCustomDomain )
|
| 85 |
+
{
|
| 86 |
+
oWindow.document.open();
|
| 87 |
+
oWindow.document.write( sHTML );
|
| 88 |
+
oWindow.document.close();
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
};
|
| 92 |
+
|
| 93 |
+
var pluginName = 'preview';
|
| 94 |
+
|
| 95 |
+
// Register a plugin named "preview".
|
| 96 |
+
CKEDITOR.plugins.add( pluginName,
|
| 97 |
+
{
|
| 98 |
+
init : function( editor )
|
| 99 |
+
{
|
| 100 |
+
editor.addCommand( pluginName, previewCmd );
|
| 101 |
+
editor.ui.addButton( 'Preview',
|
| 102 |
+
{
|
| 103 |
+
label : editor.lang.preview,
|
| 104 |
+
command : pluginName
|
| 105 |
+
});
|
| 106 |
+
}
|
| 107 |
+
});
|
| 108 |
+
})();
|
pool/shard007/JavaScript/0047932_SelectFilter2.js
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*global SelectBox, gettext, interpolate, quickElement, SelectFilter*/
|
| 2 |
+
/*
|
| 3 |
+
SelectFilter2 - Turns a multiple-select box into a filter interface.
|
| 4 |
+
|
| 5 |
+
Requires jQuery, core.js, and SelectBox.js.
|
| 6 |
+
*/
|
| 7 |
+
(function($) {
|
| 8 |
+
'use strict';
|
| 9 |
+
function findForm(node) {
|
| 10 |
+
// returns the node of the form containing the given node
|
| 11 |
+
if (node.tagName.toLowerCase() !== 'form') {
|
| 12 |
+
return findForm(node.parentNode);
|
| 13 |
+
}
|
| 14 |
+
return node;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
window.SelectFilter = {
|
| 18 |
+
init: function(field_id, field_name, is_stacked) {
|
| 19 |
+
if (field_id.match(/__prefix__/)) {
|
| 20 |
+
// Don't initialize on empty forms.
|
| 21 |
+
return;
|
| 22 |
+
}
|
| 23 |
+
var from_box = document.getElementById(field_id);
|
| 24 |
+
from_box.id += '_from'; // change its ID
|
| 25 |
+
from_box.className = 'filtered';
|
| 26 |
+
|
| 27 |
+
var ps = from_box.parentNode.getElementsByTagName('p');
|
| 28 |
+
for (var i = 0; i < ps.length; i++) {
|
| 29 |
+
if (ps[i].className.indexOf("info") !== -1) {
|
| 30 |
+
// Remove <p class="info">, because it just gets in the way.
|
| 31 |
+
from_box.parentNode.removeChild(ps[i]);
|
| 32 |
+
} else if (ps[i].className.indexOf("help") !== -1) {
|
| 33 |
+
// Move help text up to the top so it isn't below the select
|
| 34 |
+
// boxes or wrapped off on the side to the right of the add
|
| 35 |
+
// button:
|
| 36 |
+
from_box.parentNode.insertBefore(ps[i], from_box.parentNode.firstChild);
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
// <div class="selector"> or <div class="selector stacked">
|
| 41 |
+
var selector_div = quickElement('div', from_box.parentNode);
|
| 42 |
+
selector_div.className = is_stacked ? 'selector stacked' : 'selector';
|
| 43 |
+
|
| 44 |
+
// <div class="selector-available">
|
| 45 |
+
var selector_available = quickElement('div', selector_div);
|
| 46 |
+
selector_available.className = 'selector-available';
|
| 47 |
+
var title_available = quickElement('h2', selector_available, interpolate(gettext('Available %s') + ' ', [field_name]));
|
| 48 |
+
quickElement(
|
| 49 |
+
'span', title_available, '',
|
| 50 |
+
'class', 'help help-tooltip help-icon',
|
| 51 |
+
'title', interpolate(
|
| 52 |
+
gettext(
|
| 53 |
+
'This is the list of available %s. You may choose some by ' +
|
| 54 |
+
'selecting them in the box below and then clicking the ' +
|
| 55 |
+
'"Choose" arrow between the two boxes.'
|
| 56 |
+
),
|
| 57 |
+
[field_name]
|
| 58 |
+
)
|
| 59 |
+
);
|
| 60 |
+
|
| 61 |
+
var filter_p = quickElement('p', selector_available, '', 'id', field_id + '_filter');
|
| 62 |
+
filter_p.className = 'selector-filter';
|
| 63 |
+
|
| 64 |
+
var search_filter_label = quickElement('label', filter_p, '', 'for', field_id + '_input');
|
| 65 |
+
|
| 66 |
+
quickElement(
|
| 67 |
+
'span', search_filter_label, '',
|
| 68 |
+
'class', 'help-tooltip search-label-icon',
|
| 69 |
+
'title', interpolate(gettext("Type into this box to filter down the list of available %s."), [field_name])
|
| 70 |
+
);
|
| 71 |
+
|
| 72 |
+
filter_p.appendChild(document.createTextNode(' '));
|
| 73 |
+
|
| 74 |
+
var filter_input = quickElement('input', filter_p, '', 'type', 'text', 'placeholder', gettext("Filter"));
|
| 75 |
+
filter_input.id = field_id + '_input';
|
| 76 |
+
|
| 77 |
+
selector_available.appendChild(from_box);
|
| 78 |
+
var choose_all = quickElement('a', selector_available, gettext('Choose all'), 'title', interpolate(gettext('Click to choose all %s at once.'), [field_name]), 'href', '#', 'id', field_id + '_add_all_link');
|
| 79 |
+
choose_all.className = 'selector-chooseall';
|
| 80 |
+
|
| 81 |
+
// <ul class="selector-chooser">
|
| 82 |
+
var selector_chooser = quickElement('ul', selector_div);
|
| 83 |
+
selector_chooser.className = 'selector-chooser';
|
| 84 |
+
var add_link = quickElement('a', quickElement('li', selector_chooser), gettext('Choose'), 'title', gettext('Choose'), 'href', '#', 'id', field_id + '_add_link');
|
| 85 |
+
add_link.className = 'selector-add';
|
| 86 |
+
var remove_link = quickElement('a', quickElement('li', selector_chooser), gettext('Remove'), 'title', gettext('Remove'), 'href', '#', 'id', field_id + '_remove_link');
|
| 87 |
+
remove_link.className = 'selector-remove';
|
| 88 |
+
|
| 89 |
+
// <div class="selector-chosen">
|
| 90 |
+
var selector_chosen = quickElement('div', selector_div);
|
| 91 |
+
selector_chosen.className = 'selector-chosen';
|
| 92 |
+
var title_chosen = quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s') + ' ', [field_name]));
|
| 93 |
+
quickElement(
|
| 94 |
+
'span', title_chosen, '',
|
| 95 |
+
'class', 'help help-tooltip help-icon',
|
| 96 |
+
'title', interpolate(
|
| 97 |
+
gettext(
|
| 98 |
+
'This is the list of chosen %s. You may remove some by ' +
|
| 99 |
+
'selecting them in the box below and then clicking the ' +
|
| 100 |
+
'"Remove" arrow between the two boxes.'
|
| 101 |
+
),
|
| 102 |
+
[field_name]
|
| 103 |
+
)
|
| 104 |
+
);
|
| 105 |
+
|
| 106 |
+
var to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', from_box.getAttribute('name'));
|
| 107 |
+
to_box.className = 'filtered';
|
| 108 |
+
var clear_all = quickElement('a', selector_chosen, gettext('Remove all'), 'title', interpolate(gettext('Click to remove all chosen %s at once.'), [field_name]), 'href', '#', 'id', field_id + '_remove_all_link');
|
| 109 |
+
clear_all.className = 'selector-clearall';
|
| 110 |
+
|
| 111 |
+
from_box.setAttribute('name', from_box.getAttribute('name') + '_old');
|
| 112 |
+
|
| 113 |
+
// Set up the JavaScript event handlers for the select box filter interface
|
| 114 |
+
var move_selection = function(e, elem, move_func, from, to) {
|
| 115 |
+
if (elem.className.indexOf('active') !== -1) {
|
| 116 |
+
move_func(from, to);
|
| 117 |
+
SelectFilter.refresh_icons(field_id);
|
| 118 |
+
}
|
| 119 |
+
e.preventDefault();
|
| 120 |
+
};
|
| 121 |
+
choose_all.addEventListener('click', function(e) {
|
| 122 |
+
move_selection(e, this, SelectBox.move_all, field_id + '_from', field_id + '_to');
|
| 123 |
+
});
|
| 124 |
+
add_link.addEventListener('click', function(e) {
|
| 125 |
+
move_selection(e, this, SelectBox.move, field_id + '_from', field_id + '_to');
|
| 126 |
+
});
|
| 127 |
+
remove_link.addEventListener('click', function(e) {
|
| 128 |
+
move_selection(e, this, SelectBox.move, field_id + '_to', field_id + '_from');
|
| 129 |
+
});
|
| 130 |
+
clear_all.addEventListener('click', function(e) {
|
| 131 |
+
move_selection(e, this, SelectBox.move_all, field_id + '_to', field_id + '_from');
|
| 132 |
+
});
|
| 133 |
+
filter_input.addEventListener('keypress', function(e) {
|
| 134 |
+
SelectFilter.filter_key_press(e, field_id);
|
| 135 |
+
});
|
| 136 |
+
filter_input.addEventListener('keyup', function(e) {
|
| 137 |
+
SelectFilter.filter_key_up(e, field_id);
|
| 138 |
+
});
|
| 139 |
+
filter_input.addEventListener('keydown', function(e) {
|
| 140 |
+
SelectFilter.filter_key_down(e, field_id);
|
| 141 |
+
});
|
| 142 |
+
selector_div.addEventListener('change', function(e) {
|
| 143 |
+
if (e.target.tagName === 'SELECT') {
|
| 144 |
+
SelectFilter.refresh_icons(field_id);
|
| 145 |
+
}
|
| 146 |
+
});
|
| 147 |
+
selector_div.addEventListener('dblclick', function(e) {
|
| 148 |
+
if (e.target.tagName === 'OPTION') {
|
| 149 |
+
if (e.target.closest('select').id === field_id + '_to') {
|
| 150 |
+
SelectBox.move(field_id + '_to', field_id + '_from');
|
| 151 |
+
} else {
|
| 152 |
+
SelectBox.move(field_id + '_from', field_id + '_to');
|
| 153 |
+
}
|
| 154 |
+
SelectFilter.refresh_icons(field_id);
|
| 155 |
+
}
|
| 156 |
+
});
|
| 157 |
+
findForm(from_box).addEventListener('submit', function() {
|
| 158 |
+
SelectBox.select_all(field_id + '_to');
|
| 159 |
+
});
|
| 160 |
+
SelectBox.init(field_id + '_from');
|
| 161 |
+
SelectBox.init(field_id + '_to');
|
| 162 |
+
// Move selected from_box options to to_box
|
| 163 |
+
SelectBox.move(field_id + '_from', field_id + '_to');
|
| 164 |
+
|
| 165 |
+
if (!is_stacked) {
|
| 166 |
+
// In horizontal mode, give the same height to the two boxes.
|
| 167 |
+
var j_from_box = $('#' + field_id + '_from');
|
| 168 |
+
var j_to_box = $('#' + field_id + '_to');
|
| 169 |
+
var resize_filters = function() { j_to_box.height($(filter_p).outerHeight() + j_from_box.outerHeight()); };
|
| 170 |
+
if (j_from_box.outerHeight() > 0) {
|
| 171 |
+
resize_filters(); // This fieldset is already open. Resize now.
|
| 172 |
+
} else {
|
| 173 |
+
// This fieldset is probably collapsed. Wait for its 'show' event.
|
| 174 |
+
j_to_box.closest('fieldset').one('show.fieldset', resize_filters);
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
// Initial icon refresh
|
| 179 |
+
SelectFilter.refresh_icons(field_id);
|
| 180 |
+
},
|
| 181 |
+
any_selected: function(field) {
|
| 182 |
+
var any_selected = false;
|
| 183 |
+
try {
|
| 184 |
+
// Temporarily add the required attribute and check validity.
|
| 185 |
+
// This is much faster in WebKit browsers than the fallback.
|
| 186 |
+
field.attr('required', 'required');
|
| 187 |
+
any_selected = field.is(':valid');
|
| 188 |
+
field.removeAttr('required');
|
| 189 |
+
} catch (e) {
|
| 190 |
+
// Browsers that don't support :valid (IE < 10)
|
| 191 |
+
any_selected = field.find('option:selected').length > 0;
|
| 192 |
+
}
|
| 193 |
+
return any_selected;
|
| 194 |
+
},
|
| 195 |
+
refresh_icons: function(field_id) {
|
| 196 |
+
var from = $('#' + field_id + '_from');
|
| 197 |
+
var to = $('#' + field_id + '_to');
|
| 198 |
+
// Active if at least one item is selected
|
| 199 |
+
$('#' + field_id + '_add_link').toggleClass('active', SelectFilter.any_selected(from));
|
| 200 |
+
$('#' + field_id + '_remove_link').toggleClass('active', SelectFilter.any_selected(to));
|
| 201 |
+
// Active if the corresponding box isn't empty
|
| 202 |
+
$('#' + field_id + '_add_all_link').toggleClass('active', from.find('option').length > 0);
|
| 203 |
+
$('#' + field_id + '_remove_all_link').toggleClass('active', to.find('option').length > 0);
|
| 204 |
+
},
|
| 205 |
+
filter_key_press: function(event, field_id) {
|
| 206 |
+
var from = document.getElementById(field_id + '_from');
|
| 207 |
+
// don't submit form if user pressed Enter
|
| 208 |
+
if ((event.which && event.which === 13) || (event.keyCode && event.keyCode === 13)) {
|
| 209 |
+
from.selectedIndex = 0;
|
| 210 |
+
SelectBox.move(field_id + '_from', field_id + '_to');
|
| 211 |
+
from.selectedIndex = 0;
|
| 212 |
+
event.preventDefault();
|
| 213 |
+
return false;
|
| 214 |
+
}
|
| 215 |
+
},
|
| 216 |
+
filter_key_up: function(event, field_id) {
|
| 217 |
+
var from = document.getElementById(field_id + '_from');
|
| 218 |
+
var temp = from.selectedIndex;
|
| 219 |
+
SelectBox.filter(field_id + '_from', document.getElementById(field_id + '_input').value);
|
| 220 |
+
from.selectedIndex = temp;
|
| 221 |
+
return true;
|
| 222 |
+
},
|
| 223 |
+
filter_key_down: function(event, field_id) {
|
| 224 |
+
var from = document.getElementById(field_id + '_from');
|
| 225 |
+
// right arrow -- move across
|
| 226 |
+
if ((event.which && event.which === 39) || (event.keyCode && event.keyCode === 39)) {
|
| 227 |
+
var old_index = from.selectedIndex;
|
| 228 |
+
SelectBox.move(field_id + '_from', field_id + '_to');
|
| 229 |
+
from.selectedIndex = (old_index === from.length) ? from.length - 1 : old_index;
|
| 230 |
+
return false;
|
| 231 |
+
}
|
| 232 |
+
// down arrow -- wrap around
|
| 233 |
+
if ((event.which && event.which === 40) || (event.keyCode && event.keyCode === 40)) {
|
| 234 |
+
from.selectedIndex = (from.length === from.selectedIndex + 1) ? 0 : from.selectedIndex + 1;
|
| 235 |
+
}
|
| 236 |
+
// up arrow -- wrap around
|
| 237 |
+
if ((event.which && event.which === 38) || (event.keyCode && event.keyCode === 38)) {
|
| 238 |
+
from.selectedIndex = (from.selectedIndex === 0) ? from.length - 1 : from.selectedIndex - 1;
|
| 239 |
+
}
|
| 240 |
+
return true;
|
| 241 |
+
}
|
| 242 |
+
};
|
| 243 |
+
|
| 244 |
+
window.addEventListener('load', function(e) {
|
| 245 |
+
$('select.selectfilter, select.selectfilterstacked').each(function() {
|
| 246 |
+
var $el = $(this),
|
| 247 |
+
data = $el.data();
|
| 248 |
+
SelectFilter.init($el.attr('id'), data.fieldName, parseInt(data.isStacked, 10));
|
| 249 |
+
});
|
| 250 |
+
});
|
| 251 |
+
|
| 252 |
+
})(django.jQuery);
|
pool/shard007/JavaScript/0047934_gfycat.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
modules['showImages'].siteModules['gfycat'] = {
|
| 2 |
+
domains: ['gfycat.com'],
|
| 3 |
+
options: {
|
| 4 |
+
'prefer RES support': {
|
| 5 |
+
description: 'Prefer RES support for gfycat rather than reddit\'s built in support',
|
| 6 |
+
value: true,
|
| 7 |
+
type: 'boolean'
|
| 8 |
+
}
|
| 9 |
+
},
|
| 10 |
+
calls: {},
|
| 11 |
+
detect: function(href, elem) {
|
| 12 |
+
return href.indexOf('gfycat.com') !== -1 && href.substring(-1) !== '+';
|
| 13 |
+
},
|
| 14 |
+
handleLink: function(elem) {
|
| 15 |
+
var hashRe = /^https?:\/\/(?:[\w]+.)?gfycat\.com\/(\w+)(?:\.gif)?/i,
|
| 16 |
+
def = $.Deferred(),
|
| 17 |
+
siteMod = modules['showImages'].siteModules['gfycat'],
|
| 18 |
+
groups = hashRe.exec(elem.href),
|
| 19 |
+
existingExpando = $(elem).closest('.entry').find('.expando-button.video:not(.commentImg)');
|
| 20 |
+
|
| 21 |
+
if (groups && (siteMod.options['prefer RES support'].value || existingExpando.length === 0)) {
|
| 22 |
+
existingExpando.remove();
|
| 23 |
+
var apiURL = location.protocol + '//gfycat.com/cajax/get/' + encodeURIComponent(groups[1]);
|
| 24 |
+
if (apiURL in siteMod.calls) {
|
| 25 |
+
if (siteMod.calls[apiURL] != null) {
|
| 26 |
+
def.resolve(elem, siteMod.calls[apiURL]);
|
| 27 |
+
} else {
|
| 28 |
+
siteMod.calls[apiURL] = null;
|
| 29 |
+
def.reject();
|
| 30 |
+
}
|
| 31 |
+
} else {
|
| 32 |
+
RESUtils.runtime.ajax({
|
| 33 |
+
method: 'GET',
|
| 34 |
+
url: apiURL,
|
| 35 |
+
aggressiveCache: true,
|
| 36 |
+
onload: function(response) {
|
| 37 |
+
try {
|
| 38 |
+
var json = JSON.parse(response.responseText);
|
| 39 |
+
json.gfyItem.src = elem.href;
|
| 40 |
+
siteMod.calls[apiURL] = json;
|
| 41 |
+
def.resolve(elem, json.gfyItem);
|
| 42 |
+
} catch (error) {
|
| 43 |
+
siteMod.calls[apiURL] = null;
|
| 44 |
+
def.reject();
|
| 45 |
+
}
|
| 46 |
+
},
|
| 47 |
+
onerror: function(response) {
|
| 48 |
+
def.reject();
|
| 49 |
+
}
|
| 50 |
+
});
|
| 51 |
+
}
|
| 52 |
+
} else {
|
| 53 |
+
def.reject();
|
| 54 |
+
}
|
| 55 |
+
return def.promise();
|
| 56 |
+
},
|
| 57 |
+
handleInfo: function(elem, info) {
|
| 58 |
+
var generate = function(options) {
|
| 59 |
+
var template = RESTemplates.getSync('GfycatUI');
|
| 60 |
+
var video = {
|
| 61 |
+
loop: true,
|
| 62 |
+
autoplay: true, // gfycat always has muted or no auto, so autoplay is OK
|
| 63 |
+
muted: true,
|
| 64 |
+
directurl: elem.href
|
| 65 |
+
};
|
| 66 |
+
video.poster = location.protocol + '//thumbs.gfycat.com/'+info.gfyName+'-poster.jpg';
|
| 67 |
+
// gfycat returns http:// even if the request came over https://, so let's swap it out
|
| 68 |
+
if (location.protocol === 'https:') {
|
| 69 |
+
info.webmUrl = info.webmUrl.replace('http:','https:');
|
| 70 |
+
info.mp4Url = info.mp4Url.replace('http:','https:');
|
| 71 |
+
}
|
| 72 |
+
video.sources = [
|
| 73 |
+
{
|
| 74 |
+
'source': info.webmUrl,
|
| 75 |
+
'type': 'video/webm',
|
| 76 |
+
'class': 'gfyRwebmsrc'
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
'source': info.mp4Url,
|
| 80 |
+
'type': 'video/mp4',
|
| 81 |
+
'class': 'gfyRmp4src'
|
| 82 |
+
}
|
| 83 |
+
];
|
| 84 |
+
var element = template.html(video)[0],
|
| 85 |
+
v = element.querySelector('video');
|
| 86 |
+
|
| 87 |
+
// set the max width to the width of the entry area
|
| 88 |
+
v.style.maxWidth = $(elem).closest('.entry').width() + 'px';
|
| 89 |
+
new window.gfyObject(element,elem.href,info.frameRate);
|
| 90 |
+
return element;
|
| 91 |
+
};
|
| 92 |
+
elem.type = 'GENERIC_EXPANDO';
|
| 93 |
+
elem.subtype = 'VIDEO';
|
| 94 |
+
// open via 'view all images'
|
| 95 |
+
elem.expandOnViewAll = true;
|
| 96 |
+
elem.expandoClass = ' video-muted';
|
| 97 |
+
|
| 98 |
+
elem.expandoOptions = {
|
| 99 |
+
generate: generate,
|
| 100 |
+
media: info
|
| 101 |
+
};
|
| 102 |
+
|
| 103 |
+
if (RESUtils.pageType() === 'linklist') {
|
| 104 |
+
$(elem).closest('.thing').find('.thumbnail').attr('href', elem.href);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
return $.Deferred().resolve(elem).promise();
|
| 108 |
+
}
|
| 109 |
+
};
|
pool/shard007/JavaScript/0047936_store.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Vue from 'vue'
|
| 2 |
+
import Vuex from 'vuex'
|
| 3 |
+
import axios from './axios-auth'
|
| 4 |
+
import globalAxios from 'axios'
|
| 5 |
+
|
| 6 |
+
import router from './router'
|
| 7 |
+
|
| 8 |
+
Vue.use(Vuex)
|
| 9 |
+
|
| 10 |
+
export default new Vuex.Store({
|
| 11 |
+
state: {
|
| 12 |
+
idToken: null,
|
| 13 |
+
userId: null,
|
| 14 |
+
user: null
|
| 15 |
+
},
|
| 16 |
+
mutations: {
|
| 17 |
+
authUser(state, userData) {
|
| 18 |
+
state.idToken = userData.token
|
| 19 |
+
state.userId = userData.userId
|
| 20 |
+
},
|
| 21 |
+
storeUser(state, user) {
|
| 22 |
+
state.user = user
|
| 23 |
+
},
|
| 24 |
+
clearAuthData(state){
|
| 25 |
+
state.idToken = null;
|
| 26 |
+
state.userId = null;
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
actions: {
|
| 30 |
+
signup({commit, dispatch}, authData) {
|
| 31 |
+
axios.post('/signupNewUser?key=AIzaSyCKWv_aD1daU9hn3e4NpRXUxlRx9lJMxTw', {
|
| 32 |
+
email: authData.email,
|
| 33 |
+
password: authData.password,
|
| 34 |
+
returnSecureToken: true
|
| 35 |
+
})
|
| 36 |
+
.then(res => {
|
| 37 |
+
console.log(res)
|
| 38 |
+
commit('authUser', {
|
| 39 |
+
token: res.data.idToken,
|
| 40 |
+
userId: res.data.localId
|
| 41 |
+
})
|
| 42 |
+
// Calculate expiration datetime for the token
|
| 43 |
+
const now = new Date();
|
| 44 |
+
const expirationDate = new Date(now.getTime() + res.data.expiresIn * 1000);
|
| 45 |
+
// Using local storage
|
| 46 |
+
localStorage.setItem('token', res.data.idToken)
|
| 47 |
+
localStorage.setItem('expirationDate', expirationDate)
|
| 48 |
+
localStorage.setItem('userId', res.data.localId)
|
| 49 |
+
dispatch('storeUser', authData)
|
| 50 |
+
dispatch('setLogoutTimer', res.data.expiresIn)
|
| 51 |
+
})
|
| 52 |
+
.catch(error => console.log(error))
|
| 53 |
+
},
|
| 54 |
+
tryAutoLogin({commit}){
|
| 55 |
+
// Checking if the token is in the local storage
|
| 56 |
+
const token = localStorage.getItem('token')
|
| 57 |
+
if(token == null){
|
| 58 |
+
return
|
| 59 |
+
} else {
|
| 60 |
+
// Checking if the token is still valid
|
| 61 |
+
const expirationDate = localStorage.getItem('expirationDate');
|
| 62 |
+
const now = new Date();
|
| 63 |
+
if(now >= expirationDate){
|
| 64 |
+
return
|
| 65 |
+
} else {
|
| 66 |
+
const userId = localStorage.getItem('userId');
|
| 67 |
+
commit('authUser', {
|
| 68 |
+
token: token,
|
| 69 |
+
userId: userId
|
| 70 |
+
})
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
login({commit, dispatch}, authData) {
|
| 75 |
+
axios.post('/verifyPassword?key=AIzaSyCKWv_aD1daU9hn3e4NpRXUxlRx9lJMxTw', {
|
| 76 |
+
email: authData.email,
|
| 77 |
+
password: authData.password,
|
| 78 |
+
returnSecureToken: true
|
| 79 |
+
})
|
| 80 |
+
.then(res => {
|
| 81 |
+
console.log(res)
|
| 82 |
+
commit('authUser', {
|
| 83 |
+
token: res.data.idToken,
|
| 84 |
+
userId: res.data.localId
|
| 85 |
+
})
|
| 86 |
+
// Calculate expiration datetime for the token
|
| 87 |
+
const now = new Date();
|
| 88 |
+
const expirationDate = new Date(now.getTime() + res.data.expiresIn * 100);
|
| 89 |
+
// Using local storage
|
| 90 |
+
localStorage.setItem('token', res.data.idToken)
|
| 91 |
+
localStorage.setItem('expirationDate', expirationDate)
|
| 92 |
+
localStorage.setItem('userId', res.data.localId)
|
| 93 |
+
dispatch('setLogoutTimer', res.data.expiresIn)
|
| 94 |
+
})
|
| 95 |
+
.catch(error => console.log(error))
|
| 96 |
+
},
|
| 97 |
+
storeUser({commit, state}, userData) {
|
| 98 |
+
if (!state.idToken) {
|
| 99 |
+
return
|
| 100 |
+
}
|
| 101 |
+
globalAxios.post('/users.json' + '?auth=' + state.idToken, userData)
|
| 102 |
+
.then(res => console.log(res))
|
| 103 |
+
.catch(error => console.log(error))
|
| 104 |
+
},
|
| 105 |
+
fetchUser({commit, state}) {
|
| 106 |
+
if (!state.idToken) {
|
| 107 |
+
return
|
| 108 |
+
}
|
| 109 |
+
globalAxios.get('/users.json' + '?auth=' + state.idToken)
|
| 110 |
+
.then(res => {
|
| 111 |
+
console.log(res)
|
| 112 |
+
const data = res.data
|
| 113 |
+
const users = []
|
| 114 |
+
for (let key in data) {
|
| 115 |
+
const user = data[key]
|
| 116 |
+
user.id = key
|
| 117 |
+
users.push(user)
|
| 118 |
+
}
|
| 119 |
+
console.log(users)
|
| 120 |
+
commit('storeUser', users[0])
|
| 121 |
+
})
|
| 122 |
+
.catch(error => console.log(error))
|
| 123 |
+
},
|
| 124 |
+
logout({commit}){
|
| 125 |
+
commit('clearAuthData')
|
| 126 |
+
localStorage.removeItem('expirationDate');
|
| 127 |
+
localStorage.removeItem('token');
|
| 128 |
+
localStorage.removeItem('userId');
|
| 129 |
+
router.push('/signin')
|
| 130 |
+
},
|
| 131 |
+
setLogoutTimer({commit}, expirationTime){
|
| 132 |
+
setTimeout(() => {
|
| 133 |
+
commit('clearAuthData')
|
| 134 |
+
}, expirationTime * 1000)
|
| 135 |
+
}
|
| 136 |
+
},
|
| 137 |
+
getters: {
|
| 138 |
+
user(state){
|
| 139 |
+
return state.user
|
| 140 |
+
},
|
| 141 |
+
isAuthenticated(state){
|
| 142 |
+
return state.idToken !== null
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
})
|
pool/shard007/JavaScript/0047938_file-system-blob-store-spec.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @babel */
|
| 2 |
+
/* eslint-disable
|
| 3 |
+
no-return-assign,
|
| 4 |
+
no-undef,
|
| 5 |
+
node/no-deprecated-api,
|
| 6 |
+
*/
|
| 7 |
+
// TODO: This file was created by bulk-decaffeinate.
|
| 8 |
+
// Fix any style issues and re-enable lint.
|
| 9 |
+
/*
|
| 10 |
+
* decaffeinate suggestions:
|
| 11 |
+
* DS101: Remove unnecessary use of Array.from
|
| 12 |
+
* DS102: Remove unnecessary code created because of implicit returns
|
| 13 |
+
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
| 14 |
+
*/
|
| 15 |
+
const temp = require('temp').track()
|
| 16 |
+
const path = require('path')
|
| 17 |
+
const fs = require('fs-plus')
|
| 18 |
+
const FileSystemBlobStore = require('../src/file-system-blob-store')
|
| 19 |
+
|
| 20 |
+
describe('FileSystemBlobStore', function () {
|
| 21 |
+
let [storageDirectory, blobStore] = Array.from([])
|
| 22 |
+
|
| 23 |
+
beforeEach(function () {
|
| 24 |
+
storageDirectory = temp.path('atom-spec-filesystemblobstore')
|
| 25 |
+
return blobStore = FileSystemBlobStore.load(storageDirectory)
|
| 26 |
+
})
|
| 27 |
+
|
| 28 |
+
afterEach(() => fs.removeSync(storageDirectory))
|
| 29 |
+
|
| 30 |
+
it("is empty when the file doesn't exist", function () {
|
| 31 |
+
expect(blobStore.get('foo')).toBeUndefined()
|
| 32 |
+
return expect(blobStore.get('bar')).toBeUndefined()
|
| 33 |
+
})
|
| 34 |
+
|
| 35 |
+
it('allows to read and write buffers from/to memory without persisting them', function () {
|
| 36 |
+
blobStore.set('foo', new Buffer('foo'))
|
| 37 |
+
blobStore.set('bar', new Buffer('bar'))
|
| 38 |
+
|
| 39 |
+
expect(blobStore.get('foo')).toEqual(new Buffer('foo'))
|
| 40 |
+
expect(blobStore.get('bar')).toEqual(new Buffer('bar'))
|
| 41 |
+
|
| 42 |
+
expect(blobStore.get('baz')).toBeUndefined()
|
| 43 |
+
return expect(blobStore.get('qux')).toBeUndefined()
|
| 44 |
+
})
|
| 45 |
+
|
| 46 |
+
it('persists buffers when saved and retrieves them on load, giving priority to in-memory ones', function () {
|
| 47 |
+
blobStore.set('foo', new Buffer('foo'))
|
| 48 |
+
blobStore.set('bar', new Buffer('bar'))
|
| 49 |
+
blobStore.save()
|
| 50 |
+
|
| 51 |
+
blobStore = FileSystemBlobStore.load(storageDirectory)
|
| 52 |
+
|
| 53 |
+
expect(blobStore.get('foo')).toEqual(new Buffer('foo'))
|
| 54 |
+
expect(blobStore.get('bar')).toEqual(new Buffer('bar'))
|
| 55 |
+
expect(blobStore.get('baz')).toBeUndefined()
|
| 56 |
+
expect(blobStore.get('qux')).toBeUndefined()
|
| 57 |
+
|
| 58 |
+
blobStore.set('foo', new Buffer('changed'))
|
| 59 |
+
|
| 60 |
+
return expect(blobStore.get('foo')).toEqual(new Buffer('changed'))
|
| 61 |
+
})
|
| 62 |
+
|
| 63 |
+
it('persists in-memory and previously stored buffers, and deletes unused keys when saved', function () {
|
| 64 |
+
blobStore.set('foo', new Buffer('foo'))
|
| 65 |
+
blobStore.set('bar', new Buffer('bar'))
|
| 66 |
+
blobStore.save()
|
| 67 |
+
|
| 68 |
+
blobStore = FileSystemBlobStore.load(storageDirectory)
|
| 69 |
+
blobStore.set('bar', new Buffer('changed'))
|
| 70 |
+
blobStore.set('qux', new Buffer('qux'))
|
| 71 |
+
blobStore.save()
|
| 72 |
+
|
| 73 |
+
blobStore = FileSystemBlobStore.load(storageDirectory)
|
| 74 |
+
|
| 75 |
+
expect(blobStore.get('foo')).toBeUndefined()
|
| 76 |
+
expect(blobStore.get('bar')).toEqual(new Buffer('changed'))
|
| 77 |
+
return expect(blobStore.get('qux')).toEqual(new Buffer('qux'))
|
| 78 |
+
})
|
| 79 |
+
|
| 80 |
+
it('allows to delete keys from both memory and stored buffers', function () {
|
| 81 |
+
blobStore.set('a', new Buffer('a'))
|
| 82 |
+
blobStore.set('b', new Buffer('b'))
|
| 83 |
+
blobStore.save()
|
| 84 |
+
|
| 85 |
+
blobStore = FileSystemBlobStore.load(storageDirectory)
|
| 86 |
+
|
| 87 |
+
blobStore.get('a') // prevent the key from being deleted on save
|
| 88 |
+
blobStore.set('b', new Buffer('b'))
|
| 89 |
+
blobStore.set('c', new Buffer('c'))
|
| 90 |
+
blobStore.delete('b')
|
| 91 |
+
blobStore.delete('c')
|
| 92 |
+
blobStore.save()
|
| 93 |
+
|
| 94 |
+
blobStore = FileSystemBlobStore.load(storageDirectory)
|
| 95 |
+
|
| 96 |
+
expect(blobStore.get('a')).toEqual(new Buffer('a'))
|
| 97 |
+
expect(blobStore.get('b')).toBeUndefined()
|
| 98 |
+
expect(blobStore.get('b')).toBeUndefined()
|
| 99 |
+
return expect(blobStore.get('c')).toBeUndefined()
|
| 100 |
+
})
|
| 101 |
+
|
| 102 |
+
return it('ignores errors when loading an invalid blob store', function () {
|
| 103 |
+
blobStore.set('a', new Buffer('a'))
|
| 104 |
+
blobStore.set('b', new Buffer('b'))
|
| 105 |
+
blobStore.save()
|
| 106 |
+
|
| 107 |
+
// Simulate corruption
|
| 108 |
+
fs.writeFileSync(path.join(storageDirectory, 'MAP'), new Buffer([0]))
|
| 109 |
+
fs.writeFileSync(path.join(storageDirectory, 'INVKEYS'), new Buffer([0]))
|
| 110 |
+
fs.writeFileSync(path.join(storageDirectory, 'BLOB'), new Buffer([0]))
|
| 111 |
+
|
| 112 |
+
blobStore = FileSystemBlobStore.load(storageDirectory)
|
| 113 |
+
|
| 114 |
+
expect(blobStore.get('a')).toBeUndefined()
|
| 115 |
+
expect(blobStore.get('b')).toBeUndefined()
|
| 116 |
+
|
| 117 |
+
blobStore.set('a', new Buffer('x'))
|
| 118 |
+
blobStore.set('b', new Buffer('y'))
|
| 119 |
+
blobStore.save()
|
| 120 |
+
|
| 121 |
+
blobStore = FileSystemBlobStore.load(storageDirectory)
|
| 122 |
+
|
| 123 |
+
expect(blobStore.get('a')).toEqual(new Buffer('x'))
|
| 124 |
+
return expect(blobStore.get('b')).toEqual(new Buffer('y'))
|
| 125 |
+
})
|
| 126 |
+
})
|
pool/shard007/JavaScript/0047942_regular_expression.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var parse = require('bennu').parse;
|
| 2 |
+
var regular_expression_lexer = require('../../index').lex.regular_expression_lexer;
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
var reEq = function(test, x, y) {
|
| 6 |
+
return test.equal(x.toString(), y.toString());
|
| 7 |
+
};
|
| 8 |
+
|
| 9 |
+
exports.basic_regex = function(test) {
|
| 10 |
+
reEq(test,
|
| 11 |
+
parse.run(regular_expression_lexer.regularExpressionLiteral, "`abc`"),
|
| 12 |
+
/abc/);
|
| 13 |
+
|
| 14 |
+
reEq(test,
|
| 15 |
+
parse.run(regular_expression_lexer.regularExpressionLiteral, "`abc`i"),
|
| 16 |
+
/abc/i);
|
| 17 |
+
|
| 18 |
+
reEq(test,
|
| 19 |
+
parse.run(regular_expression_lexer.regularExpressionLiteral, "`abc`igm"),
|
| 20 |
+
/abc/igm);
|
| 21 |
+
|
| 22 |
+
test.done();
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
exports.simple_class = function(test) {
|
| 26 |
+
reEq(test,
|
| 27 |
+
parse.run(regular_expression_lexer.regularExpressionLiteral, "`[abc]`"),
|
| 28 |
+
/[abc]/);
|
| 29 |
+
|
| 30 |
+
reEq(test,
|
| 31 |
+
parse.run(regular_expression_lexer.regularExpressionLiteral, "`[^*. 3][]`"),
|
| 32 |
+
/[^*. 3][]/);
|
| 33 |
+
|
| 34 |
+
test.done();
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
exports.escape_class = function(test) {
|
| 38 |
+
reEq(test,
|
| 39 |
+
parse.run(regular_expression_lexer.regularExpressionLiteral, "`[\\]]`"),
|
| 40 |
+
/[\]]/);
|
| 41 |
+
|
| 42 |
+
test.done();
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
exports.escape_backtick = function(test) {
|
| 47 |
+
reEq(test,
|
| 48 |
+
parse.run(regular_expression_lexer.regularExpressionLiteral, "`\\`ab`"),
|
| 49 |
+
/\`ab/);
|
| 50 |
+
|
| 51 |
+
test.done();
|
| 52 |
+
};
|
pool/shard007/JavaScript/0047944_SVGPan.js
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* SVGPan library 1.2.1
|
| 3 |
+
* ======================
|
| 4 |
+
*
|
| 5 |
+
* Given an unique existing element with id "viewport" (or when missing, the first g
|
| 6 |
+
* element), including the the library into any SVG adds the following capabilities:
|
| 7 |
+
*
|
| 8 |
+
* - Mouse panning
|
| 9 |
+
* - Mouse zooming (using the wheel)
|
| 10 |
+
* - Object dragging
|
| 11 |
+
*
|
| 12 |
+
* You can configure the behaviour of the pan/zoom/drag with the variables
|
| 13 |
+
* listed in the CONFIGURATION section of this file.
|
| 14 |
+
*
|
| 15 |
+
* Known issues:
|
| 16 |
+
*
|
| 17 |
+
* - Zooming (while panning) on Safari has still some issues
|
| 18 |
+
*
|
| 19 |
+
* Releases:
|
| 20 |
+
*
|
| 21 |
+
* 1.2.1, Mon Jul 4 00:33:18 CEST 2011, Andrea Leofreddi
|
| 22 |
+
* - Fixed a regression with mouse wheel (now working on Firefox 5)
|
| 23 |
+
* - Working with viewBox attribute (#4)
|
| 24 |
+
* - Added "use strict;" and fixed resulting warnings (#5)
|
| 25 |
+
* - Added configuration variables, dragging is disabled by default (#3)
|
| 26 |
+
*
|
| 27 |
+
* 1.2, Sat Mar 20 08:42:50 GMT 2010, Zeng Xiaohui
|
| 28 |
+
* Fixed a bug with browser mouse handler interaction
|
| 29 |
+
*
|
| 30 |
+
* 1.1, Wed Feb 3 17:39:33 GMT 2010, Zeng Xiaohui
|
| 31 |
+
* Updated the zoom code to support the mouse wheel on Safari/Chrome
|
| 32 |
+
*
|
| 33 |
+
* 1.0, Andrea Leofreddi
|
| 34 |
+
* First release
|
| 35 |
+
*
|
| 36 |
+
* This code is licensed under the following BSD license:
|
| 37 |
+
*
|
| 38 |
+
* Copyright 2009-2010 Andrea Leofreddi <a.leofreddi@itcharm.com>. All rights reserved.
|
| 39 |
+
*
|
| 40 |
+
* Redistribution and use in source and binary forms, with or without modification, are
|
| 41 |
+
* permitted provided that the following conditions are met:
|
| 42 |
+
*
|
| 43 |
+
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
| 44 |
+
* conditions and the following disclaimer.
|
| 45 |
+
*
|
| 46 |
+
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
| 47 |
+
* of conditions and the following disclaimer in the documentation and/or other materials
|
| 48 |
+
* provided with the distribution.
|
| 49 |
+
*
|
| 50 |
+
* THIS SOFTWARE IS PROVIDED BY Andrea Leofreddi ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
| 51 |
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
| 52 |
+
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Andrea Leofreddi OR
|
| 53 |
+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
| 54 |
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 55 |
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
| 56 |
+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
| 57 |
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
| 58 |
+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 59 |
+
*
|
| 60 |
+
* The views and conclusions contained in the software and documentation are those of the
|
| 61 |
+
* authors and should not be interpreted as representing official policies, either expressed
|
| 62 |
+
* or implied, of Andrea Leofreddi.
|
| 63 |
+
*/
|
| 64 |
+
|
| 65 |
+
"use strict";
|
| 66 |
+
|
| 67 |
+
/// CONFIGURATION
|
| 68 |
+
/// ====>
|
| 69 |
+
|
| 70 |
+
var enablePan = 1; // 1 or 0: enable or disable panning (default enabled)
|
| 71 |
+
var enableZoom = 1; // 1 or 0: enable or disable zooming (default enabled)
|
| 72 |
+
var enableDrag = 0; // 1 or 0: enable or disable dragging (default disabled)
|
| 73 |
+
|
| 74 |
+
/// <====
|
| 75 |
+
/// END OF CONFIGURATION
|
| 76 |
+
|
| 77 |
+
var root = document.documentElement;
|
| 78 |
+
|
| 79 |
+
var state = 'none', svgRoot, stateTarget, stateOrigin, stateTf;
|
| 80 |
+
|
| 81 |
+
setupHandlers(root);
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* Register handlers
|
| 85 |
+
*/
|
| 86 |
+
function setupHandlers(root){
|
| 87 |
+
setAttributes(root, {
|
| 88 |
+
"onmouseup" : "handleMouseUp(evt)",
|
| 89 |
+
"onmousedown" : "handleMouseDown(evt)",
|
| 90 |
+
"onmousemove" : "handleMouseMove(evt)",
|
| 91 |
+
//"onmouseout" : "handleMouseUp(evt)", // Decomment this to stop the pan functionality when dragging out of the SVG element
|
| 92 |
+
});
|
| 93 |
+
|
| 94 |
+
if(navigator.userAgent.toLowerCase().indexOf('webkit') >= 0)
|
| 95 |
+
window.addEventListener('mousewheel', handleMouseWheel, false); // Chrome/Safari
|
| 96 |
+
else
|
| 97 |
+
window.addEventListener('DOMMouseScroll', handleMouseWheel, false); // Others
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
* Retrieves the root element for SVG manipulation. The element is then cached into the svgRoot global variable.
|
| 102 |
+
*/
|
| 103 |
+
function getRoot(root) {
|
| 104 |
+
if(typeof(svgRoot) == "undefined") {
|
| 105 |
+
var g = null;
|
| 106 |
+
|
| 107 |
+
g = root.getElementById("viewport");
|
| 108 |
+
|
| 109 |
+
if(g == null)
|
| 110 |
+
g = root.getElementsByTagName('g')[0];
|
| 111 |
+
|
| 112 |
+
if(g == null)
|
| 113 |
+
alert('Unable to obtain SVG root element');
|
| 114 |
+
|
| 115 |
+
setCTM(g, g.getCTM());
|
| 116 |
+
|
| 117 |
+
g.removeAttribute("viewBox");
|
| 118 |
+
|
| 119 |
+
svgRoot = g;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
return svgRoot;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
/**
|
| 126 |
+
* Instance an SVGPoint object with given event coordinates.
|
| 127 |
+
*/
|
| 128 |
+
function getEventPoint(evt) {
|
| 129 |
+
var p = root.createSVGPoint();
|
| 130 |
+
|
| 131 |
+
p.x = evt.clientX;
|
| 132 |
+
p.y = evt.clientY;
|
| 133 |
+
|
| 134 |
+
return p;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/**
|
| 138 |
+
* Sets the current transform matrix of an element.
|
| 139 |
+
*/
|
| 140 |
+
function setCTM(element, matrix) {
|
| 141 |
+
var s = "matrix(" + matrix.a + "," + matrix.b + "," + matrix.c + "," + matrix.d + "," + matrix.e + "," + matrix.f + ")";
|
| 142 |
+
|
| 143 |
+
element.setAttribute("transform", s);
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
/**
|
| 147 |
+
* Dumps a matrix to a string (useful for debug).
|
| 148 |
+
*/
|
| 149 |
+
function dumpMatrix(matrix) {
|
| 150 |
+
var s = "[ " + matrix.a + ", " + matrix.c + ", " + matrix.e + "\n " + matrix.b + ", " + matrix.d + ", " + matrix.f + "\n 0, 0, 1 ]";
|
| 151 |
+
|
| 152 |
+
return s;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
/**
|
| 156 |
+
* Sets attributes of an element.
|
| 157 |
+
*/
|
| 158 |
+
function setAttributes(element, attributes){
|
| 159 |
+
for (var i in attributes)
|
| 160 |
+
element.setAttributeNS(null, i, attributes[i]);
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* Handle mouse wheel event.
|
| 165 |
+
*/
|
| 166 |
+
function handleMouseWheel(evt) {
|
| 167 |
+
if(!enableZoom)
|
| 168 |
+
return;
|
| 169 |
+
|
| 170 |
+
if(evt.preventDefault)
|
| 171 |
+
evt.preventDefault();
|
| 172 |
+
|
| 173 |
+
evt.returnValue = false;
|
| 174 |
+
|
| 175 |
+
var svgDoc = evt.target.ownerDocument;
|
| 176 |
+
|
| 177 |
+
var delta;
|
| 178 |
+
|
| 179 |
+
if(evt.wheelDelta)
|
| 180 |
+
delta = evt.wheelDelta / 1500; // Chrome/Safari
|
| 181 |
+
else
|
| 182 |
+
delta = evt.detail / -25; // Mozilla
|
| 183 |
+
|
| 184 |
+
var z = 1 + delta; // Zoom factor: 0.9/1.1
|
| 185 |
+
|
| 186 |
+
var g = getRoot(svgDoc);
|
| 187 |
+
|
| 188 |
+
var p = getEventPoint(evt);
|
| 189 |
+
|
| 190 |
+
p = p.matrixTransform(g.getCTM().inverse());
|
| 191 |
+
|
| 192 |
+
// Compute new scale matrix in current mouse position
|
| 193 |
+
var k = root.createSVGMatrix().translate(p.x, p.y).scale(z).translate(-p.x, -p.y);
|
| 194 |
+
|
| 195 |
+
setCTM(g, g.getCTM().multiply(k));
|
| 196 |
+
|
| 197 |
+
if(typeof(stateTf) == "undefined")
|
| 198 |
+
stateTf = g.getCTM().inverse();
|
| 199 |
+
|
| 200 |
+
stateTf = stateTf.multiply(k.inverse());
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
/**
|
| 204 |
+
* Handle mouse move event.
|
| 205 |
+
*/
|
| 206 |
+
function handleMouseMove(evt) {
|
| 207 |
+
if(evt.preventDefault)
|
| 208 |
+
evt.preventDefault();
|
| 209 |
+
|
| 210 |
+
evt.returnValue = false;
|
| 211 |
+
|
| 212 |
+
var svgDoc = evt.target.ownerDocument;
|
| 213 |
+
|
| 214 |
+
var g = getRoot(svgDoc);
|
| 215 |
+
|
| 216 |
+
if(state == 'pan' && enablePan) {
|
| 217 |
+
// Pan mode
|
| 218 |
+
var p = getEventPoint(evt).matrixTransform(stateTf);
|
| 219 |
+
|
| 220 |
+
setCTM(g, stateTf.inverse().translate(p.x - stateOrigin.x, p.y - stateOrigin.y));
|
| 221 |
+
} else if(state == 'drag' && enableDrag) {
|
| 222 |
+
// Drag mode
|
| 223 |
+
var p = getEventPoint(evt).matrixTransform(g.getCTM().inverse());
|
| 224 |
+
|
| 225 |
+
setCTM(stateTarget, root.createSVGMatrix().translate(p.x - stateOrigin.x, p.y - stateOrigin.y).multiply(g.getCTM().inverse()).multiply(stateTarget.getCTM()));
|
| 226 |
+
|
| 227 |
+
stateOrigin = p;
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
/**
|
| 232 |
+
* Handle click event.
|
| 233 |
+
*/
|
| 234 |
+
function handleMouseDown(evt) {
|
| 235 |
+
if(evt.preventDefault)
|
| 236 |
+
evt.preventDefault();
|
| 237 |
+
|
| 238 |
+
evt.returnValue = false;
|
| 239 |
+
|
| 240 |
+
var svgDoc = evt.target.ownerDocument;
|
| 241 |
+
|
| 242 |
+
var g = getRoot(svgDoc);
|
| 243 |
+
|
| 244 |
+
if(
|
| 245 |
+
evt.target.tagName == "svg"
|
| 246 |
+
|| !enableDrag // Pan anyway when drag is disabled and the user clicked on an element
|
| 247 |
+
) {
|
| 248 |
+
// Pan mode
|
| 249 |
+
state = 'pan';
|
| 250 |
+
|
| 251 |
+
stateTf = g.getCTM().inverse();
|
| 252 |
+
|
| 253 |
+
stateOrigin = getEventPoint(evt).matrixTransform(stateTf);
|
| 254 |
+
} else {
|
| 255 |
+
// Drag mode
|
| 256 |
+
state = 'drag';
|
| 257 |
+
|
| 258 |
+
stateTarget = evt.target;
|
| 259 |
+
|
| 260 |
+
stateTf = g.getCTM().inverse();
|
| 261 |
+
|
| 262 |
+
stateOrigin = getEventPoint(evt).matrixTransform(stateTf);
|
| 263 |
+
}
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
/**
|
| 267 |
+
* Handle mouse button release event.
|
| 268 |
+
*/
|
| 269 |
+
function handleMouseUp(evt) {
|
| 270 |
+
if(evt.preventDefault)
|
| 271 |
+
evt.preventDefault();
|
| 272 |
+
|
| 273 |
+
evt.returnValue = false;
|
| 274 |
+
|
| 275 |
+
var svgDoc = evt.target.ownerDocument;
|
| 276 |
+
|
| 277 |
+
if(state == 'pan' || state == 'drag') {
|
| 278 |
+
// Quit pan mode
|
| 279 |
+
state = '';
|
| 280 |
+
}
|
| 281 |
+
}
|
| 282 |
+
|
pool/shard007/JavaScript/0047945_platform.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function() {
|
| 2 |
+
|
| 3 |
+
Dagaz.Model.showLose = false;
|
| 4 |
+
|
| 5 |
+
var CheckInvariants = Dagaz.Model.CheckInvariants;
|
| 6 |
+
|
| 7 |
+
Dagaz.Model.CheckInvariants = function(board) {
|
| 8 |
+
var design = Dagaz.Model.design;
|
| 9 |
+
var up = design.getDirection("up");
|
| 10 |
+
var down = design.getDirection("down");
|
| 11 |
+
_.chain(board.moves)
|
| 12 |
+
.filter(function(move) {
|
| 13 |
+
return move.actions.length == 1;
|
| 14 |
+
})
|
| 15 |
+
.each(function(move) {
|
| 16 |
+
var from = move.actions[0][0][0];
|
| 17 |
+
var to = move.actions[0][1][0];
|
| 18 |
+
var dir = design.findDirection(from, to);
|
| 19 |
+
if (dir !== null) {
|
| 20 |
+
var d = design.navigate(1, from, down);
|
| 21 |
+
var p = design.navigate(1, from, up);
|
| 22 |
+
while ((d === null) && (p !== null)) {
|
| 23 |
+
var piece = board.getPiece(p);
|
| 24 |
+
if (piece !== null) {
|
| 25 |
+
var t = design.navigate(1, p, dir);
|
| 26 |
+
if (t !== null) {
|
| 27 |
+
t = design.navigate(1, t, dir);
|
| 28 |
+
}
|
| 29 |
+
if (t !== null) {
|
| 30 |
+
if ((piece.type == 1) && design.inZone(1, board.player, t)) {
|
| 31 |
+
piece = piece.promote(6);
|
| 32 |
+
}
|
| 33 |
+
move.movePiece(p, t, piece.setValue(0, true));
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
p = design.navigate(board.player, p, up);
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
});
|
| 40 |
+
CheckInvariants(board);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
})();
|
pool/shard007/JavaScript/0047947_buildHtml_test.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var grunt = require('grunt');
|
| 4 |
+
|
| 5 |
+
/*
|
| 6 |
+
======== A Handy Little Nodeunit Reference ========
|
| 7 |
+
https://github.com/caolan/nodeunit
|
| 8 |
+
|
| 9 |
+
Test methods:
|
| 10 |
+
test.expect(numAssertions)
|
| 11 |
+
test.done()
|
| 12 |
+
Test assertions:
|
| 13 |
+
test.ok(value, [message])
|
| 14 |
+
test.equal(actual, expected, [message])
|
| 15 |
+
test.notEqual(actual, expected, [message])
|
| 16 |
+
test.deepEqual(actual, expected, [message])
|
| 17 |
+
test.notDeepEqual(actual, expected, [message])
|
| 18 |
+
test.strictEqual(actual, expected, [message])
|
| 19 |
+
test.notStrictEqual(actual, expected, [message])
|
| 20 |
+
test.throws(block, [error], [message])
|
| 21 |
+
test.doesNotThrow(block, [error], [message])
|
| 22 |
+
test.ifError(value)
|
| 23 |
+
*/
|
| 24 |
+
var tmpFolder = '.tmp';
|
| 25 |
+
|
| 26 |
+
exports.buildHtml = {
|
| 27 |
+
nothingToDo: function(test) {
|
| 28 |
+
var actual = grunt.file.read(tmpFolder + '/nothing-to-do.html');
|
| 29 |
+
var expected = grunt.file.read('test/expected/simple-hello-world.html');
|
| 30 |
+
test.equal(actual, expected, 'nothing has been altered.');
|
| 31 |
+
test.done();
|
| 32 |
+
},
|
| 33 |
+
simpleSkeleton: function(test) {
|
| 34 |
+
var actual = grunt.file.read(tmpFolder + '/simple-skeleton.html');
|
| 35 |
+
var expected = grunt.file.read('test/expected/simple-hello-world.html');
|
| 36 |
+
test.equal(actual, expected, 'a simple skeleton is loaded with 2 params set.');
|
| 37 |
+
test.done();
|
| 38 |
+
},
|
| 39 |
+
simpleSkeletonWithSubmodule: function(test) {
|
| 40 |
+
var actual = grunt.file.read(tmpFolder + '/simple-skeleton-with-submodule.html');
|
| 41 |
+
var expected = grunt.file.read('test/expected/simple-hello-world.html');
|
| 42 |
+
test.equal(actual, expected, 'a simple skeleton is loaded with 2 params set, one of them is a submodule.');
|
| 43 |
+
test.done();
|
| 44 |
+
},
|
| 45 |
+
includeContentHelloWorld: function(test) {
|
| 46 |
+
var actual = grunt.file.read(tmpFolder + '/include-content-hello-world.html');
|
| 47 |
+
var expected = grunt.file.read('test/expected/simple-hello-world.html');
|
| 48 |
+
test.equal(actual, expected, 'a simple skeleton is loaded with 2 params set, one of them is a submodule, this submodule simply loads a module.');
|
| 49 |
+
test.done();
|
| 50 |
+
},
|
| 51 |
+
includeContentHelloWorldFromSubfolder: function(test) {
|
| 52 |
+
var actual = grunt.file.read(tmpFolder + '/include-content-hello-world-from-subfolder.html');
|
| 53 |
+
var expected = grunt.file.read('test/expected/include-content-hello-world-from-subfolder.html');
|
| 54 |
+
test.equal(actual, expected, 'test the correct behavior with namespaced templates');
|
| 55 |
+
test.done();
|
| 56 |
+
},
|
| 57 |
+
includeContentHelloWorldFromVeryDeepSubfolder: function(test) {
|
| 58 |
+
var actual = grunt.file.read(tmpFolder + '/include-content-hello-world-from-very-long-url.html');
|
| 59 |
+
var expected = grunt.file.read('test/expected/include-content-hello-world-from-very-long-url.html');
|
| 60 |
+
test.equal(actual, expected, 'test the correct behavior with very long remote url');
|
| 61 |
+
test.done();
|
| 62 |
+
},
|
| 63 |
+
missingParamDefault: function(test) {
|
| 64 |
+
var actual = grunt.file.read(tmpFolder + '/missing-params-default.html');
|
| 65 |
+
var expected = grunt.file.read('test/expected/missing-params-default.html');
|
| 66 |
+
test.equal(actual, expected, 'load a module without overriding a default parameter.');
|
| 67 |
+
test.done();
|
| 68 |
+
},
|
| 69 |
+
missingParamCustom: function(test) {
|
| 70 |
+
var actual = grunt.file.read(tmpFolder + '/missing-params-custom.html');
|
| 71 |
+
var expected = grunt.file.read('test/expected/missing-params-custom.html');
|
| 72 |
+
test.equal(actual, expected, 'load a module overriding a default parameter.');
|
| 73 |
+
test.done();
|
| 74 |
+
},
|
| 75 |
+
templatesWithWhitespaceInTheirName: function(test) {
|
| 76 |
+
var actual = grunt.file.read(tmpFolder + '/include-content-hello-world-with-whitespace.html');
|
| 77 |
+
var expected = grunt.file.read('test/expected/simple-hello-world.html');
|
| 78 |
+
test.equal(actual, expected, 'folder tree structure is not altered.');
|
| 79 |
+
test.done();
|
| 80 |
+
},
|
| 81 |
+
processSubfolder: function(test) {
|
| 82 |
+
var actual = grunt.file.read(tmpFolder + '/subfolder/nothing-to-do.html');
|
| 83 |
+
var expected = grunt.file.read('test/expected/subfolder/nothing-to-do.html');
|
| 84 |
+
test.equal(actual, expected, 'folder tree structure is not altered.');
|
| 85 |
+
test.done();
|
| 86 |
+
},
|
| 87 |
+
simpleGridSystem: function(test) {
|
| 88 |
+
var actual = grunt.file.read(tmpFolder + '/simple-grid.html');
|
| 89 |
+
var expected = grunt.file.read('test/expected/simple-grid.html');
|
| 90 |
+
test.equal(actual, expected, 'a simple grid system.');
|
| 91 |
+
test.done();
|
| 92 |
+
},
|
| 93 |
+
simpleSkeletonWithRemoteSubmodule: function(test) {
|
| 94 |
+
var actual = grunt.file.read(tmpFolder + '/simple-skeleton-with-remote-submodule.html');
|
| 95 |
+
var expected = grunt.file.read('test/expected/simple-hello-world.html');
|
| 96 |
+
test.equal(actual, expected, 'a simple skeleton is loaded with 2 params set, one of them is a remote submodule.');
|
| 97 |
+
test.done();
|
| 98 |
+
},
|
| 99 |
+
stopNestedEvaluation: function(test) {
|
| 100 |
+
var actual = grunt.file.read(tmpFolder + '/simple-hello-world-without-nested-evalation.html');
|
| 101 |
+
var expected = grunt.file.read('test/expected/simple-hello-world-without-nested-evalation.html');
|
| 102 |
+
test.equal(actual, expected, 'submodule should not be evaluated !');
|
| 103 |
+
test.done();
|
| 104 |
+
}
|
| 105 |
+
};
|
pool/shard007/JavaScript/0047948_delete-entry.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var express = require('express');
|
| 2 |
+
var router = express.Router();
|
| 3 |
+
var ObjectId = require('mongodb').ObjectID;
|
| 4 |
+
var mongoDbConnection = require('../lib/db.js');
|
| 5 |
+
|
| 6 |
+
var isAuthenticated = function (req, res, next) {
|
| 7 |
+
if (req.isAuthenticated())
|
| 8 |
+
return next();
|
| 9 |
+
res.redirect('/login');
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
/* GET home page. */
|
| 13 |
+
router.get('/', function(req, res) {
|
| 14 |
+
res.send("This router does not support get");
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
router.delete('/:collection/id/:id',isAuthenticated, function(req, res) {
|
| 18 |
+
entryId = req.params.id;
|
| 19 |
+
collectionName = req.params.collection;
|
| 20 |
+
console.log(entryId);
|
| 21 |
+
if ((isValidObjectId(entryId)) == false) {
|
| 22 |
+
console.log("Not a valid object ID");
|
| 23 |
+
res.send(404);
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
mongoDbConnection(function(pdb) {
|
| 27 |
+
pdb.collection(collectionName, function(err, collection) {
|
| 28 |
+
if (err) {
|
| 29 |
+
console.log(err);
|
| 30 |
+
res.send(404);
|
| 31 |
+
};
|
| 32 |
+
//Update or insert document
|
| 33 |
+
collection.remove({
|
| 34 |
+
_id: ObjectId(entryId)
|
| 35 |
+
}, function(err, numberOfRemovedDocs) {
|
| 36 |
+
if (err) {
|
| 37 |
+
console.log(err);
|
| 38 |
+
res.send(404);
|
| 39 |
+
};
|
| 40 |
+
res.send(200);
|
| 41 |
+
});
|
| 42 |
+
});
|
| 43 |
+
});
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
function isValidObjectId(str) {
|
| 47 |
+
var pattern = new RegExp("^[0-9a-fA-F]{24}$");
|
| 48 |
+
var res = pattern.test(str);
|
| 49 |
+
return res;
|
| 50 |
+
}
|
| 51 |
+
module.exports = router;
|
pool/shard007/JavaScript/0047951_i18n.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
The i18n module, loads the language files and initializes i18next
|
| 3 |
+
|
| 4 |
+
@module i18n
|
| 5 |
+
*/
|
| 6 |
+
const fs = require('fs');
|
| 7 |
+
const i18n = require('i18next');
|
| 8 |
+
|
| 9 |
+
let i18nConf = fs.readFileSync(`${__dirname}/../interface/project-tap.i18n`);
|
| 10 |
+
i18nConf = JSON.parse(i18nConf);
|
| 11 |
+
|
| 12 |
+
const resources = {
|
| 13 |
+
dev: { translation: require('../interface/i18n/mist.en.i18n.json') },
|
| 14 |
+
};
|
| 15 |
+
|
| 16 |
+
// add supported languages
|
| 17 |
+
i18nConf.supported_languages.forEach((lang) => {
|
| 18 |
+
resources[lang] = { translation: require(`../interface/i18n/mist.${lang}.i18n.json`) };
|
| 19 |
+
});
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Given a language code, get best matched code from supported languages.
|
| 23 |
+
*
|
| 24 |
+
* > getBestMatchedLangCode('en-US')
|
| 25 |
+
* 'en'
|
| 26 |
+
* > getBestMatchedLangCode('zh-TW')
|
| 27 |
+
* 'zh-TW'
|
| 28 |
+
* > getBestMatchedLangCode('no-such-code')
|
| 29 |
+
* 'en'
|
| 30 |
+
*/
|
| 31 |
+
i18n.getBestMatchedLangCode = (langCode) => {
|
| 32 |
+
const codeList = Object.keys(resources);
|
| 33 |
+
let bestMatchedCode = langCode;
|
| 34 |
+
if (codeList.indexOf(langCode) === -1) {
|
| 35 |
+
if (codeList.indexOf(langCode.substr(0, 2)) > -1) {
|
| 36 |
+
bestMatchedCode = langCode.substr(0, 2);
|
| 37 |
+
} else {
|
| 38 |
+
bestMatchedCode = 'en';
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
return bestMatchedCode;
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
// init i18n
|
| 46 |
+
i18n.init({
|
| 47 |
+
lng: global.language || 'en',
|
| 48 |
+
resources,
|
| 49 |
+
interpolation: { prefix: '__', suffix: '__' },
|
| 50 |
+
});
|
| 51 |
+
|
| 52 |
+
module.exports = i18n;
|
pool/shard007/JavaScript/0047952_client.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module.exports = function(app){
|
| 2 |
+
|
| 3 |
+
var log = app.utils.log,
|
| 4 |
+
Dao = app.dao.client,
|
| 5 |
+
responseView = require('../views/jsonSuccessResponse');
|
| 6 |
+
|
| 7 |
+
return {
|
| 8 |
+
|
| 9 |
+
create: function(req, res, next){
|
| 10 |
+
|
| 11 |
+
if(req.user.role == 'admin'){
|
| 12 |
+
Dao.createClient(req.body).then(function(client){
|
| 13 |
+
responseView(client, res);
|
| 14 |
+
}).catch(next);
|
| 15 |
+
} else {
|
| 16 |
+
throw {
|
| 17 |
+
message: "insuficient_privileges",
|
| 18 |
+
statusCode: 401
|
| 19 |
+
};
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
};
|
| 25 |
+
|
| 26 |
+
};
|
pool/shard007/JavaScript/0047954_tfsConnectionConfiguration.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const Q = require('q');
|
| 2 |
+
const vsts = require('vso-node-api');
|
| 3 |
+
const ConnectionBasic = require('./connectionBasic');
|
| 4 |
+
const ConnectionNtlm = require('./connectionNtlm');
|
| 5 |
+
const ConnectionBearer = require('./connectionBearer');
|
| 6 |
+
|
| 7 |
+
class TfsConnectionConfiguration {
|
| 8 |
+
constructor(options) {
|
| 9 |
+
const classes = {ConnectionBasic, ConnectionNtlm, ConnectionBearer};
|
| 10 |
+
const connectionType = classes['Connection' + options.authenticationType];
|
| 11 |
+
|
| 12 |
+
this._Type = new connectionType(options);
|
| 13 |
+
this._Url = options.url;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
getConnection() {
|
| 17 |
+
return new vsts.WebApi(this._Url, this._Type.getHandler());
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
module.exports = TfsConnectionConfiguration;
|
pool/shard007/JavaScript/0047955_repo_v2_fallback.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import V2FallbackSerializer from 'travis/serializers/v2_fallback';
|
| 2 |
+
|
| 3 |
+
var Serializer = V2FallbackSerializer.extend({
|
| 4 |
+
normalize: function (modelClass, resourceHash) {
|
| 5 |
+
if (!resourceHash['@type']) {
|
| 6 |
+
let slug = resourceHash.slug;
|
| 7 |
+
|
| 8 |
+
if (slug && !resourceHash.name) {
|
| 9 |
+
resourceHash.name = slug.split('/')[1];
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
if (slug && !resourceHash.owner) {
|
| 13 |
+
resourceHash.owner = { login: slug.split('/')[0] };
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
return this._super(modelClass, resourceHash);
|
| 18 |
+
}
|
| 19 |
+
});
|
| 20 |
+
|
| 21 |
+
export default Serializer;
|
pool/shard007/JavaScript/0047956_Object_create.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//shape - = superclass
|
| 2 |
+
function Shape() {
|
| 3 |
+
this.x = 0;
|
| 4 |
+
this.y = 0;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
Shape.prototype.move = function(x, y) {
|
| 8 |
+
this.x += x;
|
| 9 |
+
this.y += y;
|
| 10 |
+
console.info("Shape moved.")
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
//Rectangle - subclass
|
| 14 |
+
function Rectangle() {
|
| 15 |
+
Shape.call(this); //call super constructor.
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
Rectangle.prototype = Object.create(Shape.prototype);
|
| 19 |
+
|
| 20 |
+
var rect = new Rectangle();
|
| 21 |
+
|
| 22 |
+
console.log(rect instanceof Rectangle);
|
| 23 |
+
console.log(rect instanceof Shape);
|
| 24 |
+
|
| 25 |
+
rect.move(1,1);
|
pool/shard007/JavaScript/0047965_Pool.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var define = require("../define").define,
|
| 2 |
+
Collection = require("./Collection"),
|
| 3 |
+
Queue = require("./Queue"),
|
| 4 |
+
base = require("../base");
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* @class Base class for a pool.
|
| 8 |
+
*
|
| 9 |
+
* @name Pool
|
| 10 |
+
* @memberOf comb.collections
|
| 11 |
+
*
|
| 12 |
+
* @property {Number} count the total number of objects in the pool, including free and in use objects.
|
| 13 |
+
* @property {Number} freeCount the number of free objects in this pool.
|
| 14 |
+
* @property {Number} inUseCount the number of objects in use in this pool.
|
| 15 |
+
* @property {Number} [minObjects=0] the minimum number of objects this pool should contain.
|
| 16 |
+
* @property {Number} [maxObjects=1] the maximum number of objects this pool should contain
|
| 17 |
+
* @ignoreCode
|
| 18 |
+
*/
|
| 19 |
+
exports = module.exports = define(null, {
|
| 20 |
+
instance : {
|
| 21 |
+
/**@lends comb.collections.Pool.prototype*/
|
| 22 |
+
|
| 23 |
+
__minObjects : 0,
|
| 24 |
+
|
| 25 |
+
__maxObjects : 1,
|
| 26 |
+
|
| 27 |
+
constructor : function(options) {
|
| 28 |
+
options = options || {};
|
| 29 |
+
this.__freeObjects = new Queue();
|
| 30 |
+
this.__inUseObjects = [];
|
| 31 |
+
this.__minObjects = options.minObjects || 0;
|
| 32 |
+
this.__maxObjects = options.maxObjects || 1;
|
| 33 |
+
this.minObjects = this.__minObjects;
|
| 34 |
+
this.maxObjects = this.__maxObjects;
|
| 35 |
+
},
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* Retrieves an object from this pool.
|
| 39 |
+
* `
|
| 40 |
+
* @return {*} an object to contained in this pool
|
| 41 |
+
*/
|
| 42 |
+
getObject : function() {
|
| 43 |
+
var ret = undefined;
|
| 44 |
+
if (this.freeCount > 0) {
|
| 45 |
+
ret = this.__freeObjects.dequeue();
|
| 46 |
+
this.__inUseObjects.push(ret);
|
| 47 |
+
} else if (this.__maxObjects > this.count) {
|
| 48 |
+
ret = this.createObject();
|
| 49 |
+
this.__inUseObjects.push(ret);
|
| 50 |
+
}
|
| 51 |
+
return ret;
|
| 52 |
+
},
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* Returns an object to this pool. The object is validated before it is returned to the pool,
|
| 56 |
+
* if the validation fails then it is removed from the pool;
|
| 57 |
+
* @param {*} obj the object to return to the pool
|
| 58 |
+
*/
|
| 59 |
+
returnObject : function(obj) {
|
| 60 |
+
if (this.validate(obj) && this.count <= this.__maxObjects) {
|
| 61 |
+
this.__freeObjects.enqueue(obj);
|
| 62 |
+
var index;
|
| 63 |
+
if ((index = this.__inUseObjects.indexOf(obj)) > -1)
|
| 64 |
+
this.__inUseObjects.splice(index, 1);
|
| 65 |
+
} else {
|
| 66 |
+
this.removeObject(obj);
|
| 67 |
+
}
|
| 68 |
+
},
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Removes an object from the pool, this can be overriden to provide any
|
| 72 |
+
* teardown of objects that needs to take place.
|
| 73 |
+
*
|
| 74 |
+
* @param {*} obj the object that needs to be removed.
|
| 75 |
+
*
|
| 76 |
+
* @return {*} the object removed.
|
| 77 |
+
*/
|
| 78 |
+
removeObject : function(obj) {
|
| 79 |
+
var index;
|
| 80 |
+
if (this.__freeObjects.contains(obj)) {
|
| 81 |
+
this.__freeObjects.remove(obj);
|
| 82 |
+
} else if ((index = this.__inUseObjects.indexOf(obj)) > -1) {
|
| 83 |
+
this.__inUseObjects.splice(index, 1);
|
| 84 |
+
}
|
| 85 |
+
//otherwise its not contained in this pool;
|
| 86 |
+
return obj;
|
| 87 |
+
},
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Validates an object in this pool.
|
| 91 |
+
* </br>
|
| 92 |
+
* <b>THIS SHOULD BE OVERRIDDEN TO VALIDATE</b>
|
| 93 |
+
*
|
| 94 |
+
* @param {*} obj the object to validate.
|
| 95 |
+
*/
|
| 96 |
+
validate : function(obj) {
|
| 97 |
+
return true;
|
| 98 |
+
},
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
* Creates a new object for this pool.
|
| 102 |
+
* * </br>
|
| 103 |
+
* <b>THIS SHOULD BE OVERRIDDEN TO ADD THE CORRECT TYPE OF OBJECT</b>
|
| 104 |
+
*
|
| 105 |
+
* @return {Object} be default just creates an object.
|
| 106 |
+
*/
|
| 107 |
+
createObject : function() {
|
| 108 |
+
return {};
|
| 109 |
+
},
|
| 110 |
+
|
| 111 |
+
setters : {
|
| 112 |
+
minObjects : function(l) {
|
| 113 |
+
|
| 114 |
+
if (l <= this.__maxObjects) {
|
| 115 |
+
this.__minObjects = l;
|
| 116 |
+
var i;
|
| 117 |
+
if ((i = this.count) < l) {
|
| 118 |
+
while (i++ < l) {
|
| 119 |
+
this.__freeObjects.enqueue(this.createObject());
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
} else {
|
| 123 |
+
throw "comb.collections.Pool : minObjects cannot be greater than maxObjects.";
|
| 124 |
+
}
|
| 125 |
+
},
|
| 126 |
+
maxObjects : function(l) {
|
| 127 |
+
if (l >= this.__minObjects) {
|
| 128 |
+
this.__maxObjects = l;
|
| 129 |
+
var i = this.count, j = this.freeCount, fo = this.__freeObjects;
|
| 130 |
+
while (i > l && j >= 0) {
|
| 131 |
+
this.removeObject(fo.dequeue());
|
| 132 |
+
j--;
|
| 133 |
+
i--;
|
| 134 |
+
}
|
| 135 |
+
} else {
|
| 136 |
+
throw "comb.collections.Pool : maxObjects cannot be less than maxObjects.";
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
}
|
| 140 |
+
},
|
| 141 |
+
|
| 142 |
+
getters : {
|
| 143 |
+
freeCount : function() {
|
| 144 |
+
return this.__freeObjects.count;
|
| 145 |
+
},
|
| 146 |
+
inUseCount : function() {
|
| 147 |
+
return this.__inUseObjects.length;
|
| 148 |
+
},
|
| 149 |
+
count : function() {
|
| 150 |
+
return this.__freeObjects.count + this.__inUseObjects.length;
|
| 151 |
+
|
| 152 |
+
},
|
| 153 |
+
|
| 154 |
+
minObjects : function() {
|
| 155 |
+
return this.__minObjects;
|
| 156 |
+
},
|
| 157 |
+
maxObjects : function() {
|
| 158 |
+
return this.__maxObjects;
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
})
|
pool/shard007/JavaScript/0047969_test.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var test = require('tape');
|
| 2 |
+
var xpath2css = require('./index');
|
| 3 |
+
|
| 4 |
+
test('basic', function(assert) {
|
| 5 |
+
var actual, expected;
|
| 6 |
+
|
| 7 |
+
actual = xpath2css('/HTML/HEAD/TITLE');
|
| 8 |
+
expected = 'HTML > HEAD > TITLE';
|
| 9 |
+
assert.equal(actual, expected, 'child, upper case');
|
| 10 |
+
|
| 11 |
+
actual = xpath2css('//html//head//title');
|
| 12 |
+
expected = 'html head title';
|
| 13 |
+
assert.equal(actual, expected, 'descendant, lower case');
|
| 14 |
+
|
| 15 |
+
assert.end();
|
| 16 |
+
});
|
| 17 |
+
|
| 18 |
+
test('converting', function(assert) {
|
| 19 |
+
var actual, expected;
|
| 20 |
+
|
| 21 |
+
actual = xpath2css("/HTML/BODY/DIV[@id='menu']/NAV/UL[5]");
|
| 22 |
+
expected = "HTML > BODY > DIV[id='menu'] > NAV > UL:nth-of-type(5)";
|
| 23 |
+
assert.equal(actual, expected, 'attribute, index (nth-of-type)');
|
| 24 |
+
|
| 25 |
+
actual = xpath2css("//NAV/*[5]");
|
| 26 |
+
expected = "NAV > *:nth-child(5)";
|
| 27 |
+
assert.equal(actual, expected, 'index (nth-child)');
|
| 28 |
+
|
| 29 |
+
actual = xpath2css("//x[position() = 5 and a = 'b']");
|
| 30 |
+
expected = "x:nth-of-type(5)[a='b']";
|
| 31 |
+
assert.equal(actual, expected, 'index "position() = n"');
|
| 32 |
+
|
| 33 |
+
actual = xpath2css('//div[contains(@id, foo )]/ span [ contains ( @class , \' bar\' ) ] //a[contains(@class, "baz ")]//img');
|
| 34 |
+
expected = 'div[id*=foo] > span[class*=\' bar\'] a[class*="baz "] img';
|
| 35 |
+
assert.equal(actual, expected, '"contains" clause, spaces');
|
| 36 |
+
|
| 37 |
+
actual = xpath2css('//*[starts-with(@data-id, " test ")]');
|
| 38 |
+
expected = '*[data-id^=" test "]';
|
| 39 |
+
assert.equal(actual, expected, '"starts-with" clause, spaces');
|
| 40 |
+
|
| 41 |
+
actual = xpath2css('//*[ends-with(@data-test , "test")]');
|
| 42 |
+
expected = '*[data-test$="test"]';
|
| 43 |
+
assert.equal(actual, expected, '"ends-with" clause, spaces');
|
| 44 |
+
|
| 45 |
+
actual = xpath2css('//*[ends-with(@data-test , "test") and @data-x = "xx"]');
|
| 46 |
+
expected = '*[data-test$="test"][data-x="xx"]';
|
| 47 |
+
assert.equal(actual, expected, '"and" clause');
|
| 48 |
+
|
| 49 |
+
actual = xpath2css('//*[contains(text(), "substring")]');
|
| 50 |
+
expected = '*:contains("substring")';
|
| 51 |
+
assert.equal(actual, expected, '"contains(text(), ...)" clause');
|
| 52 |
+
|
| 53 |
+
actual = xpath2css('//x[@a="1"]/.[@b="2"]');
|
| 54 |
+
expected = 'x[a="1"][b="2"]';
|
| 55 |
+
assert.equal(actual, expected, '"./" (self) clause');
|
| 56 |
+
|
| 57 |
+
actual = xpath2css('//A[contains(@href, "www.example.com/test/") and contains(@href, "test=value")]');
|
| 58 |
+
expected = 'A[href*="www.example.com/test/"][href*="test=value"]';
|
| 59 |
+
assert.equal(actual, expected, 'multiple "contains"');
|
| 60 |
+
|
| 61 |
+
actual = xpath2css('//A[starts-with(@href, "www.example.com/test/") and starts-with(@href, "test=value")]');
|
| 62 |
+
expected = 'A[href^="www.example.com/test/"][href^="test=value"]';
|
| 63 |
+
assert.equal(actual, expected, 'multiple "starts-with"');
|
| 64 |
+
|
| 65 |
+
actual = xpath2css('//A[ends-with(@href, "www.example.com/test/") and ends-with(@href, "test=value")]');
|
| 66 |
+
expected = 'A[href$="www.example.com/test/"][href$="test=value"]';
|
| 67 |
+
assert.equal(actual, expected, 'multiple "ends-with"');
|
| 68 |
+
|
| 69 |
+
actual = xpath2css('//DIV[contains(text(), "x") and contains(@class, \'bold\')]');
|
| 70 |
+
expected = 'DIV:contains("x")[class*=\'bold\']';
|
| 71 |
+
assert.equal(actual, expected, 'contains(text(), ...) and contains(@attr, ...)');
|
| 72 |
+
|
| 73 |
+
actual = xpath2css(' // x [ 42 ] ');
|
| 74 |
+
expected = 'x:eq(41)';
|
| 75 |
+
assert.equal(actual, expected, 'index (eq), spaces');
|
| 76 |
+
|
| 77 |
+
assert.end();
|
| 78 |
+
});
|
| 79 |
+
|
| 80 |
+
test('escaping', function(assert) {
|
| 81 |
+
var actual, expected;
|
| 82 |
+
|
| 83 |
+
actual = xpath2css('//x[@a = "a string with special chars and clauses like: \\\'::\\\', \\" and \\", \' or \', \', /, //, /////, /.., [, ], (, ) and @"]');
|
| 84 |
+
expected = 'x[a="a string with special chars and clauses like: \\\'::\\\', \\" and \\", \' or \', \', /, //, /////, /.., [, ], (, ) and @"]';
|
| 85 |
+
assert.equal(actual, expected, 'special chars & clauses');
|
| 86 |
+
|
| 87 |
+
actual = xpath2css('//x[contains(text(), "//x[a=\'1\']")]');
|
| 88 |
+
expected = 'x:contains("//x[a=\'1\']")';
|
| 89 |
+
assert.equal(actual, expected, 'special chars & clauses, "contains(text(), ...)"');
|
| 90 |
+
|
| 91 |
+
actual = xpath2css('//x[contains(text(), unquoted-string)]');
|
| 92 |
+
expected = 'x:contains(unquoted-string)';
|
| 93 |
+
assert.equal(actual, expected, 'unquoted string');
|
| 94 |
+
|
| 95 |
+
assert.end();
|
| 96 |
+
});
|
| 97 |
+
|
| 98 |
+
test('comments', function(assert) {
|
| 99 |
+
var actual, expected;
|
| 100 |
+
|
| 101 |
+
actual = xpath2css('//x[ (: a comment with special chars and clauses like: \\\'::\\\', \\" and \\", \' or \', \', /, //, /////, /.., [, ], (, ) and @ :) a = 1 ]');
|
| 102 |
+
expected = 'x[a=1]';
|
| 103 |
+
assert.equal(actual, expected, 'XPATH 2.0 comment');
|
| 104 |
+
|
| 105 |
+
actual = xpath2css('//x[a = 1 and "comment #1 with special chars and clauses like: \\\'::\\\', \\" and \\", \' or \', \', /, //, /////, /.., [, ], (, ) and @"]');
|
| 106 |
+
expected = 'x[a=1]';
|
| 107 |
+
assert.equal(actual, expected, 'always-true-string comment #1');
|
| 108 |
+
|
| 109 |
+
actual = xpath2css('//x[ "comment #2 with special chars and clauses like: \\\'::\\\', \\" and \\", \' or \', \', /, //, /////, /.., [, ], (, ) and @" and a = "2"]');
|
| 110 |
+
expected = 'x[a="2"]';
|
| 111 |
+
assert.equal(actual, expected, 'always-true-string comment #2');
|
| 112 |
+
|
| 113 |
+
assert.end();
|
| 114 |
+
});
|
pool/shard007/JavaScript/0047970_superfish.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
/*
|
| 3 |
+
* Superfish v1.4.8 - jQuery menu widget
|
| 4 |
+
* Copyright (c) 2008 Joel Birch
|
| 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 |
+
* CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
;(function($){
|
| 14 |
+
$.fn.superfish = function(op){
|
| 15 |
+
|
| 16 |
+
var sf = $.fn.superfish,
|
| 17 |
+
c = sf.c,
|
| 18 |
+
$arrow = $(['<span class="',c.arrowClass,'"> »</span>'].join('')),
|
| 19 |
+
over = function(){
|
| 20 |
+
var $$ = $(this), menu = getMenu($$);
|
| 21 |
+
clearTimeout(menu.sfTimer);
|
| 22 |
+
$$.showSuperfishUl().siblings().hideSuperfishUl();
|
| 23 |
+
},
|
| 24 |
+
out = function(){
|
| 25 |
+
var $$ = $(this), menu = getMenu($$), o = sf.op;
|
| 26 |
+
clearTimeout(menu.sfTimer);
|
| 27 |
+
menu.sfTimer=setTimeout(function(){
|
| 28 |
+
o.retainPath=($.inArray($$[0],o.$path)>-1);
|
| 29 |
+
$$.hideSuperfishUl();
|
| 30 |
+
if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
|
| 31 |
+
},o.delay);
|
| 32 |
+
},
|
| 33 |
+
getMenu = function($menu){
|
| 34 |
+
var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
|
| 35 |
+
sf.op = sf.o[menu.serial];
|
| 36 |
+
return menu;
|
| 37 |
+
},
|
| 38 |
+
addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
|
| 39 |
+
|
| 40 |
+
return this.each(function() {
|
| 41 |
+
var s = this.serial = sf.o.length;
|
| 42 |
+
var o = $.extend({},sf.defaults,op);
|
| 43 |
+
o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
|
| 44 |
+
$(this).addClass([o.hoverClass,c.bcClass].join(' '))
|
| 45 |
+
.filter('li:has(ul)').removeClass(o.pathClass);
|
| 46 |
+
});
|
| 47 |
+
sf.o[s] = sf.op = o;
|
| 48 |
+
|
| 49 |
+
$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
|
| 50 |
+
if (o.autoArrows) addArrow( $('>a:first-child',this) );
|
| 51 |
+
})
|
| 52 |
+
.not('.'+c.bcClass)
|
| 53 |
+
.hideSuperfishUl();
|
| 54 |
+
|
| 55 |
+
var $a = $('a',this);
|
| 56 |
+
$a.each(function(i){
|
| 57 |
+
var $li = $a.eq(i).parents('li');
|
| 58 |
+
$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
|
| 59 |
+
});
|
| 60 |
+
o.onInit.call(this);
|
| 61 |
+
|
| 62 |
+
}).each(function() {
|
| 63 |
+
var menuClasses = [c.menuClass];
|
| 64 |
+
if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
|
| 65 |
+
$(this).addClass(menuClasses.join(' '));
|
| 66 |
+
});
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
var sf = $.fn.superfish;
|
| 70 |
+
sf.o = [];
|
| 71 |
+
sf.op = {};
|
| 72 |
+
sf.IE7fix = function(){
|
| 73 |
+
var o = sf.op;
|
| 74 |
+
if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
|
| 75 |
+
this.toggleClass(sf.c.shadowClass+'-off');
|
| 76 |
+
};
|
| 77 |
+
sf.c = {
|
| 78 |
+
bcClass : 'sf-breadcrumb',
|
| 79 |
+
menuClass : 'sf-js-enabled',
|
| 80 |
+
anchorClass : 'sf-with-ul',
|
| 81 |
+
arrowClass : 'sf-sub-indicator',
|
| 82 |
+
shadowClass : 'sf-shadow'
|
| 83 |
+
};
|
| 84 |
+
sf.defaults = {
|
| 85 |
+
hoverClass : 'sfhover',
|
| 86 |
+
pathClass : 'overideThisToUse',
|
| 87 |
+
pathLevels : 1,
|
| 88 |
+
delay : 800,
|
| 89 |
+
animation : {opacity:'show'},
|
| 90 |
+
speed : 'normal',
|
| 91 |
+
autoArrows : true,
|
| 92 |
+
dropShadows : true,
|
| 93 |
+
disableHI : false, // true disables hoverIntent detection
|
| 94 |
+
onInit : function(){}, // callback functions
|
| 95 |
+
onBeforeShow: function(){},
|
| 96 |
+
onShow : function(){},
|
| 97 |
+
onHide : function(){}
|
| 98 |
+
};
|
| 99 |
+
$.fn.extend({
|
| 100 |
+
hideSuperfishUl : function(){
|
| 101 |
+
var o = sf.op,
|
| 102 |
+
not = (o.retainPath===true) ? o.$path : '';
|
| 103 |
+
o.retainPath = false;
|
| 104 |
+
var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
|
| 105 |
+
.find('>ul').hide().css('visibility','hidden');
|
| 106 |
+
o.onHide.call($ul);
|
| 107 |
+
return this;
|
| 108 |
+
},
|
| 109 |
+
showSuperfishUl : function(){
|
| 110 |
+
var o = sf.op,
|
| 111 |
+
sh = sf.c.shadowClass+'-off',
|
| 112 |
+
$ul = this.addClass(o.hoverClass)
|
| 113 |
+
.find('>ul:hidden').css('visibility','visible');
|
| 114 |
+
sf.IE7fix.call($ul);
|
| 115 |
+
o.onBeforeShow.call($ul);
|
| 116 |
+
$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
|
| 117 |
+
return this;
|
| 118 |
+
}
|
| 119 |
+
});
|
| 120 |
+
|
| 121 |
+
})(jQuery);
|
| 122 |
+
|
pool/shard007/JavaScript/0047972_size_report.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* grunt-size-report
|
| 3 |
+
* -
|
| 4 |
+
*
|
| 5 |
+
* Copyright (c) 2013 Jesse Luoto / Activeark JWT
|
| 6 |
+
* Licensed under the MIT license.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
'use strict';
|
| 10 |
+
|
| 11 |
+
module.exports = function(grunt) {
|
| 12 |
+
|
| 13 |
+
// Init ShellJS
|
| 14 |
+
var fs = require('fs');
|
| 15 |
+
var path = require('path');
|
| 16 |
+
var util = require('util');
|
| 17 |
+
|
| 18 |
+
function FileSize(filePath) {
|
| 19 |
+
this.relativePath = filePath;
|
| 20 |
+
this.absolutePath = path.resolve(filePath);
|
| 21 |
+
this.size = fs.statSync(this.absolutePath).size;
|
| 22 |
+
this.hSize = humanReadableFilesize(this.size);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
var sizeArr = [
|
| 26 |
+
"B ", // padded
|
| 27 |
+
"KiB",
|
| 28 |
+
"MiB",
|
| 29 |
+
"GiB",
|
| 30 |
+
"TiB",
|
| 31 |
+
"PiB",
|
| 32 |
+
"EiB",
|
| 33 |
+
"ZiB",
|
| 34 |
+
"YiB"
|
| 35 |
+
];
|
| 36 |
+
|
| 37 |
+
function humanReadableFilesize(size) {
|
| 38 |
+
var currSize = size;
|
| 39 |
+
var pow = 0;
|
| 40 |
+
while(currSize > 762) { // more than ~0.7
|
| 41 |
+
pow++;
|
| 42 |
+
currSize = size / (Math.pow(1024, pow) || 1);
|
| 43 |
+
}
|
| 44 |
+
if(pow > 0) {
|
| 45 |
+
currSize = currSize.toFixed(1);
|
| 46 |
+
}
|
| 47 |
+
return currSize + " " + sizeArr[pow];
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
function padRight(string, width, padding) {
|
| 51 |
+
if(typeof(padding) === "undefined") {
|
| 52 |
+
padding = " "; // default
|
| 53 |
+
}
|
| 54 |
+
return (width <= string.length) ? string : padRight(padding + string, width, padding);
|
| 55 |
+
}
|
| 56 |
+
function padLeft(string, width, padding) {
|
| 57 |
+
if(typeof(padding) === "undefined") {
|
| 58 |
+
padding = " "; // default
|
| 59 |
+
}
|
| 60 |
+
return (width <= string.length) ? string : padLeft(string + padding, width, padding);
|
| 61 |
+
}
|
| 62 |
+
function averageFileSize(files) {
|
| 63 |
+
return files.reduce(function(a,b) {
|
| 64 |
+
return a + b.size;
|
| 65 |
+
}, 0) / files.length;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
grunt.registerMultiTask('size_report', 'Create size report of your project', function() {
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
// Merge task-specific and/or target-specific options with these defaults.
|
| 73 |
+
var options = this.options({
|
| 74 |
+
// TODO: human-readable on/off
|
| 75 |
+
'header': 'Size report',
|
| 76 |
+
'showStatistics': false
|
| 77 |
+
});
|
| 78 |
+
|
| 79 |
+
if (typeof options.header !== 'string') {
|
| 80 |
+
grunt.log.error('Header should be a string');
|
| 81 |
+
return false;
|
| 82 |
+
}
|
| 83 |
+
if (options.header.indexOf('\n') > -1) {
|
| 84 |
+
grunt.log.error('Only single-line headers are supported');
|
| 85 |
+
grunt.log.error('Remove any line breaks in `options.header` variable');
|
| 86 |
+
return false;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
// Iterate over all specified file groups.
|
| 90 |
+
this.files.forEach(function(f) {
|
| 91 |
+
|
| 92 |
+
// Generate FileSize objects
|
| 93 |
+
var fileSizes = f.src.filter(function(filepath) {
|
| 94 |
+
// Warn on and remove invalid source files (if nonull was set).
|
| 95 |
+
if (!grunt.file.exists(filepath)) {
|
| 96 |
+
grunt.log.warn('Source file "' + filepath + '" not found.');
|
| 97 |
+
return false;
|
| 98 |
+
} else {
|
| 99 |
+
return true;
|
| 100 |
+
}
|
| 101 |
+
}).map(function(file) {
|
| 102 |
+
return new FileSize(file);
|
| 103 |
+
});
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
// Calculate statistics
|
| 107 |
+
var total = 0;
|
| 108 |
+
var longestPathLength = 0;
|
| 109 |
+
var numFiles = fileSizes.length.toString();
|
| 110 |
+
fileSizes.forEach(function(f) {
|
| 111 |
+
total += f.size;
|
| 112 |
+
longestPathLength = Math.max(longestPathLength, f.relativePath.length);
|
| 113 |
+
});
|
| 114 |
+
|
| 115 |
+
fileSizes.sort(function(a,b) {
|
| 116 |
+
return b.size - a.size;
|
| 117 |
+
});
|
| 118 |
+
|
| 119 |
+
var average = humanReadableFilesize(averageFileSize(fileSizes));
|
| 120 |
+
|
| 121 |
+
// Generate report
|
| 122 |
+
|
| 123 |
+
// Header
|
| 124 |
+
grunt.log.writeln();
|
| 125 |
+
grunt.log.write(padLeft("", options.header.length, "~"));
|
| 126 |
+
grunt.log.subhead(options.header);
|
| 127 |
+
grunt.log.writeln(padLeft("", options.header.length, "~"));
|
| 128 |
+
|
| 129 |
+
if (options.showStatistics) {
|
| 130 |
+
// Overall statistics
|
| 131 |
+
grunt.log.writeln();
|
| 132 |
+
grunt.log.writeln("Total number of files: " + numFiles.bold);
|
| 133 |
+
grunt.log.writeln("Average file size: " + padRight(average, numFiles.length + 8).bold);
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
// Size table
|
| 137 |
+
grunt.log.subhead(padLeft("Filename", longestPathLength + 6) + "Size" + padRight("%", 11));
|
| 138 |
+
grunt.log.writeln(grunt.log.wordlist([padLeft("", longestPathLength + 21, "-")], {color: 'grey'}));
|
| 139 |
+
fileSizes.forEach(function(f){
|
| 140 |
+
//grunt.log.writeln(grunt.log.wordlist(['\nWarning: ' + result.output], {color: 'yellow'}));
|
| 141 |
+
grunt.log.writeln(util.format("%s %s %s",
|
| 142 |
+
padLeft(f.relativePath, longestPathLength),
|
| 143 |
+
padRight(f.hSize, 9),
|
| 144 |
+
padRight((f.size / total * 100).toFixed(1) + "%", 6)
|
| 145 |
+
));
|
| 146 |
+
});
|
| 147 |
+
grunt.log.write(grunt.log.wordlist([padLeft("", longestPathLength + 21, "=")], {color: 'grey'}));
|
| 148 |
+
grunt.log.subhead("Total: " + padRight(humanReadableFilesize(total), longestPathLength + 5));
|
| 149 |
+
});
|
| 150 |
+
});
|
| 151 |
+
|
| 152 |
+
// Return testable functions
|
| 153 |
+
return {
|
| 154 |
+
'FileSize': FileSize,
|
| 155 |
+
'humanReadableFilesize': humanReadableFilesize,
|
| 156 |
+
'padRight': padRight,
|
| 157 |
+
'padLeft': padLeft,
|
| 158 |
+
'averageFileSize': averageFileSize
|
| 159 |
+
};
|
| 160 |
+
|
| 161 |
+
};
|
pool/shard007/JavaScript/0047975_bug970427.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// XXXshu: I tried wrapping the entire test in an |if (pjs)|, but the timing
|
| 2 |
+
// is fragile and it no longer reproduced the bug, thus getting this value at
|
| 3 |
+
// the beginning.
|
| 4 |
+
var pjs = getBuildConfiguration().parallelJS;
|
| 5 |
+
function f(a, b) {
|
| 6 |
+
var o = a;
|
| 7 |
+
gczeal(2);
|
| 8 |
+
}
|
| 9 |
+
f(3, 4);
|
| 10 |
+
var len = 5000;
|
| 11 |
+
var iters = 100;
|
| 12 |
+
for (var i = 0; i < iters; i++) {
|
| 13 |
+
var par = pjs ? Array.buildPar(len, fill) : true;
|
| 14 |
+
}
|
| 15 |
+
function fill(i) { return 10/i; }
|
pool/shard007/JavaScript/0047976_index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
define(function( require ) {
|
| 2 |
+
'use strict';
|
| 3 |
+
|
| 4 |
+
var capsParams = require('../capsParams'),
|
| 5 |
+
fn = require('../fn/common'),
|
| 6 |
+
validate = require('../helper/validate'),
|
| 7 |
+
method = capsParams.getSiteCollections,
|
| 8 |
+
defaults;
|
| 9 |
+
|
| 10 |
+
defaults = {
|
| 11 |
+
type: 'GET',
|
| 12 |
+
data: {
|
| 13 |
+
RequestType: method.name,
|
| 14 |
+
OutputType: 'json'
|
| 15 |
+
}
|
| 16 |
+
};
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
*
|
| 20 |
+
* @param options {object} getSiteCollections configuration object
|
| 21 |
+
* @param params {object} ajax settings overwriting defaults and options
|
| 22 |
+
* @returns {*} promise
|
| 23 |
+
*/
|
| 24 |
+
function getSiteCollections ( options, params ) {
|
| 25 |
+
options = options || {};
|
| 26 |
+
|
| 27 |
+
var request,
|
| 28 |
+
data = {},
|
| 29 |
+
optional = method.optional,
|
| 30 |
+
required = method.required;
|
| 31 |
+
|
| 32 |
+
data = validate.addRequiredProperties(options, data, required, 'getSiteCollections');
|
| 33 |
+
data = validate.addOptionalProperties(options, data, optional, 'getSiteCollections');
|
| 34 |
+
|
| 35 |
+
request = $.extend(true, {}, defaults, {
|
| 36 |
+
data: data
|
| 37 |
+
}, params);
|
| 38 |
+
|
| 39 |
+
return fn.getPromise(request);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
return getSiteCollections;
|
| 43 |
+
}
|
| 44 |
+
);
|