hexsha string | size int64 | ext string | lang string | max_stars_repo_path string | max_stars_repo_name string | max_stars_repo_head_hexsha string | max_stars_repo_licenses list | max_stars_count int64 | max_stars_repo_stars_event_min_datetime string | max_stars_repo_stars_event_max_datetime string | max_issues_repo_path string | max_issues_repo_name string | max_issues_repo_head_hexsha string | max_issues_repo_licenses list | max_issues_count int64 | max_issues_repo_issues_event_min_datetime string | max_issues_repo_issues_event_max_datetime string | max_forks_repo_path string | max_forks_repo_name string | max_forks_repo_head_hexsha string | max_forks_repo_licenses list | max_forks_count int64 | max_forks_repo_forks_event_min_datetime string | max_forks_repo_forks_event_max_datetime string | content string | avg_line_length float64 | max_line_length int64 | alphanum_fraction float64 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3780014b05df87c317d8a04c07b656184e34097f | 1,209 | js | JavaScript | resources/[VRP]/vrp_ilegal/nui/ui.js | Madriguera-rp/FiveM-Bulgarian-CustomRP-vRP | 6e1d1d09d866786535fdd12ed1dd53d7a9fdad4e | [
"MIT"
] | 10 | 2020-05-03T19:50:49.000Z | 2022-03-21T22:21:12.000Z | resources/[VRP]/vrp_ilegal/nui/ui.js | Madriguera-rp/FiveM-Bulgarian-CustomRP-vRP | 6e1d1d09d866786535fdd12ed1dd53d7a9fdad4e | [
"MIT"
] | null | null | null | resources/[VRP]/vrp_ilegal/nui/ui.js | Madriguera-rp/FiveM-Bulgarian-CustomRP-vRP | 6e1d1d09d866786535fdd12ed1dd53d7a9fdad4e | [
"MIT"
] | 10 | 2020-04-28T22:07:04.000Z | 2022-03-31T22:17:21.000Z |
$(document).ready(function(){
window.addEventListener( 'message', function( event ) {
var item = event.data;
if ( item.showPlayerMenu == true ) {
$('body').css('background-color','transparent');
$('.container-fluid').css('display','block');
} else if ( item.showPlayerMenu == false ) { // Hide the menu
$('.container-fluid').css('display','none');
$('body').css('background-color','transparent important!');
$("body").css("background-image","none");
}
} );
$("#desempregado").click(function(){
$.post('http://vrp_ilegal/desempregado', JSON.stringify({}));2
});
$("#ladraocarro").click(function(){
$.post('http://vrp_ilegal/ladraocarro', JSON.stringify({}));2
});
$("#traficatortuga").click(function(){
$.post('http://vrp_ilegal/traficatortuga', JSON.stringify({}));2
});
$("#traficadrogas").click(function(){
$.post('http://vrp_ilegal/traficadrogas', JSON.stringify({}));2
});
$("#hacker").click(function(){
$.post('http://vrp_ilegal/hacker', JSON.stringify({}));2
});
$("#closebtn").click(function(){
$.post('http://vrp_ilegal/closeButton', JSON.stringify({}));2
});
})
| 23.705882 | 72 | 0.580645 |
37801cb226eaac5e3ae9baa78ad6daa70a6a54d5 | 1,033 | js | JavaScript | src/api/controllers/events/get.events.js | ungdev/api.gala.utt.fr | d88381a36442f92903287ef3fe7cbd985bea38d8 | [
"MIT"
] | null | null | null | src/api/controllers/events/get.events.js | ungdev/api.gala.utt.fr | d88381a36442f92903287ef3fe7cbd985bea38d8 | [
"MIT"
] | 2 | 2018-03-15T12:32:05.000Z | 2021-04-26T08:09:04.000Z | src/api/controllers/events/get.events.js | ungdev/Gala-api | d88381a36442f92903287ef3fe7cbd985bea38d8 | [
"MIT"
] | 1 | 2022-02-22T17:31:57.000Z | 2022-02-22T17:31:57.000Z | const errorHandler = require('../../utils/errorHandler')
const isAuth = require('../../middlewares/isAuth')
const isAdmin = require('../../middlewares/isAdmin')
module.exports = app => {
app.get('/events', async (req, res) => {
const { Event, Place } = app.locals.models
try {
const events = await Event.findAll({
include: [Place],
where: {
visible: true
},
order: [
['start', 'ASC']
]
})
return res
.status(200)
.json(events)
} catch (err) {
errorHandler(err, res)
}
})
app.get('/events/all', [isAuth('events-get-all'), isAdmin('events-get-all')])
app.get('/events/all', async (req, res) => {
const { Event, Place } = app.locals.models
try {
const events = await Event.findAll({
include: [Place],
order: [
['start', 'ASC']
]
})
return res
.status(200)
.json(events)
} catch (err) {
errorHandler(err, res)
}
})
}
| 22.456522 | 79 | 0.509197 |
3780f9b541ba45391d2b925268c97f58704f432d | 551 | js | JavaScript | src/redux/selectors/tagSelectors.js | anibali/showoff | 522ebf6d1b4d9fbac7b6066015b5938399294f53 | [
"Apache-2.0"
] | 1 | 2016-08-14T17:41:35.000Z | 2016-08-14T17:41:35.000Z | src/redux/selectors/tagSelectors.js | anibali/showoff | 522ebf6d1b4d9fbac7b6066015b5938399294f53 | [
"Apache-2.0"
] | 5 | 2016-06-30T13:49:07.000Z | 2017-09-28T06:09:11.000Z | src/redux/selectors/tagSelectors.js | anibali/showoff | 522ebf6d1b4d9fbac7b6066015b5938399294f53 | [
"Apache-2.0"
] | null | null | null | import _ from 'lodash';
import { createSelector } from '../../helpers/select';
export const getTags = createSelector(
[],
state => state.entities.tags
);
export const getNotebookTags = createSelector(
[
state => getTags(state),
(state, notebookId) => notebookId,
],
(tags, notebookId) =>
_.filter(_.values(tags), tag => tag.relationships.notebook.data.id === notebookId)
);
export const getTagNames = createSelector(
[getTags],
(tags) => _.uniqBy(_.values(tags).map(tag => _.pick(tag.attributes, ['name'])), 'name'),
);
| 22.958333 | 90 | 0.656987 |
3781161a7d9ab308e4c33b95012312dfd03dbe65 | 434 | js | JavaScript | client/components/Header/Header.js | SiamV/React-OpenSourceProject-FullStack | a1b8b98f4a711488ac6776f1d594e06328ad3009 | [
"MIT"
] | 1 | 2020-12-11T01:12:55.000Z | 2020-12-11T01:12:55.000Z | client/components/Header/Header.js | SiamV/React-OpenSourceProject-FullStack | a1b8b98f4a711488ac6776f1d594e06328ad3009 | [
"MIT"
] | null | null | null | client/components/Header/Header.js | SiamV/React-OpenSourceProject-FullStack | a1b8b98f4a711488ac6776f1d594e06328ad3009 | [
"MIT"
] | null | null | null | import React from 'react';
import {NavLink} from 'react-router-dom';
import HeaderImg from '../../images/logoMexicoline.png'
import classes from './Header.module.css'
const Header = () => {
return (
<div className={classes.headerWrapper}>
<NavLink to={'/'}>
<img src={HeaderImg} alt='Logo' className={classes.headerImg}/>
</NavLink>
</div>
)
}
export default Header;
| 24.111111 | 79 | 0.596774 |
37816bb0701f75175f3eabb1a77e127786cc9b1b | 562 | js | JavaScript | src/mqtt.js | galileopy/mqtt-line | 77ac0963ea132518567438ddcf576e7ad9437a8c | [
"MIT"
] | 1 | 2017-11-26T13:02:37.000Z | 2017-11-26T13:02:37.000Z | src/mqtt.js | galileopy/mqtt-lines | 77ac0963ea132518567438ddcf576e7ad9437a8c | [
"MIT"
] | null | null | null | src/mqtt.js | galileopy/mqtt-lines | 77ac0963ea132518567438ddcf576e7ad9437a8c | [
"MIT"
] | null | null | null | const mqtt = require('async-mqtt')
const { forEach } = require('ramda')
module.exports = (host, options, log) => {
const client = mqtt.connect(host, options)
client.on('connect', function () {
log("connected")
})
client.on('error', function (error) {
log("Error")
log(error)
})
client.on('offline', function () {
log('Server offline')
})
client.on('reconnect', function () {
log("Reconecting")
})
client.on('close', function () {
log('Connection terminated by server')
process.exit(0)
})
return client
}
| 18.733333 | 44 | 0.604982 |
3781a87097a288a189f3d90b39a4ca6b74d36b33 | 1,223 | js | JavaScript | controllers/histogram.js | npmmirror/duing | 31d9934821938bfbe2b7153866913484788d823d | [
"MIT"
] | null | null | null | controllers/histogram.js | npmmirror/duing | 31d9934821938bfbe2b7153866913484788d823d | [
"MIT"
] | null | null | null | controllers/histogram.js | npmmirror/duing | 31d9934821938bfbe2b7153866913484788d823d | [
"MIT"
] | null | null | null | const getWidth = require('../helper/').getWidth;
const histogram = async function (ctx) {
let {
list,
} = ctx.query;
const {
color = '01D48F',
title = 'histogram for something',
type = 'histogram',
} = ctx.query;
let itemWidth = 50;
let maxValue = 0;
list = JSON.parse(list);
for (const item of list) {
let { k, v } = item;
k = k.toString();
v = v.toString();
item.textLength = getWidth(k, 11);
item.valueLength = getWidth(v, 11);
itemWidth = Math.max(itemWidth, getWidth(k, 11), getWidth(v, 11));
maxValue = Math.max(maxValue, v);
}
const viewHeight = 100;
const viewWidth = (itemWidth) * list.length;
let dPath = 'M';
let initDPath = 'M';
if (type === 'line') {
for (let i = 0; i < list.length; i++) {
dPath += `${itemWidth * (i + 1.5)},${viewHeight + 60 - (list[i].v / maxValue) * viewHeight}L`;
initDPath += `${itemWidth * (i + 1.5)},95L`;
}
}
dPath = dPath.slice(0, -1);
initDPath = initDPath.slice(0, -1);
await ctx.render('histogram', {
type,
list,
dPath,
initDPath,
itemWidth,
maxValue,
color,
title,
viewWidth,
viewHeight,
});
};
module.exports = histogram;
| 19.412698 | 100 | 0.564186 |
37829136654c3434bc3133801be944a100ebd779 | 184 | js | JavaScript | src/plugins/vuex-router-sync.js | hernandev/utopian-vue-demo | cf2f9e7bc69f1dd5581a6c6468999a272d580652 | [
"MIT"
] | 1 | 2018-06-01T00:20:55.000Z | 2018-06-01T00:20:55.000Z | src/plugins/vuex-router-sync.js | hernandev/utopian-vue-demo | cf2f9e7bc69f1dd5581a6c6468999a272d580652 | [
"MIT"
] | 1 | 2018-06-01T21:43:54.000Z | 2018-06-01T21:43:54.000Z | src/plugins/vuex-router-sync.js | hernandev/utopian-vue-demo | cf2f9e7bc69f1dd5581a6c6468999a272d580652 | [
"MIT"
] | 3 | 2018-05-31T21:40:39.000Z | 2018-06-01T21:42:09.000Z | // imports.
import { sync } from 'vuex-router-sync'
// sync vue route and vuex.
export default ({ app, store, router, Vue }) => {
// sync should not return.
sync(store, router)
}
| 20.444444 | 49 | 0.641304 |
3783500b55c058f66d13bbef3ae7d1c660772e51 | 304 | js | JavaScript | components/style/fullScreenVideo.js | kotayya/UI | 57a5baf2a4e945beb1a3ee532b3735c88710fda1 | [
"MIT"
] | null | null | null | components/style/fullScreenVideo.js | kotayya/UI | 57a5baf2a4e945beb1a3ee532b3735c88710fda1 | [
"MIT"
] | null | null | null | components/style/fullScreenVideo.js | kotayya/UI | 57a5baf2a4e945beb1a3ee532b3735c88710fda1 | [
"MIT"
] | null | null | null | import { StyleSheet } from "react-native";
import config from "../DoctorConnect/config/app.js";
export default StyleSheet.create({
container: {
width: window.width,
height: config.screenHeight
},
video: {
width: config.screenWidth,
height: config.screenHeight,
top: 35
}
});
| 20.266667 | 52 | 0.674342 |
37847c3427c87cbda87ef982725969a252a421e4 | 581 | js | JavaScript | example/src/Box.js | vincentbollaert/styled-theming | e2b04171fd229146804659da65833afe3dee287a | [
"MIT"
] | 1,010 | 2017-08-11T07:06:56.000Z | 2022-03-24T21:14:32.000Z | example/src/Box.js | vincentbollaert/styled-theming | e2b04171fd229146804659da65833afe3dee287a | [
"MIT"
] | 2 | 2019-07-10T00:30:06.000Z | 2021-10-01T20:08:30.000Z | example/src/Box.js | vincentbollaert/styled-theming | e2b04171fd229146804659da65833afe3dee287a | [
"MIT"
] | 43 | 2017-10-12T15:59:01.000Z | 2021-10-01T19:40:21.000Z | // @flow
import styled from 'styled-components';
import theme from '../..';
import colors from './colors';
const fontSize = theme('size', {
normal: '1em',
large: '1.2em',
});
const boxBackgroundColor = theme('mode', {
light: colors.white,
dark: colors.grayDarker,
});
const boxColor = theme('mode', {
light: colors.grayDarker,
dark: colors.grayLighter,
});
const Box = styled.div`
position: relative;
width: 100%;
height: 100%;
padding: 4em;
font-size: ${fontSize};
background-color: ${boxBackgroundColor};
color: ${boxColor};
`;
export default Box;
| 18.15625 | 42 | 0.659208 |
3784bef87715d9539327081f2be15cf97f09a870 | 1,151 | js | JavaScript | web/app/plugins/intelly-related-posts/assets/js/button-mce.js | faladinojames/ttb-wordpress | edecb09cba2ff154fd41057f3178d2bcf27387af | [
"MIT"
] | null | null | null | web/app/plugins/intelly-related-posts/assets/js/button-mce.js | faladinojames/ttb-wordpress | edecb09cba2ff154fd41057f3178d2bcf27387af | [
"MIT"
] | null | null | null | web/app/plugins/intelly-related-posts/assets/js/button-mce.js | faladinojames/ttb-wordpress | edecb09cba2ff154fd41057f3178d2bcf27387af | [
"MIT"
] | null | null | null | (function() {
tinymce.PluginManager.add('irp_mce_button', function(editor, url) {
editor.addButton('irp_mce_button', {
title: 'Inline Related Posts PRO'
, type: 'menubutton'
, icon: 'icon irp-own-icon'
, image : url + '/../images/repeat.png'
, menu: [
{
text: 'Inline Related Post'
, onclick: function() {
var code='[irp]';
editor.insertContent(code);
}
}
, {
text: 'Custom Related Post'
, onclick: function() {
editor.windowManager.open({
title: 'Choose a post'
, width: 350
, height: 250
, file: ajaxurl+'?action=do_action&irp_action=ui_button_editor'
, inline: 1
, resizable: false
});
}
}
]
});
});
})(); | 35.96875 | 91 | 0.356212 |
3784e094c902b7fb501ec253da5f48086d763eca | 2,600 | js | JavaScript | tests/unit/state-test.js | maxfierke/ember-concurrency-retryable | 4b18ccc073872d8a7592c4f1eb6c17461938334b | [
"MIT"
] | 22 | 2018-03-19T04:10:53.000Z | 2019-09-25T19:53:28.000Z | tests/unit/state-test.js | maxfierke/ember-concurrency-retryable | 4b18ccc073872d8a7592c4f1eb6c17461938334b | [
"MIT"
] | 295 | 2018-04-24T04:31:02.000Z | 2022-03-24T09:06:24.000Z | tests/unit/state-test.js | maxfierke/ember-concurrency-retryable | 4b18ccc073872d8a7592c4f1eb6c17461938334b | [
"MIT"
] | 2 | 2018-11-15T19:39:24.000Z | 2019-02-28T17:14:58.000Z | import EmberObject from '@ember/object';
import Evented, { on } from '@ember/object/evented';
import { run, later } from '@ember/runloop';
import { task } from 'ember-concurrency';
import { module, test } from 'qunit';
import { Promise } from 'rsvp';
import sinon from 'sinon';
import DelayPolicy from 'ember-concurrency-retryable/policies/delay';
import RetryableTaskInstance from 'ember-concurrency-retryable/-private/retryable-task-instance';
module('Unit: state', function () {
test('resets retryable state after task is retried successfully', function (assert) {
assert.expect(8);
const DELAY_MS = 100;
const EXPECTED_ERROR = new Error('solar flare interrupted stuff');
const done = assert.async(1);
let taskAttemptCounter = 0;
let lastRetryCount = 0;
let lastRetryError = null;
let lastRetryableInstance = null;
const delayPolicy = new DelayPolicy({
delay: [DELAY_MS, DELAY_MS, DELAY_MS, DELAY_MS],
});
const retriedStub = sinon.stub();
let Obj = EmberObject.extend(Evented, {
doStuff: task(function* () {
taskAttemptCounter++;
if (taskAttemptCounter <= 3) {
throw EXPECTED_ERROR;
} else {
yield Promise.resolve('stuff happened');
}
})
.evented()
.retryable(delayPolicy),
onRetried: on('doStuff:retried', function (_ti, retryableTaskInstance) {
lastRetryCount = retryableTaskInstance.retryCount;
lastRetryError = retryableTaskInstance.lastError;
lastRetryableInstance = retryableTaskInstance;
retriedStub(_ti, retryableTaskInstance);
}),
});
let obj, taskInstance;
assert.equal(taskAttemptCounter, 0);
run(() => {
obj = Obj.create();
});
run(() => {
taskInstance = obj.doStuff.perform();
assert.equal(taskAttemptCounter, 1);
});
later(() => {
assert.equal(taskAttemptCounter, 4);
assert.ok(
retriedStub.calledOnceWith(
taskInstance,
sinon.match.instanceOf(RetryableTaskInstance)
),
'expected retried callback to have been called once with correct arguments'
);
assert.equal(
lastRetryCount,
3,
'retried hook is called before retryCount is reset'
);
assert.equal(lastRetryableInstance.retryCount, 0);
assert.equal(
lastRetryError,
EXPECTED_ERROR,
'retried hook is called before lastError is reset'
);
assert.equal(lastRetryableInstance.lastError, null);
done();
}, DELAY_MS * 4 + 10);
});
});
| 28.888889 | 97 | 0.640769 |
3785563062d406dc7b8968b1b8df39b8db5fff3b | 1,550 | js | JavaScript | models/Pokemon.js | sarahdurks/-fullstack-pokemon-game | ea2d40bcd01d0241ea28f68606806805996515a8 | [
"MIT"
] | 3 | 2021-05-22T04:43:58.000Z | 2022-02-18T02:25:46.000Z | models/Pokemon.js | MeganClo/fullstack-pokemon-game | 12f0237e431ebb12c02869f36b9a51e51a711d14 | [
"MIT"
] | 16 | 2021-05-03T10:14:30.000Z | 2021-05-17T05:50:24.000Z | models/Pokemon.js | MeganClo/fullstack-pokemon-game | 12f0237e431ebb12c02869f36b9a51e51a711d14 | [
"MIT"
] | 3 | 2021-05-03T04:34:55.000Z | 2021-12-27T07:14:28.000Z | const { Model, DataTypes, Deferrable } = require('sequelize');
const sequelize = require('../config/connection');
// create Pokemon model
class Pokemon extends Model { }
Pokemon.init(
{
pokedex: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
primaryKey: true,
},
pokemon_name: {
type: DataTypes.STRING,
allowNull: false
},
pokemon_pic: {
type: DataTypes.STRING,
allowNull: false,
validate: {
isUrl: true
}
},
hp: {
type: DataTypes.INTEGER,
allowNull: false
},
attack: {
type: DataTypes.INTEGER,
allowNull: false
},
defense: {
type: DataTypes.INTEGER,
allowNull: false
},
speed: {
type: DataTypes.INTEGER,
allowNull: false
},
team_id: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: 'team',
key: 'id',
deferrable: Deferrable.INITIALLY_IMMEDIATE
}
},
selected: {
type: DataTypes.BOOLEAN,
defaultValue: false,
allowNull: false
}
},
{
sequelize,
timestamps: false,
freezeTableName: true,
underscored: true,
modelName: 'pokemon'
}
);
module.exports = Pokemon; | 23.484848 | 62 | 0.46129 |
37855b431bbf4cf72bd541dd59f50e6db668092b | 1,935 | js | JavaScript | database/schemas/categorySchema.js | Mern-A-team/MERN-assessment-backend | bfe4bceb9123f0b3e39fd8c4c39112c61cb0549e | [
"MIT"
] | 1 | 2020-02-10T00:15:41.000Z | 2020-02-10T00:15:41.000Z | database/schemas/categorySchema.js | Roakz/MERN-assessment-backend | d21a406b3e300ad5be5da8c630f6c0dff5f311fc | [
"MIT"
] | 3 | 2020-01-22T03:17:34.000Z | 2021-09-02T05:29:03.000Z | database/schemas/categorySchema.js | Roakz/MERN-assessment-backend | d21a406b3e300ad5be5da8c630f6c0dff5f311fc | [
"MIT"
] | 2 | 2020-01-13T05:39:36.000Z | 2020-01-13T06:44:48.000Z | // Requiring the mongoose library and assigning it to a constant.
const mongoose = require('mongoose')
// Declare the validation function identifiers. We can't define the
// functions themselves until we have a valid model.
let nameUnique, parentExists
// Declaring the validator functions and custom error messages for mongoose. This syntax allows
// for expansion to include more custom validators for each field. Each within the array will be
// complete for the specified field.
const nameValidators = [
{
validator: name => nameUnique(name),
msg: 'Category already exists! cannot save.'
}
]
const parentValidators = [
{
validator: parent => parentExists(parent),
msg: 'The parent you have selected does not exist.'
}
]
// Declaring and defining the category schema.
const categorySchema = new mongoose.Schema({
// required name field with custom validator object declared.
name: {
type: String,
required: true,
validate: nameValidators
},
// required parent field with custom validator object declared.
parent: {
type: String,
required: true,
validate: parentValidators
}
})
// Declare and define the cateogry model passing it the category schema that we have defined.
const categoryModel = mongoose.model('categories', categorySchema)
// Now that the model is defined the functions themselves are defined enabling them
// to use the model itself. essentially we have taken advantage of javascripts hoisting mechanisms.
// Name must be unique
nameUnique = name => {
let result = categoryModel.find({ name: `${name}` }).then(result => {
return result.length >= 1 ? false : true
})
return result
}
// Parent must be an already exisitng category.
parentExists = parent => {
let result = categoryModel.find({ name: `${parent}` }).then(result => {
return (parent === "All") || (result.length >= 1) ? true : false
})
return result
}
// Export the model
module.exports = categoryModel
| 29.769231 | 99 | 0.731266 |
378621f5ea53c8c0451f5e9fc44d6c3f29181da9 | 10,928 | js | JavaScript | bitrix/modules/voximplant/install/components/bitrix/voximplant.lines/templates/.default/script.js | BuildingBridge/biznet | 0e9e864be99e01bd35f4321a04736866937897b0 | [
"Unlicense"
] | 1 | 2020-10-05T04:28:40.000Z | 2020-10-05T04:28:40.000Z | bitrix/modules/voximplant/install/components/bitrix/voximplant.lines/templates/.default/script.js | shuchitamathur28/bitrix24 | fafc179382f028989a4ee4a5f97422e49b1526b4 | [
"Unlicense"
] | null | null | null | bitrix/modules/voximplant/install/components/bitrix/voximplant.lines/templates/.default/script.js | shuchitamathur28/bitrix24 | fafc179382f028989a4ee4a5f97422e49b1526b4 | [
"Unlicense"
] | null | null | null | ;(function()
{
BX.namespace("BX.Voximplant");
var gridId = "voximplant_lines_list";
BX.Voximplant.Lines = {
init: function()
{
BX.bind(BX("add-group"), "click", this.addGroup.bind(this));
},
reloadGrid: function()
{
if(!BX.Main || !BX.Main.gridManager)
{
return;
}
var gridData = BX.Main.gridManager.getById(gridId);
if(!gridData)
{
return;
}
gridData.instance.reload()
},
showConfig: function(configId)
{
BX.SidePanel.Instance.open("/telephony/edit.php?ID=" + configId, {
cacheable: false,
allowChangeHistory: false,
events: {
onClose: this.reloadGrid.bind(this)
}
});
},
addGroup: function()
{
var editor = new BX.Voximplant.NumberGroup({
onClose: this.reloadGrid.bind(this)
});
editor.show();
},
deleteGroup: function(id)
{
BX.Voximplant.showLoader();
BX.ajax.runComponentAction("bitrix:voximplant.lines", "deleteGroup", {
data: {id: id}
}).then(function(response)
{
BX.Voximplant.hideLoader();
this.reloadGrid();
}.bind(this)).catch(function(response)
{
BX.Voximplant.hideLoader();
var error = response.errors[0];
BX.Voximplant.alert(BX.message("VOX_LINES_ERROR"), error.message);
});
},
editGroup: function(id)
{
var editor = new BX.Voximplant.NumberGroup({
groupId: id
});
editor.show();
},
addNumberToGroup: function(number, groupId)
{
BX.Voximplant.showLoader();
BX.ajax.runComponentAction("bitrix:voximplant.lines", "addToGroup", {
data: {
number: number,
groupId: groupId
}
}).then(function(response)
{
BX.Voximplant.hideLoader();
this.reloadGrid();
}.bind(this)).catch(function(response)
{
BX.Voximplant.hideLoader();
var error = response.errors[0];
BX.Voximplant.alert(BX.message("VOX_LINES_ERROR"), error.message);
});
},
removeNumberFromGroup: function(number)
{
BX.Voximplant.showLoader();
BX.ajax.runComponentAction("bitrix:voximplant.lines", "removeFromGroup", {
data: {
number: number,
}
}).then(function(response)
{
BX.Voximplant.hideLoader();
this.reloadGrid();
}.bind(this)).catch(function(response)
{
BX.Voximplant.hideLoader();
var error = response.errors[0];
BX.Voximplant.alert(BX.message("VOX_LINES_ERROR"), error.message);
});
},
getCallerIdFields: function(number)
{
return new Promise(function(resolve, reject)
{
BX.ajax.runAction("voximplant.callerid.get", {data: {phoneNumber: number}}).then(function(response)
{
resolve(response.data);
}).catch(function(response)
{
reject(response.errors[0]);
});
})
},
verifyCallerId: function(number)
{
var configPromise = this.getCallerIdFields(number);
var callerIdForm = new BX.Voximplant.CallerIdSlider({
dataPromise: configPromise,
onClose: this.reloadGrid.bind(this)
});
callerIdForm.show();
},
deleteCallerId: function(number)
{
var self = this;
BX.Voximplant.confirm(
BX.message("VOX_LINES_CONFIRM_ACTION"),
BX.message("VOX_LINES_CALLERID_DELETE_CONFIRM").replace("#NUMBER#", number)
).then(function(result)
{
if(!result)
{
return;
}
BX.Voximplant.showLoader();
BX.ajax.runAction("voximplant.callerId.delete", {
data: {
phoneNumber: number
}
}).then(function()
{
BX.Voximplant.hideLoader();
self.reloadGrid();
}).catch(function(response)
{
BX.Voximplant.hideLoader();
var error = response.errors[0];
BX.Voximplant.alert(BX.message("VOX_LINES_ERROR"), error.message);
})
});
},
deleteSip: function(id)
{
var self = this;
BX.Voximplant.confirm(BX.message("VOX_LINES_CONFIRM_ACTION"), BX.message("VOX_LINES_SIP_DELETE_CONFIRM")).then(function (result)
{
if(!result)
{
return;
}
BX.Voximplant.showLoader();
BX.ajax.runAction("voximplant.sip.delete", {
data: {
id: id
}
}).then(function()
{
BX.Voximplant.hideLoader();
self.reloadGrid();
}).catch(function(response)
{
BX.Voximplant.hideLoader();
var error = response.errors[0];
BX.Voximplant.alert(BX.message("VOX_LINES_ERROR"), error.message);
})
});
},
deleteNumber: function(number)
{
BX.Voximplant.NumberRent.create().deleteNumber(number).then(function()
{
this.reloadGrid();
}.bind(this));
},
cancelNumberDeletion: function(number)
{
BX.Voximplant.NumberRent.create().cancelNumberDeletion(number).then(function()
{
this.reloadGrid();
}.bind(this));
}
};
BX.Voximplant.NumberGroup = function(config)
{
this.slider = null;
this.id = config.id || null;
this.groupName = "";
this.selectedNumbers = {};
this.unassignedNumbers = [];
this.elements = {
groupName: null,
error: null,
numbersContainer: null,
createButton: null,
cancelButton: null,
};
this.callBacks = {
onClose: BX.type.isFunction(config.onClose) ? config.onClose : BX.DoNothing
}
};
BX.Voximplant.NumberGroup.prototype = {
fetchUnassignedNumbers: function()
{
return new Promise(function(resolve,reject)
{
BX.ajax.runComponentAction("bitrix:voximplant.lines", "getUnassignedNumbers").then(function(response)
{
this.unassignedNumbers = response.data;
resolve();
}.bind(this)).catch(function(e)
{
console.error(e.errors[0]);
reject();
})
}.bind(this))
},
show: function()
{
BX.SidePanel.Instance.open("voximplant:number-group-add", {
width: 400,
events: {
onClose: this.onSliderClose.bind(this),
onDestroy: this.onSliderDestroy.bind(this)
},
contentCallback: function (slider)
{
var promise = new BX.Promise();
this.slider = slider;
top.BX.loadExt("voximplant.common").then(function()
{
this.fetchUnassignedNumbers().then(function()
{
var layout = this.render();
promise.resolve(layout);
}.bind(this));
}.bind(this), 0);
return promise;
}.bind(this)
});
},
render: function()
{
return BX.createFragment([
BX.create("div", {
props: {className: "voximplant-slider-pagetitle-wrap"},
children: [
BX.create("div", {
props: {className: "voximplant-slider-pagetitle"},
children: [
BX.create("span", {
text: BX.message("VOX_LINES_ADD_NUMBER_GROUP")
})
]
})
]
}),
BX.create("div", {
props: {className: "voximplant-container voximplant-options-popup"},
children: [
BX.create("h2", {
props: {className: "voximplant-control-row"},
children: [
BX.create("div", {
props: {className: "voximplant-control-title-editable"},
children: [
this.elements.groupName = BX.create("input", {
props: {className: "voximplant-control-input"},
attrs: {
type: "text",
value: this.groupName,
placeholder: BX.message("VOX_LINES_NUMBER_GROUP_NAME")
},
events: {
change: function(e)
{
this.groupName = e.currentTarget.value;
}.bind(this)
}
}),
BX.create('span', {
props: {className: "voximplant-control-btn-edit"},
})
]
})
]
}),
this.elements.error = BX.create("div", {
props: {className: "voximplant-control-row"}
}),
BX.create("div", {
props: {className: "voximplant-control-row"},
children: [
BX.create("h5", {
props: {className: "voximplant-control-title-grey-sm"},
text: BX.message("VOX_LINES_SELECT_UNASSIGNED_NUMBERS")
}),
this.elements.numbersContainer = BX.create("div", {
props: {className: "voximplant-number-group-numbers voximplant-group-create"},
children: this.renderUnassignedNumbers()
})
]
}),
BX.create("div", {
props: {className: "voximplant-control-row"},
children: [
this.elements.createButton = BX.create("button", {
props: {className: "ui-btn ui-btn-primary"},
text: BX.message("VOX_LINES_BUTTON_CREATE"),
events: {
click: this.onCreateButtonClick.bind(this)
}
}),
this.elements.cancelButton = BX.create("button", {
props: {className: "ui-btn ui-btn-primary"},
text: BX.message("VOX_LINES_BUTTON_CANCEL"),
events: {
click: this.onCancelButtonClick.bind(this)
}
})
]
})
]
}),
]);
},
renderUnassignedNumbers: function()
{
return this.unassignedNumbers.map(function(numberFields)
{
return BX.create("span", {
props: {className: "tel-set-list-item"},
children: [
BX.create("input", {
props: {
id: "phone" + numberFields["ID"],
className: "tel-set-list-item-checkbox",
type: "checkbox",
value: numberFields["ID"]
},
events: {
change: this.onNumberChanged.bind(this)
}
}),
BX.create("label", {
props: {
className: "tel-set-list-item-num"
},
attrs: {
"for": "phone" + numberFields["ID"]
},
text: numberFields["NAME"]
})
]
})
}, this);
},
showError: function(message)
{
BX.adjust(this.elements.error, {
children: [
BX.create("div", {
props: {className: "ui-alert ui-alert-danger ui-alert-icon-danger"},
children: [
BX.create("span", {
props: {className: "ui-alert-message"},
text: message
})
]
})
]
});
},
hideError: function()
{
BX.cleanNode(this.elements.error);
},
onSliderClose: function (e)
{
this.slider.destroy();
this.callBacks.onClose();
},
onSliderDestroy: function (e)
{
this.slider = null;
},
onNumberChanged: function(e)
{
var number = e.currentTarget.value;
var checked = e.currentTarget.checked;
if(checked)
{
this.selectedNumbers[number] = true;
}
else
{
delete this.selectedNumbers[number];
}
},
onCreateButtonClick: function(e)
{
this.hideError();
BX.addClass(this.elements.createButton, "ui-btn-wait");
BX.ajax.runComponentAction("bitrix:voximplant.lines", "createGroup", {
data: {
name: this.groupName,
numbers: Object.keys(this.selectedNumbers)
}
}).then(function(response)
{
BX.removeClass(this.elements.createButton, "ui-btn-wait");
this.slider.close();
}.bind(this)).catch(function(response)
{
BX.removeClass(this.elements.createButton, "ui-btn-wait");
var error = response.errors[0];
this.showError(error.message);
}.bind(this));
},
onCancelButtonClick: function(e)
{
this.slider.close();
},
}
})(); | 22.766667 | 131 | 0.595809 |
378655500efd0ed5b677a6482dfa99a4fe842759 | 4,158 | js | JavaScript | django_harmonization/ui/static/ui/js/show_extract_mappings.js | chrisroederucdenver/Kao-Harmonization-Release | 1a90db58cd378244a8aba138e27f049376045729 | [
"Apache-2.0"
] | null | null | null | django_harmonization/ui/static/ui/js/show_extract_mappings.js | chrisroederucdenver/Kao-Harmonization-Release | 1a90db58cd378244a8aba138e27f049376045729 | [
"Apache-2.0"
] | null | null | null | django_harmonization/ui/static/ui/js/show_extract_mappings.js | chrisroederucdenver/Kao-Harmonization-Release | 1a90db58cd378244a8aba138e27f049376045729 | [
"Apache-2.0"
] | null | null | null | /****
module: show_extract_mappings
prefix: semm
events: call to load_show_extract_mappings when the extract_study_id changes
****/
var createShowExtractMappingsModule = function(extract_mapping_choice_cb) {
const _prefix = "semm";
let _json_list;
const _mapping_cb = extract_mapping_choice_cb;
var get_extract_study_id_update = function(extract_study_id) {
if (extract_study_id != null) {
var url = "/ui/get_extract_mapping_list/" + extract_study_id + "/";
console.log("show_extract_mappings.get_extract_study_id_update() " + url);
load_url(url, _build_columns_for_extract_study);
} else {
console.log("no bueno" + study_id)
}
};
function _radio_cb() {
x = get_checked_radio_button("semm_mapping_row_choice_");
console.log(_json_list[x]);
console.log(_mapping_cb);
console.log(JSON.stringify(_mapping_cb));
_mapping_cb(_json_list[x]);
}
function _get_concept_details(vocabulary_id, concept_code, i) {
url = "/ui/get_concept_by_vocab_and_concept_code/" + vocabulary_id + "/" + concept_code + "/";
console.log("_get_concept_details() " + url);
function _add_concept_details(json_list) {
//console.log("_get_concept_details()._add_concept_details() " + json_list.length);
//console.log("XX:" + JSON.stringify(json_list[0]));
// i is in the scope...a true closure
concept_name_span = document.getElementById("semm_concept_name_" + i);
concept_name_span.innerHTML = json_list[0].concept_name;
}
load_url(url, _add_concept_details)
}
function _build_columns_for_extract_study(json_list) {
console.log("building...");
_json_list = json_list;
// console.log(JSON.stringify(json_list))
name_base= _prefix + "_mapping_row_choice_" ;
var the_div = document.getElementById("semm_show_extract_mappings_div");
var html_string = "";
html_string += "<table class=\"scroll\">";
html_string += "<thead><tr>";
html_string += "<th>Vocabulary/Concept</th>";
html_string += "<th>Concept Name</th>";
html_string += "<th>Table</th>";
html_string += "<th>Column</th>";
html_string += "<th>Function</th>";
html_string += "<th>Name</th>";
html_string += "<th>Short Name</th>";
html_string += "</tr></thead>";
html_string += "<tbody>";
choice_class_name= _prefix + "_mapping_row_choice" ;
name_base= _prefix + "_mapping_row_choice_" ;
for (var i=0; i<json_list.length; i++) {
id = name_base + i;
html_string += "<tr><td>"
//+ "<input value=\"" + i + "\""
//+ " class=\"" + choice_class_name + "\""
//+ " type=\"radio\""
//+ " name=\"" + name_base + "\""
//+ " id=\"" + id + "\">"
+ json_list[i].from_vocabulary_id + "/" + json_list[i].from_concept_code
//+ "</input>"
+ "</td>"
+ "<td>" + " <span id=\"semm_concept_name_" + i + "\"></span></td>"
+ "<td>" + json_list[i].from_table + "</td>"
+ "<td>" + json_list[i].from_column + "</td>"
+ "<td>" + json_list[i].function_name + "</td>"
+ "<td>" + json_list[i].long_name + "</td>"
+ "<td>" + json_list[i].short_name + "</td>"
}
html_string += "</tbody></table></select>";
the_div.innerHTML = html_string;
var select_div = document.getElementById("semm_show_extract_mappings_div");
select_div.addEventListener('change', _radio_cb, false);
for (var i=0; i<json_list.length; i++) {
_get_concept_details(json_list[i].from_vocabulary_id, json_list[i].from_concept_code, i);
}
};
console.log("show_extract_mappings.ctor()")
return {
get_extract_study_id_update
};
}
| 40.368932 | 102 | 0.560847 |
3788c1738c5243ddea4119d2c378f35817fc1bfa | 578 | js | JavaScript | node_modules/@redis/graph/dist/commands/QUERY.js | ArtemZ154/Project-for-MSF | 7b0f51f27f9b5397b38442cff3f5977a0bc2e307 | [
"Apache-2.0"
] | null | null | null | node_modules/@redis/graph/dist/commands/QUERY.js | ArtemZ154/Project-for-MSF | 7b0f51f27f9b5397b38442cff3f5977a0bc2e307 | [
"Apache-2.0"
] | null | null | null | node_modules/@redis/graph/dist/commands/QUERY.js | ArtemZ154/Project-for-MSF | 7b0f51f27f9b5397b38442cff3f5977a0bc2e307 | [
"Apache-2.0"
] | null | null | null | "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
const _1 = require(".");
exports.FIRST_KEY_INDEX = 1;
function transformArguments(graph, query, timeout) {
return (0, _1.pushQueryArguments)(['GRAPH.QUERY'], graph, query, timeout);
}
exports.transformArguments = transformArguments;
;
function transformReply(reply) {
return {
headers: reply[0],
data: reply[1],
metadata: reply[2]
};
}
exports.transformReply = transformReply;
| 30.421053 | 87 | 0.709343 |
3788c2e704c334b0e3e9df66e61b02ea23864cd9 | 635 | js | JavaScript | docs/nakama/examples/javascript/simple-chat/simple-chat/src/components/App.js | LucasGaspar/nakama-docs | f1f256d88c11292b3c1daa1ef9c0e580179dcd34 | [
"Apache-2.0"
] | 49 | 2016-12-29T16:30:47.000Z | 2021-11-08T10:16:01.000Z | docs/nakama/examples/javascript/simple-chat/simple-chat/src/components/App.js | LucasGaspar/nakama-docs | f1f256d88c11292b3c1daa1ef9c0e580179dcd34 | [
"Apache-2.0"
] | 162 | 2017-02-06T12:34:00.000Z | 2022-03-08T12:56:33.000Z | docs/nakama/examples/javascript/simple-chat/simple-chat/src/components/App.js | LucasGaspar/nakama-docs | f1f256d88c11292b3c1daa1ef9c0e580179dcd34 | [
"Apache-2.0"
] | 77 | 2017-03-15T06:57:32.000Z | 2022-03-01T13:36:49.000Z | import React from 'react';
import {
Container,
Grid,
Menu,
Segment
} from 'semantic-ui-react';
import Chat from './Chat';
export default () => {
return (
<Segment vertical>
<Menu size='huge' fixed='top' inverted borderless>
<Container fluid>
<Menu.Item header>Simple chat with Nakama server</Menu.Item>
</Container>
</Menu>
<Grid padded divided>
<Grid.Row columns={2}>
<Grid.Column>
<Chat />
</Grid.Column>
<Grid.Column>
<Chat />
</Grid.Column>
</Grid.Row>
</Grid>
</Segment>
);
};
| 19.242424 | 70 | 0.522835 |
378a5496c23229214582b1148cd021fdd19df237 | 886 | js | JavaScript | routes/post.js | fagnerErnesto/restful-blog-api | 8afde89b38be4cac3728bd8dfffd348c23c9a3ee | [
"MIT"
] | null | null | null | routes/post.js | fagnerErnesto/restful-blog-api | 8afde89b38be4cac3728bd8dfffd348c23c9a3ee | [
"MIT"
] | null | null | null | routes/post.js | fagnerErnesto/restful-blog-api | 8afde89b38be4cac3728bd8dfffd348c23c9a3ee | [
"MIT"
] | null | null | null | module.exports = {
getPosts(req, res, store) {
res.status(200).send(store.posts)
},
addPosts(req, res, store) {
var id = store.posts.length;
var post = {
"name": req.body.name,
"url": req.body.url,
"text": req.body.text,
"comments": []
}
store.posts.push(post);
store.posts[id].comments = [];
res.status(201).send({"id":id});
},
updatePosts(req, res, store) {
var id = req.params.postId;
store.posts[id].name = req.body.name;
store.posts[id].url = req.body.url;
store.posts[id].text = req.body.text;
res.status(200).send(store.posts[id]);
},
deletePost(req, res, store) {
var id = req.params.postId
store.posts.splice(id, 1);
res.status(204).send({"message":"Post was deleted!"});
}
}
| 28.580645 | 62 | 0.519187 |
378a9866fba8e8829d69de8f966557080c78d28b | 305 | js | JavaScript | core/utilities/commissions.js | efeng0414/Nobul-Edward | a549749ccac2ba9d25170b0c25630627733df4c8 | [
"MIT"
] | null | null | null | core/utilities/commissions.js | efeng0414/Nobul-Edward | a549749ccac2ba9d25170b0c25630627733df4c8 | [
"MIT"
] | null | null | null | core/utilities/commissions.js | efeng0414/Nobul-Edward | a549749ccac2ba9d25170b0c25630627733df4c8 | [
"MIT"
] | null | null | null | import { STANDARD_COMMISSIONS } from "../data/commissions";
const getStandardCommission = (province, country) => {
if (province && STANDARD_COMMISSIONS.province[province])
return STANDARD_COMMISSIONS.province[province];
return STANDARD_COMMISSIONS[country];
};
export { getStandardCommission };
| 30.5 | 59 | 0.767213 |
378c7d85c2947581a7f752a85bb1079873292605 | 657 | js | JavaScript | webapp/public/js/main.js | zonuexe/private_isu | d7c25c42857863dc4b9ccbb82f0980199ebae245 | [
"MIT"
] | 2 | 2016-04-28T10:37:06.000Z | 2016-05-12T09:43:18.000Z | webapp/public/js/main.js | zonuexe/private_isu | d7c25c42857863dc4b9ccbb82f0980199ebae245 | [
"MIT"
] | 33 | 2019-05-01T21:34:47.000Z | 2019-05-17T23:37:05.000Z | webapp/public/js/main.js | zonuexe/private_isu | d7c25c42857863dc4b9ccbb82f0980199ebae245 | [
"MIT"
] | 1 | 2016-09-07T10:38:30.000Z | 2016-09-07T10:38:30.000Z | 'use strict';
$(function () {
$('#isu-post-more-btn').on('click', function () {
$('#isu-post-more').addClass('loading');
$.ajax({
type: 'GET',
url: '/posts',
data: {
max_created_at: $('.isu-post:last').attr('data-created-at')
},
dataType: 'html'
}).done(function (html) {
$(html).find('.isu-post').each(function() {
var id = $(this).attr('id');
if ($('#' + id).length === 0) {
$('.isu-posts').append($(this).clone());
}
});
$('time.timeago').timeago();
$('#isu-post-more').removeClass('loading');
});
});
$('time.timeago').timeago();
});
| 25.269231 | 67 | 0.465753 |
378cbc3dddd018d4e102d10b5c6949a38d0c8e2e | 6,205 | js | JavaScript | src/views/Uischool/UischoolDetail.js | snitin315/universal-inovators | a47afcb2656c043aa686687e6421702a31f9da2f | [
"MIT"
] | 5 | 2019-09-09T16:01:27.000Z | 2019-10-16T10:48:25.000Z | src/views/Uischool/UischoolDetail.js | snitin315/universal-inovators | a47afcb2656c043aa686687e6421702a31f9da2f | [
"MIT"
] | 50 | 2020-04-07T07:21:01.000Z | 2022-02-26T17:47:08.000Z | src/views/Uischool/UischoolDetail.js | snitin315/universal-inovators | a47afcb2656c043aa686687e6421702a31f9da2f | [
"MIT"
] | 2 | 2020-02-25T11:01:15.000Z | 2020-09-30T20:14:14.000Z | import React from "react";
// @material-ui/core components
import { makeStyles } from "@material-ui/core/styles";
// core components
import GridContainer from "components/Grid/GridContainer.js";
import GridItem from "components/Grid/GridItem.js";
import Card from "components/Card/Card.js";
import CardHeader from "components/Card/CardHeader.js";
import CardBody from "components/Card/CardBody.js";
import sideImage from "assets/img/school.jpg"
import styles from "assets/jss/material-kit-react/views/landingPageSections/productStyle.js";
import Fade from "react-reveal/Fade";
const useStyles = makeStyles(styles);
export default function UischoolDetails() {
const classes = useStyles();
const design ={
textAlign : 'justify'
}
const flex = {
display : 'flex',
alignItems : 'center',
}
const Service = function(props){
const classes = useStyles();
return (
<div className="box" style={{height : "200px", boxShadow : "0 0"}}>
<div className="icon"><a href={props.link}><i class={props.icon}></i></a></div>
<h4 className="title"><a href={props.link}>{props.title}</a></h4>
<p className={classes.description} >{props.description}</p>
</div>
)}
return (
<div className={classes.section}>
<GridContainer style = {flex}>
<GridItem xs={12} sm={12} md={6}>
<h3 className={classes.title}> What is UI-SCHOOL ?</h3>
<Fade right duration ={2000}>
<p className={classes.description} style={design} >
Every success story begins with a vision.The Universal Inovators (UI) is a private and autonomous body promoting research-based innovative activities all over the globe for the overall growth of human welfare and environment. The UI aims to do non-profit collaborative research in the field of engineering, applied sciences, management and other domains. We aim to be the leading independent academic and professional body working in collaboration with academicians, faculties, students, researchers, industry experts, Private bodies, government bodies and educational institutes. This leads us to be playing a creative and critical role in the society by disseminating teaching and research on a global scale, the cornerstones of which are good, long-term relationships, a focus on real life applications necessary for the welfare of the mankind, and an ability to combine quality and innovation. The mission of Universal Inovator is to cultivate and carry out research in high-tech, productive and cost efficient methodologies. We deal in conducting FDP’s, workshops, seminars, summer and winter schools, research projects, Book publishing, internship, and conferences. As a recognized body, Universal Innovators (UI) seeks to facilitate the availability of academic excellence and disseminate innovative knowledge worldwide.<br/>
<strong> Universal Inovator is an Indian research lab </strong>to promote research and development in India via conferences, FDPs, workshops, seminars, summer and winter schools, journals, research collaborations, patents, paper publication, book publications and collaborated national and international projects.
</p>
</Fade>
</GridItem>
<GridItem xs={12} sm={12} md={6}>
<Fade left duration={2000}>
<img style = {{width : "100%"}}src={sideImage}/>
</Fade>
</GridItem>
</GridContainer>
<br/>
<GridContainer>
<GridItem xs={12} sm={4} md={4}>
<Service
icon = "fas fa-clock"
title = "Tentative Dates"
description = "3rd week of June to 4th week of July & 4th week December to 1st week of January."
/>
</GridItem>
<GridItem xs={12} sm={4} md={4}>
<Service
icon = "fas fa-microphone"
title = "Target Audience"
description = "Under Grad/Post Grad/ PhD students of all the streams and all years."
/>
</GridItem>
<GridItem xs={12} sm={4} md={4}>
<Service
icon = "fas fa-users"
title = "Number Of Seats"
description = "180 seats, Our motto is serving quality not quantity"
/>
</GridItem>
</GridContainer>
<Fade bottom>
<Card className={classes.textCenter}>
<strong><CardHeader color="info">HIGHLIGHTS OF THE PROGRAM</CardHeader></strong>
<CardBody>
<h4 className={classes.cardTitle}><strong>Machine Learning and Deep Learning.</strong></h4>
<Fade left cascade delay={500}>
<p style={design}>
<li><strong>Python and R Programming languages</strong></li> <br/>
<li> <strong>Learn Machine Learning (Decision Tree, Random Forest, SVM, Linear Model, etc)</strong></li> <br/>
<li> <strong>Learn Deep Learning (CNN, RNN, LSTM, GAN, Auto-encoders, etc</strong></li> <br/>
<li> <strong>Optimization Techniques (Genetic Algorithm, PSO, Random Algorithms, DE)</strong></li> <br/>
<li> <strong>One major project and 5-6 minor project. Top three projects will be awarded prizes.</strong></li> <br/>
<li> <strong>Hands-on practice on IoT.</strong></li> <br/>
<li> <strong>Learn how to write research paper and patents</strong></li> <br/>
<li> <strong>Many more (Block chain, Flask, DJango, JavaScript, NodeJS, React, Exploring Machine Learning competitions such as <a href="https://www.kaggle.com" target="_blank" rel="noopener">www.kaggle.com)</a></strong></li> <br/>
<li> <strong>Resource persons are from IITs, NITs, IIITs, Thapar and Industry.</strong></li> <br/>
</p>
</Fade>
</CardBody>
</Card>
</Fade>
<h5 className={classes.title}>For Any Enquiry Related To School Write Us At : <a>universalinovators@gmail.com</a></h5>
</div>
);
}
| 47.730769 | 1,342 | 0.63191 |
378ce3110ccc44f8323a289b572ab72a8a982f37 | 3,851 | js | JavaScript | src/flags/Cy/index.js | leolima/react-flags-icons | b49e6c94a5577609016a1c33511d0cd0fea069a6 | [
"MIT"
] | null | null | null | src/flags/Cy/index.js | leolima/react-flags-icons | b49e6c94a5577609016a1c33511d0cd0fea069a6 | [
"MIT"
] | null | null | null | src/flags/Cy/index.js | leolima/react-flags-icons | b49e6c94a5577609016a1c33511d0cd0fea069a6 | [
"MIT"
] | null | null | null | /* eslint-disable */
/**
*
*
* This component is auto-generated, please don't touch it!
*
*
*/
import * as React from "react";
function Cy(props) {
return <svg width="1em" height="1em" viewBox="0 0 512 336" xmlns="http://www.w3.org/2000/svg" {...props}><g fill="none"><path d="M503.172 335.724H8.828A8.829 8.829 0 0 1 0 326.896V9.103A8.829 8.829 0 0 1 8.828.275h494.345a8.829 8.829 0 0 1 8.828 8.828v317.793a8.83 8.83 0 0 1-8.829 8.828z" fill="#F5F5F5" /><g fill="#73AF00"><path d="M244.426 272.546c4.884-3.648 9.128-4.841 15.694-6.034 6.569-1.193 13.506-3.228 17.144-4.21 3.67-1.016-12.328 4.841-16.403 5.999-4.007 1.227-16.435 4.245-16.435 4.245zm26.439-10.272c-1.314-8.252 1.952-16.941 9.429-20.41 1.752 5.996-3.604 16.166-9.429 20.41zm12.764-4.277c-4.008-6.904 2.728-15.763 7.746-20.074 2.324 4.143-1.752 16.503-7.746 20.074zm11.754-5.322c-4.244-5.895.809-16.201 6.198-20.276 2.088 5.828-.001 16.267-6.198 20.276zm11.788-7.409c-3.906-5.558-1.177-14.18 4.446-19.805 4.009 4.649.572 14.686-4.446 19.805zm9.466-7.41c-3.267-5.255.739-17.816 5.994-21.287 2.256 4.648.572 17.785-5.994 21.287zm7.509-1.986c-.943-7.511 12.192-15.83 17.548-15.594-.573 6.128-6.197 12.864-17.548 15.594zm-7.343 8.485c6.198-6.33 18.155-6.33 22.397-5.018-1.11 3.706-15.255 11.756-22.397 5.018z" /><path d="M308.316 250.722c8.69-2.325 14.314-4.211 19.501 1.177-3.671 4.649-17.749 3.269-19.501-1.177zm-12.393 5.626c8.319-4.447 18.389 2.121 19.905 5.927-9.262 3.872-20.074-4.952-19.905-5.927zm-11.385 6.364c7.578-2.897 16.268.943 19.703 5.187-4.042 1.954-14.618 4.075-19.703-5.187zm-10.372 3.266c8.69-.977 17.007 5.625 18.827 9.364-11.049 1.077-15.325-2.256-18.827-9.364zm-2.796 6.568c-4.817-3.648-9.06-4.841-15.628-6.034-6.569-1.193-13.506-3.228-17.209-4.21-3.604-1.016 12.394 4.841 16.468 5.999 4.041 1.227 16.369 4.245 16.369 4.245zm-26.439-10.272c1.379-8.252-1.887-16.941-9.431-20.41-1.684 5.996 3.672 16.166 9.431 20.41zm-12.698-4.277c4.076-6.904-2.728-15.763-7.746-20.074-2.324 4.143 1.752 16.503 7.746 20.074zm-11.821-5.322c4.311-5.895-.742-16.201-6.131-20.276-2.12 5.828.001 16.267 6.131 20.276zm-11.755-7.409c3.873-5.558 1.18-14.18-4.412-19.805-4.007 4.649-.572 14.686 4.412 19.805zm-9.429-7.41c3.334-5.255-.742-17.816-5.996-21.287-2.324 4.648-.573 17.785 5.996 21.287zm-7.579-1.986c1.011-7.511-12.125-15.83-17.481-15.594.573 6.128 6.098 12.864 17.481 15.594zm7.41 8.485c-6.198-6.33-18.153-6.33-22.397-5.018 1.177 3.706 15.255 11.756 22.397 5.018z" /><path d="M207.546 250.722c-8.69-2.325-14.314-4.211-19.501 1.177 3.604 4.649 17.749 3.269 19.501-1.177zm12.326 5.626c-8.284-4.447-18.322 2.121-19.838 5.927 9.263 3.872 20.007-4.952 19.838-5.927zm11.35 6.364c-7.544-2.897-16.2.943-19.635 5.187 4.076 1.954 14.652 4.075 19.635-5.187zm10.509 3.266c-8.757-.977-17.075 5.625-18.86 9.364 11.114 1.077 15.358-2.256 18.86-9.364z" /></g><path d="M147.966 141.194s-2.412 3.146 1.685 11.114c4.097 7.968 1.154 17.164 5.568 20.106s.185 8.778 5.242 12.664c5.056 3.887 18.345 12.831 27.517 13.877 9.172 1.045 18.082-8.222 23.374-1.382 5.292 6.84 4.136 11.661 9.128 12.193s4.992-1.675 4.625-4.985c-.367-3.31 3.309-12.505 11.769-12.505s17.422-1.007 31.7-6.389c14.278-5.382 21.266-7.956 23.105-16.416 1.839-8.46 7.068-18.462 17.143-13.828 10.076 4.633 9.398 2.46 12.495.236 3.097-2.223 13.483 4.209 15.83.809 2.348-3.401-18.377-20.224-17.209-29.1 1.166-8.875 3.961-16.247 12.495-16.975 8.533-.728 6.326-10.291 15.154-15.073 8.828-4.781 12.894-5.329 19.872-12.412 6.978-7.083 25.329-21.421 25.329-21.421s-35.701 17.097-42.841 18.66c-7.14 1.564-10.084 11.863-29.947 17.38-19.863 5.517-20.966 7.724-36.046 11.034-13.581 2.982-44.26 1.981-62.408-3.843a3.649 3.649 0 0 0-4.768 3.793c.747 8.821.537 24.681-10.176 27.142 0 0-14.603-10.906-23.798-6.125-9.195 4.781-15.735 21.834-22.58 19.192-6.845-2.643-7.741-13.587-12.258-7.746z" fill="#FFC850" /></g></svg>;
}
export default Cy; | 226.529412 | 3,668 | 0.686315 |
378cf9f07d3b221435713be9c5891d431f120b1c | 301 | js | JavaScript | src/main.js | kelvinoenning/vuejs-presentation | 3a3541fd32607b77e701506134b90856c96417d8 | [
"MIT"
] | null | null | null | src/main.js | kelvinoenning/vuejs-presentation | 3a3541fd32607b77e701506134b90856c96417d8 | [
"MIT"
] | null | null | null | src/main.js | kelvinoenning/vuejs-presentation | 3a3541fd32607b77e701506134b90856c96417d8 | [
"MIT"
] | null | null | null | import Vue from 'vue'
import App from './App'
import router from './router'
Vue.config.productionTip = false
import 'bootstrap/dist/css/bootstrap.min.css'
import '@/../static/prism.css'
import '@/../static/prism.js'
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App }
})
| 16.722222 | 45 | 0.657807 |
378d166bb2cd90a9b89d96343ec1330c46614c60 | 889 | js | JavaScript | src/data/mutations/user/update.js | jonirrings/react-stack | 1126813617cc25f6ab724fe04053fa86ed272b2d | [
"MIT"
] | 6 | 2016-12-03T08:13:40.000Z | 2017-10-25T07:33:40.000Z | src/data/mutations/user/update.js | jonirrings/react-stack | 1126813617cc25f6ab724fe04053fa86ed272b2d | [
"MIT"
] | 5 | 2017-04-08T10:03:14.000Z | 2017-08-09T10:11:12.000Z | src/data/mutations/user/update.js | jonirrings/react-stack | 1126813617cc25f6ab724fe04053fa86ed272b2d | [
"MIT"
] | 4 | 2017-02-23T14:46:34.000Z | 2018-07-06T05:43:57.000Z | /**
* react-stack react-stack
*
* Copyright © 2016. JonirRings.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {
GraphQLNonNull as NonNull,
GraphQLString as StringType,
GraphQLID as IDType,
} from 'graphql';
import {
mutationWithClientMutationId,
} from 'graphql-relay';
import { UserType } from '../../types';
import { updateUser } from '../../models';
const mutation = mutationWithClientMutationId({
name: 'UpdateUser',
inputFields: {
id: { type: new NonNull(IDType) },
name: { type: new NonNull(StringType) },
avatar: { type: new NonNull(StringType) },
},
outputFields: {
user: {
type: UserType,
resolve: user => user,
},
},
mutateAndGetPayload: ({ id, name, avatar }) => updateUser({ id, name, avatar }),
});
export default mutation;
| 23.394737 | 82 | 0.656918 |
378dc35bd5477d5898c6d7626a24e73dbca53c31 | 509 | js | JavaScript | scripts/dynamo.js | jav13r/pulumi-aws | 9b0a5520bca13a7cda4d37070c9ad93438037fa4 | [
"MIT"
] | null | null | null | scripts/dynamo.js | jav13r/pulumi-aws | 9b0a5520bca13a7cda4d37070c9ad93438037fa4 | [
"MIT"
] | null | null | null | scripts/dynamo.js | jav13r/pulumi-aws | 9b0a5520bca13a7cda4d37070c9ad93438037fa4 | [
"MIT"
] | null | null | null | "use strict"
const aws = require("@pulumi/aws");
module.exports = function (env, config) {
const aws_dynamo_testing = new aws.dynamodb.Table(`${env}-dynamo-aws-testing`, {
name: `${env}-dynamo-aws-testing`,
attributes: [
{ name: "Id", type: "S" },
],
hashKey: "Id",
readCapacity: 1,
writeCapacity: 1,
});
return {
aws_dynamo_testing_arn: aws_dynamo_testing.arn,
aws_dynamo_testing_name: aws_dynamo_testing.name,
}
} | 26.789474 | 84 | 0.585462 |
378e630dc3f3f2460d1cc8692cea1a445561e876 | 1,126 | js | JavaScript | src/lib/error.js | smihica/Fashion | 25e2f4f368225890e41a90de9b3079742f394324 | [
"MIT"
] | 3 | 2015-03-17T12:30:42.000Z | 2020-07-08T11:08:06.000Z | src/lib/error.js | smihica/Fashion | 25e2f4f368225890e41a90de9b3079742f394324 | [
"MIT"
] | null | null | null | src/lib/error.js | smihica/Fashion | 25e2f4f368225890e41a90de9b3079742f394324 | [
"MIT"
] | null | null | null | var FashionError = function(message) {
Error.apply(this, arguments);
if (typeof Error.captureStackTrace !== 'undefined')
Error.captureStackTrace(this, this.constructor);
this.message = message;
};
FashionError.prototype = new Error();
var createExceptionClass = function(exceptionClassName) {
var exceptionClass = function() { FashionError.apply(this, arguments); };
exceptionClass.prototype = new FashionError();
exceptionClass.prototype.name = exceptionClassName;
return exceptionClass;
}
var NotImplemented = createExceptionClass('NotImplemented');
var ValueError = createExceptionClass('ValueError');
var PropertyError = createExceptionClass('PropertyError');
var NotSupported = createExceptionClass('NotSupported');
var ArgumentError = createExceptionClass('ArgumentError');
var NotAttached = createExceptionClass('NotAttached');
var NotFound = createExceptionClass('NotFound');
var AlreadyExists = createExceptionClass('AlreadyExists');
var DeclarationError = createExceptionClass('DeclarationError');
var AssertionFailure = createExceptionClass('AssertionFailure');
| 45.04 | 75 | 0.771758 |
378eabd6b189ce5dacba7f98ddd48f64359be72c | 195 | js | JavaScript | tpaTRD/scripts/src/imports.js | QUATERS11/MCBE-tpa-addon | 1d49f604b1668603ed306905f17d766a1de8e763 | [
"MIT"
] | null | null | null | tpaTRD/scripts/src/imports.js | QUATERS11/MCBE-tpa-addon | 1d49f604b1668603ed306905f17d766a1de8e763 | [
"MIT"
] | 1 | 2022-03-24T09:34:18.000Z | 2022-03-24T09:34:18.000Z | tpaTRD/scripts/src/imports.js | QUATERS11/mcbe-tpa-addon | 1d49f604b1668603ed306905f17d766a1de8e763 | [
"MIT"
] | null | null | null | import './commands/tpadecline.js'
import './commands/tpaadmin.js'
import './commands/tpaconfig.js'
import './commands/tpaaccept.js'
import './commands/tpasend.js'
import './commands/tpahelp.js'
| 24.375 | 33 | 0.748718 |
378f23f06041c98811a185f3e12437bb8b6c484c | 3,238 | js | JavaScript | src/js/containers/todo.container.js | AlexRogalskiy/TicTacToe | c695e6f5fd4e810b328c4709e0debdab52e489d6 | [
"MIT"
] | 1 | 2020-07-26T20:48:12.000Z | 2020-07-26T20:48:12.000Z | src/js/containers/todo.container.js | AlexRogalskiy/TicTacToe | c695e6f5fd4e810b328c4709e0debdab52e489d6 | [
"MIT"
] | null | null | null | src/js/containers/todo.container.js | AlexRogalskiy/TicTacToe | c695e6f5fd4e810b328c4709e0debdab52e489d6 | [
"MIT"
] | null | null | null | 'use strict';
/**
* Module dependencies
*/
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { Dispatch } from 'redux';
//import { RouteComponentProps } from 'react-router';
import { reset, add, remove, toggle } from 'actions/todo.action';
import * as TodoActions from 'actions/todo.action';
import TodoListControl from 'components/controls/todo-list.control';
import { getVisibleTodoItemsSelector } from 'selectors/todo.selector';
import type { TodoItem, TodoProps, TodoFilterState, DispatchProps } from 'types/todo.type';//Dispatch
const mapStateToProps = (state: TodoFilterState): TodoProps => ({
//pathname: state.router.pathname,
//search: state.router.location.search,
//hash: state.router.location.hash,
list: getVisibleTodoItemsSelector(state.list)
});
const mapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({
//onReset: () => dispatch(reset()),
//onAdd: (data: TodoItem) => dispatch(add(data)),
//onRemove: (data: TodoItem) => dispatch(remove(data)),
//onToggle: (data: TodoItem) => dispatch(toggle(data))
actions: bindActionCreators(TodoActions, dispatch)
});
const TodoContainer = connect(
mapStateToProps,
mapDispatchToProps
)(TodoListControl);
export default TodoContainer;
/*
// @flow
import React from 'react';
import configureStore from 'redux-mock-store';
import { shallow } from 'enzyme';
import VisibleTodoList from './VisibleTodoList';
import { toggleTodo } from '../actions/todos';
import { setVisibilityFilter } from '../actions/visibilityFilter';
const setup = (setupProps = {}) => {
const store = configureStore()({
todos: [
{
text: 'Test AddTodo',
completed: false,
id: 0
},
{
text: 'Test AddTodo',
completed: true,
id: 1
}
]
});
const wrapper = shallow(<VisibleTodoList store={store} />);
return {
store,
wrapper
};
};
describe('VisibleTodoList', () => {
test('renders without crashing', () => {
const { wrapper } = setup();
expect(wrapper).toMatchSnapshot();
});
test('shows all todos when SHOW_ALL filter is active', () => {
const { store, wrapper } = setup();
store.dispatch(setVisibilityFilter('SHOW_ALL'));
expect(store.getActions()).toEqual([setVisibilityFilter('SHOW_ALL')]);
expect(wrapper).toMatchSnapshot();
});
test('shows active todos when SHOW_ACTIVE filter is active', () => {
const { store, wrapper } = setup();
store.dispatch(setVisibilityFilter('SHOW_ACTIVE'));
expect(store.getActions()).toEqual([setVisibilityFilter('SHOW_ACTIVE')]);
expect(wrapper).toMatchSnapshot();
});
test('shows completed todos when SHOW_COMPLETED filter is active', () => {
const { store, wrapper } = setup();
store.dispatch(setVisibilityFilter('SHOW_COMPLETED'));
expect(store.getActions()).toEqual([setVisibilityFilter('SHOW_COMPLETED')]);
expect(wrapper).toMatchSnapshot();
});
test('toggles todos when a todo is clicked', () => {
const { store, wrapper } = setup();
expect(wrapper.shallow()).toMatchSnapshot();
wrapper.shallow().find('Todo').first().simulate('click');
expect(store.getActions()).toEqual([toggleTodo(0)]);
});
});
*/ | 28.156522 | 101 | 0.672329 |
378f7ab01365ceef56facfe43609e041b8a2a1d1 | 416 | js | JavaScript | app/middleware/ratelimit.js | bitstashco/bitstashinfo-api | 1e064abaeb500eb8e838fd89245236cef297df5f | [
"MIT"
] | null | null | null | app/middleware/ratelimit.js | bitstashco/bitstashinfo-api | 1e064abaeb500eb8e838fd89245236cef297df5f | [
"MIT"
] | null | null | null | app/middleware/ratelimit.js | bitstashco/bitstashinfo-api | 1e064abaeb500eb8e838fd89245236cef297df5f | [
"MIT"
] | null | null | null | const ratelimit = require('koa-ratelimit')
module.exports = (options, app) => ratelimit({
...options,
id: ctx => `${app.name}-${ctx.get('cf-conecting-ip') || ctx.get('x-forwarded-for') || ctx.ip}`,
whitelist: options.whitelist && (
ctx => options.whitelist.includes(ctx.get('cf-connecting-ip') || ctx.get('x-forwarded-for') || ctx.ip)
|| options.whitelist.includes(ctx.get('application-id'))
)
})
| 37.818182 | 106 | 0.639423 |
3790a30cb9491cd50110007aca5db2ece296182f | 357 | js | JavaScript | src/components/forms/index.js | caioliveira277/taskman | 27d3e2362678a164c2b702b95025b284f7a3cc9a | [
"MIT"
] | 4 | 2020-04-22T12:18:24.000Z | 2021-09-17T00:10:14.000Z | src/components/forms/index.js | caioliveira277/taskman | 27d3e2362678a164c2b702b95025b284f7a3cc9a | [
"MIT"
] | null | null | null | src/components/forms/index.js | caioliveira277/taskman | 27d3e2362678a164c2b702b95025b284f7a3cc9a | [
"MIT"
] | null | null | null | import React from "react";
import { useSelector } from "react-redux";
import FormLogin from "./login";
import FormSignIn from "./signIn";
import NewGroup from "./newGroup";
export function Form() {
const changeForm = useSelector((state) => state.ChangeForm.form);
return changeForm === "Login" ? <FormLogin /> : <FormSignIn />;
}
export { NewGroup };
| 27.461538 | 67 | 0.697479 |
37916aadebd72e0829a8cf08a4f7764224bafd2d | 3,171 | js | JavaScript | lib/dispatcher.js | bvjebin/parallel_time_q_and_dispatcher | 0478cacee62de6e4e84704e4284fbe278ef53783 | [
"MIT"
] | null | null | null | lib/dispatcher.js | bvjebin/parallel_time_q_and_dispatcher | 0478cacee62de6e4e84704e4284fbe278ef53783 | [
"MIT"
] | null | null | null | lib/dispatcher.js | bvjebin/parallel_time_q_and_dispatcher | 0478cacee62de6e4e84704e4284fbe278ef53783 | [
"MIT"
] | null | null | null | "use strict";
const _ = require("lodash"),
Promise = require("bluebird"),
dispatcher = {
_queue: null,
init(id) {
this.name = id;
if(global.Proxy) {
this._queue = new Proxy([], {
set(array, prop, value) {
arr[prop] = val;
if(prop === "length" && val === 0 && typeof this.resolver === "function") {
this.resolver();
this.resolver = undefined;
}
return true;
}
});
} else {
this._queue = [];
Object.observe(this._queue, (changes) => {
changes.find((change) => {
if(change.type === "update" && change.name === "length" && this._queue.length === 0 && typeof this.resolver === "function") {
this.resolver();
this.resolver = undefined;
}
});
});
}
return this;
},
add(job) {
this._queue.push(job);
if(this._queue.length === 1) {
this._dispatcher(job.delay);
}
},
_dispatcher(delay) {
if(delay) {
setTimeout(() => {
this._call();
}, (delay));
} else {
this._call();
}
},
_callDispatcher() {
this._queue.splice(0, 1);
this._queue[0] && this._dispatcher(this._queue[0].delay);
},
_call() {
let item = this._queue[0];
if(item && typeof item.fn === "function") {
try {
let result = item.fn.apply(item.context, item.args);
if(Promise.resolve(result) == result) {
result.then(()=> {
this._callDispatcher();
}).catch((e) => {
console.log(`Error caught while executing function :: ${item.fn.name} in queue ${this.name}`);
this._callDispatcher();
});
} else {
this._callDispatcher();
}
} catch(e) {
console.log(`Error caught while executing function :: ${item.fn.name} in queue ${this.name}`);
this._callDispatcher();
}
}
},
destroy(preemptiveDestroy) {
this.add = () => {
console.log(`Can't add any more job. This queue will be destroyed.`);
};
return new Promise((resolve) => {
this.resolver = resolve;
if(preemptiveDestroy == true) {
this._queue.length = 0;
}
});
}
};
module.exports = function queue(id) {
let newDispatcher = _.cloneDeep(dispatcher);
return newDispatcher.init(id);
};
| 35.233333 | 149 | 0.384737 |
3791b805d27706588d2274265d58c46ab0b82f73 | 2,895 | js | JavaScript | client/GenericMeteorApp.js | MartinStolle/GenericMeteorApp | 9a676eb36d5323e8168870dd0472119d3ec4ee45 | [
"Unlicense"
] | null | null | null | client/GenericMeteorApp.js | MartinStolle/GenericMeteorApp | 9a676eb36d5323e8168870dd0472119d3ec4ee45 | [
"Unlicense"
] | null | null | null | client/GenericMeteorApp.js | MartinStolle/GenericMeteorApp | 9a676eb36d5323e8168870dd0472119d3ec4ee45 | [
"Unlicense"
] | null | null | null | Meteor.subscribe('Simulators');
Meteor.subscribe('Statuses');
Template.simulatortable.helpers({
simulators: function() {
return simulators.find({});
}
});
Template.simulatorform.helpers({
statuses: function() {
return statuses.find({});
},
'selectedStatus': function() {
var status = statuses.findOne(this._id);
if (status == undefined) {
return "";
}
var selectedSimulator = Session.get('selectedSimulator');
var simulator = simulators.findOne(selectedSimulator);
if (simulator == undefined) {
return "";
}
if (simulator.status == status.name) {
return "selected";
}
}
});
Template.simulatorrow.helpers({
'selectedClass': function() {
var simulatorId = this._id;
var selectedSimulator = Session.get('selectedSimulator');
// Do these IDs match?
if (simulatorId == selectedSimulator) {
// Return a CSS class
return "success";
}
}
});
Template.body.events({
/* "click #add": function (event) {
// Prevent the browser from applying default behaviour to the form
event.preventDefault();
var validationObject = Mesosphere.loginForm.validate(rawFormData);
var name = document.getElementById("name").value;
var hostname = document.getElementById("hostname").value;
var ip = document.getElementById("ip").value;
var status = document.getElementById("status").value;
Meteor.call('insertSimulator', name, hostname, ip, status);
document.getElementById("name").value = "";
document.getElementById("ip").value = "";
document.getElementById("hostname").value = "";
return false;
},*/
"click #edit": function() {
event.preventDefault();
var selectedSimulator = Session.get('selectedSimulator');
var name = document.getElementById("name").value;
var hostname = document.getElementById("hostname").value;
var ip = document.getElementById("ip").value;
var status = document.getElementById("status").value;
Meteor.call('modifySimulator', selectedSimulator, name, hostname, ip, status);
},
"click #delete": function() {
// Prevent the browser from applying default behaviour to the form
event.preventDefault();
Meteor.call('removeSimulator', this._id);
},
"click td": function() {
var simulatorId = this._id;
var simulator = simulators.findOne(simulatorId);
document.getElementById("name").value = simulator.name;
document.getElementById("hostname").value = simulator.hostname;
document.getElementById("ip").value = simulator.ip;
Session.set('selectedSimulator', simulatorId);
}
});
| 35.304878 | 86 | 0.60829 |
3793b688728c854345bc42d0ece9c67a3aba771d | 173 | js | JavaScript | index.android.js | ohmygodvt95/react-native-redux-todo-app | 5a9c66d17dea1827701f2ad3e78f6d04000c03b5 | [
"MIT"
] | null | null | null | index.android.js | ohmygodvt95/react-native-redux-todo-app | 5a9c66d17dea1827701f2ad3e78f6d04000c03b5 | [
"MIT"
] | null | null | null | index.android.js | ohmygodvt95/react-native-redux-todo-app | 5a9c66d17dea1827701f2ad3e78f6d04000c03b5 | [
"MIT"
] | null | null | null | import React, { Component } from 'react';
import {
AppRegistry
} from 'react-native';
import App from './app/App';
AppRegistry.registerComponent('untitled1', () => App);
| 21.625 | 54 | 0.693642 |
3794629adbfb153010446024df72c8910fd037da | 318 | js | JavaScript | src/utils/format.js | cindyrise/apollo-scaffold | 8e2341c32bd732f17b1f69d0f47c0eb01f6358db | [
"MIT"
] | null | null | null | src/utils/format.js | cindyrise/apollo-scaffold | 8e2341c32bd732f17b1f69d0f47c0eb01f6358db | [
"MIT"
] | null | null | null | src/utils/format.js | cindyrise/apollo-scaffold | 8e2341c32bd732f17b1f69d0f47c0eb01f6358db | [
"MIT"
] | null | null | null | export default class EventEmitter {
constructor(symbol) {
}
dropMenu(data) {
return data.map(item => {
item.value = itme.value;
item.label = item.text;
})
}
chartBar() {
}
chartBiax() {
}
chartLine() {
}
chartPar() {
}
}
| 13.25 | 36 | 0.455975 |
3795017b96e1427d2ac095716410ea7e6604dfc8 | 886 | js | JavaScript | src/pages/index.js | vitorpacheco/spotify-collector | e61253b7cf7cd4355388158e9e210075e259baf8 | [
"MIT"
] | null | null | null | src/pages/index.js | vitorpacheco/spotify-collector | e61253b7cf7cd4355388158e9e210075e259baf8 | [
"MIT"
] | 8 | 2020-07-20T04:21:37.000Z | 2022-03-26T11:20:11.000Z | src/pages/index.js | vitorpacheco/spotify-collector | e61253b7cf7cd4355388158e9e210075e259baf8 | [
"MIT"
] | null | null | null | import express from 'express'
import { getItem, getAll } from '../services/itemsService'
export default (env) => {
const app = express();
app.set('port', env.PORT || 3000)
app.get('/api', (req, res) => {
res.setHeader('Content-type', 'application/json')
res.setHeader('Cache-control', 's-max-age=1, stale-while-revalidate')
res.json({
'description': 'Spotify Collector Telegram Bot'
})
})
app.get('/api/items', async (req, res) => {
getAll({}).then((items) => {
res.json({
data: items
})
})
});
app.get('/api/items/:uuid', (req, res) => {
const { uuid } = req.params
getItem(uuid)
.then((item) => {
if (!item) {
res.status(404)
}
res.json(item)
}
)
})
app.listen(app.get('port'), () => {
console.log(`app listening at ${app.get('port')}`)
})
}
| 20.604651 | 73 | 0.528217 |
3795a1016a100d5da4486cbee93a168ef834a871 | 1,982 | js | JavaScript | server.js | familycaptain/firstmate | 47ac9a296bcb28044a702a478be4f5251b106fad | [
"MIT"
] | null | null | null | server.js | familycaptain/firstmate | 47ac9a296bcb28044a702a478be4f5251b106fad | [
"MIT"
] | null | null | null | server.js | familycaptain/firstmate | 47ac9a296bcb28044a702a478be4f5251b106fad | [
"MIT"
] | null | null | null | /*jslint node: true */
/*jslint nomen: true*/
'use strict';
// Load configuration .env file into environment variables
console.log();
require('dotenv').load();
var config = require('./config/config'),
initApi = require('./config/api'),
loadFamily = require('./config/family'),
loadItems = require('./config/items'),
loadPrograms = require('./config/programs'),
_ = require('lodash'),
InfiniteLoop = require('infinite-loop'),
events = require('events'),
eventEmitter = new events.EventEmitter();
console.log('Starting ' + config.appName + '...');
console.log();
console.log('Using web service URL: ' + config.webServiceUrl);
var FM,
family,
familyItems,
familyPrograms;
initApi(eventEmitter)
.then(function (scriptApi) {
FM = scriptApi;
return loadFamily();
})
.then(function (f) {
family = f;
return loadItems(family);
})
.then(function (items) {
familyItems = items;
return loadPrograms(family, familyItems, FM);
})
.then(function (programs) {
familyPrograms = programs;
console.log();
console.log('Waiting for something to happen....');
var il = new InfiniteLoop;
function tick() {
FM.debug();
FM.debug('Tick ' + (new Date()).toLocaleTimeString());
FM.emit('tick');
if (FM.timedEvent) {
var d = new Date();
if (d.getHours() == FM.timedEvent.hour &&
d.getMinutes() == FM.timedEvent.minute &&
d.getSeconds() == FM.timedEvent.second) {
var callback = FM.timedEvent.callback;
FM.timedEvent = null;
callback();
}
}
}
il.setInterval(1000);
il.add(tick);
il.run();
}); | 26.783784 | 66 | 0.515641 |
3795a164c87feeb78b489703c22f13652e2d8bab | 113 | js | JavaScript | middlewares/currency.js | nodejs-express/stats-crypto-overview-page | 3df36a90b9701213f599f7fb05f4148e85e769ac | [
"MIT"
] | null | null | null | middlewares/currency.js | nodejs-express/stats-crypto-overview-page | 3df36a90b9701213f599f7fb05f4148e85e769ac | [
"MIT"
] | null | null | null | middlewares/currency.js | nodejs-express/stats-crypto-overview-page | 3df36a90b9701213f599f7fb05f4148e85e769ac | [
"MIT"
] | null | null | null | module.exports = (req, res, next) => {
if(!req.session.currency)
req.session.currency = 'USD';
next();
}
| 18.833333 | 38 | 0.60177 |
3796093e61248f4d9b3cf44341d143b6302a660c | 422 | js | JavaScript | client/src/components/Productlist/Productlist.js | kevlarpixels/vendmoappmarkii | 17a6c99ce51982cce8216085929e6f5a89bdacaf | [
"MIT"
] | null | null | null | client/src/components/Productlist/Productlist.js | kevlarpixels/vendmoappmarkii | 17a6c99ce51982cce8216085929e6f5a89bdacaf | [
"MIT"
] | null | null | null | client/src/components/Productlist/Productlist.js | kevlarpixels/vendmoappmarkii | 17a6c99ce51982cce8216085929e6f5a89bdacaf | [
"MIT"
] | null | null | null | import React from "react";
import "./Productlist.css";
const Productlist = props => (
<div key={props.id} className="card">
<div className="img-container">
<a>
<img alt="test" src={props.url} />{" "}
</a>
</div>
<div>{props.desc}</div>
<div>${props.price}</div>
<button onClick={() => props.addToCart(props.product)}>Add to cart</button>
</div>
);
export default Productlist;
| 23.444444 | 79 | 0.590047 |
3796926290537e1e672d6eab5ee81b1fb57d7bee | 6,483 | js | JavaScript | app/controllers/TodoController.js | scatcher/angular-point-todomvc | 26d8888472390df2c94c9c003f3674a5e2bcf598 | [
"MIT"
] | 1 | 2015-09-26T19:24:01.000Z | 2015-09-26T19:24:01.000Z | app/controllers/TodoController.js | scatcher/angular-point-todomvc | 26d8888472390df2c94c9c003f3674a5e2bcf598 | [
"MIT"
] | null | null | null | app/controllers/TodoController.js | scatcher/angular-point-todomvc | 26d8888472390df2c94c9c003f3674a5e2bcf598 | [
"MIT"
] | null | null | null | /// <reference path='../_all.ts' />
var todos;
(function (todos_1) {
'use strict';
/**
* The main controller for the app. The controller:
* - retrieves and persists the model via the todoStorage service
* - exposes the model to the template and provides event handlers
*/
var TodoController = (function () {
// dependencies are injected via AngularJS $injector
// controller's name is registered in Application.ts and specified from ng-controller attribute in index.html
function TodoController(todosModel, $scope, $location, filterFilter, $q) {
this.todosModel = todosModel;
this.$scope = $scope;
this.$location = $location;
this.filterFilter = filterFilter;
this.$q = $q;
this.newTodo = '';
this.todos = [];
//Using controllerAs, vm represents view model
var vm = this;
vm.refreshTodos();
// watching for events/changes in scope, which are caused by view/user input
// if you subscribe to scope or event with lifetime longer than this controller, make sure you unsubscribe.
//$scope.$watch('todos', () => vm.updateStats(), true);
$scope.$watch('vm.$location.path()', function (path) {
switch (path) {
case '/active':
vm.statusFilter = { completed: false };
break;
case '/completed':
vm.statusFilter = { completed: true };
break;
default:
vm.statusFilter = undefined;
}
});
if ($location.path() === '') {
$location.path('/');
}
}
TodoController.prototype.addTodo = function () {
var _this = this;
var newTodoTitle = this.newTodo.trim();
if (!newTodoTitle.length) {
return;
}
var newTodo = this.todosModel.createEmptyItem({
title: newTodoTitle,
completed: false
});
newTodo.saveChanges()
.then(function (savedTodo) {
//Todo saved
_this.refreshTodos();
})
.catch(function (err) {
throw new Error(err);
});
this.newTodo = '';
};
TodoController.prototype.editTodo = function (todoItem) {
this.editedTodo = todoItem;
};
TodoController.prototype.doneEditing = function (todoItem) {
var _this = this;
this.editedTodo = null;
todoItem.title = todoItem.title.trim();
if (!todoItem.title) {
this.removeTodo(todoItem);
}
else {
todoItem.saveChanges()
.then(function (updatedTodo) {
_this.refreshTodos();
});
}
};
/**
* Initially pulls all todos, each subsequent call only gets the changes that occured since
* the previous request
*/
TodoController.prototype.refreshTodos = function () {
var _this = this;
this.todosModel.executeQuery('primary')
.then(function (todos) {
_this.todoCache = todos;
_this.todos = todos.toArray();
_this.remainingCount = _this.filterFilter(_this.todos, { completed: false }).length;
_this.doneCount = _this.todos.length - _this.remainingCount;
_this.allChecked = !_this.remainingCount;
});
};
TodoController.prototype.removeTodo = function (todoItem) {
var _this = this;
todoItem.deleteItem()
.then(function () {
//No need to refresh because successful deletion of a list item automatically
//prunes all local caches
_this.todos = _this.todoCache.toArray();
})
.catch(function (err) {
//Something bad happened
throw new Error(err);
});
};
TodoController.prototype.clearDoneTodos = function () {
var _this = this;
//Collection all promises so we can wait until all actions are complete before refreshing
var promises = [];
for (var _i = 0, _a = this.todos; _i < _a.length; _i++) {
var todoItem = _a[_i];
if (todoItem.completed) {
promises.push(todoItem.deleteItem());
}
}
this.$q.all(promises)
.then(function () {
//All updates complete
_this.todos = _this.todoCache.toArray();
});
};
TodoController.prototype.markAll = function () {
var _this = this;
//Collection all promises so we can wait until all actions are complete before refreshing
var promises = [];
for (var _i = 0, _a = this.todos; _i < _a.length; _i++) {
var todoItem = _a[_i];
//Only save todos that aren't already set
if (todoItem.completed !== this.allChecked) {
todoItem.completed = this.allChecked;
promises.push(todoItem.saveChanges());
}
}
this.$q.all(promises)
.then(function () {
//All updates complete
_this.refreshTodos();
});
this.allChecked = !this.allChecked;
};
// $inject annotation.
// It provides $injector with information about dependencies to be injected into constructor
// it is better to have it close to the constructor, because the parameters must match in count and type.
// See http://docs.angularjs.org/guide/di
TodoController.$inject = [
'todosModel',
'$scope',
'$location',
'filterFilter',
'$q'
];
return TodoController;
})();
todos_1.TodoController = TodoController;
angular
.module('todomvc')
.controller('todoController', TodoController);
})(todos || (todos = {}));
//# sourceMappingURL=TodoController.js.map | 40.267081 | 119 | 0.507944 |
37981998cf1277fd56b1f90f8efdd80265b91372 | 2,034 | js | JavaScript | examples/experimental/h3-grid/src/h3-utils.js | StijnAmeloot/deck.gl | d67688e3f71a37e2f021dde6681bb1516bebac2b | [
"MIT"
] | 2,334 | 2020-04-15T00:47:36.000Z | 2022-03-31T19:48:08.000Z | examples/experimental/h3-grid/src/h3-utils.js | StijnAmeloot/deck.gl | d67688e3f71a37e2f021dde6681bb1516bebac2b | [
"MIT"
] | 1,867 | 2020-04-14T23:21:22.000Z | 2022-03-31T14:29:34.000Z | examples/experimental/h3-grid/src/h3-utils.js | StijnAmeloot/deck.gl | d67688e3f71a37e2f021dde6681bb1516bebac2b | [
"MIT"
] | 579 | 2020-04-14T23:52:42.000Z | 2022-03-30T04:33:43.000Z | import {polyfill, getRes0Indexes, h3GetFaces, geoToH3} from 'h3-js';
// Number of hexagons at resolution 10 in tile x:497 y:505 z:10
// This tile is close to the equator and includes a pentagon 8a7400000007fff
// which makes it denser than other tiles
const HEX_COUNT_ZOOM_10_RES_10 = 166283;
// size multiplier when zoom increases by 1
const ZOOM_FACTOR = 1 / 4;
// size multiplier when resolution increases by 1
// h3.numHexagons(n + 1) / h3.numHexagons(n)
const RES_FACTOR = 7;
export function getHexagonsInBoundingBox({west, north, east, south}, resolution) {
if (resolution === 0) {
return getRes0Indexes();
}
if (east - west > 180) {
// This is a known issue in h3-js: polyfill does not work correctly
// when longitude span is larger than 180 degrees.
return getHexagonsInBoundingBox({west, north, east: 0, south}, resolution).concat(
getHexagonsInBoundingBox({west: 0, north, east, south}, resolution)
);
}
return polyfill(
[[[west, north], [west, south], [east, south], [east, north], [west, north]]],
resolution,
true
);
}
export function getTileInfo(tile, resolution) {
if (!tile.centerHexagon) {
const {west, north, east, south} = tile.bbox;
const faces = [];
const NW = geoToH3(north, west, resolution);
faces.push(...h3GetFaces(NW));
const NE = geoToH3(north, east, resolution);
faces.push(...h3GetFaces(NE));
const SW = geoToH3(south, west, resolution);
faces.push(...h3GetFaces(SW));
const SE = geoToH3(south, east, resolution);
faces.push(...h3GetFaces(SE));
tile.hasMultipleFaces = new Set(faces).size > 1;
tile.centerHexagon = geoToH3((north + south) / 2, (west + east) / 2, resolution);
}
return tile;
}
export function getMinZoom(resolution, maxHexCount) {
const hexCountZoom10 = HEX_COUNT_ZOOM_10_RES_10 * Math.pow(RES_FACTOR, resolution - 10);
const maxHexCountZoom = 10 + Math.log2(maxHexCount / hexCountZoom10) / Math.log2(ZOOM_FACTOR);
return Math.max(0, Math.floor(maxHexCountZoom));
}
| 33.344262 | 96 | 0.689774 |
37987f4b938809e8ad31ce729c861255d388c83c | 189 | js | JavaScript | sharding.js | andtsa/azen | 09e85839f39d3cc476e4a42c6085cd3f7c7369c7 | [
"Apache-2.0"
] | 1 | 2018-06-29T13:53:56.000Z | 2018-06-29T13:53:56.000Z | sharding.js | andreasaoneo/azen | 09e85839f39d3cc476e4a42c6085cd3f7c7369c7 | [
"Apache-2.0"
] | 3 | 2020-07-16T07:17:12.000Z | 2021-09-01T20:35:09.000Z | sharding.js | andreasaoneo/azen | 09e85839f39d3cc476e4a42c6085cd3f7c7369c7 | [
"Apache-2.0"
] | null | null | null | import { Client } from "discord.js";
const Discord = require("discord.js");
const Manager = new Discord.ShardingManager("./index.js");
Manager.spawn(Math.round(Client.guilds.size / 500));
| 31.5 | 58 | 0.724868 |
379a734cb47d3d4218350d25b67b81672969b769 | 5,516 | js | JavaScript | assets/js/v-535f0a9f.3b64e4c4.js | zhyboys/zhyboys.github.io | b6fa81165e6860f95ce20513df3b697a9810aba0 | [
"Apache-2.0"
] | null | null | null | assets/js/v-535f0a9f.3b64e4c4.js | zhyboys/zhyboys.github.io | b6fa81165e6860f95ce20513df3b697a9810aba0 | [
"Apache-2.0"
] | null | null | null | assets/js/v-535f0a9f.3b64e4c4.js | zhyboys/zhyboys.github.io | b6fa81165e6860f95ce20513df3b697a9810aba0 | [
"Apache-2.0"
] | null | null | null | "use strict";(self.webpackChunkvuepress_blog=self.webpackChunkvuepress_blog||[]).push([[31556],{79763:(n,s,a)=>{a.r(s),a.d(s,{data:()=>p});const p={key:"v-535f0a9f",path:"/typora/01frontEnd/10Webpack/11ES6%E6%A8%A1%E5%9D%97%E4%B8%AD.html",title:"11 ES6模块中",lang:"zh-CN",frontmatter:{},excerpt:"",headers:[],filePathRelative:"typora/01frontEnd/10Webpack/11ES6模块中.md",git:{updatedTime:1631527134e3}}},46989:(n,s,a)=>{a.r(s),a.d(s,{default:()=>e});const p=(0,a(36425).uE)('<h1 id="_11-es6模块中" tabindex="-1"><a class="header-anchor" href="#_11-es6模块中" aria-hidden="true">#</a> 11 ES6模块中</h1><p>暴露与接收方法二</p><div class="language-javascript ext-js line-numbers-mode"><pre class="language-javascript"><code><span class="token keyword">let</span> name <span class="token operator">=</span> <span class="token string">"zs"</span><span class="token punctuation">;</span>\n<span class="token keyword">export</span> <span class="token keyword">default</span> name<span class="token punctuation">;</span>\n\n<span class="token keyword">import</span> name <span class="token keyword">from</span> <span class="token string">"./b.js"</span><span class="token punctuation">;</span>\n<span class="token keyword">import</span> str <span class="token keyword">from</span> <span class="token string">"./b.js"</span><span class="token punctuation">;</span> <span class="token comment">//仍然可以</span>\n<span class="token comment">/*\n注意点:\n1.如果是通过export default xxx;导出数据, 那么在接收导出数据的时候变量名称可以和导出的明白不一致\n2.如果是通过export default xxx;导出数据, 那么在模块中只能使用一次export default\n* */</span>\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p><strong>混合使用</strong></p><div class="language-javascript ext-js line-numbers-mode"><pre class="language-javascript"><code><span class="token keyword">let</span> name <span class="token operator">=</span> <span class="token string">"lnj"</span><span class="token punctuation">;</span>\n<span class="token keyword">let</span> age <span class="token operator">=</span> <span class="token number">33</span><span class="token punctuation">;</span>\n<span class="token keyword">function</span> <span class="token function">say</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">"hi"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n<span class="token punctuation">}</span>\n<span class="token keyword">export</span> <span class="token punctuation">{</span>name<span class="token punctuation">,</span> age<span class="token punctuation">,</span> say<span class="token punctuation">}</span><span class="token punctuation">;</span> <span class="token comment">//导出</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Person</span> <span class="token punctuation">{</span>\n <span class="token function">constructor</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>\n <span class="token keyword">this</span><span class="token punctuation">.</span>name <span class="token operator">=</span> <span class="token string">"zs"</span><span class="token punctuation">;</span>\n <span class="token keyword">this</span><span class="token punctuation">.</span>age <span class="token operator">=</span> <span class="token number">18</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n<span class="token keyword">export</span> <span class="token keyword">default</span> Person<span class="token punctuation">;</span> <span class="token comment">//导出</span>\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><div class="language-javascript ext-js line-numbers-mode"><pre class="language-javascript"><code><span class="token keyword">import</span> Person<span class="token punctuation">,</span><span class="token punctuation">{</span>name<span class="token punctuation">,</span> age<span class="token punctuation">,</span> say<span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">"./c.js"</span><span class="token punctuation">;</span> <span class="token comment">//引入</span>\n</code></pre><div class="line-numbers"><span class="line-number">1</span><br></div></div>',6),e={render:function(n,s){return p}}}}]); | 5,516 | 5,516 | 0.709391 |
379cc4a24a4e0d23078b4a410b734bd6397d2cef | 4,057 | js | JavaScript | hsts.js | xvilo/hsts-cookie | b7c05f408226a3e7126a8bdf26ab8b3d7c602839 | [
"MIT"
] | 166 | 2015-12-31T18:42:27.000Z | 2021-09-02T07:13:23.000Z | hsts.js | xvilo/hsts-cookie | b7c05f408226a3e7126a8bdf26ab8b3d7c602839 | [
"MIT"
] | 11 | 2016-01-13T19:57:18.000Z | 2018-04-25T12:44:16.000Z | hsts.js | xvilo/hsts-cookie | b7c05f408226a3e7126a8bdf26ab8b3d7c602839 | [
"MIT"
] | 24 | 2016-01-14T01:35:55.000Z | 2021-02-10T09:58:03.000Z | "use strict";
/*jslint browser: true, regexp: true*/
var hsts = {
token: null,
tokenHex: null,
tokenBin: null,
tokenArray: [],
hostname: '[HOSTNAME]',
doTest: true,
i: 0,
init: function () {
// drop a test token to see if they've been here before
hsts.httpGet('http://wts.' + hsts.hostname + '/h.gif');
},
generateToken: function () {
// generate a random token on their first visit
hsts.token = Math.floor(Math.random() * 16777215);
hsts.tokenBin = (new Array(24).join("0") + hsts.token.toString(2)).slice(-24);
hsts.tokenHex = hsts.token.toString(16);
hsts.printTokens();
},
dropTokens: function () {
var i = 0,
b = null,
fullhost = null;
console.log("First visit. Dropping tokens.");
// request the test token as https so we can test whether their
// next visit is a return - we will read the tokens on their next visit
hsts.doTest = false;
hsts.httpGet('https://wts.' + hsts.hostname + '/h.gif');
// now drop a unique set of individual tokens as https
for (i = 0; i < hsts.tokenBin.length; i += 1) {
b = hsts.tokenBin.charAt(i);
if (b === '1') {
fullhost = 'w' + (i < 10 ? "0" + i : i) + '.' + hsts.hostname;
hsts.httpGet('https://' + fullhost + '/h.gif');
}
}
},
readTokens: function () {
var i = 0,
padded = null,
url = null;
console.log("Return visit. Retrieving tokens.");
// drop 24 tokens as http so we can determine which were redirected
for (i = 0; i < 24; i += 1) {
padded = (i < 10 ? "0" + i : i);
url = 'http://w' + padded + '.' + hsts.hostname + '/h.gif';
hsts.httpGet(url);
}
},
parseTokenArray: function () {
console.log("Parsing token array.");
hsts.tokenBin = hsts.tokenArray.join('');
hsts.token = parseInt(hsts.tokenBin, 2);
hsts.tokenHex = hsts.token.toString(16);
hsts.printTokens();
},
printTokens: function () {
console.log(hsts.tokenBin);
console.log(hsts.tokenBin);
console.log(hsts.tokenHex);
},
httpGet: function (url) {
var xmlHttp = new XMLHttpRequest(),
bit = null,
doParse = null,
i = 0;
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
var sub = xmlHttp.responseURL.match(/\/\/w(.*?)\./)[1],
isHttps = xmlHttp.responseURL.charAt(4) === 's';
if (sub === 'ts') {
// this is the test token
if (!hsts.doTest) {
// this is the initial flag set, don't act on it
return;
}
if (isHttps) {
// the test token came in as https, so they're returning
hsts.readTokens();
} else {
// seems they've never been here before, drop a token
hsts.generateToken();
hsts.dropTokens();
}
} else {
// this is a bit token
bit = parseInt(sub, 10);
hsts.tokenArray[bit] = isHttps ? 1 : 0;
// check if token array is full, if so parse the array
doParse = true;
for (i = 0; i < 24; i += 1) {
if (hsts.tokenArray[i] === undefined) {
doParse = false;
}
}
if (doParse) {
hsts.parseTokenArray();
}
}
}
};
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
},
};
hsts.init();
| 34.381356 | 86 | 0.456002 |
379d8206e3cc9a349dd145e442f8b31b69534c3e | 3,285 | js | JavaScript | front-end/src/pages/register/Register.js | carlosgustavo/react-authentication-user | 4ca4082244cbdc9fc5609afd6e13a22c14c4472c | [
"MIT"
] | null | null | null | front-end/src/pages/register/Register.js | carlosgustavo/react-authentication-user | 4ca4082244cbdc9fc5609afd6e13a22c14c4472c | [
"MIT"
] | null | null | null | front-end/src/pages/register/Register.js | carlosgustavo/react-authentication-user | 4ca4082244cbdc9fc5609afd6e13a22c14c4472c | [
"MIT"
] | null | null | null | import React, { useState, useEffect } from "react";
import { ErrorMessage, Formik, Form, Field } from "formik";
import * as yup from "yup";
import axios from "axios";
import { history } from "../../history";
import { ClipLoader } from "react-spinners";
import { css } from "@emotion/core";
import "../login/Login.css";
const Register = () => {
const [loadingProducts, setLoadingProducts] = useState(false);
const handleSubmit = (values) => {
axios.post("http://localhost:8080/v1/api/user", values).then((resp) => {
const { data } = resp;
if (data) {
history.push("/login");
}
});
};
const validations = yup.object().shape({
firstName: yup.string().required("Este campo é obrigatório"),
lastName: yup.string().required("Este campo é obrigatório"),
email: yup
.string()
.email(" Email Invalido")
.required("Este campo é obrigatório"),
password: yup
.string()
.min(8, "A senha deve ter pelo menos 8 caracteres")
.required("Este campo é obrigatório"),
});
useEffect(() => {
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function loadProducts() {
setLoadingProducts(true);
await delay(2000);
setLoadingProducts(false);
}
loadProducts();
}, []);
const loadCSS = css`
margin: 150px 0 0 180px;
`;
/* if (loadingProducts === true) {
return <ClipLoader size={80} color="#0b3783" css={loadCSS} />;
} */
return loadingProducts ? (
<ClipLoader size={80} color="#0b3783" css={loadCSS} />
) : (
<div className="man">
<h1>Registro</h1>
<p>Preencha os campos para criar um novo usuário</p>
<Formik
initialValues={{}}
onSubmit={handleSubmit}
validationSchema={validations}
>
<Form className="Login">
<div className="Login-Group">
<Field
name="firstName"
className="Login-Field"
placeholder="Nome"
/>
<ErrorMessage
component="span"
name="firstName"
className="Login-Error"
/>
</div>
<div className="Login-Group">
<Field
name="lastName"
className="Login-Field"
placeholder="Sobrenome"
/>
<ErrorMessage
component="span"
name="lastName"
className="Login-Error"
/>
</div>
<div className="Login-Group">
<Field name="email" className="Login-Field" placeholder="Email" />
<ErrorMessage
component="span"
name="email"
className="Login-Error"
/>
</div>
<div className="Login-Group">
<Field
name="password"
className="Login-Field"
placeholder="Senha"
/>
<ErrorMessage
component="span"
name="password"
className="Login-Error"
/>
</div>
<button className="cadastra" type="submit">
Cadastra
</button>
</Form>
</Formik>
</div>
);
};
export default Register;
| 28.815789 | 78 | 0.525723 |
379dda87ffece4723d6342fc006c4f03b5c34938 | 87 | js | JavaScript | node_modules/carbon-icons-svelte/lib/NumberSmall_832/index.js | seekersapp2013/new | 1e393c593ad30dc1aa8642703dad69b84bad3992 | [
"MIT"
] | null | null | null | node_modules/carbon-icons-svelte/lib/NumberSmall_832/index.js | seekersapp2013/new | 1e393c593ad30dc1aa8642703dad69b84bad3992 | [
"MIT"
] | null | null | null | node_modules/carbon-icons-svelte/lib/NumberSmall_832/index.js | seekersapp2013/new | 1e393c593ad30dc1aa8642703dad69b84bad3992 | [
"MIT"
] | null | null | null | import NumberSmall_832 from "./NumberSmall_832.svelte";
export default NumberSmall_832; | 43.5 | 55 | 0.850575 |
37a03d0ddbf60b0b367b4644665e414d7baf4482 | 2,310 | js | JavaScript | test/integration/populateIds.js | nhsuk/etl-toolkit | 63b21eb1ed767df82c9bad5bcd4286386bddd12f | [
"MIT"
] | 1 | 2018-09-06T20:40:46.000Z | 2018-09-06T20:40:46.000Z | test/integration/populateIds.js | nhsuk/etl-toolkit | 63b21eb1ed767df82c9bad5bcd4286386bddd12f | [
"MIT"
] | 1 | 2018-03-15T14:51:15.000Z | 2018-03-15T14:55:37.000Z | test/integration/populateIds.js | nhsuk/etl-toolkit | 63b21eb1ed767df82c9bad5bcd4286386bddd12f | [
"MIT"
] | 1 | 2021-04-11T07:39:12.000Z | 2021-04-11T07:39:12.000Z | const chai = require('chai');
const populateIds = require('../../lib/queues/populateIds');
const etlStore = require('../../lib/etlStore');
const expect = chai.expect;
function getIdsAction(pageNo) {
return new Promise((resolve) => {
resolve([pageNo + 10, pageNo + 20]);
});
}
function getIdsWithErrorAction(pageNo) {
return new Promise((resolve) => {
if (pageNo === 2) {
throw new Error('bad page');
} else {
resolve([pageNo + 10, pageNo + 20]);
}
});
}
function assertEtlStore() {
const ids = etlStore.getIds();
expect(ids.length).to.equal(4);
expect(ids[0]).to.equal(11);
expect(ids[1]).to.equal(21);
expect(ids[2]).to.equal(12);
expect(ids[3]).to.equal(22);
}
describe('Populate ID queue', () => {
beforeEach(() => {
etlStore.clearState();
populateIds.clearState();
etlStore.setIdKey('id');
});
it('should populate etlStore with loaded ids', (done) => {
const options = {
getIdsAction,
queueComplete: () => {
assertEtlStore();
done();
},
totalPages: 2,
workers: 1,
};
populateIds.start(options);
});
it('should call queueComplete for zero pages', (done) => {
const options = {
getIdsAction: () => { done('should not have been called'); },
queueComplete: () => {
done();
},
totalPages: 0,
workers: 1,
};
populateIds.start(options);
});
it('should ignore pages already scanned', (done) => {
const queueComplete = () => {
assertEtlStore();
done();
};
const options = {
getIdsAction: () => { done('should not have been called'); },
queueComplete,
totalPages: 2,
workers: 1,
};
const restartQueue = () => {
populateIds.start(options);
};
const restartOptions = {
getIdsAction,
queueComplete: restartQueue,
totalPages: 2,
workers: 1,
};
populateIds.start(restartOptions);
});
it('should gracefully handle errors', (done) => {
const options = {
getIdsAction: getIdsWithErrorAction,
queueComplete: () => {
const ids = etlStore.getIds();
expect(ids.length).to.equal(4);
done();
},
totalPages: 3,
workers: 1,
};
populateIds.start(options);
});
});
| 22 | 67 | 0.565801 |
37a06624bc8c9e14841e115e462a5b4756679cda | 4,525 | js | JavaScript | src/scenes/preload.js | snowlizard/JSGames | b7702503acfdd2418ae27f2b99d349b5695426a4 | [
"CC0-1.0"
] | null | null | null | src/scenes/preload.js | snowlizard/JSGames | b7702503acfdd2418ae27f2b99d349b5695426a4 | [
"CC0-1.0"
] | null | null | null | src/scenes/preload.js | snowlizard/JSGames | b7702503acfdd2418ae27f2b99d349b5695426a4 | [
"CC0-1.0"
] | null | null | null | import Phaser from "phaser";
class Preload extends Phaser.Scene {
constructor(){
super('preload');
};
preload = () => {
// Buttons
this.load.image('button', 'assets/sprites/blue_button04.png');
this.load.image('button_hover', 'assets/sprites/blue_button05.png');
// Tic Tac Toe Assets
this.load.image('tile', 'assets/sprites/blank_tile.png');
this.load.image('X', 'assets/sprites/X.png');
this.load.image('O', 'assets/sprites/O.png');
this.load.image('board', 'assets/sprites/board.png');
// irasutoya
this.load.image('dealer', 'assets/sprites/casino_dealer_woman.png');
this.load.image('gameMan', 'assets/sprites/game_man.png');
this.load.image('xo' ,'assets/sprites/tictactoe_.png');
this.load.image('21', 'assets/sprites/21_.png');
// Cards clubs
this.load.image('2-clubs', 'assets/cards/2-clubs.png');
this.load.image('3-clubs', 'assets/cards/3-clubs.png');
this.load.image('4-clubs', 'assets/cards/4-clubs.png');
this.load.image('5-clubs', 'assets/cards/5-clubs.png');
this.load.image('6-clubs', 'assets/cards/6-clubs.png');
this.load.image('7-clubs', 'assets/cards/7-clubs.png');
this.load.image('8-clubs', 'assets/cards/8-clubs.png');
this.load.image('9-clubs', 'assets/cards/9-clubs.png');
this.load.image('10-clubs', 'assets/cards/10-clubs.png');
this.load.image('A-clubs', 'assets/cards/A-clubs.png');
this.load.image('J-clubs', 'assets/cards/J-clubs.png');
this.load.image('Q-clubs', 'assets/cards/Q-clubs.png');
this.load.image('K-clubs', 'assets/cards/K-clubs.png');
// Cards diamonds
this.load.image('2-diamonds', 'assets/cards/2-diamonds.png');
this.load.image('3-diamonds', 'assets/cards/3-diamonds.png');
this.load.image('4-diamonds', 'assets/cards/4-diamonds.png');
this.load.image('5-diamonds', 'assets/cards/5-diamonds.png');
this.load.image('6-diamonds', 'assets/cards/6-diamonds.png');
this.load.image('7-diamonds', 'assets/cards/7-diamonds.png');
this.load.image('8-diamonds', 'assets/cards/8-diamonds.png');
this.load.image('9-diamonds', 'assets/cards/9-diamonds.png');
this.load.image('10-diamonds', 'assets/cards/10-diamonds.png');
this.load.image('A-diamonds', 'assets/cards/A-diamonds.png');
this.load.image('J-diamonds', 'assets/cards/J-diamonds.png');
this.load.image('Q-diamonds', 'assets/cards/Q-diamonds.png');
this.load.image('K-diamonds', 'assets/cards/K-diamonds.png');
// Cards Hearts
this.load.image('2-hearts', 'assets/cards/2-hearts.png');
this.load.image('3-hearts', 'assets/cards/3-hearts.png');
this.load.image('4-hearts', 'assets/cards/4-hearts.png');
this.load.image('5-hearts', 'assets/cards/5-hearts.png');
this.load.image('6-hearts', 'assets/cards/6-hearts.png');
this.load.image('7-hearts', 'assets/cards/7-hearts.png');
this.load.image('8-hearts', 'assets/cards/8-hearts.png');
this.load.image('9-hearts', 'assets/cards/9-hearts.png');
this.load.image('10-hearts', 'assets/cards/10-hearts.png');
this.load.image('A-hearts', 'assets/cards/A-hearts.png');
this.load.image('J-hearts', 'assets/cards/J-hearts.png');
this.load.image('Q-hearts', 'assets/cards/Q-hearts.png');
this.load.image('K-hearts', 'assets/cards/K-hearts.png');
// Cards Spades
this.load.image('2-spades', 'assets/cards/2-spades.png');
this.load.image('3-spades', 'assets/cards/3-spades.png');
this.load.image('4-spades', 'assets/cards/4-spades.png');
this.load.image('5-spades', 'assets/cards/5-spades.png');
this.load.image('6-spades', 'assets/cards/6-spades.png');
this.load.image('7-spades', 'assets/cards/7-spades.png');
this.load.image('8-spades', 'assets/cards/8-spades.png');
this.load.image('9-spades', 'assets/cards/9-spades.png');
this.load.image('10-spades', 'assets/cards/10-spades.png');
this.load.image('A-spades', 'assets/cards/A-spades.png');
this.load.image('J-spades', 'assets/cards/J-spades.png');
this.load.image('Q-spades', 'assets/cards/Q-spades.png');
this.load.image('K-spades', 'assets/cards/K-spades.png');
};
create = () => {
this.scene.start('menu');
}
}
export default Preload; | 49.725275 | 76 | 0.615912 |
37a0c1d5a65cbd832a7bbacb05a66e8e3e7ab4bd | 1,554 | js | JavaScript | js/main.js | mariJhunny/tutor | 9e1f46590c69336fdd2714ddafaaa0d57b0a7788 | [
"MIT"
] | null | null | null | js/main.js | mariJhunny/tutor | 9e1f46590c69336fdd2714ddafaaa0d57b0a7788 | [
"MIT"
] | null | null | null | js/main.js | mariJhunny/tutor | 9e1f46590c69336fdd2714ddafaaa0d57b0a7788 | [
"MIT"
] | null | null | null | function showMenus() {
document.getElementById("Signup").style.display = "none";
document.getElementById("Signin").style.display = "none";
}
function showLogued() {
document.getElementById("Logout").style.display = "none";
}
//COLORBOX
$('.tema-info').colorbox({inline:true, width:"50%"});
//registro correcto
$(document).ready(function(){
$('#registro').on('submit', function(e){
e.preventDefault();
var datos = $(this).serializeArray();
$.ajax({
type: $(this).attr('method'),
data: datos,
url: $(this).attr('action'),
dataType: 'json',
success: function(data){
var resultado = data;
if(resultado.respuesta == 'exito'){
swal(
'Correcto',
'El usuario se creo correctamente',
'clic'
)
}else{
swal(
'Error',
'Hubo un error',
'clic'
)
}
}
})
});
});
/*$(document).ready(main);
var contador =1;
function main(){
$('.menu_bar').clic(function(){
//$('nav ul'.toggle())
if(contador==1){
$('nav ul').animate({
left: '0'
});
contador=0;
}else{
$('nav ul').animate({
left: '-100'
});
contador=1;
}
});
}*/ | 26.793103 | 61 | 0.414414 |
37a0e11b711981fb3cc7bde61a8cd7bd2e0834b8 | 4,345 | js | JavaScript | packages/icons/bin/build.js | patricksmithlooker/components | 57799c8c3d2d75cdfed4082d12a61dfb6eff7c4c | [
"MIT"
] | null | null | null | packages/icons/bin/build.js | patricksmithlooker/components | 57799c8c3d2d75cdfed4082d12a61dfb6eff7c4c | [
"MIT"
] | 372 | 2020-10-12T00:40:10.000Z | 2022-03-26T13:46:30.000Z | packages/icons/bin/build.js | patricksmithlooker/components | 57799c8c3d2d75cdfed4082d12a61dfb6eff7c4c | [
"MIT"
] | null | null | null | /*
MIT License
Copyright (c) 2020 Looker Data Sciences, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
const util = require('util')
const exec = util.promisify(require('child_process').exec)
const globPromise = util.promisify(require('glob'))
const mkdir = util.promisify(require('fs').mkdir)
const rimrafPromise = util.promisify(require('rimraf'))
const writeFile = util.promisify(require('fs').writeFile)
const rename = util.promisify(require('fs').rename)
const path = require('path')
const ora = require('ora')
/**
* Constants for directory names, file extensions, etc
*/
const iconGlyphFileExtension = 'tsx'
const packageSrcPath = path.join('src')
const buildPath = path.join(packageSrcPath, 'generated')
const iconTemplatePath = path.join('bin', 'icon_template.js')
const iconSVGPath = path.join(packageSrcPath, 'svg')
const iconGlyphPath = path.join(buildPath, 'glyphs')
// typescript (globpath: string, ext: string)
async function getBasenames(globpath, ext) {
const filenames = await globPromise(path.join(globpath, `*.${ext}`))
const basenames = filenames.map(n => path.basename(n, `.${ext}`))
basenames.sort()
return basenames
}
/**
* Step 0: Clean up prior build.
*/
async function cleanGlyphsAndComponents() {
await rimrafPromise(buildPath)
await mkdir(buildPath)
}
/**
* Convert the SVG to React components using CLI `svgr` command.
* This by default converts all components to PascalCased filenames.
* The --title-prop flag adds a title tag and destructures a title prop (defaulted in icon-template to the filename in Start Case)
* The --replace-attr-values flag is used to replace fills on exported svg files from Figma so Icon color can be changed
*/
async function convertSVGToComponent() {
const result = await exec(
`yarn svgr --typescript --title-prop --icon --ext ${iconGlyphFileExtension} \
--replace-attr-values "#1C2125=currentColor" \
--template "${iconTemplatePath}" --out-dir "${iconGlyphPath}" "${iconSVGPath}"`
)
if (result.stderr) {
/* eslint-enable-next-line no-console */
console.log(result.stderr)
process.exit(1)
}
}
async function renameGlyphIndexFile() {
// Rename auto-generated index from `.tsx` to `.ts`
await rename(
path.join(iconGlyphPath, 'index.tsx'),
path.join(iconGlyphPath, 'index.ts')
)
}
async function generateIconNameFile() {
function iconNameFile(icons) {
const iconNames = icons.map(i => {
return `'${i}'`
})
return `
export type IconNames = ${iconNames.join('|')}
export const iconNameList = [${iconNames.join(',')}]
`
}
const basenames = await getBasenames(iconGlyphPath, iconGlyphFileExtension)
await writeFile(path.join(buildPath, 'IconNames.ts'), iconNameFile(basenames))
return basenames
}
async function run() {
const spinner = ora('Cleaning icons...')
spinner.color = 'magenta'
spinner.start()
await cleanGlyphsAndComponents()
spinner.color = 'cyan'
spinner.text = 'Converting SVG to components...'
await convertSVGToComponent()
spinner.color = 'green'
spinner.text = 'Exporting Glyphs and generating Typescript interfaces...'
await renameGlyphIndexFile()
await generateIconNameFile()
spinner.color = 'blue'
spinner.succeed('Done building icons!')
spinner.stop()
}
/* eslint-enable-next-line no-console */
run().catch(err => console.log(err))
| 34.76 | 130 | 0.733717 |
37a290d29ed846058d02b5c12e72c617c7a000eb | 610 | js | JavaScript | www/src/controllers/QuoteController.js | vitush93/rocnikac | 8b95677f8ce2c1cc446224828203e85c6a897320 | [
"Apache-2.0"
] | null | null | null | www/src/controllers/QuoteController.js | vitush93/rocnikac | 8b95677f8ce2c1cc446224828203e85c6a897320 | [
"Apache-2.0"
] | null | null | null | www/src/controllers/QuoteController.js | vitush93/rocnikac | 8b95677f8ce2c1cc446224828203e85c6a897320 | [
"Apache-2.0"
] | null | null | null | var Templates = require('../templates');
var config = require('../config');
var QuoteView = require('../views/QuoteView');
var CommentsView = require('../views/CommentsView');
var UserStorage = require('../helpers/UserStorage');
module.exports = function (id) {
var quoteView = new QuoteView(Templates.quote_detail, $('#content-load'), id);
var data = window.quote;
data.logged_user = UserStorage.user;
quoteView.render(data);
$.getJSON(config.api.comments(id), function (data) {
var comments = new CommentsView($('#js-comments-load'));
comments.render(data);
});
}; | 32.105263 | 82 | 0.663934 |
37a2ab774ccaa25af22d28d2b79cd7daef417723 | 892 | js | JavaScript | server/controllers/upload_class_schedule.js | T0UGH/watersoup | 148ce0ed5632c889d6490ce5faf46c659c79e7cc | [
"MIT"
] | 3 | 2019-05-05T00:51:41.000Z | 2021-05-06T08:13:03.000Z | server/controllers/upload_class_schedule.js | T0UGH/watersoup | 148ce0ed5632c889d6490ce5faf46c659c79e7cc | [
"MIT"
] | null | null | null | server/controllers/upload_class_schedule.js | T0UGH/watersoup | 148ce0ed5632c889d6490ce5faf46c659c79e7cc | [
"MIT"
] | 2 | 2019-03-18T05:43:09.000Z | 2021-05-06T14:48:49.000Z | const qcloud = require('../qcloud')
const { mysql } = qcloud
module.exports = async (ctx, next) => {
if (ctx.state.$wxInfo.loginState === 1) {
try {
var data = JSON.parse(ctx.query.data);
for (item of data) {
var hasExistSchedule = await mysql('class_schedule')
.where({
open_gid: item.open_gid,
schedule_id: item.schedule_id
});
if (hasExistSchedule.length != 0) {//[msg|判断这门课是否已经存在,存在就update,不存在就insert]
await mysql('class_schedule')
.update('open_id', item.open_id)
.where({
open_gid: item.open_gid,
schedule_id: item.schedule_id
});
} else {
await mysql('class_schedule').insert(item);
}
}
} catch (e) {
console.log(e);
ctx.state.code = -1;
}
} else {
ctx.state.code = -1;
}
} | 28.774194 | 83 | 0.529148 |
37a57f7d5fbdf1179b785ed8f590de0262f0291c | 10,179 | js | JavaScript | static/build/production/js/main.js | danielmicaletti/ride_cell | 910be09ebc714b8c744edaf81559c8a9266473e3 | [
"MIT"
] | null | null | null | static/build/production/js/main.js | danielmicaletti/ride_cell | 910be09ebc714b8c744edaf81559c8a9266473e3 | [
"MIT"
] | null | null | null | static/build/production/js/main.js | danielmicaletti/ride_cell | 910be09ebc714b8c744edaf81559c8a9266473e3 | [
"MIT"
] | null | null | null | (function(){
'use strict';
angular
.module('rideCell', [
'ngAnimate',
'ngSanitize',
'ui.router',
'ui.bootstrap',
'rideCell.config',
'rideCell.routes',
'main'
]);
angular
.module('rideCell.config', ['ui.router']);
angular
.module('rideCell.routes', ['ui.router.router']);
angular
.module('rideCell')
.run(runCSRF);
runCSRF.$inject = ['$http'];
function runCSRF($http) {
$http.defaults.xsrfHeaderName = 'X-CSRFToken';
$http.defaults.xsrfCookieName = 'csrftoken';
};
})();;(function(){
'use strict';
angular
.module('rideCell.config')
.config(config);
config.$inject = ['$locationProvider', '$urlMatcherFactoryProvider', '$httpProvider'];
function config($locationProvider, $urlMatcherFactoryProvider, $httpProvider){
// $locationProvider.html5Mode({enabled: true, requireBase: false});
$locationProvider.hashPrefix('');
$urlMatcherFactoryProvider.caseInsensitive(true);
$urlMatcherFactoryProvider.strictMode(false);
};
})();;(function(){
'use strict';
angular
.module('rideCell.routes')
.config(config);
config.$inject = ['$stateProvider', '$urlRouterProvider'];
function config($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise(function($injector){
var $state = $injector.get('$state');
$state.go('app');
});
$stateProvider
.state('app', {
url: '/app',
controller: 'AppController',
controllerAs: 'vm',
templateUrl: static_path('views/main/app.html'),
});
};
})();
;(function(){
'use strict';
angular
.module('main', [
'main.controllers',
'main.services',
'main.directives',
]);
angular
.module('main.controllers', []);
angular
.module('main.services', []);
angular
.module('main.directives', []);
})();;(function(){
'use strict';
angular
.module('main.controllers')
.controller('AppController', AppController);
AppController.$inject = ['$scope', '$sce', '$timeout', '$uibModal', 'Main'];
function AppController($scope, $sce, $timeout, $uibModal, Main){
var vm = this;
vm.loading = true;
vm.alerts = [];
var mediaPath = media_path('');
var staticPath = static_path('');
$scope.path = {
static_files: $sce.trustAsResourceUrl(staticPath),
media: $sce.trustAsResourceUrl(mediaPath),
};
function activate(){
getUserPosition();
};
function geoLocError() {
console.log("Unable to retrieve your location");
setMap({lat: 37.769706, lng: -122.447939});
};
function getUserPosition(){
if (!navigator.geolocation){
console.log("Geolocation is not supported by your browser");
vm.userPosition = {lat: 37.769706, lng: -122.447939};
setMap(vm.userPosition);
}else{
navigator.geolocation.getCurrentPosition(function(position){
vm.userPosition = {lat:position.coords.latitude, lng:position.coords.longitude};
setMap(vm.userPosition);
}, geoLocError);
}
};
function setMap(position){
vm.map = new google.maps.Map(document.getElementById('map'), {
center: position,
zoom: 13
});
var marker = new google.maps.Marker({
position: position,
map: vm.map,
draggable: true,
flat:true,
label: {
fontFamily: 'Fontawesome',
text: '\uf2bd'
}
});
marker.addListener('dragend', function(){
var newPosition = {lat:marker.getPosition().lat(), lng:marker.getPosition().lng()};
vm.map.setCenter(newPosition);
mapRadius = getMapRadius();
vm.getParkingLots(newPosition, mapRadius.radius);
});
vm.map.addListener('zoom_changed', function(){
mapRadius = getMapRadius();
vm.getParkingLots(mapRadius.position, mapRadius.radius);
});
vm.loading = false;
var mapRadius = getMapRadius();
vm.getParkingLots(mapRadius.position, mapRadius.radius);
};
function initMapError(errMsg){
console.log(errMsg);
vm.mapError = "Sorry, your map could not be loaded. Please try again later.";
};
function getMapRadius(){
var radius = 10
var bounds = vm.map.getBounds();
var center = vm.map.getCenter()
var position = {lat:vm.map.getCenter().lat(), lng:vm.map.getCenter().lng()};
if(bounds && center){
var ne = bounds.getNorthEast();
radius = google.maps.geometry.spherical.computeDistanceBetween(center, ne)/1609.344;
};
vm.curRadius = radius;
return {radius:radius, position:position};
};
vm.getParkingLots = function(position, radius){
position['radius'] = radius;
Main.getParkingLots(position)
.then(getParkingLotsSuccess)
.catch(getParkingLotsError);
};
function getParkingLotsSuccess(response){
vm.parkingLots = response;
plotLots(vm.parkingLots, vm.map);
};
function getParkingLotsError(errMsg){
console.log(errMsg);
};
function plotLots(lots, map){
angular.forEach(lots, function(val){
var marker = new google.maps.Marker({
position: {lat: val.parking_lot_location[0], lng: val.parking_lot_location[1]},
map: map,
animation: google.maps.Animation.DROP,
draggable: false,
flat:true,
label: {
fontFamily: 'Fontawesome',
text: '\uf1b9'
},
title: val.parking_lot_name
});
marker.addListener('click', function() {
vm.openModal(val);
});
});
};
vm.openModal = function(lot){
var modalInstance = $uibModal.open({
animation: true,
templateUrl: $sce.trustAsResourceUrl(static_path('views/modals/reserve.modal.html')),
controller: 'ReserveModalController',
controllerAs: 'vm',
size: 'md',
resolve: {
lot: function(){
return lot;
}
}
});
modalInstance.result.then(function(lotId){
if(lotId){
Main.reserveSpot(lotId)
.then(reserveSpotSuccess)
.catch(reserveSpotError);
};
}, function(){
console.log('Modal dismissed');
});
};
function reserveSpotSuccess(response){
vm.addAlert({
type: 'success',
msg: 'Your spot has been reserved!'
});
vm.getParkingLots(vm.userPosition, vm.curRadius);
};
function reserveSpotError(errMsg){
console.log(errMsg);
};
vm.addAlert = function(alert){
vm.alerts.push({
type: alert.type,
msg: alert.msg
});
$timeout(function(){
vm.closeAlert(0);
}, 3000);
};
vm.closeAlert = function(index) {
vm.alerts.splice(index, 1);
};
activate();
};
})();
;(function(){
'use strict';
angular
.module('main.controllers')
.controller('ReserveModalController', ReserveModalController);
ReserveModalController.$inject = ['$uibModalInstance', 'lot'];
function ReserveModalController($uibModalInstance, lot){
var vm = this;
vm.lot = lot;
vm.reserveTime = 0;
vm.submitReservation = function(){
$uibModalInstance.close({parking_lot_id:vm.lot.id, spot_res_end:vm.reserveTime});
};
vm.closeModal = function(){
$uibModalInstance.dismiss('cancel');
};
};
})();
;(function(){
'use strict';
angular
.module('main.services')
.factory('Main', Main);
Main.$inject = ['$http', '$sce', '$q'];
function Main($http, $sce, $q) {
var vm = this;
var Main = {
getParkingLots: getParkingLots,
reserveSpot: reserveSpot,
cancelSpot: cancelSpot
};
return Main;
function generalCallbackSuccess(response){
return response.data;
};
function generalCallbackError(response){
return $q.reject(response);
};
function getParkingLots(position){
return $http.get('api/v1/parking-lot-locations?lat='+position.lat+'&lng='+position.lng+'&radius='+position.radius+'')
.then(generalCallbackSuccess)
.catch(generalCallbackError);
};
function reserveSpot(lotId){
return $http.post('api/v1/spot-reservation/', lotId)
.then(generalCallbackSuccess)
.catch(generalCallbackError);
};
function cancelSpot(reservationId){
return $http.delete('api/v1/spot-reservation/'+reservationId+'/')
.then(generalCallbackSuccess)
.catch(generalCallbackError);
};
};
})();
| 28.118785 | 129 | 0.5084 |
37a5eb76081449eaca44a0a3b2ce15ae48e6f72d | 5,410 | js | JavaScript | src/jsx/CartReview.js | ummerh/eforms | 04eeac9ee2ba5359d9b52efc49e010598b2a6f0b | [
"Apache-2.0"
] | null | null | null | src/jsx/CartReview.js | ummerh/eforms | 04eeac9ee2ba5359d9b52efc49e010598b2a6f0b | [
"Apache-2.0"
] | 4 | 2020-06-08T19:34:13.000Z | 2020-10-23T13:28:26.000Z | src/jsx/CartReview.js | ummerh/eforms | 04eeac9ee2ba5359d9b52efc49e010598b2a6f0b | [
"Apache-2.0"
] | null | null | null | const React = require('react');
const ReactDOM = require('react-dom');
import {
BrowserRouter as Router,
Switch,
Link,
Route
} from "react-router-dom";
export class CartReview extends React.Component{
constructor(props){
super(props);
this.state = {currTab:""};
}
render(){
return (
<div className="container"><br/>
<div className="row">
<h3>Review and place order</h3>
</div>
<div className="row">
<div className="col-md-8 order-md-1">
<h4 className="d-flex justify-content-between align-items-center mb-3">
<span className="text-muted">Order summary</span>
<span className="badge badge-secondary badge-pill">3</span>
</h4>
<ul className="list-group mb-3">
<li className="list-group-item d-flex justify-content-between lh-condensed">
<div>
<h6 className="my-0">Product name</h6>
<small className="text-muted">Brief description</small>
</div>
<span className="text-muted">$12</span>
</li>
<li className="list-group-item d-flex justify-content-between lh-condensed">
<div>
<h6 className="my-0">Second product</h6>
<small className="text-muted">Brief description</small>
</div>
<span className="text-muted">$8</span>
</li>
<li className="list-group-item d-flex justify-content-between lh-condensed">
<div>
<h6 className="my-0">Third item</h6>
<small className="text-muted">Brief description</small>
</div>
<span className="text-muted">$5</span>
</li>
<li className="list-group-item d-flex justify-content-between bg-light">
<div className="text-success">
<h6 className="my-0">Promo code</h6>
<small>EXAMPLECODE</small>
</div>
<span className="text-success">-$5</span>
</li>
<li className="list-group-item d-flex justify-content-between">
<span>Total (USD)</span>
<strong>$20</strong>
</li>
</ul>
</div>
<div className="col-md-8 order-md-1">
<h4 className="mb-3">Shipping address</h4>
<ul className="list-group mb-3">
<li className="list-group-item d-flex justify-content-between lh-condensed">
<div>
<small className="text-muted">John Doe</small><br/>
<small className="text-muted">1234 W Smith Court</small><br/>
<small className="text-muted">OKEMO, MI 48864</small>
</div>
<a href="#">edit</a>
</li>
</ul>
</div>
<div className="col-md-8 order-md-1">
<h4 className="mb-3">Payment Method</h4>
<ul className="list-group mb-3">
<li className="list-group-item d-flex justify-content-between lh-condensed">
<div>
<small className="text-muted">Visa Credit Card</small><br/>
<small className="text-muted">xxxx-xxxx-xxxx-4886</small><br/>
<small className="text-muted">Billing address - same as shipping address</small>
</div>
<a href="#">edit</a>
</li>
</ul>
</div>
<div className="col-md-8 order-md-1">
<hr className="mb-4" />
<Link className="btn btn-primary btn-lg btn-block" to="/">Place Order</Link>
</div>
</div>
</div>
);
}
}
| 55.204082 | 160 | 0.356747 |
37a6b3fcb93dc9422b0c53e020b91ddebae9410f | 602 | js | JavaScript | tzcode/tzcode/doctype/pm_visit/pm_visit.js | Lewinta/TZCode | 4a44ed85ec202446fdba0fd54e20680ed56b8ad3 | [
"MIT"
] | null | null | null | tzcode/tzcode/doctype/pm_visit/pm_visit.js | Lewinta/TZCode | 4a44ed85ec202446fdba0fd54e20680ed56b8ad3 | [
"MIT"
] | null | null | null | tzcode/tzcode/doctype/pm_visit/pm_visit.js | Lewinta/TZCode | 4a44ed85ec202446fdba0fd54e20680ed56b8ad3 | [
"MIT"
] | null | null | null | // Copyright (c) 2021, Lewin Villar and contributors
// For license information, please see license.txt
frappe.ui.form.on('PM Visit', {
validate(frm) {
frm.trigger("validate_time");
frm.trigger("calculate_time");
},
validate_time(frm) {
if (frm.doc.arrival > frm.doc.leave)
frappe.throw(__("Arrival must be before Leave"))
},
calculate_time(frm) {
let dt1 = new Date(`${frm.doc.date} ${frm.doc.arrival}`);
let dt2 = new Date(`${frm.doc.date} ${frm.doc.leave}`);
var diff = (dt1.getTime() - dt2.getTime()) / 1000;
frm.set_value("total_time", Math.abs(Math.round(diff)));
}
});
| 30.1 | 60 | 0.66113 |
37a6db5bd204765374d1b88a78aa0ee6f60824d7 | 2,221 | js | JavaScript | src/Components/Rides/RideRequestsCard/RideRequestsCard.spec.js | BloomTech-Labs/carpal-fe | 7f342aad49157a942a9209b7f5dc09b87d42979a | [
"MIT"
] | null | null | null | src/Components/Rides/RideRequestsCard/RideRequestsCard.spec.js | BloomTech-Labs/carpal-fe | 7f342aad49157a942a9209b7f5dc09b87d42979a | [
"MIT"
] | 13 | 2020-03-20T03:09:00.000Z | 2020-05-27T00:48:13.000Z | src/Components/Rides/RideRequestsCard/RideRequestsCard.spec.js | BloomTech-Labs/carpal-fe | 7f342aad49157a942a9209b7f5dc09b87d42979a | [
"MIT"
] | 6 | 2020-05-15T23:27:17.000Z | 2020-07-06T18:24:09.000Z | import React from "react";
import RideRequestsCard from "./RideRequestsCard";
import { render, fireEvent } from "@testing-library/react";
import { Provider } from "react-redux";
import { Router } from "react-router-dom";
import thunk from "redux-thunk";
import * as actionMock from "../../../Redux/Actions/UserAction";
import configureStore from "redux-mock-store";
import * as rtl from "@testing-library/react";
import ReactDOM from "react-dom";
import { createBrowserHistory } from "history";
import RideRequests from "../RideRequests/RideRequests";
const mockStore = configureStore([thunk]);
let store;
const initState = {
requests: {
id: 105,
driver_id: 1,
driver_name: "dang",
ride_id: 1,
status: "accepted",
hobbies: ["video games"],
audio_likes: ["rock"],
audio_dislikes: ["country", "rock"]
}
};
beforeEach(() => {
store = mockStore({
user: {
user: initState
}
});
});
const customHistory = createBrowserHistory();
afterEach(rtl.cleanup);
test("Should Render the request Card component", () => {
const div = document.createElement("div");
const Wrapper = ReactDOM.render(
<Provider store={store}>
<Router history={customHistory}>
<RideRequests>
<RideRequestsCard />
</RideRequests>
</Router>
</Provider>,
div
);
expect(Wrapper).toBeNull();
});
//Additional testing ideas
// const patchy = Wrapper.getAllByAltText("Patchy");
// const buttons = Wrapper.getByText("Details");
// const buttons2 = Wrapper.findByDisplayValue("Accept");
// const buttons3 = Wrapper.findByDisplayValue("Decline");
// expect(patchy).toBeTruthy();
// expect(buttons).toBeDefined();
// expect(buttons2).toBeDefined();
// expect(buttons3).toBeDefined();
//Toggle isDetailsOpen to open
// await fireEvent.click(buttons);
// const hobbies = Wrapper.getByText("Hobbies");
// const audioLike = Wrapper.getByText("Audio I Like");
// const audioDislikes = Wrapper.getByText("Audio I Dislike");
// expect(hobbies.nodeName).toEqual("H3");
// expect(audioLike).toBeDefined();
// expect(audioDislikes).toBeTruthy();
| 28.474359 | 64 | 0.649257 |
37a7748fc8fbf627c88fba86b5f3f21a15756f9f | 289 | js | JavaScript | app/models/uielement.js | apiacademy/cardgame-uberfishclient | 2a10afd4c8ba070da1e30b8735b17e115f31b5b3 | [
"MIT"
] | null | null | null | app/models/uielement.js | apiacademy/cardgame-uberfishclient | 2a10afd4c8ba070da1e30b8735b17e115f31b5b3 | [
"MIT"
] | null | null | null | app/models/uielement.js | apiacademy/cardgame-uberfishclient | 2a10afd4c8ba070da1e30b8735b17e115f31b5b3 | [
"MIT"
] | null | null | null | // UIElement is a generic hypermedia driven presentation element for EmberJS
// In theory I should be able to drop in any hypermedia adapter as long as it
// is capable of creating a UIElement model instance.
export default DS.Model.extend({
text: DS.attr(),
className: DS.attr()
});
| 36.125 | 78 | 0.747405 |
37aaa11c2585358706f3a082d6adb3a7e81784c0 | 3,599 | js | JavaScript | lib/onedrive/server.js | lkaybob/express-cloud-uploader | 110d4102041e274d17132e7caefd531beacdccb8 | [
"Apache-2.0"
] | 2 | 2018-12-05T02:02:33.000Z | 2019-01-03T05:32:49.000Z | lib/onedrive/server.js | lkaybob/express-cloud-uploader | 110d4102041e274d17132e7caefd531beacdccb8 | [
"Apache-2.0"
] | null | null | null | lib/onedrive/server.js | lkaybob/express-cloud-uploader | 110d4102041e274d17132e7caefd531beacdccb8 | [
"Apache-2.0"
] | null | null | null | let http = require("http");
let express = require("express");
let passport = require("passport");
let OIDCStrategy = require("passport-azure-ad").OIDCStrategy;
let session = require("express-session");
let graph = require("./graph");
let fs = require("fs");
const cookieParser = require("cookie-parser");
let oauth2 = require("simple-oauth2").create({
client: {
id: process.env.OAUTH_APP_ID,
secret: process.env.OAUTH_APP_PASSWORD
},
auth: {
tokenHost: process.env.OAUTH_AUTHORITY,
authorizePath: process.env.OAUTH_AUTHORIZE_ENDPOINT,
tokenPath: process.env.OAUTH_TOKEN_ENDPOINT
}
});
let app = express();
app.server = http.createServer(app);
// Configure passport
// In-memory storage of logged-in users
// For demo purposes only, production apps should store
// this in a reliable storage
let users = {};
// Passport calls serializeUser and deserializeUser to
// manage users
passport.serializeUser(function(user, done) {
// Use the OID property of the user as a key
users[user.profile.oid] = user;
done (null, user.profile.oid);
});
passport.deserializeUser(function(id, done) {
done(null, users[id]);
});
// Callback function called once the sign-in is complete
// and an access token has been obtained
async function signInComplete(iss, sub, profile, accessToken, refreshToken, params, done) {
if (!profile.oid) {
return done(new Error("No OID found in user profile."), null);
}
try{
const user = await graph.getUserDetails(accessToken);
if (user) {
// Add properties to profile
profile['email'] = user.mail ? user.mail : user.userPrincipalName;
}
} catch (err) {
done(err, null);
}
// Create a simple-oauth2 token from raw tokens
let oauthToken = oauth2.accessToken.create(params);
// TODO Access Token 객체들을 저장하기 (onedrive-token.json)
// TODO fs.writeFile 을 활용해서 Code 객체 저장하기 (w/ JSON.stringify)
fs.writeFile(__dirname.concat("/onedrive-token.json"), JSON.stringify(oauthToken), () => {
});
// Save the profile and tokens in user storage
users[profile.oid] = { profile, oauthToken };
return done(null, users[profile.oid]);
}
// Configure OIDC strategy
passport.use(new OIDCStrategy(
{
identityMetadata: `${process.env.OAUTH_AUTHORITY}${process.env.OAUTH_ID_METADATA}`,
clientID: process.env.OAUTH_APP_ID,
responseType: 'code id_token',
responseMode: 'form_post',
redirectUrl: process.env.OAUTH_REDIRECT_URI,
allowHttpForRedirectUrl: true,
clientSecret: process.env.OAUTH_APP_PASSWORD,
validateIssuer: false,
passReqToCallback: false,
scope: process.env.OAUTH_SCOPES.split(' ')
},
signInComplete
));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
// Session middleware
// NOTE: Uses default in-memory session store, which is not
// suitable for production
app.use(session({
secret: 'your_secret_value_here',
resave: false,
saveUninitialized: false,
unset: 'destroy'
}));
// Initialize passport
app.use(passport.initialize());
app.use(passport.session());
app.use(function(req, res, next) {
// Set the authenticated user in the
// template locals
if (req.user) {
res.locals.user = req.user.profile;
}
next();
});
let authRouter = require("./auth");
app.use('/auth', authRouter);
app.use("/", ((req, res, next) => {
res.send("Auth token has been saved. You may close the browser");
next();
}), () => {
// TODO 어차피 발급이 모두 끝났으니 서버 종료!!
app.server.close();
console.log("Auth Token Server Closed");
});
module.exports = app;
// app.server.listen(1111);
| 27.06015 | 92 | 0.696027 |
37aaf0f54f0ecc412d7833383c3175436af7f767 | 407 | js | JavaScript | packages/client/src/components/Field/ErrorMessage/ErrorMessage.js | andismith/react-lambda-forms | 836b0ddb8bcb3aee09f1cbcf01202b286ae7efc4 | [
"MIT"
] | null | null | null | packages/client/src/components/Field/ErrorMessage/ErrorMessage.js | andismith/react-lambda-forms | 836b0ddb8bcb3aee09f1cbcf01202b286ae7efc4 | [
"MIT"
] | null | null | null | packages/client/src/components/Field/ErrorMessage/ErrorMessage.js | andismith/react-lambda-forms | 836b0ddb8bcb3aee09f1cbcf01202b286ae7efc4 | [
"MIT"
] | null | null | null | import React from 'react';
import styles from './ErrorMessage.module.scss';
const ErrorMessage = ({ errors }) => {
return (
<div className={styles.error}>
{(errors || []).map(error => (
<span className={styles.message} key={error.message}>
{error.message}
</span>
))}
</div>
);
};
ErrorMessage.displayName = 'ErrorMessage';
export default ErrorMessage;
| 20.35 | 61 | 0.599509 |
37ab7a9dafece4a3a56804fb9e9974c336caa3c9 | 57 | js | JavaScript | lib/collections/seoCollection.js | JoeKarlsson/night-out | 4db965a878a18300224141f1543e59372467f9be | [
"MIT"
] | 1 | 2021-09-27T11:58:08.000Z | 2021-09-27T11:58:08.000Z | lib/collections/seoCollection.js | JoeKarlsson1/night-out | 4db965a878a18300224141f1543e59372467f9be | [
"MIT"
] | 1 | 2019-01-11T03:07:16.000Z | 2019-01-11T03:14:18.000Z | lib/collections/seoCollection.js | JoeKarlsson1/night-out | 4db965a878a18300224141f1543e59372467f9be | [
"MIT"
] | null | null | null | // SeoCollection = new Mongo.Collection('SeoCollection'); | 57 | 57 | 0.77193 |
37ac45b447b987be412fcdc87f96a4f318342b59 | 1,143 | js | JavaScript | public/js/app.js | mmrysir/RPMPM-APP | 610622ac24648275a7276c7a98b0f1eb3c5b19ba | [
"MIT"
] | null | null | null | public/js/app.js | mmrysir/RPMPM-APP | 610622ac24648275a7276c7a98b0f1eb3c5b19ba | [
"MIT"
] | null | null | null | public/js/app.js | mmrysir/RPMPM-APP | 610622ac24648275a7276c7a98b0f1eb3c5b19ba | [
"MIT"
] | null | null | null | const sign_in_btn = document.querySelector("#sign-in-btn");
const sign_up_btn = document.querySelector("#sign-up-btn");
const container = document.querySelector(".container");
sign_up_btn.addEventListener("click", () => {
container.classList.add("sign-up-mode");
});
sign_in_btn.addEventListener("click", () => {
container.classList.remove("sign-up-mode");
});
function signin() {
location.replace("register")
}
function signup() {
location.replace("login")
}
function add() {
location.replace("addEmployee.blade.php")
}
function addproject() {
location.replace("addProject.html")
}
function addTeam() {
location.replace("addTeam.html")
}
function logout() {
location.replace("login.html")
}
const myForm = document.getElementById('myForm');
myForm.addEventListener('submit', function(e){
e.preventDefault();
const formData = new FormData(this);
fetch('http://127.0.0.1:8000/api/users',{
method:'post',
body:myForm
}).then(function (response){
return response.text("success");
}).then(function(text){
console.log(text)
}).catch(function(errr){
console.error(error);
})
}); | 21.166667 | 59 | 0.684164 |
37acd8432fee016f3a4fa590e28c4f22ebb4620a | 1,073 | js | JavaScript | problems/possible-bipartition/possibleBipartition.js | ecgan/leetcode | cd77308f4ab60bc6a0e9ec6796c075bf616d7cf8 | [
"MIT"
] | 9 | 2019-08-15T07:52:20.000Z | 2022-03-26T07:50:01.000Z | problems/possible-bipartition/possibleBipartition.js | ecgan/leetcode | cd77308f4ab60bc6a0e9ec6796c075bf616d7cf8 | [
"MIT"
] | 9 | 2019-12-29T16:50:39.000Z | 2021-05-29T12:23:46.000Z | problems/possible-bipartition/possibleBipartition.js | ecgan/leetcode | cd77308f4ab60bc6a0e9ec6796c075bf616d7cf8 | [
"MIT"
] | 2 | 2021-08-11T19:59:02.000Z | 2021-10-17T02:43:23.000Z | const getDfsFn = (lists, numGroupMap) => {
const dfs = (num, group) => {
if (numGroupMap.has(num)) {
return numGroupMap.get(num) === group
}
numGroupMap.set(num, group)
const dislikes = lists[num] || []
for (let i = 0; i < dislikes.length; i++) {
if (!dfs(dislikes[i], group ^ 1)) {
return false
}
}
return true
}
return dfs
}
const getDislikesLists = (dislikes) => {
const lists = []
for (let i = 0; i < dislikes.length; i++) {
const [a, b] = dislikes[i]
lists[a] = lists[a] || []
lists[a].push(b)
lists[b] = lists[b] || []
lists[b].push(a)
}
return lists
}
/**
* @param {number} N
* @param {number[][]} dislikes
* @return {boolean}
*/
const possibleBipartition = function (N, dislikes) {
const lists = getDislikesLists(dislikes)
const numGroupMap = new Map()
const dfs = getDfsFn(lists, numGroupMap)
for (let i = 1; i <= N; i++) {
if (!numGroupMap.has(i) && !dfs(i, 0)) {
return false
}
}
return true
}
module.exports = possibleBipartition
| 18.5 | 52 | 0.562908 |
37ad6cc57fb91303637e1adcf86bbad9de0d3bda | 1,901 | js | JavaScript | public/js/custom.js | fahimrafeek/php_fahim | 8a5824b3b8e94c5be7e52f1b35fe30281d8649ef | [
"MIT"
] | null | null | null | public/js/custom.js | fahimrafeek/php_fahim | 8a5824b3b8e94c5be7e52f1b35fe30281d8649ef | [
"MIT"
] | null | null | null | public/js/custom.js | fahimrafeek/php_fahim | 8a5824b3b8e94c5be7e52f1b35fe30281d8649ef | [
"MIT"
] | null | null | null | $(document).ready(function () {
initPage();
$("#image").change(function() {
imagePreview(this);
});
});
function initPage() {
setTimeout(function () {
$("#alert-danger").hide();
}, 5000);
setTimeout(function () {
$("#alert-success").hide();
}, 5000);
}
function deleteUser(user_id) {
if(user_id != "" && user_id != undefined) {
if(confirm("Are you sure you want to delete this user?")) {
$.ajax({
type: "POST",
url: "/users/delete",
data: {user_id: user_id},
success: function (data, textStatus, jQxhr) {
window.location.reload();
},
error: function (jqXhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
}else {
return false;
}
}else{
return false;
}
}
function deleteSalesRepresentative(id) {
if(id != "" && id != undefined) {
if(confirm("Are you sure you want to delete this sales representative?")) {
$.ajax({
type: "POST",
url: "/sales-representatives/delete",
data: {id: id},
success: function (data, textStatus, jQxhr) {
window.location.reload();
},
error: function (jqXhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
}else {
return false;
}
}else{
return false;
}
}
function imagePreview(input) {
if(input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#image_preview').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
| 25.689189 | 83 | 0.467649 |
37aeb0c7228d74c15268375575328611ab103317 | 141 | js | JavaScript | web/src/components/NewsItem/NewsItem.stories.js | redwoodjs-prjs/newsapp-redwood | 1bbb515932dd480c0b04465fdae872d1bebc59df | [
"MIT"
] | null | null | null | web/src/components/NewsItem/NewsItem.stories.js | redwoodjs-prjs/newsapp-redwood | 1bbb515932dd480c0b04465fdae872d1bebc59df | [
"MIT"
] | null | null | null | web/src/components/NewsItem/NewsItem.stories.js | redwoodjs-prjs/newsapp-redwood | 1bbb515932dd480c0b04465fdae872d1bebc59df | [
"MIT"
] | null | null | null | import NewsItem from './NewsItem'
export const generated = () => {
return <NewsItem />
}
export default { title: 'Components/NewsItem' }
| 17.625 | 47 | 0.680851 |
37af324950795e57b42d33041a0bc9b6231ac1c7 | 380 | js | JavaScript | routes/libs/parser.js | stvnorg/sprofile-page | 1632df9d5619b25750c88531fe2b5c1a767e4743 | [
"MIT"
] | null | null | null | routes/libs/parser.js | stvnorg/sprofile-page | 1632df9d5619b25750c88531fe2b5c1a767e4743 | [
"MIT"
] | null | null | null | routes/libs/parser.js | stvnorg/sprofile-page | 1632df9d5619b25750c88531fe2b5c1a767e4743 | [
"MIT"
] | null | null | null | function splitString (string) {
return string.split(';')
}
function Parser () {}
Parser.prototype.getLinksAndIcons = function (string) {
var data = splitString(string)
var LinksAndIcons = []
data.forEach((element) => {
element = element.split(' ')
LinksAndIcons.push({ link: element[0], icon: element[1] })
})
return LinksAndIcons
}
module.exports = Parser
| 21.111111 | 62 | 0.676316 |
37b0c14b4cfbe918816caec2152e9b21ac553010 | 689 | js | JavaScript | gatsby-node.js | mvarrieur/portfolio-gatsby | 792521544052244e5cabe15196a3eba5e5025cbe | [
"MIT"
] | null | null | null | gatsby-node.js | mvarrieur/portfolio-gatsby | 792521544052244e5cabe15196a3eba5e5025cbe | [
"MIT"
] | 223 | 2020-02-06T10:38:13.000Z | 2022-03-28T10:30:16.000Z | gatsby-node.js | mvarrieur/portfolio-gatsby | 792521544052244e5cabe15196a3eba5e5025cbe | [
"MIT"
] | null | null | null | /**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
const pageCreators = require('./page-creators');
const slug = require('./src/helpers/slug');
exports.createPages = async ({ actions, graphql }) => {
const { createPage } = actions;
await pageCreators.projects(createPage, graphql);
await pageCreators.projectTags(createPage, graphql);
};
exports.onCreateNode = ({ node, actions }) => {
const { createNodeField } = actions;
if (node.internal.type === 'MarkdownRemark') {
const markdownSlug = slug(node.frontmatter.title);
createNodeField({
node,
name: 'slug',
value: markdownSlug,
});
}
};
| 25.518519 | 55 | 0.658926 |
37b0dcbace633adaa4af07dd4fcea32d5cf48f21 | 273 | js | JavaScript | Tasks/duplicate.js | vadymshturkhal/Exams | f43d45687eb2ab04099428db243c8c4b23c6b2f5 | [
"MIT"
] | null | null | null | Tasks/duplicate.js | vadymshturkhal/Exams | f43d45687eb2ab04099428db243c8c4b23c6b2f5 | [
"MIT"
] | null | null | null | Tasks/duplicate.js | vadymshturkhal/Exams | f43d45687eb2ab04099428db243c8c4b23c6b2f5 | [
"MIT"
] | null | null | null | 'use strict';
// Return an array without duplicates
const duplicate = (value, n) => {
if (n <= 0) return [];
else {
const res = [];
for (let i = 0; i < n; i++) {
res[i] = value;
}
return res;
}
};
require('../Tests/duplicate.js')(duplicate);
| 16.058824 | 44 | 0.520147 |
37b180f82fa5df943513cc90a31e64325926be82 | 11,028 | js | JavaScript | src/pages/environment.js | shimmy568/2911-Project-Website | c00a9f6bdb44aa4233a7d4ceef12de3432b110a5 | [
"MIT"
] | null | null | null | src/pages/environment.js | shimmy568/2911-Project-Website | c00a9f6bdb44aa4233a7d4ceef12de3432b110a5 | [
"MIT"
] | null | null | null | src/pages/environment.js | shimmy568/2911-Project-Website | c00a9f6bdb44aa4233a7d4ceef12de3432b110a5 | [
"MIT"
] | null | null | null | import React from "react"
import Layout from "../components/layout"
import SEO from "../components/seo"
import { ImageContainer as ImageContainerRaw } from "../components/shared"
import styled from "styled-components"
import { Typography } from "@material-ui/core"
import EnvironmentPageLogo from "../components/images/EnvironmentPageLogo"
import EWaterImage from "../components/images/EWaterImage"
const ImageContainer = styled(ImageContainerRaw)`
max-width: 350px;
`
const GenericImageContainer = styled.div`
margin: 50px auto;
max-width: 700px;
`
const EnvironmentPage = () => (
<Layout>
<SEO title="Environment" />
<div>
<ImageContainer>
<EnvironmentPageLogo />
</ImageContainer>
<Typography variant="h3" component="h1" align="center">
Environmental Concerns With IOT
</Typography>
</div>
<div>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
Consider this, there are 12.4 million homes in Canada. We believe that
every home will have one or more IoT devices in their home in the not
too distant future. That means at least 12.4 million devices on the web.
From Google Home to the smart coffee maker, there are two traits shared
by every IoT device: their connection to the web and they need the
energy to operate.
</Typography>
<Typography variant="body1" component="body1">
This has massive implications for our environment. There are three
important environmental issues we would like to focus on. They are as
follows:
</Typography>
<ol>
<li>
<Typography variant="body1" component="body1">
Power Efficiency
</Typography>
</li>
<li>
<Typography variant="body1" component="body1">
Manufacturing Processes
</Typography>
</li>
<li>
<Typography variant="body1" component="body1">
End of Life Disposal
</Typography>
</li>
</ol>
<Typography variant="h5" component="h5">
Power Consumption
</Typography>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
In electronics design, there is a war. The war is between efficiency,
power consumption and cost among others. This war has serious ethical
implications, particularly in the cost department. Is it ethical to
sacrifice efficiency and power consumption for a lower BOM cost? Is it
ethical to cut corners just to make the extra million?
</Typography>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
Consider a smoke alarm with a 1 uA quiescent current. Now consider that
there are about 5 smoke alarms in every house. How much power does that
consume? Well for the 12.4 million homes, that's about 7.4 kW just for
the smoke alarms in Canada; we will use that as our benchmark.
</Typography>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
Now, making efficient smoke alarm costs money. If we cut corners, that
will save millions. Here’s the catch; the quiescent current of the less
efficient smoke alarm is now 1 mA. How much power does that consume? 7.4
MW of power. To save a million dollars, we waste megawatts of power.
That power has to come from somewhere; and that somewhere is usually
fossil fuels.
</Typography>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
So, is it ethical for a manufacturer to save a million dollars but
making the society burn excess power?
</Typography>
<Typography variant="h5" component="h5">
Manufacturing Process
</Typography>
<Typography variant="body1" component="body1">
Look at this photo.
</Typography>
<GenericImageContainer>
<EWaterImage />
</GenericImageContainer>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
What do you see? Is this what you think about when you think about the
internet of things? You may not think about the manufacturing of IoT
devices, but it is still an important consideration.
</Typography>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
For example, China. Electronics manufacture and export is at the core of
their economy. Does this justify the wasteful way in which these widgets
are produced? What about the workers in the factories? They work long
hours in windowless rooms using dangerous compounds to make our everyday
items. Many of these workers are getting sick working at these
factories. Does our enjoyment outweigh their suffering?
</Typography>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
Moreover, is it ethical to produce such devices if they include harmful
byproducts? Is it ethical for the developed countries to profit off of
such technology at the expense of the developing nations and the poor?
</Typography>
<Typography variant="h5" component="h5">
End of Life Disposal
</Typography>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
The computer you’re reading this on, how long have you had it? How long
do you expect to have it? What happened to your previous computer? What
about your phone? Most people have never considered where their IoT
devices go.
</Typography>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
Let’s consider the US; in 2010 it was estimated that 258 million
electronic devices were disposed of. It was also estimated that
two-thirds of the discarded electronics were recycled. So what happens
to the recycled material? More importantly, what about the other third
that isn’t recycled?
</Typography>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
The sad truth is that most discarded electronics are shipped to
countries in Latin America, Asia, and Africa under false pretenses. The
old electronics are usually labelled as “used goods” even though they do
not usually function at all. Another sad part of this is that this is
legally allowed to do.
</Typography>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
If exporting old broken electronics is legal, does that also mean it’s
ethical? Is it ethical to take advantage of developing countries to
further our own prosperity?
</Typography>
<Typography variant="h5" component="h5">
What we can do
</Typography>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
We believe it is unethical for companies to cut corners in the name of
the bottom line. Whether they are reducing efficiency, manufacturing the
product poorly, or have a complete disregard for the end of life of a
product. So what can you do?
</Typography>
<Typography
variant="body1"
component="body1"
paragraph={true}
display="block"
>
The best way you can fight this behaviour is by using your wallet; don’t
buy anything from an unethical company. Research the options for IoT
device manufacturers. Go with the one that has taken the care to
safeguard the environment. Sure it will cost more, but ask yourself
this: What does it cost us as a society to support companies that are
making this planet uninhabitable?
</Typography>
<Typography variant="h5" component="h5">
References
</Typography>
<ul>
<li>
<Typography variant="body1" component="body1">
[1](
<a href="https://www150.statcan.gc.ca/n1/pub/11-402-x/2011000/chap/fam/fam-eng.htm">
Families, Households and Housing
</a>
):
</Typography>
</li>
<li>
<Typography variant="body1" component="body1">
[2](
<a href="https://ieeexplore.ieee.org/document/7122861">
The Power of Models: Modeling Power Consumption for IoT Devices
</a>
):
</Typography>
</li>
<li>
<Typography variant="body1" component="body1">
[3](
<a href="https://www.nationalgeographic.com/environment/2018/11/china-ban-plastic-trash-imports-shifts-waste-crisis-southeast-asia-malaysia/">
China's ban on trash imports shifts waste crisis to Southeast Asia
</a>
):
</Typography>
</li>
<li>
<Typography variant="body1" component="body1">
[4](
<a href="https://www.needpix.com/photo/1276605/pollution-waters-smoke-industry-mill-free-pictures-free-photos-free-images-royalty-free">
Pollution Waters Smoke Free Photo
</a>
):
</Typography>
</li>
<li>
<Typography variant="body1" component="body1">
[5](
<a href="https://www.bsr.org/reports/BSR_Electronics_Supply_Networks_Water_Pollution_in_China.pdf">
Electronics Supply Networks and Water Pollution in China
</a>
):
</Typography>
</li>
<li>
<Typography variant="body1" component="body1">
[6](
<a href="https://www.wired.com/2015/04/inside-chinese-factories/">
How China Is Screwing Over Its Poisoned Factory Workers
</a>
):
</Typography>
</li>
<li>
<Typography variant="body1" component="body1">
[7](
<a href="https://ourworld.unu.edu/en/toxic-e-waste-dumped-in-poor-nations-says-united-nations">
Toxic E-Waste Dumped in Poor Nations, Says United Nations
</a>
):
</Typography>
</li>
</ul>
</div>
</Layout>
)
export default EnvironmentPage
| 35.459807 | 154 | 0.610083 |
37b2303337ce8ef8ade24e232f9e1403daabcb6c | 5,445 | js | JavaScript | static_files/grits.js | fhinkel/solutions-load-balanced-gaming-server-on-google-compute-engine | 44809e037d58ae7a2119a615679c75f68b674e8e | [
"Apache-2.0"
] | 1 | 2019-02-23T00:39:58.000Z | 2019-02-23T00:39:58.000Z | static_files/grits.js | lauro-cesar/solutions-load-balanced-gaming-server-on-google-compute-engine | 61a4a53e1aecbfcf0656b14b4856c6255cdc0ec8 | [
"Apache-2.0"
] | 1 | 2021-03-21T10:54:23.000Z | 2021-03-21T10:54:23.000Z | static_files/grits.js | lauro-cesar/solutions-load-balanced-gaming-server-on-google-compute-engine | 61a4a53e1aecbfcf0656b14b4856c6255cdc0ec8 | [
"Apache-2.0"
] | null | null | null | // Copyright 2013 Google Inc. All Rights Reserved.
//
// 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
//
// 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.
/**
* @fileoverview JavaScript that starts Grits game.
*/
/**
* An Object representing load status of single instance. The information is
* generated and retrned by server in JSON format.
*
* @typedef {{
* host: string,
* ipaddress: string,
* status: string,
* load: number,
* force_set: boolean
* }}
*/
var JsonSingleInstanceStat;
/**
* Redirects the browser to Grits game server to start game.
*/
function playGrits() {
$.getJSON('/getip.json', function(json) {
if (json['ipaddress']) {
window.location.replace('http://' + json['ipaddress'] + ':8080/');
} else {
showMessage('No Game Server Available.');
}
});
}
/**
* Sets auto-reload of game server cluster status every 5 seconds.
*/
$(function() {
getStat();
setInterval(getStat, 5000);
});
/**
* A class to represent stat information of single instance of game server.
*
* @constructor
* @param {JsonSingleInstanceStat} jsonStat Object passed from server in JSON
* that contains load information of the single instance.
*/
function SingleStatForUser(jsonStat) {
/**
* Status information of single game server instance.
* @type {JsonSingleInstanceStat}
* @private
*/
this.jsonStat_ = jsonStat;
/**
* jQuery instance to represent HTML div box for single game server instance.
* @type {?jQuery}
* @private
*/
this.statBox_ = null;
}
/**
* Adds DOM structure that shows status of single instance.
*
* @return {jQuery} jQuery object to represent the new single stat box.
*/
SingleStatForUser.prototype.createBox = function() {
this.statBox_ = $('<div class="server-status-user"></div>');
this.statBox_.attr('id', this.jsonStat_['host']);
var joinDiv = $('<div class="join"></div>');
this.statBox_.append(joinDiv);
joinDiv.html('<a href="http://' + this.jsonStat_['ipaddress'] + ':8080/">' +
'Join</a>');
this.statBox_.append('<div class="ip-address-user">' +
this.jsonStat_['ipaddress'] + '</div>');
this.addLoadIndicator_();
this.statBox_.append('<div class="clear-both"></div>');
return this.statBox_;
};
/**
* Tells whether load level is included in the JSON for an instance.
*
* @private
* @return {boolean} Boolean value to indicate whether load level information
* for the instance exists.
*/
SingleStatForUser.prototype.hasLoadInfo_ = function() {
return (this.jsonStat_['load'] != null);
};
/**
* Displays load level information of a single instance.
*
* @param {jQuery} loadBar Container jQuery object for load bar.
*/
SingleStatForUser.prototype.setLoad = function(loadBar) {
var load = (this.jsonStat_['load'] || 0);
// 48px per 12.5% (1 user).
loadBar.css({'width': '' + Math.floor(load / 12) * 48 + 'px'});
var joinDiv = this.statBox_.find('.join');
// If load is >= 100%, hide "join" link.
if (load >= 100) {
joinDiv.css('visibility', 'hidden');
} else {
joinDiv.css('visibility', 'visible');
}
};
/**
* Displays load UI of a single instance. Load UI includes load percentage,
* bar of the load level, and controls to overwrite actual load level.
*
* @private
*/
SingleStatForUser.prototype.addLoadIndicator_ = function() {
var loadBar = $('<div class="user-count-bar"></div>');
this.statBox_.append(loadBar);
this.setLoad(loadBar);
};
/**
* Updates status of existing instance. The function updates status of
* Compute Engine instance and load level of the instance.
*
* @param {jQuery} statBox jQuery object to represent the container of single
* instance information.
*/
SingleStatForUser.prototype.updateStat = function(statBox) {
this.statBox_ = statBox;
if (this.hasLoadInfo_()) {
var loadBar = this.statBox_.children('.user-count-bar');
this.setLoad(loadBar);
}
};
/**
* Processes stats in JSON and updates UI.
* @param {Array.<JsonSingleInstanceStat>} json JSON stats returned from server.
*/
function processJsonStats(json) {
var serverList = $('#server-list');
var boxes = serverList.children('.server-status-user');
$.each(json, function(index, jsonStat) {
var processed = false;
var singleStat = new SingleStatForUser(jsonStat);
boxes = boxes.filter(function(i) {
if (this && $(this).attr('id') == jsonStat['host']) {
singleStat.updateStat($(this));
processed = true;
return false;
}
return true;
});
if (!processed) {
serverList.append(singleStat.createBox());
}
});
$.each(boxes, function(index, val) {
$(val).remove();
});
}
/**
* Gets status of game server cluster. It throws AJAX request to get status
* information in JSON, and updates status information when successfully
* queried.
*/
function getStat() {
$.getJSON('/stats-user.json', function(json) {
processJsonStats(json);
});
}
| 27.089552 | 80 | 0.664463 |
37b281aaf400396b214a7c55a04d848ecc013669 | 1,375 | js | JavaScript | src/tests/components/Search.test.js | chocosinensis/saqib.ml | 96daf639d0c8f53835438b10fc5b140c5e73c22c | [
"0BSD"
] | 1 | 2021-08-19T08:02:22.000Z | 2021-08-19T08:02:22.000Z | src/tests/components/Search.test.js | chocosinensis/saqib.eu.org | 605b477780988f1e6554d669be47939a2a8f53fd | [
"0BSD"
] | null | null | null | src/tests/components/Search.test.js | chocosinensis/saqib.eu.org | 605b477780988f1e6554d669be47939a2a8f53fd | [
"0BSD"
] | null | null | null | import { render, screen, fireEvent } from '@testing-library/react'
import Search from '../../components/Search'
describe('Search', () => {
const props = { value: '', set: jest.fn() }
it('should render input field with given placeholder', () => {
render(<Search {...props} placeholder='Input Field' />)
const inputElem = screen.getByPlaceholderText(/input\sfield/i)
expect(inputElem).toBeInTheDocument()
})
it('should update the input field', () => {
let val = ''
render(<Search {...props} set={(value) => (val = value)} />)
const inputElem = screen.getByRole('textbox')
fireEvent.change(inputElem, { target: { value: 'Input Value' } })
expect(val).toBe('Input Value')
})
describe('.match()', () => {
it("should match with title if doesn't start with '@'", () => {
const title = 'My Awesome Title'
const failing = 'My Faltu Title'
const term = 'awes'
expect(Search.match({ title }, term)).toBeTruthy()
expect(Search.match({ title: failing }, term)).toBeFalsy()
})
it("should match with author if starts with '@'", () => {
const author = ['My', 'Awesome Author']
const failing = ['My', 'Faltu Author']
const term = '@awes'
expect(Search.match({ author }, term)).toBeTruthy()
expect(Search.match({ author: failing }, term)).toBeFalsy()
})
})
})
| 30.555556 | 69 | 0.600727 |
37b28afa901b7d405961a2b35bbbce66f33a1250 | 5,306 | js | JavaScript | client/src/components/HomeComponents/CheckoutForm/index.js | seanbelverstone/Bird-Bird-Ordering | bd6680d8126a8257ddf9c6ec221b1c8bb5732243 | [
"MIT"
] | 1 | 2020-07-02T13:26:44.000Z | 2020-07-02T13:26:44.000Z | client/src/components/HomeComponents/CheckoutForm/index.js | seanbelverstone/Bird-Bird-Ordering | bd6680d8126a8257ddf9c6ec221b1c8bb5732243 | [
"MIT"
] | 1 | 2020-05-20T20:45:33.000Z | 2020-05-20T20:45:33.000Z | client/src/components/HomeComponents/CheckoutForm/index.js | seanbelverstone/Bird-Bird-Ordering | bd6680d8126a8257ddf9c6ec221b1c8bb5732243 | [
"MIT"
] | null | null | null | import React from 'react';
import {useStripe, useElements, CardElement} from '@stripe/react-stripe-js';
import {Button} from "reactstrap";
import API from "../../../utils/API";
import emailjs from "emailjs-com";
import format from "date-fns/format";
import "./style.css"
let templateParams = {};
const completed = 0;
const CheckoutForm = (props) => {
const stripe = useStripe();
const elements = useElements();
const handleSubmit = async (event) => {
// We don't want to let default form submission happen here,
// which would refresh the page.
event.preventDefault();
const result = await stripe.createPaymentMethod({
type: 'card',
card: elements.getElement(CardElement),
billing_details: {
// Include any additional collected billing details.
name: props.name,
email: props.email,
},
});
handlePaymentMethodResult(result);
};
const handlePaymentMethodResult = async (result) => {
if (result.error) {
showErrorMessage();
// An error happened when collecting card details,
// show `result.error.message` in the payment form.
} else {
// Otherwise send paymentMethod.id to your server (see Step 3)
// loading symbol appears
props.setState({
loading: true,
errors: false
});
const response = await fetch('/stripe/charge', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
payment_method_id: result.paymentMethod.id,
// multiplying the amount below by 100 as stripe doesnt use decimals. 1099 is 10.99
amount: parseInt((props.total) *100)
}),
});
const serverResponse = await response.json();
handleServerResponse(serverResponse);
}
};
const handleServerResponse = (serverResponse) => {
if (serverResponse.error) {
showErrorMessage();
// An error happened when charging the card,
// show the error in the payment form.
} else if (serverResponse.requiresAction) {
// Use Stripe.js to handle required card action
stripe.handleCardAction(
serverResponse.clientSecret
).then(function(result) {
if (result.error) {
// Show `result.error.message` in payment form
showErrorMessage();
} else {
// The card action has been handled
// The PaymentIntent can be confirmed again on the server
fetch('/stripe/charge', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ payment_intent_id: result.paymentIntent.id })
}).then(function(confirmResult) {
return confirmResult.json();
}).then(handleServerResponse);
}
});
} else {
// Show a success message
props.setState({
showSuccess: true
})
createOrder()
}
};
const createOrder = () => {
API.createOrder(
props.name,
props.telephone,
props.email,
props.quantity,
props.jamSelected,
props.gravySelected,
props.total,
props.pickupDateTime,
completed,
).then(response => {
console.log(response)
// Stores the response data into the templateParams variable, allowing us to send an email with the
// relevant information to the user
templateParams = {
name: response.data.name,
email: response.data.email,
telephone: response.data.telephone,
orderNumber: response.data.id,
quantity: response.data.biscuitQuantity,
// Formatting it here for easier readability for the user upon receiving their email
pickupDateTime: format(new Date(response.data.pickupDateTime), "PPPPp"),
total: response.data.totalCost,
timePlaced: response.data.createdAt
};
console.log(templateParams);
// Emailjs send form function.
emailjs.send(process.env.REACT_APP_SERVICE_ID, process.env.REACT_APP_TEMPLATE_ID, templateParams, process.env.REACT_APP_USER_ID)
.then((response) => {
console.log("Email successfully sent", response.status, response.text)
// hides the loading symbol
props.setState({
loading: false,
});
// Updating the biscuit count AFTER the email has been sent
props.setStateOfBiscuits({
biscuitCount: props.biscuitCount - props.quantity
})
}, (err) => {
console.log("Email sending failed", err)
});
})
}
// sets the parent's state of errors to true, so the alert appears
const showErrorMessage = () => {
props.setState({
errors: true,
loading: false
})
}
const handleCardChange = (event) => {
if (event.error) {
// Show `event.error.message` in the payment form.
}
};
return (
<div>
<form onSubmit={handleSubmit}>
<CardElement onChange={handleCardChange} />
<Button type="submit" color="secondary" id="stripeButton" disabled={!stripe}>
Submit Order
</Button>
</form>
</div>
);
}
export default CheckoutForm; | 30.67052 | 136 | 0.606483 |
37b2f2d373e2726556850d71557601567453c076 | 1,515 | js | JavaScript | commands/base64.js | Faris0520/ruka_DiscordBot | d0633947e48edcb78e16bb579a63f4ad3068c6c6 | [
"Apache-2.0"
] | 5 | 2020-09-24T03:10:31.000Z | 2021-11-12T11:22:48.000Z | commands/base64.js | Faris0520/ruka_DiscordBot | d0633947e48edcb78e16bb579a63f4ad3068c6c6 | [
"Apache-2.0"
] | null | null | null | commands/base64.js | Faris0520/ruka_DiscordBot | d0633947e48edcb78e16bb579a63f4ad3068c6c6 | [
"Apache-2.0"
] | 5 | 2020-09-24T03:11:40.000Z | 2021-10-03T16:12:51.000Z | const Discord = require('discord.js');
const base64 = require("js-base64").Base64;
module.exports.run = async (client, message, args) => {
if(args[0] === 'encode') {
if(!args[0]) return message.channel.send("Pls provide text!");
let txt = args.join(' ').slice(7);
let txtEncode = base64.encode(txt);
message.channel.send(`\`${txtEncode}\` `);
var embedu = new Discord.RichEmbed()
.setTitle(`Base64 Encode`)
.setColor('BLUE')
.setDescription(`Text : ${txt} \n\nEncode : ${txtEncode}`)
message.channel.send(embedu);
return;
}
if(args[0] === 'decode') {
if(!args[0]) return message.channel.send("Pls provide code!");
let txt = args.join(' ').slice(7);
let txtDecode = base64.decode(txt);
message.channel.send(`\`${txtDecode}\` `);
var embed = new Discord.RichEmbed()
.setTitle(`Base64 Encode`)
.setColor('BLUE')
.setDescription(`Code : ${txt} \n\nDecode : ${txtDecode}`)
message.channel.send(embed);
return;
}
let emvbed = new Discord.RichEmbed()
.setColor('RANDOM')
.setAuthor('BASE64')
.addField('Base64 Commands', '``base64 encode [text]``, ``base64 decode [text]``');
message.channel.send(emvbed);
console.log(`++++++++++++++++++++++++++++++++++++++++++++++++\nCommand base64 digunakan oleh ${message.author.username} di ${message.guild.name}\n++++++++++++++++++++++++++++++++++++++++++++++++`)
}
exports.conf = {
aliases: ['base64']
}
exports.help = {
name: 'base64',
usage: "base64 <text>"
} | 32.934783 | 198 | 0.586139 |
37b30570f7f767f43f4e271afa2a8d4273f76b81 | 434 | js | JavaScript | test/spec/click.js | siebenfarben/webdriverio | 241a5d2b6eaf949489f9b46149526f2433aa6b19 | [
"MIT"
] | 7 | 2019-01-09T13:52:12.000Z | 2020-03-12T09:36:02.000Z | test/spec/click.js | siebenfarben/webdriverio | 241a5d2b6eaf949489f9b46149526f2433aa6b19 | [
"MIT"
] | 31 | 2018-12-10T13:58:20.000Z | 2019-08-22T14:19:40.000Z | test/spec/click.js | siebenfarben/webdriverio | 241a5d2b6eaf949489f9b46149526f2433aa6b19 | [
"MIT"
] | 21 | 2018-12-10T12:30:35.000Z | 2019-12-12T10:53:20.000Z | describe('click', () => {
it('text should be visible after clicking on .btn1', async function () {
const elemSelector = '//html/body/section/div[7]'
const buttonSelector = '//html/body/section/button[1]';
(await this.client.isVisible(elemSelector)).should.be.equal(false)
await this.client.click(buttonSelector);
(await this.client.isVisible(elemSelector)).should.be.equal(true)
})
})
| 39.454545 | 76 | 0.654378 |
37b3062372e18710c4ceaed657d547c2dfdc917f | 240 | js | JavaScript | src/components/Figure/styled.js | Murilohim/ecodesign | 678b1e16db6c9823eb342bb5d7341b7f175fc060 | [
"MIT"
] | null | null | null | src/components/Figure/styled.js | Murilohim/ecodesign | 678b1e16db6c9823eb342bb5d7341b7f175fc060 | [
"MIT"
] | null | null | null | src/components/Figure/styled.js | Murilohim/ecodesign | 678b1e16db6c9823eb342bb5d7341b7f175fc060 | [
"MIT"
] | null | null | null | import styled from "styled-components";
export const FigureContainer = styled.div`
display: flex;
align-items: center;
justify-content: space-evenly;
width: 530px;
height: 280px;
img {
width: 300px;
}
` | 18.461538 | 42 | 0.6375 |
37b35c2291049bb2e398e04ffdbdc4fdb4d531aa | 66 | js | JavaScript | app/application-loading/route.js | tsmalls93/ember-nrg-ui | 5e2a0d8a179f4eb82324497155160b007657c1a0 | [
"MIT"
] | null | null | null | app/application-loading/route.js | tsmalls93/ember-nrg-ui | 5e2a0d8a179f4eb82324497155160b007657c1a0 | [
"MIT"
] | null | null | null | app/application-loading/route.js | tsmalls93/ember-nrg-ui | 5e2a0d8a179f4eb82324497155160b007657c1a0 | [
"MIT"
] | null | null | null | export { default } from 'ember-nrg-ui/application-loading/route';
| 33 | 65 | 0.757576 |
295fa5190ac61591874a0ad29602969b2e8c793d | 160 | js | JavaScript | web/src/pages/AuthLoginPage/AuthLoginPage.stories.js | cecilian-archives/cecilian-archives | b1714ab7571f1cfeb291387095c334f6a340cdf2 | [
"MIT"
] | null | null | null | web/src/pages/AuthLoginPage/AuthLoginPage.stories.js | cecilian-archives/cecilian-archives | b1714ab7571f1cfeb291387095c334f6a340cdf2 | [
"MIT"
] | null | null | null | web/src/pages/AuthLoginPage/AuthLoginPage.stories.js | cecilian-archives/cecilian-archives | b1714ab7571f1cfeb291387095c334f6a340cdf2 | [
"MIT"
] | null | null | null | import AuthLoginPage from "./AuthLoginPage";
export const generated = () => {
return <AuthLoginPage />;
};
export default { title: "Pages/AuthLoginPage" };
| 20 | 48 | 0.69375 |
295fbd597cab00e4279f539d783daa5b225f290e | 7,056 | js | JavaScript | aframe-object-scaling.js | banada/aframe-object-scaling | 6cc15a2e078bd975a953b5ab946ff57ce0ab8d4f | [
"MIT"
] | null | null | null | aframe-object-scaling.js | banada/aframe-object-scaling | 6cc15a2e078bd975a953b5ab946ff57ce0ab8d4f | [
"MIT"
] | null | null | null | aframe-object-scaling.js | banada/aframe-object-scaling | 6cc15a2e078bd975a953b5ab946ff57ce0ab8d4f | [
"MIT"
] | null | null | null | 'use strict';
AFRAME.registerComponent('sizing-tool', {
schema: {
hand: {}
},
init: function() {
let self = this;
let ruler = [['meters', 1], ['feet', 0.3048], ['inches', 0.0254], ['centimeters', 0.01], ['millimeters', 0.001], ['micrometers', 0.000001]];
// ruler index
let i = 0;
let isHuman = false;
let pickup = false;
let yAxis;
// Adjust the camera when in VR
let camera = document.getElementById('cameraRig');
document.addEventListener('enter-vr', function() {
console.log("entering VR, adjusting camera");
camera.setAttribute('position', '0 0 2');
});
// Left hand: teleport, scroll-scaling
if (self.data.hand === 'left') {
let last = null;
// menu button
self.el.addEventListener('menudown', function() {
toggleHuman();
});
// trigger
self.el.addEventListener('triggerdown', function() {
changeSize();
});
// Fine-tune size 1% using the vive touchpad
self.el.addEventListener('axismove', function(evt) {
i = document.getElementById('model').getAttribute('ruler');
let direction;
// Ignore the first location to set a delta
if (last === null) {
last = evt.detail.axis[1];
return;
}
// When finger leaves the touchpad, it resets to 0,0. Adjusts for this
// This could cause a bug if the user hits true (0,0). Unlikely
if ((evt.detail.axis[0] === 0) && (evt.detail.axis[1] === 0)) {
last = null;
return;
}
// Set 0.1 as a high-pass filter
if (evt.detail.axis[1] > (last+0.1)) {
direction = 1;
} else if (evt.detail.axis[1] < (last-0.1)){
direction = -1;
} else {
return;
}
let scale = document.getElementById('model').getAttribute('scale');
for (let val in scale) {
scale[val] += ruler[i][1]*direction*0.01;
}
document.getElementById('model').setAttribute('scale', scale);
// Ready for next delta
last = evt.detail.axis[1];
});
}
// Right hand: move up/down
if (self.data.hand === 'right') {
// detect trackpad position for reference on trackpaddown
self.el.addEventListener('axismove', function(evt) {
yAxis = evt.detail.axis[1];
});
// trackpad button
self.el.addEventListener('trackpaddown', function(evt) {
if (yAxis > 0) {
moveUp();
} else {
moveDown();
}
});
document.addEventListener('keypress', function(evt) {
// Change size on log scale
if (evt.key === ' ') {
changeSize();
}
// Adjust y axis up 1 cm
if (evt.key === 'q') {
moveUp();
}
// Adjust y axis down 1 cm
if (evt.key === 'e') {
moveDown();
}
// Add a human for scale
if (evt.key === 'h') {
toggleHuman();
}
// Change if object can be picked up or not
if (evt.key === 'p') {
if (!pickup) {
pickup = true;
console.log('pickup ON');
} else {
pickup = false;
console.log('pickup OFF');
}
}
// Create JSON object
if (evt.key === 'j') {
console.log("generating JSON..");
let doc = new Object();
// Parse name from file path
let name = document.getElementById('model').getAttribute('src');
let period = name.split('.');
let slash = period[0].split('/');
// Create JSON using rounding to avoid scientific notation
doc.name = slash[slash.length - 1];
doc.uuid = "";
doc.pickup = pickup;
let test = document.getElementById('model').getAttribute('position').y;
doc.offset = parseFloat(document.getElementById('model').getAttribute('position').y).toFixed(8);
let position = document.getElementById('model').getAttribute('position');
console.log(position);
for (let val in position) {
position[val] = parseFloat(position[val]).toFixed(8);
}
doc.position = position;
let rotation = document.getElementById('model').getAttribute('rotation');
for (let val in rotation) {
rotation[val] = parseFloat(rotation[val]).toFixed(8);
}
doc.rotation = rotation;
let scale = document.getElementById('model').getAttribute('scale');
for (let val in scale) {
scale[val] = parseFloat(scale[val]).toFixed(8);
}
doc.scale = scale;
console.log(doc);
// Download the JSON file, with formatting
let json = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(doc, null, " "));
console.log(json);
let el = document.getElementById('jsonlink');
el.setAttribute('href', json);
el.setAttribute('download', doc.name+'.json');
el.click();
}
});
// Fine-tune size by 1%
document.addEventListener('wheel', function(evt) {
i = document.getElementById('model').getAttribute('ruler');
let direction;
if (evt.deltaY > 0) {
direction = 1;
} else {
direction = -1;
}
let scale = document.getElementById('model').getAttribute('scale');
for (let val in scale) {
scale[val] += ruler[i][1]*direction*0.01;
}
document.getElementById('model').setAttribute('scale', scale);
});
}
// Change size on a log
function changeSize() {
console.log("changing size..");
if (i === (ruler.length-1)) {
i = 0;
console.log(ruler[i][0]);
document.getElementById('model').setAttribute('scale', ruler[i][1]+' '+ruler[i][1]+' '+ruler[i][1]);
document.getElementById('model').setAttribute('ruler', i);
} else {
i++;
console.log(ruler[i][0]);
document.getElementById('model').setAttribute('scale', ruler[i][1]+' '+ruler[i][1]+' '+ruler[i][1]);
document.getElementById('model').setAttribute('ruler', i);
}
}
function moveUp() {
console.log("moving up..");
let position = document.getElementById('model').getAttribute('position');
position.y += 0.01;
console.log(position.y);
document.getElementById('model').setAttribute('position', position);
}
function moveDown() {
console.log("moving down..");
let position = document.getElementById('model').getAttribute('position');
position.y -= 0.01;
console.log(position.y);
document.getElementById('model').setAttribute('position', position);
}
// Add a human for scale
function toggleHuman() {
if (!isHuman) {
isHuman = true;
console.log("adding human for scale");
let el = document.createElement('a-obj-model');
el.setAttribute('id', 'human');
el.setAttribute('src', 'assets/human_male.obj');
el.setAttribute('scale', '0.001 0.001 0.001');
el.setAttribute('position', '0 0 0.5');
el.setAttribute('rotation', '0 0 0');
document.getElementsByTagName('a-scene')[0].appendChild(el);
} else {
isHuman = false;
console.log("removing human..");
let el = document.getElementById('human');
document.getElementsByTagName('a-scene')[0].removeChild(el);
}
}
}
});
| 31.5 | 143 | 0.585176 |
296058e8a7ece11da6e8460a4c10e068414d0237 | 930 | js | JavaScript | src/components/Gallery/ImageItem/ImageItem.test.js | witalewski/infinite-scroll | a550a2cffd5688147cd8c60b4d974b5e7a784667 | [
"MIT"
] | null | null | null | src/components/Gallery/ImageItem/ImageItem.test.js | witalewski/infinite-scroll | a550a2cffd5688147cd8c60b4d974b5e7a784667 | [
"MIT"
] | null | null | null | src/components/Gallery/ImageItem/ImageItem.test.js | witalewski/infinite-scroll | a550a2cffd5688147cd8c60b4d974b5e7a784667 | [
"MIT"
] | null | null | null | import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow';
import { Set } from 'immutable';
import mockImageURLs from '../../../fixtures/imageURLs.json';
import { ImageItem } from './ImageItem';
describe('ImageItem', () => {
it('matches snapshot for favourite image', () => {
const renderer = new ShallowRenderer();
renderer.render(
<ImageItem
image={mockImageURLs[0]}
height={400}
favourites={new Set(mockImageURLs)}
/>
);
const result = renderer.getRenderOutput();
expect(result).toMatchSnapshot();
});
it('matches snapshot for non-favourite image', () => {
const renderer = new ShallowRenderer();
renderer.render(
<ImageItem
image={mockImageURLs[0]}
height={400}
favourites={new Set([])}
/>
);
const result = renderer.getRenderOutput();
expect(result).toMatchSnapshot();
});
});
| 28.181818 | 61 | 0.625806 |
29609148d4cc06e18bbeabe320c99a458453606f | 519 | js | JavaScript | .eslintrc.js | AnonymousGuy9/twitter-to-discord | 20a8d7b16779958a47906c2ab2db1a62be8ed6eb | [
"MIT"
] | 20 | 2019-04-17T14:26:46.000Z | 2020-07-13T18:45:06.000Z | .eslintrc.js | AnonymousGuy9/twitter-to-discord | 20a8d7b16779958a47906c2ab2db1a62be8ed6eb | [
"MIT"
] | 4 | 2018-10-25T03:00:16.000Z | 2018-11-01T03:28:44.000Z | .eslintrc.js | AnonymousGuy9/twitter-to-discord | 20a8d7b16779958a47906c2ab2db1a62be8ed6eb | [
"MIT"
] | 18 | 2019-09-18T01:05:01.000Z | 2021-01-02T13:42:56.000Z | module.exports = {
extends: 'eslint:recommended',
env: {
node: true,
es6: true
},
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
rules: {
'no-console': 'off',
'no-unused-vars': 'off',
'block-scoped-var': 'error',
'curly': ['error', 'multi-line'],
'no-empty-function': 'off',
'no-labels': 'error',
'no-lone-blocks': 'error',
'no-useless-return': 'off',
'semi': 'error'
}
}; | 23.590909 | 41 | 0.473988 |
29611439620ede1a54f38adf11e901a0ed328a49 | 130 | js | JavaScript | sites/fast-component-explorer/mock.js | tgoze/fast | 4a4e2c16987aa015c3f90adbe400f09a0d4c2563 | [
"MIT"
] | 6,481 | 2020-06-27T04:52:16.000Z | 2022-03-31T14:37:40.000Z | sites/fast-component-explorer/mock.js | tgoze/fast | 4a4e2c16987aa015c3f90adbe400f09a0d4c2563 | [
"MIT"
] | 1,848 | 2020-06-26T06:42:33.000Z | 2022-03-31T23:24:30.000Z | sites/fast-component-explorer/mock.js | tgoze/fast | 4a4e2c16987aa015c3f90adbe400f09a0d4c2563 | [
"MIT"
] | 362 | 2020-06-30T14:51:30.000Z | 2022-03-30T22:11:05.000Z | window.matchMedia = jest.fn().mockImplementation(query => {
return {
matches: false,
media: query,
};
});
| 18.571429 | 59 | 0.561538 |
2961cba4e65c342c791b57b37a4d3c7bb8f1cb29 | 995 | js | JavaScript | server/config.js | cosmoarunn/shhserver | 6f00bfbee27fc655b97300897fca5c05e16f5870 | [
"MIT"
] | 1 | 2020-08-18T00:25:13.000Z | 2020-08-18T00:25:13.000Z | server/config.js | cosmoarunn/shhserver | 6f00bfbee27fc655b97300897fca5c05e16f5870 | [
"MIT"
] | null | null | null | server/config.js | cosmoarunn/shhserver | 6f00bfbee27fc655b97300897fca5c05e16f5870 | [
"MIT"
] | null | null | null | /**
*
*
*
*
* Server Configuration file
* Author : Arun Panneerselvam
*/
const path = require('path');
const fs = require('fs');
module.exports = {
host: getHost(),
port: 10010,
allowedOrigins : ['httpsgen.arunpanneerselvam.com','https://httpsgen.arunpanneerselvam.com/', 'https://165.22.35.93:4040','https://arunpanneerselvam.com', 'https://gsunitedtechnologies.com'],
superSecret: '8m9u4L4VeiWkPLXEoWAbvwzb-nyw6eA2Nz1gUgNR45ytAcc1PHzFLomeYhFc6whQ4ieWpHAwF1WeZgFCqp316o8W00054587Q1m=',
auth_duration : 30000,
//socket: 'https://' + getHost() + ':3030',
https: true,
socketEnabled: true,
corsEnabled: false,
sslEnabled: true,
sslOptions: {
key : fs.readFileSync(path.resolve('./ssh/key.pem')),
cert: fs.readFileSync(path.resolve('./ssh/server.crt'))
},
}
function getHost(name) {
return process.env.CI === 'true' ? name : '127.0.0.1';
}
| 28.428571 | 199 | 0.60804 |
296296be0508dcd69d116d95513c7bfa5c63c5dc | 4,477 | js | JavaScript | pages/StepTwo/index.js | JonssonJohanna/Kollektiva | 291682f49c9b8ad1298b3e2bfa0c16dfe0abf5bd | [
"MIT"
] | null | null | null | pages/StepTwo/index.js | JonssonJohanna/Kollektiva | 291682f49c9b8ad1298b3e2bfa0c16dfe0abf5bd | [
"MIT"
] | null | null | null | pages/StepTwo/index.js | JonssonJohanna/Kollektiva | 291682f49c9b8ad1298b3e2bfa0c16dfe0abf5bd | [
"MIT"
] | null | null | null | import Link from "next/link";
import styles from "/styles/StepTwo.module.css";
const StepTwo = () => {
return (
<div className={styles.bodyContainer}>
<div className={styles.pageNavigate}>
<Link href="/" passHref>
<a>Hem / </a>
</Link>
<Link href="/landlord">
<a>Hyr ut din bostad / </a>
</Link>
<Link href="/StepOne">
<a>Skapa annons</a>
</Link>
</div>
<h2 className={styles.mainTitle}>Steg 2</h2>
<p className={styles.breadText}>
Fyll i information om den bostaden du vill hyra ut
</p>
<div className={styles.parentContainer}>
<div className={styles.leftContainer}>
<div className={styles.stepOne}>
<h4 className={styles.step}>Steg 1</h4>
<p className={styles.stepInfo}>Om din bostad</p>
</div>
<div className={styles.active}>
<h4 className={styles.stepActive}>Steg 2</h4>
<p className={styles.stepInfo}>Bekvämligheter</p>
</div>
<div className={styles.stepOne}>
<h4 className={styles.step}>Steg 3</h4>
<p className={styles.stepInfo}>Husregler</p>
</div>
<div className={styles.stepOne}>
<h4 className={styles.step}>Steg 4</h4>
<p className={styles.stepInfo}>Uthyrning</p>
</div>
</div>
<div className={styles.rightContainer}>
<div className={styles.info}>
<h3 className={styles.title}>Bekvämligheter</h3>
<h4 className={styles.InfoType}>
Klicka i alla bekvämligheter som finns i din bostad
</h4>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/parking.svg"></img>
<p>Parkering</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/wifi.svg"></img>
<p>Wi-fi</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/pool.svg"></img>
<p>Pool</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/garden.svg"></img>
<p>Trädgård</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/balcony.svg"></img>
<p>Balkong</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/dryer.svg"></img>
<p>Torktumlare</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/washer.svg"></img>
<p>Tvättmaskin</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/sauna.svg"></img>
<p>Bastu</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/fire.svg"></img>
<p>Öppen spis</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/gym.svg"></img>
<p>Gym</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/garage.svg"></img>
<p>Garage</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/tent.svg"></img>
<p>Uteplats</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/bbq.svg"></img>
<p>Grill</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/alarm.svg"></img>
<p>Brandvarnare</p>
</button>
<button className={styles.amentiesItem}>
<img src="/icons/amenities/storage.svg"></img>
<p>Förråd</p>
</button>
</div>
<div className={styles.save}>
<button className={styles.buttons}>Spara utkast</button>
<Link href="StepThree">
<button className={styles.buttons}>Nästa</button>
</Link>
</div>
</div>
</div>
</div>
);
};
export default StepTwo;
| 36.104839 | 68 | 0.510833 |
2963d01a160e49ad11b4006a6335c13871a2d690 | 562 | js | JavaScript | frontend/util/days_array.js | jaredjj3/knowtation | ac9820123a397f3d647a633f7b1ac3b1322048bb | [
"MIT"
] | null | null | null | frontend/util/days_array.js | jaredjj3/knowtation | ac9820123a397f3d647a633f7b1ac3b1322048bb | [
"MIT"
] | null | null | null | frontend/util/days_array.js | jaredjj3/knowtation | ac9820123a397f3d647a633f7b1ac3b1322048bb | [
"MIT"
] | null | null | null | // this util returns an array of objects that represent the number
// of days ago (v) and the letter of the day that corresponds with it
// (f)
// integer in 0..6, that is, the number of times to rotate - 1
const todaysDay = new Date().getDay() + 1;
const push = Array.prototype.push;
const splice = Array.prototype.splice;
let daysArray = ['s', 'm', 't', 'w', 't', 'f', 's'];
push.apply(daysArray, splice.call(daysArray, 0, todaysDay));
daysArray = daysArray.reverse();
daysArray = daysArray.map((day, idx) => ({ v: idx, f: day }));
export default daysArray;
| 37.466667 | 69 | 0.677936 |
296573fc69293869cb2eb27b596e67ce48b0bc12 | 29,686 | js | JavaScript | examples/screen_sharing_extension/mutation-summary.js | ruifigueira/mutation-summary | a2863246b15d9939f1ec0d60c0297a7242bfff27 | [
"Apache-2.0"
] | null | null | null | examples/screen_sharing_extension/mutation-summary.js | ruifigueira/mutation-summary | a2863246b15d9939f1ec0d60c0297a7242bfff27 | [
"Apache-2.0"
] | null | null | null | examples/screen_sharing_extension/mutation-summary.js | ruifigueira/mutation-summary | a2863246b15d9939f1ec0d60c0297a7242bfff27 | [
"Apache-2.0"
] | null | null | null | !function(t,e){for(var r in e)t[r]=e[r]}(window,function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}({1:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a,n=r(5),i=function(){function t(){this.nodes=[],this.values=[]}return t.prototype.isIndex=function(t){return+t==t>>>0},t.prototype.nodeId=function(e){var r=e[t.ID_PROP];return r||(r=e[t.ID_PROP]=t.nextId_++),r},t.prototype.set=function(t,e){var r=this.nodeId(t);this.nodes[r]=t,this.values[r]=e},t.prototype.get=function(t){var e=this.nodeId(t);return this.values[e]},t.prototype.has=function(t){return this.nodeId(t)in this.nodes},t.prototype.delete=function(t){var e=this.nodeId(t);delete this.nodes[e],delete this.values[e]},t.prototype.keys=function(){var t=[];for(var e in this.nodes)this.isIndex(e)&&t.push(this.nodes[e]);return t},t.ID_PROP="__mutation_summary_node_map_id__",t.nextId_=1,t}();e.NodeMap=i,function(t){t[t.STAYED_OUT=0]="STAYED_OUT",t[t.ENTERED=1]="ENTERED",t[t.STAYED_IN=2]="STAYED_IN",t[t.REPARENTED=3]="REPARENTED",t[t.REORDERED=4]="REORDERED",t[t.EXITED=5]="EXITED"}(a=e.Movement||(e.Movement={}));var o=function(){function t(t,e,r,a,n,i,o,s){void 0===e&&(e=!1),void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===n&&(n=null),void 0===i&&(i=!1),void 0===o&&(o=null),void 0===s&&(s=null),this.node=t,this.childList=e,this.attributes=r,this.characterData=a,this.oldParentNode=n,this.added=i,this.attributeOldValues=o,this.characterDataOldValue=s,this.isCaseInsensitive=this.node.nodeType===Node.ELEMENT_NODE&&this.node instanceof HTMLElement&&this.node.ownerDocument instanceof HTMLDocument}return t.prototype.getAttributeOldValue=function(t){if(this.attributeOldValues)return this.isCaseInsensitive&&(t=t.toLowerCase()),this.attributeOldValues[t]},t.prototype.getAttributeNamesMutated=function(){var t=[];if(!this.attributeOldValues)return t;for(var e in this.attributeOldValues)t.push(e);return t},t.prototype.attributeMutated=function(t,e){this.attributes=!0,this.attributeOldValues=this.attributeOldValues||{},t in this.attributeOldValues||(this.attributeOldValues[t]=e)},t.prototype.characterDataMutated=function(t){this.characterData||(this.characterData=!0,this.characterDataOldValue=t)},t.prototype.removedFromParent=function(t){this.childList=!0,this.added||this.oldParentNode?this.added=!1:this.oldParentNode=t},t.prototype.insertedIntoParent=function(){this.childList=!0,this.added=!0},t.prototype.getOldParent=function(){if(this.childList){if(this.oldParentNode)return this.oldParentNode;if(this.added)return null}return this.node.parentNode},t}();e.NodeChange=o;var s=function(){return function(){this.added=new i,this.removed=new i,this.maybeMoved=new i,this.oldPrevious=new i,this.moved=void 0}}();e.ChildListChange=s;var u=function(t){function e(e,r){var a=t.call(this)||this;a.rootNode=e,a.reachableCache=new i,a.wasReachableCache=new i,a.anyParentsChanged=!1,a.anyAttributesChanged=!1,a.anyCharacterDataChanged=!1;for(var n=function(t){switch(t.type){case"childList":o.anyParentsChanged=!0,t.removedNodes.forEach(function(e){a.getChange(e).removedFromParent(t.target)}),t.addedNodes.forEach(function(t){a.getChange(t).insertedIntoParent()});break;case"attributes":o.anyAttributesChanged=!0,o.getChange(t.target).attributeMutated(t.attributeName,t.oldValue);break;case"characterData":o.anyCharacterDataChanged=!0,o.getChange(t.target).characterDataMutated(t.oldValue)}},o=this,s=0,u=r;s<u.length;s++){n(u[s])}return a}return n.__extends(e,t),e.prototype.getChange=function(t){var e=this.get(t);return e||(e=new o(t),this.set(t,e)),e},e.prototype.getOldParent=function(t){var e=this.get(t);return e?e.getOldParent():t.parentNode},e.prototype.getIsReachable=function(t){if(t===this.rootNode)return!0;if(!t)return!1;var e=this.reachableCache.get(t);return void 0===e&&(e=this.getIsReachable(t.parentNode),this.reachableCache.set(t,e)),e},e.prototype.getWasReachable=function(t){if(t===this.rootNode)return!0;if(!t)return!1;var e=this.wasReachableCache.get(t);return void 0===e&&(e=this.getWasReachable(this.getOldParent(t)),this.wasReachableCache.set(t,e)),e},e.prototype.reachabilityChange=function(t){return this.getIsReachable(t)?this.getWasReachable(t)?a.STAYED_IN:a.ENTERED:this.getWasReachable(t)?a.EXITED:a.STAYED_OUT},e}(i);e.TreeChanges=u;var h=function(){function t(t,e,r,a,n){this.rootNode=t,this.mutations=e,this.selectors=r,this.calcReordered=a,this.calcOldPreviousSibling=n,this.treeChanges=new u(t,e),this.entered=[],this.exited=[],this.stayedIn=new i,this.visited=new i,this.childListChangeMap=void 0,this.characterDataOnly=void 0,this.matchCache=void 0,this.processMutations()}return t.prototype.processMutations=function(){if(this.treeChanges.anyParentsChanged||this.treeChanges.anyAttributesChanged)for(var t=0,e=this.treeChanges.keys();t<e.length;t++){var r=e[t];this.visitNode(r,void 0)}},t.prototype.visitNode=function(t,e){if(!this.visited.has(t)){this.visited.set(t,!0);var r=this.treeChanges.get(t),n=e;if((r&&r.childList||null==n)&&(n=this.treeChanges.reachabilityChange(t)),n!==a.STAYED_OUT){if(this.matchabilityChange(t),n===a.ENTERED)this.entered.push(t);else if(n===a.EXITED)this.exited.push(t),this.ensureHasOldPreviousSiblingIfNeeded(t);else if(n===a.STAYED_IN){var i=a.STAYED_IN;r&&r.childList&&(r.oldParentNode!==t.parentNode?(i=a.REPARENTED,this.ensureHasOldPreviousSiblingIfNeeded(t)):this.calcReordered&&this.wasReordered(t)&&(i=a.REORDERED)),this.stayedIn.set(t,i)}if(n!==a.STAYED_IN)for(var o=t.firstChild;o;o=o.nextSibling)this.visitNode(o,n)}}},t.prototype.ensureHasOldPreviousSiblingIfNeeded=function(t){if(this.calcOldPreviousSibling){this.processChildlistChanges();var e=t.parentNode,r=this.treeChanges.get(t);r&&r.oldParentNode&&(e=r.oldParentNode);var a=this.getChildlistChange(e);a.oldPrevious.has(t)||a.oldPrevious.set(t,t.previousSibling)}},t.prototype.getChanged=function(t,e,r){this.selectors=e,this.characterDataOnly=r;for(var n=0,i=this.entered;n<i.length;n++){var o=i[n];(d=this.matchabilityChange(o))!==a.ENTERED&&d!==a.STAYED_IN||t.added.push(o)}for(var s=0,u=this.stayedIn.keys();s<u.length;s++){o=u[s];if((d=this.matchabilityChange(o))===a.ENTERED)t.added.push(o);else if(d===a.EXITED)t.removed.push(o);else if(d===a.STAYED_IN&&(t.reparented||t.reordered)){var h=this.stayedIn.get(o);t.reparented&&h===a.REPARENTED?t.reparented.push(o):t.reordered&&h===a.REORDERED&&t.reordered.push(o)}}for(var c=0,l=this.exited;c<l.length;c++){var d;o=l[c];(d=this.matchabilityChange(o))!==a.EXITED&&d!==a.STAYED_IN||t.removed.push(o)}},t.prototype.getOldParentNode=function(t){var e=this.treeChanges.get(t);if(e&&e.childList)return e.oldParentNode?e.oldParentNode:null;var r=this.treeChanges.reachabilityChange(t);if(r===a.STAYED_OUT||r===a.ENTERED)throw Error("getOldParentNode requested on invalid node.");return t.parentNode},t.prototype.getOldPreviousSibling=function(t){var e=t.parentNode,r=this.treeChanges.get(t);r&&r.oldParentNode&&(e=r.oldParentNode);var a=this.findChildlistChange(e);if(!a)throw Error("getOldPreviousSibling requested on invalid node.");return a.oldPrevious.get(t)},t.prototype.getOldAttribute=function(t,e){var r=this.treeChanges.get(t);if(!r||!r.attributes)throw Error("getOldAttribute requested on invalid node.");var a=r.getAttributeOldValue(e);if(void 0===a)throw Error("getOldAttribute requested for unchanged attribute name.");return a},t.prototype.attributeChangedNodes=function(t){if(!this.treeChanges.anyAttributesChanged)return{};var e,r;if(t){e={},r={};for(var n=0,i=t;n<i.length;n++){e[p=i[n]]=!0,r[p.toLowerCase()]=p}}for(var o={},s=0,u=this.treeChanges.keys();s<u.length;s++){var h=u[s],c=this.treeChanges.get(h);if(c.attributes&&(a.STAYED_IN===this.treeChanges.reachabilityChange(h)&&a.STAYED_IN===this.matchabilityChange(h)))for(var l=h,d=0,f=c.getAttributeNamesMutated();d<f.length;d++){var p=f[d];if(!e||e[p]||c.isCaseInsensitive&&r[p])c.getAttributeOldValue(p)!==l.getAttribute(p)&&(r&&c.isCaseInsensitive&&(p=r[p]),o[p]=o[p]||[],o[p].push(l))}}return o},t.prototype.getOldCharacterData=function(t){var e=this.treeChanges.get(t);if(!e||!e.characterData)throw Error("getOldCharacterData requested on invalid node.");return e.characterDataOldValue},t.prototype.getCharacterDataChanged=function(){if(!this.treeChanges.anyCharacterDataChanged)return[];for(var t=[],e=0,r=this.treeChanges.keys();e<r.length;e++){var n=r[e];if(a.STAYED_IN===this.treeChanges.reachabilityChange(n)){var i=this.treeChanges.get(n);i.characterData&&n.textContent!=i.characterDataOldValue&&t.push(n)}}return t},t.prototype.computeMatchabilityChange=function(t,e){this.matchCache||(this.matchCache=[]),this.matchCache[t.uid]||(this.matchCache[t.uid]=new i);var r=this.matchCache[t.uid],a=r.get(e);return void 0===a&&(a=t.matchabilityChange(e,this.treeChanges.get(e)),r.set(e,a)),a},t.prototype.matchabilityChange=function(t){var e=this;if(this.characterDataOnly)switch(t.nodeType){case Node.COMMENT_NODE:case Node.TEXT_NODE:return a.STAYED_IN;default:return a.STAYED_OUT}if(!this.selectors)return a.STAYED_IN;if(t.nodeType!==Node.ELEMENT_NODE)return a.STAYED_OUT;for(var r=t,n=this.selectors.map(function(t){return e.computeMatchabilityChange(t,r)}),i=a.STAYED_OUT,o=0;i!==a.STAYED_IN&&o<n.length;){switch(n[o]){case a.STAYED_IN:i=a.STAYED_IN;break;case a.ENTERED:i=i===a.EXITED?a.STAYED_IN:a.ENTERED;break;case a.EXITED:i=i===a.ENTERED?a.STAYED_IN:a.EXITED}o++}return i},t.prototype.findChildlistChange=function(t){return this.childListChangeMap.get(t)},t.prototype.getChildlistChange=function(t){var e=this.findChildlistChange(t);return e||(e=new s,this.childListChangeMap.set(t,e)),e},t.prototype.processChildlistChanges=function(){if(!this.childListChangeMap){this.childListChangeMap=new i;for(var t=0,e=this.mutations;t<e.length;t++){var r=e[t];if("childList"==r.type&&(this.treeChanges.reachabilityChange(r.target)===a.STAYED_IN||this.calcOldPreviousSibling)){var n=this.getChildlistChange(r.target),o=r.previousSibling,s=function(t,e){!t||n.oldPrevious.has(t)||n.added.has(t)||n.maybeMoved.has(t)||e&&(n.added.has(e)||n.maybeMoved.has(e))||n.oldPrevious.set(t,e)};r.removedNodes.forEach(function(t){s(t,o),n.added.has(t)?n.added.delete(t):(n.removed.set(t,!0),n.maybeMoved.delete(t)),o=t}),s(r.nextSibling,o),r.addedNodes.forEach(function(t){n.removed.has(t)?(n.removed.delete(t),n.maybeMoved.set(t,!0)):n.added.set(t,!0)})}}}},t.prototype.wasReordered=function(t){if(!this.treeChanges.anyParentsChanged)return!1;this.processChildlistChanges();var e=t.parentNode,r=this.treeChanges.get(t);r&&r.oldParentNode&&(e=r.oldParentNode);var a=this.findChildlistChange(e);if(!a)return!1;if(a.moved)return a.moved.get(t);a.moved=new i;var n=new i;function o(t){if(!t)return!1;if(!a.maybeMoved.has(t))return!1;var e=a.moved.get(t);return void 0!==e?e:(n.has(t)?e=!0:(n.set(t,!0),e=function(t){if(u.has(t))return u.get(t);var e=t.previousSibling;for(;e&&(a.added.has(e)||o(e));)e=e.previousSibling;return u.set(t,e),e}(t)!==function t(e){var r=s.get(e);if(void 0!==r)return r;r=a.oldPrevious.get(e);for(;r&&(a.removed.has(r)||o(r));)r=t(r);void 0===r&&(r=e.previousSibling);s.set(e,r);return r}(t)),n.has(t)?(n.delete(t),a.moved.set(t,e)):e=a.moved.get(t),e)}var s=new i;var u=new i;return a.maybeMoved.keys().forEach(o),a.moved.get(t)},t}();e.MutationProjection=h;var c=function(){function t(t,e){var r=this;if(this.projection=t,this.added=[],this.removed=[],this.reparented=e.all||e.element||e.characterData?[]:void 0,this.reordered=e.all?[]:void 0,t.getChanged(this,e.elementFilter,e.characterData),e.all||e.attribute||e.attributeList){var a=e.attribute?[e.attribute]:e.attributeList,n=t.attributeChangedNodes(a);e.attribute?this.valueChanged=n[e.attribute]||[]:(this.attributeChanged=n,e.attributeList&&e.attributeList.forEach(function(t){r.attributeChanged.hasOwnProperty(t)||(r.attributeChanged[t]=[])}))}if(e.all||e.characterData){var i=t.getCharacterDataChanged();e.characterData?this.valueChanged=i:this.characterDataChanged=i}this.reordered&&(this.getOldPreviousSibling=t.getOldPreviousSibling.bind(t))}return t.prototype.getOldParentNode=function(t){return this.projection.getOldParentNode(t)},t.prototype.getOldAttribute=function(t,e){return this.projection.getOldAttribute(t,e)},t.prototype.getOldCharacterData=function(t){return this.projection.getOldCharacterData(t)},t.prototype.getOldPreviousSibling=function(t){return this.projection.getOldPreviousSibling(t)},t}();e.Summary=c;var l=/[a-zA-Z_]+/,d=/[a-zA-Z0-9_\-]+/;function f(t){return'"'+t.replace(/"/,'\\"')+'"'}var p=function(){function t(){}return t.prototype.matches=function(t){if(null===t)return!1;if(void 0===this.attrValue)return!0;if(!this.contains)return this.attrValue==t;for(var e=0,r=t.split(" ");e<r.length;e++){var a=r[e];if(this.attrValue===a)return!0}return!1},t.prototype.toString=function(){return"class"===this.attrName&&this.contains?"."+this.attrValue:"id"!==this.attrName||this.contains?this.contains?"["+this.attrName+"~="+f(this.attrValue)+"]":void 0!==this.attrValue&&null!==this.attrName?"["+this.attrName+"="+f(this.attrValue)+"]":"["+this.attrName+"]":"#"+this.attrValue},t}(),v=function(){function t(){this.uid=t.nextUid++,this.qualifiers=[]}var e;return Object.defineProperty(t.prototype,"caseInsensitiveTagName",{get:function(){return this.tagName.toUpperCase()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectorString",{get:function(){return this.tagName+this.qualifiers.join("")},enumerable:!0,configurable:!0}),t.prototype.isMatching=function(e){return e[t.matchesSelector](this.selectorString)},t.prototype.wasMatching=function(t,e,r){if(!e||!e.attributes)return r;var a=e.isCaseInsensitive?this.caseInsensitiveTagName:this.tagName;if("*"!==a&&a!==t.tagName)return!1;for(var n=[],i=!1,o=0,s=this.qualifiers;o<s.length;o++){var u=s[o],h=e.getAttributeOldValue(u.attrName);n.push(h),i=i||void 0!==h}if(!i)return r;for(var c=0;c<this.qualifiers.length;c++){var l=this.qualifiers[c];if(void 0===(h=n[c])&&(h=t.getAttribute(l.attrName)),!l.matches(h))return!1}return!0},t.prototype.matchabilityChange=function(t,e){var r=this.isMatching(t);return r?this.wasMatching(t,e,r)?a.STAYED_IN:a.ENTERED:this.wasMatching(t,e,r)?a.EXITED:a.STAYED_OUT},t.parseSelectors=function(e){var r,a,n=[];function i(){r&&(a&&(r.qualifiers.push(a),a=void 0),n.push(r)),r=new t}function o(){a&&r.qualifiers.push(a),a=new p}for(var s,u=/\s/,h="Invalid or unsupported selector syntax.",c=1,f=0;f<e.length;){var v=e[f++];switch(c){case 1:if(v.match(l)){i(),r.tagName=v,c=2;break}if("*"==v){i(),r.tagName="*",c=3;break}if("."==v){i(),o(),r.tagName="*",a.attrName="class",a.contains=!0,c=4;break}if("#"==v){i(),o(),r.tagName="*",a.attrName="id",c=4;break}if("["==v){i(),o(),r.tagName="*",a.attrName="",c=6;break}if(v.match(u))break;throw Error(h);case 2:if(v.match(d)){r.tagName+=v;break}if("."==v){o(),a.attrName="class",a.contains=!0,c=4;break}if("#"==v){o(),a.attrName="id",c=4;break}if("["==v){o(),a.attrName="",c=6;break}if(v.match(u)){c=14;break}if(","==v){c=1;break}throw Error(h);case 3:if("."==v){o(),a.attrName="class",a.contains=!0,c=4;break}if("#"==v){o(),a.attrName="id",c=4;break}if("["==v){o(),a.attrName="",c=6;break}if(v.match(u)){c=14;break}if(","==v){c=1;break}throw Error(h);case 4:if(v.match(l)){a.attrValue=v,c=5;break}throw Error(h);case 5:if(v.match(d)){a.attrValue+=v;break}if("."==v){o(),a.attrName="class",a.contains=!0,c=4;break}if("#"==v){o(),a.attrName="id",c=4;break}if("["==v){o(),c=6;break}if(v.match(u)){c=14;break}if(","==v){c=1;break}throw Error(h);case 6:if(v.match(l)){a.attrName=v,c=7;break}if(v.match(u))break;throw Error(h);case 7:if(v.match(d)){a.attrName+=v;break}if(v.match(u)){c=8;break}if("~"==v){a.contains=!0,c=9;break}if("="==v){a.attrValue="",c=11;break}if("]"==v){c=3;break}throw Error(h);case 8:if("~"==v){a.contains=!0,c=9;break}if("="==v){a.attrValue="",c=11;break}if("]"==v){c=3;break}if(v.match(u))break;throw Error(h);case 9:if("="==v){a.attrValue="",c=11;break}throw Error(h);case 10:if("]"==v){c=3;break}if(v.match(u))break;throw Error(h);case 11:if(v.match(u))break;if('"'==v||"'"==v){s=v,c=13;break}a.attrValue+=v,c=12;break;case 12:if(v.match(u)){c=10;break}if("]"==v){c=3;break}if("'"==v||'"'==v)throw Error(h);a.attrValue+=v;break;case 13:if(v==s){c=10;break}a.attrValue+=v;break;case 14:if(v.match(u))break;if(","==v){c=1;break}throw Error(h)}}switch(c){case 1:case 2:case 3:case 5:case 14:i();break;default:throw Error(h)}if(!n.length)throw Error(h);return n},t.nextUid=1,t.matchesSelector="function"==typeof(e=document.createElement("div")).webkitMatchesSelector?"webkitMatchesSelector":"function"==typeof e.mozMatchesSelector?"mozMatchesSelector":"function"==typeof e.msMatchesSelector?"msMatchesSelector":"matchesSelector",t}(),b=/^([a-zA-Z:_]+[a-zA-Z0-9_\-:\.]*)$/;function g(t){if("string"!=typeof t)throw Error("Invalid request opion. attribute must be a non-zero length string.");if(!(t=t.trim()))throw Error("Invalid request opion. attribute must be a non-zero length string.");if(!t.match(b))throw Error("Invalid request option. invalid attribute name: "+t);return t}function y(t){if(!t.trim().length)throw Error("Invalid request option: elementAttributes must contain at least one attribute.");for(var e={},r={},a=0,n=t.split(/\s+/);a<n.length;a++){if(i=n[a]){var i,o=(i=g(i)).toLowerCase();if(e[o])throw Error("Invalid request option: observing multiple case variations of the same attribute is not supported.");r[i]=!0,e[o]=!0}}return Object.keys(r)}var m=function(){function t(e){var r=this;this.connected=!1,this.options=t.validateOptions(e),this.observerOptions=t.createObserverOptions(this.options.queries),this.root=this.options.rootNode,this.callback=this.options.callback,this.mutations=[],this.elementFilter=Array.prototype.concat.apply([],this.options.queries.map(function(t){return t.elementFilter?t.elementFilter:[]})),this.elementFilter.length||(this.elementFilter=void 0),this.calcReordered=this.options.queries.some(function(t){return t.all}),this.queryValidators=[],t.createQueryValidator&&(this.queryValidators=this.options.queries.map(function(e){return t.createQueryValidator(r.root,e)})),this.observer=new MutationObserver(function(t){r.observerCallback(t)}),this.reconnect()}return t.createObserverOptions=function(t){var e,r={childList:!0,subtree:!0};function a(t){r.attributes&&!e||(r.attributes=!0,r.attributeOldValue=!0,t?(e=e||{},t.forEach(function(t){e[t]=!0,e[t.toLowerCase()]=!0})):e=void 0)}return t.forEach(function(t){if(t.characterData)return r.characterData=!0,void(r.characterDataOldValue=!0);if(t.all)return a(),r.characterData=!0,void(r.characterDataOldValue=!0);if(t.attribute)a([t.attribute.trim()]);else{var e=function(t){var e={};return t.forEach(function(t){t.qualifiers.forEach(function(t){e[t.attrName]=!0})}),Object.keys(e)}(t.elementFilter).concat(t.attributeList||[]);e.length&&a(e)}}),e&&(r.attributeFilter=Object.keys(e)),r},t.validateOptions=function(e){for(var r in e)if(!(r in t.optionKeys))throw Error("Invalid option: "+r);if(e.callback&&"function"!=typeof e.callback)throw Error("Invalid options: callback is optional and must be a function");if(!e.queries||!e.queries.length)throw Error("Invalid options: queries must contain at least one query request object.");for(var a={callback:e.callback,rootNode:e.rootNode||document,observeOwnChanges:!!e.observeOwnChanges,oldPreviousSibling:!!e.oldPreviousSibling,queries:[]},n=0,i=e.queries;n<i.length;n++){var o=i[n];if(o.all){if(Object.keys(o).length>1)throw Error("Invalid request option. all has no options.");a.queries.push({all:!0})}else if("attribute"in o){if((u={attribute:g(o.attribute)}).elementFilter=v.parseSelectors("*["+u.attribute+"]"),Object.keys(o).length>1)throw Error("Invalid request option. attribute has no options.");a.queries.push(u)}else if("element"in o){var s=Object.keys(o).length,u={element:o.element,elementFilter:v.parseSelectors(o.element)};if(o.hasOwnProperty("elementAttributes")&&(u.attributeList=y(o.elementAttributes),s--),s>1)throw Error("Invalid request option. element only allows elementAttributes option.");a.queries.push(u)}else{if(!o.characterData)throw Error("Invalid request option. Unknown query request.");if(Object.keys(o).length>1)throw Error("Invalid request option. characterData has no options.");a.queries.push({characterData:!0})}}return a},t.prototype.createSummaries=function(){var t=this.resetMutations();if(!t.length)return[];for(var e=new h(this.root,t,this.elementFilter,this.calcReordered,this.options.oldPreviousSibling),r=[],a=0,n=this.options.queries;a<n.length;a++){var i=n[a];r.push(new c(e,i))}return r},t.prototype.checkpointQueryValidators=function(){this.queryValidators.forEach(function(t){t&&t.recordPreviousState()})},t.prototype.runQueryValidators=function(t){this.queryValidators.forEach(function(e,r){e&&e.validate(t[r])})},t.prototype.changesToReport=function(t){return t.some(function(t){if(["added","removed","reordered","reparented","valueChanged","characterDataChanged"].some(function(e){return t[e]&&t[e].length}))return!0;if(t.attributeChanged&&Object.keys(t.attributeChanged).some(function(e){return!!t.attributeChanged[e].length}))return!0;return!1})},t.prototype.observerCallback=function(t){if(this.addMutations(t),this.callback){this.options.observeOwnChanges||this.observer.disconnect();var e=this.createSummaries();this.runQueryValidators(e),this.options.observeOwnChanges&&this.checkpointQueryValidators(),this.changesToReport(e)&&this.callback(e),!this.options.observeOwnChanges&&this.connected&&(this.checkpointQueryValidators(),this.observer.observe(this.root,this.observerOptions))}},t.prototype.reconnect=function(){if(this.connected)throw Error("Already connected");this.observer.observe(this.root,this.observerOptions),this.connected=!0,this.checkpointQueryValidators()},t.prototype.takeSummaries=function(){if(!this.connected)throw Error("Not connected");this.addMutations(this.observer.takeRecords());var t=this.createSummaries();return this.changesToReport(t)?t:void 0},t.prototype.disconnect=function(){var t=this.takeSummaries();return this.observer.disconnect(),this.connected=!1,t},t.prototype.addMutations=function(t){var e;(e=this.mutations).push.apply(e,t)},t.prototype.resetMutations=function(){var t=this.mutations;return this.mutations=[],t},t.NodeMap=i,t.parseElementFilter=v.parseSelectors,t.optionKeys={callback:!0,queries:!0,rootNode:!0,oldPreviousSibling:!0,observeOwnChanges:!0},t}();e.MutationSummary=m},5:function(t,e,r){"use strict";r.r(e),r.d(e,"__extends",function(){return n}),r.d(e,"__assign",function(){return i}),r.d(e,"__rest",function(){return o}),r.d(e,"__decorate",function(){return s}),r.d(e,"__param",function(){return u}),r.d(e,"__metadata",function(){return h}),r.d(e,"__awaiter",function(){return c}),r.d(e,"__generator",function(){return l}),r.d(e,"__exportStar",function(){return d}),r.d(e,"__values",function(){return f}),r.d(e,"__read",function(){return p}),r.d(e,"__spread",function(){return v}),r.d(e,"__await",function(){return b}),r.d(e,"__asyncGenerator",function(){return g}),r.d(e,"__asyncDelegator",function(){return y}),r.d(e,"__asyncValues",function(){return m}),r.d(e,"__makeTemplateObject",function(){return E}),r.d(e,"__importStar",function(){return C}),r.d(e,"__importDefault",function(){return N});
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
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
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function n(t,e){function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return(i=Object.assign||function(t){for(var e,r=1,a=arguments.length;r<a;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};function o(t,e){var r={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(r[a]=t[a]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(a=Object.getOwnPropertySymbols(t);n<a.length;n++)e.indexOf(a[n])<0&&(r[a[n]]=t[a[n]])}return r}function s(t,e,r,a){var n,i=arguments.length,o=i<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,r,a);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(o=(i<3?n(o):i>3?n(e,r,o):n(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o}function u(t,e){return function(r,a){e(r,a,t)}}function h(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function c(t,e,r,a){return new(r||(r=Promise))(function(n,i){function o(t){try{u(a.next(t))}catch(t){i(t)}}function s(t){try{u(a.throw(t))}catch(t){i(t)}}function u(t){t.done?n(t.value):new r(function(e){e(t.value)}).then(o,s)}u((a=a.apply(t,e||[])).next())})}function l(t,e){var r,a,n,i,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,a&&(n=2&i[0]?a.return:i[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,i[1])).done)return n;switch(a=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,a=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(n=(n=o.trys).length>0&&n[n.length-1])&&(6===i[0]||2===i[0])){o=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){o.label=i[1];break}if(6===i[0]&&o.label<n[1]){o.label=n[1],n=i;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(i);break}n[2]&&o.ops.pop(),o.trys.pop();continue}i=e.call(t,o)}catch(t){i=[6,t],a=0}finally{r=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function d(t,e){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}function f(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}function p(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var a,n,i=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(a=i.next()).done;)o.push(a.value)}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return o}function v(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(p(arguments[e]));return t}function b(t){return this instanceof b?(this.v=t,this):new b(t)}function g(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a,n=r.apply(t,e||[]),i=[];return a={},o("next"),o("throw"),o("return"),a[Symbol.asyncIterator]=function(){return this},a;function o(t){n[t]&&(a[t]=function(e){return new Promise(function(r,a){i.push([t,e,r,a])>1||s(t,e)})})}function s(t,e){try{(r=n[t](e)).value instanceof b?Promise.resolve(r.value.v).then(u,h):c(i[0][2],r)}catch(t){c(i[0][3],t)}var r}function u(t){s("next",t)}function h(t){s("throw",t)}function c(t,e){t(e),i.shift(),i.length&&s(i[0][0],i[0][1])}}function y(t){var e,r;return e={},a("next"),a("throw",function(t){throw t}),a("return"),e[Symbol.iterator]=function(){return this},e;function a(a,n){e[a]=t[a]?function(e){return(r=!r)?{value:b(t[a](e)),done:"return"===a}:n?n(e):e}:n}}function m(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=f(t),e={},a("next"),a("throw"),a("return"),e[Symbol.asyncIterator]=function(){return this},e);function a(r){e[r]=t[r]&&function(e){return new Promise(function(a,n){(function(t,e,r,a){Promise.resolve(a).then(function(e){t({value:e,done:r})},e)})(a,n,(e=t[r](e)).done,e.value)})}}}function E(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function C(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function N(t){return t&&t.__esModule?t:{default:t}}}})); | 1,855.375 | 24,069 | 0.725999 |
2965d80ded769d3668b2a1075ea958420c373ba5 | 2,133 | js | JavaScript | src/screens/landing.js | gradam/portfolio_v2 | 8f92939de200198a2da19c399b3a99da938b31b2 | [
"MIT"
] | null | null | null | src/screens/landing.js | gradam/portfolio_v2 | 8f92939de200198a2da19c399b3a99da938b31b2 | [
"MIT"
] | null | null | null | src/screens/landing.js | gradam/portfolio_v2 | 8f92939de200198a2da19c399b3a99da938b31b2 | [
"MIT"
] | null | null | null | import React, { useState } from 'react'
import styled from 'styled-components'
import Typist from 'react-typist'
import Section from '@components/section'
import { OrangeText, WhiteText } from '@styles/span'
import Button from '@styles/button'
import media from '@styles/media'
import { pxToRem } from '@utils/css'
import 'react-typist/dist/Typist.css'
const LandingSection = styled(Section)`
background: ${props => props.theme.colors.black};
width: 100vw;
min-height: 100vh;
display: flex;
align-content: center;
justify-content: center;
flex-direction: column;
.Typist {
display: flex;
align-content: center;
justify-content: center;
flex-direction: column;
}
`
const TextContainer = styled.div`
font-weight: 700;
text-align: center;
margin-left: 50px;
margin-right: 50px;
${media.lessThan('xsmall')`
font-size: ${pxToRem(40)};
padding-top: 20px;
`}
${media.between('xsmall', 'small')`
font-size: ${pxToRem(56)};
padding-top: 30px;
`}
${media.between('small', 'medium')`
font-size: ${pxToRem(80)};
padding-top: 40px;
`}
${media.greaterThan('medium')`
font-size: ${pxToRem(80)};
padding-top: 50px;
`}
`
const LandingButton = styled(Button)`
color: ${props => props.theme.colors.white};
align-self: center;
`
const Landing = () => {
const [hideButton, setHideButton] = useState(false)
return (
<LandingSection sectionId="landing">
<Typist
cursor={{ show: false }}
onTypingDone={() => {
setTimeout(() => setHideButton(true), 1000)
}}
>
<TextContainer>
<WhiteText>HI!, I AM </WhiteText>
<OrangeText>JAKUB</OrangeText>
<Typist.Backspace count={'HI!, I AM JAKUB'.length} delay={1000} />
<WhiteText>ARE YOU LOOKING FOR A FULL STACK </WhiteText>
<br />
<OrangeText>DEVELOPER</OrangeText>
<WhiteText>?</WhiteText>
</TextContainer>
</Typist>
<LandingButton className={`full ${hideButton && 'hide'}`}>GET TO KNOW ME</LandingButton>
</LandingSection>
)
}
export default Landing
| 23.966292 | 94 | 0.62963 |
296680a3e51170358230b048f0cef3c399f9a6f7 | 756 | js | JavaScript | src/__mocks__/filehelpers.js | jadesrochers/filereworker | 59afd2bd155548e760dce9f24388d593b027eb3f | [
"MIT"
] | null | null | null | src/__mocks__/filehelpers.js | jadesrochers/filereworker | 59afd2bd155548e760dce9f24388d593b027eb3f | [
"MIT"
] | 1 | 2021-05-08T08:05:32.000Z | 2021-05-08T08:05:32.000Z | src/__mocks__/filehelpers.js | jadesrochers/filereworker | 59afd2bd155548e760dce9f24388d593b027eb3f | [
"MIT"
] | null | null | null | // /__mocks__/filehelpers.js
const fh = jest.requireActual('../filehelpers')
const mockfs = require('mock-fs')
randRows = (rows) => {
var str = ''
for(var i = 0; i < rows; i++){
str = str.concat(Math.random() + '\n')
}
return str
}
mockfs({
'/fake/path/dir': {
'fakefile1.txt': 'Fake file 1 contents',
'fakefile2.txt': 'Another fake file',
'fakefile3.txt': 'The last fake file in this location',
},
'/not/a/real': {
'file.csv': randRows(100000)
},
'/fake/splits': {
'notsplit.txt': '',
'fake_Split_01': 'split1',
'fake_Split_02': 'split2',
'fake_Split_05': 'split5',
'fake_Split_23': 'split23',
'otherfile.csv': '',
'source.json': '',
}
})
fh.mockfs = mockfs
module.exports = fh
| 20.432432 | 59 | 0.578042 |
296801961e02a63c8fd28bcfc052f0b77fc9ba06 | 2,921 | js | JavaScript | lib/revisionPolicy.js | gwicke/restbase-cassandra | f405c4a7d5b1fed7310a7025a7f63604c1617815 | [
"Apache-2.0"
] | null | null | null | lib/revisionPolicy.js | gwicke/restbase-cassandra | f405c4a7d5b1fed7310a7025a7f63604c1617815 | [
"Apache-2.0"
] | null | null | null | lib/revisionPolicy.js | gwicke/restbase-cassandra | f405c4a7d5b1fed7310a7025a7f63604c1617815 | [
"Apache-2.0"
] | null | null | null | "use strict";
const dbu = require('./dbutils');
const P = require('bluebird');
/**
* Applies a revision retention policy to a sequence of rows.
*
* @param {object} db; instance of DB
* @param {object} request; request to use as baseline
* @param {object} schema; the table schema
* @param {Date} reqTime; the request time derived from request tid
*/
class RevisionPolicyManager {
constructor(db, request, schema, reqTime) {
this.db = db;
this.schema = schema;
this.policy = schema.revisionRetentionPolicy;
this.request = dbu.makeRawRequest(request, { ttl: this.policy.grace_ttl });
this.noop = this.policy.type === 'all' ||
(this.policy.type === 'latest' && this.policy.count === 0);
this.count = 0;
if (this.policy.type === 'interval') {
const interval = this.policy.interval * 1000;
this.intervalLimitTime = reqTime - reqTime % interval;
} else {
this.intervalLimitTime = null;
}
}
_setTtl(item) {
this.request.query.attributes = item;
const query = dbu.buildPutQuery(this.request, true);
const queryOptions = { consistency: this.request.consistency, prepare: true };
return this.db.client.execute(query.cql, query.params, queryOptions)
.catch((e) => {
this.db.log('error/table/cassandra/revisionRetentionPolicyUpdate', e);
});
}
/**
* Process one row in the sequence.
*
* @param {object} row; a row object.
* @return a promise that resolves when the corresponding update is complete.
*/
handleRow(row) {
if (this.noop) {
return P.resolve();
}
if (this.count < this.policy.count) {
this.count++;
return P.resolve();
}
if (this.policy.type === 'latest' || this.policy.type === 'latest_hash') {
// We want to update the current iteration row, so what needs to
// be done is to resend the same row we have received here with a
// new timestamp. Modifying this.request in-place is alright since
// the requests are sequentially sent, and once executed, the request
// object itthis is not needed. Also, note that dbu.makeRawRequest()
// creates a deep clone of this.request.query, so we are sure not to
// modify the original incoming request
if (row._ttl && row._ttl <= this.policy.grace_ttl) {
return P.resolve();
}
return this._setTtl(row);
} else if (this.policy.type === 'interval') {
if (row[this.schema.tid].getDate() >= this.intervalLimitTime && !row._ttl) {
return this._setTtl(row);
} else {
return P.resolve();
}
}
}
}
module.exports = {
RevisionPolicyManager
};
| 34.77381 | 88 | 0.581308 |
2968603bffc70ff2c32e702c1ccfecca1986d848 | 2,107 | js | JavaScript | src/assets/services/service.js | RAAMENN/vue-element-demo | 3cf31ee841ab794920f03936a323d59f57af3a25 | [
"MIT"
] | 1 | 2020-06-12T07:55:52.000Z | 2020-06-12T07:55:52.000Z | src/assets/services/service.js | RAAMENN/vue-element-demo | 3cf31ee841ab794920f03936a323d59f57af3a25 | [
"MIT"
] | 10 | 2021-03-02T01:04:52.000Z | 2022-03-08T23:14:15.000Z | src/assets/services/service.js | RAAMENN/vue-element-demo | 3cf31ee841ab794920f03936a323d59f57af3a25 | [
"MIT"
] | null | null | null | import axios from 'axios'
// import { BASE_URL } from "@/assets/consts/urls"
let services
let uploadServices
let downloadServices
let publicParams = {}
function httpService(service, contentType) {
service.interceptors.request.use(
request => {
if (request.method === 'get') {
request.params = {
// 公用参数
...publicParams,
...request.params,
// 当前时间用来去除ie缓存
t: Date.now()
}
}
if (
request.method === 'post' &&
contentType !== 'multipart/form-data;charset=UTF-8'
) {
request.data = {
// 公用参数
...publicParams,
...request.data,
// 当前时间用来去除ie缓存
t: Date.now()
}
}
return request
},
error => {
console.error('Request Error: ' + error)
return Promise.reject(error)
}
)
}
/**
*
* @param {axios配置文件} axiosConfig
* @param {接口地址} baseUrl
* @param {请求头部参数} headers
*/
function createService(axiosConfig = {}, baseUrl = '/api', headers = {}) {
let params = {
baseURL: baseUrl,
timeout: 60000,
header: {
['X-Requested-With']: 'XMLHttpRequest',
...publicParams,
...headers
},
...axiosConfig
}
const service = axios.create(params)
httpService(service, headers['Content-Type'])
return service
}
/**
*
* @param {接口需要传递的公用参数} params
*/
function initPublicParams(params = {}) {
if (process.env.NODE_ENV === 'development') {
let paramsInStorage = localStorage.getItem('accountParams')
if (paramsInStorage) {
params = JSON.parse(paramsInStorage)
}
}
publicParams = params
services = createService()
uploadServices = createService({}, undefined, {
'Content-Type': 'multipart/form-data;charset=UTF-8'
})
downloadServices = createService({ responseType: 'blob' })
}
/**
*
* 带进度条的下载请求
*/
function downloadServicesWithProgress(payload) {
return createService({
responseType: 'blob',
...payload
})
}
export {
services,
downloadServices,
downloadServicesWithProgress,
initPublicParams,
uploadServices
}
| 21.5 | 74 | 0.598956 |
296870e34f597ea16b2cdefb66aebf72837a2e8c | 1,537 | js | JavaScript | models/qrcode/bitmap.js | Refuel-ZL/furniture | b112a9d3f91bb6284bc57b793d6682129db7bca9 | [
"MIT"
] | null | null | null | models/qrcode/bitmap.js | Refuel-ZL/furniture | b112a9d3f91bb6284bc57b793d6682129db7bca9 | [
"MIT"
] | null | null | null | models/qrcode/bitmap.js | Refuel-ZL/furniture | b112a9d3f91bb6284bc57b793d6682129db7bca9 | [
"MIT"
] | 1 | 2019-03-23T00:51:29.000Z | 2019-03-23T00:51:29.000Z | "use strict";
var uint32 = require('./uint32');
var Context = require('./context');
class Bitmap {
constructor(w,h,options) {
this.width = Math.floor(w);
this.height = Math.floor(h);
this.data = Buffer.alloc(w*h*4);
var fillval = 0x000000FF;
for(var j=0; j<h; j++) {
for (var i = 0; i < w; i++) {
this.setPixelRGBA(i, j, fillval);
}
}
}
calculateIndex (x,y) {
x = Math.floor(x);
y = Math.floor(y);
if (x<0 || y<0 || x >= this.width || y >= this.height) return 0;
return (this.width*y+x)*4;
}
setPixelRGBA(x,y,rgba) {
let i = this.calculateIndex(x, y);
const bytes = uint32.getBytesBigEndian(rgba);
this.data[i+0] = bytes[0];
this.data[i+1] = bytes[1];
this.data[i+2] = bytes[2];
this.data[i+3] = bytes[3];
}
setPixelRGBA_i(x,y,r,g,b,a) {
let i = this.calculateIndex(x, y);
this.data[i+0] = r;
this.data[i+1] = g;
this.data[i+2] = b;
this.data[i+3] = a;
}
getPixelRGBA(x,y) {
let i = this.calculateIndex(x, y);
return uint32.fromBytesBigEndian(
this.data[i+0],
this.data[i+1],
this.data[i+2],
this.data[i+3]);
}
getPixelRGBA_separate(x,y) {
var i = this.calculateIndex(x,y);
return this.data.slice(i,i+4);
}
getContext(type) {
return new Context(this);
}
}
module.exports = Bitmap;
| 26.5 | 72 | 0.497723 |
2968b2afe3e99f19b99e49e959dab1a0091cf764 | 99 | js | JavaScript | src/components/Sidebar/Helpers/index.js | JuananRodriguez/ninaleal-portfolio | c08c46178c3a84df1bb4f8208f48f369275a2596 | [
"MIT"
] | null | null | null | src/components/Sidebar/Helpers/index.js | JuananRodriguez/ninaleal-portfolio | c08c46178c3a84df1bb4f8208f48f369275a2596 | [
"MIT"
] | null | null | null | src/components/Sidebar/Helpers/index.js | JuananRodriguez/ninaleal-portfolio | c08c46178c3a84df1bb4f8208f48f369275a2596 | [
"MIT"
] | null | null | null | import extractCommonClasses from './extractCommonClasses.js';
export {
extractCommonClasses
} | 16.5 | 61 | 0.787879 |
296a0056d5f03bb4321bc7a6a2b597077be85406 | 5,839 | js | JavaScript | src/components/Board.js | Mannydheer/Tic-Tac-Toe | d184f1a17600a828312c501e4c17be72215d88f7 | [
"MIT"
] | null | null | null | src/components/Board.js | Mannydheer/Tic-Tac-Toe | d184f1a17600a828312c501e4c17be72215d88f7 | [
"MIT"
] | 5 | 2021-03-10T11:39:39.000Z | 2022-02-27T01:31:10.000Z | src/components/Board.js | Mannydheer/Tic-Tac-Toe | d184f1a17600a828312c501e4c17be72215d88f7 | [
"MIT"
] | null | null | null | import React from 'react';
import styled from 'styled-components';
import SimpleAlerts from '../Alert';
import { useHistory } from 'react-router-dom';
export const Board = React.createContext();
let o = '👾';
let x = null;
const InitialData = {
box0: { x, o },
box1: { x, o },
box2: { x, o },
box3: { x, o },
box4: { x, o },
box5: { x, o },
box6: { x, o },
box7: { x, o },
box8: { x, o },
}
const reducer = (state, action) => {
switch (action.type) {
case 'change-click-me': {
state[action.box].selected = action.letter;
state[action.box].isClicked = true;
return {
...state,
}
}
}
}
const BoardProvider = ({ children }) => {
//useState('Z') is the initial value of x... also the initial State.
const [state, dispatch] = React.useReducer(reducer, { ...InitialData })
const [turn, setTurn] = React.useState(true);
const [alert, setAlert] = React.useState(false);
const [draw, setDraw] = React.useState(false);
const [visible, setVisible] = React.useState(false);
const [character, setCharacter] = React.useState(null)
const visibility = visible ? 'visible' : 'hidden';
console.log(state);
let x = character;
console.log(x, ' X INSIDE BOARD')
React.useEffect(() => {
if (state.box0.selected === o && state.box1.selected === o && state.box2.selected === o || state.box0.selected === x && state.box1.selected === x && state.box2.selected === x) {
handleWinner(turn, setVisible, visible, setAlert);
}
else if (state.box3.selected === o && state.box4.selected === o && state.box5.selected === o || state.box3.selected === x && state.box4.selected === x && state.box5.selected === x) {
handleWinner(turn, setVisible, visible, setAlert);
}
else if (state.box6.selected === o && state.box7.selected === o && state.box8.selected === o || state.box6.selected === x && state.box7.selected === x && state.box8.selected === x) {
handleWinner(turn, setVisible, visible, setAlert);
}
//horizontal
else if (state.box0.selected === o && state.box3.selected === o && state.box6.selected === o || state.box0.selected === x && state.box3.selected === x && state.box6.selected === x) {
handleWinner(turn, setVisible, visible, setAlert);
}
else if (state.box1.selected === o && state.box4.selected === o && state.box7.selected === o || state.box1.selected === x && state.box4.selected === x && state.box7.selected === x) {
handleWinner(turn, setVisible, visible, setAlert);
}
else if (state.box2.selected === o && state.box5.selected === o && state.box8.selected === o || state.box2.selected === x && state.box5.selected === x && state.box8.selected === x) {
handleWinner(turn, setVisible, visible, setAlert);
}
//diagonal
else if (state.box0.selected === o && state.box4.selected === o && state.box8.selected === o || state.box0.selected === x && state.box4.selected === x && state.box8.selected === x) {
handleWinner(turn, setVisible, visible, setAlert);
}
else if (state.box2.selected === o && state.box4.selected === o && state.box6.selected === o || state.box2.selected === x && state.box4.selected === x && state.box6.selected === x) {
handleWinner(turn, setVisible, visible, setAlert);
}
else {
let isClickedArray = Object.keys(state)
let bool = isClickedArray.every(element => state[element].isClicked === true)
if (bool) {
setDraw(true)
setVisible(true)
}
}
}, [state])
const clickMe = (box) => {
dispatch({
type: 'change-click-me',
...box
})
}
//handlers.
const handleCharacter = (e) => {
e.preventDefault();
let selectedCharacter = e.target.innerHTML
setCharacter(selectedCharacter);
}
const handleWinner = () => {
if (turn) {
setVisible(true)
setAlert(true)
} else {
setVisible(true)
setAlert(true)
}
}
const handleRestart = () => {
window.location.pathname = '/'
}
//render
return (
<Board.Provider value={
{
state,
actions: {
setTurn,
clickMe,
handleRestart,
handleCharacter,
turn,
x,
o,
alert
}
}
}>
{children}
<Reset>
{alert ? <div><SimpleAlerts x={x} o={o} turn={turn} alert={alert}></SimpleAlerts></div> : <div> </div>}
{draw ? <div><SimpleAlerts x={x} o={o} draw={draw} alert={alert}></SimpleAlerts></div> : <div> </div>}
<RestartDiv>
<RestartButton
onClick={() => {
handleRestart();
}}>
RESTART
</RestartButton>
</RestartDiv>
</Reset>
</Board.Provider>
)
}
export default BoardProvider;
//STYLING.
const RestartButton = styled.button`
border-radius: 25px;
font-size: 2em;
color: pink;
font-family: 'Abril Fatface', cursive;
transition: all 0.2s ease;
margin: auto;
&:hover {
cursor: pointer;
background-color: pink;
color: white;
}
`
const RestartDiv = styled.div`
display:flex;
justify-content: center;
`
const Reset = styled.div`
@media only screen and (max-width: 450px) {
margin-top: 120px;
}
`
| 30.731579 | 190 | 0.525946 |
296c48603dc94b04e8f54b50e05747a249b22cd7 | 1,194 | js | JavaScript | run/loaders/glslify.js | keeffEoghan/tendrils | faa3f27900e318d727db6d8fa8fc984779cda464 | [
"MIT"
] | 24 | 2018-04-01T00:47:44.000Z | 2021-11-30T15:35:29.000Z | master/keeffeoghan.github.io-master/keeffeoghan.github.io-master/run/loaders/glslify.js | AlexRogalskiy/DevArtifacts | 931aabb8cbf27656151c54856eb2ea7d1153203a | [
"MIT"
] | 371 | 2020-03-04T21:51:56.000Z | 2022-03-31T20:59:11.000Z | run/loaders/glslify.js | keeffEoghan/tendrils | faa3f27900e318d727db6d8fa8fc984779cda464 | [
"MIT"
] | 4 | 2018-04-01T00:48:05.000Z | 2022-03-14T23:41:21.000Z | /**
* Copied wholesale from `glslify-loader` - that package had a really out of
* date version of `glslify` which was causing problems.
*/
const glslify = require('glslify');
const path = require('path');
const readJSON = require('read-package-json');
let queue = [];
let config = null;
function load(source, callback) {
const basedir = path.dirname(this.resourcePath);
glslify.bundle(source, Object.assign({
inline: true,
basedir
},
config.glslify),
(err, src, files) => {
if(files) {
files.forEach((file) => this.addDependency(file));
}
return callback(err, src);
});
}
readJSON('package.json', console.warn, (e, data) => {
if(e) {
console.error(e);
}
else {
config = data;
while(queue.length) {
queue.pop()();
}
}
});
module.exports = function(source) {
const callback = this.async();
const go = load.bind(this, source, callback);
this.cacheable(true);
if(config) {
go();
}
else {
queue.push(go);
}
};
| 21.321429 | 76 | 0.51675 |
296d212fd3087e146ef886e86d1cb6db1134b859 | 5,489 | js | JavaScript | src/main/webapp/scripts/tabs/controller/tabsCtrl.js | DataScientists/NodeCode4Financials | f8f50caa1297df950c5af028893c7fe124d6550b | [
"MIT"
] | null | null | null | src/main/webapp/scripts/tabs/controller/tabsCtrl.js | DataScientists/NodeCode4Financials | f8f50caa1297df950c5af028893c7fe124d6550b | [
"MIT"
] | 2 | 2021-12-14T20:39:10.000Z | 2021-12-14T21:24:33.000Z | src/main/webapp/scripts/tabs/controller/tabsCtrl.js | DataScientists/NodeCode4Financials | f8f50caa1297df950c5af028893c7fe124d6550b | [
"MIT"
] | null | null | null | (function() {
angular.module("nodeCodeApp.Tabs").controller("TabsCtrl", TabsCtrl);
TabsCtrl.$inject = ['$scope', '$state', '$rootScope', '$log', '$stickyState', 'AuthenticationService'];
function TabsCtrl($scope, $state, $rootScope, $log, $stickyState, auth) {
$scope.loading = false;
$scope.tabOptions = [];
if (auth.isLoggedIn() && auth.userHasPermission(['USER','ADMIN'])) {
$scope.tabOptions.push({
state: "tabs.nodes",
data: ""
});
}
if (auth.isLoggedIn() && auth.userHasPermission(['USER','ADMIN'])) {
$scope.tabOptions.push({
state: "tabs.files",
data: ""
});
}
if (auth.isLoggedIn() && auth.userHasPermission(['ADMIN'])) {
$scope.tabOptions.push({
state: "tabs.admin",
data: ""
});
}
//
// if (auth.isLoggedIn() && auth.userHasPermission(['ADMIN'])) {
// $scope.tabOptions.push({
// state: "tabs.jmx",
// data: ""
// });
// }
//
$scope.$watch('selectedIndex', function(current, old) {
var state = null;
var data = null;
if ($scope.tabOptions[current]) {
if ($scope.tabOptions[current].state) {
$log.info("Navigating to " + $scope.tabOptions[current].state);
state = $scope.tabOptions[current].state;
} else {
var msg = "No state in $scope.$watch - selectedIndex";
alert(msg);
console.error(msg);
}
if ($scope.tabOptions[current].data) {
data = $scope.tabOptions[current].data;
}
} else {
var msg = "No tabOptions in $scope.$watch - selectedIndex";
alert(msg);
console.error(msg);
}
$log.info("going to state " + state);
$state.go(state, data);
});
var tabs = [];
tabs.selected = null;
tabs.previous = null;
if (auth.isLoggedIn() && auth.userHasPermission(['USER', 'ADMIN'])) {
tabs.push({
title: 'DMRS',
viewName: 'nodes@tabs'
});
}
if (auth.isLoggedIn() && auth.userHasPermission(['USER', 'ADMIN'])) {
tabs.push({
title: 'Files',
viewName: 'files@tabs'
});
}
if (auth.isLoggedIn() && auth.userHasPermission(['ADMIN'])) {
tabs.push({
title: 'Admin',
viewName: 'admin@tabs'
});
}
// if (auth.isLoggedIn() && auth.userHasPermission(['ADMIN'])) {
// tabs.push({
// title: 'JMeter',
// viewName: 'jmx@tabs'
// });
// }
$scope.tabs = tabs;
$scope.selectedIndex = 0;
$scope.addNewTab = function(row) {
tabs.push({
title: row.name,
viewName: 'new@tabs',
canClose: true,
disabled: false
});
$scope.tabOptions.push({
state: "tabs.new",
data: {
row: row.idNode
}
});
$rootScope.tabsLoading = true;
safeDigest($rootScope.tabsLoading);
};
$rootScope.addErrorTab = function(error) {
var tabTitle = "Error!";
var state = "tabs.error";
$stickyState.reset(state);
tabs.push({
title: tabTitle,
viewName: 'error@tabs',
canClose: true,
disabled: false
});
$scope.tabOptions.push({
state: state,
data: {
error: error
}
});
$rootScope.tabsLoading = false;
safeDigest($rootScope.tabsLoading);
};
$scope.removeTab = function(tab) {
var index = tabs.indexOf(tab);
tabs.splice(index, 1);
$scope.tabOptions.splice(index, 1);
};
$scope.turnOffProgressBar = function turnOffProgressBar() {
$scope.loading = false;
return 'Done';
}
$scope.tabMenu = function(tab) {
if (tabs.indexOf(tab) > 1) {
return [
['Close Tab', function(tab) {
$scope.removeTab(tab);
}]
]
} else {
return [];
}
}
function checkIfTabIsOpen(tabs, title) {
var openedTab = false;
_.find(tabs, function(el, ind) {
if (el.title === title) {
$scope.selectedIndex = ind;
safeDigest($scope.selectedIndex);
openedTab = true;
}
});
return openedTab;
}
var safeDigest = function(obj) {
if (!obj.$$phase) {
try {
obj.$digest();
} catch (e) {}
}
}
}
})();
| 30.664804 | 107 | 0.411186 |
296e4864b233495d0b9e82663118d5608ce009ef | 6,267 | js | JavaScript | js/tooltips.js | neherlab/multiflu | 995b0ee8b8704f3a9be66fb5f5b54c5e749528af | [
"MIT"
] | 1 | 2020-03-25T06:58:39.000Z | 2020-03-25T06:58:39.000Z | js/tooltips.js | neherlab/multiflu | 995b0ee8b8704f3a9be66fb5f5b54c5e749528af | [
"MIT"
] | 1 | 2018-12-19T03:33:09.000Z | 2018-12-19T03:33:09.000Z | js/tooltips.js | neherlab/multiflu | 995b0ee8b8704f3a9be66fb5f5b54c5e749528af | [
"MIT"
] | 1 | 2020-03-25T06:58:40.000Z | 2020-03-25T06:58:40.000Z | var virusTooltip = d3.tip()
.direction('se')
.attr('class', 'd3-tip')
.offset([0, 12])
.html(function(d) {
string = "";
// safe to assume the following attributes
if (typeof d.strain != "undefined") {
string += d.strain;
}
string += "<div class=\"smallspacer\"></div>";
string += "<div class=\"smallnote\">";
// division / country / region
// known to division level
if (typeof d.attr.division != "undefined" && typeof d.attr.country != "undefined" && d.attr.division != d.attr.country) {
string += d.attr.division;
string += d.attr.country;
}
// division / country / region
// known to country level
else if (typeof d.attr.division != "undefined" && typeof d.attr.country != "undefined" && d.attr.division == d.attr.country) {
string += d.attr.country;
}
// country / region
// known to country level
else if (typeof d.attr.country != "undefined") {
string += d.attr.country;
}
if (typeof d.attr.raw_date != "undefined") {
string += ", " + d.attr.raw_date;
}
else if (typeof d.attr.date != "undefined") {
string += ", " + d.attr.date;
}
else if (typeof d.shell.coloring != "undefined") {
string += "<br>col: "+d.shell.coloring;
}
if ((typeof d.attr.db != "undefined") && (typeof d.attr.accession != "undefined") && (d.attr.db == "GISAID")) {
string += "<br>GISAID ID: EPI" + d.accession;
}
if ((typeof d.attr.db != "undefined") && (typeof d.attr.accession != "undefined") && (d.attr.db == "Genbank")) {
string += "<br>Accession: " + d.accession;
}
if (typeof d.attr.lab != "undefined") {
if (d.attr.lab != "") {
string += "<br>Source: " + d.attr.lab.replace(/([A-Z])/g, ' $1').replace(/_/g, ' ').toTitleCase().substring(0,25);
if (d.attr.lab.length>25) string += '...';
}
}
if (typeof d.attr.authors != "undefined") {
if ((d.attr.authors != "") && (d.attr.authors != "?")) {
string += "<br>Authors: " + d.attr.authors.substring(0,25);
if (d.attr.authors.length>25) string += '...';
}
}
string += "</div>";
// following may or may not be present
if ((typeof focusNode != "undefined")){
string += "<div class=\"smallspacer\"></div>";
string += "HI against serum from "+focusNode.strain;
string += "<div class=\"smallspacer\"></div>";
string += "<div class=\"smallnote\">"
string += '<table class="table table-condensed"><thead><tr><td>Serum</td><td>Δlog<sub>2</sub></td><td>heterol.</td><td>homol.</td></tr></thead><tbody>';
var tmp_titers = HI_titers[focusNode.clade][d.clade];
var tmp_auto_titers = HI_titers[focusNode.clade][focusNode.clade];
var tmp_avi = titer_subs_model["avidity"][d.clade];
var tmp_pot = titer_subs_model["avidity"][d.clade];
if (typeof tmp_titers != "undefined"){
for (var tmp_serum in tmp_titers){
var autoHI = tmp_auto_titers[tmp_serum][1];
var rawHI = tmp_titers[tmp_serum][1];
var logHI = tmp_titers[tmp_serum][0];
if (correctVirus){logHI-=tmp_avi;}
if (correctPotency){logHI-=titer_subs_model["potency"][focusNode.clade][tmp_serum];}
var serum_name;
if (tmp_serum.length<20){
serum_name = tmp_serum;
}else{
serum_name = tmp_serum.substring(0,17)+'...';
}
string += '<tr><td>' + serum_name + '</td><td>' + logHI.toFixed(2) + '</td><td>' + rawHI.toFixed(0)+ '</td><td>' + autoHI.toFixed(0) +"</td></tr>";
}
}
string += '<tr><td>' + 'Tree model' + '</td><td>' + d.HI_dist_tree.toFixed(2) + '</td><td> --- </td><td>---</td></tr>';
string += '<tr><td>' + 'Subs. model ' + '</td><td>' + d.HI_dist_mut.toFixed(2) + '</td><td> --- </td><td>---</td></tr>';
string += "</tbody></table></div>";
}
string += "<div class=\"smallspacer\"></div>";
// following may or may not be present
string += "<div class=\"smallnote\">";
if (typeof d.attr.cTiter != "undefined") {
string += "Antigenic adv: " + d.attr.cTiter.toFixed(1) + "<br>";
}
if (typeof d.attr.ep != "undefined") {
string += "Epitope distance: " + d.attr.ep + "<br>";
}
if (typeof d.attr.rb != "undefined") {
string += "Receptor binding distance: " + d.attr.rb + "<br>";
}
if (typeof d.attr.glyc != "undefined") {
string += "Glycosylation sites: " + d.attr.glyc + "<br>";
}
if (typeof d.attr.age != "undefined") {
if (d.attr.age != "unknown"){
string += "Host age: " + d.attr.age + "y<br>";
}
}
if (typeof d.LBI != "undefined") {
string += "Local branching index: " + d.LBI.toFixed(3) + "<br>";
}
if (typeof d.dfreq != "undefined") {
string += "Freq. change: " + d.dfreq.toFixed(3) + "<br>";
}
if (typeof d.attr.pred_distance != "undefined") {
string += "Predicted distance: " + d.pred_distance.toFixed(3) + "<br>";
}
string += "</div>";
return string;
});
var linkTooltip = d3.tip()
.direction('e')
.attr('class', 'd3-tip')
.offset([0, 12])
.html(function(d) {
string = ""
if (typeof d.frequency != "undefined") {
string += "Frequency: " + (100 * d.frequency).toFixed(1) + "%"
}
if (typeof d.attr.dTiter != "undefined") {
string += "<br>Titer drop: " + d.attr.dTiter.toFixed(2)
}
string += "<div class=\"smallspacer\"></div>";
string += "<div class=\"smallnote\">";
var ncount = d.muts.length;
if (ncount) {string += "<b>Mutations:</b><ul>";}
if ((typeof d.aa_muts !="undefined")){
for (tmp_gene in d.aa_muts) {ncount+=d.aa_muts[tmp_gene].length;}
for (tmp_gene in d.aa_muts){
if (d.aa_muts[tmp_gene].length){
string+="<li>"+tmp_gene+":</b> "+d.aa_muts[tmp_gene].join(', ') + "</li>";
}
}
}
if ((typeof d.muts !="undefined") && (d.muts.length)){
var nmuts = d.muts.length;
var tmp_muts = d.muts.slice(0,Math.min(10, nmuts))
string += "<li>nuc: "+tmp_muts.join(', ');
if (nmuts>10) {string+=' + '+ (nmuts-10) + ' more';}
string += "</li>";
}
string += "</ul>";
if (typeof d.fitness != "undefined") {
string += "Fitness: " + d.fitness.toFixed(3) + "<br>";
}
if (typeof d.attr.age_score != "undefined") {
string += "Age_stat: " + d.attr.age_score.toFixed(3) + "<br>";
}
if (typeof d.attr.avg_age != "undefined") {
string += "Avg age: " + d.attr.avg_age.toFixed(3) + "y<br>";
}
string += "click to zoom into clade"
string += "</div>";
return string;
});
| 35.40678 | 159 | 0.575714 |
296eabc4d1c69a7bcf5a8249c9c5d98f90171bc9 | 743 | js | JavaScript | hackerrank/plus_minus.js | dedeco/algorithm-practice | 28626df561b70f321a84fa2182a91502c290ce9c | [
"MIT"
] | null | null | null | hackerrank/plus_minus.js | dedeco/algorithm-practice | 28626df561b70f321a84fa2182a91502c290ce9c | [
"MIT"
] | 1 | 2022-02-28T09:47:39.000Z | 2022-02-28T09:47:39.000Z | hackerrank/plus_minus.js | dedeco/algorithm-practice | 28626df561b70f321a84fa2182a91502c290ce9c | [
"MIT"
] | 1 | 2022-02-28T04:37:22.000Z | 2022-02-28T04:37:22.000Z | function countGroups(arr) {
return arr.reduce((previous, current) => {
let currentKey;
if (current === 0)
currentKey = 'zero';
else if (current > 0)
currentKey = 'positive';
else
currentKey = 'negative';
previous[currentKey]++;
return previous;
}, {
positive: 0,
negative: 0,
zero: 0,
});
}
function plusMinus(arr) {
const size = arr.length;
const groupedElements = countGroups(arr);
for (const item in groupedElements) {
const value = (
groupedElements[item] / size
)
.toPrecision(6);
console.log(value); // result here
}
} | 21.852941 | 46 | 0.496635 |
296fcd1107140b0496179fe2e724297fc998a560 | 1,036 | js | JavaScript | build/schema/User/typeDefs.js | WalidMoultamiss/Megastore | 201e334f33723a85a27cafd641ad27cbf3dcb34f | [
"MIT"
] | 2 | 2022-03-25T15:29:47.000Z | 2022-03-27T16:54:41.000Z | build/schema/User/typeDefs.js | WalidMoultamiss/Megastore | 201e334f33723a85a27cafd641ad27cbf3dcb34f | [
"MIT"
] | 3 | 2022-03-25T15:24:00.000Z | 2022-03-28T11:56:34.000Z | build/schema/User/typeDefs.js | WalidMoultamiss/Megastore | 201e334f33723a85a27cafd641ad27cbf3dcb34f | [
"MIT"
] | 1 | 2022-03-24T21:22:03.000Z | 2022-03-24T21:22:03.000Z | "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.typeDefs = void 0;
const apollo_server_express_1 = require("apollo-server-express");
// Construct a schema, using GraphQL schema language
exports.typeDefs = (0, apollo_server_express_1.gql) `
input UserInput {
firstName: String
lastName: String
email: String
password: String
role: Role
}
enum Role {
USER
SELLER
}
input LoginInput {
email: String
password: String
}
type User {
id: ID!
firstName: String!
lastName: String!
email: String!
role: Role!
password: String!
token: String!
store: Store!
createdAt: String!
}
type Query {
hello: String
getAllUsers: [User]
getUserById(id: ID!): User
}
type Mutation {
register(input: UserInput): User
login(input: LoginInput): User
}
type Subscription {
userLoggedIn: User
userAdded: User
userUpdated: User
userDeleted: User
}
`;
//# sourceMappingURL=typeDefs.js.map | 18.836364 | 65 | 0.653475 |
2972aaddc129d7a4b92dde6c02a81fd830608276 | 10,039 | js | JavaScript | dist/MockingBird.min.js | gburghardt/mocking_bird | 89e9da4cb4281249d9f152b7114e1a708e6f6b7d | [
"MIT"
] | null | null | null | dist/MockingBird.min.js | gburghardt/mocking_bird | 89e9da4cb4281249d9f152b7114e1a708e6f6b7d | [
"MIT"
] | null | null | null | dist/MockingBird.min.js | gburghardt/mocking_bird | 89e9da4cb4281249d9f152b7114e1a708e6f6b7d | [
"MIT"
] | null | null | null | /*! MockingBird v1.0.2 2015-05-20 */
;var MockingBird={interceptAjax:function(a){return new MockingBird.XMLHttpRequestInterceptor(a)}};MockingBird.XMLHttpRequest=function XMLHttpRequest(){this._requestHeaders={};this._responseHeaders={}};MockingBird.XMLHttpRequest.prototype={_async:true,_connectionStrategy:null,_method:null,_requestHeaders:null,_responseHeaders:null,_data:null,_password:null,_url:null,_username:null,constructor:MockingBird.XMLHttpRequest,returns:function(b,a,c){return this._connectionStrategy=new MockingBird.XMLHttpRequest.SimpleConnectionStrategy(this).status(b).body(a||null).headers(c||{})},connects:function(){return this._connectionStrategy=new MockingBird.XMLHttpRequest.ConnectionBuilderStrategy(this).connects()},changeState:function(a,b){this.readyState=a;this.status=b;if(this.readyState===this.DONE){this.responseXML=this._parseResponseText()}this.onreadystatechange()},delayExecution:function(){return this._connectionStrategy=new MockingBird.XMLHttpRequest.ConnectionBuilderStrategy(this).delayExecution()},getAllRequestHeaders:function(){return this._requestHeaders},getLastRequest:function(){return new MockingBird.XMLHttpRequest.RequestInfo(this)},_parseResponseText:function(){var c=null,d,a;if(this.responseText){try{d=new DOMParser();c=d.parseFromString(this.responseText,"application/xml");if(c.getElementsByTagName("parsererror").length>0){c=null}}catch(b){c=null}}return c},resetRequest:function(){this.readyState=this.UNSENT;this.status=0;this.responseText=null;this.responseXML=null},DONE:4,HEADERS_RECEIVED:2,LOADING:3,OPENED:1,UNSENT:0,readyState:0,responseText:null,responseXML:null,status:0,onreadystatechange:function(){},abort:function(){this.resetRequest();this.changeState(this.UNSENT,0)},getAllResponseHeaders:function(){return this._responseHeaders},getResponseHeader:function(a){return this._responseHeaders.hasOwnProperty(a)?this._responseHeaders[a]:null},getRequestHeader:function(a){return this._requestHeaders.hasOwnProperty(a)?this._requestHeaders[a]:null},setResponseHeaders:function(a){this._responseHeaders=a},setRequestHeader:function(a,b){this._requestHeaders[a]=b},open:function(e,b,c,d,a){this._method=e;this._url=b;this._async=!!c;this._username=d;this._password=a;this.changeState(this.OPENED,0)},overrideMimeType:function(a){this._mimeType=a},send:function(a){this._data=a;this._connectionStrategy.execute(a)}};MockingBird.XMLHttpRequest.ConnectionBuilderStrategy=function ConnectionBuilderStrategy(a){this.chunks=[];this._events=[];this.xhr=a};MockingBird.XMLHttpRequest.ConnectionBuilderStrategy.prototype={chunks:null,_delayExecution:false,_events:null,requestBody:null,xhr:null,constructor:MockingBird.XMLHttpRequest.ConnectionBuilderStrategy,_addChunk:function(a){return this.chunks.push(this._chunkToString(a))-1},_addEvent:function(a){if(this._delayExecution){a.call(this,this.xhr)}else{this._events.push(a)}},connects:function(){this._addEvent(function(a){a.changeState(a.OPENED,0)});return this},delayExecution:function(){this._delayExecution=true;return this},disconnects:function(){this._addEvent(function(a){a.resetRequest();a.changeState(a.UNSENT,0)});return this},done:function(b,a){if(a&&this.chunks.length){this._addChunk(a)}this._addEvent(function(c){if(this.chunks.length){c.responseText=this.joinChunks()}else{c.responseText=this._chunkToString(a);c.changeState(c.LOADING,b)}c.changeState(c.DONE,b)})},execute:function(c){this.requestBody=this._chunkToString(c);if(this._delayExecution){return}if(!this._events.length){throw new Error("No request lifecycle events have been added to this strategy")}for(var a=0,b=this._events.length;a<b;a++){this._events[a].call(this,this.xhr)}},joinChunks:function(){return this.chunks.join("")},receivesChunk:function(a,b){var c=this._addChunk(b);this._addEvent(function(d){d.responseText=(d.responseText||"")+this.chunks[c];d.changeState(d.LOADING,a||200)});return this},receivesHeaders:function(a,b){this._addEvent(function(c){c.setResponseHeaders(b||{});c.changeState(c.HEADERS_RECEIVED,a||200)});return this},_chunkToString:function(a){if(a===undefined||a===null){return null}return typeof a==="object"?JSON.stringify(a):String(a)}};MockingBird.XMLHttpRequest.MockBuilder=function MockBuilder(e,b,c,d,a){this.method=e.toUpperCase();this.url=b;this.async=typeof c==="boolean"?c:true;this.username=d||null;this.password=a||null};MockingBird.XMLHttpRequest.MockBuilder.prototype={async:true,method:null,password:null,strategy:null,url:null,username:null,constructor:MockingBird.XMLHttpRequest.MockBuilder,chunks:function(a,f,e){if(!f||!f.length){throw new Error("Missing or empty argument: chunks")}var d=this.connects().receivesHeaders(a,e||{});for(var b=0,c=f.length-1;b<c;b++){d.receivesChunk(a,f[b])}if(c>-1){d.done(a,f[c])}return d},connects:function(){return this.strategy=new MockingBird.XMLHttpRequest().connects()},getRequest:function(){return this.strategy.xhr},matches:function(e,b,c,d,a){return this.method==e.toUpperCase()&&this.url==b&&this.async==c&&this.username==d&&this.password==a},returns:function(b,a,c){return this.strategy=new MockingBird.XMLHttpRequest().returns(b,a,c)}};MockingBird.XMLHttpRequest.RequestInfo=function RequestInfo(a){this.method=a._method;this.url=a._url;this.async=a._async;this.username=a._username;this.password=a._password;this.data=a._data;this.status=a.status;this.requestHeaders=Object.create(a._requestHeaders);this.responseHeaders=Object.create(a._responseHeaders);this.responseText=a.responseText;this.responseXML=a.responseXML;this.readyState=a.readyState};MockingBird.XMLHttpRequest.RequestInfo.prototype={constructor:MockingBird.XMLHttpRequest.RequestInfo,getRequestHeader:function(a){return a in this.requestHeaders?this.requestHeaders[a]:null},hasRequestHeader:function(a){return !!this.getRequestHeader(a)},getResponseHeader:function(a){return a in this.responseHeaders?this.responseHeaders[a]:null},hasResponseHeader:function(a){return !!this.getResponseHeader(a)},isComplete:function(){return this.readyState===4},isGet:function(){return(this.method||"").toUpperCase()==="GET"},isDelete:function(){return(this.method||"").toUpperCase()==="DELETE"},isHead:function(){return(this.method||"").toUpperCase()==="HEAD"},isPost:function(){return(this.method||"").toUpperCase()==="POST"},isPut:function(){return(this.method||"").toUpperCase()==="PUT"},isTeapot:function(){return this.status===418}};MockingBird.XMLHttpRequest.SimpleConnectionStrategy=function SimpleConnectionStrategy(a){this._headers={};this.xhr=a};MockingBird.XMLHttpRequest.SimpleConnectionStrategy.prototype={_body:null,_headers:null,_status:200,xhr:null,constructor:MockingBird.XMLHttpRequest.SimpleConnectionStrategy,body:function(a){if(a===undefined||a===null){this._body=null}else{this._body=typeof a=="object"?JSON.stringify(a):String(a)}return this},execute:function(a){if(this.xhr.readyState!=this.xhr.OPENED){this.xhr.changeState(this.xhr.OPENED,0)}this.xhr.setResponseHeaders(this._headers);this.xhr.changeState(this.xhr.HEADERS_RECEIVED,this._status);this.xhr.responseText=this._body;this.xhr.changeState(this.xhr.LOADING,this._status);this.xhr.changeState(this.xhr.DONE,this._status)},headers:function(b){for(var a in b){if(b.hasOwnProperty(a)){this._headers[a]=b[a]}}return this},status:function(a){this._status=a;return this}};MockingBird.XMLHttpRequestInterceptor=function XMLHttpRequestInterceptor(a){if("XMLHttpRequest" in a){this.OriginalXMLHttpRequest=a.XMLHttpRequest;a.XMLHttpRequest=this.getXMLHttpRequestFactory(this);this.global=a}else{throw new Error("No XMLHttpRequest constructor was found in "+Object.prototype.toString.call(a))}this.mocks=[]};MockingBird.XMLHttpRequestInterceptor.prototype={global:null,mocks:null,OriginalXMLHttpRequest:null,constructor:MockingBird.XMLHttpRequestInterceptor,destroy:function(){if(this.global){this.global.XMLHttpRequest=this.OriginalXMLHttpRequest}this.mocks=this.global=this.OriginalXMLHttpRequest=null},getRequest:function(f,b,d,e,a){var c=this.mocks.length;d=typeof d==="boolean"?d:true;while(c--){if(this.mocks[c].matches(f,b,d,e,a)){return this.mocks[c].getRequest()}}throw new MockingBird.XMLHttpRequestMockNotFoundError(f,b,d,e,a)},getXMLHttpRequestFactory:function(b){return function a(){return new MockingBird.XMLHttpRequestProxy(b)}},mock:function(f,c,d,e,b){var a=new MockingBird.XMLHttpRequest.MockBuilder(f,c,d,e,b);this.mocks.push(a);return a}};MockingBird.XMLHttpRequestMockNotFoundError=function XMLHttpRequestMockNotFoundError(f,c,d,e,b){var a=new Error("No mock registered for "+f+" "+c+" (async: "+d+"; username: "+e+"; password: "+b+")");a.name="MockingBird.XMLHttpRequestMockNotFoundError";return a};MockingBird.XMLHttpRequestProxy=function XMLHttpRequestProxy(c){var b=null,a=function(){};Object.defineProperty(this,"onreadystatechange",{get:function(){return a},set:function(d){a=d;if(b){b.onreadystatechange=d}}});Object.defineProperty(this,"readyState",{get:function(){return b?b.readyState:0}});Object.defineProperty(this,"response",{get:function(){return b?b.response:null}});Object.defineProperty(this,"responseText",{get:function(){return b?b.responseText:null}});Object.defineProperty(this,"responseType",{get:function(){return b?b.responseType:null}});Object.defineProperty(this,"responseXML",{get:function(){return b?b.responseXML:null}});Object.defineProperty(this,"status",{get:function(){return b?b.status:0}});Object.defineProperty(this,"xhr",{get:function(){return b}});this.abort=function(){b.abort()};this.getAllResponseHeaders=function(){return b.getAllResponseHeaders()};this.getResponseHeader=function(d){return b.getResponseHeader(d)};this.open=function(h,f,g,d,e){b=c.getRequest(h,f,g,d,e);b.onreadystatechange=a;b.open(h,f,g,d,e)};this.overrideMimeType=function(d){b.overrideMimeType(d)};this.send=function(){if(arguments.length===1){b.send(arguments[0])}else{b.send(null)}};this.setRequestHeader=function(d,e){b.setRequestHeader(d,e)}};MockingBird.XMLHttpRequestProxy.prototype={constructor:MockingBird.XMLHttpRequestProxy,UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4}; | 5,019.5 | 10,002 | 0.802769 |
2972d5839e83d4fb1443006d70481ffefb8ab8cd | 110 | js | JavaScript | lib/truncate.js | dwest-teo/wattos-spaceship-emporium | 29a35f1cfe2888e470b4296c780a005422e97dd4 | [
"MIT"
] | 1 | 2018-05-02T14:37:48.000Z | 2018-05-02T14:37:48.000Z | lib/truncate.js | dwest-teo/wattos-spaceship-emporium | 29a35f1cfe2888e470b4296c780a005422e97dd4 | [
"MIT"
] | null | null | null | lib/truncate.js | dwest-teo/wattos-spaceship-emporium | 29a35f1cfe2888e470b4296c780a005422e97dd4 | [
"MIT"
] | 2 | 2017-06-18T04:27:33.000Z | 2019-02-08T01:20:29.000Z | const truncate = (str, max) => str.length > max ? `${str.substr(0, max)}...` : str;
export default truncate;
| 27.5 | 83 | 0.618182 |
29748394e793d1d45262a1eaf262b3b3ab58cad1 | 2,103 | js | JavaScript | js/stepper.js | antonpernisch/familycup-expresna-website | ec9284bef4d1c23a54d5d170dfade873016e97c2 | [
"MIT"
] | null | null | null | js/stepper.js | antonpernisch/familycup-expresna-website | ec9284bef4d1c23a54d5d170dfade873016e97c2 | [
"MIT"
] | null | null | null | js/stepper.js | antonpernisch/familycup-expresna-website | ec9284bef4d1c23a54d5d170dfade873016e97c2 | [
"MIT"
] | null | null | null | function Stepper() {
this.steps_slugs = ["onboarding", "rodina", "veduci", "clenovia", "kategorie", "email", "rekapitulacia"];
this.current_step_index = -1;
return;
}
Stepper.prototype = {
NextStep: function (passedData, validateForm = false) {
if (validateForm) {
var flag = false;
$(".validate-this-box").each(function () {
var el = $(this);
var val = el.val();
if (val == "") flag = true;
});
if (flag) {
AddErrHit();
let notFulfilledToast = mdb.Toast.getInstance(document.getElementById('toast-notFulfilled'));
notFulfilledToast.show();
return;
}
}
var nextStepIndex = this.current_step_index + 1;
if (nextStepIndex > this.steps_slugs.length - 1) return;
var nextStepSlug = this.steps_slugs[nextStepIndex];
nextStepIndex == 0 || nextStepIndex == 1 ? Animation.BtnChange(".nextStep-btn", `<span class="spinner-grow text-light spinner-grow-sm" role="status" aria-hidden="true"></span>`) : Animation.BtnChange(".nextStep-btn", `<span class="spinner-grow text-primary spinner-grow-sm" role="status" aria-hidden="true"></span>`);
// Load next design block and show it afterwards
$.ajax({
url: `blocks/steps/${nextStepSlug}.php?${$.param(passedData)}`,
success: (result) => {
Animation.BtnChange(".nextStep-btn", `<i class="far fa-check-circle"></i>`);
Animation.Do("#main-inner-content", "fade-out-down", () => { }, 0, 800);
setTimeout(() => {
$("#main-inner-content").html(result);
$("#main-inner-content").removeClass("fade-out-down");
Animation.Do("#main-inner-content", "fade-in-up");
Stepper.current_step_index = nextStepIndex;
}, 800);
},
error: (e) => {
console.error(e);
}
});
}
};
var Stepper = new Stepper(); | 44.744681 | 325 | 0.53067 |
2975387ee6da4d4df299d5885c8d1816f0c47d2b | 290 | js | JavaScript | change-the-prototype-to-new-object/index.js | wellpinho/javascript-algorithms-and-data-structures | d3f5221bd3a0d5c089ae3ad7b69fd63e02d845ff | [
"MIT"
] | null | null | null | change-the-prototype-to-new-object/index.js | wellpinho/javascript-algorithms-and-data-structures | d3f5221bd3a0d5c089ae3ad7b69fd63e02d845ff | [
"MIT"
] | null | null | null | change-the-prototype-to-new-object/index.js | wellpinho/javascript-algorithms-and-data-structures | d3f5221bd3a0d5c089ae3ad7b69fd63e02d845ff | [
"MIT"
] | null | null | null | //Mudar o protótipo para um novo objeto
function Dog(name) {
this.name = name;
}
Dog.prototype = {
// adcionado uma nova propriedade
numLegs: 2,
// criando novo método
eat: () => {
console.log('eat method')
},
describe: () => {
console.log('describe method')
}
}; | 16.111111 | 39 | 0.606897 |
2976d72b379db677ec26482d909b9ab5acb46c5b | 84 | js | JavaScript | tests/Scenarios/RedeemUnderlyingEthScenTest.js | supernova-cash/Quicksilver | 059e70ff99a36f94402ff852e50c7c0782feb69b | [
"BSD-3-Clause"
] | 1 | 2022-03-23T17:16:29.000Z | 2022-03-23T17:16:29.000Z | tests/Scenarios/RedeemUnderlyingEthScenTest.js | supernova-cash/Quicksilver | 059e70ff99a36f94402ff852e50c7c0782feb69b | [
"BSD-3-Clause"
] | 1 | 2021-09-08T13:38:19.000Z | 2021-09-08T13:38:19.000Z | tests/Scenarios/RedeemUnderlyingEthScenTest.js | Tropykus/protocol | cb40e0a3413b043960e8b1a8ac8acfade9aebefe | [
"BSD-3-Clause"
] | null | null | null | const scenario = require('../Scenario');
scenario.run('RedeemUnderlyingEth.scen');
| 21 | 41 | 0.738095 |