Upload folder using huggingface_hub (part 54)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- pool/shard004/JavaScript/0026537_multiline-ternary.js +66 -0
- pool/shard004/JavaScript/0026540_addfire.js +14 -0
- pool/shard004/JavaScript/0026544_reset-password.js +44 -0
- pool/shard004/JavaScript/0026545_generator.js +42 -0
- pool/shard004/JavaScript/0026548_NodeAttachmentMap.js +43 -0
- pool/shard004/JavaScript/0026550_aroon.js +71 -0
- pool/shard004/JavaScript/0026552_lodashModule.js +32 -0
- pool/shard004/JavaScript/0026555_routes.js +30 -0
- pool/shard004/JavaScript/0026556_chkInternalIP.js +17 -0
- pool/shard004/JavaScript/0026558_photo.js +80 -0
- pool/shard004/JavaScript/0026560_load-map.js +87 -0
- pool/shard004/JavaScript/0026561_ng.directive_ngInclude.jqlite_test.js +34 -0
- pool/shard004/JavaScript/0026567_session.js +51 -0
- pool/shard004/JavaScript/0026568_DesignerNav.js +58 -0
- pool/shard004/JavaScript/0026569_list_pool.js +173 -0
- pool/shard004/JavaScript/0026572_datatables-init.js +53 -0
- pool/shard004/JavaScript/0026573_assessment-test.js +100 -0
- pool/shard004/JavaScript/0026577_sigint.js +16 -0
- pool/shard004/JavaScript/0026582_Permissions.js +39 -0
- pool/shard004/JavaScript/0026583_token.js +108 -0
- pool/shard004/JavaScript/0026584_HaProxyHelper.js +37 -0
- pool/shard004/JavaScript/0026589_config.js +148 -0
- pool/shard004/JavaScript/0026593_styleswitch.js +69 -0
- pool/shard004/JavaScript/0026595_mongo_translator.js +123 -0
- pool/shard004/JavaScript/0026597_DDPConnection.js +269 -0
- pool/shard004/JavaScript/0026598_index.js +40 -0
- pool/shard004/JavaScript/0026602_update.js +32 -0
- pool/shard004/JavaScript/0026605_GraphEdge.js +69 -0
- pool/shard004/JavaScript/0026607_addCommand.js +63 -0
- pool/shard004/JavaScript/0026612_mousepress.js +60 -0
- pool/shard004/JavaScript/0026613_input-list.js +29 -0
- pool/shard004/JavaScript/0026615_columnAnimationService.js +106 -0
- pool/shard004/JavaScript/0026618_stateGetter.test.js +160 -0
- pool/shard004/JavaScript/0026621_selenium.js +222 -0
- pool/shard004/JavaScript/0026623_tooltip.js +127 -0
- pool/shard004/JavaScript/0026626_cookies.js +147 -0
- pool/shard004/JavaScript/0026631_jobStatistic.js +108 -0
- pool/shard004/JavaScript/0026635_editor_plugin.js +80 -0
- pool/shard004/JavaScript/0026636_date-format.filter.js +19 -0
- pool/shard004/JavaScript/0026638_compareTest.js +67 -0
- pool/shard004/JavaScript/0026641_stockData.js +167 -0
- pool/shard004/JavaScript/0026642_adaptation.list_custom_classes.js +75 -0
- pool/shard004/JavaScript/0026644_collision.js +86 -0
- pool/shard004/JavaScript/0026645_card-poster.js +86 -0
- pool/shard004/JavaScript/0026649_markdownFilter.js +23 -0
- pool/shard004/JavaScript/0026651_1012101.js +48 -0
- pool/shard004/JavaScript/0026653_includes.js +146 -0
- pool/shard004/JavaScript/0026654_adff06c4cdf63693395a023ef358c3d9b77cceb1.js +93 -0
- pool/shard004/JavaScript/0026656_source-map.js +88 -0
- pool/shard004/JavaScript/0026659_css-toggle.js +27 -0
pool/shard004/JavaScript/0026537_multiline-ternary.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @fileoverview Enforce newlines between operands of ternary expressions
|
| 3 |
+
* @author Kai Cataldo
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
"use strict";
|
| 7 |
+
|
| 8 |
+
const astUtils = require("../ast-utils");
|
| 9 |
+
|
| 10 |
+
//------------------------------------------------------------------------------
|
| 11 |
+
// Rule Definition
|
| 12 |
+
//------------------------------------------------------------------------------
|
| 13 |
+
|
| 14 |
+
module.exports = {
|
| 15 |
+
meta: {
|
| 16 |
+
docs: {
|
| 17 |
+
description: "enforce newlines between operands of ternary expressions",
|
| 18 |
+
category: "Stylistic Issues",
|
| 19 |
+
recommended: false
|
| 20 |
+
},
|
| 21 |
+
schema: []
|
| 22 |
+
},
|
| 23 |
+
|
| 24 |
+
create(context) {
|
| 25 |
+
|
| 26 |
+
//--------------------------------------------------------------------------
|
| 27 |
+
// Helpers
|
| 28 |
+
//--------------------------------------------------------------------------
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Tests whether node is preceded by supplied tokens
|
| 32 |
+
* @param {ASTNode} node - node to check
|
| 33 |
+
* @param {ASTNode} parentNode - parent of node to report
|
| 34 |
+
* @returns {void}
|
| 35 |
+
* @private
|
| 36 |
+
*/
|
| 37 |
+
function reportError(node, parentNode) {
|
| 38 |
+
context.report({
|
| 39 |
+
node,
|
| 40 |
+
message: "Expected newline between {{typeOfError}} of ternary expression.",
|
| 41 |
+
data: {
|
| 42 |
+
typeOfError: node === parentNode.test ? "test and consequent" : "consequent and alternate"
|
| 43 |
+
}
|
| 44 |
+
});
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
//--------------------------------------------------------------------------
|
| 48 |
+
// Public
|
| 49 |
+
//--------------------------------------------------------------------------
|
| 50 |
+
|
| 51 |
+
return {
|
| 52 |
+
ConditionalExpression(node) {
|
| 53 |
+
const areTestAndConsequentOnSameLine = astUtils.isTokenOnSameLine(node.test, node.consequent);
|
| 54 |
+
const areConsequentAndAlternateOnSameLine = astUtils.isTokenOnSameLine(node.consequent, node.alternate);
|
| 55 |
+
|
| 56 |
+
if (areTestAndConsequentOnSameLine) {
|
| 57 |
+
reportError(node.test, node);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
if (areConsequentAndAlternateOnSameLine) {
|
| 61 |
+
reportError(node.consequent, node);
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
};
|
| 65 |
+
}
|
| 66 |
+
};
|
pool/shard004/JavaScript/0026540_addfire.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
window.prepareFire = function() {
|
| 2 |
+
var fire = new BABYLON.FireMaterial("fire", scene);
|
| 3 |
+
fire.diffuseTexture = new BABYLON.Texture("/playground/textures/fire/diffuse.png", scene);
|
| 4 |
+
fire.distortionTexture = new BABYLON.Texture("/playground/textures/fire/distortion.png", scene);
|
| 5 |
+
fire.opacityTexture = new BABYLON.Texture("/playground/textures/fire/opacity.png", scene);
|
| 6 |
+
|
| 7 |
+
registerRangeUI("fire", "speed", 0, 20, function(value) {
|
| 8 |
+
fire.speed = value;
|
| 9 |
+
}, function() {
|
| 10 |
+
return fire.speed;
|
| 11 |
+
});
|
| 12 |
+
|
| 13 |
+
return fire;
|
| 14 |
+
};
|
pool/shard004/JavaScript/0026544_reset-password.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var keystone = require('keystone'),
|
| 2 |
+
User = keystone.list('User');
|
| 3 |
+
|
| 4 |
+
exports = module.exports = function(req, res) {
|
| 5 |
+
|
| 6 |
+
var view = new keystone.View(req, res),
|
| 7 |
+
locals = res.locals;
|
| 8 |
+
|
| 9 |
+
view.on('init', function(next) {
|
| 10 |
+
|
| 11 |
+
console.log(req.params.key);
|
| 12 |
+
|
| 13 |
+
User.model.findOne().where('resetPasswordKey', req.params.key).exec(function(err, user) {
|
| 14 |
+
if (err) return next(err);
|
| 15 |
+
if (!user) {
|
| 16 |
+
req.flash('error', "Sorry, that reset password key isn't valid.");
|
| 17 |
+
return res.redirect('/forgot-password');
|
| 18 |
+
}
|
| 19 |
+
locals.found = user;
|
| 20 |
+
next();
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
});
|
| 24 |
+
|
| 25 |
+
view.on('post', { action: 'reset-password' }, function(next) {
|
| 26 |
+
|
| 27 |
+
if (req.body.password != req.body.password_confirm) {
|
| 28 |
+
req.flash('error', 'Please make sure both passwords match.');
|
| 29 |
+
return next();
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
locals.found.password = req.body.password;
|
| 33 |
+
locals.found.resetPasswordKey = '';
|
| 34 |
+
locals.found.save(function(err) {
|
| 35 |
+
if (err) return next(err);
|
| 36 |
+
req.flash('success', 'We changed your password, please sign in.');
|
| 37 |
+
res.redirect('/signin');
|
| 38 |
+
});
|
| 39 |
+
|
| 40 |
+
});
|
| 41 |
+
|
| 42 |
+
view.render('reset-password');
|
| 43 |
+
|
| 44 |
+
}
|
pool/shard004/JavaScript/0026545_generator.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
import path from "path";
|
| 4 |
+
import uniq from "lodash/uniq";
|
| 5 |
+
|
| 6 |
+
import SiteGenerator from "./generator/index.jsx";
|
| 7 |
+
import locales from "./src/localization";
|
| 8 |
+
|
| 9 |
+
class Generator extends SiteGenerator {
|
| 10 |
+
onProcessPath(filePath) {
|
| 11 |
+
if (filePath === "/:lang/entry/:name") {
|
| 12 |
+
const allEntries = ["test"];
|
| 13 |
+
return allEntries.map((name)=> filePath.replace(":name", name));
|
| 14 |
+
} else {
|
| 15 |
+
return super.onProcessPath(filePath);
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
matchUrl(url, locale) {
|
| 19 |
+
/* eslint class-methods-use-this: 0 */
|
| 20 |
+
return url.replace(":lang", locale);
|
| 21 |
+
}
|
| 22 |
+
writeFile(url, html, origUrl) {
|
| 23 |
+
/* eslint prefer-template: 0 */
|
| 24 |
+
const filePath = origUrl === "/:lang" ?
|
| 25 |
+
path.join(url, "index.html") :
|
| 26 |
+
`${url}.html`;
|
| 27 |
+
this.writer.writeFile(filePath, html);
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
const g = new Generator();
|
| 32 |
+
const urls = Object.keys(locales).reduce(
|
| 33 |
+
(urls, locale)=>
|
| 34 |
+
g.generate(locale, (url)=> {
|
| 35 |
+
if (url === "/404" && locale !== "en") {
|
| 36 |
+
return true;
|
| 37 |
+
}
|
| 38 |
+
}).concat(urls), []);
|
| 39 |
+
|
| 40 |
+
const sitemapUrls = uniq(urls).filter((p)=> p !== "/");
|
| 41 |
+
|
| 42 |
+
g.generateSitemap(sitemapUrls, "http://example.com");
|
pool/shard004/JavaScript/0026548_NodeAttachmentMap.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function(window)
|
| 2 |
+
{
|
| 3 |
+
var Gitana = window.Gitana;
|
| 4 |
+
|
| 5 |
+
Gitana.NodeAttachmentMap = Gitana.BinaryAttachmentMap.extend(
|
| 6 |
+
/** @lends Gitana.NodeAttachmentMap.prototype */
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* @constructs
|
| 10 |
+
* @augments Gitana.BinaryAttachmentMap
|
| 11 |
+
*
|
| 12 |
+
* @class Provides access to node attachments
|
| 13 |
+
*
|
| 14 |
+
* @param repository
|
| 15 |
+
* @param map
|
| 16 |
+
*/
|
| 17 |
+
constructor: function(persistable, object)
|
| 18 |
+
{
|
| 19 |
+
this.base(persistable, object);
|
| 20 |
+
|
| 21 |
+
this.objectType = function() { return "Gitana.NodeAttachmentMap"; };
|
| 22 |
+
},
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* @override
|
| 26 |
+
*/
|
| 27 |
+
clone: function()
|
| 28 |
+
{
|
| 29 |
+
return new Gitana.NodeAttachmentMap(this.__persistable(), this);
|
| 30 |
+
},
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* @param json
|
| 34 |
+
*/
|
| 35 |
+
buildObject: function(attachment)
|
| 36 |
+
{
|
| 37 |
+
return new Gitana.NodeAttachment(this.__persistable(), attachment);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
});
|
| 42 |
+
|
| 43 |
+
})(window);
|
pool/shard004/JavaScript/0026550_aroon.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
module.exports = function(indicatorMixin, accessor_ohlc) { // Injected dependencies
|
| 4 |
+
return function() { // Closure function
|
| 5 |
+
var p = {}, // Container for private, direct access mixed in variables
|
| 6 |
+
period = 20,
|
| 7 |
+
overbought = 70,
|
| 8 |
+
middle = 0,
|
| 9 |
+
oversold = 30;
|
| 10 |
+
|
| 11 |
+
function indicator(data) {
|
| 12 |
+
return data.map(function(d, i) {
|
| 13 |
+
if(i >= (period-1)){
|
| 14 |
+
var max = 0;
|
| 15 |
+
var maxi = 0;
|
| 16 |
+
var min = 10000;
|
| 17 |
+
var mini = 0;
|
| 18 |
+
for (var j = 0; j < period; j++) {
|
| 19 |
+
if( p.accessor.h(data[i-j]) > max){
|
| 20 |
+
max = p.accessor.h(data[i-j]);
|
| 21 |
+
maxi = j;
|
| 22 |
+
}
|
| 23 |
+
if( p.accessor.l(data[i-j]) < min){
|
| 24 |
+
min = p.accessor.l(data[i-j]);
|
| 25 |
+
mini = j;
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
var up = ((period-maxi)/period)*100;
|
| 29 |
+
var down = ((period-mini)/period)*100;
|
| 30 |
+
var oscillator = up - down;
|
| 31 |
+
return datum(p.accessor.d(d), up,down, oscillator, middle, overbought, oversold);
|
| 32 |
+
}
|
| 33 |
+
else return datum(p.accessor.d(d));
|
| 34 |
+
}).filter(function(d) { return d.up; });
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
indicator.period = function(_) {
|
| 38 |
+
if (!arguments.length) return period;
|
| 39 |
+
period = _;
|
| 40 |
+
return indicator;
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
indicator.overbought = function(_) {
|
| 44 |
+
if (!arguments.length) return overbought;
|
| 45 |
+
overbought = _;
|
| 46 |
+
return indicator;
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
indicator.middle = function(_) {
|
| 50 |
+
if (!arguments.length) return middle;
|
| 51 |
+
middle = _;
|
| 52 |
+
return indicator;
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
indicator.oversold = function(_) {
|
| 56 |
+
if (!arguments.length) return oversold;
|
| 57 |
+
oversold = _;
|
| 58 |
+
return indicator;
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
// Mixin 'superclass' methods and variables
|
| 62 |
+
indicatorMixin(indicator, p).accessor(accessor_ohlc());
|
| 63 |
+
|
| 64 |
+
return indicator;
|
| 65 |
+
};
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
function datum(date, up,down,oscillator, middle, overbought, oversold) {
|
| 69 |
+
if(up) return { date: date, up: up,down:down,oscillator:oscillator, middle: middle, overbought: overbought, oversold: oversold };
|
| 70 |
+
else return { date: date, up: null,down:null,oscillator:null, middle: null, overbought: null, oversold: null };
|
| 71 |
+
}
|
pool/shard004/JavaScript/0026552_lodashModule.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var _ = require('lodash');
|
| 2 |
+
var lodashtemplate = require('html!./lodashdemo.html');
|
| 3 |
+
var lodashModule = module.exports = function(){
|
| 4 |
+
this.init();
|
| 5 |
+
};
|
| 6 |
+
|
| 7 |
+
var p = lodashModule.prototype;
|
| 8 |
+
|
| 9 |
+
p.init=function(){
|
| 10 |
+
console.log('goto render');
|
| 11 |
+
this.render();
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
p.render = function(){
|
| 15 |
+
if(_.isFunction(this.beforeRender)) this.beforeRender();
|
| 16 |
+
if(_.isFunction(this.afterRender)) this.afterRender();
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
p.beforeRender=function(){
|
| 20 |
+
console.log('goto templateRender');
|
| 21 |
+
this.templateRender();
|
| 22 |
+
};
|
| 23 |
+
p.templateRender = function(){
|
| 24 |
+
var compiled = _.template(lodashtemplate);
|
| 25 |
+
//$('div').append(compiled({
|
| 26 |
+
// test:111
|
| 27 |
+
//}));
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
p.afterRender=function(){
|
| 31 |
+
console.log('render end');
|
| 32 |
+
};
|
pool/shard004/JavaScript/0026555_routes.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var api = require('./controllers/api'),
|
| 4 |
+
index = require('./controllers');
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Application routes
|
| 8 |
+
*/
|
| 9 |
+
module.exports = function (app) {
|
| 10 |
+
|
| 11 |
+
// Server API Routes
|
| 12 |
+
app.route('/api/tech')
|
| 13 |
+
.get(api.technologies);
|
| 14 |
+
|
| 15 |
+
app.route('/api/developers')
|
| 16 |
+
.get(api.developers);
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
// All undefined api routes should return a 404
|
| 20 |
+
app.route('/api/*')
|
| 21 |
+
.get(function (req, res) {
|
| 22 |
+
res.send(404);
|
| 23 |
+
});
|
| 24 |
+
|
| 25 |
+
// All other routes to use Angular routing in app/scripts/app.js
|
| 26 |
+
app.route('/partials/*')
|
| 27 |
+
.get(index.partials);
|
| 28 |
+
app.route('/*')
|
| 29 |
+
.get(index.index);
|
| 30 |
+
};
|
pool/shard004/JavaScript/0026556_chkInternalIP.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Meteor.methods({
|
| 2 |
+
chkInternalIP(username) {
|
| 3 |
+
var access = RocketChat.settings.get('allowexternal');
|
| 4 |
+
var departmentsToAssign = access.split(/\s*,\s*/);
|
| 5 |
+
var IsAllAccess = departmentsToAssign.indexOf('*') > -1;
|
| 6 |
+
var IsUserAccess = departmentsToAssign.indexOf(username) > -1;
|
| 7 |
+
if (IsAllAccess || IsUserAccess) {
|
| 8 |
+
console.log('default access');
|
| 9 |
+
return true;
|
| 10 |
+
} else
|
| 11 |
+
console.log(username + ' - ' + this.connection.httpHeaders['x-forwarded-for']);
|
| 12 |
+
var Iplist = this.connection.httpHeaders['x-forwarded-for'].split(",");
|
| 13 |
+
var Ip = Iplist[0];
|
| 14 |
+
var url = RocketChat.settings.get('COMMAPI') + "/ChatService.svc/IsInternalIP/" + Ip;
|
| 15 |
+
return HTTP.call("GET", url, { headers: { "accept": "application/json" } }).data;
|
| 16 |
+
}
|
| 17 |
+
});
|
pool/shard004/JavaScript/0026558_photo.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Generated by CoffeeScript 1.9.3
|
| 2 |
+
var Photo, app, doPipe, downloader;
|
| 3 |
+
|
| 4 |
+
Photo = require('../models/photo');
|
| 5 |
+
|
| 6 |
+
downloader = require('../helpers/downloader');
|
| 7 |
+
|
| 8 |
+
app = null;
|
| 9 |
+
|
| 10 |
+
module.exports.setApp = function(ref) {
|
| 11 |
+
return app = ref;
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
module.exports.fetch = function(req, res, next, id) {
|
| 15 |
+
if (id.indexOf('.jpg') > 0) {
|
| 16 |
+
id = id.substring(0, id.length - 4);
|
| 17 |
+
}
|
| 18 |
+
return Photo.find(id, (function(_this) {
|
| 19 |
+
return function(err, photo) {
|
| 20 |
+
if (err) {
|
| 21 |
+
return next(err);
|
| 22 |
+
} else if (!photo) {
|
| 23 |
+
return next(NotFound("Photo " + id));
|
| 24 |
+
} else {
|
| 25 |
+
req.photo = photo;
|
| 26 |
+
return next();
|
| 27 |
+
}
|
| 28 |
+
};
|
| 29 |
+
})(this));
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
doPipe = function(req, which, download, res, next) {
|
| 33 |
+
var binaryPath, disposition, onError, ref1, ref2, request;
|
| 34 |
+
if (download) {
|
| 35 |
+
disposition = 'attachment; filename=' + req.photo.title;
|
| 36 |
+
res.setHeader('Content-disposition', disposition);
|
| 37 |
+
}
|
| 38 |
+
onError = function(err) {
|
| 39 |
+
if (err) {
|
| 40 |
+
return next(err);
|
| 41 |
+
}
|
| 42 |
+
};
|
| 43 |
+
if ((ref1 = req.photo._attachments) != null ? ref1[which] : void 0) {
|
| 44 |
+
binaryPath = "/data/" + req.photo.id + "/attachments/" + which;
|
| 45 |
+
return request = downloader.download(binaryPath, function(stream) {
|
| 46 |
+
if (stream.statusCode === 200) {
|
| 47 |
+
res.on('close', function() {
|
| 48 |
+
return request.abort();
|
| 49 |
+
});
|
| 50 |
+
return stream.pipe(res);
|
| 51 |
+
} else {
|
| 52 |
+
return res.sendfile('./server/img/error.gif');
|
| 53 |
+
}
|
| 54 |
+
});
|
| 55 |
+
} else if ((ref2 = req.photo.binary) != null ? ref2[which] : void 0) {
|
| 56 |
+
binaryPath = "/data/" + req.photo.id + "/binaries/" + which;
|
| 57 |
+
return request = downloader.download(binaryPath, function(stream) {
|
| 58 |
+
if (stream.statusCode === 200) {
|
| 59 |
+
res.on('close', function() {
|
| 60 |
+
return request.abort();
|
| 61 |
+
});
|
| 62 |
+
return stream.pipe(res);
|
| 63 |
+
} else {
|
| 64 |
+
return res.sendfile('./server/img/error.gif');
|
| 65 |
+
}
|
| 66 |
+
});
|
| 67 |
+
} else {
|
| 68 |
+
return res.sendfile('./server/img/error.gif');
|
| 69 |
+
}
|
| 70 |
+
};
|
| 71 |
+
|
| 72 |
+
module.exports.thumb = function(req, res, next) {
|
| 73 |
+
return doPipe(req, 'thumb', false, res, next);
|
| 74 |
+
};
|
| 75 |
+
|
| 76 |
+
module.exports.raw = function(req, res, next) {
|
| 77 |
+
var ref1, ref2, ref3, which;
|
| 78 |
+
which = ((ref1 = req.photo._attachments) != null ? ref1.raw : void 0) ? 'raw' : ((ref2 = req.photo.binary) != null ? ref2.raw : void 0) ? 'raw' : ((ref3 = req.photo.binary) != null ? ref3.file : void 0) ? 'file' : 'file';
|
| 79 |
+
return doPipe(req, which, true, res, next);
|
| 80 |
+
};
|
pool/shard004/JavaScript/0026560_load-map.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
| 3 |
+
*
|
| 4 |
+
* WSO2 Inc. licenses this file to you under the Apache License,
|
| 5 |
+
* Version 2.0 (the "License"); you may not use this file except
|
| 6 |
+
* in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing,
|
| 12 |
+
* software distributed under the License is distributed on an
|
| 13 |
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
| 14 |
+
* either express or implied. See the License for the
|
| 15 |
+
* specific language governing permissions and limitations
|
| 16 |
+
* under the License.
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
var map;
|
| 20 |
+
|
| 21 |
+
function loadLeafletMap() {
|
| 22 |
+
|
| 23 |
+
var deviceLocationID = "#device-location",
|
| 24 |
+
locations = $(deviceLocationID).data("locations"),
|
| 25 |
+
location_lat = $(deviceLocationID).data("lat"),
|
| 26 |
+
location_long = $(deviceLocationID).data("long"),
|
| 27 |
+
container = "device-location",
|
| 28 |
+
zoomLevel = 13,
|
| 29 |
+
tileSet = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
| 30 |
+
attribution = "© <a href='https://openstreetmap.org/copyright'>OpenStreetMap</a> contributors";
|
| 31 |
+
|
| 32 |
+
if (location_long && location_lat) {
|
| 33 |
+
|
| 34 |
+
map = L.map(container).setView([location_lat, location_long], zoomLevel);
|
| 35 |
+
L.tileLayer(tileSet, {attribution: attribution}).addTo(map);
|
| 36 |
+
|
| 37 |
+
var m = L.marker([location_lat, location_long], {"opacity": 0.70}).addTo(map).bindPopup("Your device is here");
|
| 38 |
+
m.on('mouseover', function (e) {
|
| 39 |
+
this.openPopup();
|
| 40 |
+
});
|
| 41 |
+
m.on('mouseout', function (e) {
|
| 42 |
+
this.closePopup();
|
| 43 |
+
});
|
| 44 |
+
$("#map-error").hide();
|
| 45 |
+
$("#device-location").show();
|
| 46 |
+
setTimeout(function(){ map.invalidateSize()}, 400);
|
| 47 |
+
} else {
|
| 48 |
+
$("#device-location").hide();
|
| 49 |
+
$("#map-error").show();
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
$(".media.tab-responsive [data-toggle=tab]").on("shown.bs.tab", function (e) {
|
| 54 |
+
var activeTabPane = $(e.target).attr("href");
|
| 55 |
+
var activeListGroupItem = $(".media .list-group-item.active");
|
| 56 |
+
|
| 57 |
+
$(activeTabPane).removeClass("visible-xs-block");
|
| 58 |
+
$(activeTabPane).siblings().not(".arrow-left").addClass("visible-xs-block");
|
| 59 |
+
positionArrow(activeListGroupItem);
|
| 60 |
+
});
|
| 61 |
+
|
| 62 |
+
$(".media.tab-responsive .tab-content").on("shown.bs.collapse", function (e) {
|
| 63 |
+
var thisParent = $(e.target).parent();
|
| 64 |
+
var activeTabPaneCaret = thisParent.find('.caret-updown');
|
| 65 |
+
var activeTabPaneCaretSiblings = thisParent.siblings().find('.caret-updown');
|
| 66 |
+
|
| 67 |
+
activeTabPaneCaret.removeClass("fw-up").addClass("fw-down");
|
| 68 |
+
activeTabPaneCaretSiblings.removeClass("fw-down").addClass("fw-up");
|
| 69 |
+
});
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
$('.media.tab-responsive a[data-toggle="collapse"]').on('click',function(){
|
| 73 |
+
var clickedPanel = $(this).attr('href');
|
| 74 |
+
|
| 75 |
+
if($(clickedPanel).hasClass('in')){
|
| 76 |
+
$(clickedPanel).collapse('hide');
|
| 77 |
+
}else{
|
| 78 |
+
$(clickedPanel).collapse('show');
|
| 79 |
+
}
|
| 80 |
+
});
|
| 81 |
+
|
| 82 |
+
$(document).ready(function () {
|
| 83 |
+
$(".location_tab").on("click", function () {
|
| 84 |
+
console.log('here');
|
| 85 |
+
loadLeafletMap();
|
| 86 |
+
});
|
| 87 |
+
});
|
pool/shard004/JavaScript/0026561_ng.directive_ngInclude.jqlite_test.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
describe("api/ng.directive:ngInclude", function() {
|
| 2 |
+
beforeEach(function() {
|
| 3 |
+
browser.get("index-nocache.html#!/api/ng.directive:ngInclude");
|
| 4 |
+
});
|
| 5 |
+
|
| 6 |
+
var templateSelect = element(by.model('template'));
|
| 7 |
+
var includeElem = element(by.css('.doc-example-live [ng-include]'));
|
| 8 |
+
|
| 9 |
+
it('should load template1.html', function() {
|
| 10 |
+
expect(includeElem.getText()).toMatch(/Content of template1.html/);
|
| 11 |
+
});
|
| 12 |
+
|
| 13 |
+
it('should load template2.html', function() {
|
| 14 |
+
if (browser.params.browser == 'firefox') {
|
| 15 |
+
// Firefox can't handle using selects
|
| 16 |
+
// See https://github.com/angular/protractor/issues/480
|
| 17 |
+
return;
|
| 18 |
+
}
|
| 19 |
+
templateSelect.click();
|
| 20 |
+
templateSelect.element.all(by.css('option')).get(2).click();
|
| 21 |
+
expect(includeElem.getText()).toMatch(/Content of template2.html/);
|
| 22 |
+
});
|
| 23 |
+
|
| 24 |
+
it('should change to blank', function() {
|
| 25 |
+
if (browser.params.browser == 'firefox') {
|
| 26 |
+
// Firefox can't handle using selects
|
| 27 |
+
return;
|
| 28 |
+
}
|
| 29 |
+
templateSelect.click();
|
| 30 |
+
templateSelect.element.all(by.css('option')).get(0).click();
|
| 31 |
+
expect(includeElem.isPresent()).toBe(false);
|
| 32 |
+
});
|
| 33 |
+
|
| 34 |
+
});
|
pool/shard004/JavaScript/0026567_session.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function() {
|
| 2 |
+
'use strict';
|
| 3 |
+
|
| 4 |
+
function session($state, $timeout, auth, fbutil) {
|
| 5 |
+
var sessionData = {};
|
| 6 |
+
|
| 7 |
+
init();
|
| 8 |
+
return sessionData;
|
| 9 |
+
|
| 10 |
+
function init(){
|
| 11 |
+
auth.$onAuth(onAuth);
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
function onAuth(authObj){
|
| 15 |
+
if(authObj){
|
| 16 |
+
var profilePath = ['profiles', authObj.uid];
|
| 17 |
+
var prefPath = ['preferences', authObj.uid];
|
| 18 |
+
var channelPath = ['preferences', authObj.uid, 'channels'];
|
| 19 |
+
|
| 20 |
+
sessionData.user = fbutil.syncObject(profilePath);
|
| 21 |
+
sessionData.prefs = fbutil.syncObject(prefPath);
|
| 22 |
+
sessionData.channels = fbutil.syncArray(channelPath);
|
| 23 |
+
|
| 24 |
+
var channelRef = fbutil.ref(channelPath);
|
| 25 |
+
|
| 26 |
+
channelRef.once('value', function onDataInit(){
|
| 27 |
+
channelRef.initialized = true;
|
| 28 |
+
});
|
| 29 |
+
|
| 30 |
+
channelRef.on('child_removed', function onChannelLeave(snapshot){
|
| 31 |
+
if(channelRef.initialized !== true){
|
| 32 |
+
return;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
$state.transitionTo('root.home.channel', {channel: 'general'});
|
| 36 |
+
});
|
| 37 |
+
|
| 38 |
+
sessionData.uid = authObj.uid;
|
| 39 |
+
} else {
|
| 40 |
+
try {
|
| 41 |
+
sessionData.user.$destroy();
|
| 42 |
+
} catch(e){}
|
| 43 |
+
sessionData.user = null;
|
| 44 |
+
$state.transitionTo('login');
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
angular.module('common.firebase')
|
| 50 |
+
.factory('session', session);
|
| 51 |
+
})();
|
pool/shard004/JavaScript/0026568_DesignerNav.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Created by dllo on 17/8/29.
|
| 3 |
+
*/
|
| 4 |
+
import React, {Component} from 'react'
|
| 5 |
+
import '../../assets/styles/miss/Miss.styl'
|
| 6 |
+
const logoArr = ['子类:', '网页设计App', '设计移动网页/H5 页面设计', '活动页面设计', 'icon设计', 'banner 设计', '其它 UI 设计']
|
| 7 |
+
class DesignerNav extends Component {
|
| 8 |
+
constructor(props) {
|
| 9 |
+
super(props)
|
| 10 |
+
this.state = {
|
| 11 |
+
array: []
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
clickLogo = () => {
|
| 15 |
+
console.log(123)
|
| 16 |
+
var navChild = document.getElementsByClassName('wxj_nav1')[0]
|
| 17 |
+
navChild.innerHTML = ''
|
| 18 |
+
for (let i = 0; i < logoArr.length; i++) {
|
| 19 |
+
var aBiaoQian = document.createElement('a')
|
| 20 |
+
navChild.appendChild(aBiaoQian)
|
| 21 |
+
var liBiaoQian = document.createElement('li')
|
| 22 |
+
liBiaoQian.innerHTML = logoArr[i]
|
| 23 |
+
aBiaoQian.appendChild(liBiaoQian)
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
render () {
|
| 27 |
+
return (
|
| 28 |
+
<div style={{backgroundColor: 'grey'}}>
|
| 29 |
+
<div className='wxj_nav_all_HOVER'>
|
| 30 |
+
<ul className='wxj_nav_HOVER'>
|
| 31 |
+
<a style={{width: '46px', height: '19px'}}><li>分类:</li></a>
|
| 32 |
+
<a style={{width: '28px', height: '19px'}}><li>全部</li></a>
|
| 33 |
+
<a style={{width: '76px', height: '19px'}}><li onClick={this.clickLogo} className='kang'>LOGO/品牌</li></a>
|
| 34 |
+
<a style={{width: '56px', height: '19px'}}><li>平面设计</li></a>
|
| 35 |
+
<a style={{width: '75px', height: '19px'}}><li>UI设计</li></a>
|
| 36 |
+
<a style={{width: '63px', height: '19px'}}><li>绘画/插画</li></a>
|
| 37 |
+
<a style={{width: '91px', height: '19px'}}><li>工业/产品设计</li></a>
|
| 38 |
+
<a style={{width: '68px', height: '19px'}}><li>影视/动画</li></a>
|
| 39 |
+
<a style={{width: '56px', height: '19px'}}><li>服装设计</li></a>
|
| 40 |
+
<a style={{width: '56px', height: '19px'}}><li>室内设计</li></a>
|
| 41 |
+
<a style={{width: '56px', height: '19px'}}><li>造型设计</li></a>
|
| 42 |
+
<a style={{width: '56px', height: '19px'}}><li>私家定制</li></a>
|
| 43 |
+
<a style={{width: '28px', height: '19px'}}><li>其他</li></a>
|
| 44 |
+
</ul>
|
| 45 |
+
<ul className='wxj_nav1'>
|
| 46 |
+
<a style={{width: '56px', height: '19px'}}><li>子类:</li></a>
|
| 47 |
+
<a style={{width: '56px', height: '19px'}}><li>插画设计</li></a>
|
| 48 |
+
<a style={{width: '56px', height: '19px'}}><li>原画设计</li></a>
|
| 49 |
+
<a style={{width: '56px', height: '19px'}}><li>漫画设计</li></a>
|
| 50 |
+
<a style={{width: '80px', height: '19px'}}><li>形象/吉祥物</li></a>
|
| 51 |
+
<a style={{width: '84px', height: '19px'}}><li>其他插画艺术</li></a>
|
| 52 |
+
</ul>
|
| 53 |
+
</div>
|
| 54 |
+
</div>
|
| 55 |
+
)
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
export default DesignerNav
|
pool/shard004/JavaScript/0026569_list_pool.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2012. The Genome Analysis Centre, Norwich, UK
|
| 3 |
+
* MISO project contacts: Robert Davey @ TGAC
|
| 4 |
+
* *********************************************************************
|
| 5 |
+
*
|
| 6 |
+
* This file is part of MISO.
|
| 7 |
+
*
|
| 8 |
+
* MISO is free software: you can redistribute it and/or modify
|
| 9 |
+
* it under the terms of the GNU General Public License as published by
|
| 10 |
+
* the Free Software Foundation, either version 3 of the License, or
|
| 11 |
+
* (at your option) any later version.
|
| 12 |
+
*
|
| 13 |
+
* MISO 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 General Public License for more details.
|
| 17 |
+
*
|
| 18 |
+
* You should have received a copy of the GNU General Public License
|
| 19 |
+
* along with MISO. If not, see <http://www.gnu.org/licenses/>.
|
| 20 |
+
*
|
| 21 |
+
* *********************************************************************
|
| 22 |
+
*/
|
| 23 |
+
|
| 24 |
+
ListTarget.pool = {
|
| 25 |
+
name: "Pools",
|
| 26 |
+
getUserManualUrl: function() {
|
| 27 |
+
return Urls.external.userManual('pools');
|
| 28 |
+
},
|
| 29 |
+
createUrl: function(config, projectId) {
|
| 30 |
+
if (projectId) {
|
| 31 |
+
return Urls.rest.pools.projectDatatable(projectId);
|
| 32 |
+
} else {
|
| 33 |
+
return Urls.rest.pools.platformDatatable(config.platformType);
|
| 34 |
+
}
|
| 35 |
+
},
|
| 36 |
+
getQueryUrl: function() {
|
| 37 |
+
return Urls.rest.pools.query;
|
| 38 |
+
},
|
| 39 |
+
createBulkActions: function(config, projectId) {
|
| 40 |
+
var actions = HotTarget.pool.getBulkActions(config);
|
| 41 |
+
actions.push({
|
| 42 |
+
name: "Delete",
|
| 43 |
+
action: function(items) {
|
| 44 |
+
var lines = ['Are you sure you wish to delete the following pools? This cannot be undone.',
|
| 45 |
+
'Any associated orders will also be deleted.', 'Note: a pool may only be deleted by its creator or an admin.'];
|
| 46 |
+
var ids = [];
|
| 47 |
+
jQuery.each(items, function(index, pool) {
|
| 48 |
+
lines.push('* ' + pool.name + ' (' + pool.alias + ')');
|
| 49 |
+
ids.push(pool.id);
|
| 50 |
+
});
|
| 51 |
+
Utils.showConfirmDialog('Delete Pools', 'Delete', lines, function() {
|
| 52 |
+
Utils.ajaxWithDialog('Deleting Pools', 'POST', Urls.rest.pools.bulkDelete, ids, function() {
|
| 53 |
+
Utils.page.pageReload();
|
| 54 |
+
});
|
| 55 |
+
});
|
| 56 |
+
}
|
| 57 |
+
});
|
| 58 |
+
actions.push({
|
| 59 |
+
name: "Merge",
|
| 60 |
+
action: function(pools) {
|
| 61 |
+
var fields = pools.map(function(pool) {
|
| 62 |
+
return {
|
| 63 |
+
type: 'int',
|
| 64 |
+
label: pool.alias + " (" + pool.name + ")",
|
| 65 |
+
value: 1,
|
| 66 |
+
property: 'pool' + pool.id,
|
| 67 |
+
required: true
|
| 68 |
+
};
|
| 69 |
+
});
|
| 70 |
+
|
| 71 |
+
HotUtils.showDialogForBoxCreation("Merge Proportions", "Merge", fields, Urls.ui.pools.bulkMerge, function(output) {
|
| 72 |
+
var ids = pools.map(Utils.array.getId);
|
| 73 |
+
var proportions = ids.map(function(id) {
|
| 74 |
+
return output['pool' + id];
|
| 75 |
+
});
|
| 76 |
+
return {
|
| 77 |
+
ids: ids.join(','),
|
| 78 |
+
proportions: proportions.join(',')
|
| 79 |
+
};
|
| 80 |
+
}, function(result) {
|
| 81 |
+
return 1;
|
| 82 |
+
});
|
| 83 |
+
}
|
| 84 |
+
});
|
| 85 |
+
return actions;
|
| 86 |
+
},
|
| 87 |
+
createStaticActions: function(config, prodjectId) {
|
| 88 |
+
return [{
|
| 89 |
+
name: "Add",
|
| 90 |
+
handler: function() {
|
| 91 |
+
window.location = Urls.ui.pools.create;
|
| 92 |
+
}
|
| 93 |
+
}];
|
| 94 |
+
},
|
| 95 |
+
createColumns: function(config, projectId) {
|
| 96 |
+
return [{
|
| 97 |
+
"sTitle": "ID",
|
| 98 |
+
"mData": "id",
|
| 99 |
+
"bVisible": false
|
| 100 |
+
}, {
|
| 101 |
+
"sTitle": "Name",
|
| 102 |
+
"mData": "name",
|
| 103 |
+
"include": true,
|
| 104 |
+
"iSortPriority": 1,
|
| 105 |
+
"iDataSort": 0, // Use ID for sorting
|
| 106 |
+
"mRender": Warning.tableWarningRenderer(WarningTarget.pool, function(pool) {
|
| 107 |
+
return Urls.ui.pools.edit(pool.id);
|
| 108 |
+
}),
|
| 109 |
+
"sClass": "nowrap"
|
| 110 |
+
}, ListUtils.labelHyperlinkColumn("Alias", Urls.ui.pools.edit, Utils.array.getId, "alias", 0, true), {
|
| 111 |
+
"sTitle": "Description",
|
| 112 |
+
"mData": "description",
|
| 113 |
+
"include": true,
|
| 114 |
+
"iSortPriority": 0,
|
| 115 |
+
"bSortable": false
|
| 116 |
+
}, {
|
| 117 |
+
"sTitle": "Date Created",
|
| 118 |
+
"mData": "creationDate",
|
| 119 |
+
"include": true,
|
| 120 |
+
"iSortPriority": 0
|
| 121 |
+
}, {
|
| 122 |
+
"sTitle": "Library Aliquots",
|
| 123 |
+
"mData": "libraryAliquotCount",
|
| 124 |
+
"include": true,
|
| 125 |
+
"iSortPriority": 0,
|
| 126 |
+
"bSortable": false,
|
| 127 |
+
}, {
|
| 128 |
+
"sTitle": "Concentration",
|
| 129 |
+
"mData": "concentration",
|
| 130 |
+
"include": true,
|
| 131 |
+
"iSortPriority": 0,
|
| 132 |
+
"mRender": function(data, type, full) {
|
| 133 |
+
if (type === 'display' && !!data) {
|
| 134 |
+
var units = Constants.concentrationUnits.find(function(unit) {
|
| 135 |
+
return unit.name == full.concentrationUnits;
|
| 136 |
+
});
|
| 137 |
+
if (!!units) {
|
| 138 |
+
return data + ' ' + units.units;
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
return data;
|
| 142 |
+
}
|
| 143 |
+
}, {
|
| 144 |
+
"sTitle": "Location",
|
| 145 |
+
"mData": "locationLabel",
|
| 146 |
+
"bSortable": false,
|
| 147 |
+
"mRender": function(data, type, full) {
|
| 148 |
+
return full.box ? "<a href='" + Urls.ui.boxes.edit(full.box.id) + "'>" + data + "</a>" : data;
|
| 149 |
+
},
|
| 150 |
+
"include": true,
|
| 151 |
+
"iSortPriority": 0
|
| 152 |
+
}, {
|
| 153 |
+
"sTitle": "Average Insert Size",
|
| 154 |
+
"mData": "insertSize",
|
| 155 |
+
"bSortable": false,
|
| 156 |
+
"mRender": function(data, type, full) {
|
| 157 |
+
return data ? Math.round(data) : "N/A";
|
| 158 |
+
},
|
| 159 |
+
"include": true,
|
| 160 |
+
"iSortPriority": 0
|
| 161 |
+
}, {
|
| 162 |
+
"sTitle": "Last Modified",
|
| 163 |
+
"mData": "lastModified",
|
| 164 |
+
"include": Constants.isDetailedSample,
|
| 165 |
+
"iSortPriority": 2
|
| 166 |
+
}];
|
| 167 |
+
},
|
| 168 |
+
searchTermSelector: function(searchTerms) {
|
| 169 |
+
return [searchTerms['id'], searchTerms['created'], searchTerms['entered'], searchTerms['changed'], searchTerms['creator'],
|
| 170 |
+
searchTerms['changedby'], searchTerms['platform'], searchTerms['index_name'], searchTerms['index_seq'], searchTerms['box'],
|
| 171 |
+
searchTerms['freezer'], searchTerms['distributed'], searchTerms['distributedto']];
|
| 172 |
+
}
|
| 173 |
+
};
|
pool/shard004/JavaScript/0026572_datatables-init.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function ($) {
|
| 2 |
+
// "use strict";
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
/* Data Table
|
| 6 |
+
-------------*/
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
$('#bootstrap-data-table').DataTable({
|
| 12 |
+
lengthMenu: [[10, 20, 50, -1], [10, 20, 50, "All"]],
|
| 13 |
+
});
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
$('#bootstrap-data-table-export').DataTable({
|
| 18 |
+
dom: 'lBfrtip',
|
| 19 |
+
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
|
| 20 |
+
buttons: [
|
| 21 |
+
'copy', 'csv', 'excel', 'pdf', 'print'
|
| 22 |
+
]
|
| 23 |
+
});
|
| 24 |
+
|
| 25 |
+
$('#row-select').DataTable( {
|
| 26 |
+
initComplete: function () {
|
| 27 |
+
this.api().columns().every( function () {
|
| 28 |
+
var column = this;
|
| 29 |
+
var select = $('<select class="form-control"><option value=""></option></select>')
|
| 30 |
+
.appendTo( $(column.footer()).empty() )
|
| 31 |
+
.on( 'change', function () {
|
| 32 |
+
var val = $.fn.dataTable.util.escapeRegex(
|
| 33 |
+
$(this).val()
|
| 34 |
+
);
|
| 35 |
+
|
| 36 |
+
column
|
| 37 |
+
.search( val ? '^'+val+'$' : '', true, false )
|
| 38 |
+
.draw();
|
| 39 |
+
} );
|
| 40 |
+
|
| 41 |
+
column.data().unique().sort().each( function ( d, j ) {
|
| 42 |
+
select.append( '<option value="'+d+'">'+d+'</option>' )
|
| 43 |
+
} );
|
| 44 |
+
} );
|
| 45 |
+
}
|
| 46 |
+
} );
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
})(jQuery);
|
pool/shard004/JavaScript/0026573_assessment-test.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { run } from '@ember/runloop';
|
| 2 |
+
import { set, get } from '@ember/object';
|
| 3 |
+
import { module, test } from 'qunit';
|
| 4 |
+
import { setupTest } from 'ember-qunit';
|
| 5 |
+
|
| 6 |
+
module('Unit | Model | assessment', function(hooks) {
|
| 7 |
+
setupTest(hooks);
|
| 8 |
+
|
| 9 |
+
test('it exists', function(assert) {
|
| 10 |
+
let model = run(() => this.owner.lookup('service:store').createRecord('assessment'));
|
| 11 |
+
|
| 12 |
+
run(function() {
|
| 13 |
+
let startDate = new Date(new Date().getFullYear() - 1, 1, 1);
|
| 14 |
+
let endDate = new Date(new Date().getFullYear() - 1, 12, 31);
|
| 15 |
+
|
| 16 |
+
set(model, 'startDate', startDate);
|
| 17 |
+
set(model, 'endDate', endDate);
|
| 18 |
+
|
| 19 |
+
assert.equal(get(model, 'startDate'), startDate, 'start date set correctly');
|
| 20 |
+
assert.equal(get(model, 'endDate'), endDate, 'end date set correctly');
|
| 21 |
+
});
|
| 22 |
+
});
|
| 23 |
+
|
| 24 |
+
test('requires supporting documents', function(assert) {
|
| 25 |
+
let model = run(() => this.owner.lookup('service:store').createRecord('assessment'));
|
| 26 |
+
run(() => {
|
| 27 |
+
// not locked, has responses require proof
|
| 28 |
+
set(model, 'locked', false);
|
| 29 |
+
set(model, 'requiresProofCount', 12);
|
| 30 |
+
assert.ok(get(model, 'requiresSupportingDocumentation'), 'requires docs when unlocked');
|
| 31 |
+
|
| 32 |
+
// not locked, no responses that require proof
|
| 33 |
+
set(model, 'locked', false);
|
| 34 |
+
set(model, 'requiresProofCount', 0);
|
| 35 |
+
assert.notOk(get(model, 'requiresSupportingDocumentation'), 'does not require docs');
|
| 36 |
+
|
| 37 |
+
// not locked, responses require proof
|
| 38 |
+
set(model, 'locked', true);
|
| 39 |
+
set(model, 'requiresProofCount', 12);
|
| 40 |
+
assert.ok(get(model, 'requiresSupportingDocumentation'), 'requires docs when locked');
|
| 41 |
+
});
|
| 42 |
+
});
|
| 43 |
+
|
| 44 |
+
test('is correct document upload progress', function(assert) {
|
| 45 |
+
let model = run(() => this.owner.lookup('service:store').createRecord('assessment'));
|
| 46 |
+
|
| 47 |
+
run(function() {
|
| 48 |
+
let requiresProofCount = 20;
|
| 49 |
+
let requiresProofProgressCount = 10;
|
| 50 |
+
|
| 51 |
+
set(model, 'requiresProofCount', requiresProofCount);
|
| 52 |
+
set(model, 'requiresProofProgressCount', requiresProofProgressCount);
|
| 53 |
+
|
| 54 |
+
assert.equal(get(model, 'documentUploadProgress'), 50, 'document upload progress set correctly');
|
| 55 |
+
});
|
| 56 |
+
});
|
| 57 |
+
|
| 58 |
+
test('previous year', function(assert) {
|
| 59 |
+
let model = run(() => this.owner.lookup('service:store').createRecord('assessment', { year: 2016 }));
|
| 60 |
+
assert.equal(get(model, 'previousYear'), 2015, 'year decremented');
|
| 61 |
+
});
|
| 62 |
+
|
| 63 |
+
test('next year', function(assert) {
|
| 64 |
+
let model = run(() => this.owner.lookup('service:store').createRecord('assessment', { year: 2016 }));
|
| 65 |
+
assert.equal(get(model, 'nextYear'), 2017, 'year incremented');
|
| 66 |
+
});
|
| 67 |
+
|
| 68 |
+
test('is rated', function(assert) {
|
| 69 |
+
let model = run(() => this.owner.lookup('service:store').createRecord('assessment'));
|
| 70 |
+
run(() => {
|
| 71 |
+
assert.notOk(get(model, 'isRated'), 'no status is not rated');
|
| 72 |
+
|
| 73 |
+
set(model, 'status', 'In Progress');
|
| 74 |
+
assert.notOk(get(model, 'isRated'), 'in progress not rated');
|
| 75 |
+
|
| 76 |
+
set(model, 'status', 'Rated');
|
| 77 |
+
assert.ok(get(model, 'isRated'), 'Rated is rated');
|
| 78 |
+
|
| 79 |
+
set(model, 'status', 'RaTeD');
|
| 80 |
+
assert.ok(get(model, 'isRated'), 'case insensitive rated is rated');
|
| 81 |
+
});
|
| 82 |
+
});
|
| 83 |
+
|
| 84 |
+
test('hasQuestionsForDiscussion', function(assert) {
|
| 85 |
+
let model = run(() => this.owner.lookup('service:store').createRecord('assessment'));
|
| 86 |
+
run(() => {
|
| 87 |
+
set(model, 'requiresDiscussionCount', 0);
|
| 88 |
+
assert.notOk(get(model, 'hasQuestionsForDiscussion'), 'no questions marked for discussion');
|
| 89 |
+
|
| 90 |
+
set(model, 'requiresDiscussionCount', 1);
|
| 91 |
+
assert.ok(get(model, 'hasQuestionsForDiscussion'), 'has questions marked for discussion');
|
| 92 |
+
|
| 93 |
+
set(model, 'requiresDiscussionCount', 2);
|
| 94 |
+
assert.ok(get(model, 'hasQuestionsForDiscussion'), 'has questions marked for discussion');
|
| 95 |
+
|
| 96 |
+
set(model, 'requiresDiscussionCount', -1);
|
| 97 |
+
assert.notOk(get(model, 'hasQuestionsForDiscussion'), 'no questions marked for discussion');
|
| 98 |
+
});
|
| 99 |
+
});
|
| 100 |
+
});
|
pool/shard004/JavaScript/0026577_sigint.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var win32 = process.platform === 'win32';
|
| 2 |
+
if (win32){
|
| 3 |
+
var readline = require ('readline'),
|
| 4 |
+
rl = readline.createInterface ({
|
| 5 |
+
input: process.stdin,
|
| 6 |
+
output: process.stdout
|
| 7 |
+
});
|
| 8 |
+
|
| 9 |
+
rl.on ('SIGINT', function (){
|
| 10 |
+
process.emit ('SIGINT');
|
| 11 |
+
});
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
module.exports = {
|
| 15 |
+
enabled: win32
|
| 16 |
+
};
|
pool/shard004/JavaScript/0026582_Permissions.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import PropTypes from 'prop-types';
|
| 3 |
+
import { CAN_VOTE, getPermissionDisplay } from 'common/auth/permissions';
|
| 4 |
+
import Card from '../Card';
|
| 5 |
+
import IconText from '../IconText';
|
| 6 |
+
import css from './Permissions.css';
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
function Permissions({ canVote, permissions }) {
|
| 10 |
+
const shouldBeAbleToVote = permissions >= CAN_VOTE;
|
| 11 |
+
return (
|
| 12 |
+
<Card
|
| 13 |
+
classes={css.card}
|
| 14 |
+
title="Rettigheter"
|
| 15 |
+
corner={shouldBeAbleToVote && !canVote && <IconText iconClass={css.canNotVote} />}
|
| 16 |
+
>
|
| 17 |
+
<div>Rettighetsnivå: {getPermissionDisplay(permissions)}</div>
|
| 18 |
+
{shouldBeAbleToVote &&
|
| 19 |
+
<div>Stemmeberettiget: {canVote ?
|
| 20 |
+
'Ja' :
|
| 21 |
+
<span title="Kontakt tellekorpset for å bli stemmeberettiget.">Nei</span>
|
| 22 |
+
}
|
| 23 |
+
</div>
|
| 24 |
+
}
|
| 25 |
+
</Card>
|
| 26 |
+
);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
Permissions.defaultProps = {
|
| 30 |
+
canVote: false,
|
| 31 |
+
permissions: 0,
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
Permissions.propTypes = {
|
| 35 |
+
canVote: PropTypes.bool,
|
| 36 |
+
permissions: PropTypes.number,
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
export default Permissions;
|
pool/shard004/JavaScript/0026583_token.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var express = require('express');
|
| 2 |
+
var request = require('request');
|
| 3 |
+
var sign=require('../libs/sign');//微信提供的签名方法
|
| 4 |
+
var config=require('../libs/config.json');//配置文件
|
| 5 |
+
var router = express.Router();
|
| 6 |
+
|
| 7 |
+
/* 最简单的获取签名信息 */
|
| 8 |
+
router.get('/', function(req, res) {
|
| 9 |
+
request('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='+config.appId+'&secret='+config.appSecret, function (error, response, body) {
|
| 10 |
+
console.log('根据appId和appSecret获取accessToken ..');
|
| 11 |
+
if(error || response.statusCode != 200){
|
| 12 |
+
res.send(error);
|
| 13 |
+
return;
|
| 14 |
+
}
|
| 15 |
+
var access_token=JSON.parse(body).access_token;
|
| 16 |
+
console.log('access_token: '+access_token);
|
| 17 |
+
|
| 18 |
+
request('https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token='+access_token+'&type=jsapi', function (error, response, body) {
|
| 19 |
+
console.log('根据accessToken获取..');
|
| 20 |
+
if (error || response.statusCode != 200) {
|
| 21 |
+
res.send(error);
|
| 22 |
+
return;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
var ticket=JSON.parse(body).ticket;
|
| 26 |
+
console.log('ticket: '+ticket);
|
| 27 |
+
|
| 28 |
+
var port = req.app.settings.port;
|
| 29 |
+
var url=req.protocol + '://' + req.host + ( port == 80 || port == 443 ? '' : ':'+port ) + req.path;
|
| 30 |
+
var result=sign(ticket,url);
|
| 31 |
+
|
| 32 |
+
res.send(result);
|
| 33 |
+
});
|
| 34 |
+
});
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
var globalToken={};
|
| 38 |
+
var max_live=7200-1000;
|
| 39 |
+
|
| 40 |
+
router.get('/sign',function(req,res){
|
| 41 |
+
var now=new Date().getTime()/1000;
|
| 42 |
+
var callback=function(){
|
| 43 |
+
var url= req.param('url');
|
| 44 |
+
var result=sign(globalToken.ticket,url);
|
| 45 |
+
res.send(result);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
if (!globalToken.time || now-globalToken.time>max_live){
|
| 49 |
+
refreshGlobalToken(req,res,function(){
|
| 50 |
+
console.log('获取新的token');
|
| 51 |
+
callback();
|
| 52 |
+
})
|
| 53 |
+
}else{
|
| 54 |
+
console.log('重复使用token');
|
| 55 |
+
callback();
|
| 56 |
+
}
|
| 57 |
+
});
|
| 58 |
+
|
| 59 |
+
/* 正式的演示代码,包括服务器端生成签名,客户端通过签名使用微信API方法 */
|
| 60 |
+
router.get('/client', function(req, res) {
|
| 61 |
+
var now=new Date().getTime()/1000;
|
| 62 |
+
|
| 63 |
+
if (!globalToken.time || now-globalToken.time>max_live){
|
| 64 |
+
refreshGlobalToken(req,res,function(){
|
| 65 |
+
console.log('获取新的token');
|
| 66 |
+
renderClient(req,res);
|
| 67 |
+
})
|
| 68 |
+
}else{
|
| 69 |
+
console.log('重复使用token');
|
| 70 |
+
renderClient(req,res);
|
| 71 |
+
}
|
| 72 |
+
});
|
| 73 |
+
|
| 74 |
+
function refreshGlobalToken(req,res,callback){
|
| 75 |
+
request('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='+config.appId+'&secret='+config.appSecret, function (error, response, body) {
|
| 76 |
+
console.log('根据appId和appSecret获取accessToken ..');
|
| 77 |
+
if(error || response.statusCode != 200){
|
| 78 |
+
res.send(error);
|
| 79 |
+
return;
|
| 80 |
+
}
|
| 81 |
+
var access_token=JSON.parse(body).access_token;
|
| 82 |
+
console.log('access_token: '+access_token);
|
| 83 |
+
|
| 84 |
+
request('https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token='+access_token+'&type=jsapi', function (error, response, body) {
|
| 85 |
+
console.log('根据accessToken获取..');
|
| 86 |
+
if (error || response.statusCode != 200) {
|
| 87 |
+
res.send(error);
|
| 88 |
+
return;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
var ticket=JSON.parse(body).ticket;
|
| 92 |
+
console.log('ticket: '+ticket);
|
| 93 |
+
|
| 94 |
+
globalToken.time=new Date().getTime()/1000;
|
| 95 |
+
globalToken.ticket=ticket;
|
| 96 |
+
callback();
|
| 97 |
+
});
|
| 98 |
+
});
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
function renderClient(req,res){
|
| 102 |
+
var port = req.app.settings.port;
|
| 103 |
+
var url=req.protocol + '://' + req.host + ( port == 80 || port == 443 ? '' : ':'+port ) + req.path;
|
| 104 |
+
var result=sign(globalToken.ticket,url);
|
| 105 |
+
res.render('client',{config:config,result:result});
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
module.exports = router;
|
pool/shard004/JavaScript/0026584_HaProxyHelper.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ==UserScript==
|
| 2 |
+
// @name Haproxy Helper
|
| 3 |
+
// @namespace http://www.omnimed.com/
|
| 4 |
+
// @version 0.3
|
| 5 |
+
// @description Adds some cool functionality to Haproxy Web Management Interface
|
| 6 |
+
// @author Omnimed
|
| 7 |
+
// @match http://*/stats*
|
| 8 |
+
// @grant none
|
| 9 |
+
// @require https://code.jquery.com/jquery-2.1.4.min.js
|
| 10 |
+
// @require http://nylen.github.io/shiftcheckbox/jquery.shiftcheckbox.js
|
| 11 |
+
// ==/UserScript==
|
| 12 |
+
|
| 13 |
+
var DISABLE_REFRESH = true;
|
| 14 |
+
|
| 15 |
+
var $ = jQuery;
|
| 16 |
+
|
| 17 |
+
$(function() {
|
| 18 |
+
if (DISABLE_REFRESH && window.location.href.indexOf('norefresh') == -1) {
|
| 19 |
+
window.location.href = window.location.href + ';norefresh';
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
$(':checkbox').shiftcheckbox();
|
| 23 |
+
|
| 24 |
+
$('th.pxname').each(function() {
|
| 25 |
+
$(this).prepend('<button style="float:left" onclick="toggleSection(this);return false;">- / +</button>').attr('width', '15%');
|
| 26 |
+
});
|
| 27 |
+
});
|
| 28 |
+
|
| 29 |
+
window.toggleSection = function(thead) {
|
| 30 |
+
jQuery(thead).parents('table').next().toggle();
|
| 31 |
+
|
| 32 |
+
return false;
|
| 33 |
+
|
| 34 |
+
};
|
| 35 |
+
|
| 36 |
+
/* Display Host in DRAIN mode in yellow */
|
| 37 |
+
$("td.ac:contains(DRAIN)").parent().css( "background-color", "#FAED6C" );
|
pool/shard004/JavaScript/0026589_config.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @fileoverview Blog configuration.
|
| 3 |
+
* @author Jak Wings
|
| 4 |
+
* @license The MIT License (MIT)
|
| 5 |
+
* @preserve Copyright (c) 2013 Jak Wings
|
| 6 |
+
*/
|
| 7 |
+
'use strict';
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
define('blog.config', function () {
|
| 11 |
+
/**
|
| 12 |
+
* Configurations.
|
| 13 |
+
* 让普通用户自行修改的博客配置。
|
| 14 |
+
* @constant {Object.<string, *>}
|
| 15 |
+
*/
|
| 16 |
+
return {
|
| 17 |
+
/**
|
| 18 |
+
* Author name or your nick name.
|
| 19 |
+
* 博主名称。
|
| 20 |
+
* @type {string}
|
| 21 |
+
*/
|
| 22 |
+
author: 'Cyan',
|
| 23 |
+
/**
|
| 24 |
+
* Main title of your blog.
|
| 25 |
+
* 博客主标题。
|
| 26 |
+
* @type {string}
|
| 27 |
+
*/
|
| 28 |
+
title: 'Absolute Zero',
|
| 29 |
+
/**
|
| 30 |
+
* Subtitle of your blog.
|
| 31 |
+
* 博客副标题。
|
| 32 |
+
* @type {string}
|
| 33 |
+
*/
|
| 34 |
+
subtitle: 'Let life be beautiful like summer flowers and death like autumn leaves.',
|
| 35 |
+
/**
|
| 36 |
+
* Current timezone. Format (ABNF):
|
| 37 |
+
* ("+" / "-") 1*2DIGIT [":" 1*2DIGIT [":" 1*2DIGIT [":" 1*2DIGIT]]]
|
| 38 |
+
* 当前时区。格式可以为形如 +08 或 +08:00 或 +08:00:00 ,
|
| 39 |
+
* 分别代表相对于格林尼治标准时区的时分秒偏移量。
|
| 40 |
+
* @type {string}
|
| 41 |
+
*/
|
| 42 |
+
timezone: '+08:00',
|
| 43 |
+
/**
|
| 44 |
+
* License information.
|
| 45 |
+
* 博客文章的版权信息。
|
| 46 |
+
* @type {{text: string, url: string}}
|
| 47 |
+
*/
|
| 48 |
+
license: {
|
| 49 |
+
text: 'Creative Commons BY',
|
| 50 |
+
url: 'http://creativecommons.org/licenses/by/3.0/deed'
|
| 51 |
+
},
|
| 52 |
+
/**
|
| 53 |
+
* Bulletin on sidebar.
|
| 54 |
+
* 博客公告栏信息。
|
| 55 |
+
* @type {string}
|
| 56 |
+
*/
|
| 57 |
+
bulletin: 'Welcome!',
|
| 58 |
+
/**
|
| 59 |
+
* Links on side bar.
|
| 60 |
+
* 博客相关链接。
|
| 61 |
+
* @type {Array.<{{text: string, url: string}}>}
|
| 62 |
+
*/
|
| 63 |
+
links: [
|
| 64 |
+
{text: 'Cyanidea', url: 'http://cyanidea.com'},
|
| 65 |
+
],
|
| 66 |
+
/**
|
| 67 |
+
* Menu on sidebar.
|
| 68 |
+
* 博客菜单栏链接。
|
| 69 |
+
* @type {Array.<{{title: string, url: string, file: string=}}>}
|
| 70 |
+
*/
|
| 71 |
+
menu: [
|
| 72 |
+
{text: '首页', url: ''},
|
| 73 |
+
{text: 'Wiedersehen Wiki', url: 'wiki', file: 'archives/wiki'},
|
| 74 |
+
],
|
| 75 |
+
/**
|
| 76 |
+
* Article links
|
| 77 |
+
* 博客文章链接,由旧到新排序。为了 SEO ,改由 HTML 源代码指定。
|
| 78 |
+
* @type {Array.<{{title: string, url: string, file: string=}}>}
|
| 79 |
+
*/
|
| 80 |
+
articles: [],
|
| 81 |
+
/**
|
| 82 |
+
* Comment system Loader
|
| 83 |
+
* 评论框载入函数。
|
| 84 |
+
* @param {Object} window global object
|
| 85 |
+
* @param {Element} container container of comments
|
| 86 |
+
* @param {string} id indentifier
|
| 87 |
+
* @param {string} url full url
|
| 88 |
+
*/
|
| 89 |
+
loadComment: function (window, container, id, url) {
|
| 90 |
+
// duoshuo.com
|
| 91 |
+
var duoshuo_shortname = 'duoshuo_shortname'; //修改此处
|
| 92 |
+
// DON'T EDIT BELOW THIS LINE
|
| 93 |
+
if (!duoshuo_shortname) { return; }
|
| 94 |
+
var document = window.document;
|
| 95 |
+
if (!window.DUOSHUO) {
|
| 96 |
+
window.duoshuoQuery = {short_name: duoshuo_shortname};
|
| 97 |
+
container.className += ' ds-thread';
|
| 98 |
+
container.setAttribute('data-thread-key', id);
|
| 99 |
+
container.setAttribute('data-url', url);
|
| 100 |
+
container.setAttribute('data-title', document.title);
|
| 101 |
+
var ds = document.createElement('script');
|
| 102 |
+
ds.type = 'text/javascript';ds.async = true;
|
| 103 |
+
ds.src = 'http://static.duoshuo.com/embed.js';
|
| 104 |
+
ds.charset = 'UTF-8';
|
| 105 |
+
(document.getElementsByTagName('head')[0]
|
| 106 |
+
|| document.getElementsByTagName('body')[0]).appendChild(ds);
|
| 107 |
+
} else {
|
| 108 |
+
container.innerHTML = '';
|
| 109 |
+
var clone = document.createElement('div');
|
| 110 |
+
clone.id = 'ds-thread';
|
| 111 |
+
clone.className = 'comments hide';
|
| 112 |
+
clone.setAttribute('data-thread-key', id);
|
| 113 |
+
clone.setAttribute('data-url', url);
|
| 114 |
+
clone.setAttribute('data-title', document.title);
|
| 115 |
+
container.parentNode.replaceChild(clone, container);
|
| 116 |
+
window.DUOSHUO.EmbedThread(clone);
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
//// disqus.com
|
| 120 |
+
//window.disqus_shortname = '';
|
| 121 |
+
//// DON'T EDIT BELOW THIS LINE
|
| 122 |
+
//if (!window.disqus_shortname) { return; }
|
| 123 |
+
//var document = window.document;
|
| 124 |
+
//if (!window.DISQUS) {
|
| 125 |
+
// window.disqus_disable_mobile = false;
|
| 126 |
+
// window.disqus_identifier = id;
|
| 127 |
+
// window.disqus_url = url;
|
| 128 |
+
// window.disqus_title = document.title;
|
| 129 |
+
// container.id = 'disqus_thread';
|
| 130 |
+
// var dsq = document.createElement('script');
|
| 131 |
+
// dsq.type = 'text/javascript';
|
| 132 |
+
// dsq.async = true;
|
| 133 |
+
// dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
|
| 134 |
+
// (document.getElementsByTagName('head')[0] ||
|
| 135 |
+
// document.getElementsByTagName('body')[0]).appendChild(dsq);
|
| 136 |
+
//} else {
|
| 137 |
+
// window.DISQUS.reset({
|
| 138 |
+
// reload: true,
|
| 139 |
+
// config: function () {
|
| 140 |
+
// this.page.identifier = id;
|
| 141 |
+
// this.page.url = url;
|
| 142 |
+
// this.page.title = document.title;
|
| 143 |
+
// }
|
| 144 |
+
// });
|
| 145 |
+
//}
|
| 146 |
+
},
|
| 147 |
+
};
|
| 148 |
+
});
|
pool/shard004/JavaScript/0026593_styleswitch.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
class StyleSwitcher {
|
| 4 |
+
constructor () {
|
| 5 |
+
this.currentStylesheet = this.STYLE_DAY;
|
| 6 |
+
this.loadStyleFromCookie();
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
setActiveStyleSheet (style) {
|
| 10 |
+
const htmlClasses = document.documentElement.classList;
|
| 11 |
+
const setMethod = style === StyleSwitcher.STYLE_DAY ? htmlClasses.remove : htmlClasses.add;
|
| 12 |
+
setMethod.call(htmlClasses, StyleSwitcher.NIGHT_CLASS);
|
| 13 |
+
|
| 14 |
+
StyleSwitcher.setButtonText(style);
|
| 15 |
+
|
| 16 |
+
this.currentStylesheet = style;
|
| 17 |
+
StyleSwitcher.createCookie(this.currentStylesheet);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
static setButtonText (style) {
|
| 21 |
+
const $button = StyleSwitcher.getButton();
|
| 22 |
+
if (!$button || !$button.length) {
|
| 23 |
+
return;
|
| 24 |
+
}
|
| 25 |
+
$button.html(`${style === StyleSwitcher.STYLE_DAY ? "Night" : "Day"} Mode`);
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
getActiveStyleSheet () {
|
| 29 |
+
return this.currentStylesheet;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
loadStyleFromCookie () {
|
| 33 |
+
this.cookie = StyleSwitcher.readCookie();
|
| 34 |
+
this.cookie = this.cookie ? this.cookie : StyleSwitcher.STYLE_DAY;
|
| 35 |
+
this.setActiveStyleSheet(this.cookie);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
static getButton () {
|
| 39 |
+
if (!window.$) {
|
| 40 |
+
return;
|
| 41 |
+
}
|
| 42 |
+
return $(".nightModeToggle");
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
static createCookie (value) {
|
| 46 |
+
Cookies.set("style", value, {expires: 365});
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
static readCookie () {
|
| 50 |
+
return Cookies.get("style");
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
toggleActiveStyleSheet () {
|
| 54 |
+
const newStyle = this.currentStylesheet === StyleSwitcher.STYLE_DAY ? StyleSwitcher.STYLE_NIGHT : StyleSwitcher.STYLE_DAY;
|
| 55 |
+
this.setActiveStyleSheet(newStyle);
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
StyleSwitcher.STYLE_DAY = "day";
|
| 60 |
+
StyleSwitcher.STYLE_NIGHT = "night";
|
| 61 |
+
StyleSwitcher.NIGHT_CLASS = "night-mode";
|
| 62 |
+
|
| 63 |
+
// NIGHT MODE ==========================================================================================================
|
| 64 |
+
const styleSwitcher = new StyleSwitcher();
|
| 65 |
+
|
| 66 |
+
window.addEventListener("unload", function () {
|
| 67 |
+
const title = styleSwitcher.getActiveStyleSheet();
|
| 68 |
+
StyleSwitcher.createCookie(title);
|
| 69 |
+
});
|
pool/shard004/JavaScript/0026595_mongo_translator.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Module Dependencies
|
| 5 |
+
*/
|
| 6 |
+
var QueryTranslator = require('../query_translator');
|
| 7 |
+
var Junction = require('../expressions/junction');
|
| 8 |
+
var LikeExpression = require('../expressions/').LikeExpression;
|
| 9 |
+
var _ = require('lodash');
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Extends the Session.
|
| 13 |
+
*/
|
| 14 |
+
QueryTranslator.extend(MongoTranslator);
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Static Local Variables
|
| 18 |
+
*/
|
| 19 |
+
var OP = {
|
| 20 |
+
eq : '$eq',
|
| 21 |
+
ge : '$gte',
|
| 22 |
+
gt : '$gt',
|
| 23 |
+
le : '$lte',
|
| 24 |
+
lt : '$lt',
|
| 25 |
+
ne : '$ne',
|
| 26 |
+
LIKE : '$eq',
|
| 27 |
+
AND : '$and',
|
| 28 |
+
OR : '$or'
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Translate the criterion query to mongodb criteria query.
|
| 33 |
+
*
|
| 34 |
+
* @returns {MongoTranslator}
|
| 35 |
+
*/
|
| 36 |
+
function MongoTranslator() {
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* Return the specified op equivalent.
|
| 41 |
+
*
|
| 42 |
+
* @param {String} op
|
| 43 |
+
* @returns {Object}
|
| 44 |
+
*/
|
| 45 |
+
MongoTranslator.prototype.parseOp = function(op) {
|
| 46 |
+
return OP[op];
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Returns the query of the criterion.
|
| 51 |
+
*
|
| 52 |
+
* @param {CriteriaImpl} criteria
|
| 53 |
+
* @param {Criterion} criterion
|
| 54 |
+
* @returns {Scalar}
|
| 55 |
+
*/
|
| 56 |
+
MongoTranslator.prototype.getQuery = function(criteria, criterion) {
|
| 57 |
+
var propertyName = criterion.propertyName;
|
| 58 |
+
var value = criterion.value;
|
| 59 |
+
var op = criterion.op;
|
| 60 |
+
var mongoOp = this.parseOp(op);
|
| 61 |
+
|
| 62 |
+
var query = { };
|
| 63 |
+
query[propertyName] = { };
|
| 64 |
+
query[propertyName][mongoOp] = value;
|
| 65 |
+
|
| 66 |
+
if (criterion instanceof LikeExpression) {
|
| 67 |
+
value = value.replace(/\%/g, '.*').
|
| 68 |
+
replace(/\_/g, '.');
|
| 69 |
+
value = new RegExp(value, 'i');
|
| 70 |
+
|
| 71 |
+
query[propertyName] = value;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
return query;
|
| 75 |
+
};
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* Returns the order query.
|
| 79 |
+
*
|
| 80 |
+
* @param {CriteriaImpl} criteria
|
| 81 |
+
* @param {Order} order
|
| 82 |
+
* @returns {Scalar}
|
| 83 |
+
*/
|
| 84 |
+
MongoTranslator.prototype.getOrderQuery = function(criteria, order) {
|
| 85 |
+
var query = { };
|
| 86 |
+
query[order.propertyName] = order.ascending ? 1 : -1;
|
| 87 |
+
|
| 88 |
+
return query;
|
| 89 |
+
};
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* Returns the junction query.
|
| 93 |
+
*
|
| 94 |
+
* @param {CriteriaImpl} criteria
|
| 95 |
+
* @param {Junction} junction
|
| 96 |
+
* @returns {Scalar}
|
| 97 |
+
*/
|
| 98 |
+
MongoTranslator.prototype.getJunctionQuery = function(criteria, junction) {
|
| 99 |
+
var nature = junction.nature;
|
| 100 |
+
var conditions = junction.conditions;
|
| 101 |
+
|
| 102 |
+
if (conditions.length === 0) {
|
| 103 |
+
return { };
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
var mongoOp = this.parseOp(nature);
|
| 107 |
+
|
| 108 |
+
var expressions = [];
|
| 109 |
+
conditions.forEach(function(criterion) {
|
| 110 |
+
var criterionQuery = criterion.getQuery(criteria, this);
|
| 111 |
+
expressions.push(criterionQuery);
|
| 112 |
+
}.bind(this));
|
| 113 |
+
|
| 114 |
+
var query = { };
|
| 115 |
+
query[mongoOp] = expressions;
|
| 116 |
+
|
| 117 |
+
return query;
|
| 118 |
+
};
|
| 119 |
+
|
| 120 |
+
/**
|
| 121 |
+
* Module Exports
|
| 122 |
+
*/
|
| 123 |
+
module.exports = MongoTranslator;
|
pool/shard004/JavaScript/0026597_DDPConnection.js
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import _try from 'fast.js/function/try';
|
| 2 |
+
import _bind from 'fast.js/function/bind';
|
| 3 |
+
import HeartbeatManager from './HeartbeatManager';
|
| 4 |
+
const EventEmitter = typeof window !== 'undefined' && window.Mars
|
| 5 |
+
? window.Mars.EventEmitter : require('marsdb').EventEmitter;
|
| 6 |
+
const PromiseQueue = typeof window !== 'undefined' && window.Mars
|
| 7 |
+
? window.Mars.PromiseQueue : require('marsdb').PromiseQueue;
|
| 8 |
+
const EJSON = typeof window !== 'undefined' && window.Mars
|
| 9 |
+
? window.Mars.EJSON : require('marsdb').EJSON;
|
| 10 |
+
const Random = typeof window !== 'undefined' && window.Mars
|
| 11 |
+
? window.Mars.Random : require('marsdb').Random;
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
// Status of a DDP connection
|
| 15 |
+
const DDP_VERSION = '1';
|
| 16 |
+
const HEARTBEAT_INTERVAL = 17500;
|
| 17 |
+
const HEARTBEAT_TIMEOUT = 15000;
|
| 18 |
+
const RECONNECT_INTERVAL = 5000;
|
| 19 |
+
export const CONN_STATUS = {
|
| 20 |
+
CONNECTING: 'CONNECTING',
|
| 21 |
+
CONNECTED: 'CONNECTED',
|
| 22 |
+
DISCONNECTED: 'DISCONNECTED',
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
export default class DDPConnection extends EventEmitter {
|
| 27 |
+
constructor({ url, socket, autoReconnect = true }) {
|
| 28 |
+
super();
|
| 29 |
+
this.url = url;
|
| 30 |
+
this._processQueue = new PromiseQueue(1);
|
| 31 |
+
this._sessionId = null;
|
| 32 |
+
this._autoReconnect = autoReconnect;
|
| 33 |
+
this._socket = socket;
|
| 34 |
+
this._status = CONN_STATUS.DISCONNECTED;
|
| 35 |
+
this._fullConnectedOnce = false;
|
| 36 |
+
|
| 37 |
+
this._heartbeat = new HeartbeatManager(
|
| 38 |
+
HEARTBEAT_INTERVAL, HEARTBEAT_TIMEOUT
|
| 39 |
+
);
|
| 40 |
+
this._heartbeat.on('timeout', _bind(this._handleHearbeatTimeout, this));
|
| 41 |
+
this._heartbeat.on('sendPing', _bind(this.sendPing, this));
|
| 42 |
+
this._heartbeat.on('sendPong', _bind(this.sendPong, this));
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Returns true if client is fully connected to a server
|
| 47 |
+
* @return {Boolean}
|
| 48 |
+
*/
|
| 49 |
+
get isConnected() {
|
| 50 |
+
return this._status === CONN_STATUS.CONNECTED;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* Returns true if client disconnected
|
| 55 |
+
* @return {Boolean}
|
| 56 |
+
*/
|
| 57 |
+
get isDisconnected() {
|
| 58 |
+
return this._status === CONN_STATUS.DISCONNECTED;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Sends a "method" message to the server with given
|
| 63 |
+
* parameters
|
| 64 |
+
* @param {String} name
|
| 65 |
+
* @param {String} params
|
| 66 |
+
* @param {String} id
|
| 67 |
+
* @param {String} randomSeed
|
| 68 |
+
*/
|
| 69 |
+
sendMethod(name, params = [], id, randomSeed) {
|
| 70 |
+
const msg = {
|
| 71 |
+
msg: 'method',
|
| 72 |
+
id: id,
|
| 73 |
+
method: name,
|
| 74 |
+
params: params,
|
| 75 |
+
};
|
| 76 |
+
if (randomSeed) {
|
| 77 |
+
msg.randomSeed = randomSeed;
|
| 78 |
+
}
|
| 79 |
+
this._sendMessage(msg);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* Send "sub" message to the server with given
|
| 84 |
+
* publusher name and parameters
|
| 85 |
+
* @param {String} name
|
| 86 |
+
* @param {Array} params
|
| 87 |
+
* @param {String} id
|
| 88 |
+
*/
|
| 89 |
+
sendSub(name, params = [], id) {
|
| 90 |
+
this._sendMessage({
|
| 91 |
+
msg: 'sub',
|
| 92 |
+
id: id,
|
| 93 |
+
name: name,
|
| 94 |
+
params: params,
|
| 95 |
+
});
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* Send "unsub" message to the server for given
|
| 100 |
+
* subscription id
|
| 101 |
+
* @param {String} id
|
| 102 |
+
*/
|
| 103 |
+
sendUnsub(id) {
|
| 104 |
+
this._sendMessage({
|
| 105 |
+
msg: 'unsub',
|
| 106 |
+
id: id,
|
| 107 |
+
});
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* Send a "ping" message with randomly generated ping id
|
| 112 |
+
*/
|
| 113 |
+
sendPing() {
|
| 114 |
+
this._sendMessage({
|
| 115 |
+
msg: 'ping',
|
| 116 |
+
id: Random.default().id(20),
|
| 117 |
+
});
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/**
|
| 121 |
+
* Sends a "pong" message for given id of ping message
|
| 122 |
+
* @param {String} id
|
| 123 |
+
*/
|
| 124 |
+
sendPong(id) {
|
| 125 |
+
this._sendMessage({
|
| 126 |
+
msg: 'pong',
|
| 127 |
+
id: id,
|
| 128 |
+
});
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
/**
|
| 132 |
+
* Make a new WebSocket connection to the server
|
| 133 |
+
* if we are not connected yet (isDicsonnected).
|
| 134 |
+
* Returns true if connecting, false if already connectiong
|
| 135 |
+
* @returns {Boolean}
|
| 136 |
+
*/
|
| 137 |
+
connect() {
|
| 138 |
+
if (this.isDisconnected) {
|
| 139 |
+
this._rawConn = new (this._socket)(this.url);
|
| 140 |
+
this._rawConn.onopen = _bind(this._handleOpen, this);
|
| 141 |
+
this._rawConn.onerror = _bind(this._handleError, this);
|
| 142 |
+
this._rawConn.onclose = _bind(this._handleClose, this);
|
| 143 |
+
this._rawConn.onmessage = _bind(this._handleRawMessage, this);
|
| 144 |
+
this._setStatus(CONN_STATUS.CONNECTING);
|
| 145 |
+
return true;
|
| 146 |
+
}
|
| 147 |
+
return false;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
/**
|
| 151 |
+
* Reconnect to the server with unlimited tries. A period
|
| 152 |
+
* of tries is 5 seconds. It reconnects only if not
|
| 153 |
+
* connected. It cancels previously scheduled `connect` by `reconnect`.
|
| 154 |
+
* Returns a function for canceling reconnection process or undefined
|
| 155 |
+
* if connection is not disconnected.
|
| 156 |
+
* @return {Function}
|
| 157 |
+
*/
|
| 158 |
+
reconnect() {
|
| 159 |
+
if (this.isDisconnected) {
|
| 160 |
+
clearTimeout(this._reconnTimer);
|
| 161 |
+
this._reconnecting = true;
|
| 162 |
+
this._reconnTimer = setTimeout(
|
| 163 |
+
_bind(this.connect, this),
|
| 164 |
+
RECONNECT_INTERVAL
|
| 165 |
+
);
|
| 166 |
+
|
| 167 |
+
return () => {
|
| 168 |
+
clearTimeout(this._reconnTimer);
|
| 169 |
+
this._reconnecting = false;
|
| 170 |
+
this.disconnect();
|
| 171 |
+
};
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
/**
|
| 176 |
+
* Close WebSocket connection. If autoReconnect is enabled
|
| 177 |
+
* (enabled by default), then after 5 sec reconnection will
|
| 178 |
+
* be initiated.
|
| 179 |
+
*/
|
| 180 |
+
disconnect() {
|
| 181 |
+
_try(() => this._rawConn && this._rawConn.close());
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
_handleOpen() {
|
| 185 |
+
this._heartbeat.waitPing();
|
| 186 |
+
|
| 187 |
+
const connMsg = {
|
| 188 |
+
msg: 'connect',
|
| 189 |
+
version: DDP_VERSION,
|
| 190 |
+
support: [DDP_VERSION],
|
| 191 |
+
};
|
| 192 |
+
|
| 193 |
+
if (this._sessionId) {
|
| 194 |
+
connMsg.session = this._sessionId;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
this._sendMessage(connMsg);
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
_handleConnectedMessage(msg) {
|
| 201 |
+
if (!this.isConnected) {
|
| 202 |
+
const isTrulyReconnected = this._fullConnectedOnce && this._reconnecting;
|
| 203 |
+
this._setStatus(CONN_STATUS.CONNECTED, isTrulyReconnected);
|
| 204 |
+
this._sessionId = msg.session;
|
| 205 |
+
this._reconnecting = false;
|
| 206 |
+
this._fullConnectedOnce = true;
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
_handleClose() {
|
| 211 |
+
this._heartbeat._clearTimers();
|
| 212 |
+
this._setStatus(CONN_STATUS.DISCONNECTED, this._fullConnectedOnce);
|
| 213 |
+
|
| 214 |
+
if (this._autoReconnect) {
|
| 215 |
+
this._reconnecting = false;
|
| 216 |
+
this.reconnect();
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
_handleHearbeatTimeout() {
|
| 221 |
+
this.disconnect();
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
_handleError(error) {
|
| 225 |
+
this.emit('error', error);
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
_handleRawMessage(rawMsg) {
|
| 229 |
+
return this._processQueue.add(() => {
|
| 230 |
+
const msgObj = EJSON.parse(rawMsg.data);
|
| 231 |
+
return this._processMessage(msgObj);
|
| 232 |
+
}).then(null, err => {
|
| 233 |
+
this._handleError(err);
|
| 234 |
+
});
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
_processMessage(msg) {
|
| 238 |
+
switch (msg.msg) {
|
| 239 |
+
case 'connected': return this._handleConnectedMessage(msg);
|
| 240 |
+
case 'ping': return this._heartbeat.handlePing(msg);
|
| 241 |
+
case 'pong': return this._heartbeat.handlePong(msg);
|
| 242 |
+
case 'removed':
|
| 243 |
+
case 'changed':
|
| 244 |
+
case 'added':
|
| 245 |
+
case 'updated':
|
| 246 |
+
case 'result':
|
| 247 |
+
case 'nosub':
|
| 248 |
+
case 'ready':
|
| 249 |
+
case 'error':
|
| 250 |
+
return this.emitAsync(`message:${msg.msg}`, msg);
|
| 251 |
+
default:
|
| 252 |
+
// just ignore unknown message
|
| 253 |
+
}
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
_sendMessage(msgObj) {
|
| 257 |
+
const result = _try(() =>
|
| 258 |
+
this._rawConn.send(EJSON.stringify(msgObj))
|
| 259 |
+
);
|
| 260 |
+
if (result instanceof Error) {
|
| 261 |
+
this._handleError(result);
|
| 262 |
+
}
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
_setStatus(status, a) {
|
| 266 |
+
this._status = status;
|
| 267 |
+
this.emit(`status:${status}`.toLowerCase(), a);
|
| 268 |
+
}
|
| 269 |
+
}
|
pool/shard004/JavaScript/0026598_index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
| 4 |
+
|
| 5 |
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
| 6 |
+
|
| 7 |
+
Object.defineProperty(exports, "__esModule", {
|
| 8 |
+
value: true
|
| 9 |
+
});
|
| 10 |
+
var _exportNames = {
|
| 11 |
+
avatarClasses: true
|
| 12 |
+
};
|
| 13 |
+
Object.defineProperty(exports, "default", {
|
| 14 |
+
enumerable: true,
|
| 15 |
+
get: function () {
|
| 16 |
+
return _Avatar.default;
|
| 17 |
+
}
|
| 18 |
+
});
|
| 19 |
+
Object.defineProperty(exports, "avatarClasses", {
|
| 20 |
+
enumerable: true,
|
| 21 |
+
get: function () {
|
| 22 |
+
return _avatarClasses.default;
|
| 23 |
+
}
|
| 24 |
+
});
|
| 25 |
+
|
| 26 |
+
var _Avatar = _interopRequireDefault(require("./Avatar"));
|
| 27 |
+
|
| 28 |
+
var _avatarClasses = _interopRequireWildcard(require("./avatarClasses"));
|
| 29 |
+
|
| 30 |
+
Object.keys(_avatarClasses).forEach(function (key) {
|
| 31 |
+
if (key === "default" || key === "__esModule") return;
|
| 32 |
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
| 33 |
+
if (key in exports && exports[key] === _avatarClasses[key]) return;
|
| 34 |
+
Object.defineProperty(exports, key, {
|
| 35 |
+
enumerable: true,
|
| 36 |
+
get: function () {
|
| 37 |
+
return _avatarClasses[key];
|
| 38 |
+
}
|
| 39 |
+
});
|
| 40 |
+
});
|
pool/shard004/JavaScript/0026602_update.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Created by Administrator on 2015/10/14.
|
| 3 |
+
*/
|
| 4 |
+
'use strict';
|
| 5 |
+
var EditPager = require('../views/EditPager');
|
| 6 |
+
var database = require('../database');
|
| 7 |
+
var query = require('./query');
|
| 8 |
+
var post = require('./post');
|
| 9 |
+
var IndexAction = require('./index');
|
| 10 |
+
var LoginAction = require('./login');
|
| 11 |
+
module.exports = function(req,res){
|
| 12 |
+
|
| 13 |
+
if(!req.session.isLogined){
|
| 14 |
+
LoginAction(req,res);
|
| 15 |
+
return;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
if(req.method == 'GET'){
|
| 19 |
+
var id = query(req).id;
|
| 20 |
+
var article = database.list[id];
|
| 21 |
+
var errors = {};
|
| 22 |
+
res.end(new EditPager(id,article,errors,req.session.isLogined).render());
|
| 23 |
+
}else{
|
| 24 |
+
post(req).then(data =>{
|
| 25 |
+
// let {id,title,body} = data;
|
| 26 |
+
let id = data.id;
|
| 27 |
+
delete data.id;
|
| 28 |
+
database.update(data.id,data);
|
| 29 |
+
IndexAction(req,res);
|
| 30 |
+
})
|
| 31 |
+
}
|
| 32 |
+
};
|
pool/shard004/JavaScript/0026605_GraphEdge.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var GraphEdge = cc.DrawNode.extend({
|
| 2 |
+
|
| 3 |
+
//
|
| 4 |
+
// Members
|
| 5 |
+
//
|
| 6 |
+
|
| 7 |
+
m_ObjectA : null, // GraphNode
|
| 8 |
+
m_ObjectB : null, // GraphNode
|
| 9 |
+
m_NameLabel : null, // cc.Label
|
| 10 |
+
|
| 11 |
+
//
|
| 12 |
+
// Construction
|
| 13 |
+
//
|
| 14 |
+
|
| 15 |
+
ctor : function(
|
| 16 |
+
objectA, // GraphNode
|
| 17 |
+
objectB, // GraphNode
|
| 18 |
+
name // String
|
| 19 |
+
)
|
| 20 |
+
{
|
| 21 |
+
this._super();
|
| 22 |
+
|
| 23 |
+
this.m_ObjectA = objectA;
|
| 24 |
+
this.m_ObjectB = objectB;
|
| 25 |
+
|
| 26 |
+
this.m_NameLabel = cc.LabelTTF.create(name, "Arial", 20);
|
| 27 |
+
this.m_NameLabel.setColor(cc.color(204, 204, 0));
|
| 28 |
+
this.addChild(this.m_NameLabel);
|
| 29 |
+
|
| 30 |
+
objectA.addEdge(this);
|
| 31 |
+
objectB.addEdge(this);
|
| 32 |
+
|
| 33 |
+
this.graphNodeUpdated();
|
| 34 |
+
},
|
| 35 |
+
|
| 36 |
+
//
|
| 37 |
+
// Interface
|
| 38 |
+
//
|
| 39 |
+
|
| 40 |
+
graphNodeUpdated : function()
|
| 41 |
+
{
|
| 42 |
+
var pos1 = this.m_ObjectA.getPosition();
|
| 43 |
+
var pos2 = this.m_ObjectB.getPosition();
|
| 44 |
+
|
| 45 |
+
this.setPosition(pos1);
|
| 46 |
+
|
| 47 |
+
var vector = cc.pSub(pos2, pos1);
|
| 48 |
+
var vectorLength = cc.pLength(vector);
|
| 49 |
+
|
| 50 |
+
var angle = Math.acos(vector.x / vectorLength) * 57.295;
|
| 51 |
+
|
| 52 |
+
this.setRotation(pos1.y < pos2.y ? -angle : angle);
|
| 53 |
+
|
| 54 |
+
var size = cc.size(vectorLength, 18);
|
| 55 |
+
|
| 56 |
+
this.clear();
|
| 57 |
+
this.drawRect(cc.p(0, 0), cc.p(size.width, 3), cc.color(51, 102, 255, 255));
|
| 58 |
+
|
| 59 |
+
var vtx = [
|
| 60 |
+
cc.p(size.width, -6),
|
| 61 |
+
cc.p(size.width, 6),
|
| 62 |
+
cc.p(size.width + 12, 1.5)
|
| 63 |
+
];
|
| 64 |
+
|
| 65 |
+
this.drawPoly(vtx, cc.color(51, 102, 255, 255), 1, cc.color(255, 255, 255, 255));
|
| 66 |
+
|
| 67 |
+
this.m_NameLabel.setPosition(size.width * 0.5, size.height);
|
| 68 |
+
}
|
| 69 |
+
});
|
pool/shard004/JavaScript/0026607_addCommand.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
describe('addCommand', function() {
|
| 2 |
+
|
| 3 |
+
before(h.setup());
|
| 4 |
+
|
| 5 |
+
describe('add regular command', function() {
|
| 6 |
+
|
| 7 |
+
before(function() {
|
| 8 |
+
this.client.addCommand('getUrlAndTitle', function() {
|
| 9 |
+
|
| 10 |
+
var result = {};
|
| 11 |
+
|
| 12 |
+
return this.url().then(function(url) {
|
| 13 |
+
result.url = url.value;
|
| 14 |
+
}).getTitle().then(function(title) {
|
| 15 |
+
result.title = title;
|
| 16 |
+
}).then(function() {
|
| 17 |
+
return result;
|
| 18 |
+
});
|
| 19 |
+
|
| 20 |
+
});
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
it('added a `getUrlAndTitle` command', function() {
|
| 24 |
+
return this.client.getUrlAndTitle().then(function(result) {
|
| 25 |
+
assert.strictEqual(result.url, conf.testPage.start);
|
| 26 |
+
assert.strictEqual(result.title, conf.testPage.title);
|
| 27 |
+
});
|
| 28 |
+
});
|
| 29 |
+
|
| 30 |
+
it('should promisify added command', function() {
|
| 31 |
+
return this.client.getUrlAndTitle().then(function(result) {
|
| 32 |
+
assert.strictEqual(result.url, conf.testPage.start);
|
| 33 |
+
assert.strictEqual(result.title, conf.testPage.title);
|
| 34 |
+
});
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
});
|
| 38 |
+
|
| 39 |
+
describe('try to add an existing command', function() {
|
| 40 |
+
|
| 41 |
+
it('should throw an error', function() {
|
| 42 |
+
var self = this;
|
| 43 |
+
|
| 44 |
+
(function(){
|
| 45 |
+
self.client.addCommand('shake', function() {
|
| 46 |
+
return 'should fail';
|
| 47 |
+
});
|
| 48 |
+
}).should.throw();
|
| 49 |
+
});
|
| 50 |
+
|
| 51 |
+
it('should overwrite existing method if overwrite flag is given', function() {
|
| 52 |
+
this.client.addCommand('shake', function() {
|
| 53 |
+
return 'should not fail';
|
| 54 |
+
}, true);
|
| 55 |
+
|
| 56 |
+
return this.client.shake().then(function(res) {
|
| 57 |
+
expect(res).to.be.equal('should not fail');
|
| 58 |
+
});
|
| 59 |
+
});
|
| 60 |
+
|
| 61 |
+
});
|
| 62 |
+
|
| 63 |
+
});
|
pool/shard004/JavaScript/0026612_mousepress.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* simple helper for a mousepress event
|
| 3 |
+
* used by webshims improving spinbutton controls for input[type=time], input[type=number]...
|
| 4 |
+
*
|
| 5 |
+
* $(element).bind('mousepress', function(){
|
| 6 |
+
* //repeatedly called after mousedown, till mouseleave/mouseup
|
| 7 |
+
* });
|
| 8 |
+
*/
|
| 9 |
+
(function($){
|
| 10 |
+
var removeTimer = function(elem, full){
|
| 11 |
+
var timer = elem.data('mousepresstimer');
|
| 12 |
+
if(timer){
|
| 13 |
+
clearTimeout(timer);
|
| 14 |
+
}
|
| 15 |
+
if(full){
|
| 16 |
+
elem.unbind('mouseup.mousepressext mouseleave.mousepressext');
|
| 17 |
+
}
|
| 18 |
+
elem = null;
|
| 19 |
+
};
|
| 20 |
+
$.event.special.mousepress = {
|
| 21 |
+
setup: function(){
|
| 22 |
+
var timer;
|
| 23 |
+
$(this).bind('mousedown.mousepressext', function(e){
|
| 24 |
+
var elem = $(this);
|
| 25 |
+
|
| 26 |
+
var startIntervall = function(delay){
|
| 27 |
+
var steps = 0;
|
| 28 |
+
removeTimer(elem);
|
| 29 |
+
elem.data('mousepresstimer', setInterval(function(){
|
| 30 |
+
$.event.special.mousepress.handler(elem[0], e);
|
| 31 |
+
steps++;
|
| 32 |
+
if(steps > 3 && delay > 45){
|
| 33 |
+
startIntervall(delay - 40);
|
| 34 |
+
}
|
| 35 |
+
}, delay));
|
| 36 |
+
};
|
| 37 |
+
var target = $(e.target).trigger('mousepressstart', [e]);
|
| 38 |
+
|
| 39 |
+
removeTimer(elem);
|
| 40 |
+
elem.data('mousepresstimer', setTimeout(function(){
|
| 41 |
+
startIntervall(180);
|
| 42 |
+
}, 200));
|
| 43 |
+
|
| 44 |
+
elem.bind('mouseup.mousepressext mouseleave.mousepressext', function(e){
|
| 45 |
+
removeTimer(elem, true);
|
| 46 |
+
target.trigger('mousepressend', [e]);
|
| 47 |
+
elem = null;
|
| 48 |
+
target = null;
|
| 49 |
+
});
|
| 50 |
+
});
|
| 51 |
+
},
|
| 52 |
+
teardown: function(){
|
| 53 |
+
removeTimer($(this).unbind('.mousepressext'), true);
|
| 54 |
+
},
|
| 55 |
+
handler: function(elem, e){
|
| 56 |
+
return ($.event.dispatch || $.event.handle).call(elem, {type: 'mousepress', target: e.target, pageX: e.pageX, pageY: e.pageY});
|
| 57 |
+
}
|
| 58 |
+
};
|
| 59 |
+
|
| 60 |
+
})(jQuery);
|
pool/shard004/JavaScript/0026613_input-list.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
jQuery( function ( $ ) {
|
| 2 |
+
function update() {
|
| 3 |
+
var $this = $( this ),
|
| 4 |
+
$children = $this.closest( 'li' ).children( 'ul' );
|
| 5 |
+
|
| 6 |
+
if ( $this.is( ':checked' ) ) {
|
| 7 |
+
$children.removeClass( 'hidden' );
|
| 8 |
+
} else {
|
| 9 |
+
$children
|
| 10 |
+
.addClass( 'hidden' )
|
| 11 |
+
.find( 'input' )
|
| 12 |
+
.removeAttr( 'checked' );
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
$( '.rwmb-input' )
|
| 17 |
+
.on( 'change', '.rwmb-input-list.collapse :checkbox', update )
|
| 18 |
+
.on( 'clone', '.rwmb-input-list.collapse :checkbox', update );
|
| 19 |
+
$( '.rwmb-input-list.collapse :checkbox' ).each( update );
|
| 20 |
+
|
| 21 |
+
$( '.rwmb-input-list-select-all-none' ).toggle(
|
| 22 |
+
function () {
|
| 23 |
+
$('input.rwmb-checkbox_list[name="' + $(this).data('name') + '[]"]').prop('checked', true);
|
| 24 |
+
},
|
| 25 |
+
function () {
|
| 26 |
+
$('input.rwmb-checkbox_list[name="' + $(this).data('name') + '[]"]').prop('checked', false);
|
| 27 |
+
}
|
| 28 |
+
);
|
| 29 |
+
} );
|
pool/shard004/JavaScript/0026615_columnAnimationService.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* ag-grid - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
|
| 3 |
+
* @version v18.0.0
|
| 4 |
+
* @link http://www.ag-grid.com/
|
| 5 |
+
* @license MIT
|
| 6 |
+
*/
|
| 7 |
+
"use strict";
|
| 8 |
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
| 9 |
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
| 10 |
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
| 11 |
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
| 12 |
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
| 13 |
+
};
|
| 14 |
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
| 15 |
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
| 16 |
+
};
|
| 17 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 18 |
+
var context_1 = require("../context/context");
|
| 19 |
+
var gridOptionsWrapper_1 = require("../gridOptionsWrapper");
|
| 20 |
+
var ColumnAnimationService = (function () {
|
| 21 |
+
function ColumnAnimationService() {
|
| 22 |
+
this.executeNextFuncs = [];
|
| 23 |
+
this.executeLaterFuncs = [];
|
| 24 |
+
this.active = false;
|
| 25 |
+
this.animationThreadCount = 0;
|
| 26 |
+
}
|
| 27 |
+
ColumnAnimationService.prototype.registerGridComp = function (gridPanel) {
|
| 28 |
+
this.gridPanel = gridPanel;
|
| 29 |
+
};
|
| 30 |
+
ColumnAnimationService.prototype.isActive = function () {
|
| 31 |
+
return this.active;
|
| 32 |
+
};
|
| 33 |
+
ColumnAnimationService.prototype.start = function () {
|
| 34 |
+
if (this.active) {
|
| 35 |
+
return;
|
| 36 |
+
}
|
| 37 |
+
if (this.gridOptionsWrapper.isSuppressColumnMoveAnimation()) {
|
| 38 |
+
return;
|
| 39 |
+
}
|
| 40 |
+
// if doing RTL, we don't animate open / close as due to how the pixels are inverted,
|
| 41 |
+
// the animation moves all the row the the right rather than to the left (ie it's the static
|
| 42 |
+
// columns that actually get their coordinates updated)
|
| 43 |
+
if (this.gridOptionsWrapper.isEnableRtl()) {
|
| 44 |
+
return;
|
| 45 |
+
}
|
| 46 |
+
this.ensureAnimationCssClassPresent();
|
| 47 |
+
this.active = true;
|
| 48 |
+
};
|
| 49 |
+
ColumnAnimationService.prototype.finish = function () {
|
| 50 |
+
if (!this.active) {
|
| 51 |
+
return;
|
| 52 |
+
}
|
| 53 |
+
this.flush();
|
| 54 |
+
this.active = false;
|
| 55 |
+
};
|
| 56 |
+
ColumnAnimationService.prototype.executeNextVMTurn = function (func) {
|
| 57 |
+
if (this.active) {
|
| 58 |
+
this.executeNextFuncs.push(func);
|
| 59 |
+
}
|
| 60 |
+
else {
|
| 61 |
+
func();
|
| 62 |
+
}
|
| 63 |
+
};
|
| 64 |
+
ColumnAnimationService.prototype.executeLaterVMTurn = function (func) {
|
| 65 |
+
if (this.active) {
|
| 66 |
+
this.executeLaterFuncs.push(func);
|
| 67 |
+
}
|
| 68 |
+
else {
|
| 69 |
+
func();
|
| 70 |
+
}
|
| 71 |
+
};
|
| 72 |
+
ColumnAnimationService.prototype.ensureAnimationCssClassPresent = function () {
|
| 73 |
+
var _this = this;
|
| 74 |
+
// up the count, so we can tell if someone else has updated the count
|
| 75 |
+
// by the time the 'wait' func executes
|
| 76 |
+
this.animationThreadCount++;
|
| 77 |
+
var animationThreadCountCopy = this.animationThreadCount;
|
| 78 |
+
this.gridPanel.setColumnMovingCss(true);
|
| 79 |
+
this.executeLaterFuncs.push(function () {
|
| 80 |
+
// only remove the class if this thread was the last one to update it
|
| 81 |
+
if (_this.animationThreadCount === animationThreadCountCopy) {
|
| 82 |
+
_this.gridPanel.setColumnMovingCss(false);
|
| 83 |
+
}
|
| 84 |
+
});
|
| 85 |
+
};
|
| 86 |
+
ColumnAnimationService.prototype.flush = function () {
|
| 87 |
+
var nowFuncs = this.executeNextFuncs;
|
| 88 |
+
this.executeNextFuncs = [];
|
| 89 |
+
var waitFuncs = this.executeLaterFuncs;
|
| 90 |
+
this.executeLaterFuncs = [];
|
| 91 |
+
if (nowFuncs.length === 0 && waitFuncs.length === 0) {
|
| 92 |
+
return;
|
| 93 |
+
}
|
| 94 |
+
setTimeout(function () { return nowFuncs.forEach(function (func) { return func(); }); }, 0);
|
| 95 |
+
setTimeout(function () { return waitFuncs.forEach(function (func) { return func(); }); }, 300);
|
| 96 |
+
};
|
| 97 |
+
__decorate([
|
| 98 |
+
context_1.Autowired('gridOptionsWrapper'),
|
| 99 |
+
__metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
|
| 100 |
+
], ColumnAnimationService.prototype, "gridOptionsWrapper", void 0);
|
| 101 |
+
ColumnAnimationService = __decorate([
|
| 102 |
+
context_1.Bean('columnAnimationService')
|
| 103 |
+
], ColumnAnimationService);
|
| 104 |
+
return ColumnAnimationService;
|
| 105 |
+
}());
|
| 106 |
+
exports.ColumnAnimationService = ColumnAnimationService;
|
pool/shard004/JavaScript/0026618_stateGetter.test.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import expect from 'expect';
|
| 2 |
+
import { fromJS, Map, List } from 'immutable';
|
| 3 |
+
import { stateGetter } from './../../src/util/stateGetter';
|
| 4 |
+
|
| 5 |
+
describe('State Getter Function', () => {
|
| 6 |
+
|
| 7 |
+
// sample redux wrapper for state.get
|
| 8 |
+
function getState() {
|
| 9 |
+
return true;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
function getStateWithImmutable() {
|
| 13 |
+
return Map({
|
| 14 |
+
x: 1
|
| 15 |
+
});
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
it('Should return state if its registered', () => {
|
| 19 |
+
const state = { filterState: { get: getState } };
|
| 20 |
+
const props = {};
|
| 21 |
+
expect(
|
| 22 |
+
stateGetter(state, props, 'filterState', 'someProp')
|
| 23 |
+
).toBeTruthy();
|
| 24 |
+
});
|
| 25 |
+
|
| 26 |
+
it('Should return an immutable object if state is immutable', () => {
|
| 27 |
+
const state = { filterState: { get: getStateWithImmutable } };
|
| 28 |
+
const props = {};
|
| 29 |
+
expect(
|
| 30 |
+
stateGetter(state, props, 'filterState', 'someProp')
|
| 31 |
+
).toEqual(Map({
|
| 32 |
+
x: 1
|
| 33 |
+
}));
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
it('Should return null if it\'s not registered', () => {
|
| 37 |
+
const state = { filterState: { get: getState } };
|
| 38 |
+
const props = {};
|
| 39 |
+
expect(
|
| 40 |
+
stateGetter(state, props, 'unknownState', 'someProp')
|
| 41 |
+
).toEqual(null);
|
| 42 |
+
});
|
| 43 |
+
|
| 44 |
+
it('Should return state when a dynamic key is used if registerd', () => {
|
| 45 |
+
const state = { someFilterState: { get: getState } };
|
| 46 |
+
const props = {
|
| 47 |
+
reducerKeys: {
|
| 48 |
+
filterState: 'someFilterState'
|
| 49 |
+
}
|
| 50 |
+
};
|
| 51 |
+
expect(
|
| 52 |
+
stateGetter(state, props, 'filterState', 'someProp')
|
| 53 |
+
).toBeTruthy();
|
| 54 |
+
});
|
| 55 |
+
|
| 56 |
+
it(['Should return state when a dynamic key ',
|
| 57 |
+
'is used, and has immutable state'].join(''), () => {
|
| 58 |
+
const state = { someFilterState: { get: getStateWithImmutable } };
|
| 59 |
+
const props = {
|
| 60 |
+
reducerKeys: {
|
| 61 |
+
filterState: 'someFilterState'
|
| 62 |
+
}
|
| 63 |
+
};
|
| 64 |
+
expect(
|
| 65 |
+
stateGetter(state, props, 'filterState', 'someProp')
|
| 66 |
+
).toEqual(Map({
|
| 67 |
+
x: 1
|
| 68 |
+
}));
|
| 69 |
+
});
|
| 70 |
+
|
| 71 |
+
it('Should return null if a dynamic key is used if not registered', () => {
|
| 72 |
+
const state = {};
|
| 73 |
+
const props = {
|
| 74 |
+
reducerKeys: {
|
| 75 |
+
filterState: 'someFilterState'
|
| 76 |
+
}
|
| 77 |
+
};
|
| 78 |
+
expect(
|
| 79 |
+
stateGetter(state, props, 'filterState', 'someProp')
|
| 80 |
+
).toEqual(null);
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
it('Should return state when it is nested and registered', () => {
|
| 84 |
+
const state = { nested: {filterState: { get: getState } } };
|
| 85 |
+
const props = {
|
| 86 |
+
reducerKeys: 'nested'
|
| 87 |
+
};
|
| 88 |
+
expect(
|
| 89 |
+
stateGetter(state, props, 'filterState', 'someProp')
|
| 90 |
+
).toBeTruthy();
|
| 91 |
+
});
|
| 92 |
+
|
| 93 |
+
it(['Should return state when it is nested ',
|
| 94 |
+
'and has immutable state'].join(''), () => {
|
| 95 |
+
const state = {
|
| 96 |
+
nested: { filterState: { get: getStateWithImmutable } }
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
const props = {
|
| 100 |
+
reducerKeys: 'nested'
|
| 101 |
+
};
|
| 102 |
+
expect(
|
| 103 |
+
stateGetter(state, props, 'filterState', 'someProp')
|
| 104 |
+
).toEqual(Map({
|
| 105 |
+
x: 1
|
| 106 |
+
}));
|
| 107 |
+
});
|
| 108 |
+
|
| 109 |
+
it(['Should return state when it is nested in an immutable object ',
|
| 110 |
+
'and has immutable state'].join(''), () => {
|
| 111 |
+
const state = Map({
|
| 112 |
+
nested: { filterState: { get: getStateWithImmutable } }
|
| 113 |
+
});
|
| 114 |
+
|
| 115 |
+
const props = {
|
| 116 |
+
reducerKeys: 'nested'
|
| 117 |
+
};
|
| 118 |
+
expect(
|
| 119 |
+
stateGetter(state, props, 'filterState', 'someProp')
|
| 120 |
+
).toEqual(Map({
|
| 121 |
+
x: 1
|
| 122 |
+
}));
|
| 123 |
+
});
|
| 124 |
+
|
| 125 |
+
it('Should return null if state is nested and not registered', () => {
|
| 126 |
+
const state = { nested: {} };
|
| 127 |
+
const props = {
|
| 128 |
+
reducerKeys: 'nested'
|
| 129 |
+
};
|
| 130 |
+
expect(
|
| 131 |
+
stateGetter(state, props, 'filterState', 'someProp')
|
| 132 |
+
).toEqual(null);
|
| 133 |
+
});
|
| 134 |
+
|
| 135 |
+
it('Should return null when no keys and no state are provided', () => {
|
| 136 |
+
const state = {};
|
| 137 |
+
const props = {};
|
| 138 |
+
expect(
|
| 139 |
+
stateGetter(state, props, 'filterState', 'someProp')
|
| 140 |
+
).toEqual(null);
|
| 141 |
+
});
|
| 142 |
+
|
| 143 |
+
it('Should return state when its stored using immutable', () => {
|
| 144 |
+
const state = fromJS({ data: { thing: [1] } });
|
| 145 |
+
const props = {};
|
| 146 |
+
|
| 147 |
+
expect(
|
| 148 |
+
stateGetter(state, props, 'data', 'thing')
|
| 149 |
+
).toEqual(List([1]));
|
| 150 |
+
});
|
| 151 |
+
|
| 152 |
+
it('Should return state when its not stored using immutable', () => {
|
| 153 |
+
const state = { data: { thing: [1] } };
|
| 154 |
+
const props = {};
|
| 155 |
+
|
| 156 |
+
expect(
|
| 157 |
+
stateGetter(state, props, 'data', 'thing')
|
| 158 |
+
).toEqual([1]);
|
| 159 |
+
});
|
| 160 |
+
});
|
pool/shard004/JavaScript/0026621_selenium.js
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
steal('steal/browser', function(){
|
| 2 |
+
steal.browser.selenium = function(options){
|
| 3 |
+
// kill the server in case it was running from before
|
| 4 |
+
this.killServer();
|
| 5 |
+
steal.browser.call(this, options, 'selenium')
|
| 6 |
+
this._startServer();
|
| 7 |
+
this.clientPath = "funcunit/selenium";
|
| 8 |
+
}
|
| 9 |
+
steal.extend(steal.browser.selenium, {
|
| 10 |
+
defaults: {
|
| 11 |
+
serverPort: 4444,
|
| 12 |
+
serverHost: "localhost"
|
| 13 |
+
},
|
| 14 |
+
trigger: function(){
|
| 15 |
+
browser.trigger.apply(self, arguments);
|
| 16 |
+
}
|
| 17 |
+
});
|
| 18 |
+
steal.browser.selenium.prototype = new steal.browser();
|
| 19 |
+
steal.extend(steal.browser.selenium.prototype, {
|
| 20 |
+
/**
|
| 21 |
+
* Opens the browser, at each of the specified browsers, one by one
|
| 22 |
+
* @param {Object} page
|
| 23 |
+
* @param {Object} browsers
|
| 24 |
+
*/
|
| 25 |
+
open: function(page, browsers){
|
| 26 |
+
this._currentBrowserIndex = 0;
|
| 27 |
+
this.page = this._getPageUrl(page);
|
| 28 |
+
this.browsers = browsers || ["*firefox"];
|
| 29 |
+
this._browserStart(0);
|
| 30 |
+
this._poll();
|
| 31 |
+
// block until we're done
|
| 32 |
+
this.browserOpen = true;
|
| 33 |
+
while(this.browserOpen) {
|
| 34 |
+
java.lang.Thread.currentThread().sleep(1000);
|
| 35 |
+
}
|
| 36 |
+
return this;
|
| 37 |
+
},
|
| 38 |
+
_loadDriverClass: function() {
|
| 39 |
+
var URLClassLoader = Packages.java.net.URLClassLoader,
|
| 40 |
+
URL = java.net.URL,
|
| 41 |
+
File = java.io.File,
|
| 42 |
+
ss = new File("funcunit/selenium/selenium-java-client-driver.jar"),
|
| 43 |
+
ssurl = ss.toURL(),
|
| 44 |
+
urls = java.lang.reflect.Array.newInstance(URL, 1);
|
| 45 |
+
urls[0] = new URL(ssurl);
|
| 46 |
+
|
| 47 |
+
var clazzLoader = new URLClassLoader(urls),
|
| 48 |
+
mthds = clazzLoader.loadClass("com.thoughtworks.selenium.DefaultSelenium").getDeclaredConstructors(),
|
| 49 |
+
rawMeth = null;
|
| 50 |
+
//iterate through methods to find the one we are looking for
|
| 51 |
+
for ( var i = 0; i < mthds.length; i++ ) {
|
| 52 |
+
var meth = mthds[i];
|
| 53 |
+
if ( meth.toString().match(/DefaultSelenium\(java.lang.String,int,java.lang.String,java.lang.String\)/) ) {
|
| 54 |
+
constructor = meth;
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
return function( serverHost, serverPort, browserStartCommand, browserURL ) {
|
| 58 |
+
var host = new java.lang.String(serverHost),
|
| 59 |
+
port = new java.lang.Integer(serverPort),
|
| 60 |
+
cmd = new java.lang.String(browserStartCommand),
|
| 61 |
+
url = new java.lang.String(browserURL);
|
| 62 |
+
return constructor.newInstance(host, port, cmd, url);
|
| 63 |
+
};
|
| 64 |
+
},
|
| 65 |
+
_startServer: function(){
|
| 66 |
+
//first lets ping and make sure the server is up
|
| 67 |
+
var port = this.options.serverPort,
|
| 68 |
+
addr = java.net.InetAddress.getByName(this.options.serverHost)
|
| 69 |
+
try {
|
| 70 |
+
var s = new java.net.Socket(addr, port)
|
| 71 |
+
}
|
| 72 |
+
catch (ex) {
|
| 73 |
+
spawn(function(){
|
| 74 |
+
var jarCommand = 'java -jar '+
|
| 75 |
+
'funcunit/selenium/selenium-server-standalone-2.12.0.jar'+
|
| 76 |
+
' -userExtensions funcunit/selenium/user-extensions.js';
|
| 77 |
+
if (java.lang.System.getProperty("os.name").indexOf("Windows") != -1) {
|
| 78 |
+
var command = 'start "selenium" ' + jarCommand;
|
| 79 |
+
runCommand("cmd", "/C", command.replace(/\//g, "\\"))
|
| 80 |
+
}
|
| 81 |
+
else {
|
| 82 |
+
var command = jarCommand + " > selenium.log 2> selenium.log &";
|
| 83 |
+
runCommand("sh", "-c", command);
|
| 84 |
+
}
|
| 85 |
+
})
|
| 86 |
+
var timeouts = 0,
|
| 87 |
+
started = false;
|
| 88 |
+
var pollSeleniumServer = function(){
|
| 89 |
+
try {
|
| 90 |
+
var s = new java.net.Socket(addr, port)
|
| 91 |
+
started = true;
|
| 92 |
+
}
|
| 93 |
+
catch (ex) {
|
| 94 |
+
if (timeouts > 20) {
|
| 95 |
+
print("Selenium is not running. Please use js -selenium to start it.")
|
| 96 |
+
quit();
|
| 97 |
+
} else {
|
| 98 |
+
timeouts++;
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
while(!started){
|
| 103 |
+
java.lang.Thread.currentThread().sleep(1000);
|
| 104 |
+
pollSeleniumServer();
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
this.DefaultSelenium = this._loadDriverClass();
|
| 108 |
+
},
|
| 109 |
+
killServer: function(){
|
| 110 |
+
if (java.lang.System.getProperty("os.name").indexOf("Windows") != -1) {
|
| 111 |
+
runCommand("cmd", "/C", 'taskkill /fi "Windowtitle eq selenium" > NUL')
|
| 112 |
+
} else { // mac
|
| 113 |
+
runCommand("sh", "-c", "ps aux | awk '/selenium\\// {print$2}' | xargs kill -9")
|
| 114 |
+
}
|
| 115 |
+
},
|
| 116 |
+
// create new selenium instance, start it, open page, set FuncUnit.mode = "Selenium", start polling for data
|
| 117 |
+
_browserStart: function(index){
|
| 118 |
+
var browser = this.browsers[this._currentBrowserIndex];
|
| 119 |
+
this.trigger("browserStart", {
|
| 120 |
+
browser: browser
|
| 121 |
+
})
|
| 122 |
+
this.selenium = this.DefaultSelenium(this.options.serverHost,
|
| 123 |
+
this.options.serverPort,
|
| 124 |
+
browser,
|
| 125 |
+
this.page);
|
| 126 |
+
this.selenium.start();
|
| 127 |
+
this.selenium.open(this.page);
|
| 128 |
+
selThreads.resumePolling();
|
| 129 |
+
},
|
| 130 |
+
close: function(data){
|
| 131 |
+
//print(">>>>>>>>>> CLOSING")
|
| 132 |
+
//this.keepPolling = false;
|
| 133 |
+
var browser = this.browsers[this._currentBrowserIndex];
|
| 134 |
+
this.trigger("browserDone", {
|
| 135 |
+
browser: browser
|
| 136 |
+
});
|
| 137 |
+
selThreads.pausePolling();
|
| 138 |
+
this.selenium.close();
|
| 139 |
+
this.selenium.stop();
|
| 140 |
+
//print(">>>>>>>>>> STOPPED")
|
| 141 |
+
this._currentBrowserIndex++;
|
| 142 |
+
if (this._currentBrowserIndex < this.browsers.length) {
|
| 143 |
+
this._browserStart(this._currentBrowserIndex)
|
| 144 |
+
}
|
| 145 |
+
else {
|
| 146 |
+
selThreads.stopPolling();
|
| 147 |
+
//print(">>>>>>>>>> ALL DONE")
|
| 148 |
+
this.trigger("allDone");
|
| 149 |
+
this.killServer();
|
| 150 |
+
this.browserOpen = false;
|
| 151 |
+
}
|
| 152 |
+
},
|
| 153 |
+
evaluate: function(fn){
|
| 154 |
+
var txt = fn.toString().replace(/\n|\r\n/g,""),
|
| 155 |
+
evalText = "Selenium.evaluate('"+txt+"')";
|
| 156 |
+
var res = this.selenium.getEval(evalText);
|
| 157 |
+
res = ""+res;
|
| 158 |
+
return res;
|
| 159 |
+
},
|
| 160 |
+
injectJS: function(file){
|
| 161 |
+
var scriptText = readFile(file).replace(/\n|\r\n/g,""),
|
| 162 |
+
evalText = "Selenium.injectJS('"+escape(scriptText)+"')";
|
| 163 |
+
this.selenium.getEval(evalText);
|
| 164 |
+
return true;
|
| 165 |
+
},
|
| 166 |
+
_poll: function(){
|
| 167 |
+
selThreads.poll(this);
|
| 168 |
+
|
| 169 |
+
}
|
| 170 |
+
});
|
| 171 |
+
|
| 172 |
+
var keepPolling = false,
|
| 173 |
+
stopPolling = false;
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
var selThreads = {
|
| 177 |
+
poll : function(self){
|
| 178 |
+
this.resumePolling();
|
| 179 |
+
|
| 180 |
+
spawn(function(){
|
| 181 |
+
|
| 182 |
+
var stop = selThreads.getResult(self);
|
| 183 |
+
if(!stop){
|
| 184 |
+
java.lang.Thread.currentThread().sleep(350);
|
| 185 |
+
arguments.callee();
|
| 186 |
+
}
|
| 187 |
+
})
|
| 188 |
+
|
| 189 |
+
},
|
| 190 |
+
pausePolling : sync(function(){
|
| 191 |
+
keepPolling = false;
|
| 192 |
+
}),
|
| 193 |
+
resumePolling : sync(function(){
|
| 194 |
+
keepPolling = true;
|
| 195 |
+
}),
|
| 196 |
+
stopPolling : sync(function(){
|
| 197 |
+
stopPolling = true;
|
| 198 |
+
keepPolling = false;
|
| 199 |
+
}),
|
| 200 |
+
getResult : sync(function(self){
|
| 201 |
+
if(!keepPolling){
|
| 202 |
+
return stopPolling;
|
| 203 |
+
}
|
| 204 |
+
var resultJSON,
|
| 205 |
+
res,
|
| 206 |
+
evt;
|
| 207 |
+
//self.keepPolling = true;
|
| 208 |
+
//print(">>>>>>>>>> POLLING")
|
| 209 |
+
resultJSON = self.selenium.getEval("Selenium.getResult()");
|
| 210 |
+
eval("res = "+resultJSON);
|
| 211 |
+
if(res && res.length){
|
| 212 |
+
for (var i = 0; i < res.length; i++) {
|
| 213 |
+
evt = res[i];
|
| 214 |
+
self.trigger(evt.type, evt.data);
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
return stopPolling;
|
| 218 |
+
}),
|
| 219 |
+
keepPolling : false
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
})
|
pool/shard004/JavaScript/0026623_tooltip.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
/* Services */
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
angular.module('tooltip', []).
|
| 7 |
+
factory('tooltip', ['$rootScope', '$compile', function($rootScope, $compile) {
|
| 8 |
+
// init tooltip
|
| 9 |
+
var scope = $rootScope.$new(true);
|
| 10 |
+
var isMouseInTooltip = false;
|
| 11 |
+
scope.onmouseenter = function() {
|
| 12 |
+
// mouse enters tooltip
|
| 13 |
+
isMouseInTooltip = true;
|
| 14 |
+
};
|
| 15 |
+
scope.onmouseleave = function() {
|
| 16 |
+
// mouse leaves tooltip
|
| 17 |
+
isMouseInTooltip = false;
|
| 18 |
+
hide();
|
| 19 |
+
};
|
| 20 |
+
var _left = 0;
|
| 21 |
+
var _top = 0;
|
| 22 |
+
|
| 23 |
+
var tooltip = $compile('<div class="tooltip" ng-mouseenter="onmouseenter()" ng-mouseleave="onmouseleave()"></div>')(scope);
|
| 24 |
+
tooltip.css('max-width', viewWidth() + 'px');
|
| 25 |
+
|
| 26 |
+
// append tooltip to the end of body element
|
| 27 |
+
angular.element(document.getElementsByTagName('body')[0]).append(tooltip);
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
function viewWidth() {
|
| 31 |
+
// FIXME: why -32 here?
|
| 32 |
+
return (window.innerWidth || document.documentElement.clientWidth) - 32;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
function setContent(content) {
|
| 36 |
+
tooltip.children().remove();
|
| 37 |
+
if (angular.isUndefined(content)) {
|
| 38 |
+
throw 'In tooltip: content undefined!';
|
| 39 |
+
} else if (angular.isString(content)) {
|
| 40 |
+
tooltip.html(content);
|
| 41 |
+
} else {
|
| 42 |
+
tooltip.append(content);
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
function setPosition(position) {
|
| 47 |
+
_left = parseInt(position.left.replace('px', ''));
|
| 48 |
+
_top = parseInt(position.top.replace('px', ''));
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
function show() {
|
| 52 |
+
// move tooltip to the right
|
| 53 |
+
// (don't cross the right side of browser inner window)
|
| 54 |
+
var _right = _left + tooltip.prop('offsetWidth');
|
| 55 |
+
if ( _right > viewWidth() )
|
| 56 |
+
_left -= (_right - viewWidth());
|
| 57 |
+
|
| 58 |
+
tooltip.css('left', _left + 'px');
|
| 59 |
+
tooltip.css('top', _top + 'px');
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
function hide() {
|
| 63 |
+
if (!isMouseInTooltip)
|
| 64 |
+
tooltip.css('left', '-9999px');
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
var serviceInstance = {
|
| 68 |
+
viewWidth: viewWidth,
|
| 69 |
+
isHidden: function() {return (tooltip.css('left') === '-9999px');},
|
| 70 |
+
getLeftSpace: function() {return _left;},
|
| 71 |
+
getRightSpace: function() {return viewWidth() - _left - tooltip.prop('offsetWidth');},
|
| 72 |
+
setContent: setContent,
|
| 73 |
+
setPosition: setPosition,
|
| 74 |
+
show: show,
|
| 75 |
+
hide: hide
|
| 76 |
+
};
|
| 77 |
+
return serviceInstance;
|
| 78 |
+
}]).
|
| 79 |
+
|
| 80 |
+
factory('AddTooltipToElement', ['tooltip', function(tooltip) {
|
| 81 |
+
// when user's mouse hovers over words,
|
| 82 |
+
// delay a period of time before look up.
|
| 83 |
+
var DELAY_INTERVAL = 1000; // ms
|
| 84 |
+
|
| 85 |
+
var isMouseInWord = false;
|
| 86 |
+
|
| 87 |
+
function onWordMouseOver(e) {
|
| 88 |
+
isMouseInWord = true;
|
| 89 |
+
this.style.color = 'red';
|
| 90 |
+
|
| 91 |
+
setTimeout(angular.bind(this, function() {
|
| 92 |
+
// 'this' keyword here refers to raw dom element
|
| 93 |
+
if (this.style.color === 'red') {
|
| 94 |
+
// mouse is still on word
|
| 95 |
+
var word = this.innerHTML.toLowerCase();
|
| 96 |
+
tooltip.setContent(
|
| 97 |
+
word + ' ' + word + '<br>' +
|
| 98 |
+
'<span>' + word + '</span>' + ' ' + word
|
| 99 |
+
);
|
| 100 |
+
tooltip.setPosition({
|
| 101 |
+
'left': (this.getBoundingClientRect().left + 'px'),
|
| 102 |
+
'top': (this.getBoundingClientRect().top + this.offsetHeight + 'px'),
|
| 103 |
+
});
|
| 104 |
+
tooltip.show();
|
| 105 |
+
}
|
| 106 |
+
}), DELAY_INTERVAL);
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
function onWordMouseOut(e) {
|
| 110 |
+
isMouseInWord = false;
|
| 111 |
+
this.style.color = '';
|
| 112 |
+
|
| 113 |
+
setTimeout(angular.bind(this, function() {
|
| 114 |
+
if (!isMouseInWord) {
|
| 115 |
+
tooltip.hide();
|
| 116 |
+
}
|
| 117 |
+
}), DELAY_INTERVAL);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
function add(elm) {
|
| 121 |
+
elm.onmouseover = onWordMouseOver;
|
| 122 |
+
elm.onmouseout = onWordMouseOut;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
var serviceInstance = { add: add };
|
| 126 |
+
return serviceInstance;
|
| 127 |
+
}]);
|
pool/shard004/JavaScript/0026626_cookies.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Cookies.js - 1.0.1
|
| 3 |
+
* https://github.com/ScottHamper/Cookies
|
| 4 |
+
*
|
| 5 |
+
* This is free and unencumbered software released into the public domain.
|
| 6 |
+
*/
|
| 7 |
+
(function (undefined) {
|
| 8 |
+
'use strict';
|
| 9 |
+
|
| 10 |
+
var Cookies = function (key, value, options) {
|
| 11 |
+
return arguments.length === 1 ?
|
| 12 |
+
Cookies.get(key) : Cookies.set(key, value, options);
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
// Allows for setter injection in unit tests
|
| 16 |
+
Cookies._document = document;
|
| 17 |
+
Cookies._navigator = navigator;
|
| 18 |
+
|
| 19 |
+
// Used to ensure cookie keys do not collide with
|
| 20 |
+
// built-in `Object` properties
|
| 21 |
+
Cookies._cacheKeyPrefix = 'cookey.'; // Hurr hurr, :)
|
| 22 |
+
|
| 23 |
+
Cookies.defaults = {
|
| 24 |
+
path: '/',
|
| 25 |
+
secure: false
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
+
Cookies.get = function (key) {
|
| 29 |
+
if (Cookies._cachedDocumentCookie !== Cookies._document.cookie) {
|
| 30 |
+
Cookies._renewCache();
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
return Cookies._cache[Cookies._cacheKeyPrefix + key];
|
| 34 |
+
};
|
| 35 |
+
|
| 36 |
+
Cookies.set = function (key, value, options) {
|
| 37 |
+
options = Cookies._getExtendedOptions(options);
|
| 38 |
+
options.expires = Cookies._getExpiresDate(value === undefined ? -1 : options.expires);
|
| 39 |
+
|
| 40 |
+
Cookies._document.cookie = Cookies._generateCookieString(key, value, options);
|
| 41 |
+
|
| 42 |
+
return Cookies;
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
Cookies.expire = function (key, options) {
|
| 46 |
+
return Cookies.set(key, undefined, options);
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
Cookies._getExtendedOptions = function (options) {
|
| 50 |
+
return {
|
| 51 |
+
path: options && options.path || Cookies.defaults.path,
|
| 52 |
+
domain: options && options.domain || Cookies.defaults.domain,
|
| 53 |
+
expires: options && options.expires || Cookies.defaults.expires,
|
| 54 |
+
secure: options && options.secure !== undefined ? options.secure : Cookies.defaults.secure
|
| 55 |
+
};
|
| 56 |
+
};
|
| 57 |
+
|
| 58 |
+
Cookies._isValidDate = function (date) {
|
| 59 |
+
return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());
|
| 60 |
+
};
|
| 61 |
+
|
| 62 |
+
Cookies._getExpiresDate = function (expires, now) {
|
| 63 |
+
now = now || new Date();
|
| 64 |
+
switch (typeof expires) {
|
| 65 |
+
case 'number': expires = new Date(now.getTime() + expires * 1000); break;
|
| 66 |
+
case 'string': expires = new Date(expires); break;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
if (expires && !Cookies._isValidDate(expires)) {
|
| 70 |
+
throw new Error('`expires` parameter cannot be converted to a valid Date instance');
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
return expires;
|
| 74 |
+
};
|
| 75 |
+
|
| 76 |
+
Cookies._generateCookieString = function (key, value, options) {
|
| 77 |
+
key = key.replace(/[^#$&+\^`|]/g, encodeURIComponent);
|
| 78 |
+
key = key.replace(/\(/g, '%28').replace(/\)/g, '%29');
|
| 79 |
+
value = (value + '').replace(/[^!#$&-+\--:<-\[\]-~]/g, encodeURIComponent);
|
| 80 |
+
options = options || {};
|
| 81 |
+
|
| 82 |
+
var cookieString = key + '=' + value;
|
| 83 |
+
cookieString += options.path ? ';path=' + options.path : '';
|
| 84 |
+
cookieString += options.domain ? ';domain=' + options.domain : '';
|
| 85 |
+
cookieString += options.expires ? ';expires=' + options.expires.toUTCString() : '';
|
| 86 |
+
cookieString += options.secure ? ';secure' : '';
|
| 87 |
+
|
| 88 |
+
return cookieString;
|
| 89 |
+
};
|
| 90 |
+
|
| 91 |
+
Cookies._getCacheFromString = function (documentCookie) {
|
| 92 |
+
var cookieCache = {};
|
| 93 |
+
var cookiesArray = documentCookie ? documentCookie.split('; ') : [];
|
| 94 |
+
|
| 95 |
+
for (var i = 0; i < cookiesArray.length; i++) {
|
| 96 |
+
var cookieKvp = Cookies._getKeyValuePairFromCookieString(cookiesArray[i]);
|
| 97 |
+
|
| 98 |
+
if (cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] === undefined) {
|
| 99 |
+
cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] = cookieKvp.value;
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
return cookieCache;
|
| 104 |
+
};
|
| 105 |
+
|
| 106 |
+
Cookies._getKeyValuePairFromCookieString = function (cookieString) {
|
| 107 |
+
// "=" is a valid character in a cookie value according to RFC6265, so cannot `split('=')`
|
| 108 |
+
var separatorIndex = cookieString.indexOf('=');
|
| 109 |
+
|
| 110 |
+
// IE omits the "=" when the cookie value is an empty string
|
| 111 |
+
separatorIndex = separatorIndex < 0 ? cookieString.length : separatorIndex;
|
| 112 |
+
|
| 113 |
+
return {
|
| 114 |
+
key: decodeURIComponent(cookieString.substr(0, separatorIndex)),
|
| 115 |
+
value: decodeURIComponent(cookieString.substr(separatorIndex + 1))
|
| 116 |
+
};
|
| 117 |
+
};
|
| 118 |
+
|
| 119 |
+
Cookies._renewCache = function () {
|
| 120 |
+
Cookies._cache = Cookies._getCacheFromString(Cookies._document.cookie);
|
| 121 |
+
Cookies._cachedDocumentCookie = Cookies._document.cookie;
|
| 122 |
+
};
|
| 123 |
+
|
| 124 |
+
Cookies._areEnabled = function () {
|
| 125 |
+
var testKey = 'cookies.js';
|
| 126 |
+
var areEnabled = Cookies.set(testKey, 1).get(testKey) === '1';
|
| 127 |
+
Cookies.expire(testKey);
|
| 128 |
+
return areEnabled;
|
| 129 |
+
};
|
| 130 |
+
|
| 131 |
+
Cookies.enabled = Cookies._areEnabled();
|
| 132 |
+
|
| 133 |
+
// AMD support
|
| 134 |
+
if (typeof define === 'function' && define.amd) {
|
| 135 |
+
define(function () { return Cookies; });
|
| 136 |
+
// CommonJS and Node.js module support.
|
| 137 |
+
} else if (typeof exports !== 'undefined') {
|
| 138 |
+
// Support Node.js specific `module.exports` (which can be a function)
|
| 139 |
+
if (typeof module !== 'undefined' && module.exports) {
|
| 140 |
+
exports = module.exports = Cookies;
|
| 141 |
+
}
|
| 142 |
+
// But always support CommonJS module 1.1.1 spec (`exports` cannot be a function)
|
| 143 |
+
exports.Cookies = Cookies;
|
| 144 |
+
} else {
|
| 145 |
+
window.Cookies = Cookies;
|
| 146 |
+
}
|
| 147 |
+
})();
|
pool/shard004/JavaScript/0026631_jobStatistic.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Licensed to the Apache Software Foundation (ASF) under one
|
| 3 |
+
* or more contributor license agreements. See the NOTICE file
|
| 4 |
+
* distributed with this work for additional information
|
| 5 |
+
* regarding copyright ownership. The ASF licenses this file
|
| 6 |
+
* to you under the Apache License, Version 2.0 (the
|
| 7 |
+
* "License"); you may not use this file except in compliance
|
| 8 |
+
* with the License. You may obtain a copy of the License at
|
| 9 |
+
*
|
| 10 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 11 |
+
*
|
| 12 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 13 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 14 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 15 |
+
* See the License for the specific language governing permissions and
|
| 16 |
+
* limitations under the License.
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
(function () {
|
| 20 |
+
/**
|
| 21 |
+
* `register` without params will load the module which using require
|
| 22 |
+
*/
|
| 23 |
+
register(function (jpmApp) {
|
| 24 |
+
jpmApp.directive("jpmWidget", function () {
|
| 25 |
+
return {
|
| 26 |
+
restrict: 'AE',
|
| 27 |
+
controller: function($scope, $interval, Application, JPM, Time) {
|
| 28 |
+
var site = $scope.site;
|
| 29 |
+
var refreshInterval;
|
| 30 |
+
|
| 31 |
+
if(!site) {
|
| 32 |
+
$scope.list = $.map(Application.find("JPM_WEB_APP"), function (app) {
|
| 33 |
+
return {
|
| 34 |
+
siteId: app.site.siteId,
|
| 35 |
+
siteName: app.site.siteName || app.site.siteId,
|
| 36 |
+
count: -1
|
| 37 |
+
};
|
| 38 |
+
});
|
| 39 |
+
} else {
|
| 40 |
+
$scope.list = [{
|
| 41 |
+
siteId: site.siteId,
|
| 42 |
+
siteName: site.siteName || site.siteId,
|
| 43 |
+
count: -1
|
| 44 |
+
}];
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function refresh() {
|
| 48 |
+
$.each($scope.list, function (i, site) {
|
| 49 |
+
var query = JPM.getQuery("GROUPS", site.siteId);
|
| 50 |
+
var url = common.template(query, {
|
| 51 |
+
query: "RunningJobExecutionService",
|
| 52 |
+
condition: '@site="' + site.siteId + '" AND @internalState="RUNNING"',
|
| 53 |
+
groups: "@site",
|
| 54 |
+
field: "count",
|
| 55 |
+
order: "",
|
| 56 |
+
top: "",
|
| 57 |
+
limit: 100000,
|
| 58 |
+
startTime: Time.format(Time().subtract(3, "d")),
|
| 59 |
+
endTime: Time.format(Time().add(1, "d"))
|
| 60 |
+
});
|
| 61 |
+
JPM.get(url).then(function (res) {
|
| 62 |
+
site.count = common.getValueByPath(res, ["data", "obj", 0, "value", 0]);
|
| 63 |
+
});
|
| 64 |
+
});
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
refresh();
|
| 68 |
+
refreshInterval = $interval(refresh, 30 * 1000);
|
| 69 |
+
|
| 70 |
+
$scope.$on('$destroy', function() {
|
| 71 |
+
$interval.cancel(refreshInterval);
|
| 72 |
+
});
|
| 73 |
+
},
|
| 74 |
+
template:
|
| 75 |
+
'<div class="small-box bg-aqua jpm">' +
|
| 76 |
+
'<div class="inner">' +
|
| 77 |
+
'<h3>JPM</h3>' +
|
| 78 |
+
'<p ng-repeat="site in list track by $index">' +
|
| 79 |
+
'<a ui-sref="jpmList({siteId: site.siteId})">' +
|
| 80 |
+
'<strong>{{site.siteName}}</strong>: ' +
|
| 81 |
+
'<span ng-show="site.count === -1" class="fa fa-refresh fa-spin no-animate"></span>' +
|
| 82 |
+
'<span ng-show="site.count !== -1">{{site.count || "N/A"}}</span> Running Jobs' +
|
| 83 |
+
'</a>' +
|
| 84 |
+
'</p>' +
|
| 85 |
+
'</div>' +
|
| 86 |
+
'<div class="icon">' +
|
| 87 |
+
'<i class="fa fa-taxi"></i>' +
|
| 88 |
+
'</div>' +
|
| 89 |
+
'</div>',
|
| 90 |
+
replace: true
|
| 91 |
+
};
|
| 92 |
+
});
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* Customize the widget content. Return false will prevent auto compile.
|
| 96 |
+
* @param {{}} $element
|
| 97 |
+
* @param {function} $element.append
|
| 98 |
+
*/
|
| 99 |
+
function registerWidget($element) {
|
| 100 |
+
$element.append(
|
| 101 |
+
$("<div jpm-widget data-site='site'>")
|
| 102 |
+
);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
jpmApp.widget("jobStatistic", registerWidget);
|
| 106 |
+
jpmApp.widget("jobStatistic", registerWidget, true);
|
| 107 |
+
});
|
| 108 |
+
})();
|
pool/shard004/JavaScript/0026635_editor_plugin.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* editor_plugin_src.js
|
| 3 |
+
*
|
| 4 |
+
* Copyright 2009, Moxiecode Systems AB
|
| 5 |
+
* Released under LGPL License.
|
| 6 |
+
*
|
| 7 |
+
* License: http://tinymce.moxiecode.com/license
|
| 8 |
+
* Contributing: http://tinymce.moxiecode.com/contributing
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
(function() {
|
| 12 |
+
tinymce.create('tinymce.plugins.StylePlugin', {
|
| 13 |
+
init : function(ed, url) {
|
| 14 |
+
// Register commands
|
| 15 |
+
ed.addCommand('mceStyleProps', function() {
|
| 16 |
+
|
| 17 |
+
var applyStyleToBlocks = false;
|
| 18 |
+
var blocks = ed.selection.getSelectedBlocks();
|
| 19 |
+
var styles = [];
|
| 20 |
+
|
| 21 |
+
if (blocks.length === 1) {
|
| 22 |
+
styles.push(ed.selection.getNode().style.cssText);
|
| 23 |
+
}
|
| 24 |
+
else {
|
| 25 |
+
tinymce.each(blocks, function(block) {
|
| 26 |
+
styles.push(ed.dom.getAttrib(block, 'style'));
|
| 27 |
+
});
|
| 28 |
+
applyStyleToBlocks = true;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
ed.windowManager.open({
|
| 32 |
+
file : url + '/props.htm',
|
| 33 |
+
width : 480 + parseInt(ed.getLang('style.delta_width', 0)),
|
| 34 |
+
height : 380 + parseInt(ed.getLang('style.delta_height', 0)),
|
| 35 |
+
inline : 1
|
| 36 |
+
}, {
|
| 37 |
+
applyStyleToBlocks : applyStyleToBlocks,
|
| 38 |
+
plugin_url : url,
|
| 39 |
+
styles : styles
|
| 40 |
+
});
|
| 41 |
+
});
|
| 42 |
+
|
| 43 |
+
ed.addCommand('mceSetElementStyle', function(ui, v) {
|
| 44 |
+
if (e = ed.selection.getNode()) {
|
| 45 |
+
ed.dom.setAttrib(e, 'style', v);
|
| 46 |
+
ed.execCommand('mceRepaint');
|
| 47 |
+
}
|
| 48 |
+
});
|
| 49 |
+
|
| 50 |
+
/*
|
| 51 |
+
ed.on("NodeChange", function(ed, cm, n) {
|
| 52 |
+
cm.setDisabled('styleprops', n.nodeName === 'BODY');
|
| 53 |
+
});
|
| 54 |
+
*/
|
| 55 |
+
|
| 56 |
+
// Register buttons
|
| 57 |
+
ed.addButton(
|
| 58 |
+
'styleprops',
|
| 59 |
+
{
|
| 60 |
+
title : 'style.desc',
|
| 61 |
+
cmd : 'mceStyleProps',
|
| 62 |
+
disabledStateSelector: "body"
|
| 63 |
+
}
|
| 64 |
+
);
|
| 65 |
+
},
|
| 66 |
+
|
| 67 |
+
getInfo : function() {
|
| 68 |
+
return {
|
| 69 |
+
longname : 'Style',
|
| 70 |
+
author : 'Moxiecode Systems AB',
|
| 71 |
+
authorurl : 'http://tinymce.moxiecode.com',
|
| 72 |
+
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/style',
|
| 73 |
+
version : tinymce.majorVersion + "." + tinymce.minorVersion
|
| 74 |
+
};
|
| 75 |
+
}
|
| 76 |
+
});
|
| 77 |
+
|
| 78 |
+
// Register plugin
|
| 79 |
+
tinymce.PluginManager.add('style', tinymce.plugins.StylePlugin);
|
| 80 |
+
})();
|
pool/shard004/JavaScript/0026636_date-format.filter.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function dateFormatFilter() {
|
| 2 |
+
return function dateFormat(oldValue) {
|
| 3 |
+
var newValue;
|
| 4 |
+
|
| 5 |
+
if (oldValue) {
|
| 6 |
+
var year = oldValue.substr(0, 4);
|
| 7 |
+
var month = oldValue.substr(5, 2);
|
| 8 |
+
var day = oldValue.substr(8, 2);
|
| 9 |
+
|
| 10 |
+
newValue = day + '/' + month + '/' + year;
|
| 11 |
+
} else {
|
| 12 |
+
newValue = '-';
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
return newValue;
|
| 16 |
+
};
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
export default dateFormatFilter;
|
pool/shard004/JavaScript/0026638_compareTest.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
describe('compare', function() {
|
| 2 |
+
|
| 3 |
+
var stringA1 = 'hello';
|
| 4 |
+
var stringA2 = 'hello';
|
| 5 |
+
var stringB1 = 'goodbye';
|
| 6 |
+
var arrayA1 = ['a', 'b', 'c'];
|
| 7 |
+
var arrayA2 = ['a', 'b', 'c'];
|
| 8 |
+
var arrayB1 = ['c', 'b', 'a'];
|
| 9 |
+
var objectA1 = {greeting: 'hello', colour: 'red'};
|
| 10 |
+
var objectA2 = {greeting: 'hello', colour: 'red'};
|
| 11 |
+
var objectB1 = {greeting: 'goodbye', colour: 'blue'};
|
| 12 |
+
var objectC1 = {favouriteobject: stringA1, otherobjects: [arrayA1, objectA1]};
|
| 13 |
+
var objectC2 = {favouriteobject: stringA2, otherobjects: [arrayA2, objectA2]};
|
| 14 |
+
var objectD1 = {favouriteobject: stringB1, otherobjects: [arrayB1, objectB1]};
|
| 15 |
+
|
| 16 |
+
runtests = function(object_type, objA1, objA2, objB1) {
|
| 17 |
+
describe(object_type, function() {
|
| 18 |
+
it('should be true for matching ' + object_type, function() {
|
| 19 |
+
expect(Object.objects_equal(objA1, objA1)).toBe(true);
|
| 20 |
+
expect(Object.objects_equal(objA1, objA2)).toBe(true);
|
| 21 |
+
expect(Object.objects_equal(objA2, objA1)).toBe(true);
|
| 22 |
+
});
|
| 23 |
+
it('should be false for ' + object_type + ' that don\'t match', function() {
|
| 24 |
+
expect(Object.objects_equal(objA1, objB1)).toBe(false);
|
| 25 |
+
expect(Object.objects_equal(objA2, objB1)).toBe(false);
|
| 26 |
+
});
|
| 27 |
+
it('should be false for comparison with a null object', function() {
|
| 28 |
+
expect(Object.objects_equal(objA1, null)).toBe(false);
|
| 29 |
+
});
|
| 30 |
+
});
|
| 31 |
+
};
|
| 32 |
+
|
| 33 |
+
runtests('strings', stringA1, stringA2, stringB1);
|
| 34 |
+
runtests('arrays', arrayA1, arrayA2, arrayB1);
|
| 35 |
+
runtests('objects', objectA1, objectA2, objectB1);
|
| 36 |
+
runtests('complex objects', objectA1, objectA2, objectB1);
|
| 37 |
+
|
| 38 |
+
describe('string comparison', function() {
|
| 39 |
+
it('should sort strings alphanumerically', function() {
|
| 40 |
+
expect('a'<'b').toBe(true);
|
| 41 |
+
expect('b'>'a').toBe(true);
|
| 42 |
+
expect('a'>'0').toBe(true);
|
| 43 |
+
expect('a'<'aa').toBe(true);
|
| 44 |
+
expect('b'>'ab').toBe(true);
|
| 45 |
+
expect('a'>'b').toBe(false);
|
| 46 |
+
expect('b'<'a').toBe(false);
|
| 47 |
+
expect('a'<'0').toBe(false);
|
| 48 |
+
expect('a'>'aa').toBe(false);
|
| 49 |
+
expect('b'<'ab').toBe(false);
|
| 50 |
+
})
|
| 51 |
+
})
|
| 52 |
+
describe('array comparison', function() {
|
| 53 |
+
describe('when given two arrays of the same length', function() {
|
| 54 |
+
it('should sort them by sorting each element', function() {
|
| 55 |
+
expect(['a']<['b']).toBe(true);
|
| 56 |
+
expect(['a','c']<['a','d']).toBe(true);
|
| 57 |
+
expect(['b','c']>['a','d']).toBe(true);
|
| 58 |
+
expect([2,'c']>[1,'c']).toBe(true);
|
| 59 |
+
expect(['a']>['b']).toBe(false);
|
| 60 |
+
expect(['a','c']>['a','d']).toBe(false);
|
| 61 |
+
expect(['b','c']<['a','d']).toBe(false);
|
| 62 |
+
expect([2,'c']<[1,'c']).toBe(false);
|
| 63 |
+
})
|
| 64 |
+
})
|
| 65 |
+
})
|
| 66 |
+
|
| 67 |
+
});
|
pool/shard004/JavaScript/0026641_stockData.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
isc.defineClass("FinanceDataSource", "DataSource").addProperties({
|
| 2 |
+
canMultiSort: false,
|
| 3 |
+
allowAdvancedCriteria: false,
|
| 4 |
+
|
| 5 |
+
fields: [
|
| 6 |
+
{ name: "symbol", title: "Symbol" },
|
| 7 |
+
{ name: "date", title: "Date", type: "date" },
|
| 8 |
+
{ name: "open", title: "Open", type: "float" },
|
| 9 |
+
{ name: "high", title: "High", type: "float" },
|
| 10 |
+
{ name: "low", title: "Low", type: "float" },
|
| 11 |
+
{ name: "close", title: "Close", type: "float" },
|
| 12 |
+
{ name: "volume", title: "Volume", type: "float" },
|
| 13 |
+
{ name: "adjClose", title: "Adj Close", type: "float" }
|
| 14 |
+
],
|
| 15 |
+
|
| 16 |
+
handleError : function (response, request) {
|
| 17 |
+
// Suppress RPCManager.handleError() from being called. In the sample,
|
| 18 |
+
// an error label is drawn rather than showing the default warning dialog.
|
| 19 |
+
return false;
|
| 20 |
+
},
|
| 21 |
+
|
| 22 |
+
// Parses the CSV formatted data returned from the server into a list of records.
|
| 23 |
+
_parseData : function (data, symbol) {
|
| 24 |
+
var records = [],
|
| 25 |
+
fields = [],
|
| 26 |
+
len = data.length,
|
| 27 |
+
i = -1, j;
|
| 28 |
+
|
| 29 |
+
// The line separator is "\n" and the value separator is ",".
|
| 30 |
+
while (true) {
|
| 31 |
+
j = data.indexOf("\n", i + 1);
|
| 32 |
+
if (j == -1) j = len;
|
| 33 |
+
|
| 34 |
+
if (j > i + 1) { // Skip consecutive newlines.
|
| 35 |
+
|
| 36 |
+
var record = {}, k = i, l, index = 0;
|
| 37 |
+
while (true) {
|
| 38 |
+
l = Math.min(data.indexOf(",", k + 1), j);
|
| 39 |
+
if (l == -1) l = j;
|
| 40 |
+
|
| 41 |
+
if (i == -1) {
|
| 42 |
+
// The first line is a header:
|
| 43 |
+
// e.g. "Date,Open,High,Low,Close,Volume,Adj Close"
|
| 44 |
+
fields[index] = this.getFieldByTitle(data.substring(k + 1, l));
|
| 45 |
+
|
| 46 |
+
} else {
|
| 47 |
+
var field = fields[index];
|
| 48 |
+
if (field != null) {
|
| 49 |
+
var fieldName = field.name,
|
| 50 |
+
fieldType = field.type,
|
| 51 |
+
value = data.substring(k + 1, l);
|
| 52 |
+
|
| 53 |
+
if (fieldType === "float") {
|
| 54 |
+
record[fieldName] = parseFloat(value);
|
| 55 |
+
} else if (fieldType === "date") {
|
| 56 |
+
// e.g. "2012-07-19" is July 19, 2012
|
| 57 |
+
var year = parseInt(value.substring(0, 4));
|
| 58 |
+
var month = 10 * parseInt(value.charAt(5)) + parseInt(value.charAt(6));
|
| 59 |
+
var day = 10 * parseInt(value.charAt(8)) + parseInt(value.charAt(9));
|
| 60 |
+
record[fieldName] = isc.DateUtil.createLogicalDate(year, month - 1, day);
|
| 61 |
+
} else {
|
| 62 |
+
record[fieldName] = value;
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
if (!(l != -1 && l < j)) break;
|
| 68 |
+
k = l;
|
| 69 |
+
++index;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
if (i != -1) {
|
| 73 |
+
record.symbol = symbol;
|
| 74 |
+
records.push(record);
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
if (!(j != -1 && j < len)) break;
|
| 79 |
+
i = j;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
return records;
|
| 83 |
+
}
|
| 84 |
+
});
|
| 85 |
+
|
| 86 |
+
var stockData = isc.FinanceDataSource.create({
|
| 87 |
+
ID: "stockData",
|
| 88 |
+
dataURL: "http://ichart.finance.yahoo.com/table.csv",
|
| 89 |
+
dataProtocol: "getParams",
|
| 90 |
+
dataFormat: "custom",
|
| 91 |
+
|
| 92 |
+
_months: ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11"],
|
| 93 |
+
|
| 94 |
+
// Options for the query parameter "g":
|
| 95 |
+
_daily: "d",
|
| 96 |
+
_weekly: "w",
|
| 97 |
+
_month: "m",
|
| 98 |
+
_dividendsOnly: "v",
|
| 99 |
+
transformRequest : function (dsRequest) {
|
| 100 |
+
if (dsRequest.operationType === "fetch") {
|
| 101 |
+
var criteria = dsRequest.data,
|
| 102 |
+
symbol = criteria && criteria.symbol;
|
| 103 |
+
|
| 104 |
+
if (symbol == null) return;
|
| 105 |
+
|
| 106 |
+
var to = new Date(),
|
| 107 |
+
from = new Date(to.getFullYear() - 10, to.getMonth(), to.getDate()),
|
| 108 |
+
startMonth = this._months[from.getMonth()],
|
| 109 |
+
startDay = from.getDate(),
|
| 110 |
+
startYear = from.getFullYear(),
|
| 111 |
+
endMonth = this._months[to.getMonth()],
|
| 112 |
+
endDay = to.getDate(),
|
| 113 |
+
endYear = to.getFullYear();
|
| 114 |
+
|
| 115 |
+
dsRequest.clientContext = isc.addProperties({ symbol: symbol }, dsRequest.clientContext);
|
| 116 |
+
|
| 117 |
+
return {
|
| 118 |
+
s: symbol,
|
| 119 |
+
a: startMonth,
|
| 120 |
+
b: startDay,
|
| 121 |
+
c: startYear,
|
| 122 |
+
d: endMonth,
|
| 123 |
+
e: endDay,
|
| 124 |
+
f: endYear,
|
| 125 |
+
g: this._daily,
|
| 126 |
+
ignore: ".csv"
|
| 127 |
+
};
|
| 128 |
+
}
|
| 129 |
+
},
|
| 130 |
+
|
| 131 |
+
transformResponse : function (dsResponse, dsRequest, data) {
|
| 132 |
+
var status = dsResponse.status,
|
| 133 |
+
success = !(dsResponse.status < 0),
|
| 134 |
+
symbol = dsRequest.clientContext.symbol;
|
| 135 |
+
|
| 136 |
+
dsResponse.data = success ? this._parseData(data, symbol) : null;
|
| 137 |
+
dsResponse.status = status;
|
| 138 |
+
delete dsResponse.startRow;
|
| 139 |
+
delete dsResponse.endRow;
|
| 140 |
+
delete dsResponse.totalRows;
|
| 141 |
+
return dsResponse;
|
| 142 |
+
}
|
| 143 |
+
});
|
| 144 |
+
|
| 145 |
+
var staticStockData = isc.FinanceDataSource.create({
|
| 146 |
+
ID: "staticStockData",
|
| 147 |
+
dataProtocol: "clientCustom",
|
| 148 |
+
|
| 149 |
+
transformRequest : function (dsRequest) {
|
| 150 |
+
if (dsRequest.operationType === "fetch") {
|
| 151 |
+
var symbol = dsRequest.data.symbol;
|
| 152 |
+
isc.RPCManager.sendRequest({
|
| 153 |
+
actionURL: isc.Page.getURL("[ISOMORPHIC]/system/reference/inlineExamples/charts/" + symbol + ".txt"),
|
| 154 |
+
willHandleError: true,
|
| 155 |
+
callback : function (rpcResponse, rawData, rpcRequest) {
|
| 156 |
+
var dsResponse = {
|
| 157 |
+
status: rpcResponse.status
|
| 158 |
+
};
|
| 159 |
+
if (!(rpcResponse.status < 0)) {
|
| 160 |
+
data = dsResponse.data = staticStockData._parseData(rawData, symbol);
|
| 161 |
+
}
|
| 162 |
+
staticStockData.processResponse(dsRequest.requestId, dsResponse);
|
| 163 |
+
}
|
| 164 |
+
});
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
});
|
pool/shard004/JavaScript/0026642_adaptation.list_custom_classes.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2021 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
'use strict';
|
| 17 |
+
|
| 18 |
+
function main(parent) {
|
| 19 |
+
// [START speech_v1p1beta1_generated_Adaptation_ListCustomClasses_async]
|
| 20 |
+
/**
|
| 21 |
+
* TODO(developer): Uncomment these variables before running the sample.
|
| 22 |
+
*/
|
| 23 |
+
/**
|
| 24 |
+
* Required. The parent, which owns this collection of custom classes. Format:
|
| 25 |
+
* `projects/{project}/locations/{location}/customClasses`
|
| 26 |
+
* Speech-to-Text supports three locations: `global`, `us` (US North America),
|
| 27 |
+
* and `eu` (Europe). If you are calling the `speech.googleapis.com`
|
| 28 |
+
* endpoint, use the `global` location. To specify a region, use a
|
| 29 |
+
* regional endpoint (/speech-to-text/docs/endpoints) with matching `us` or
|
| 30 |
+
* `eu` location value.
|
| 31 |
+
*/
|
| 32 |
+
// const parent = 'abc123'
|
| 33 |
+
/**
|
| 34 |
+
* The maximum number of custom classes to return. The service may return
|
| 35 |
+
* fewer than this value. If unspecified, at most 50 custom classes will be
|
| 36 |
+
* returned. The maximum value is 1000; values above 1000 will be coerced to
|
| 37 |
+
* 1000.
|
| 38 |
+
*/
|
| 39 |
+
// const pageSize = 1234
|
| 40 |
+
/**
|
| 41 |
+
* A page token, received from a previous `ListCustomClass` call.
|
| 42 |
+
* Provide this to retrieve the subsequent page.
|
| 43 |
+
* When paginating, all other parameters provided to `ListCustomClass` must
|
| 44 |
+
* match the call that provided the page token.
|
| 45 |
+
*/
|
| 46 |
+
// const pageToken = 'abc123'
|
| 47 |
+
|
| 48 |
+
// Imports the Speech library
|
| 49 |
+
const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1;
|
| 50 |
+
|
| 51 |
+
// Instantiates a client
|
| 52 |
+
const speechClient = new AdaptationClient();
|
| 53 |
+
|
| 54 |
+
async function callListCustomClasses() {
|
| 55 |
+
// Construct request
|
| 56 |
+
const request = {
|
| 57 |
+
parent,
|
| 58 |
+
};
|
| 59 |
+
|
| 60 |
+
// Run request
|
| 61 |
+
const iterable = await speechClient.listCustomClassesAsync(request);
|
| 62 |
+
for await (const response of iterable) {
|
| 63 |
+
console.log(response);
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
callListCustomClasses();
|
| 68 |
+
// [END speech_v1p1beta1_generated_Adaptation_ListCustomClasses_async]
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
process.on('unhandledRejection', err => {
|
| 72 |
+
console.error(err.message);
|
| 73 |
+
process.exitCode = 1;
|
| 74 |
+
});
|
| 75 |
+
main(...process.argv.slice(2));
|
pool/shard004/JavaScript/0026644_collision.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var moment = require('moment-timezone'),
|
| 2 |
+
Promise = require('bluebird'),
|
| 3 |
+
_ = require('lodash'),
|
| 4 |
+
errors = require('../../errors');
|
| 5 |
+
|
| 6 |
+
module.exports = function (Bookshelf) {
|
| 7 |
+
var ParentModel = Bookshelf.Model,
|
| 8 |
+
Model;
|
| 9 |
+
|
| 10 |
+
Model = Bookshelf.Model.extend({
|
| 11 |
+
/**
|
| 12 |
+
* Update collision protection.
|
| 13 |
+
*
|
| 14 |
+
* IMPORTANT NOTES:
|
| 15 |
+
* The `sync` method is called for any query e.g. update, add, delete, fetch
|
| 16 |
+
*
|
| 17 |
+
* We had the option to override Bookshelf's `save` method, but hooking into the `sync` method gives us
|
| 18 |
+
* the ability to access the `changed` object. Bookshelf already knows which attributes has changed.
|
| 19 |
+
*
|
| 20 |
+
* Bookshelf's timestamp function can't be overridden, as it's synchronous, there is no way to return an Error.
|
| 21 |
+
*
|
| 22 |
+
* If we want to enable the collision plugin for other tables, the queries might need to run in a transaction.
|
| 23 |
+
* This depends on if we fetch the model before editing. Imagine two concurrent requests come in, both would fetch
|
| 24 |
+
* the same current database values and both would succeed to update and override each other.
|
| 25 |
+
*/
|
| 26 |
+
sync: function timestamp(options) {
|
| 27 |
+
var parentSync = ParentModel.prototype.sync.apply(this, arguments),
|
| 28 |
+
originalUpdateSync = parentSync.update,
|
| 29 |
+
self = this;
|
| 30 |
+
|
| 31 |
+
// CASE: only enabled for posts table
|
| 32 |
+
if (this.tableName !== 'posts' ||
|
| 33 |
+
!self.serverData ||
|
| 34 |
+
((options.method !== 'update' && options.method !== 'patch') || !options.method)
|
| 35 |
+
) {
|
| 36 |
+
return parentSync;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* Only hook into the update sync
|
| 41 |
+
*
|
| 42 |
+
* IMPORTANT NOTES:
|
| 43 |
+
* Even if the client sends a different `id` property, it get's ignored by bookshelf.
|
| 44 |
+
* Because you can't change the `id` of an existing post.
|
| 45 |
+
*
|
| 46 |
+
* HTML is always auto generated, ignore.
|
| 47 |
+
*/
|
| 48 |
+
parentSync.update = function update() {
|
| 49 |
+
var changed = _.omit(self.changed, [
|
| 50 |
+
'created_at', 'updated_at', 'author_id', 'id',
|
| 51 |
+
'published_by', 'updated_by', 'html', 'plaintext'
|
| 52 |
+
]),
|
| 53 |
+
clientUpdatedAt = moment(self.clientData.updated_at || self.serverData.updated_at || new Date()),
|
| 54 |
+
serverUpdatedAt = moment(self.serverData.updated_at || clientUpdatedAt);
|
| 55 |
+
|
| 56 |
+
if (Object.keys(changed).length) {
|
| 57 |
+
if (clientUpdatedAt.diff(serverUpdatedAt) !== 0) {
|
| 58 |
+
return Promise.reject(new errors.InternalServerError({
|
| 59 |
+
message: 'Saving failed! Someone else is editing this post.',
|
| 60 |
+
code: 'UPDATE_COLLISION'
|
| 61 |
+
}));
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
return originalUpdateSync.apply(this, arguments);
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
return parentSync;
|
| 69 |
+
},
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* We have to remember current server data and client data.
|
| 73 |
+
* The `sync` method has no access to it.
|
| 74 |
+
* `updated_at` is already set to "Date.now" when the overridden `sync.update` is called.
|
| 75 |
+
* See https://github.com/tgriesser/bookshelf/blob/79c526870e618748caf94e7476a0bc796ee090a6/src/model.js#L955
|
| 76 |
+
*/
|
| 77 |
+
save: function save(data) {
|
| 78 |
+
this.clientData = _.cloneDeep(data) || {};
|
| 79 |
+
this.serverData = _.cloneDeep(this.attributes);
|
| 80 |
+
|
| 81 |
+
return ParentModel.prototype.save.apply(this, arguments);
|
| 82 |
+
}
|
| 83 |
+
});
|
| 84 |
+
|
| 85 |
+
Bookshelf.Model = Model;
|
| 86 |
+
};
|
pool/shard004/JavaScript/0026645_card-poster.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var load = require('../../js/lib/load');
|
| 2 |
+
var notice = require('../component/notice');
|
| 3 |
+
var crop= require('./card-poster-crop');
|
| 4 |
+
var uploader;
|
| 5 |
+
|
| 6 |
+
function PageView() {
|
| 7 |
+
this.init();
|
| 8 |
+
};
|
| 9 |
+
|
| 10 |
+
PageView.prototype.init = function() {
|
| 11 |
+
load('//cdn.bootcss.com/plupload/2.1.7/plupload.full.min.js', function() {
|
| 12 |
+
fileupload();
|
| 13 |
+
});
|
| 14 |
+
};
|
| 15 |
+
|
| 16 |
+
PageView.prototype.close = function() {
|
| 17 |
+
uploader.destroy();
|
| 18 |
+
crop.destroy();
|
| 19 |
+
};
|
| 20 |
+
|
| 21 |
+
function fileupload() {
|
| 22 |
+
var domain = $('#domain').val();
|
| 23 |
+
|
| 24 |
+
uploader = new plupload.Uploader({
|
| 25 |
+
runtimes : 'html5,flash,html4',
|
| 26 |
+
browse_button : 'pickfile',
|
| 27 |
+
max_file_size : '4mb',
|
| 28 |
+
|
| 29 |
+
// Fake server response here
|
| 30 |
+
url: "http://upload.qiniu.com/",
|
| 31 |
+
|
| 32 |
+
flash_swf_url : '/js/plupload/Moxie.swf',
|
| 33 |
+
filters : [
|
| 34 |
+
{title : "Image files", extensions : "jpg,gif,png"},
|
| 35 |
+
],
|
| 36 |
+
multipart_params: {
|
| 37 |
+
token: $('#uptoken').val()
|
| 38 |
+
},
|
| 39 |
+
|
| 40 |
+
init: {
|
| 41 |
+
PostInit: function() {
|
| 42 |
+
$('filelist').innerHTML = '';
|
| 43 |
+
|
| 44 |
+
$('uploadfiles').onclick = function() {
|
| 45 |
+
uploader.start();
|
| 46 |
+
return false;
|
| 47 |
+
};
|
| 48 |
+
},
|
| 49 |
+
|
| 50 |
+
FilesAdded: function(up, files) {
|
| 51 |
+
uploader.start();
|
| 52 |
+
$('.upload-progress').show();
|
| 53 |
+
$('.image-preview').removeClass('image-bg');
|
| 54 |
+
},
|
| 55 |
+
|
| 56 |
+
UploadProgress: function(up, file) {
|
| 57 |
+
$('.upload-progress .bar').css('width', file.percent + '%');
|
| 58 |
+
},
|
| 59 |
+
|
| 60 |
+
FileUploaded: function(up, file, info) {
|
| 61 |
+
var res = $.parseJSON(info.response);
|
| 62 |
+
var img = new Image();
|
| 63 |
+
img.onload = function() {
|
| 64 |
+
$('.image-preview').addClass('image-bg');
|
| 65 |
+
$('#poster-preview').attr('src', this.src);
|
| 66 |
+
$('#imagePreview').attr('src', this.src);
|
| 67 |
+
$('#saveCrop').removeClass('disabled');
|
| 68 |
+
crop.reload(this.src);
|
| 69 |
+
}
|
| 70 |
+
img.src = domain + res.key;
|
| 71 |
+
|
| 72 |
+
setTimeout(function() {
|
| 73 |
+
$('.upload-progress').find('.bar').css('width', '1%').end().hide();
|
| 74 |
+
}, 500);
|
| 75 |
+
},
|
| 76 |
+
|
| 77 |
+
Error: function(up, err) {
|
| 78 |
+
notice.alert(err.message);
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
uploader.init();
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
module.exports = PageView;
|
pool/shard004/JavaScript/0026649_markdownFilter.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function (angular) {
|
| 2 |
+
|
| 3 |
+
'use strict';
|
| 4 |
+
|
| 5 |
+
angular.module('birdyard.utilities')
|
| 6 |
+
|
| 7 |
+
.directive('markdownFilter', ['$timeout', 'markdownFilterService', function($timeout, markdownFilterService) {
|
| 8 |
+
|
| 9 |
+
return {
|
| 10 |
+
restrict: 'A',
|
| 11 |
+
replace: false,
|
| 12 |
+
link: function (scope, element, attrs) {
|
| 13 |
+
$timeout(function () {
|
| 14 |
+
var limit = parseInt(attrs['markdownFilter'], 10) || 0;
|
| 15 |
+
var text = element.text();
|
| 16 |
+
var filtered = markdownFilterService.filter(text);
|
| 17 |
+
var limited = (limit) ? filtered.slice(0, limit) : filtered;
|
| 18 |
+
element.text(limited);
|
| 19 |
+
});
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
}]);
|
| 23 |
+
})(angular);
|
pool/shard004/JavaScript/0026651_1012101.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
/*
|
| 23 |
+
玛亚
|
| 24 |
+
*/
|
| 25 |
+
|
| 26 |
+
var status = 0;
|
| 27 |
+
|
| 28 |
+
function start() {
|
| 29 |
+
status = -1;
|
| 30 |
+
action(1, 0, 0);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
function action(mode, type, selection) {
|
| 34 |
+
if (mode == -1) {
|
| 35 |
+
cm.dispose();
|
| 36 |
+
} else {
|
| 37 |
+
if (mode == 1)
|
| 38 |
+
status++;
|
| 39 |
+
else
|
| 40 |
+
status--;
|
| 41 |
+
if (status == 0) {
|
| 42 |
+
cm.sendNext("你找我有事么?如果你足够强大的话,可以看看任务面板!");
|
| 43 |
+
} else if (status == 1) {
|
| 44 |
+
cm.sendOk("任务面板没有任务的话,那赶紧去升级吧!");
|
| 45 |
+
cm.dispose();
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
}
|
pool/shard004/JavaScript/0026653_includes.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var assert = require("chai").assert;
|
| 2 |
+
var crossbow = require("../../index");
|
| 3 |
+
|
| 4 |
+
describe("Doing includes", function() {
|
| 5 |
+
|
| 6 |
+
it("Add 1 page & compile with includes", function(done) {
|
| 7 |
+
|
| 8 |
+
var site = crossbow.builder({
|
| 9 |
+
config: {
|
| 10 |
+
base: "test/fixtures"
|
| 11 |
+
},
|
| 12 |
+
errorHandler: function (err) {
|
| 13 |
+
console.log(err);
|
| 14 |
+
}
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
var item = site.add({key: "src/docs/index.html", content: "{{inc src='button.html' name='kittie'}}"});
|
| 18 |
+
|
| 19 |
+
site.freeze();
|
| 20 |
+
|
| 21 |
+
site.compile({
|
| 22 |
+
item: item,
|
| 23 |
+
cb: function (err, out) {
|
| 24 |
+
assert.include(out.get("compiled"), "<button>kittie Button</button>");
|
| 25 |
+
done();
|
| 26 |
+
}
|
| 27 |
+
});
|
| 28 |
+
});
|
| 29 |
+
|
| 30 |
+
it("Add 1 page & compile with includes in simple mode", function(done) {
|
| 31 |
+
|
| 32 |
+
crossbow.compile({
|
| 33 |
+
config: {
|
| 34 |
+
base: "test/fixtures"
|
| 35 |
+
},
|
| 36 |
+
key: "src/docs/index.html",
|
| 37 |
+
content: "{{inc src='button.html' name='kittie'}}",
|
| 38 |
+
cb: function (err, out) {
|
| 39 |
+
assert.include(out.get("compiled"), "<button>kittie Button</button>");
|
| 40 |
+
done();
|
| 41 |
+
}
|
| 42 |
+
});
|
| 43 |
+
});
|
| 44 |
+
|
| 45 |
+
it("Add 1 page & compile without markdown", function(done) {
|
| 46 |
+
|
| 47 |
+
var site = crossbow.builder({
|
| 48 |
+
config: {
|
| 49 |
+
base: "test/fixtures"
|
| 50 |
+
},
|
| 51 |
+
errorHandler: function (err) {
|
| 52 |
+
console.log(err);
|
| 53 |
+
}
|
| 54 |
+
});
|
| 55 |
+
|
| 56 |
+
var item = site.add({key: "src/docs/index.html", content: "This is not a P"});
|
| 57 |
+
|
| 58 |
+
site.freeze();
|
| 59 |
+
|
| 60 |
+
site.compile({
|
| 61 |
+
item: item,
|
| 62 |
+
cb: function (err, out) {
|
| 63 |
+
assert.notInclude(out.get("compiled"), "<p>This is not a P</p>");
|
| 64 |
+
assert.include(out.get("compiled"), "This is not a P");
|
| 65 |
+
done();
|
| 66 |
+
}
|
| 67 |
+
});
|
| 68 |
+
});
|
| 69 |
+
|
| 70 |
+
it("Does an include with a HL filter", function(done) {
|
| 71 |
+
|
| 72 |
+
var site = crossbow.builder({
|
| 73 |
+
config: {
|
| 74 |
+
base: "test/fixtures"
|
| 75 |
+
}
|
| 76 |
+
});
|
| 77 |
+
|
| 78 |
+
var item = site.add({key: "src/docs/index.html", content: "{{inc src='_includes/button.html' filter='hl'}}"});
|
| 79 |
+
|
| 80 |
+
site.freeze();
|
| 81 |
+
|
| 82 |
+
site.compile({
|
| 83 |
+
item: item,
|
| 84 |
+
cb: function (err, out) {
|
| 85 |
+
assert.include(out.get("compiled"), '<code class="html"><span class="hljs-tag"><<span'); // jshint ignore:line
|
| 86 |
+
done();
|
| 87 |
+
}
|
| 88 |
+
});
|
| 89 |
+
});
|
| 90 |
+
it("Does an include with a MD filter", function(done) {
|
| 91 |
+
|
| 92 |
+
var site = crossbow.builder({
|
| 93 |
+
config: {
|
| 94 |
+
base: "test/fixtures",
|
| 95 |
+
errorHandler: function (err) {
|
| 96 |
+
console.log(err);
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
});
|
| 100 |
+
|
| 101 |
+
var item = site.add({key: "src/docs/index.html", content: "{{inc src='markdown' filter='md'}}"});
|
| 102 |
+
|
| 103 |
+
site.freeze();
|
| 104 |
+
|
| 105 |
+
site.compile({
|
| 106 |
+
item: item,
|
| 107 |
+
cb: function (err, out) {
|
| 108 |
+
if (err) {
|
| 109 |
+
return done(err);
|
| 110 |
+
}
|
| 111 |
+
//console.log(out.get("compiled"));
|
| 112 |
+
//assert.include(out.get("compiled"), 'This is a title</h2>'); // jshint ignore:line
|
| 113 |
+
done();
|
| 114 |
+
}
|
| 115 |
+
});
|
| 116 |
+
});
|
| 117 |
+
it("includes with correct context", function (done) {
|
| 118 |
+
|
| 119 |
+
var site = crossbow.builder({
|
| 120 |
+
config: {
|
| 121 |
+
base: "test/fixtures"
|
| 122 |
+
},
|
| 123 |
+
data: {
|
| 124 |
+
buttons: ["one", "two"],
|
| 125 |
+
site: {
|
| 126 |
+
title: "Crossbow"
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
});
|
| 130 |
+
|
| 131 |
+
var item = site.add({key: "src/docs/index.html", content: ":{{#each buttons}}{{inc src='context.html' title='Param title'}}{{/each}}:"});
|
| 132 |
+
|
| 133 |
+
site.freeze();
|
| 134 |
+
|
| 135 |
+
site.compile({
|
| 136 |
+
item: item,
|
| 137 |
+
cb: function (err, out) {
|
| 138 |
+
var compiled = out.get("compiled");
|
| 139 |
+
assert.include(compiled, "Site Title: Crossbow");
|
| 140 |
+
assert.include(compiled, "Page Url: /src/docs/index.html");
|
| 141 |
+
assert.include(compiled, "Param Title: Param title");
|
| 142 |
+
done();
|
| 143 |
+
}
|
| 144 |
+
});
|
| 145 |
+
});
|
| 146 |
+
});
|
pool/shard004/JavaScript/0026654_adff06c4cdf63693395a023ef358c3d9b77cceb1.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var autoprefixer = require('autoprefixer');
|
| 3 |
+
var cssnano = require('cssnano');
|
| 4 |
+
var gulp = require('gulp');
|
| 5 |
+
var gulpLoadPlugins = require('gulp-load-plugins');
|
| 6 |
+
var merge = require('merge-stream');
|
| 7 |
+
var util = require('gulp-util');
|
| 8 |
+
var path_1 = require('path');
|
| 9 |
+
var config_1 = require('../../config');
|
| 10 |
+
var plugins = gulpLoadPlugins();
|
| 11 |
+
var cleanCss = require('gulp-clean-css');
|
| 12 |
+
var gulpConcatCssConfig = config_1.default.getPluginConfig('gulp-concat-css');
|
| 13 |
+
var processors = [
|
| 14 |
+
autoprefixer({
|
| 15 |
+
browsers: config_1.default.BROWSER_LIST
|
| 16 |
+
})
|
| 17 |
+
];
|
| 18 |
+
var reportPostCssError = function (e) { return util.log(util.colors.red(e.message)); };
|
| 19 |
+
var isProd = config_1.default.ENV === 'prod';
|
| 20 |
+
if (isProd) {
|
| 21 |
+
processors.push(cssnano({
|
| 22 |
+
discardComments: { removeAll: true },
|
| 23 |
+
discardUnused: false,
|
| 24 |
+
zindex: false,
|
| 25 |
+
reduceIdents: false
|
| 26 |
+
}));
|
| 27 |
+
}
|
| 28 |
+
function prepareTemplates() {
|
| 29 |
+
return gulp.src(path_1.join(config_1.default.APP_SRC, '**', '*.html'))
|
| 30 |
+
.pipe(gulp.dest(config_1.default.TMP_DIR));
|
| 31 |
+
}
|
| 32 |
+
function processComponentStylesheets() {
|
| 33 |
+
return config_1.default.ENABLE_SCSS ? processComponentScss() : processComponentCss();
|
| 34 |
+
}
|
| 35 |
+
function processComponentScss() {
|
| 36 |
+
return gulp.src(path_1.join(config_1.default.APP_SRC, '**', '*.scss'))
|
| 37 |
+
.pipe(isProd ? plugins.cached('process-component-scss') : plugins.util.noop())
|
| 38 |
+
.pipe(isProd ? plugins.progeny() : plugins.util.noop())
|
| 39 |
+
.pipe(plugins.sourcemaps.init())
|
| 40 |
+
.pipe(plugins.sass(config_1.default.getPluginConfig('gulp-sass')).on('error', plugins.sass.logError))
|
| 41 |
+
.pipe(plugins.postcss(processors))
|
| 42 |
+
.on('error', reportPostCssError)
|
| 43 |
+
.pipe(plugins.sourcemaps.write(isProd ? '.' : ''))
|
| 44 |
+
.pipe(gulp.dest(isProd ? config_1.default.TMP_DIR : config_1.default.APP_DEST));
|
| 45 |
+
}
|
| 46 |
+
function processComponentCss() {
|
| 47 |
+
return gulp.src([
|
| 48 |
+
path_1.join(config_1.default.APP_SRC, '**', '*.css'),
|
| 49 |
+
'!' + path_1.join(config_1.default.APP_SRC, 'assets', '**', '*.css')
|
| 50 |
+
])
|
| 51 |
+
.pipe(isProd ? plugins.cached('process-component-css') : plugins.util.noop())
|
| 52 |
+
.pipe(plugins.postcss(processors))
|
| 53 |
+
.on('error', reportPostCssError)
|
| 54 |
+
.pipe(gulp.dest(isProd ? config_1.default.TMP_DIR : config_1.default.APP_DEST));
|
| 55 |
+
}
|
| 56 |
+
function processExternalStylesheets() {
|
| 57 |
+
return config_1.default.ENABLE_SCSS ? processAllExternalStylesheets() : processExternalCss();
|
| 58 |
+
}
|
| 59 |
+
function processAllExternalStylesheets() {
|
| 60 |
+
return merge(getExternalCssStream(), getExternalScssStream())
|
| 61 |
+
.pipe(isProd ? plugins.concatCss(gulpConcatCssConfig.targetFile, gulpConcatCssConfig.options) : plugins.util.noop())
|
| 62 |
+
.pipe(plugins.postcss(processors))
|
| 63 |
+
.on('error', reportPostCssError)
|
| 64 |
+
.pipe(isProd ? cleanCss() : plugins.util.noop())
|
| 65 |
+
.pipe(gulp.dest(config_1.default.CSS_DEST));
|
| 66 |
+
}
|
| 67 |
+
function getExternalCssStream() {
|
| 68 |
+
return gulp.src(getExternalCss())
|
| 69 |
+
.pipe(isProd ? plugins.cached('process-external-css') : plugins.util.noop());
|
| 70 |
+
}
|
| 71 |
+
function getExternalCss() {
|
| 72 |
+
return config_1.default.DEPENDENCIES.filter(function (dep) { return /\.css$/.test(dep.src); }).map(function (dep) { return dep.src; });
|
| 73 |
+
}
|
| 74 |
+
function getExternalScssStream() {
|
| 75 |
+
return gulp.src(getExternalScss())
|
| 76 |
+
.pipe(isProd ? plugins.cached('process-external-scss') : plugins.util.noop())
|
| 77 |
+
.pipe(isProd ? plugins.progeny() : plugins.util.noop())
|
| 78 |
+
.pipe(plugins.sass(config_1.default.getPluginConfig('gulp-sass')).on('error', plugins.sass.logError));
|
| 79 |
+
}
|
| 80 |
+
function getExternalScss() {
|
| 81 |
+
return config_1.default.DEPENDENCIES.filter(function (dep) { return /\.scss$/.test(dep.src); }).map(function (dep) { return dep.src; })
|
| 82 |
+
.concat([path_1.join(config_1.default.CSS_SRC, '**', '*.scss')]);
|
| 83 |
+
}
|
| 84 |
+
function processExternalCss() {
|
| 85 |
+
return getExternalCssStream()
|
| 86 |
+
.pipe(plugins.postcss(processors))
|
| 87 |
+
.pipe(isProd ? plugins.concatCss(gulpConcatCssConfig.targetFile, gulpConcatCssConfig.options) : plugins.util.noop())
|
| 88 |
+
.on('error', reportPostCssError)
|
| 89 |
+
.pipe(isProd ? cleanCss() : plugins.util.noop())
|
| 90 |
+
.pipe(gulp.dest(config_1.default.CSS_DEST));
|
| 91 |
+
}
|
| 92 |
+
module.exports = function () { return merge(processComponentStylesheets(), prepareTemplates(), processExternalStylesheets()); };
|
| 93 |
+
//# sourceMappingURL=/var/www/html/s3b4a2/ts-node/d945a700a6de3ebc7d7e631a73475997a3f6f55f/adff06c4cdf63693395a023ef358c3d9b77cceb1.js.map
|
pool/shard004/JavaScript/0026656_source-map.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
var _classCallCheck = require("babel-runtime/helpers/class-call-check")["default"];
|
| 4 |
+
|
| 5 |
+
var _interopRequireDefault = require("babel-runtime/helpers/interop-require-default")["default"];
|
| 6 |
+
|
| 7 |
+
var _interopRequireWildcard = require("babel-runtime/helpers/interop-require-wildcard")["default"];
|
| 8 |
+
|
| 9 |
+
exports.__esModule = true;
|
| 10 |
+
|
| 11 |
+
var _sourceMap = require("source-map");
|
| 12 |
+
|
| 13 |
+
var _sourceMap2 = _interopRequireDefault(_sourceMap);
|
| 14 |
+
|
| 15 |
+
var _babelTypes = require("babel-types");
|
| 16 |
+
|
| 17 |
+
var t = _interopRequireWildcard(_babelTypes);
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Build a sourcemap.
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
var SourceMap = (function () {
|
| 24 |
+
function SourceMap(position, opts, code) {
|
| 25 |
+
_classCallCheck(this, SourceMap);
|
| 26 |
+
|
| 27 |
+
this.position = position;
|
| 28 |
+
this.opts = opts;
|
| 29 |
+
|
| 30 |
+
if (opts.sourceMaps) {
|
| 31 |
+
this.map = new _sourceMap2["default"].SourceMapGenerator({
|
| 32 |
+
file: opts.sourceMapTarget,
|
| 33 |
+
sourceRoot: opts.sourceRoot
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
this.map.setSourceContent(opts.sourceFileName, code);
|
| 37 |
+
} else {
|
| 38 |
+
this.map = null;
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Get the sourcemap.
|
| 44 |
+
*/
|
| 45 |
+
|
| 46 |
+
SourceMap.prototype.get = function get() {
|
| 47 |
+
var map = this.map;
|
| 48 |
+
if (map) {
|
| 49 |
+
return map.toJSON();
|
| 50 |
+
} else {
|
| 51 |
+
return map;
|
| 52 |
+
}
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Mark a node's generated position, and add it to the sourcemap.
|
| 57 |
+
*/
|
| 58 |
+
|
| 59 |
+
SourceMap.prototype.mark = function mark(node, type) {
|
| 60 |
+
var loc = node.loc;
|
| 61 |
+
if (!loc) return; // no location info
|
| 62 |
+
|
| 63 |
+
var map = this.map;
|
| 64 |
+
if (!map) return; // no source map
|
| 65 |
+
|
| 66 |
+
if (t.isProgram(node) || t.isFile(node)) return; // illegal mapping nodes
|
| 67 |
+
|
| 68 |
+
var position = this.position;
|
| 69 |
+
|
| 70 |
+
var generated = {
|
| 71 |
+
line: position.line,
|
| 72 |
+
column: position.column
|
| 73 |
+
};
|
| 74 |
+
|
| 75 |
+
var original = loc[type];
|
| 76 |
+
|
| 77 |
+
map.addMapping({
|
| 78 |
+
source: this.opts.sourceFileName,
|
| 79 |
+
generated: generated,
|
| 80 |
+
original: original
|
| 81 |
+
});
|
| 82 |
+
};
|
| 83 |
+
|
| 84 |
+
return SourceMap;
|
| 85 |
+
})();
|
| 86 |
+
|
| 87 |
+
exports["default"] = SourceMap;
|
| 88 |
+
module.exports = exports["default"];
|
pool/shard004/JavaScript/0026659_css-toggle.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function () {
|
| 2 |
+
'use strict';
|
| 3 |
+
describe('Testing css-toggle', function () {
|
| 4 |
+
var constants;
|
| 5 |
+
beforeEach(function () {
|
| 6 |
+
module('Tombola.NoughtAndCrosses.cssSelection');
|
| 7 |
+
inject(function ($injector) {
|
| 8 |
+
constants = $injector.get('cssToggle');
|
| 9 |
+
});
|
| 10 |
+
});
|
| 11 |
+
|
| 12 |
+
it('Ensures the default css is main.css', function () {
|
| 13 |
+
constants.cssStyle.should.equal('main.css');
|
| 14 |
+
});
|
| 15 |
+
|
| 16 |
+
it('Ensures that toggling the css will result in altSkin.css', function () {
|
| 17 |
+
constants.toggleCss();
|
| 18 |
+
constants.cssStyle.should.equal('altSkin.css');
|
| 19 |
+
});
|
| 20 |
+
|
| 21 |
+
it('Ensures that toggling two times will put the css back to main.css', function () {
|
| 22 |
+
constants.toggleCss();
|
| 23 |
+
constants.toggleCss();
|
| 24 |
+
constants.cssStyle.should.equal('main.css');
|
| 25 |
+
});
|
| 26 |
+
});
|
| 27 |
+
})();
|