Upload folder using huggingface_hub (part 124)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- pool/shard011/JavaScript/0070299_playground.js +64 -0
- pool/shard011/JavaScript/0070300_Images.react.js +48 -0
- pool/shard011/JavaScript/0070301_star-rating-test.js +125 -0
- pool/shard011/JavaScript/0070302_config.js +134 -0
- pool/shard011/JavaScript/0070304_tools.js +83 -0
- pool/shard011/JavaScript/0070306_index.js +89 -0
- pool/shard011/JavaScript/0070308_progress.js +33 -0
- pool/shard011/JavaScript/0070309_setup.js +30 -0
- pool/shard011/JavaScript/0070311_step3_controller.js +158 -0
- pool/shard011/JavaScript/0070313_post_draft.test.js +150 -0
- pool/shard011/JavaScript/0070314_index.js +26 -0
- pool/shard011/JavaScript/0070320_cohorts.js +272 -0
- pool/shard011/JavaScript/0070325_tr.js +51 -0
- pool/shard011/JavaScript/0070328_params.js +171 -0
- pool/shard011/JavaScript/0070330_idempotency.spec.js +156 -0
- pool/shard011/JavaScript/0070333_a.js +26 -0
- pool/shard011/JavaScript/0070334_script.js +12 -0
- pool/shard011/JavaScript/0070335_express.js +102 -0
- pool/shard011/JavaScript/0070336_index.js +55 -0
- pool/shard011/JavaScript/0070337_utils.js +135 -0
- pool/shard011/JavaScript/0070338_cMosca.js +114 -0
- pool/shard011/JavaScript/0070339_main-resource-test.js +74 -0
- pool/shard011/JavaScript/0070340_WFSService.js +167 -0
- pool/shard011/JavaScript/0070341_routes.js +57 -0
- pool/shard011/JavaScript/0070344_worker.js +53 -0
- pool/shard011/JavaScript/0070348_not-equal-email-domain.js +45 -0
- pool/shard011/JavaScript/0070350_file.js +262 -0
- pool/shard011/JavaScript/0070351_app.js +34 -0
- pool/shard011/JavaScript/0070352_calendars-service.spec.js +107 -0
- pool/shard011/JavaScript/0070360_Leg.js +51 -0
- pool/shard011/JavaScript/0070364_handler.js +176 -0
- pool/shard011/JavaScript/0070365_Tags.js +74 -0
- pool/shard011/JavaScript/0070366_getNotifications.js +40 -0
- pool/shard011/JavaScript/0070373_form.js +141 -0
- pool/shard011/JavaScript/0070375_Gruntfile.js +17 -0
- pool/shard011/JavaScript/0070376_util.js +49 -0
- pool/shard011/JavaScript/0070378_find.js +47 -0
- pool/shard011/JavaScript/0070394_mobile_operator.js +96 -0
- pool/shard011/JavaScript/0070396_eachs.js +102 -0
- pool/shard011/JavaScript/0070398_fs.js +17 -0
- pool/shard011/JavaScript/0070399_list-elem.js +61 -0
- pool/shard011/JavaScript/0070400_Provider.js +103 -0
- pool/shard011/JavaScript/0070407_blip-assistant.js +305 -0
- pool/shard011/JavaScript/0070410_eserveri.js +52 -0
- pool/shard011/JavaScript/0070413_js.js +29 -0
- pool/shard011/JavaScript/0070414_md023.js +38 -0
- pool/shard011/JavaScript/0070415_tab.js +155 -0
- pool/shard011/JavaScript/0070416_sigV4Client.js +220 -0
- pool/shard011/JavaScript/0070417_app.js +140 -0
- pool/shard011/JavaScript/0070418_Cordova.js +90 -0
pool/shard011/JavaScript/0070299_playground.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const memoryFS = require("memory-fs");
|
| 2 |
+
const cloneDeep = require("lodash.clonedeep");
|
| 3 |
+
|
| 4 |
+
const webpackConfigurations = require("./webpack.config.shared");
|
| 5 |
+
|
| 6 |
+
const compile = (webpackEngine, config, fs) => {
|
| 7 |
+
const compiler = webpackEngine(cloneDeep(config));
|
| 8 |
+
compiler.outputFileSystem = fs;
|
| 9 |
+
return new Promise((resolve, reject) => {
|
| 10 |
+
compiler.run((err, stats) => {
|
| 11 |
+
if (err || stats.hasErrors()) {
|
| 12 |
+
reject(new Error(err || stats.compilation.errors));
|
| 13 |
+
}
|
| 14 |
+
const code = fs
|
| 15 |
+
.readFileSync(`${webpackConfigurations.buildPath}/main.js`)
|
| 16 |
+
.toString();
|
| 17 |
+
console.log(code);
|
| 18 |
+
// eval(code);
|
| 19 |
+
resolve();
|
| 20 |
+
});
|
| 21 |
+
});
|
| 22 |
+
};
|
| 23 |
+
|
| 24 |
+
const compileWithWebpackVersion = (webpackVersion, configName) =>
|
| 25 |
+
compile(
|
| 26 |
+
require(`../${webpackVersion}/node_modules/webpack`),
|
| 27 |
+
{
|
| 28 |
+
mode: "development",
|
| 29 |
+
entry: {
|
| 30 |
+
main: "./test/common/src/index.js"
|
| 31 |
+
},
|
| 32 |
+
output: {
|
| 33 |
+
filename: "[name].js",
|
| 34 |
+
chunkFilename: "[name].js",
|
| 35 |
+
publicPath: "originalPublicPath/",
|
| 36 |
+
path: webpackConfigurations.buildPath
|
| 37 |
+
},
|
| 38 |
+
module: {
|
| 39 |
+
rules: [
|
| 40 |
+
{
|
| 41 |
+
test: /index\.js$/,
|
| 42 |
+
use: {
|
| 43 |
+
loader: path.resolve(
|
| 44 |
+
`test/${webpackVersion}/node_modules/worker-loader`
|
| 45 |
+
)
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
]
|
| 49 |
+
},
|
| 50 |
+
plugins: [
|
| 51 |
+
new WebpackRequireFrom({
|
| 52 |
+
path: "staticPath/"
|
| 53 |
+
})
|
| 54 |
+
]
|
| 55 |
+
},
|
| 56 |
+
new memoryFS()
|
| 57 |
+
);
|
| 58 |
+
|
| 59 |
+
(async function run() {
|
| 60 |
+
await compileWithWebpackVersion(
|
| 61 |
+
"webpack4",
|
| 62 |
+
"replaceSrcMethodName_pluginConf"
|
| 63 |
+
);
|
| 64 |
+
})();
|
pool/shard011/JavaScript/0070300_Images.react.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const React = require('react');
|
| 2 |
+
|
| 3 |
+
const Row = require('react-bootstrap/lib/row');
|
| 4 |
+
const Col = require('react-bootstrap/lib/Col');
|
| 5 |
+
const logs = require('../utilities/logsMixin');
|
| 6 |
+
|
| 7 |
+
var imgArray = ["./img/sf1.jpg", "./img/sf2.jpg", "./img/sf3.jpg", "./img/sf4.jpg"]
|
| 8 |
+
|
| 9 |
+
const imageStyle ={
|
| 10 |
+
width: "100%",
|
| 11 |
+
height: "auto"
|
| 12 |
+
|
| 13 |
+
}
|
| 14 |
+
const Images = React.createClass({
|
| 15 |
+
|
| 16 |
+
//-------default API------------------
|
| 17 |
+
|
| 18 |
+
// getDefaultProps: function(){},
|
| 19 |
+
//getInitialState: function(){},
|
| 20 |
+
// componentWillMount: function(){},
|
| 21 |
+
// componentDidMount: function(){},
|
| 22 |
+
//componentWillReceiveProps: function(){},
|
| 23 |
+
//shouldComponentUpdate: function(){},
|
| 24 |
+
// componentWillUpdate: function(){},
|
| 25 |
+
|
| 26 |
+
render: function() {
|
| 27 |
+
var imgs;
|
| 28 |
+
|
| 29 |
+
if (imgArray.length > 0) {
|
| 30 |
+
imgs = imgArray.map(function(val, idx){
|
| 31 |
+
return (
|
| 32 |
+
<Col key={idx} xs={6}><img style={imageStyle} src={val}></img></Col>
|
| 33 |
+
)
|
| 34 |
+
})
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
return (
|
| 38 |
+
<Row >
|
| 39 |
+
{imgs}
|
| 40 |
+
</Row>
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
},
|
| 44 |
+
// componetDidUpdate: function(){},
|
| 45 |
+
// compoentWillUnmount: function(){}
|
| 46 |
+
});
|
| 47 |
+
|
| 48 |
+
module.exports = Images
|
pool/shard011/JavaScript/0070301_star-rating-test.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import EmberObject from '@ember/object';
|
| 2 |
+
import { module, test } from 'qunit';
|
| 3 |
+
import { setupRenderingTest } from 'ember-qunit';
|
| 4 |
+
import { render, click } from '@ember/test-helpers';
|
| 5 |
+
import hbs from 'htmlbars-inline-precompile';
|
| 6 |
+
|
| 7 |
+
module('Integration | Component | star-rating', function(hooks) {
|
| 8 |
+
setupRenderingTest(hooks);
|
| 9 |
+
|
| 10 |
+
test('Renders the full and empty stars correctly with integer ratings', async function(assert) {
|
| 11 |
+
let song = EmberObject.create({ rating: 4 });
|
| 12 |
+
this.set('song', song);
|
| 13 |
+
this.set('maxRating', 5);
|
| 14 |
+
|
| 15 |
+
await render(hbs`{{star-rating item=song rating=song.rating maxRating=maxRating}}`);
|
| 16 |
+
|
| 17 |
+
assert.dom('.glyphicon-star').exists({ count: 4 }, "The right amount of full stars is rendered");
|
| 18 |
+
assert.dom('.glyphicon-star-empty').exists({ count: 1 }, "The right amount of empty stars is rendered");
|
| 19 |
+
|
| 20 |
+
this.set('maxRating', 10);
|
| 21 |
+
assert.dom('.glyphicon-star').exists({ count: 4 }, "The right amount of full stars is rendered after changing maxRating");
|
| 22 |
+
assert.dom('.glyphicon-star-empty').exists({ count: 6 }, "The right amount of empty stars is rendered after changing maxRating");
|
| 23 |
+
|
| 24 |
+
this.set('song.rating', 2);
|
| 25 |
+
assert.dom('.glyphicon-star').exists({ count: 2 }, "The right amount of full stars is rendered after changing rating");
|
| 26 |
+
assert.dom('.glyphicon-star-empty').exists({ count: 8 }, "The right amount of empty stars is rendered after changing rating");
|
| 27 |
+
});
|
| 28 |
+
|
| 29 |
+
test('Applies the passed fullClassNames and emptyClassNames', async function(assert) {
|
| 30 |
+
let song = EmberObject.create({ rating: 4 });
|
| 31 |
+
this.set('song', song);
|
| 32 |
+
this.set('maxRating', 5);
|
| 33 |
+
|
| 34 |
+
await render(hbs`{{star-rating item=song rating=song.rating maxRating=maxRating fullClassNames='fa fa-star' emptyClassNames='fa fa-star-o'}}`);
|
| 35 |
+
|
| 36 |
+
assert.dom('.fa-star').exists({ count: 4 }, "The right amount of full stars is rendered");
|
| 37 |
+
assert.dom('.fa-star-o').exists({ count: 1 }, "The right amount of empty stars is rendered");
|
| 38 |
+
});
|
| 39 |
+
|
| 40 |
+
test('Renders the full and empty stars correctly with float ratings', async function(assert) {
|
| 41 |
+
let song = EmberObject.create({ rating: 3.2 });
|
| 42 |
+
this.set('song', song);
|
| 43 |
+
this.set('maxRating', 5);
|
| 44 |
+
|
| 45 |
+
await render(hbs`{{star-rating item=song rating=song.rating maxRating=maxRating}}`);
|
| 46 |
+
|
| 47 |
+
assert.dom('.glyphicon-star').exists({ count: 3 }, "The right amount of full stars is rendered");
|
| 48 |
+
assert.dom('.glyphicon-star-empty').exists({ count: 2 }, "The right amount of empty stars is rendered");
|
| 49 |
+
|
| 50 |
+
this.set('maxRating', 10);
|
| 51 |
+
|
| 52 |
+
assert.dom('.glyphicon-star').exists({ count: 3 }, "The right amount of full stars is rendered after changing maxRating");
|
| 53 |
+
assert.dom('.glyphicon-star-empty').exists({ count: 7 }, "The right amount of empty stars is rendered after changing maxRating");
|
| 54 |
+
|
| 55 |
+
this.set('song.rating', 1.9);
|
| 56 |
+
assert.dom('.glyphicon-star').exists({ count: 2 }, "The right amount of full stars is rendered after changing rating");
|
| 57 |
+
assert.dom('.glyphicon-star-empty').exists({ count: 8 }, "The right amount of empty stars is rendered after changing rating");
|
| 58 |
+
});
|
| 59 |
+
|
| 60 |
+
test('Triggers the passed-in action when clicked', async function(assert) {
|
| 61 |
+
let song = EmberObject.create({ rating: 4 }),
|
| 62 |
+
clickedRating;
|
| 63 |
+
|
| 64 |
+
this.set('song', song);
|
| 65 |
+
this.set('maxRating', 5);
|
| 66 |
+
|
| 67 |
+
this.actions = {
|
| 68 |
+
updateRating(params) {
|
| 69 |
+
clickedRating = params.rating;
|
| 70 |
+
}
|
| 71 |
+
};
|
| 72 |
+
|
| 73 |
+
await render(hbs`{{star-rating item=song rating=song.rating on-click=(action "updateRating")}}`);
|
| 74 |
+
|
| 75 |
+
let firstStar = document.querySelectorAll('.rating-star')[0];
|
| 76 |
+
await click(firstStar);
|
| 77 |
+
assert.equal(clickedRating, 1, "The `updateRating` action was called");
|
| 78 |
+
});
|
| 79 |
+
|
| 80 |
+
test('In block form, yields back the decorated stars', async function(assert) {
|
| 81 |
+
let song = EmberObject.create({ rating: 4 });
|
| 82 |
+
this.set('song', song);
|
| 83 |
+
this.set('maxRating', 5);
|
| 84 |
+
|
| 85 |
+
await render(hbs`
|
| 86 |
+
{{#star-rating item=song rating=song.rating maxRating=maxRating as |stars|}}
|
| 87 |
+
{{#each stars as |star|}}
|
| 88 |
+
<span class="{{if star.full 'full-star' 'empty-star'}}"></span>
|
| 89 |
+
{{/each}}
|
| 90 |
+
{{/star-rating}}
|
| 91 |
+
`);
|
| 92 |
+
|
| 93 |
+
assert.dom('.full-star').exists({ count: 4 }, "The right amount of full stars is rendered");
|
| 94 |
+
assert.dom('.empty-star').exists({ count: 1 }, "The right amount of empty stars is rendered");
|
| 95 |
+
});
|
| 96 |
+
|
| 97 |
+
test('In block form, calls the passed in `on-click` action', async function(assert) {
|
| 98 |
+
let song = EmberObject.create({ rating: 4 });
|
| 99 |
+
let clickedRating;
|
| 100 |
+
|
| 101 |
+
this.set('song', song);
|
| 102 |
+
this.set('maxRating', 5);
|
| 103 |
+
this.actions = {
|
| 104 |
+
updateRating: function(params) {
|
| 105 |
+
clickedRating = params.rating;
|
| 106 |
+
}
|
| 107 |
+
};
|
| 108 |
+
|
| 109 |
+
await render(hbs`
|
| 110 |
+
{{#star-rating item=song rating=song.rating maxRating=maxRating on-click=(action "updateRating") as |stars setRating|}}
|
| 111 |
+
{{#each stars as |star|}}
|
| 112 |
+
<span
|
| 113 |
+
class="rating-star"
|
| 114 |
+
onclick={{action setRating star.rating}}>
|
| 115 |
+
<span class="fa fa-star"></span>
|
| 116 |
+
</span>
|
| 117 |
+
{{/each}}
|
| 118 |
+
{{/star-rating}}
|
| 119 |
+
`);
|
| 120 |
+
|
| 121 |
+
let firstStar = document.querySelectorAll('.rating-star')[0];
|
| 122 |
+
await click(firstStar);
|
| 123 |
+
assert.equal(clickedRating, 1, "The `updateRating` action was called");
|
| 124 |
+
});
|
| 125 |
+
});
|
pool/shard011/JavaScript/0070302_config.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var HOST = "";
|
| 2 |
+
|
| 3 |
+
jsolait.baseURI = HOST + "/jsolait/";
|
| 4 |
+
var serviceURL = HOST + "/rpc.cgi";
|
| 5 |
+
var jsonrpc = null;
|
| 6 |
+
var Version = "1.0.1";
|
| 7 |
+
var DEBUG = false;
|
| 8 |
+
var methods = [ "config.getVariable",
|
| 9 |
+
"config.setVariable",
|
| 10 |
+
"config.getConfig",
|
| 11 |
+
"file.exists",
|
| 12 |
+
"misc.remoteCmd",
|
| 13 |
+
"misc.fileDownload",
|
| 14 |
+
"misc.fileUpload",
|
| 15 |
+
"misc.getVersion",
|
| 16 |
+
"misc.getGatewayNetworkInfo",
|
| 17 |
+
"misc.setGatewayNetworkInfo",
|
| 18 |
+
"misc.getNtpServers",
|
| 19 |
+
"misc.setNtpServers",
|
| 20 |
+
"misc.softwareReset",
|
| 21 |
+
"misc.hardReset",
|
| 22 |
+
"misc.setGprsProviderInfo",
|
| 23 |
+
"misc.getGprsProviderInfo",
|
| 24 |
+
"user.secure_challenge",
|
| 25 |
+
"user.secure_login",
|
| 26 |
+
"user.logout" ];
|
| 27 |
+
|
| 28 |
+
function InitJSON(){
|
| 29 |
+
try {
|
| 30 |
+
jsonrpc = imprt("jsonrpc");
|
| 31 |
+
} catch (e) {
|
| 32 |
+
alert(e);
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
function SetPageCommonElements(){
|
| 37 |
+
document.title = "MCS Admin";
|
| 38 |
+
var divHeader = document.getElementById("header");
|
| 39 |
+
if (divHeader){
|
| 40 |
+
divHeader.innerHTML = "<table width='100%' cellspacing='0' cellpadding='0' border='0'>" +
|
| 41 |
+
"<tr>" +
|
| 42 |
+
"<td align='left'><img id='imgCompany' src='images/CompanyLogo.png' height='30px'></td>" +
|
| 43 |
+
"<td align='right'>/admin/ User Interface</td>"
|
| 44 |
+
"</tr>" +
|
| 45 |
+
"</table>";
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
var divFooter = document.getElementById("footer");
|
| 49 |
+
if (divFooter){
|
| 50 |
+
divFooter.innerHTML = "<p><table width='100%' ><tr><td align='left'>Version " + Version + " </td><td align='right'> NIVIS® 2012</tr></table></p>";
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
var divMenu = document.getElementById("columnB");
|
| 54 |
+
if (divMenu != null) {
|
| 55 |
+
divMenu.innerHTML = "<h3>Upgrade</h3>"+
|
| 56 |
+
"<ul class='list1'>"+
|
| 57 |
+
"<li> <a href='firmware_upgrade.html'>Edge Router Firmware</a></li>"+
|
| 58 |
+
"<li> <a href='load_versa_node_firmware.html'>Transceiver Firmware</a></li>"+
|
| 59 |
+
"<li> <a href='upload.html'>Application Website</a></li>"+
|
| 60 |
+
"</ul>"+
|
| 61 |
+
"<h3>Configuration</h3>"+
|
| 62 |
+
"<ul class='list1'>"+
|
| 63 |
+
"<li> <a href='application.html'>Log Files</a></li>"+
|
| 64 |
+
"<li> <a href='update_profile.html'>Reset Profile</a></li>"+
|
| 65 |
+
"<li> <a href='edit_configuration.html'>Advanced Settings</a></li>"+
|
| 66 |
+
"<li> <a href='network_configuration.html'>Network</a></li>" +
|
| 67 |
+
"</ul>"+
|
| 68 |
+
"<h3>Session</h3>"+
|
| 69 |
+
"<ul class='list1'>"+
|
| 70 |
+
"<li> <a href='changepassword.html'>Change Password</a></li>"+
|
| 71 |
+
"<li> <a href='login.html'>Logout</a></li>"+
|
| 72 |
+
"</ul>";
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
function HandleException(ex, msg){
|
| 77 |
+
if (ex.message != null &&
|
| 78 |
+
ex.message.toLowerCase().indexOf("login first") != -1 ||
|
| 79 |
+
ex.message.toLowerCase().indexOf("unable to start session") != -1 ||
|
| 80 |
+
ex.message.toLowerCase().indexOf("internal xml-rpc error") != -1 ||
|
| 81 |
+
ex.message.toLowerCase().indexOf("internal json-rpc error") != -1)
|
| 82 |
+
{
|
| 83 |
+
top.location.href = "login.html?exp";
|
| 84 |
+
return;
|
| 85 |
+
}
|
| 86 |
+
if(!DEBUG){
|
| 87 |
+
alert(msg);
|
| 88 |
+
}else{
|
| 89 |
+
alert(msg + "\n" + ex);
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
function operationDoneListener(text) {
|
| 94 |
+
ToggleProgressOperation(false);
|
| 95 |
+
innerHTML = "";
|
| 96 |
+
var operationStatus = document.getElementById('operationStatus');
|
| 97 |
+
if ( text ){
|
| 98 |
+
if ( text.result ){
|
| 99 |
+
innerHTML = "Log results:<br><pre>" + text.result + "</pre>";
|
| 100 |
+
DisplayOperationResult("operationStatus", "Operation successfully completed !");
|
| 101 |
+
} else if ( text.error ){
|
| 102 |
+
innerHTML = "Log results:<br><pre>" + text.error + "</pre>";
|
| 103 |
+
DisplayOperationResultError("operationStatus", "Operation failed !");
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
document.getElementById("result").innerHTML = innerHTML;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
function DisplayOperationResult(controlId, msg) {
|
| 110 |
+
var control = document.getElementById(controlId);
|
| 111 |
+
control.className = "opResultGreen";
|
| 112 |
+
control.innerHTML = msg;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
function DisplayOperationResultError(controlId, msg) {
|
| 116 |
+
var control = document.getElementById(controlId);
|
| 117 |
+
control.className = "opResultRed";
|
| 118 |
+
control.innerHTML = msg;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
function ClearOperationResult(controlId) {
|
| 122 |
+
DisplayOperationResult(controlId, "");
|
| 123 |
+
var control = document.getElementById(controlId);
|
| 124 |
+
control.className = "";
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
function ToggleProgressOperation(bool){
|
| 128 |
+
var operationStatus = document.getElementById("operationStatusImg");
|
| 129 |
+
if(bool){
|
| 130 |
+
operationStatus.style.display = "inline";
|
| 131 |
+
} else{
|
| 132 |
+
operationStatus.style.display = "none";
|
| 133 |
+
}
|
| 134 |
+
}
|
pool/shard011/JavaScript/0070304_tools.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var program = require('commander');
|
| 2 |
+
var fs = require('fs');
|
| 3 |
+
var path = require('path');
|
| 4 |
+
var Imagemin = require('imagemin');
|
| 5 |
+
var imageminOptipng = require('imagemin-optipng');
|
| 6 |
+
|
| 7 |
+
var redirectFilePath = './config/redirect-urls.json';
|
| 8 |
+
var addRedirect = function(oldUrl, newUrl, callback) {
|
| 9 |
+
fs.readFile(redirectFilePath, function(err, json) {
|
| 10 |
+
if (err) { return callback(err); }
|
| 11 |
+
|
| 12 |
+
var data = JSON.parse(json);
|
| 13 |
+
data.push({
|
| 14 |
+
from: oldUrl,
|
| 15 |
+
to: newUrl
|
| 16 |
+
});
|
| 17 |
+
|
| 18 |
+
json = JSON.stringify(data, null, 2);
|
| 19 |
+
fs.writeFile(redirectFilePath, json, callback);
|
| 20 |
+
});
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
program
|
| 25 |
+
.version('0.0.1');
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
program.command('mv <oldUrl> <newUrl>')
|
| 29 |
+
.action(function (oldUrl, newUrl) {
|
| 30 |
+
if (oldUrl[0] !== '/') {
|
| 31 |
+
oldUrl = '/' + oldUrl;
|
| 32 |
+
}
|
| 33 |
+
if (newUrl[0] !== '/') {
|
| 34 |
+
newUrl = '/' + newUrl;
|
| 35 |
+
}
|
| 36 |
+
var oldPath = 'articles' + oldUrl + '.md';
|
| 37 |
+
var newPath = 'articles' + newUrl + '.md';
|
| 38 |
+
fs.rename(oldPath, newPath, function(err) {
|
| 39 |
+
if (err) { return console.error(err); }
|
| 40 |
+
|
| 41 |
+
addRedirect(oldUrl, newUrl, function(err) {
|
| 42 |
+
if (err) { return console.error(err); }
|
| 43 |
+
|
| 44 |
+
console.log('File renamed');
|
| 45 |
+
});
|
| 46 |
+
});
|
| 47 |
+
});
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
program.command('imgs')
|
| 51 |
+
.action(function() {
|
| 52 |
+
new Imagemin()
|
| 53 |
+
.src('media/**/*.png')
|
| 54 |
+
.dest('media')
|
| 55 |
+
.use(imageminOptipng({optimizationLevel: 3}))
|
| 56 |
+
.run((err, files) => {
|
| 57 |
+
if (err) {
|
| 58 |
+
console.error(err);
|
| 59 |
+
}
|
| 60 |
+
console.log('Minified ' + files.length + ' images.');
|
| 61 |
+
//=> {path: 'build/images/foo.jpg', contents: <Buffer 89 50 4e ...>}
|
| 62 |
+
});
|
| 63 |
+
});
|
| 64 |
+
|
| 65 |
+
program.command('img <imgPath>')
|
| 66 |
+
.action(function(imgPath) {
|
| 67 |
+
new Imagemin()
|
| 68 |
+
.src(imgPath)
|
| 69 |
+
.dest(path.dirname(imgPath))
|
| 70 |
+
.use(imageminOptipng({optimizationLevel: 3}))
|
| 71 |
+
.run((err, files) => {
|
| 72 |
+
if (err) {
|
| 73 |
+
console.error(err);
|
| 74 |
+
}
|
| 75 |
+
console.log('Minified ' + files.length + ' images.');
|
| 76 |
+
//=> {path: 'build/images/foo.jpg', contents: <Buffer 89 50 4e ...>}
|
| 77 |
+
});
|
| 78 |
+
});
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
program.parse(process.argv);
|
pool/shard011/JavaScript/0070306_index.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, {Component} from 'react'
|
| 2 |
+
import Dropdown from 'rc-dropdown'
|
| 3 |
+
import Menu, {Item as MenuItem, Divider, SubMenu} from 'rc-menu';
|
| 4 |
+
import 'rc-dropdown/assets/index.css';
|
| 5 |
+
import 'rc-menu/assets/index.css';
|
| 6 |
+
import {menu as fspMenu} from '../../settings/fspSettings';
|
| 7 |
+
import './style.css'
|
| 8 |
+
import {createHashHistory} from 'history'
|
| 9 |
+
const history = createHashHistory({queryKey: false});
|
| 10 |
+
class FSPMenu extends Component {
|
| 11 |
+
|
| 12 |
+
state = {
|
| 13 |
+
visible: false
|
| 14 |
+
};
|
| 15 |
+
|
| 16 |
+
onClick({selectedKeys}) {
|
| 17 |
+
if (!this.props.multiple) {
|
| 18 |
+
this.setState({
|
| 19 |
+
visible: false
|
| 20 |
+
})
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
onSelect({selectedKeys}) {
|
| 25 |
+
this.handleDropdownChanges(selectedKeys)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
onVisibleChange(visible) {
|
| 29 |
+
this.setState({visible})
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
getDefaultView() {
|
| 33 |
+
return 'uganda/mobilemoney';
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
handleDropdownChanges(selectedFilters) {
|
| 37 |
+
const selected = selectedFilters[0] || this.getDefaultView();
|
| 38 |
+
const split = selected.split('/');
|
| 39 |
+
const country = split[0];
|
| 40 |
+
const view = split[1];
|
| 41 |
+
history.replace(`/fsp/${country}/${view}`);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
render() {
|
| 45 |
+
|
| 46 |
+
const menu = (
|
| 47 |
+
<Menu
|
| 48 |
+
multiple={this.props.multiple}
|
| 49 |
+
onClick={this.onClick.bind(this)}
|
| 50 |
+
onSelect={this.onSelect.bind(this)}
|
| 51 |
+
onDeselect={this.onSelect.bind(this)}
|
| 52 |
+
className={this.props.multiple ? 'checkboxes' : ''}
|
| 53 |
+
>
|
| 54 |
+
{fspMenu.map(({id, description, subMenu}) => {
|
| 55 |
+
if (subMenu) {
|
| 56 |
+
return (
|
| 57 |
+
<SubMenu title={description} key={id}>
|
| 58 |
+
{
|
| 59 |
+
subMenu.map(sub => (
|
| 60 |
+
<MenuItem key={`${id}/${sub.id}`}>{sub.description}</MenuItem>
|
| 61 |
+
))
|
| 62 |
+
}
|
| 63 |
+
</SubMenu>
|
| 64 |
+
);
|
| 65 |
+
} else return (
|
| 66 |
+
<MenuItem key={id}>{description}</MenuItem>
|
| 67 |
+
);
|
| 68 |
+
}
|
| 69 |
+
)}
|
| 70 |
+
</Menu>
|
| 71 |
+
);
|
| 72 |
+
|
| 73 |
+
return (
|
| 74 |
+
<Dropdown
|
| 75 |
+
trigger={['click']}
|
| 76 |
+
overlay={<div style={{width: 200, backgroundColor: 'white'}}>{menu}</div>}
|
| 77 |
+
onVisibleChange={this.onVisibleChange.bind(this)}
|
| 78 |
+
visible={this.state.visible}
|
| 79 |
+
defaultActiveFirst
|
| 80 |
+
overlayClassName="overlays-dropdown">
|
| 81 |
+
<span className='filter' title='Thematic Analysis'>Thematic Analysis ▾</span>
|
| 82 |
+
</Dropdown>
|
| 83 |
+
)
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
export default FSPMenu
|
pool/shard011/JavaScript/0070308_progress.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Progress = function (player, elapsed, total, meter) {
|
| 2 |
+
this.player = player;
|
| 3 |
+
this.elapsed = elapsed;
|
| 4 |
+
this.total = total;
|
| 5 |
+
this.meter = meter;
|
| 6 |
+
|
| 7 |
+
var _this = this;
|
| 8 |
+
|
| 9 |
+
this.player.addEventListener("timeupdate", function (event) {
|
| 10 |
+
function renderTime(seconds) {
|
| 11 |
+
var _minutes = Math.floor(seconds / 60);
|
| 12 |
+
var _seconds = Math.floor(seconds - _minutes * 60);
|
| 13 |
+
|
| 14 |
+
_minutes = _minutes < 10 ? "0" + _minutes : _minutes;
|
| 15 |
+
_seconds = _seconds < 10 ? "0" + _seconds : _seconds;
|
| 16 |
+
|
| 17 |
+
return _minutes + ":" + _seconds;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
var elapsed = event.target.currentTime;
|
| 21 |
+
var total = event.target.duration;
|
| 22 |
+
|
| 23 |
+
_this.elapsed.textContent = renderTime(elapsed);
|
| 24 |
+
_this.total.textContent = renderTime(total);
|
| 25 |
+
_this.meter.setAttribute("style", "width: " + (elapsed / total * 100) + "%");
|
| 26 |
+
});
|
| 27 |
+
|
| 28 |
+
this.player.addEventListener("ended", function (event) {
|
| 29 |
+
_this.elapsed.textContent = "";
|
| 30 |
+
_this.total.textContent = "";
|
| 31 |
+
_this.meter.setAttribute("style", "width: 0");
|
| 32 |
+
});
|
| 33 |
+
};
|
pool/shard011/JavaScript/0070309_setup.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var open = require('open');
|
| 2 |
+
|
| 3 |
+
module.exports = function (clientID, cb) {
|
| 4 |
+
var REDIRECT_URI = 'https://rogeriopvl.github.com/downstagram';
|
| 5 |
+
|
| 6 |
+
console.log('\n********** DOWNSTAGRAM OAUTH SETUP **********');
|
| 7 |
+
console.log('\n To use downstagram you need to authorize it to access your instagram account.');
|
| 8 |
+
console.log('Your browser will open for you to authorize the app...');
|
| 9 |
+
|
| 10 |
+
var authURI = [
|
| 11 |
+
'https://instagram.com/oauth/authorize/?',
|
| 12 |
+
'client_id=' + clientID,
|
| 13 |
+
'&redirect_uri=' + REDIRECT_URI,
|
| 14 |
+
'&response_type=token'
|
| 15 |
+
].join('');
|
| 16 |
+
|
| 17 |
+
console.log('\n If your browser does not open up, you can stil open it manually:');
|
| 18 |
+
console.log(authURI, ' \n');
|
| 19 |
+
|
| 20 |
+
open(authURI);
|
| 21 |
+
|
| 22 |
+
console.log('Now according to the intructions in the App page, insert your access token here:');
|
| 23 |
+
|
| 24 |
+
process.stdin.resume();
|
| 25 |
+
process.stdin.on('data', function (chunk) {
|
| 26 |
+
var token = chunk.toString().trim();
|
| 27 |
+
process.stdin.pause();
|
| 28 |
+
cb(null, token);
|
| 29 |
+
});
|
| 30 |
+
};
|
pool/shard011/JavaScript/0070311_step3_controller.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
/**
|
| 20 |
+
* @typedef {object} hawqHaConfigDependencies
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
var App = require('app');
|
| 24 |
+
require('utils/configs/hawq_ha_config_initializer');
|
| 25 |
+
|
| 26 |
+
App.AddHawqStandbyWizardStep3Controller = Em.Controller.extend({
|
| 27 |
+
name: "addHawqStandbyWizardStep3Controller",
|
| 28 |
+
|
| 29 |
+
// Used in service_config.hbs
|
| 30 |
+
// selectedService
|
| 31 |
+
// hideDependenciesInfoBar
|
| 32 |
+
// versionLoaded
|
| 33 |
+
|
| 34 |
+
selectedService: null,
|
| 35 |
+
|
| 36 |
+
hawqProps: null,
|
| 37 |
+
|
| 38 |
+
hideDependenciesInfoBar: true,
|
| 39 |
+
|
| 40 |
+
versionLoaded: true,
|
| 41 |
+
|
| 42 |
+
// Used in step3.hbs
|
| 43 |
+
// isLoaded
|
| 44 |
+
// isSubmitDisabled
|
| 45 |
+
// hawqMasterDirectoryCleanUpMessage
|
| 46 |
+
isLoaded: false,
|
| 47 |
+
|
| 48 |
+
isSubmitDisabled: Em.computed.not('isLoaded'),
|
| 49 |
+
|
| 50 |
+
loadStep: function () {
|
| 51 |
+
this.renderConfigs();
|
| 52 |
+
},
|
| 53 |
+
|
| 54 |
+
content: Em.Object.create({
|
| 55 |
+
controllerName: 'addHawqStandbyWizardStep3Controller'
|
| 56 |
+
}),
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* Render configs to show them in <code>App.ServiceConfigView</code>
|
| 60 |
+
*/
|
| 61 |
+
renderConfigs: function () {
|
| 62 |
+
|
| 63 |
+
var configs = require('data/configs/wizards/hawq_ha_properties').haConfig;
|
| 64 |
+
|
| 65 |
+
var serviceConfig = App.ServiceConfig.create({
|
| 66 |
+
serviceName: configs.serviceName,
|
| 67 |
+
displayName: configs.displayName,
|
| 68 |
+
configCategories: [],
|
| 69 |
+
showConfig: true,
|
| 70 |
+
|
| 71 |
+
configs: []
|
| 72 |
+
});
|
| 73 |
+
|
| 74 |
+
configs.configCategories.forEach(function (configCategory) {
|
| 75 |
+
if (App.Service.find().someProperty('serviceName', configCategory.name)) {
|
| 76 |
+
serviceConfig.configCategories.pushObject(configCategory);
|
| 77 |
+
}
|
| 78 |
+
}, this);
|
| 79 |
+
|
| 80 |
+
this.renderConfigProperties(configs, serviceConfig);
|
| 81 |
+
App.ajax.send({
|
| 82 |
+
name: 'config.tags',
|
| 83 |
+
sender: this,
|
| 84 |
+
success: 'loadConfigTagsSuccessCallback',
|
| 85 |
+
error: '',
|
| 86 |
+
data: {
|
| 87 |
+
serviceConfig: serviceConfig
|
| 88 |
+
}
|
| 89 |
+
});
|
| 90 |
+
|
| 91 |
+
},
|
| 92 |
+
|
| 93 |
+
loadConfigTagsSuccessCallback: function (data, opt, params) {
|
| 94 |
+
var urlParams = '(type=hawq-site&tag=' + data.Clusters.desired_configs['hawq-site'].tag + ')';
|
| 95 |
+
App.ajax.send({
|
| 96 |
+
name: 'reassign.load_configs',
|
| 97 |
+
sender: this,
|
| 98 |
+
data: {
|
| 99 |
+
urlParams: urlParams,
|
| 100 |
+
serviceConfig: params.serviceConfig
|
| 101 |
+
},
|
| 102 |
+
success: 'loadConfigsSuccessCallback',
|
| 103 |
+
error: 'loadConfigsSuccessCallback'
|
| 104 |
+
});
|
| 105 |
+
},
|
| 106 |
+
|
| 107 |
+
loadConfigsSuccessCallback: function (data, opt, params) {
|
| 108 |
+
params = params.serviceConfig ? params.serviceConfig : {};
|
| 109 |
+
this.setDynamicConfigValues(params, data);
|
| 110 |
+
this.setProperties({
|
| 111 |
+
selectedService: params,
|
| 112 |
+
isLoaded: true,
|
| 113 |
+
hawqProps: data
|
| 114 |
+
});
|
| 115 |
+
},
|
| 116 |
+
|
| 117 |
+
setDynamicConfigValues: function (configs, data) {
|
| 118 |
+
var topologyLocalDB = this.get('content').getProperties(['masterComponentHosts']);
|
| 119 |
+
configs.configs.forEach(function (config) {
|
| 120 |
+
App.HawqHaConfigInitializer.initialValue(config, topologyLocalDB);
|
| 121 |
+
});
|
| 122 |
+
App.HawqHaConfigInitializer.cleanup();
|
| 123 |
+
return configs;
|
| 124 |
+
},
|
| 125 |
+
|
| 126 |
+
/**
|
| 127 |
+
* Load child components to service config object
|
| 128 |
+
* @param _componentConfig
|
| 129 |
+
* @param componentConfig
|
| 130 |
+
*/
|
| 131 |
+
renderConfigProperties: function (_componentConfig, componentConfig) {
|
| 132 |
+
_componentConfig.configs.forEach(function (_serviceConfigProperty) {
|
| 133 |
+
var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
|
| 134 |
+
componentConfig.configs.pushObject(serviceConfigProperty);
|
| 135 |
+
serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
|
| 136 |
+
}, this);
|
| 137 |
+
},
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
submit: function () {
|
| 141 |
+
if (!this.get('isSubmitDisabled')) {
|
| 142 |
+
const dataDir = this.get('hawqProps').items[0].properties['hawq_master_directory'];
|
| 143 |
+
const hawqStandby = this.get('content.hawqHosts.newHawqStandby');
|
| 144 |
+
App.showConfirmationPopup(
|
| 145 |
+
function() {
|
| 146 |
+
App.get('router.mainAdminKerberosController').getKDCSessionState(function() {
|
| 147 |
+
App.router.send("next");
|
| 148 |
+
});
|
| 149 |
+
},
|
| 150 |
+
Em.I18n.t('admin.addHawqStandby.wizard.step3.confirm.dataDir.body').format(dataDir, hawqStandby),
|
| 151 |
+
null,
|
| 152 |
+
Em.I18n.t('admin.addHawqStandby.wizard.step3.confirm.dataDir.title'),
|
| 153 |
+
"Confirm"
|
| 154 |
+
);
|
| 155 |
+
}
|
| 156 |
+
},
|
| 157 |
+
|
| 158 |
+
});
|
pool/shard011/JavaScript/0070313_post_draft.test.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
| 2 |
+
// See LICENSE.txt for license information.
|
| 3 |
+
|
| 4 |
+
import React from 'react';
|
| 5 |
+
import configureMockStore from 'redux-mock-store';
|
| 6 |
+
import thunk from 'redux-thunk';
|
| 7 |
+
|
| 8 |
+
import Preferences from '@mm-redux/constants/preferences';
|
| 9 |
+
import intitialState from '@store/initial_state';
|
| 10 |
+
import {renderWithReduxIntl} from '@test/testing_library';
|
| 11 |
+
|
| 12 |
+
import PostDraft from './post_draft';
|
| 13 |
+
|
| 14 |
+
jest.mock('app/components/compass_icon', () => 'Icon');
|
| 15 |
+
|
| 16 |
+
const mockStore = configureMockStore([thunk]);
|
| 17 |
+
const state = {
|
| 18 |
+
...intitialState,
|
| 19 |
+
entities: {
|
| 20 |
+
...intitialState.entities,
|
| 21 |
+
channels: {
|
| 22 |
+
...intitialState.entities.channels,
|
| 23 |
+
channels: {
|
| 24 |
+
'channel-id': {
|
| 25 |
+
id: 'channel-id',
|
| 26 |
+
name: 'test-channel',
|
| 27 |
+
display_name: 'Display Name',
|
| 28 |
+
type: 'O',
|
| 29 |
+
},
|
| 30 |
+
},
|
| 31 |
+
channelMemberCountsByGroup: {},
|
| 32 |
+
},
|
| 33 |
+
},
|
| 34 |
+
device: {
|
| 35 |
+
...intitialState.device,
|
| 36 |
+
dimension: {
|
| 37 |
+
deviceWidth: 375,
|
| 38 |
+
deviceHeight: 812,
|
| 39 |
+
},
|
| 40 |
+
},
|
| 41 |
+
};
|
| 42 |
+
const store = mockStore(state);
|
| 43 |
+
|
| 44 |
+
describe('PostDraft', () => {
|
| 45 |
+
const baseProps = {
|
| 46 |
+
testID: 'post_draft',
|
| 47 |
+
canPost: true,
|
| 48 |
+
channelId: 'channel-id',
|
| 49 |
+
channelIsArchived: false,
|
| 50 |
+
channelIsReadOnly: false,
|
| 51 |
+
deactivatedChannel: false,
|
| 52 |
+
registerTypingAnimation: () => jest.fn(),
|
| 53 |
+
rootId: '',
|
| 54 |
+
screenId: 'NavigationScreen1',
|
| 55 |
+
theme: Preferences.THEMES.denim,
|
| 56 |
+
};
|
| 57 |
+
|
| 58 |
+
test('Should render the DraftInput', () => {
|
| 59 |
+
const {getByTestId, queryByText, toJSON} = renderWithReduxIntl(
|
| 60 |
+
<PostDraft
|
| 61 |
+
{...baseProps}
|
| 62 |
+
/>,
|
| 63 |
+
store,
|
| 64 |
+
);
|
| 65 |
+
|
| 66 |
+
expect(toJSON()).toMatchSnapshot();
|
| 67 |
+
expect(getByTestId('post_draft.post.input')).toBeTruthy();
|
| 68 |
+
expect(queryByText('Close Channel')).toBeNull();
|
| 69 |
+
});
|
| 70 |
+
|
| 71 |
+
test('Should render the Archived for channelIsArchived', () => {
|
| 72 |
+
const {queryByTestId, getByText, toJSON} = renderWithReduxIntl(
|
| 73 |
+
<PostDraft
|
| 74 |
+
{...baseProps}
|
| 75 |
+
channelIsArchived={true}
|
| 76 |
+
/>,
|
| 77 |
+
store,
|
| 78 |
+
);
|
| 79 |
+
|
| 80 |
+
expect(toJSON()).toMatchSnapshot();
|
| 81 |
+
|
| 82 |
+
// Should not render text input
|
| 83 |
+
expect(queryByTestId('post_draft.post.input')).toBeNull();
|
| 84 |
+
|
| 85 |
+
// Should match text description
|
| 86 |
+
expect(getByText('You are viewing an')).toBeTruthy();
|
| 87 |
+
expect(getByText('archived channel')).toBeTruthy();
|
| 88 |
+
expect(getByText('. New messages cannot be posted.')).toBeTruthy();
|
| 89 |
+
expect(getByText('Close Channel')).toBeTruthy();
|
| 90 |
+
});
|
| 91 |
+
|
| 92 |
+
test('Should render the Archived for deactivatedChannel', () => {
|
| 93 |
+
const {queryByTestId, getByText, toJSON} = renderWithReduxIntl(
|
| 94 |
+
<PostDraft
|
| 95 |
+
{...baseProps}
|
| 96 |
+
deactivatedChannel={true}
|
| 97 |
+
/>,
|
| 98 |
+
store,
|
| 99 |
+
);
|
| 100 |
+
|
| 101 |
+
expect(toJSON()).toMatchSnapshot();
|
| 102 |
+
|
| 103 |
+
// Should not render text input
|
| 104 |
+
expect(queryByTestId('post_draft.post.input')).toBeNull();
|
| 105 |
+
|
| 106 |
+
// Should match text description
|
| 107 |
+
expect(getByText('You are viewing an')).toBeTruthy();
|
| 108 |
+
expect(getByText('archived channel')).toBeTruthy();
|
| 109 |
+
expect(getByText('. New messages cannot be posted.')).toBeTruthy();
|
| 110 |
+
expect(getByText('Close Channel')).toBeTruthy();
|
| 111 |
+
});
|
| 112 |
+
|
| 113 |
+
test('Should render the ReadOnly for channelIsReadOnly', () => {
|
| 114 |
+
const {queryByTestId, getByText, queryByText, toJSON} = renderWithReduxIntl(
|
| 115 |
+
<PostDraft
|
| 116 |
+
{...baseProps}
|
| 117 |
+
channelIsReadOnly={true}
|
| 118 |
+
/>,
|
| 119 |
+
store,
|
| 120 |
+
);
|
| 121 |
+
|
| 122 |
+
expect(toJSON()).toMatchSnapshot();
|
| 123 |
+
|
| 124 |
+
// Should not render text input
|
| 125 |
+
expect(queryByTestId('post_draft.post.input')).toBeNull();
|
| 126 |
+
|
| 127 |
+
// Should match text description
|
| 128 |
+
expect(getByText('This channel is read-only.')).toBeTruthy();
|
| 129 |
+
expect(queryByText('Close Channel')).toBeNull();
|
| 130 |
+
});
|
| 131 |
+
|
| 132 |
+
test('Should render the ReadOnly for canPost', () => {
|
| 133 |
+
const {queryByTestId, getByText, queryByText, toJSON} = renderWithReduxIntl(
|
| 134 |
+
<PostDraft
|
| 135 |
+
{...baseProps}
|
| 136 |
+
canPost={false}
|
| 137 |
+
/>,
|
| 138 |
+
store,
|
| 139 |
+
);
|
| 140 |
+
|
| 141 |
+
expect(toJSON()).toMatchSnapshot();
|
| 142 |
+
|
| 143 |
+
// Should not render text input
|
| 144 |
+
expect(queryByTestId('post_draft.post.input')).toBeNull();
|
| 145 |
+
|
| 146 |
+
// Should match text description
|
| 147 |
+
expect(getByText('This channel is read-only.')).toBeTruthy();
|
| 148 |
+
expect(queryByText('Close Channel')).toBeNull();
|
| 149 |
+
});
|
| 150 |
+
});
|
pool/shard011/JavaScript/0070314_index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* global fetch */
|
| 2 |
+
import search from './search';
|
| 3 |
+
import album from './album';
|
| 4 |
+
|
| 5 |
+
import API_URL from './config';
|
| 6 |
+
import toJSON from './utils';
|
| 7 |
+
|
| 8 |
+
export default class SpotifyWrapper {
|
| 9 |
+
constructor(options) {
|
| 10 |
+
this.apiURL = options.apiURL || API_URL;
|
| 11 |
+
this.token = options.token;
|
| 12 |
+
|
| 13 |
+
this.album = album.bind(this)();
|
| 14 |
+
this.search = search.bind(this)();
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
request(url) {
|
| 18 |
+
const headers = {
|
| 19 |
+
headers: {
|
| 20 |
+
Authorization: `'Bearer ${this.token}'`,
|
| 21 |
+
},
|
| 22 |
+
};
|
| 23 |
+
|
| 24 |
+
return fetch(url, headers).then(toJSON);
|
| 25 |
+
}
|
| 26 |
+
}
|
pool/shard011/JavaScript/0070320_cohorts.js
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// structure stolen from http://briancray.com/posts/javascript-module-pattern
|
| 2 |
+
|
| 3 |
+
var CohortManager = (function ($) {
|
| 4 |
+
// private variables and functions
|
| 5 |
+
|
| 6 |
+
// using jQuery
|
| 7 |
+
function getCookie(name) {
|
| 8 |
+
var cookieValue = null;
|
| 9 |
+
if (document.cookie && document.cookie != '') {
|
| 10 |
+
var cookies = document.cookie.split(';');
|
| 11 |
+
for (var i = 0; i < cookies.length; i++) {
|
| 12 |
+
var cookie = $.trim(cookies[i]);
|
| 13 |
+
// Does this cookie string begin with the name we want?
|
| 14 |
+
if (cookie.substring(0, name.length + 1) == (name + '=')) {
|
| 15 |
+
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
| 16 |
+
break;
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
return cookieValue;
|
| 21 |
+
}
|
| 22 |
+
var csrftoken = getCookie('csrftoken');
|
| 23 |
+
|
| 24 |
+
function csrfSafeMethod(method) {
|
| 25 |
+
// these HTTP methods do not require CSRF protection
|
| 26 |
+
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
|
| 27 |
+
}
|
| 28 |
+
$.ajaxSetup({
|
| 29 |
+
crossDomain: false, // obviates need for sameOrigin test
|
| 30 |
+
beforeSend: function(xhr, settings) {
|
| 31 |
+
if (!csrfSafeMethod(settings.type)) {
|
| 32 |
+
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
// constructor
|
| 38 |
+
var module = function () {
|
| 39 |
+
var el = $(".cohort_manager");
|
| 40 |
+
// localized jquery
|
| 41 |
+
var $$ = function (selector) {
|
| 42 |
+
return $(selector, el)
|
| 43 |
+
}
|
| 44 |
+
var state_init = "init";
|
| 45 |
+
var state_summary = "summary";
|
| 46 |
+
var state_detail = "detail";
|
| 47 |
+
var state = state_init;
|
| 48 |
+
|
| 49 |
+
var url = el.data('ajax_url');
|
| 50 |
+
var self = this;
|
| 51 |
+
|
| 52 |
+
// Pull out the relevant parts of the html
|
| 53 |
+
// global stuff
|
| 54 |
+
var errors = $$(".errors");
|
| 55 |
+
|
| 56 |
+
// cohort summary display
|
| 57 |
+
var summary = $$(".summary");
|
| 58 |
+
var cohorts = $$(".cohorts");
|
| 59 |
+
var show_cohorts_button = $$(".controls .show_cohorts");
|
| 60 |
+
var add_cohort_input = $$(".cohort_name");
|
| 61 |
+
var add_cohort_button = $$(".add_cohort");
|
| 62 |
+
|
| 63 |
+
// single cohort user display
|
| 64 |
+
var detail = $$(".detail");
|
| 65 |
+
var detail_header = $(".header", detail);
|
| 66 |
+
var detail_users = $$(".users");
|
| 67 |
+
var detail_page_num = $$(".page_num");
|
| 68 |
+
var users_area = $$(".users_area");
|
| 69 |
+
var add_members_button = $$(".add_members");
|
| 70 |
+
var op_results = $$(".op_results");
|
| 71 |
+
var cohort_id = null;
|
| 72 |
+
var cohort_title = null;
|
| 73 |
+
var detail_url = null;
|
| 74 |
+
var page = null;
|
| 75 |
+
|
| 76 |
+
// *********** Summary view methods
|
| 77 |
+
|
| 78 |
+
function show_cohort(item) {
|
| 79 |
+
// item is a li that has a data-href link to the cohort base url
|
| 80 |
+
var el = $(this);
|
| 81 |
+
cohort_title = el.text();
|
| 82 |
+
detail_url = el.data('href');
|
| 83 |
+
cohort_id = el.data('id');
|
| 84 |
+
state = state_detail;
|
| 85 |
+
render();
|
| 86 |
+
return false;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
function add_to_cohorts_list(item) {
|
| 90 |
+
var li = $('<li><a href="#"></a></li>');
|
| 91 |
+
$("a", li).text(item.name)
|
| 92 |
+
.data('href', url + '/' + item.id)
|
| 93 |
+
.addClass('link')
|
| 94 |
+
.click(show_cohort);
|
| 95 |
+
cohorts.append(li);
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
function log_error(msg) {
|
| 99 |
+
errors.empty();
|
| 100 |
+
errors.append($("<li />").text(msg).addClass("error"));
|
| 101 |
+
};
|
| 102 |
+
|
| 103 |
+
function load_cohorts(response) {
|
| 104 |
+
cohorts.empty();
|
| 105 |
+
if (response && response.success) {
|
| 106 |
+
response.cohorts.forEach(add_to_cohorts_list);
|
| 107 |
+
} else {
|
| 108 |
+
log_error(response.msg || "There was an error loading cohorts");
|
| 109 |
+
}
|
| 110 |
+
summary.show();
|
| 111 |
+
};
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
function added_cohort(response) {
|
| 115 |
+
if (response && response.success) {
|
| 116 |
+
add_to_cohorts_list(response.cohort);
|
| 117 |
+
} else {
|
| 118 |
+
log_error(response.msg || "There was an error adding a cohort");
|
| 119 |
+
}
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
// *********** Detail view methods
|
| 123 |
+
|
| 124 |
+
function remove_user_from_cohort(username, cohort_id, row) {
|
| 125 |
+
var delete_url = detail_url + '/delete';
|
| 126 |
+
var data = {'username': username}
|
| 127 |
+
$.post(delete_url, data).done(function() {row.remove()})
|
| 128 |
+
.fail(function(jqXHR, status, error) {
|
| 129 |
+
log_error('Error removing user ' + username +
|
| 130 |
+
' from cohort. ' + status + ' ' + error);
|
| 131 |
+
});
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
function add_to_users_list(item) {
|
| 135 |
+
var tr = $('<tr><td class="name"></td><td class="username"></td>' +
|
| 136 |
+
'<td class="email"></td>' +
|
| 137 |
+
'<td class="remove"></td></tr>');
|
| 138 |
+
var current_cohort_id = cohort_id;
|
| 139 |
+
|
| 140 |
+
$(".name", tr).text(item.name);
|
| 141 |
+
$(".username", tr).text(item.username);
|
| 142 |
+
$(".email", tr).text(item.email);
|
| 143 |
+
|
| 144 |
+
$(".remove", tr).html('<a href="#">remove</a>')
|
| 145 |
+
.click(function() {
|
| 146 |
+
remove_user_from_cohort(item.username, current_cohort_id, tr);
|
| 147 |
+
return false;
|
| 148 |
+
});
|
| 149 |
+
|
| 150 |
+
detail_users.append(tr);
|
| 151 |
+
};
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
function show_users(response) {
|
| 155 |
+
detail_users.html("<tr><th>Name</th><th>Username</th><th>Email</th></tr>");
|
| 156 |
+
if (response && response.success) {
|
| 157 |
+
response.users.forEach(add_to_users_list);
|
| 158 |
+
detail_page_num.text("Page " + response.page + " of " + response.num_pages);
|
| 159 |
+
} else {
|
| 160 |
+
log_error(response.msg ||
|
| 161 |
+
"There was an error loading users for " + cohort.title);
|
| 162 |
+
}
|
| 163 |
+
op_results.empty();
|
| 164 |
+
detail.show();
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
function added_users(response) {
|
| 169 |
+
op_results.empty();
|
| 170 |
+
if (response && response.success) {
|
| 171 |
+
function add_to_list(text, color) {
|
| 172 |
+
op_results.append($("<li/>").text(text).css("color", color));
|
| 173 |
+
}
|
| 174 |
+
response.added.forEach(
|
| 175 |
+
function(item) {
|
| 176 |
+
add_to_list(
|
| 177 |
+
"Added: " + item.name + ", " + item.username + ", " + item.email,
|
| 178 |
+
"green"
|
| 179 |
+
);
|
| 180 |
+
}
|
| 181 |
+
);
|
| 182 |
+
response.changed.forEach(
|
| 183 |
+
function(item) {
|
| 184 |
+
add_to_list(
|
| 185 |
+
"Moved from cohort " + item.previous_cohort + ": " + item.name + ", " + item.username + ", " + item.email,
|
| 186 |
+
"purple"
|
| 187 |
+
)
|
| 188 |
+
}
|
| 189 |
+
);
|
| 190 |
+
response.present.forEach(
|
| 191 |
+
function(item) {
|
| 192 |
+
add_to_list("Already present: " + item, "black");
|
| 193 |
+
}
|
| 194 |
+
);
|
| 195 |
+
response.unknown.forEach(
|
| 196 |
+
function(item) {
|
| 197 |
+
add_to_list("Unknown user: " + item, "red")
|
| 198 |
+
}
|
| 199 |
+
);
|
| 200 |
+
users_area.val('')
|
| 201 |
+
} else {
|
| 202 |
+
log_error(response.msg || "There was an error adding users");
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
// ******* Rendering
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
function render() {
|
| 210 |
+
// Load and render the right thing based on the state
|
| 211 |
+
|
| 212 |
+
// start with both divs hidden
|
| 213 |
+
summary.hide();
|
| 214 |
+
detail.hide();
|
| 215 |
+
// and clear out the errors
|
| 216 |
+
errors.empty();
|
| 217 |
+
if (state == state_summary) {
|
| 218 |
+
$.ajax(url).done(load_cohorts).fail(function() {
|
| 219 |
+
log_error("Error trying to load cohorts");
|
| 220 |
+
});
|
| 221 |
+
} else if (state == state_detail) {
|
| 222 |
+
detail_header.text("Members of " + cohort_title);
|
| 223 |
+
$.ajax(detail_url).done(show_users).fail(function() {
|
| 224 |
+
log_error("Error trying to load users in cohort");
|
| 225 |
+
});
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
show_cohorts_button.click(function() {
|
| 230 |
+
state = state_summary;
|
| 231 |
+
render();
|
| 232 |
+
return false;
|
| 233 |
+
});
|
| 234 |
+
|
| 235 |
+
add_cohort_input.change(function() {
|
| 236 |
+
if (!$(this).val()) {
|
| 237 |
+
add_cohort_button.removeClass('button').addClass('button-disabled');
|
| 238 |
+
} else {
|
| 239 |
+
add_cohort_button.removeClass('button-disabled').addClass('button');
|
| 240 |
+
}
|
| 241 |
+
});
|
| 242 |
+
|
| 243 |
+
add_cohort_button.click(function() {
|
| 244 |
+
var add_url = url + '/add';
|
| 245 |
+
data = {'name': add_cohort_input.val()}
|
| 246 |
+
$.post(add_url, data).done(added_cohort);
|
| 247 |
+
return false;
|
| 248 |
+
});
|
| 249 |
+
|
| 250 |
+
add_members_button.click(function() {
|
| 251 |
+
var add_url = detail_url + '/add';
|
| 252 |
+
data = {'users': users_area.val()}
|
| 253 |
+
$.post(add_url, data).done(added_users);
|
| 254 |
+
return false;
|
| 255 |
+
});
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
};
|
| 259 |
+
|
| 260 |
+
// prototype
|
| 261 |
+
module.prototype = {
|
| 262 |
+
constructor: module,
|
| 263 |
+
};
|
| 264 |
+
|
| 265 |
+
// return module
|
| 266 |
+
return module;
|
| 267 |
+
})(jQuery);
|
| 268 |
+
|
| 269 |
+
$(window).load(function () {
|
| 270 |
+
var my_module = new CohortManager();
|
| 271 |
+
})
|
| 272 |
+
|
pool/shard011/JavaScript/0070325_tr.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var catw = require('../');
|
| 2 |
+
var test = require('tape');
|
| 3 |
+
var fs = require('fs');
|
| 4 |
+
var path = require('path');
|
| 5 |
+
var os = require('os');
|
| 6 |
+
var tmpdir = os.tmpdir || os.tmpDir;
|
| 7 |
+
var mkdirp = require('mkdirp');
|
| 8 |
+
var concat = require('concat-stream');
|
| 9 |
+
var through = require('through');
|
| 10 |
+
|
| 11 |
+
test('source transform', function (t) {
|
| 12 |
+
t.plan(4);
|
| 13 |
+
var dir = path.join(tmpdir(), 'cat-watch-test-exec', Math.random()+'');
|
| 14 |
+
mkdirp.sync(dir);
|
| 15 |
+
|
| 16 |
+
fs.writeFileSync(path.join(dir, 'beep.txt'), 'beep');
|
| 17 |
+
fs.writeFileSync(path.join(dir, 'boop.txt'), 'boop');
|
| 18 |
+
|
| 19 |
+
var cat = catw(path.join(dir, '*.txt'), {
|
| 20 |
+
transform: function (file) {
|
| 21 |
+
if (path.basename(file) !== 'beep.txt') return through();
|
| 22 |
+
return through(write);
|
| 23 |
+
function write (buf) {
|
| 24 |
+
this.queue(buf.toString('utf8').toUpperCase());
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
});
|
| 28 |
+
t.on('end', function () { cat.close() });
|
| 29 |
+
var expected = [ 'BEEPboop', 'BEEP boop', 'BEEP boop!', 'BEEP boop!!!' ];
|
| 30 |
+
|
| 31 |
+
cat.on('stream', function (stream) {
|
| 32 |
+
stream.pipe(concat(function (body) {
|
| 33 |
+
t.equal(body.toString('utf8'), expected.shift());
|
| 34 |
+
setTimeout(nextUpdate, 100);
|
| 35 |
+
}));
|
| 36 |
+
});
|
| 37 |
+
|
| 38 |
+
var updates = [
|
| 39 |
+
[ 'beep.txt', 'beep ' ],
|
| 40 |
+
[ 'boop.txt', 'boop!' ],
|
| 41 |
+
[ 'c.txt', '!!' ]
|
| 42 |
+
];
|
| 43 |
+
|
| 44 |
+
function nextUpdate () {
|
| 45 |
+
if (updates.length === 0) return;
|
| 46 |
+
var file = updates.shift();
|
| 47 |
+
fs.writeFile(path.join(dir, file[0]), file[1], function (err) {
|
| 48 |
+
if (err) return t.fail(err)
|
| 49 |
+
});
|
| 50 |
+
}
|
| 51 |
+
});
|
pool/shard011/JavaScript/0070328_params.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
*
|
| 3 |
+
* ProjectName:blogme
|
| 4 |
+
* Description:
|
| 5 |
+
* Created by qimuyunduan on 16/4/13 .
|
| 6 |
+
* Revise person:qimuyunduan
|
| 7 |
+
* Revise Time:16/4/13 下午3:27
|
| 8 |
+
* @version
|
| 9 |
+
*
|
| 10 |
+
*/
|
| 11 |
+
var _ = require('lodash'),
|
| 12 |
+
Promise = require('bluebird'),
|
| 13 |
+
errors = require('../errors'),
|
| 14 |
+
utils = require('../utils'),
|
| 15 |
+
events = require('../events'),
|
| 16 |
+
appBookshelf = require('./base'),
|
| 17 |
+
validator = require('validator'),
|
| 18 |
+
param,
|
| 19 |
+
params;
|
| 20 |
+
|
| 21 |
+
param = appBookshelf.Model.extend({
|
| 22 |
+
|
| 23 |
+
tableName: ' params ',
|
| 24 |
+
|
| 25 |
+
saving: function saving() {
|
| 26 |
+
|
| 27 |
+
var self = this;
|
| 28 |
+
|
| 29 |
+
},
|
| 30 |
+
|
| 31 |
+
validate: function validate() {
|
| 32 |
+
|
| 33 |
+
},
|
| 34 |
+
|
| 35 |
+
toJSON: function toJSON(options) {
|
| 36 |
+
options = options || {};
|
| 37 |
+
|
| 38 |
+
var attrs = appBookshelf.Model.prototype.toJSON.call(this, options);
|
| 39 |
+
// remove password hash for security reasons
|
| 40 |
+
delete attrs.password;
|
| 41 |
+
|
| 42 |
+
if (!options || !options.context || (!options.context.user && !options.context.internal)) {
|
| 43 |
+
delete attrs.email;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
return attrs;
|
| 47 |
+
},
|
| 48 |
+
|
| 49 |
+
format: function format(options) {
|
| 50 |
+
if (!_.isEmpty(options.website) &&
|
| 51 |
+
!validator.isURL(options.website, {
|
| 52 |
+
require_protocol: true,
|
| 53 |
+
protocols: ['http', 'https']})) {
|
| 54 |
+
options.website = 'http://' + options.website;
|
| 55 |
+
}
|
| 56 |
+
return appBookshelf.Model.prototype.format.call(this, options);
|
| 57 |
+
},
|
| 58 |
+
|
| 59 |
+
findOne: function findOne(data, options) {
|
| 60 |
+
|
| 61 |
+
},
|
| 62 |
+
|
| 63 |
+
edit: function edit(data, options) {
|
| 64 |
+
|
| 65 |
+
},
|
| 66 |
+
|
| 67 |
+
add: function add(data, options) {
|
| 68 |
+
|
| 69 |
+
},
|
| 70 |
+
|
| 71 |
+
// Finds the user by email, and checks the password
|
| 72 |
+
check: function check(object) {
|
| 73 |
+
|
| 74 |
+
},
|
| 75 |
+
|
| 76 |
+
changePassword: function changePassword(object, options) {
|
| 77 |
+
|
| 78 |
+
},
|
| 79 |
+
|
| 80 |
+
generateResetToken: function generateResetToken(email, expires, dbHash) {
|
| 81 |
+
return this.getByEmail(email).then(function then(foundUser) {
|
| 82 |
+
if (!foundUser) {
|
| 83 |
+
return Promise.reject(new errors.NotFoundError('errors.models.user.noUserWithEnteredEmailAddr'));
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
var hash = crypto.createHash('sha256'),
|
| 87 |
+
text = '';
|
| 88 |
+
|
| 89 |
+
// Token:
|
| 90 |
+
// BASE64(TIMESTAMP + email + HASH(TIMESTAMP + email + oldPasswordHash + dbHash ))
|
| 91 |
+
hash.update(String(expires));
|
| 92 |
+
hash.update(email.toLocaleLowerCase());
|
| 93 |
+
hash.update(foundUser.get('password'));
|
| 94 |
+
hash.update(String(dbHash));
|
| 95 |
+
|
| 96 |
+
text += [expires, email, hash.digest('base64')].join('|');
|
| 97 |
+
return new Buffer(text).toString('base64');
|
| 98 |
+
});
|
| 99 |
+
},
|
| 100 |
+
|
| 101 |
+
validateToken: function validateToken(token, dbHash) {
|
| 102 |
+
|
| 103 |
+
var tokenText = new Buffer(token, 'base64').toString('ascii'),
|
| 104 |
+
parts,
|
| 105 |
+
expires,
|
| 106 |
+
email;
|
| 107 |
+
|
| 108 |
+
parts = tokenText.split('|');
|
| 109 |
+
|
| 110 |
+
// Check if invalid structure
|
| 111 |
+
if (!parts || parts.length !== 3) {
|
| 112 |
+
return Promise.reject(new errors.BadRequestError('errors.models.user.invalidTokenStructure'));
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
expires = parseInt(parts[0], 10);
|
| 116 |
+
email = parts[1];
|
| 117 |
+
|
| 118 |
+
if (isNaN(expires)) {
|
| 119 |
+
return Promise.reject(new errors.BadRequestError('errors.models.user.invalidTokenExpiration'));
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
if (expires < Date.now()) {
|
| 123 |
+
return Promise.reject(new errors.ValidationError('errors.models.user.expiredToken'));
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
if (tokenSecurity[email + '+' + expires] && tokenSecurity[email + '+' + expires].count >= 10) {
|
| 127 |
+
return Promise.reject(new errors.NoPermissionError('errors.models.user.tokenLocked'));
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
return this.generateResetToken(email, expires, dbHash).then(function then(generatedToken) {
|
| 131 |
+
// Check for matching tokens with timing independent comparison
|
| 132 |
+
var diff = 0,
|
| 133 |
+
i;
|
| 134 |
+
|
| 135 |
+
// check if the token length is correct
|
| 136 |
+
if (token.length !== generatedToken.length) {
|
| 137 |
+
diff = 1;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
for (i = token.length - 1; i >= 0; i = i - 1) {
|
| 141 |
+
diff |= token.charCodeAt(i) ^ generatedToken.charCodeAt(i);
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
if (diff === 0) {
|
| 145 |
+
return email;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
tokenSecurity[email + '+' + expires] = {
|
| 149 |
+
count: tokenSecurity[email + '+' + expires] ? tokenSecurity[email + '+' + expires].count + 1 : 1
|
| 150 |
+
};
|
| 151 |
+
return Promise.reject(new errors.BadRequestError('errors.models.user.invalidToken'));
|
| 152 |
+
});
|
| 153 |
+
},
|
| 154 |
+
|
| 155 |
+
});
|
| 156 |
+
|
| 157 |
+
params = appBookshelf.Collection.extend({
|
| 158 |
+
model:param
|
| 159 |
+
});
|
| 160 |
+
|
| 161 |
+
module.exports = {
|
| 162 |
+
param:{
|
| 163 |
+
model: function(){
|
| 164 |
+
return param;
|
| 165 |
+
},
|
| 166 |
+
collection:function(){
|
| 167 |
+
return params;
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
};
|
pool/shard011/JavaScript/0070330_idempotency.spec.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { markdownToDraft, draftToMarkdown } from '../src/index';
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* Note: These tests are to make sure markdown to draft and then back to markdown have the exact same value before-and-after
|
| 5 |
+
*
|
| 6 |
+
* However, there are some cases where this will not be possible -
|
| 7 |
+
* For example, this is valid in draftjs:
|
| 8 |
+
* _I am italic content with a space included at the end _
|
| 9 |
+
* but markdown will struggle with this so we need to convert it to:
|
| 10 |
+
* _I am italic content with a space after the closing italic symbol instead of before_
|
| 11 |
+
* The end result should basically look the same to a human, but behind the scenes it has to be a bit different.
|
| 12 |
+
*
|
| 13 |
+
* Still, for the most part results should match, so these tests are for cases when they _should_ match.
|
| 14 |
+
*/
|
| 15 |
+
|
| 16 |
+
describe('idempotency', function () {
|
| 17 |
+
|
| 18 |
+
it('renders new lines text correctly', function () {
|
| 19 |
+
var markdownString = 'Test\n\n\nHello There\n\nSmile\n\n\n\n\n\n\n\nYep Hi';
|
| 20 |
+
var draftJSObject = markdownToDraft(markdownString, {preserveNewlines: true});
|
| 21 |
+
var markdownFromDraft = draftToMarkdown(draftJSObject, {preserveNewlines: true});
|
| 22 |
+
|
| 23 |
+
expect(markdownFromDraft).toEqual(markdownString);
|
| 24 |
+
|
| 25 |
+
markdownString = 'a\nb\n\nc\n\n\nd';
|
| 26 |
+
draftJSObject = markdownToDraft(markdownString, {preserveNewlines: true});
|
| 27 |
+
markdownFromDraft = draftToMarkdown(draftJSObject, {preserveNewlines: true});
|
| 28 |
+
|
| 29 |
+
expect(markdownFromDraft).toEqual(markdownString);
|
| 30 |
+
|
| 31 |
+
markdownString = '\n\na';
|
| 32 |
+
draftJSObject = markdownToDraft(markdownString, {preserveNewlines: true});
|
| 33 |
+
markdownFromDraft = draftToMarkdown(draftJSObject, {preserveNewlines: true});
|
| 34 |
+
expect(markdownFromDraft).toEqual(markdownString);
|
| 35 |
+
|
| 36 |
+
});
|
| 37 |
+
|
| 38 |
+
it('renders new lines text correctly with styled blocks', function () {
|
| 39 |
+
var markdownString = '# Test\n\n\nHello There\n\nSmile\n\n\n\n\n\n\n\nYep Hi';
|
| 40 |
+
var draftJSObject = markdownToDraft(markdownString, {preserveNewlines: true});
|
| 41 |
+
var markdownFromDraft = draftToMarkdown(draftJSObject, {preserveNewlines: true});
|
| 42 |
+
|
| 43 |
+
expect(markdownFromDraft).toEqual(markdownString);
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
it ('renders preserved new lines after list correctly', function () {
|
| 47 |
+
var markdown = '- unordered item\n\n\n1. ordered item\n\n\nparagraph'
|
| 48 |
+
var rawDraftConversion = markdownToDraft(markdown, {preserveNewlines: true });
|
| 49 |
+
var markdownConversion = draftToMarkdown(rawDraftConversion, {preserveNewlines: true});
|
| 50 |
+
|
| 51 |
+
expect(markdownConversion).toEqual(markdown);
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
it('renders blockquotes correctly', function () {
|
| 55 |
+
var markdownString = '> Hello I am Blockquote\n\nI am not\n\n> I am';
|
| 56 |
+
var draftJSObject = markdownToDraft(markdownString, {preserveNewlines: true});
|
| 57 |
+
var markdownFromDraft = draftToMarkdown(draftJSObject, {preserveNewlines: true});
|
| 58 |
+
expect(markdownFromDraft).toEqual(markdownString);
|
| 59 |
+
});
|
| 60 |
+
|
| 61 |
+
it('renders italic text correctly', function () {
|
| 62 |
+
var markdownString = '_I am italic_ …I am not italic.';
|
| 63 |
+
var draftJSObject = markdownToDraft(markdownString);
|
| 64 |
+
var markdownFromDraft = draftToMarkdown(draftJSObject);
|
| 65 |
+
|
| 66 |
+
expect(markdownFromDraft).toEqual(markdownString);
|
| 67 |
+
});
|
| 68 |
+
|
| 69 |
+
it('renders bold text correctly', function () {
|
| 70 |
+
var markdownString = 'Hello **I am bold** I am not bold.';
|
| 71 |
+
var draftJSObject = markdownToDraft(markdownString);
|
| 72 |
+
var markdownFromDraft = draftToMarkdown(draftJSObject);
|
| 73 |
+
|
| 74 |
+
expect(markdownFromDraft).toEqual(markdownString);
|
| 75 |
+
});
|
| 76 |
+
|
| 77 |
+
it('renders nested styles correctly', function () {
|
| 78 |
+
var markdownString = '**bold** _italic_ test **bold _italic_** _italic_ _italic **bold** italic **bold italic**_';
|
| 79 |
+
var draftJSObject = markdownToDraft(markdownString);
|
| 80 |
+
var markdownFromDraft = draftToMarkdown(draftJSObject);
|
| 81 |
+
|
| 82 |
+
expect(markdownFromDraft).toEqual(markdownString);
|
| 83 |
+
});
|
| 84 |
+
|
| 85 |
+
it('renders inline code correctly', function () {
|
| 86 |
+
var markdownString = 'Test `here is some inline code`';
|
| 87 |
+
var draftJSObject = markdownToDraft(markdownString);
|
| 88 |
+
var markdownFromDraft = draftToMarkdown(draftJSObject);
|
| 89 |
+
|
| 90 |
+
expect(markdownFromDraft).toEqual(markdownString);
|
| 91 |
+
});
|
| 92 |
+
|
| 93 |
+
it('renders code fences correctly', function () {
|
| 94 |
+
var markdownString = '```\nHello I am Codefence\n```';
|
| 95 |
+
var draftJSObject = markdownToDraft(markdownString);
|
| 96 |
+
var markdownFromDraft = draftToMarkdown(draftJSObject);
|
| 97 |
+
|
| 98 |
+
expect(markdownFromDraft).toEqual(markdownString);
|
| 99 |
+
});
|
| 100 |
+
|
| 101 |
+
it('renders blockquotes correctly', function () {
|
| 102 |
+
var markdownString = '> Hello I am Blockquote';
|
| 103 |
+
var draftJSObject = markdownToDraft(markdownString);
|
| 104 |
+
var markdownFromDraft = draftToMarkdown(draftJSObject);
|
| 105 |
+
|
| 106 |
+
expect(markdownFromDraft).toEqual(markdownString);
|
| 107 |
+
});
|
| 108 |
+
|
| 109 |
+
// TODO this test should pass but markdown-to-draft doesn’t correctly create empty markdown blocks in this case currently.
|
| 110 |
+
xit('renders blockquotes with blank lines correctly', function () {
|
| 111 |
+
var markdownString = '> Hello I am Blockquote\n> more\n> \n> \n> hey';
|
| 112 |
+
var draftJSObject = markdownToDraft(markdownString);
|
| 113 |
+
var markdownFromDraft = draftToMarkdown(draftJSObject);
|
| 114 |
+
|
| 115 |
+
expect(markdownFromDraft).toEqual(markdownString);
|
| 116 |
+
});
|
| 117 |
+
|
| 118 |
+
it('renders links correctly', function () {
|
| 119 |
+
var markdown = 'This is a test of [a link](https://google.com)\n\nAnd [perhaps](https://facebook.github.io/draft-js/) we should test once more.';
|
| 120 |
+
var rawDraftConversion = markdownToDraft(markdown);
|
| 121 |
+
var markdownConversion = draftToMarkdown(rawDraftConversion);
|
| 122 |
+
|
| 123 |
+
expect(markdownConversion).toEqual(markdown);
|
| 124 |
+
});
|
| 125 |
+
|
| 126 |
+
it ('renders codeblock with syntax correctly', function () {
|
| 127 |
+
var markdown = '```javascript\nsingle line codeblock\n```';
|
| 128 |
+
var rawDraftConversion = markdownToDraft(markdown);
|
| 129 |
+
var markdownConversion = draftToMarkdown(rawDraftConversion);
|
| 130 |
+
expect(markdownConversion).toEqual(markdown);
|
| 131 |
+
});
|
| 132 |
+
|
| 133 |
+
it('renders "the kitchen sink" correctly', function () {
|
| 134 |
+
var markdown = '# Hello!\n\nMy name is **Rose** :)\nToday, I\'m here to talk to you about how great markdown is!\n\n## First, here\'s a few bullet points:\n\n- One\n- Two\n- Three\n\n```\nA codeblock\n```\n\nAnd then... `some monospace text`?\nOr... _italics?_';
|
| 135 |
+
var rawDraftConversion = markdownToDraft(markdown);
|
| 136 |
+
var markdownConversion = draftToMarkdown(rawDraftConversion);
|
| 137 |
+
|
| 138 |
+
expect(markdownConversion).toEqual(markdown);
|
| 139 |
+
});
|
| 140 |
+
|
| 141 |
+
it ('renders escaped italics correctly', function () {
|
| 142 |
+
var markdown = 'test \\_not italic\\_ test';
|
| 143 |
+
var rawDraftConversion = markdownToDraft(markdown);
|
| 144 |
+
var markdownConversion = draftToMarkdown(rawDraftConversion);
|
| 145 |
+
|
| 146 |
+
expect(markdownConversion).toEqual(markdown);
|
| 147 |
+
});
|
| 148 |
+
|
| 149 |
+
it ('renders escaped bold correctly', function () {
|
| 150 |
+
var markdown = 'test \\*\\*not italic\\*\\* test';
|
| 151 |
+
var rawDraftConversion = markdownToDraft(markdown);
|
| 152 |
+
var markdownConversion = draftToMarkdown(rawDraftConversion);
|
| 153 |
+
|
| 154 |
+
expect(markdownConversion).toEqual(markdown);
|
| 155 |
+
});
|
| 156 |
+
});
|
pool/shard011/JavaScript/0070333_a.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* 2017-9-16 sunzhiyue
|
| 3 |
+
*/
|
| 4 |
+
var b = function(){
|
| 5 |
+
|
| 6 |
+
};
|
| 7 |
+
b.arr = [1, 2, 3, 4, 5];
|
| 8 |
+
b.obj = {
|
| 9 |
+
name : 'wan',
|
| 10 |
+
age : 18,
|
| 11 |
+
car : true
|
| 12 |
+
}
|
| 13 |
+
b.fun = function(){
|
| 14 |
+
console.log('fun');
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
Object.defineProperty(b,'len',{
|
| 18 |
+
enumerable: true,
|
| 19 |
+
configurable: false,
|
| 20 |
+
get: function() { return this.arr.length; }
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
)
|
| 24 |
+
b.arr.length = 10;
|
| 25 |
+
console.log(b.len);
|
| 26 |
+
console.log(b.obj.len);
|
pool/shard011/JavaScript/0070334_script.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var onlyUniques = (...args) => {
|
| 2 |
+
let array = [];
|
| 3 |
+
for (let i = 0; i < args.length; i++) {
|
| 4 |
+
if (!array.includes(args[i])) {
|
| 5 |
+
array.push(args[i]);
|
| 6 |
+
}
|
| 7 |
+
}
|
| 8 |
+
return array;
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
console.log(onlyUniques("cat", "cat", "dog", "pig")); //['cat', 'dog', 'pig']
|
| 12 |
+
console.log(onlyUniques(1, 4, 7, 1, 2, 7, 4)); //[1, 4, 7, 2]
|
pool/shard011/JavaScript/0070335_express.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var Q = require('q'),
|
| 2 |
+
pkg = require('../package.json'),
|
| 3 |
+
|
| 4 |
+
express = require('express'),
|
| 5 |
+
consolidate = require('consolidate'),
|
| 6 |
+
morgan = require('morgan'),
|
| 7 |
+
compression = require('compression'),
|
| 8 |
+
finalhandler = require('finalhandler'),
|
| 9 |
+
colors = require('colors/safe'),
|
| 10 |
+
http = require('http'),
|
| 11 |
+
env = require('./env.js');
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
// ----------------------------------------------------------------------------
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
console.log(colors.underline(pkg.name) + ' v' + pkg.version + ' starting up...');
|
| 18 |
+
|
| 19 |
+
Q.when(makeApp()).then(function(app) {
|
| 20 |
+
|
| 21 |
+
var server = http.createServer(app),
|
| 22 |
+
port = env('expressPort');
|
| 23 |
+
|
| 24 |
+
server.listen(port, '0.0.0.0', function () {
|
| 25 |
+
console.info(colors.blue('listening on port %s'), port);
|
| 26 |
+
});
|
| 27 |
+
|
| 28 |
+
});
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
// ----------------------------------------------------------------------------
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
morgan.token('ms', function (req, res){
|
| 35 |
+
if (!res._header || !req._startAt) { return ''; }
|
| 36 |
+
var diff = process.hrtime(req._startAt);
|
| 37 |
+
var ms = diff[0] * 1e3 + diff[1] * 1e-6;
|
| 38 |
+
return Math.ceil(ms)+'ms';
|
| 39 |
+
});
|
| 40 |
+
|
| 41 |
+
function render404 (req, res) {
|
| 42 |
+
finalhandler(req, res)(false);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
function makeApp () {
|
| 47 |
+
|
| 48 |
+
var app = express(),
|
| 49 |
+
log = morgan( ':method :url :ms :status' );
|
| 50 |
+
|
| 51 |
+
app.engine('html', consolidate.lodash);
|
| 52 |
+
app.set('view engine', 'html');
|
| 53 |
+
app.set('views', __dirname);
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
// middleware stack starts here
|
| 57 |
+
app.use(compression());
|
| 58 |
+
|
| 59 |
+
app.get('/robots.txt', [
|
| 60 |
+
log,
|
| 61 |
+
function (req, res) {
|
| 62 |
+
res.type('text/plain');
|
| 63 |
+
res.send('User-agent: *\nDisallow: /');
|
| 64 |
+
}
|
| 65 |
+
]);
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
app.use('/api/foo', [
|
| 69 |
+
log,
|
| 70 |
+
function (req, res, next) {
|
| 71 |
+
var d = parseInt(req.query.delay, 10);
|
| 72 |
+
if(d>0) { setTimeout(next, Math.min(d,10) * 1000); }
|
| 73 |
+
else next();
|
| 74 |
+
},
|
| 75 |
+
render404
|
| 76 |
+
]);
|
| 77 |
+
|
| 78 |
+
// serve the api
|
| 79 |
+
app.use('/api', [
|
| 80 |
+
log,
|
| 81 |
+
require('./api/index.js'),
|
| 82 |
+
render404
|
| 83 |
+
]);
|
| 84 |
+
|
| 85 |
+
// any other path, serve 404
|
| 86 |
+
app.all('*', [
|
| 87 |
+
log,
|
| 88 |
+
render404
|
| 89 |
+
]);
|
| 90 |
+
|
| 91 |
+
var mongo = require('./mongo.js');
|
| 92 |
+
|
| 93 |
+
if(mongo.connection.readyState === 1) {
|
| 94 |
+
return app;
|
| 95 |
+
}
|
| 96 |
+
else {
|
| 97 |
+
return Q.ninvoke(mongo.connection, 'once', 'connected').then(function() {
|
| 98 |
+
return app;
|
| 99 |
+
});
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
}
|
pool/shard011/JavaScript/0070336_index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { Fragment } from 'react';
|
| 2 |
+
import PropTypes from 'prop-types';
|
| 3 |
+
import { connect } from 'react-redux';
|
| 4 |
+
import { createStructuredSelector } from 'reselect';
|
| 5 |
+
|
| 6 |
+
import { titleCase, truncate } from 'voca';
|
| 7 |
+
|
| 8 |
+
import { selectPrimaryMeaning, selectSecondaryMeanings } from 'features/reviews/selectors';
|
| 9 |
+
|
| 10 |
+
import { PrimaryMeaning, SecondaryMeanings } from './styles';
|
| 11 |
+
|
| 12 |
+
VocabMeaning.propTypes = {
|
| 13 |
+
primaryMeaning: PropTypes.string.isRequired,
|
| 14 |
+
secondaryMeanings: PropTypes.arrayOf(PropTypes.string),
|
| 15 |
+
shouldTruncate: PropTypes.bool,
|
| 16 |
+
showSecondary: PropTypes.bool,
|
| 17 |
+
renderPrimary: PropTypes.func,
|
| 18 |
+
renderSecondary: PropTypes.func,
|
| 19 |
+
};
|
| 20 |
+
|
| 21 |
+
VocabMeaning.defaultProps = {
|
| 22 |
+
secondaryMeanings: [],
|
| 23 |
+
showSecondary: true,
|
| 24 |
+
shouldTruncate: false,
|
| 25 |
+
renderPrimary: ({ text }) => <PrimaryMeaning>{text}</PrimaryMeaning>, // eslint-disable-line react/prop-types
|
| 26 |
+
renderSecondary: ({ text }) => text && <SecondaryMeanings>{text}</SecondaryMeanings>, // eslint-disable-line react/prop-types
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
function VocabMeaning({
|
| 30 |
+
primaryMeaning,
|
| 31 |
+
secondaryMeanings,
|
| 32 |
+
shouldTruncate,
|
| 33 |
+
showSecondary,
|
| 34 |
+
renderPrimary,
|
| 35 |
+
renderSecondary,
|
| 36 |
+
}) {
|
| 37 |
+
const noSplit = ["'"];
|
| 38 |
+
let secondaryText = secondaryMeanings.join(', ');
|
| 39 |
+
secondaryText = truncate(secondaryText, shouldTruncate ? 30 : secondaryText.length);
|
| 40 |
+
return (
|
| 41 |
+
<Fragment>
|
| 42 |
+
{renderPrimary({ text: titleCase(primaryMeaning, noSplit) })}
|
| 43 |
+
{showSecondary &&
|
| 44 |
+
!!secondaryText.length &&
|
| 45 |
+
renderSecondary({ text: titleCase(secondaryText, noSplit) })}
|
| 46 |
+
</Fragment>
|
| 47 |
+
);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
const mapStateToProps = createStructuredSelector({
|
| 51 |
+
primaryMeaning: selectPrimaryMeaning,
|
| 52 |
+
secondaryMeanings: selectSecondaryMeanings,
|
| 53 |
+
});
|
| 54 |
+
|
| 55 |
+
export default connect(mapStateToProps)(VocabMeaning);
|
pool/shard011/JavaScript/0070337_utils.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export class VisibilityTracker {
|
| 2 |
+
constructor(
|
| 3 |
+
{ratioThreshold = 0.9, durationThreshold = 2, upperDurationThreshold = 1800} = {},
|
| 4 |
+
onFlush = () => {}
|
| 5 |
+
) {
|
| 6 |
+
this.components = {};
|
| 7 |
+
this.groups = {};
|
| 8 |
+
this.ratioThreshold = ratioThreshold;
|
| 9 |
+
this.durationThreshold = durationThreshold;
|
| 10 |
+
// Upper duration threshold should remove any cases where the page is left
|
| 11 |
+
// open and forgotten
|
| 12 |
+
this.upperDurationThreshold = upperDurationThreshold;
|
| 13 |
+
|
| 14 |
+
document.addEventListener('visibilitychange', () => {
|
| 15 |
+
if (document.visibilityState === 'hidden') {
|
| 16 |
+
this.stopAndFlush(onFlush);
|
| 17 |
+
} else if (document.visibilityState === 'visible') {
|
| 18 |
+
this.restart();
|
| 19 |
+
}
|
| 20 |
+
});
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
update(comp, entry) {
|
| 24 |
+
let screenCoveredRatio = 0;
|
| 25 |
+
if (entry.rootBounds && entry.rootBounds.height !== 0) {
|
| 26 |
+
const rootArea = entry.rootBounds.height * entry.rootBounds.width;
|
| 27 |
+
const cardArea = entry.boundingClientRect.height * entry.boundingClientRect.width;
|
| 28 |
+
screenCoveredRatio = 1 - (rootArea - (cardArea * entry.intersectionRatio)) / rootArea;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
// Update or add the component
|
| 32 |
+
if (!this.components[comp.$meta.uid]) {
|
| 33 |
+
this.components[comp.$meta.uid] = {}
|
| 34 |
+
}
|
| 35 |
+
const compData = this.components[comp.$meta.uid];
|
| 36 |
+
compData.component = comp;
|
| 37 |
+
compData.intersectionRatio = entry.intersectionRatio;
|
| 38 |
+
compData.screenCoveredRatio = screenCoveredRatio;
|
| 39 |
+
compData.isVisible = this.isCompVisible(comp);
|
| 40 |
+
|
| 41 |
+
const group = comp.$meta.group;
|
| 42 |
+
if (!group) return;
|
| 43 |
+
|
| 44 |
+
// Group the component
|
| 45 |
+
if (!this.groups[group.$meta.uid]) {
|
| 46 |
+
const components = this.components;
|
| 47 |
+
this.groups[group.$meta.uid] = {
|
| 48 |
+
tag: group.$meta.tag,
|
| 49 |
+
components: [],
|
| 50 |
+
get isVisible() {
|
| 51 |
+
return this.components.some((uid) => components[uid].isVisible);
|
| 52 |
+
},
|
| 53 |
+
};
|
| 54 |
+
}
|
| 55 |
+
if (
|
| 56 |
+
this.groups[group.$meta.uid].components.indexOf(comp.$meta.uid) === -1
|
| 57 |
+
) {
|
| 58 |
+
this.groups[group.$meta.uid].components.push(comp.$meta.uid);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
const timer = this.updateGroupTimer(group);
|
| 62 |
+
const duration = (Date.now() - timer) / 1000;
|
| 63 |
+
|
| 64 |
+
return {
|
| 65 |
+
report: (
|
| 66 |
+
!this.groups[group.$meta.uid].isVisible &&
|
| 67 |
+
timer &&
|
| 68 |
+
duration >= this.durationThreshold &&
|
| 69 |
+
duration < this.upperDurationThreshold
|
| 70 |
+
),
|
| 71 |
+
tag: group.$meta.tag,
|
| 72 |
+
duration: duration,
|
| 73 |
+
};
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
isCompVisible(comp) {
|
| 77 |
+
let onScreen = false;
|
| 78 |
+
const componentData = this.components[comp.$meta.uid];
|
| 79 |
+
|
| 80 |
+
// Report if the component it is mostly visible
|
| 81 |
+
if (componentData.intersectionRatio > this.ratioThreshold) {
|
| 82 |
+
onScreen = true;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
// Covers the most screen space
|
| 86 |
+
onScreen = onScreen || (Object.values(this.components).every(
|
| 87 |
+
(comp) => comp.screenCoveredRatio <= componentData.screenCoveredRatio,
|
| 88 |
+
) && componentData.screenCoveredRatio > 0.1);
|
| 89 |
+
|
| 90 |
+
return onScreen;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
updateGroupTimer(group) {
|
| 94 |
+
const groupData = this.groups[group.$meta.uid];
|
| 95 |
+
|
| 96 |
+
let timer = null;
|
| 97 |
+
if (groupData.isVisible) {
|
| 98 |
+
if (!groupData.timer) {
|
| 99 |
+
groupData.timer = Date.now();
|
| 100 |
+
}
|
| 101 |
+
timer = groupData.timer;
|
| 102 |
+
} else {
|
| 103 |
+
timer = groupData.timer;
|
| 104 |
+
groupData.timer = null;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
return timer;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
stopAndFlush(callbackfn) {
|
| 111 |
+
Object.values(this.groups)
|
| 112 |
+
.filter((groupData) => groupData.isVisible)
|
| 113 |
+
.forEach((groupData) => {
|
| 114 |
+
const duration = (Date.now() - groupData.timer ?? Date.now()) / 1000;
|
| 115 |
+
|
| 116 |
+
groupData.stopped = true;
|
| 117 |
+
groupData.timer = null;
|
| 118 |
+
|
| 119 |
+
callbackfn({
|
| 120 |
+
report: duration >= this.durationThreshold && duration < this.upperDurationThreshold,
|
| 121 |
+
tag: groupData.tag,
|
| 122 |
+
duration: duration,
|
| 123 |
+
});
|
| 124 |
+
});
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
restart() {
|
| 128 |
+
Object.values(this.groups)
|
| 129 |
+
.filter((groupData) => groupData.stopped)
|
| 130 |
+
.forEach((groupData) => {
|
| 131 |
+
groupData.stopped = false;
|
| 132 |
+
groupData.timer = Date.now();
|
| 133 |
+
});
|
| 134 |
+
}
|
| 135 |
+
}
|
pool/shard011/JavaScript/0070338_cMosca.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Created by stitchcula on 2016/9/4.
|
| 3 |
+
*/
|
| 4 |
+
|
| 5 |
+
import mosca from 'mosca'
|
| 6 |
+
|
| 7 |
+
export default class Mosca {
|
| 8 |
+
constructor(mongo){
|
| 9 |
+
this.mongo=mongo
|
| 10 |
+
var ascoltatore={
|
| 11 |
+
type:'redis',
|
| 12 |
+
redis:require('redis'),
|
| 13 |
+
host:process.env['REDIS_HOST'],
|
| 14 |
+
port:process.env['REDIS_PORT'],
|
| 15 |
+
password:process.env['REDIS_AUTH'],
|
| 16 |
+
return_buffers:true
|
| 17 |
+
}
|
| 18 |
+
this.settings={
|
| 19 |
+
port:1883,
|
| 20 |
+
backend:ascoltatore,
|
| 21 |
+
persistence:{
|
| 22 |
+
factory: mosca.persistence.Redis,
|
| 23 |
+
host:process.env['REDIS_HOST'],
|
| 24 |
+
port:process.env['REDIS_PORT'],
|
| 25 |
+
password:process.env['REDIS_AUTH']
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
listen(port){
|
| 30 |
+
if(port) this.settings.port=port
|
| 31 |
+
this.server = new mosca.Server(this.settings)
|
| 32 |
+
this.server.on('ready',this.onReady.bind(this))
|
| 33 |
+
this.server.on('published',this.onPublished.bind(this))
|
| 34 |
+
this.server.on("clientDisconnected",this.onDisconnected.bind(this))
|
| 35 |
+
}
|
| 36 |
+
async onReady(){
|
| 37 |
+
this.server.authenticate =async function(client, obj, token, callback) {//online login
|
| 38 |
+
token=token.toString()
|
| 39 |
+
if(obj&&token) {
|
| 40 |
+
var {uin,device_id}=JSON.parse(obj)
|
| 41 |
+
var res =uin?(await this.mongo.collection("users").findOne({token, uin})):
|
| 42 |
+
(await this.mongo.collection("users").findOne({token, device_id}))
|
| 43 |
+
if (res) {
|
| 44 |
+
await this.mongo.collection("online_list")
|
| 45 |
+
.insertOne({session: client.id, uin,device_id, time: new Date().getTime()})
|
| 46 |
+
/*
|
| 47 |
+
if(uin)//用户接入的时候报告设备状态
|
| 48 |
+
setTimeout(function () {
|
| 49 |
+
this.server.publish({
|
| 50 |
+
topic: "$SMTH/" + device_id + "/ONLINE",
|
| 51 |
+
payload: res.uin,
|
| 52 |
+
qos: 1, retain: false
|
| 53 |
+
})}.bind(this), 1000)
|
| 54 |
+
else//设备一上线就通知用户
|
| 55 |
+
this.server.publish({
|
| 56 |
+
topic: "$SMTH/" + device_id + "/ONLINE",
|
| 57 |
+
payload: res.uin,
|
| 58 |
+
qos: 1, retain: false
|
| 59 |
+
})
|
| 60 |
+
*/
|
| 61 |
+
callback(null, true);
|
| 62 |
+
} else
|
| 63 |
+
callback(null, false);
|
| 64 |
+
}
|
| 65 |
+
}.bind(this)
|
| 66 |
+
this.server.authorizePublish=function (client, topic, payload, callback) {
|
| 67 |
+
console.log("authorizePublish:"+client.id)
|
| 68 |
+
callback(null,true)
|
| 69 |
+
}
|
| 70 |
+
this.server.authorizeSubscribe=function (client, topic, callback) {
|
| 71 |
+
console.log("authorizeSubscribe:"+client.id)
|
| 72 |
+
callback(null,true)
|
| 73 |
+
}
|
| 74 |
+
console.log("MQTT broker is running at "+new Date())
|
| 75 |
+
}
|
| 76 |
+
async onPublished(packet){
|
| 77 |
+
//Topic->device id or user uin
|
| 78 |
+
//node_id->modules id or user token
|
| 79 |
+
//node_type->modules or USER
|
| 80 |
+
//msg_type->data/notice
|
| 81 |
+
if(packet.topic.split('/')[0]!="$SMTH"||packet.topic.split('/')[2])
|
| 82 |
+
return
|
| 83 |
+
var {node_id,node_type,msg_type,msg_id,msg_c}=JSON.parse(packet.payload.toString())
|
| 84 |
+
console.log(packet.topic+":"+node_id+
|
| 85 |
+
" SEND "+JSON.stringify({node_type,msg_type,msg_id,msg_c})+
|
| 86 |
+
" at "+new Date())
|
| 87 |
+
if(node_type=="USER"){//User->Edison
|
| 88 |
+
//todo:
|
| 89 |
+
//user's order, save to db
|
| 90 |
+
}else{//Edison->User
|
| 91 |
+
//save to db
|
| 92 |
+
//device's data or notice, if it's notice,user sure response.
|
| 93 |
+
await this.mongo.collection("publish_msg")
|
| 94 |
+
.insertOne({uin:packet.topic,node_id,node_type,msg_type,msg_id,msg_c})
|
| 95 |
+
if(msg_type=="NOTICE"){
|
| 96 |
+
this.server.publish({
|
| 97 |
+
topic:packet.topic+"/NOTICE",
|
| 98 |
+
payload:packet.payload,
|
| 99 |
+
qos:1,retain:false
|
| 100 |
+
})
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
async onDisconnected(client){//offline logout
|
| 105 |
+
var res=await this.mongo.collection("online_list")
|
| 106 |
+
.removeOne({session:client.id})
|
| 107 |
+
/*
|
| 108 |
+
this.server.publish({topic:"$SMTH/"+res.device_id+"/OFFLINE",
|
| 109 |
+
payload:packet.payload,
|
| 110 |
+
qos:1,retain:false})
|
| 111 |
+
*/
|
| 112 |
+
console.log(res.result)
|
| 113 |
+
}
|
| 114 |
+
}
|
pool/shard011/JavaScript/0070339_main-resource-test.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @license Copyright 2017 Google Inc. All Rights Reserved.
|
| 3 |
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
| 4 |
+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
| 5 |
+
*/
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
/* eslint-env jest */
|
| 9 |
+
|
| 10 |
+
const Runner = require('../../../runner.js');
|
| 11 |
+
const assert = require('assert');
|
| 12 |
+
|
| 13 |
+
describe('MainResource computed artifact', () => {
|
| 14 |
+
let computedArtifacts;
|
| 15 |
+
|
| 16 |
+
beforeEach(() => {
|
| 17 |
+
computedArtifacts = Runner.instantiateComputedArtifacts();
|
| 18 |
+
});
|
| 19 |
+
|
| 20 |
+
it('returns an artifact', () => {
|
| 21 |
+
const record = {
|
| 22 |
+
url: 'https://example.com',
|
| 23 |
+
};
|
| 24 |
+
const networkRecords = [
|
| 25 |
+
{url: 'http://example.com'},
|
| 26 |
+
record,
|
| 27 |
+
];
|
| 28 |
+
computedArtifacts.requestNetworkRecords = _ => Promise.resolve(networkRecords);
|
| 29 |
+
const URL = {finalUrl: 'https://example.com'};
|
| 30 |
+
|
| 31 |
+
return computedArtifacts.requestMainResource({URL}).then(output => {
|
| 32 |
+
assert.equal(output, record);
|
| 33 |
+
});
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
it('thows when main resource can\'t be found', () => {
|
| 37 |
+
const networkRecords = [
|
| 38 |
+
{url: 'https://example.com'},
|
| 39 |
+
];
|
| 40 |
+
computedArtifacts.requestNetworkRecords = _ => Promise.resolve(networkRecords);
|
| 41 |
+
const URL = {finalUrl: 'https://m.example.com'};
|
| 42 |
+
|
| 43 |
+
return computedArtifacts.requestMainResource({URL}).then(() => {
|
| 44 |
+
assert.ok(false, 'should have thrown');
|
| 45 |
+
}).catch(err => {
|
| 46 |
+
assert.equal(err.message, 'Unable to identify the main resource');
|
| 47 |
+
});
|
| 48 |
+
});
|
| 49 |
+
|
| 50 |
+
it('should identify correct main resource in the wikipedia fixture', () => {
|
| 51 |
+
const wikiDevtoolsLog = require('../../fixtures/wikipedia-redirect.devtoolslog.json');
|
| 52 |
+
const URL = {finalUrl: 'https://en.m.wikipedia.org/wiki/Main_Page'};
|
| 53 |
+
const artifacts = {devtoolsLog: wikiDevtoolsLog, URL};
|
| 54 |
+
|
| 55 |
+
return computedArtifacts.requestMainResource(artifacts).then(output => {
|
| 56 |
+
assert.equal(output.url, 'https://en.m.wikipedia.org/wiki/Main_Page');
|
| 57 |
+
});
|
| 58 |
+
});
|
| 59 |
+
|
| 60 |
+
it('should identify correct main resource with hash URLs', () => {
|
| 61 |
+
const networkRecords = [
|
| 62 |
+
{url: 'https://beta.httparchive.org/reports'},
|
| 63 |
+
{url: 'https://beta.httparchive.org/reports/state-of-the-web'},
|
| 64 |
+
];
|
| 65 |
+
|
| 66 |
+
computedArtifacts.requestNetworkRecords = _ => Promise.resolve(networkRecords);
|
| 67 |
+
const URL = {finalUrl: 'https://beta.httparchive.org/reports/state-of-the-web#pctHttps'};
|
| 68 |
+
const artifacts = {URL};
|
| 69 |
+
|
| 70 |
+
return computedArtifacts.requestMainResource(artifacts).then(output => {
|
| 71 |
+
assert.equal(output.url, 'https://beta.httparchive.org/reports/state-of-the-web');
|
| 72 |
+
});
|
| 73 |
+
});
|
| 74 |
+
});
|
pool/shard011/JavaScript/0070340_WFSService.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* WFSService handles rendering of all wfs layers onto the map
|
| 3 |
+
* @module map
|
| 4 |
+
* @class WFSService
|
| 5 |
+
*
|
| 6 |
+
*/
|
| 7 |
+
allModules.service('WFSService',['$rootScope','GoogleMapService','LayerManagerService','Constants','GetWFSRelatedService','GMLParserService','QuerierPanelService','RenderStatusService','UtilitiesService','NVCLService',
|
| 8 |
+
function ($rootScope,GoogleMapService,LayerManagerService,Constants,GetWFSRelatedService,GMLParserService,QuerierPanelService,RenderStatusService,UtilitiesService,NVCLService) {
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Render a point data to the map
|
| 12 |
+
* @method renderPoint
|
| 13 |
+
* @param point - the point to render
|
| 14 |
+
* @param map - The map where the point is to be rendered
|
| 15 |
+
*/
|
| 16 |
+
this.renderPoint = function(point,map){
|
| 17 |
+
var marker = new google.maps.Marker({
|
| 18 |
+
position:point.coords,
|
| 19 |
+
map: map,
|
| 20 |
+
title: point.name
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
marker.addListener('click', function() {
|
| 24 |
+
// Ask the map to display a loading mask
|
| 25 |
+
GoogleMapService.busyStart();
|
| 26 |
+
|
| 27 |
+
// Invoke core tray image carousel
|
| 28 |
+
if (point.featureNode.nodeName=='gsml:Borehole') {
|
| 29 |
+
QuerierPanelService.setCarouselBusy(true);
|
| 30 |
+
NVCLService.getCoreDisplay(point.description, point.featureNode.nodeName, point.name);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
// Set data for the query panel and display it
|
| 34 |
+
var displayable = QuerierPanelService.setPanelNode(point.featureNode, "Feature", "WFS", false);
|
| 35 |
+
if (displayable) {
|
| 36 |
+
QuerierPanelService.openPanel(true);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
// Ask the map to dissolve the loading mask
|
| 40 |
+
GoogleMapService.busyEnd();
|
| 41 |
+
});
|
| 42 |
+
return marker;
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Render a LINESTRING data to the map
|
| 47 |
+
* @method renderLineString
|
| 48 |
+
* @param linestring - the linestring to render
|
| 49 |
+
* @param map - The map where the point is to be rendered
|
| 50 |
+
*/
|
| 51 |
+
this.renderLineString = function(linestring,map){
|
| 52 |
+
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Render a POLYGON data to the map
|
| 57 |
+
* @method renderPolygon
|
| 58 |
+
* @param polygon - the polygon to render
|
| 59 |
+
* @param map - The map where the point is to be rendered
|
| 60 |
+
*/
|
| 61 |
+
this.renderPolygon = function(polygon,map){
|
| 62 |
+
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Method to decide how the wfs layer should be rendered and add the wfs to the map
|
| 67 |
+
* @method renderLayer
|
| 68 |
+
* @param layer - The layer containing the wfs to be rendered
|
| 69 |
+
*/
|
| 70 |
+
this.renderLayer = function(layer,param){
|
| 71 |
+
var map = GoogleMapService.getMap();
|
| 72 |
+
var me = this;
|
| 73 |
+
var onlineResources = LayerManagerService.getWFS(layer);
|
| 74 |
+
RenderStatusService.setMaxValue(layer,onlineResources.length);
|
| 75 |
+
for(var index in onlineResources){
|
| 76 |
+
|
| 77 |
+
if(UtilitiesService.filterProviderSkip(param.optionalFilters, onlineResources[index].url)){
|
| 78 |
+
RenderStatusService.updateCompleteStatus(layer,onlineResources[index],Constants.statusProgress.SKIPPED);
|
| 79 |
+
continue;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
RenderStatusService.updateCompleteStatus(layer,onlineResources[index],Constants.statusProgress.RUNNING);
|
| 83 |
+
|
| 84 |
+
GetWFSRelatedService.getFeature(layer, onlineResources[index],param).then(function(response){
|
| 85 |
+
try{
|
| 86 |
+
var rootNode = GMLParserService.getRootNode(response.data.gml);
|
| 87 |
+
var primitives = GMLParserService.makePrimitives(rootNode);
|
| 88 |
+
|
| 89 |
+
RenderStatusService.updateCompleteStatus(layer,response.resource,Constants.statusProgress.COMPLETED);
|
| 90 |
+
|
| 91 |
+
for(var key in primitives){
|
| 92 |
+
switch(primitives[key].geometryType){
|
| 93 |
+
case Constants.geometryType.POINT:
|
| 94 |
+
GoogleMapService.addMarkerToActive(layer.id,me.renderPoint(primitives[key],map));
|
| 95 |
+
break;
|
| 96 |
+
case Constants.geometryType.LINESTRING:
|
| 97 |
+
me.renderLineString(primitives[key],map);
|
| 98 |
+
break;
|
| 99 |
+
case Constants.geometryType.POLYGON:
|
| 100 |
+
me.renderPolygon(primitives[key],map);
|
| 101 |
+
break;
|
| 102 |
+
default:
|
| 103 |
+
break;
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
}catch(err){
|
| 107 |
+
RenderStatusService.updateCompleteStatus(layer,response.resource,Constants.statusProgress.ERROR);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
},function(error){
|
| 112 |
+
RenderStatusService.updateCompleteStatus(layer,error.onlineResource,Constants.statusProgress.ERROR);
|
| 113 |
+
});
|
| 114 |
+
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
};
|
| 118 |
+
|
| 119 |
+
/**
|
| 120 |
+
* Method to decide how the wfs resource should be rendered and add the wfs to the map
|
| 121 |
+
* @method renderResource
|
| 122 |
+
* @param resource - The resource containing the wfs to be rendered
|
| 123 |
+
*/
|
| 124 |
+
this.renderCSWRecord = function(layer,cswRecord){
|
| 125 |
+
var map = GoogleMapService.getMap();
|
| 126 |
+
var me = this;
|
| 127 |
+
var onlineResources = LayerManagerService.getWFSFromCSW(cswRecord);
|
| 128 |
+
RenderStatusService.setMaxValue(layer,onlineResources.length);
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
for(var index in onlineResources){
|
| 132 |
+
RenderStatusService.updateCompleteStatus(layer,onlineResources[index],Constants.statusProgress.RUNNING);
|
| 133 |
+
GetWFSRelatedService.getFeature(layer, onlineResources[index]).then(function(response){
|
| 134 |
+
try{
|
| 135 |
+
var rootNode = GMLParserService.getRootNode(response.data.gml);
|
| 136 |
+
var primitives = GMLParserService.makePrimitives(rootNode);
|
| 137 |
+
|
| 138 |
+
RenderStatusService.updateCompleteStatus(layer,response.resource,Constants.statusProgress.COMPLETED);
|
| 139 |
+
|
| 140 |
+
for(var key in primitives){
|
| 141 |
+
switch(primitives[key].geometryType){
|
| 142 |
+
case Constants.geometryType.POINT:
|
| 143 |
+
GoogleMapService.addMarkerToActive(layer.id,me.renderPoint(primitives[key],map));
|
| 144 |
+
break;
|
| 145 |
+
case Constants.geometryType.LINESTRING:
|
| 146 |
+
me.renderLineString(primitives[key],map);
|
| 147 |
+
break;
|
| 148 |
+
case Constants.geometryType.POLYGON:
|
| 149 |
+
me.renderPolygon(primitives[key],map);
|
| 150 |
+
break;
|
| 151 |
+
default:
|
| 152 |
+
break;
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
}catch(err){
|
| 156 |
+
RenderStatusService.updateCompleteStatus(layer,response.resource,Constants.statusProgress.ERROR);
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
},function(error){
|
| 160 |
+
RenderStatusService.updateCompleteStatus(layer,error.onlineResource,Constants.statusProgress.ERROR);
|
| 161 |
+
});
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
};
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
}]);
|
pool/shard011/JavaScript/0070341_routes.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function() {
|
| 2 |
+
var nextId = 0;
|
| 3 |
+
var people = [
|
| 4 |
+
{
|
| 5 |
+
"id": "" + (nextId++),
|
| 6 |
+
"name": "Saasha",
|
| 7 |
+
"age": "6"
|
| 8 |
+
}, {
|
| 9 |
+
"id": "" + (nextId++),
|
| 10 |
+
"name": "Planet",
|
| 11 |
+
"age": "8"
|
| 12 |
+
}
|
| 13 |
+
];
|
| 14 |
+
|
| 15 |
+
var isUniqueName = function(name) {
|
| 16 |
+
var result = people.filter(function(person) {
|
| 17 |
+
return person.name === name;
|
| 18 |
+
});
|
| 19 |
+
return result.length === 0;
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
module.exports = function(app, options) {
|
| 23 |
+
app.get('/', function(req, res) {
|
| 24 |
+
return res.render("" + options.base + "/index.html");
|
| 25 |
+
});
|
| 26 |
+
app.get('/people', function(req, res) {
|
| 27 |
+
return res.json(people);
|
| 28 |
+
});
|
| 29 |
+
app.post('/people', function(req, res) {
|
| 30 |
+
var age, message, name, person;
|
| 31 |
+
name = req.body.name;
|
| 32 |
+
age = req.body.age;
|
| 33 |
+
message = {
|
| 34 |
+
"title": "Duplicate!",
|
| 35 |
+
"message": "" + name + " is a duplicate. Please enter a new name."
|
| 36 |
+
};
|
| 37 |
+
if (!isUniqueName(name)) {
|
| 38 |
+
return res.send(message, 403);
|
| 39 |
+
}
|
| 40 |
+
person = {
|
| 41 |
+
"id": "" + (nextId++),
|
| 42 |
+
"name": "" + name,
|
| 43 |
+
"age": "" + age
|
| 44 |
+
};
|
| 45 |
+
people.push(person);
|
| 46 |
+
return res.json(person);
|
| 47 |
+
});
|
| 48 |
+
return app.get('/people/:id', function(req, res) {
|
| 49 |
+
var id = req.params.id;
|
| 50 |
+
var current = people.filter(function(person) {
|
| 51 |
+
return person.id === id;
|
| 52 |
+
});
|
| 53 |
+
return res.json(current || null);
|
| 54 |
+
});
|
| 55 |
+
};
|
| 56 |
+
|
| 57 |
+
}).call(this);
|
pool/shard011/JavaScript/0070344_worker.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var CACHE_NAME = 'pwa-zero-inside';
|
| 2 |
+
var urlsToCache = [
|
| 3 |
+
'/',
|
| 4 |
+
'static',
|
| 5 |
+
'images/myProfile.jpg',
|
| 6 |
+
'images/portfolio/gponbot/web-home.png',
|
| 7 |
+
'images/portfolio/pettracker/IMG_20200530_181223.jpg',
|
| 8 |
+
'images/portfolio/shap/IMG_2020-11-30-20-36-25-499.jpg',
|
| 9 |
+
'images/portfolio/watermonitoring/ss1.png'
|
| 10 |
+
];
|
| 11 |
+
|
| 12 |
+
// Install a service worker
|
| 13 |
+
self.addEventListener('install', event => {
|
| 14 |
+
// Perform install steps
|
| 15 |
+
event.waitUntil(
|
| 16 |
+
caches.open(CACHE_NAME)
|
| 17 |
+
.then(function(cache) {
|
| 18 |
+
console.log('Opened cache');
|
| 19 |
+
return cache.addAll(urlsToCache);
|
| 20 |
+
})
|
| 21 |
+
);
|
| 22 |
+
});
|
| 23 |
+
|
| 24 |
+
// Cache and return requests
|
| 25 |
+
self.addEventListener('fetch', event => {
|
| 26 |
+
event.respondWith(
|
| 27 |
+
caches.match(event.request)
|
| 28 |
+
.then(function(response) {
|
| 29 |
+
// Cache hit - return response
|
| 30 |
+
if (response) {
|
| 31 |
+
return response;
|
| 32 |
+
}
|
| 33 |
+
return fetch(event.request);
|
| 34 |
+
}
|
| 35 |
+
)
|
| 36 |
+
);
|
| 37 |
+
});
|
| 38 |
+
|
| 39 |
+
// Update a service worker
|
| 40 |
+
self.addEventListener('activate', event => {
|
| 41 |
+
var cacheWhitelist = ['pwa-zero-inside'];
|
| 42 |
+
event.waitUntil(
|
| 43 |
+
caches.keys().then(cacheNames => {
|
| 44 |
+
return Promise.all(
|
| 45 |
+
cacheNames.map(cacheName => {
|
| 46 |
+
if (cacheWhitelist.indexOf(cacheName) === -1) {
|
| 47 |
+
return caches.delete(cacheName);
|
| 48 |
+
}
|
| 49 |
+
})
|
| 50 |
+
);
|
| 51 |
+
})
|
| 52 |
+
);
|
| 53 |
+
});
|
pool/shard011/JavaScript/0070348_not-equal-email-domain.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import _ from 'lodash';
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Validate email's domain to not equal to the listed domains
|
| 5 |
+
* in ruleObj.params[0]. Separate the domains using comma (,).
|
| 6 |
+
*
|
| 7 |
+
* @param val - email
|
| 8 |
+
* @param ruleObj
|
| 9 |
+
*
|
| 10 |
+
* @returns {Boolean}
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
const validate = (val, ruleObj) => {
|
| 14 |
+
if (!val) {
|
| 15 |
+
return true;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
const parts = val.split('@');
|
| 19 |
+
|
| 20 |
+
if (parts.length !== 2) {
|
| 21 |
+
// most likely not email
|
| 22 |
+
return false;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
const domain = parts.pop();
|
| 26 |
+
|
| 27 |
+
if (!domain) {
|
| 28 |
+
return false;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
const lowerDomain = domain.toLowerCase();
|
| 32 |
+
|
| 33 |
+
const prohibitedDomains = _.chain(ruleObj.params[0])
|
| 34 |
+
.toLower()
|
| 35 |
+
.split(',')
|
| 36 |
+
.map(domain => _.trim(domain))
|
| 37 |
+
.compact()
|
| 38 |
+
.value();
|
| 39 |
+
|
| 40 |
+
return !_.includes(prohibitedDomains, lowerDomain);
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
const message = '<%= propertyName %>\'s domain is not valid.';
|
| 44 |
+
|
| 45 |
+
export default {validate, message};
|
pool/shard011/JavaScript/0070350_file.js
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
define("widget.FileInput", ["AbilianWidget", "jquery", "FileAPI", "Hogan"], (
|
| 2 |
+
Abilian,
|
| 3 |
+
$,
|
| 4 |
+
api,
|
| 5 |
+
Hogan
|
| 6 |
+
) => {
|
| 7 |
+
"use strict";
|
| 8 |
+
/**
|
| 9 |
+
* File input widget. Uses FileAPI (http://mailru.github.io/FileAPI/)
|
| 10 |
+
*/
|
| 11 |
+
const defaults = {
|
| 12 |
+
fileItemTemplate: Hogan.compile(
|
| 13 |
+
'<div id="{{ uid }}" class="file-item">\n' +
|
| 14 |
+
'<span class="file-info">{{ name }} ({{ size }})</span> ' +
|
| 15 |
+
'<a class="close" href="#">×</a>' +
|
| 16 |
+
"\n</div>"
|
| 17 |
+
),
|
| 18 |
+
progressTemplate:
|
| 19 |
+
'<div class="progress">' +
|
| 20 |
+
'<div class="progress-bar" role="progressbar" ' +
|
| 21 |
+
' aria-valuenow="0" aria-valuemin="0" ' +
|
| 22 |
+
' aria-valuemax="100" style="width: 0;">' +
|
| 23 |
+
"</div>" +
|
| 24 |
+
"</div>",
|
| 25 |
+
inputTemplate: '<input type="hidden" name="{{ name }}" />',
|
| 26 |
+
progressBarHeight: "0.2em",
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
function FileInput(node, options) {
|
| 30 |
+
const self = this;
|
| 31 |
+
this.currentlyUploaded = {};
|
| 32 |
+
this.options = $.extend({}, defaults, options);
|
| 33 |
+
this.form = node.parent("form");
|
| 34 |
+
this.$input = node.find(".js-fileapi-wrapper input");
|
| 35 |
+
this.$input.attr("disabled", null);
|
| 36 |
+
this.rootNode = node;
|
| 37 |
+
this.button = node.find(".js-fileapi-wrapper .btn-file");
|
| 38 |
+
this.multiple = Boolean(this.$input.attr("multiple"));
|
| 39 |
+
this.$input.attr("multiple", null);
|
| 40 |
+
this.inputName = this.$input.attr("name");
|
| 41 |
+
this.$input.attr("name", null);
|
| 42 |
+
this.listNode = node.find(".selected-files");
|
| 43 |
+
|
| 44 |
+
if (node.data("cloned")) {
|
| 45 |
+
this.listNode.empty();
|
| 46 |
+
} else {
|
| 47 |
+
this.listNode.find(".file-item-existing").each(function () {
|
| 48 |
+
self.setupExistingFileNode($(this));
|
| 49 |
+
});
|
| 50 |
+
this.listNode.find(".file-item-uploaded").each(function () {
|
| 51 |
+
self.setupFileNode($(this));
|
| 52 |
+
});
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
this.button.on("change", "input", this.addFiles.bind(this));
|
| 56 |
+
|
| 57 |
+
this.form.on("submit", this.onFormSubmit.bind(this));
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
FileInput.prototype = {
|
| 61 |
+
addFiles(evt) {
|
| 62 |
+
const self = this;
|
| 63 |
+
let files = api.getFiles(evt);
|
| 64 |
+
|
| 65 |
+
if (!this.multiple) {
|
| 66 |
+
this.listNode.empty();
|
| 67 |
+
files = files.slice(0, 1);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
$(files).each(function () {
|
| 71 |
+
self.addFileNode(evt.target, this);
|
| 72 |
+
});
|
| 73 |
+
},
|
| 74 |
+
|
| 75 |
+
setupExistingFileNode(node) {
|
| 76 |
+
const button = node.find("button");
|
| 77 |
+
const unwrappedButton = button.get(0);
|
| 78 |
+
const deleted = button.data("deleted");
|
| 79 |
+
|
| 80 |
+
if (!unwrappedButton) {
|
| 81 |
+
return;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
unwrappedButton.markerInputElement = $("<input>").attr({
|
| 85 |
+
type: "hidden",
|
| 86 |
+
name: button.data("name"),
|
| 87 |
+
value: button.data("value"),
|
| 88 |
+
});
|
| 89 |
+
|
| 90 |
+
if (deleted) {
|
| 91 |
+
node.append(unwrappedButton.markerInputElement);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
button.on("click", { node: node }, this.onExistingNodeChange.bind(this));
|
| 95 |
+
},
|
| 96 |
+
|
| 97 |
+
setupFileNode(node) {
|
| 98 |
+
node.find("a.close").on("click", this.removeFileNode.bind(this));
|
| 99 |
+
},
|
| 100 |
+
|
| 101 |
+
addFileNode(input, file) {
|
| 102 |
+
const el = this.createFileNode(file);
|
| 103 |
+
this.setupFileNode(el);
|
| 104 |
+
this.listNode.append(el);
|
| 105 |
+
this.triggerUpload(el, file);
|
| 106 |
+
},
|
| 107 |
+
|
| 108 |
+
triggerUpload(element, file) {
|
| 109 |
+
const uid = api.uid(file);
|
| 110 |
+
this.currentlyUploaded[uid] = true;
|
| 111 |
+
|
| 112 |
+
api.upload({
|
| 113 |
+
url: Abilian.api.upload.newFileUrl,
|
| 114 |
+
headers: {
|
| 115 |
+
Accept: "application/json",
|
| 116 |
+
"X-CSRF-Token": Abilian.csrf_token,
|
| 117 |
+
},
|
| 118 |
+
files: { file: file },
|
| 119 |
+
progress: this.onFileProgress.bind(this),
|
| 120 |
+
complete: this.onFileComplete.bind(this),
|
| 121 |
+
});
|
| 122 |
+
},
|
| 123 |
+
|
| 124 |
+
removeFileNode(evt) {
|
| 125 |
+
evt.preventDefault();
|
| 126 |
+
$(evt.target).parent(".file-item").remove();
|
| 127 |
+
},
|
| 128 |
+
|
| 129 |
+
createFileNode(file) {
|
| 130 |
+
const infos = this.getFileInfos(file);
|
| 131 |
+
const el = $(this.options.fileItemTemplate.render(infos));
|
| 132 |
+
const progress = $(this.options.progressTemplate).css({
|
| 133 |
+
height: this.options.progressBarHeight,
|
| 134 |
+
});
|
| 135 |
+
|
| 136 |
+
el.append(progress);
|
| 137 |
+
return el;
|
| 138 |
+
},
|
| 139 |
+
|
| 140 |
+
getElementForFile(file) {
|
| 141 |
+
const uid = api.uid(file);
|
| 142 |
+
return $(document.getElementById(uid));
|
| 143 |
+
},
|
| 144 |
+
|
| 145 |
+
getFileInfos(file) {
|
| 146 |
+
return {
|
| 147 |
+
name: this.sanitizeFilename(file.name),
|
| 148 |
+
type: file.type,
|
| 149 |
+
size: this.humanSize(file.size),
|
| 150 |
+
uid: api.uid(file),
|
| 151 |
+
};
|
| 152 |
+
},
|
| 153 |
+
|
| 154 |
+
onExistingNodeChange(evt) {
|
| 155 |
+
const button = $(evt.target);
|
| 156 |
+
const markerInputElement = evt.target.markerInputElement;
|
| 157 |
+
const isActive = button.hasClass("active");
|
| 158 |
+
|
| 159 |
+
button.toggleClass("active");
|
| 160 |
+
|
| 161 |
+
if (isActive) {
|
| 162 |
+
button.removeClass("btn-danger");
|
| 163 |
+
button.addClass("btn-default");
|
| 164 |
+
$(markerInputElement).remove();
|
| 165 |
+
} else {
|
| 166 |
+
button.removeClass("btn-default");
|
| 167 |
+
button.addClass("btn-danger");
|
| 168 |
+
button.parent(".file-item").append(markerInputElement);
|
| 169 |
+
}
|
| 170 |
+
},
|
| 171 |
+
|
| 172 |
+
onFileProgress(evt, file, xhr, options) {
|
| 173 |
+
const progress = (evt.loaded / evt.total) * 100;
|
| 174 |
+
this.getElementForFile(file)
|
| 175 |
+
.find(".progress-bar")
|
| 176 |
+
.css({ width: `${progress}%` });
|
| 177 |
+
},
|
| 178 |
+
|
| 179 |
+
onFileComplete(err, xhr, file, options) {
|
| 180 |
+
const $el = this.getElementForFile(xhr.currentFile);
|
| 181 |
+
const uid = api.uid(xhr.currentFile);
|
| 182 |
+
|
| 183 |
+
delete this.currentlyUploaded[uid];
|
| 184 |
+
|
| 185 |
+
if (err) {
|
| 186 |
+
$el.remove();
|
| 187 |
+
alert("Echec de l'envoi du fichier!"); // FIXME: i18n
|
| 188 |
+
return;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
const $input = $("<input>").attr({
|
| 192 |
+
type: "hidden",
|
| 193 |
+
name: this.inputName,
|
| 194 |
+
});
|
| 195 |
+
const responseText = xhr.responseText;
|
| 196 |
+
const result = JSON.parse(responseText);
|
| 197 |
+
|
| 198 |
+
$el.find(".progress").remove();
|
| 199 |
+
$input.val(result.handle);
|
| 200 |
+
$el.append($input);
|
| 201 |
+
},
|
| 202 |
+
|
| 203 |
+
onFormSubmit(e) {
|
| 204 |
+
if (Object.keys(this.currentlyUploaded).length > 0) {
|
| 205 |
+
e.preventDefault();
|
| 206 |
+
alert("Des fichiers sont en cours d'envoi"); // FIXME: i18n
|
| 207 |
+
}
|
| 208 |
+
},
|
| 209 |
+
|
| 210 |
+
sanitizeFilename(filename) {
|
| 211 |
+
return filename.replace(/\\/g, "/").replace(/.*\//, "");
|
| 212 |
+
},
|
| 213 |
+
|
| 214 |
+
humanSize(size) {
|
| 215 |
+
let unit = "b";
|
| 216 |
+
let divider = null;
|
| 217 |
+
|
| 218 |
+
if (size > api.TB) {
|
| 219 |
+
unit = "TB";
|
| 220 |
+
divider = api.TB;
|
| 221 |
+
} else if (size > api.GB) {
|
| 222 |
+
unit = "GB";
|
| 223 |
+
divider = api.GB;
|
| 224 |
+
} else if (size > api.MB) {
|
| 225 |
+
unit = "MB";
|
| 226 |
+
divider = api.MB;
|
| 227 |
+
} else if (size > api.KB) {
|
| 228 |
+
unit = "KB";
|
| 229 |
+
divider = api.KB;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
if (divider) {
|
| 233 |
+
size = (size / divider).toFixed(2);
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
return size.toString() + unit;
|
| 237 |
+
},
|
| 238 |
+
};
|
| 239 |
+
|
| 240 |
+
function createFileInput(options) {
|
| 241 |
+
const element = $(this);
|
| 242 |
+
const widget = new FileInput(element, options);
|
| 243 |
+
element.data("file-input", widget);
|
| 244 |
+
return widget;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
Abilian.registerWidgetCreator("fileInput", createFileInput);
|
| 248 |
+
|
| 249 |
+
$.fn.fileInput = function (options) {
|
| 250 |
+
return this.each(function () {
|
| 251 |
+
const node = $(this);
|
| 252 |
+
let widget = node.data("file-input");
|
| 253 |
+
if (widget === undefined) {
|
| 254 |
+
widget = new FileInput(node, options);
|
| 255 |
+
node.data("file-input", widget);
|
| 256 |
+
}
|
| 257 |
+
return widget;
|
| 258 |
+
});
|
| 259 |
+
};
|
| 260 |
+
|
| 261 |
+
return FileInput;
|
| 262 |
+
});
|
pool/shard011/JavaScript/0070351_app.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var evalApp = angular.module( 'evalApp',
|
| 2 |
+
[ 'templates-app',
|
| 3 |
+
'templates-common',
|
| 4 |
+
'evalApp.home',
|
| 5 |
+
'evalApp.about',
|
| 6 |
+
'evalApp.login',
|
| 7 |
+
'evalApp.admin',
|
| 8 |
+
'evalApp.user',
|
| 9 |
+
'evalApp.newTemplate',
|
| 10 |
+
'evalApp.evaluations',
|
| 11 |
+
'evalApp.course',
|
| 12 |
+
'ui.router'
|
| 13 |
+
]);
|
| 14 |
+
|
| 15 |
+
evalApp.constant('SERVER_URL', 'http://dispatch.ru.is/h48/api/v1/');
|
| 16 |
+
|
| 17 |
+
evalApp.config( function myAppConfig ( $stateProvider, $urlRouterProvider ) {
|
| 18 |
+
$urlRouterProvider.otherwise( '/login' );
|
| 19 |
+
});
|
| 20 |
+
|
| 21 |
+
evalApp.run( function run () {
|
| 22 |
+
});
|
| 23 |
+
|
| 24 |
+
evalApp.controller( 'AppCtrl', function AppCtrl ( $scope, $location ) {
|
| 25 |
+
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){
|
| 26 |
+
if ( angular.isDefined( toState.data.pageTitle ) ) {
|
| 27 |
+
$scope.pageTitle = toState.data.pageTitle + ' | Evaluation App' ;
|
| 28 |
+
}
|
| 29 |
+
});
|
| 30 |
+
});
|
| 31 |
+
|
| 32 |
+
evalApp.directive('evaluation-question', function() {
|
| 33 |
+
return ;
|
| 34 |
+
});
|
pool/shard011/JavaScript/0070352_calendars-service.spec.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const expect = require('chai').expect;
|
| 2 |
+
const rewire = require('rewire');
|
| 3 |
+
const sinon = require('sinon');
|
| 4 |
+
const Promise = require('bluebird');
|
| 5 |
+
const mockEventList = require('./mocks/eventList.json');
|
| 6 |
+
|
| 7 |
+
const CalendarService = rewire('../services/calendar-service');
|
| 8 |
+
|
| 9 |
+
describe('Calendar Test', () => {
|
| 10 |
+
const calendar = CalendarService.__get__('calendar');
|
| 11 |
+
let jwtRevert;
|
| 12 |
+
|
| 13 |
+
beforeEach(done => {
|
| 14 |
+
const stub = sinon.stub().returns(Promise.resolve('a secured client'));
|
| 15 |
+
jwtRevert = CalendarService.__set__('createJWT', stub);
|
| 16 |
+
done();
|
| 17 |
+
});
|
| 18 |
+
|
| 19 |
+
afterEach(() => jwtRevert());
|
| 20 |
+
|
| 21 |
+
it('should send an update to Google Calendar', done => {
|
| 22 |
+
const updateEvent = CalendarService.__get__('updateEvent');
|
| 23 |
+
const updateSpy = sinon.spy(calendar.events, 'update');
|
| 24 |
+
const fakeResourceBody = {
|
| 25 |
+
summary: 'testing',
|
| 26 |
+
foo: 'bar'
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
// Since it will fail as this isn't an actual event
|
| 30 |
+
updateEvent({eventId: 'event1', calendarId: 'calendar1'}, fakeResourceBody)
|
| 31 |
+
.catch(() => {
|
| 32 |
+
const expectedParams = {
|
| 33 |
+
eventId: 'event1',
|
| 34 |
+
calendarId: 'calendar1',
|
| 35 |
+
resource: fakeResourceBody,
|
| 36 |
+
auth: 'a secured client'
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
// eslint-disable-next-line no-unused-expressions
|
| 40 |
+
expect(updateSpy.calledWith(expectedParams)).to.be.true;
|
| 41 |
+
done();
|
| 42 |
+
});
|
| 43 |
+
});
|
| 44 |
+
|
| 45 |
+
it('should return a sync token', done => {
|
| 46 |
+
const mockFullSync = () => Promise.resolve(mockEventList);
|
| 47 |
+
const revert = CalendarService.__set__('getFullSync', mockFullSync);
|
| 48 |
+
const getSyncToken = CalendarService.__get__('getSyncToken');
|
| 49 |
+
|
| 50 |
+
getSyncToken()
|
| 51 |
+
.then(syncToken => {
|
| 52 |
+
expect(syncToken).to.equal('CPiw4dWUu84CEPiw4dWUu84CGAU=');
|
| 53 |
+
revert();
|
| 54 |
+
done();
|
| 55 |
+
});
|
| 56 |
+
});
|
| 57 |
+
|
| 58 |
+
it('should perform a full sync', done => {
|
| 59 |
+
const getFullSync = CalendarService.__get__('getFullSync');
|
| 60 |
+
const mock1 = {
|
| 61 |
+
events: [1, 2],
|
| 62 |
+
nextPageToken: 2
|
| 63 |
+
};
|
| 64 |
+
const mock2 = {
|
| 65 |
+
events: [3, 4],
|
| 66 |
+
syncToken: 'token'
|
| 67 |
+
};
|
| 68 |
+
// Override eventList to check integrity of callback
|
| 69 |
+
const eventListMock = params => {
|
| 70 |
+
if (params.nextPageToken) {
|
| 71 |
+
return Promise.resolve(mock2);
|
| 72 |
+
}
|
| 73 |
+
return Promise.resolve(mock1);
|
| 74 |
+
};
|
| 75 |
+
const revert = CalendarService.__set__('listEvents', eventListMock);
|
| 76 |
+
getFullSync('brhim@apidevdemo.com').then(lastPageResponse => {
|
| 77 |
+
expect(lastPageResponse.syncToken).to.equal('token');
|
| 78 |
+
revert();
|
| 79 |
+
done();
|
| 80 |
+
});
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
it('should perform an incremental sync', done => {
|
| 84 |
+
const listStub = sinon.stub().returns(Promise.resolve([]));
|
| 85 |
+
const listRevert = CalendarService.__set__('listEvents', listStub);
|
| 86 |
+
const getIncrementalSync = CalendarService.__get__('getIncrementalSync');
|
| 87 |
+
const mockCalendarInfo = {
|
| 88 |
+
syncToken: '12345abcefg',
|
| 89 |
+
calendarId: 'calendarId1'
|
| 90 |
+
};
|
| 91 |
+
|
| 92 |
+
getIncrementalSync(mockCalendarInfo)
|
| 93 |
+
.then(() => {
|
| 94 |
+
const expectedParams = {
|
| 95 |
+
auth: 'a secured client',
|
| 96 |
+
calendarId: 'calendarId1',
|
| 97 |
+
singleEvents: false,
|
| 98 |
+
syncToken: '12345abcefg',
|
| 99 |
+
showDeleted: true
|
| 100 |
+
};
|
| 101 |
+
// eslint-disable-next-line no-unused-expressions
|
| 102 |
+
expect(listStub.calledWith(expectedParams)).to.be.true;
|
| 103 |
+
listRevert();
|
| 104 |
+
done();
|
| 105 |
+
});
|
| 106 |
+
});
|
| 107 |
+
});
|
pool/shard011/JavaScript/0070360_Leg.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { LEG_CAVE } from '../core/constants';
|
| 2 |
+
|
| 3 |
+
class Leg {
|
| 4 |
+
|
| 5 |
+
constructor ( factory, legInfo, s1, s2 ) {
|
| 6 |
+
|
| 7 |
+
const s1Start = ( s1.shortestPathDistance() < s2.shortestPathDistance() );
|
| 8 |
+
const survey = factory.survey;
|
| 9 |
+
|
| 10 |
+
this.factory = factory;
|
| 11 |
+
this.legLength = legInfo.length;
|
| 12 |
+
this.index = legInfo.index;
|
| 13 |
+
this.segmentId = legInfo.segment;
|
| 14 |
+
this.startStation = s1Start ? s1 : s2;
|
| 15 |
+
this.endStation = s1Start ? s2 : s1;
|
| 16 |
+
this.legs = survey.getFeature( LEG_CAVE );
|
| 17 |
+
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
start () {
|
| 21 |
+
|
| 22 |
+
return this.startStation;
|
| 23 |
+
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
end () {
|
| 27 |
+
|
| 28 |
+
return this.endStation;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
length () {
|
| 32 |
+
|
| 33 |
+
return this.legLength;
|
| 34 |
+
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
color ( color = false ) {
|
| 38 |
+
|
| 39 |
+
this.legs.setLegColor( this.index * 2, color );
|
| 40 |
+
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
segment() {
|
| 44 |
+
|
| 45 |
+
return this.factory.getSegment( this.segmentId );
|
| 46 |
+
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
export { Leg };
|
pool/shard011/JavaScript/0070364_handler.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var AbstractAdminContentHandler = Class.create(AbstractContentHandler, {
|
| 2 |
+
show: function(data){
|
| 3 |
+
this.data = data;
|
| 4 |
+
adminTemplateEngine.process(this.tpl, data, this.target, this.finished.bind(this));
|
| 5 |
+
}
|
| 6 |
+
});
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* PkgNavHandler
|
| 10 |
+
*/
|
| 11 |
+
var ScriptListHandler = Class.create(AbstractAdminContentHandler, {
|
| 12 |
+
initialize: function($super, target){
|
| 13 |
+
$super('tplScriptList', target);
|
| 14 |
+
this.provider = new ScriptListProvider(this.show.bind(this));
|
| 15 |
+
this.ajaxload = true;
|
| 16 |
+
}
|
| 17 |
+
});
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* PkgNavHandler
|
| 21 |
+
*/
|
| 22 |
+
var PkgConfListHandler = Class.create(AbstractAdminContentHandler, {
|
| 23 |
+
initialize: function($super, target){
|
| 24 |
+
$super('tplPkgSettings', target);
|
| 25 |
+
this.provider = new PkgConfListProvider(this.show.bind(this));
|
| 26 |
+
this.ajaxload = true;
|
| 27 |
+
}
|
| 28 |
+
});
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* PkgListHandler
|
| 32 |
+
*/
|
| 33 |
+
var PkgListHandler = Class.create(AbstractAdminContentHandler, {
|
| 34 |
+
initialize: function($super, target){
|
| 35 |
+
$super('tplPkgList', target);
|
| 36 |
+
this.provider = new PkgListProvider(this.show.bind(this));
|
| 37 |
+
this.ajaxload = true;
|
| 38 |
+
this.fakeprovider = new PkgFakeProvider(this.show.bind(this));
|
| 39 |
+
},
|
| 40 |
+
|
| 41 |
+
loadPkg: function(sel, needle){
|
| 42 |
+
this.provider.setSelection(sel, needle);
|
| 43 |
+
if (this.provider.packages.length != 0) {
|
| 44 |
+
this.requestStarted();
|
| 45 |
+
this.fakeprovider.setList(this.provider.getSelected());
|
| 46 |
+
this.fakeprovider.load();
|
| 47 |
+
}
|
| 48 |
+
else
|
| 49 |
+
this.load();
|
| 50 |
+
|
| 51 |
+
},
|
| 52 |
+
|
| 53 |
+
loadAll: function(){
|
| 54 |
+
this.loadPkg(this.provider.ALL);
|
| 55 |
+
},
|
| 56 |
+
|
| 57 |
+
loadUpgradable: function(){
|
| 58 |
+
this.loadPkg(this.provider.UPGRADE);
|
| 59 |
+
},
|
| 60 |
+
|
| 61 |
+
loadInstalled: function(){
|
| 62 |
+
this.loadPkg(this.provider.INST);
|
| 63 |
+
},
|
| 64 |
+
|
| 65 |
+
loadFilter: function(needle){
|
| 66 |
+
this.loadPkg(this.provider.SEARCH, needle);
|
| 67 |
+
}
|
| 68 |
+
});
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* PkgNavHandler
|
| 72 |
+
*/
|
| 73 |
+
var PkgNavHandler = Class.create(AbstractAdminContentHandler,{
|
| 74 |
+
initialize: function($super, target){
|
| 75 |
+
$super('tplNavPkgs', target);
|
| 76 |
+
},
|
| 77 |
+
|
| 78 |
+
load: function(){
|
| 79 |
+
data = {};
|
| 80 |
+
core.setAjaxLoad('navContent');
|
| 81 |
+
this.show(data);
|
| 82 |
+
}
|
| 83 |
+
});
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* SwitchFeedHandler
|
| 87 |
+
*
|
| 88 |
+
*/
|
| 89 |
+
var SwitchFeedHandler = Class.create(AbstractAdminContentHandler, {
|
| 90 |
+
initialize: function(){
|
| 91 |
+
this.provider = new SimpleRequestProvider();
|
| 92 |
+
},
|
| 93 |
+
|
| 94 |
+
load: function(url, parms){
|
| 95 |
+
this.provider.simpleResultQuery(
|
| 96 |
+
url,
|
| 97 |
+
parms,
|
| 98 |
+
this.simpleResultCallback.bind(this)
|
| 99 |
+
);
|
| 100 |
+
},
|
| 101 |
+
|
| 102 |
+
showSimpleResult: function(result){
|
| 103 |
+
id = result.getStateText();
|
| 104 |
+
element = document.getElementById(id.replace('.off','') + "-pic");
|
| 105 |
+
hiddenInput = document.getElementById(id.replace('.off','') + "-name");
|
| 106 |
+
if (result.getState()) {
|
| 107 |
+
if (id.endsWith('.conf')) {
|
| 108 |
+
element.alt='disable';
|
| 109 |
+
element.src = '/web-data/img/minus.png';
|
| 110 |
+
var title = 'enable ' + id;
|
| 111 |
+
element.up('.sPkgConfFeedsLink').title='disable ' + id;
|
| 112 |
+
|
| 113 |
+
}
|
| 114 |
+
else {
|
| 115 |
+
element.alt='enable';
|
| 116 |
+
element.src = '/web-data/img/plus.png';
|
| 117 |
+
var title = 'enable ' + id.replace('.off','');
|
| 118 |
+
element.up('.sPkgConfFeedsLink').title='enable ' + id.replace('.off','');
|
| 119 |
+
}
|
| 120 |
+
hiddenInput.value=id;
|
| 121 |
+
}
|
| 122 |
+
else {
|
| 123 |
+
alert(id);
|
| 124 |
+
};
|
| 125 |
+
},
|
| 126 |
+
});
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* MemoryHandler
|
| 130 |
+
*
|
| 131 |
+
*/
|
| 132 |
+
|
| 133 |
+
var MemoryHandler = Class.create(AbstractAdminContentHandler, {
|
| 134 |
+
initialize: function(){
|
| 135 |
+
this.provider = new MemoryProvider(this.show.bind(this));
|
| 136 |
+
},
|
| 137 |
+
|
| 138 |
+
load: function(url, parms){
|
| 139 |
+
this.provider.simpleResultQuery(
|
| 140 |
+
url,
|
| 141 |
+
parms,
|
| 142 |
+
this.simpleResultCallback.bind(this)
|
| 143 |
+
);
|
| 144 |
+
},
|
| 145 |
+
|
| 146 |
+
getMem: function(){
|
| 147 |
+
this.load('/webadmin/web/getmemory');
|
| 148 |
+
},
|
| 149 |
+
|
| 150 |
+
showSimpleResult: function(result){
|
| 151 |
+
str = result.getStateText();
|
| 152 |
+
if (result.getState()) {
|
| 153 |
+
document.getElementById('memContent').innerHTML=result.getStateText() + " MB free";
|
| 154 |
+
}
|
| 155 |
+
else {
|
| 156 |
+
alert(str);
|
| 157 |
+
};
|
| 158 |
+
},
|
| 159 |
+
});
|
| 160 |
+
|
| 161 |
+
/**
|
| 162 |
+
* SimpleWebAdminPageHandler
|
| 163 |
+
*
|
| 164 |
+
*/
|
| 165 |
+
|
| 166 |
+
var templateEngine2 = new TemplateEngine('/webadmin/tpl/');
|
| 167 |
+
|
| 168 |
+
var SimpleWebAdminPageHandler = Class.create(AbstractContentHandler,{
|
| 169 |
+
initialize: function($super, target){
|
| 170 |
+
$super(null, target);
|
| 171 |
+
},
|
| 172 |
+
|
| 173 |
+
show: function(tpl, data){
|
| 174 |
+
templateEngine2.process(tpl, data, this.target, this.finished.bind(this));
|
| 175 |
+
}
|
| 176 |
+
});
|
pool/shard011/JavaScript/0070365_Tags.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const React = require('react');
|
| 2 |
+
const classNames = require('classnames');
|
| 3 |
+
const Icon = require('./Icon');
|
| 4 |
+
|
| 5 |
+
const Tags = React.createClass({
|
| 6 |
+
propTypes: {
|
| 7 |
+
children: React.PropTypes.node
|
| 8 |
+
},
|
| 9 |
+
|
| 10 |
+
render() {
|
| 11 |
+
return (
|
| 12 |
+
<ul className="tags">
|
| 13 |
+
{this.props.children}
|
| 14 |
+
</ul>
|
| 15 |
+
);
|
| 16 |
+
}
|
| 17 |
+
});
|
| 18 |
+
|
| 19 |
+
const TagItem = React.createClass({
|
| 20 |
+
propTypes: {
|
| 21 |
+
title: React.PropTypes.string,
|
| 22 |
+
href: React.PropTypes.string,
|
| 23 |
+
active: React.PropTypes.bool,
|
| 24 |
+
onClick: React.PropTypes.func,
|
| 25 |
+
// count and showX are exclusive
|
| 26 |
+
count: React.PropTypes.number,
|
| 27 |
+
showX: React.PropTypes.bool
|
| 28 |
+
},
|
| 29 |
+
|
| 30 |
+
getDefaultProps() {
|
| 31 |
+
return {
|
| 32 |
+
href: '#',
|
| 33 |
+
showX: false
|
| 34 |
+
};
|
| 35 |
+
},
|
| 36 |
+
|
| 37 |
+
onClick(e) {
|
| 38 |
+
const { onClick } = this.props;
|
| 39 |
+
|
| 40 |
+
if (!onClick) {
|
| 41 |
+
return;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
e.preventDefault();
|
| 45 |
+
onClick();
|
| 46 |
+
},
|
| 47 |
+
|
| 48 |
+
render() {
|
| 49 |
+
const { active, count, showX, title, href } = this.props;
|
| 50 |
+
|
| 51 |
+
const className = classNames('tag', {
|
| 52 |
+
active
|
| 53 |
+
});
|
| 54 |
+
|
| 55 |
+
let inner = '';
|
| 56 |
+
if (showX) {
|
| 57 |
+
inner = <span className="extra"> <Icon id="x"/></span>;
|
| 58 |
+
} else if (typeof count !== 'undefined') {
|
| 59 |
+
inner = <span className="extra"> | {count}</span>;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
return (
|
| 63 |
+
<li className={className}>
|
| 64 |
+
<a href={href} onClick={this.onClick}>
|
| 65 |
+
<span className="name">{title}</span>
|
| 66 |
+
{inner}
|
| 67 |
+
</a>
|
| 68 |
+
</li>
|
| 69 |
+
);
|
| 70 |
+
}
|
| 71 |
+
});
|
| 72 |
+
|
| 73 |
+
module.exports = Tags;
|
| 74 |
+
module.exports.Item = TagItem;
|
pool/shard011/JavaScript/0070366_getNotifications.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { createSelector } from 'reselect';
|
| 2 |
+
import * as commons from './commons';
|
| 3 |
+
|
| 4 |
+
/**
|
| 5 |
+
* Select notifications for a member from state
|
| 6 |
+
*
|
| 7 |
+
* @alias module:Members.getNotifications
|
| 8 |
+
* @category selectors
|
| 9 |
+
*
|
| 10 |
+
* @example
|
| 11 |
+
* const mapStateToProps = (state, props) => ({
|
| 12 |
+
* show: BetaSeries.getSelector('members', 'getNotifications')(state, { memberId: props.memberId });
|
| 13 |
+
* });
|
| 14 |
+
*
|
| 15 |
+
* @param {Object} [state] Redux state
|
| 16 |
+
* @param {Object} [obj] Accept the following:
|
| 17 |
+
* @param {Object} [obj.memberId] Member ID
|
| 18 |
+
*
|
| 19 |
+
* @returns {Array} Notifications array element or `undefined`
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
const getNotifications = createSelector(
|
| 23 |
+
[commons.getMembers, commons.getNotifications, commons.getMemberId],
|
| 24 |
+
(members, membersNotifications, memberId) => {
|
| 25 |
+
const notifications = !Object.prototype.hasOwnProperty.call(
|
| 26 |
+
membersNotifications,
|
| 27 |
+
memberId
|
| 28 |
+
)
|
| 29 |
+
? null
|
| 30 |
+
: membersNotifications[memberId];
|
| 31 |
+
|
| 32 |
+
if (!notifications) {
|
| 33 |
+
return undefined;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
return notifications;
|
| 37 |
+
}
|
| 38 |
+
);
|
| 39 |
+
|
| 40 |
+
export default getNotifications;
|
pool/shard011/JavaScript/0070373_form.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* JavaScript for form editing date conditions.
|
| 3 |
+
*
|
| 4 |
+
* @module moodle-availability_date-form
|
| 5 |
+
*/
|
| 6 |
+
M.availability_date = M.availability_date || {};
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* @class M.availability_date.form
|
| 10 |
+
* @extends M.core_availability.plugin
|
| 11 |
+
*/
|
| 12 |
+
M.availability_date.form = Y.Object(M.core_availability.plugin);
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Initialises this plugin.
|
| 16 |
+
*
|
| 17 |
+
* Because the date fields are complex depending on Moodle calendar settings,
|
| 18 |
+
* we create the HTML for these fields in PHP and pass it to this method.
|
| 19 |
+
*
|
| 20 |
+
* @method initInner
|
| 21 |
+
* @param {String} html HTML to use for date fields
|
| 22 |
+
* @param {Number} defaultTime Time value that corresponds to initial fields
|
| 23 |
+
*/
|
| 24 |
+
M.availability_date.form.initInner = function(html, defaultTime) {
|
| 25 |
+
this.html = html;
|
| 26 |
+
this.defaultTime = defaultTime;
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
M.availability_date.form.getNode = function(json) {
|
| 30 |
+
var strings = M.str.availability_date;
|
| 31 |
+
var html = strings.direction_before + ' <span class="availability-group">' +
|
| 32 |
+
'<label><span class="accesshide">' + strings.direction_label + ' </span>' +
|
| 33 |
+
'<select name="direction">' +
|
| 34 |
+
'<option value=">=">' + strings.direction_from + '</option>' +
|
| 35 |
+
'<option value="<">' + strings.direction_until + '</option>' +
|
| 36 |
+
'</select></label></span> ' + this.html;
|
| 37 |
+
var node = Y.Node.create('<span>' + html + '</span>');
|
| 38 |
+
|
| 39 |
+
// Set initial value if non-default.
|
| 40 |
+
if (json.t !== undefined) {
|
| 41 |
+
node.setData('time', json.t);
|
| 42 |
+
// Disable everything.
|
| 43 |
+
node.all('select:not([name=direction])').each(function(select) {
|
| 44 |
+
select.set('disabled', true);
|
| 45 |
+
});
|
| 46 |
+
|
| 47 |
+
var url = M.cfg.wwwroot + '/availability/condition/date/ajax.php?action=fromtime' +
|
| 48 |
+
'&time=' + json.t;
|
| 49 |
+
Y.io(url, { on : {
|
| 50 |
+
success : function(id, response) {
|
| 51 |
+
var fields = Y.JSON.parse(response.responseText);
|
| 52 |
+
for (var field in fields) {
|
| 53 |
+
var select = node.one('select[name=x\\[' + field + '\\]]');
|
| 54 |
+
select.set('value', fields[field]);
|
| 55 |
+
select.set('disabled', false);
|
| 56 |
+
}
|
| 57 |
+
},
|
| 58 |
+
failure : function() {
|
| 59 |
+
window.alert(M.str.availability_date.ajaxerror);
|
| 60 |
+
}
|
| 61 |
+
}});
|
| 62 |
+
} else {
|
| 63 |
+
// Set default time that corresponds to the HTML selectors.
|
| 64 |
+
node.setData('time', this.defaultTime);
|
| 65 |
+
}
|
| 66 |
+
if (json.d !== undefined) {
|
| 67 |
+
node.one('select[name=direction]').set('value', json.d);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
// Add event handlers (first time only).
|
| 71 |
+
if (!M.availability_date.form.addedEvents) {
|
| 72 |
+
M.availability_date.form.addedEvents = true;
|
| 73 |
+
|
| 74 |
+
var root = Y.one('#fitem_id_availabilityconditionsjson');
|
| 75 |
+
root.delegate('change', function() {
|
| 76 |
+
// For the direction, just update the form fields.
|
| 77 |
+
M.core_availability.form.update();
|
| 78 |
+
}, '.availability_date select[name=direction]');
|
| 79 |
+
|
| 80 |
+
root.delegate('change', function() {
|
| 81 |
+
// Update time using AJAX call from root node.
|
| 82 |
+
M.availability_date.form.updateTime(this.ancestor('span.availability_date'));
|
| 83 |
+
}, '.availability_date select:not([name=direction])');
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
if (node.one('a[href=#]')) {
|
| 87 |
+
// Add the date selector magic.
|
| 88 |
+
M.form.dateselector.init_single_date_selector(node);
|
| 89 |
+
|
| 90 |
+
// This special handler detects when the date selector changes the year.
|
| 91 |
+
var yearSelect = node.one('select[name=x\\[year\\]]');
|
| 92 |
+
var oldSet = yearSelect.set;
|
| 93 |
+
yearSelect.set = function(name, value) {
|
| 94 |
+
oldSet.call(yearSelect, name, value);
|
| 95 |
+
if (name === 'selectedIndex') {
|
| 96 |
+
// Do this after timeout or the other fields haven't been set yet.
|
| 97 |
+
setTimeout(function() {
|
| 98 |
+
M.availability_date.form.updateTime(node);
|
| 99 |
+
}, 0);
|
| 100 |
+
}
|
| 101 |
+
};
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
return node;
|
| 105 |
+
};
|
| 106 |
+
|
| 107 |
+
/**
|
| 108 |
+
* Updates time from AJAX. Whenever the field values change, we recompute the
|
| 109 |
+
* actual time via an AJAX request to Moodle.
|
| 110 |
+
*
|
| 111 |
+
* This will set the 'time' data on the node and then update the form, once it
|
| 112 |
+
* gets an AJAX response.
|
| 113 |
+
*
|
| 114 |
+
* @method updateTime
|
| 115 |
+
* @param {Y.Node} component Node for plugin controls
|
| 116 |
+
*/
|
| 117 |
+
M.availability_date.form.updateTime = function(node) {
|
| 118 |
+
// After a change to the date/time we need to recompute the
|
| 119 |
+
// actual time using AJAX because it depends on the user's
|
| 120 |
+
// time zone and calendar options.
|
| 121 |
+
var url = M.cfg.wwwroot + '/availability/condition/date/ajax.php?action=totime' +
|
| 122 |
+
'&year=' + node.one('select[name=x\\[year\\]]').get('value') +
|
| 123 |
+
'&month=' + node.one('select[name=x\\[month\\]]').get('value') +
|
| 124 |
+
'&day=' + node.one('select[name=x\\[day\\]]').get('value') +
|
| 125 |
+
'&hour=' + node.one('select[name=x\\[hour\\]]').get('value') +
|
| 126 |
+
'&minute=' + node.one('select[name=x\\[minute\\]]').get('value');
|
| 127 |
+
Y.io(url, { on : {
|
| 128 |
+
success : function(id, response) {
|
| 129 |
+
node.setData('time', response.responseText);
|
| 130 |
+
M.core_availability.form.update();
|
| 131 |
+
},
|
| 132 |
+
failure : function() {
|
| 133 |
+
window.alert(M.str.availability_date.ajaxerror);
|
| 134 |
+
}
|
| 135 |
+
}});
|
| 136 |
+
};
|
| 137 |
+
|
| 138 |
+
M.availability_date.form.fillValue = function(value, node) {
|
| 139 |
+
value.d = node.one('select[name=direction]').get('value');
|
| 140 |
+
value.t = parseInt(node.getData('time'), 10);
|
| 141 |
+
};
|
pool/shard011/JavaScript/0070375_Gruntfile.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var UmxGruntConfig = require('umx-grunt-config');
|
| 2 |
+
module.exports = function(grunt) {
|
| 3 |
+
var configurator = new UmxGruntConfig(require, grunt);
|
| 4 |
+
configurator.initBump();
|
| 5 |
+
configurator.initWebpack();
|
| 6 |
+
configurator.initWatch();
|
| 7 |
+
configurator.initJshint();
|
| 8 |
+
configurator.initMochaTest();
|
| 9 |
+
configurator.initUglify();
|
| 10 |
+
configurator.registerBumpTasks();
|
| 11 |
+
grunt.initConfig(configurator.config);
|
| 12 |
+
grunt.registerTask('test', [ 'jshint', 'mochaTest' ]);
|
| 13 |
+
grunt.registerTask('build', [ 'test', 'webpack' ]);
|
| 14 |
+
grunt.registerTask('build-min', [ 'build', 'uglify' ]);
|
| 15 |
+
grunt.registerTask('commit', [ 'build-min', 'bump-commit' ]);
|
| 16 |
+
grunt.registerTask('default', [ 'build-min' ]);
|
| 17 |
+
}
|
pool/shard011/JavaScript/0070376_util.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @file General utilities and settings.
|
| 3 |
+
*
|
| 4 |
+
* It also contains some helper functions to be used in EJS templates.
|
| 5 |
+
*
|
| 6 |
+
* @module lib/util
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
'use strict'
|
| 10 |
+
|
| 11 |
+
var path = require('path')
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Directory with all the fate data.
|
| 15 |
+
* @type {string}
|
| 16 |
+
*/
|
| 17 |
+
module.exports.dir = '/var/www/fateweb'
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Port to listen on.
|
| 21 |
+
* @type {number}
|
| 22 |
+
*/
|
| 23 |
+
module.exports.port = 8080
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Get the Gitweb URL of a piece of history between two commits or from
|
| 27 |
+
* one commit back.
|
| 28 |
+
*
|
| 29 |
+
* @param newer {string} Revision of the newer commit.
|
| 30 |
+
* @param [older] {string} Revision of the older commit.
|
| 31 |
+
* @return {string} HTML code for a hyperlink to the URL of the history.
|
| 32 |
+
*/
|
| 33 |
+
module.exports.linkGitHist = function (newer, older) {
|
| 34 |
+
var end = older ? ';hp=' + older : ''
|
| 35 |
+
return '<a href="http://git.videolan.org/?p=ffmpeg.git;a=shortlog;h=' + newer + end + '">'
|
| 36 |
+
+ (older ? older : newer)
|
| 37 |
+
+ '</a>'
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
module.exports.formatConfig = function (str) {
|
| 41 |
+
if (str == undefined) return ''
|
| 42 |
+
return str.replace(/(?!^)--/g, '<br>--')
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
module.exports.log = path.resolve(__dirname, '..', 'logs', 'access.log')
|
| 46 |
+
|
| 47 |
+
module.exports.proxy = true
|
| 48 |
+
|
| 49 |
+
module.exports.cache = 10
|
pool/shard011/JavaScript/0070378_find.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module.exports = app => {
|
| 2 |
+
class Post extends app.Service {
|
| 3 |
+
//新增数据
|
| 4 |
+
* create(post){
|
| 5 |
+
return yield this.ctx.model.Post.create(post);
|
| 6 |
+
}
|
| 7 |
+
//删除数据
|
| 8 |
+
* delete(id){
|
| 9 |
+
return yield this.ctx.model.Post.destroy({where:{id: id}});
|
| 10 |
+
}
|
| 11 |
+
//更新操作
|
| 12 |
+
* update(id,msg){
|
| 13 |
+
return yield this.ctx.model.Post.update(msg,{where:{id: id}});
|
| 14 |
+
}
|
| 15 |
+
//关联查询
|
| 16 |
+
* find(id){
|
| 17 |
+
const post = yield this.ctx.model.Post.findById(id,{
|
| 18 |
+
include: [{
|
| 19 |
+
model: this.ctx.model.User,
|
| 20 |
+
as: 'user',
|
| 21 |
+
attributes: ['id','name','age'],
|
| 22 |
+
}],
|
| 23 |
+
});
|
| 24 |
+
if(!post){
|
| 25 |
+
this.ctx.throw(404,'post not found');
|
| 26 |
+
}
|
| 27 |
+
return post;
|
| 28 |
+
};
|
| 29 |
+
//单表查询
|
| 30 |
+
* findSigle(id){
|
| 31 |
+
const post = yield this.ctx.model.Post.findOne({where:{id: id}});
|
| 32 |
+
if(!post){
|
| 33 |
+
this.ctx.throw(404,'post not found');
|
| 34 |
+
}
|
| 35 |
+
return post;
|
| 36 |
+
}
|
| 37 |
+
//单表查询,查询条件为数组
|
| 38 |
+
* findInArray(ids){
|
| 39 |
+
const post = yield this.ctx.model.Post.findAll({where: {id: ids}});
|
| 40 |
+
if(!post){
|
| 41 |
+
this.ctx.throw(404,'post not found');
|
| 42 |
+
}
|
| 43 |
+
return post;
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
return Post;
|
| 47 |
+
}
|
pool/shard011/JavaScript/0070394_mobile_operator.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var MobileOperator = {
|
| 4 |
+
BRAZIL_MCC: 724,
|
| 5 |
+
BRAZIL_CELLBROADCAST_CHANNEL: 50,
|
| 6 |
+
|
| 7 |
+
userFacingInfo: function mo_userFacingInfo(mobileConnection) {
|
| 8 |
+
var network = mobileConnection.voice.network;
|
| 9 |
+
var iccInfo = mobileConnection.iccInfo;
|
| 10 |
+
var operator = network.shortName || network.longName;
|
| 11 |
+
|
| 12 |
+
if (iccInfo.isDisplaySpnRequired && iccInfo.spn
|
| 13 |
+
&& !mobileConnection.voice.roaming) {
|
| 14 |
+
if (iccInfo.isDisplayNetworkNameRequired) {
|
| 15 |
+
operator = operator + ' ' + iccInfo.spn;
|
| 16 |
+
} else {
|
| 17 |
+
operator = iccInfo.spn;
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
var carrier, region;
|
| 22 |
+
if (this.isBrazil(mobileConnection)) {
|
| 23 |
+
// We are in Brazil, It is legally required to show local info
|
| 24 |
+
// about current registered GSM network in a legally specified way.
|
| 25 |
+
var lac = mobileConnection.voice.cell.gsmLocationAreaCode % 100;
|
| 26 |
+
var carriers = MobileInfo.brazil.carriers;
|
| 27 |
+
var regions = MobileInfo.brazil.regions;
|
| 28 |
+
|
| 29 |
+
carrier = carriers[network.mnc] || (this.BRAZIL_MCC.toString() + network.mnc);
|
| 30 |
+
region = (regions[lac] ? regions[lac] + ' ' + lac : '');
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
return {
|
| 34 |
+
'operator': operator,
|
| 35 |
+
'carrier': carrier,
|
| 36 |
+
'region': region
|
| 37 |
+
};
|
| 38 |
+
},
|
| 39 |
+
|
| 40 |
+
isBrazil: function mo_isBrazil(mobileConnection) {
|
| 41 |
+
var cell = mobileConnection.voice.cell;
|
| 42 |
+
return mobileConnection.voice.network.mcc == this.BRAZIL_MCC &&
|
| 43 |
+
cell && cell.gsmLocationAreaCode;
|
| 44 |
+
}
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
var MobileInfo = {
|
| 49 |
+
brazil: {
|
| 50 |
+
carriers: {
|
| 51 |
+
'0': 'NEXTEL',
|
| 52 |
+
'2': 'TIM', '3': 'TIM', '4': 'TIM',
|
| 53 |
+
'5': 'CLARO', '6': 'VIVO', '7': 'CTBC', '8': 'TIM',
|
| 54 |
+
'10': 'VIVO', '11': 'VIVO', '15': 'SERCOMTEL',
|
| 55 |
+
'16': 'OI', '23': 'VIVO', '24': 'OI', '31': 'OI',
|
| 56 |
+
'32': 'CTBC', '33': 'CTBC', '34': 'CTBC', '37': 'AEIOU'
|
| 57 |
+
},
|
| 58 |
+
regions: {
|
| 59 |
+
'11': 'SP', '12': 'SP', '13': 'SP', '14': 'SP', '15': 'SP', '16': 'SP',
|
| 60 |
+
'17': 'SP', '18': 'SP', '19': 'SP',
|
| 61 |
+
'21': 'RJ', '22': 'RJ', '24': 'RJ',
|
| 62 |
+
'27': 'ES', '28': 'ES',
|
| 63 |
+
'31': 'MG', '32': 'MG', '33': 'MG', '34': 'MG', '35': 'MG', '37': 'MG',
|
| 64 |
+
'38': 'MG',
|
| 65 |
+
'41': 'PR', '42': 'PR', '43': 'PR', '44': 'PR', '45': 'PR', '46': 'PR',
|
| 66 |
+
'47': 'SC', '48': 'SC', '49': 'SC',
|
| 67 |
+
'51': 'RS', '53': 'RS', '54': 'RS', '55': 'RS',
|
| 68 |
+
'61': 'DF',
|
| 69 |
+
'62': 'GO',
|
| 70 |
+
'63': 'TO',
|
| 71 |
+
'64': 'GO',
|
| 72 |
+
'65': 'MT', '66': 'MT',
|
| 73 |
+
'67': 'MS',
|
| 74 |
+
'68': 'AC',
|
| 75 |
+
'69': 'RO',
|
| 76 |
+
'71': 'BA', '73': 'BA', '74': 'BA', '75': 'BA', '77': 'BA',
|
| 77 |
+
'79': 'SE',
|
| 78 |
+
'81': 'PE',
|
| 79 |
+
'82': 'AL',
|
| 80 |
+
'83': 'PB',
|
| 81 |
+
'84': 'RN',
|
| 82 |
+
'85': 'CE',
|
| 83 |
+
'86': 'PI',
|
| 84 |
+
'87': 'PE',
|
| 85 |
+
'88': 'CE',
|
| 86 |
+
'89': 'PI',
|
| 87 |
+
'91': 'PA',
|
| 88 |
+
'92': 'AM',
|
| 89 |
+
'93': 'PA', '94': 'PA',
|
| 90 |
+
'95': 'RR',
|
| 91 |
+
'96': 'AP',
|
| 92 |
+
'97': 'AM',
|
| 93 |
+
'98': 'MA', '99': 'MA'
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
};
|
pool/shard011/JavaScript/0070396_eachs.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* jshint strict: true, undef: true */
|
| 2 |
+
/* globals spec, _, to_string, is_enumerable, length, keys_or_indexes */
|
| 3 |
+
/* globals exports */
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
// TODO: spec :eachs does not alter inputs
|
| 7 |
+
spec(
|
| 8 |
+
["01", "12"],
|
| 9 |
+
function eachs_passes_key_and_val() {
|
| 10 |
+
|
| 11 |
+
var v = [];
|
| 12 |
+
eachs( [1,2], function (kx, x) { v.push("" + kx + x); });
|
| 13 |
+
return v;
|
| 14 |
+
}
|
| 15 |
+
);
|
| 16 |
+
|
| 17 |
+
spec(
|
| 18 |
+
["1a", "1b", "2a", "2b"],
|
| 19 |
+
function eachs_passes_vals_of_multiple_colls() {
|
| 20 |
+
|
| 21 |
+
var v = [];
|
| 22 |
+
eachs( [1,2], ["a", "b"], function (kx, x, ky, y) { v.push("" + x + y); });
|
| 23 |
+
return v;
|
| 24 |
+
}
|
| 25 |
+
);
|
| 26 |
+
|
| 27 |
+
spec(
|
| 28 |
+
["onea", "twoa"],
|
| 29 |
+
function eachs_passes_keys_and_vals_of_arrays_and_plain_objects() {
|
| 30 |
+
|
| 31 |
+
var v = [];
|
| 32 |
+
eachs({one: 1, two: 2}, ["a"], function (kx, x, ky, y) { v.push("" + kx + y); });
|
| 33 |
+
return v;
|
| 34 |
+
}
|
| 35 |
+
);
|
| 36 |
+
|
| 37 |
+
spec(
|
| 38 |
+
["1a", "1b", "2a", "2b"],
|
| 39 |
+
function eachs_passes_vals_of_plain_object_and_array() {
|
| 40 |
+
|
| 41 |
+
var v = [];
|
| 42 |
+
eachs({one: 1, two: 2}, ["a", "b"], function (kx, x, ky, y) { v.push("" + x + y); });
|
| 43 |
+
return v;
|
| 44 |
+
}
|
| 45 |
+
);
|
| 46 |
+
|
| 47 |
+
spec( [],
|
| 48 |
+
function eachs_returns_empty_array_if_one_array_is_empty() {
|
| 49 |
+
|
| 50 |
+
var v = [];
|
| 51 |
+
eachs({one: 1, two: 2}, [], ["a"], function (kx, x, ky, y, kz, z) {
|
| 52 |
+
v.push("" + kx + y);
|
| 53 |
+
});
|
| 54 |
+
return v;
|
| 55 |
+
}
|
| 56 |
+
);
|
| 57 |
+
|
| 58 |
+
exports.eachs = eachs;
|
| 59 |
+
function eachs() {
|
| 60 |
+
|
| 61 |
+
var args = _.toArray(arguments);
|
| 62 |
+
|
| 63 |
+
if (args.length < 2)
|
| 64 |
+
throw new Error("Not enough args: " + to_string(args));
|
| 65 |
+
var f = args.pop();
|
| 66 |
+
|
| 67 |
+
// === Validate inputs before continuing:
|
| 68 |
+
for (var i = 0; i < args.length; i++) {
|
| 69 |
+
if (!is_enumerable(args[i]))
|
| 70 |
+
throw new Error("Invalid value for eachs: " + to_string(args[i]));
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
// === Process inputs:
|
| 74 |
+
var cols_length = length(args);
|
| 75 |
+
|
| 76 |
+
return eachs_row_maker([], 0, _.map(args, keys_or_indexes));
|
| 77 |
+
|
| 78 |
+
function eachs_row_maker(row, col_i, key_cols) {
|
| 79 |
+
if (col_i >= cols_length) {
|
| 80 |
+
if (row.length !== f.length)
|
| 81 |
+
throw new Error("f.length (" + f.length + ") should be " + row.length + " (collection count * 2 )");
|
| 82 |
+
f.apply(null, [].concat(row)); // set reduced value
|
| 83 |
+
return;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
var keys = key_cols[col_i].slice(0);
|
| 87 |
+
var vals = args[col_i];
|
| 88 |
+
++col_i;
|
| 89 |
+
|
| 90 |
+
for(var i = 0; i < keys.length; i++) {
|
| 91 |
+
row.push(keys[i]); // key
|
| 92 |
+
row.push(vals[keys[i]]); // actual value
|
| 93 |
+
|
| 94 |
+
eachs_row_maker(row, col_i, key_cols);
|
| 95 |
+
|
| 96 |
+
row.pop();
|
| 97 |
+
row.pop();
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
return;
|
| 101 |
+
}
|
| 102 |
+
}
|
pool/shard011/JavaScript/0070398_fs.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict'
|
| 2 |
+
|
| 3 |
+
const fs = jest.genMockFromModule(`fs`)
|
| 4 |
+
|
| 5 |
+
let mockFiles = {}
|
| 6 |
+
function __setMockFiles(newMockFiles) {
|
| 7 |
+
mockFiles = Object.assign({}, newMockFiles)
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
function readFileSync(filePath, parser) {
|
| 11 |
+
return mockFiles[filePath]
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
fs.__setMockFiles = __setMockFiles
|
| 15 |
+
fs.readFileSync = readFileSync
|
| 16 |
+
|
| 17 |
+
module.exports = fs
|
pool/shard011/JavaScript/0070399_list-elem.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function() {
|
| 2 |
+
window.daElements.listElem = {
|
| 3 |
+
properties: {
|
| 4 |
+
localData: {
|
| 5 |
+
type: Array,
|
| 6 |
+
value: []
|
| 7 |
+
},
|
| 8 |
+
filters: {
|
| 9 |
+
type: Array,
|
| 10 |
+
notify: true,
|
| 11 |
+
value: []
|
| 12 |
+
},
|
| 13 |
+
activeFilterId: {
|
| 14 |
+
type: Number,
|
| 15 |
+
value: null,
|
| 16 |
+
observer: 'filter',
|
| 17 |
+
notify: true
|
| 18 |
+
},
|
| 19 |
+
user: {
|
| 20 |
+
type: String
|
| 21 |
+
}
|
| 22 |
+
},
|
| 23 |
+
listeners: {
|
| 24 |
+
'cell-tap': 'cellTap'
|
| 25 |
+
},
|
| 26 |
+
cellListeners: {
|
| 27 |
+
'Docket': 'docketTap'
|
| 28 |
+
},
|
| 29 |
+
ready: function() {
|
| 30 |
+
return app.patchDatatable(this.$.datatableList, this);
|
| 31 |
+
},
|
| 32 |
+
refresh: function() {
|
| 33 |
+
console.log("refreshing case list");
|
| 34 |
+
this.$.datatableList.data = [];
|
| 35 |
+
this.filter();
|
| 36 |
+
return this.$.datatableList.data = this.localData;
|
| 37 |
+
},
|
| 38 |
+
filter: function() {
|
| 39 |
+
var filter;
|
| 40 |
+
if (this.activeFilterId !== null) {
|
| 41 |
+
filter = this.filters[this.activeFilterId];
|
| 42 |
+
return this.localData = filter.filter(app.cases);
|
| 43 |
+
} else {
|
| 44 |
+
return this.localData = app.cases;
|
| 45 |
+
}
|
| 46 |
+
},
|
| 47 |
+
cellTap: function(e) {
|
| 48 |
+
if (this.cellListeners[e.detail.column.header] != null) {
|
| 49 |
+
return this[this.cellListeners[e.detail.column.header]](e);
|
| 50 |
+
}
|
| 51 |
+
},
|
| 52 |
+
docketTap: function(e) {
|
| 53 |
+
if (e.detail.item["case"] != null) {
|
| 54 |
+
return app.displayCase(e.detail.item["case"].id);
|
| 55 |
+
} else {
|
| 56 |
+
return app.displayCase(e.detail.item.id);
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
}).call(this);
|
pool/shard011/JavaScript/0070400_Provider.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
angular.module('FullstackApp.Provider',[])
|
| 4 |
+
.factory('ProviderFct', function() {
|
| 5 |
+
|
| 6 |
+
var providerFct = {
|
| 7 |
+
new: function() {
|
| 8 |
+
|
| 9 |
+
var model = {
|
| 10 |
+
id: null,
|
| 11 |
+
name: ""
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
return model;
|
| 15 |
+
}
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
return providerFct;
|
| 19 |
+
})
|
| 20 |
+
.service('ProviderSvc',function( $http ) {
|
| 21 |
+
this.providers = [];
|
| 22 |
+
var That = this;
|
| 23 |
+
|
| 24 |
+
this.getAll = function() {
|
| 25 |
+
var promise = new Promise(
|
| 26 |
+
function( resolve, reject) {
|
| 27 |
+
if ( That.providers.length ) {
|
| 28 |
+
resolve( That.providers);
|
| 29 |
+
}
|
| 30 |
+
else {
|
| 31 |
+
$http.get('/providers').then(function(res) {
|
| 32 |
+
That.providers = res.data;
|
| 33 |
+
resolve( res.data)
|
| 34 |
+
}).catch(reject);
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
);
|
| 38 |
+
return promise;
|
| 39 |
+
}
|
| 40 |
+
this.delete = function( provider ) { return $http.delete('/providers/' + provider.id) }
|
| 41 |
+
this.save = function( provider ) {
|
| 42 |
+
var promise = new Promise(
|
| 43 |
+
function( resolve, reject ) {
|
| 44 |
+
$http.post('/providers/:id', provider).then(resolve, reject);
|
| 45 |
+
}
|
| 46 |
+
);
|
| 47 |
+
return promise;
|
| 48 |
+
}
|
| 49 |
+
this.getAll = this.getAll.bind( this );
|
| 50 |
+
})
|
| 51 |
+
.controller('ProviderCtrl',function( $scope, ProviderSvc, ProviderFct ) {
|
| 52 |
+
|
| 53 |
+
angular.extend($scope, {
|
| 54 |
+
providers: [],
|
| 55 |
+
newProvider: ProviderFct.new()
|
| 56 |
+
});
|
| 57 |
+
|
| 58 |
+
$scope.saveProvider = function( provider ) {
|
| 59 |
+
ProviderSvc.save( provider ).then(function( res ){
|
| 60 |
+
if (!provider.id) {
|
| 61 |
+
$scope.providers.push( res.data.model );
|
| 62 |
+
$scope.newProvider.name = "";
|
| 63 |
+
}
|
| 64 |
+
$scope.$emit('providersChange', $scope.providers);
|
| 65 |
+
}).catch( function( err ) {
|
| 66 |
+
$scope.showError( err.data );
|
| 67 |
+
});
|
| 68 |
+
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
// Adds a new provider
|
| 72 |
+
$scope.addProvider = function() {
|
| 73 |
+
if ( $scope.newProvider.name.length ) $scope.saveProvider( $scope.newProvider );
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
// Updates a provider's name
|
| 77 |
+
$scope.editProvider = function( provider ) {
|
| 78 |
+
var name = prompt("Enter the provider's name", provider.name);
|
| 79 |
+
if ( angular.isString( name ) && name.length ) {
|
| 80 |
+
provider.name = name;
|
| 81 |
+
$scope.saveProvider( provider );
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
// Deletes a provider
|
| 86 |
+
$scope.deleteProvider = function( provider ) {
|
| 87 |
+
if (confirm("Are you sure you want to delete the provider: ".concat(provider.name,"?"))) {
|
| 88 |
+
ProviderSvc.delete( provider ).then(function( res ) {
|
| 89 |
+
var i = $scope.providers.indexOf( provider );
|
| 90 |
+
$scope.providers.splice(i, 1);
|
| 91 |
+
$scope.$emit('providersChange', $scope.providers);
|
| 92 |
+
});
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
// Loads the provider's list
|
| 97 |
+
ProviderSvc.getAll().then(function( providers ) {
|
| 98 |
+
$scope.providers = providers;
|
| 99 |
+
$scope.$emit('providersChange', providers);
|
| 100 |
+
}).catch(function( res ) {
|
| 101 |
+
$scope.showError( res.data.err );
|
| 102 |
+
})
|
| 103 |
+
});
|
pool/shard011/JavaScript/0070407_blip-assistant.js
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function BlipAssistant() {
|
| 2 |
+
/* this is the creator function for your scene assistant object. It will be passed all the
|
| 3 |
+
additional parameters (after the scene name) that were passed to pushScene. The reference
|
| 4 |
+
to the scene controller (this.controller) has not be established yet, so any initialization
|
| 5 |
+
that needs the scene controller should be done in the setup function below. */
|
| 6 |
+
|
| 7 |
+
// Database object
|
| 8 |
+
this.sqlite = new Sqlite("tram2000")
|
| 9 |
+
// Number of seconds since beginning of the journey
|
| 10 |
+
this.seconds = 0
|
| 11 |
+
// Latest timestamp returned by GPS
|
| 12 |
+
this.timestamp = 0
|
| 13 |
+
this.positions_queue = []
|
| 14 |
+
// Keeps active blip object
|
| 15 |
+
this.blip = false
|
| 16 |
+
// Latest know position
|
| 17 |
+
// this.lat_lng = false
|
| 18 |
+
// How many stops did we past
|
| 19 |
+
this.count = 0
|
| 20 |
+
//
|
| 21 |
+
this.last_measure = 0
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
// this function is for setup tasks that have to happen when the scene is first created
|
| 25 |
+
BlipAssistant.prototype.setup = function() {
|
| 26 |
+
|
| 27 |
+
// Timer setup
|
| 28 |
+
this.timerRollHandler = this.timerRoll.bind(this)
|
| 29 |
+
this.interval = window.setInterval(this.timerRollHandler, 1000)
|
| 30 |
+
|
| 31 |
+
// Command menu setup
|
| 32 |
+
this.commandMenuModel = {items: [{label: 'Pokaż szczegóły', command: 'show-details'}, {label: 'Reset', icon:'refresh', command:'reset'}]}
|
| 33 |
+
this.controller.setupWidget(Mojo.Menu.commandMenu, {}, this.commandMenuModel)
|
| 34 |
+
|
| 35 |
+
// Start tracking
|
| 36 |
+
this.controller.serviceRequest('palm://com.palm.location', {
|
| 37 |
+
method : "startTracking",
|
| 38 |
+
parameters: {
|
| 39 |
+
accuracy : 1,
|
| 40 |
+
responseTime: 1,
|
| 41 |
+
subscribe : true
|
| 42 |
+
},
|
| 43 |
+
onSuccess : this.onGpsSuccess.bind(this),
|
| 44 |
+
onFailure : this.onGpsFailure.bind(this)
|
| 45 |
+
})
|
| 46 |
+
|
| 47 |
+
// Require the device to stay awake
|
| 48 |
+
this.controller.serviceRequest("palm://com.palm.power/com/palm/power", {
|
| 49 |
+
method : "activityStart",
|
| 50 |
+
parameters: {
|
| 51 |
+
id : "com.palm.app.news.update-1",
|
| 52 |
+
duration_ms : "900000" // = 15 minutes (max)
|
| 53 |
+
},
|
| 54 |
+
onSuccess : function(){ console.log("Keeping awake for 15 min...") },
|
| 55 |
+
onFailure : function(){ console.log("Keeping awake failure.") }
|
| 56 |
+
})
|
| 57 |
+
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
BlipAssistant.prototype.onGpsSuccess = function(data) {
|
| 61 |
+
|
| 62 |
+
// Time which might be useful if we create new blip
|
| 63 |
+
this.timestamp = data.timestamp
|
| 64 |
+
this.positions_queue.push({lat: data.latitude, lng: data.longitude, time: data.timestamp})
|
| 65 |
+
// console.log(Object.toJSON(this.positions_queue))
|
| 66 |
+
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
BlipAssistant.prototype.onGpsFailure = function(status){
|
| 70 |
+
// console.log("Porażka gps" + Object.toJSON(errorCode))
|
| 71 |
+
window.clearInterval(this.interval)
|
| 72 |
+
this.controller.showAlertDialog({
|
| 73 |
+
onChoose: function() { },
|
| 74 |
+
title: 'Błąd GPS ('+ status.errorCode +')',
|
| 75 |
+
message: 'Nie mogłem ustalić bieżącego położenia.',
|
| 76 |
+
choices: [
|
| 77 |
+
{label: 'Spróbuj ponownie'},
|
| 78 |
+
{label: 'Anuluj'}
|
| 79 |
+
]
|
| 80 |
+
})
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
// On found nearby stops
|
| 84 |
+
BlipAssistant.prototype.dbSuccessHandler = function(transaction, SQLResultSet) {
|
| 85 |
+
// Handle successful queries including receiving results
|
| 86 |
+
// console.log("SQL success: " + SQLResultSet.rows.length)
|
| 87 |
+
var the_nearest_stop
|
| 88 |
+
var position = this.positions_queue[this.positions_queue.length - 1]
|
| 89 |
+
|
| 90 |
+
if(SQLResultSet.rows.length > 1) {
|
| 91 |
+
// Find the closest stop
|
| 92 |
+
var first_stop = SQLResultSet.rows.item(0)
|
| 93 |
+
// Infinity
|
| 94 |
+
var closest_distance = length(decodeGeoHash(first_stop.geo), position) // We can use this.lat_lng because it is the same as current position
|
| 95 |
+
the_nearest_stop = first_stop
|
| 96 |
+
|
| 97 |
+
for(var i=1; i<SQLResultSet.rows.length; i++){
|
| 98 |
+
var stop = SQLResultSet.rows.item(i)
|
| 99 |
+
var distance = length(decodeGeoHash(stop.geo), position)
|
| 100 |
+
if(closest_distance > distance){
|
| 101 |
+
closest_distance = distance
|
| 102 |
+
the_nearest_stop = stop
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
} else if(SQLResultSet.rows.length == 1) {
|
| 106 |
+
the_nearest_stop = SQLResultSet.rows.item(0)
|
| 107 |
+
} else {
|
| 108 |
+
// Nothing to do here
|
| 109 |
+
return
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
// console.log("Najbliższy przystanek: " + the_nearest_stop.id)
|
| 113 |
+
// console.log("Next: " + Object.toJSON(this.blip.next))
|
| 114 |
+
|
| 115 |
+
// if(!this.blip){
|
| 116 |
+
// // The same stop. Nothing do do here
|
| 117 |
+
// return
|
| 118 |
+
// }
|
| 119 |
+
|
| 120 |
+
// Check whether or not we are where we were
|
| 121 |
+
if(this.blip && this.blip.beg_id != the_nearest_stop.id) {
|
| 122 |
+
|
| 123 |
+
if(this.blip.next.indexOf( the_nearest_stop.id ) == -1) {
|
| 124 |
+
var transfer = false
|
| 125 |
+
$.each(this.blip.alternate_next, function(id, hash){
|
| 126 |
+
if(hash.next.indexOf( the_nearest_stop.id ) != -1){
|
| 127 |
+
transfer = {id: id, time: hash.time}
|
| 128 |
+
return
|
| 129 |
+
}
|
| 130 |
+
})
|
| 131 |
+
if(transfer) { // There was a transfer (previously)
|
| 132 |
+
// Remove redundant data
|
| 133 |
+
var transfer_time = Math.round((transfer.time - this.blip.beg_time) / 1000)
|
| 134 |
+
// console.log(transfer_time)
|
| 135 |
+
this.data = this.blip.data.substring(transfer_time)
|
| 136 |
+
|
| 137 |
+
this.blip.beg_id = transfer.id
|
| 138 |
+
this.blip.beg_time = transfer.time
|
| 139 |
+
} else {
|
| 140 |
+
// We may transferred
|
| 141 |
+
if(!this.blip.alternate_next[the_nearest_stop.id]) {
|
| 142 |
+
this.blip.alternate_next[the_nearest_stop.id] = {next: the_nearest_stop.next.split(","), time: this.timestamp}
|
| 143 |
+
|
| 144 |
+
}
|
| 145 |
+
return
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
// Otherwise we have the simplest scenario
|
| 149 |
+
|
| 150 |
+
// Finish and save current blip
|
| 151 |
+
// These are common actions for both situations: with and without transfer
|
| 152 |
+
this.blip.end_id = the_nearest_stop.id
|
| 153 |
+
this.blip.save()
|
| 154 |
+
this.blip = false
|
| 155 |
+
|
| 156 |
+
} else if(this.blip) {
|
| 157 |
+
// Prevent double blip
|
| 158 |
+
return
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
// Begin new blip
|
| 162 |
+
this.blip = new Blip(this.sqlite, this.timestamp, the_nearest_stop)
|
| 163 |
+
this.controller.get("count").update(this.count++)
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
BlipAssistant.prototype.timerRoll = function(event){
|
| 167 |
+
|
| 168 |
+
// Update timer
|
| 169 |
+
this.seconds++
|
| 170 |
+
var min = Math.floor(this.seconds / 60)
|
| 171 |
+
var sec = this.seconds % 60
|
| 172 |
+
if(sec < 10) sec = "0" + sec
|
| 173 |
+
this.controller.get("time").update(min + ":" + sec)
|
| 174 |
+
|
| 175 |
+
this.last_measure++
|
| 176 |
+
// Calculate speed
|
| 177 |
+
var speed = 0
|
| 178 |
+
// If this is not a first call (so we can display current speed)
|
| 179 |
+
|
| 180 |
+
if(this.positions_queue.length == 2){
|
| 181 |
+
// Current position
|
| 182 |
+
var location = this.positions_queue.pop()
|
| 183 |
+
// this will be our reference
|
| 184 |
+
var prev_location = this.positions_queue.pop()
|
| 185 |
+
|
| 186 |
+
// Estimate current speed (if there is a movement)
|
| 187 |
+
if(prev_location.lat != location.lat || prev_location.lng != location.lng)
|
| 188 |
+
speed = Math.round(length(prev_location, location) * ((location.time - prev_location.time) * (100/36)))
|
| 189 |
+
|
| 190 |
+
} else if(location && this.last_measure == 1) {
|
| 191 |
+
// First call or GPS didn't return position
|
| 192 |
+
speed = 0
|
| 193 |
+
} else {
|
| 194 |
+
// GPS doesn't respond for 3 seconds or more
|
| 195 |
+
speed = -1
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
console.log("speed: " + speed)
|
| 199 |
+
// console.log(Object.toJSON(data))
|
| 200 |
+
if(speed == -1) {
|
| 201 |
+
speed = "-"
|
| 202 |
+
} else {
|
| 203 |
+
|
| 204 |
+
// Only if there is no speed,
|
| 205 |
+
// check if we are close enough to a stop (or stops)
|
| 206 |
+
if(speed == 0) Stops.findNearby(this.sqlite, location, this.dbSuccessHandler.bind(this))
|
| 207 |
+
|
| 208 |
+
// append new data to blip
|
| 209 |
+
if(this.blip) {
|
| 210 |
+
this.blip.add( length(location, this.blip) * 1000, this.last_measure )
|
| 211 |
+
this.last_measure = 0
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
this.positions_queue = [location]
|
| 215 |
+
|
| 216 |
+
speed += " km/h"
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
this.controller.get("speed").update(speed)
|
| 220 |
+
|
| 221 |
+
// We no longer need previous position
|
| 222 |
+
// this.lat_lng = p2
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
BlipAssistant.prototype.activate = function(event) {
|
| 228 |
+
/* put in event handlers here that should only be in effect when this scene is active. For
|
| 229 |
+
example, key handlers that are observing the document */
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
BlipAssistant.prototype.deactivate = function(event) {
|
| 234 |
+
/* remove any event handlers you added in activate and do any other cleanup that should happen before
|
| 235 |
+
this scene is popped or another scene is pushed on top */
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
BlipAssistant.prototype.cleanup = function(event) {
|
| 239 |
+
/* this function should do any cleanup needed before the scene is destroyed as
|
| 240 |
+
a result of being popped off the scene stack */
|
| 241 |
+
|
| 242 |
+
clearInterval(this.interval)
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
BlipAssistant.prototype.toggleDetails = function(){
|
| 246 |
+
// console.log("showing details")
|
| 247 |
+
$("#details").toggleClass("hidden")
|
| 248 |
+
// Nie mogłem połączyć się z siecią internet.
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
BlipAssistant.prototype.handleCommand = function(event) {
|
| 252 |
+
|
| 253 |
+
if(event.type == Mojo.Event.command) {
|
| 254 |
+
switch(event.command) {
|
| 255 |
+
case 'show-details':
|
| 256 |
+
this.commandMenuModel.temp = this.commandMenuModel.items
|
| 257 |
+
this.commandMenuModel.items = [{label: 'Ukryj szczegóły', command: 'hide-details'}, {label: 'Reset', icon:'refresh', command:'reset'}]
|
| 258 |
+
this.controller.modelChanged(this.commandMenuModel)
|
| 259 |
+
this.toggleDetails()
|
| 260 |
+
break
|
| 261 |
+
|
| 262 |
+
case 'hide-details':
|
| 263 |
+
this.commandMenuModel.items = this.commandMenuModel.temp
|
| 264 |
+
this.controller.modelChanged(this.commandMenuModel)
|
| 265 |
+
this.toggleDetails()
|
| 266 |
+
break
|
| 267 |
+
|
| 268 |
+
case 'reset':
|
| 269 |
+
Mojo.Controller.stageController.activeScene().showAlertDialog({
|
| 270 |
+
onChoose: function(value) {
|
| 271 |
+
if(value){
|
| 272 |
+
this.blip = false
|
| 273 |
+
this.count = 0
|
| 274 |
+
this.seconds = -1
|
| 275 |
+
this.controller.get("count").update("-")
|
| 276 |
+
}
|
| 277 |
+
},
|
| 278 |
+
title: "Restart",
|
| 279 |
+
message: "Czy na pewno chcesz na nowo rozpocząć proces monitorowania podróży?",
|
| 280 |
+
choices:[
|
| 281 |
+
{label: 'Tak', value: true},
|
| 282 |
+
{label: 'Nie', value: false}
|
| 283 |
+
]
|
| 284 |
+
})
|
| 285 |
+
break
|
| 286 |
+
}
|
| 287 |
+
}
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
// Converts degrees to radians
|
| 291 |
+
Number.prototype.toRad = function() {
|
| 292 |
+
return this * Math.PI / 180
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
// Returns length between two points in km
|
| 296 |
+
function length(p1, p2){
|
| 297 |
+
var R = 6371 // Radius of the earth in km
|
| 298 |
+
var dLat = (p2.lat - p1.lat).toRad() // Javascript functions in radians
|
| 299 |
+
var dLon = (p2.lng - p1.lng).toRad()
|
| 300 |
+
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
|
| 301 |
+
Math.cos(p1.lat.toRad()) * Math.cos(p2.lat.toRad()) *
|
| 302 |
+
Math.sin(dLon/2) * Math.sin(dLon/2)
|
| 303 |
+
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a))
|
| 304 |
+
return R * c // Return distance in km
|
| 305 |
+
}
|
pool/shard011/JavaScript/0070410_eserveri.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
exports.run = function(bot, msg, args) {
|
| 2 |
+
var tag = msg.guild.owner.user;
|
| 3 |
+
msg.delete();
|
| 4 |
+
msg.channel.send({
|
| 5 |
+
embed: {
|
| 6 |
+
color: 3447003,
|
| 7 |
+
author: {
|
| 8 |
+
name: msg.guild.name,
|
| 9 |
+
icon_url: msg.guild.iconURL
|
| 10 |
+
},
|
| 11 |
+
title: 'Statistics',
|
| 12 |
+
url: '',
|
| 13 |
+
description: 'serverinfo',
|
| 14 |
+
fields: [{
|
| 15 |
+
name: 'Owner:',
|
| 16 |
+
value: `${tag.username}#${tag.discriminator} (${msg.guild.owner.id})`
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
name: 'Member Count',
|
| 20 |
+
value: `${msg.guild.memberCount} (${msg.guild.members.filter(m=>m.user.bot).size} Bots)`,
|
| 21 |
+
inline: true
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
name: 'AFK Timeout',
|
| 25 |
+
value: `${msg.guild.afkTimeout / 60} minutes`,
|
| 26 |
+
inline: true
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
name: 'Location',
|
| 30 |
+
value: msg.guild.region,
|
| 31 |
+
inline: true
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
name: 'Created',
|
| 35 |
+
value: msg.guild.createdAt.toLocaleString(),
|
| 36 |
+
inline: true
|
| 37 |
+
}
|
| 38 |
+
],
|
| 39 |
+
timestamp: new Date(),
|
| 40 |
+
footer: {
|
| 41 |
+
icon_url: bot.user.avatarURL,
|
| 42 |
+
text: '© Jesse / Maxine#8621'
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
});
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
exports.info = {
|
| 49 |
+
name: 'server',
|
| 50 |
+
usage: 'server',
|
| 51 |
+
description: 'shows the serverinfo in embed'
|
| 52 |
+
};
|
pool/shard011/JavaScript/0070413_js.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
exports.vargs = function(args, n) { return Array.prototype.slice.call(args, n || 0); }
|
| 2 |
+
exports.isArray = function(input) { return Object.prototype.toString.call(input) === '[object Array]'; }
|
| 3 |
+
|
| 4 |
+
exports.shallowCopy = function(input) {
|
| 5 |
+
if (exports.isArray(input)) {
|
| 6 |
+
return input.slice(0);
|
| 7 |
+
} else {
|
| 8 |
+
var out = {};
|
| 9 |
+
for (var key in input) {
|
| 10 |
+
if (input.hasOwnProperty(key)) {
|
| 11 |
+
out[key] = input[key];
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
return out;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
exports.merge = function(base, extra) {
|
| 20 |
+
base = base || {};
|
| 21 |
+
|
| 22 |
+
for (var key in extra) {
|
| 23 |
+
if (extra.hasOwnProperty(key) && !base.hasOwnProperty(key)) {
|
| 24 |
+
base[key] = extra[key];
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
return base;
|
| 29 |
+
}
|
pool/shard011/JavaScript/0070414_md023.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// @ts-check
|
| 2 |
+
|
| 3 |
+
"use strict";
|
| 4 |
+
|
| 5 |
+
const { addErrorContext, filterTokens } = require("../helpers");
|
| 6 |
+
|
| 7 |
+
const spaceBeforeHeadingRe = /^((?:\s+)|(?:[>\s]+\s\s))[^>\s]/;
|
| 8 |
+
|
| 9 |
+
module.exports = {
|
| 10 |
+
"names": [ "MD023", "heading-start-left", "header-start-left" ],
|
| 11 |
+
"description": "Headings must start at the beginning of the line",
|
| 12 |
+
"tags": [ "headings", "headers", "spaces" ],
|
| 13 |
+
"function": function MD023(params, onError) {
|
| 14 |
+
filterTokens(params, "heading_open", function forToken(token) {
|
| 15 |
+
const { lineNumber, line } = token;
|
| 16 |
+
const match = line.match(spaceBeforeHeadingRe);
|
| 17 |
+
if (match) {
|
| 18 |
+
const [ prefixAndFirstChar, prefix ] = match;
|
| 19 |
+
let deleteCount = prefix.length;
|
| 20 |
+
const prefixLengthNoSpace = prefix.trimEnd().length;
|
| 21 |
+
if (prefixLengthNoSpace) {
|
| 22 |
+
deleteCount -= prefixLengthNoSpace - 1;
|
| 23 |
+
}
|
| 24 |
+
addErrorContext(
|
| 25 |
+
onError,
|
| 26 |
+
lineNumber,
|
| 27 |
+
line,
|
| 28 |
+
null,
|
| 29 |
+
null,
|
| 30 |
+
[ 1, prefixAndFirstChar.length ],
|
| 31 |
+
{
|
| 32 |
+
"editColumn": prefixLengthNoSpace + 1,
|
| 33 |
+
"deleteCount": deleteCount
|
| 34 |
+
});
|
| 35 |
+
}
|
| 36 |
+
});
|
| 37 |
+
}
|
| 38 |
+
};
|
pool/shard011/JavaScript/0070415_tab.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* ========================================================================
|
| 2 |
+
* Bootstrap: tab.js v3.3.7
|
| 3 |
+
* http://getbootstrap.com/javascript/#tabs
|
| 4 |
+
* ========================================================================
|
| 5 |
+
* Copyright 2011-2016 Twitter, Inc.
|
| 6 |
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
| 7 |
+
* ======================================================================== */
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
+function ($) {
|
| 11 |
+
'use strict';
|
| 12 |
+
|
| 13 |
+
// TAB CLASS DEFINITION
|
| 14 |
+
// ====================
|
| 15 |
+
|
| 16 |
+
var Tab = function (element) {
|
| 17 |
+
// jscs:disable requireDollarBeforejQueryAssignment
|
| 18 |
+
this.element = $(element);
|
| 19 |
+
// jscs:enable requireDollarBeforejQueryAssignment
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
Tab.VERSION = '3.3.7';
|
| 23 |
+
|
| 24 |
+
Tab.TRANSITION_DURATION = 150;
|
| 25 |
+
|
| 26 |
+
Tab.prototype.show = function () {
|
| 27 |
+
var $this = this.element;
|
| 28 |
+
var $ul = $this.closest('ul:not(.dropdown-menu)');
|
| 29 |
+
var selector = $this.data('target');
|
| 30 |
+
|
| 31 |
+
if (!selector) {
|
| 32 |
+
selector = $this.attr('href');
|
| 33 |
+
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, ''); // strip for ie7
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
if ($this.parent('li').hasClass('active')) return;
|
| 37 |
+
|
| 38 |
+
var $previous = $ul.find('.active:last a');
|
| 39 |
+
var hideEvent = $.Event('hide.bs.tab', {
|
| 40 |
+
relatedTarget: $this[0]
|
| 41 |
+
});
|
| 42 |
+
var showEvent = $.Event('show.bs.tab', {
|
| 43 |
+
relatedTarget: $previous[0]
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
$previous.trigger(hideEvent);
|
| 47 |
+
$this.trigger(showEvent);
|
| 48 |
+
|
| 49 |
+
if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return;
|
| 50 |
+
|
| 51 |
+
var $target = $(selector);
|
| 52 |
+
|
| 53 |
+
this.activate($this.closest('li'), $ul);
|
| 54 |
+
this.activate($target, $target.parent(), function () {
|
| 55 |
+
$previous.trigger({
|
| 56 |
+
type: 'hidden.bs.tab',
|
| 57 |
+
relatedTarget: $this[0]
|
| 58 |
+
});
|
| 59 |
+
$this.trigger({
|
| 60 |
+
type: 'shown.bs.tab',
|
| 61 |
+
relatedTarget: $previous[0]
|
| 62 |
+
})
|
| 63 |
+
})
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
Tab.prototype.activate = function (element, container, callback) {
|
| 67 |
+
var $active = container.find('> .active');
|
| 68 |
+
var transition = callback
|
| 69 |
+
&& $.support.transition
|
| 70 |
+
&& ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length);
|
| 71 |
+
|
| 72 |
+
function next() {
|
| 73 |
+
$active
|
| 74 |
+
.removeClass('active')
|
| 75 |
+
.find('> .dropdown-menu > .active')
|
| 76 |
+
.removeClass('active')
|
| 77 |
+
.end()
|
| 78 |
+
.find('[data-toggle="tab"]')
|
| 79 |
+
.attr('aria-expanded', false);
|
| 80 |
+
|
| 81 |
+
element
|
| 82 |
+
.addClass('active')
|
| 83 |
+
.find('[data-toggle="tab"]')
|
| 84 |
+
.attr('aria-expanded', true);
|
| 85 |
+
|
| 86 |
+
if (transition) {
|
| 87 |
+
element[0].offsetWidth; // reflow for transition
|
| 88 |
+
element.addClass('in')
|
| 89 |
+
} else {
|
| 90 |
+
element.removeClass('fade')
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
if (element.parent('.dropdown-menu').length) {
|
| 94 |
+
element
|
| 95 |
+
.closest('li.dropdown')
|
| 96 |
+
.addClass('active')
|
| 97 |
+
.end()
|
| 98 |
+
.find('[data-toggle="tab"]')
|
| 99 |
+
.attr('aria-expanded', true)
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
callback && callback()
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
$active.length && transition ?
|
| 106 |
+
$active
|
| 107 |
+
.one('bsTransitionEnd', next)
|
| 108 |
+
.emulateTransitionEnd(Tab.TRANSITION_DURATION) :
|
| 109 |
+
next();
|
| 110 |
+
|
| 111 |
+
$active.removeClass('in')
|
| 112 |
+
};
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
// TAB PLUGIN DEFINITION
|
| 116 |
+
// =====================
|
| 117 |
+
|
| 118 |
+
function Plugin(option) {
|
| 119 |
+
return this.each(function () {
|
| 120 |
+
var $this = $(this);
|
| 121 |
+
var data = $this.data('bs.tab');
|
| 122 |
+
|
| 123 |
+
if (!data) $this.data('bs.tab', (data = new Tab(this)));
|
| 124 |
+
if (typeof option == 'string') data[option]()
|
| 125 |
+
})
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
var old = $.fn.tab;
|
| 129 |
+
|
| 130 |
+
$.fn.tab = Plugin;
|
| 131 |
+
$.fn.tab.Constructor = Tab;
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
// TAB NO CONFLICT
|
| 135 |
+
// ===============
|
| 136 |
+
|
| 137 |
+
$.fn.tab.noConflict = function () {
|
| 138 |
+
$.fn.tab = old;
|
| 139 |
+
return this
|
| 140 |
+
};
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
// TAB DATA-API
|
| 144 |
+
// ============
|
| 145 |
+
|
| 146 |
+
var clickHandler = function (e) {
|
| 147 |
+
e.preventDefault();
|
| 148 |
+
Plugin.call($(this), 'show')
|
| 149 |
+
};
|
| 150 |
+
|
| 151 |
+
$(document)
|
| 152 |
+
.on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
|
| 153 |
+
.on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)
|
| 154 |
+
|
| 155 |
+
}(jQuery);
|
pool/shard011/JavaScript/0070416_sigV4Client.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License").
|
| 5 |
+
* You may not use this file except in compliance with the License.
|
| 6 |
+
* A copy of the License is located at
|
| 7 |
+
*
|
| 8 |
+
* http://aws.amazon.com/apache2.0
|
| 9 |
+
*
|
| 10 |
+
* or in the "license" file accompanying this file. This file is distributed
|
| 11 |
+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
| 12 |
+
* express or implied. See the License for the specific language governing
|
| 13 |
+
* permissions and limitations under the License.
|
| 14 |
+
*/
|
| 15 |
+
|
| 16 |
+
/*
|
| 17 |
+
* Note: The original sourcecode autogenerated by the Amazon APIGateway has been modified by
|
| 18 |
+
* Civic.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
var utils = require("./utils");
|
| 22 |
+
var CryptoJS = require("../CryptoJS/rollups/hmac-sha256");
|
| 23 |
+
var axios = require("../axios/dist/axios.standalone");
|
| 24 |
+
|
| 25 |
+
var sigV4ClientFactory = {};
|
| 26 |
+
sigV4ClientFactory.newClient = function (config) {
|
| 27 |
+
var AWS_SHA_256 = 'AWS4-HMAC-SHA256';
|
| 28 |
+
var AWS4_REQUEST = 'aws4_request';
|
| 29 |
+
var AWS4 = 'AWS4';
|
| 30 |
+
var X_AMZ_DATE = 'x-amz-date';
|
| 31 |
+
var X_AMZ_SECURITY_TOKEN = 'x-amz-security-token';
|
| 32 |
+
var HOST = 'host';
|
| 33 |
+
var AUTHORIZATION = 'Authorization';
|
| 34 |
+
|
| 35 |
+
function hash(value) {
|
| 36 |
+
return CryptoJS.SHA256(value);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
function hexEncode(value) {
|
| 40 |
+
return value.toString(CryptoJS.enc.Hex);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
function hmac(secret, value) {
|
| 44 |
+
return CryptoJS.HmacSHA256(value, secret, {asBytes: true});
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function buildCanonicalRequest(method, path, queryParams, headers, payload) {
|
| 48 |
+
return method + '\n' +
|
| 49 |
+
buildCanonicalUri(path) + '\n' +
|
| 50 |
+
buildCanonicalQueryString(queryParams) + '\n' +
|
| 51 |
+
buildCanonicalHeaders(headers) + '\n' +
|
| 52 |
+
buildCanonicalSignedHeaders(headers) + '\n' +
|
| 53 |
+
hexEncode(hash(payload));
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
function hashCanonicalRequest(request) {
|
| 57 |
+
return hexEncode(hash(request));
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
function buildCanonicalUri(uri) {
|
| 61 |
+
return encodeURI(uri);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
function buildCanonicalQueryString(queryParams) {
|
| 65 |
+
if (Object.keys(queryParams).length < 1) {
|
| 66 |
+
return '';
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
var sortedQueryParams = [];
|
| 70 |
+
for (var property in queryParams) {
|
| 71 |
+
if (queryParams.hasOwnProperty(property)) {
|
| 72 |
+
sortedQueryParams.push(property);
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
sortedQueryParams.sort();
|
| 76 |
+
|
| 77 |
+
var canonicalQueryString = '';
|
| 78 |
+
for (var i = 0; i < sortedQueryParams.length; i++) {
|
| 79 |
+
canonicalQueryString += sortedQueryParams[i] + '=' + encodeURIComponent(queryParams[sortedQueryParams[i]]) + '&';
|
| 80 |
+
}
|
| 81 |
+
return canonicalQueryString.substr(0, canonicalQueryString.length - 1);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
function buildCanonicalHeaders(headers) {
|
| 85 |
+
var canonicalHeaders = '';
|
| 86 |
+
var sortedKeys = [];
|
| 87 |
+
for (var property in headers) {
|
| 88 |
+
if (headers.hasOwnProperty(property)) {
|
| 89 |
+
sortedKeys.push(property);
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
sortedKeys.sort();
|
| 93 |
+
|
| 94 |
+
for (var i = 0; i < sortedKeys.length; i++) {
|
| 95 |
+
canonicalHeaders += sortedKeys[i].toLowerCase() + ':' + headers[sortedKeys[i]] + '\n';
|
| 96 |
+
}
|
| 97 |
+
return canonicalHeaders;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
function buildCanonicalSignedHeaders(headers) {
|
| 101 |
+
var sortedKeys = [];
|
| 102 |
+
for (var property in headers) {
|
| 103 |
+
if (headers.hasOwnProperty(property)) {
|
| 104 |
+
sortedKeys.push(property.toLowerCase());
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
sortedKeys.sort();
|
| 108 |
+
|
| 109 |
+
return sortedKeys.join(';');
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
function buildStringToSign(datetime, credentialScope, hashedCanonicalRequest) {
|
| 113 |
+
return AWS_SHA_256 + '\n' +
|
| 114 |
+
datetime + '\n' +
|
| 115 |
+
credentialScope + '\n' +
|
| 116 |
+
hashedCanonicalRequest;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
function buildCredentialScope(datetime, region, service) {
|
| 120 |
+
return datetime.substr(0, 8) + '/' + region + '/' + service + '/' + AWS4_REQUEST
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
function calculateSigningKey(secretKey, datetime, region, service) {
|
| 124 |
+
return hmac(hmac(hmac(hmac(AWS4 + secretKey, datetime.substr(0, 8)), region), service), AWS4_REQUEST);
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
function calculateSignature(key, stringToSign) {
|
| 128 |
+
return hexEncode(hmac(key, stringToSign));
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
function buildAuthorizationHeader(accessKey, credentialScope, headers, signature) {
|
| 132 |
+
return AWS_SHA_256 + ' Credential=' + accessKey + '/' + credentialScope + ', SignedHeaders=' + buildCanonicalSignedHeaders(headers) + ', Signature=' + signature;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
var awsSigV4Client = { };
|
| 136 |
+
if(config.accessKey === undefined || config.secretKey === undefined) {
|
| 137 |
+
return awsSigV4Client;
|
| 138 |
+
}
|
| 139 |
+
awsSigV4Client.accessKey = utils.assertDefined(config.accessKey, 'accessKey');
|
| 140 |
+
awsSigV4Client.secretKey = utils.assertDefined(config.secretKey, 'secretKey');
|
| 141 |
+
awsSigV4Client.sessionToken = config.sessionToken;
|
| 142 |
+
awsSigV4Client.serviceName = utils.assertDefined(config.serviceName, 'serviceName');
|
| 143 |
+
awsSigV4Client.region = utils.assertDefined(config.region, 'region');
|
| 144 |
+
awsSigV4Client.endpoint = utils.assertDefined(config.endpoint, 'endpoint');
|
| 145 |
+
awsSigV4Client.host = utils.assertDefined(config.host, 'host');
|
| 146 |
+
|
| 147 |
+
awsSigV4Client.makeRequest = function (request) {
|
| 148 |
+
var verb = utils.assertDefined(request.verb, 'verb');
|
| 149 |
+
var path = utils.assertDefined(request.path, 'path');
|
| 150 |
+
var queryParams = utils.copy(request.queryParams);
|
| 151 |
+
if (queryParams === undefined) {
|
| 152 |
+
queryParams = {};
|
| 153 |
+
}
|
| 154 |
+
var headers = utils.copy(request.headers);
|
| 155 |
+
if (headers === undefined) {
|
| 156 |
+
headers = {};
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
//If the user has not specified an override for Content type the use default
|
| 160 |
+
if(headers['Content-Type'] === undefined) {
|
| 161 |
+
headers['Content-Type'] = config.defaultContentType;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
//If the user has not specified an override for Accept type the use default
|
| 165 |
+
if(headers['Accept'] === undefined) {
|
| 166 |
+
headers['Accept'] = config.defaultAcceptType;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
var body = utils.copy(request.body);
|
| 170 |
+
if (body === undefined || verb === 'GET') { // override request body and set to empty when signing GET requests
|
| 171 |
+
body = '';
|
| 172 |
+
} else {
|
| 173 |
+
body = JSON.stringify(body);
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
//If there is no body remove the content-type header so it is not included in SigV4 calculation
|
| 177 |
+
if(body === '' || body === undefined || body === null) {
|
| 178 |
+
delete headers['Content-Type'];
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
var datetime = new Date().toISOString().replace(/\.\d{3}Z$/, 'Z').replace(/[:\-]|\.\d{3}/g, '');
|
| 182 |
+
headers[X_AMZ_DATE] = datetime;
|
| 183 |
+
headers[HOST] = awsSigV4Client.host;
|
| 184 |
+
var canonicalRequest = buildCanonicalRequest(verb, path, queryParams, headers, body);
|
| 185 |
+
|
| 186 |
+
var hashedCanonicalRequest = hashCanonicalRequest(canonicalRequest);
|
| 187 |
+
var credentialScope = buildCredentialScope(datetime, awsSigV4Client.region, awsSigV4Client.serviceName);
|
| 188 |
+
var stringToSign = buildStringToSign(datetime, credentialScope, hashedCanonicalRequest);
|
| 189 |
+
var signingKey = calculateSigningKey(awsSigV4Client.secretKey, datetime, awsSigV4Client.region, awsSigV4Client.serviceName);
|
| 190 |
+
var signature = calculateSignature(signingKey, stringToSign);
|
| 191 |
+
headers[AUTHORIZATION] = buildAuthorizationHeader(awsSigV4Client.accessKey, credentialScope, headers, signature);
|
| 192 |
+
if(awsSigV4Client.sessionToken !== undefined && awsSigV4Client.sessionToken !== '') {
|
| 193 |
+
headers[X_AMZ_SECURITY_TOKEN] = awsSigV4Client.sessionToken;
|
| 194 |
+
}
|
| 195 |
+
delete headers[HOST];
|
| 196 |
+
|
| 197 |
+
var url = config.endpoint + path;
|
| 198 |
+
var queryString = buildCanonicalQueryString(queryParams);
|
| 199 |
+
if (queryString != '') {
|
| 200 |
+
url += '?' + queryString;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
//Need to re-attach Content-Type if it is not specified at this point
|
| 204 |
+
if(headers['Content-Type'] === undefined) {
|
| 205 |
+
headers['Content-Type'] = config.defaultContentType;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
var signedRequest = {
|
| 209 |
+
method: verb,
|
| 210 |
+
url: url,
|
| 211 |
+
headers: headers,
|
| 212 |
+
data: body
|
| 213 |
+
};
|
| 214 |
+
return axios(signedRequest);
|
| 215 |
+
};
|
| 216 |
+
|
| 217 |
+
return awsSigV4Client;
|
| 218 |
+
};
|
| 219 |
+
|
| 220 |
+
module.exports = sigV4ClientFactory;
|
pool/shard011/JavaScript/0070417_app.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
*
|
| 3 |
+
* INSPINIA - Responsive Admin Theme
|
| 4 |
+
* version 2.7.1
|
| 5 |
+
*
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
$(document).ready(function () {
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
// Add body-small class if window less than 768px
|
| 12 |
+
if ($(this).width() < 769) {
|
| 13 |
+
$('body').addClass('body-small')
|
| 14 |
+
} else {
|
| 15 |
+
$('body').removeClass('body-small')
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
// MetsiMenu
|
| 19 |
+
$('#side-menu').metisMenu();
|
| 20 |
+
|
| 21 |
+
// Collapse ibox function
|
| 22 |
+
$('.collapse-link').on('click', function () {
|
| 23 |
+
var ibox = $(this).closest('div.ibox');
|
| 24 |
+
var button = $(this).find('i');
|
| 25 |
+
var content = ibox.children('.ibox-content');
|
| 26 |
+
content.slideToggle(200);
|
| 27 |
+
button.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down');
|
| 28 |
+
ibox.toggleClass('').toggleClass('border-bottom');
|
| 29 |
+
setTimeout(function () {
|
| 30 |
+
ibox.resize();
|
| 31 |
+
ibox.find('[id^=map-]').resize();
|
| 32 |
+
}, 50);
|
| 33 |
+
});
|
| 34 |
+
|
| 35 |
+
// Close ibox function
|
| 36 |
+
$('.close-link').on('click', function () {
|
| 37 |
+
var content = $(this).closest('div.ibox');
|
| 38 |
+
content.remove();
|
| 39 |
+
});
|
| 40 |
+
|
| 41 |
+
// Fullscreen ibox function
|
| 42 |
+
$('.fullscreen-link').on('click', function () {
|
| 43 |
+
var ibox = $(this).closest('div.ibox');
|
| 44 |
+
var button = $(this).find('i');
|
| 45 |
+
$('body').toggleClass('fullscreen-ibox-mode');
|
| 46 |
+
button.toggleClass('fa-expand').toggleClass('fa-compress');
|
| 47 |
+
ibox.toggleClass('fullscreen');
|
| 48 |
+
setTimeout(function () {
|
| 49 |
+
$(window).trigger('resize');
|
| 50 |
+
}, 100);
|
| 51 |
+
});
|
| 52 |
+
|
| 53 |
+
// Minimalize menu
|
| 54 |
+
$('.navbar-minimalize').on('click', function (event) {
|
| 55 |
+
event.preventDefault();
|
| 56 |
+
$("body").toggleClass("mini-navbar");
|
| 57 |
+
SmoothlyMenu();
|
| 58 |
+
|
| 59 |
+
});
|
| 60 |
+
|
| 61 |
+
// Full height of sidebar
|
| 62 |
+
function fix_height() {
|
| 63 |
+
var heightWithoutNavbar = $("body > #wrapper").height() - 61;
|
| 64 |
+
$(".sidebard-panel").css("min-height", heightWithoutNavbar + "px");
|
| 65 |
+
|
| 66 |
+
var navbarHeight = $('nav.navbar-default').height();
|
| 67 |
+
var wrapperHeight = $('#page-wrapper').height();
|
| 68 |
+
|
| 69 |
+
if (navbarHeight > wrapperHeight) {
|
| 70 |
+
$('#page-wrapper').css("min-height", navbarHeight + "px");
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
if (navbarHeight < wrapperHeight) {
|
| 74 |
+
$('#page-wrapper').css("min-height", $(window).height() + "px");
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
if ($('body').hasClass('fixed-nav')) {
|
| 78 |
+
if (navbarHeight > wrapperHeight) {
|
| 79 |
+
$('#page-wrapper').css("min-height", navbarHeight + "px");
|
| 80 |
+
} else {
|
| 81 |
+
$('#page-wrapper').css("min-height", $(window).height() - 60 + "px");
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
fix_height();
|
| 88 |
+
|
| 89 |
+
// Fixed Sidebar
|
| 90 |
+
$(window).bind("load", function () {
|
| 91 |
+
if ($("body").hasClass('fixed-sidebar')) {
|
| 92 |
+
$('.sidebar-collapse').slimScroll({
|
| 93 |
+
height: '100%',
|
| 94 |
+
railOpacity: 0.9
|
| 95 |
+
});
|
| 96 |
+
}
|
| 97 |
+
});
|
| 98 |
+
|
| 99 |
+
$(window).bind("load resize scroll", function () {
|
| 100 |
+
if (!$("body").hasClass('body-small')) {
|
| 101 |
+
fix_height();
|
| 102 |
+
}
|
| 103 |
+
});
|
| 104 |
+
|
| 105 |
+
// Add slimscroll to element
|
| 106 |
+
$('.full-height-scroll').slimscroll({
|
| 107 |
+
height: '100%'
|
| 108 |
+
})
|
| 109 |
+
});
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
// Minimalize menu when screen is less than 768px
|
| 113 |
+
$(window).bind("resize", function () {
|
| 114 |
+
if ($(this).width() < 769) {
|
| 115 |
+
$('body').addClass('body-small')
|
| 116 |
+
} else {
|
| 117 |
+
$('body').removeClass('body-small')
|
| 118 |
+
}
|
| 119 |
+
});
|
| 120 |
+
|
| 121 |
+
function SmoothlyMenu() {
|
| 122 |
+
if (!$('body').hasClass('mini-navbar') || $('body').hasClass('body-small')) {
|
| 123 |
+
// Hide menu in order to smoothly turn on when maximize menu
|
| 124 |
+
$('#side-menu').hide();
|
| 125 |
+
// For smoothly turn on menu
|
| 126 |
+
setTimeout(
|
| 127 |
+
function () {
|
| 128 |
+
$('#side-menu').fadeIn(400);
|
| 129 |
+
}, 200);
|
| 130 |
+
} else if ($('body').hasClass('fixed-sidebar')) {
|
| 131 |
+
$('#side-menu').hide();
|
| 132 |
+
setTimeout(
|
| 133 |
+
function () {
|
| 134 |
+
$('#side-menu').fadeIn(400);
|
| 135 |
+
}, 100);
|
| 136 |
+
} else {
|
| 137 |
+
// Remove all inline style from jquery fadeIn function to reset menu state
|
| 138 |
+
$('#side-menu').removeAttr('style');
|
| 139 |
+
}
|
| 140 |
+
}
|
pool/shard011/JavaScript/0070418_Cordova.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @private
|
| 3 |
+
*/
|
| 4 |
+
Ext.define('Ext.device.notification.Cordova', {
|
| 5 |
+
alternateClassName: 'Ext.device.notification.PhoneGap',
|
| 6 |
+
extend: 'Ext.device.notification.Abstract',
|
| 7 |
+
requires: ['Ext.device.Communicator'],
|
| 8 |
+
|
| 9 |
+
show: function(config) {
|
| 10 |
+
config = this.callParent(arguments);
|
| 11 |
+
this.confirm(config);
|
| 12 |
+
},
|
| 13 |
+
|
| 14 |
+
confirm: function(config) {
|
| 15 |
+
config = this.callParent(arguments);
|
| 16 |
+
|
| 17 |
+
var buttons = config.buttons,
|
| 18 |
+
ln = config.buttons.length;
|
| 19 |
+
|
| 20 |
+
if (ln && typeof buttons[0] != "string") {
|
| 21 |
+
var newButtons = [],
|
| 22 |
+
i;
|
| 23 |
+
|
| 24 |
+
for (i = 0; i < ln; i++) {
|
| 25 |
+
newButtons.push(buttons[i].text);
|
| 26 |
+
}
|
| 27 |
+
buttons = newButtons;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
var callback = function(index) {
|
| 31 |
+
if (config.callback) {
|
| 32 |
+
config.callback.apply(config.scope, (buttons) ? [buttons[index - 1].toLowerCase()] : []);
|
| 33 |
+
}
|
| 34 |
+
};
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
navigator.notification.confirm(
|
| 38 |
+
config.message,
|
| 39 |
+
callback,
|
| 40 |
+
config.title,
|
| 41 |
+
buttons
|
| 42 |
+
);
|
| 43 |
+
},
|
| 44 |
+
|
| 45 |
+
alert: function(config) {
|
| 46 |
+
navigator.notification.alert(
|
| 47 |
+
config.message,
|
| 48 |
+
config.callback,
|
| 49 |
+
config.title,
|
| 50 |
+
config.buttonName
|
| 51 |
+
);
|
| 52 |
+
},
|
| 53 |
+
|
| 54 |
+
prompt: function(config) {
|
| 55 |
+
config = this.callParent(arguments);
|
| 56 |
+
var buttons = config.buttons,
|
| 57 |
+
ln = config.buttons.length;
|
| 58 |
+
|
| 59 |
+
if (ln && typeof buttons[0] != "string") {
|
| 60 |
+
var newButtons = [],
|
| 61 |
+
i;
|
| 62 |
+
|
| 63 |
+
for (i = 0; i < ln; i++) {
|
| 64 |
+
newButtons.push(buttons[i].text);
|
| 65 |
+
}
|
| 66 |
+
buttons = newButtons;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
var callback = function(result) {
|
| 70 |
+
if (config.callback) {
|
| 71 |
+
config.callback.call(config.scope, (buttons) ? buttons[result.buttonIndex - 1].toLowerCase() : null, result.input1);
|
| 72 |
+
}
|
| 73 |
+
};
|
| 74 |
+
|
| 75 |
+
navigator.notification.prompt(
|
| 76 |
+
config.message,
|
| 77 |
+
callback,
|
| 78 |
+
config.title,
|
| 79 |
+
buttons
|
| 80 |
+
);
|
| 81 |
+
},
|
| 82 |
+
|
| 83 |
+
vibrate: function(time) {
|
| 84 |
+
navigator.notification.vibrate(time);
|
| 85 |
+
},
|
| 86 |
+
|
| 87 |
+
beep: function(times) {
|
| 88 |
+
navigator.notification.vibrate(times);
|
| 89 |
+
}
|
| 90 |
+
});
|