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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4665838f0ce3737528d04efe13d30fbe9b1f0b10 | 411 | js | JavaScript | src/utils/utils.js | cameronbroe/clue-sheets | 5f4cc4de899b056e4cf4ae74a6166beeaca89058 | [
"MIT"
] | null | null | null | src/utils/utils.js | cameronbroe/clue-sheets | 5f4cc4de899b056e4cf4ae74a6166beeaca89058 | [
"MIT"
] | null | null | null | src/utils/utils.js | cameronbroe/clue-sheets | 5f4cc4de899b056e4cf4ae74a6166beeaca89058 | [
"MIT"
] | null | null | null | import _ from 'lodash';
export async function getBoard (boardId) {
let gamesListResponse = await fetch('static/games-list.json');
let gamesList = await gamesListResponse.json();
let listEntry = _.find(gamesList.games, (e) => { return e.boardId === boardId; });
let gameBoardResponse = await fetch(`static/${listEntry.filename}`);
let gameBoard = await gameBoardResponse.json();
return gameBoard;
}
| 37.363636 | 84 | 0.722628 |
46668eb424346a4c176353084014e8ee363b365c | 106 | js | JavaScript | crates/swc_ecma_codegen/tests/test262/c964ed7bc2373c54.js | mengxy/swc | bcc3ae86ae0732979f9fbfef370ae729ba9af080 | [
"Apache-2.0"
] | 1 | 2022-03-25T05:35:24.000Z | 2022-03-25T05:35:24.000Z | crates/swc_ecma_codegen/tests/test262/c964ed7bc2373c54.js | Austaras/swc | 4a4e72f424efe11cc2e2edc1a4f305799f26f7b8 | [
"Apache-2.0"
] | 1 | 2021-12-11T06:34:27.000Z | 2021-12-11T06:34:27.000Z | crates/swc_ecma_codegen/tests/test262/c964ed7bc2373c54.js | Austaras/swc | 4a4e72f424efe11cc2e2edc1a4f305799f26f7b8 | [
"Apache-2.0"
] | 1 | 2022-01-26T05:29:04.000Z | 2022-01-26T05:29:04.000Z | function a({ a =(1) , b }) {}
function b([b, c = (2)]) {}
var { d =(3) , e } = d;
var [d, e = (4)] = d;
| 21.2 | 30 | 0.358491 |
46674badd3660e0fe7003813f7a3f9be6a5caade | 971 | js | JavaScript | lib/commonAPI/coreapi/public/api/rhoapi-native.android.js | hanazuki/rhodes | eff0e410361dba791853a235d58471ba9e25e2fc | [
"MIT"
] | null | null | null | lib/commonAPI/coreapi/public/api/rhoapi-native.android.js | hanazuki/rhodes | eff0e410361dba791853a235d58471ba9e25e2fc | [
"MIT"
] | null | null | null | lib/commonAPI/coreapi/public/api/rhoapi-native.android.js | hanazuki/rhodes | eff0e410361dba791853a235d58471ba9e25e2fc | [
"MIT"
] | null | null | null | /* Rho API Android native bridge */
(function ($, rho, rhoPlatform, rhoUtil) {
'use strict';
if (window[rhoUtil.flag.USE_AJAX_BRIDGE]) return;
var RHO_API_CALL_TAG = '__rhoNativeApiCall';
var RHO_API_TAG = '__rhoNativeApi';
var nativeApi = {
apiCall: function (cmdText, async, resultHandler) {
//window.alert(cmdText);
var nativeApiResult = {};
if (window[RHO_API_TAG] && 'function' == typeof window[RHO_API_TAG]['apiCall']) {
nativeApiResult = window[RHO_API_TAG].apiCall(cmdText, async);
} else {
nativeApiResult = prompt(cmdText, RHO_API_CALL_TAG + ':prompt');
}
//window.alert(nativeApiResult);
resultHandler(JSON.parse(nativeApiResult));
}
};
// TODO: uncomment as native handler will be implemented
rhoPlatform.nativeApiCall = nativeApi.apiCall;
})(Rho.jQuery, Rho, Rho.platform, Rho.util);
| 29.424242 | 93 | 0.6138 |
4667d10eaf8dc1c07fd72df55e0e312954f6d8f4 | 2,878 | js | JavaScript | src/VoxRenderer/Level/Level.js | dgoemans/VoxRenderer | 15c69e860ada66ef0b9d6180249927e960902fae | [
"MIT"
] | 3 | 2018-03-12T13:10:48.000Z | 2020-05-09T16:12:51.000Z | src/VoxRenderer/Level/Level.js | dgoemans/VoxRenderer | 15c69e860ada66ef0b9d6180249927e960902fae | [
"MIT"
] | null | null | null | src/VoxRenderer/Level/Level.js | dgoemans/VoxRenderer | 15c69e860ada66ef0b9d6180249927e960902fae | [
"MIT"
] | null | null | null | import * as THREE from 'three';
import Lamp from "../Objects/Lamp";
import Ball from "../Objects/Ball";
import Road from "../Objects/Road";
import PhysicsHelper from '../Physics/PhysicsHelper';
import VoxModelLoader from '../VoxModel/VoxModelLoader';
export default class Level {
constructor(renderer, physics) {
this.physics = physics;
this.renderer = renderer;
this.scene = new THREE.Scene();
this.scene.fog = new THREE.FogExp2( 0x1f2125, 0.0015 );
const light = new THREE.HemisphereLight( 0xfafaff, 0xffffff, 0.1 );
this.scene.add( light );
const floorGeometry = new THREE.BoxGeometry(4096, 1, 4096);
const {shape, center} = PhysicsHelper.createBox(floorGeometry);
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0x333333,
metalness: 0,
flatShading: true,
roughness: 1
});
const floor = new THREE.Mesh(floorGeometry, floorMaterial);
floor.userData.physicsShape = shape;
floor.userData.physicsCenter = center;
floor.receiveShadow = true;
floor.position.set(0,-0.5,0);
this.addToScene(floor, 0, 0.5);
for(let i=-480; i<480; i+=40) {
new Road(this, new THREE.Vector3(-20, 0, i));
}
this.addLamps();
this.addBuildings();
}
async addLamps() {
for(let i=-1000; i <= 1000; i+= 280) {
await new Lamp(this, new THREE.Vector3(-44.5,0, i - 44.5));
await new Lamp(this, new THREE.Vector3(35.5,0, i + 35.5));
}
}
async addBuildings() {
for(let i=-2000; i <= 2000; i+= 150) {
await this.loadVox('building_1', new THREE.Vector3(-200,0,i));
await this.loadVox('building_1', new THREE.Vector3(63,0,i));
}
}
async loadVox(model, position, rotation) {
position = position || new THREE.Vector3();
rotation = rotation || new THREE.Euler();
const voxLoader = new VoxModelLoader();
const mesh = await voxLoader.load(`../models/${model}.vox`, position, rotation);
this.addToScene(mesh, 0);
}
addToScene(mesh, mass = 1, restitution = 0) {
this.scene.add(mesh);
mesh.userData.physicsShape && this.physics.createRigidBody(mesh, mass, restitution);
this.renderer.shadowMap.needsUpdate = true;
}
addBall(position) {
return new Ball(this, position);
}
update(delta, totalElapsed) {
/*if(totalElapsed > 5 && totalElapsed < 30 && Math.random() < 0.05) {
const angle = Math.random() * Math.PI * 2
const radius = 20;
const x = radius*Math.cos(angle);
const z = radius*Math.sin(angle);
this.addBall(new THREE.Vector3(x,105,z));
}*/
}
} | 33.465116 | 92 | 0.576095 |
4667dc3c7349ebfc01bc02c3f7fd4d7ac42a47e8 | 1,041 | js | JavaScript | admin/tabs/userData/JsonBlobPanel.js | vaibhavantil2/hoist-react | f0d5fdf9fcd1799b2737d535593f63504e985fe6 | [
"Apache-2.0"
] | 13 | 2018-04-27T04:32:53.000Z | 2019-05-02T09:39:00.000Z | admin/tabs/userData/JsonBlobPanel.js | vaibhavantil2/hoist-react | f0d5fdf9fcd1799b2737d535593f63504e985fe6 | [
"Apache-2.0"
] | 1,132 | 2019-09-18T10:27:25.000Z | 2022-03-30T18:47:46.000Z | admin/tabs/userData/JsonBlobPanel.js | exhi/hoist-react | f818d325d18a5be797c8a9262863091bdc1b1aa2 | [
"Apache-2.0"
] | 2 | 2021-02-26T17:19:58.000Z | 2021-12-15T17:14:37.000Z | /*
* This file belongs to Hoist, an application development toolkit
* developed by Extremely Heavy Industries (www.xh.io | info@xh.io)
*
* Copyright © 2021 Extremely Heavy Industries Inc.
*/
import {creates, hoistCmp} from '@xh/hoist/core';
import {fragment} from '@xh/hoist/cmp/layout';
import {restGrid} from '@xh/hoist/desktop/cmp/rest';
import {button} from '@xh/hoist/desktop/cmp/button';
import {Icon} from '@xh/hoist/icon';
import {JsonBlobModel} from './JsonBlobModel';
import {differ} from '../../differ/Differ';
export const jsonBlobPanel = hoistCmp.factory({
model: creates(JsonBlobModel),
render({model}) {
return fragment(
restGrid({
extraToolbarItems: () => {
return button({
icon: Icon.diff(),
text: 'Compare w/ Remote',
onClick: () => model.openDiffer()
});
}
}),
differ({omit: !model.differModel})
);
}
});
| 29.742857 | 67 | 0.560999 |
46683b4d5968fd0ba9db556710bc50cd29799a23 | 5,278 | js | JavaScript | study/boolean-tutor/js/app.js | tecanal/kids-corner | cb65a95494675c660c60bbc18279102dc47cc411 | [
"MIT"
] | null | null | null | study/boolean-tutor/js/app.js | tecanal/kids-corner | cb65a95494675c660c60bbc18279102dc47cc411 | [
"MIT"
] | 10 | 2020-06-24T18:22:58.000Z | 2020-07-23T18:01:35.000Z | study/boolean-tutor/js/app.js | tecanal/kids-corner | cb65a95494675c660c60bbc18279102dc47cc411 | [
"MIT"
] | 3 | 2020-06-29T20:22:06.000Z | 2022-02-16T23:08:39.000Z | const exampleEl = document.getElementById("example");
const alphabet = "abcdefghijklmnopqrstuvwxyz".split("");
// the starting probability of boolean expression nesting
const EASY_DIFF_NESTING_PROBABILITY = 0.80;
// the rate in which the nesting probability diminishes each recursive step
const PROB_DECAY = 0.50;
// global state variable
let answer;
let score = 0;
/**
* Initialize UI components when the script starts.
*/
(function initUI() {
document.querySelector("#answerTrue").onclick = () => answerPrompt(true);
document.querySelector("#answerFalse").onclick = () => answerPrompt(false);
generateProblem();
})();
/**
* Recursively create an evaluateable boolean expression.
* @param {String[]} operands
* @param {Number} nestingProbability
* @returns {String} expression
*/
function getBooleanExpression(operands, nestingProbability) {
// generate boolean expressions from the given operands
let expressions = operands.map(x => {
// if number is under the probabilty threshold, generate nested expression
if (Math.random() < nestingProbability) {
return `(${getBooleanExpression(operands, nestingProbability - PROB_DECAY)})`;
}
else {
return x;
}
});
// choose the boolean operations that will be performed between expressions
let operations = operands.map(_ => {
// flip a coin to choose
if (Math.round(Math.random())) {
return " && ";
}
else {
return " || ";
}
});
// combine the expressions and operations together
return expressions.reduce((a, b, i) => [a, b].join(operations[(i - 1) % operations.length]));
}
/**
* Create a new boolean expression problem to show on screen.
*/
function generateProblem() {
let start = Math.round(Math.random()) ? "!" : "";
let booleanExpression = start;
// generate a random number of operands depending on difficulty level
// TODO skew towards lower numbers? and change based on diff level
let min = 2, max = 2;
let numOperands = Math.floor(Math.random() * (max - min + 1)) + min;
// generate array of unique operand identifiers
let operands =[...Array(numOperands).keys()].reduce((ids, _) => {
ids.push(getRandomUniqueIdentifier(ids));
return ids;
}, []);
// if starts with negation, there needs to be parenthesis around the expression
if (start == "!") {
booleanExpression += `(${getBooleanExpression(operands, EASY_DIFF_NESTING_PROBABILITY)})`;
}
else {
booleanExpression += `${getBooleanExpression(operands, EASY_DIFF_NESTING_PROBABILITY)}`;
}
// generate initial values for the operands
let initValues = operands.map(_ => Math.round(Math.random()) ? 1 : 0);
// if all initial values are true, make one false
if (initValues.every(x => x === 1)) {
initValues[Math.floor(Math.random() * initValues.length)] = 0;
}
// if all initial values are false, make one true
else if (initValues.every(x => !x)) {
initValues[Math.floor(Math.random() * initValues.length)] = 1;
}
// create the boolean expression
let expression = initValues.reduce((acc, curr, i) => {
return acc + `boolean ${operands[i]} = ${!!curr};\n`;
}, "");
expression += `\n${booleanExpression}`;
// create an executable javascript boolean expression to eval()
let executableExpression = operands.reduce((acc, curr, i) => {
return acc.replace(new RegExp(curr, "g"), initValues[i]);
}, booleanExpression);
// evaluate the expression and make that the answer
answer = !!eval(executableExpression);
// add code mirror className so syntax highlighting works
exampleEl.className = "cm-s-default";
// run CodeMirror syntax highlighting on the code
CodeMirror.runMode(expression, { name: "text/x-java" }, example);
}
/**
* Answer the question.
* @param {Boolean} input
*/
function answerPrompt(input) {
// show the notification alert
const notif = document.getElementById("notification");
notif.style.display = "";
if (input == answer) {
setScore(10);
// give the user feedback that they're right
notif.innerHTML = "That's right!";
notif.className = "success";
}
else {
setScore(-10);
// give the user feedback that they're wrong
notif.innerHTML = "That's wrong.";
notif.className = "failure";
}
// hide the notification alert after 1 second
setTimeout(() => notif.style.display = "none", 1000);
generateProblem();
}
/**
* Change the score UI element.
* @param {Number} delta
*/
function setScore(delta) {
// change score by delta value
score += delta;
// update score UI element
document.getElementById("score").innerText = "Score: " + score;
}
/**
* Get a random one-letter identifier that does is not a duplicate of
* any ones in the prev array.
* @param {String[]} prev
* @returns String
*/
function getRandomUniqueIdentifier(prev) {
let id = alphabet[Math.floor(Math.random() * alphabet.length)];
if (prev.length && prev.includes(id)) {
return getRandomUniqueIdentifier(prev);
}
return id;
} | 30.16 | 98 | 0.642668 |
4668bea525a72e69d00d6997fd87216cb02c7c57 | 2,645 | js | JavaScript | lib/run-bot.js | lonelybots/lonelybots-sdk-node | 1d158ca9d66f50c8a95a1e5e4fcef5623008f2e1 | [
"MIT"
] | 1 | 2016-05-15T15:30:50.000Z | 2016-05-15T15:30:50.000Z | lib/run-bot.js | lonelybots/lonelybots-sdk-node | 1d158ca9d66f50c8a95a1e5e4fcef5623008f2e1 | [
"MIT"
] | null | null | null | lib/run-bot.js | lonelybots/lonelybots-sdk-node | 1d158ca9d66f50c8a95a1e5e4fcef5623008f2e1 | [
"MIT"
] | null | null | null | var _ = require('lodash')
var express = require('express')
var getAttachmentFuncFactory = require('./get-attachment')
var replyFuncFactory = require('./reply')
var createFormFuncFactory = require('./create-form')
var bodyParser = require('body-parser').json()
module.exports = function (options, dependencies) {
// validate input arguments
if (!options) {
throw new Error('missing required argument options')
}
if (!options.validationToken) {
throw new Error('missing required argument options.validationToken')
}
if (!options.accessToken) {
throw new Error('missing required argument options.accessToken')
}
if (!options.callback) {
throw new Error('missing required argument options.callback')
}
if (typeof options.callback !== 'function') {
throw new Error('options.callback must be a function')
}
// allow dependency injection for testability
var getAttachment = dependencies && dependencies.getAttachment
? dependencies.getAttachment
: getAttachmentFuncFactory(options)
var reply = dependencies && dependencies.reply
? dependencies.reply
: replyFuncFactory(options)
var createForm = dependencies && dependencies.createForm
? dependencies.createForm
: createFormFuncFactory(options)
// sets up the result express middleware
var router = express.Router()
// GET requests are for ownership validation
router.get('/', function (req, res, next) {
if (req.get('authorization') === options.validationToken) {
res.send(req.query['response'])
} else {
res.status(401).send('validation token mismatch')
}
})
// POST requests are receiving emails
router.post('/', bodyParser, function (req, res, next) {
if (req.get('authorization') === options.validationToken) {
var mail = _.cloneDeep(req.body)
mail.reply = function (outgoingEmail) {
return reply(mail, outgoingEmail, true)
}
mail.replyAll = function (outgoingEmail) {
return reply(mail, outgoingEmail, false)
}
mail.createForm = function (form) {
return createForm(mail, form)
}
if (mail.attachments) {
_.each(mail.attachments, function (attachment) {
attachment.get = (function (mailId, generatedFileName) {
return function () {
return getAttachment(
mailId, generatedFileName, dependencies)
}
})(mail.id, attachment.generatedFileName)
})
}
options.callback(mail)
res.status(200).send('OK')
} else {
res.status(401).send('validation token mismatch')
}
})
return router
}
| 30.755814 | 72 | 0.66465 |
4668fb868f4a10fdf335284cef62c33e680ba759 | 9,096 | js | JavaScript | src/app/src/lib/navigation.js | GrupaZero/admin | 3463d2f9fec1bd11778d10d6763c6d8c46e23915 | [
"MIT"
] | 4 | 2015-01-21T12:37:41.000Z | 2016-08-11T08:34:57.000Z | src/app/src/lib/navigation.js | GrupaZero/admin | 3463d2f9fec1bd11778d10d6763c6d8c46e23915 | [
"MIT"
] | 40 | 2015-01-07T16:52:36.000Z | 2016-08-21T18:23:38.000Z | src/app/src/lib/navigation.js | GrupaZero/admin | 3463d2f9fec1bd11778d10d6763c6d8c46e23915 | [
"MIT"
] | null | null | null | function Navigation() {
'use strict';
var items = [];
/**
* Function checks if 'item' structure is valid
*
* @param item object
* @returns {boolean}
*/
var checkStructure = function(item) {
if (_.has(item, 'divider')) {
if (item.divider !== true) {
throw new Error('Property: ' + '\'divider\'' + ' must be set to \'true\'');
}
} else if (!_.has(item, 'title')) {
throw new Error('Property: ' + 'title' + ' is missing');
} else if (!_.has(item, 'action') && !_.has(item, 'href')) {
throw new Error('Property: ' + '\'action\' or \'href\'' + ' are required');
}
return true;
};
/**
* Function returns children of element specified by 'title'
*
* @param title string
* @returns {Array}
*/
var getChildren = function(title) {
var children = [],
foundFlag = false;
_.forEach(items, function(value, index) {
if (value.title === title) {
foundFlag = true;
if (_.has(value, 'children') && Array.isArray(value.children)) {
children = value.children;
}
return false;
}
});
if (foundFlag === false) {
throw new Error('Parent: \'' + title + '\' have no children, because does not exist');
}
return children;
};
/**
* Function adds element according to 'position' argument
* position = 'before' - element will be added before element specified by 'title'
* position = 'after' - element will be added after element specified by 'title'
*
* @param title string
* @param item object
* @param position string
*/
var addBeforeAfter = function(title, item, position) {
if (typeof position === 'undefined') {
throw new Error('Argument \'position\' is required, values: \'before\' or \'after\'');
} else if (typeof position !== 'string') {
throw new Error('Argument \'position\' must be of string type, values: \'before\' or \'after\'');
}
if (checkStructure(item)) {
var foundFlag = false;
_.forEach(items, function(value, index) {
if (value.title === title) {
foundFlag = true;
if (position === 'before') {
items.splice(index, 0, item);
} else if (position === 'after') {
items.splice(index + 1, 0, item);
}
return false;
}
});
if (foundFlag === false) {
throw new Error('Element: \'' + title + '\' does not exist');
}
}
};
/**
* Function adds child link according to 'position' argument
* position = true - child will be added as first element
* position = false - child will be added as last element
*
* @param parent string
* @param item object
* @param position boolean
*/
var addChild = function(parent, item, position) {
if (typeof position === 'undefined') {
position = false;
} else if (typeof position !== 'boolean') {
throw new Error('Argument \'position\' must be of boolean type');
}
if (checkStructure(item)) {
var foundFlag = false;
_.forEach(items, function(value, index) {
if (value.title === parent) {
if (!_.has(value, 'children') || !Array.isArray(value.children)) {
value.children = [];
}
if (position === true) {
value.children.unshift(item);
} else if (position === false) {
value.children.push(item);
}
foundFlag = true;
return false;
}
});
if (foundFlag === false) {
throw new Error('Parent: \'' + parent + '\' does not exist');
}
}
};
/**
* Function adds child link according to 'position' argument
* position = 'before' - child will be added before element specified by 'title'
* position = 'after' - child will be added after element specified by 'title'
*
* @param parent string
* @param title string
* @param item object
* @param position string
*/
var addBeforeAfterChild = function(parent, title, item, position) {
if (typeof position === 'undefined') {
throw new Error('Argument \'position\' is required, values: \'before\' or \'after\'');
} else if (typeof position !== 'string') {
throw new Error('Argument \'position\' must be of string type, values: \'before\' or \'after\'');
}
if (checkStructure(item)) {
var foundFlag = false,
children = getChildren(parent);
if (children.length === 0) {
throw new Error('Parent: \'' + parent + '\' have no children');
}
_.forEach(children, function(value, index) {
if (value.title === title) {
foundFlag = true;
if (position === 'before') {
children.splice(index, 0, item);
} else if (position === 'after') {
children.splice(index + 1, 0, item);
}
return false;
}
});
if (foundFlag === false) {
throw new Error('Child: \'' + title + '\' does not exist');
}
}
};
return {
/**
* Function adds element to the end of menu
*
* @param item object
*/
add: function(item) {
if (checkStructure(item)) {
items.push(item);
}
},
/**
* Function adds element to the menu as first
*
* @param item object
*/
addFirst: function(item) {
if (checkStructure(item)) {
items.unshift(item);
}
},
/**
* Function adds element 'item' to the menu before element specified by 'title'
*
* @param title string
* @param item object
*/
addBefore: function(title, item) {
addBeforeAfter(title, item, 'before');
},
/**
* Function adds element 'item' to the menu after element specified by 'title'
*
* @param title string
* @param newItem object
*/
addAfter: function(title, newItem) {
addBeforeAfter(title, newItem, 'after');
},
/**
* Function adds child link as first to the element specified by 'parent' argument
*
* @param parent string
* @param item object
*/
addFirstChild: function(parent, item) {
addChild(parent, item, true);
},
/**
* Function adds child link as last to the element specified by 'parent' argument
*
* @param parent string
* @param item object
*/
addLastChild: function(parent, item) {
addChild(parent, item, false);
},
/**
* Function adds link to the element specified by 'parent' before child element specified by 'title'
*
* @param parent string
* @param title string
* @param item object
*/
addBeforeChild: function(parent, title, item) {
addBeforeAfterChild(parent, title, item, 'before');
},
/**
* Function adds link to the element specified by 'parent' after child element specified by 'title'
*
* @param parent string
* @param title string
* @param item object
*/
addAfterChild: function(parent, title, item) {
addBeforeAfterChild(parent, title, item, 'after');
},
/**
* Function return items from menu
*
* @returns {Array}
*/
getItems: function() {
return items;
},
/**
* Function exports links to 'dropdown' menu
*
* @returns {Array}
*/
exportToDropdownMenu: function() {
var results = [];
var newItem = {};
_.forEach(items, function(value) {
_.forIn(value, function(value, key) {
if (key === 'title') {
newItem.text = value;
} else {
newItem[key] = value;
}
});
results.push(newItem);
newItem = {};
});
return results;
}
};
}
module.exports = Navigation;
| 34.324528 | 109 | 0.475044 |
46699751620df1182a05803165d0d6926c0b5dc3 | 100 | js | JavaScript | packages/plugin-remove-useless-continue/test/fixture/if.js | sobolevn/putout | 965279977fa9aa7e522960a86793813c64af1f26 | [
"MIT"
] | 260 | 2019-01-21T21:21:09.000Z | 2022-03-28T13:06:47.000Z | packages/plugin-remove-useless-continue/test/fixture/if.js | sobolevn/putout | 965279977fa9aa7e522960a86793813c64af1f26 | [
"MIT"
] | 98 | 2019-04-24T12:01:35.000Z | 2022-03-31T18:38:15.000Z | packages/plugin-remove-useless-continue/test/fixture/if.js | sobolevn/putout | 965279977fa9aa7e522960a86793813c64af1f26 | [
"MIT"
] | 31 | 2019-02-19T14:25:40.000Z | 2022-02-12T22:20:53.000Z | for (const currentPath of bodyPath) {
if (isUseStrict(currentPath)) {
continue;
}
}
| 16.666667 | 37 | 0.61 |
4669d2d5c2e0a0de9e7b4c41f030bbe2168577cd | 290 | js | JavaScript | src/containers/UsersNow.js | maxim-saplin/GA-RealtimeReport-PWA | 6094aa1e932c09bf10091a7d480da7df2b14ae67 | [
"MIT"
] | 1 | 2019-10-15T21:09:00.000Z | 2019-10-15T21:09:00.000Z | src/containers/UsersNow.js | maxim-saplin/GA-RealtimeReport-PWA | 6094aa1e932c09bf10091a7d480da7df2b14ae67 | [
"MIT"
] | null | null | null | src/containers/UsersNow.js | maxim-saplin/GA-RealtimeReport-PWA | 6094aa1e932c09bf10091a7d480da7df2b14ae67 | [
"MIT"
] | null | null | null | import {connect} from 'react-redux';
import Users from '../components/Users';
const mapStateToProps = (state) => {
return {
users: state.gaData.usersNow,
countriesAndUsers: state.gaData.countriesAndUsersNow,
title: "Now"
}
}
export default connect(mapStateToProps)(Users); | 24.166667 | 57 | 0.717241 |
466a895b7ccdbfeb00f32662dfdb6486c9920356 | 129 | js | JavaScript | node_modules/carbon-icons-svelte/lib/WatsonHealthAiResultsUrgent32/index.js | seekersapp2013/new | 1e393c593ad30dc1aa8642703dad69b84bad3992 | [
"MIT"
] | null | null | null | node_modules/carbon-icons-svelte/lib/WatsonHealthAiResultsUrgent32/index.js | seekersapp2013/new | 1e393c593ad30dc1aa8642703dad69b84bad3992 | [
"MIT"
] | null | null | null | node_modules/carbon-icons-svelte/lib/WatsonHealthAiResultsUrgent32/index.js | seekersapp2013/new | 1e393c593ad30dc1aa8642703dad69b84bad3992 | [
"MIT"
] | null | null | null | import WatsonHealthAiResultsUrgent32 from "./WatsonHealthAiResultsUrgent32.svelte";
export default WatsonHealthAiResultsUrgent32; | 64.5 | 83 | 0.899225 |
466afa81864162cccf54b08b95e4cc20215b2ec8 | 314 | js | JavaScript | src/store/index.js | yuri2peter/naples-next | 616e05ae410d048f19186fd62ddc983e42c99be8 | [
"Apache-2.0"
] | null | null | null | src/store/index.js | yuri2peter/naples-next | 616e05ae410d048f19186fd62ddc983e42c99be8 | [
"Apache-2.0"
] | null | null | null | src/store/index.js | yuri2peter/naples-next | 616e05ae410d048f19186fd62ddc983e42c99be8 | [
"Apache-2.0"
] | null | null | null | // For more usage about redux: https://redux.js.org/tutorials/quick-start
// Browser extension Redux DevTools is supported by default.
import { configureStore } from '@reduxjs/toolkit';
import exampleSlice from './slices/example';
export default configureStore({
reducer: {
example: exampleSlice,
},
});
| 28.545455 | 74 | 0.735669 |
466b188649001710cd5ae2038c558e7c3b03a47b | 222 | js | JavaScript | cli/tests/test_unresolved_promise.js | Preta-Crowz/deno | 2d865f7f3f4608231862610b7375ddc2e9294903 | [
"MIT"
] | 5 | 2021-03-19T00:19:41.000Z | 2021-11-08T09:47:26.000Z | cli/tests/test_unresolved_promise.js | Preta-Crowz/deno | 2d865f7f3f4608231862610b7375ddc2e9294903 | [
"MIT"
] | 26 | 2021-11-22T04:24:30.000Z | 2022-03-13T01:30:44.000Z | cli/tests/test_unresolved_promise.js | Preta-Crowz/deno | 2d865f7f3f4608231862610b7375ddc2e9294903 | [
"MIT"
] | 2 | 2021-04-25T18:22:04.000Z | 2021-05-28T16:50:02.000Z | Deno.test({
name: "unresolved promise",
fn() {
return new Promise((_resolve, _reject) => {
console.log("in promise");
});
},
});
Deno.test({
name: "ok",
fn() {
console.log("ok test");
},
});
| 13.875 | 47 | 0.509009 |
466bd087533bf8919ff0ff447df3822b0d491198 | 2,618 | js | JavaScript | klient/js/LoadingScreen.js | MStabryla/GwentZSL | 2e81345a4a608747ddd519857d8b3b042c668ae2 | [
"MIT"
] | null | null | null | klient/js/LoadingScreen.js | MStabryla/GwentZSL | 2e81345a4a608747ddd519857d8b3b042c668ae2 | [
"MIT"
] | null | null | null | klient/js/LoadingScreen.js | MStabryla/GwentZSL | 2e81345a4a608747ddd519857d8b3b042c668ae2 | [
"MIT"
] | null | null | null | function LS()
{
var that = this;
this.scene = new THREE.Scene();
this.camera = new THREE.PerspectiveCamera(
45, // kąt patrzenia kamery (FOV - field of view)
0.8*window.innerWidth / window.innerHeight, // proporcje widoku, powinny odpowiadać proporjom naszego ekranu przeglądarki
0.1, // minimalna renderowana odległość
10000 // maxymalna renderowana odległość
);
this.renderer = new THREE.WebGLRenderer();
this.renderer.setClearColor(0x76716A);
this.renderer.setSize( window.innerWidth, window.innerHeight);
var a = "76716A";
var axis = new THREE.AxisHelper(200000000);
this.scene.add(axis);
var light = new THREE.SpotLight(0xffffff, 100,500, 3.14);
light.position.set(0, -101, 100);
this.scene.add(light);
document.getElementById("LoadingScreen").appendChild(this.renderer.domElement);
this.camera.position.x = 0;
this.camera.position.y = 120;
this.camera.position.z = -150;
this.camera.lookAt(0,100, 250);
function Model() {
var daeModel
this.loadModel = function (url, callback) {
var loader = new THREE.ColladaLoader();
loader.load(url, function (collada) {
daeModel = collada.scene;
daeModel.scale.set(10, 10, 10)
daeModel.traverse(function (child) {
if (child instanceof THREE.Mesh) {
}
});
callback(daeModel)
})
}
this.getModel = function () {
return daeModel
}
}
var model = new Model();
var witch = null;
model.loadModel ("model/Witcher2.xml", function (modelData) {
witch = modelData;
modelData.position.y -= 100;
modelData.position.z -= 250;
modelData.rotation.y = Math.PI;
//modelData.position.z -= 50;
that.scene.add(modelData)
var newpos = new THREE.Vector3(modelData.position.x,modelData.position.y+50,modelData.position.z)
that.camera.lookAt(newpos);
that.camera.position.z -= 30;
/*function animateScene() {
requestAnimationFrame(animateScene);
modelData.rotation.z += 0.005
}
animateScene();*/
})
this.stop = false;
function animateScene() {
if(!that.stop)
{
requestAnimationFrame(animateScene);
}
if(witch)
{
witch.rotation.z += 0.005;
}
that.renderer.render(that.scene, that.camera);
}
animateScene();
} | 34.906667 | 129 | 0.576776 |
466c14c13950d2bfea8d316b9c64ea87da28080d | 1,312 | js | JavaScript | 10react/code20/react-hkzf/src/components/AuthRoute/index.js | nacker/web | 62a725ebc4891c78a437bcef9b57f2f3bd80b85d | [
"Apache-2.0"
] | 2 | 2019-12-03T08:57:24.000Z | 2019-12-04T03:40:25.000Z | 10react/code20/react-hkzf/src/components/AuthRoute/index.js | nacker/web | 62a725ebc4891c78a437bcef9b57f2f3bd80b85d | [
"Apache-2.0"
] | null | null | null | 10react/code20/react-hkzf/src/components/AuthRoute/index.js | nacker/web | 62a725ebc4891c78a437bcef9b57f2f3bd80b85d | [
"Apache-2.0"
] | null | null | null | import React from 'react'
import { Route, Redirect } from 'react-router-dom'
import { isAuth } from '../../utils'
/*
① 在 components 目录中创建 AuthRoute/index.js 文件。
② 创建组件 AuthRoute 并导出。
③ 在 AuthRoute 组件中返回 Route 组件(在 Route 基础上做了一层包装,用于实现自定义功能)。
④ 给 Route 组件,添加 render 方法,指定该组件要渲染的内容(类似于 component 属性)。
⑤ 在 render 方法中,调用 isAuth() 判断是否登录。
⑥ 如果登录了,就渲染当前组件(通过参数 component 获取到要渲染的组件,需要重命名)。
⑦ 如果没有登录,就重定向到登录页面,并且指定登录成功后要跳转到的页面路径。
⑧ 将 AuthRoute 组件接收到的 props 原样传递给 Route 组件(保证与 Route 组件使用方式相同)。
⑨ 使用 AuthRoute 组件配置路由规则,验证能否实现页面的登录访问控制。
// 去出租页面:
<AuthRoute path="/rent/add" component={RentAdd} />
*/
const AuthRoute = ({ component: Component, ...rest }) => {
return (
<Route
{...rest}
render={props => {
// props 表示:当前路由信息
if (isAuth()) {
// 登录
// 注意:需要将 props 也就是路由信息传递给该组件,才能在被渲染的组件中获取到路由信息
return <Component {...props} />
} else {
// 没有登录
return (
<Redirect
to={{
// 要跳转到的页面路径
pathname: '/login',
// 传递额外的数据,此处,用来指定登录后要返回的页面路径
state: { from: props.location }
}}
/>
)
}
}}
/>
)
}
export default AuthRoute
| 26.24 | 65 | 0.537348 |
466ca7c74f213aa39a941fee427e33f43ffab511 | 1,682 | js | JavaScript | packages/transform-metering/test/test-transform.js | ctjlewis/agoric-sdk | 05e43706fad9988d2571971e46f98aba7ad2435c | [
"Apache-2.0"
] | null | null | null | packages/transform-metering/test/test-transform.js | ctjlewis/agoric-sdk | 05e43706fad9988d2571971e46f98aba7ad2435c | [
"Apache-2.0"
] | null | null | null | packages/transform-metering/test/test-transform.js | ctjlewis/agoric-sdk | 05e43706fad9988d2571971e46f98aba7ad2435c | [
"Apache-2.0"
] | null | null | null | /* eslint-disable no-await-in-loop */
import test from 'ava';
import fs from 'fs';
import path from 'path';
import { makeMeteringTransformer } from '../src/index.js';
import * as c from '../src/constants.js';
const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
test('meter transform', async t => {
let getMeter;
const meteringTransform = makeMeteringTransformer(undefined, {
overrideMeterId: '$m',
overrideRegExpIdPrefix: '$re_',
});
const rewrite = (source, testName) => {
let cMeter;
getMeter = () => ({
[c.METER_COMPUTE]: units => (cMeter = units),
});
const ss = meteringTransform.rewrite({
src: source,
endowments: { getMeter },
sourceType: 'script',
});
t.is(cMeter, source.length, `compute meter updated ${testName}`);
return ss.src;
};
t.throws(
() => rewrite(`$m.l()`, 'blacklisted meterId'),
{ instanceOf: SyntaxError },
'meterId cannot appear in source',
);
const base = `${dirname}/../testdata`;
const tests = await fs.promises.readdir(base);
for (const testDir of tests) {
const src = await fs.promises.readFile(
`${base}/${testDir}/source.js`,
'utf8',
);
const rewritten = await fs.promises
.readFile(`${base}/${testDir}/rewrite.js`, 'utf8')
// Fix golden files in case they have DOS or MacOS line endings.
.then(s => s.replace(/(\r\n|\r)/g, '\n'))
.catch(_ => undefined);
const transformed = rewrite(src.trimRight(), testDir);
if (rewritten === undefined) {
console.log(transformed);
}
t.is(transformed, rewritten.trimRight(), `rewrite ${testDir}`);
}
});
| 28.508475 | 70 | 0.619501 |
466cd9d54bd29175bd7a9d25226bc0dfe49ed6ab | 3,814 | js | JavaScript | client/src/components/allInfo/FullPageWeeklySpecials.js | tsbolty/GoingsOn | 79067ea6c12ae994fe39d916c240de309ead9f4a | [
"MIT"
] | null | null | null | client/src/components/allInfo/FullPageWeeklySpecials.js | tsbolty/GoingsOn | 79067ea6c12ae994fe39d916c240de309ead9f4a | [
"MIT"
] | 1 | 2020-08-16T20:58:29.000Z | 2020-08-16T20:58:29.000Z | client/src/components/allInfo/FullPageWeeklySpecials.js | tsbolty/GoingsOn | 79067ea6c12ae994fe39d916c240de309ead9f4a | [
"MIT"
] | null | null | null | import React from 'react';
const FullPageWeeklySpecials = ({ specials }) => {
const tableStyle = {
paddingLeft: "20px",
paddingRight: "20px"
}
return (
<div className="weekly-specials">
<h4>Weekly Specials</h4>
{specials.weeklySpecials && specials.weeklySpecials.map(special => (
<table key= {special._id}>
<thead>
<tr>
<th style={tableStyle} className="weekly-specials-table-header">Monday</th>
<th style={tableStyle} className="weekly-specials-table-header">Tuesday</th>
<th style={tableStyle} className="weekly-specials-table-header">Wednesday</th>
<th style={tableStyle} className="weekly-specials-table-header">Thursday</th>
<th style={tableStyle} className="weekly-specials-table-header">Friday</th>
<th style={tableStyle} className="weekly-specials-table-header">Saturday</th>
<th style={tableStyle} className="weekly-specials-table-header">Sunday</th>
</tr>
</thead>
<tbody>
<tr>
<td style={tableStyle}><strong>{special.mondayFoodSpecialHeading}</strong></td>
<td style={tableStyle}><strong>{special.tuesdayFoodSpecialHeading}</strong></td>
<td style={tableStyle}><strong>{special.wednesdayFoodSpecialHeading}</strong></td>
<td style={tableStyle}><strong>{special.thursdayFoodSpecialHeading}</strong></td>
<td style={tableStyle}><strong>{special.fridayFoodSpecialHeading}</strong></td>
<td style={tableStyle}><strong>{special.saturdayFoodSpecialHeading}</strong></td>
<td style={tableStyle}><strong>{special.sundayFoodSpecialHeading}</strong></td>
</tr>
<tr>
<td style={tableStyle}>{special.mondayFoodSpecialDescription}</td>
<td style={tableStyle}>{special.tuesdayFoodSpecialDescription}</td>
<td style={tableStyle}>{special.wednesdayFoodSpecialDescription}</td>
<td style={tableStyle}>{special.thursdayFoodSpecialDescription}</td>
<td style={tableStyle}>{special.fridayFoodSpecialDescription}</td>
<td style={tableStyle}>{special.saturdayFoodSpecialDescription}</td>
<td style={tableStyle}>{special.sundayFoodSpecialDescription}</td>
</tr>
<tr>
<td style={tableStyle}><strong>{special.mondayDrinkSpecialHeading}</strong></td>
<td style={tableStyle}><strong>{special.tuesdayDrinkSpecialHeading}</strong></td>
<td style={tableStyle}><strong>{special.wednesdayDrinkSpecialHeading}</strong></td>
<td style={tableStyle}><strong>{special.thursdayDrinkSpecialHeading}</strong></td>
<td style={tableStyle}><strong>{special.fridayDrinkSpecialHeading}</strong></td>
<td style={tableStyle}><strong>{special.saturdayDrinkSpecialHeading}</strong></td>
<td style={tableStyle}><strong>{special.sundayDrinkSpecialHeading}</strong></td>
</tr>
<tr>
<td style={tableStyle}>{special.mondayDrinkSpecialDescription}</td>
<td style={tableStyle}>{special.tuesdayDrinkSpecialDescription}</td>
<td style={tableStyle}>{special.wednesdayDrinkSpecialDescription}</td>
<td style={tableStyle}>{special.thursdayDrinkSpecialDescription}</td>
<td style={tableStyle}>{special.fridayDrinkSpecialDescription}</td>
<td style={tableStyle}>{special.saturdayDrinkSpecialDescription}</td>
<td style={tableStyle}>{special.sundayDrinkSpecialDescription}</td>
</tr>
</tbody>
</table>
))}
</div>
)
}
export default FullPageWeeklySpecials; | 54.485714 | 97 | 0.628474 |
466ced12425c3a731ec9b1b37d5f3340cc098797 | 148 | js | JavaScript | frontend/portals/CartItemSubscriptionInfo/components/Label/styles.js | shopgate-professional-services/ext-recharge | 3c6267730000e74733b5ccdac63862faf616b107 | [
"Apache-2.0"
] | null | null | null | frontend/portals/CartItemSubscriptionInfo/components/Label/styles.js | shopgate-professional-services/ext-recharge | 3c6267730000e74733b5ccdac63862faf616b107 | [
"Apache-2.0"
] | 2 | 2019-09-04T08:58:39.000Z | 2020-03-04T13:16:05.000Z | frontend/portals/CartItemSubscriptionInfo/components/Label/styles.js | shopgate-professional-services/ext-recharge | 3c6267730000e74733b5ccdac63862faf616b107 | [
"Apache-2.0"
] | null | null | null | import { css } from 'glamor';
const label = css({
fontSize: '12px',
justifyContent: 'space-between',
}).toString();
export default { label };
| 16.444444 | 34 | 0.648649 |
466d760ce413b7ce06e006527917ce4a56c63c45 | 887 | js | JavaScript | rollup.config.js | exuanbo/module-from-string | abe8506e6e06bbb001d1d825d641f5e8f6f3d764 | [
"MIT"
] | 14 | 2021-02-21T20:24:04.000Z | 2022-03-29T16:41:35.000Z | rollup.config.js | exuanbo/module-from-string | abe8506e6e06bbb001d1d825d641f5e8f6f3d764 | [
"MIT"
] | 14 | 2020-12-09T18:58:23.000Z | 2021-12-17T23:03:56.000Z | rollup.config.js | exuanbo/module-from-string | abe8506e6e06bbb001d1d825d641f5e8f6f3d764 | [
"MIT"
] | null | null | null | import esbuild from 'rollup-plugin-esbuild-transform'
import dts from 'rollup-plugin-dts'
import pkg from './package.json'
export default [
{
external: ['module', 'path', 'url', 'vm', ...Object.keys(pkg.dependencies), 'nanoid/async'],
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs'
},
{
file: pkg.module,
format: 'es'
}
],
plugins: [
esbuild([
{
loader: 'ts'
},
{
output: true,
target: 'node12.20.0'
}
]),
{
name: 'dynamic-import',
renderDynamicImport() {
return {
left: 'import(',
right: ')'
}
}
}
]
},
{
input: '.cache/index.d.ts',
output: {
file: pkg.types,
format: 'es'
},
plugins: [dts()]
}
]
| 18.102041 | 96 | 0.438557 |
466e0db06af60987c4041a0f7950665ed2dfa705 | 7,604 | js | JavaScript | api_demo/components/types/list.js | Dorajs/samples | 0960cc9ce967407af238958fdfdb098a295344b6 | [
"MIT"
] | 69 | 2020-03-29T13:26:22.000Z | 2022-02-09T05:04:29.000Z | api_demo/components/types/list.js | DoraKit/addons | 0960cc9ce967407af238958fdfdb098a295344b6 | [
"MIT"
] | 2 | 2020-05-17T07:23:08.000Z | 2021-02-27T16:21:59.000Z | api_demo/components/types/list.js | DoraKit/addons | 0960cc9ce967407af238958fdfdb098a295344b6 | [
"MIT"
] | 14 | 2020-04-15T15:13:51.000Z | 2022-02-07T04:17:14.000Z | const fs = require('fs')
module.exports = {
type: 'list',
style: 'simple',
actions: [
{
id: 'update_menu',
title: 'Update title',
onClick: async function () {
let newTitle = await $input.prompt({
title: 'Update title',
hint: 'new title',
value: this.title
})
this.title = newTitle
}
}
],
async fetch() {
return [
// label
{
title: '样式: label',
style: 'category'
},
{
title: 'Label 1',
style: 'label'
},
{
title: 'Label 2',
style: 'label'
},
{
title: 'Label 3',
style: 'label'
},
{
title: 'Label 4',
style: 'label'
},
// chips
{
title: '样式: chips',
style: 'category'
},
{
title: 'Chips title',
style: 'chips',
actions: [
{
title: 'Action 1'
},
{
title: 'Action 2'
},
{
title: 'Action 3'
},
{
title: 'Action 4'
}
]
},
// simple
{
title: '样式:simple',
style: 'category'
},
{
title: 'Hello World!',
style: 'simple'
},
{
title: 'Hello World!',
style: 'simple',
summary: '一个简单的样式'
},
{
title: 'Hello World!',
style: 'simple',
image: $icon('face', 'black'),
summary: '一个简单的样式'
},
// icon
{
title: '样式:icon',
style: 'category'
},
{
title: 'icon',
style: 'icon',
image: $icon('face', 'red')
},
{
title: 'icon',
style: 'icon',
image: $icon('code')
},
{
title: 'icon',
style: 'icon',
image: $icon('build', 'green')
},
// dashboard
{
title: '样式:dashboard',
style: 'category'
},
{
style: 'dashboard',
image: $icon('memory'),
title: '内存使用',
summary: '1024 MB',
color: '#8B355E',
textColor: 'white'
},
{
style: 'dashboard',
image: $icon('battery_alert'),
title: '电池使用',
summary: '1024MB',
color: '#81AF37',
textColor: 'white'
},
// vod
{
title: '样式:vod',
style: 'category'
},
{
title: '冰雪奇缘2',
style: 'vod',
thumb:
'https://p0.meituan.net/moviemachine/58ee13be6dc60bf5e636cf915bbbaaa55787785.jpg@464w_644h_1e_1c',
label: '喜剧,动画,冒险',
summary:
'为什么艾莎(伊迪娜·门泽尔 配音)天生就拥有神奇魔法?谜题的答案一直呼唤着她,也威胁着王国的安全。她将和安娜(克里斯汀·贝尔 配音)、克斯托夫(乔纳森·格罗夫 配音)、雪宝(乔什·盖德 配音)和驯鹿斯特共同开启一场非凡的冒险旅程。艾莎曾担心世界不能接受自己的冰雪魔法,但在《冰雪奇缘2》中她却必须祈祷自己的魔法足够强大,能够拯救世界。本片由奥斯卡金牌团队打造——导演珍妮弗·李和克里斯·巴克、制作人彼得·戴尔·维克以及词曲作者克里斯汀·安德森-洛佩兹及罗伯特·洛佩兹悉数回归,原配音班底伊迪娜·门泽尔、克里斯汀·贝尔、乔纳森·格罗夫和乔什·盖德再度加盟。华特迪士尼动画工作室荣誉出品《冰雪奇缘2》将于2019年11月22日登陆北美院线。'
},
{
title: '复仇者联盟4:终局之战d',
style: 'vod',
thumb:
'https://p0.meituan.net/moviemachine/f7d2ad70eb79d6d9b8a197713db9b8c41711752.jpg@464w_644h_1e_1c',
label: '动作,冒险,奇幻',
summary:
'一声响指,宇宙间半数生命灰飞烟灭。几近绝望的复仇者们在惊奇队长(布丽·拉尔森 饰)的帮助下找到灭霸(乔什·布洛林 饰)归隐之处,却得知六颗无限宝石均被销毁,希望彻底破灭。如是过了五年,迷失在量子领域的蚁人(保罗·路德 饰)意外回到现实世界,他的出现为幸存的复仇者们点燃了希望。与美国队长(克里斯·埃文斯 饰)冰释前嫌的托尼(小罗伯特·唐尼 饰)找到了穿越时空的方法,星散各地的超级英雄再度集结,他们分别穿越不同的时代去搜集无限宝石。而在这一过程中,平行宇宙的灭霸察觉了他们的计划。 注定要载入史册的最终决战,超级英雄们为了心中恪守的信念前仆后继……'
},
// live
{
title: '样式:live',
style: 'category'
},
{
title: 'Coding...',
style: 'live',
image: 'https://weiliicimg9.pstatp.com/weili/l/778002376200945690.webp',
label: '英雄联盟',
viewerCount: '1.1k',
author: {
name: 'linroid',
avatar: 'https://linroid.com/avatar.png'
}
},
{
title: 'Coding...',
style: 'live',
image: 'https://weiliicimg9.pstatp.com/weili/l/778002376200945690.webp',
label: '英雄联盟',
author: {
name: 'linroid',
avatar: 'https://linroid.com/avatar.png'
}
},
{
title: 'Coding...',
style: 'live',
image: 'https://weiliicimg9.pstatp.com/weili/l/778002376200945690.webp',
spanCount: 12,
label: '英雄联盟',
author: {
name: 'linroid',
avatar: 'https://linroid.com/avatar.png'
}
},
// richMedia
{
title: '样式:richMedia',
style: 'category'
},
{
title: 'Title goes here',
style: 'richMedia',
image: 'https://weiliicimg9.pstatp.com/weili/l/778002376200945690.webp',
rating: {
score: 4.5,
total: 5,
text: '4.5(1000)'
},
summary:
'Secondary line text Lorem ipsum dolor sit amet, nec no nominavi scaevola. Per et sint sapientem, nobis perpetua salutandi mei te.',
subtitle: 'Subtitle goes here',
tags: [
{
title: 'Tag 1',
onClick: this.simpleOnClick
},
{
title: 'Tag 2',
onClick: this.simpleOnClick
},
{
title: 'Tag 3',
onClick: this.simpleOnClick
}
],
actions: [
{
title: 'Action1',
onClick: this.simpleOnClick
},
{
title: 'Action 2',
onClick: this.simpleOnClick
}
]
},
// category
{
title: '样式:gallery',
style: 'category'
},
{
title: 'gallery',
style: 'gallery',
image: 'https://weiliicimg9.pstatp.com/weili/l/778002376200945690.webp',
author: {
name: 'linroid',
avatar: 'https://avatars0.githubusercontent.com/u/3192142?s=460&v=4'
}
},
// category
{
title: '样式:book',
style: 'category'
},
{
image: 'https://img1.doubanio.com/view/subject/l/public/s2768378.jpg',
title: '三体',
style: 'book'
},
{
image: 'https://img3.doubanio.com/view/subject/l/public/s8958650.jpg',
title: 'JavaScript高级程序设计',
style: 'book'
},
// article
{
title: '样式: article',
style: 'category'
},
{
time: 'just now',
title: '任天堂 Switch 国行版上市, 腾讯提供本地化网络服务',
style: 'article',
author: {
name: 'xx媒体'
},
image: 'https://weiliicimg9.pstatp.com/weili/l/778002376200945690.webp',
summary:
'12 月 4 日,腾讯集团和任天堂在上海举行发布会,宣布腾讯引进的任天堂新世代游戏机 Nintendo Switch 将于 12 月 10 日正式发售 ... 有「马力欧之父」称号的任天堂株式会社代表取缔役、专门领域开发主导宫本茂通过视频形式表示:任天堂长久以来,一直希望可以为中国顾客提供任天堂的游戏娱乐,现在这个梦想得以实现,真的感到十分高兴,也十分感谢 ... 腾讯游戏任天堂合作部总经理钱赓介绍,关于未来 Nintendo Switch 的网络服务方面,腾讯在国内架设了适合中国网络环境的网络系统,将通过云服务,设立了本地化的网络服务'
},
// richContent
{
title: '样式: richContent',
style: 'category'
},
{
title: 'README.md',
style: 'richContent',
content: {
url: 'https://docs.dorajs.com/',
markdown: this.readReadme()
}
},
{
title: '百度一下',
style: 'richContent',
content: {
url: 'https://baidu.com/'
}
}
]
},
simpleOnClick(data) {
$ui.toast(`onClick ${JSON.stringify(data)}`)
},
readReadme() {
return fs.readFileSync('./README.md', { encoding: 'utf8' })
}
}
| 25.09571 | 330 | 0.48343 |
466e97e5b3cd689cb05ca14a968664e265930809 | 2,312 | js | JavaScript | src/array-source.js | emaclean03/nova-tables | 2eda241c351fce3fa4c0614fdea63510a04e0c30 | [
"MIT"
] | 5 | 2018-06-30T06:28:21.000Z | 2022-01-14T22:40:17.000Z | src/array-source.js | emaclean03/nova-tables | 2eda241c351fce3fa4c0614fdea63510a04e0c30 | [
"MIT"
] | 5 | 2018-04-09T18:44:20.000Z | 2022-01-25T19:42:48.000Z | src/array-source.js | emaclean03/nova-tables | 2eda241c351fce3fa4c0614fdea63510a04e0c30 | [
"MIT"
] | 13 | 2018-04-06T17:46:59.000Z | 2022-02-03T14:52:38.000Z | import FuzzyMatcher from './fuzzy-matcher.js';
import AbstractSource from './abstract-source.js';
class ArraySource extends AbstractSource
{
constructor(items, matcher) {
super();
this.items = items;
this.filterClosures = [];
this.matcher = matcher || new FuzzyMatcher();
}
addFilter(filter) {
this.filterClosures.push(filter);
}
get() {
var promise = Promise.resolve(this.items);
this.filterClosures.map((filter) => {
promise = promise.then(filter);
});
return promise
.then((items) => {
return items.filter((item) => {
if (this.search) {
// find out if any fields match
return _.find(this.search_fields, (field) => {
return this.matcher.matches(this.search, item[field]);
});
}
return true;
});
})
.then((items) => {
var sort_field = this.sort_field;
return items.sort((a, b) => {
if (a[sort_field] < b[sort_field]) {
return this.sort_direction === 'A' ? -1 : 1;
} else if (a[sort_field] > b[sort_field]) {
return this.sort_direction === 'A' ? 1 : -1;
}
return 0;
});
})
.then((items) => {
var page_length = this.page_length || items.length;
if (!this.page) {
this.page = 1;
}
var pageCount = page_length ? Math.ceil(items.length / page_length) : 1;
if (this.page > pageCount) {
this.page = pageCount;
}
var totalCount = items.length;
items = items.slice((this.page - 1) * page_length, this.page * page_length);
return {
items: items,
pageCount: pageCount,
page: this.page,
totalCount: totalCount,
};
});
}
}
export default ArraySource;
| 34.507463 | 92 | 0.429066 |
466f07f716d866bc648e1e7fb50d2b7bbc8a43a3 | 1,167 | js | JavaScript | src/middleware/service/member/createList.js | ufwd-dev/system | 8773ad1e9c8ea2c03970f435580fafda74edace1 | [
"MIT"
] | 1 | 2020-07-28T12:07:13.000Z | 2020-07-28T12:07:13.000Z | src/middleware/service/member/createList.js | ufwd-dev/system | 8773ad1e9c8ea2c03970f435580fafda74edace1 | [
"MIT"
] | 20 | 2018-06-17T21:41:33.000Z | 2019-07-27T12:09:04.000Z | src/middleware/service/member/createList.js | ufwd-dev/system | 8773ad1e9c8ea2c03970f435580fafda74edace1 | [
"MIT"
] | null | null | null | 'use strict';
const { throwError} = require('error-standardize');
const Sequelize = require('sequelize');
module.exports = function* createMemberList(req, res, next) {
const {accountId} = req.params;
const {groupPool} = req.body;
const Member = res.sequelize.model('ufwdMember');
const UfwdAccount = res.sequelize.model('ufwdAccount');
const Group = res.sequelize.model('ufwdGroup');
const ufwdAccount = yield UfwdAccount.findOne({
where: {
accountId
}
});
if (!ufwdAccount) {
throwError('The account is not exist.', 403);
}
const groupList = yield Group.findAll({
where: {
id: {
[Sequelize.Op.in]: groupPool
}
}
});
const group = groupList.map(group => group.id);
const accountMemberList = yield Member.findAll({
where: {
accountId,
groupId: {
[Sequelize.Op.in]: groupPool
}
}
});
const member = accountMemberList.map(member => member.groupId);
const list = group.filter(item => {
if (member.indexOf(item) === -1) {
return true;
}
}).map(item => {
return {
accountId,
groupId: item
};
});
const memberList = yield Member.bulkCreate(list);
res.data(memberList);
next();
}; | 18.822581 | 64 | 0.651243 |
466fbd0e48433449b1366e7fb01a919c4ff5849b | 5,884 | js | JavaScript | ssc/export-annotated-parts.js | jb892/sstk | afc0bbb3da0dbdfc14f9b838e92211d3cba20c86 | [
"MIT"
] | null | null | null | ssc/export-annotated-parts.js | jb892/sstk | afc0bbb3da0dbdfc14f9b838e92211d3cba20c86 | [
"MIT"
] | null | null | null | ssc/export-annotated-parts.js | jb892/sstk | afc0bbb3da0dbdfc14f9b838e92211d3cba20c86 | [
"MIT"
] | null | null | null | #!/usr/bin/env node
var fs = require('fs');
var async = require('async');
var shell = require('shelljs');
var STK = require('./stk-ssc');
var cmd = require('commander');
cmd
.version('0.0.1')
.description('Export part annotations')
.option('--id <id>', 'Model id [default: 101]', STK.util.cmd.parseList, ['101'])
.option('--source <source>', 'Model source [default: p5d]', 'p5d')
// .option('--ann_type <type>', 'Annotation type', /^(raw|clean|aggr)$/)
.option('-n, --ann_limit <num>', 'Limit on number of annotations to export', STK.util.cmd.parseInt, 1)
.option('--output_dir <dir>', 'Base directory for output files', '.')
.option('--include_annId [flag]', 'Whether to include ann id in output filename', STK.util.cmd.parseBoolean, false)
.option('--skip_existing [flag]', 'Whether to skip output of existing files', STK.util.cmd.parseBoolean, false)
.parse(process.argv);
var argv = cmd;
// Parse arguments and initialize globals
var skip_existing = argv.skip_existing;
var assetManager = new STK.assets.AssetManager({ autoAlignModels: false, autoScaleModels: false });
var ids = argv.id;
var assets = require('./data/assets.json');
var assetsMap = _.keyBy(assets, 'name');
STK.assets.registerCustomAssetGroupsSync(assetsMap, [argv.source]);
var assetGroup = STK.assets.AssetGroups.getAssetGroup(argv.source);
var assetsDb = assetGroup? assetGroup.assetDb : null;
if (!assetsDb) {
console.log('Unrecognized asset source ' + argv.source);
return;
}
if (ids.indexOf('all') >= 0) {
ids = assetsDb.getAssetIds().map(function (x) {
return x.split('.', 2)[1];
});
} else if (ids.indexOf('annotated') >= 0) {
var annotationsUrl = STK.Constants.baseUrl + '/part-annotations/list?format=json&$columns=itemId';
var data = STK.util.readSync(annotationsUrl);
var itemIds = _.uniq(JSON.parse(data).map(function(x) { return x.itemId; })).filter(function(x) { return x; });
ids = itemIds.map(function (x) {
return x.split('.', 2)[1];
});
} else {
if (ids.length === 1 && ids[0].endsWith('.txt')) {
// Read files form input file
var data = STK.util.readSync(ids[0]);
ids = data.split('\n').map(function(x) { return STK.util.trim(x); }).filter(function(x) { return x.length > 0; });
}
}
var source = argv.source;
var segmentsType = 'part-annotations';
// if (argv.ann_type === 'raw') {
// segmentsType = 'segment-annotations-raw';
// } else if (argv.ann_type === 'clean') {
// segmentsType = 'segment-annotations-clean';
// }
var annNum = argv.ann_limit;
console.log('segmentsType is ' + segmentsType);
var segments = new STK.geo.Segments({ showNodeCallback: function (segmentedObject3D) { } }, segmentsType);
function exportAnnotation(loadInfo, outdir, callback) {
shell.mkdir('-p', outdir);
assetManager.getModelInstanceFromLoadModelInfo(loadInfo, function (mInst) {
segments.init(mInst);
mInst.model.info.annId = loadInfo.annId;
segments.loadSegments(function (err, res) {
if (!err) {
var id = loadInfo.id;
var annId = loadInfo.annId;
var annIndex = loadInfo.annIndex;
var basename = id;
if (argv.include_annId) {
basename = (annId != undefined)? id + '_' + annIndex : id;
} else {
basename = (annIndex != undefined) ? id + '_' + annIndex : id;
}
basename = outdir + '/' + basename;
segments.indexedSegmentation.annId = loadInfo.annId;
fs.writeFileSync(basename + '.json', JSON.stringify(segments.indexedSegmentation));
callback(err, res);
} else {
console.error(err, res);
callback(err, res);
}
});
});
}
function processIds(ids, outdir, doneCallback) {
async.forEachSeries(ids, function (id, callback) {
var mInfo = assetsDb.getAssetInfo(argv.source + '.' + id);
var loadInfo = assetManager.getLoadModelInfo(argv.source, id, mInfo);
var segmentsInfo = loadInfo[segmentsType];
STK.util.clearCache();
var basename = outdir + '/' + id;
console.log('skip_existing is ' + skip_existing);
if (skip_existing && shell.test('-d', basename)) {
console.warn('Skipping existing output at: ' + basename);
setTimeout(function () { callback(); }, 0);
} else if (segmentsInfo) {
if (segmentsInfo.files && segmentsInfo.files.annIds) {
console.log('fetching from ' + segmentsInfo.files.annIds);
STK.util.getJSON(segmentsInfo.files.annIds)
.done(function (data) {
shell.mkdir('-p', basename);
data.forEach(function(x) {
if (typeof x.data === 'string') {
x.data = JSON.parse(x.data);
}
});
fs.writeFileSync(basename + '/' + id + '.anns.json', JSON.stringify(data));
var annIds = data.map(function (rec) {
return rec.id;
});
if (annNum > 0) {
annIds = _.sortBy(annIds, function(id) { return -id; });
annIds = _.take(annIds, annNum);
}
async.forEachOfSeries(annIds, function (annId, index, cb) {
var loadInfoCopy = _.clone(loadInfo);
loadInfoCopy.annId = annId;
loadInfoCopy.annIndex = (annNum !== 1)? index : undefined;
exportAnnotation(loadInfoCopy, basename, cb);
}, function (err, results) {
callback(err, results);
});
})
.fail(function (err) {
callback(err, null);
})
} else {
exportAnnotation(loadInfo, basename, callback);
}
} else {
setTimeout(function () { callback('No annotations for ' + id + ', segmentsType ' + segmentsType, null); }, 0);
}
}, function (err, results) {
if (doneCallback) {
doneCallback(err, results);
} else {
console.log('DONE');
}
});
}
processIds(ids, argv.output_dir);
| 38.207792 | 118 | 0.613528 |
46706636548d0f7b73c880cbd0fde87549828c39 | 438 | js | JavaScript | src/Components/PlayPause/stories.js | booyaa/breathe | 8a1893abcdadb160f879943fc6d69d761c714d4d | [
"MIT"
] | 1 | 2018-09-21T12:46:17.000Z | 2018-09-21T12:46:17.000Z | src/Components/PlayPause/stories.js | booyaa/breathe | 8a1893abcdadb160f879943fc6d69d761c714d4d | [
"MIT"
] | null | null | null | src/Components/PlayPause/stories.js | booyaa/breathe | 8a1893abcdadb160f879943fc6d69d761c714d4d | [
"MIT"
] | null | null | null | import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import PlayPause from '.';
export const mode = {
isPlaying: true
}
export const actions = {
onPressed: action('onPressed')
}
storiesOf('PlayPause', module)
.add('default', () => <PlayPause mode={mode} {...actions}/>)
.add('paused', () => <PlayPause mode={{...mode, isPlaying: false}} {...actions} />)
; | 24.333333 | 83 | 0.648402 |
46711904cc4641eb080bad14c836c957e20c57bb | 1,386 | js | JavaScript | intervalMessages/rule.js | TelevisionNinja/Row-Bot | 8403e82a318639bd3da541ee5484afe9efa4f773 | [
"MIT"
] | null | null | null | intervalMessages/rule.js | TelevisionNinja/Row-Bot | 8403e82a318639bd3da541ee5484afe9efa4f773 | [
"MIT"
] | null | null | null | intervalMessages/rule.js | TelevisionNinja/Row-Bot | 8403e82a318639bd3da541ee5484afe9efa4f773 | [
"MIT"
] | null | null | null | import { getImageRule0 } from '../commands/rule.js';
import { default as config } from '../config.json';
import DailyInterval from 'daily-intervals';
import {
getChannel,
sendImg
} from '../lib/msgUtils.js';
import { tagArrToParsedTagArr } from '../lib/stringUtils.js';
import { randomMath } from '../lib/randomFunctions.js';
import { cutOff } from '../lib/stringUtils.js';
const ruleConfig = config.rule,
noResultsMsg = config.noResultsMsg;
const filter = ruleConfig.filterTags.map(t => `-${t}`);
// posts a daily rule image
export async function execute(client) {
const recipient = await getChannel(client, ruleConfig.intervalChannelID);
const interval = new DailyInterval(
async () => {
const randIndex = randomMath(ruleConfig.intervalTags.length);
const selection = ruleConfig.intervalTags[randIndex];
let tagArr = [selection, ...filter];
tagArr = tagArrToParsedTagArr(tagArr, ruleConfig.sites[0].whitespace);
const img = await getImageRule0(tagArr);
if (img.results) {
sendImg(recipient, img, false);
}
else {
recipient.send(cutOff(`${noResultsMsg}\nTags:\n\`${tagArr}\``, 2000));
}
},
'0:0',
ruleConfig.intervalWait,
5000 // 5 second offset
);
interval.start();
}
| 30.8 | 86 | 0.619048 |
46717225a3ac84ac1b47a3ef602173f6be54c381 | 543 | js | JavaScript | Fundamentals Project HOOKS,ROUTES,API/15.course-goals/src/Components/CourseGoals/CourseGoalList/CourseGoalList.js | georgiangelov2000/React-Js-Development | f4ce52127fb10f94e453663c970ddb529b688175 | [
"MIT"
] | null | null | null | Fundamentals Project HOOKS,ROUTES,API/15.course-goals/src/Components/CourseGoals/CourseGoalList/CourseGoalList.js | georgiangelov2000/React-Js-Development | f4ce52127fb10f94e453663c970ddb529b688175 | [
"MIT"
] | null | null | null | Fundamentals Project HOOKS,ROUTES,API/15.course-goals/src/Components/CourseGoals/CourseGoalList/CourseGoalList.js | georgiangelov2000/React-Js-Development | f4ce52127fb10f94e453663c970ddb529b688175 | [
"MIT"
] | null | null | null | import React from "react";
import styled from "styled-components";
import CourseGoalItem from "../CourseGoalItem/CourseGoalItem";
const GoalList = styled.ul`
list-style: none;
margin: 0;
padding: 0;
`;
const CourseGoalList = (props) => {
return (
<GoalList>
{props.items.map((goal) => (
<CourseGoalItem
key={goal.id}
id={goal.id}
onDelete={props.onDeleteItem}
>
{goal.text}
</CourseGoalItem>
))}
</GoalList>
);
};
export default CourseGoalList;
| 18.724138 | 62 | 0.59116 |
4671a17c055eb9603c8a86086ee04deee08148ca | 2,659 | js | JavaScript | CUDA/matrix_mult/node_modules/mathjs/lib/function/statistics/min.js | leiverandres/HPC_assignments | 54e9099b7834362181c4a05b50b0b179fb7b8e60 | [
"MIT"
] | 8 | 2018-12-18T16:18:55.000Z | 2020-02-22T09:31:36.000Z | node_modules/mathjs/lib/function/statistics/min.js | Alekcy/vacancy-analysis | 0938e90db8827ac33036996b8492df4ebce0ad0c | [
"MIT"
] | 2 | 2020-08-26T15:34:56.000Z | 2021-06-03T21:37:12.000Z | node_modules/mathjs/lib/function/statistics/min.js | Alekcy/vacancy-analysis | 0938e90db8827ac33036996b8492df4ebce0ad0c | [
"MIT"
] | 2 | 2019-02-20T20:36:57.000Z | 2020-01-21T12:38:41.000Z | 'use strict';
var deepForEach = require('../../utils/collection/deepForEach');
var reduce = require('../../utils/collection/reduce');
var containsCollections = require('../../utils/collection/containsCollections');
function factory (type, config, load, typed) {
var smaller = load(require('../relational/smaller'));
/**
* Compute the maximum value of a matrix or a list of values.
* In case of a multi dimensional array, the maximum of the flattened array
* will be calculated. When `dim` is provided, the maximum over the selected
* dimension will be calculated. Parameter `dim` is zero-based.
*
* Syntax:
*
* math.min(a, b, c, ...)
* math.min(A)
* math.min(A, dim)
*
* Examples:
*
* math.min(2, 1, 4, 3); // returns 1
* math.min([2, 1, 4, 3]); // returns 1
*
* // maximum over a specified dimension (zero-based)
* math.min([[2, 5], [4, 3], [1, 7]], 0); // returns [1, 3]
* math.min([[2, 5], [4, 3], [1, 7]], 1); // returns [2, 3, 1]
*
* math.max(2.7, 7.1, -4.5, 2.0, 4.1); // returns 7.1
* math.min(2.7, 7.1, -4.5, 2.0, 4.1); // returns -4.5
*
* See also:
*
* mean, median, max, prod, std, sum, var
*
* @param {... *} args A single matrix or or multiple scalar values
* @return {*} The minimum value
*/
var min = typed('min', {
// min([a, b, c, d, ...])
'Array | Matrix': _min,
// min([a, b, c, d, ...], dim)
'Array | Matrix, number | BigNumber': function (array, dim) {
return reduce(array, dim.valueOf(), _smallest);
},
// min(a, b, c, d, ...)
'...': function (args) {
if (containsCollections(args)) {
throw new TypeError('Scalar values expected in function min');
}
return _min(args);
}
});
min.toTex = '\\min\\left(${args}\\right)';
return min;
/**
* Return the smallest of two values
* @param {*} x
* @param {*} y
* @returns {*} Returns x when x is smallest, or y when y is smallest
* @private
*/
function _smallest(x, y) {
return smaller(x, y) ? x : y;
}
/**
* Recursively calculate the minimum value in an n-dimensional array
* @param {Array} array
* @return {number} min
* @private
*/
function _min(array) {
var min = undefined;
deepForEach(array, function (value) {
if (min === undefined || smaller(value, min)) {
min = value;
}
});
if (min === undefined) {
throw new Error('Cannot calculate min of an empty array');
}
return min;
}
}
exports.name = 'min';
exports.factory = factory;
| 26.59 | 80 | 0.544566 |
4671b331fed802d9e81674d5655519bad92687a0 | 1,428 | js | JavaScript | resources/js/AxiosRepository.js | julfiker/laravel-mail | e91551c8304060aad18676fe240511f4deaa17bb | [
"MIT"
] | null | null | null | resources/js/AxiosRepository.js | julfiker/laravel-mail | e91551c8304060aad18676fe240511f4deaa17bb | [
"MIT"
] | null | null | null | resources/js/AxiosRepository.js | julfiker/laravel-mail | e91551c8304060aad18676fe240511f4deaa17bb | [
"MIT"
] | null | null | null | import axios from "axios";
export default {
GET_COMMAND: 'GET',
POST_COMMAND: 'POST',
PUT_COMMAND: 'PUT',
PATCH_COMMAND: 'PATCH',
DELETE_COMMAND: 'DELETE',
apiBasePath: 'http://127.0.0.1:8000/v1',
callApi: async function(requestType='GET', url, params={}, headers={}) {
url = this.apiBasePath + url;
const methodName = requestType.toUpperCase();
if (methodName === 'GET') {
return await axios.get(url, params, headers)
.then(response => {
return response;
})
.catch(error => {
return error;
});
} else if (methodName === 'POST') {
return await axios.post(url, params, headers)
.then(response => {
return response;
})
.catch(error => {
return error;
});
} else if ((methodName === 'PUT') || (methodName === 'PATCH')) {
return await axios.put(url, params, headers)
.then(response => {
return response;
});
} else if (methodName === 'DELETE') {
return await axios.delete(url, params, headers)
.then(response => {
return response;
});
} else {
return false;
}
}
}
| 33.209302 | 76 | 0.452381 |
4671e60a9a1333424f7cae5f96dde3e1a0f257a1 | 4,433 | js | JavaScript | src/screens/Platform/index.js | ElrondNetwork/ledger-live-mobile | bbfa40a2e460fc20a3d3ab825cc24e53d9bdc84f | [
"Apache-2.0"
] | 1 | 2022-01-08T01:48:35.000Z | 2022-01-08T01:48:35.000Z | src/screens/Platform/index.js | ElrondNetwork/ledger-live-mobile | bbfa40a2e460fc20a3d3ab825cc24e53d9bdc84f | [
"Apache-2.0"
] | 3 | 2022-02-15T07:04:07.000Z | 2022-03-08T23:39:43.000Z | src/screens/Platform/index.js | behnamsafiee/ledger-live-mobile | 4305eb627204cb189806a3ffc642983ee5e5e953 | [
"Apache-2.0"
] | null | null | null | // @flow
import React, { useMemo, useCallback, useState } from "react";
import { StyleSheet, ScrollView, View, Linking } from "react-native";
import { Trans } from "react-i18next";
import { useNavigation, useTheme } from "@react-navigation/native";
import { usePlatformApp } from "@ledgerhq/live-common/lib/platform/PlatformAppProvider";
import { filterPlatformApps } from "@ledgerhq/live-common/lib/platform/PlatformAppProvider/helpers";
import type { AccountLike, Account } from "@ledgerhq/live-common/lib/types";
import type { AppManifest } from "@ledgerhq/live-common/lib/platform/types";
import { useBanner } from "../../components/banners/hooks";
import TrackScreen from "../../analytics/TrackScreen";
import { urls } from "../../config/urls";
import { ScreenName } from "../../const";
import IconCode from "../../icons/Code";
import CatalogTwitterBanner from "./CatalogTwitterBanner";
import DAppDisclaimer from "./DAppDisclaimer";
import type { Props as DisclaimerProps } from "./DAppDisclaimer";
import CatalogBanner from "./CatalogBanner";
import CatalogCTA from "./CatalogCTA";
import AppCard from "./AppCard";
import AnimatedHeaderView from "../../components/AnimatedHeader";
type RouteParams = {
defaultAccount: ?AccountLike,
defaultParentAccount: ?Account,
};
type DisclaimerOpts = $Diff<DisclaimerProps, { isOpened: boolean }> | null;
const DAPP_DISCLAIMER_ID = "PlatformAppDisclaimer";
const PlatformCatalog = ({ route }: { route: { params: RouteParams } }) => {
const { params: routeParams } = route;
const { colors } = useTheme();
const navigation = useNavigation();
const { manifests } = usePlatformApp();
const filteredManifests = useMemo(() => {
const branches = ["stable", "soon"];
return filterPlatformApps(Array.from(manifests.values()), {
version: "0.0.1",
platform: "mobile",
branches,
});
}, []);
// Disclaimer State
const [disclaimerOpts, setDisclaimerOpts] = useState<DisclaimerOpts>(null);
const [disclaimerOpened, setDisclaimerOpened] = useState<boolean>(false);
const [disclaimerDisabled, setDisclaimerDisabled] = useBanner(
DAPP_DISCLAIMER_ID,
);
const handlePressCard = useCallback(
(manifest: AppManifest) => {
const openDApp = () =>
navigation.navigate(ScreenName.PlatformApp, {
...routeParams,
platform: manifest.id,
name: manifest.name,
});
if (!disclaimerDisabled) {
setDisclaimerOpts({
disableDisclaimer: () => setDisclaimerDisabled(),
closeDisclaimer: () => setDisclaimerOpened(false),
icon: manifest.icon,
onContinue: openDApp,
});
setDisclaimerOpened(true);
} else {
openDApp();
}
},
[navigation, routeParams, setDisclaimerDisabled, disclaimerDisabled],
);
const handleDeveloperCTAPress = useCallback(() => {
Linking.openURL(urls.platform.developerPage);
}, []);
return (
<AnimatedHeaderView
titleStyle={styles.title}
title={<Trans i18nKey={"platform.catalog.title"} />}
>
<TrackScreen category="Platform" name="Catalog" />
{disclaimerOpts && (
<DAppDisclaimer
disableDisclaimer={disclaimerOpts.disableDisclaimer}
closeDisclaimer={disclaimerOpts.closeDisclaimer}
onContinue={disclaimerOpts.onContinue}
isOpened={disclaimerOpened}
icon={disclaimerOpts.icon}
/>
)}
<ScrollView style={styles.wrapper}>
<CatalogBanner />
<CatalogTwitterBanner />
{filteredManifests.map(manifest => (
<AppCard
key={manifest.id}
manifest={manifest}
onPress={handlePressCard}
/>
))}
<View style={[styles.separator, { backgroundColor: colors.fog }]} />
<CatalogCTA
Icon={IconCode}
title={<Trans i18nKey={"platform.catalog.developerCTA.title"} />}
onPress={handleDeveloperCTAPress}
>
<Trans i18nKey={"platform.catalog.developerCTA.description"} />
</CatalogCTA>
</ScrollView>
</AnimatedHeaderView>
);
};
const styles = StyleSheet.create({
root: {
flex: 1,
},
wrapper: {
flex: 1,
},
title: {
fontSize: 34,
lineHeight: 40,
textAlign: "left",
},
separator: {
width: "100%",
height: 1,
marginBottom: 24,
},
});
export default PlatformCatalog;
| 30.156463 | 100 | 0.648094 |
467450f0d38b20c3e407b2d7843e3ef6ce4f8ac0 | 4,639 | js | JavaScript | packages/i18n/I18nDecorator/I18nDecorator.js | jeonghee27/enact | 128df8d55bdd6af2dd5df5638a375e239e40c4cd | [
"Apache-2.0"
] | null | null | null | packages/i18n/I18nDecorator/I18nDecorator.js | jeonghee27/enact | 128df8d55bdd6af2dd5df5638a375e239e40c4cd | [
"Apache-2.0"
] | null | null | null | packages/i18n/I18nDecorator/I18nDecorator.js | jeonghee27/enact | 128df8d55bdd6af2dd5df5638a375e239e40c4cd | [
"Apache-2.0"
] | null | null | null | /**
* Adds Internationalization (I18N) support to an application using ilib.
*
* @module i18n/I18nDecorator
* @exports I18nDecorator
* @exports I18nContextDecorator
* @exports I18nContext
*/
import {on, off} from '@enact/core/dispatcher';
import hoc from '@enact/core/hoc';
import {Publisher, contextTypes as stateContextTypes} from '@enact/core/internal/PubSub';
import PropTypes from 'prop-types';
import React from 'react';
import ilib from '../src/index.js';
import {isRtlLocale, updateLocale} from '../locale';
import getI18nClasses from './getI18nClasses';
const contextTypes = {
rtl: PropTypes.bool,
updateLocale: PropTypes.func
};
const I18nContext = React.createContext(null);
/**
* A higher-order component that is used to wrap the root element in an app. It provides an `rtl` member on the
* context of the wrapped component, allowing the children to check the current text directionality as well as
* an `updateLocale` method that can be used to update the current locale.
*
* There are no configurable options on this HOC.
*
* @class I18nDecorator
* @memberof i18n/I18nDecorator
* @hoc
* @public
*/
const I18nDecorator = hoc((config, Wrapped) => {
return class extends React.Component {
static displayName = 'I18nDecorator'
static propTypes = /** @lends i18n/I18nDecorator.I18nDecorator.prototype */ {
/**
* Classname for a root app element.
*
* @type {String}
* @public
*/
className: PropTypes.string,
/**
* A string with a {@link https://tools.ietf.org/html/rfc5646|BCP 47 language tag}.
*
* The system locale will be used by default.
*
* @type {String}
* @public
*/
locale: PropTypes.string
}
static contextTypes = stateContextTypes
static childContextTypes = {...contextTypes, ...stateContextTypes}
constructor (props) {
super(props);
const ilibLocale = ilib.getLocale();
const locale = props.locale && props.locale !== ilibLocale ? updateLocale(props.locale) : ilibLocale;
this.state = {
locale: locale,
rtl: isRtlLocale(),
updateLocale: this.updateLocale
};
}
getChildContext () {
return {
Subscriber: this.publisher.getSubscriber(),
rtl: isRtlLocale(),
updateLocale: this.updateLocale
};
}
componentWillMount () {
this.publisher = Publisher.create('i18n', this.context.Subscriber);
this.publisher.publish({
locale: this.state.locale,
rtl: isRtlLocale()
});
}
componentDidMount () {
if (typeof window === 'object') {
on('languagechange', this.handleLocaleChange, window);
}
}
componentWillReceiveProps (newProps) {
if (newProps.locale) {
this.updateLocale(newProps.locale);
}
}
componentWillUnmount () {
if (typeof window === 'object') {
off('languagechange', this.handleLocaleChange, window);
}
}
handleLocaleChange = () => {
this.updateLocale();
}
/**
* Updates the locale for the application. If `newLocale` is omitted, the locale will be
* reset to the device's default locale.
*
* @param {String} newLocale Locale identifier string
*
* @returns {undefined}
* @public
*/
updateLocale = (newLocale) => {
const locale = updateLocale(newLocale);
const updated = {
locale,
rtl: isRtlLocale()
};
this.setState(updated);
this.publisher.publish(updated);
}
render () {
const props = Object.assign({}, this.props);
let classes = getI18nClasses();
if (this.props.className) {
classes = this.props.className + ' ' + classes;
}
delete props.locale;
return (
<I18nContext.Provider value={this.state}>
<Wrapped {...props} className={classes} />
</I18nContext.Provider>
);
}
};
});
const defaultConfig = {
localeProp: null,
rtlProp: null,
updateLocaleProp: null
};
const I18nContextDecorator = hoc(defaultConfig, (config, Wrapped) => {
const {localeProp, rtlProp, updateLocaleProp} = config;
// eslint-disable-next-line no-shadow
return function I18nContextDecorator (props) {
return (
<I18nContext.Consumer>
{(i18nContext) => {
if (i18nContext) {
const {locale, rtl, updateLocale: update} = i18nContext;
props = Object.assign({}, props);
if (localeProp) {
props[localeProp] = locale;
}
if (rtlProp) {
props[rtlProp] = rtl;
}
if (updateLocaleProp) {
props[updateLocaleProp] = update;
}
}
return (
<Wrapped {...props} />
);
}}
</I18nContext.Consumer>
);
};
});
export default I18nDecorator;
export {
contextTypes,
I18nContext,
I18nContextDecorator,
I18nDecorator
};
| 22.852217 | 111 | 0.65984 |
4675694ffb4e68005ce27726ab9018848dfb5b31 | 1,206 | js | JavaScript | functions/files/music/handlePlaylist.js | loughreykian/Aurora | 08e218ec3f14a23e971f5463e5d1ab93aea032ed | [
"MIT"
] | 3 | 2018-06-03T13:41:58.000Z | 2019-08-05T11:41:47.000Z | functions/files/music/handlePlaylist.js | loughreykian/Aurora | 08e218ec3f14a23e971f5463e5d1ab93aea032ed | [
"MIT"
] | null | null | null | functions/files/music/handlePlaylist.js | loughreykian/Aurora | 08e218ec3f14a23e971f5463e5d1ab93aea032ed | [
"MIT"
] | 1 | 2019-12-14T19:04:28.000Z | 2019-12-14T19:04:28.000Z | module.exports = async function(message, playlist, options) {
try {
if(message.author.id == message.client.config.ownerID) options.override = true
if (!message.member.voiceChannel) return message.send(`${message.emote('error')} Get in a voice channel`);
const serverQueue = message.client.queue[message.guild.id];
const voiceChannel = message.member.voiceChannel;
let msg = await message.send(`${message.emote('mag')} Fetching playlist...`);
const pl = await message.client.functions['getPlaylist'](message.client, playlist);
//if(!options.override && serverQueue ? (serverQueue.tracks.length + pl.length) > 75 : pl.length > 75) { pl.splice(76, pl.length.toFixed(2)), message.send(`${message.emote('list')} Shortened queue to \`${pl.length}\` songs.`) };
msg.edit(`${message.emote('add')} Enqueued \`${pl.length}\` songs.`);
pl.forEach(async list => {
await message.client.functions['handleTrack'](message, list, voiceChannel, {
playlist: true,
override: options.override,
link: false
});
});
} catch (err) {
return message.send(`${message.emote('error')} Error getting playlist: ${e}`);
};
};
| 43.071429 | 233 | 0.649254 |
46756dc2d6f06daf3fead86e9af939bcd0930770 | 4,693 | js | JavaScript | src/containers/dashboard/sortableTable.js | vlganev/react-admin-panel | 1f6aefe9fbed49536c379c7fdab0ed4f9ac1634c | [
"MIT"
] | 4 | 2018-11-29T22:39:20.000Z | 2020-09-11T14:17:11.000Z | src/containers/dashboard/sortableTable.js | vlganev/react-admin-panel | 1f6aefe9fbed49536c379c7fdab0ed4f9ac1634c | [
"MIT"
] | null | null | null | src/containers/dashboard/sortableTable.js | vlganev/react-admin-panel | 1f6aefe9fbed49536c379c7fdab0ed4f9ac1634c | [
"MIT"
] | null | null | null | import * as React from "react";
import { Menu, MenuItem } from "@blueprintjs/core";
import {
Cell,
Column,
ColumnHeaderCell,
CopyCellsMenuItem,
SelectionModes,
Table,
Utils,
} from "@blueprintjs/table";
// tslint:disable-next-line:no-var-requires
// const sumo = [
// ["A", "Apple", "Ape", "Albania", "Anchorage"],
// ["B", "Banana", "Boa", "Brazil", "Boston"],
// ["C", "Cranberry", "Cougar", "Croatia", "Chicago"],
// ["D", "Dragonfruit", "Deer", "Denmark", "Denver"],
// ["E", "Eggplant", "Elk", "Eritrea", "El Paso"],
// ];
// export type ICellLookup = (rowIndex: number, columnIndex: number) => any;
// export type ISortCallback = (columnIndex: number, comparator: (a: any, b: any) => number) => void;
// export interface ISortableColumn {
// getColumn(getCellData: ICellLookup, sortColumn: ISortCallback): JSX.Element;
// }
class TextSortableColumn {
constructor(name, index) {
this.name = name,
this.index = index
}
getColumn(getCellData, sortColumn) {
const cellRenderer = (rowIndex, columnIndex) => (
<Cell>{getCellData(rowIndex, columnIndex)}</Cell>
);
const menuRenderer = this.renderMenu.bind(this, sortColumn);
const columnHeaderCellRenderer = () => <ColumnHeaderCell name={this.name} menuRenderer={menuRenderer} />;
return (
<Column
cellRenderer={cellRenderer}
columnHeaderCellRenderer={columnHeaderCellRenderer}
key={this.index}
name={this.name}
/>
);
}
renderMenu(sortColumn) {
const sortAsc = () => sortColumn(this.index, (a, b) => this.compare(a, b));
const sortDesc = () => sortColumn(this.index, (a, b) => this.compare(b, a));
return (
<Menu>
<MenuItem icon="sort-asc" onClick={sortAsc} text="Sort Asc" />
<MenuItem icon="sort-desc" onClick={sortDesc} text="Sort Desc" />
</Menu>
);
}
compare(a, b) {
return a.toString().localeCompare(b);
}
}
export class SortableTable extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
columns: [
new TextSortableColumn("К 1", 0),
new TextSortableColumn("Колона 2", 1),
new TextSortableColumn("Колона 3", 2),
new TextSortableColumn("Колона 4", 3),
new TextSortableColumn("Колона 5", 4),
new TextSortableColumn("Колона 6", 5),
new TextSortableColumn("Колона 7", 6),
new TextSortableColumn("Колона 8", 7),
new TextSortableColumn("Колона 9", 8),
new TextSortableColumn("Колона 10", 9),
new TextSortableColumn("Колона 11", 10),
new TextSortableColumn("Колона 12", 11),
new TextSortableColumn("Колона 13", 12),
],
data: props.data,
sortedIndexMap: [],
columnWidths: [30, 140, 250, 100, 200, 100, 100, 100, 100, 100, 100, 100, 100],
};
}
render() {
const numRows = this.state.data.length;
const columns = this.state.columns.map(col => col.getColumn(this.getCellData, this.sortColumn));
return (
<Table
bodyContextMenuRenderer={this.renderBodyContextMenu}
numRows={numRows}
selectionModes={SelectionModes.COLUMNS_AND_CELLS}
columnWidths={this.state.columnWidths}
>
{columns}
</Table>
);
}
componentWillReceiveProps(props) {
if (props.data != undefined) {
this.setState({ data: props.data })
} else {
this.setState({ data: [] });
}
}
getCellData = (rowIndex, columnIndex) => {
const sortedRowIndex = this.state.sortedIndexMap[rowIndex];
if (sortedRowIndex != null) {
rowIndex = sortedRowIndex;
}
return this.state.data[rowIndex][columnIndex];
};
renderBodyContextMenu = (context) => {
return (
<Menu>
<CopyCellsMenuItem context={context} getCellData={this.getCellData} text="Copy" />
</Menu>
);
};
sortColumn = (columnIndex, comparator) => {
const { data } = this.state;
const sortedIndexMap = Utils.times(data.length, (i) => i);
sortedIndexMap.sort((a, b) => {
return comparator(data[a][columnIndex], data[b][columnIndex]);
});
this.setState({ sortedIndexMap });
};
} | 33.76259 | 113 | 0.549329 |
4677430dc9dc05e236777a5ec151bafecefcee6c | 141 | js | JavaScript | modules/weblounge-ui/src/main/resources/editor/scripts/docs.js | digitalcafe/weblounge | 653c25ff728c18c31bdf12b21d45106dacc080dc | [
"BSD-Source-Code"
] | 2 | 2019-06-12T20:16:05.000Z | 2019-08-05T02:55:48.000Z | modules/weblounge-ui/src/main/resources/editor/scripts/docs.js | digitalcafe/weblounge | 653c25ff728c18c31bdf12b21d45106dacc080dc | [
"BSD-Source-Code"
] | null | null | null | modules/weblounge-ui/src/main/resources/editor/scripts/docs.js | digitalcafe/weblounge | 653c25ff728c18c31bdf12b21d45106dacc080dc | [
"BSD-Source-Code"
] | null | null | null | //js editor/scripts/doc.js
load('steal/rhino/steal.js');
steal.plugins("documentjs").then(function(){
DocumentJS('editor/editor.html');
}); | 23.5 | 44 | 0.716312 |
46778e7eb22692981d00c486dc7074683a613f40 | 243 | js | JavaScript | src/angular_demo_addin/js/mainController.js | InteractiveIntelligence/ConnectAddinDevEnvironment | 276035737d33e469141c6bc921cc1fcde17650b0 | [
"MIT"
] | 1 | 2016-06-28T09:53:53.000Z | 2016-06-28T09:53:53.000Z | src/angular_demo_addin/js/mainController.js | InteractiveIntelligence/ConnectAddinDevEnvironment | 276035737d33e469141c6bc921cc1fcde17650b0 | [
"MIT"
] | 1 | 2015-08-26T15:59:58.000Z | 2015-08-26T15:59:58.000Z | src/angular_demo_addin/js/mainController.js | InteractiveIntelligence/ConnectAddinDevEnvironment | 276035737d33e469141c6bc921cc1fcde17650b0 | [
"MIT"
] | null | null | null | clientaddin.controller('MainController', function($scope, $rootScope, QueueService){
$scope.$watch(function () {
return QueueService.getInteractions();
}, function (data) {
$scope.interactions = data;
}, true);
});
| 30.375 | 84 | 0.646091 |
46781442a3a7a5d691d811fdd04c26b18da4c7eb | 3,245 | js | JavaScript | applications/luci-app-vnstat2/htdocs/luci-static/resources/view/vnstat2/config.js | fanck0605/luci-1 | d2dfc522f1e5315fc06a93738483ca8cc3d6f6c1 | [
"Apache-2.0"
] | 4 | 2020-06-09T08:56:20.000Z | 2020-06-09T08:58:01.000Z | applications/luci-app-vnstat2/htdocs/luci-static/resources/view/vnstat2/config.js | fanck0605/luci-1 | d2dfc522f1e5315fc06a93738483ca8cc3d6f6c1 | [
"Apache-2.0"
] | 1 | 2020-11-14T16:03:55.000Z | 2020-11-17T12:17:10.000Z | applications/luci-app-vnstat2/htdocs/luci-static/resources/view/vnstat2/config.js | fanck0605/luci-1 | d2dfc522f1e5315fc06a93738483ca8cc3d6f6c1 | [
"Apache-2.0"
] | 4 | 2019-12-21T02:39:54.000Z | 2020-09-15T21:40:59.000Z | // This is free software, licensed under the Apache License, Version 2.0
'use strict';
'require view';
'require fs';
'require ui';
'require uci';
'require form';
'require tools.widgets as widgets';
var isReadonlyView = !L.hasViewPermission() || null;
return view.extend({
handleDeleteModal: function(m, iface, ev) {
L.showModal(_('Delete interface <em>%h</em>').format(iface), [
E('p', _('The interface will be removed from the database permanently. This cannot be undone.')),
E('div', { 'class': 'right' }, [
E('div', {
'class': 'btn',
'click': L.hideModal
}, _('Cancel')),
' ',
E('div', {
'class': 'btn cbi-button-negative',
'click': ui.createHandlerFn(this, 'handleDelete', m, iface)
}, _('Delete'))
])
]);
},
handleDelete: function(m, iface, ev) {
return fs.exec('/usr/bin/vnstat', ['--remove', '-i', iface, '--force'])
.then(L.bind(m.render, m))
.catch(function(e) {
ui.addNotification(null, E('p', e.message));
})
.finally(L.hideModal);
},
render: function() {
var m, s, o;
m = new form.Map('vnstat', _('vnStat'), _('vnStat is a network traffic monitor for Linux that keeps a log of network traffic for the selected interface(s).'));
s = m.section(form.TypedSection, 'vnstat', _('Interfaces'));
s.anonymous = true;
s.addremove = false;
o = s.option(widgets.DeviceSelect, 'interface', _('Monitor interfaces'), _('The selected interfaces are automatically added to the vnStat database upon startup.'));
o.rmempty = true;
o.multiple = true;
o.noaliases = true;
o.nobridges = false;
o.noinactive = false;
o.nocreate = false;
o = s.option(form.DummyValue, '_database');
o.load = function(section_id) {
return fs.exec('/usr/bin/vnstat', ['--json', 'f', '1']).then(L.bind(function(result) {
var databaseInterfaces = [];
if (result.code == 0) {
var vnstatData = JSON.parse(result.stdout);
for (var i = 0; i < vnstatData.interfaces.length; i++) {
databaseInterfaces.push(vnstatData.interfaces[i].name);
}
}
var configInterfaces = uci.get_first('vnstat', 'vnstat', 'interface') || [];
this.interfaces = databaseInterfaces.filter(function(iface) {
return configInterfaces.indexOf(iface) == -1;
});
}, this));
};
o.render = L.bind(function(view, section_id) {
var table = E('div', { 'class': 'table' }, [
E('div', { 'class': 'tr table-titles' }, [
E('div', { 'class': 'th' }, _('Interface')),
E('div', { 'class': 'th right' }, _('Delete'))
])
]);
var rows = [];
for (var i = 0; i < this.interfaces.length; i++) {
rows.push([
this.interfaces[i],
E('button', {
'class': 'btn cbi-button-remove',
'click': ui.createHandlerFn(view, 'handleDeleteModal', m, this.interfaces[i]),
'disabled': isReadonlyView
}, [ _('Delete…') ])
]);
}
cbi_update_table(table, rows, E('em', _('No unconfigured interfaces found in database.')));
return E([], [
E('h3', _('Unconfigured interfaces')),
E('div', { 'class': 'cbi-section-descr' },
_('These interfaces are present in the vnStat database, but are not configured above.')),
table
]);
}, o, this);
return m.render();
}
});
| 28.464912 | 166 | 0.602773 |
4678483e8458a6b2699c063f597188c8694f5cee | 5,663 | js | JavaScript | chrome/test/data/extensions/api_test/tabs/connect/test.js | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 14,668 | 2015-01-01T01:57:10.000Z | 2022-03-31T23:33:32.000Z | chrome/test/data/extensions/api_test/tabs/connect/test.js | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 113 | 2015-05-04T09:58:14.000Z | 2022-01-31T19:35:03.000Z | chrome/test/data/extensions/api_test/tabs/connect/test.js | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 5,941 | 2015-01-02T11:32:21.000Z | 2022-03-31T16:35:46.000Z | // Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// browser_tests --gtest_filter=ExtensionApiTest.TabConnect
// The test tab used for all tests.
var testTab = null;
// Path to the empty HTML document, fetched from the test configuration.
var emptyDocumentURL = null;
// The could-not-establish-connection error message. Used in a number of tests.
var couldNotEstablishError =
'Could not establish connection. Receiving end does not exist.';
var assertEq = chrome.test.assertEq;
var assertFalse = chrome.test.assertFalse;
var assertTrue = chrome.test.assertTrue;
var callbackFail = chrome.test.callbackFail;
var fail = chrome.test.fail;
var listenForever = chrome.test.listenForever;
var listenOnce = chrome.test.listenOnce;
var pass = chrome.test.callbackPass;
function waitForReady(ready) {
chrome.test.listenOnce(chrome.runtime.onMessage, function(msg, sender) {
assertEq('ready', msg);
ready(sender.tab);
});
}
chrome.test.runTests([
function setup() {
chrome.test.getConfig(pass(function(config) {
emptyDocumentURL = 'http://localhost:' + config.testServer.port +
'/extensions/api_test/tabs/connect/empty.html';
setupWindow([emptyDocumentURL], pass());
waitForReady(pass(function(tab) {
testTab = tab;
}));
}));
},
function connectMultipleConnects() {
var connectCount = 0;
function connect10() {
var port = chrome.tabs.connect(testTab.id);
listenOnce(port.onMessage, function(msg) {
assertEq(++connectCount, msg.connections);
if (connectCount < 10)
connect10();
});
port.postMessage('GET');
}
connect10();
},
function connectName() {
var name = 'akln3901n12la';
var port = chrome.tabs.connect(testTab.id, {'name': name});
listenOnce(port.onMessage, function(msg) {
assertEq(name, msg.name);
var port = chrome.tabs.connect(testTab.id);
listenOnce(port.onMessage, function(msg) {
assertEq('', msg.name);
});
port.postMessage('GET');
});
port.postMessage('GET');
},
function connectPostMessageTypes() {
var port = chrome.tabs.connect(testTab.id);
// Test the content script echoes the message back.
var echoMsg = {'num': 10, 'string': 'hi', 'array': [1,2,3,4,5],
'obj':{'dec': 1.0}};
listenOnce(port.onMessage, function(msg) {
assertEq(echoMsg.num, msg.num);
assertEq(echoMsg.string, msg.string);
assertEq(echoMsg.array[4], msg.array[4]);
assertEq(echoMsg.obj.dec, msg.obj.dec);
});
port.postMessage(echoMsg);
},
function connectPostManyMessages() {
var port = chrome.tabs.connect(testTab.id);
var count = 0;
var done = listenForever(port.onMessage, function(msg) {
assertEq(count++, msg);
if (count == 100) {
done();
}
});
for (var i = 0; i < 100; i++) {
port.postMessage(i);
}
},
function connectToRemovedTab() {
// Expect a disconnect event when you connect to a non-existent tab, and
// once disconnected, expect an error while trying to post messages.
chrome.tabs.create({}, pass(function(tab) {
chrome.tabs.remove(tab.id, pass(function() {
var p = chrome.tabs.connect(tab.id);
p.onDisconnect.addListener(callbackFail(couldNotEstablishError,
function() {
try {
p.postMessage();
fail('Error should have been thrown.');
} catch (e) {
// Do nothing- an exception should be thrown.
}
}));
}));
}));
},
function sendRequest() {
var request = 'test';
chrome.tabs.sendRequest(testTab.id, request, pass(function(response) {
assertEq(request, response);
}));
},
function sendRequestToImpossibleTab() {
chrome.tabs.sendRequest(9999, 'test', callbackFail(couldNotEstablishError));
},
function sendRequestToRemovedTab() {
chrome.tabs.create({}, pass(function(tab) {
chrome.tabs.remove(tab.id, pass(function() {
chrome.tabs.sendRequest(tab.id, 'test',
callbackFail(couldNotEstablishError));
}));
}));
},
function sendRequestMultipleTabs() {
// Regression test for crbug.com/520303. Instruct the test tab to create
// another tab, then send a message to each. The bug was that the message
// is sent to both, if they're in the same process.
//
// The tab itself must do the open so that they share a process,
// chrome.tabs.create doesn't guarantee that.
chrome.tabs.sendMessage(testTab.id, {open: emptyDocumentURL});
waitForReady(pass(function(secondTab) {
var gotDuplicates = false;
var messages = new Set();
var done = listenForever(chrome.runtime.onMessage, function(msg) {
if (messages.has(msg))
gotDuplicates = true;
else
messages.add(msg);
});
chrome.tabs.sendMessage(testTab.id, {send: 'msg1'}, function() {
chrome.tabs.sendMessage(secondTab.id, {send: 'msg2'}, function() {
// Send an empty final message to hopefully ensure that the events
// for msg1 and msg2 have been fired.
chrome.tabs.sendMessage(testTab.id, {}, function() {
assertEq(2, messages.size);
assertTrue(messages.has('msg1'));
assertTrue(messages.has('msg2'));
assertFalse(gotDuplicates);
done();
});
});
});
}));
},
]);
| 32.545977 | 80 | 0.623168 |
46784cd2ebf3446174fccef27a61cea59b221b2e | 1,636 | js | JavaScript | widgets/foursquare/foursquare.js | FlyNYCMeter/sonia | 9eebff223044d788a890a5c710e96bde2f03129f | [
"MIT"
] | 5 | 2015-11-05T10:10:52.000Z | 2021-10-30T08:07:01.000Z | widgets/foursquare/foursquare.js | FlyNYCMeter/sonia | 9eebff223044d788a890a5c710e96bde2f03129f | [
"MIT"
] | 2 | 2020-01-21T10:28:54.000Z | 2020-01-21T10:28:54.000Z | widgets/foursquare/foursquare.js | FlyNYCMeter/sonia | 9eebff223044d788a890a5c710e96bde2f03129f | [
"MIT"
] | 2 | 2015-04-10T05:54:19.000Z | 2015-10-20T12:02:36.000Z | var Foursquare = Class.create(Widget, {
initialize: function($super, widget_id, config) {
this.checkins = [];
return($super(widget_id, config));
},
handlePayload: function(payload) {
this.checkins = [];
payload.each(function(checkin) {
this.checkins.push(checkin);
}.bind(this));
this.update();
},
build: function() {
this.checkinsContainer = this.buildCheckins();
this.headerContainer = this.buildHeader();
this.container.insert(this.headerContainer);
this.container.insert(this.buildWidgetIcon());
this.container.insert(this.checkinsContainer);
this.makeDraggable();
},
update: function() {
this.checkinsContainer.childElements().invoke('remove');
this.checkins.each(function(checkin) {
var cont = new Element('p', { id: checkin.id});
cont.appendChild(new Element('img', { src: checkin.avatar_url, height:48, width:48}));
cont.appendChild(new Element('div', {'class':'author'}).update(checkin.name));
cont.appendChild(new Element('div').update(checkin.venue + " " + checkin.when + " ago"));
cont.insert(new Element('hr' ));
this.checkinsContainer.insert(cont);
// new Effect.Pulsate(this.container, { pulses: 2, duration: 1 });
}.bind(this));
},
buildWidgetIcon: function() {
return(new Element("img", {src: "images/foursquare/icon.png", width: 32, height: 32, className: 'foursquare icon'}));
},
buildHeader: function() {
return(new Element("h2", { 'class': 'handle' }).update(this.title));
},
buildCheckins: function() {
return(new Element("div", { 'class': 'checkins' }));
}
});
| 34.808511 | 121 | 0.646699 |
4678e3d0453a1a7bd374e7edc4afc2be49e8004b | 1,546 | js | JavaScript | dist/constants.js | theroyalwhee0/snowman | 0362d011f4ffb1bf5965d5297e9ffad6281ffee5 | [
"Apache-2.0"
] | 1 | 2021-03-14T04:43:52.000Z | 2021-03-14T04:43:52.000Z | dist/constants.js | theroyalwhee0/snowman | 0362d011f4ffb1bf5965d5297e9ffad6281ffee5 | [
"Apache-2.0"
] | null | null | null | dist/constants.js | theroyalwhee0/snowman | 0362d011f4ffb1bf5965d5297e9ffad6281ffee5 | [
"Apache-2.0"
] | null | null | null | "use strict";
/**
* @file Snowman constants.
* @author Adam Mill <hismajesty@theroyalwhee.com>
* @copyright Copyright 2021 Adam Mill
* @license Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.MAX_ID = exports.MAX_SEQUENCE = exports.MAX_NODE = exports.MAX_TIMESTAMP = exports.MIN_SEQUENCE = exports.MIN_ID = exports.MIN_NODE = exports.MIN_TIMESTAMP = exports.RESERVED = exports.OFFSET_SEQUENCE = exports.OFFSET_NODE = exports.OFFSET_TIMESTAMP = exports.OFFSET_RESERVED = exports.MASK_SEQUENCE = exports.MASK_NODE = exports.MASK_TIMESTAMP = exports.MASK_RESERVED = exports.MASK_ID = exports.DEFAULT_OFFSET = void 0;
/**
* Constants.
* @private
*/
exports.DEFAULT_OFFSET = 1577836800000; // 2020-01-01T00:00:00+00:00
exports.MASK_ID = 0x7fffffffffffffffn;
exports.MASK_RESERVED = 0x8000000000000000n; // 1 = 1
exports.MASK_TIMESTAMP = 0x7fffffffff800000n; // 7+8+8+8+8+1 = 40
exports.MASK_NODE = 0x00000000007fe000n; // 7+3 = 10
exports.MASK_SEQUENCE = 0x0000000000001fffn; // 5+8 = 13
exports.OFFSET_RESERVED = 39n;
exports.OFFSET_TIMESTAMP = 23n;
exports.OFFSET_NODE = 13n;
exports.OFFSET_SEQUENCE = 0n;
exports.RESERVED = 0; // Reserved may only be zero.
exports.MIN_TIMESTAMP = 1; // 0 = offset time
exports.MIN_NODE = 0n;
exports.MIN_ID = 0;
exports.MIN_SEQUENCE = 0n;
exports.MAX_TIMESTAMP = 1099511627775; // 2**40-1, ~34.8 years
exports.MAX_NODE = 1023n; // 2**10-1
exports.MAX_SEQUENCE = 8191; // 2**13-1
exports.MAX_ID = 9223372036854775807n; // 2n**63n-1n
//# sourceMappingURL=constants.js.map | 46.848485 | 429 | 0.754204 |
46797c1e12b77b5cddac43967a36b62a66579bfa | 705 | js | JavaScript | src/domains/manager/index.js | fagocbr/project-manager | 0593d3ad8c93a3d550c148607a14d996ea94d86f | [
"MIT"
] | null | null | null | src/domains/manager/index.js | fagocbr/project-manager | 0593d3ad8c93a3d550c148607a14d996ea94d86f | [
"MIT"
] | null | null | null | src/domains/manager/index.js | fagocbr/project-manager | 0593d3ad8c93a3d550c148607a14d996ea94d86f | [
"MIT"
] | null | null | null | import { meta } from 'genesis/support/model'
import { route } from 'genesis/infra/router/resources'
import project from 'src/domains/manager/project/routes'
import repository from 'src/domains/manager/repository/routes'
import issue from 'src/domains/manager/issue/routes'
export const managerPath = '/dashboard/manager'
export const managerName = 'manager.index'
export const managerComponent = 'app/modules/dashboard/components/DashboardRouterView'
export const managerMeta = Object.assign(
{}, {noLink: true}, meta('format_quote', '<~>', '<~>')
)
export const routes = [
route(managerPath, managerName, managerComponent, {}, managerMeta, [
...project,
...repository,
...issue
])
]
| 32.045455 | 86 | 0.734752 |
467992cf6051a688cdb3ea624570f1fe591360fe | 3,305 | js | JavaScript | src/containers/login/index.js | vlganev/react-admin-panel | 1f6aefe9fbed49536c379c7fdab0ed4f9ac1634c | [
"MIT"
] | 4 | 2018-11-29T22:39:20.000Z | 2020-09-11T14:17:11.000Z | src/containers/login/index.js | vlganev/react-admin-panel | 1f6aefe9fbed49536c379c7fdab0ed4f9ac1634c | [
"MIT"
] | null | null | null | src/containers/login/index.js | vlganev/react-admin-panel | 1f6aefe9fbed49536c379c7fdab0ed4f9ac1634c | [
"MIT"
] | null | null | null | import React, { Component } from 'react';
import { connect } from 'react-redux';
// import logo from '../image/-logo.png'
import {Redirect} from 'react-router-dom';
import { Button, Label, InputGroup } from "@blueprintjs/core";
import { isLoggedIn, login } from '../../actions/login';
import { Row } from 'react-simple-flex-grid';
import "react-simple-flex-grid/lib/main.css";
class LoginForm extends Component {
constructor(props) {
super(props);
this.state = {
username: '',
password: ''
};
this.onSubmit = this.onSubmit.bind(this);
}
onSubmit(e) {
e.preventDefault();
this.props.login(this.state.username, this.state.password);
}
componentWillUpdate() {
this.props.isLoggedIn();
}
render() {
let {isLoginSuccess, loginError} = this.props;
let { from } = this.props.location.state || { from: { pathname: '/dashboard' } }
if (isLoginSuccess) {
return (
<Redirect to={from}/>
)
}
return (
<div className="container-login">
<Row justify="center">
<div className="login">
<h2>Добре дошли в Admin panel</h2>
<article>
<div className="error-message text-center">{ loginError && <div>{loginError.message}</div> }</div>
<form onSubmit={this.onSubmit}>
<Label
className="h2"
text="Потребителско име"
>
<InputGroup
className="bp3-large"
type="text"
name="username"
id="username"
ref="username"
placeholder="Потребителско име"
dir="auto"
onChange={event => this.setState({username: event.target.value}) }
value={this.state.username}
/>
</Label>
<Label
text="Парола"
>
<InputGroup
className="bp3-large"
type="password"
name="password"
id="password"
ref="password"
placeholder="Парола"
dir="auto"
onChange={event => this.setState({ password: event.target.value })}
value={this.state.password}
/>
</Label>
<Button
className="bp3-button bp3-fill"
icon="log-in"
type="submit"
text="Вход"
/>
</form>
</article>
</div>
</Row>
</div>
)
}
}
const mapStateToProps = (state) => {
return {
isLoginPending: state.login.isLoginPending,
isLoginSuccess: state.login.isLoginSuccess,
loginError: state.login.loginError,
};
}
const mapDispatchToProps = (dispatch) => {
return {
dispatch,
login: (username, password) => dispatch(login(username, password)),
isLoggedIn: () => dispatch(isLoggedIn())
};
}
export default connect(mapStateToProps, mapDispatchToProps)(LoginForm); | 30.601852 | 114 | 0.486233 |
467a542a42feefa112a86174a6e72e7f3a2da434 | 904 | js | JavaScript | commands/messages/emojiSteal.js | dannyhpy/_Cleckzie | 40c8bdde710d3ad09752d4ac3ce1e35bd3ea9841 | [
"MIT"
] | null | null | null | commands/messages/emojiSteal.js | dannyhpy/_Cleckzie | 40c8bdde710d3ad09752d4ac3ce1e35bd3ea9841 | [
"MIT"
] | null | null | null | commands/messages/emojiSteal.js | dannyhpy/_Cleckzie | 40c8bdde710d3ad09752d4ac3ce1e35bd3ea9841 | [
"MIT"
] | null | null | null | const { Client, Message, MessageEmbed, Util } = require("discord.js");
module.exports = {
name: "steal-emoji",
aliases: ['emoji-stealer', 'ems'],
usage: "*steal-emoji :superflushed:",
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
if(!args.length) return message.reply(`Please specify some emojis.`)
for (const rawEmoji of args) {
const parsedEmoji = Util.parseEmoji(rawEmoji);
if(parsedEmoji.id) {
const extention = parsedEmoji.animated ? " .gif" : " .png";
const url = `https://cdn.discordapp.com/emojis/${parsedEmoji.id + extention}`;
message.guild.emojis.create(url, parsedEmoji.name)
.then((emoji) => message.channel.send(`Added: \`${emoji.url}\``));
}
}
}
} | 34.769231 | 92 | 0.561947 |
467a81b73aee34cf07f823d7fbd6bfae54a6f761 | 214 | js | JavaScript | src/components/Link/index.js | vdonoladev/QuizCatolico | a7a05b13bd05cf0786067635eec4b7dfc7001484 | [
"MIT"
] | null | null | null | src/components/Link/index.js | vdonoladev/QuizCatolico | a7a05b13bd05cf0786067635eec4b7dfc7001484 | [
"MIT"
] | null | null | null | src/components/Link/index.js | vdonoladev/QuizCatolico | a7a05b13bd05cf0786067635eec4b7dfc7001484 | [
"MIT"
] | null | null | null | import NextLink from 'next/link';
export default function Link({children, href, ...props}) {
return (
<NextLink href={href} passHref>
<a {...props}>
{children}
</a>
</NextLink>
);
} | 19.454545 | 58 | 0.565421 |
467b21fe812c18ae6d1b76aea79730f405eb343c | 3,274 | js | JavaScript | assets/js/app.js | Heylias/hub | 071f3deb6034d04a81de95e495ca02de0af90e3a | [
"MIT"
] | null | null | null | assets/js/app.js | Heylias/hub | 071f3deb6034d04a81de95e495ca02de0af90e3a | [
"MIT"
] | null | null | null | assets/js/app.js | Heylias/hub | 071f3deb6034d04a81de95e495ca02de0af90e3a | [
"MIT"
] | null | null | null | import './../css/app.scss';
import authAPI from './services/authAPI';
import AuthContext from './contexts/AuthContext';
import 'react-toastify/dist/ReactToastify.css';
//modules
import { ToastContainer, toast } from 'react-toastify';
import React, { useState } from 'react';
import ReactDom from 'react-dom';
import { HashRouter, Switch, Route, withRouter } from 'react-router-dom';
//components
import Navbar from './components/Navbar';
import PrivateRoute from './components/PrivateRoute';
// other pages
import HomePage from './pages/HomePage';
import LoginPage from './pages/LoginPage';
import RegisterPage from './pages/RegisterPage';
//edit pages
import EditFanfictionPage from './pages/itemPages/EditFanfictionPage';
import EditUserPage from './pages/itemPages/EditUserPage';
import PasswordChangePage from './pages/itemPages/PasswordChangePage';
import UploadChapterPage from './pages/itemPages/UploadChapterPage';
//item pages
import FanfictionPage from './pages/itemPages/FanfictionPage';
import UserPage from './pages/itemPages/UserPage';
//collection pages
import FanfictionsPage from './pages/collectionPages/FanfictionsPage';
import RecentUploadPage from './pages/collectionPages/RecentUploadsPage';
import BestRatedPage from './pages/collectionPages/BestRatedPage';
console.log('Hello Webpack Encore! Edit me in assets/js/app.js')
authAPI.setup()
const App = () => {
const [isAuthenticated, setIsAuthenticated] = useState(authAPI.isAuthenticated())
const NavbarWithRouter = withRouter(Navbar)
const contextValue = {
isAuthenticated: isAuthenticated,
setIsAuthenticated : setIsAuthenticated
}
return (
<AuthContext.Provider value={ contextValue }>
<HashRouter>
<NavbarWithRouter/>
<main className="container pt-5">
<Switch>
<PrivateRoute path="/fanfictions/new" component={ EditFanfictionPage } />
<PrivateRoute path="/fanfictions/:id/edit" component={ EditFanfictionPage } />
<PrivateRoute path="/fanfictions/:id/upload" component={ UploadChapterPage } />
<Route path="/fanfictions/best" component={ BestRatedPage } />
<Route path="/fanfictions/latest" component={ RecentUploadPage } />
<Route path="/fanfictions/:id" component={ FanfictionPage } />
<Route path="/fanfictions" component={ FanfictionsPage } />
<PrivateRoute path="/users/:id/password" component={ PasswordChangePage } />
<PrivateRoute path="/users/:id/edit" component={ EditUserPage } />
<Route path="/users/:id" component={ UserPage } />
<Route path="/register" component={ RegisterPage }/>
<Route path="/login" component={ LoginPage }/>
<Route path="/" component={ HomePage } />
</Switch>
</main>
</HashRouter>
<ToastContainer position={ toast.POSITION.BOTTOM_LEFT } />
</AuthContext.Provider>
)
}
const rootElement = document.querySelector('#app')
ReactDom.render(<App />, rootElement) | 41.974359 | 103 | 0.648137 |
467c55dc498563365372e047b906cf81839e8fc3 | 265 | js | JavaScript | client/src/theme/materialTheme.js | yg1110/NetListers | e1ca6508bcd9e5f4c3bb0ae03790f82463d07ff1 | [
"MIT"
] | null | null | null | client/src/theme/materialTheme.js | yg1110/NetListers | e1ca6508bcd9e5f4c3bb0ae03790f82463d07ff1 | [
"MIT"
] | null | null | null | client/src/theme/materialTheme.js | yg1110/NetListers | e1ca6508bcd9e5f4c3bb0ae03790f82463d07ff1 | [
"MIT"
] | null | null | null | import createMuiTheme from "@material-ui/core/styles/createMuiTheme";
export const PrimaryTheme = createMuiTheme({
palette: {
default: "#fefefe",
kournikova: "#ffee82",
selago: "#f6e3fd",
frostedmint: "#dafff7",
yourpink: "#ffcabf",
},
});
| 22.083333 | 69 | 0.656604 |
467c838ac63f04a0e171cf1c9861f282b698965e | 2,980 | js | JavaScript | bundle/microservices/client/client-mqtt.js | jeckhart/nest | 89c76a682e4f8656e7f32a55e8ebf1337c029245 | [
"MIT"
] | null | null | null | bundle/microservices/client/client-mqtt.js | jeckhart/nest | 89c76a682e4f8656e7f32a55e8ebf1337c029245 | [
"MIT"
] | null | null | null | bundle/microservices/client/client-mqtt.js | jeckhart/nest | 89c76a682e4f8656e7f32a55e8ebf1337c029245 | [
"MIT"
] | null | null | null | "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const logger_service_1 = require("@nestjs/common/services/logger.service");
const load_package_util_1 = require("@nestjs/common/utils/load-package.util");
const constants_1 = require("../constants");
const client_proxy_1 = require("./client-proxy");
const constants_2 = require("./constants");
let mqttPackage = {};
class ClientMqtt extends client_proxy_1.ClientProxy {
constructor(options) {
super();
this.options = options;
this.logger = new logger_service_1.Logger(client_proxy_1.ClientProxy.name);
this.url =
this.getOptionsProp(this.options, 'url') || constants_1.MQTT_DEFAULT_URL;
mqttPackage = load_package_util_1.loadPackage('mqtt', ClientMqtt.name);
}
getAckPatternName(pattern) {
return `${pattern}_ack`;
}
getResPatternName(pattern) {
return `${pattern}_res`;
}
close() {
this.mqttClient && this.mqttClient.end();
this.mqttClient = null;
}
connect() {
if (this.mqttClient) {
return Promise.resolve();
}
this.mqttClient = this.createClient();
this.handleError(this.mqttClient);
return this.connect$(this.mqttClient).toPromise();
}
createClient() {
return mqttPackage.connect(this.url, this.options);
}
handleError(client) {
client.addListener(constants_1.ERROR_EVENT, err => err.code !== constants_2.ECONNREFUSED && this.logger.error(err));
}
createResponseCallback(packet, callback) {
return (channel, buffer) => {
const { err, response, isDisposed, id } = JSON.parse(buffer.toString());
if (id !== packet.id) {
return undefined;
}
if (isDisposed || err) {
return callback({
err,
response: null,
isDisposed: true,
});
}
callback({
err,
response,
});
};
}
publish(partialPacket, callback) {
try {
const packet = this.assignPacketId(partialPacket);
const pattern = this.normalizePattern(partialPacket.pattern);
const responseChannel = this.getResPatternName(pattern);
const responseCallback = this.createResponseCallback(packet, callback);
this.mqttClient.on(constants_1.MESSAGE_EVENT, responseCallback);
this.mqttClient.subscribe(responseChannel);
this.mqttClient.publish(this.getAckPatternName(pattern), JSON.stringify(packet));
return () => {
this.mqttClient.unsubscribe(responseChannel);
this.mqttClient.removeListener(constants_1.MESSAGE_EVENT, responseCallback);
};
}
catch (err) {
callback({ err });
}
}
}
exports.ClientMqtt = ClientMqtt;
| 36.790123 | 124 | 0.595973 |
467d178e69e78ffea1497ab638020f9d6ed78140 | 198 | js | JavaScript | build/script/ofl/buenard.map.js | xErik/pdfmake-fonts-google | f66c7c58d6590c87c0d1327f31da2f5a53e76f36 | [
"MIT"
] | 8 | 2015-09-16T14:23:40.000Z | 2020-10-20T19:49:11.000Z | build/script/ofl/buenard.map.js | xErik/pdfmake-fonts-google | f66c7c58d6590c87c0d1327f31da2f5a53e76f36 | [
"MIT"
] | 1 | 2017-01-24T16:21:51.000Z | 2017-01-24T16:45:50.000Z | build/script/ofl/buenard.map.js | xErik/pdfmake-fonts-google | f66c7c58d6590c87c0d1327f31da2f5a53e76f36 | [
"MIT"
] | 8 | 2016-04-07T05:58:05.000Z | 2021-03-14T10:26:50.000Z | window.pdfMake = window.pdfMake || {}; window.pdfMake.fonts = {"Buenard":{"bold":"Buenard-Bold.ttf","normal":"Buenard-Regular.ttf","italics":"Buenard-Regular.ttf","bolditalics":"Buenard-Bold.ttf"}}; | 198 | 198 | 0.712121 |
467d8ce2498522b53b55a33fc270a102ea6fcfd5 | 1,645 | js | JavaScript | src/scopeReducer.js | iamrickyspanish/redux-scoped-ducks | dd558cc4a56719b8ac42b6d7472a37752b035a08 | [
"MIT"
] | null | null | null | src/scopeReducer.js | iamrickyspanish/redux-scoped-ducks | dd558cc4a56719b8ac42b6d7472a37752b035a08 | [
"MIT"
] | null | null | null | src/scopeReducer.js | iamrickyspanish/redux-scoped-ducks | dd558cc4a56719b8ac42b6d7472a37752b035a08 | [
"MIT"
] | null | null | null | const isActionTypeScoped = (scope, actionType) => {
const splittedActionType = actionType.split("/");
return splittedActionType.length >= 3 && splittedActionType[1] === scope;
};
/**
* Scopes a reducer function.
*
* Accepts a scope and a reducer function and returns a scoped reducer fucnction. A scoped reducer works and can be used like a regular reducer - the only difference is that the scoped reducer will ignore all actions that aren't scoped the same.
* If not of type "function", the given reducer is returned as it is.
*
* @example
*
* const setValue = payload => ({
* type: "app/reducerA/SET_VALUE",
* payload
* })
*
* const scopedSetValue = scopeAction("reducerB", setValue)
*
* const reducer = (state = 0, action) => action.type === "app/reducerA/SET_VALUE" ? action.payload : state
* const scopedReducer = scopeReducer("reducerB", reducer)
*
* // scoped reducer ignores unscoped action
* console.log(scopedReducer(0, setValue(42)))
* // 0
*
* // scoped reducer handles scoped action
* console.log(scopedReducer(0, scopedSetValue(42)))
* // 42
*
* @param {string} scope
* @param {function} reducer
* @returns {function}
*/
const scopeReducer = (scope, reducer) =>
scope && typeof reducer === "function"
? (state, action) => {
const shouldProcessAction =
action.meta &&
action.meta.unscopedActionType &&
isActionTypeScoped(scope, action.type);
return shouldProcessAction
? reducer(state, { ...action, type: action.meta.unscopedActionType })
: reducer(state, {});
}
: reducer;
export default scopeReducer;
| 32.254902 | 245 | 0.665046 |
467e13c56aee1825147afe653736ee49d7a2be9a | 3,356 | js | JavaScript | src/components/Content.js | fetus-hina/ikalog-webui-dev | 94a9b207de7899df9cc78d64693dcebd8b7b4e75 | [
"Apache-2.0"
] | null | null | null | src/components/Content.js | fetus-hina/ikalog-webui-dev | 94a9b207de7899df9cc78d64693dcebd8b7b4e75 | [
"Apache-2.0"
] | null | null | null | src/components/Content.js | fetus-hina/ikalog-webui-dev | 94a9b207de7899df9cc78d64693dcebd8b7b4e75 | [
"Apache-2.0"
] | null | null | null | /*
* IkaLog
* ======
*
* Copyright (C) 2015 Takeshi HASEGAWA
* Copyright (C) 2016 AIZAWA Hina
*
* 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.
*/
import React, { Component } from 'react';
import { stopEvent } from '../Utils';
import Sidebar from './Sidebar';
import MainContent from './MainContent';
export default class Content extends Component {
render() {
const classesMain = this._addPushClass([
'col-12',
'col-sm-7',
'col-md-8',
'col-lg-9',
'col-xl-9',
]);
const classesSide = this._addPullClass(this._makeCounterSide(classesMain));
return (
<div className="container mt-2">
<div className="row">
<XsHelper {...this.props} />
<MainContent className={classesMain.join(' ')} {...this.props} />
<Sidebar className={classesSide.join(' ')} {...this.props} />
</div>
</div>
);
}
// 左右入れ替えのための push-**-** クラスを生成して返す (col-md-10 => col-md-10 push-md-2)
_addPushClass(classes) {
return this._addPushPullClass(classes, 'push');
}
// 左右入れ替えのための pull-**-** クラスを生成して返す (col-md-10 => col-md-10 pull-md-2)
_addPullClass(classes) {
return this._addPushPullClass(classes, 'pull');
}
// _addPushClass/_addPullClass の実装関数
_addPushPullClass(classes, pushOrPull) {
const ret = [];
classes.forEach(className => {
const match = className.match(/^col-([a-z]{2})-(\d+)$/);
ret.push(className);
if (!match || match[2] === '12') {
return;
}
const push = 12 - parseInt(match[2], 10);
ret.push(`${pushOrPull}-${match[1]}-${push}`);
});
return ret;
}
// 2カラムレイアウトの反対側のクラスを自動生成する(col-**-** の合計が12になるように作る)
_makeCounterSide(classes) {
const ret = [];
classes.forEach(className => {
const match = className.match(/^col-(?:([a-z]{2})-)?(\d+)$/);
if (!match) {
return;
}
if (match[2] === '12') {
ret.push(className);
return;
}
const width = 12 - parseInt(match[2], 10);
ret.push(`col-${match[1]}-${width}`);
});
return ret;
}
}
class XsHelper extends Component {
constructor(props) {
super(props);
this._onClick = this._onClick.bind(this);
}
render() {
return (
<div className="col-12 hidden-sm-up">
<div className="text-right text-xs-right mb-2">
<button className="btn btn-secondary" onClick={this._onClick}>
<span className="fa fa-fw fa-angle-double-down" />
{window.i18n.t('Menu', {ns: 'sidebar'})}
</button>
</div>
</div>
);
}
_onClick(e) {
const $ = window.jQuery;
const $target = $('#menu');
$('body,html').animate({scrollTop:$target.offset().top - 16}, 'fast');
$('body,html').animate({scrollLeft:0}, 'fast');
stopEvent(e);
}
}
| 28.201681 | 79 | 0.58969 |
467e6a1434dcd4b20dc32ec0ba4b59da7626abee | 5,027 | js | JavaScript | files/code/segmentsCloudViewer/js/lib/conjugate-gradient/twiddle.js | Ammarkhat/ammarkhat.github.io | c4e55e1ec5706f0faca64ae63cba232b60ed8fb7 | [
"MIT"
] | null | null | null | files/code/segmentsCloudViewer/js/lib/conjugate-gradient/twiddle.js | Ammarkhat/ammarkhat.github.io | c4e55e1ec5706f0faca64ae63cba232b60ed8fb7 | [
"MIT"
] | null | null | null | files/code/segmentsCloudViewer/js/lib/conjugate-gradient/twiddle.js | Ammarkhat/ammarkhat.github.io | c4e55e1ec5706f0faca64ae63cba232b60ed8fb7 | [
"MIT"
] | null | null | null | /**
* Bit twiddling hacks for JavaScript.
*
* Author: Mikola Lysenko
*
* Ported from Stanford bit twiddling hack library:
* http://graphics.stanford.edu/~seander/bithacks.html
*/
"use strict"; "use restrict";
var twiddle = {};
//Number of bits in an integer
var INT_BITS = 32;
//Constants
twiddle.INT_BITS = INT_BITS;
twiddle.INT_MAX = 0x7fffffff;
twiddle.INT_MIN = -1 << (INT_BITS - 1);
//Returns -1, 0, +1 depending on sign of x
twiddle.sign = function (v) {
return (v > 0) - (v < 0);
}
//Computes absolute value of integer
twiddle.abs = function(v) {
var mask = v >> (INT_BITS-1);
return (v ^ mask) - mask;
}
//Computes minimum of integers x and y
twiddle.min = function(x, y) {
return y ^ ((x ^ y) & -(x < y));
}
//Computes maximum of integers x and y
twiddle.max = function(x, y) {
return x ^ ((x ^ y) & -(x < y));
}
//Checks if a number is a power of two
twiddle.isPow2 = function(v) {
return !(v & (v-1)) && (!!v);
}
//Computes log base 2 of v
twiddle.log2 = function(v) {
var r, shift;
r = (v > 0xFFFF) << 4; v >>>= r;
shift = (v > 0xFF ) << 3; v >>>= shift; r |= shift;
shift = (v > 0xF ) << 2; v >>>= shift; r |= shift;
shift = (v > 0x3 ) << 1; v >>>= shift; r |= shift;
return r | (v >> 1);
}
//Computes log base 10 of v
twiddle.log10 = function(v) {
return (v >= 1000000000) ? 9 : (v >= 100000000) ? 8 : (v >= 10000000) ? 7 :
(v >= 1000000) ? 6 : (v >= 100000) ? 5 : (v >= 10000) ? 4 :
(v >= 1000) ? 3 : (v >= 100) ? 2 : (v >= 10) ? 1 : 0;
}
//Counts number of bits
twiddle.popCount = function(v) {
v = v - ((v >>> 1) & 0x55555555);
v = (v & 0x33333333) + ((v >>> 2) & 0x33333333);
return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24;
}
//Counts number of trailing zeros
function countTrailingZeros(v) {
var c = 32;
v &= -v;
if (v) c--;
if (v & 0x0000FFFF) c -= 16;
if (v & 0x00FF00FF) c -= 8;
if (v & 0x0F0F0F0F) c -= 4;
if (v & 0x33333333) c -= 2;
if (v & 0x55555555) c -= 1;
return c;
}
twiddle.countTrailingZeros = countTrailingZeros;
//Rounds to next power of 2
twiddle.nextPow2 = function(v) {
v += v === 0;
--v;
v |= v >>> 1;
v |= v >>> 2;
v |= v >>> 4;
v |= v >>> 8;
v |= v >>> 16;
return v + 1;
}
//Rounds down to previous power of 2
twiddle.prevPow2 = function(v) {
v |= v >>> 1;
v |= v >>> 2;
v |= v >>> 4;
v |= v >>> 8;
v |= v >>> 16;
return v - (v>>>1);
}
//Computes parity of word
twiddle.parity = function(v) {
v ^= v >>> 16;
v ^= v >>> 8;
v ^= v >>> 4;
v &= 0xf;
return (0x6996 >>> v) & 1;
}
var REVERSE_TABLE = new Array(256);
(function(tab) {
for(var i=0; i<256; ++i) {
var v = i, r = i, s = 7;
for (v >>>= 1; v; v >>>= 1) {
r <<= 1;
r |= v & 1;
--s;
}
tab[i] = (r << s) & 0xff;
}
})(REVERSE_TABLE);
//Reverse bits in a 32 bit word
twiddle.reverse = function(v) {
return (REVERSE_TABLE[ v & 0xff] << 24) |
(REVERSE_TABLE[(v >>> 8) & 0xff] << 16) |
(REVERSE_TABLE[(v >>> 16) & 0xff] << 8) |
REVERSE_TABLE[(v >>> 24) & 0xff];
}
//Interleave bits of 2 coordinates with 16 bits. Useful for fast quadtree codes
twiddle.interleave2 = function(x, y) {
x &= 0xFFFF;
x = (x | (x << 8)) & 0x00FF00FF;
x = (x | (x << 4)) & 0x0F0F0F0F;
x = (x | (x << 2)) & 0x33333333;
x = (x | (x << 1)) & 0x55555555;
y &= 0xFFFF;
y = (y | (y << 8)) & 0x00FF00FF;
y = (y | (y << 4)) & 0x0F0F0F0F;
y = (y | (y << 2)) & 0x33333333;
y = (y | (y << 1)) & 0x55555555;
return x | (y << 1);
}
//Extracts the nth interleaved component
twiddle.deinterleave2 = function(v, n) {
v = (v >>> n) & 0x55555555;
v = (v | (v >>> 1)) & 0x33333333;
v = (v | (v >>> 2)) & 0x0F0F0F0F;
v = (v | (v >>> 4)) & 0x00FF00FF;
v = (v | (v >>> 16)) & 0x000FFFF;
return (v << 16) >> 16;
}
//Interleave bits of 3 coordinates, each with 10 bits. Useful for fast octree codes
twiddle.interleave3 = function(x, y, z) {
x &= 0x3FF;
x = (x | (x<<16)) & 4278190335;
x = (x | (x<<8)) & 251719695;
x = (x | (x<<4)) & 3272356035;
x = (x | (x<<2)) & 1227133513;
y &= 0x3FF;
y = (y | (y<<16)) & 4278190335;
y = (y | (y<<8)) & 251719695;
y = (y | (y<<4)) & 3272356035;
y = (y | (y<<2)) & 1227133513;
x |= (y << 1);
z &= 0x3FF;
z = (z | (z<<16)) & 4278190335;
z = (z | (z<<8)) & 251719695;
z = (z | (z<<4)) & 3272356035;
z = (z | (z<<2)) & 1227133513;
return x | (z << 2);
}
//Extracts nth interleaved component of a 3-tuple
twiddle.deinterleave3 = function(v, n) {
v = (v >>> n) & 1227133513;
v = (v | (v>>>2)) & 3272356035;
v = (v | (v>>>4)) & 251719695;
v = (v | (v>>>8)) & 4278190335;
v = (v | (v>>>16)) & 0x3FF;
return (v<<22)>>22;
}
//Computes next combination in colexicographic order (this is mistakenly called nextPermutation on the bit twiddling hacks page)
twiddle.nextCombination = function(v) {
var t = v | (v - 1);
return (t + 1) | (((~t & -~t) - 1) >>> (countTrailingZeros(v) + 1));
}
| 24.521951 | 128 | 0.515417 |
467f030ba19623970c8c89fb76f9062675af0e29 | 4,671 | js | JavaScript | jssrc/iphone/generated/frmImgCrop.js | mschary932/KitchenSinkApp | 8d8f3dfa13a226d0246039e3583eb26701353954 | [
"MIT"
] | null | null | null | jssrc/iphone/generated/frmImgCrop.js | mschary932/KitchenSinkApp | 8d8f3dfa13a226d0246039e3583eb26701353954 | [
"MIT"
] | null | null | null | jssrc/iphone/generated/frmImgCrop.js | mschary932/KitchenSinkApp | 8d8f3dfa13a226d0246039e3583eb26701353954 | [
"MIT"
] | null | null | null | function addWidgetsfrmImgCrop() {
var labelDesc = new kony.ui.Label({
"id": "labelDesc",
"isVisible": true,
"skin": "lblNormalSimilar",
"text": "Image cropped as image size is larger than image widget size"
}, {
"containerWeight": 100,
"contentAlignment": constants.CONTENT_ALIGN_TOP_LEFT,
"hExpand": true,
"margin": [12, 18, 12, 15],
"marginInPixel": true,
"padding": [5, 0, 5, 5],
"paddingInPixel": true,
"vExpand": false,
"widgetAlignment": constants.WIDGET_ALIGN_CENTER
}, {
"textCopyable": false,
"wrapping": constants.WIDGET_TEXT_WORD_WRAP
});
var linetop = new kony.ui.Line({
"id": "linetop",
"isVisible": true,
"skin": "lineNormal"
}, {
"marginInPixel": false,
"thickness": 1
}, {});
var hboxmain = new kony.ui.Box({
"id": "hboxmain",
"isVisible": true,
"orientation": constants.BOX_LAYOUT_HORIZONTAL,
"position": constants.BOX_POSITION_AS_NORMAL
}, {
"containerWeight": 100,
"layoutAlignment": constants.BOX_LAYOUT_ALIGN_FROM_LEFT,
"layoutType": constants.CONTAINER_LAYOUT_BOX,
"margin": [12, 10, 12, 10],
"marginInPixel": true,
"padding": [5, 5, 5, 5],
"paddingInPixel": true,
"percent": true,
"vExpand": false,
"widgetAlignment": constants.WIDGET_ALIGN_TOP_LEFT
}, {});
var imgCrop = new kony.ui.Image2({
"id": "imgCrop",
"isVisible": true,
"src": "koala_250x200.png"
}, {
"containerWeight": 40,
"imageScaleMode": constants.IMAGE_SCALE_MODE_CROP,
"margin": [0, 0, 0, 0],
"marginInPixel": false,
"padding": [0, 0, 0, 0],
"paddingInPixel": false,
"referenceHeight": 100,
"referenceWidth": 200,
"widgetAlignment": constants.WIDGET_ALIGN_CENTER
}, {
"glossyEffect": constants.IMAGE_GLOSSY_EFFECT_DEFAULT
});
var labelno = new kony.ui.Label({
"id": "labelno",
"isVisible": true,
"skin": "lblNormal"
}, {
"containerWeight": 60,
"contentAlignment": constants.CONTENT_ALIGN_MIDDLE_LEFT,
"hExpand": true,
"margin": [1, 1, 1, 1],
"marginInPixel": true,
"padding": [6, 10, 6, 10],
"paddingInPixel": true,
"vExpand": false,
"widgetAlignment": constants.WIDGET_ALIGN_CENTER
}, {
"textCopyable": false,
"wrapping": constants.WIDGET_TEXT_WORD_WRAP
});
hboxmain.add(imgCrop, labelno);
var linebottom = new kony.ui.Line({
"id": "linebottom",
"isVisible": true,
"skin": "lineNormal"
}, {
"marginInPixel": false,
"thickness": 1
}, {});
frmImgCrop.add(labelDesc, linetop, hboxmain, linebottom);
};
function frmImgCropGlobals() {
frmImgCrop = new kony.ui.Form2({
"addWidgets": addWidgetsfrmImgCrop,
"bounces": true,
"enabledForIdleTimeout": false,
"id": "frmImgCrop",
"needAppMenu": true,
"title": "Crop"
}, {
"displayOrientation": constants.FORM_DISPLAY_ORIENTATION_PORTRAIT,
"layoutType": constants.CONTAINER_LAYOUT_BOX,
"paddingInPixel": false
}, {
"bounces": true,
"configureExtendBottom": false,
"configureExtendTop": false,
"configureStatusBarStyle": false,
"extendBottom": false,
"extendTop": false,
"footerOverlap": false,
"formTransparencyDuringPostShow": 100,
"headerOverlap": false,
"inputAccessoryViewType": constants.FORM_INPUTACCESSORYVIEW_DEFAULT,
"inTransitionConfig": {
"transitionDirection": "none",
"transitionEffect": "none"
},
"needsIndicatorDuringPostShow": true,
"outTransitionConfig": {
"transitionDirection": "none",
"transitionEffect": "none"
},
"retainScrollPosition": false,
"statusBarStyle": constants.STATUS_BAR_STYLE_DEFAULT,
"titleBar": true,
"titleBarConfig": {
"renderTitleText": true,
"prevFormTitle": false,
"titleBarLeftSideView": "title",
"labelLeftSideView": "Back",
"titleBarRightSideView": "none"
},
"titleBarSkin": "sknTitleBarSampleApp"
});
frmImgCrop.info = {
"kuid": "p2kwiet12889314951352"
};
}; | 33.364286 | 79 | 0.55213 |
4680bf8106f2fd7287fa664f115b1e49c258e4c8 | 1,859 | js | JavaScript | frontend/src/components/test-box.js | ethorn/eit-web-ar | 6e9838d9cc0981d6c3933e6d831de6bb018662bd | [
"MIT"
] | null | null | null | frontend/src/components/test-box.js | ethorn/eit-web-ar | 6e9838d9cc0981d6c3933e6d831de6bb018662bd | [
"MIT"
] | 5 | 2020-07-31T07:15:38.000Z | 2020-07-31T07:15:39.000Z | frontend/src/components/test-box.js | ethorn/eit-web-ar | 6e9838d9cc0981d6c3933e6d831de6bb018662bd | [
"MIT"
] | 2 | 2020-07-31T07:18:39.000Z | 2020-07-31T07:20:51.000Z | import AFRAME, { THREE } from "aframe";
import * as utils from "../modules/utils";
const log = utils.getLogger("components:test-box");
// Test component to make sure silly code works
AFRAME.registerComponent('test-box', {
schema: {
width: { type: 'number', default: 1 },
height: { type: 'number', default: 1 },
depth: { type: 'number', default: 1 },
color: { type: 'color', default: '#AAA' }
},
init: function () {
var data = this.data;
var el = this.el;
this.geometry = new THREE.BoxBufferGeometry(data.width, data.height, data.depth);
this.material = new THREE.MeshStandardMaterial({ color: data.color });
this.mesh = new THREE.Mesh(this.geometry, this.material);
el.setObject3D('mesh', this.mesh);
log.info("init done");
},
/**
* Update the mesh in response to property updates.
*/
update: function (oldData) {
var data = this.data;
var el = this.el;
// If `oldData` is empty, then this means we're in the initialization process.
// No need to update.
if (Object.keys(oldData).length === 0) { return; }
// Geometry-related properties changed. Update the geometry.
if (data.width !== oldData.width ||
data.height !== oldData.height ||
data.depth !== oldData.depth) {
el.getObject3D('mesh').geometry = new THREE.BoxBufferGeometry(data.width, data.height,
data.depth);
}
// Material-related properties changed. Update the material.
if (data.color !== oldData.color) {
el.getObject3D('mesh').material.color = new THREE.Color(data.color);
}
},
remove: function () {
this.el.removeObject3D('mesh');
},
events: {
"model-loaded": function (e) {
log.info("Picked up model-loaded for" + e.target.id);
}
}
}); | 30.983333 | 95 | 0.599785 |
4680d19403cc4078ecde01cc44fc7f32bd6370f9 | 990 | js | JavaScript | app/utils/img-manager/simple-map.js | huafu/ember-img-manager | e3ba920475905fb2afe6f062f7e74e1468a432e0 | [
"MIT"
] | 17 | 2015-01-29T00:17:52.000Z | 2015-07-09T15:16:15.000Z | app/utils/img-manager/simple-map.js | huafu/ember-img-manager | e3ba920475905fb2afe6f062f7e74e1468a432e0 | [
"MIT"
] | 9 | 2015-02-12T20:20:22.000Z | 2017-01-02T00:11:24.000Z | app/utils/img-manager/simple-map.js | huafu/ember-img-manager | e3ba920475905fb2afe6f062f7e74e1468a432e0 | [
"MIT"
] | 9 | 2015-03-16T06:46:52.000Z | 2019-04-11T02:04:49.000Z | function SimpleMap() {
this.keys = [];
this.values = [];
}
(function (proto) {
proto.set = function (key, value) {
var index = this.indexOfKey(key);
if (index === -1) {
this.keys.push(key);
this.values.push(value);
}
else {
this.values[index] = value;
}
};
proto.get = function (key) {
var index = this.indexOfKey(key);
if (index !== -1) {
return this.values[index];
}
};
proto.unset = function (key) {
var index = this.indexOfKey(key);
if (index !== -1) {
this.keys.splice(index, 1);
return this.values.splice(index, 1)[0];
}
};
proto.has = function (key) {
return this.indexOfKey(key) !== -1;
};
proto.indexOfKey = function (key) {
return this.keys.indexOf(key);
};
proto.indexOfValue = function (value) {
return this.values.indexOf(value);
};
proto.size = function () {
return this.keys.length;
};
})(SimpleMap.prototype);
export default SimpleMap;
| 18.679245 | 45 | 0.572727 |
4681d13a08336fe167af3f9d9c578d1c53f35927 | 1,164 | js | JavaScript | test/src/test.progress.js | oslllo/svg-fixer | 2435529673699813be020894dd05a505e5bf916b | [
"MIT"
] | 59 | 2020-05-08T13:11:39.000Z | 2022-03-29T17:56:46.000Z | test/src/test.progress.js | oslllo/svg-fixer | 2435529673699813be020894dd05a505e5bf916b | [
"MIT"
] | 26 | 2020-05-13T12:51:38.000Z | 2022-03-08T18:16:43.000Z | test/src/test.progress.js | oslllo/svg-fixer | 2435529673699813be020894dd05a505e5bf916b | [
"MIT"
] | 7 | 2020-05-13T18:05:08.000Z | 2022-03-08T15:23:42.000Z | "use strict";
var capcon = require("capture-console");
const { SVGFixer, assert, path2 } = require("./helper");
describe("test.progress", () => {
it("shows progress bar if showProgressBar is set to true", async () => {
var output = [];
capcon.startCapture(process.stdout, function (stdout) {
output.push(stdout);
});
var options = {
showProgressBar: true,
};
await SVGFixer(path2.direct.absolute, path2.fixed.absolute, options).fix();
capcon.stopCapture(process.stdout);
var expected = ["Fixing:", path2.direct.absolute, "Done!"];
output = output.join(" ");
expected.forEach((value) => {
assert.isTrue(output.includes(value));
});
});
it("does not show progress bar if showProgressBar is set to false", async () => {
var output = [];
capcon.startCapture(process.stdout, function (stdout) {
output.push(stdout);
});
var options = {
showProgressBar: false,
};
await SVGFixer(path2.direct.absolute, path2.fixed.absolute, options).fix();
capcon.stopCapture(process.stdout);
var expected = [];
assert.deepEqual(output, expected);
});
});
| 24.25 | 83 | 0.628007 |
468213c10818f3de3a4076f6b92445cebff1e7e6 | 15,178 | js | JavaScript | horizon/static/horizon/js/horizon.tables.js | rackerlabs/horizon | 8914ed95fc8fa44771f5f3ec827e325a5855b60a | [
"Apache-2.0"
] | 2 | 2018-10-21T22:30:29.000Z | 2020-11-21T08:58:31.000Z | horizon/static/horizon/js/horizon.tables.js | e/horizon | abbce256b68178ebf42816eb87303292212c1dfe | [
"Apache-2.0"
] | null | null | null | horizon/static/horizon/js/horizon.tables.js | e/horizon | abbce256b68178ebf42816eb87303292212c1dfe | [
"Apache-2.0"
] | null | null | null | /* Namespace for core functionality related to DataTables. */
horizon.datatables = {
update: function () {
var $rows_to_update = $('tr.status_unknown.ajax-update');
if ($rows_to_update.length) {
var interval = $rows_to_update.attr('data-update-interval'),
$table = $rows_to_update.closest('table'),
decay_constant = $table.attr('decay_constant');
// Do not update this row if the action column is expanded
if ($rows_to_update.find('.actions_column .btn-group.open').length) {
// Wait and try to update again in next interval instead
setTimeout(horizon.datatables.update, interval);
// Remove interval decay, since this will not hit server
$table.removeAttr('decay_constant');
return;
}
// Trigger the update handlers.
$rows_to_update.each(function(index, row) {
var $row = $(this),
$table = $row.closest('table.datatable');
horizon.ajax.queue({
url: $row.attr('data-update-url'),
error: function (jqXHR, textStatus, errorThrown) {
switch (jqXHR.status) {
// A 404 indicates the object is gone, and should be removed from the table
case 404:
// Update the footer count and reset to default empty row if needed
var $footer, row_count, footer_text, colspan, template, params, $empty_row;
// existing count minus one for the row we're removing
horizon.datatables.update_footer_count($table, -1);
if(row_count === 0) {
colspan = $table.find('th[colspan]').attr('colspan');
template = horizon.templates.compiled_templates["#empty_row_template"];
params = {"colspan": colspan};
empty_row = template.render(params);
$row.replaceWith(empty_row);
} else {
$row.remove();
}
// Reset tablesorter's data cache.
$table.trigger("update");
break;
default:
horizon.utils.log(gettext("An error occurred while updating."));
$row.removeClass("ajax-update");
$row.find("i.ajax-updating").remove();
break;
}
},
success: function (data, textStatus, jqXHR) {
var $new_row = $(data);
if ($new_row.hasClass('status_unknown')) {
var spinner_elm = $new_row.find("td.status_unknown:last");
if ($new_row.find('a.btn-action-required').length > 0) {
spinner_elm.prepend(
$("<div />")
.addClass("action_required_img")
.append(
$("<img />")
.attr("src", "/static/dashboard/img/action_required.png")));
} else {
// Replacing spin.js here with an animated gif to reduce CPU
spinner_elm.prepend(
$("<div />")
.addClass("loading_gif")
.append(
$("<img />")
.attr("src", "/static/dashboard/img/loading.gif")));
}
}
// Only replace row if the html content has changed
if($new_row.html() != $row.html()) {
if($row.find(':checkbox').is(':checked')) {
// Preserve the checkbox if it's already clicked
$new_row.find(':checkbox').prop('checked', true);
}
$row.replaceWith($new_row);
// Reset tablesorter's data cache.
$table.trigger("update");
// Reset decay constant.
$table.removeAttr('decay_constant');
}
},
complete: function (jqXHR, textStatus) {
// Revalidate the button check for the updated table
horizon.datatables.validate_button();
}
});
});
// Set interval decay to this table, and increase if it already exist
if(decay_constant === undefined) {
decay_constant = 1;
} else {
decay_constant++;
}
$table.attr('decay_constant', decay_constant);
// Poll until there are no rows in an "unknown" state on the page.
next_poll = interval * decay_constant;
// Limit the interval to 30 secs
if(next_poll > 30 * 1000) next_poll = 30 * 1000;
setTimeout(horizon.datatables.update, next_poll);
}
},
validate_button: function () {
// Disable form button if checkbox are not checked
$("form").each(function (i) {
var checkboxes = $(this).find(":checkbox");
if(!checkboxes.length) {
// Do nothing if no checkboxes in this form
return;
}
if(!checkboxes.filter(":checked").length) {
$(this).find(".table_actions button.btn-danger").addClass("disabled");
}
});
}
};
/* Generates a confirmation modal dialog for the given action. */
horizon.datatables.confirm = function (action) {
var $action = $(action),
$modal_parent = $(action).closest('.modal'),
name_array = new Array(),
closest_table_id, action_string, name_string,
title, body, modal, form;
if($action.hasClass("disabled")) {
return;
}
action_string = $action.text();
name_string = "";
// Add the display name defined by table.get_object_display(datum)
closest_table_id = $(action).closest("table").attr("id");
// Check if data-display attribute is available
if ($("#"+closest_table_id+" tr[data-display]").length > 0) {
name_string = gettext("You have selected ");
if($(action).closest("div").hasClass("table_actions")) {
// One or more checkboxes selected
$("#"+closest_table_id+" tr[data-display]").has(":checkbox:checked").each(function() {
name_array.push(" \"" + $(this).attr("data-display") + "\"");
});
name_array.join(", ");
name_string += name_array.toString() + ". ";
} else {
// If no checkbox is selected
name_string += " \"" + $(action).closest("tr").attr("data-display") + "\". ";
}
}
title = gettext("Confirm ") + action_string;
body = name_string + gettext("Please confirm your selection. This action cannot be undone.");
modal = horizon.modals.create(title, body, action_string);
modal.modal();
if($modal_parent.length) {
var child_backdrop = modal.next('.modal-backdrop');
// re-arrange z-index for these stacking modal
child_backdrop.css('z-index', $modal_parent.css('z-index')+10);
modal.css('z-index', child_backdrop.css('z-index')+10);
}
modal.find('.btn-primary').click(function (evt) {
form = $action.closest('form');
form.append("<input type='hidden' name='" + $action.attr('name') + "' value='" + $action.attr('value') + "'/>");
form.submit();
modal.modal('hide');
horizon.modals.modal_spinner(gettext("Working"));
return false;
});
return modal;
};
$.tablesorter.addParser({
// set a unique id
id: 'sizeSorter',
is: function(s) {
// Not an auto-detected parser
return false;
},
// compare int values
format: function(s) {
var sizes = {BYTE: 0, B: 0, KB: 1, MB: 2,
GB: 3, TB: 4, PB: 5};
var regex = /([\d\.,]+)\s*(byte|B|KB|MB|GB|TB|PB)+/i;
var match = s.match(regex);
if (match && match.length === 3){
return parseFloat(match[1]) *
Math.pow(1024, sizes[match[2].toUpperCase()]);
}
return parseInt(s, 10);
},
type: 'numeric'
});
horizon.datatables.update_footer_count = function (el, modifier) {
var $el = $(el),
$browser, $footer, row_count, footer_text_template, footer_text;
if (!modifier) {
modifier = 0;
}
// code paths for table or browser footers...
$browser = $el.closest("#browser_wrapper");
if ($browser.length) {
$footer = $browser.find('.tfoot span.content_table_count');
}
else {
$footer = $el.find('tfoot span.table_count');
}
row_count = $el.find('tbody tr:visible').length + modifier - $el.find('.empty').length;
footer_text_template = ngettext("Displaying %s item", "Displaying %s items", row_count);
footer_text = interpolate(footer_text_template, [row_count]);
$footer.text(footer_text);
};
horizon.datatables.add_no_results_row = function (table) {
// Add a "no results" row if there are no results.
template = horizon.templates.compiled_templates["#empty_row_template"];
if (!table.find("tbody tr:visible").length && typeof(template) !== "undefined") {
colspan = table.find("th[colspan]").attr('colspan');
params = {"colspan": colspan};
table.find("tbody").append(template.render(params));
}
};
horizon.datatables.remove_no_results_row = function (table) {
table.find("tr.empty").remove();
};
/*
* Fixes the striping of the table after filtering results.
**/
horizon.datatables.fix_row_striping = function (table) {
table.trigger('applyWidgetId', ['zebra']);
};
horizon.datatables.set_table_sorting = function (parent) {
// Function to initialize the tablesorter plugin strictly on sortable columns.
$(parent).find("table.datatable").each(function () {
var $table = $(this),
header_options = {};
// Disable if not sortable or has <= 1 item
if ($table.find('tbody tr').not('.empty').length > 1){
$table.find("thead th[class!='table_header']").each(function (i, val) {
$th = $(this);
if (!$th.hasClass('sortable')) {
header_options[i] = {sorter: false};
} else if ($th.data('type') == 'size'){
header_options[i] = {sorter: 'sizeSorter'};
} else if ($th.data('type') == 'ip'){
header_options[i] = {sorter: 'ipAddress'};
}
});
$table.tablesorter({
headers: header_options,
selectorHeaders: "thead th[class!='table_header']",
cancelSelection: false
});
}
});
};
horizon.datatables.add_table_checkboxes = function(parent) {
$(parent).find('table thead .multi_select_column').each(function(index, thead) {
if (!$(thead).find(':checkbox').length &&
$(thead).parents('table').find('tbody :checkbox').length) {
$(thead).append('<input type="checkbox">');
}
});
};
horizon.datatables.set_table_query_filter = function (parent) {
$(parent).find('table').each(function (index, elm) {
var input = $($(elm).find('div.table_search input')),
table_selector;
if (input.length > 0) {
// Disable server-side searcing if we have client-side searching since
// (for now) the client-side is actually superior. Server-side filtering
// remains as a noscript fallback.
// TODO(gabriel): figure out an overall strategy for making server-side
// filtering the preferred functional method.
input.on('keypress', function (evt) {
if (evt.keyCode === 13) {
return false;
}
});
input.next('button.btn-search').on('click keypress', function (evt) {
return false;
});
// Enable the client-side searching.
table_selector = 'table#' + $(elm).attr('id');
input.quicksearch(table_selector + ' tbody tr', {
'delay': 300,
'loader': 'span.loading',
'bind': 'keyup click',
'show': this.show,
'hide': this.hide,
onBefore: function () {
var table = $(table_selector);
horizon.datatables.remove_no_results_row(table);
},
onAfter: function () {
var template, table, colspan, params;
table = $(table_selector);
horizon.datatables.update_footer_count(table);
horizon.datatables.add_no_results_row(table);
horizon.datatables.fix_row_striping(table);
},
prepareQuery: function (val) {
return new RegExp(val, "i");
},
testQuery: function (query, txt, _row) {
return query.test($(_row).find('td:not(.hidden):not(.actions_column)').text());
}
});
}
});
};
horizon.datatables.set_table_fixed_filter = function (parent) {
$(parent).find('table.datatable').each(function (index, elm) {
$(elm).on('click', 'div.table_filter button', function(evt) {
var table = $(elm);
var category = $(this).val();
evt.preventDefault();
horizon.datatables.remove_no_results_row(table);
table.find('tbody tr').hide();
table.find('tbody tr.category-' + category).show();
horizon.datatables.update_footer_count(table);
horizon.datatables.add_no_results_row(table);
horizon.datatables.fix_row_striping(table);
});
$(elm).find('div.table_filter button').each(function (i, button) {
// Select the first non-empty category
if ($(button).text().indexOf(' (0)') == -1) {
$(button).addClass('active');
$(button).trigger('click');
return false;
}
});
});
};
horizon.addInitFunction(function() {
horizon.datatables.validate_button();
$('table.datatable').each(function (idx, el) {
horizon.datatables.update_footer_count($(el), 0);
});
// Bind the "select all" checkbox action.
$('div.table_wrapper, #modal_wrapper').on('click', 'table thead .multi_select_column :checkbox', function(evt) {
var $this = $(this),
$table = $this.closest('table'),
is_checked = $this.prop('checked'),
checkboxes = $table.find('tbody :visible:checkbox');
checkboxes.prop('checked', is_checked);
});
// Change "select all" checkbox behaviour while any checkbox is checked/unchecked.
$("div.table_wrapper, #modal_wrapper").on("click", 'table tbody :checkbox', function (evt) {
var $table = $(this).closest('table');
var $multi_select_checkbox = $table.find('thead .multi_select_column :checkbox');
var any_unchecked = $table.find("tbody :checkbox").not(":checked");
$multi_select_checkbox.prop('checked', !(any_unchecked.length > 0));
});
// Enable dangerous buttons only if one or more checkbox is checked.
$("div.table_wrapper, #modal_wrapper").on("click", ':checkbox', function (evt) {
var $form = $(this).closest("form");
var any_checked = $form.find("tbody :checkbox").is(":checked");
if(any_checked) {
$form.find(".table_actions button.btn-danger").removeClass("disabled");
}else {
$form.find(".table_actions button.btn-danger").addClass("disabled");
}
});
// Trigger run-once setup scripts for tables.
horizon.datatables.add_table_checkboxes($('body'));
horizon.datatables.set_table_sorting($('body'));
horizon.datatables.set_table_query_filter($('body'));
horizon.datatables.set_table_fixed_filter($('body'));
// Also apply on tables in modal views.
horizon.modals.addModalInitFunction(horizon.datatables.add_table_checkboxes);
horizon.modals.addModalInitFunction(horizon.datatables.set_table_sorting);
horizon.modals.addModalInitFunction(horizon.datatables.set_table_query_filter);
horizon.modals.addModalInitFunction(horizon.datatables.set_table_fixed_filter);
horizon.datatables.update();
});
| 38.620865 | 116 | 0.599288 |
4683467542c0c49092783f857c3c19219abad622 | 826 | js | JavaScript | client/src/components/BackToTop/index.js | paulvoloschuk/ncms_back | ce176c40646b43d7d7bd8d817a5d2b7132c05803 | [
"Unlicense"
] | null | null | null | client/src/components/BackToTop/index.js | paulvoloschuk/ncms_back | ce176c40646b43d7d7bd8d817a5d2b7132c05803 | [
"Unlicense"
] | null | null | null | client/src/components/BackToTop/index.js | paulvoloschuk/ncms_back | ce176c40646b43d7d7bd8d817a5d2b7132c05803 | [
"Unlicense"
] | null | null | null | import { combineClasses as combine } from 'index/helpers'
import React, { Component } from 'react'
import { scrollTop } from 'index/helpers'
import classes from './styles.scss'
class BackToTop extends Component {
constructor() {
super()
this.state = {hidden: true}
}
shouldComponentUpdate(nextProps, nextState) {
return nextState.hidden !== this.state.hidden
}
componentDidMount() {
this.scrollContainer = document.querySelector('html')
document.addEventListener('scroll', event => {
let { availHeight } = window.screen
this.setState({
hidden: (this.scrollContainer.scrollTop < availHeight * 0.5)
})
})
}
render() {
return <div className={combine(classes.button, this.state.hidden && classes.hidden)} onClick={scrollTop()}/>
}
}
export default BackToTop
| 28.482759 | 112 | 0.681598 |
4683595a71f4f19ccf2038325d08b709fb0886c4 | 215 | js | JavaScript | tests/typing_tests/semantics/builtin_array23.js | mir597/ml_safe | e0da1d9c564b0e8850e75db1d3d976b959bf61cb | [
"BSD-3-Clause"
] | 2 | 2018-10-07T21:28:29.000Z | 2020-11-11T12:09:30.000Z | tests/typing_tests/semantics/builtin_array23.js | mir597/ml_safe | e0da1d9c564b0e8850e75db1d3d976b959bf61cb | [
"BSD-3-Clause"
] | null | null | null | tests/typing_tests/semantics/builtin_array23.js | mir597/ml_safe | e0da1d9c564b0e8850e75db1d3d976b959bf61cb | [
"BSD-3-Clause"
] | 3 | 2020-10-21T10:50:23.000Z | 2021-12-27T21:34:50.000Z | function f0() {}
function f1(input) {
var w = new Array(input.length / 4);
w[0] = new Array();
return w[0][0];
}
function f2() {
return f1(new Array());
}
var __result1 = f2();
var __expect1 = undefined;
| 14.333333 | 38 | 0.6 |
46849b7c5a8074cdaf48d55218b90dea2db88ef7 | 209 | js | JavaScript | Security/router.js | sensate-iot/platform-database-metrics | db51153253346c9e41616783f65d4855faf0df80 | [
"Apache-2.0"
] | null | null | null | Security/router.js | sensate-iot/platform-database-metrics | db51153253346c9e41616783f65d4855faf0df80 | [
"Apache-2.0"
] | null | null | null | Security/router.js | sensate-iot/platform-database-metrics | db51153253346c9e41616783f65d4855faf0df80 | [
"Apache-2.0"
] | null | null | null | db.createUser({
user: "router",
pwd: "",
roles: [
{
role: "read", db: "SensateIoT"
},
{
role: "read", db: "SensateStaging"
}
]
})
| 16.076923 | 59 | 0.354067 |
4684e2651628999f30ce7dc6e7ac60b3c4d3463a | 18,202 | js | JavaScript | src/core/glyf.js | SaiKiranMukka/pdf.js | 70fc30d97c619de0f2fcb51e67bfdb1a46922725 | [
"Apache-2.0"
] | 30,918 | 2015-01-01T06:49:42.000Z | 2022-03-31T16:32:07.000Z | src/core/glyf.js | SaiKiranMukka/pdf.js | 70fc30d97c619de0f2fcb51e67bfdb1a46922725 | [
"Apache-2.0"
] | 9,388 | 2015-01-01T11:58:42.000Z | 2022-03-31T22:16:20.000Z | src/core/glyf.js | SaiKiranMukka/pdf.js | 70fc30d97c619de0f2fcb51e67bfdb1a46922725 | [
"Apache-2.0"
] | 8,649 | 2015-01-01T16:25:47.000Z | 2022-03-31T17:49:22.000Z | /* Copyright 2021 Mozilla Foundation
*
* 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.
*/
const ON_CURVE_POINT = 1 << 0;
const X_SHORT_VECTOR = 1 << 1;
const Y_SHORT_VECTOR = 1 << 2;
const REPEAT_FLAG = 1 << 3;
const X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR = 1 << 4;
const Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR = 1 << 5;
const OVERLAP_SIMPLE = 1 << 6;
const ARG_1_AND_2_ARE_WORDS = 1 << 0;
const ARGS_ARE_XY_VALUES = 1 << 1;
// const ROUND_XY_TO_GRID = 1 << 2;
const WE_HAVE_A_SCALE = 1 << 3;
const MORE_COMPONENTS = 1 << 5;
const WE_HAVE_AN_X_AND_Y_SCALE = 1 << 6;
const WE_HAVE_A_TWO_BY_TWO = 1 << 7;
const WE_HAVE_INSTRUCTIONS = 1 << 8;
// const USE_MY_METRICS = 1 << 9;
// const OVERLAP_COMPOUND = 1 << 10;
// const SCALED_COMPONENT_OFFSET = 1 << 11;
// const UNSCALED_COMPONENT_OFFSET = 1 << 12;
/**
* GlyfTable object represents a glyf table containing glyph information:
* - glyph header (xMin, yMin, xMax, yMax);
* - contours if any;
* - components if the glyph is a composite.
*
* It's possible to re-scale each glyph in order to have a new font which
* exactly fits an other one: the goal is to be able to build some substitution
* font for well-known fonts (Myriad, Arial, ...).
*
* A full description of glyf table can be found here
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html
*/
class GlyfTable {
constructor({ glyfTable, isGlyphLocationsLong, locaTable, numGlyphs }) {
this.glyphs = [];
const loca = new DataView(
locaTable.buffer,
locaTable.byteOffset,
locaTable.byteLength
);
const glyf = new DataView(
glyfTable.buffer,
glyfTable.byteOffset,
glyfTable.byteLength
);
const offsetSize = isGlyphLocationsLong ? 4 : 2;
let prev = isGlyphLocationsLong ? loca.getUint32(0) : 2 * loca.getUint16(0);
let pos = 0;
for (let i = 0; i < numGlyphs; i++) {
pos += offsetSize;
const next = isGlyphLocationsLong
? loca.getUint32(pos)
: 2 * loca.getUint16(pos);
if (next === prev) {
this.glyphs.push(new Glyph({}));
continue;
}
const glyph = Glyph.parse(prev, glyf);
this.glyphs.push(glyph);
prev = next;
}
}
getSize() {
return this.glyphs.reduce((a, g) => {
const size = g.getSize();
// Round to next multiple of 4 if needed.
return a + ((size + 3) & ~3);
}, 0);
}
write() {
const totalSize = this.getSize();
const glyfTable = new DataView(new ArrayBuffer(totalSize));
const isLocationLong = totalSize > /* 0xffff * 2 */ 0x1fffe;
const offsetSize = isLocationLong ? 4 : 2;
const locaTable = new DataView(
new ArrayBuffer((this.glyphs.length + 1) * offsetSize)
);
if (isLocationLong) {
locaTable.setUint32(0, 0);
} else {
locaTable.setUint16(0, 0);
}
let pos = 0;
let locaIndex = 0;
for (const glyph of this.glyphs) {
pos += glyph.write(pos, glyfTable);
// Round to next multiple of 4 if needed.
pos = (pos + 3) & ~3;
locaIndex += offsetSize;
if (isLocationLong) {
locaTable.setUint32(locaIndex, pos);
} else {
locaTable.setUint16(locaIndex, pos >> 1);
}
}
return {
isLocationLong,
loca: new Uint8Array(locaTable.buffer),
glyf: new Uint8Array(glyfTable.buffer),
};
}
scale(factors) {
for (let i = 0, ii = this.glyphs.length; i < ii; i++) {
this.glyphs[i].scale(factors[i]);
}
}
}
class Glyph {
constructor({ header = null, simple = null, composites = null }) {
this.header = header;
this.simple = simple;
this.composites = composites;
}
static parse(pos, glyf) {
const [read, header] = GlyphHeader.parse(pos, glyf);
pos += read;
if (header.numberOfContours < 0) {
// Composite glyph.
const composites = [];
while (true) {
const [n, composite] = CompositeGlyph.parse(pos, glyf);
pos += n;
composites.push(composite);
if (!(composite.flags & MORE_COMPONENTS)) {
break;
}
}
return new Glyph({ header, composites });
}
const simple = SimpleGlyph.parse(pos, glyf, header.numberOfContours);
return new Glyph({ header, simple });
}
getSize() {
if (!this.header) {
return 0;
}
const size = this.simple
? this.simple.getSize()
: this.composites.reduce((a, c) => a + c.getSize(), 0);
return this.header.getSize() + size;
}
write(pos, buf) {
if (!this.header) {
return 0;
}
const spos = pos;
pos += this.header.write(pos, buf);
if (this.simple) {
pos += this.simple.write(pos, buf);
} else {
for (const composite of this.composites) {
pos += composite.write(pos, buf);
}
}
return pos - spos;
}
scale(factor) {
if (!this.header) {
return;
}
const xMiddle = (this.header.xMin + this.header.xMax) / 2;
this.header.scale(xMiddle, factor);
if (this.simple) {
this.simple.scale(xMiddle, factor);
} else {
for (const composite of this.composites) {
composite.scale(xMiddle, factor);
}
}
}
}
class GlyphHeader {
constructor({ numberOfContours, xMin, yMin, xMax, yMax }) {
this.numberOfContours = numberOfContours;
this.xMin = xMin;
this.yMin = yMin;
this.xMax = xMax;
this.yMax = yMax;
}
static parse(pos, glyf) {
return [
10,
new GlyphHeader({
numberOfContours: glyf.getInt16(pos),
xMin: glyf.getInt16(pos + 2),
yMin: glyf.getInt16(pos + 4),
xMax: glyf.getInt16(pos + 6),
yMax: glyf.getInt16(pos + 8),
}),
];
}
getSize() {
return 10;
}
write(pos, buf) {
buf.setInt16(pos, this.numberOfContours);
buf.setInt16(pos + 2, this.xMin);
buf.setInt16(pos + 4, this.yMin);
buf.setInt16(pos + 6, this.xMax);
buf.setInt16(pos + 8, this.yMax);
return 10;
}
scale(x, factor) {
this.xMin = Math.round(x + (this.xMin - x) * factor);
this.xMax = Math.round(x + (this.xMax - x) * factor);
}
}
class Contour {
constructor({ flags, xCoordinates, yCoordinates }) {
this.xCoordinates = xCoordinates;
this.yCoordinates = yCoordinates;
this.flags = flags;
}
}
class SimpleGlyph {
constructor({ contours, instructions }) {
this.contours = contours;
this.instructions = instructions;
}
static parse(pos, glyf, numberOfContours) {
const endPtsOfContours = [];
for (let i = 0; i < numberOfContours; i++) {
const endPt = glyf.getUint16(pos);
pos += 2;
endPtsOfContours.push(endPt);
}
const numberOfPt = endPtsOfContours[numberOfContours - 1] + 1;
const instructionLength = glyf.getUint16(pos);
pos += 2;
const instructions = new Uint8Array(glyf).slice(
pos,
pos + instructionLength
);
pos += instructionLength;
const flags = [];
for (let i = 0; i < numberOfPt; pos++, i++) {
let flag = glyf.getUint8(pos);
flags.push(flag);
if (flag & REPEAT_FLAG) {
const count = glyf.getUint8(++pos);
flag ^= REPEAT_FLAG;
for (let m = 0; m < count; m++) {
flags.push(flag);
}
i += count;
}
}
const allXCoordinates = [];
let xCoordinates = [];
let yCoordinates = [];
let pointFlags = [];
const contours = [];
let endPtsOfContoursIndex = 0;
let lastCoordinate = 0;
// Get x coordinates.
for (let i = 0; i < numberOfPt; i++) {
const flag = flags[i];
if (flag & X_SHORT_VECTOR) {
// 8-bits unsigned value.
const x = glyf.getUint8(pos++);
lastCoordinate += flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR ? x : -x;
xCoordinates.push(lastCoordinate);
} else if (flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR) {
// IS_SAME.
xCoordinates.push(lastCoordinate);
} else {
lastCoordinate += glyf.getInt16(pos);
pos += 2;
xCoordinates.push(lastCoordinate);
}
if (endPtsOfContours[endPtsOfContoursIndex] === i) {
// Next entry is the first one of a new contour.
endPtsOfContoursIndex++;
allXCoordinates.push(xCoordinates);
xCoordinates = [];
}
}
lastCoordinate = 0;
endPtsOfContoursIndex = 0;
for (let i = 0; i < numberOfPt; i++) {
const flag = flags[i];
if (flag & Y_SHORT_VECTOR) {
// 8-bits unsigned value.
const y = glyf.getUint8(pos++);
lastCoordinate += flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR ? y : -y;
yCoordinates.push(lastCoordinate);
} else if (flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR) {
// IS_SAME.
yCoordinates.push(lastCoordinate);
} else {
lastCoordinate += glyf.getInt16(pos);
pos += 2;
yCoordinates.push(lastCoordinate);
}
pointFlags.push((flag & ON_CURVE_POINT) | (flag & OVERLAP_SIMPLE));
if (endPtsOfContours[endPtsOfContoursIndex] === i) {
// Next entry is the first one of a new contour.
xCoordinates = allXCoordinates[endPtsOfContoursIndex];
endPtsOfContoursIndex++;
contours.push(
new Contour({
flags: pointFlags,
xCoordinates,
yCoordinates,
})
);
yCoordinates = [];
pointFlags = [];
}
}
return new SimpleGlyph({
contours,
instructions,
});
}
getSize() {
let size = this.contours.length * 2 + 2 + this.instructions.length;
let lastX = 0;
let lastY = 0;
for (const contour of this.contours) {
size += contour.flags.length;
for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
const x = contour.xCoordinates[i];
const y = contour.yCoordinates[i];
let abs = Math.abs(x - lastX);
if (abs > 255) {
size += 2;
} else if (abs > 0) {
size += 1;
}
lastX = x;
abs = Math.abs(y - lastY);
if (abs > 255) {
size += 2;
} else if (abs > 0) {
size += 1;
}
lastY = y;
}
}
return size;
}
write(pos, buf) {
const spos = pos;
const xCoordinates = [];
const yCoordinates = [];
const flags = [];
let lastX = 0;
let lastY = 0;
for (const contour of this.contours) {
for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
let flag = contour.flags[i];
const x = contour.xCoordinates[i];
let delta = x - lastX;
if (delta === 0) {
flag |= X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR;
xCoordinates.push(0);
} else {
const abs = Math.abs(delta);
if (abs <= 255) {
flag |=
delta >= 0
? X_SHORT_VECTOR | X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR
: X_SHORT_VECTOR;
xCoordinates.push(abs);
} else {
xCoordinates.push(delta);
}
}
lastX = x;
const y = contour.yCoordinates[i];
delta = y - lastY;
if (delta === 0) {
flag |= Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR;
yCoordinates.push(0);
} else {
const abs = Math.abs(delta);
if (abs <= 255) {
flag |=
delta >= 0
? Y_SHORT_VECTOR | Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR
: Y_SHORT_VECTOR;
yCoordinates.push(abs);
} else {
yCoordinates.push(delta);
}
}
lastY = y;
flags.push(flag);
}
// Write endPtsOfContours entry.
buf.setUint16(pos, xCoordinates.length - 1);
pos += 2;
}
// Write instructionLength.
buf.setUint16(pos, this.instructions.length);
pos += 2;
if (this.instructions.length) {
// Write instructions.
new Uint8Array(buf.buffer, 0, buf.buffer.byteLength).set(
this.instructions,
pos
);
pos += this.instructions.length;
}
// Write flags.
for (const flag of flags) {
buf.setUint8(pos++, flag);
}
// Write xCoordinates.
for (let i = 0, ii = xCoordinates.length; i < ii; i++) {
const x = xCoordinates[i];
const flag = flags[i];
if (flag & X_SHORT_VECTOR) {
buf.setUint8(pos++, x);
} else if (!(flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR)) {
buf.setInt16(pos, x);
pos += 2;
}
}
// Write yCoordinates.
for (let i = 0, ii = yCoordinates.length; i < ii; i++) {
const y = yCoordinates[i];
const flag = flags[i];
if (flag & Y_SHORT_VECTOR) {
buf.setUint8(pos++, y);
} else if (!(flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR)) {
buf.setInt16(pos, y);
pos += 2;
}
}
return pos - spos;
}
scale(x, factor) {
for (const contour of this.contours) {
if (contour.xCoordinates.length === 0) {
continue;
}
for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
contour.xCoordinates[i] = Math.round(
x + (contour.xCoordinates[i] - x) * factor
);
}
}
}
}
class CompositeGlyph {
constructor({
flags,
glyphIndex,
argument1,
argument2,
transf,
instructions,
}) {
this.flags = flags;
this.glyphIndex = glyphIndex;
this.argument1 = argument1;
this.argument2 = argument2;
this.transf = transf;
this.instructions = instructions;
}
static parse(pos, glyf) {
const spos = pos;
const transf = [];
let flags = glyf.getUint16(pos);
const glyphIndex = glyf.getUint16(pos + 2);
pos += 4;
let argument1, argument2;
if (flags & ARG_1_AND_2_ARE_WORDS) {
if (flags & ARGS_ARE_XY_VALUES) {
argument1 = glyf.getInt16(pos);
argument2 = glyf.getInt16(pos + 2);
} else {
argument1 = glyf.getUint16(pos);
argument2 = glyf.getUint16(pos + 2);
}
pos += 4;
flags ^= ARG_1_AND_2_ARE_WORDS;
} else {
argument1 = glyf.getUint8(pos);
argument2 = glyf.getUint8(pos + 1);
if (flags & ARGS_ARE_XY_VALUES) {
const abs1 = argument1 & 0x7f;
argument1 = argument1 & 0x80 ? -abs1 : abs1;
const abs2 = argument2 & 0x7f;
argument2 = argument2 & 0x80 ? -abs2 : abs2;
}
pos += 2;
}
if (flags & WE_HAVE_A_SCALE) {
// Single F2.14.
transf.push(glyf.getUint16(pos));
pos += 2;
} else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
// Two F2.14.
transf.push(glyf.getUint16(pos), glyf.getUint16(pos + 2));
pos += 4;
} else if (flags & WE_HAVE_A_TWO_BY_TWO) {
// Four F2.14.
transf.push(
glyf.getUint16(pos),
glyf.getUint16(pos + 2),
glyf.getUint16(pos + 4),
glyf.getUint16(pos + 6)
);
pos += 8;
}
let instructions = null;
if (flags & WE_HAVE_INSTRUCTIONS) {
const instructionLength = glyf.getUint16(pos);
pos += 2;
instructions = new Uint8Array(glyf).slice(pos, pos + instructionLength);
pos += instructionLength;
}
return [
pos - spos,
new CompositeGlyph({
flags,
glyphIndex,
argument1,
argument2,
transf,
instructions,
}),
];
}
getSize() {
let size = 2 + 2 + this.transf.length * 2;
if (this.flags & WE_HAVE_INSTRUCTIONS) {
size += 2 + this.instructions.length;
}
size += 2;
if (this.flags & 2) {
// Arguments are signed.
if (
!(
this.argument1 >= -128 &&
this.argument1 <= 127 &&
this.argument2 >= -128 &&
this.argument2 <= 127
)
) {
size += 2;
}
} else {
if (
!(
this.argument1 >= 0 &&
this.argument1 <= 255 &&
this.argument2 >= 0 &&
this.argument2 <= 255
)
) {
size += 2;
}
}
return size;
}
write(pos, buf) {
const spos = pos;
if (this.flags & ARGS_ARE_XY_VALUES) {
// Arguments are signed.
if (
!(
this.argument1 >= -128 &&
this.argument1 <= 127 &&
this.argument2 >= -128 &&
this.argument2 <= 127
)
) {
this.flags |= ARG_1_AND_2_ARE_WORDS;
}
} else {
if (
!(
this.argument1 >= 0 &&
this.argument1 <= 255 &&
this.argument2 >= 0 &&
this.argument2 <= 255
)
) {
this.flags |= ARG_1_AND_2_ARE_WORDS;
}
}
buf.setUint16(pos, this.flags);
buf.setUint16(pos + 2, this.glyphIndex);
pos += 4;
if (this.flags & ARG_1_AND_2_ARE_WORDS) {
if (this.flags & ARGS_ARE_XY_VALUES) {
buf.setInt16(pos, this.argument1);
buf.setInt16(pos + 2, this.argument2);
} else {
buf.setUint16(pos, this.argument1);
buf.setUint16(pos + 2, this.argument2);
}
pos += 4;
} else {
buf.setUint8(pos, this.argument1);
buf.setUint8(pos + 1, this.argument2);
pos += 2;
}
if (this.flags & WE_HAVE_INSTRUCTIONS) {
buf.setUint16(pos, this.instructions.length);
pos += 2;
// Write instructions.
if (this.instructions.length) {
new Uint8Array(buf.buffer, 0, buf.buffer.byteLength).set(
this.instructions,
pos
);
pos += this.instructions.length;
}
}
return pos - spos;
}
scale(x, factor) {}
}
export { GlyfTable };
| 25.745403 | 82 | 0.561971 |
468582b658d6174269679ebafef56ead34c702d7 | 1,138 | js | JavaScript | scripts/lib/runic.js | karnotcycle/kokorobot | 264b0d874bfec55923a669b0f56a6b906d4e7c63 | [
"MIT"
] | 9 | 2018-02-28T09:51:20.000Z | 2021-11-26T11:52:45.000Z | scripts/lib/runic.js | karnotcycle/kokorobot | 264b0d874bfec55923a669b0f56a6b906d4e7c63 | [
"MIT"
] | 5 | 2018-03-12T19:29:07.000Z | 2022-01-27T17:12:10.000Z | scripts/lib/runic.js | karnotcycle/kokorobot | 264b0d874bfec55923a669b0f56a6b906d4e7c63 | [
"MIT"
] | 5 | 2018-02-19T01:05:29.000Z | 2021-06-30T15:33:10.000Z | 'use strict'
function Runic (lib = {}) {
function filter (line) {
const pass = lib[line.substr(0, 1)] && line.substr(1, 1) === ' '
if (pass !== true) { console.warn('Runic', 'Error near: ', line) }
return pass
}
function stash (acc, line) {
const rune = line.substr(0, 1)
const prev = acc[acc.length - 1] ? acc[acc.length - 1] : [{ rune: rune, arr: [] }]
if (prev.rune === rune) { prev.arr.push(line.substr(2)) } else { acc.push({ rune: rune, arr: [line.substr(2)] }) }
return acc
}
function wrap (html, tag, cl) {
return tag ? `<${tag} ${cl ? 'class="' + cl + '"' : ''}>${html}</${tag}>` : html
}
this.run = (input = [], host = null) => {
return input.filter(filter).reduce(stash, []).reduce((acc, stash) => {
const rune = lib[stash.rune]
const html = stash.arr.reduce((acc, val, id) => {
const inner = rune.fn ? rune.fn(stash.arr[id], host) : stash.arr[id]
const outer = rune.tag ? wrap(inner, rune.tag, rune.class) : inner
return `${acc}${outer}`
}, '')
return `${acc}${wrap(html, rune.wrapper, rune.wrapperClass)}`
}, '')
}
}
| 34.484848 | 118 | 0.542179 |
4685dfa7ab8984ca2950048b077733c75b2562bc | 31,760 | js | JavaScript | services/lnd/grpc.js | SatoshiNakamotoBitcoin/juggernaut-desktop | 36a37ab9194bfaf69c9e0ad89f47fc2415a23712 | [
"MIT"
] | 124 | 2020-04-13T22:20:23.000Z | 2022-03-18T15:38:47.000Z | services/lnd/grpc.js | SatoshiNakamotoBitcoin/juggernaut-desktop | 36a37ab9194bfaf69c9e0ad89f47fc2415a23712 | [
"MIT"
] | 57 | 2020-04-16T21:14:35.000Z | 2021-09-28T08:30:41.000Z | services/lnd/grpc.js | SatoshiNakamotoBitcoin/juggernaut-desktop | 36a37ab9194bfaf69c9e0ad89f47fc2415a23712 | [
"MIT"
] | 13 | 2020-04-16T18:21:07.000Z | 2022-03-18T15:38:51.000Z | import EventEmitter from 'events';
import intersection from 'lodash/intersection';
import { proxyValue } from 'comlinkjs';
import crypto from 'crypto';
import { status } from '@grpc/grpc-js';
import LndGrpc from '@ln-juggernaut/lnd-grpc';
import { grpcLog } from '../../utils/log';
import errors from '../../renderer/constants/errors.json';
import delay from '../../utils/delay';
import promiseTimeout from '../../utils/promiseTimeout';
import isObject from '../../utils/isObject';
import { forwardAll, unforwardAll } from '../../utils/events/events';
import lightningMethods from './lightning.methods';
import lightningSubscriptions from './lightning.subscriptions';
import { getCustomRecords } from '../../utils/customRecords';
import extractMessageFromInvoice from '../../utils/extractMessageFromInvoice';
import extractMessageFromPayment from '../../utils/extractMessageFromPayment';
import getSignedDataFromMessage from '../../utils/getSignedDataFromMessage';
import mapNode from '../../utils/mappings/lnd/node';
import mapEdge from '../../utils/mappings/lnd/edge';
import enhanceNodesFromEdges from '../../utils/enhanceNodesFromEdges';
const GRPC_WALLET_UNLOCKER_SERVICE_ACTIVE = 'WALLET_LOCKED';
const GRPC_LIGHTNING_SERVICE_ACTIVE = 'WALLET_ACTIVE';
// Timeout for WalletUnlocker actions.
const WALLET_UNLOCKER_TIMEOUT = 1000 * 60;
/**
* LND gRPC wrapper.
*
* @augments EventEmitter
*/
class LndGrpcWrapper extends EventEmitter {
/**
* State properties that should be reset after a disconnect.
*
* @type {object}
*/
static VOLATILE_STATE = {
options: {},
services: {},
activeSubscriptions: {}
};
constructor() {
super();
this.availableSubscriptions = {};
this.registerSubscription('invoices', 'Lightning', 'subscribeInvoices');
this.registerSubscription(
'transactions',
'Lightning',
'subscribeTransactions'
);
this.registerSubscription(
'channelgraph',
'Lightning',
'subscribeChannelGraph'
);
this.registerSubscription('info', 'Lightning', 'subscribeGetInfo');
this.registerSubscription(
'backups',
'Lightning',
'subscribeChannelBackups'
);
this.registerSubscription(
'channelevents',
'Lightning',
'subscribeChannelEvents'
);
this.registerSubscription('peerevents', 'Lightning', 'subscribePeerEvents');
Object.assign(this, LndGrpcWrapper.VOLATILE_STATE);
}
/**
* connect - Initiate gRPC connection.
*
* @param {object} options Connection options
* @returns {LndGrpc} LndGrpc connection
*/
async connect(options) {
if (this.grpc && this.grpc.state !== 'ready') {
throw new Error('Can not connect (already connected)');
}
this.options = options;
// Create a new grpc instance using settings from init options.
const grpcOptions = this.getConnectionSettings();
this.grpc = new LndGrpc(grpcOptions);
// Set up service accessors.
this.services = this.grpc.services;
// Inject helper methods.
Object.assign(this.services.Lightning, lightningMethods);
Object.assign(this.services.Lightning, lightningSubscriptions);
// Setup gRPC event handlers.
this.grpc.on('locked', () => {
this.emit(GRPC_WALLET_UNLOCKER_SERVICE_ACTIVE);
});
this.grpc.on('active', async () => {
await this.initializePubkey();
this.emit(GRPC_LIGHTNING_SERVICE_ACTIVE);
this.subscribeAll();
});
await this.grpc.connect(options);
// Connect the service.
return this.wallet;
}
/* eslint-disable no-await-in-loop */
async getValidMessageFromPayment(payment) {
if (payment.status !== 'SUCCEEDED') {
return null;
}
const senderPubkey = await this.getPubkey();
const message = await extractMessageFromPayment(payment);
if (!message) {
return null;
}
const {
createdAt,
content,
contentType,
requestIdentifier,
preimage,
amountMSats,
feeAmountMSats,
receiverPubkey
} = message;
return {
createdAt,
content,
contentType,
requestIdentifier,
preimage,
amountMSats,
feeAmountMSats,
receiverPubkey,
senderPubkey,
unread: false,
valid: true
};
}
async getAllSentMessages() {
const messages = [];
const payments = await this.listPayments();
for (let i = 0; i < payments.length; i += 1) {
const message = await this.getValidMessageFromPayment(payments[i]);
if (message) {
messages.push(message);
}
}
return messages;
}
async getMessagesSinceSettleIndex(settleIndex) {
const messages = [];
let { invoices, lastIndexOffset } = await this.listInvoices(settleIndex);
while (invoices.length > 0) {
for (let i = 0; i < invoices.length; i += 1) {
const message = await this.getValidMessageFromInvoice(invoices[i]);
if (message) {
messages.push(message);
}
}
({ invoices, lastIndexOffset } = await this.listInvoices(
lastIndexOffset
));
}
return messages;
}
/* eslint-enable no-await-in-loop */
async getValidMessageFromInvoice(invoice) {
if (!invoice.settled) {
return null;
}
const message = extractMessageFromInvoice(invoice);
if (!message) {
return null;
}
const receiverPubkey = await this.getPubkey();
const signData = getSignedDataFromMessage(message, receiverPubkey);
const { signatureBytes: signature } = message;
const validMessage = await this.isValidMessage(signData, signature);
const {
senderPubkey,
createdAt,
content,
contentType,
requestIdentifier,
preimage,
settleIndex,
amountMSats,
feeAmountMSats
} = message;
return {
senderPubkey,
receiverPubkey,
createdAt,
content,
contentType,
requestIdentifier,
preimage,
settleIndex,
amountMSats,
feeAmountMSats,
valid: validMessage,
unread: true
};
}
async subscribeToMessages() {
this.on('subscribeInvoices.data', async invoice => {
const validMessage = await this.getValidMessageFromInvoice(invoice);
if (validMessage) {
this.emit('subscribeMessages.data', validMessage);
}
});
}
async getAllNodes() {
const { nodes, edges } = await this.services.Lightning.describeGraph({
include_unannounced: false
});
const mappedNodes = nodes.map(mapNode);
const mappedEdges = edges.map(mapEdge);
enhanceNodesFromEdges(mappedNodes, mappedEdges);
const otherNodes = mappedNodes.filter(node => {
return node.pubKey !== this.pubkey;
});
return otherNodes;
}
async newAddress(type) {
const { address } = await this.services.Lightning.newAddress({ type });
return address;
}
async isValidMessage(msg, signature) {
try {
const verifyResponse = await this.verifyMessage({ msg, signature });
return verifyResponse.valid;
} catch (e) {
return false;
}
}
async validConnectionDetails(options) {
const grpcOptions = this.getConnectionSettings(options);
try {
const grpc = new LndGrpc(grpcOptions);
await grpc.connect();
} catch (e) {
return false;
}
return true;
}
get state() {
return this.grpc.state;
}
/**
* unlock - Unlock gRPC service.
*
* @param {string} password Password
* @returns {Promise} Promise that resolves after unlocking a wallet and connecting to the Lightning interface.
*/
async unlock(password) {
try {
const { grpc } = this;
await promiseTimeout(
WALLET_UNLOCKER_TIMEOUT,
grpc.services.WalletUnlocker.unlockWallet({
wallet_password: Buffer.from(password)
})
);
return await promiseTimeout(
WALLET_UNLOCKER_TIMEOUT,
grpc.activateLightning()
);
} catch (e) {
grpcLog.error(`Error when trying to connect to LND grpc: %o`, e);
throw e;
}
}
/**
* initWallet - Create / Restore wallet.
*
* @param {object} payload Payload
* @returns {Promise} Promise that resolves after creating wallet and connecting to the Lightning interface.
*/
async initWallet(payload) {
try {
const { grpc } = this;
await promiseTimeout(
WALLET_UNLOCKER_TIMEOUT,
grpc.services.WalletUnlocker.initWallet(payload)
);
return await promiseTimeout(
WALLET_UNLOCKER_TIMEOUT,
grpc.activateLightning()
);
} catch (e) {
grpcLog.error(`Error when trying to create wallet: %o`, e);
throw e;
}
}
/**
* disconnect - Disconnect gRPC service.
*
* @param {...object} args Disconnect args
*/
async disconnect(...args) {
await this.unsubscribe();
this.removeAllListeners('subscribeInvoices.data');
if (this.grpc) {
if (this.grpc.can('disconnect')) {
await this.grpc.disconnect(args);
}
// Remove gRPC event handlers.
this.grpc.removeAllListeners('locked');
this.grpc.removeAllListeners('active');
}
// Reset the state.
Object.assign(this, LndGrpcWrapper.VOLATILE_STATE);
}
/**
* waitForState - Wait for grpc service to enter specific sate (proxy method).
*
* @param {...object} args WaitForState args
* @returns {object} LndGrpc.waitForState
*/
waitForState(...args) {
return proxyValue(this.grpc.waitForState(args));
}
isSubscribed(subscription) {
return Boolean(this.activeSubscriptions[subscription]);
}
/**
* subscribeAll - Subscribe to all gRPC streams.
*/
async subscribeAll() {
this.subscribe(
'invoices',
'transactions',
'backups',
'channelevents',
'peerevents'
);
this.subscribeToMessages();
// Finalize subscriptions if `data.synced_to_chain` is true.
// Returns true if subscriptions were finalized and false otherwise
const finalizeSubscriptions = async data => {
if (data && data.synced_to_chain) {
if (this.isSubscribed('info')) {
await this.unsubscribe('info');
}
this.subscribe({ name: 'info', params: { pollInterval: 60000 } });
this.subscribeChannelGraph();
return true;
}
return false;
};
const data = await this.services.Lightning.getInfo();
// If we are already fully synced set up finalize the subscriptions right away.
if (!(await finalizeSubscriptions(data))) {
// Otherwise, set up a fast poling subscription to the info stream and finalize once the chain sync has completed.
// This is needed because LND chanRouter waits for chain sync to complete before accepting subscriptions.
this.subscribe({ name: 'info', params: { pollImmediately: true } });
this.on('subscribeGetInfo.data', finalizeSubscriptions);
}
}
/**
* subscribe - Subscribe Subscribe to gRPC streams (``@streams` must be a subset of `this.availableSubscriptions`).
*
* @param {...string|object} streams optional list of streams to subscribe to. if omitted, uses all available streams
* if `stream` is to be called with params array element must be of {name, params} format
*/
subscribe(...streams) {
// some of the streams may have params
// create a map <streamName, params> out of them
const getSubscriptionParams = streams => {
if (!(streams && streams.length)) {
return {};
}
return streams.reduce((acc, next) => {
if (isObject(next)) {
acc[next.name] = next.params;
}
return acc;
}, {});
};
// flattens @streams into an Array<string> of stream names to subscribe to
const getSubscriptionsNames = streams =>
streams && streams.map(entry => (isObject(entry) ? entry.name : entry));
// make sure we are subscribing to known streams if a specific list is provided
const allSubKeys = Object.keys(this.availableSubscriptions);
const params = getSubscriptionParams(streams);
const subNames = getSubscriptionsNames(streams);
const activeSubKeys =
subNames && subNames.length
? intersection(allSubKeys, subNames)
: allSubKeys;
if (!activeSubKeys.length) {
return;
}
grpcLog.info(`Subscribing to gRPC streams: %o`, activeSubKeys);
// Close and clear subscriptions when they emit an end event.
activeSubKeys.forEach(key => {
if (this.isSubscribed(key)) {
grpcLog.warn(
`Unable to subscribe to gRPC streams: %s (already active)`,
key
);
return;
}
// Set up the subscription.
const { serviceName, methodName } = this.availableSubscriptions[key];
const service = this.services[serviceName];
const subscriptionParams = params[key] || {};
this.activeSubscriptions[key] = service[methodName](subscriptionParams);
grpcLog.info(`gRPC subscription "${key}" started.`);
// Setup subscription event forwarders.
forwardAll(service, methodName, this);
// Set up subscription event listeners to handle when streams close.
if (this.activeSubscriptions[key]) {
this.activeSubscriptions[key].on('end', () => {
grpcLog.info(`gRPC subscription "${key}" ended.`);
delete this.activeSubscriptions[key];
});
this.activeSubscriptions[key].on('status', callStatus => {
if (callStatus.code === status.CANCELLED) {
delete this.activeSubscriptions[key];
grpcLog.info(`gRPC subscription "${key}" cancelled.`);
}
});
}
});
}
/**
* unsubscribe - Unsubscribe from all streams. (@streams must be a subset of `this.availableSubscriptions`).
*
* @param {...string} streams optional list of streams to unsubscribe from. if omitted, uses all active streams.
*/
async unsubscribe(...streams) {
// make sure we are unsubscribing from active services if a specific list is provided
const allSubKeys = Object.keys(this.activeSubscriptions);
const activeSubKeys =
streams && streams.length
? intersection(allSubKeys, streams)
: allSubKeys;
if (!activeSubKeys.length) {
return;
}
grpcLog.info(`Unsubscribing from gRPC streams: %o`, activeSubKeys);
const cancellations = activeSubKeys.map(key =>
this.cancelSubscription(key)
);
await Promise.all(cancellations);
}
/**
* registerSubscription - Register a stream.
* Provide a mapping between a service and a subscription activation helper method.
*
* @param {string} key Key used to identify the subscription.
* @param {string} serviceName Name of service that provides the subscription.
* @param {string} methodName Name of service methods that activates the subscription.
*/
registerSubscription(key, serviceName, methodName) {
this.availableSubscriptions[key] = { key, serviceName, methodName };
}
/**
* cancelSubscription - Unsubscribe from a single stream.
*
* @param {string} key Name of stream subscription to cancel
* @returns {Promise} Resolves once stream has been canceled
*/
async cancelSubscription(key) {
if (!this.activeSubscriptions[key]) {
grpcLog.warn(
`Unable to unsubscribe from gRPC stream: %s (not active)`,
key
);
return null;
}
grpcLog.info(`Unsubscribing from ${key} gRPC stream`);
// Remove subscription event forwarders.
const { serviceName, methodName } = this.availableSubscriptions[key];
const service = this.services[serviceName];
unforwardAll(service, methodName);
// Cancellation status callback handler.
const result = new Promise(resolve => {
this.activeSubscriptions[key].on('status', callStatus => {
if (callStatus.code === status.CANCELLED) {
delete this.activeSubscriptions[key];
grpcLog.info(`Unsubscribed from ${key} gRPC stream`);
resolve();
}
});
this.activeSubscriptions[key].on('end', () => {
delete this.activeSubscriptions[key];
grpcLog.info(`Unsubscribed from ${key} gRPC stream`);
resolve();
});
});
// Initiate cancellation request.
this.activeSubscriptions[key].cancel();
// Resolve once we receive confirmation of the call's cancellation.
return result;
}
/**
* getConnectionSettings - Get connection details based on wallet config.
*
* @returns {object} Connection settings
*/
getConnectionSettings(options) {
const { id, type, host, cert, macaroon, lndconnectUri, protoDir } =
options || this.options;
// Don't use macaroons when connecting to the local tmp instance.
const useMacaroon = this.useMacaroon && id !== 'tmp';
// If connecting to a local instance, wait for the macaroon file to exist.
const waitForMacaroon = type === 'local';
const waitForCert = type === 'local';
return {
host,
cert,
macaroon,
waitForMacaroon,
waitForCert,
useMacaroon,
protoDir,
lndconnectUri
};
}
/**
* subscribeChannelGraph - Set up subscription to the channel graph stream.
*
* There is no guarentee that it is ready yet as it can take time for lnd to start it once chain sync has finished
* so set up a schedular to keep retrying until it works.
*
* @param {number} initialTimeout Length of time to wait until first retry (ms)
* @param {number} backoff Backoff exponent
* @param {number} maxTimeout Maximux Length of time to wait until a retry (ms)
*/
subscribeChannelGraph(
initialTimeout = 250,
backoff = 2,
maxTimeout = 1000 * 60
) {
const initSubscription = async timeout => {
if (this.grpc.state !== 'active') {
return;
}
// If the channel graph subscription fails to start, try again in a bit.
if (this.activeSubscriptions.channelgraph) {
this.activeSubscriptions.channelgraph.once('error', async error => {
if (error.message === 'router not started') {
grpcLog.warn(
'Unable to subscribe to channelgraph. Will try again in %sms',
timeout
);
await delay(timeout);
const nextTimeout = Math.min(maxTimeout, timeout * backoff);
initSubscription(nextTimeout);
}
});
}
// Set up the subscription.
this.subscribe('channelgraph');
};
initSubscription(initialTimeout);
}
async getInfo() {
const data = await this.services.Lightning.getInfo();
return data;
}
async getNodeInfo(pubKey, includeChannels = false) {
const nodeInfo = await this.services.Lightning.getNodeInfo({
pub_key: pubKey,
include_channels: includeChannels
});
return {
lastUpdate: nodeInfo.node.last_update,
pubKey: nodeInfo.node.pub_key,
alias: nodeInfo.node.alias,
addresses: nodeInfo.node.addresses,
color: nodeInfo.node.color,
numChannels: nodeInfo.num_channels,
totalCapacity: nodeInfo.total_capacity,
channels: nodeInfo.channels.map(channel => {
return {
channelId: channel.channel_id,
chanPoint: channel.chan_point,
lastUpdate: channel.last_update,
node1Pub: channel.node1_pub,
node2Pub: channel.node2_pub,
capacity: channel.capacity,
node1Policy: {
timeLockDelta: channel.node1_policy.time_lock_delta,
minHtlc: channel.node1_policy.min_htlc,
feeBaseMsat: channel.node1_policy.fee_base_msat,
feeRateMilliMsat: channel.node1_policy.fee_rate_milli_msat,
disabled: channel.node1_policy.disabled,
maxHtlcMsat: channel.node1_policy.max_htlc_msat,
lastUpdate: channel.node1_policy.last_update
},
node2Policy: {
timeLockDelta: channel.node1_policy.time_lock_delta,
minHtlc: channel.node1_policy.min_htlc,
feeBaseMsat: channel.node1_policy.fee_base_msat,
feeRateMilliMsat: channel.node1_policy.fee_rate_milli_msat,
disabled: channel.node1_policy.disabled,
maxHtlcMsat: channel.node1_policy.max_htlc_msat,
lastUpdate: channel.node1_policy.last_update
}
};
})
};
}
async listPeers(pubKey) {
const { peers } = await this.services.Lightning.listPeers({});
const mappedPeers = peers.map(peer => {
return {
pubKey: peer.pub_key,
address: peer.address,
bytesSent: peer.bytes_sent,
bytesRecv: peer.bytes_recv,
satSent: peer.sat_sent,
satRecv: peer.sat_recv,
inbound: peer.inbound,
pingTime: peer.ping_time,
syncType: peer.sync_type,
features: peer.features
};
});
if (pubKey) {
return mappedPeers.find(peer => peer.pubKey === pubKey);
}
return mappedPeers;
}
async getNodeDetails(pubKey) {
const {
lastUpdate,
alias,
color,
addresses,
features,
numChannels,
totalCapacity,
channels: remoteChannels
} = await this.getNodeInfo(pubKey, true);
const peer = await this.listPeers(pubKey);
const { active, pending } = await this.listChannels(pubKey);
return {
pubKey,
color,
alias,
lastUpdate,
addresses,
features,
numChannels,
totalCapacity,
remoteChannels,
channels: active,
pendingChannels: pending,
peer
};
}
async initializePubkey() {
const info = await this.services.Lightning.getInfo({});
this.pubkey = info.identity_pubkey;
this.pubkeyBytes = Buffer.from(this.pubkey, 'hex');
}
async getPubkey() {
if (this.pubkey) {
return this.pubkey;
}
await this.initializePubkey();
return this.pubkey;
}
/* eslint-disable compat/compat */
async sendMessageToPubKey(
message,
contentType,
requestIdentifier,
destinationPubKey,
amountMSats,
feeLimitMSats
) {
const preimageBytes = crypto.randomBytes(32);
const hash = crypto.createHash('sha256');
hash.update(preimageBytes);
const preimageHash = hash.digest();
const timestamp = new Date().getTime();
const timeBytes = Buffer.allocUnsafe(8);
timeBytes.writeBigInt64BE(BigInt(timestamp), 0);
const destinationKeyBytes = Buffer.from(destinationPubKey, 'hex');
const messageBytes = Buffer.from(message, 'utf8');
const contentTypeBytes = Buffer.from(contentType, 'utf8');
const requestIdentifierBytes = Buffer.from(requestIdentifier, 'hex');
const signData = Buffer.concat([
this.pubkeyBytes,
destinationKeyBytes,
timeBytes,
messageBytes,
contentTypeBytes
]);
let signResponse = null;
try {
signResponse = await this.services.Lightning.signMessage({
msg: signData
});
} catch (e) {
grpcLog.info('failed to sign message: %O', e);
}
const { signature } = signResponse;
const signatureBytes = Buffer.from(signature, 'utf8');
const customRecords = getCustomRecords({
message: messageBytes,
sourcePubkey: this.pubkeyBytes,
timestamp: timeBytes,
preimage: preimageBytes,
signature: signatureBytes,
contentType: contentTypeBytes,
requestIdentifier: requestIdentifierBytes
});
const amountToSend = Math.max(amountMSats, 1000);
const sendPaymentRequest = {
payment_hash: preimageHash,
amt_msat: amountToSend,
dest: destinationKeyBytes,
dest_custom_records: customRecords,
final_cltv_delta: 40,
fee_limit_msat: feeLimitMSats,
timeout_seconds: 30
};
grpcLog.info(sendPaymentRequest);
const sentPayment = this.grpc.services.Router.sendPayment(
sendPaymentRequest
);
return new Promise((resolve, reject) => {
sentPayment.on('data', data => {
grpcLog.info('received sendPayment data %O', data);
if (data.state && data.state !== 'IN_FLIGHT') {
if (data.state === 'SUCCEEDED') {
this.emit('paymentSent', data);
const feeAmountMSats = data.htlcs.reduce((totalFeesMSats, htlc) => {
return totalFeesMSats + htlc.route.total_fees_msat;
}, 0);
resolve({
amountMSats: amountToSend,
preimage: preimageBytes.toString('hex'),
feeAmountMSats
});
} else {
const paymentState = data.state;
reject(new Error(paymentState));
}
}
});
sentPayment.on('status', status => {
grpcLog.info('received sendPayment status %O', status);
});
sentPayment.on('error', error => {
if (error && error.message.includes('amount must be specified')) {
reject(new Error(errors.OLD_LND_VERSION));
}
grpcLog.info('received sendPayment error %O', error);
});
sentPayment.on('end', () => {
grpcLog.info('received sendPayment end');
});
});
}
async listPayments() {
const { payments } = await this.services.Lightning.listPayments({
include_incomplete: false
});
// todo: map payments
return payments;
}
async listInvoices(lastSettleIndex) {
const listInvoiceRequest = {};
if (lastSettleIndex) {
listInvoiceRequest.index_offset = lastSettleIndex;
}
const {
invoices,
last_index_offset: lastIndexOffset
} = await this.services.Lightning.listInvoices(listInvoiceRequest);
// todo map invoices
return {
invoices,
lastIndexOffset
};
}
async verifyMessage(message) {
return this.services.Lightning.verifyMessage(message);
}
async signMessage(message) {
return this.services.Lightning.signMessage(message);
}
async getBalanceInformation() {
const [walletBalance, channelBalance] = await Promise.all([
this.services.Lightning.walletBalance(),
this.services.Lightning.channelBalance()
]);
const availableBalance =
walletBalance.confirmed_balance + channelBalance.balance;
const pendingBalance =
walletBalance.unconfirmed_balance + channelBalance.pending_open_balance;
return {
availableBalance,
pendingBalance
};
}
async openChannel({
pubkey,
localSatoshis,
remoteSatoshis,
targetConfirmations
}) {
try {
await this.grpc.services.Lightning.openChannel({
node_pubkey: Buffer.from(pubkey, 'hex'),
local_funding_amount: localSatoshis + remoteSatoshis,
push_sat: remoteSatoshis,
target_conf: targetConfirmations
});
} catch (e) {
grpcLog.info('failed to open channel');
grpcLog.info(e.message);
if (e.message === 'channel is too small') {
throw new Error(errors.CHANNEL_TOO_SMALL);
} else if (e.message.match(/dial.tcp(.*)connect(.*)no.route.to.host/i)) {
throw new Error(errors.PEER_IS_OFFLINE);
} else if (e.message.match(/received.funding.error.from/i)) {
throw new Error(errors.PEER_IS_OFFLINE);
} else {
throw e;
}
}
}
async closeChannel({ channelPoint, chanId, force }) {
const [fundingTxid, outputIndex] = channelPoint.split(':');
return this.grpc.services.Lightning.closeChannel({
channel_point: {
funding_txid: fundingTxid,
output_index: outputIndex
},
chan_id: chanId,
force
});
}
async listChannels(pubKey) {
const { channels } = await this.grpc.services.Lightning.listChannels({
active_only: true,
inactive_only: false,
public_only: false,
private_only: false
});
const {
pending_open_channels: pendingOpenChannels,
pending_closing_channels: pendingClosingChannels,
pending_force_closing_channels: pendingForceClosingChannels,
waiting_close_channels: waitingCloseChannels
} = await this.grpc.services.Lightning.pendingChannels({});
const pendingCloseChannels = pendingClosingChannels
.concat(pendingForceClosingChannels)
.concat(waitingCloseChannels)
.map(channel => channel.channel);
const pendingChannels = pendingOpenChannels.map(channel => channel.channel);
const filteredChannels = channels.filter(channel => {
const pubkeyMatches = !pubKey || channel.remote_pubkey === pubKey;
const isClosing = pendingCloseChannels.find(
pendingCloseChannel =>
pendingCloseChannel.channel_point === channel.channel_point
);
return pubkeyMatches && !isClosing;
});
const filteredPendingChannels = pendingChannels.filter(channel => {
return !pubKey || channel.remote_node_pub === pubKey;
});
const filteredClosingChannels = pendingCloseChannels.filter(channel => {
return !pubKey || channel.remote_node_pub === pubKey;
});
const mappedPendingChannels = filteredPendingChannels.map(channel => {
return {
active: false,
closing: false,
opening: true,
remotePubkey: channel.remote_node_pub,
channelPoint: channel.channel_point,
capacity: channel.capacity,
localBalance: channel.local_balance,
remoteBalance: channel.remote_balance,
localChanReserveSat: channel.local_chan_reserve_sat,
remoteChanReserveSat: channel.remote_chan_reserve_sat
};
});
const mappedClosingChannels = filteredClosingChannels.map(channel => {
return {
active: false,
closing: true,
opening: false,
remotePubkey: channel.remote_node_pub,
channelPoint: channel.channel_point,
capacity: channel.capacity,
localBalance: channel.local_balance,
remoteBalance: channel.remote_balance,
localChanReserveSat: channel.local_chan_reserve_sat,
remoteChanReserveSat: channel.remote_chan_reserve_sat
};
});
const mappedActiveChannels = filteredChannels.map(channel => {
return {
active: channel.active,
closing: false,
opening: false,
remotePubkey: channel.remote_pubkey,
channelPoint: channel.channel_point,
chanId: channel.chan_id,
capacity: channel.capacity,
localBalance: channel.local_balance,
remoteBalance: channel.remote_balance,
commitFee: channel.commit_fee,
commitWeight: channel.commit_weight,
feePerKw: channel.fee_per_kw,
unsettledBalance: channel.unsettled_balance,
totalSatoshisSent: channel.total_satoshis_sent,
totalSatoshisReceived: channel.total_satoshis_received,
numUpdates: channel.num_updates,
pendingHtlcs: channel.pending_htlcs.map(htlc => {
return {
incoming: htlc.incoming,
amount: htlc.amount,
hashLock: htlc.hash_lock,
expirationHeight: htlc.expiration_height
};
}),
csvDelay: channel.csv_delay,
private: channel.private,
initiator: channel.initiator,
chanStatusFlags: channel.chan_status_flags,
localChanReserveSat: channel.local_chan_reserve_sat,
remoteChanReserveSat: channel.remote_chan_reserve_sat,
staticRemoteKey: channel.static_remote_key,
lifetime: channel.lifetime,
uptime: channel.uptime,
closeAddress: channel.close_address
};
});
return {
active: mappedActiveChannels,
pending: mappedPendingChannels,
closing: mappedClosingChannels
};
}
}
export default LndGrpcWrapper;
| 29.737828 | 120 | 0.646474 |
4686789b16e9898e9906dd600698c81df51dbe30 | 208 | js | JavaScript | backend/src/utils/generatePin.js | dominickbrasileiro/uniforme-bonja | 0849a405033251f6489753626193f1d499d405ba | [
"MIT"
] | 3 | 2020-05-10T02:39:46.000Z | 2020-07-21T00:28:10.000Z | backend/src/utils/generatePin.js | dominickbrasileiro/uniforme-bonja | 0849a405033251f6489753626193f1d499d405ba | [
"MIT"
] | 5 | 2020-11-27T16:29:20.000Z | 2022-02-27T04:27:46.000Z | backend/src/utils/generatePin.js | dominickbrasileiro/uniforme-bonja | 0849a405033251f6489753626193f1d499d405ba | [
"MIT"
] | null | null | null | module.exports = (length = 6) => {
const pin = [];
for (let i = 0; i < length; i += 1) {
const randomNumber = Math.floor(Math.random() * 10);
pin.push(randomNumber);
}
return pin.join('');
};
| 23.111111 | 56 | 0.552885 |
46879a23fd32cbef3be1260539ef4a17354d7eb1 | 1,322 | js | JavaScript | client/web/src/apidata/storySummaries.js | ajeGames/storytime | 4e38564e7b8183076221883ef8f6a379f25b8f60 | [
"Apache-2.0"
] | 1 | 2015-09-24T03:40:34.000Z | 2015-09-24T03:40:34.000Z | client/web/src/apidata/storySummaries.js | ajeGames/storytime | 4e38564e7b8183076221883ef8f6a379f25b8f60 | [
"Apache-2.0"
] | null | null | null | client/web/src/apidata/storySummaries.js | ajeGames/storytime | 4e38564e7b8183076221883ef8f6a379f25b8f60 | [
"Apache-2.0"
] | null | null | null | const storySummaries = [
{
storyKey: "o9s0toym",
title: "The Cave",
author: {
penName: "Bubba Gumpzzz"
},
tagLine: "You want to read this.",
about: "Sometimes life compels you great things. And sometimes you'd rather play this game.",
firstChapter: "fjjieo",
},
{
storyKey: "5qcao3fu",
title: "Where the Water Goes",
author: {
penName: "Mr. Bubbles"
},
tagLine: "Round and round and down and down",
about: "What happens when someone pulls the plug?",
firstChapter: "i2o3fojfj"
},
{
storyKey: "12345678",
title: "New Story A",
author: {
penName: "Bubba Gumpzzz"
},
tagLine: "You want to read this.",
about: "Sometimes life compels you great things. And sometimes you'd rather play this game.",
firstChapter: "fh938"
},
{
storyKey: "09876543",
title: "New Story B",
author: {
penName: "Mr. Bubbles"
},
tagLine: "Blargy blargy",
about: "Whaaaaaaaat happens...?",
firstChapter: "ihfoiie"
},
{
storyKey: "qwertyui",
title: "New Story C",
author: {
penName: "Mr. Bubbles"
},
tagLine: "Ooga booga, unga bunga.",
about: "When someone does something bad, who gets the blame?",
firstChapter: "kjoifjwe"
}
];
export default storySummaries;
| 24.036364 | 98 | 0.600605 |
4687a5d88134e9d5b4977ddf0969561b93f22d9e | 2,165 | js | JavaScript | node_modules/angular2-notifications/dist/src/simple-notifications.module.js | swutask/appoinmentapp | a4b3b72632ca2299a11a3bb9a5f05ec3f051b12d | [
"MIT"
] | null | null | null | node_modules/angular2-notifications/dist/src/simple-notifications.module.js | swutask/appoinmentapp | a4b3b72632ca2299a11a3bb9a5f05ec3f051b12d | [
"MIT"
] | null | null | null | node_modules/angular2-notifications/dist/src/simple-notifications.module.js | swutask/appoinmentapp | a4b3b72632ca2299a11a3bb9a5f05ec3f051b12d | [
"MIT"
] | null | null | null | "use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var common_1 = require("@angular/common");
var simple_notifications_component_1 = require("./simple-notifications/components/simple-notifications.component");
var notification_component_1 = require("./simple-notifications/components/notification.component");
var max_pipe_1 = require("./simple-notifications/pipes/max.pipe");
var notifications_service_1 = require("./simple-notifications/services/notifications.service");
__export(require("./simple-notifications/interfaces/icons"));
__export(require("./simple-notifications/components/simple-notifications.component"));
__export(require("./simple-notifications/components/notification.component"));
__export(require("./simple-notifications/pipes/max.pipe"));
__export(require("./simple-notifications/services/notifications.service"));
var SimpleNotificationsModule = (function () {
function SimpleNotificationsModule() {
}
SimpleNotificationsModule.forRoot = function () {
return {
ngModule: SimpleNotificationsModule,
};
};
return SimpleNotificationsModule;
}());
SimpleNotificationsModule.decorators = [
{ type: core_1.NgModule, args: [{
providers: [notifications_service_1.NotificationsService],
imports: [
common_1.CommonModule
],
declarations: [
simple_notifications_component_1.SimpleNotificationsComponent,
notification_component_1.NotificationComponent,
max_pipe_1.MaxPipe
],
exports: [simple_notifications_component_1.SimpleNotificationsComponent]
},] },
];
/** @nocollapse */
SimpleNotificationsModule.ctorParameters = function () { return []; };
exports.SimpleNotificationsModule = SimpleNotificationsModule;
//# sourceMappingURL=simple-notifications.module.js.map | 49.204545 | 117 | 0.676212 |
4687c675af53537378a7212ef6d5cceaea371846 | 214 | js | JavaScript | lib/private_props/index.js | optinull/eslint-config | f7919a83036a0a77905565a8c6f413e0f808006d | [
"MIT"
] | null | null | null | lib/private_props/index.js | optinull/eslint-config | f7919a83036a0a77905565a8c6f413e0f808006d | [
"MIT"
] | null | null | null | lib/private_props/index.js | optinull/eslint-config | f7919a83036a0a77905565a8c6f413e0f808006d | [
"MIT"
] | 3 | 2020-11-28T22:58:16.000Z | 2022-03-15T20:45:04.000Z | module.exports = {
plugins: ['private-props'],
rules: {
'private-props/no-unused-or-undeclared': [2, { privateMatchers: ['^_'] }],
'private-props/no-use-outside': [2, { privateMatchers: ['^_'] }]
}
}
| 26.75 | 78 | 0.593458 |
46884e8098b10b05fb27536cf868681046b97873 | 2,027 | js | JavaScript | examples/javascript/ImageClassification/ImageClassification_DoodleNet_Video/sketch.js | starakaj/ml5-library | f5bd687d3f474bf939ee98ef2a54e80cee40ff6b | [
"MIT"
] | 635 | 2018-03-06T03:25:54.000Z | 2022-03-19T05:17:34.000Z | examples/javascript/ImageClassification/ImageClassification_DoodleNet_Video/sketch.js | starakaj/ml5-library | f5bd687d3f474bf939ee98ef2a54e80cee40ff6b | [
"MIT"
] | 195 | 2018-03-06T14:29:01.000Z | 2020-04-05T15:34:45.000Z | examples/javascript/ImageClassification/ImageClassification_DoodleNet_Video/sketch.js | starakaj/ml5-library | f5bd687d3f474bf939ee98ef2a54e80cee40ff6b | [
"MIT"
] | 547 | 2018-03-07T19:34:37.000Z | 2021-11-01T21:53:57.000Z | // Copyright (c) 2019 ml5
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
/* ===
ml5 Example
Webcam Image Classification using DoodleNet
This example uses a callback pattern to create the classifier
=== */
// Initialize the Image Classifier method with DoodleNet.
let classifier;
// A variable to hold the Webcam video we want to classify
let video;
// Two variable to hold the label and confidence of the result
let label;
let confidence;
let canvas;
let ctx;
let width = 280;
let height = 280;
async function setup() {
// Create a 'label' and 'confidence' div to hold results
label = document.querySelector('#label');
confidence = document.querySelector('#confidence');
// Create a camera input
video = document.querySelector('#myCanvas');
video = await getVideo();
classifier = await ml5.imageClassifier('DoodleNet', video);
classifyVideo();
}
setup();
// Get a prediction for the current video frame
function classifyVideo() {
classifier.classify(gotResult);
}
// A function to run when we get any errors and the results
function gotResult(error, results) {
// Display error in the console
if (error) {
console.error(error);
}
// The results are in an array ordered by confidence.
console.log(results);
// Show the first label and confidence
label.innerHTML = results[0].label;
confidence.innerHTML = results[0].confidence.toFixed(4); // Round the confidence to 0.01
// Call classifyVideo again
classifyVideo();
}
// Helper Functions
async function getVideo(){
// Grab elements, create settings, etc.
const videoElement = document.createElement('video');
// videoElement.setAttribute("style", "display: none;");
videoElement.width = width;
videoElement.height = height;
document.body.appendChild(videoElement);
// Create a webcam capture
const capture = await navigator.mediaDevices.getUserMedia({ video: true })
videoElement.srcObject = capture;
videoElement.play();
return videoElement
} | 25.3375 | 91 | 0.724716 |
46887b855aa7a414c63c5b05bfc777fabfa2f917 | 487 | js | JavaScript | core/Engine.js | panarch/famous-mig | a241d9955d20ceb0fe3ce0a1fb13e9961e1c6878 | [
"MIT"
] | 6 | 2015-08-09T15:33:18.000Z | 2020-08-12T23:57:41.000Z | core/Engine.js | panarch/famous-mig | a241d9955d20ceb0fe3ce0a1fb13e9961e1c6878 | [
"MIT"
] | null | null | null | core/Engine.js | panarch/famous-mig | a241d9955d20ceb0fe3ce0a1fb13e9961e1c6878 | [
"MIT"
] | null | null | null | // @author Taehoon Moon 2015
'use strict';
var FamousEngine = require('famous/core/FamousEngine');
var View = require('./View');
var Timer = require('../utilities/Timer');
function Engine() {}
Engine.createContext = function createContext() {
FamousEngine.init();
var scene = FamousEngine.createScene();
Timer.setNode(scene.addChild());
var node = scene.addChild();
var view = new View();
view.setNode(node);
return view;
};
module.exports = Engine;
| 18.730769 | 55 | 0.667351 |
46888dbe5756baab7ae2b0b79a8b0aa3a2f61968 | 3,037 | js | JavaScript | build.js | panamadevhub/super-easy-forms | 1ad5d8d2b271232669211894dc9258419f33f928 | [
"MIT"
] | null | null | null | build.js | panamadevhub/super-easy-forms | 1ad5d8d2b271232669211894dc9258419f33f928 | [
"MIT"
] | null | null | null | build.js | panamadevhub/super-easy-forms | 1ad5d8d2b271232669211894dc9258419f33f928 | [
"MIT"
] | null | null | null | require('dotenv').config();
var fs = require("fs");
var {optionError} = require('./lib/InternalModules')
let regionSet = [
"us-east-2",
"us-east-1",
"us-west-1",
"us-west-2",
"af-south-1",
"ap-east-1",
"ap-south-1",
"ap-northeast-2",
"ap-southeast-1",
"ap-southeast-2",
"ap-northeast-1",
"ca-central-1",
"cn-north-1",
"cn-northwest-1",
"eu-central-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"eu-north-1",
"me-south-1",
"sa-east-1",
"us-gov-east-1",
"us-gov-west-1"
];
function createFile(file, contents, callback) {
if(fs.existsSync(file)){
let err = `file ${file} already exists`
if(callback && typeof callback === 'function') callback(null, err)
else return data;
}
else {
fs.writeFile(file, contents, (err) => {
if (err) {
if(callback && typeof callback === 'function') callback(new Error(err))
else throw new Error(err);
}
else {
let data = `Created the ${file} file`
if(callback && typeof callback === 'function') callback(null, data)
else return data;
}
})
}
}
function createDir(dir, callback){
if (fs.existsSync(dir)){
let err = (`directory ${dir} already exists`)
if(callback && typeof callback === 'function') callback(null, err)
else return err
}
else {
fs.mkdir(dir, (err) => {
if (err) {
if(callback && typeof callback === 'function') callback(new Error(err))
else throw new Error(err);
}
else {
let data = `Created the ${dir} directory`
if(callback && typeof callback === 'function') callback(null, data)
else return data;
}
});
}
}
function initBuild(region, profile, callback){
let env_file = "";
try {
/* createFile('./settings.json', '{}', function(err, data){
if(err) throw new Error(err)
else console.log(data)
}) */
createDir('./forms', function(err, data){
if(err) throw new Error(err)
else console.log(data)
})
if(profile){
if(/^[a-zA-Z0-9]*$/.test(profile)){
env_file += `\nAWS_PROFILE=${profile}`
}
else{
let err = "AWS Profile invalid. Only alphanumeric characters accepted. No spaces.";
throw new Error(err);
}
}
if(region){
if(regionSet.includes(region)){
env_file += `\nAWS_REGION=${region}`
}
else {
let err = "Invalid AWS region code";
throw new Error(err)
}
}
createFile('./.env', env_file, function(err, data){
if(err) throw new Error(err)
else {
//console.log(data)
createFile('./.gitignore', '.env', function(err, data){
if(err) throw new Error(err)
else {
//console.log(data)
if(callback && typeof callback === 'function'){
callback(null, 'Success');
}
}
})
}
});
}
catch(err){
optionError(err, callback)
}
}
module.exports = {
initBuild,
createDir,
createFile
} | 23.913386 | 91 | 0.548238 |
468894edf02b4bf5bf6d3efcbea0b66c727a9d50 | 600 | js | JavaScript | bower_components/queue-async/src/package.js | lmullen/paulist-missions | ae10606e7f779af3aeaf2d786984bae45f6d400a | [
"MIT"
] | 1 | 2017-01-01T23:41:19.000Z | 2017-01-01T23:41:19.000Z | bower_components/queue-async/src/package.js | lmullen/paulist-missions | ae10606e7f779af3aeaf2d786984bae45f6d400a | [
"MIT"
] | null | null | null | bower_components/queue-async/src/package.js | lmullen/paulist-missions | ae10606e7f779af3aeaf2d786984bae45f6d400a | [
"MIT"
] | null | null | null | var queue = require("../queue");
console.log(JSON.stringify({
"name": "queue-async",
"version": queue.version,
"description": "A little helper for asynchronous JavaScript.",
"keywords": [
"asynchronous",
"async",
"queue"
],
"author": {
"name": "Mike Bostock",
"url": "http://bost.ocks.org/mike"
},
"repository": {
"type": "git",
"url": "https://github.com/mbostock/queue.git"
},
"main": "queue.js",
"devDependencies": {
"uglify-js": "~2.2.5",
"vows": "~0.7.0"
},
"scripts": {
"test": "node_modules/.bin/vows; echo"
}
}, null, 2));
| 20.689655 | 64 | 0.551667 |
4689e592154335153fb8b2015af83949f5a031d2 | 157 | js | JavaScript | app/javascript/packs/application.js | johnnini/sample_app | 2d9246a706973d7414678260052b983ef7aa1d75 | [
"RSA-MD"
] | null | null | null | app/javascript/packs/application.js | johnnini/sample_app | 2d9246a706973d7414678260052b983ef7aa1d75 | [
"RSA-MD"
] | 21 | 2019-09-26T03:07:51.000Z | 2022-02-26T18:17:20.000Z | app/javascript/packs/application.js | johnnini/sample_app | 2d9246a706973d7414678260052b983ef7aa1d75 | [
"RSA-MD"
] | null | null | null | require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require("jquery")
import "bootstrap"
| 22.428571 | 39 | 0.732484 |
468b158860f07b2f6d2fe341dfbae2bf284c01d0 | 21,528 | js | JavaScript | venv/lib/python3.8/site-packages/hass_frontend/frontend_latest/74cf8fa5.js | vsevolodpohvalenko/home-assistant | 4ae19b7d5d843c65ba700922c1814755257eb4e0 | [
"Apache-2.0"
] | null | null | null | venv/lib/python3.8/site-packages/hass_frontend/frontend_latest/74cf8fa5.js | vsevolodpohvalenko/home-assistant | 4ae19b7d5d843c65ba700922c1814755257eb4e0 | [
"Apache-2.0"
] | null | null | null | venv/lib/python3.8/site-packages/hass_frontend/frontend_latest/74cf8fa5.js | vsevolodpohvalenko/home-assistant | 4ae19b7d5d843c65ba700922c1814755257eb4e0 | [
"Apache-2.0"
] | null | null | null | /*! For license information please see 74cf8fa5.js.LICENSE.txt */
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[6561],{26561:(c,e,o)=>{"use strict";o.d(e,{X:()=>b});var r=o(87480),d=o(55704),a=(o(66702),o(38103)),t=o(18601),i=o(98734),n=o(81471),m=o(49629);class h extends t.Wg{constructor(){super(...arguments),this.checked=!1,this.indeterminate=!1,this.disabled=!1,this.value="",this.reducedTouchTarget=!1,this.animationClass="",this.shouldRenderRipple=!1,this.focused=!1,this.useStateLayerCustomProperties=!1,this.mdcFoundationClass=void 0,this.mdcFoundation=void 0,this.rippleElement=null,this.rippleHandlers=new i.A((()=>(this.shouldRenderRipple=!0,this.ripple.then((c=>this.rippleElement=c)),this.ripple)))}createAdapter(){return{}}update(c){const e=c.get("indeterminate"),o=c.get("checked"),r=c.get("disabled");if(void 0!==e||void 0!==o||void 0!==r){const c=this.calculateAnimationStateName(!!o,!!e,!!r),d=this.calculateAnimationStateName(this.checked,this.indeterminate,this.disabled);this.animationClass=`${c}-${d}`}super.update(c)}calculateAnimationStateName(c,e,o){return o?"disabled":e?"indeterminate":c?"checked":"unchecked"}renderRipple(){return this.shouldRenderRipple?d.dy`<mwc-ripple
.disabled="${this.disabled}"
.internalUseStateLayerCustomProperties="${this.useStateLayerCustomProperties}"
unbounded></mwc-ripple>`:""}render(){const c=this.indeterminate||this.checked,e={"mdc-checkbox--disabled":this.disabled,"mdc-checkbox--selected":c,"mdc-checkbox--touch":!this.reducedTouchTarget,"mdc-ripple-upgraded--background-focused":this.focused,"mdc-checkbox--anim-checked-indeterminate":"checked-indeterminate"==this.animationClass,"mdc-checkbox--anim-checked-unchecked":"checked-unchecked"==this.animationClass,"mdc-checkbox--anim-indeterminate-checked":"indeterminate-checked"==this.animationClass,"mdc-checkbox--anim-indeterminate-unchecked":"indeterminate-unchecked"==this.animationClass,"mdc-checkbox--anim-unchecked-checked":"unchecked-checked"==this.animationClass,"mdc-checkbox--anim-unchecked-indeterminate":"unchecked-indeterminate"==this.animationClass},o=this.indeterminate?"mixed":void 0;return d.dy`
<div class="mdc-checkbox mdc-checkbox--upgraded ${(0,n.$)(e)}">
<input type="checkbox"
class="mdc-checkbox__native-control"
name="${(0,m.o)(this.name)}"
aria-checked="${(0,m.o)(o)}"
aria-label="${(0,m.o)(this.ariaLabel)}"
aria-labelledby="${(0,m.o)(this.ariaLabelledBy)}"
aria-describedby="${(0,m.o)(this.ariaDescribedBy)}"
data-indeterminate="${this.indeterminate?"true":"false"}"
?disabled="${this.disabled}"
.indeterminate="${this.indeterminate}"
.checked="${this.checked}"
.value="${this.value}"
@change="${this.handleChange}"
@focus="${this.handleFocus}"
@blur="${this.handleBlur}"
@mousedown="${this.handleRippleMouseDown}"
@mouseenter="${this.handleRippleMouseEnter}"
@mouseleave="${this.handleRippleMouseLeave}"
@touchstart="${this.handleRippleTouchStart}"
@touchend="${this.handleRippleDeactivate}"
@touchcancel="${this.handleRippleDeactivate}">
<div class="mdc-checkbox__background"
@animationend="${this.resetAnimationClass}">
<svg class="mdc-checkbox__checkmark"
viewBox="0 0 24 24">
<path class="mdc-checkbox__checkmark-path"
fill="none"
d="M1.73,12.91 8.1,19.28 22.79,4.59"></path>
</svg>
<div class="mdc-checkbox__mixedmark"></div>
</div>
${this.renderRipple()}
</div>`}handleFocus(){this.focused=!0,this.handleRippleFocus()}handleBlur(){this.focused=!1,this.handleRippleBlur()}handleRippleMouseDown(c){const e=()=>{window.removeEventListener("mouseup",e),this.handleRippleDeactivate()};window.addEventListener("mouseup",e),this.rippleHandlers.startPress(c)}handleRippleTouchStart(c){this.rippleHandlers.startPress(c)}handleRippleDeactivate(){this.rippleHandlers.endPress()}handleRippleMouseEnter(){this.rippleHandlers.startHover()}handleRippleMouseLeave(){this.rippleHandlers.endHover()}handleRippleFocus(){this.rippleHandlers.startFocus()}handleRippleBlur(){this.rippleHandlers.endFocus()}handleChange(){this.checked=this.formElement.checked,this.indeterminate=this.formElement.indeterminate}resetAnimationClass(){this.animationClass=""}get isRippleActive(){var c;return(null===(c=this.rippleElement)||void 0===c?void 0:c.isActive)||!1}}(0,r.__decorate)([(0,d.IO)(".mdc-checkbox")],h.prototype,"mdcRoot",void 0),(0,r.__decorate)([(0,d.IO)("input")],h.prototype,"formElement",void 0),(0,r.__decorate)([(0,d.Cb)({type:Boolean,reflect:!0})],h.prototype,"checked",void 0),(0,r.__decorate)([(0,d.Cb)({type:Boolean})],h.prototype,"indeterminate",void 0),(0,r.__decorate)([(0,d.Cb)({type:Boolean,reflect:!0})],h.prototype,"disabled",void 0),(0,r.__decorate)([(0,d.Cb)({type:String,reflect:!0})],h.prototype,"name",void 0),(0,r.__decorate)([(0,d.Cb)({type:String})],h.prototype,"value",void 0),(0,r.__decorate)([a.L,(0,d.Cb)({type:String,attribute:"aria-label"})],h.prototype,"ariaLabel",void 0),(0,r.__decorate)([a.L,(0,d.Cb)({type:String,attribute:"aria-labelledby"})],h.prototype,"ariaLabelledBy",void 0),(0,r.__decorate)([a.L,(0,d.Cb)({type:String,attribute:"aria-describedby"})],h.prototype,"ariaDescribedBy",void 0),(0,r.__decorate)([(0,d.Cb)({type:Boolean})],h.prototype,"reducedTouchTarget",void 0),(0,r.__decorate)([(0,d.SB)()],h.prototype,"animationClass",void 0),(0,r.__decorate)([(0,d.SB)()],h.prototype,"shouldRenderRipple",void 0),(0,r.__decorate)([(0,d.SB)()],h.prototype,"focused",void 0),(0,r.__decorate)([(0,d.SB)()],h.prototype,"useStateLayerCustomProperties",void 0),(0,r.__decorate)([(0,d.GC)("mwc-ripple")],h.prototype,"ripple",void 0),(0,r.__decorate)([(0,d.hO)({passive:!0})],h.prototype,"handleRippleTouchStart",null);const k=d.iv`.mdc-checkbox{padding:calc((40px - 18px) / 2);padding:calc((var(--mdc-checkbox-ripple-size, 40px) - 18px) / 2);margin:calc((40px - 40px) / 2);margin:calc((var(--mdc-checkbox-touch-target-size, 40px) - 40px) / 2)}.mdc-checkbox .mdc-checkbox__ripple::before,.mdc-checkbox .mdc-checkbox__ripple::after{background-color:#000;background-color:var(--mdc-ripple-color, #000)}.mdc-checkbox:hover .mdc-checkbox__ripple::before,.mdc-checkbox.mdc-ripple-surface--hover .mdc-checkbox__ripple::before{opacity:0.04;opacity:var(--mdc-ripple-hover-opacity, 0.04)}.mdc-checkbox.mdc-ripple-upgraded--background-focused .mdc-checkbox__ripple::before,.mdc-checkbox:not(.mdc-ripple-upgraded):focus .mdc-checkbox__ripple::before{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-focus-opacity, 0.12)}.mdc-checkbox:not(.mdc-ripple-upgraded) .mdc-checkbox__ripple::after{transition:opacity 150ms linear}.mdc-checkbox:not(.mdc-ripple-upgraded):active .mdc-checkbox__ripple::after{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-checkbox.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-checkbox.mdc-checkbox--selected .mdc-checkbox__ripple::before,.mdc-checkbox.mdc-checkbox--selected .mdc-checkbox__ripple::after{background-color:#018786;background-color:var(--mdc-ripple-color, var(--mdc-theme-secondary, #018786))}.mdc-checkbox.mdc-checkbox--selected:hover .mdc-checkbox__ripple::before,.mdc-checkbox.mdc-checkbox--selected.mdc-ripple-surface--hover .mdc-checkbox__ripple::before{opacity:0.04;opacity:var(--mdc-ripple-hover-opacity, 0.04)}.mdc-checkbox.mdc-checkbox--selected.mdc-ripple-upgraded--background-focused .mdc-checkbox__ripple::before,.mdc-checkbox.mdc-checkbox--selected:not(.mdc-ripple-upgraded):focus .mdc-checkbox__ripple::before{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-focus-opacity, 0.12)}.mdc-checkbox.mdc-checkbox--selected:not(.mdc-ripple-upgraded) .mdc-checkbox__ripple::after{transition:opacity 150ms linear}.mdc-checkbox.mdc-checkbox--selected:not(.mdc-ripple-upgraded):active .mdc-checkbox__ripple::after{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-checkbox.mdc-checkbox--selected.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-checkbox.mdc-ripple-upgraded--background-focused.mdc-checkbox--selected .mdc-checkbox__ripple::before,.mdc-checkbox.mdc-ripple-upgraded--background-focused.mdc-checkbox--selected .mdc-checkbox__ripple::after{background-color:#018786;background-color:var(--mdc-ripple-color, var(--mdc-theme-secondary, #018786))}.mdc-checkbox .mdc-checkbox__background{top:calc((40px - 18px) / 2);top:calc((var(--mdc-checkbox-ripple-size, 40px) - 18px) / 2);left:calc((40px - 18px) / 2);left:calc((var(--mdc-checkbox-ripple-size, 40px) - 18px) / 2)}.mdc-checkbox .mdc-checkbox__native-control{top:calc((40px - 40px) / 2);top:calc((40px - var(--mdc-checkbox-touch-target-size, 40px)) / 2);right:calc((40px - 40px) / 2);right:calc((40px - var(--mdc-checkbox-touch-target-size, 40px)) / 2);left:calc((40px - 40px) / 2);left:calc((40px - var(--mdc-checkbox-touch-target-size, 40px)) / 2);width:40px;width:var(--mdc-checkbox-touch-target-size, 40px);height:40px;height:var(--mdc-checkbox-touch-target-size, 40px)}.mdc-checkbox .mdc-checkbox__native-control:enabled:not(:checked):not(:indeterminate):not([data-indeterminate=true])~.mdc-checkbox__background{border-color:rgba(0, 0, 0, 0.54);border-color:var(--mdc-checkbox-unchecked-color, rgba(0, 0, 0, 0.54));background-color:transparent}.mdc-checkbox .mdc-checkbox__native-control:enabled:checked~.mdc-checkbox__background,.mdc-checkbox .mdc-checkbox__native-control:enabled:indeterminate~.mdc-checkbox__background,.mdc-checkbox .mdc-checkbox__native-control[data-indeterminate=true]:enabled~.mdc-checkbox__background{border-color:#018786;border-color:var(--mdc-checkbox-checked-color, var(--mdc-theme-secondary, #018786));background-color:#018786;background-color:var(--mdc-checkbox-checked-color, var(--mdc-theme-secondary, #018786))}@keyframes mdc-checkbox-fade-in-background-8A000000FF01878600000000FF018786{0%{border-color:rgba(0, 0, 0, 0.54);border-color:var(--mdc-checkbox-unchecked-color, rgba(0, 0, 0, 0.54));background-color:transparent}50%{border-color:#018786;border-color:var(--mdc-checkbox-checked-color, var(--mdc-theme-secondary, #018786));background-color:#018786;background-color:var(--mdc-checkbox-checked-color, var(--mdc-theme-secondary, #018786))}}@keyframes mdc-checkbox-fade-out-background-8A000000FF01878600000000FF018786{0%,80%{border-color:#018786;border-color:var(--mdc-checkbox-checked-color, var(--mdc-theme-secondary, #018786));background-color:#018786;background-color:var(--mdc-checkbox-checked-color, var(--mdc-theme-secondary, #018786))}100%{border-color:rgba(0, 0, 0, 0.54);border-color:var(--mdc-checkbox-unchecked-color, rgba(0, 0, 0, 0.54));background-color:transparent}}.mdc-checkbox.mdc-checkbox--anim-unchecked-checked .mdc-checkbox__native-control:enabled~.mdc-checkbox__background,.mdc-checkbox.mdc-checkbox--anim-unchecked-indeterminate .mdc-checkbox__native-control:enabled~.mdc-checkbox__background{animation-name:mdc-checkbox-fade-in-background-8A000000FF01878600000000FF018786}.mdc-checkbox.mdc-checkbox--anim-checked-unchecked .mdc-checkbox__native-control:enabled~.mdc-checkbox__background,.mdc-checkbox.mdc-checkbox--anim-indeterminate-unchecked .mdc-checkbox__native-control:enabled~.mdc-checkbox__background{animation-name:mdc-checkbox-fade-out-background-8A000000FF01878600000000FF018786}.mdc-checkbox .mdc-checkbox__native-control[disabled]:not(:checked):not(:indeterminate):not([data-indeterminate=true])~.mdc-checkbox__background{border-color:rgba(0, 0, 0, 0.38);border-color:var(--mdc-checkbox-disabled-color, rgba(0, 0, 0, 0.38));background-color:transparent}.mdc-checkbox .mdc-checkbox__native-control[disabled]:checked~.mdc-checkbox__background,.mdc-checkbox .mdc-checkbox__native-control[disabled]:indeterminate~.mdc-checkbox__background,.mdc-checkbox .mdc-checkbox__native-control[data-indeterminate=true][disabled]~.mdc-checkbox__background{border-color:transparent;background-color:rgba(0, 0, 0, 0.38);background-color:var(--mdc-checkbox-disabled-color, rgba(0, 0, 0, 0.38))}.mdc-checkbox .mdc-checkbox__native-control:enabled~.mdc-checkbox__background .mdc-checkbox__checkmark{color:#fff;color:var(--mdc-checkbox-ink-color, #fff)}.mdc-checkbox .mdc-checkbox__native-control:enabled~.mdc-checkbox__background .mdc-checkbox__mixedmark{border-color:#fff;border-color:var(--mdc-checkbox-ink-color, #fff)}.mdc-checkbox .mdc-checkbox__native-control:disabled~.mdc-checkbox__background .mdc-checkbox__checkmark{color:#fff;color:var(--mdc-checkbox-ink-color, #fff)}.mdc-checkbox .mdc-checkbox__native-control:disabled~.mdc-checkbox__background .mdc-checkbox__mixedmark{border-color:#fff;border-color:var(--mdc-checkbox-ink-color, #fff)}.mdc-touch-target-wrapper{display:inline}@keyframes mdc-checkbox-unchecked-checked-checkmark-path{0%,50%{stroke-dashoffset:29.7833385}50%{animation-timing-function:cubic-bezier(0, 0, 0.2, 1)}100%{stroke-dashoffset:0}}@keyframes mdc-checkbox-unchecked-indeterminate-mixedmark{0%,68.2%{transform:scaleX(0)}68.2%{animation-timing-function:cubic-bezier(0, 0, 0, 1)}100%{transform:scaleX(1)}}@keyframes mdc-checkbox-checked-unchecked-checkmark-path{from{animation-timing-function:cubic-bezier(0.4, 0, 1, 1);opacity:1;stroke-dashoffset:0}to{opacity:0;stroke-dashoffset:-29.7833385}}@keyframes mdc-checkbox-checked-indeterminate-checkmark{from{animation-timing-function:cubic-bezier(0, 0, 0.2, 1);transform:rotate(0deg);opacity:1}to{transform:rotate(45deg);opacity:0}}@keyframes mdc-checkbox-indeterminate-checked-checkmark{from{animation-timing-function:cubic-bezier(0.14, 0, 0, 1);transform:rotate(45deg);opacity:0}to{transform:rotate(360deg);opacity:1}}@keyframes mdc-checkbox-checked-indeterminate-mixedmark{from{animation-timing-function:mdc-animation-deceleration-curve-timing-function;transform:rotate(-45deg);opacity:0}to{transform:rotate(0deg);opacity:1}}@keyframes mdc-checkbox-indeterminate-checked-mixedmark{from{animation-timing-function:cubic-bezier(0.14, 0, 0, 1);transform:rotate(0deg);opacity:1}to{transform:rotate(315deg);opacity:0}}@keyframes mdc-checkbox-indeterminate-unchecked-mixedmark{0%{animation-timing-function:linear;transform:scaleX(1);opacity:1}32.8%,100%{transform:scaleX(0);opacity:0}}.mdc-checkbox{display:inline-block;position:relative;flex:0 0 18px;box-sizing:content-box;width:18px;height:18px;line-height:0;white-space:nowrap;cursor:pointer;vertical-align:bottom}@media screen and (forced-colors: active),(-ms-high-contrast: active){.mdc-checkbox__native-control[disabled]:not(:checked):not(:indeterminate):not([data-indeterminate=true])~.mdc-checkbox__background{border-color:GrayText;border-color:var(--mdc-checkbox-disabled-color, GrayText);background-color:transparent}.mdc-checkbox__native-control[disabled]:checked~.mdc-checkbox__background,.mdc-checkbox__native-control[disabled]:indeterminate~.mdc-checkbox__background,.mdc-checkbox__native-control[data-indeterminate=true][disabled]~.mdc-checkbox__background{border-color:GrayText;background-color:transparent;background-color:var(--mdc-checkbox-disabled-color, transparent)}.mdc-checkbox__native-control:disabled~.mdc-checkbox__background .mdc-checkbox__checkmark{color:GrayText;color:var(--mdc-checkbox-ink-color, GrayText)}.mdc-checkbox__native-control:disabled~.mdc-checkbox__background .mdc-checkbox__mixedmark{border-color:GrayText;border-color:var(--mdc-checkbox-ink-color, GrayText)}.mdc-checkbox__mixedmark{margin:0 1px}}.mdc-checkbox--disabled{cursor:default;pointer-events:none}.mdc-checkbox__background{display:inline-flex;position:absolute;align-items:center;justify-content:center;box-sizing:border-box;width:18px;height:18px;border:2px solid currentColor;border-radius:2px;background-color:transparent;pointer-events:none;will-change:background-color,border-color;transition:background-color 90ms 0ms cubic-bezier(0.4, 0, 0.6, 1),border-color 90ms 0ms cubic-bezier(0.4, 0, 0.6, 1)}.mdc-checkbox__checkmark{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;opacity:0;transition:opacity 180ms 0ms cubic-bezier(0.4, 0, 0.6, 1)}.mdc-checkbox--upgraded .mdc-checkbox__checkmark{opacity:1}.mdc-checkbox__checkmark-path{transition:stroke-dashoffset 180ms 0ms cubic-bezier(0.4, 0, 0.6, 1);stroke:currentColor;stroke-width:3.12px;stroke-dashoffset:29.7833385;stroke-dasharray:29.7833385}.mdc-checkbox__mixedmark{width:100%;height:0;transform:scaleX(0) rotate(0deg);border-width:1px;border-style:solid;opacity:0;transition:opacity 90ms 0ms cubic-bezier(0.4, 0, 0.6, 1),transform 90ms 0ms cubic-bezier(0.4, 0, 0.6, 1)}.mdc-checkbox--anim-unchecked-checked .mdc-checkbox__background,.mdc-checkbox--anim-unchecked-indeterminate .mdc-checkbox__background,.mdc-checkbox--anim-checked-unchecked .mdc-checkbox__background,.mdc-checkbox--anim-indeterminate-unchecked .mdc-checkbox__background{animation-duration:180ms;animation-timing-function:linear}.mdc-checkbox--anim-unchecked-checked .mdc-checkbox__checkmark-path{animation:mdc-checkbox-unchecked-checked-checkmark-path 180ms linear 0s;transition:none}.mdc-checkbox--anim-unchecked-indeterminate .mdc-checkbox__mixedmark{animation:mdc-checkbox-unchecked-indeterminate-mixedmark 90ms linear 0s;transition:none}.mdc-checkbox--anim-checked-unchecked .mdc-checkbox__checkmark-path{animation:mdc-checkbox-checked-unchecked-checkmark-path 90ms linear 0s;transition:none}.mdc-checkbox--anim-checked-indeterminate .mdc-checkbox__checkmark{animation:mdc-checkbox-checked-indeterminate-checkmark 90ms linear 0s;transition:none}.mdc-checkbox--anim-checked-indeterminate .mdc-checkbox__mixedmark{animation:mdc-checkbox-checked-indeterminate-mixedmark 90ms linear 0s;transition:none}.mdc-checkbox--anim-indeterminate-checked .mdc-checkbox__checkmark{animation:mdc-checkbox-indeterminate-checked-checkmark 500ms linear 0s;transition:none}.mdc-checkbox--anim-indeterminate-checked .mdc-checkbox__mixedmark{animation:mdc-checkbox-indeterminate-checked-mixedmark 500ms linear 0s;transition:none}.mdc-checkbox--anim-indeterminate-unchecked .mdc-checkbox__mixedmark{animation:mdc-checkbox-indeterminate-unchecked-mixedmark 300ms linear 0s;transition:none}.mdc-checkbox__native-control:checked~.mdc-checkbox__background,.mdc-checkbox__native-control:indeterminate~.mdc-checkbox__background,.mdc-checkbox__native-control[data-indeterminate=true]~.mdc-checkbox__background{transition:border-color 90ms 0ms cubic-bezier(0, 0, 0.2, 1),background-color 90ms 0ms cubic-bezier(0, 0, 0.2, 1)}.mdc-checkbox__native-control:checked~.mdc-checkbox__background .mdc-checkbox__checkmark-path,.mdc-checkbox__native-control:indeterminate~.mdc-checkbox__background .mdc-checkbox__checkmark-path,.mdc-checkbox__native-control[data-indeterminate=true]~.mdc-checkbox__background .mdc-checkbox__checkmark-path{stroke-dashoffset:0}.mdc-checkbox__native-control{position:absolute;margin:0;padding:0;opacity:0;cursor:inherit}.mdc-checkbox__native-control:disabled{cursor:default;pointer-events:none}.mdc-checkbox--touch{margin:calc((48px - 40px) / 2);margin:calc((var(--mdc-checkbox-state-layer-size, 48px) - var(--mdc-checkbox-state-layer-size, 40px)) / 2)}.mdc-checkbox--touch .mdc-checkbox__native-control{top:calc((40px - 48px) / 2);top:calc((var(--mdc-checkbox-state-layer-size, 40px) - var(--mdc-checkbox-state-layer-size, 48px)) / 2);right:calc((40px - 48px) / 2);right:calc((var(--mdc-checkbox-state-layer-size, 40px) - var(--mdc-checkbox-state-layer-size, 48px)) / 2);left:calc((40px - 48px) / 2);left:calc((var(--mdc-checkbox-state-layer-size, 40px) - var(--mdc-checkbox-state-layer-size, 48px)) / 2);width:48px;width:var(--mdc-checkbox-state-layer-size, 48px);height:48px;height:var(--mdc-checkbox-state-layer-size, 48px)}.mdc-checkbox__native-control:checked~.mdc-checkbox__background .mdc-checkbox__checkmark{transition:opacity 180ms 0ms cubic-bezier(0, 0, 0.2, 1),transform 180ms 0ms cubic-bezier(0, 0, 0.2, 1);opacity:1}.mdc-checkbox__native-control:checked~.mdc-checkbox__background .mdc-checkbox__mixedmark{transform:scaleX(1) rotate(-45deg)}.mdc-checkbox__native-control:indeterminate~.mdc-checkbox__background .mdc-checkbox__checkmark,.mdc-checkbox__native-control[data-indeterminate=true]~.mdc-checkbox__background .mdc-checkbox__checkmark{transform:rotate(45deg);opacity:0;transition:opacity 90ms 0ms cubic-bezier(0.4, 0, 0.6, 1),transform 90ms 0ms cubic-bezier(0.4, 0, 0.6, 1)}.mdc-checkbox__native-control:indeterminate~.mdc-checkbox__background .mdc-checkbox__mixedmark,.mdc-checkbox__native-control[data-indeterminate=true]~.mdc-checkbox__background .mdc-checkbox__mixedmark{transform:scaleX(1) rotate(0deg);opacity:1}.mdc-checkbox.mdc-checkbox--upgraded .mdc-checkbox__background,.mdc-checkbox.mdc-checkbox--upgraded .mdc-checkbox__checkmark,.mdc-checkbox.mdc-checkbox--upgraded .mdc-checkbox__checkmark-path,.mdc-checkbox.mdc-checkbox--upgraded .mdc-checkbox__mixedmark{transition:none}:host{outline:none;display:inline-flex;-webkit-tap-highlight-color:transparent}:host([checked]),:host([indeterminate]){--mdc-ripple-color:var(--mdc-theme-secondary, #018786)}.mdc-checkbox .mdc-checkbox__background::before{content:none}`;let b=class extends h{};b.styles=[k],b=(0,r.__decorate)([(0,d.Mo)("mwc-checkbox")],b)}}]);
//# sourceMappingURL=74cf8fa5.js.map | 538.2 | 17,693 | 0.772668 |
468b22c429a652a87a4019e01967d7c010f6f1f6 | 120 | js | JavaScript | src/index.js | antixrist/node-starter | e07f453bc05f26b8bc1e07031481024925da6792 | [
"MIT"
] | 1 | 2018-08-23T12:15:08.000Z | 2018-08-23T12:15:08.000Z | src/index.js | antixrist/node-starter | e07f453bc05f26b8bc1e07031481024925da6792 | [
"MIT"
] | 1 | 2021-05-07T21:01:39.000Z | 2021-05-07T21:01:39.000Z | src/index.js | antixrist/node-starter | e07f453bc05f26b8bc1e07031481024925da6792 | [
"MIT"
] | 2 | 2018-12-12T22:20:31.000Z | 2020-11-04T04:53:09.000Z | // eslint-disable-next-line no-console
process.on('shutdown', ({ code, signal }) => console.log('Bye!', code, signal));
| 40 | 80 | 0.666667 |
468ccde46c065ba4cf909a273811ddb0462dc5eb | 170 | js | JavaScript | app/js/display/radius/radius-age.js | ToxicJojo/github-issue-visualizer | 63c10b75551af57e557f52d9a9ccebbe05e3d12d | [
"MIT"
] | 5 | 2020-05-03T22:49:28.000Z | 2021-11-22T11:08:09.000Z | app/js/display/radius/radius-age.js | ToxicJojo/github-issue-visualizer | 63c10b75551af57e557f52d9a9ccebbe05e3d12d | [
"MIT"
] | 3 | 2018-06-12T13:49:52.000Z | 2018-06-23T16:21:51.000Z | app/js/display/radius/radius-age.js | ToxicJojo/github-issue-visualizer | 63c10b75551af57e557f52d9a9ccebbe05e3d12d | [
"MIT"
] | null | null | null | const radiusAge = (issue) => {
return Math.floor((new Date().getTime() - new Date(issue.created_at).getTime()) / (1000 * 60 * 60 * 24));
}
export default radiusAge | 34 | 108 | 0.641176 |
468ccfea4063c85ce9d4f3ff826aaf923f5a758a | 1,395 | js | JavaScript | 04-instrumented-server.js | mmarchini/nodejs-production-diagnostic-tools | ebbc572717c7eac7b07a58c5019301ae6a729ca7 | [
"MIT"
] | 11 | 2018-07-16T21:12:40.000Z | 2022-03-21T15:08:29.000Z | 04-instrumented-server.js | mmarchini/nodejs-production-diagnostic-tools | ebbc572717c7eac7b07a58c5019301ae6a729ca7 | [
"MIT"
] | null | null | null | 04-instrumented-server.js | mmarchini/nodejs-production-diagnostic-tools | ebbc572717c7eac7b07a58c5019301ae6a729ca7 | [
"MIT"
] | null | null | null | 'use strict';
const app = require('fastify')();
const pino = require('pino')();
const cpuProfiler = require('./utils/v8-cpu-profiler');
const heapProfiler = require('heap-profile');
heapProfiler.start();
const heavyComputation = require('./utils/heavy-computation');
app.get('/slow/', function slowHandler(req, res) {
heavyComputation.run();
res.send({});
});
const memoryLeaker = require('./utils/memory-leaker');
app.get('/leaker/', function leakerHandler(req, res) {
memoryLeaker.run();
res.send({});
});
const crasher = require('./utils/crasher');
app.get('/crash/', function crashHandler(req, res) {
crasher.run();
res.json({});
});
app.get('/healthy/', function (req, res) {
res.send({});
});
app.addHook('preHandler', async function preHandler(request, reply) {
const route = request.req.url.replace(new RegExp(/\//, 'g'), "");
cpuProfiler.startProfiling();
heapProfiler.write(`./out/${route}-${request.id}-before.heapprofile`);
pino.info(request.req);
});
app.addHook('onSend', async function onSend(request, reply, payload) {
const route = request.req.url.replace(new RegExp(/\//, 'g'), "");
pino.info(reply.res);
heapProfiler.write(`./out/${route}-${request.id}-after.heapprofile`);
cpuProfiler.stopProfiling(`./out/${route}-${request.id}.cpuprofile`);
});
app.listen(3000, (err, address) => { pino.info({address: address, status: 'running'}); });
| 31 | 90 | 0.668817 |
468d567a27934631a6baf62dd9bff3d7e00d62fb | 969 | js | JavaScript | mail/static/mail/compose.js | Przemo-git/mail_app | d274b681c982b5ddc9376174651e41227e002edb | [
"MIT"
] | null | null | null | mail/static/mail/compose.js | Przemo-git/mail_app | d274b681c982b5ddc9376174651e41227e002edb | [
"MIT"
] | null | null | null | mail/static/mail/compose.js | Przemo-git/mail_app | d274b681c982b5ddc9376174651e41227e002edb | [
"MIT"
] | null | null | null | document.addEventListener('DOMContentLoaded',function () {
const form = document.querySelector('#compose-form')
form.onsubmit = () => {
const to = document.querySelector('#compose-recipients');
const subject = document.querySelector('#compose-subject');
const body = document.querySelector('#compose-body');
if (to.length === 0 || to.body === 0) {
return;
}
fetch(`/emails`, {
method: 'POST',
body: JSON.stringify({
recipients: to.value,
subject: subject.value,
body: body.value
})
}).then(response => response.json()).then(result => {
console.log(result);
console.log(result.status);
if (result.status === 201) {
load_mailbox('sent');
} else {
alert(`${result.error}`)
}
});
return false;
}
});
| 32.3 | 67 | 0.496388 |
468de76c4ec24ccf463451ff66dba954ae811335 | 5,755 | js | JavaScript | libraries/mathjax/localization/es/TeX.js | Locercus/calc | 0a47e579d91aff1ccf0e51547b04ed5b0a3fb9c7 | [
"Apache-2.0"
] | 984 | 2015-01-02T08:10:55.000Z | 2022-03-31T05:07:02.000Z | libraries/mathjax/localization/es/TeX.js | Locercus/calc | 0a47e579d91aff1ccf0e51547b04ed5b0a3fb9c7 | [
"Apache-2.0"
] | 315 | 2015-01-05T07:56:51.000Z | 2022-03-25T07:57:21.000Z | libraries/mathjax/localization/es/TeX.js | Locercus/calc | 0a47e579d91aff1ccf0e51547b04ed5b0a3fb9c7 | [
"Apache-2.0"
] | 525 | 2015-01-02T08:11:15.000Z | 2022-03-31T05:07:27.000Z | /*
* /MathJax/localization/es/TeX.js
*
* Copyright (c) 2009-2015 The MathJax Consortium
*
* 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.
*/
MathJax.Localization.addTranslation("es","TeX",{version:"2.5.0",isLoaded:true,strings:{ExtraOpenMissingClose:"Llave de apertura adicional o falta la llave de cierre",ExtraCloseMissingOpen:"Llave de cierre adicional o falta la llave de apertura",MissingLeftExtraRight:"Falta \\left o \\right adicional",MissingScript:"Falta argumento super\u00EDndice o sub\u00EDndice",ExtraLeftMissingRight:"\\left adicional o falta \\right",Misplaced:"%1 ubicado incorrectamente",MissingOpenForSub:"Falta la llave de apertura para el sub\u00EDndice",MissingOpenForSup:"Falta la llave de apertura para super\u00EDndice",AmbiguousUseOf:"Uso ambiguo de %1",EnvBadEnd:"\\begin{%1} termina con \\end{%2}",EnvMissingEnd:"Falta \\end{%1}",MissingBoxFor:"Falta la caja para %1",MissingCloseBrace:"Falta la llave de cierre",UndefinedControlSequence:"Secuencia de control indefinida %1",DoubleExponent:"Doble exponente: utiliza llaves para aclarar",DoubleSubscripts:"Doble sub\u00EDndices: utiliza llaves para aclarar",DoubleExponentPrime:"El s\u00EDmbolo \u00ABprima\u00BB causa un exponente doble, utiliza llaves para aclarar",CantUseHash1:'No puedes utilizar "n\u00FAmero de car\u00E1cter de par\u00E1metro de macro" en modo matem\u00E1tico',MisplacedMiddle:"%1 debe estar dentro de \\left y \\right",MisplacedLimits:"%1 est\u00E1 permitido solo en operadores",MisplacedMoveRoot:"%1 solo puede aparecer dentro de una ra\u00EDz",MultipleCommand:"M\u00FAltiples %1",IntegerArg:"El argumento para %1 debe ser un entero",NotMathMLToken:"%1 no es un elemento",InvalidMathMLAttr:"El atributo MathML no es v\u00E1lido: %1",UnknownAttrForElement:"%1 no es un atributo reconocido para %2",MaxMacroSub1:"Conteo m\u00E1ximo de sustituci\u00F3n de macro MathJax superado, \u00BFhay una llamada recursiva de macro?",MaxMacroSub2:"Se excedi\u00F3 el conteo m\u00E1ximo de sustituci\u00F3n MathJax, \u00BFhay un ambiente recursivo de LaTeX?",MissingArgFor:"Falta el argumento para %1",ExtraAlignTab:"Ficha de alineaci\u00F3n adicional en texto \\cases",BracketMustBeDimension:"El argumento de par\u00E9ntesis %1 debe ser una dimensi\u00F3n",InvalidEnv:"Nombre de entorno \u00AB%1\u00BB no v\u00E1lido",UnknownEnv:"Entorno desconocido \u00AB%1\u00BB",ExtraCloseLooking:"Llave de cierre adicional al buscar %1",MissingCloseBracket:'No se pudo encontrar "]" de cierre para el argumento %1',MissingOrUnrecognizedDelim:"Delimitador no reconocido o faltante para %1",MissingDimOrUnits:"Falta la dimensi\u00F3n o sus unidades para %1",TokenNotFoundForCommand:"No se pudo encontrar %1 para %2",MathNotTerminated:"La notaci\u00F3n matem\u00E1tica no termina en el cuadro de texto",IllegalMacroParam:"Referencia de par\u00E1metro de macro ilegal",MaxBufferSize:"Tama\u00F1o del b\u00FAfer interno de MathJax excedido. \u00BFHay una llamada macro recursiva?",CommandNotAllowedInEnv:"%1 no permitido en el entorno %2",MultipleLabel:"Se defini\u00F3 la etiqueta \u00AB%1\u00BB varias veces",CommandAtTheBeginingOfLine:"%1 debe aparecer al principio de la l\u00EDnea",IllegalAlign:"Se especific\u00F3 un alineamiento incorrecto en %1",BadMathStyleFor:"Estilo matem\u00E1tico err\u00F3neo para %1",PositiveIntegerArg:"El argumento de %1 debe ser un entero positivo",ErroneousNestingEq:"Anidaci\u00F3n err\u00F3nea de estructuras de ecuaciones",MultlineRowsOneCol:"Las filas dentro del entorno %1 deben tener exactamente una columna",MultipleBBoxProperty:"Se ha especificado %1 dos veces en %2",InvalidBBoxProperty:'"%1" no parece ser un color, una dimensi\u00F3n de relleno o un estilo',ExtraEndMissingBegin:"%1 adicional o falta \\begingroup",GlobalNotFollowedBy:"%1 no va seguido de \\let, \\def o \\newcommand",UndefinedColorModel:"El modelo de color \u00AB%1\u00BB no est\u00E1 definido",ModelArg1:"Los valores de color para el modelo %1 requieren 3 n\u00FAmeros",InvalidDecimalNumber:"El n\u00FAmero decimal no es v\u00E1lido",ModelArg2:"Los valores de color para el modelo %1 deben estar entre %2 y %3",InvalidNumber:"El n\u00FAmero no es v\u00E1lido",NewextarrowArg1:"El primer argumento de %1 debe ser un nombre de secuencia de control",NewextarrowArg2:"El segundo argumento de %1 debe ser dos n\u00FAmeros enteros separados por una coma",NewextarrowArg3:"El tercer argumento de %1 debe ser un n\u00FAmero de caracteres Unicode",NoClosingChar:"No se puede encontrar el %1 de cierre",IllegalControlSequenceName:"El nombre de la secuencia de control para %1 es incorrecto",IllegalParamNumber:"Se especific\u00F3 una cantidad incorrecta de par\u00E1metros en %1",MissingCS:"A %1 ha de a\u00F1ad\u00EDrsele una secuencia de control",CantUseHash2:"Uso incorrecto de \u00AB#\u00BB en la plantilla para %1",SequentialParam:"Los par\u00E1metros para %1 deben ser numerados de forma secuencial",MissingReplacementString:"Falta la cadena de sustituci\u00F3n para la definici\u00F3n de %1",MismatchUseDef:"El uso de %1 no coincide con su definici\u00F3n",RunawayArgument:"\u00BFArgumento de escape para %1?",NoClosingDelim:"No se puede encontrar el delimitador de cierre para %1"}});MathJax.Ajax.loadComplete("[MathJax]/localization/es/TeX.js");
| 287.75 | 5,089 | 0.795656 |
4691329b4bfdf8f7128e7bd0e8b667298f966522 | 2,126 | js | JavaScript | resources/js/src/containers/Frontend/Restaurants/Meals/Comments/Comment/Index.js | marvinboris/turbo-guide | 3d1d7760b143887647533292fbb08e5517ab817b | [
"MIT"
] | null | null | null | resources/js/src/containers/Frontend/Restaurants/Meals/Comments/Comment/Index.js | marvinboris/turbo-guide | 3d1d7760b143887647533292fbb08e5517ab817b | [
"MIT"
] | null | null | null | resources/js/src/containers/Frontend/Restaurants/Meals/Comments/Comment/Index.js | marvinboris/turbo-guide | 3d1d7760b143887647533292fbb08e5517ab817b | [
"MIT"
] | null | null | null | import { faCheckCircle, faHeart, faThumbsDown, faThumbsUp } from '@fortawesome/free-regular-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React from 'react';
import Stars from '../../../../../../components/UI/Stars';
const appreciations = [
{ color: 'green', gt: 4, text: 'Positive' },
{ color: 'orange', gt: 3, text: 'Average' },
{ color: 'red', gt: 0, text: 'Negative' },
];
export default ({ name, mark = 0, body }) => {
const appreciation = appreciations.find(c => c.gt <= mark);
return <div className="mb-3 pb-2 border-bottom border-soft">
<div className="mb-2 pb-1 position-relative">
<div className="d-flex align-items-center">
<div className="text-12 text-500">
{name}
</div>
<div>
<div className={`mx-2 rounded-pill px-1 text-5 text-${appreciation.color} bg-${appreciation.color}-25`} style={{ paddingTop: 1, paddingBottom: 1 }}>
<FontAwesomeIcon icon={faCheckCircle} className="mr-1" />
{appreciation.text}
</div>
</div>
<div>
<div className="d-flex">
<div className="mr-2 text-8">Ratings</div>
<div>
<Stars readOnly mark={mark} />
</div>
</div>
</div>
</div>
<div className="position-absolute" style={{ bottom: 0, left: 0 }}>
<div>
<div className="bg-orange" style={{ width: 31, height: .5 }} />
</div>
</div>
</div>
<div className="text-10 text-300 mb-2">{body}</div>
<div className="text-14 text-right d-none">
<FontAwesomeIcon icon={faThumbsUp} className="text-green mr-2" />
<FontAwesomeIcon icon={faThumbsDown} className="text-red mr-2" />
<FontAwesomeIcon icon={faHeart} className="text-orange" />
</div>
</div>
} | 36.033898 | 168 | 0.500941 |
4691e9d0456548f52fb3175c22ae1425fa99d0c9 | 1,635 | js | JavaScript | node_modules/rxjs/_esm2015/internal/operators/scan.js | GenaAiv/portfolio-website | 66e5f5f012b73fe41879a824f231e8798fb7b5f8 | [
"MIT"
] | null | null | null | node_modules/rxjs/_esm2015/internal/operators/scan.js | GenaAiv/portfolio-website | 66e5f5f012b73fe41879a824f231e8798fb7b5f8 | [
"MIT"
] | null | null | null | node_modules/rxjs/_esm2015/internal/operators/scan.js | GenaAiv/portfolio-website | 66e5f5f012b73fe41879a824f231e8798fb7b5f8 | [
"MIT"
] | null | null | null | import { Subscriber } from '../Subscriber';
export function scan(accumulator, seed) {
let hasSeed = false;
if (arguments.length >= 2) {
hasSeed = true;
}
return function scanOperatorFunction(source) {
return source.lift(new ScanOperator(accumulator, seed, hasSeed));
};
}
class ScanOperator {
constructor(accumulator, seed, hasSeed = false) {
this.accumulator = accumulator;
this.seed = seed;
this.hasSeed = hasSeed;
}
call(subscriber, source) {
return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
}
}
class ScanSubscriber extends Subscriber {
constructor(destination, accumulator, _seed, hasSeed) {
super(destination);
this.accumulator = accumulator;
this._seed = _seed;
this.hasSeed = hasSeed;
this.index = 0;
}
get seed() {
return this._seed;
}
set seed(value) {
this.hasSeed = true;
this._seed = value;
}
_next(value) {
if (!this.hasSeed) {
this.seed = value;
this.destination.next(value);
}
else {
return this._tryNext(value);
}
}
_tryNext(value) {
const index = this.index++;
let result;
try {
result = this.accumulator(this.seed, value, index);
}
catch (err) {
this.destination.error(err);
}
this.seed = result;
this.destination.next(result);
}
}
//# sourceMappingURL=scan.js.map | 28.189655 | 108 | 0.554128 |
469217557fc84d9c113002698b471e8ecf6c20cc | 6,676 | js | JavaScript | funwithphysics/src/App.js | ps6067966/FunwithScience | 236c75261908a836ef98d07106ed09bb04957ea2 | [
"MIT"
] | null | null | null | funwithphysics/src/App.js | ps6067966/FunwithScience | 236c75261908a836ef98d07106ed09bb04957ea2 | [
"MIT"
] | null | null | null | funwithphysics/src/App.js | ps6067966/FunwithScience | 236c75261908a836ef98d07106ed09bb04957ea2 | [
"MIT"
] | null | null | null | import Home from "./Components/Home/Home";
import Loadingimg from "./Images/Logo/logo.webp"
import { Switch, Route, Redirect } from "react-router-dom";
import "./index.css";
import React, { Suspense, lazy} from "react";
import ClassicalMechanics from "./Components/Classical_Mechanics/ClassicalMechanics";
import Thermodynamics from "./Components/Thermodynamics/Thermodynamics";
import CalcClassic from "./Components/Classical_Mechanics/Topics/Calculator";
import CalcThermo from "./Components/Thermodynamics/Topics/Calculator";
import WPECalculator from "./Components/Classical_Mechanics/Topics/wpe_Calculator";
import GravitationCalculator from "./Components/Classical_Mechanics/Topics/gravitation_Calculator";
import PhysicsTopic from "./Components/PhysicsTopic";
import MOICalculator from "./Components/Classical_Mechanics/Topics/moi_Calulator";
import shm_Calculator from "./Components/Classical_Mechanics/Topics/shm_Calculator";
import rotation_Calculator from "./Components/Classical_Mechanics/Topics/rotation_Calculator";
import Quiz from "./Components/Quiz/Quiz";
import FluidCalculator from "./Components/Classical_Mechanics/Topics/fluidmechanics_Calculator";
import Electromagnetism from "./Components/Electromagnetism/Electromagnetism";
import electricfield_calculator from "./Components/Electromagnetism/Topics/electricfield_calculator";
import { electricpotential_calculator } from "./Components/Electromagnetism/Topics/electricpotential_calculator";
import calculatorElec from "./Components/Electromagnetism/Topics/calculator";
import {Helmet} from "react-helmet"
import NumMCQ from "./Components/NumMCQ/NumMCQ";
import Singlequestion from "./Components/NumMCQ/Singlequestion";
// import { Helmet } from "react-helmet"
import { hydrate, render } from "react-dom";
import flux_calculator from "./Components/Electromagnetism/Topics/flux_calculator";
// import Electromagnetism from "./Components/Electromagnetism/Electromagnetism";
// import electricfield_calculator from "./Components/Electromagnetism/Topics/electricfield_calculator";
// import calculatorElec from "./Components/Electromagnetism/Topics/calculator";
const Navbar = lazy(()=>{return Promise.all([
import("./Components/Navbar/Navbar"),
new Promise(resolve => setTimeout(resolve, 4000))
])
.then(([moduleExports]) => moduleExports);});
// https://i.pinimg.com/originals/45/12/4d/45124d126d0f0b6d8f5c4d635d466246.gif
const App = () => {
return (
<React.Fragment>
<Helmet>
<title>Fun with Science - Tech N Science</title>
<meta name="description" content="Website for Physics formula and Physics calculator for IIT-JEE and NEET. In this website we provide free calculator
and also formulas to make the long, tiring calculations easy. This website can be used by anyone who wants to reduce their efforts of long calculations." data-react-helmet="true"/>
<meta name="keyword" content="Physics formula, Physics calculator, IIT-JEE, NEET,Tech N Science, tech, science, questions, technscienceweb, technscience, tech and science, technscience.com, Tech N Science, technscience. com, tech n science" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
</Helmet>
<Suspense fallback={<div className="loadingdiv"><img className="loadingimg" src={Loadingimg} alt=""/></div>}>
<Navbar />
</Suspense>
<Switch>
<Route exact path="/" component={Home} />
<Route exact path="/about" component={Home} />
<Route exact path="/contact" component={Home} />
<Route
exact
path="/classicalmechanics"
component={ClassicalMechanics}
/>
<Route
exact
path="/thermodynamics"
component={Thermodynamics}
/>
<Route exact path="/physics" component={PhysicsTopic} />
<Route
exact
path="/classicalmechanics/calc/:topic"
component={CalcClassic}
/>
<Route
exact
path="/thermodynamics/calc/:topic"
component={CalcThermo}
/>
<Route
exact
path="/classicalmechanics/calc/gravitation/:topic"
component={GravitationCalculator}
/>
<Route
exact
path="/classicalmechanics/calc/moment_of_inertia/:topic"
component={MOICalculator}
/>
<Route
exact
path="/classicalmechanics/calc/shm/:topic"
component={shm_Calculator}
/>
<Route
exact
path="/classicalmechanics/calc/work_power_energy/:topic"
component={WPECalculator}
/>
<Route
exact
path="/classicalmechanics/calc/rotation/:topic"
component={rotation_Calculator}
/>
<Route
exact
path="/electromagnetism"
component={Electromagnetism}
/>
<Route
exact
path="/electromagnetism/calc/:topic"
component={calculatorElec}
/>
<Route
exact
path="/electromagnetism/calc/electric_field/:topic"
component={electricfield_calculator}
/>
<Route exact path="/quiz" component={Quiz} />
<Route
exact
path="/classicalmechanics/calc/fluid_mechanics/:topic"
component={FluidCalculator}
/>
<Route
exact
path="/electromagnetism"
component={Electromagnetism}
/>
<Route
exact
path="/electromagnetism/calc/:topic"
component={calculatorElec}
/>
<Route
exact
path="/electromagnetism/calc/electric_field/:topic"
component={electricfield_calculator}
/>
<Route
exact
path="/electromagnetism/calc/Flux/:topic"
component={flux_calculator}
/>
<Route
exact
path="/electromagnetism/calc/electric_potential/:topic"
component={electricpotential_calculator}
/>
<Route
exact
path="/questions"
component={NumMCQ}
/>
<Route
exact
path="/questions/:id"
component={Singlequestion}
/>
<Redirect to="/" />
</Switch>
</React.Fragment>
);
};
export default App;
const rootElement = document.getElementById("root");
if (rootElement.hasChildNodes()) {
hydrate(App, rootElement);
} else {
render(App, rootElement);
} | 35.892473 | 251 | 0.652187 |
4692968055d577368f62d53c02a340b1d652c64a | 1,223 | js | JavaScript | 2017/dragdrop/883_code_uglify.js | ripter/js1k | 914229791a2b894ae1c17817676742b260f7d996 | [
"MIT"
] | null | null | null | 2017/dragdrop/883_code_uglify.js | ripter/js1k | 914229791a2b894ae1c17817676742b260f7d996 | [
"MIT"
] | null | null | null | 2017/dragdrop/883_code_uglify.js | ripter/js1k | 914229791a2b894ae1c17817676742b260f7d996 | [
"MIT"
] | null | null | null | function t(t){return'<svg viewBox="0 0 1000 800">'+t.map(function(t){return'<polygon points="'+t[0]+'" style="'+t[1]+'"/>'}).join("")+"</svg>"}function e(t,e,r){var n=document.createElement(t);return n.innerHTML=e,r.prepend(n),n}var r=null;window.m=function(t){var e,n=t.target;switch(t.type){case"mousedown":if(r)return;if("svg"==n.tagName)return;r=n,r.start=[t.x,t.y];break;case"mousemove":if(!r)return;r.deltaX=t.x-r.start[0],r.deltaY=t.y-r.start[1],r.setAttribute("transform","translate("+r.deltaX+", "+r.deltaY+")");break;case"mouseup":if(!r)return;e=r.getAttribute("points"),e=e.replace(/([\d.]+),([\d.]+)/g,function(t,e,n){return""+(+e+r.deltaX)+","+(+n+r.deltaY)}),r.setAttribute("points",e),r.removeAttribute("transform"),r=null}};var n=[["0,0 0,100 50,50","fill: #001f3f"],["0,100 100,100 50,50","fill: #0074D9"],["100,100 100,50 75,75","fill: #7FDBFF"],["100,50 100,0 50,0","fill: #39CCCC"],["50,50 75,25 100,50 75,75","fill: #3D9970"],["50,50 75,25 25,25","fill: #2ECC40"],["0,0 50,0 75,25 25,25","fill: #01FF70"]];n=n.map(function(t){return t[0]=t[0].replace(/(\d+)/g,function(t){return 2.5*t}),t});var i=e("div",t(n),b);["down","move","up","out"].forEach(function(t){i.addEventListener("mouse"+t,window.m)});
| 611.5 | 1,222 | 0.638594 |
46939a915741cf7df3f41af3b10bc1463bf4894b | 303 | js | JavaScript | migrations/20180618042617-AddParentIdToCategory.js | nghia11110/nodejs_api_form | ce91211a85a70443b0b25a9c868bb85320328f45 | [
"MIT"
] | null | null | null | migrations/20180618042617-AddParentIdToCategory.js | nghia11110/nodejs_api_form | ce91211a85a70443b0b25a9c868bb85320328f45 | [
"MIT"
] | null | null | null | migrations/20180618042617-AddParentIdToCategory.js | nghia11110/nodejs_api_form | ce91211a85a70443b0b25a9c868bb85320328f45 | [
"MIT"
] | null | null | null | const dbName = 'categories';
module.exports = {
up: (queryInterface, Sequelize) => queryInterface.addColumn(
dbName,
'parent_id',
{
type: Sequelize.INTEGER,
allowNull: true,
}
),
down: (queryInterface, Sequelize) => queryInterface.removeColumn(dbName, 'parent_id')
};
| 21.642857 | 87 | 0.653465 |
46947f6e8bf42c9a06340641eed083cccb6ec151 | 151 | js | JavaScript | src/createPageAction.js | JunQiGenYuan/react-redux-page | 137e589ff77b2938c071c980f6c92105b46378e0 | [
"MIT"
] | 2 | 2017-04-18T10:43:59.000Z | 2018-04-02T07:42:29.000Z | src/createPageAction.js | JunQiGenYuan/react-redux-page | 137e589ff77b2938c071c980f6c92105b46378e0 | [
"MIT"
] | null | null | null | src/createPageAction.js | JunQiGenYuan/react-redux-page | 137e589ff77b2938c071c980f6c92105b46378e0 | [
"MIT"
] | null | null | null | import { ACTION_PREFIX } from './const';
export default (action) => {
return Object.assign({
type: ACTION_PREFIX + action.type
}, action);
};
| 18.875 | 40 | 0.649007 |
4694a26850878268da2be1450b22c598fd92790c | 1,031 | js | JavaScript | js/pageInforme.js | eric2916/proyecto | 989af5e61bc1fe138012ba776a096d77f543ff78 | [
"MIT"
] | null | null | null | js/pageInforme.js | eric2916/proyecto | 989af5e61bc1fe138012ba776a096d77f543ff78 | [
"MIT"
] | null | null | null | js/pageInforme.js | eric2916/proyecto | 989af5e61bc1fe138012ba776a096d77f543ff78 | [
"MIT"
] | null | null | null | console.info("hello world");
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
var cursoactual=localStorage.getItem('curso');
console.info(cursoactual);
if(cursoactual!=null){
$("#spncurso").html(""+cursoactual);
$("#curso").val(""+cursoactual);
}else{
var d = new Date();
var n = d.getFullYear();
$("#spncurso").html(""+n);
$("#curso").val(""+n);
}
var tema=localStorage.getItem('tema');
if(tema!=null){
if(tema=="ocre"){
$("body").css("background-color","#E3D671");
}else if(tema=="dark"){
$("body").css("background-color","#754831");
}
}
$("a.dropdown-tema-dark")
.click(function () {
localStorage.setItem("tema", "dark");
$("body").css("background-color","#754831");
});
$("a.dropdown-tema-ocre")
.click(function () {
localStorage.setItem("tema", "ocre");
$("body").css("background-color","#E3D671");
});
$("a.dropdown-tema-default")
.click(function () {
localStorage.setItem("tema", "default");
$("body").css("background-color","white");
}); | 23.431818 | 52 | 0.586809 |
4694e5ea4a0e4e7009a516cf359af2e137dfc6bb | 1,235 | js | JavaScript | src/components/SectionSobre/SocialNav.js | IDEjr/site-idejr | 80b430211ff8b538e22244095d31f013b00e9fff | [
"RSA-MD"
] | null | null | null | src/components/SectionSobre/SocialNav.js | IDEjr/site-idejr | 80b430211ff8b538e22244095d31f013b00e9fff | [
"RSA-MD"
] | 30 | 2020-10-27T18:07:29.000Z | 2021-08-02T14:05:39.000Z | src/components/SectionSobre/SocialNav.js | IDEjr/site-idejr | 80b430211ff8b538e22244095d31f013b00e9fff | [
"RSA-MD"
] | 1 | 2021-03-01T21:08:07.000Z | 2021-03-01T21:08:07.000Z | import React from "react"
import styled from "styled-components"
import { FaGithub, FaLinkedin, FaInstagram, FaFacebookF } from "react-icons/fa"
import colors from "@utils/colors"
import { SMALL } from "@utils/breakpoints"
const Aside = styled.aside`
position: absolute;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: fit-content;
height: fit-content;
svg {
height: 2.5rem;
width: 2.5rem;
color: ${ colors.BLUE }
}
@media (max-width: ${SMALL}px) {
position: static;
flex-direction: row;
justify-content: space-around;
width: 100%;
}
`
export default function SocialNav() {
return (
<Aside >
<a href="https://github.com/IDEjr" target="_blank" rel="noopener noreferrer">
<FaGithub />
</a>
<a href="https://www.linkedin.com/company/empresa-j%C3%BAnior-ide/" target="_blank" rel="noopener noreferrer">
<FaLinkedin />
</a>
<a href="https://www.instagram.com/ide_jr/" target="_blank" rel="noopener noreferrer">
<FaInstagram />
</a>
<a href="https://www.facebook.com/idejr" target="_blank" rel="noopener noreferrer">
<FaFacebookF />
</a>
</Aside>
)
}
| 25.729167 | 116 | 0.634818 |
4695267adc917e67200ee0cce528a7bf9115c26f | 1,351 | js | JavaScript | src/MusicPlayerError.js | ZinMain/discord-music-player | 0ff75f60fd5d869acf8d2a4161318f2e8e4f522f | [
"MIT"
] | null | null | null | src/MusicPlayerError.js | ZinMain/discord-music-player | 0ff75f60fd5d869acf8d2a4161318f2e8e4f522f | [
"MIT"
] | null | null | null | src/MusicPlayerError.js | ZinMain/discord-music-player | 0ff75f60fd5d869acf8d2a4161318f2e8e4f522f | [
"MIT"
] | null | null | null | /**
* Specific errors.
*/
const customErrors = {
'MessageTypeInvalid': 'Message must me a type of Message.',
'SearchIsNull': 'No Song was found with that query.',
'VoiceChannelTypeInvalid': 'Voice Channel must be a type of VoiceChannel.',
'SongTypeInvalid': 'Song must be a type of String.',
'QueueIsNull': 'The Guild Queue is NULL.',
'OptionsTypeInvalid': 'The Search Options must be a type of Object.',
'NotANumber': 'The provided argument is not a Number.',
'QueueTooSmall': "The queue is too small you can't move anything",
'invalidNumber': 'Song you choose is playing / invalid.',
'InvalidPlaylist': 'No Playlist was found with that link.',
'MaxSongsTypeInvalid': 'The provided argument (MaxSongsTypeInvalid) is not a Number.',
'PlaylistTypeInvalid': 'The provided argument (PlaylistURL) was not a String.',
'InvalidSpotify': 'No Spotify Song was found with that link.'
}
/**
* Represents a Music Error.
*/
class MusicPlayerError {
/**
* @param {String} error Error message type.
*/
constructor(error) {
/**
* Error message.
* @type {String}
*/
this.type = error;
/**
* Error message.
* @type {String}
*/
this.message = customErrors[error];
}
}
module.exports = MusicPlayerError; | 32.166667 | 90 | 0.633605 |
4695f52dd97571a73e4f3318b199fddbc2eb9757 | 1,231 | js | JavaScript | frontend/src/Services/services.js | Likhitha-22/shopping-cart-assignment | 69460044261a38fee7d3c578eeba4a30ced9e339 | [
"MIT"
] | null | null | null | frontend/src/Services/services.js | Likhitha-22/shopping-cart-assignment | 69460044261a38fee7d3c578eeba4a30ced9e339 | [
"MIT"
] | null | null | null | frontend/src/Services/services.js | Likhitha-22/shopping-cart-assignment | 69460044261a38fee7d3c578eeba4a30ced9e339 | [
"MIT"
] | null | null | null | import axios from "axios";
const api = "http://localhost:5000";
export const getBannerList = async() => {
try {
const resp = await axios.get(`${api}/banners`);
if (resp.status === 200) {
return resp.data;
}
console.log('something went wrong');
} catch (error) {
console.log("Unable to fetch banner's list", error);
}
};
export const getCategoryList = async() => {
try {
const resp = await axios.get(`${api}/categories`);
if (resp.status === 200) {
return resp.data
}
console.log('something went wrong');
} catch (error) {
console.log("Unable to fetch category list");
}
};
export const getProductList = async() => {
try {
const resp = await axios.get(`${api}/products`);
if (resp.status === 200) {
return resp.data
}
console.log('something went wrong');
} catch (error) {
console.log("Unable to fetch product list");
}
};
export const addToCartService = async() => {
try {
const resp = await axios.post(`${api}/addToCart`);
if (resp.status === 200) {
return resp.data
}
console.log('something went wrong, Please try again.');
} catch (error) {
console.log("Unable to fetch the product list.");
}
}; | 26.76087 | 59 | 0.60195 |
46962be85a7c2b2874b0b63752b44d87b899f1cc | 2,518 | js | JavaScript | src/deck.js | troygoode/node-shuffle | 86e0505b0d25907cf92445e1152cb72c98bf5c00 | [
"MIT"
] | 21 | 2015-03-18T17:57:14.000Z | 2022-01-08T04:29:20.000Z | src/deck.js | troygoode/node-shuffle | 86e0505b0d25907cf92445e1152cb72c98bf5c00 | [
"MIT"
] | 1 | 2020-10-11T15:51:53.000Z | 2020-11-21T00:19:20.000Z | src/deck.js | troygoode/node-shuffle | 86e0505b0d25907cf92445e1152cb72c98bf5c00 | [
"MIT"
] | 13 | 2015-07-16T19:40:16.000Z | 2021-12-18T06:48:24.000Z | module.exports = function(cards, random){
this.reset = function(){
this.cards = cards.slice(0);
this.length = this.cards.length;
};
this.shuffle = function(){
fisherYates(this.cards);
};
this.reset();
this.shuffle();
this.deal = function(numberOfCards, arrayOfHands){
for(var i = 0; i < numberOfCards; i++) {
for(var j = 0; j < arrayOfHands.length; j++) {
if (!arrayOfHands[j] || !arrayOfHands[j].push) {
throw new Error('Deck#deal | Undefined Hand');
}
arrayOfHands[j].push(this.cards.pop());
}
}
this.length = this.cards.length;
};
this.draw = function(num){
if(!num || num <= 1){
this.length = this.cards.length - 1;
return this.cards.pop();
}
var ret = [];
for(var i = 0; i < num; i++)
ret.push(this.cards.pop());
this.length = this.cards.length;
return ret;
};
this.drawFromBottomOfDeck = function(num){
if(!num || num < 1) {
num = 1;
}
var ret = [];
for(var i = 0; i < num; i++) {
ret.push(this.cards.shift());
}
this.length = this.cards.length;
if (ret.length === 1) {
return ret[0];
} else {
return ret;
}
};
this.drawRandom = function(num){
var _draw = function(){
var index = Math.floor(random() * this.cards.length);
var card = this.cards[index];
this.cards.splice(index, 1);
this.length = this.cards.length;
return card;
};
if(!num || num <= 1){
return _draw.apply(this);
}else{
var cards = [];
for(var i = 0; i < num; i++){
cards.push(_draw.apply(this));
}
return cards;
}
};
this.putOnTopOfDeck = function(cards){
if(!cards instanceof Array)
this.cards.push(cards);
else
for(var i = 0; i < cards.length; i++)
this.cards.push(cards[i]);
this.length = this.cards.length;
};
this.putOnBottomOfDeck = function(cards){
if(!cards instanceof Array)
this.cards.unshift(cards);
else
for(var i = 0; i < cards.length; i++)
this.cards.unshift(cards[i]);
this.length = this.cards.length;
};
//array shuffling algorithm: http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
function fisherYates(arr){
var i = arr.length;
if(i === 0)
return false;
while(--i){
var j = Math.floor(random() * (i + 1));
var tempi = arr[i];
var tempj = arr[j];
arr[i] = tempj;
arr[j] = tempi;
}
}
};
| 23.314815 | 88 | 0.547657 |
4696863819706a5d19a03a38218bd9f9ffb87f1c | 311 | js | JavaScript | src/select-menu/src/OptionShapePropType.js | jongsue/evergreen | ad3e4452994b861e97ba498ac33f0fbfdea3ab24 | [
"MIT"
] | null | null | null | src/select-menu/src/OptionShapePropType.js | jongsue/evergreen | ad3e4452994b861e97ba498ac33f0fbfdea3ab24 | [
"MIT"
] | null | null | null | src/select-menu/src/OptionShapePropType.js | jongsue/evergreen | ad3e4452994b861e97ba498ac33f0fbfdea3ab24 | [
"MIT"
] | null | null | null | import PropTypes from 'prop-types'
const OptionShapePropType = PropTypes.shape({
label: PropTypes.string,
labelInList: PropTypes.string, // Optional
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
disabled: PropTypes.bool // Optional
})
export default OptionShapePropType
| 28.272727 | 78 | 0.784566 |
4696c3bc4e2d205d1e3445a9058141cbd0fff6fa | 1,370 | js | JavaScript | tools/bip-trigger.js | IIHTDevops1/bipio | a13b03e6f15748365015b6750e22c2e8d4ac0517 | [
"Apache-2.0"
] | 715 | 2015-01-02T12:52:31.000Z | 2021-11-10T07:22:21.000Z | tools/bip-trigger.js | IIHTDevops1/bipio | a13b03e6f15748365015b6750e22c2e8d4ac0517 | [
"Apache-2.0"
] | 48 | 2015-01-19T06:54:00.000Z | 2019-04-04T05:14:31.000Z | tools/bip-trigger.js | AYCHAIN/BipServer | a13b03e6f15748365015b6750e22c2e8d4ac0517 | [
"Apache-2.0"
] | 121 | 2015-01-09T20:11:55.000Z | 2021-06-11T17:52:49.000Z | #!/usr/bin/env node
/**
*
* The Bipio API Server
*
* Copyright (c) 2017 InterDigital, 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.
*
*
* A Bipio Commercial OEM License may be obtained via hello@bip.io
*/
/**
* Triggers unpaused trigger bips.
*/
process.HEADLESS = true;
var bootstrap = require(__dirname + '/../src/bootstrap');
bootstrap.app.bastion.on('readyQueue', function(readyQueue) {
if (readyQueue == 'queue_jobs') {
app.logmessage('BIP-TRIGGER:Trigger Queue Discovered:queue_jobs');
bootstrap.app.dao.triggerAll(function(err, msg) {
if (err) {
app.logmessage('BIP-TRIGGER:' + err + ' ' + msg);
} else {
app.logmessage(msg);
app.logmessage('BIP-TRIGGER:DONE');
}
process.exit(0);
});
}
}); | 33.414634 | 75 | 0.648175 |
46976f609daa9ffd06147c5b1f13d06a607119e2 | 48 | js | JavaScript | node_modules/sugar/string/var/CAMELIZE_REG.js | slife518/Giantbaby_sv | cacae3f17a00c36dacf11f2c22f381eb10ffca5d | [
"MIT"
] | null | null | null | node_modules/sugar/string/var/CAMELIZE_REG.js | slife518/Giantbaby_sv | cacae3f17a00c36dacf11f2c22f381eb10ffca5d | [
"MIT"
] | null | null | null | node_modules/sugar/string/var/CAMELIZE_REG.js | slife518/Giantbaby_sv | cacae3f17a00c36dacf11f2c22f381eb10ffca5d | [
"MIT"
] | null | null | null | 'use strict';
module.exports = /(^|_)([^_]+)/g; | 16 | 33 | 0.520833 |
469775b9c4fa4b252006e548a88daca06bf7cdeb | 1,798 | js | JavaScript | js/account.js | kevink97/htc-website | 57525c8b4491e04fbb9ada5ae94a94936d02aca0 | [
"MIT"
] | null | null | null | js/account.js | kevink97/htc-website | 57525c8b4491e04fbb9ada5ae94a94936d02aca0 | [
"MIT"
] | null | null | null | js/account.js | kevink97/htc-website | 57525c8b4491e04fbb9ada5ae94a94936d02aca0 | [
"MIT"
] | null | null | null | // Initialize Firebase
var config = {
apiKey: "AIzaSyAJGFuMK-DhPuTgd61HLL47RMtcmXX7ckM",
authDomain: "uw-htc-website.firebaseapp.com",
databaseURL: "https://uw-htc-website.firebaseio.com",
projectId: "uw-htc-website",
storageBucket: "uw-htc-website.appspot.com",
messagingSenderId: "771697394602"
};
firebase.initializeApp(config);
console.log(firebase.auth().currentUser);
if (!firebase.auth().currentUser) {
}
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
}
else {
window.location.href = 'login.html';
}
})
var dict = {};
$('.ro').click(function() {
console.log("going to edit mode");
$(this).removeClass('ro');
$(this).addClass('edit');
dict[$(this).prop('id')] = $(this).val();
});
$(document).on('keyup', '.edit', function(e) {
if (e.keyCode == 13) {
console.log('entered');
$(this).addClass('ro');
$(this).removeClass('edit');
dict[$(this).prop('id')] = $(this).val();
myFunction($(this).prop('id'));
}
});
$('select').change(function() {
$(this).prop('data-selected-text-format', 'values');
console.log("here is the value: " + $(this).val());
myFunction($(this).prop('id'));
});
$('input').blur(function() {
console.log("going back to read only");
$(this).removeClass('edit');
$(this).addClass('ro');
$(this).val(dict[$(this).prop('id')]);
})
$('[data-toggle="tooltip"]').tooltip();
function myFunction(val) {
// Get the snackbar DIV
var x = document.getElementById("snackbar");
x.innerText = "Saved your " + val;
// Add the "show" class to DIV
x.className = "show";
// After 3 seconds, remove the show class from DIV
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 2000);
} | 26.835821 | 83 | 0.600111 |
4697af4e47b2225b636cecabc9ea1768130aa907 | 568 | js | JavaScript | src/pages/home-page.js | arnaudgregoire/Registry | 48fddf1e64f1a42c1d0db29a85ab0bccc205dfff | [
"MIT"
] | null | null | null | src/pages/home-page.js | arnaudgregoire/Registry | 48fddf1e64f1a42c1d0db29a85ab0bccc205dfff | [
"MIT"
] | null | null | null | src/pages/home-page.js | arnaudgregoire/Registry | 48fddf1e64f1a42c1d0db29a85ab0bccc205dfff | [
"MIT"
] | null | null | null | class HomePage {
constructor(args) {
this.render();
this.addEventListeners();
}
render() {
const content = document.createElement('div');
content.setAttribute('id', 'home');
content.innerHTML = `<button type="button" class="btn" id='play-button'>Play</button>`;
document.body.innerHTML = '';
document.body.appendChild(content);
}
addEventListeners() {
document.getElementById('play-button').addEventListener('click',e =>{
window.dispatchEvent(new CustomEvent('render-lobby'));
});
}
}
export default HomePage;
| 24.695652 | 92 | 0.660211 |
46982d3889cc7423b5b7577d086122862c4f9231 | 302 | js | JavaScript | src/routines/turn-off.js | codyrushing/proximity-lights | ee7edd3fe8a0a3918f6fde1abafc2c087bf8a31b | [
"MIT"
] | null | null | null | src/routines/turn-off.js | codyrushing/proximity-lights | ee7edd3fe8a0a3918f6fde1abafc2c087bf8a31b | [
"MIT"
] | null | null | null | src/routines/turn-off.js | codyrushing/proximity-lights | ee7edd3fe8a0a3918f6fde1abafc2c087bf8a31b | [
"MIT"
] | null | null | null | const lightChannel = require('../light-channel');
const BaseRoutine = require('./base');
const config = require('../constants');
class TurnOff extends BaseRoutine {
init(){
return lightChannel.update(
this.lightId,
{
on: false
}
);
}
}
module.exports = TurnOff;
| 17.764706 | 49 | 0.615894 |
469842f94ec75638b3046114dd31341c28fc98fa | 2,200 | js | JavaScript | packages/dotter/dist/dotter.js | ianwalter/generates | a34f88bc1e0754112e747716dadf97f2f8618ba3 | [
"Apache-2.0"
] | 2 | 2020-12-29T02:32:20.000Z | 2021-08-03T13:45:06.000Z | packages/dotter/dist/dotter.js | generates/generates | 30fe84da6280e84ed41ccd75864cceebd6bd8655 | [
"Apache-2.0"
] | 26 | 2018-11-27T17:33:03.000Z | 2022-02-27T22:07:06.000Z | packages/dotter/dist/dotter.js | ianwalter/generates | a34f88bc1e0754112e747716dadf97f2f8618ba3 | [
"Apache-2.0"
] | 1 | 2020-11-02T10:57:24.000Z | 2020-11-02T10:57:24.000Z | 'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const isObj = i => typeof i === 'object' && i && !Array.isArray(i);
function get (src, path, defaultValue) {
if (!path) return src
const pathKeys = path.split('.');
let current = src;
for (const key of pathKeys) {
if (!current || !(key in current)) return defaultValue
current = current[key];
}
return current
}
function set (src, path = '', value) {
const pathKeys = path.split('.');
const lastIndex = pathKeys.length - 1;
let current = src;
for (let i = 0; i < pathKeys.length; i++) {
if (i === lastIndex) {
current[pathKeys[i]] = value;
} else {
if (!isObj(current[pathKeys[i]])) current[pathKeys[i]] = {};
current = current[pathKeys[i]];
}
}
return src
}
function del (src, path = '') {
const pathKeys = path.split('.');
const lastIndex = pathKeys.length - 1;
let current = src;
for (let i = 0; i < pathKeys.length; i++) {
if (!current) continue
if (i === lastIndex) {
delete current[pathKeys[i]];
} else {
if (!isObj(current[pathKeys[i]])) return
current = current[pathKeys[i]];
}
}
return src
}
function has (src, path = '') {
const pathKeys = path.split('.');
const lastIndex = pathKeys.length - 1;
let current = src;
for (let i = 0; i < pathKeys.length; i++) {
if (i === lastIndex) {
return current && pathKeys[i] in current
} else {
if (!current || !isObj(current[pathKeys[i]])) return false
current = current[pathKeys[i]];
}
}
}
function match (a = '', b = '') {
const aKeys = a.split('.');
const bKeys = b.split('.');
const last = aKeys.length - 1;
let aStar = false;
let bStar = false;
for (let i = 0; i < aKeys.length; i++) {
if (i === last && aKeys[i] === bKeys[i]) return true
aStar = aKeys[i] === '*' || (aStar && !aKeys[i]);
bStar = bKeys[i] === '*' || (bStar && !bKeys[i]);
const starMatch = (aStar && bKeys[i]) || (bStar && aKeys[i]);
if (aKeys[i] !== bKeys[i] && !starMatch) return false
}
return true
}
exports.del = del;
exports.get = get;
exports.has = has;
exports.match = match;
exports.set = set;
| 23.913043 | 67 | 0.571818 |
4698716fa337750b0dc19bfc79b9a61b53ff1e2c | 99,231 | js | JavaScript | blog/docs/notes_1.basic_2.css_2.flex.md.js | zqy233/vitepress--vue-theme-blog | 9b1ccb44aa505f707e3203bf181365bc1d88cb07 | [
"MIT"
] | null | null | null | blog/docs/notes_1.basic_2.css_2.flex.md.js | zqy233/vitepress--vue-theme-blog | 9b1ccb44aa505f707e3203bf181365bc1d88cb07 | [
"MIT"
] | null | null | null | blog/docs/notes_1.basic_2.css_2.flex.md.js | zqy233/vitepress--vue-theme-blog | 9b1ccb44aa505f707e3203bf181365bc1d88cb07 | [
"MIT"
] | null | null | null | "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports[Symbol.toStringTag] = "Module";
var serverRenderer = require("vue/server-renderer");
var vue = require("vue");
var pluginVue_exportHelper = require("./assets/plugin-vue_export-helper.db096aab.js");
var _imports_0 = "/vite-vue-blog/assets/image-20220424150223657.453e8b97.png";
var _imports_1 = "/vite-vue-blog/assets/image-20220424150311020.80f9a44f.png";
var _imports_2 = "/vite-vue-blog/assets/image-20220424150335938.7ec4b352.png";
var _imports_3 = "/vite-vue-blog/assets/image-20220424150638671.5822eece.png";
var _imports_4 = "/vite-vue-blog/assets/image-20220424152437332.1100c733.png";
var _imports_5 = "/vite-vue-blog/assets/image-20220424152743477.64e4ee78.png";
var _imports_6 = "/vite-vue-blog/assets/image-20220424153015665.3de90ff9.png";
var _imports_7 = "/vite-vue-blog/assets/image-20220424153106761.ee44169b.png";
var _imports_8 = "/vite-vue-blog/assets/image-20220424154549761.d260f0f5.png";
var _imports_9 = "/vite-vue-blog/assets/image-20220424155904034.868c5708.png";
var _imports_10 = "/vite-vue-blog/assets/image-20220424160214451.e9a7165f.png";
var _imports_11 = "/vite-vue-blog/assets/image-20220424165207527.9305b5da.png";
var _imports_12 = "/vite-vue-blog/assets/image-20220424174654646.c6146ba1.png";
const __pageData = '{"title":"flex","description":"","frontmatter":{},"headers":[{"level":2,"title":"\u7EC3\u4E60html","slug":"\u7EC3\u4E60html"},{"level":2,"title":"display: flex","slug":"display-flex"},{"level":2,"title":"flex\u5BB9\u5668\u516D\u5927\u5C5E\u6027","slug":"flex\u5BB9\u5668\u516D\u5927\u5C5E\u6027"},{"level":2,"title":"flex-direction","slug":"flex-direction"},{"level":2,"title":"flex-wrap","slug":"flex-wrap"},{"level":2,"title":"flex-flow","slug":"flex-flow"},{"level":2,"title":"justify-content","slug":"justify-content"},{"level":2,"title":"align-items","slug":"align-items"},{"level":2,"title":"align-content","slug":"align-content"},{"level":2,"title":"\u9879\u76EE(\u5B50\u5143\u7D20)\u7684\u516D\u5927\u5C5E\u6027","slug":"\u9879\u76EE-\u5B50\u5143\u7D20-\u7684\u516D\u5927\u5C5E\u6027"},{"level":2,"title":"order","slug":"order"},{"level":2,"title":"flex-grow","slug":"flex-grow"},{"level":2,"title":"flex-shrink","slug":"flex-shrink"},{"level":2,"title":"flex-basis","slug":"flex-basis"},{"level":2,"title":"flex","slug":"flex-1"},{"level":2,"title":"align-self","slug":"align-self"},{"level":2,"title":"\u5782\u76F4\u5C45\u4E2D","slug":"\u5782\u76F4\u5C45\u4E2D"}],"relativePath":"notes/1.basic/2.css/2.flex.md","lastUpdated":1652939653924}';
const _sfc_main = {};
function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
_push(`<div${serverRenderer.ssrRenderAttrs(_attrs)}><h1 id="flex" tabindex="-1">flex <a class="header-anchor" href="#flex" aria-hidden="true">#</a></h1><blockquote><p>2009\u5E74\uFF0CW3C \u63D0\u51FA\u4E86\u4E00\u79CD\u65B0\u7684\u65B9\u6848----Flex \u5E03\u5C40\uFF0C\u53EF\u4EE5\u7B80\u4FBF\u3001\u5B8C\u6574\u3001\u54CD\u5E94\u5F0F\u5730\u5B9E\u73B0\u5404\u79CD\u9875\u9762\u5E03\u5C40\u3002\u76EE\u524D\uFF0C\u5B83\u5DF2\u7ECF\u5F97\u5230\u4E86\u6240\u6709\u6D4F\u89C8\u5668\u7684\u652F\u6301\uFF0C\u8FD9\u610F\u5473\u7740\uFF0C\u73B0\u5728\u5C31\u80FD\u5F88\u5B89\u5168\u5730\u4F7F\u7528\u8FD9\u9879\u529F\u80FD</p><p>Flex \u662F Flexible Box \u7684\u7F29\u5199\uFF0C\u610F\u4E3A"\u5F39\u6027\u5E03\u5C40"\uFF0C\u7528\u6765\u4E3A\u76D2\u72B6\u6A21\u578B\u63D0\u4F9B\u6700\u5927\u7684\u7075\u6D3B\u6027</p></blockquote><h2 id="\u7EC3\u4E60html" tabindex="-1">\u7EC3\u4E60html <a class="header-anchor" href="#\u7EC3\u4E60html" aria-hidden="true">#</a></h2><p>\u57FA\u4E8E\u4EE5\u4E0Bhtml\u6765\u5F00\u59CB\u5B66\u4E60\uFF0C\u8FD0\u884C\u8BE5html\u540E\uFF0C\u5E03\u5C40\u6837\u5F0F\u4E3A1\u81F39\u4ECE\u4E0A\u800C\u4E0B\u6392\u5217\uFF0C\u6BCF\u4E2A\u7684\u5BBD\u5EA6\u90FD\u4E3A300px</p><div class="language-html"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"><</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C792EA" })}">class</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">=</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C3E88D" })}">flex-practise</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"><</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C792EA" })}">class</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">=</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C3E88D" })}">item</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">1</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"></</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"><</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C792EA" })}">class</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">=</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C3E88D" })}">item</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">2</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"></</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"><</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C792EA" })}">class</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">=</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C3E88D" })}">item</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">3</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"></</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"><</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C792EA" })}">class</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">=</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C3E88D" })}">item</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">4</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"></</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"><</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C792EA" })}">class</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">=</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C3E88D" })}">item</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">5</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"></</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"><</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C792EA" })}">class</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">=</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C3E88D" })}">item</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">6</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"></</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"><</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C792EA" })}">class</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">=</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C3E88D" })}">item</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">7</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"></</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"><</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C792EA" })}">class</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">=</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C3E88D" })}">item</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">8</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"></</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"><</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C792EA" })}">class</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">=</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C3E88D" })}">item</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">9</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"></</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"></</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"> <</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">style</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">body</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">flex-practise</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">height</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">background-color</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">eeeeee</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0B\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0A\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">item</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">33.33%</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">height</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">33.33%</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">color</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">ffffff</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">display</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">justify-content</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> center</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">align-items</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> center</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">font-size</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">30px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">background-color</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">000000</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">border</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">1px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> solid </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">fff</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">box-sizing</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> border-box</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">border-radius</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">15px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"></</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">style</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"></span></code></pre></div><p><img${serverRenderer.ssrRenderAttr("src", _imports_0)} alt="image-20220424150223657"></p><h2 id="display-flex" tabindex="-1">display: flex <a class="header-anchor" href="#display-flex" aria-hidden="true">#</a></h2><p>\u91C7\u7528flex\u5E03\u5C40\u7684\u5143\u7D20\uFF0C\u53C8\u79F0\u4E3A<code>flex\u5BB9\u5668</code>(flex container)\uFF0C\u5B83\u7684<code>\u6BCF\u4E2A\u5B50\u5143\u7D20</code>\u81EA\u52A8\u6210\u4E3A\u5BB9\u5668\u6210\u5458\uFF0C\u53C8\u79F0\u4E3A<code>flex\u9879\u76EE</code>(flex item)\uFF0C\u7B80\u79F0<code>\u9879\u76EE</code></p><p>\u5B9E\u9645\u5F00\u53D1\u4E2D\uFF0Cflex\u5E03\u5C40\u5E38\u7528\u4E8E\u4F7F\u6240\u6709<code>\u72EC\u5360\u4E00\u884C\u7684\u5757\u7EA7\u5B50\u5143\u7D20</code>(\u57FA\u672C\u4E0A\u662F<code>div</code>)\uFF0C\u53D8\u4E3A\u4E00\u884C\u663E\u793A</p><p>\u793A\u4F8B\u4EE3\u7801\u5982\u4E0B\uFF0C\u5E03\u5C40\u6837\u5F0F\u53D8\u4E3A1\u81F39\u4ECE\u5DE6\u5230\u7531\u6392\u5217\uFF0C\u4E14\u5BBD\u5EA6\u7B49\u6BD4\u7F29\u653E</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">flex-practise</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">height</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0B\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">display</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0A\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><p><img${serverRenderer.ssrRenderAttr("src", _imports_1)} alt="image-20220424150311020"></p><p>\u53EF\u662F\u6211\u4EEC\u660E\u660E\u5DF2\u7ECF\u8BBE\u7F6E\u5B50\u5143\u7D20\u7684\u5BBD\u5EA6\u4E3A33.33%\uFF0C\u4ECE\u800C\u6211\u4EEC\u53EF\u4EE5\u5F97\u51FA\u4E86\u4E00\u4E2A\u7ED3\u8BBA\uFF1A</p><p>flex\u5E03\u5C40\u4E0B\u7684\u6240\u6709<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u9ED8\u8BA4\u6392\u5728\u4E00\u884C\uFF0C\u6240\u6709<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u7684\u5BBD\u5EA6\u4E4B\u548C\u8D85\u8FC7\u7236\u5143\u7D20\u4E5F\u4E0D\u6362\u884C\uFF0C\u800C\u662F\u6309\u6BD4\u4F8B\u7F29\u5C0F\u6240\u6709<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u5BBD\u5EA6\uFF0C\u8FD9\u5176\u5B9E\u662F<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u7684<code>flex-shrink</code>\u5C5E\u6027\u9ED8\u8BA4\u4E3A<code>1</code>\u7684\u7F18\u6545\uFF0C\u4E0B\u9762\u7684\u7AE0\u8282\u4F1A\u5B66\u4E60\u8BE5\u5C5E\u6027</p><h2 id="flex\u5BB9\u5668\u516D\u5927\u5C5E\u6027" tabindex="-1">flex\u5BB9\u5668\u516D\u5927\u5C5E\u6027 <a class="header-anchor" href="#flex\u5BB9\u5668\u516D\u5927\u5C5E\u6027" aria-hidden="true">#</a></h2><ul><li><code>flex-direction</code></li><li><code>flex-wrap</code></li><li><code>flex-flow</code></li><li><code>justify-content</code></li><li><code>align-items</code></li><li><code>align-content</code></li></ul><h2 id="flex-direction" tabindex="-1">flex-direction <a class="header-anchor" href="#flex-direction" aria-hidden="true">#</a></h2><p><code>flex-direction</code>\u5C5E\u6027\u51B3\u5B9A\u5B50\u5143\u7D20\u7684\u6392\u5217\u65B9\u5411</p><ul><li><code>row</code>\uFF08\u9ED8\u8BA4\uFF09\uFF1A\u6240\u6709<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u4ECE\u5DE6\u5230\u53F3\u6392\u5217</li><li><code>row-reverse</code>\uFF1A\u6240\u6709<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u4ECE\u53F3\u5230\u5DE6\u6392\u5217</li><li><code>column</code>\uFF1A\u6240\u6709(<code>\u9879\u76EE\u5B50\u5143\u7D20)</code>\u4ECE\u4E0A\u5230\u4E0B\u6392\u5217</li><li><code>column-reverse</code>\uFF1A\u6240\u6709<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u4ECE\u4E0B\u5230\u4E0A\u6392\u5217</li></ul><p>\u793A\u4F8B\u4EE3\u7801\u5982\u4E0B\uFF0C\u5E03\u5C40\u6837\u5F0F\u53D8\u4E3A9\u81F31\u4ECE\u5DE6\u5230\u53F3\u6392\u5217\uFF0C\u4E14\u5BBD\u5EA6\u7B49\u6BD4\u7F29\u653E</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">flex-practise</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">height</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0B\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">display</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">flex-direction</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> row-reverse</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0A\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><p><img${serverRenderer.ssrRenderAttr("src", _imports_2)} alt="image-20220424150335938"></p><h2 id="flex-wrap" tabindex="-1">flex-wrap <a class="header-anchor" href="#flex-wrap" aria-hidden="true">#</a></h2><p>\u4E4B\u524D\u6211\u4EEC\u77E5\u9053\u4E86\uFF1Aflex\u5E03\u5C40\u4E0B\u7684\u6240\u6709<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u9ED8\u8BA4\u6392\u5728\u4E00\u884C\uFF0C\u6240\u6709<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u7684\u5BBD\u5EA6\u4E4B\u548C\u8D85\u8FC7\u7236\u5143\u7D20\u4E5F\u4E0D\u6362\u884C\uFF0C\u800C\u662F\u6309\u6BD4\u4F8B\u7F29\u5C0F\u6240\u6709<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u5BBD\u5EA6</p><p>\u5982\u679C\u5E0C\u671B\u6240\u6709<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u7684\u5BBD\u5EA6\u4E4B\u548C\u8D85\u8FC7\u7236\u5143\u7D20\u540E\u6362\u884C\uFF0C\u9700\u8981\u8BBE\u7F6E<code>flex-wrap</code></p><ul><li><code>nowrap</code>\uFF08\u9ED8\u8BA4\uFF09\uFF1A\u4E0D\u6362\u884C</li><li><code>wrap</code>\uFF1A\u6362\u884C</li><li><code>wrap-reverse</code>\uFF1A\u6362\u884C\uFF0C<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u4ECE\u4E0B\u5230\u4E0A\u6392\u5217\uFF0C\u5373\u7B2C\u4E00\u884C\u5728\u6700\u4E0B\u65B9\uFF0C\u7B2C\u4E8C\u884C\u5728\u7B2C\u4E00\u884C\u4E0A\u65B9</li></ul><p>\u793A\u4F8B\u4EE3\u7801\u5982\u4E0B\uFF0C\u5E03\u5C40\u6837\u5F0F\u53D8\u4E3A3*3\uFF0C\u4E14\u4ECE\u53F3\u5230\u5DE6\u6392\u5217</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">flex-practise</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">height</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0B\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">display</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">flex-direction</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> row-reverse</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">flex-wrap</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> wrap</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0A\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><p><img${serverRenderer.ssrRenderAttr("src", _imports_3)} alt="image-20220424150638671"></p><h2 id="flex-flow" tabindex="-1">flex-flow <a class="header-anchor" href="#flex-flow" aria-hidden="true">#</a></h2><p>flex-flow\u5C5E\u6027\u662F<code>flex-direction</code>\u5C5E\u6027\u548C<code>flex-wrap</code>\u5C5E\u6027\u7684\u7B80\u5199\u5F62\u5F0F</p><p>\u9ED8\u8BA4\u503C\u4E3A<code>row</code> <code>nowrap</code>\uFF0C\u5373\u6240\u6709<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u4ECE\u5DE6\u5230\u53F3\u6392\u5217\u4E14\u4E0D\u6362\u884C</p><p>\u793A\u4F8B\u4EE3\u7801\u5982\u4E0B\uFF0C\u5E03\u5C40\u6837\u5F0F\u53D8\u4E3A3*3\uFF0C\u4E14\u4ECE\u53F3\u5230\u5DE6\u6392\u5217\uFF0C\u540C\u4E0A\u65B9\u7B49\u4EF7</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">flex-practise</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">height</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0B\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">display</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">flex-flow</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> row-reverse wrap</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0A\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><h2 id="justify-content" tabindex="-1">justify-content <a class="header-anchor" href="#justify-content" aria-hidden="true">#</a></h2><p>\u6240\u6709<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u5728\u8BBE\u7F6Eflex\u5E03\u5C40\u7684\u7236\u5143\u7D20(<code>flex\u5BB9\u5668</code>)\u4E2D\u6A2A\u5411\u7684\u4F4D\u7F6E\uFF08\u6240\u6709<code>\u9879\u76EE(\u5B50\u5143\u7D20)</code>\u7684\u5BBD\u5EA6\u4E4B\u548C\u53EA\u5360\u7236\u5143\u7D20(<code>flex\u5BB9\u5668</code>)\u5BBD\u5EA6\u4E00\u90E8\u5206\u7684\u60C5\u51B5\u4E0B\uFF09</p><ul><li><code>flex-start\uFF08\u9ED8\u8BA4\uFF09</code>\uFF1A\u5C45\u5DE6</li><li><code>flex-end</code>\uFF1A\u5C45\u53F3</li><li><code>center</code>\uFF1A \u5C45\u4E2D</li><li><code>space-between</code>\uFF1A\u4E24\u7AEF\u5BF9\u9F50\uFF0C\u5B50\u5143\u7D20\u4E4B\u95F4\u7684\u95F4\u9694\u90FD\u76F8\u7B49</li><li><code>space-around</code>\uFF1A\u5B50\u5143\u7D20\u4E24\u4FA7\u7684\u95F4\u9694\u76F8\u7B49\u3002\u6240\u4EE5\u6700\u5DE6\u8FB9\u548C\u6700\u53F3\u8FB9\u5B50\u5143\u7D20\u79BB\u8FB9\u7684\u95F4\u9694\u53EA\u6709\u5B50\u5143\u7D20\u4E4B\u95F4\u95F4\u9694\u7684\u4E00\u534A</li></ul><p>\u4E3A\u4E86\u770B\u5230\u6548\u679C\uFF0C\u4FEE\u6539item\u7684width\u4E3A20%</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">item</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">20%</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> ...</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span></span>
<span class="line"></span></code></pre></div><p>\u793A\u4F8B\u4EE3\u7801\u5982\u4E0B\uFF0C\u5E03\u5C40\u6837\u5F0F\u53D8\u4E3A\u5728<code>\u6A2A\u5411\u4E0A</code>\u5C45\u4E2D\u6392\u5217</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">flex-practise</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">height</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">background-color</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">eeeeee</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0B\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">display</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">flex-wrap</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> wrap</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">justify-content</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> center</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0A\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><p><img${serverRenderer.ssrRenderAttr("src", _imports_4)} alt="image-20220424152437332"></p><p>\u540C\u65F6\u5BF9<code>justify-content</code>\u548C<code>flex-direction</code>\u8BBE\u7F6E\uFF0C\u793A\u4F8B\u4EE3\u7801\u5982\u4E0B\uFF0C</p><p><code>justify-content: flex-end;</code>\u7531<code>\u5C45\u53F3</code>\u53D8\u6210<code>\u5C45\u5DE6</code>\uFF0C\u53EF\u89C1<code>justify-content</code>\u53D7<code>flex-direction</code>\u5F71\u54CD</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">flex-practise</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">height</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">background-color</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">eeeeee</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0B\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">display</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">flex-flow</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> row-reverse wrap</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">justify-content</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex-end</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0A\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><p><img${serverRenderer.ssrRenderAttr("src", _imports_5)} alt="image-20220424152743477"></p><h2 id="align-items" tabindex="-1">align-items <a class="header-anchor" href="#align-items" aria-hidden="true">#</a></h2><p>\u5B50\u5143\u7D20\u5728\u7236\u5143\u7D20\u4E2D\u7EB5\u5411\u7684\u4F4D\u7F6E\uFF08\u5B50\u5143\u7D20\u7684\u9AD8\u5EA6\u53EA\u5360\u7236\u5143\u7D20\u9AD8\u5EA6\u4E00\u90E8\u5206\u7684\u60C5\u51B5\u4E0B\uFF09</p><p>\u4E3B\u8981\u7528\u4E8E\u5355\u884C\u5B50\u5143\u7D20\uFF0C\u4F46\u591A\u884C\u4E5F\u6709\u6548\u679C</p><p>\u5355\u884C\u6548\u679C\u5982\u4E0B</p><ul><li><code>flex-start</code>\uFF1A\uFF1A\u5C45\u4E0A</li><li><code>flex-end</code>\uFF1A\u5C45\u4E0B</li><li><code>center</code>\uFF1A\u5C45\u4E2D</li><li><code>baseline</code>: \u5B50\u5143\u7D20\u7684\u7B2C\u4E00\u884C\u6587\u5B57\u7684\u57FA\u7EBF\u5BF9\u9F50</li><li><code>stretch\uFF08\u9ED8\u8BA4\uFF09</code>\uFF1A\u5982\u679C\u5B50\u5143\u7D20\u672A\u8BBE\u7F6E\u9AD8\u5EA6\u6216\u8BBE\u4E3Aauto\uFF0C\u5C06\u5360\u6EE1\u6574\u4E2A\u5BB9\u5668\u7684\u9AD8\u5EA6</li></ul><p>\u591A\u884C\u6548\u679C\u5982\u4E0B</p><ul><li><code>flex-start</code>\uFF1A\uFF1A\u6BCF\u884C\u4E0B\u65B9\u95F4\u9694\u76F8\u7B49</li><li><code>flex-end</code>\uFF1A\u6BCF\u884C\u4E0A\u65B9\u95F4\u9694\u76F8\u7B49</li><li><code>center</code>\uFF1A\u6BCF\u884C\u4E0A\u4E0B\u95F4\u9694\u76F8\u7B49\uFF0C\u6240\u4EE5\u6700\u4E0A\u8FB9\u884C\u548C\u6700\u4E0B\u8FB9\u884C\u79BB\u8FB9\u7684\u95F4\u9694\u53EA\u6709\u6BCF\u884C\u95F4\u9694\u7684\u4E00\u534A</li><li><code>baseline</code>: \u5B50\u5143\u7D20\u7684\u6BCF\u4E00\u884C\u6587\u5B57\u7684\u57FA\u7EBF\u5BF9\u9F50</li><li><code>stretch\uFF08\u9ED8\u8BA4\uFF09</code>\uFF1A\u6BCF\u884C\u4E0B\u65B9\u95F4\u9694\u4E00\u6837</li></ul><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>\u7236\u5143\u7D20\u6CA1\u6709\u56FA\u5B9A\u9AD8\u5EA6\uFF0C\u4E14\u6CA1\u6709\u8BBE\u7F6E<code>align-items</code>\uFF0C\u5373<code>align-items</code>\u503C\u4E3A<code>stretch\uFF08\u9ED8\u8BA4\uFF09</code>\uFF0C\u5219\u7236\u5143\u7D20\u9AD8\u5EA6\u7531\u6700\u9AD8\u5B50\u5143\u7D20\u51B3\u5B9A</p><p>\u7236\u5143\u7D20\u8BBE\u7F6E<code>align-items:center</code>\u540E\uFF0C\u5B50\u5143\u7D20\u7684\u9AD8\u5EA6\uFF0C\u7531\u81EA\u8EAB\u5185\u5BB9\u51B3\u5B9A\uFF0C\u6B64\u65F6\u518D\u4E3A\u5B50\u5143\u7D20\u8BBE\u7F6E\u9AD8\u5EA6100%\u662F\u6CA1\u6709\u4F5C\u7528\u7684</p><p>\u8FD9\u4E00\u70B9\u5E38\u89C1\u4E8E\u8BBE\u7F6E\u8868\u683C\u6837\u5F0F</p></div><p>\u5355\u884C\u60C5\u51B5\uFF0C\u793A\u4F8B\u4EE3\u7801\u4E0E\u6837\u5F0F\u5982\u4E0B</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">flex-practise</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">height</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">background-color</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">eeeeee</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0B\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">display</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">align-items</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex-end</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0A\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><p><img${serverRenderer.ssrRenderAttr("src", _imports_6)} alt="image-20220424153015665"></p><p>\u591A\u884C\u60C5\u51B5\uFF0C\u793A\u4F8B\u4EE3\u7801\u4E0E\u6837\u5F0F\u5982\u4E0B\uFF0C\u6BCF\u884C\u4E0A\u65B9\u95F4\u9694\u76F8\u7B49</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">flex-practise</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">height</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">background-color</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">eeeeee</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0B\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">display</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">align-items</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex-end</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0A\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><p><img${serverRenderer.ssrRenderAttr("src", _imports_7)} alt="image-20220424153106761"></p><h2 id="align-content" tabindex="-1">align-content <a class="header-anchor" href="#align-content" aria-hidden="true">#</a></h2><p><code>\u591A\u884C\u5B50\u5143\u7D20</code>\u5728\u7236\u5143\u7D20\u4E2D\u7EB5\u5411\u7684\u4F4D\u7F6E</p><p><strong><code>\u5982\u679C\u53EA\u6709\u4E00\u884C\uFF0C\u8BE5\u5C5E\u6027\u4E0D\u8D77\u4F5C\u7528</code></strong></p><p><code>\u591A\u884C\u5B50\u5143\u7D20</code>\u60C5\u51B5\u4E0B\uFF0C\u540C\u65F6\u8BBE\u7F6E<code>align-items</code>\u548C<code>align-content</code>\uFF0C\u53EA\u6709<code>align-content</code>\u751F\u6548</p><ul><li><code>flex-start</code>\uFF1A\u5C45\u4E0A</li><li><code>flex-end</code>\uFF1A\u5C45\u4E0B</li><li><code>center</code>\uFF1A\u5C45\u4E2D\u6392\u5217</li><li><code>space-between</code>\uFF1A\u4E0A\u4E0B\u4E24\u7AEF\u5BF9\u9F50\uFF0C\u6BCF\u884C\u4E4B\u95F4\u7684\u95F4\u9694\u76F8\u7B49</li><li><code>space-around</code>\uFF1A\u6BCF\u884C\u4E0A\u4E0B\u95F4\u9694\u76F8\u7B49\uFF0C\u6240\u4EE5\u6700\u4E0A\u8FB9\u884C\u548C\u6700\u4E0B\u8FB9\u884C\u79BB\u8FB9\u7684\u95F4\u9694\u53EA\u6709\u6BCF\u884C\u95F4\u9694\u7684\u4E00\u534A</li><li><code>stretch\uFF08\u9ED8\u8BA4\u503C\uFF09</code>\uFF1A\u4E0B\u65B9\u95F4\u9694\u76F8\u7B49</li></ul><p>\u5355\u884C\u60C5\u51B5\uFF0C\u793A\u4F8B\u4EE3\u7801\u5982\u4E0B\uFF0C\u6CA1\u6709\u6548\u679C</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">flex-practise</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">height</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">background-color</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">eeeeee</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0B\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">display</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">align-content</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex-end</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0A\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><p>\u591A\u884C\u60C5\u51B5\uFF0C\u793A\u4F8B\u4EE3\u7801\u5982\u4E0B\uFF0C\u6837\u5F0F\u4E0E<code>align-items</code>\u6709\u660E\u663E\u533A\u522B\uFF0C\u662F\u628A\u591A\u884C\u5B50\u5143\u7D20\u4F5C\u4E3A\u4E00\u4E2A\u6574\u4F53</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">flex-practise</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">height</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">background-color</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">eeeeee</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0B\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">display</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">align-content</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex-end</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0A\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><p><img${serverRenderer.ssrRenderAttr("src", _imports_8)} alt="image-20220424154549761"></p><p><code>\u591A\u884C\u5B50\u5143\u7D20</code>\u60C5\u51B5\u4E0B\uFF0C\u540C\u65F6\u8BBE\u7F6E<code>align-items</code>\u548C<code>align-content</code>\uFF0C\u53EA\u6709<code>align-content</code>\u751F\u6548\uFF0C\u800C<code>\u5355\u884C\u5B50\u5143\u7D20</code>\u60C5\u51B5\u4E0B\uFF0C<code>align-content</code>\u76F4\u63A5\u65E0\u6548\uFF0C\u6545\u4E0D\u7528\u518D\u8FDB\u884C\u6BD4\u8F83</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">flex-practise</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">width</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">height</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">300px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">background-color</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">eeeeee</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0B\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">display</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">flex-wrap</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> wrap</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">align-items</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex-start</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">align-content</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex-end</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#676E95", "font-style": "italic" })}">/* \u6B64\u5904\u7684\u4E0A\u65B9\u7F16\u5199css */</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><h2 id="\u9879\u76EE-\u5B50\u5143\u7D20-\u7684\u516D\u5927\u5C5E\u6027" tabindex="-1">\u9879\u76EE(\u5B50\u5143\u7D20)\u7684\u516D\u5927\u5C5E\u6027 <a class="header-anchor" href="#\u9879\u76EE-\u5B50\u5143\u7D20-\u7684\u516D\u5927\u5C5E\u6027" aria-hidden="true">#</a></h2><ul><li><code>order</code></li><li><code>flex-grow</code></li><li><code>flex-shrink</code></li><li><code>flex-basis</code></li><li><code>flex</code></li><li><code>align-self</code></li></ul><h2 id="order" tabindex="-1">order <a class="header-anchor" href="#order" aria-hidden="true">#</a></h2><p><code>order</code>\u5C5E\u6027\u5B9A\u4E49\u9879\u76EE(\u5B50\u5143\u7D20)\u7684\u6392\u5217\u987A\u5E8F\u3002\u6570\u503C\u8D8A\u5C0F\uFF0C\u6392\u5217\u8D8A\u9760\u524D\uFF0C\u9ED8\u8BA4\u4E3A0</p><p>\u4E3A\u7B2C\u4E5D\u4E2A\u5B50\u5143\u7D20\u52A0\u4E00\u4E2Anine\u7684class</p><div class="language-html"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"><</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C792EA" })}">class</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">=</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#C3E88D" })}">item nine</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">"</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">9</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}"></</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F07178" })}">div</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">></span></span>
<span class="line"></span></code></pre></div><p>\u8BBE\u7F6E<code>order</code>\u540E\uFF0C\u6837\u5F0F\u5982\u4E0B\u53D8\u5316</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">nine</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">order</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">-1</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><p><img${serverRenderer.ssrRenderAttr("src", _imports_9)} alt="image-20220424155904034"></p><h2 id="flex-grow" tabindex="-1">flex-grow <a class="header-anchor" href="#flex-grow" aria-hidden="true">#</a></h2><p><code>flex-grow</code>\u5C5E\u6027\u5B9A\u4E49\u9879\u76EE(\u5B50\u5143\u7D20)\u7684<code>\u653E\u5927\u6BD4\u4F8B</code>\uFF0C\u9ED8\u8BA4\u4E3A<code>0</code>\uFF0C\u5373\u5982\u679C\u5B58\u5728\u5269\u4F59\u7A7A\u95F4\uFF0C\u4E5F\u4E0D\u653E\u5927</p><p>\u5982\u679C\u6240\u6709\u9879\u76EE(\u5B50\u5143\u7D20)\u7684flex-grow\u5C5E\u6027\u90FD\u4E3A<code>1</code>\uFF0C\u5219\u5B83\u4EEC\u5C06\u7B49\u5206\u7236\u5143\u7D20\u5269\u4F59\u7A7A\u95F4\uFF08\u5982\u679C\u6709\u7684\u8BDD\uFF09\u3002\u5982\u679C\u4E00\u4E2A\u9879\u76EE(\u5B50\u5143\u7D20)\u7684flex-grow\u5C5E\u6027\u4E3A<code>2</code>\uFF0C\u5176\u4ED6\u9879\u76EE(\u5B50\u5143\u7D20)\u90FD\u4E3A<code>1</code>\uFF0C\u5219\u524D\u8005\u5360\u636E\u7684\u5269\u4F59\u7A7A\u95F4\u5C06\u6BD4\u5176\u4ED6\u9879<code>\u591A\u4E00\u500D</code></p><p>\u4E3A\u9879\u76EE(\u5B50\u5143\u7D20)\u8BBE\u7F6E<code>flex-grow: 1;</code>\u540E\uFF0C\u6837\u5F0F\u4E3A</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">item</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">flex-grow</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">1</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> ...</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><p><img${serverRenderer.ssrRenderAttr("src", _imports_10)} alt="image-20220424160214451"></p><h2 id="flex-shrink" tabindex="-1">flex-shrink <a class="header-anchor" href="#flex-shrink" aria-hidden="true">#</a></h2><p><code>flex-shrink</code>\u5C5E\u6027\u5B9A\u4E49\u4E86\u9879\u76EE(\u5B50\u5143\u7D20)\u7684<code>\u7F29\u5C0F\u6BD4\u4F8B</code>\uFF0C\u9ED8\u8BA4\u4E3A<code>1</code>\uFF0C\u5373\u5982\u679C\u7A7A\u95F4\u4E0D\u8DB3\uFF0C\u8BE5\u9879\u76EE(\u5B50\u5143\u7D20)\u5C06\u7F29\u5C0F</p><p>\u5373\u4F7F\u4E3A\u9879\u76EE(\u5B50\u5143\u7D20)\u8BBE\u7F6E\u4E86<code>\u56FA\u5B9A\u5BBD\u5EA6</code>\uFF0C\u5982\u679C\u7236\u5143\u7D20\u5BBD\u5EA6\u5C0F\u4E8E\u5404\u9879\u76EE(\u5B50\u5143\u7D20)\u4E4B\u548C\uFF0C\u8FD8\u662F\u4F1A\u7B49\u6BD4\u4F8B\u7F29\u5C0F\u5404\u9879\u76EE(\u5B50\u5143\u7D20)</p><p>\u6240\u4EE5\u5982\u679C\u4E0D\u60F3\u5BBD\u5EA6\u88AB\u7F29\u5C0F\uFF0C\u9700\u8981\u8BBE\u7F6E\u9879\u76EE(\u5B50\u5143\u7D20)<code>flex-shrink</code>\u5C5E\u6027\u4E3A<code>0</code></p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">flex-shrink</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">: 0;</span></span>
<span class="line"></span></code></pre></div><h2 id="flex-basis" tabindex="-1">flex-basis <a class="header-anchor" href="#flex-basis" aria-hidden="true">#</a></h2><p><code>flex-basis</code>\u5C5E\u6027\u5B9A\u4E49\u4E86\u5728\u5206\u914D\u591A\u4F59\u7A7A\u95F4\u4E4B\u524D\uFF0C\u9879\u76EE(\u5B50\u5143\u7D20)\u5360\u636E\u7684\u4E3B\u8F74\u7A7A\u95F4\uFF08main size\uFF09\u3002\u6D4F\u89C8\u5668\u6839\u636E\u8FD9\u4E2A\u5C5E\u6027\uFF0C\u8BA1\u7B97\u4E3B\u8F74\u662F\u5426\u6709\u591A\u4F59\u7A7A\u95F4\u3002</p><p>\u5B83\u7684\u9ED8\u8BA4\u503C\u4E3A<code>auto</code>\uFF0C\u5373\u9879\u76EE\u7684\u672C\u6765\u5927\u5C0F</p><p>\u5B83\u53EF\u4EE5\u8BBE\u4E3A\u8DDF<code>width</code>\u5C5E\u6027\u4E00\u6837\u7684\u503C\uFF08\u6BD4\u5982100px\uFF09\uFF0C\u5219\u9879\u76EE\u5C06\u5360\u636E\u56FA\u5B9A\u7A7A\u95F4\uFF0C\u5373\u5B83\u4E0D\u53D7<code>flex-shrink:1</code>\u7684\u5F71\u54CD</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">nine</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">flex-basis</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">100px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><p><img${serverRenderer.ssrRenderAttr("src", _imports_11)} alt="image-20220424165207527"></p><h2 id="flex-1" tabindex="-1">flex <a class="header-anchor" href="#flex-1" aria-hidden="true">#</a></h2><p><code>flex</code>\u5C5E\u6027\u662F<code>flex-grow</code>, <code>flex-shrink</code> \u548C <code>flex-basis</code>\u7684\u7B80\u5199\uFF0C\u9ED8\u8BA4\u503C\u4E3A<code>0 1 auto</code>\uFF0C\u4E5F\u5C31\u662F\u4E09\u4E2A\u5C5E\u6027\u7684\u9ED8\u8BA4\u503C\uFF0C<code>\u540E\u4E24\u4E2A\u5C5E\u6027\u53EF\u9009</code></p><p>\u6BD4\u8F83\u5E38\u89C1\u7684\u662F<code>flex: 1 </code>\uFF0C\u5176\u76F8\u5F53\u4E8E<code>1 1 0%</code>\uFF0C\u5373\u7B49\u5206\u7236\u5143\u7D20\u5269\u4F59\u7A7A\u95F4\uFF0C\u7B49\u6BD4\u4F8B\u7F29\u5C0F\uFF0C\u4E0D\u5360\u636E\u56FA\u5B9A\u7A7A\u95F4</p><p>\u6240\u4EE5<code>flex: 1 </code>\u540E\uFF0C\u5373\u4F7F\u7236\u5143\u7D20\u8BBE\u7F6E<code>flex:wrap</code>\uFF0C\u6240\u6709\u9879\u76EE\u8FD8\u662F\u5904\u4E8E\u4E00\u884C\uFF0C\u4E14\u4F1A\u7B49\u6BD4\u4F8B\u7F29\u5C0F\uFF0C\u5373\u4F7F\u4E3A\u9879\u76EE(\u5B50\u5143\u7D20)\u8BBE\u7F6E\u4E86<code>\u56FA\u5B9A\u5BBD\u5EA6</code>\uFF0C\u8FD8\u662F\u4F1A\u7F29\u5C0F\u4E8E\u8BBE\u7F6E\u7684width\uFF0C\u56E0\u4E3A\u4E0D\u4EC5<code>flex-shrink</code>\u4E3A<code>1</code>,\u4E14 <code>flex-basis</code>\u4E3A<code>0%</code></p><p>\u5982\u679C\u4F7F\u7528flex\u5C5E\u6027\uFF0C\u4FEE\u6539\u7B2C\u4E09\u4E2A\u53C2\u6570<code>flex-basis</code>\u7684\u503C\u5373\u53EF\u8BBE\u7F6E<code>\u6700\u5C0F\u56FA\u5B9A\u5BBD\u5EA6</code>\uFF0C\u4E14\u65E0\u9700\u518D\u8BBE\u7F6E\u5BBD</p><p>\u793A\u4F8B\u4EE3\u7801\uFF0C\u5219\u7B49\u5206\u7236\u5143\u7D20\u5269\u4F59\u7A7A\u95F4\uFF0C\u7B49\u6BD4\u4F8B\u7F29\u5C0F\u4F46\u5BBD\u5EA6\u6700\u5C0F\u4E3A\u7236\u5143\u7D2050%</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">.</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">item</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">{</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">1</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">1</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">50%</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">color</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">ffffff</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">display</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> flex</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">justify-content</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> center</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">align-items</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> center</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">font-size</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">30px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">background-color</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">000000</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">border</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">1px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> solid </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">#</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">fff</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">box-sizing</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> border-box</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#B2CCD6" })}">border-radius</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">:</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#F78C6C" })}">15px</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}"> </span><span style="${serverRenderer.ssrRenderStyle({ "color": "#89DDFF" })}">}</span></span>
<span class="line"></span></code></pre></div><p><img${serverRenderer.ssrRenderAttr("src", _imports_12)} alt="image-20220424174654646"></p><h2 id="align-self" tabindex="-1">align-self <a class="header-anchor" href="#align-self" aria-hidden="true">#</a></h2><p><code>align-self</code>\u5C5E\u6027\u5141\u8BB8\u5355\u4E2A\u9879\u76EE\u6709\u4E0E\u5176\u4ED6\u9879\u76EE\u4E0D\u4E00\u6837\u7684\u5BF9\u9F50\u65B9\u5F0F\uFF0C\u53EF\u8986\u76D6<code>align-items</code>\u5C5E\u6027\u3002\u9ED8\u8BA4\u503C\u4E3A<code>auto</code>\uFF0C\u8868\u793A\u7EE7\u627F\u7236\u5143\u7D20\u7684<code>align-items</code>\u5C5E\u6027\uFF0C\u5982\u679C\u6CA1\u6709\u7236\u5143\u7D20\uFF0C\u5219\u7B49\u540C\u4E8E<code>stretch</code>\u3002</p><ul><li>auto\uFF08\u9ED8\u8BA4\u503C\uFF09</li><li>flex-start</li><li>flex-end</li><li>center</li><li>baseline</li><li>stretch</li></ul><h2 id="\u5782\u76F4\u5C45\u4E2D" tabindex="-1">\u5782\u76F4\u5C45\u4E2D <a class="header-anchor" href="#\u5782\u76F4\u5C45\u4E2D" aria-hidden="true">#</a></h2><p>\u975E\u5E38\u5E38\u7528\u7684flex\u8BED\u6CD5</p><div class="language-css"><pre><code><span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">display: flex;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">align-items</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">: center;</span></span>
<span class="line"><span style="${serverRenderer.ssrRenderStyle({ "color": "#FFCB6B" })}">justify-content</span><span style="${serverRenderer.ssrRenderStyle({ "color": "#A6ACCD" })}">: center;</span></span>
<span class="line"></span></code></pre></div></div>`);
}
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
const ssrContext = vue.useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("notes/1.basic/2.css/2.flex.md");
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
var _2_flex = /* @__PURE__ */ pluginVue_exportHelper._export_sfc(_sfc_main, [["ssrRender", _sfc_ssrRender]]);
exports.__pageData = __pageData;
exports["default"] = _2_flex;
| 493.686567 | 3,090 | 0.682841 |
4698788b4793ab67338aa1de9cc6422389b915b8 | 34 | js | JavaScript | assets/grocery_crud/js/jquery_plugins/config/localized/inject.local.x-pseudo.js | celfons/ci_boostrap_3 | 112c6d5dd203245f710b412f716a8aa26338d091 | [
"MIT"
] | 1 | 2020-03-20T13:47:57.000Z | 2020-03-20T13:47:57.000Z | assets/grocery_crud/js/jquery_plugins/config/localized/inject.local.x-pseudo.js | celfons/ci_boostrap_3 | 112c6d5dd203245f710b412f716a8aa26338d091 | [
"MIT"
] | null | null | null | assets/grocery_crud/js/jquery_plugins/config/localized/inject.local.x-pseudo.js | celfons/ci_boostrap_3 | 112c6d5dd203245f710b412f716a8aa26338d091 | [
"MIT"
] | 2 | 2020-03-31T19:49:46.000Z | 2020-07-07T13:13:02.000Z | var ciLocaleOverride = "x-pseudo"
| 17 | 33 | 0.764706 |
4698951b35e1c146b362812960a34606c953750d | 803 | js | JavaScript | src/components/ItemPerks/index.js | infininight/destinySets | ab93cb17878aa2fc7ecbbda090f0b6e8839897ad | [
"MIT"
] | 147 | 2017-01-07T22:59:48.000Z | 2022-02-15T07:00:43.000Z | src/components/ItemPerks/index.js | infininight/destinySets | ab93cb17878aa2fc7ecbbda090f0b6e8839897ad | [
"MIT"
] | 208 | 2017-10-03T23:28:32.000Z | 2022-03-08T22:41:50.000Z | src/components/ItemPerks/index.js | infininight/destinySets | ab93cb17878aa2fc7ecbbda090f0b6e8839897ad | [
"MIT"
] | 45 | 2017-01-02T03:32:27.000Z | 2022-03-08T16:21:13.000Z | import React from 'react';
import BungieImage from 'app/components/BungieImage';
import s from './styles.styl';
export default function ItemPerks({ perks, className }) {
return (
<div className={className}>
{perks &&
perks.map(perk => (
<div key={perk.hash} className={s.perk}>
<div className={s.accessory}>
<BungieImage
className={s.perkImage}
src={perk.displayProperties.icon}
/>
</div>
<div className={s.main}>
<div className={s.name}>{perk.displayProperties.name}</div>
<div className={s.description}>
{perk.displayProperties.description}
</div>
</div>
</div>
))}
</div>
);
}
| 26.766667 | 73 | 0.516812 |
46990d1ff7dc75dc276a5b166305fac99014c0c1 | 798 | js | JavaScript | eshop/definitions/auth.js | tonyshark1/cms | 2311d100dd064614b76a221916079cf1272410f1 | [
"MIT"
] | null | null | null | eshop/definitions/auth.js | tonyshark1/cms | 2311d100dd064614b76a221916079cf1272410f1 | [
"MIT"
] | null | null | null | eshop/definitions/auth.js | tonyshark1/cms | 2311d100dd064614b76a221916079cf1272410f1 | [
"MIT"
] | null | null | null | // A protection for multiple sign-in
var protection = {};
// Simple auth for administration
F.on('controller', function(controller, name) {
if (!controller.url.startsWith(CONFIG('manager-url'), true))
return;
// Checks protection
if (protection[controller.req.ip] > 10) {
controller.throw401();
controller.cancel();
return;
}
var user = F.config.custom.users[U.parseInt(controller.req.cookie('__manager'))];
if (user) {
controller.req.user = user;
return;
}
if (!protection[controller.req.ip])
protection[controller.req.ip] = 1;
else
protection[controller.req.ip]++;
controller.cancel();
controller.theme('');
controller.view('manager-login');
});
// Clears blocked IP addreses
F.on('service', function(interval) {
if (interval % 30 === 0)
protection = {};
}); | 21.567568 | 82 | 0.682957 |
469923152ab5d1668586e1fdc51ca049d00fd72f | 6,728 | js | JavaScript | app/client/cypress/integration/Smoke_TestSuite/Application/ImportExportForkApplication_spec.js | patevs/appsmith | f26aec77d6cdfc5350200899bede742c55233b8b | [
"Apache-2.0"
] | 1 | 2022-01-24T08:20:05.000Z | 2022-01-24T08:20:05.000Z | app/client/cypress/integration/Smoke_TestSuite/Application/ImportExportForkApplication_spec.js | patevs/appsmith | f26aec77d6cdfc5350200899bede742c55233b8b | [
"Apache-2.0"
] | null | null | null | app/client/cypress/integration/Smoke_TestSuite/Application/ImportExportForkApplication_spec.js | patevs/appsmith | f26aec77d6cdfc5350200899bede742c55233b8b | [
"Apache-2.0"
] | null | null | null | const homePage = require("../../../locators/HomePage");
const reconnectDatasourceModal = require("../../../locators/ReconnectLocators");
describe("Import, Export and Fork application and validate data binding", function() {
let workspaceId;
let appid;
let newWorkspaceName;
let appName;
it("Import application from json and validate data on pageload", function() {
// import application
cy.get(homePage.homeIcon).click();
cy.get(homePage.optionsIcon)
.first()
.click();
cy.get(homePage.workspaceImportAppOption).click({ force: true });
cy.get(homePage.workspaceImportAppModal).should("be.visible");
cy.xpath(homePage.uploadLogo).attachFile("forkedApp.json");
cy.get(homePage.importAppProgressWrapper).should("be.visible");
cy.wait("@importNewApplication").then((interception) => {
cy.wait(100);
// should check reconnect modal openning
const { isPartialImport } = interception.response.body.data;
if (isPartialImport) {
// should reconnect button
cy.get(reconnectDatasourceModal.Modal).should("be.visible");
cy.get(reconnectDatasourceModal.SkipToAppBtn).click({ force: true });
cy.wait(2000);
} else {
cy.get(homePage.toastMessage).should(
"contain",
"Application imported successfully",
);
}
const uuid = () => Cypress._.random(0, 1e4);
const name = uuid();
appName = `app${name}`;
cy.get(homePage.applicationName).click({ force: true });
cy.get(`${homePage.applicationEditMenu} li:first-child a`).click({
force: true,
});
cy.wait(2000);
cy.get(homePage.applicationName)
.clear()
.type(appName);
cy.wrap(appName).as("appname");
cy.wait(2000);
// validating data binding for the imported application
cy.xpath("//input[@value='Submit']").should("be.visible");
cy.xpath("//span[text()='schema_name']").should("be.visible");
cy.xpath("//span[text()='id']").should("be.visible");
cy.xpath("//span[text()='title']").should("be.visible");
cy.xpath("//span[text()='due']").should("be.visible");
});
});
it("Fork application and validate data binding for the widgets", function() {
// fork application
cy.get(homePage.homeIcon).click();
cy.get(homePage.searchInput).type(`${appName}`);
cy.wait(2000);
cy.get(homePage.applicationCard)
.first()
.trigger("mouseover");
cy.get(homePage.appMoreIcon)
.first()
.click({ force: true });
cy.get(homePage.forkAppFromMenu).click({ force: true });
cy.get(homePage.forkAppWorkspaceButton).click({ force: true });
cy.wait(4000);
// validating data binding for the forked application
cy.xpath("//input[@value='Submit']").should("be.visible");
cy.xpath("//span[text()='schema_name']").should("be.visible");
cy.xpath("//span[text()='id']").should("be.visible");
cy.xpath("//span[text()='title']").should("be.visible");
cy.xpath("//span[text()='due']").should("be.visible");
});
it("Export and import application and validate data binding for the widgets", function() {
cy.NavigateToHome();
cy.get(homePage.searchInput)
.clear()
.type(`${appName}`);
cy.wait(2000);
cy.get(homePage.applicationCard)
.first()
.trigger("mouseover");
cy.get(homePage.appMoreIcon)
.first()
.click({ force: true });
// export application
cy.get(homePage.exportAppFromMenu).click({ force: true });
cy.get(homePage.searchInput).clear();
cy.get(`a[id=t--export-app-link]`).then((anchor) => {
const url = anchor.prop("href");
cy.request(url).then(({ body, headers }) => {
expect(headers).to.have.property("content-type", "application/json");
expect(headers).to.have.property(
"content-disposition",
`attachment; filename*=UTF-8''${appName}.json`,
);
cy.writeFile("cypress/fixtures/exportedApp.json", body, "utf-8");
cy.generateUUID().then((uid) => {
workspaceId = uid;
localStorage.setItem("OrgName", workspaceId);
cy.createWorkspace();
cy.wait("@createWorkspace").then((createWorkspaceInterception) => {
newWorkspaceName =
createWorkspaceInterception.response.body.data.name;
cy.renameWorkspace(newWorkspaceName, workspaceId);
cy.get(homePage.workspaceImportAppOption).click({ force: true });
cy.get(homePage.workspaceImportAppModal).should("be.visible");
// cy.get(".t--import-json-card input").attachFile("exportedApp.json");
cy.xpath(homePage.uploadLogo).attachFile("exportedApp.json");
// import exported application in new workspace
// cy.get(homePage.workspaceImportAppButton).click({ force: true });
cy.wait("@importNewApplication").then((interception) => {
const { isPartialImport } = interception.response.body.data;
if (isPartialImport) {
// should reconnect button
cy.get(reconnectDatasourceModal.Modal).should("be.visible");
cy.get(reconnectDatasourceModal.SkipToAppBtn).click({
force: true,
});
cy.wait(2000);
} else {
cy.get(homePage.toastMessage).should(
"contain",
"Application imported successfully",
);
}
const importedApp = interception.response.body.data.application;
const appSlug = importedApp.slug;
cy.wait("@getPagesForCreateApp").then((interception) => {
const pages = interception.response.body.data.pages;
let defaultPage = pages.find(
(eachPage) => !!eachPage.isDefault,
);
// validating data binding for imported application
cy.xpath("//input[@value='Submit']").should("be.visible");
cy.xpath("//span[text()='schema_name']").should("be.visible");
// cy.xpath("//span[text()='information_schema']").should(
// "be.visible",
// );
cy.xpath("//span[text()='id']").should("be.visible");
cy.xpath("//span[text()='title']").should("be.visible");
cy.xpath("//span[text()='due']").should("be.visible");
cy.url().should(
"include",
`/${appSlug}/${defaultPage.slug}-${defaultPage.id}/edit`,
);
});
});
});
});
});
});
});
});
| 41.78882 | 92 | 0.582194 |
46992d52a101e72b5a1cd7add280a2be8797dc12 | 5,691 | js | JavaScript | node_modules/ajv/lib/async.js | andela-mbabalola/contact-manager | b6730670027514d469c6e333c21aa36b89cb544c | [
"MIT"
] | null | null | null | node_modules/ajv/lib/async.js | andela-mbabalola/contact-manager | b6730670027514d469c6e333c21aa36b89cb544c | [
"MIT"
] | null | null | null | node_modules/ajv/lib/async.js | andela-mbabalola/contact-manager | b6730670027514d469c6e333c21aa36b89cb544c | [
"MIT"
] | null | null | null | 'use strict';
module.exports = {
setup: setupAsync,
compile: compileAsync
};
var util = require('./compile/util');
var ASYNC = {
'*': checkGenerators,
'co*': checkGenerators,
'es7': checkAsyncFunction
};
var TRANSPILE = {
'nodent': getNodent,
'regenerator': getRegenerator
};
var MODES = [
{ async: 'co*' },
{ async: 'es7', transpile: 'nodent' },
{ async: 'co*', transpile: 'regenerator' }
];
var regenerator, nodent;
function setupAsync(opts, required) {
if (required !== false) required = true;
var async = opts.async
, transpile = opts.transpile
, check;
switch (typeof transpile) {
case 'string':
var get = TRANSPILE[transpile];
if (!get) throw new Error('bad transpiler: ' + transpile);
return (opts._transpileFunc = get(opts, required));
case 'undefined':
case 'boolean':
if (typeof async == 'string') {
check = ASYNC[async];
if (!check) throw new Error('bad async mode: ' + async);
return (opts.transpile = check(opts, required));
}
for (var i=0; i<MODES.length; i++) {
var _opts = MODES[i];
if (setupAsync(_opts, false)) {
util.copy(_opts, opts);
return opts.transpile;
}
}
/* istanbul ignore next */
throw new Error('generators, nodent and regenerator are not available');
case 'function':
return (opts._transpileFunc = opts.transpile);
default:
throw new Error('bad transpiler: ' + transpile);
}
}
function checkGenerators(opts, required) {
/* jshint evil: true */
try {
eval('(function*(){})()');
return true;
} catch(e) {
/* istanbul ignore next */
if (required) throw new Error('generators not supported');
}
}
function checkAsyncFunction(opts, required) {
/* jshint evil: true */
try {
eval('(async function(){})()');
/* istanbul ignore next */
return true;
} catch(e) {
if (required) throw new Error('es7 async functions not supported');
}
}
function getRegenerator(opts, required) {
try {
if (!regenerator) {
regenerator = require('' + 'regenerator');
regenerator.runtime();
}
if (!opts.async || opts.async === true)
opts.async = 'es7';
return regeneratorTranspile;
} catch(e) {
/* istanbul ignore next */
if (required) throw new Error('regenerator not available');
}
}
function regeneratorTranspile(code) {
return regenerator.compile(code).code;
}
function getNodent(opts, required) {
/* jshint evil: true */
try {
if (!nodent) nodent = require('' + 'nodent')({ log: false, dontInstallRequireHook: true });
if (opts.async != 'es7') {
if (opts.async && opts.async !== true) console.warn('nodent transpiles only es7 async functions');
opts.async = 'es7';
}
return nodentTranspile;
} catch(e) {
/* istanbul ignore next */
if (required) throw new Error('nodent not available');
}
}
function nodentTranspile(code) {
return nodent.compile(code, '', { promises: true, sourcemap: false }).code;
}
/**
* Creates validating function for passed schema with asynchronous loading of missing schemas.
* `loadSchema` option should be a function that accepts schema uri and node-style callback.
* @this Ajv
* @param {Object} schema schema object
* @param {Function} callback node-style callback, it is always called with 2 parameters: error (or null) and validating function.
*/
function compileAsync(schema, callback) {
/* eslint no-shadow: 0 */
/* jshint validthis: true */
var schemaObj;
var self = this;
try {
schemaObj = this._addSchema(schema);
} catch(e) {
setTimeout(function() { callback(e); });
return;
}
if (schemaObj.validate) {
setTimeout(function() { callback(null, schemaObj.validate); });
} else {
if (typeof this._opts.loadSchema != 'function')
throw new Error('options.loadSchema should be a function');
_compileAsync(schema, callback, true);
}
function _compileAsync(schema, callback, firstCall) {
var validate;
try { validate = self.compile(schema); }
catch(e) {
if (e.missingSchema) loadMissingSchema(e);
else deferCallback(e);
return;
}
deferCallback(null, validate);
function loadMissingSchema(e) {
var ref = e.missingSchema;
if (self._refs[ref] || self._schemas[ref])
return callback(new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved'));
var _callbacks = self._loadingSchemas[ref];
if (_callbacks) {
if (typeof _callbacks == 'function')
self._loadingSchemas[ref] = [_callbacks, schemaLoaded];
else
_callbacks[_callbacks.length] = schemaLoaded;
} else {
self._loadingSchemas[ref] = schemaLoaded;
self._opts.loadSchema(ref, function (err, sch) {
var _callbacks = self._loadingSchemas[ref];
delete self._loadingSchemas[ref];
if (typeof _callbacks == 'function') {
_callbacks(err, sch);
} else {
for (var i=0; i<_callbacks.length; i++)
_callbacks[i](err, sch);
}
});
}
function schemaLoaded(err, sch) {
if (err) return callback(err);
if (!(self._refs[ref] || self._schemas[ref])) {
try {
self.addSchema(sch, ref);
} catch(e) {
callback(e);
return;
}
}
_compileAsync(schema, callback);
}
}
function deferCallback(err, validate) {
if (firstCall) setTimeout(function() { callback(err, validate); });
else return callback(err, validate);
}
}
}
| 26.469767 | 130 | 0.608153 |
46997914d2a40691cfb712812df79d907b2d77ad | 2,130 | js | JavaScript | server/game/cards/09.4-TCoH/EmissaryOfLies.js | tvdstaaij/ringteki | 7b2b1580fc52a37a5d39bf34e4672eb559585995 | [
"MIT"
] | null | null | null | server/game/cards/09.4-TCoH/EmissaryOfLies.js | tvdstaaij/ringteki | 7b2b1580fc52a37a5d39bf34e4672eb559585995 | [
"MIT"
] | null | null | null | server/game/cards/09.4-TCoH/EmissaryOfLies.js | tvdstaaij/ringteki | 7b2b1580fc52a37a5d39bf34e4672eb559585995 | [
"MIT"
] | null | null | null | const DrawCard = require('../../drawcard.js');
const { CardTypes } = require('../../Constants');
class EmissaryOfLies extends DrawCard {
setupCardAbilities() {
this.action({
title: 'Move a character home',
condition: context => context.source.isParticipating(),
target: {
cardType: CardTypes.Character,
cardCondition: (card, context) => card.isParticipating() && card.controller === context.player.opponent
},
handler: context => {
this.originalContext = context;
this.game.promptWithMenu(context.player.opponent, this, {
source: context.source,
activePrompt: {
menuTitle: 'Name a card',
controls: [
{ type: 'card-name', command: 'menuButton', method: 'selectCardName', name: 'card-name' }
]
}
});
}
});
}
selectCardName(player, cardName, source) {
this.game.addMessage('{0} names {1} - {2} must choose if they want to reveal their hand', player, cardName, player.opponent);
let opponent = player.opponent;
this.game.promptWithHandlerMenu(source.controller, {
choices: ['Yes', 'No'],
handlers: [() => {
let handCardNames = opponent.hand.map(card => card.name);
this.game.actions.lookAt().resolve(opponent.hand.sortBy(card => card.name), this.originalContext);
if(!handCardNames.includes(cardName)) {
this.game.actions.sendHome().resolve(this.originalContext.target, this.originalContext);
return true;
}
return true;
}, () => true],
activePromptTitle: 'Do you want to reveal your hand?',
waitingPromptTitle: 'Waiting for opponent to choose to reveal their hand or not'
});
return true;
}
}
EmissaryOfLies.id = 'emissary-of-lies';
module.exports = EmissaryOfLies;
| 41.764706 | 133 | 0.53662 |