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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b8f048e5f1d7a68e3b342af4514b2c327b9e964e | 545 | js | JavaScript | Utils/ResponseCodes.js | jfescobar18/Login-API | cfe155a412a45cbf0d4793b67bd54f1b99926042 | [
"MIT"
] | null | null | null | Utils/ResponseCodes.js | jfescobar18/Login-API | cfe155a412a45cbf0d4793b67bd54f1b99926042 | [
"MIT"
] | null | null | null | Utils/ResponseCodes.js | jfescobar18/Login-API | cfe155a412a45cbf0d4793b67bd54f1b99926042 | [
"MIT"
] | null | null | null | var ResponseCodes = {}
ResponseCodes.UserInserted = { name: "UserInserted", code: 1 };
ResponseCodes.UserNotInserted = { name: "UserNotInserted", code: 2 };
ResponseCodes.InvalidCredentials = { name: "Invalid Credentials", code: 3 };
ResponseCodes.AuthenticatedUser = { name: "Authenticated User", code: 4 };
ResponseCodes.AuthHeaderMissed = { name: "Authorization Header Missed", code: 5 };
ResponseCodes.ExpiredToken = { name: "Expired Token", code: 6 };
ResponseCodes.Hello = { name: "Hello User", code: 7 };
module.exports = ResponseCodes; | 49.545455 | 82 | 0.73211 |
b8f14a6d25fe103a449695eca000b5d843f5bb2e | 1,164 | js | JavaScript | examples/helloadaptive/clientReplica.js | cafjs/caf_sharing | 7ef6664daddbe2a00c2c8bd5f367adfd4f152b38 | [
"Apache-2.0"
] | null | null | null | examples/helloadaptive/clientReplica.js | cafjs/caf_sharing | 7ef6664daddbe2a00c2c8bd5f367adfd4f152b38 | [
"Apache-2.0"
] | 1 | 2019-12-21T01:03:00.000Z | 2019-12-21T01:03:00.000Z | examples/helloadaptive/clientReplica.js | cafjs/caf_sharing | 7ef6664daddbe2a00c2c8bd5f367adfd4f152b38 | [
"Apache-2.0"
] | null | null | null | 'use strict';
/* eslint-disable no-console */
const caf_core = require('caf_core');
const caf_comp = caf_core.caf_components;
const myUtils = caf_comp.myUtils;
const caf_cli = caf_core.caf_cli;
const util = require('util');
/* `from` CA needs to be the same as target `ca` to enable creation, i.e.,
* only owners can create CAs.
*
* With security on, we would need a token to authenticate `from`.
*
*/
const URL = 'http://root-hellosharing.vcap.me:3000/#from=foo-ca1&ca=foo-ca1';
const s = new caf_cli.Session(URL);
s.onopen = async function() {
const retryWithDelayPromise = util.promisify(myUtils.retryWithDelay);
try {
const label = await retryWithDelayPromise(async function() {
try {
return [null, await s.getLabel('whatever:').getPromise()];
} catch (err) {
return [err];
}
}, 10, 100);
console.log('Label is ' + label);
s.close();
} catch (err) {
s.close(err);
}
};
s.onclose = function(err) {
if (err) {
console.log(myUtils.errToPrettyStr(err));
process.exit(1);
}
console.log('Done OK');
};
| 27.069767 | 77 | 0.602234 |
b8f162072cf54339a750f655aa208af25b36d961 | 1,495 | js | JavaScript | projects/in-the-picture/js/main.js | OrelVaizman/Portofilo | a2ffbcf80767d65b27ed57ea12406285a1c25866 | [
"MIT"
] | null | null | null | projects/in-the-picture/js/main.js | OrelVaizman/Portofilo | a2ffbcf80767d65b27ed57ea12406285a1c25866 | [
"MIT"
] | null | null | null | projects/in-the-picture/js/main.js | OrelVaizman/Portofilo | a2ffbcf80767d65b27ed57ea12406285a1c25866 | [
"MIT"
] | null | null | null | var gQuests = [
{ id: 0, opts: ['The weekend', 'Justin Bieber'], correctOptIndex: 0 },
{ id: 1, opts: ['Lil Uzi', 'Drake'], correctOptIndex: 1 },
{ id: 2, opts: ['Young MA', 'Bobby Shmurda'], correctOptIndex: 1 },
{ id: 3, opts: ['Travis Scott', 'Juice-WRLD'], correctOptIndex: 0 },
]
var isVictory = false;
var gCurrQuestIdx = 0;
function init() {
renderBoard(gQuests)
}
function onAnswerClick(chosenAnswer,) {
var elBtn = document.querySelector('.number' + (chosenAnswer));
if (chosenAnswer !== gQuests[gCurrQuestIdx].correctOptIndex) {
elBtn.style.backgroundColor = 'red';
} else {
elBtn.style.backgroundColor = 'green';
gCurrQuestIdx++;
renderBoard(gQuests);
}
// if (gCurrQuestIdx > 3) {
// console.log(gCurrQuestIdx)
// }
}
function renderBoard(questions) {
if (gCurrQuestIdx === 4) {
return;
}
var htmlStr = '<img src="imgs/' + gCurrQuestIdx + '.jpg">';
for (var i = 0; i < questions[0].opts.length; i++) {
// console.log(questions[0].opts[i]) The question text
htmlStr += '<div onclick="onAnswerClick(' + i + ')" class="question number' + i + '">' + questions[gCurrQuestIdx].opts[i] + '</div>'
}
var elContent = document.querySelector('.content');
elContent.innerHTML = htmlStr;
}
// function isGameOver(isVictory) {
// if (gCurrQuestIdx === 4) {
// alert('You\'re the winner!');
// gCurrQuestIdx = 0;
// }
// }
dqss | 27.685185 | 140 | 0.589298 |
b8f16bd10517f9947854ceb3e5fff398adae3a18 | 3,762 | js | JavaScript | client/user_pharmacist/update_stocks/partials/scripts/add_medicine.js | yasgun/easypharma | fb929608afcf165d0b166e8d584dc186648dc397 | [
"MIT"
] | 10 | 2018-09-30T14:15:07.000Z | 2021-11-25T16:51:15.000Z | client/user_pharmacist/update_stocks/partials/scripts/add_medicine.js | yasgun/easypharma | fb929608afcf165d0b166e8d584dc186648dc397 | [
"MIT"
] | null | null | null | client/user_pharmacist/update_stocks/partials/scripts/add_medicine.js | yasgun/easypharma | fb929608afcf165d0b166e8d584dc186648dc397 | [
"MIT"
] | 1 | 2021-02-16T19:38:36.000Z | 2021-02-16T19:38:36.000Z | Template.add_medicine.onCreated(function () {
const self = this;
self.add_medicine_color = new ReactiveDict();
self.add_medicine_color.set("add_medicine_green", true);
self.add_medicine_color.set("add_medicine_yellow", false);
self.add_medicine_color.set("add_medicine_blue", false);
});
Template.add_medicine.helpers({
add_medicine_green: () => {
return Template.instance().add_medicine_color.get("add_medicine_green");
},
add_medicine_yellow: () => {
return Template.instance().add_medicine_color.get("add_medicine_yellow");
},
add_medicine_blue: () => {
return Template.instance().add_medicine_color.get("add_medicine_blue");
},
});
Template.add_medicine.events({
'submit form': function (event, template) {
event.preventDefault();
$('#submit').attr("disabled", true);
let medicine = {};
medicine.inputGeneralName = event.target.inputGeneralName.value;
medicine.inputScientificName = event.target.inputScientificName.value;
medicine.inputUnitName = event.target.inputUnitName.value;
medicine.inputSellingPrice = event.target.inputSellingPrice.value;
medicine.inputAlertLevel = event.target.inputAlertLevel.value;
medicine.inputIntakeQuantity = event.target.inputIntakeQuantity.value;
medicine.inputAmountPaid = event.target.inputAmountPaid.value;
medicine.inputReturnedQuantity = event.target.inputReturnedQuantity.value;
medicine.inputAmountReceived = event.target.inputAmountReceived.value;
if (template.add_medicine_color.get("add_medicine_green")) {
medicine.inputColor = 'green';
}
if (template.add_medicine_color.get("add_medicine_yellow")) {
medicine.inputColor = 'yellow';
}
if (template.add_medicine_color.get("add_medicine_blue")) {
medicine.inputColor = 'blue';
}
Meteor.call('add_medicine', medicine, function (error) {
$('#submit').attr("disabled", false);
if (error !== undefined) {
alert(error.reason);
console.log("error in add_medicine");
console.log(error);
} else {
event.target.inputGeneralName.value = "";
event.target.inputScientificName.value = "";
event.target.inputUnitName.value = "";
event.target.inputSellingPrice.value = "";
event.target.inputAlertLevel.value = "";
event.target.inputIntakeQuantity.value = 0;
event.target.inputAmountPaid.value = 0;
event.target.inputReturnedQuantity.value = 0;
event.target.inputAmountReceived.value = 0;
}
});
},
'click #add_medicine_green_btn': function (event, template) {
event.preventDefault();
template.add_medicine_color.set("add_medicine_green", true);
template.add_medicine_color.set("add_medicine_yellow", false);
template.add_medicine_color.set("add_medicine_blue", false);
},
'click #add_medicine_yellow_btn': function (event, template) {
event.preventDefault();
template.add_medicine_color.set("add_medicine_green", false);
template.add_medicine_color.set("add_medicine_yellow", true);
template.add_medicine_color.set("add_medicine_blue", false);
},
'click #add_medicine_blue_btn': function (event, template) {
event.preventDefault();
template.add_medicine_color.set("add_medicine_green", false);
template.add_medicine_color.set("add_medicine_yellow", false);
template.add_medicine_color.set("add_medicine_blue", true);
},
}); | 36.524272 | 82 | 0.65311 |
b8f1915398586782653bb69d8d6b127152b939c5 | 841 | js | JavaScript | resources/js/components/Expense/Components/Summary/SummaryCategory/AllSummary/Chart.js | nishanthveemarasan/expense-pro | d6689e9c5a0154808af9db302cfc281cf64967ec | [
"MIT"
] | null | null | null | resources/js/components/Expense/Components/Summary/SummaryCategory/AllSummary/Chart.js | nishanthveemarasan/expense-pro | d6689e9c5a0154808af9db302cfc281cf64967ec | [
"MIT"
] | null | null | null | resources/js/components/Expense/Components/Summary/SummaryCategory/AllSummary/Chart.js | nishanthveemarasan/expense-pro | d6689e9c5a0154808af9db302cfc281cf64967ec | [
"MIT"
] | null | null | null | import React, { useEffect, useState } from "react";
import SimplePieChart from "../../../../../../Chart/PieChart/SimplePieChart";
import { limitDemialPlaces } from "../../../../../Helper/Helper";
const Chart = ({ data }) => {
const [series, setSeries] = useState([]);
const [categories, setCategories] = useState([]);
useEffect(() => {
let series = [];
let categories = [];
Object.keys(data).forEach((key) => {
series.push(limitDemialPlaces(Math.abs(data[key].total)));
categories.push(key);
});
setSeries(series);
setCategories(categories);
}, [data]);
return (
<>
{categories.length > 0 && (
<SimplePieChart series={series} categories={categories} />
)}
</>
);
};
export default Chart;
| 31.148148 | 77 | 0.537455 |
b8f1bf7dfcf71cf4c9e93c028552f98239a847a6 | 13,011 | js | JavaScript | js/src/Itrans.js | androidpcguy/itrans | 32578dfb80e5889fd78099b2d3bcf15df0006ed0 | [
"MIT"
] | 17 | 2017-01-31T19:43:16.000Z | 2022-02-14T10:08:48.000Z | js/src/Itrans.js | androidpcguy/itrans | 32578dfb80e5889fd78099b2d3bcf15df0006ed0 | [
"MIT"
] | 5 | 2017-09-04T05:37:22.000Z | 2022-02-03T10:30:22.000Z | js/src/Itrans.js | androidpcguy/itrans | 32578dfb80e5889fd78099b2d3bcf15df0006ed0 | [
"MIT"
] | 8 | 2018-07-25T19:56:16.000Z | 2021-06-01T18:38:35.000Z | /**
* @fileoverview Convert input text tokens into Unicode output using a table driven
* conversion. The tables are loaded from a .tsv spreadsheet text file.
* @author Avinash Chopde <avinash@aczoom.com>
* @version 0.2.0
* @since 2016-10-10
*
* http://www.aczoom.com/itrans/
*/
'use strict';
/*jshint esversion: 6 */
/*jshint node: true */
/**
* Load and operate on the tables that map itrans input to Unicode output.
*
* The tables are loaded from a .tsv spreadsheet text file, that may contain Unicode
* characters.
*
* http://www.aczoom.com/itrans/
*/
/* ========================================================================== */
const {
toSafeHtml,
toHtmlCodes,
Braces,
} = require('./util');
const constants = require('./constants');
// import { constants } from "./constants.js";
const ItransTable = require('./ItransTable');
// import { ItransTable } from "./ItransTable.js";
/*
* When the Unicode names are output, we wrap them in these characters.
*/
const BRACES = constants.BRACES;
/** Reserved words: Values used in the TITLES.type column data describing row data */
const ROW_TYPE = constants.ROW_TYPE;
/** Supported output format types */
const OUTPUT_FORMAT = constants.OUTPUT_FORMAT;
/**
* Reserved words: Values used in the TITLES.unicodeName column. These rows are used
* for special processing, such as handling C1 + C2 + C2 + V consonant ligature creation,
* turning itrans on/off, etc.
* Regarding END-WORD-VOWEL: The schwa (vowel A) is not deleted in languages such as Sanskrit.
* In Hindi, there is schwa deletion. Words like "dil" in Hindi need to written with a virama
* at the end in Sanskrit to match the Hindi pronunciation.
* END-WORD-VOWEL is the row that is applied when a sequence of consonants is missing its
* ending vowel (ending dependent-vowel). For Sanskrit, the table usually defines it as the
* virama, for hindi it is defined as the schwa (DV-A).
*/
const RESERVED_NAMES = constants.RESERVED_NAMES;
/* ========================================================================== */
/**
* Itrans: The itrans processor. Convert input text to Unicode output.
*/
class Itrans {
constructor() {
/**
* This table stores all the data that drives the input to output conversion.
*/
this.itransTable = new ItransTable();
this.currentLanguage = '';
}
/**
* Prepares and loads required tables for the conversion to be done.
* @param {string} tsvString Tab-Separated-Values representing the table.
* Table size is usually small: 300 rows (== each itrans code),
* and 10 columns (== each language), but larger tables with 1000+ rows
* should not be a problem even for interative web browser execution.
*/
load(tsvString) {
this.itransTable.load(tsvString);
return this;
}
/* ======================================================================== */
/**
* Convert the input string to Unicode. Multiple output formats supported,
* UTF-8, HTML7, or even just the Unicode names corresponding to each input itrans code.
*
* @param {string} input String with itrans code tokens to convert.
* @param {string} language If a valid langauge, start of string is assumed to be
* itrans encoded text for that language. Otherwise, a language marker is necessary to
* indicate itrans encoded text, such as #sanskrit ka kha ...
* @returns {string} Returns converted text.
*/
convert(input, {language, outputFormat = OUTPUT_FORMAT.unicodeNames} = {}) {
const table = this.itransTable;
const output = []; // collect each converted letters here
let length = input.length;
// If language is a valid language, start off in itrans mode for that language
let prevLanguage = table.isLanguage(language) && language;
let inItrans = Boolean(prevLanguage);
let inConsonants = false; // track whether we are in the middle or end of consonants
let prevRow;
let prevName;
let prevType;
/**
* This function matches the next token (itrans code) in the input to a ItransTable row.
* The row provides the replacement text for that input token.
*
* If there were no consonants in the table, then this function simply needs to:
* 1: output the replacement text for each itrans codeword. If not in itrans text
* section, then output the input text unchanged.
*
* Any row that has ROW_TYPE of consonants requires special processing, and depending
* on the previous and subsequent characters in the input, it may have to:
* 2: Output the default ending vowel for consonants, in the END-WORD-VOWEL row, and then
* do #1 above.
* 3: Output the CONSONANTS-JOINER or NO-LIGATURE, and then do #1 above.
*
* Option 2 kicks in if previous character was a consonant and the next one is not
* a dependent-vowel. Each consonant must end in a vowel, so if one is not present in
* the input, have to output the END-WORD-VOWEL.
*
* Option 3 kicks in if previous and next characters are consonants, so we are in the
* middle of two consonants. [NUKTA is special - it modifies previous consonant, but
* we still stay in the state of being in midst of a consonants sequence.]
* When in the middle of two consonants, we have to output the CONSONANTS-JOINER
* (unless the previous character was NO-LIGATURE), and then do #1 above too.
*
* Additionally, certain tokens in the input will be skipped and don't produce any
* output on their own.
* _ (NO-OUTPUT), ## (ITRANS-TOGGLE), #language markers, etc.
*
*/
let consumed;
// Loop for one more than string length, to handle any END-WORD-VOWEL processing
for (let start = 0; start <= length; start += consumed) {
// Since we loop for one extra time, start may be == length, current will be ''
const current = input.slice(start);
// Match next itrans token in the input
const {matched, row: nextRow} = this.match(current, {inItrans, inConsonants});
const nextName = nextRow && table.rowName(nextRow);
const nextType = nextRow && table.rowType(nextRow);
// These input codes do not affect the value of inConsonants for next loop around
// and they do not need any special processing even if we are inConsonants sequence
const consonantModifiers = (nextName === RESERVED_NAMES.noOutput
|| nextName === RESERVED_NAMES.nukta // nukta is just a consonant modifier
|| nextName === RESERVED_NAMES.consonantsJoiner // input has explicit consonant-joiner
|| nextName === RESERVED_NAMES.noLigature); // input has explicit no-ligature
// Check if Option 2 or 3 applies: whether we need END-WORD-VOWEL or CONSONANT-JOINER
if (inConsonants) {
let name; // extra character to output, based on where we are in the consonants sequence
if (consonantModifiers || nextType === ROW_TYPE.dependentVowel) {
// input has explicit modifier, or an explicit consonant vowel
// nothing extra to do, just output nextRow normally in Option 1 steps
} else if (nextType === ROW_TYPE.consonant) {
// Option 3 applies: we need CONSONANTS-JOINER unless prevRow was NO-LIGATURE
if (prevName !== RESERVED_NAMES.noLigature
&& (prevName === RESERVED_NAMES.nukta // nukta is just a consonant modifier
|| prevName === RESERVED_NAMES.noOutput // noOutput is just a consonant modifier
|| prevType === ROW_TYPE.consonant)) {
name = RESERVED_NAMES.consonantsJoiner;
}
} else {
// Option 2: Missing dependent vowel on the previous consonant(s).
// Need to output the END-WORD-VOWEL defined in the table.
name = RESERVED_NAMES.endWordVowel;
}
if (name) {
// Need to output this extra character before outputting nextName
const row = table.getRowForName(name);
const replacement = table.rowLanguage(row, prevLanguage);
output.push(outputRow(name, replacement, outputFormat));
}
}
// Option 1: Normal processing: Output the next itrans code replacement text
if (nextRow) {
console.assert(matched, 'Internal error: got row, but nothing matched', nextRow);
consumed = matched.length;
const nameN = table.rowName(nextRow); // CODE_NAMEs
const replacement = table.rowLanguage(nextRow, prevLanguage);
output.push(outputRow(nameN, replacement, outputFormat));
} else {
// Echo one character, not an itrans code
// Note that current may be '', but we still increment by 1 to allow loop to terminate.
consumed = 1;
output.push(current.charAt(0));
}
console.assert(consumed > 0, 'Infinite loop: moved 0 characters');
// Replacement for the next character has been output.
// Update all state variables for next time around the loop.
if (nextName === RESERVED_NAMES.itransToggle) {
inItrans = !inItrans;
}
if (nextType === ROW_TYPE.command && table.isLanguage(nextName)) {
// Switch to new language
prevLanguage = nextName;
inItrans = true;
}
// Update inConsonants to true if we are starting or still in sequence of consonants
if (nextType === ROW_TYPE.consonant || (inConsonants && consonantModifiers)) {
inConsonants = true;
} else {
inConsonants = false;
}
prevRow = nextRow;
prevName = nextName;
prevType = nextType;
}
return output.join('');
}
/* ======================================================================== */
/**
* Match the next word in the input to the input itrans codes, and return the matched
* characters and ItransTable row index.
*
* Handles dependent vowels specially, since those are only to be matched
* when input contains a sequence of consonants such as C1 + C2 + ... + DEPENDENT-VOWEL
* example: ki or tkii etc use i and ii dependent vowels while kai tkaii have full vowels
* i and ii and dependent vowel a.
*
* @param {string} current This is a line or word or syllable to match.
* @param {boolean} inConsonants Set this to true if input has seen C1C2... sequence
* of consonants, which means if the next match is a VOWEL, return a DEPENDENT-VOWEL
* instead.
* @param {boolean} inItrans Set this to true if input should match all itrans codes,
* otherwise, only looks for language markers and
* @returns {object} {matched: string matched, row: array}
* matched: is in the portion of the current string matched.
* row: is the row at itransRows[index]
*/
match(current, {inItrans, inConsonants}) {
const table = this.itransTable;
// In itrans encoded text, look for any itrans code using itransRe
// Outside itrans encoded text, look for any language marker using languagesRe
const inputRe = inItrans ? table.itransRe: table.languagesRe ;
let {matched, row} = table.matchRe(current, inputRe);
if (matched) {
const isVowel = table.rowType(row) === ROW_TYPE.vowel;
if (inConsonants && isVowel) {
// This signifies end of the C1 + C2 + C3 ... V consonant sequence.
// The dependent vowel itrans input codes are usually blank, which means we have
// to find the dependent vowel row with the same name as the vowel.
const dvCodeName = table.getDependentVowelName(table.rowName(row));
row = table.getRowForName(dvCodeName);
console.assert(table.rowType(row) == ROW_TYPE.dependentVowel,
'Internal error: DV named row has a non-dependent-vowel type', row);
}
}
return {matched, row};
}
}
/* ========================================================================== */
function outputRow(name, replacement, outputFormat) {
// Javascript strings are UTF-16 code-points, need to convert them for output.
// console.log(' outputRow: got replacement ', replacement, name);
let output;
if (outputFormat === OUTPUT_FORMAT.unicodeNames) {
output = BRACES.wrap(name); // For Unicode output, use the name in braces
} else if (outputFormat === OUTPUT_FORMAT.html7) {
// Spreadsheet may be missing some columns - especially for rows added programatically.
// Return '' when replacement is not a string. This won't handle String() objects, but
// that is not necessary here.
output = typeof replacement === 'string' ? replacement : '';
} else {
// TODO: Utf8 is not yet supported
// May need something like: return unescape(encodeURIComponent(output));
throw Error('UTF-8 output not yet supported');
}
// TODO: assuming HTML output, may need to create another mode for command line
// execution that does not convert to safe HTML output.
return toHtmlCodes(toSafeHtml(output));
}
// export { Itrans, };
module.exports = Itrans;
| 41.304762 | 96 | 0.656214 |
b8f2fcc4400c62dcff75e9b1e322eed82a7b2992 | 1,988 | js | JavaScript | src/components/Map/Popup.js | BennaceurHichem/Corrona_Project_2cs | 64d7125410b6d7b606e62f7a7bf25be7ad4dfc24 | [
"MIT"
] | null | null | null | src/components/Map/Popup.js | BennaceurHichem/Corrona_Project_2cs | 64d7125410b6d7b606e62f7a7bf25be7ad4dfc24 | [
"MIT"
] | null | null | null | src/components/Map/Popup.js | BennaceurHichem/Corrona_Project_2cs | 64d7125410b6d7b606e62f7a7bf25be7ad4dfc24 | [
"MIT"
] | null | null | null | import React from 'react';
import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
export default function FormDialog(externalProps) {
let openVar = externalProps.open ? true :false
const [open,setOpen] =React.useState(openVar);
console.log("external props:"+Object.keys(externalProps))
const handleClickOpen = () => {
};
const handleClose = () => {
setOpen(false);
};
const handleSubmit= ()=>{
setOpen(false);
}
return (
<div>
<Button variant="outlined" color="primary" onClick={handleClickOpen}>
Open form dialog
</Button>
<Dialog open={open} fullScreen="true" onClose={handleClose} aria-labelledby="form-dialog-title">
<DialogTitle id="form-dialog-title">Subscribe</DialogTitle>
<DialogContent>
<TextField
margin="dense"
id="nbCase"
label="Case Number"
type="number"
fullWidth
/>
<TextField
margin="dense"
id="nbDeath"
label="Death Numbers"
type="number"
fullWidth
/>
<TextField
margin="dense"
id="nbrecovered"
label="Recovered Number"
type="number"
fullWidth
/>
</DialogContent>
<DialogActions>
<Button onClick={()=>handleClose} color="primary">
Cancel
</Button>
<Button color="primary">
Submit Data
</Button>
</DialogActions>
</Dialog>
</div>
);
}
| 20.080808 | 102 | 0.566398 |
b8f3559a0fb49af108768c1280a5fb40e8fe1d78 | 1,028 | js | JavaScript | frontend/app/src/js/KgpIframeInterface.js | isplab-unil/kin-genomic-privacy | a563a1cc02269d240efd687b64d20f25b12a9650 | [
"Apache-2.0"
] | null | null | null | frontend/app/src/js/KgpIframeInterface.js | isplab-unil/kin-genomic-privacy | a563a1cc02269d240efd687b64d20f25b12a9650 | [
"Apache-2.0"
] | null | null | null | frontend/app/src/js/KgpIframeInterface.js | isplab-unil/kin-genomic-privacy | a563a1cc02269d240efd687b64d20f25b12a9650 | [
"Apache-2.0"
] | null | null | null |
/******** down events ********/
export function kgpSetSourceEvent(source){
return {"type": "KgpSetSourceEvent", "source":source}
}
export function kgpSetLanguageEvent(lng){
return {"type": "KgpSetLanguageEvent", "lng":lng}
}
/** Event from kgpmeter to kgp-iframe to signale iframe max dimensions */
export function kgpSetIframeMaxDimensionEvent(maxHeight){
return {"type": "KgpSetIframeMaxDimensionEvent", "maxHeight":maxHeight}
}
export function kgpLaunchTutorialEvent(){
return {"type": "KgpLaunchTutorialEvent"}
}
export function kgpToggleTutorialButtonEvent(showTutorialButton){
return {"type": "KgpToggleTutorialButtonEvent", "showTutorialButton":showTutorialButton}
}
export function kgpRemoveSurveyEvent(){
return {"type": "KgpRemoveSurveyEvent"}
}
/******** up events ********/
/** Event from kgp-iframe to kgpmeter to change height */
export function kgpSetHeightEvent(height, transitionDuration){
return {"type": "KgpSetHeightEvent", "height":height, "transitionDuration": transitionDuration}
} | 29.371429 | 97 | 0.747082 |
b8f36617bfce9b6e1b21a9f49cd81d5c4a42e064 | 89 | js | JavaScript | docs/search--/s_3295.js | Zalexanninev15/VitNX | 43f2dd04b8ba97c4a78ae51a99e7980a6b9b85a9 | [
"MIT"
] | 2 | 2022-01-25T12:09:46.000Z | 2022-01-27T11:26:48.000Z | docs/search--/s_3295.js | Zalexanninev15/VitNX | 43f2dd04b8ba97c4a78ae51a99e7980a6b9b85a9 | [
"MIT"
] | null | null | null | docs/search--/s_3295.js | Zalexanninev15/VitNX | 43f2dd04b8ba97c4a78ae51a99e7980a6b9b85a9 | [
"MIT"
] | null | null | null | search_result['3295']=["topic_0000000000000C29.html","OSS_REAL_DLL_NOT_LINKED Field",""]; | 89 | 89 | 0.797753 |
b8f37c69d0eefbe289628cfa67e79e36353fc956 | 785 | js | JavaScript | src/index.js | cds-snc/lighthouse-cloud | 9be1f556f37a2ffcea0084ff92d324392bcd82fd | [
"MIT"
] | null | null | null | src/index.js | cds-snc/lighthouse-cloud | 9be1f556f37a2ffcea0084ff92d324392bcd82fd | [
"MIT"
] | null | null | null | src/index.js | cds-snc/lighthouse-cloud | 9be1f556f37a2ffcea0084ff92d324392bcd82fd | [
"MIT"
] | null | null | null | require = require("esm")(module); // eslint-disable-line no-global-assign
require("dotenv-safe").config({ allowEmptyValues: true });
const handle = require("./handler").handle;
const scanURL = async (request, response) => {
if (request.query.secret === process.env.SECRET) {
const data = await handle(request.query.url);
response
.status(200)
.set("Content-Type", "application/json")
.send(data);
} else {
response.status(400).send("Secret is not valid");
}
};
// used for local testing
(async () => {
const argv = require("minimist")(process.argv.slice(2));
const { mockPayload } = argv;
if (mockPayload) {
const result = await handle("https://digital.canada.ca");
console.log(result);
}
})();
module.exports.scanURL = scanURL;
| 27.068966 | 73 | 0.648408 |
b8f5e2e06c71fd1e743f7e948786fc075de78eef | 8,073 | js | JavaScript | src/core/ui/components/Autocomplete/Autocomplete.stories.js | COMATCH/comatch-ui | 74fd12472b75639b27bab8ee22a31941954f562d | [
"MIT"
] | 12 | 2018-11-14T07:14:01.000Z | 2020-10-08T17:15:34.000Z | src/core/ui/components/Autocomplete/Autocomplete.stories.js | COMATCH/comatch-ui | 74fd12472b75639b27bab8ee22a31941954f562d | [
"MIT"
] | 16 | 2019-01-17T15:46:57.000Z | 2021-10-05T20:42:01.000Z | src/core/ui/components/Autocomplete/Autocomplete.stories.js | COMATCH/comatch-ui | 74fd12472b75639b27bab8ee22a31941954f562d | [
"MIT"
] | 1 | 2019-08-06T12:29:32.000Z | 2019-08-06T12:29:32.000Z | /* eslint-disable max-classes-per-file */
import React, { Component } from 'react';
import { debounce } from 'lodash';
import Highlight from 'react-highlight';
import { storiesOf } from '@storybook/react';
import { Autocomplete } from './Autocomplete';
const options = [
{ value: 'John Doe', label: 'John Doe' },
{ value: 'John Wick', label: 'John Wick' },
{ value: 'Dwayne Johnson', label: 'Dwayne Johnson' },
];
const optionsToString = (optionsArr) =>
optionsArr.reduce((acc, { value, label }, index) => {
let res = acc;
if (index) {
res += ',\n';
}
res += `{ value: ${value}, label: ${label} }`;
if (index === optionsArr.length - 1) {
res += ']';
}
return res;
}, '[\n');
class AutocompleteWrapper extends Component {
constructor(props, context) {
super(props, context);
this.state = {
// eslint-disable-next-line react/prop-types
inputValue: props.inputValue || '',
};
}
onInputChange = (event) => {
this.setState({
inputValue: event.target.value,
});
};
get autocompleteAdditionalProps() {
return Object.keys(this.props).reduce((selectProps, propKey) => {
const isPropForUnderlyingSelect = propKey !== 'inputValue' && propKey !== 'onInputChange';
if (isPropForUnderlyingSelect) {
// eslint-disable-next-line no-param-reassign
selectProps[propKey] = this.props[propKey];
}
return selectProps;
}, {});
}
render() {
const { inputValue } = this.state;
const { autocompleteAdditionalProps, onInputChange } = this;
return (
<Autocomplete
name="person-name"
options={options}
inputValue={inputValue}
onInputChange={onInputChange}
{...autocompleteAdditionalProps}
/>
);
}
}
class AutocompleteWrapperWithFakeCall extends Component {
constructor(props, context) {
super(props, context);
this.state = {
// eslint-disable-next-line react/prop-types
inputValue: props.inputValue || '',
loading: false,
};
}
onLoadingFinish = debounce(() => {
this.setState({
loading: false,
});
}, 1000);
onInputChange = (event) => {
this.setState(
{
inputValue: event.target.value,
loading: true,
},
this.onLoadingFinish,
);
};
get autocompleteAdditionalProps() {
return Object.keys(this.props).reduce((selectProps, propKey) => {
const isPropForUnderlyingSelect = propKey !== 'inputValue' && propKey !== 'onInputChange';
if (isPropForUnderlyingSelect) {
// eslint-disable-next-line no-param-reassign
selectProps[propKey] = this.props[propKey];
}
return selectProps;
}, {});
}
render() {
const { inputValue, loading } = this.state;
const { autocompleteAdditionalProps, onInputChange } = this;
return (
<Autocomplete
name="person-name"
options={loading ? [] : options}
inputValue={inputValue}
isLoading={loading}
onInputChange={onInputChange}
{...autocompleteAdditionalProps}
/>
);
}
}
storiesOf('Autocomplete', module)
.add('With name and options', () => (
<>
<AutocompleteWrapper />
<Highlight className="html">
{`<Autocomplete name="person-name" options={${optionsToString(options)}} />`}
</Highlight>
</>
))
.add('With label', () => (
<>
<AutocompleteWrapper label="Person's name" />
<Highlight className="html">
{`<Autocomplete label="Person's name" name="person-name" options={${optionsToString(options)}} />`}
</Highlight>
</>
))
.add('With more than 10 options', () => {
const optionsArr = [
...options,
...options.map(({ label, value }) => ({
label: `${label} 2`,
value: `${value} 2`,
})),
...options.map(({ label, value }) => ({
label: `${label} 3`,
value: `${value} 3`,
})),
...options.map(({ label, value }) => ({
label: `${label} 4`,
value: `${value} 4`,
})),
];
return (
<>
<AutocompleteWrapper label="Person's name" options={optionsArr} />
<Highlight className="html">
{'<Autocomplete' +
'\nlabel="Person\'s name"' +
'\nname="person-name"' +
`\noptions={${optionsToString(optionsArr)}} />`}
</Highlight>
</>
);
})
.add('With initial value', () => (
<>
<AutocompleteWrapper label="Person's name" inputValue="Dwayne Johnson" />
<Highlight className="html">
{'<Autocomplete' +
'\nlabel="Person\'s name"' +
'\nname="person-name"' +
'\ninputValue="Dwayne Johnson"' +
`\noptions={${optionsToString(options)}} />`}
</Highlight>
</>
))
.add('With an onChange listener', () => (
<>
<AutocompleteWrapper
label="Person's name"
inputValue="Dwayne Johnson"
onChange={(event) => {
// eslint-disable-next-line no-console
console.log(event);
}}
/>
<Highlight className="html">
{'<Autocomplete' +
'\nlabel="Person\'s name"' +
'\nname="person-name"' +
'\ninputValue="Dwayne Johnson"' +
`\nonChange={(event) => { console.log(event); }}` +
`\noptions={${optionsToString(options)}} />`}
</Highlight>
</>
))
.add('With custom noOptionsMessage', () => (
<>
<AutocompleteWrapper
label="Person's name"
noOptionsMessage={({ inputValue }) => `Nothing found for "${inputValue}"`}
options={[]}
/>
<Highlight className="html">
{'<Autocomplete' +
'\nlabel="Person\'s name"' +
'\nname="person-name"' +
`\noOptionsMessage={({ inputValue }) => \`Nothing found for "\${inputValue}"\`}` +
'\noptions={[]} />'}
</Highlight>
</>
))
.add('With a "fake" API call', () => (
<>
<AutocompleteWrapperWithFakeCall label="Person's name" />
<Highlight className="html">
{'<Autocomplete' +
'\nlabel="Person\'s name"' +
'\nname="person-name"' +
`\noptions={${optionsToString(options)}} />`}
</Highlight>
</>
))
.add('With a "fake" API call and custom loading message', () => (
<>
<AutocompleteWrapperWithFakeCall
label="Person's name"
loadingMessage={({ inputValue }) => `Server is searching for "${inputValue}"`}
/>
<Highlight className="html">
{'<Autocomplete' +
'\nlabel="Person\'s name"' +
`loadingMessage={({ inputValue }) => \`Server is searching for "\${inputValue}"\`}` +
'\nname="person-name"' +
`\noptions={${optionsToString(options)}} />`}
</Highlight>
</>
));
| 31.909091 | 115 | 0.46575 |
b8f5e907a84ceac198146b968410c13c6a8f68ff | 3,052 | js | JavaScript | gatsby-config.js | viral810/gatsby-viralpatel.blog | c290e262bb0fedae1816435e681deea880fea250 | [
"MIT"
] | null | null | null | gatsby-config.js | viral810/gatsby-viralpatel.blog | c290e262bb0fedae1816435e681deea880fea250 | [
"MIT"
] | 6 | 2020-07-11T19:44:41.000Z | 2022-02-17T20:18:02.000Z | gatsby-config.js | viral810/gatsby-viralpatel.blog | c290e262bb0fedae1816435e681deea880fea250 | [
"MIT"
] | null | null | null | module.exports = {
siteMetadata: {
title: `Viral Patel | Software Developer | Toronto`,
description: `Viral Patel | Software Developer | Toronto | thedecodedcoder.`,
author: `@thedecodedcoder`,
siteUrl: `https://viralpatel.blog`,
},
plugins: [
`gatsby-plugin-react-helmet`,
`gatsby-plugin-sitemap`,
`gatsby-plugin-advanced-sitemap`,
`gatsby-plugin-feed`,
`gatsby-plugin-styled-components`,
{
resolve: `gatsby-plugin-google-analytics`,
options: {
// replace "UA-XXXXXXXXX-X" with your own Tracking ID
trackingId: "UA-134715104-1",
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/src/content`,
name: "markdown-pages",
},
},
`gatsby-transformer-sharp`,
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
`gatsby-remark-emoji`, // <-- this line adds emoji
{
resolve: `gatsby-remark-vscode`,
// All options are optional. Defaults shown here.
options: {
colorTheme: "Tomorrow Night Blue", // Read on for list of included themes. Also accepts object and function forms.
wrapperClassName: "", // Additional class put on 'pre' tag
injectStyles: true, // Injects (minimal) additional CSS for layout and scrolling
extensions: ["night-owl"], // Extensions to download from the marketplace to provide more languages and themes
languageAliases: {}, // Map of custom/unknown language codes to standard/known language codes
replaceColor: (x) => x, // Function allowing replacement of a theme color with another. Useful for replacing hex colors with CSS variables.
getLineClassName: ({
// Function allowing dynamic setting of additional class names on individual lines
content, // - the string content of the line
index, // - the zero-based index of the line within the code fence
language, // - the language specified for the code fence
codeFenceOptions, // - any options set on the code fence alongside the language (more on this later)
}) => "",
},
},
],
},
},
`gatsby-plugin-sharp`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/favicon.png`, // This path is relative to the root of the site.
},
},
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.app/offline
// "gatsby-plugin-offline",
],
}
| 37.679012 | 153 | 0.587156 |
b8f5f26dcfe429530af49afd03830b86f71c07c7 | 116 | js | JavaScript | lbh/components/lbh-error-summary/error-summary.js | dracos/lbh-frontend | faf0007ee4cdeaa7b91385889a711861acb59fd3 | [
"MIT"
] | 4 | 2021-03-15T13:51:19.000Z | 2021-05-31T10:56:30.000Z | lbh/components/lbh-error-summary/error-summary.js | dracos/lbh-frontend | faf0007ee4cdeaa7b91385889a711861acb59fd3 | [
"MIT"
] | 43 | 2021-03-13T15:11:29.000Z | 2021-11-02T13:19:53.000Z | lbh/components/lbh-error-summary/error-summary.js | dracos/lbh-frontend | faf0007ee4cdeaa7b91385889a711861acb59fd3 | [
"MIT"
] | 6 | 2021-03-12T16:35:59.000Z | 2022-01-22T15:40:01.000Z | import ErrorSummary from 'govuk-frontend/govuk/components/error-summary/error-summary'
export default ErrorSummary
| 29 | 86 | 0.853448 |
b8f6ff86aa49f4bbc79cddb04e3d7105392cbf1e | 3,281 | js | JavaScript | resources/js/app.js | nafism05/chat_TA_pusher | 7fb663d340ed9572436108d662639e3055602cdb | [
"MIT"
] | null | null | null | resources/js/app.js | nafism05/chat_TA_pusher | 7fb663d340ed9572436108d662639e3055602cdb | [
"MIT"
] | 5 | 2021-03-09T17:17:48.000Z | 2022-02-26T17:32:51.000Z | resources/js/app.js | nafism05/chat_TA_pusher | 7fb663d340ed9572436108d662639e3055602cdb | [
"MIT"
] | null | null | null | /**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap');
window.Vue = require('vue');
/**
* The following block of code may be used to automatically register your
* Vue components. It will recursively scan this directory for the Vue
* components and automatically register them with their "basename".
*
* Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
*/
// const files = require.context('./', true, /\.vue$/i);
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default));
// Vue.component('example-component', require('./components/ExampleComponent.vue').default);
Vue.component('chat-messages', require('./components/ChatMessages.vue').default);
Vue.component('chat-form', require('./components/ChatForm.vue').default);
Vue.component('room-list', require('./components/guru/RoomList.vue').default);
Vue.component('room-list-s', require('./components/siswa/RoomList.vue').default);
Vue.component('send-notification', require('./components/SendNotification.vue').default);
/**
* Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
const app = new Vue({
el: '#app',
data: {
messages: [],
rooms: []
},
created() {
// var channel = Echo.channel('channelName');
},
methods: {
fetchMessages(roomid) {
// console.log('roomId = '+roomid);
axios.get('/messages/'+roomid).then(response => {
this.messages = response.data;
});
},
sendMessage(message){
this.messages.push(message);
axios.post('/messages', message).then(response => {
console.log(response.data);
}).catch(error => {
console.log('error post axios : '+error);
});
},
listenMessageSent(roomid){
Echo.channel('chat.'+roomid)
.listen('MessageSent', (e) => {
this.messages.push({
message: e.message.message,
user: e.user
});
});
console.log('listenMessageSent jalan');
},
fetchRooms(){
axios.get('/chatrooms').then(response => {
this.rooms = response.data;
console.log('chatroomsaaa :'+response.data);
});
},
gFetchRooms(){
axios.get('/guru/chatrooms').then(response => {
this.rooms = response.data;
console.log('chatroomsaaa :'+response.data);
});
},
gListenRoomList(guruid){
Echo.private('guru.'+guruid)
.listen('RoomCreated', (e) => {
this.rooms.push({
judul: e.chatroom.judul
});
console.log('tes bosse');
console.log(e);
});
}
}
});
| 31.247619 | 98 | 0.563548 |
b8f7b288a8fa05ba0899b43693fbc66d1e356236 | 450 | js | JavaScript | js/github-interface.js | Russspruce/github_API_demo | dbdd103b4ba8070fe4e54e14da0056c3332f4e4f | [
"MIT"
] | null | null | null | js/github-interface.js | Russspruce/github_API_demo | dbdd103b4ba8070fe4e54e14da0056c3332f4e4f | [
"MIT"
] | null | null | null | js/github-interface.js | Russspruce/github_API_demo | dbdd103b4ba8070fe4e54e14da0056c3332f4e4f | [
"MIT"
] | null | null | null | var getRepos = require('./../js/github.js').getRepos;
var displayRepos = function(username, profileData) {
$('.showGithub').text(""+username+"'s GitHub repositories currently on display: "+profileData+".");
}
$(document).ready(function() {
var githubInfo = new getRepos();
$('#githubSearch').click(function() {
var username = $('#username').val();
$('#username').val("");
githubInfo.getAllRepos(username, displayRepos);
});
});
| 30 | 101 | 0.648889 |
b8f8f0a6d3c021877cfb5eba3571fee3722ddb88 | 1,312 | js | JavaScript | utils/api.js | nishantbn/flashcards | 27b46634fb6b4ee5133b593ac6e702182d4fbe66 | [
"MIT"
] | null | null | null | utils/api.js | nishantbn/flashcards | 27b46634fb6b4ee5133b593ac6e702182d4fbe66 | [
"MIT"
] | 3 | 2021-05-11T17:58:51.000Z | 2022-02-27T06:48:50.000Z | utils/api.js | nishantbn/flashcards | 27b46634fb6b4ee5133b593ac6e702182d4fbe66 | [
"MIT"
] | 1 | 2020-06-19T06:40:08.000Z | 2020-06-19T06:40:08.000Z | import AsyncStorage from "@react-native-community/async-storage";
const DATABASE_KEY = "flash:decks";
export const getDecks = () => {
// TODO - return all decks
return AsyncStorage.getItem(DATABASE_KEY);
};
export const getDeck = (id) => {
return AsyncStorage.getItem(DATABASE_KEY).then((result) => {
const parsed = JSON.parse(result);
return parsed[id];
});
};
export const saveDeckTitle = (title) => {
return AsyncStorage.mergeItem(
DATABASE_KEY,
JSON.stringify({
[title]: {
title: title,
questions: [],
},
})
);
};
export const addCardToDeck = (title, question) => {
return AsyncStorage.getItem(DATABASE_KEY).then((results) => {
let state = JSON.parse(results);
state = {
...state,
[title]: {
...state[title],
questions: [
...state[title].questions,
{
question: question.question,
answer: question.answer,
},
],
},
};
AsyncStorage.setItem(DATABASE_KEY, JSON.stringify(state));
});
};
export const removeDeck = (title) => {
return AsyncStorage.getItem(DATABASE_KEY).then((results) => {
const parsed = JSON.parse(results);
delete parsed[title];
AsyncStorage.setItem(DATABASE_KEY, JSON.stringify(parsed));
});
};
| 23.017544 | 65 | 0.602134 |
b8fa9c4439369ac97dde404e4dd960ac2ecd565e | 2,350 | js | JavaScript | src/color-namer/dist/picker/picker.js | Uvacoder/test-tailwind-ink | fbfdcd036d5c8b636aa2e24f8a36d1f5f90704eb | [
"MIT"
] | 336 | 2020-08-29T16:33:40.000Z | 2022-03-08T23:30:26.000Z | dist/picker/picker.js | BombinateLive/color-namer | 9b3745128cf3e47836fdf1b430ea0df4c24bb364 | [
"MIT"
] | 12 | 2019-08-24T18:34:05.000Z | 2022-01-24T15:05:00.000Z | dist/picker/picker.js | BombinateLive/color-namer | 9b3745128cf3e47836fdf1b430ea0df4c24bb364 | [
"MIT"
] | 32 | 2018-04-14T14:15:07.000Z | 2022-03-29T11:09:50.000Z | $(function() {
var l = 50;
var h = parseInt(Math.random()*360, 10);
var s = parseInt(Math.random()*100, 10);
var set = true;
var clipRGB = new ZeroClipboard.Client();
clipRGB.setHandCursor(true);
var clipHEX = new ZeroClipboard.Client();
clipHEX.setHandCursor(true);
var clipHSL = new ZeroClipboard.Client();
clipHSL.setHandCursor(true);
var color = [0,0,0];
var hex = '#000000';
function setColor() {
$('body').css('background-color', 'hsl('+h+','+s+'%,'+l+'%)');
var bgcolor = $('body').css('background-color');
if (bgcolor.match(/^rgb/)) {
color = bgcolor.replace('rgb(', '').replace(')', '').split(', ');
hex = '#' + (color[0] > 16 ? '' : '0') + parseInt(color[0], 10).toString(16) +
(color[1] > 16 ? '' : '0') + parseInt(color[1], 10).toString(16) +
(color[2] > 16 ? '' : '0') + parseInt(color[2], 10).toString(16);
} else {
hex = bgcolor;
color = [parseInt(bgcolor.substr(1,2), 16), parseInt(bgcolor.substr(3,2), 16), parseInt(bgcolor.substr(5,2), 16)];
}
$('#hexval').html(hex);
$('#r').html(color[0]);
$('#g').html(color[1]);
$('#b').html(color[2]);
$('#h').html(h);
$('#s').html(s+'%');
$('#l').html(l+'%');
clipRGB.setText(color[0]+' '+color[1]+' '+color[2]);
clipHEX.setText(hex);
clipHSL.setText(h+' '+s+'% '+l+'%');
}
try {
var pageTracker = _gat._getTracker("UA-3110123-8");
pageTracker._trackPageview();
} catch(err) {}
clipRGB.glue('rgb');
clipHEX.glue('hex');
clipHSL.glue('hsl');
$(window).mousemove(function(e) {
if (set) {
h = Math.min(360, parseInt((e.clientX / $(window).width()) * 360, 10));
s = 100 - Math.min(100, parseInt((e.clientY / $(window).height()) * 100, 10));
setColor();
}
});
$(window).mousewheel(function(e, d) {
e.preventDefault();
if (set) {
l = Math.max(0, Math.min(100, l + parseInt(d, 10)));
setColor();
}
});
$(window).click(function() {
setColor();
set = !set;
$('#color').toggleClass('itsok', set);
});
$('div:not(#color)').mousemove(function() {
$('#color').addClass('hover');
}).mouseleave(function() {
$('#color').removeClass('hover');
});
$('div:not(#color)').click(function(e) {
e.stopPropagation();
});
setColor();
});
| 26.404494 | 120 | 0.531064 |
b8fab53191202e474ca95a194e3ec0bc98a6b3b5 | 1,135 | js | JavaScript | dist-mdi/mdi/link-variant-off.js | maciejg-git/vue-bootstrap-icons | bc60cf77193e15cc72ec7eb7f9949ed8b552e7ec | [
"MIT",
"CC-BY-4.0",
"MIT-0"
] | null | null | null | dist-mdi/mdi/link-variant-off.js | maciejg-git/vue-bootstrap-icons | bc60cf77193e15cc72ec7eb7f9949ed8b552e7ec | [
"MIT",
"CC-BY-4.0",
"MIT-0"
] | null | null | null | dist-mdi/mdi/link-variant-off.js | maciejg-git/vue-bootstrap-icons | bc60cf77193e15cc72ec7eb7f9949ed8b552e7ec | [
"MIT",
"CC-BY-4.0",
"MIT-0"
] | null | null | null | import { h } from 'vue'
export default {
name: "LinkVariantOff",
vendor: "Mdi",
type: "",
tags: ["link","variant","off"],
render() {
return h(
"svg",
{"xmlns":"http://www.w3.org/2000/svg","width":"24","height":"24","viewBox":"0 0 24 24","class":"v-icon","fill":"currentColor","data-name":"mdi-link-variant-off","innerHTML":"<path d='M2,5.27L3.28,4L20,20.72L18.73,22L13.9,17.17L11.29,19.78C9.34,21.73 6.17,21.73 4.22,19.78C2.27,17.83 2.27,14.66 4.22,12.71L5.71,11.22C5.7,12.04 5.83,12.86 6.11,13.65L5.64,14.12C4.46,15.29 4.46,17.19 5.64,18.36C6.81,19.54 8.71,19.54 9.88,18.36L12.5,15.76L10.88,14.15C10.87,14.39 10.77,14.64 10.59,14.83C10.2,15.22 9.56,15.22 9.17,14.83C8.12,13.77 7.63,12.37 7.72,11L2,5.27M12.71,4.22C14.66,2.27 17.83,2.27 19.78,4.22C21.73,6.17 21.73,9.34 19.78,11.29L18.29,12.78C18.3,11.96 18.17,11.14 17.89,10.36L18.36,9.88C19.54,8.71 19.54,6.81 18.36,5.64C17.19,4.46 15.29,4.46 14.12,5.64L10.79,8.97L9.38,7.55L12.71,4.22M13.41,9.17C13.8,8.78 14.44,8.78 14.83,9.17C16.2,10.54 16.61,12.5 16.06,14.23L14.28,12.46C14.23,11.78 13.94,11.11 13.41,10.59C13,10.2 13,9.56 13.41,9.17Z' />"},
)
}
} | 87.307692 | 953 | 0.643172 |
b8ff7913868e9a7696bc04fb02518a59b579bdd2 | 2,475 | js | JavaScript | gulpfile.js | nhusher/js-channels | 5be4ef2d4df8e4efdc4a61cf1803e1613ad44bf8 | [
"MIT"
] | null | null | null | gulpfile.js | nhusher/js-channels | 5be4ef2d4df8e4efdc4a61cf1803e1613ad44bf8 | [
"MIT"
] | 2 | 2015-02-22T02:31:50.000Z | 2015-02-22T02:35:40.000Z | gulpfile.js | nhusher/js-channels | 5be4ef2d4df8e4efdc4a61cf1803e1613ad44bf8 | [
"MIT"
] | null | null | null | /*jshint node:true */
var babelify = require('babelify');
var babel = require('gulp-babel');
var browserify = require('browserify');
var concat = require('gulp-concat');
var gulp = require('gulp');
var merge = require('gulp-merge');
var ngAnnotate = require('gulp-ng-annotate');
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var through2 = require('through2');
var uglify = require('gulp-uglify');
var browserified = function() {
return through2.obj(function (file, enc, next) {
return browserify({ entries: file.path, debug: true })
.transform(babelify)
.bundle(function(err, res) {
if(err) {
throw err;
}
file.contents = res;
next(null, file);
});
});
};
gulp.task('clean', function() {
return gulp.src('dist', { read: false }).pipe(require('gulp-clean')());
});
gulp.task('angular', [ 'clean' ], function() {
var tx = gulp.src([ 'src/channels/*.js', 'src/angular/promise.js', '!src/channels/index*', '!src/channels/promise.js' ])
.pipe(sourcemaps.init({ debug: true }))
.pipe(babel({ modules: require('./util/angular-module-formatter.js') }));
return merge(
gulp.src('src/angular/index.js').pipe(sourcemaps.init({ debug: true })),
tx)
.pipe(ngAnnotate())
.pipe(concat('js-channels.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/angular'));
});
gulp.task('angular-min', [ 'clean' ], function() {
var tx = gulp.src([ 'src/channels/*.js', 'src/angular/promise.js', '!src/channels/index*', '!src/channels/promise.js' ])
.pipe(sourcemaps.init({ debug: true }))
.pipe(babel({ modules: require('./util/angular-module-formatter.js') }));
return merge(
gulp.src('src/angular/index.js').pipe(sourcemaps.init({ debug: true })),
tx)
.pipe(ngAnnotate())
.pipe(concat('js-channels.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/angular'));
});
gulp.task('node', [ 'clean' ], function() {
return gulp.src('src/channels/*.js')
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist/node'));
});
gulp.task('test', [ 'clean' ], function() {
return gulp.src('test/test.js')
.pipe(browserified())
.pipe(gulp.dest('dist/tests'));
});
// TODO: browser module
gulp.task('default', [ 'node', 'angular', 'angular-min', 'test' ]); | 30.9375 | 122 | 0.598788 |
b8ff9ec2febb47f2745e70ec180e1f0ff7d5404b | 2,953 | js | JavaScript | public/static/js/factory/approve.js | beads123/ikacn | 5af2fb900b4c269043654fe301c38fbf2af98496 | [
"Apache-2.0"
] | null | null | null | public/static/js/factory/approve.js | beads123/ikacn | 5af2fb900b4c269043654fe301c38fbf2af98496 | [
"Apache-2.0"
] | null | null | null | public/static/js/factory/approve.js | beads123/ikacn | 5af2fb900b4c269043654fe301c38fbf2af98496 | [
"Apache-2.0"
] | null | null | null | app.factory("approve", function ($http) {
var obj = {}
// 网站认证
// 网站认证 代码2 文件1
obj.codeIndex = 2 //验证类型
// 获取网站认证需要 网站wid ---obj.webWid
// 获取网站认证信息
obj.getApproveInfo = function () {
$http.post("/member/Account/getmete", { wid: obj.webWid }).success(function (data) {
obj.appData = data
obj.appCode = data.meta
})
}
// 复制认证代码
obj.copyCode = function () {
var textCode = $("#textCode")
textCode.select();
document.execCommand("Copy");
modal_alert("代码已经成功复制")
}
// 开始网站认证 upSrt :上架接口 cb 认证回调 成功:success 失败 :fail
obj.webApprove = function (cb,upStr, wid, gid, web_url) {
if(!web_url){
web_url = obj.web_url
}
obj.startApprove = function(){
obj.loading =1;
obj.up_data = '网站认证中';
$('.modal_loading').modal('show')
var webcheckInfo = {
wid: obj.webWid,
type: obj.codeIndex,
gid: gid
}
if (wid) {
webcheckInfo.wid = wid
}
$http({
url: '/member/Account/webcheck',
data: webcheckInfo,
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
transformRequest: function (obj) {
var str = [];
for (var o in obj)
if (obj[o]) str.push(encodeURIComponent(o) + "=" + encodeURIComponent(obj[o]));
return str.join("&");
}
}).success(function (data) {
$('.modal_loading').modal('hide')
if (data.statusCode == 200) {
if(cb){
cb('success')
}
$('.authen_success').modal("show")
if (upStr) {
//上架
$http.post(upStr, { wid: wid, gid: gid, status: '上架' }).success(function (data) {
})
}
} else {
if(cb){
cb('fail')
}
$('.authen_lose').modal('show'); // 失败
}
}, function () { })
}
if(web_url){
$http.post('/member/Account/getcheck',{url:web_url}).success(function(data){
if(data.statusCode == 200){
// 200已经认证过
modal_confirm( web_url + ' 已经有认证出售,您的网站认证通过后,会下架原来卖家的所有商品。',function(){
obj.startApprove();
})
}else{
obj.startApprove();
}
})
}
}
// 重新认证
obj.reAuth = function () {
$(".checkwebsite").modal("show")
}
return obj
})
| 29.828283 | 105 | 0.408737 |
77013721d8dd730e510abcd19a62790193dbefd1 | 550 | js | JavaScript | models/payslip.js | Carllawrence/StudentAdminSystem | 7194be74bea4a391e80e7c906c00746e95a161fe | [
"MIT"
] | null | null | null | models/payslip.js | Carllawrence/StudentAdminSystem | 7194be74bea4a391e80e7c906c00746e95a161fe | [
"MIT"
] | null | null | null | models/payslip.js | Carllawrence/StudentAdminSystem | 7194be74bea4a391e80e7c906c00746e95a161fe | [
"MIT"
] | null | null | null | var mongoose = require('mongoose'),
Schema = mongoose.Schema;
/**
* Todo Schema
*/
var PayslipSchema = new Schema({
ncp: Number,
dco: Date,
dva: Date,
uti: String,
pie: String,
eve: Number,
ope: Number,
lib: String,
debit: String,
credit: String,
createdAt:Date,
updatedAt:Date
});
// keep track of when todos are updated and created
PayslipSchema.pre('save', function(next, done){
if (this.isNew) {
this.createdAt = Date.now();
}
this.updatedAt = Date.now();
next();
});
mongoose.model('Payslip', PayslipSchema); | 17.1875 | 51 | 0.658182 |
7702f3936eccc77fa9053d0cdddd61c24bbecbdf | 359 | js | JavaScript | api/src/controllers/category/createCategory.js | Drivello/On-The-Rocks | 40614601f538431dd418be85a66c215684a5fdba | [
"MIT"
] | 2 | 2021-10-06T19:23:04.000Z | 2022-03-08T15:57:27.000Z | api/src/controllers/category/createCategory.js | Drivello/On-The-Rocks | 40614601f538431dd418be85a66c215684a5fdba | [
"MIT"
] | 11 | 2021-08-23T02:19:48.000Z | 2021-08-30T16:38:43.000Z | api/src/controllers/category/createCategory.js | Drivello/On-The-Rocks | 40614601f538431dd418be85a66c215684a5fdba | [
"MIT"
] | 1 | 2021-09-07T01:35:55.000Z | 2021-09-07T01:35:55.000Z | const { Category } = require("../../db");
module.exports = async (req, res, next) => {
let category = req.body;
try {
category = await Category.create({ ...category });
return res.json({ success: "Category successfully created" }).status(200);
} catch (err) {
return res.send({ error: err.message }).status(409);
}
};
| 29.916667 | 82 | 0.576602 |
77068dad5a4659847f5f4cc8f874e174a99e1c38 | 440 | js | JavaScript | 6kyu/WeIrD-StRiNg-CaSe/toWeirdCase.js | robhung/codewars | c3f213c08f1d1286b0e899d31f552b52bb2f9b92 | [
"MIT"
] | null | null | null | 6kyu/WeIrD-StRiNg-CaSe/toWeirdCase.js | robhung/codewars | c3f213c08f1d1286b0e899d31f552b52bb2f9b92 | [
"MIT"
] | null | null | null | 6kyu/WeIrD-StRiNg-CaSe/toWeirdCase.js | robhung/codewars | c3f213c08f1d1286b0e899d31f552b52bb2f9b92 | [
"MIT"
] | null | null | null | const toWeirdCase = string => {
const isEven = num => num % 2 === 0;
const wordArr = string.split(' ');
const newWordArr = wordArr.map(word => {
const characterArr = word.split('');
const newCharacterArr = characterArr.map((letter, index) =>
isEven(index) ? letter.toUpperCase() : letter.toLowerCase()
);
return newCharacterArr.join('');
});
return newWordArr.join(' ');
};
module.exports = toWeirdCase;
| 24.444444 | 65 | 0.634091 |
770891b8b84476d2eea99506a4d0a341d8d0bc7e | 450 | js | JavaScript | src/components/App.test.js | dmaixner/todorr | dd200a70d0e8327b3b89091c5fb14fc526dce04a | [
"Apache-2.0"
] | 1 | 2022-03-25T06:17:08.000Z | 2022-03-25T06:17:08.000Z | src/components/App.test.js | sunkisrinivas005/todorr | dd200a70d0e8327b3b89091c5fb14fc526dce04a | [
"Apache-2.0"
] | null | null | null | src/components/App.test.js | sunkisrinivas005/todorr | dd200a70d0e8327b3b89091c5fb14fc526dce04a | [
"Apache-2.0"
] | 1 | 2022-03-25T06:12:37.000Z | 2022-03-25T06:12:37.000Z | import { render, screen } from '@testing-library/react';
import App from './App';
import { Provider } from 'react-redux'
import { createStore } from 'redux';
import reducers from '../reducers';
test('renders title', () => {
let store = createStore(reducers);
render(
<Provider store={store}>
<App />
</Provider>
);
const loadingElement = screen.getByText(/Loading data.../i);
expect(loadingElement).toBeInTheDocument();
});
| 25 | 62 | 0.662222 |
7709a26023fa6d413ee06e8ebb4947c570d179d1 | 6,624 | js | JavaScript | api/controllers/modules/dj-dps-commands/src/markdown/render/plugins/markit/test/server.js | vadim-lev/jace-dps | cc1d9dde388908924bd7b71fe0296d25df3c4556 | [
"MIT"
] | null | null | null | api/controllers/modules/dj-dps-commands/src/markdown/render/plugins/markit/test/server.js | vadim-lev/jace-dps | cc1d9dde388908924bd7b71fe0296d25df3c4556 | [
"MIT"
] | null | null | null | api/controllers/modules/dj-dps-commands/src/markdown/render/plugins/markit/test/server.js | vadim-lev/jace-dps | cc1d9dde388908924bd7b71fe0296d25df3c4556 | [
"MIT"
] | 4 | 2020-05-28T17:36:05.000Z | 2021-05-17T16:38:29.000Z | 'use strict';
const should = require('should');
// introduce models for fixtures
require('engine/koa/tutorial').Article;
require('engine/koa/tutorial').Task;
const Parser = require('../serverParser');
const dataUtil = require('lib/dataUtil');
const path = require('path');
const stripYamlMetadata = require('../stripYamlMetadata');
// compares removing spaces between tags
should.Assertion.add('html', function(str) {
this.obj.should.be.a.String;
str.should.be.a.String;
this.obj.trim().replace(/>\s+</g, '><').should.equal(str.trim().replace(/>\s+</g, '><'));
}, false);
async function render(text) {
let tmp;
try {
tmp = stripYamlMetadata(text);
} catch (e) {
// bad metadata stops parsing immediately
return e.message;
}
text = tmp.text;
let env = {meta: tmp.meta};
const parser = new Parser({
resourceWebRoot: '/resources',
publicRoot: __dirname,
env
});
const tokens = await parser.parse(text);
let result = parser.render(tokens);
//console.log(env);
return result;
}
describe('MarkIt', function() {
before(async function() {
await dataUtil.loadModels(path.join(__dirname, './fixture/tutorial'), {reset: true});
});
describe('code', function() {
it(`[js src="1.js" height=300]`, async function() {
let result = await render(this.test.title);
result.should.be.html(`<div data-trusted="1" class="code-example" data-demo-height="300">
<div class="codebox code-example__codebox">
<div class="codebox__code" data-code="1">
<pre class="line-numbers language-javascript"><code>let a = 5</code></pre>
</div>
</div>
</div>`);
});
it('```\ncode\n```', async function() {
let result = await render(this.test.title);
result.should.be.html(`<div data-trusted="1" class="code-example">
<div class="codebox code-example__codebox">
<div class="codebox__code" data-code="1">
<pre class="line-numbers language-none"><code>code</code></pre>
</div>
</div>
</div>`);
});
it('```js\na = 5\n```\n', async function() {
let result = await render(this.test.title);
result.should.be.html(`<div data-trusted="1" class="code-example">
<div class="codebox code-example__codebox">
<div class="codebox__code" data-code="1">
<pre class="line-numbers language-javascript"><code>a = 5</code></pre>
</div>
</div>
</div>`
);
});
});
it(`[iframe src="/path"]`, async function() {
let result = await render(this.test.title);
result.should.be.html(`<div class="code-result">
<div class="code-result__toolbar toolbar"></div>
<iframe class="code-result__iframe" data-trusted="1" style="height:300px" src="/path"></iframe>
</div>`
);
});
/*
it(`<info:task/task-1>`, async function() {
let result = await render(this.test.title);
result.trim().should.be.eql('<p><a href="/task/task-1">Task 1</a></p>');
});
it(`<info:article-1.2>`, async function() {
let result = await render(this.test.title);
result.trim().should.be.eql('<p><a href="/article-1.2">Article 1.2</a></p>');
});
*/
it(`notfigure `, async function() {
let result = await render(this.test.title);
result.trim().should.be.eql('<p>notfigure <img src="/url" alt="desc" height="100" width="200"></p>');
});
it(`notfigure `, async function() {
let result = await render(this.test.title);
result.trim().should.be.eql('<p>notfigure <img src="/resources/blank.png" alt="desc" width="3" height="2"></p>');
});
it(`notfigure `, async function() {
let result = await render(this.test.title);
result.trim().should.match(/^<p>notfigure <span class="markdown-error">.*?<\/p>$/);
});
it(`notfigure `, async function() {
let result = await render(this.test.title);
result.trim().should.match(/^<p>notfigure <span class="markdown-error">.*?<\/p>$/);
});
it(`notfigure `, async function() {
let result = await render(this.test.title);
result.trim().should.match(/^<p>notfigure <span class="markdown-error">.*?<\/p>$/);
});
it(``, async function() {
let result = await render(this.test.title);
result.trim().should.be.html(`<figure><div class="image" style="width:200px">
<div class="image__ratio" style="padding-top:50%"></div>
<img src="/url" alt="" height="100" width="200" class="image__image">
</div></figure>`);
});
it(`## Header [#anchor]`, async function() {
let result = await render(this.test.title);
result.trim().should.be.html('<h2><a class="main__anchor" name="anchor" href="#anchor">Header</a></h2>');
});
it(`## My header`, async function() {
let result = await render(this.test.title);
result.trim().should.be.html('<h2><a class="main__anchor" name="my-header" href="#my-header">My header</a></h2>');
});
0 && it(`## Tag <script>`, async function() {
let result = await render(this.test.title);
result.trim().should.be.html('<h2><a class="main__anchor" name="tag" href="#tag">Tag <script></a></h2>');
});
it(`\`\`\`compare
- Полная интеграция с HTML/CSS.
- Простые вещи делаются просто.
- Поддерживается всеми распространёнными браузерами и включён по умолчанию.
\`\`\``, async function() {
let result = await render(this.test.title);
result.trim().should.be.html(`
<div class="balance balance_single">
<div class="balance__minuses">
<div class="balance__content">
<ul class="balance__list">
<li>Полная интеграция с HTML/CSS.</li>
<li>Простые вещи делаются просто.</li>
<li>Поддерживается всеми распространёнными браузерами и включён по умолчанию.</li>
</ul>
</div>
</div>
</div>`);
});
it(`\`\`\`compare
+ one
- two
\`\`\``, async function() {
let result = await render(this.test.title);
result.trim().should.be.html(`<div class="balance">
<div class="balance__pluses">
<div class="balance__content">
<div class="balance__title">Достоинства</div>
<ul class="balance__list">
<li>one</li>
</ul>
</div>
</div>
<div class="balance__minuses">
<div class="balance__content">
<div class="balance__title">Недостатки</div>
<ul class="balance__list">
<li>two</li>
</ul>
</div>
</div>
</div>`);
});
});
| 30.385321 | 118 | 0.601147 |
770a5d188c47591c722c415a3e8cc6bd42143781 | 82 | js | JavaScript | trananhtuan-hust/lesson2/gen-key.js | tatuan19/blockchain-course-032021 | b08af03cdbb6cbc3bc06ac91489edca4480f55bb | [
"MIT"
] | null | null | null | trananhtuan-hust/lesson2/gen-key.js | tatuan19/blockchain-course-032021 | b08af03cdbb6cbc3bc06ac91489edca4480f55bb | [
"MIT"
] | null | null | null | trananhtuan-hust/lesson2/gen-key.js | tatuan19/blockchain-course-032021 | b08af03cdbb6cbc3bc06ac91489edca4480f55bb | [
"MIT"
] | null | null | null | const requests = require("./requests");
console.log(requests.generateKeyPairs()); | 27.333333 | 41 | 0.756098 |
770ac09b131381fbf23ab94fd25ad08357323111 | 6,559 | js | JavaScript | ForumArchive/acc/post_34294_page_1.js | doc22940/Extensions | d8dbc9be08e0b8c0bd6b72e068ef73223d2799a8 | [
"Apache-2.0"
] | 136 | 2015-01-01T17:33:35.000Z | 2022-02-26T16:38:08.000Z | ForumArchive/acc/post_34294_page_1.js | doc22940/Extensions | d8dbc9be08e0b8c0bd6b72e068ef73223d2799a8 | [
"Apache-2.0"
] | 60 | 2015-06-20T00:39:16.000Z | 2021-09-02T22:55:27.000Z | ForumArchive/acc/post_34294_page_1.js | doc22940/Extensions | d8dbc9be08e0b8c0bd6b72e068ef73223d2799a8 | [
"Apache-2.0"
] | 141 | 2015-04-29T09:50:11.000Z | 2022-03-18T09:20:44.000Z | [{"Owner":"hunts","Date":"2017-11-29T22:14:05Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\tlocation and rotation is already applied\n_lt_/p_gt_\n\n_lt_p_gt_\n\ti tried playing my gltf model in the sandbox_co_\n_lt_/p_gt_\n\n_lt_p_gt_\n\tthis is the model i used _eq_ _lt_a href_eq__qt_https_dd_//www.dropbox.com/s/d1hkket6n0i1b4e/hit_reaction.fbx?dl_eq_0_qt_ rel_eq__qt_external nofollow_qt__gt_https_dd_//dl.dropbox.com/s/d1hkket6n0i1b4e/hit_reaction.fbx_lt_/a_gt_\n_lt_/p_gt_\n\n_lt_p_gt_\n\there_t_s the result\n_lt_/p_gt_\n\n_lt_p_gt_\n\t_lt_a class_eq__qt_ipsAttachLink ipsAttachLink_image_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/uploads/monthly_2017_11/5a1f308daf1f8_Screenshot2017-11-2916_59_23.png.ed3e7a7668cc98755e2e756debff9b43.png_qt_ data-fileid_eq__qt_16037_qt_ rel_eq__qt__qt__gt__lt_img class_eq__qt_ipsImage ipsImage_thumbnailed_qt_ data-fileid_eq__qt_16037_qt_ src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/monthly_2017_11/5a1f308f8c4fa_Screenshot2017-11-2916_59_23.thumb.png.40855e38c413d152491e3d7d312b4338.png_qt_ alt_eq__qt_5a1f308f8c4fa_Screenshot2017-11-2916_59_23.thumb.png.40855e38c413d152491e3d7d312b4338.png_qt_ /_gt__lt_/a_gt_\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"Sebavan","Date":"2017-11-30T01:59:35Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\tping _lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/26831-bghgary/?do_eq_hovercard_qt_ data-mentionid_eq__qt_26831_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/26831-bghgary/_qt_ rel_eq__qt__qt__gt_@bghgary_lt_/a_gt_\n_lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"bghgary","Date":"2017-11-30T02:00:31Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\t_lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/25354-hunts/?do_eq_hovercard_qt_ data-mentionid_eq__qt_25354_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/25354-hunts/_qt_ rel_eq__qt__qt__gt_@hunts_lt_/a_gt_ How did you convert the fbx to glTF?\n_lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"hunts","Date":"2017-11-30T03:41:35Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\t_lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/26831-bghgary/?do_eq_hovercard_qt_ data-mentionid_eq__qt_26831_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/26831-bghgary/_qt_ rel_eq__qt__qt__gt_@bghgary_lt_/a_gt_ through blender\n_lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"Sebavan","Date":"2017-11-30T03:48:07Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\t_lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/25354-hunts/?do_eq_hovercard_qt_ data-mentionid_eq__qt_25354_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/25354-hunts/_qt_ rel_eq__qt__qt__gt_@hunts_lt_/a_gt_ could you share the gltf files ? and are they working in other gltf viewers ?\n_lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"hunts","Date":"2017-11-30T22:24:03Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\t_lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/20193-sebavan/?do_eq_hovercard_qt_ data-mentionid_eq__qt_20193_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/20193-sebavan/_qt_ rel_eq__qt__qt__gt_@Sebavan_lt_/a_gt_\n_lt_/p_gt_\n\n_lt_p_gt_\n\t_lt_a href_eq__qt_https_dd_//www.dropbox.com/s/fafy098wep6ftoj/2armyuntitled.bin?dl_eq_0_qt_ rel_eq__qt_external nofollow_qt__gt_https_dd_//dl.dropbox.com/s/fafy098wep6ftoj/2armyuntitled.bin_lt_/a_gt_\n_lt_/p_gt_\n\n_lt_p_gt_\n\t_lt_a href_eq__qt_https_dd_//www.dropbox.com/s/bafqd0z32ymutat/2armyuntitled.gltf?dl_eq_0_qt_ rel_eq__qt_external nofollow_qt__gt_https_dd_//dl.dropbox.com/s/bafqd0z32ymutat/2armyuntitled.gltf_lt_/a_gt_\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"Sebavan","Date":"2017-11-30T23:40:47Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\tperfect thx_co_ ping _lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/26831-bghgary/?do_eq_hovercard_qt_ data-mentionid_eq__qt_26831_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/26831-bghgary/_qt_ rel_eq__qt__qt__gt_@bghgary_lt_/a_gt__co_ the model is here _dd_-)\n_lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"bghgary","Date":"2017-11-30T23:55:28Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\t_lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/25354-hunts/?do_eq_hovercard_qt_ data-mentionid_eq__qt_25354_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/25354-hunts/_qt_ rel_eq__qt__qt__gt_@hunts_lt_/a_gt_ This seems to be a Blender issue. three.js viewer does the same thing as BabylonJS. I am able to import the fbx into Unity and export into a working glTF using my exporter.\n_lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"dbawel","Date":"2017-12-01T04:17:22Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\t_lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/25354-hunts/?do_eq_hovercard_qt_ data-mentionid_eq__qt_25354_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/25354-hunts/_qt_ rel_eq__qt__qt__gt_@hunts_lt_/a_gt_-\n_lt_/p_gt_\n\n_lt_p_gt_\n\tI recommend using the free FBX converter. It is always reliable in setting the correct version of FBX both ascii and binary to ensure compatibility.\n_lt_/p_gt_\n\n_lt_p_gt_\n\tDB\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"}] | 6,559 | 6,559 | 0.853026 |
770b152dc0face4f27fa26924f499f4a688d5420 | 1,350 | js | JavaScript | components/MessageItem.js | WoleIlori/React-Native-Chat-App | 6209819bc4a4051d9cd5b1f8a9f1ae0706699643 | [
"MIT"
] | null | null | null | components/MessageItem.js | WoleIlori/React-Native-Chat-App | 6209819bc4a4051d9cd5b1f8a9f1ae0706699643 | [
"MIT"
] | null | null | null | components/MessageItem.js | WoleIlori/React-Native-Chat-App | 6209819bc4a4051d9cd5b1f8a9f1ae0706699643 | [
"MIT"
] | null | null | null | import React from 'react';
import {StyleSheet, Text, View} from 'react-native'
const OTHER = "Kevin"
const handleDateDisplay = date=>{
const split = date.split(" ")
if(split[0] === new Date().toLocaleDateString()){
return split[1]
}
return date
}
const MessageItem = props => (
//Patient Name
<View style={{justifyContent: 'space-between', flexDirection: 'row'}}>
{props.sender === OTHER && (
<View style={{width: 50}}/>
)}
<View>
<View style={props.sender === OTHER ? [styles.messageBubble,styles.messageBubbleRight]: [styles.messageBubble,styles.messageBubbleLeft]}>
<Text style={{color:"white"}}>
{props.message}
</Text>
</View>
<Text>{handleDateDisplay(props.date)}</Text>
</View>
{props.sender !== OTHER && (
<View style={{width: 50}}/>
)}
</View>
)
const styles = StyleSheet.create({
//MessageBubble
messageBubble: {
borderRadius: 5,
marginTop: 8,
paddingHorizontal: 10,
paddingVertical: 5,
flexWrap: 'wrap'
},
messageBubbleRight: {
backgroundColor: '#d5d8d4',
},
messageBubbleLeft: {
backgroundColor: '#66db30',
},
})
export default MessageItem
| 22.881356 | 151 | 0.548148 |
770c90a3c95b9fc074e04707a4689a1b614df039 | 424 | js | JavaScript | src/store.js | Masa331/mekbadzappa | 1afe9ec334607226dab82c43d3edd55804caa714 | [
"MIT"
] | null | null | null | src/store.js | Masa331/mekbadzappa | 1afe9ec334607226dab82c43d3edd55804caa714 | [
"MIT"
] | null | null | null | src/store.js | Masa331/mekbadzappa | 1afe9ec334607226dab82c43d3edd55804caa714 | [
"MIT"
] | null | null | null | export const Store = {
get() {
return JSON.parse(localStorage.getItem('MekBadzappa')) || this.blank()
},
set(value) {
localStorage.setItem('MekBadzappa', JSON.stringify(value))
},
mergeAndSet(value) {
let currentData = this.get()
let newData = Object.assign(currentData, value)
this.set(newData)
return newData
},
blank() {
return { hours: '', description: '', data: [] }
}
}
| 19.272727 | 74 | 0.617925 |
770fa5e5ac36b30a90bd9ba56f59c8f676c18d3d | 465 | js | JavaScript | src/firebase-root.js | romannurik/dataurl.app | 3cd74475a3e0bf96b0cc547366d5aecbdf3655fe | [
"Apache-2.0"
] | 8 | 2020-11-16T18:51:25.000Z | 2022-01-22T19:31:39.000Z | src/firebase-root.js | romannurik/dataurl.app | 3cd74475a3e0bf96b0cc547366d5aecbdf3655fe | [
"Apache-2.0"
] | 2 | 2020-11-19T16:46:42.000Z | 2020-11-26T19:08:02.000Z | src/firebase-root.js | romannurik/dataurl.app | 3cd74475a3e0bf96b0cc547366d5aecbdf3655fe | [
"Apache-2.0"
] | 3 | 2021-02-09T12:51:28.000Z | 2021-12-19T10:33:22.000Z | import firebase from 'firebase/app';
import 'firebase/analytics';
firebase.initializeApp({
apiKey: "AIzaSyCp8fs-nMOQ-rQInNgc68mU8wXxGOrkDHg",
authDomain: "dataurl-app.firebaseapp.com",
databaseURL: "https://dataurl-app.firebaseio.com",
projectId: "dataurl-app",
storageBucket: "dataurl-app.appspot.com",
messagingSenderId: "280256532133",
appId: "1:280256532133:web:0263cee39eb645d1b2474c",
measurementId: "G-ZLL0WMG7FK"
});
firebase.analytics();
| 29.0625 | 53 | 0.76129 |
77116f4a138596f1a7dd685a15b379a48aab8710 | 1,429 | js | JavaScript | models/customersMdl.js | mfraht/-TravelExpertsINC | b6cded3663109cb5cc43f70c2241bc5defd5674d | [
"MIT"
] | null | null | null | models/customersMdl.js | mfraht/-TravelExpertsINC | b6cded3663109cb5cc43f70c2241bc5defd5674d | [
"MIT"
] | null | null | null | models/customersMdl.js | mfraht/-TravelExpertsINC | b6cded3663109cb5cc43f70c2241bc5defd5674d | [
"MIT"
] | 1 | 2021-08-03T16:29:29.000Z | 2021-08-03T16:29:29.000Z | //- Updated by: Mohamed Ibrahim
const mongoose = require("mongoose");
const uniqueValidator = require("mongoose-unique-validator");
const customerSchema = new mongoose.Schema({
_id: Number,
CustomerId: {
type: Number,
required: "CustomerId is required",
trim: true,
unique: "The CustomerId must be unique.",
// lowercase: true,
},
CustFirstName: {
type: String,
required: "First name is required",
trim: true,
},
CustLastName: {
type: String,
required: "Last name is required",
trim: true,
},
CustAddress: {
type: String,
trim: true,
},
CustCity: {
type: String,
trim: true,
},
CustProv: {
type: String,
trim: true,
},
CustPostal: {
type: String,
trim: true,
},
CustCountry: {
type: String,
trim: true,
},
CustHomePhone: {
type: Number,
trim: true,
},
CustBusPhone: {
type: Number,
trim: true,
},
CustEmail: {
type: String,
trim: true,
validate: {
validator: function (v) {
return /^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})*$/.test(v);
},
message: (props) => `${props.value} is not a valid Email address.`,
},
AgentId: {
type: Number,
trim: true,
},
},
});
customerSchema.plugin(uniqueValidator);
// Create a model User using the userSchema
module.exports.Customer = mongoose.model("customer", customerSchema);
| 20.126761 | 77 | 0.585724 |
771457e7d002c013255d22dd99a27cf62bfb7f0c | 89 | js | JavaScript | OS/AppMan/src/renderer/antDesignVue.js | ywymoshi/JSCourse | 7f030d1e487ca5ad33e2b52348b10f6ca71207a3 | [
"MIT"
] | 5 | 2021-03-31T13:17:41.000Z | 2021-08-07T12:13:11.000Z | OS/AppMan/src/renderer/antDesignVue.js | ywymoshi/JSCourse | 7f030d1e487ca5ad33e2b52348b10f6ca71207a3 | [
"MIT"
] | null | null | null | OS/AppMan/src/renderer/antDesignVue.js | ywymoshi/JSCourse | 7f030d1e487ca5ad33e2b52348b10f6ca71207a3 | [
"MIT"
] | null | null | null | import Vue from "vue";
import { DatePicker } from "ant-design-vue";
Vue.use(DatePicker);
| 22.25 | 44 | 0.719101 |
771693fc3c026f55a9d5c12723fa88d300566e74 | 83 | js | JavaScript | assets/js/main.js | xiaohan2012/xiaohan2012.github.io | b76f518695a14152c30f18bbfc9149c4f2cd8456 | [
"Unlicense",
"MIT"
] | 89 | 2016-07-21T11:49:36.000Z | 2021-11-25T20:22:34.000Z | assets/js/main.js | xiaohan2012/xiaohan2012.github.io | b76f518695a14152c30f18bbfc9149c4f2cd8456 | [
"Unlicense",
"MIT"
] | 73 | 2017-05-30T13:36:48.000Z | 2018-01-12T03:51:17.000Z | assets/js/main.js | xiaohan2012/xiaohan2012.github.io | b76f518695a14152c30f18bbfc9149c4f2cd8456 | [
"Unlicense",
"MIT"
] | 140 | 2016-07-23T18:08:15.000Z | 2022-03-17T20:32:49.000Z | (function () {
'use strict';
// Your additional js should go there
}());
| 11.857143 | 41 | 0.554217 |
771694c7a59b813b1763cb85f98b79637831127f | 16,990 | js | JavaScript | controllers/patient.js | medhelp-app/api | b8297687f01797734a9aea9514a7c024b0b9fada | [
"MIT"
] | null | null | null | controllers/patient.js | medhelp-app/api | b8297687f01797734a9aea9514a7c024b0b9fada | [
"MIT"
] | null | null | null | controllers/patient.js | medhelp-app/api | b8297687f01797734a9aea9514a7c024b0b9fada | [
"MIT"
] | null | null | null | var Patient = require('../models/patient');
var UserController = require('../controllers/user');
var Functions = require('../util/functions');
var fs = require('fs');
function PatientController () {
this.functions = new Functions();
}
PatientController.prototype.getAll = function(callback) {
Patient.find(function (error, patients) {
if (error) {
callback(null, error);
} else {
callback(patients);
}
});
};
PatientController.prototype.insert = function (_patient, callback) {
var patient = new Patient();
patient._id = _patient._id;
patient.addressStreet = _patient.addressStreet;
patient.addressNumber = _patient.addressNumber;
patient.city = _patient.city;
patient.state = _patient.state;
patient.zipCode = _patient.zipCode;
patient.country = _patient.country;
patient.phone = _patient.phone;
patient.crm = _patient.crm;
patient.save(function (error, patient) {
if (error) {
callback(null, error);
} else {
callback(patient);
}
})
}
PatientController.prototype.getForId = function (idUser, callback) {
var userController = new UserController();
Patient.findOne({ _id: idUser },function (error, patient) {
if (error) {
callback(null, error);
} else {
if (patient) {
userController.getForId(idUser, function (user, error) {
if (error) {
callback(null, error);
} else {
var userFull = {
_id: patient._id,
name: user.name,
email: user.email,
userType: user.userType,
profileImage: user.profileImage,
addressStreet: patient.addressStreet,
addressNumber: patient.addressNumber,
city: patient.city,
state: patient.state,
zipCode: patient.zipCode,
country: patient.country,
phone: patient.phone,
healthInsurance: patient.healthInsurance
}
callback(userFull);
}
});
} else {
callback({ error : "Paciente não existente." });
}
}
})
};
PatientController.prototype.getForIdImage = function (idUser, callback) {
var userController = new UserController();
Patient.findOne({ _id: idUser },function (error, patient) {
if (error) {
callback(null, error);
} else {
if (patient) {
userController.getForId(idUser, function (user, error) {
if (error) {
callback(null, error);
} else {
var image = {
profileImage: patient.profileImage
};
callback(image);
}
});
} else {
callback({ error : "Paciente não existente." });
}
}
})
};
PatientController.prototype.update = function (id, _patient, callback) {
var userController = new UserController();
var functions = this.functions;
userController.getForId(id, function (user, error) {
if (error) {
callback({error: 'Id inválido.'});
} else {
if (_patient.email === '' || _patient.name === '') {
callback({ error : "O campo 'nome' e 'e-mail' são obrigatórios." });
} else {
if (functions.validateEmail(_patient.email)) {
var userUpdate = {
name: _patient.name,
email: _patient.email
};
Patient.findOne({ _id: id }, function (error, patientUpdate) {
patientUpdate.addressStreet = _patient.addressStreet;
patientUpdate.addressNumber = _patient.addressNumber;
patientUpdate.city = _patient.city;
patientUpdate.state = _patient.state;
patientUpdate.zipCode = _patient.zipCode;
patientUpdate.country = _patient.country;
patientUpdate.phone = _patient.phone;
patientUpdate.healthInsurance = _patient.healthInsurance ? _patient.healthInsurance : '';
if (user.email === _patient.email) {
userController.update(id, userUpdate, function (error) {
if (error) {
callback(error);
} else {
patientUpdate.save(function (error) {
if (error) {
callback(error);
} else {
callback({ sucess: "ok" });
}
});
}
});
} else {
userController.getEmail(_patient.email, function (users, erros) {
if (erros) {
callback(erros);
} else {
if (users.length === 0) {
userController.update(id, userUpdate, function (error) {
if (error) {
callback(error);
} else {
patientUpdate.save(function (error) {
if (error) {
callback(error);
} else {
callback({ sucess: "ok" });
}
});
};
});
} else {
callback({ error : 'E-mail já existente.' });
};
};
});
};
})
} else {
callback({ error: 'E-mail inválido.' });
};
}
};
});
};
PatientController.prototype.updateImage = function (id, _image, callback) {
var userController = new UserController();
var functions = this.functions;
userController.getForId(id, function (user, error) {
if (error) {
callback({error: 'Id inválido.'});
} else {
fs.readFile('./uploads/'+_image.filename, function (error, data) {
data = new Buffer(data).toString('base64');
if(error){
callback(null,error);
} else {
Patient.findOn({ _id: id }, function (error, patient) {
patient.profileImage = data;
patient.save(function (error) {
if (error) {
fs.unlink('./uploads/'+_image.filename);
callback(error);
} else {
fs.unlink('./uploads/'+_image.filename);
callback({ sucess: "ok" });
}
})
})
}
});
};
});
};
PatientController.prototype.delete = function(id, callback) {
User.remove({ _id: id }, function (error) {
if (error) {
callback(null, { error: 'ID inválido.' });
} else {
Patient.remove({_id: id},function (error, user) {
if(error){
callback(null, error);
}else{
callback({ message: 'Removido com sucesso.' });
}
})
}
});
};
/* --------------------------bodyPart--------------------------------*/
PatientController.prototype.getBodyPartById = function (idUser, callback) {
Patient.findOne({ _id: idUser },function (error, patient) {
if (error) {
callback(null, error);
} else {
if (patient) {
callback(patient.bodyPart)
} else {
callback({ error : "Paciente não existente." });
}
}
})
};
PatientController.prototype.insertProblem = function (idUser,_problem, callback) {
Patient.findOne({ _id: idUser },function (error, patient) {
if (error) {
callback(null, error);
} else {
if (patient) {
var problem = {
local:_problem.local,
problem: _problem.problem,
description: _problem.description,
severity: _problem.severity,
occurredDate : _problem.occurredDate,
resolved: _problem.resolved,
level: _problem.level
}
if(_problem.part === 'rightArm'){
if(_problem.subpart === 'hand'){
patient.bodyPart[0].problems.push(problem);
}else if(_problem.subpart === 'forearm'){
patient.bodyPart[1].problems.push(problem);
}else if(_problem.subpart === 'elbow'){
patient.bodyPart[2].problems.push(problem);
}else if(_problem.subpart === 'arm'){
patient.bodyPart[3].problems.push(problem);
}
patient.save(function (error) {
if(error){
callback({ success : "false" })
}else{
callback({ success: "true" })
}
})
}else if(_problem.part === 'leftArm'){
if(_problem.subpart === 'hand'){
patient.bodyPart[4].problems.push(problem);
}else if(_problem.subpart === 'forearm'){
patient.bodyPart[5].problems.push(problem);
}else if(_problem.subpart === 'elbow'){
patient.bodyPart[6].problems.push(problem);
}else if(_problem.subpart === 'arm'){
patient.bodyPart[7].problems.push(problem);
}
patient.save(function (error) {
if(error){
callback({ success : "false" })
}else{
callback({ success: "true" })
}
});
}else if(_problem.part === 'rightLeg'){
if(_problem.subpart === 'foot'){
patient.bodyPart[8].problems.push(problem);
}else if(_problem.subpart === 'leg'){
patient.bodyPart[9].problems.push(problem);
}else if(_problem.subpart === 'thigh'){
patient.bodyPart[10].problems.push(problem);
}else if(_problem.subpart === 'knee'){
patient.bodyPart[11].problems.push(problem);
}
patient.save(function (error) {
if(error){
callback({ success : "false" })
}else{
callback({ success: "true" })
}
})
}else if(_problem.part === 'leftLeg'){
if(_problem.subpart === 'foot'){
patient.bodyPart[12].problems.push(problem);
}else if(_problem.subpart === 'leg'){
patient.bodyPart[13].problems.push(problem);
}else if(_problem.subpart === 'thigh'){
patient.bodyPart[14].problems.push(problem);
}else if(_problem.subpart === 'knee'){
patient.bodyPart[15].problems.push(problem);
}
patient.save(function (error) {
if(error){
callback({ success : "false" })
}else{
callback({ success: "true" })
}
})
}else if(_problem.part === 'trunk'){
if(_problem.subpart === 'thorax'){
patient.bodyPart[16].problems.push(problem);
}else if(_problem.subpart === 'loin'){
patient.bodyPart[17].problems.push(problem);
}else if(_problem.subpart === 'abdomen'){
patient.bodyPart[18].problems.push(problem);
}
patient.save(function (error) {
if(error){
callback({ success : "false" })
}else{
callback({ success: "true" })
}
})
}else if(_problem.part === 'head'){
if(_problem.subpart === 'face'){
patient.bodyPart[19].problems.push(problem);
}else if(_problem.subpart === 'head'){
patient.bodyPart[20].problems.push(problem);
}
patient.save(function (error) {
if(error){
callback({ success : "false" })
}else{
callback({ success: "true" })
}
})
}else{
callback({ error : "false" });
}
} else {
callback({ error : "Paciente não existente." });
}
}
})
}
PatientController.prototype.getProblemsByPart = function (idUser, part, callback) {
Patient.find({_id: idUser},{ bodyPart: { $elemMatch: { part: part } }},function (error, patient) {
if(error){
callback(error);
}else{
if(patient.length===0){
callback({ error : "Paciente não existene." });
}else{
if(patient[0].bodyPart.length===0){
callback({ error : "Parte do corpo não existente." });
}else {
callback(patient[0].bodyPart[0].problems);
}
}
}
})
};
PatientController.prototype.updateProblem = function (idUser,_problem, callback) {
Patient.findOne({_id: idUser} , function (error, patient) {
if (error) {
callback(error);
} else {
for(i=0;i<patient.bodyPart.length;i++){
for(j=0;j<patient.bodyPart[i].problems.length;j++){
if(patient.bodyPart[i].problems[j]._id ==_problem.idItem){
patient.bodyPart[i].problems[j].description = _problem.description;
patient.bodyPart[i].problems[j].local = _problem.local;
patient.bodyPart[i].problems[j].occurredDate = _problem.occurredDate;
patient.bodyPart[i].problems[j].problem = _problem.problem;
patient.bodyPart[i].problems[j].resolved = _problem.resolved;
patient.bodyPart[i].problems[j].severity = _problem.severity;
patient.bodyPart[i].problems[j].level = _problem.level;
}
}
}
patient.save(function (error) {
if(error){
callback({ success : "false" })
}else{
callback({ success: "true" })
}
});
}
});
}
module.exports = PatientController; | 39.60373 | 113 | 0.408711 |
77172efb87e69a4f2d3c4a21279b327174ad6eb9 | 502 | js | JavaScript | src/pages/contact.js | hugofabricio/hugo | 9e5ae3514f7786e6af7f23a20d6b9217a754310d | [
"MIT"
] | null | null | null | src/pages/contact.js | hugofabricio/hugo | 9e5ae3514f7786e6af7f23a20d6b9217a754310d | [
"MIT"
] | 7 | 2021-05-10T12:33:36.000Z | 2022-02-26T17:29:26.000Z | src/pages/contact.js | hugofabricio/hugo | 9e5ae3514f7786e6af7f23a20d6b9217a754310d | [
"MIT"
] | null | null | null | import React from "react"
import Layout from "../components/Layout"
import SEO from "../components/Seo"
import Contact from "../components/Contact"
const ContactPage = () => (
<Layout>
<SEO title="Let's talk" body={{ class: "pink" }} />
<Contact
title="Let's talk about everything!"
slogan="Got an idea? A new project? Need support?<br> I will be happy to help you."
email="me@hugofabricio.com"
phone="83 98805-0131"
/>
</Layout>
)
export default ContactPage
| 25.1 | 89 | 0.649402 |
7717d04c64af59b76446424b417e991a6fe6c2c8 | 4,485 | js | JavaScript | src/v1/controller/hr-module/kpi.js | khaliqCodes/erp-backend | f0b23cf60395c4634a0c40e69848e0f446cb6e7d | [
"MIT"
] | null | null | null | src/v1/controller/hr-module/kpi.js | khaliqCodes/erp-backend | f0b23cf60395c4634a0c40e69848e0f446cb6e7d | [
"MIT"
] | null | null | null | src/v1/controller/hr-module/kpi.js | khaliqCodes/erp-backend | f0b23cf60395c4634a0c40e69848e0f446cb6e7d | [
"MIT"
] | null | null | null | 'use strict'
const {confirmAccessLevel} = require("../../core/access-management")
const {errorHandling} = require("../../core/error-handler")
const {uid, sanitizeUserInput} = require("../../core/classes")
const {getDocumentWithKey, createDocument, updateDocumentByUid, searchDocument, deleteDocumentByUid} = require("../../core/elastic-search")
const kpiIndices = `#__kpi`
async function createKpi (request, response, next) {
try {
confirmAccessLevel(request.path, response.locals.user.accessUid, `create`)
// check for required fields
if (!request.body.kpiName) errorHandling(`400|KPI Name is required.|`)
if (!request.body.kpiTarget) errorHandling(`400|KPI Target is required.|`)
// sanitize user received input
const kpiAttributes = {
uid: uid(),
name: sanitizeUserInput(request.body.kpiName),
target: sanitizeUserInput(request.body.kpiTarget)
}
// check for duplicate kpi name
const duplicateKpi = await getDocumentWithKey({
indices: kpiIndices,
values: {
name: kpiAttributes.name
}
})
if (duplicateKpi.length > 0) errorHandling(`400|KPI name already exists|`)
// Create KPI
await createDocument({
indices: kpiIndices,
values: kpiAttributes
})
response.status(201).json()
} catch (e) {
next(new Error(e.stack))
}
}
async function modifyKpi (request, response, next) {
try {
// confirm access level
confirmAccessLevel(request.path, response.locals.user.accessUid, `update`)
// check required fields
if (!request.body.kpiUid) errorHandling(`400|KPI Uid is required.|`)
if (!request.body.kpiName) errorHandling(`400|KPI Name is required|`)
if (!request.body.kpiTarget) errorHandling(`400|KPI Target is required.|`)
// Sanitize user received input
const modifyKpiAttributes = {
uid: sanitizeUserInput(request.body.kpiUid),
name: sanitizeUserInput(request.body.kpiName),
target: sanitizeUserInput(request.body.kpiTarget),
}
// check if kpi details exists
if (await kpiExists(modifyKpiAttributes.uid) === false) errorHandling(`400|KPI records not found.|`)
// update kpi details
await updateDocumentByUid({
indices: kpiIndices,
values: modifyKpiAttributes
})
response.status(200).json()
} catch (e) {
next(new Error(e.stack))
}
}
async function deleteKpi (request, response, next) {
try {
confirmAccessLevel(request.path, response.locals.user.accessUid, `delete`)
// confirm required field
if (!request.params.kpiUid) errorHandling(`400|KPI Uid is required.|`)
// sanitize user received input
const kpiUid = sanitizeUserInput(request.params.kpiUid)
if (await kpiExists(kpiUid) === false) errorHandling(`400|KPI records not found.|`)
// delete kpi details
await deleteDocumentByUid({
indices: kpiIndices,
uid: kpiUid
})
response.status(200).json()
} catch (e) {
next(new Error(e.stack))
}
}
async function getAllKpiRecords (request, response, next) {
try {
// confirm access to endpoint
confirmAccessLevel(request.path, response.locals.user.accessUid, `read`)
const kpiRecords = await allKpiRecords()
response.status(200).json(kpiRecords)
} catch (e) {
next(new Error(e.stack))
}
}
async function kpiExists (kpiUid) {
// Confirm KPI Uid exists
const kpiExists = await getDocumentWithKey({
indices: kpiIndices,
values: {
uid: kpiUid
}
})
return kpiExists.length >= 1
}
async function allKpiRecords () {
return await searchDocument({
indices: kpiIndices,
values: {
query: {
match_all: {} // returns all users
},
_source: {
include: [
'uid',
'name',
'target'
]
},
sort: {
created: 'desc'
},
from: 0,
size : 10000,
}
})
}
module.exports = {
createKpi,
modifyKpi,
deleteKpi,
getAllKpiRecords,
allKpiRecords // Usable in other files
} | 32.737226 | 139 | 0.59019 |
77186da1ccd73aae8c1371ae80fb95491b3238e0 | 4,797 | js | JavaScript | data/split-book-data/1799755657.1641439054816.js | Nicodemous55/my-audible-library | d24c0adbff4007a28ec23f2a0200ffaa7e6b4172 | [
"0BSD"
] | null | null | null | data/split-book-data/1799755657.1641439054816.js | Nicodemous55/my-audible-library | d24c0adbff4007a28ec23f2a0200ffaa7e6b4172 | [
"0BSD"
] | null | null | null | data/split-book-data/1799755657.1641439054816.js | Nicodemous55/my-audible-library | d24c0adbff4007a28ec23f2a0200ffaa7e6b4172 | [
"0BSD"
] | null | null | null | window.peopleAlsoBoughtJSON = [{"asin":"1713547058","authors":"C. T. Rwizi","cover":"51rj84xR3BL","length":"20 hrs and 39 mins","narrators":"Korey Jackson, Susan Dalian, Kimberly Woods, and others","subHeading":"Scarlet Odyssey, Book 2","title":"Requiem Moon"},{"asin":"1549190911","authors":"M. A. Carrick","cover":"514yIaJgQ-L","length":"23 hrs and 13 mins","narrators":"Nikki Massoud","title":"The Mask of Mirrors"},{"asin":"059328741X","authors":"Naomi Novik","cover":"41g75wumgPL","length":"10 hrs and 59 mins","narrators":"Anisha Dadia","subHeading":"A Novel (The Scholomance, Book 1)","title":"A Deadly Education"},{"asin":"B003XO3RKK","authors":"Nnedi Okorafor","cover":"417OKZMczfL","length":"15 hrs and 11 mins","narrators":"Anne Flosnik","title":"Who Fears Death"},{"asin":"1799764621","authors":"James Maxwell","cover":"51j-kIOsK8L","length":"12 hrs and 24 mins","narrators":"Simon Vance","subHeading":"The Firewall Trilogy, Book 1","title":"A Girl from Nowhere"},{"asin":"1774241064","authors":"Edward W. Robertson","cover":"51lNIElqUhL","length":"10 hrs and 22 mins","narrators":"Tim Gerard Reynolds","subHeading":"The Cycle of the Scour, Book 1","title":"The Sealed Citadel"},{"asin":"198009036X","authors":"Guy Gavriel Kay","cover":"51pWlrzlf2L","length":"24 hrs and 51 mins","narrators":"Simon Vance","title":"Tigana"},{"asin":"1797103504","authors":"Matt Wallace","cover":"51i9qcmQvAL","length":"15 hrs and 20 mins","narrators":"Lameece Issaq","subHeading":"Savage Rebellion","title":"Savage Legion"},{"asin":"B08Q2BVNGC","authors":"Dyrk Ashton","cover":"51Su65Ly9nL","length":"61 hrs and 43 mins","narrators":"Nik Magill","title":"Paternus: The Complete Trilogy"},{"asin":"B07LCSP3LZ","authors":"Aron Stone","cover":"51ZAmNQ9R0L","length":"12 hrs and 49 mins","narrators":"Gary Furlong","subHeading":"Conquering the Kingdom, Book 1","title":"Conquer"},{"asin":"1713502402","authors":"Charlie N. Holmberg","cover":"51ENBiWtw2L","length":"9 hrs and 47 mins","narrators":"Elizabeth Knowelden, Joel Froomkin","subHeading":"Spellbreaker, Book 1","title":"Spellbreaker"},{"asin":"1774243849","authors":"Derrick Smythe","cover":"51och7K9NGL","length":"20 hrs and 19 mins","narrators":"Greg Patmore","subHeading":"Passage to Dawn, Book 1","title":"The Other Magic"},{"asin":"1713561395","authors":"Veronica G. Henry","cover":"51AmoQ4YGDS","length":"12 hrs and 6 mins","narrators":"Robin Miles","title":"Bacchanal"},{"asin":"0063004437","authors":"Roseanne A. Brown","cover":"51lzWj33LzL","length":"12 hrs and 4 mins","narrators":"Jordan Cobb, A. J Beckles","title":"A Song of Wraiths and Ruin"},{"asin":"1721389849","authors":"Luanne G. Smith","cover":"51W3D7GBjgL","length":"8 hrs and 42 mins","narrators":"Susannah Jones","subHeading":"The Vine Witch, Book 1","title":"The Vine Witch"},{"asin":"B07VVT4LGH","authors":"Michael R. Miller","cover":"51f1IKkwENS","length":"45 hrs and 58 mins","narrators":"Dave Cruse","subHeading":"A Complete Epic Fantasy Series","title":"The Dragon's Blade Trilogy"},{"asin":"1799755355","authors":"Barbara Davis","cover":"51jMZfYmJJL","length":"12 hrs and 58 mins","narrators":"Sarah Mollo-Christensen","subHeading":"A Novel","title":"The Last of the Moon Girls"},{"asin":"1713598566","authors":"Matthew FitzSimmons","cover":"41XDIl41LrL","length":"10 hrs and 57 mins","narrators":"January LaVoy","subHeading":"Constance, Book 1","title":"Constance"}];
window.bookSummaryJSON = "<p><b>“Thrillingly refreshing, a propulsive story built around a fascinating cast of characters...brutal and beautiful and bold and Black in every way.” - Tor.com</b></p> <p><b>Magic is women’s work; war is men’s. But in the coming battle, none of that will matter.</b></p> <p>Men do not become mystics. They become warriors. But eighteen-year-old Salo has never been good at conforming to his tribe’s expectations. For as long as he can remember, he has loved books and magic in a culture where such things are considered unmanly. Despite it being sacrilege, Salo has worked on a magical device in secret that will awaken his latent magical powers. And when his village is attacked by a cruel enchantress, Salo knows that it is time to take action.</p> <p>Salo’s queen is surprisingly accepting of his desire to be a mystic, but she will not allow him to stay in the tribe. Instead, she sends Salo on a quest. The quest will take him thousands of miles north to the Jungle City, the political heart of the continent. There he must gather information on a growing threat to his tribe.</p> <p>On the way to the city, he is joined by three fellow outcasts: a shunned female warrior, a mysterious nomad, and a deadly assassin. But they’re being hunted by the same enchantress who attacked Salo’s village. She may hold the key to Salo’s awakening - and his redemption.</p>";
| 1,599 | 3,398 | 0.725036 |
7718f4e0d8063fabfb5d79521c8d34614a83169f | 611 | js | JavaScript | public/js/edit.js | waperdomob/guiasAprendizaje | 79ac148ad38f4140b41663d846c88c753c9c9d1f | [
"MIT"
] | null | null | null | public/js/edit.js | waperdomob/guiasAprendizaje | 79ac148ad38f4140b41663d846c88c753c9c9d1f | [
"MIT"
] | null | null | null | public/js/edit.js | waperdomob/guiasAprendizaje | 79ac148ad38f4140b41663d846c88c753c9c9d1f | [
"MIT"
] | null | null | null | $(function(){
alert('hola');
$('ficha_id').on('change', onSelectFichaChange);
})
function onSelectFichaChange() {
var ficha_id = $(this).val();
if (!ficha_id){
$('#aprendiz').html('<option value="">Seleccione aprendiz</option>');
}
$.get('/guias/'+ficha_id+'/aprendices', function(data){
var html_select = '<option value="">Seleccione aprendiz</option>'
for (var i = 0; i < data.length; ++i) {
html_select += '<option value="'+data[i].id+'">'+data[i].name+'</option>';
$('#aprendiz').html(html_select);
}
});
} | 33.944444 | 92 | 0.536825 |
771a9925fbb5417522d6034d5f929a0ee3ab9a04 | 942 | js | JavaScript | src/pages/Character.js | adranuz/rick-n-morty-spa | 922274118a44305bb1df5bf138faa64739411a8e | [
"MIT"
] | null | null | null | src/pages/Character.js | adranuz/rick-n-morty-spa | 922274118a44305bb1df5bf138faa64739411a8e | [
"MIT"
] | 1 | 2022-02-19T00:21:13.000Z | 2022-02-19T00:21:13.000Z | src/pages/Character.js | adranuz/rick-n-morty-spa | 922274118a44305bb1df5bf138faa64739411a8e | [
"MIT"
] | null | null | null | import getHash from '../utils/getHash'
import getData from '../utils/getData'
const Character = async () => {
const id = getHash() //mediante el hash obtenemos el id
const character = await getData(id) //se manda el id a get data y me genera la peticion a la api con ese id
const view = `
<div class="Characters-inner">
<article class="Characters-card">
<img src="${character.image}" alt="${character.name}">
<h2>${character.name}</h2>
</article>
<article class="Characters-card">
<h3>Episodes: <span>${character.episode.length}<span></h3>
<h3>Status: <span>${character.status}<span></h3>
<h3>Species:<span>${character.species}<span></h3>
<h3>Gender: <span>${character.gender}<span></h3>
<h3>Origin: <span>${character.origin.name}<span></h3>
<h3>Last Location: <span>${character.location.name}<span></h3>
</article>
</div>
`
return view
}
export default Character | 37.68 | 109 | 0.646497 |
771af7b11616f8df43eaee37145b86ddd349fdce | 109 | js | JavaScript | src/App/Algorithms/Pathfinding/Content/mazeAlgorithms.js | bernatfogarasi/algorithm-visualizer | 3c945d89119ad886ecd642f7ac3d19dee9ad9ed3 | [
"MIT"
] | null | null | null | src/App/Algorithms/Pathfinding/Content/mazeAlgorithms.js | bernatfogarasi/algorithm-visualizer | 3c945d89119ad886ecd642f7ac3d19dee9ad9ed3 | [
"MIT"
] | null | null | null | src/App/Algorithms/Pathfinding/Content/mazeAlgorithms.js | bernatfogarasi/algorithm-visualizer | 3c945d89119ad886ecd642f7ac3d19dee9ad9ed3 | [
"MIT"
] | null | null | null | const first = {};
const mazeAlgorithms = [{ label: "First", func: first }];
export default mazeAlgorithms;
| 18.166667 | 57 | 0.688073 |
771b4c33eccf5477b4dd9e01748105a9469aee24 | 429 | js | JavaScript | js/goGame.js | larrykevin/memoryjs | 6d7848ec552ec54ea1e295001351231d341fbf7c | [
"MIT"
] | null | null | null | js/goGame.js | larrykevin/memoryjs | 6d7848ec552ec54ea1e295001351231d341fbf7c | [
"MIT"
] | null | null | null | js/goGame.js | larrykevin/memoryjs | 6d7848ec552ec54ea1e295001351231d341fbf7c | [
"MIT"
] | null | null | null | export const goGame = () => {
const welcome = document.querySelector('.welcome');
const table = document.querySelector('.table');
const headerScore = document.querySelector('.header__score');
const headerInitial = document.querySelector('.header__initial');
welcome.style.display = 'none';
headerInitial.style.display = 'none';
headerScore.style.display = 'flex';
table.style.display = 'grid';
} | 35.75 | 69 | 0.692308 |
771b7313889d73452083eb78f36f6d609428e9d6 | 3,152 | js | JavaScript | client/tailwind.config.js | scott306lr/fcs_orient_2021 | 3f343100340a58a1eeee5d89e7392492719f3309 | [
"MIT"
] | 2 | 2021-09-01T15:50:24.000Z | 2021-09-04T13:20:17.000Z | client/tailwind.config.js | scott306lr/fcs_orient_2021 | 3f343100340a58a1eeee5d89e7392492719f3309 | [
"MIT"
] | null | null | null | client/tailwind.config.js | scott306lr/fcs_orient_2021 | 3f343100340a58a1eeee5d89e7392492719f3309 | [
"MIT"
] | 1 | 2022-02-06T07:43:42.000Z | 2022-02-06T07:43:42.000Z | module.exports = {
purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {
colors: { // https://www.tailwindshades.com/
cusorange: {
50: '#FFFFFF',
100: '#FFFFFF',
200: '#FFFFFF',
300: '#FFFFFF',
400: '#EDEAE5',
500: '#D8D1C7',
600: '#C3B8A9',
700: '#AEA08B',
800: '#99876D',
900: '#7C6D57',
},
cusblue: {
50: '#F5F7F8',
100: '#E6EAED',
200: '#C8D2D8',
300: '#AAB9C3',
400: '#8CA1AE',
500: '#6E8899',
600: '#586E7C',
700: '#42535F',
800: '#2D3941',
900: '#181F23',
},
cusgreen: {
50: '#E1EFB4',
100: '#D9EB9F',
200: '#C9E275',
300: '#B8D94B',
400: '#A2C72A',
500: '#809D21',
600: '#5E7318',
700: '#3B490F',
800: '#191F06',
900: '#000000',
},
cusyellow: {
50: '#FBF2E1',
100: '#F8E8CB',
200: '#F2D39E',
300: '#ECBF71',
400: '#E6AB44',
500: '#DA951D',
600: '#AD7617',
700: '#805711',
800: '#53390B',
900: '#261A05',
},
areaA: { DEFAULT: '#FFFFFF', '50': '#FFFFFF', '100': '#FFFFFF', '200': '#FFFFFF', '300': '#FFFFFF', '400': '#FFFFFF', '500': '#FFFFFF', '600': '#E6E6E6', '700': '#CCCCCC', '800': '#B3B3B3', '900': '#999999'},
areaC: { DEFAULT: '#27BBFF', '50': '#FFFFFF', '100': '#F3FBFF', '200': '#C0EBFF', '300': '#8DDBFF', '400': '#5ACBFF', '500': '#27BBFF', '600': '#00A6F3', '700': '#0084C0', '800': '#00618D', '900': '#003E5A'},
areaE: { DEFAULT: '#FB874A', '50': '#FFFFFF', '100': '#FFFFFF', '200': '#FEEAE0', '300': '#FDC9AE', '400': '#FCA87C', '500': '#FB874A', '600': '#FA6618', '700': '#DA4E05', '800': '#A83C04', '900': '#762B03'},
areaN: { DEFAULT: '#EBC235', '50': '#FFFFFF', '100': '#FDFAEF', '200': '#F9ECC0', '300': '#F4DE92', '400': '#F0D063', '500': '#EBC235', '600': '#D8AC15', '700': '#A98711', '800': '#7B620C', '900': '#4C3D08'},
areaS: { DEFAULT: '#FF7D75', '50': '#FFFFFF', '100': '#FFFFFF', '200': '#FFFFFF', '300': '#FFDDDB', '400': '#FFADA8', '500': '#FF7D75', '600': '#FF4D42', '700': '#FF1D0F', '800': '#DB0D00', '900': '#A80A00'},
areaW: { DEFAULT: '#22E3AC', '50': '#EEFDF8', '100': '#D7FAF0', '200': '#AAF4DF', '300': '#7DEECE', '400': '#4FE9BD', '500': '#22E3AC', '600': '#18BA8C', '700': '#128D6A', '800': '#0C6048', '900': '#063326'},
silver: {
DEFAULT: '#c0c0c0',
},
}
},
},
// height: theme => ({
// auto: 'auto',
// ...theme('spacing'),
// full: '100%',
// screen: 'calc(var(--vh) * 100)',
// }),
// minHeight: theme => ({
// '0': '0',
// ...theme('spacing'),
// full: '100%',
// screen: 'calc(var(--vh) * 100)',
// }),
variants: {
extend: {},
},
plugins: [],
}
| 37.52381 | 227 | 0.41085 |
771cb98369a219cd836037417a5a1c0715cd2d89 | 1,630 | js | JavaScript | src/PickButtonBack.js | ninglee47/pickonemoive | b99ccc590cb81cef356663db14a80fa0122c8fdf | [
"MIT"
] | null | null | null | src/PickButtonBack.js | ninglee47/pickonemoive | b99ccc590cb81cef356663db14a80fa0122c8fdf | [
"MIT"
] | null | null | null | src/PickButtonBack.js | ninglee47/pickonemoive | b99ccc590cb81cef356663db14a80fa0122c8fdf | [
"MIT"
] | null | null | null | import React from 'react';
import ReactDOM from 'react-dom';
const apiKey = '361c5360d12fe6b74f04ebd76dfd7c4b'
const min_movie_id = 2
let latestUrl = `https://api.themoviedb.org/3/movie/latest?api_key=${apiKey}&language=en-US`
//generate random number
function getRandom(min,max){
return Math.floor(Math.random()*(max-min+1))+min;
};
async function getRamdonId() {
var res = await fetch(latestUrl);
var dat = await res.json();
var latest_movie_id = dat.id;
var random_movie_id = getRandom (min_movie_id, latest_movie_id);
//console.log(latest_movie_id);
//console.log(random_movie_id);
return random_movie_id
}
class Pick extends React.Component {
constructor(props) {
super(props);
this.state = {
movie: "Let's see...",
data: {}
}
}
handlePick() {
getRamdonId().then(value => {
//console.log(value)
this.setState({
movie: value
});
}).then( () => {
var movie_id = this.state.movie
let searchURl = `https://api.themoviedb.org/3/movie/${movie_id}?api_key=${apiKey}&language=en-US`
fetch(searchURl)
.then(res => res.json())
.then(data => {
//console.log(data)
this.setState({
data: data
})
})
})
}
render () {
return (
<div>{this.state.movie} {this.state.data.id}
<button onClick={()=>this.handlePick()}>Pick!</button>
</div>
)
}
}
export default Pick | 25.873016 | 109 | 0.546012 |
771d17491091daae2aab65b6fa31214d8edc5154 | 4,095 | js | JavaScript | backend/frontend/src/views/ResetPasswordView/ResetPasswordView.js | guilhermeKodama/Closetinn | 44d6792cfb0db9cce56db83f2e8c4b8777530f68 | [
"MIT"
] | null | null | null | backend/frontend/src/views/ResetPasswordView/ResetPasswordView.js | guilhermeKodama/Closetinn | 44d6792cfb0db9cce56db83f2e8c4b8777530f68 | [
"MIT"
] | null | null | null | backend/frontend/src/views/ResetPasswordView/ResetPasswordView.js | guilhermeKodama/Closetinn | 44d6792cfb0db9cce56db83f2e8c4b8777530f68 | [
"MIT"
] | null | null | null | import React, { Component } from 'react'
import { connect } from 'react-redux'
import { Button, FormControl } from 'react-bootstrap'
import styles from './ResetPasswordView.scss'
import CustomAlert from '../../components/CustomAlert'
import _ from 'lodash'
import {
isForgotPasswordTokenValid,
resetPassword,
} from '../../actions/actionCreators'
class ForgotPasswordView extends Component {
state = {
newPassword: null,
newPasswordRepeat: null,
alertVisible: false,
alertMessage: null,
alertType: null,
error: null
}
componentDidMount() {
const { params: { token } } = this.props.match
this.props.isForgotPasswordTokenValid({ token })
}
componentWillReceiveProps(newProps) {
/* Error Handling */
const { user: { error, resetPasswordSuccess } } = newProps
if(resetPasswordSuccess) {
this.setState({
alertVisible: true,
alertMessage: 'Senha atualizada com sucesso!',
alertType: 'success',
error: error
})
} else if(!resetPasswordSuccess && !_.isNil(error)) {
this.setState({
alertVisible: true,
alertMessage: 'Token invalido para alterar a senha, tente novamente!',
alertType: 'danger',
error: error
})
} else if(!_.isNil(error)) {
this.setState({
alertVisible: true,
alertMessage: 'Token não é valido, tente novamente!',
alertType: 'danger',
error: error
})
}
}
handleAlertDismiss = () => {
this.setState({
alertVisible: false
})
}
handleChangeInputNewPassword = e => {
this.setState({ newPassword: e.target.value })
}
handleChangeInputNewPasswordRepeat = e => {
this.setState({ newPasswordRepeat: e.target.value })
}
onClickResetPassword = e => {
const { user: { emailValidResetPasswordToken } } = this.props
const { params: { token } } = this.props.match
this.props.resetPassword(
emailValidResetPasswordToken,
{
newPassword: this.state.newPassword,
token
})
}
render() {
const { user: { resetPasswordTokenIsValid } } = this.props
if(resetPasswordTokenIsValid) {
return (
<div className={styles.ForgotPasswordView}>
{
this.state.alertVisible &&
<CustomAlert message={this.state.alertMessage} type={this.state.alertType} handleAlertDismiss={this.handleAlertDismiss} />
}
<div className={styles.containerElement}>
<h4> Insira seu novo password. </h4>
</div>
<div className={styles.containerElement}>
<FormControl bsClass={styles.inputText} type="password" placeholder="Nova senha" value={this.state.newPassword} onChange={this.handleChangeInputNewPassword}/>
</div>
<div className={styles.containerElement}>
<FormControl bsClass={styles.inputText} type="password" placeholder="Repetir nova senha" value={this.state.newPasswordRepeat} onChange={this.handleChangeInputNewPasswordRepeat}/>
</div>
<div className={styles.containerElement}>
<Button onClick={this.onClickResetPassword} bsClass={styles.primaryButton} bsSize="large">Enviar</Button>
</div>
</div>
)
}
return (
<div className={styles.ForgotPasswordView}>
{
this.state.alertVisible &&
<CustomAlert message={this.state.alertMessage} type={this.state.alertType} handleAlertDismiss={this.handleAlertDismiss} />
}
{
!this.state.alertVisible &&
<div className={styles.containerElement}>
<h4> Verificando token... </h4>
</div>
}
</div>
)
}
}
const mapStateToProps = (state) => {
return {
user: state.user,
}
}
const mapDispatchToProps = (dispatch) => ({
isForgotPasswordTokenValid: (token) => dispatch(isForgotPasswordTokenValid(token)),
resetPassword: (token, data) => dispatch(resetPassword(token, data)),
})
export default connect(mapStateToProps, mapDispatchToProps)(ForgotPasswordView)
| 28.4375 | 190 | 0.63663 |
771d6bf07416c45560cbdc77a287f16426571fa8 | 3,202 | js | JavaScript | lib/htmlRenderer.js | rpdurk/TemplateEngine | b216ee8a204efe0cde01ea34cbb23d1a1c0d88e5 | [
"MTLL"
] | null | null | null | lib/htmlRenderer.js | rpdurk/TemplateEngine | b216ee8a204efe0cde01ea34cbb23d1a1c0d88e5 | [
"MTLL"
] | null | null | null | lib/htmlRenderer.js | rpdurk/TemplateEngine | b216ee8a204efe0cde01ea34cbb23d1a1c0d88e5 | [
"MTLL"
] | null | null | null | // require path
const path = require("path");
// require write file
const fs = require("fs");
// template folder connect to pathway to html
const templatesDir = path.resolve(__dirname, "../templates");
// function render all employee information to an array
const render = employees => {
const html = [];
// push html add role of manager and constructors
html.push(...employees
.filter(employee => employee.getRole() === "Manager")
.map(manager => renderManager(manager))
);
// push html add role of engineer and constructors
html.push(...employees
.filter(employee => employee.getRole() === "Engineer")
.map(engineer => renderEngineer(engineer))
);
// push html add role of employee and constructors
html.push(...employees
.filter(employee => employee.getRole() === "Intern")
.map(intern => renderIntern(intern))
);
// return and join these elements
return renderMain(html.join(""));
};
// function that add the managers information to html
const renderManager = manager => {
// declare template and write the file with various components
let template = fs.readFileSync(path.resolve(templatesDir, "manager.html"), "utf8");
// on the template replace placeholder with with constructor of the manager
template = replacePlaceholders(template, "name", manager.getName());
template = replacePlaceholders(template, "role", manager.getRole());
template = replacePlaceholders(template, "email", manager.getEmail());
template = replacePlaceholders(template, "id", manager.getId());
template = replacePlaceholders(template, "officeNumber", manager.getOfficeNumber());
// return full filled
return template;
};
// function that add the engineer information to html
const renderEngineer = engineer => {
let template = fs.readFileSync(path.resolve(templatesDir, "engineer.html"), "utf8");
template = replacePlaceholders(template, "name", engineer.getName());
template = replacePlaceholders(template, "role", engineer.getRole());
template = replacePlaceholders(template, "email", engineer.getEmail());
template = replacePlaceholders(template, "id", engineer.getId());
template = replacePlaceholders(template, "github", engineer.getGithub());
return template;
};
const renderIntern = intern => {
let template = fs.readFileSync(path.resolve(templatesDir, "intern.html"), "utf8");
template = replacePlaceholders(template, "name", intern.getName());
template = replacePlaceholders(template, "role", intern.getRole());
template = replacePlaceholders(template, "email", intern.getEmail());
template = replacePlaceholders(template, "id", intern.getId());
template = replacePlaceholders(template, "school", intern.getSchool());
return template;
};
// function to render main html that adds all sections to team
const renderMain = html => {
const template = fs.readFileSync(path.resolve(templatesDir, "main.html"), "utf8");
return replacePlaceholders(template, "team", html);
};
// function to replace placeholder
const replacePlaceholders = (template, placeholder, value) => {
const pattern = new RegExp("{{ " + placeholder + " }}", "gm");
return template.replace(pattern, value);
};
module.exports = render; | 39.530864 | 86 | 0.71955 |
771dd2475e7510afd706a3251e06d65a91d6bec7 | 50 | js | JavaScript | src/constants.js | Hentaro1989/search-tours | 94de0b53855297fb3bd1507cb6646f17ec89e1b4 | [
"MIT"
] | 1 | 2018-12-06T14:21:50.000Z | 2018-12-06T14:21:50.000Z | src/constants.js | Hentaro1989/search-tours | 94de0b53855297fb3bd1507cb6646f17ec89e1b4 | [
"MIT"
] | 7 | 2021-03-01T22:07:51.000Z | 2022-03-08T22:31:41.000Z | src/constants.js | Hentaro1989/search-tours | 94de0b53855297fb3bd1507cb6646f17ec89e1b4 | [
"MIT"
] | null | null | null | export const API_KEY = 'N2NlNGM3NzUwMTA1MDY3Yg=='
| 25 | 49 | 0.8 |
771fab1aed6d35fc019ff7c179b13f71204183db | 8,760 | js | JavaScript | Resources/android/alloy/controllers/nominalLength.js | HippoMarketingGit/hackett | 241ff08184f2659818c2e5e0d6758cb69260042c | [
"Apache-2.0"
] | 1 | 2015-04-27T08:49:23.000Z | 2015-04-27T08:49:23.000Z | Resources/android/alloy/controllers/nominalLength.js | HippoMarketingGit/hackett | 241ff08184f2659818c2e5e0d6758cb69260042c | [
"Apache-2.0"
] | null | null | null | Resources/android/alloy/controllers/nominalLength.js | HippoMarketingGit/hackett | 241ff08184f2659818c2e5e0d6758cb69260042c | [
"Apache-2.0"
] | null | null | null | function __processArg(obj, key) {
var arg = null;
if (obj) {
arg = obj[key] || null;
delete obj[key];
}
return arg;
}
function Controller() {
function setLength() {
var nominalLength, meter = $.legMeter.value, fraction = $.legFraction.value;
if ("00" === meter && "00" === fraction) alert("Please enter the nominal length."); else {
nominalLength = meter + "." + fraction;
Alloy.Globals.sling.nominalLength = common.padIntRight(nominalLength);
closeModal();
}
}
function closeModal(e) {
var isManual = null !== e && e && e["type"];
$.nominalLength.close({
modal: true
});
isManual && args && args["navigateOnClose"] && true === args.navigateOnClose && args["back"] && true === args.back && Alloy.Globals.goBack();
!isManual && args && args["navigateOnClose"] && true === args.navigateOnClose && args["next"] && true === args.next && Alloy.Globals.goNext();
}
require("alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments));
this.__controllerPath = "nominalLength";
if (arguments[0]) {
{
__processArg(arguments[0], "__parentSymbol");
}
{
__processArg(arguments[0], "$model");
}
{
__processArg(arguments[0], "__itemTemplate");
}
}
var $ = this;
var exports = {};
var __defers = {};
$.__views.nominalLength = Ti.UI.createWindow({
backgroundGradient: {
type: "linear",
colors: [ "#021b4b", "#032d73" ],
startPoint: {
x: 0,
y: 0
},
endPoint: {
x: 0,
y: 960
},
backFillStart: false
},
top: "0",
height: "100%",
left: "0",
width: "100%",
layout: "vertical",
id: "nominalLength"
});
$.__views.nominalLength && $.addTopLevelView($.__views.nominalLength);
$.__views.__alloyId112 = Ti.UI.createView({
layout: "vertical",
top: "10dip",
width: "100%",
height: Titanium.UI.SIZE,
id: "__alloyId112"
});
$.__views.nominalLength.add($.__views.__alloyId112);
$.__views.__alloyId113 = Ti.UI.createImageView({
top: "30dip",
left: "20dip",
image: "/images/WHC-close.png",
height: "24dip",
width: "24dip",
id: "__alloyId113"
});
$.__views.__alloyId112.add($.__views.__alloyId113);
closeModal ? $.__views.__alloyId113.addEventListener("click", closeModal) : __defers["$.__views.__alloyId113!click!closeModal"] = true;
$.__views.__alloyId114 = Ti.UI.createView({
top: "20dip",
height: "1dip",
width: "100%",
backgroundColor: "#f7561e",
id: "__alloyId114"
});
$.__views.nominalLength.add($.__views.__alloyId114);
$.__views.scrollView = Ti.UI.createScrollView({
layout: "vertical",
bottom: "10dip",
id: "scrollView",
top: "0",
left: "0",
width: "100%"
});
$.__views.nominalLength.add($.__views.scrollView);
$.__views.content = Ti.UI.createView({
layout: "vertical",
height: Ti.UI.SIZE,
id: "content",
top: "0",
backgroundColor: "#2b3b94"
});
$.__views.scrollView.add($.__views.content);
$.__views.__alloyId115 = Ti.UI.createView({
layout: "vertical",
width: "90%",
height: Titanium.UI.SIZE,
id: "__alloyId115"
});
$.__views.content.add($.__views.__alloyId115);
$.__views.__alloyId116 = Ti.UI.createLabel({
top: "20dip",
color: "#FFF",
font: {
fontSize: 26
},
textAlign: "center",
text: "Length of Sling",
id: "__alloyId116"
});
$.__views.__alloyId115.add($.__views.__alloyId116);
$.__views.__alloyId117 = Ti.UI.createLabel({
top: "10dip",
color: "#FFF",
font: {
fontSize: 14
},
text: "Please input the length of the sling, bearing to bearing.",
id: "__alloyId117"
});
$.__views.__alloyId115.add($.__views.__alloyId117);
$.__views.__alloyId118 = Ti.UI.createView({
layout: "vertical",
top: "10dip",
width: "100%",
height: Titanium.UI.SIZE,
id: "__alloyId118"
});
$.__views.__alloyId115.add($.__views.__alloyId118);
$.__views.__alloyId119 = Ti.UI.createLabel({
top: "20dip",
color: "#FFF",
font: {
fontSize: 26
},
textAlign: "center",
text: "Nominal Length (m)",
id: "__alloyId119"
});
$.__views.__alloyId118.add($.__views.__alloyId119);
$.__views.__alloyId120 = Ti.UI.createView({
layout: "vertical",
top: "10dip",
width: "100%",
height: Titanium.UI.SIZE,
id: "__alloyId120"
});
$.__views.__alloyId115.add($.__views.__alloyId120);
$.__views.__alloyId121 = Ti.UI.createView({
layout: "horizontal",
width: Titanium.UI.SIZE,
height: Titanium.UI.SIZE,
id: "__alloyId121"
});
$.__views.__alloyId120.add($.__views.__alloyId121);
$.__views.legMeter = Ti.UI.createTextField({
height: "50dip",
width: "60dip",
left: "5dip",
borderWidth: "1dip",
borderColor: "#fba688",
backgroundColor: "#FFF",
font: {
fontSize: 30
},
paddingLeft: "4dip",
maxLength: 2,
textAlign: "center",
keyboardType: Titanium.UI.KEYBOARD_NUMBER_PAD,
color: "#000",
clearOnEdit: true,
id: "legMeter",
value: "00"
});
$.__views.__alloyId121.add($.__views.legMeter);
$.__views.__alloyId122 = Ti.UI.createLabel({
left: "5dip",
color: "#FFF",
font: {
fontSize: 50
},
text: ".",
id: "__alloyId122"
});
$.__views.__alloyId121.add($.__views.__alloyId122);
$.__views.legFraction = Ti.UI.createTextField({
height: "50dip",
width: "60dip",
left: "5dip",
borderWidth: "1dip",
borderColor: "#fba688",
backgroundColor: "#FFF",
font: {
fontSize: 30
},
paddingLeft: "4dip",
maxLength: 2,
textAlign: "center",
keyboardType: Titanium.UI.KEYBOARD_NUMBER_PAD,
color: "#000",
clearOnEdit: true,
id: "legFraction",
value: "00"
});
$.__views.__alloyId121.add($.__views.legFraction);
$.__views.__alloyId123 = Ti.UI.createView({
layout: "vertical",
top: "10dip",
width: "100%",
height: Titanium.UI.SIZE,
bottom: "20dip",
id: "__alloyId123"
});
$.__views.__alloyId115.add($.__views.__alloyId123);
$.__views.__alloyId124 = Ti.UI.createButton({
width: "100%",
height: "26dip",
backgroundImage: "/images/WHC-button--primary.png",
title: "Set Nominal Length",
color: "#FFF",
textAlign: "left",
font: {
fontSize: 16
},
id: "__alloyId124"
});
$.__views.__alloyId123.add($.__views.__alloyId124);
setLength ? $.__views.__alloyId124.addEventListener("click", setLength) : __defers["$.__views.__alloyId124!click!setLength"] = true;
$.__views.__alloyId125 = Ti.UI.createView({
height: "1dip",
width: "100%",
top: "0",
backgroundColor: "#FFF",
id: "__alloyId125"
});
$.__views.scrollView.add($.__views.__alloyId125);
exports.destroy = function() {};
_.extend($, $.__views);
var Common = require("common"), common = new Common(), args = arguments[0] || {};
$.legMeterDone && $.legMeterDone.addEventListener("click", function() {
$.legMeter.blur();
("" === $.legMeter.value || null === $.legMeter.value) && $.legMeter.setValue("00");
Ti.API.info($.legMeter.value);
});
$.legFractionDone && $.legFractionDone.addEventListener("click", function() {
$.legFraction.blur();
("" === $.legFraction.value || null === $.legFraction.value) && $.legFraction.setValue("00");
Ti.API.info($.legFraction.value);
});
__defers["$.__views.__alloyId113!click!closeModal"] && $.__views.__alloyId113.addEventListener("click", closeModal);
__defers["$.__views.__alloyId124!click!setLength"] && $.__views.__alloyId124.addEventListener("click", setLength);
_.extend($, exports);
}
var Alloy = require("alloy"), Backbone = Alloy.Backbone, _ = Alloy._;
module.exports = Controller; | 32.324723 | 150 | 0.547146 |
771fdf1efb7b5706bedab557258f9d5b2e21fddf | 961 | js | JavaScript | public/app/controller/NavCtrl.js | mpgn/Ipsum | daa335e56ac51319043c01321b5afc685e59e27f | [
"MIT"
] | 2 | 2019-06-17T21:39:12.000Z | 2020-04-05T17:23:50.000Z | public/app/controller/NavCtrl.js | mpgn/Ipsum | daa335e56ac51319043c01321b5afc685e59e27f | [
"MIT"
] | null | null | null | public/app/controller/NavCtrl.js | mpgn/Ipsum | daa335e56ac51319043c01321b5afc685e59e27f | [
"MIT"
] | 2 | 2016-05-16T04:32:23.000Z | 2020-04-05T17:23:51.000Z | app.controller('NavCtrl', ['$scope', '$location', '$translate', 'shareProperty', '$http',
function ($scope, $location, $translate, shareProperty, $http) {
$scope.currentPage = "";
$scope.$on('$routeChangeSuccess', function(event, current) {
$scope.currentPage = $location.path().slice(1).split('/')[0];
});
$scope.language_d = {};
var languageNetwork = shareProperty.getNetwork();
languageNetwork.then(function(result) {
$scope.language_d.active = result.data.default_language;
$translate.use($scope.language_d.active);
});
$scope.languages = [{
'name': 'FRENCH',
'abv': 'fr'
}, {
'name': 'ENGLISH',
'abv': 'en'
}];
$scope.changeLanguage = function (langKey) {
$translate.use(langKey);
$scope.language_d.active = langKey;
};
}
]);
| 30.03125 | 91 | 0.522373 |
772098ae337f192c2f02a227c8f03ae3d297193f | 550 | js | JavaScript | src/scaffolder-chooser.js | form8ion/lift | 2ec2477d0f6598b716008f1a1c0ffc7818cfc98e | [
"MIT"
] | 1 | 2020-03-23T04:51:56.000Z | 2020-03-23T04:51:56.000Z | src/scaffolder-chooser.js | form8ion/lift | 2ec2477d0f6598b716008f1a1c0ffc7818cfc98e | [
"MIT"
] | 608 | 2020-03-22T21:28:55.000Z | 2022-03-27T12:46:38.000Z | src/scaffolder-chooser.js | form8ion/lift | 2ec2477d0f6598b716008f1a1c0ffc7818cfc98e | [
"MIT"
] | 2 | 2020-04-16T18:35:15.000Z | 2020-10-13T00:08:35.000Z | import {Separator} from 'inquirer';
import {prompt} from '@form8ion/overridable-prompts';
import {questionNames} from './question-names';
export default async function (scaffolders, decisions) {
const {[questionNames.SCAFFOLDER]: chosenScaffolderName} = await prompt(
[{
name: questionNames.SCAFFOLDER,
message: 'Which scaffolder should be executed?',
type: 'list',
choices: ['General Maintenance', new Separator(), ...Object.keys(scaffolders)]
}],
decisions
);
return scaffolders[chosenScaffolderName];
}
| 30.555556 | 84 | 0.703636 |
7721f0dfaef20b21d25ae1cfb935e16d7c9ba6e1 | 1,448 | js | JavaScript | src/controllers/loaiDichVu.controller.js | quyen46919/NodeJs_Express_BoilerPlate | 4c3484c458a3b84ae3be1ca856bcfc7c891ee149 | [
"MIT"
] | null | null | null | src/controllers/loaiDichVu.controller.js | quyen46919/NodeJs_Express_BoilerPlate | 4c3484c458a3b84ae3be1ca856bcfc7c891ee149 | [
"MIT"
] | null | null | null | src/controllers/loaiDichVu.controller.js | quyen46919/NodeJs_Express_BoilerPlate | 4c3484c458a3b84ae3be1ca856bcfc7c891ee149 | [
"MIT"
] | null | null | null | const httpStatus = require('http-status');
const pick = require('../utils/pick');
const ApiError = require('../utils/ApiError');
const catchAsync = require('../utils/catchAsync');
const { loaiDichVuService } = require('../services');
const taoLoaiDichVu = catchAsync(async (req, res) => {
const loaiDichVu = await loaiDichVuService.taoLoaiDichVu(req.body);
res.status(httpStatus.CREATED).send(loaiDichVu);
});
const timTatCaLoaiDichVu = catchAsync(async (req, res) => {
const filter = pick(req.query, ['name']);
const options = pick(req.query, ['sortBy', 'limit', 'page']);
const result = await loaiDichVuService.timTatCaLoaiDichVu(filter, options);
res.send(result);
});
const timLoaiDichVuTheoId = catchAsync(async (req, res) => {
const loaiDichVu = await loaiDichVuService.timLoaiDichVuTheoId(req.params.loaiDichVuId);
if (!loaiDichVu) {
throw new ApiError(httpStatus.NOT_FOUND, 'Loại dịch vụ không tồn tại');
}
res.send(loaiDichVu);
});
const capNhatLoaiDichVu = catchAsync(async (req, res) => {
const loaiDichVu = await loaiDichVuService.capNhatLoaiDichVu(req.params.loaiDichVuId, req.body);
res.send(loaiDichVu);
});
const xoaLoaiDichVu = catchAsync(async (req, res) => {
await loaiDichVuService.xoaLoaiDichVu(req.params.loaiDichVuId);
res.status(httpStatus.NO_CONTENT).send();
});
module.exports = {
taoLoaiDichVu,
timTatCaLoaiDichVu,
timLoaiDichVuTheoId,
capNhatLoaiDichVu,
xoaLoaiDichVu,
};
| 32.909091 | 98 | 0.729972 |
77235a209189aef0e2b8db9ff8cf19ed1a7ab931 | 207 | js | JavaScript | src/app.js | puresick/chit | 6592e0b990e5c442ac58acf99e8b8e6807ed98f2 | [
"MIT"
] | 1 | 2020-03-20T14:44:44.000Z | 2020-03-20T14:44:44.000Z | src/app.js | puresick/chit | 6592e0b990e5c442ac58acf99e8b8e6807ed98f2 | [
"MIT"
] | 2 | 2021-03-10T15:25:25.000Z | 2021-05-10T21:33:53.000Z | src/app.js | puresick/chit | 6592e0b990e5c442ac58acf99e8b8e6807ed98f2 | [
"MIT"
] | null | null | null | import Vue from "vue"
import router from "./router"
import store from "./store"
import i18n from "./i18n"
import App from "./App.vue"
new Vue({
router,
store,
i18n,
el: "#app",
render: h => h(App)
})
| 13.8 | 29 | 0.637681 |
772473586c3f56af254baba44b8fdcfb836a52b7 | 665 | js | JavaScript | assets/scripts/app.js | Deliciaes/Tasks | 4d456c6d1653bfdef8cdb3c9dfe5dec406be2255 | [
"MIT"
] | null | null | null | assets/scripts/app.js | Deliciaes/Tasks | 4d456c6d1653bfdef8cdb3c9dfe5dec406be2255 | [
"MIT"
] | null | null | null | assets/scripts/app.js | Deliciaes/Tasks | 4d456c6d1653bfdef8cdb3c9dfe5dec406be2255 | [
"MIT"
] | 2 | 2022-01-12T16:44:36.000Z | 2022-01-13T15:17:28.000Z | const todayForms = document.querySelectorAll('.checkboxForm');
const taskForms = document.querySelectorAll('.tasksForm');
const deadlineToday = document.querySelectorAll('.deadlineToday');
if (todayForms.length !== 0) {
setCheckboxEventListener(todayForms);
}
if (taskForms.length !== 0) {
setCheckboxEventListener(taskForms);
}
if (deadlineToday.length !== 0) {
setCheckboxEventListener(deadlineToday);
}
// funktion för att submitta formet
function setCheckboxEventListener(forms) {
forms.forEach((form) => {
const checkbox = form.querySelector('.checkboxClass');
checkbox.addEventListener('click', () => {
form.submit();
});
});
}
| 26.6 | 66 | 0.720301 |
77247738799e9639b5ff641f13ce52024af4dd1e | 81 | js | JavaScript | public/js/main.js | jayce85/jayce85.github.io | 136add804792f10b55b22b68dd3f96522d62dcbb | [
"MIT"
] | null | null | null | public/js/main.js | jayce85/jayce85.github.io | 136add804792f10b55b22b68dd3f96522d62dcbb | [
"MIT"
] | null | null | null | public/js/main.js | jayce85/jayce85.github.io | 136add804792f10b55b22b68dd3f96522d62dcbb | [
"MIT"
] | null | null | null | $(document).ready(function(){return $("article").fitVids(),$("#nav").tinyNav()}); | 81 | 81 | 0.62963 |
7724b0f5804ea6da6dcde84841623d557d132c5a | 7,285 | js | JavaScript | tests/index.js | evheniy/yeps-response | e585194747c1679dd5ef269b9fc937dcd277a5bf | [
"MIT"
] | null | null | null | tests/index.js | evheniy/yeps-response | e585194747c1679dd5ef269b9fc937dcd277a5bf | [
"MIT"
] | null | null | null | tests/index.js | evheniy/yeps-response | e585194747c1679dd5ef269b9fc937dcd277a5bf | [
"MIT"
] | null | null | null | const chai = require('chai');
const chaiHttp = require('chai-http');
const App = require('yeps');
const srv = require('yeps-server');
const error = require('yeps-error');
const response = require('..');
const { expect } = chai;
chai.use(chaiHttp);
let app;
let server;
describe('YEPS response test', () => {
beforeEach(() => {
app = new App();
app.then(error());
app.then(response());
server = srv.createHttpServer(app);
});
afterEach((done) => {
server.close(done);
});
it('should test response', async () => {
let isTestFinished1 = false;
let isTestFinished2 = false;
let isTestFinished3 = false;
app.then(async (ctx) => {
isTestFinished1 = true;
return ctx.response.resolve('test');
});
app.then(async (ctx) => {
isTestFinished2 = true;
ctx.res.end('test2');
return Promise.reject();
});
await chai.request(server)
.get('/')
.send()
.then((res) => {
expect(res).to.have.status(200);
expect(res.text).to.be.equal('test');
isTestFinished3 = true;
});
expect(isTestFinished1).is.true;
expect(isTestFinished2).is.false;
expect(isTestFinished3).is.true;
});
it('should test sent response', async () => {
let isTestFinished1 = false;
let isTestFinished2 = false;
let isTestFinished3 = false;
app.then(async (ctx) => {
isTestFinished1 = true;
ctx.res.end('sent');
});
app.then(async (ctx) => {
isTestFinished2 = true;
return ctx.response.resolve('test');
});
await chai.request(server)
.get('/')
.send()
.then((res) => {
expect(res).to.have.status(200);
expect(res.text).to.be.equal('sent');
isTestFinished3 = true;
});
expect(isTestFinished1).is.true;
expect(isTestFinished2).is.true;
expect(isTestFinished3).is.true;
});
it('should test response with promise', async () => {
let isTestFinished1 = false;
let isTestFinished2 = false;
app.then(async (ctx) => {
isTestFinished1 = true;
const data = Promise.resolve('test');
return ctx.response.resolve(data);
});
await chai.request(server)
.get('/')
.send()
.then((res) => {
expect(res).to.have.status(200);
expect(res.text).to.be.equal('test');
isTestFinished2 = true;
});
expect(isTestFinished1).is.true;
expect(isTestFinished2).is.true;
});
it('should test response with stringify', async () => {
let isTestFinished1 = false;
let isTestFinished2 = false;
app.then(async (ctx) => {
isTestFinished1 = true;
return ctx.response.resolve({ message: 'Ok' });
});
await chai.request(server)
.get('/')
.send()
.then((res) => {
expect(res).to.have.status(200);
expect(res.text).to.be.equal('{"message":"Ok"}');
isTestFinished2 = true;
});
expect(isTestFinished1).is.true;
expect(isTestFinished2).is.true;
});
it('should test redirect with default parameters', async () => {
let isTestFinished1 = false;
let isTestFinished2 = false;
app.then(async (ctx) => {
isTestFinished1 = true;
return ctx.response.redirect();
});
await chai.request(server)
.get('/')
.send()
.catch((err) => {
expect(err).to.have.status(301);
expect(err.response.headers.location).to.be.equal('/');
isTestFinished2 = true;
});
expect(isTestFinished1).is.true;
expect(isTestFinished2).is.true;
});
it('should test redirect with parameters', async () => {
let isTestFinished1 = false;
let isTestFinished2 = false;
app.then(async (ctx) => {
isTestFinished1 = true;
return ctx.response.redirect('/test', 302);
});
await chai.request(server)
.get('/')
.send()
.catch((err) => {
expect(err).to.have.status(302);
expect(err.response.headers.location).to.be.equal('/test');
isTestFinished2 = true;
});
expect(isTestFinished1).is.true;
expect(isTestFinished2).is.true;
});
it('should test error resolve', async () => {
let isTestFinished1 = false;
let isTestFinished2 = false;
let isTestFinished3 = false;
let isTestFinished4 = false;
app.then(async (ctx) => {
isTestFinished1 = true;
const err = Promise.reject(new Error());
return ctx.response.resolve(err);
});
app.then(async () => {
isTestFinished2 = true;
});
app.catch(async () => {
isTestFinished3 = true;
});
await chai.request(server)
.get('/')
.send()
.catch((err) => {
expect(err).to.have.status(500);
isTestFinished4 = true;
});
expect(isTestFinished1).is.true;
expect(isTestFinished2).is.false;
expect(isTestFinished3).is.true;
expect(isTestFinished4).is.true;
});
it('should test error resolve with error', async () => {
let isTestFinished1 = false;
let isTestFinished2 = false;
let isTestFinished3 = false;
let isTestFinished4 = false;
app.then(async (ctx) => {
isTestFinished1 = true;
return ctx.response.resolve(new Error());
});
app.then(async () => {
isTestFinished2 = true;
});
app.catch(async () => {
isTestFinished3 = true;
});
await chai.request(server)
.get('/')
.send()
.catch((err) => {
expect(err).to.have.status(500);
isTestFinished4 = true;
});
expect(isTestFinished1).is.true;
expect(isTestFinished2).is.false;
expect(isTestFinished3).is.true;
expect(isTestFinished4).is.true;
});
it('should test error reject', async () => {
let isTestFinished1 = false;
let isTestFinished2 = false;
let isTestFinished3 = false;
let isTestFinished4 = false;
app.then(async (ctx) => {
isTestFinished1 = true;
const err = Promise.reject(new Error());
return ctx.response.reject(err);
});
app.then(async () => {
isTestFinished2 = true;
});
app.catch(async () => {
isTestFinished3 = true;
});
await chai.request(server)
.get('/')
.send()
.catch((err) => {
expect(err).to.have.status(500);
isTestFinished4 = true;
});
expect(isTestFinished1).is.true;
expect(isTestFinished2).is.false;
expect(isTestFinished3).is.false;
expect(isTestFinished4).is.true;
});
it('should test error reject with error', async () => {
let isTestFinished1 = false;
let isTestFinished2 = false;
let isTestFinished3 = false;
let isTestFinished4 = false;
app.then(async (ctx) => {
isTestFinished1 = true;
return ctx.response.reject(new Error());
});
app.then(async () => {
isTestFinished2 = true;
});
app.catch(async () => {
isTestFinished3 = true;
});
await chai.request(server)
.get('/')
.send()
.catch((err) => {
expect(err).to.have.status(500);
isTestFinished4 = true;
});
expect(isTestFinished1).is.true;
expect(isTestFinished2).is.false;
expect(isTestFinished3).is.false;
expect(isTestFinished4).is.true;
});
});
| 23.126984 | 67 | 0.581057 |
7725151dc78b8499a0d0e3a11c7b9cd62b8523a2 | 441 | js | JavaScript | app.js | vandaimer/NodeJS | 4c943d8773b4a1f18331cf5b429d594e0446fd40 | [
"MIT"
] | null | null | null | app.js | vandaimer/NodeJS | 4c943d8773b4a1f18331cf5b429d594e0446fd40 | [
"MIT"
] | null | null | null | app.js | vandaimer/NodeJS | 4c943d8773b4a1f18331cf5b429d594e0446fd40 | [
"MIT"
] | null | null | null | var express = require('express'),
app = express();
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
app.get('/', function(req, res){
sleep(10);
res.send('Ola Mundo');
});
var server = app.listen(3000);
console.log('Servidor Express iniciado na porta %s', server.address().port);
| 20.045455 | 78 | 0.575964 |
77261ed9af7285090b019401b827866af419087e | 1,423 | js | JavaScript | cytofpipe/v1.3/Rlibs/scaffold/shinyGUI/www/sort.js | UCL-BLIC/legion-buildscripts | 5fd6c4e2a36b5ca35fa06577b2face58174a7d78 | [
"MIT"
] | null | null | null | cytofpipe/v1.3/Rlibs/scaffold/shinyGUI/www/sort.js | UCL-BLIC/legion-buildscripts | 5fd6c4e2a36b5ca35fa06577b2face58174a7d78 | [
"MIT"
] | null | null | null | cytofpipe/v1.3/Rlibs/scaffold/shinyGUI/www/sort.js | UCL-BLIC/legion-buildscripts | 5fd6c4e2a36b5ca35fa06577b2face58174a7d78 | [
"MIT"
] | null | null | null | // return order of a sortable list
// function created by ZJ: https://groups.google.com/forum/?fromgroups=#!topic/shiny-discuss/f3n5Iv2wNQ8
var returnOrderBinding = new Shiny.InputBinding();
$.extend(returnOrderBinding, {
find: function(scope) {
return $(scope).find('.ui-sortable');
},
getId: function(el) {
return Shiny.InputBinding.prototype.getId.call(this, el) || el.name;
},
getValue: function(el) {
//console.log(el)
var hi = $(el).find("li").map(function(i,el) {return $(el).text()})
hii = []
hi.each(function() {hii.push(this)})
return hii
// return $("ul li").map(function(i,el) {return $(el).text()});
},
setValue: function(el, value) {
el.value = value;
},
receiveMessage: function(el, data) {
if (data.hasOwnProperty('value'))
{
this.setValue(el, data.value);
console.log(data.value);
$(el).empty();
var new_list = data.value.map(function(v, i, a) {return("<li class='ui-state-default stab'><span class='label'>" + v + "</span></li>");});
console.log(new_list);
$(el).append(new_list);
}
$(el).trigger('sortupdate.ui-sortable');
},
subscribe: function(el, callback) {
$(el).on("sortupdate.ui-sortable", function(event) {
callback(true);
});
},
unsubscribe: function(el) {
$(el).off('.ui-sortable');
},
});
Shiny.inputBindings.register(returnOrderBinding, 'returnOrder');
| 32.340909 | 144 | 0.617006 |
7727b778f5f3f5bfb4f5ec7fa55d015e9065b71c | 701 | js | JavaScript | public_html/js/tipo/service.js | Samyfos/Facturacion-Samuel | 00deb90bcc7e4275c232692e4feb6f8ec544b0d7 | [
"MIT"
] | null | null | null | public_html/js/tipo/service.js | Samyfos/Facturacion-Samuel | 00deb90bcc7e4275c232692e4feb6f8ec544b0d7 | [
"MIT"
] | null | null | null | public_html/js/tipo/service.js | Samyfos/Facturacion-Samuel | 00deb90bcc7e4275c232692e4feb6f8ec544b0d7 | [
"MIT"
] | null | null | null | 'use strict';
moduloTipo.factory('tipoService', ['serverService', function (serverService) {
return {
getFields: function () {
return [
{name: "id", shortname: "ID", longname: "Identificador", visible: true, type: "id"},
{name: "descripcion", shortname: "Desc.", longname: "Descripcion", visible: true, type: "text"}
];
},
getIcon: function () {
return "fa-archive";
},
getObTitle: function () {
return "tipo";
},
getTitle: function () {
return "tipo";
}
};
}]);
| 30.478261 | 115 | 0.435093 |
77282b18bc280ecf08da80b793c2b60e9ce2ba7b | 659 | js | JavaScript | resources/assets/js/components/Search.js | AlexPutrya/carlight_catalog | 20934180c13a61105499d33fbd4a20d8c75bb6c3 | [
"MIT"
] | null | null | null | resources/assets/js/components/Search.js | AlexPutrya/carlight_catalog | 20934180c13a61105499d33fbd4a20d8c75bb6c3 | [
"MIT"
] | null | null | null | resources/assets/js/components/Search.js | AlexPutrya/carlight_catalog | 20934180c13a61105499d33fbd4a20d8c75bb6c3 | [
"MIT"
] | null | null | null | import React, { Component } from 'react';
class Search extends Component {
findValue(event) {
this.props.changeHandle(event.target.value);
}
render() {
return (
<div className="search">
<div className="input-group input-group-lg">
<span className="input-group-addon" id="sizing-addon1">
Поиск
</span>
<input className="form-control" type="text" placeholder="Начните вводить модель автомобиля" onChange={this.findValue.bind(this)}/>
</div>
</div>
);
}
}
export default Search; | 28.652174 | 150 | 0.531108 |
772a434251cb08fee4c1ca96ecb8b27980b420d7 | 363 | js | JavaScript | src/etc/dom.js | jiseonk/js-todo-list-step3 | 7aa5af381f8b3605b0ad36aa1793e409560f738b | [
"MIT"
] | null | null | null | src/etc/dom.js | jiseonk/js-todo-list-step3 | 7aa5af381f8b3605b0ad36aa1793e409560f738b | [
"MIT"
] | null | null | null | src/etc/dom.js | jiseonk/js-todo-list-step3 | 7aa5af381f8b3605b0ad36aa1793e409560f738b | [
"MIT"
] | null | null | null | export const $addTeamButton = document.querySelector('#add-team-button');
export const $teamListContainer = document.querySelector('.team-list-container');
export const $todoApp = document.querySelector('#app');
export const $todoApps = document.querySelector('.todoapp-list-container');
export const $addUserButton = document.querySelector('#add-user-button');
| 51.857143 | 81 | 0.782369 |
772a4e9ecd547e9510d3e369e9e0fee58e3f0396 | 1,594 | js | JavaScript | app/util/gamegoldHelper.js | bookmansoft/gamegold-wechat-server | 6c064ad044eb32ef655c6d9a31ab560b6b0ba746 | [
"MIT"
] | 2 | 2018-11-12T10:30:01.000Z | 2018-11-20T11:14:52.000Z | app/util/gamegoldHelper.js | bookmansoft/gamegold-wechat-server | 6c064ad044eb32ef655c6d9a31ab560b6b0ba746 | [
"MIT"
] | null | null | null | app/util/gamegoldHelper.js | bookmansoft/gamegold-wechat-server | 6c064ad044eb32ef655c6d9a31ab560b6b0ba746 | [
"MIT"
] | 1 | 2019-10-23T03:20:43.000Z | 2019-10-23T03:20:43.000Z | const toolkit = require('gamerpc')
let facade = require('gamecloud')
let CoreOfBase = facade.CoreOfBase
class gamegoldHelper extends facade.Service
{
/**
* 构造函数
* @param {CoreOfBase} core
*/
constructor(core) {
super(core);
this.remote = new toolkit.conn();
//兼容性设置,提供模拟浏览器环境中的 fetch 函数
this.remote.setFetch(require('node-fetch'))
}
/**
* 将连接器设置为长连模式,同时完成登录、消息订阅等操作
*/
setlongpoll(cb) {
this.remote.setmode(this.remote.CommMode.ws, cb);
return this;
}
async execute(method, params) {
return await this.remote.execute(method, params)
}
/**
* 网络类型
*/
get network() {
return this.remote.getTerminalConfig().type;
}
/**
* CP编号,注意不要和授权终端编码混淆
*/
get cid() {
return this.remote.getTerminalConfig().cpid;
}
watch(cb, etype = '0') {
this.remote.watch(cb, etype);
return this;
}
revHex(data) {
this.assert(typeof data === 'string');
this.assert(data.length > 0);
this.assert(data.length % 2 === 0);
let out = '';
for (let i = 0; i < data.length; i += 2)
out = data.slice(i, i + 2) + out;
return out;
}
assert(value, message) {
if (!value) {
throw new assert.AssertionError({
message,
actual: value,
expected: true,
operator: '==',
stackStartFunction: assert
});
}
}
}
module.exports = gamegoldHelper;
| 20.701299 | 57 | 0.519448 |
772af84b829e2dcd0d9a39097c7229c20565a408 | 1,735 | js | JavaScript | src/components/Posts.js | MatterhornDev/mountain-top | 1bc4b80ee7b3ee97c66f90ec2c6f04219f8c412f | [
"MIT"
] | 3 | 2019-05-23T18:19:32.000Z | 2019-12-02T20:32:46.000Z | src/components/Posts.js | MatterhornDev/mountain-top | 1bc4b80ee7b3ee97c66f90ec2c6f04219f8c412f | [
"MIT"
] | 36 | 2019-05-28T06:14:15.000Z | 2021-07-21T05:55:37.000Z | src/components/Posts.js | MatterhornDev/mountain-top | 1bc4b80ee7b3ee97c66f90ec2c6f04219f8c412f | [
"MIT"
] | 1 | 2019-07-05T07:59:39.000Z | 2019-07-05T07:59:39.000Z | import React from 'react'
import { StaticQuery, graphql, Link } from 'gatsby'
// import GatsbyImage from 'gatsby-image'
export const _Posts = ({data}) => {
const { edges } = data.allMarkdownRemark
return (
<div className='posts'>
{edges.map(edge => {
const {fields, frontmatter} = edge.node
return (
<React.Fragment>
<hr key={`hr-${fields.slug}`} />
<div
className='post-container'
key={fields.slug}
>
{/* Disabled for now; also disabled in styles.
<GatsbyImage fixed={frontmatter.featuredImage.childImageSharp.fixed} /> */}
<div className='post-content'>
<Link to={fields.slug}>
<h2>{frontmatter.title}</h2>
</Link>
<p>{frontmatter.excerpt}</p>
</div>
</div>
</React.Fragment>
)
})}
</div>
)
}
/*
This is the old featuredImage query. Currently disabled
frontmatter {
featuredImage {
childImageSharp{
fixed(width: 125, height: 125) {
...GatsbyImageSharpFixed
}
}
}
}
*/
const Posts = () => {
return (
<StaticQuery
query={graphql`
query {
allMarkdownRemark(
sort: {order: DESC, fields: [frontmatter___date]}
){
edges {
node {
fields {
slug
}
frontmatter {
title
date
excerpt
}
}
}
}
}
`}
render={data => <_Posts data={data}/>}
/>
)
}
export default Posts | 23.445946 | 91 | 0.458213 |
772b34e19a1d90e43f55833329972e4102a3d952 | 10,381 | js | JavaScript | server/plugins/UIPlugin/src/components/PTC10.js | vzakharchenko/poersmart-controller | 71a1aa58acd4c6a80ebfa63cca920d482389a9ee | [
"Apache-2.0"
] | 1 | 2020-02-08T13:39:52.000Z | 2020-02-08T13:39:52.000Z | server/plugins/UIPlugin/src/components/PTC10.js | vzakharchenko/poersmart-controller | 71a1aa58acd4c6a80ebfa63cca920d482389a9ee | [
"Apache-2.0"
] | 1 | 2020-02-19T06:39:34.000Z | 2020-02-19T06:39:34.000Z | server/plugins/UIPlugin/src/components/PTC10.js | vzakharchenko/poersmart-controller | 71a1aa58acd4c6a80ebfa63cca920d482389a9ee | [
"Apache-2.0"
] | 2 | 2020-08-26T19:47:46.000Z | 2021-12-08T07:25:17.000Z | import React from 'react';
import { Panel, Table } from 'react-bootstrap';
import { observer, inject } from 'mobx-react';
import { temps } from './TempValues';
import PoersPTC10Temp from './TempTemperature.js';
import PoersPTC10Scheduler from './SchedulerTemperature.js';
export default @inject('poerSmartStore', 'languageStore')
@observer
class PTC10 extends React.Component {
handleModeChange = (event) => {
const mode = event.target.value;
this.props.poerSmartStore.changeMode(event.target.getAttribute('mac'), mode);
};
overrideTemperatureChange = (event) => {
const temp = event.target.value;
this.props.poerSmartStore.changeTemp(event.target.getAttribute('mac'), 'override', temp);
};
offTemperatureChange = (event) => {
const temp = event.target.value;
this.props.poerSmartStore.changeTemp(event.target.getAttribute('mac'), 'off', temp);
};
ecoTemperatureChange = (event) => {
const temp = event.target.value;
this.props.poerSmartStore.changeTemp(event.target.getAttribute('mac'), 'off', temp);
};
render() {
const { node } = this.props;
const {
nodeMac,
draft,
battery,
humidity,
curTemp,
actuatorStatus,
mode,
overrideTemperature,
offTemperature,
ecoTemperature,
SptTemprature,
} = node;
const { languageJS } = this.props.languageStore;
return (
<Panel>
<Panel.Body>
<Table striped bordered condensed hover>
<thead>
<tr>
<th colSpan="13">
Node PoersMart PTC10
{draft ? `(${languageJS.translate('Update')}...)` : ''}
</th>
</tr>
<tr>
<th style={{
'text-align': 'center',
'vertical-align': 'top',
}}
/>
<th style={{
'text-align': 'center',
'vertical-align': 'top',
}}
>
{languageJS.translate('Mac')}
</th>
<th style={{
'text-align': 'center',
'vertical-align': 'top',
}}
>
{languageJS.translate('curTemp')}
</th>
<th style={{
'text-align': 'center',
'vertical-align': 'top',
}}
>
{languageJS.translate('targetTemp')}
</th>
<th style={{
'text-align': 'center',
'vertical-align': 'top',
}}
>
{languageJS.translate('humidity')}
</th>
<th style={{
'text-align': 'center',
'vertical-align': 'top',
}}
>
{languageJS.translate('battery')}
</th>
<th style={{
'text-align': 'center',
'vertical-align': 'top',
}}
>
{languageJS.translate('actuatorStatus')}
</th>
<th style={{
'text-align': 'center',
'vertical-align': 'top',
}}
>
{languageJS.translate('mode/new Mode')}
</th>
<th style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
{languageJS.translate('overrideTemperature')}
</th>
<th style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
{languageJS.translate('offTemperature')}
</th>
<th style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
{languageJS.translate('ecoTemperature')}
</th>
</tr>
</thead>
<tbody>
<tr>
<td style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
<img
src="/assets/PTC10.png"
style={{
width: 100,
height: 100,
'text-align': 'center',
'vertical-align': 'middle',
}}
alt="undefined"
/>
</td>
<td style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
{nodeMac}
</td>
<td style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
{(curTemp / 10).toFixed(1)}
{' '}
°C
</td>
<td style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
{(SptTemprature / 10).toFixed(1)}
{' '}
°C
</td>
<td style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
{humidity}
%
</td>
<td style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
{battery}
%
</td>
<td style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
{actuatorStatus ? 'active' : 'inactive'}
</td>
<td style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
{mode}
/
<select
id="mode"
name="mode"
mac={nodeMac}
onChange={this.handleModeChange}
style={{ width: '100px' }}
>
{mode === 'AUTO' ? <option id="mode_AUTO" value="auto" selected>AUTO</option>
: <option id="mode_AUTO" value="AUTO">AUTO</option>}
{mode === 'MAN' ? <option id="mode_MAN" value="man" selected>MAN</option>
: <option id="mode_MAN" value="MAN">MAN</option>}
{mode === 'ECO' ? <option id="mode_ECO" value="eco" selected>MAN</option>
: <option id="mode_ECO" value="ECO">ECO</option>}
{mode === 'OFF' ? <option id="mode_OFF" value="off" selected>MAN</option>
: <option id="mode_OFF" value="OFF">OFF</option>}
{mode === 'AUTO/MAN' ? <option id="mode_AUTOMAN" value="auto/man" selected>AUTO/MAN</option>
: null}
</select>
</td>
<td style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
{(overrideTemperature / 10).toFixed(1)}
/
<select
id="overrideTemperature"
name="overrideTemperature"
mac={nodeMac}
onChange={this.overrideTemperatureChange}
style={{ width: '60px' }}
>
{
temps.map(t => (
t === overrideTemperature
? <option id={`override_${t}`} value={t} selected>{(t / 10).toFixed(1)}</option>
: <option id={`override_${t}`} value={t}>{(t / 10).toFixed(1)}</option>))
}
</select>
°C
</td>
<td style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
{(offTemperature / 10).toFixed(1)}
/
<select
id="offTemperature"
name="offTemperature"
mac={nodeMac}
onChange={this.offTemperatureChange}
style={{ width: '60px' }}
>
{
temps.map(t => (
t === offTemperature
? <option id={`override_${t}`} value={t} selected>{(t / 10).toFixed(1)}</option>
: <option id={`override_${t}`} value={t}>{(t / 10).toFixed(1)}</option>))
}
</select>
°C
</td>
<td style={{
'text-align': 'center',
'vertical-align': 'middle',
}}
>
{(ecoTemperature / 10).toFixed(1)}
/
<select
id="ecoTemperature"
name="ecoTemperature"
mac={nodeMac}
onChange={this.ecoTemperatureChange}
style={{ width: '60px' }}
>
{
temps.map(t => (
t === ecoTemperature
? <option id={`override_${t}`} value={t} selected>{(t / 10).toFixed(1)}</option>
: <option id={`override_${t}`} value={t}>{(t / 10).toFixed(1)}</option>))
}
</select>
°C
</td>
</tr>
<tr>
<td colSpan="14">
<PoersPTC10Temp node={node} />
</td>
</tr>
<tr>
<td colSpan="14">
<PoersPTC10Scheduler node={node} />
</td>
</tr>
</tbody>
</Table>
</Panel.Body>
</Panel>
);
}
}
| 32.747634 | 112 | 0.367402 |
772c0f8373b3a62d1e3fb8726606fbf6ab6a1227 | 415 | js | JavaScript | helpers/timeToReadImages.js | ftlabs/time-to-read | 3b6cb6d6c326232366a0f119f4e4959686aa1e8b | [
"MIT"
] | 2 | 2018-08-13T16:01:12.000Z | 2019-11-11T08:09:05.000Z | helpers/timeToReadImages.js | ftlabs/time-to-read | 3b6cb6d6c326232366a0f119f4e4959686aa1e8b | [
"MIT"
] | 2 | 2020-07-16T08:03:51.000Z | 2022-01-22T02:20:00.000Z | helpers/timeToReadImages.js | ftlabs/time-to-read | 3b6cb6d6c326232366a0f119f4e4959686aa1e8b | [
"MIT"
] | 3 | 2018-08-13T16:01:13.000Z | 2020-12-24T10:47:36.000Z | function calculate(imageCounts) {
return inSeconds(imageCounts) / 60;
}
function inSeconds(imageCounts) {
return imageCounts
.map(count => {
let total = 0;
let timeForImage = 12;
for (let i = 0; i < count; i++) {
total = total + timeForImage;
if (timeForImage !== 3) timeForImage = timeForImage - 1;
}
return total;
})
.reduce((a, b) => a + b, 0);
}
module.exports = { calculate };
| 20.75 | 60 | 0.616867 |
772c78030dd59eb8d6ff4a7484025c84b12fecf9 | 1,481 | js | JavaScript | theme/df-owner/login/resources/dsfr/src/core/script/collapse/collapse.js | MTES-MCT/Dossier-Facile-Keycloak | 9a8f0825bf67a90623edb5d91eade09914d8df71 | [
"MIT"
] | 63 | 2021-06-29T12:46:20.000Z | 2022-03-29T15:05:20.000Z | theme/df-owner/login/resources/dsfr/src/core/script/collapse/collapse.js | MTES-MCT/Dossier-Facile-Keycloak | 9a8f0825bf67a90623edb5d91eade09914d8df71 | [
"MIT"
] | 40 | 2021-07-06T08:35:13.000Z | 2022-03-25T09:23:57.000Z | src/core/script/collapse/collapse.js | GouvernementFR/dsfr | 1b24b4e5902b2f6bda5145719fa078c703299146 | [
"MIT"
] | 13 | 2021-07-06T10:20:21.000Z | 2022-03-31T07:40:39.000Z | import { Disclosure } from '../disclosure/disclosure.js';
import { CollapseSelector } from './collapse-selector.js';
import { DisclosureType } from '../disclosure/disclosure-type.js';
import { CollapseButton } from './collapse-button.js';
/**
* Tab coorespond au panel d'un élement Tabs (tab panel)
* Tab étend disclosure qui ajoute/enleve le modifier --selected,
* et ajoute/eleve l'attribut hidden, sur le panel
*/
class Collapse extends Disclosure {
constructor () {
super(DisclosureType.EXPAND, CollapseSelector.COLLAPSE, CollapseButton, 'CollapsesGroup');
}
static get instanceClassName () {
return 'Collapse';
}
init () {
super.init();
this.listen('transitionend', this.transitionend.bind(this));
}
transitionend (e) {
if (!this.disclosed) this.style.maxHeight = '';
}
unbound () {
this.style.maxHeight = 'none';
}
disclose (withhold) {
if (this.disclosed) return;
this.unbound();
this.adjust();
this.request(() => { super.disclose(withhold); });
}
conceal (withhold, preventFocus) {
if (!this.disclosed) return;
this.adjust();
this.request(() => { super.conceal(withhold, preventFocus); });
}
adjust () {
this.setProperty('--collapser', 'none');
const height = this.node.offsetHeight;
this.setProperty('--collapse', -height + 'px');
this.setProperty('--collapser', '');
}
reset () {
if (!this.pristine) this.disclosed = false;
}
}
export { Collapse };
| 25.101695 | 94 | 0.650912 |
772c9aa92068dd3a2585ec4596aad868a5b32193 | 915 | js | JavaScript | server.js | Enyorose/cpnt262-robots-with-appliances | eb46b60ac038ec34940d4469e42ddaecf1a5cd1a | [
"MIT"
] | null | null | null | server.js | Enyorose/cpnt262-robots-with-appliances | eb46b60ac038ec34940d4469e42ddaecf1a5cd1a | [
"MIT"
] | null | null | null | server.js | Enyorose/cpnt262-robots-with-appliances | eb46b60ac038ec34940d4469e42ddaecf1a5cd1a | [
"MIT"
] | 2 | 2021-11-04T19:12:47.000Z | 2021-11-17T07:07:16.000Z | /******************/
/* Import Modules */
/******************/
const express = require('express')
const app = express()
const router = require('./routes/api')
const teamRouter = require('./routes/team')
const loginRouter = require('./routes/login')
const subRouter = require('./routes/sub')
// Use middleware for index page
app.use(express.static('public'))
// Load routes
app.use('/api', router, teamRouter, subRouter)
app.use('/', loginRouter)
/****************************/
/* Handle 404, start server */
/****************************/
// ERROR handlers for API or HTML
app.use((req, res) => {
if(req.url.startsWith('/api')){
res.status(404)
res.send({ error: 'File Not Found'})
} else {
res.status(404)
res.redirect('/404-page/404.html')
}
})
// Start server
const PORT = process.env.PORT || 3000;
app.listen(PORT, function(){
console.log(`Listening on port ${PORT}`);
});
| 21.27907 | 46 | 0.580328 |
772d0bbebb4c63a968e03e86be623f83d6cea998 | 1,402 | js | JavaScript | test/app.js | chihab/generator-angular-es2015 | dc840c96492dccd69d41e2b043d7d54c342de674 | [
"MIT"
] | null | null | null | test/app.js | chihab/generator-angular-es2015 | dc840c96492dccd69d41e2b043d7d54c342de674 | [
"MIT"
] | null | null | null | test/app.js | chihab/generator-angular-es2015 | dc840c96492dccd69d41e2b043d7d54c342de674 | [
"MIT"
] | null | null | null | 'use strict';
var path = require('path');
var assert = require('yeoman-assert');
var helpers = require('yeoman-test');
var fs = require('fs-extra');
describe('angular-es2015:app', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/app'))
.toPromise();
});
it('creates files', function () {
assert.file([
'scripts/services/index.js',
'index.html',
]);
});
});
describe('angular-es2015:service', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/service'))
.inTmpDir(function (dir) {
var required = ['scripts/services/index.js'];
required.forEach(function (file) {
fs.copySync(path.join(__dirname, '../generators/app/templates/' + file), path.join(dir, file));
})
})
.withArguments(['foo'])
.toPromise();
});
it('generates a new service', function () {
assert.file([
'scripts/services/foo.service.js',
'scripts/services/index.js'
]);
assert.fileContent(
path.join('scripts/services/foo.service.js'),
'class FooService'
);
assert.fileContent(
path.join('scripts/services/index.js'),
'import FooService from "./foo.service";'
);
assert.fileContent(
path.join('scripts/services/index.js'),
".service('FooService', FooService)"
);
});
})
| 26.961538 | 105 | 0.601997 |
772d6e045d87b1e1c95b705f7342ba444a6f7f22 | 4,353 | js | JavaScript | src/@system.geolocation.js | onekit-x2x/quick2weixin | d57ddf3f794c47f1ff2b4339150898241f74607c | [
"MIT"
] | null | null | null | src/@system.geolocation.js | onekit-x2x/quick2weixin | d57ddf3f794c47f1ff2b4339150898241f74607c | [
"MIT"
] | null | null | null | src/@system.geolocation.js | onekit-x2x/quick2weixin | d57ddf3f794c47f1ff2b4339150898241f74607c | [
"MIT"
] | 1 | 2020-07-20T06:35:46.000Z | 2020-07-20T06:35:46.000Z | /* eslint-disable consistent-return */
/* eslint-disable no-console */
/* eslint-disable camelcase */
import PROMISE from '../node_modules/oneutil/PROMISE'
module.exports = {
getLocation(quick_object) {
if (!quick_object) {
return
}
const quick_success = quick_object.success
const quick_fail = quick_object.fail
const quick_complete = quick_object.complete
const quick_timeout = quick_object.timeout || 3000
const quick_coordType = quick_object.coordType || 'wgs84'
quick_object = null
PROMISE((SUCCESS) => {
wx.getLocation({
type: quick_coordType,
highAccuracyExpireTime: quick_timeout,
success: wx_res => {
const quick_res = {
latitude: wx_res.latitude,
longitude: wx_res.longitude,
speed: wx_res.speed,
accuracy: wx_res.accuracy,
altitude: wx_res.altitude,
verticalAccuracy: wx_res.verticalAccuracy,
horizontalAccuracy: wx_res.horizontalAccuracy,
time: new Date().getTime()
}
SUCCESS(quick_res)
}
})
}, quick_success, quick_fail, quick_complete)
},
/** openLocation */
openLocation(quick_object) {
if (!quick_object) {
return
}
const quick_success = quick_object.success
const quick_fail = quick_object.fail
const quick_complete = quick_object.complete
const quick_latitude = quick_object.latitude
const quick_longitude = quick_object.longitude
const quick_scale = quick_object.scale || 18
const quick_name = quick_object.name || ''
const quick_address = quick_object.address || ''
quick_object = null
PROMISE((SUCCESS) => {
wx.openLocation({
latitude: quick_latitude,
longitude: quick_longitude,
scale: quick_scale,
name: quick_name,
address: quick_address,
success: () => {
const quick_res = {
errMsg: 'openLocation: ok'
}
SUCCESS(quick_res)
}
})
}, quick_success, quick_fail, quick_complete)
},
/** chooseLocation */
chooseLocation(quick_object) {
if (!quick_object) {
return
}
const quick_success = quick_object.success
const quick_fail = quick_object.fail
const quick_complete = quick_object.complete
const quick_latitude = quick_object.latitude
const quick_longitude = quick_object.longitude
const quick_coordType = quick_object.coordType || 'wgs84'
quick_object = null
PROMISE((SUCCESS) => {
wx.chooseLocation({
latitude: quick_latitude,
longitude: quick_longitude,
success: (wx_res) => {
const quick_res = {
name: wx_res.name,
address: wx_res.address,
latitude: wx_res.latitude,
longitude: wx_res.longitude,
coordType: quick_coordType,
}
SUCCESS(quick_res)
}
})
}, quick_success, quick_fail, quick_complete)
},
/** getLocationType */
getLocationType(quick_object) {
if (!quick_object) {
return
}
const quick_success = quick_object.success
const quick_res = {
types: ['gps', 'network']
}
quick_success(quick_res)
},
/** geolocation.subscribe */
subscribe(quick_object) {
if (!quick_object) {
return
}
wx.startLocationUpdate()
const quick_callback = quick_object.callback
quick_object = null
wx.onLocationChange(function (wx_res) {
const quick_res = {
latitude: wx_res.latitude,
longitude: wx_res.longitude,
speed: wx_res.speed,
accuracy: wx_res.accuracy,
altitude: wx_res.altitude,
verticalAccuracy: wx_res.verticalAccuracy,
horizontalAccuracy: wx_res.horizontalAccuracy,
time: new Date().getTime()
}
quick_callback(quick_res)
})
},
/** wx.offLocationChange */
unsubscribe() {
wx.offLocationChange()
},
/** geolocation.getSupportedCoordTypes() */
getSupportedCoordTypes() {
console.log('getSupportedCoordTypes is not support')
},
/** geolocation.geocodeQuery() */
geocodeQuery() {
console.log('geocodeQuery is not support')
},
/** geolocation.reverseGeocodeQuery() */
reverseGeocodeQuery() {
console.log('reverseGeocodeQuery is not support')
},
}
| 28.638158 | 61 | 0.634735 |
772db1615c2d6947b16cf89a93331272065be140 | 4,094 | js | JavaScript | modules/qrevents/server/controllers/qrevents.server.controller.js | nicknameismos/web-qr | 2213227ed65fea8da31f77c054672d3747b63f50 | [
"MIT"
] | null | null | null | modules/qrevents/server/controllers/qrevents.server.controller.js | nicknameismos/web-qr | 2213227ed65fea8da31f77c054672d3747b63f50 | [
"MIT"
] | null | null | null | modules/qrevents/server/controllers/qrevents.server.controller.js | nicknameismos/web-qr | 2213227ed65fea8da31f77c054672d3747b63f50 | [
"MIT"
] | null | null | null | 'use strict';
/**
* Module dependencies.
*/
var path = require('path'),
mongoose = require('mongoose'),
Qrevent = mongoose.model('Qrevent'),
errorHandler = require(path.resolve('./modules/core/server/controllers/errors.server.controller')),
_ = require('lodash');
/**
* Create a Qrevent
*/
exports.create = function (req, res) {
var qrevent = new Qrevent(req.body);
qrevent.user = req.user;
qrevent.save(function (err) {
if (err) {
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.jsonp(qrevent);
}
});
};
/**
* Show the current Qrevent
*/
exports.read = function (req, res) {
// convert mongoose document to JSON
var qrevent = req.qrevent ? req.qrevent.toJSON() : {};
// Add a custom field to the Article, for determining if the current User is the "owner".
// NOTE: This field is NOT persisted to the database, since it doesn't exist in the Article model.
qrevent.isCurrentUserOwner = req.user && qrevent.user && qrevent.user._id.toString() === req.user._id.toString();
res.jsonp(qrevent);
};
/**
* Update a Qrevent
*/
exports.update = function (req, res) {
var qrevent = req.qrevent;
qrevent = _.extend(qrevent, req.body);
qrevent.save(function (err) {
if (err) {
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.jsonp(qrevent);
}
});
};
/**
* Delete an Qrevent
*/
exports.delete = function (req, res) {
var qrevent = req.qrevent;
qrevent.remove(function (err) {
if (err) {
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.jsonp(qrevent);
}
});
};
/**
* List of Qrevents
*/
exports.list = function (req, res) {
Qrevent.find().sort('-created').populate('user', 'displayName').exec(function (err, qrevents) {
if (err) {
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.jsonp(qrevents);
}
});
};
/**
* Qrevent middleware
*/
exports.qreventByID = function (req, res, next, id) {
if (!mongoose.Types.ObjectId.isValid(id)) {
return res.status(400).send({
message: 'Qrevent is invalid'
});
}
Qrevent.findById(id).populate('user', 'displayName').exec(function (err, qrevent) {
if (err) {
return next(err);
} else if (!qrevent) {
return res.status(404).send({
message: 'No Qrevent with that identifier has been found'
});
}
req.qrevent = qrevent;
next();
});
};
exports.rank = function (req, res) {
Qrevent.find().sort('-created').populate('user', 'displayName').exec(function (err, qrevents) {
if (err) {
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
var ranks = new Qrevent({
rank: qrevents.length + 1,
headers: req.headers
});
ranks.save(function (err) {
if (err) {
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.jsonp(ranks);
}
});
}
});
};
exports.reports = function (req, res) {
Qrevent.find().sort('-created').populate('user', 'displayName').exec(function (err, qrevents) {
if (err) {
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
var alldate = [];
qrevents.forEach(function (qr) {
var str = qr.created.toString();
var res = str.substr(0, 10);
if (alldate.indexOf(res) === -1) {
alldate.push(res);
}
});
var resultdata = [];
alldate.forEach(function (date) {
var qrsByDate = qrevents.filter(function (obj) { return obj.created.toString().substr(0, 10) === date.toString() });
resultdata.push({
date: date,
userscount: qrsByDate.length,
users: qrsByDate
});
});
res.jsonp(resultdata);
}
});
}; | 23.94152 | 124 | 0.583537 |
772e56dc96adc4b79d957db0863a4cd8d60771fb | 362 | js | JavaScript | Front-End/e-commerce-front-end/e-commerce-front-end/test/test/test.js | jm27/E-Commerce-MERN | e39508e37ecbca4714ca861d4e5fa987f12b98c6 | [
"Unlicense"
] | 3 | 2018-09-22T07:39:02.000Z | 2020-03-17T17:19:54.000Z | Front-End/e-commerce-front-end/e-commerce-front-end/test/test/test.js | jm27/E-Commerce-MERN | e39508e37ecbca4714ca861d4e5fa987f12b98c6 | [
"Unlicense"
] | null | null | null | Front-End/e-commerce-front-end/e-commerce-front-end/test/test/test.js | jm27/E-Commerce-MERN | e39508e37ecbca4714ca861d4e5fa987f12b98c6 | [
"Unlicense"
] | null | null | null | var expect = require("chai").expect;
var multiply = require("../index");
describe("Multiply", function() {
it("should multiply properly when passed numbers", function() {
expect(multiply(2, 4)).to.equal(8);
});
it("should throw when not passed numbers", function() {
expect(function() {
multiply(2, "4");
}).to.throw(Error);
});
});
| 22.625 | 65 | 0.616022 |
772e8c3cb5ab4cc565d53a9b907ad7c426822119 | 126 | js | JavaScript | simple-fem/src/index.js | server-state/fem-test-environment | b0ec0631e6131ca77d7b5c7940a8d61ab911e27c | [
"MIT"
] | null | null | null | simple-fem/src/index.js | server-state/fem-test-environment | b0ec0631e6131ca77d7b5c7940a8d61ab911e27c | [
"MIT"
] | 55 | 2020-04-30T10:33:58.000Z | 2021-09-30T10:02:14.000Z | simple-fem/src/index.js | server-state/fem-test-environment | b0ec0631e6131ca77d7b5c7940a8d61ab911e27c | [
"MIT"
] | null | null | null | import MyFEM from './my-fem';
export default {
component: MyFEM,
// logoUrl: "/path/to/logo or base64" // optional
}; | 21 | 53 | 0.634921 |
0117bf12fa3183851e5bc67c43608735506843f4 | 300 | js | JavaScript | src/components/atoms/upload/index.js | adhitiad/react_coba | 0f5b6d67e3113e1a330978ffd7bebe93e38ac725 | [
"MIT"
] | 1 | 2021-03-03T14:12:15.000Z | 2021-03-03T14:12:15.000Z | src/components/atoms/upload/index.js | adhitiad/react_coba | 0f5b6d67e3113e1a330978ffd7bebe93e38ac725 | [
"MIT"
] | null | null | null | src/components/atoms/upload/index.js | adhitiad/react_coba | 0f5b6d67e3113e1a330978ffd7bebe93e38ac725 | [
"MIT"
] | null | null | null | import React from "react";
import { LoginBg } from "../../../assets";
import "./upload.scss";
function UploadImg() {
return (
<div className="upload">
<img className="preview" src={LoginBg} alt="preview" />
<input type="file"></input>
</div>
);
}
export default UploadImg;
| 18.75 | 61 | 0.606667 |
0117fc82a10be9fd81ca03a9e294ee0edef29d70 | 401 | js | JavaScript | test/normalization/exercise/no-problem.js | katalysteducation/cnx-designer | 1d779840a03cb266f750a05919cb95efd9d6f205 | [
"MIT"
] | 1 | 2021-06-22T13:47:28.000Z | 2021-06-22T13:47:28.000Z | test/normalization/exercise/no-problem.js | openstax-poland/cnx-designer | 5d43ba7f012db8c63f7ce6f6ec247fa978e5cb03 | [
"MIT"
] | 57 | 2019-07-09T14:48:01.000Z | 2022-03-18T15:42:42.000Z | test/normalization/exercise/no-problem.js | katalysteducation/cnx-designer | 1d779840a03cb266f750a05919cb95efd9d6f205 | [
"MIT"
] | 1 | 2019-11-18T16:15:57.000Z | 2019-11-18T16:15:57.000Z | /** @jsx h */
export const input = <editor>
<exercise>
<exsolution>
<p><cursor/>Missing problem</p>
</exsolution>
</exercise>
</editor>
export const output = <editor>
<exercise>
<exproblem>
<p><text/></p>
</exproblem>
<exsolution>
<p><cursor/>Missing problem</p>
</exsolution>
</exercise>
</editor>
| 19.095238 | 43 | 0.501247 |
01188a525403a802e4e1657877dddef331995941 | 2,010 | js | JavaScript | experiments/some/someGen/test136.js | sola-da/LambdaTester | f993f9d67eab0120b14111be1a56d40b4c5ac9af | [
"MIT"
] | 2 | 2018-11-26T09:34:28.000Z | 2019-10-18T16:23:53.000Z | experiments/some/someGen/test136.js | sola-da/LambdaTester | f993f9d67eab0120b14111be1a56d40b4c5ac9af | [
"MIT"
] | null | null | null | experiments/some/someGen/test136.js | sola-da/LambdaTester | f993f9d67eab0120b14111be1a56d40b4c5ac9af | [
"MIT"
] | 1 | 2019-10-08T16:37:48.000Z | 2019-10-08T16:37:48.000Z |
var callbackArguments = [];
var argument1 = function callback(a,b,c) {
callbackArguments.push(JSON.stringify(arguments))
argument3[6] = {"213":"5G^T@z","705":82,"714":843,"969":9.479467245673807e+307,"|$":242,"":"L","'z0:HiL:g}`":"","w":714,"N^9>t<u25":1.0436550389996668e+308}
return a*b+c
};
var argument2 = null;
var argument3 = function callback(a,b,c) {
callbackArguments.push(JSON.stringify(arguments))
argument4[0] = null
return a*b-c
};
var argument4 = null;
var argument5 = true;
var argument6 = function callback(a,b,c) {
callbackArguments.push(JSON.stringify(arguments))
base_2[3] = ""
return a*b*c
};
var argument7 = r_0;
var argument8 = 627;
var argument9 = function callback(a,b,c) {
callbackArguments.push(JSON.stringify(arguments))
base_3[4] = [")"]
argument10[9] = "t"
argument10[1] = ["T","D","EK"]
return a+b/c
};
var base_0 = [1.7976931348623157e+308,0,0,126,"a","W0",213,"B","x"]
var r_0= undefined
try {
r_0 = base_0.some(argument1,argument2)
}
catch(e) {
r_0= "Error"
}
var base_1 = [1.7976931348623157e+308,0,0,126,"a","W0",213,"B","x"]
var r_1= undefined
try {
r_1 = base_1.some(argument3,argument4,argument5)
}
catch(e) {
r_1= "Error"
}
var base_2 = [1.7976931348623157e+308,0,0,126,"a","W0",213,"B","x"]
var r_2= undefined
try {
r_2 = base_2.some(argument6,argument7,argument8)
}
catch(e) {
r_2= "Error"
}
var base_3 = [1.7976931348623157e+308,0,0,126,"a","W0",213,"B","x"]
var r_3= undefined
try {
r_3 = base_3.some(argument9)
}
catch(e) {
r_3= "Error"
}
function serialize(array){
return array.map(function(a){
if (a === null || a == undefined) return a;
var name = a.constructor.name;
if (name==='Object' || name=='Boolean'|| name=='Array'||name=='Number'||name=='String')
return JSON.stringify(a);
return name;
});
}
setTimeout(function(){
require("fs").writeFileSync("./experiments/some/someGen/test136.json",JSON.stringify({"baseObjects":serialize([base_0,base_1,base_2,base_3]),"returnObjects":serialize([r_0,r_1,r_2,r_3]),"callbackArgs":callbackArguments}))
},300) | 25.769231 | 221 | 0.686567 |
0118bae3ddd3c18e68c43fd5c03179054619b0ca | 1,538 | js | JavaScript | test/vacancies.repository.test.js | Floby/lazyboss | 4b225e55e7723048bda92629eead8eba5a02586b | [
"Unlicense"
] | null | null | null | test/vacancies.repository.test.js | Floby/lazyboss | 4b225e55e7723048bda92629eead8eba5a02586b | [
"Unlicense"
] | 1 | 2021-05-08T07:55:07.000Z | 2021-05-08T07:55:07.000Z | test/vacancies.repository.test.js | Floby/lazyboss | 4b225e55e7723048bda92629eead8eba5a02586b | [
"Unlicense"
] | null | null | null | const shortid = require('shortid')
const delay = require('delay')
const uuid = require('uuid/v4')
const { expect } = require('chai')
const Vacancy = require('../src/domain/vacancy')
const Job = require('../src/domain/job')
const VacanciesRepository = require('../src/infra/vacancies.repository')
describe('REPOSITORY VacanciesRepository', () => {
let vacanciesRepository
beforeEach(() => {
vacanciesRepository = VacanciesRepository()
})
const job = new Job({})
const worker = { id: 'some-id' }
const vacancyId = shortid()
const vacancy = Vacancy({ id: vacancyId, worker, job })
describe('.save(vacancy)', () => {
it('returns a promise', () => {
// When
const actual = vacanciesRepository.save(vacancy)
// Then
expect(actual).to.be.an.instanceOf(Promise)
})
})
describe('get(vacancyId)', () => {
it('resolves undefined', async () => {
const actual = await vacanciesRepository.get(vacancyId)
expect(actual).to.be.undefined
})
context('after calling .save(vacancy)', () => {
beforeEach(() => vacanciesRepository.save(vacancy))
it('resolves the vacancy', async () => {
const actual = await vacanciesRepository.get(vacancyId)
expect(actual).to.equal(vacancy)
})
context('for another id', () => {
const vacancyId = shortid()
it('resolves undefined', async () => {
const actual = await vacanciesRepository.get(vacancyId)
expect(actual).to.be.undefined
})
})
})
})
})
| 32.041667 | 72 | 0.618986 |
0119295d3815642d11645825f79d7a3b969ef5a9 | 2,021 | js | JavaScript | dist/jquery.peek.min.js | nguyenj/peek-js | 8174efeee728be9515dfa65f3ec9f2be1a0bf62c | [
"MIT"
] | null | null | null | dist/jquery.peek.min.js | nguyenj/peek-js | 8174efeee728be9515dfa65f3ec9f2be1a0bf62c | [
"MIT"
] | null | null | null | dist/jquery.peek.min.js | nguyenj/peek-js | 8174efeee728be9515dfa65f3ec9f2be1a0bf62c | [
"MIT"
] | null | null | null | /*! Peek - v0.1.0 - 2015-03-22
* https://github.com/jnguyen/jquery-peek
* Copyright (c) 2015 John Nguyen; Licensed MIT */
!function(a,b,c){a.fn.peek=function(b){return"undefined"==typeof b&&(b={}),"object"==typeof b||"number"==typeof b?("number"==typeof b&&(b={animateTo:b}),this.each(function(){if(c===a(this).data("peek")){var d=new a.peek(this,b);a(this).data("peek",d)}})):void 0},a.peek=function(b,c){var d,e,f,g,h,i,j,k,l;d={renderedImage:".rendered",planImage:".wireframe",animateTo:0},e=this,e.settings={},e.nopeeking=function(){return l.unbuild(),this},e.peeking=function(){return l.init(),this},l={init:function(){e.settings=a.extend({},d,c),f=a(b),g=a("<div />",{"class":"peek__inner"}),h=f.find(e.settings.planImage),i=f.find(e.settings.renderedImage),j=a("<div />",{"class":"peek__images"}),k=a("<div />",{"class":"peek__handle"}),this.build(),this.events()},build:function(){f.hasClass("peek")||f.addClass("peek"),k.append(a("<div />",{"class":"handle-line"}),a("<div />",{"class":"handle-tab"})),j.append(h,i),g.append(j,k),i=i.removeClass(e.settings.renderedImage.slice(1)).addClass("peek__rendered peek__image"),h=h.removeClass(e.settings.planImage.slice(1)).addClass("peek__wireframe peek__image"),f.append(g)},unbuild:function(){var a="peek__wireframe peek__rendered peek__image";h=h.removeClass(a).addClass(e.settings.planImage.slice(1)),i=i.removeClass(a).addClass(e.settings.renderedImage.slice(1)).removeAttr("style"),g.remove(),f.append(h,i)},events:function(){k.draggable({containment:f,create:function(){k.animate({top:e.settings.animateTo},e.settings.animateSpeed),i.animate({height:l.calculate_peeking_height(e.settings.animateTo)},e.settings.animateSpeed)},drag:function(a,b){i.css("height",l.calculate_peeking_height(b))}})},calculate_peeking_height:function(a){return"object"==typeof a?a.position.top-parseInt(f.children().css("padding-top"),10)+k.outerHeight(!0)/2:"number"==typeof a?parseInt(a)-parseInt(f.children().css("padding-top"),10)+k.outerHeight(!0)/2:0}},l.init()}}(jQuery,this); | 505.25 | 1,899 | 0.712519 |
011a4e7aee21f4e03206bb5d63c6f062280081d1 | 1,441 | js | JavaScript | build/module/endpoints/options/EndOfDayOptions.js | bolekro/iex-cloud | 42c7fbaed0a108360646d4efc1670c571b0d41f9 | [
"MIT"
] | null | null | null | build/module/endpoints/options/EndOfDayOptions.js | bolekro/iex-cloud | 42c7fbaed0a108360646d4efc1670c571b0d41f9 | [
"MIT"
] | null | null | null | build/module/endpoints/options/EndOfDayOptions.js | bolekro/iex-cloud | 42c7fbaed0a108360646d4efc1670c571b0d41f9 | [
"MIT"
] | null | null | null | import { ApiRequest } from '../../core';
/**
* [End of Day Options](https://iexcloud.io/docs/api/#end-of-day-options)
* This call returns an array of OptionResponse for the given symbol.
*/
export const endOfDayOptions = (optionsParams) => {
const { expiration, optionSide, symbol } = optionsParams;
if (expiration) {
return ApiRequest(`stock/${symbol}/options/${expiration}/${optionSide}`);
}
return ApiRequest(`stock/${symbol}/options`);
};
export var OptionSide;
(function (OptionSide) {
OptionSide["call"] = "call";
OptionSide["put"] = "put";
})(OptionSide || (OptionSide = {}));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRW5kT2ZEYXlPcHRpb25zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2VuZHBvaW50cy9vcHRpb25zL0VuZE9mRGF5T3B0aW9ucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sWUFBWSxDQUFDO0FBRXhDOzs7R0FHRztBQUNILE1BQU0sQ0FBQyxNQUFNLGVBQWUsR0FBRyxDQUM3QixhQUE0QixFQUNRLEVBQUU7SUFDdEMsTUFBTSxFQUFFLFVBQVUsRUFBRSxVQUFVLEVBQUUsTUFBTSxFQUFFLEdBQUcsYUFBYSxDQUFDO0lBRXpELElBQUksVUFBVSxFQUFFO1FBQ2QsT0FBTyxVQUFVLENBQUMsU0FBUyxNQUFNLFlBQVksVUFBVSxJQUFJLFVBQVUsRUFBRSxDQUFDLENBQUM7S0FDMUU7SUFFRCxPQUFPLFVBQVUsQ0FBQyxTQUFTLE1BQU0sVUFBVSxDQUFDLENBQUM7QUFDL0MsQ0FBQyxDQUFDO0FBeUJGLE1BQU0sQ0FBTixJQUFZLFVBR1g7QUFIRCxXQUFZLFVBQVU7SUFDcEIsMkJBQWEsQ0FBQTtJQUNiLHlCQUFXLENBQUE7QUFDYixDQUFDLEVBSFcsVUFBVSxLQUFWLFVBQVUsUUFHckIifQ== | 80.055556 | 822 | 0.843858 |
011a6fa87cf7c91d4b48484637051b310a0ecaf3 | 616 | js | JavaScript | icons/VectorBeizer2.js | fork-ecosystem/fork-ui | 9755e7574bdb61a91e188067518fc540fbff1e01 | [
"MIT"
] | null | null | null | icons/VectorBeizer2.js | fork-ecosystem/fork-ui | 9755e7574bdb61a91e188067518fc540fbff1e01 | [
"MIT"
] | null | null | null | icons/VectorBeizer2.js | fork-ecosystem/fork-ui | 9755e7574bdb61a91e188067518fc540fbff1e01 | [
"MIT"
] | null | null | null | import React from 'react';
import withIconEnhancer from '../HOCs/withIconEnhancer';
export default withIconEnhancer('VectorBeizer2', 'vector-beizer-2', (props) => (
<svg {...props} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<rect x="3" y="3" width="4" height="4" rx="1" />
<rect x="17" y="17" width="4" height="4" rx="1" />
<line x1="7" y1="5" x2="14" y2="5" />
<line x1="10" y1="19" x2="17" y2="19" />
<circle cx="9" cy="19" r="1" />
<circle cx="15" cy="5" r="1" />
<path d="M7 5.5a5 6.5 0 0 1 5 6.5a5 6.5 0 0 0 5 6.5" />
</svg>
));
| 38.5 | 80 | 0.576299 |
011a902fe9d410ec3b5ef44ee904948cd4a72054 | 1,058 | js | JavaScript | commands/devsend.js | NobleWolf42/Stormageddon-Bot | 14cad9c52e9f6a6cdd922fd30bf3e356ad62b0ce | [
"MIT"
] | 1 | 2020-09-13T04:54:35.000Z | 2020-09-13T04:54:35.000Z | commands/devsend.js | NobleWolf42/Stormageddon-Bot | 14cad9c52e9f6a6cdd922fd30bf3e356ad62b0ce | [
"MIT"
] | 22 | 2019-11-27T04:54:59.000Z | 2020-12-07T06:54:21.000Z | commands/devsend.js | NobleWolf42/Stormageddon-Bot | 14cad9c52e9f6a6cdd922fd30bf3e356ad62b0ce | [
"MIT"
] | 1 | 2019-11-28T05:08:35.000Z | 2019-11-28T05:08:35.000Z | //#regions dependancies
const { errorCustom, embedCustom } = require('../helpers/embedMessages.js');
const botConfig = require('../data/botconfig.json');
//#endregion
module.exports = {
name: "devsend",
type: ['DM'],
aliases: [],
cooldown: 0,
class: 'direct',
usage: '!devsend ***USER-ID***, ***MESSAGE***',
description: "Developer-only command for sending messages as the bot.",
execute(message, args, client) {
var argsString = args.join(' ');
var arguments = argsString.split(', ');
var user = arguments[0];
var content = arguments[1];
if (botConfig.devids.includes(message.author.id)) {
client.users.cache.get(user).send(content + 'NOTE: You cannot respond to this message.`');
embedCustom(message, 'Message Sent.', '#0B6E29', `**Message:** \`${content}\` \n**Sent To:** \`${client.users.cache.get(user).tag}\``);
}
else {
errorCustom(message, 'You do not have permission to use this command!', module.name);
}
}
}; | 36.482759 | 147 | 0.594518 |
011ac5def6ba7b53cfb7590b62840d425031d5bb | 258 | js | JavaScript | joe-eames-fundamentals/app/js/services/ExceptionHandler.js | moonrise/angsb | 9ae8015b2e8554607deef69c36b91dc210df4526 | [
"MIT"
] | null | null | null | joe-eames-fundamentals/app/js/services/ExceptionHandler.js | moonrise/angsb | 9ae8015b2e8554607deef69c36b91dc210df4526 | [
"MIT"
] | null | null | null | joe-eames-fundamentals/app/js/services/ExceptionHandler.js | moonrise/angsb | 9ae8015b2e8554607deef69c36b91dc210df4526 | [
"MIT"
] | null | null | null | 'use strict';
//
// notice '$' prefix with $exceptionHandler; we're overriding angular $exceptionHandler
//
eventsApp.factory("$exceptionHandler", function() {
return function(exception) {
console.log("exception occurred:", exception);
}
}); | 25.8 | 87 | 0.686047 |
011ade0d71050c69b6cc74776704cf088bf0164a | 7,945 | js | JavaScript | JS/main.js | Zephyr-Quest/ZQ_server | efe32b7c2e0fe98c943644c416c35662ba6f7869 | [
"MIT-0"
] | null | null | null | JS/main.js | Zephyr-Quest/ZQ_server | efe32b7c2e0fe98c943644c416c35662ba6f7869 | [
"MIT-0"
] | null | null | null | JS/main.js | Zephyr-Quest/ZQ_server | efe32b7c2e0fe98c943644c416c35662ba6f7869 | [
"MIT-0"
] | null | null | null | /**
* !Global Var
*/
let canvas = document.getElementById('myCanvas')
let x = canvas.getAttribute('width') / 2;
let y = canvas.getAttribute('height') / 2;
let startX = 320;
let startY = canvas.getAttribute('height') / 2;
let endX = 14;
let endY = 7;
let alive = true;
let playing = false
let state
/*! ODD NUMBER FOR THE MAP LENGHT !*/
let mapLenght = 15;
let sizeOfCircle = (x / mapLenght) - 2;
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
let wait = 0
let wall
/**
* !Game settings
*/
var light = {
width: 4000000,
torch: 200,
background_big: 40000000,
background_small: 400000000
}
var game = {
lenght: mapLenght,
bcc: "white",
}
var player = {
cooX: 0,
cooY: 7,
x: startX,
y: startY,
radius: 25,
moveSize: 61,
left: false,
forward: false,
right: false,
backward: false,
torch: 0
}
/**
* !DETECTION OF KEYS FOR MOVEMENT
*/
var leftKey = 37;
var upKey = 38;
var rightKey = 39;
var downKey = 40;
var enterKey = 13;
/**
* !MOVING THE CHARACTER
*/
$(window).keydown(function(e) { // Key pushed
if (making == true) { return true }
if ((alive == false || playing == false)) { return false }
if (this.className === 'hold') { return false; }
this.className = 'hold';
var keyCode = e.keyCode;
if (keyCode == leftKey) {
player.left = true;
player.right = false;
player.backward = false;
player.forward = false;
updateStageObject()
checkTorch()
} else if (keyCode == upKey) {
player.left = false;
player.right = false;
player.backward = false;
player.forward = true;
updateStageObject()
checkTorch()
} else if (keyCode == rightKey) {
player.left = false;
player.right = true;
player.backward = false;
player.forward = false;
updateStageObject()
checkTorch()
} else if (keyCode == downKey) {
player.left = false;
player.right = false;
player.backward = true;
player.forward = false;
updateStageObject()
checkTorch()
} else if (keyCode == enterKey) {
player.left = false;
player.right = false;
player.backward = false;
player.forward = false;
if (obstaclesArray[player.cooY * 15 + player.cooX].id == 1) {
activateLever(player.cooX, player.cooY)
} else
if (player.cooY != 0 && obstaclesArray[(player.cooY - 1) * 15 + player.cooX].id == 1) {
activateLever(player.cooX, player.cooY - 1)
} else
if (player.cooY != 14 && obstaclesArray[(player.cooY + 1) * 15 + player.cooX].id == 1) {
activateLever(player.cooX, player.cooY + 1)
} else
if (player.cooX != 14 && obstaclesArray[player.cooY * 15 + player.cooX + 1].id == 1) {
activateLever(player.cooX + 1, player.cooY)
} else
if (player.cooX != 0 && obstaclesArray[player.cooY * 15 + player.cooX - 1].id == 1) {
activateLever(player.cooX - 1, player.cooY)
}
updateStageObject()
checkTorch()
}
});
$(window).keyup(function(e) { // Key stop push
if (playing == false) { return false }
this.className = '';
var keyCode = e.keyCode;
if (keyCode == leftKey) {
player.left = false;
drawPlayerWait('left', player.x, player.y)
} else if (keyCode == upKey) {
player.forward = false;
drawPlayerWait('forward', player.x, player.y)
} else if (keyCode == rightKey) {
player.right = false;
drawPlayerWait('right', player.x, player.y)
} else if (keyCode == downKey) {
player.backward = false;
drawPlayerWait('backward', player.x, player.y)
}
})
/**
* !ANIMATION PLAYER
*/
let walkCount = 1
document.getElementById("bruits_pas_1").volume = "0.3"
document.getElementById("bruits_pas_2").volume = ".3"
function soundWalk() {
if (walkCount == 1) {
document.getElementById("bruits_pas_1").play()
walkCount = 0
} else {
document.getElementById("bruits_pas_2").play()
walkCount = 1
}
}
function animationChoose() {
if (state == 0) {
state = 1;
} else if (state == 1) {
state = 2
} else { state = 1 }
}
/**
* !DRAW PLAYER AND ERASE PLAYER
*/
function drawPlayer(url, x, y) {
const image = new Image();
image.src = url;
image.onload = () => {
lightsOnPlayer()
ctx.drawImage(image, x - player.radius, y - player.radius, player.radius * 2, player.radius * 2)
}
}
function drawPlayerWait(goTo, x, y) {
ctx.clearRect(player.x - player.radius - 2, player.y - player.radius - 2, player.radius * 2, player.radius * 2);
const image = new Image();
image.src = '../img/' + goTo + '/character_stopped.png';
image.onload = () => {
ctx.drawImage(image, x - player.radius, y - player.radius, player.radius * 2, player.radius * 2)
}
}
function clearPreviousPosition() {
ctx.clearRect(player.x - player.radius - 2, player.y - player.radius - 2, player.radius * 2, player.radius * 2);
}
function drawPlayerInDaGame(goTo) {
switch (state) {
case 1:
drawPlayer('../img/' + goTo + '/character_moving_left.png', player.x, player.y)
break;
case 2:
drawPlayer('../img/' + goTo + '/character_moving_right.png', player.x, player.y)
break;
}
}
/**
* !UPDATE OF THE MOVEMENT
*/
function updateStageObject() {
if (player.left && player.x - player.moveSize > 0) {
if (player.cooX % 15 != 0 && obstaclesArray[player.cooY * 15 + player.cooX - 1].id != 3 && obstaclesArray[player.cooY * 15 + player.cooX - 1].id != 2 && obstaclesArray[player.cooY * 15 + player.cooX - 1].id != 1 && obstaclesArray[player.cooY * 15 + player.cooX - 1].id != 0) {
soundWalk()
animationChoose()
clearPreviousPosition()
player.x -= player.moveSize;
player.cooX -= 1;
drawPlayerInDaGame('left');
}
}
if (player.right && player.x + player.moveSize + player.radius < canvas.getAttribute('width')) {
if (player.cooX % 15 != 14 && obstaclesArray[player.cooY * 15 + player.cooX + 1].id != 3 && obstaclesArray[player.cooY * 15 + player.cooX + 1].id != 2 && obstaclesArray[player.cooY * 15 + player.cooX + 1].id != 1 && obstaclesArray[player.cooY * 15 + player.cooX + 1].id != 0) {
soundWalk()
animationChoose()
clearPreviousPosition()
player.x += player.moveSize;
player.cooX += 1;
drawPlayerInDaGame('right');
}
}
if (player.forward && player.y - player.moveSize > 0) {
if (player.cooY % 15 != 0 && obstaclesArray[(player.cooY - 1) * 15 + player.cooX].id != 3 && obstaclesArray[(player.cooY - 1) * 15 + player.cooX].id != 2 && obstaclesArray[(player.cooY - 1) * 15 + player.cooX].id != 1 && obstaclesArray[(player.cooY - 1) * 15 + player.cooX].id != 0) {
soundWalk()
animationChoose()
clearPreviousPosition()
player.y -= player.moveSize;
player.cooY -= 1;
drawPlayerInDaGame('forward');
}
}
if (player.backward && player.y + player.moveSize < canvas.getAttribute('height')) {
if (player.cooY % 15 != 14 && obstaclesArray[(player.cooY + 1) * 15 + player.cooX].id != 3 && obstaclesArray[(player.cooY + 1) * 15 + player.cooX].id != 2 && obstaclesArray[(player.cooY + 1) * 15 + player.cooX].id != 1 && obstaclesArray[(player.cooY + 1) * 15 + player.cooX].id != 0) {
soundWalk()
clearPreviousPosition()
animationChoose()
player.y += player.moveSize;
player.cooY += 1;
drawPlayerInDaGame('backward');
}
}
checkEnd()
checkObstacles();
} | 30.094697 | 293 | 0.572561 |
011b91091cb5b422803c2791965ff80ea29b8158 | 81 | js | JavaScript | src/pages/Test/index.js | Torix-Park/ProxyPurchase | 76a0ca26503916cd3e18bc7660b9cf0905f9b59f | [
"BSD-3-Clause"
] | null | null | null | src/pages/Test/index.js | Torix-Park/ProxyPurchase | 76a0ca26503916cd3e18bc7660b9cf0905f9b59f | [
"BSD-3-Clause"
] | 1 | 2020-06-20T02:46:50.000Z | 2020-07-15T08:01:22.000Z | src/pages/Test/index.js | Torix05/ProxyPurchase | 76a0ca26503916cd3e18bc7660b9cf0905f9b59f | [
"BSD-3-Clause"
] | null | null | null | import { Test } from './test';
window.customElements.define('test-page', Test);
| 20.25 | 48 | 0.691358 |
011c28b9816f2c06e6bdd586ffa2acab9ec609f7 | 2,203 | js | JavaScript | src/store/modules/rongIm/index.js | hester2/web-jsb | 86f3858245001cbe46f2f4e1099c651bc9e36655 | [
"MIT"
] | null | null | null | src/store/modules/rongIm/index.js | hester2/web-jsb | 86f3858245001cbe46f2f4e1099c651bc9e36655 | [
"MIT"
] | null | null | null | src/store/modules/rongIm/index.js | hester2/web-jsb | 86f3858245001cbe46f2f4e1099c651bc9e36655 | [
"MIT"
] | null | null | null | import im from '@/common/rongIm'
import user from '@/store/modules/rongIm/user'
import conversation from '@/store/modules/rongIm/conversation'
import message from '@/store/modules/rongIm/message'
import {
SET_RONG_USER_ID
} from '@/store/mutationTypes/rongIm'
const rongIm = {
namespaced: true,
modules: {
user,
conversation,
message
},
state: {},
getters: {
rongUser(state, getters, rootState, rootGetters) {
return rootState.rongIm.user
},
rongMessage(state, getters, rootState, rootGetters) {
return rootState.rongIm.message
},
rongConversation(state, getters, rootState, rootGetters) {
return rootState.rongIm.conversation
},
conversationUser(state, getters, rootState, rootGetters) {
return rootState.rongIm.conversation.conversationUser
}
},
mutations: {},
actions: {
// 初始化
Init({
dispatch,
commit
}, userInfo) {
const user = {
token: userInfo.rcToken
}
im.connect(user).then((user) => {
const id = user.id
console.log('链接成功, 链接用户 id 为: ', user.id)
// 设置融云id
commit(`rongIm/user/${SET_RONG_USER_ID}`, id, {
root: true
})
// 获取融云详情
dispatch('rongIm/user/getRongCloudUser', id, {
root: true
})
// 获取融云好友列表
dispatch('rongIm/user/getFriendList', null, {
root: true
})
// 获取群组列表
dispatch('rongIm/user/getGroupList', id, {
root: true
})
// 获取所有会话列表
dispatch('rongIm/conversation/getConversationList', null, {
root: true
}).then(res => {
if (res.length) {
console.log('dd', res)
const rcIds = res.map(item => {
return item.targetId
})
// 获取融云用户信息
dispatch('rongIm/user/getRongClourUserList', rcIds, {
root: true
})
}
})
// 获取未读数
dispatch('rongIm/message/getTotalUnreadCount', null, {
root: true
})
}).catch(function(error) {
console.log('链接失败: ', error)
})
}
}
}
export default rongIm
| 23.688172 | 67 | 0.555152 |
011c9e141a955cd77d09f61fec063259ed140a9d | 1,057 | js | JavaScript | api/invoice/index.js | jilson23/REPECO-backend | c79baa8010ac48e937064a8baf31e991809e614a | [
"MIT"
] | 2 | 2021-12-09T21:50:03.000Z | 2022-02-05T21:58:11.000Z | api/invoice/index.js | jilson23/REPECO-backend | c79baa8010ac48e937064a8baf31e991809e614a | [
"MIT"
] | null | null | null | api/invoice/index.js | jilson23/REPECO-backend | c79baa8010ac48e937064a8baf31e991809e614a | [
"MIT"
] | null | null | null | const { Router } = require('express');
const { isAuthenticated } = require('../../auth/auth.service');
const {
createInvoiceHandler,
deleteInvoiceHandler,
getAllInvoicesHandler,
getInvoiceByIdHandler,
updateInvoiceHandler,
createCardTokenHandlers,
createCustomerHandlers,
makePaymentHandlers,
getInvoicesByUserId,
getInvoiceUserById
} = require('./invoice.controller');
const router = Router();
router.get('/', getAllInvoicesHandler);
router.get('/user-invoices', isAuthenticated(), getInvoicesByUserId)
router.post('/', isAuthenticated(), createInvoiceHandler);
router.get('/user/:id', isAuthenticated(), getInvoiceUserById);
router.get('/:id', getInvoiceByIdHandler);
router.delete('/:id', updateInvoiceHandler);
router.patch('/:id', deleteInvoiceHandler);
router.post('/card-token', isAuthenticated(), createCardTokenHandlers);
router.post('/customer', isAuthenticated(), createCustomerHandlers);
router.post('/payment', isAuthenticated(), makePaymentHandlers);
router.get('/:id', getInvoiceByIdHandler);
module.exports = router;
| 33.03125 | 71 | 0.763482 |
011cf5f88d5641ddf7109c0fd11e4eb603504f8e | 503 | js | JavaScript | bin/cmd.js | m59peacemaker/node-tap-filter | 76e61a808f5e7acc9c146f6db8e5abe5417700f0 | [
"CC0-1.0"
] | null | null | null | bin/cmd.js | m59peacemaker/node-tap-filter | 76e61a808f5e7acc9c146f6db8e5abe5417700f0 | [
"CC0-1.0"
] | null | null | null | bin/cmd.js | m59peacemaker/node-tap-filter | 76e61a808f5e7acc9c146f6db8e5abe5417700f0 | [
"CC0-1.0"
] | null | null | null | #!/usr/bin/env node
const program = require('commander')
const filter = require('../')
const supportedTypes = require('../lib/supported-types')
const spacer = '\n '
const args = program
.arguments('[types...]', 'types of TAP to be output')
.option('-r, --reverse', 'filter out given types')
.on('--help', () => {
console.log(` TAP types:${spacer}${supportedTypes.join(spacer)}`)
})
.parse(process.argv)
process.stdin
.pipe(filter(args.args, args.reverse))
.pipe(process.stdout)
| 26.473684 | 70 | 0.646123 |
011e42337831ab24164b744ba299f4de27326e5c | 5,341 | js | JavaScript | app/services/wizard/wizard-service.js | leandrocgsi/erudio-angular-api-client | 0e95ae6a7d811c61935adbe88b5e4a63f21e2a98 | [
"MIT"
] | null | null | null | app/services/wizard/wizard-service.js | leandrocgsi/erudio-angular-api-client | 0e95ae6a7d811c61935adbe88b5e4a63f21e2a98 | [
"MIT"
] | null | null | null | app/services/wizard/wizard-service.js | leandrocgsi/erudio-angular-api-client | 0e95ae6a7d811c61935adbe88b5e4a63f21e2a98 | [
"MIT"
] | null | null | null | angular.module('erudioApp').factory('WizardControll', ['$state', function($state){
return function($wizard){
var self = angular.extend(this,angular.copy($wizard));
self.currenSize = 0;
self.current = function(){
var cur = -1;
angular.forEach( self.steps, function(state, key){
if( state.status.indexOf('active') != -1 ){
cur = key;
}
});
if(cur != -1 ){
self.updateSize(cur);
}
return cur;
//return self.currentIndex >= 0 ? self.currentIndex : -1;
}
self.updateSize = function(currentStep){
self.currentSize = currentStep/(self.size()-1)*100;
}
self.isValid = function(success){
var current = self.current();
if( current != -1 && self.steps[current].validate && typeof(self.validate) == 'function' ){
return self.validate(success);
}
return success();
}
self.goNext = function(callback){
if( !self.isLast() ){
var current = self.current();
if( current != -1 ){
self.desactivate(current);
self.complete(current);
}
self.activate(++current);
if( self.isDisabled(current) ){
self.enable(current);
}
$state.go( self.steps[current].name, $state.params ).then( function(){
if( callback ){
callback();
}
});
}
}
self.goPrevious = function(callback){
if( !self.isFirst() ){
var current = self.current();
self.desactivate(current);
self.uncomplete(current);
self.activate(--current);
$state.go( self.steps[current].name, $state.params ).then( function(){
if( callback ){
callback();
}
});
}
}
self.next = function(){
return self.isValid(self.goNext);
}
self.previous = function(){
return self.goPrevious();
}
self.goTo = function(stateIndex){
var current = self.current();
if( stateIndex > current ){
return self.isValid( function(){
self.goNext( function(){ self.goTo(stateIndex) } );
} );
}else if( stateIndex < current ){
return self.goPrevious( function(){
self.goTo(stateIndex);
});
}
}
self.isFirst = function(){
return self.current() == 0;
}
self.isLast = function(){
return self.current() == self.steps.length-1;
}
self.isActive = function(stateIndex){
return self.steps[stateIndex].status.indexOf( 'active' ) != -1;
}
self.isComplete = function(stateIndex){
return self.steps[stateIndex].status.indexOf('complete') != -1;
}
self.isDisabled = function(stateIndex){
return self.steps[stateIndex].status.indexOf('disabled') != -1;
}
self.desactivate = function(stateIndex){
var index = self.steps[stateIndex].status.indexOf('active');
if( index != -1 ){
self.steps[stateIndex].status.splice(index, 1);
}
}
self.activate = function(stateIndex){
if( self.steps[stateIndex].status.indexOf('active') == -1 ){
self.steps[stateIndex].status.push('active');
}
}
self.enable = function(stateIndex){
var index = self.steps[stateIndex].status.indexOf('disabled');
if( index != -1 ){
self.steps[stateIndex].status.splice(index, 1);
}
}
self.disable = function(stateIndex){
if( self.steps[stateIndex].status.indexOf('disabled') == -1 ){
self.steps[stateIndex].status.push('disabled');
}
}
self.complete = function(stateIndex){
if( self.steps[stateIndex].status.indexOf('complete') == -1 ){
self.steps[stateIndex].status.push('complete');
}
}
self.uncomplete = function(stateIndex){
var index = self.steps[stateIndex].status.indexOf('complete');
if( index != -1 ){
self.steps[stateIndex].status.splice(index, 1);
}
}
self.check = function($stateName){
if( self.current() == -1 ){
$state.go( self.steps[0].name );
self.activate(0);
}else if( $state.is( self.controllState ) ){
$state.go( self.steps[0].name );
}
}
self.size = function(){
return self.steps.length;
}
return self;
};
}]); | 36.087838 | 103 | 0.453286 |
011eee0cfb160a2b4d72d7f0cc022b54c0225801 | 1,387 | js | JavaScript | compliancemanager-web-interface/packages/jest-preset-graylog/src/setup-files/console-warnings-fail-tests.js | xformation/xformation-compliancemanager-service | 6a0dd1f7f30afd3528239cbfcd436a2d2786fde4 | [
"Apache-2.0"
] | null | null | null | compliancemanager-web-interface/packages/jest-preset-graylog/src/setup-files/console-warnings-fail-tests.js | xformation/xformation-compliancemanager-service | 6a0dd1f7f30afd3528239cbfcd436a2d2786fde4 | [
"Apache-2.0"
] | null | null | null | compliancemanager-web-interface/packages/jest-preset-graylog/src/setup-files/console-warnings-fail-tests.js | xformation/xformation-compliancemanager-service | 6a0dd1f7f30afd3528239cbfcd436a2d2786fde4 | [
"Apache-2.0"
] | 1 | 2022-01-09T12:50:05.000Z | 2022-01-09T12:50:05.000Z | /*
* Copyright (C) 2020 Graylog, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
/* eslint-disable no-console */
import { format } from 'util';
import { DEPRECATION_NOTICE } from 'util/deprecationNotice';
console.origWarn = console.warn;
console.origError = console.error;
const ignoredWarnings = [
'react-async-component-lifecycle-hooks',
'react-unsafe-component-lifecycles',
DEPRECATION_NOTICE,
];
const ignoreWarning = (args) => (!args[0] || ignoredWarnings.filter((warning) => args[0].includes(warning)).length > 0);
console.warn = jest.fn((...args) => {
console.origWarn(...args);
if (!ignoreWarning(args)) {
throw new Error(format(...args));
}
});
console.error = jest.fn((...args) => {
console.origError(...args);
if (!ignoreWarning(args)) {
throw new Error(format(...args));
}
});
| 28.895833 | 120 | 0.699351 |
011f52b90c0516b0699e70063796c468bb12e08c | 354 | js | JavaScript | resources/assets/js/frontend/pages/SignIn.js | ChrisReeves12/so-good-php | 81866f5d76caf5344d5b7fedf901b4bee769639d | [
"MIT"
] | null | null | null | resources/assets/js/frontend/pages/SignIn.js | ChrisReeves12/so-good-php | 81866f5d76caf5344d5b7fedf901b4bee769639d | [
"MIT"
] | null | null | null | resources/assets/js/frontend/pages/SignIn.js | ChrisReeves12/so-good-php | 81866f5d76caf5344d5b7fedf901b4bee769639d | [
"MIT"
] | null | null | null | import React from 'react';
import ReactDOM from 'react-dom';
import SignInForm from '../components/sign_in_form/SignInForm';
export default class SignIn extends React.Component
{
static initialize()
{
let element = document.getElementById('sign_in_form');
if(element)
ReactDOM.render(<SignInForm/>, element);
}
}
| 25.285714 | 63 | 0.686441 |
012066a8ad9077e8155ad0c6e4b3475a22b4faba | 407 | js | JavaScript | public/static/common/chajian/wind.js | fishcg/imusicApp | 8c60d720c3c9e755334db5ddb762cad1c2c41479 | [
"Apache-2.0"
] | 539 | 2015-01-02T11:16:27.000Z | 2022-03-18T18:20:47.000Z | public/static/common/chajian/wind.js | fishcg/imusicApp | 8c60d720c3c9e755334db5ddb762cad1c2c41479 | [
"Apache-2.0"
] | 5 | 2015-01-06T02:21:19.000Z | 2020-08-28T01:18:17.000Z | public/static/common/chajian/wind.js | fishcg/imusicApp | 8c60d720c3c9e755334db5ddb762cad1c2c41479 | [
"Apache-2.0"
] | 108 | 2015-01-10T18:06:14.000Z | 2021-12-17T05:36:25.000Z | /***********************************************************************
The only purpose of this file is to load all the Wind.js modules and
return the root object in Node.js environment.
***********************************************************************/
var Wind = require("./wind-core");
require("./wind-compiler");
require("./wind-async");
require("./wind-promise");
module.exports = Wind; | 37 | 73 | 0.452088 |
0121185e6af7998b64ed9ebe98ca19ef4a3e708f | 7,192 | js | JavaScript | app/@esri/calcite-app-components/dist/esm-es5/calcite-fab.entry.js | lizeidsness/minimalist | 57657f7b37d2251b95dafe92e1d3776301a3a1c0 | [
"Apache-2.0"
] | 3 | 2020-07-17T21:04:01.000Z | 2021-11-30T15:14:45.000Z | app/@esri/calcite-app-components/dist/esm-es5/calcite-fab.entry.js | lizeidsness/minimalist | 57657f7b37d2251b95dafe92e1d3776301a3a1c0 | [
"Apache-2.0"
] | 4 | 2020-04-16T19:24:25.000Z | 2021-11-29T20:15:32.000Z | app/@esri/calcite-app-components/dist/esm-es5/calcite-fab.entry.js | lizeidsness/minimalist | 57657f7b37d2251b95dafe92e1d3776301a3a1c0 | [
"Apache-2.0"
] | 5 | 2020-06-11T20:51:53.000Z | 2021-11-30T15:22:13.000Z | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import { r as registerInstance, h, H as Host, g as getElement } from './index-03e9a7ba.js';
import { f as focusElement, a as getElementDir } from './dom-7d75fa2b.js';
var CSS = {
button: "button"
};
var ICONS = {
plus: "plus"
};
var calciteFabCss = ":host{-webkit-box-sizing:border-box;box-sizing:border-box;color:var(--calcite-app-foreground);font-family:var(--calcite-app-font-family);font-size:var(--calcite-app-font-size-0);line-height:var(--calcite-app-line-height);background-color:var(--calcite-app-background)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:host{background-color:var(--calcite-app-background-transparent)}:host([hidden]){display:none}:host([theme=dark]){--calcite-app-background:#404040;--calcite-app-foreground:#dfdfdf;--calcite-app-background-hover:#2b2b2b;--calcite-app-foreground-hover:#f3f3f3;--calcite-app-background-active:#151515;--calcite-app-foreground-active:#59d6ff;--calcite-app-foreground-subtle:#eaeaea;--calcite-app-background-content:#2b2b2b;--calcite-app-border:#2b2b2b;--calcite-app-border-hover:#2b2b2b;--calcite-app-border-subtle:#2b2b2b;--calcite-app-scrim:rgba(64, 64, 64, 0.8)}:host([theme=light]){--calcite-app-background:#ffffff;--calcite-app-foreground:#404040;--calcite-app-background-hover:#eaeaea;--calcite-app-foreground-hover:#2b2b2b;--calcite-app-background-active:#c7eaff;--calcite-app-foreground-active:#00619b;--calcite-app-foreground-subtle:#757575;--calcite-app-foreground-link:#007ac2;--calcite-app-background-content:#f3f3f3;--calcite-app-background-clear:transparent;--calcite-app-border:#eaeaea;--calcite-app-border-hover:#dfdfdf;--calcite-app-border-subtle:#f3f3f3;--calcite-app-border-active:#007ac2;--calcite-app-disabled-opacity:0.25;--calcite-app-scrim:rgba(255, 255, 255, 0.8)}";
var CalciteFab = /** @class */ (function () {
function class_1(hostRef) {
registerInstance(this, hostRef);
// --------------------------------------------------------------------------
//
// Properties
//
// --------------------------------------------------------------------------
/**
* Used to set the button's appearance. Default is outline.
*/
this.appearance = "outline";
/**
* When true, disabled prevents interaction. This state shows items with lower opacity/grayed.
*/
this.disabled = false;
/**
* The name of the icon to display. The value of this property must match the icon name from https://esri.github.io/calcite-ui-icons/.
*/
this.icon = ICONS.plus;
/**
* When true, content is waiting to be loaded. This state shows a busy indicator.
*/
this.loading = false;
/**
* Specifies the size of the fab.
*/
this.scale = "m";
/**
* Indicates whether the text is displayed.
*/
this.textEnabled = false;
}
// --------------------------------------------------------------------------
//
// Methods
//
// --------------------------------------------------------------------------
class_1.prototype.setFocus = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
focusElement(this.buttonEl);
return [2 /*return*/];
});
});
};
// --------------------------------------------------------------------------
//
// Render Methods
//
// --------------------------------------------------------------------------
class_1.prototype.render = function () {
var _this = this;
var _a = this, appearance = _a.appearance, disabled = _a.disabled, el = _a.el, loading = _a.loading, scale = _a.scale, theme = _a.theme, textEnabled = _a.textEnabled, icon = _a.icon, label = _a.label, text = _a.text;
var titleText = !textEnabled && text;
var title = label || titleText;
var dir = getElementDir(el);
return (h(Host, null, h("calcite-button", { class: CSS.button, loading: loading, disabled: disabled, title: title, "aria-label": label, theme: theme, dir: dir, scale: scale, icon: icon, round: true, floating: true, width: "auto", appearance: appearance, color: "blue", ref: function (buttonEl) {
_this.buttonEl = buttonEl;
} }, this.textEnabled ? this.text : null)));
};
Object.defineProperty(class_1.prototype, "el", {
get: function () { return getElement(this); },
enumerable: true,
configurable: true
});
return class_1;
}());
CalciteFab.style = calciteFabCss;
export { CalciteFab as calcite_fab };
| 62 | 1,536 | 0.543938 |
0121598ef4279a6a40df5572119a7b188cb82089 | 831 | js | JavaScript | Euler-5.js | VadimEv/ProjectEuler100 | b0e7f5672540ee2ed0e5143f21dffb37f67289fd | [
"MIT"
] | null | null | null | Euler-5.js | VadimEv/ProjectEuler100 | b0e7f5672540ee2ed0e5143f21dffb37f67289fd | [
"MIT"
] | null | null | null | Euler-5.js | VadimEv/ProjectEuler100 | b0e7f5672540ee2ed0e5143f21dffb37f67289fd | [
"MIT"
] | null | null | null | /* This one returns smallest common multiple of all Natural number less or equal to N */
/* Greatest common divisor, Euclid says Hi! */
var gcd = function (a, b) {
if (!b) { return a }
return gcd(b, a % b)
}
/* LArgest common multiple of 2 numbers */
var lcm = function (a, b) {
return a * b / gcd(a, b)
}
/* Populate the array */
var numArr = function (n) {
/* Keys method populates array with index values, which starts from Zero so we need to add one */
const arr = [...Array(n).keys()].map(i => i + 1).reverse()
return arr
}
/* In order to find LCM of N numbers we gonna call it reqursively for 2 numbers, reduce is ideal for this */
function smallestMult (n) {
const sM = numArr(n).reduce(function (accumulator, currentValue) {
return lcm(accumulator, currentValue)
}, 1)
return sM
}
smallestMult(20)
| 29.678571 | 108 | 0.66787 |
0121688b28dec59532bee489185491468d402e32 | 11,161 | js | JavaScript | dist/src/lib/discovery.js | iherman/PubManifest | d21b256b34f784cd4d8cb6424b5c6aed9c07fddd | [
"W3C-20150513"
] | 1 | 2022-03-19T09:48:28.000Z | 2022-03-19T09:48:28.000Z | dist/src/lib/discovery.js | panaC/PubManifest | edb58baedf696c37dd45ebd6594f889670f31368 | [
"W3C-20150513"
] | 3 | 2020-08-06T15:06:53.000Z | 2022-02-18T05:24:39.000Z | dist/src/lib/discovery.js | panaC/PubManifest | edb58baedf696c37dd45ebd6594f889670f31368 | [
"W3C-20150513"
] | 1 | 2020-08-06T13:47:30.000Z | 2020-08-06T13:47:30.000Z | "use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
/** Media type for JSON */
const json_content_type = 'application/json';
/** Media type for JSON-LD */
const jsonld_content_type = 'application/ld+json';
/** Media type for HTML */
const html_content_type = 'text/html';
const node_fetch = __importStar(require("node-fetch"));
const urlHandler = __importStar(require("url"));
const validUrl = __importStar(require("valid-url"));
const jsdom = __importStar(require("jsdom"));
/**
* The effective fetch implementation run by the rest of the code.
*
* If the code is ran in a browser, we get an error message whereby
* only the fetch implementation in the Window is acceptable for the browser. However, there is
* no default fetch implementation for `node.js`, hence the necessity to import 'node-fetch' for that case.
*
* I guess this makes this entry a bit polyfill like:-)
*/
const my_fetch = (process !== undefined) ? node_fetch.default : fetch;
/**
* Basic sanity check on a URL that is supposed to be used to retrieve a Web Resource.
*
* The function returns a (possibly slightly modified) version of the URL if everything is fine, or a null value if
* the input argument is not a URL (but should be used as a filename).
*
* There might be errors, however, in the case it is a URL.
*
* The checks are as follows:
*
* 1. Check whether the protocol is http(s). Other protocols are not accepted (actually rejected by fetch, too);
* 2. Run the URL through a valid-url check, which looks at the validity of the URL in terms of
* characters used, for example;
* 3. Check that the port (if specified) is in the allowed range, ie, > 1024;
*
* @param address - the URL to be checked.
* @returns - the URL itself (which might be slightly improved by the valid-url method) or null if this is, in fact, not a URL
* @throws if it pretends to be a URL, but it is not acceptable for some reasons.
*/
function check_Web_url(address) {
const parsed = urlHandler.parse(address);
if (parsed.protocol === null) {
// This is not a URL, should be used as a file name
throw new Error(`"${address}": Invalid URL: no protocol`);
}
// Check whether we use the right protocol
if (['http:', 'https:'].includes(parsed.protocol) === false) {
throw new Error(`"${address}": URL is not dereferencable`);
}
// Run through the URL validator
const retval = validUrl.isWebUri(address);
if (retval === undefined) {
throw new Error(`"${address}": the URL isn't valid`);
}
// Check the port
if (parsed.port !== null) {
try {
const portNumber = Number(parsed.port);
if (portNumber <= 1024) {
throw new Error(`"${address}": Unsafe port number used in URL (${parsed.port})`);
}
}
catch (e) {
throw new Error(`"${address}": Invalid port number used in URL (${parsed.port})`);
}
}
// If we got this far, this is a proper URL, ready to be used.
return retval;
}
/**
* The types of documents that are considered in this module
*/
var ContentType;
(function (ContentType) {
ContentType["json"] = "json";
ContentType["html"] = "html";
})(ContentType || (ContentType = {}));
;
/**
* Get Web resource via a fetch. A sanity (security) check of the URL using [[check_Web_url]] is ran to avoid errors.
*
* @async
* @param resource_url - The URL of the resource to be fetched
* @param format - Expected format. Default is JSON (ie, application/json). Accepted values are HTML, and JSON (including the 'derivatives', ie, application/XXX+json)
* @return - Promise encapsulating the body of the resource. The appropriate parsing should be done by the caller
* @throws Error if something goes wrong with fetch
*/
async function fetch_resource(resource_url, format) {
// If there is a problem, an exception is raised
return new Promise((resolve, reject) => {
try {
// This is a real URL, whose content must be accessed via HTTP(S)
// An exception is raised if the URL has security/sanity issues.
const final_url = check_Web_url(resource_url);
my_fetch(final_url)
.then((response) => {
if (response.ok) {
// If the response content type is set (which is usually the case, but not in all cases...)
const response_type = response.headers.get('content-type');
if (response_type && response_type !== '') {
// check whether we got what we wanted
if (format === ContentType.json) {
if (response_type === json_content_type || response_type === jsonld_content_type) {
resolve(response.text());
}
}
else {
// we expect HTML then
if (response_type === html_content_type) {
resolve(response.text());
}
}
reject(new Error(`unexpected content type, expected ${format === ContentType.json ? 'json' : 'html'}`));
}
else {
// No type information on return, let us hope this is something proper
// TODO: (in case of a full implementation) to do something intelligent if there is no response header content type.
resolve(response.text());
}
}
else {
reject(new Error(`HTTP response ${response.status}: ${response.statusText}`));
}
})
.catch((err) => {
reject(new Error(`Problem accessing ${final_url}: ${err}`));
});
}
catch (err) {
reject(err);
}
});
}
/**
* Fetch an HTML file via [[fetch_resource]] and parse the result into the DOM.
*
* @async
* @param html_url - URL to be fetched
* @return - DOM object for the parsed HTML
* @throws Error if something goes wrong with fetch or DOM Parsing
*/
async function fetch_html(html_url) {
try {
const body = await fetch_resource(html_url, ContentType.html);
const retval = new jsdom.JSDOM(body, { url: html_url });
return retval;
}
catch (err) {
throw new Error(`HTML parsing error in ${html_url}: ${err}`);
}
}
exports.fetch_html = fetch_html;
/**
* Fetch the (text) content of a JSON file via via [[fetch_resource]]
*
* @async
* @param json_url - URL to be fetched
* @return - JSON content
* @throws Error if something goes wrong with fetch
*/
async function fetch_json(json_url) {
try {
const body = await fetch_resource(json_url, ContentType.json);
return body;
}
catch (err) {
throw new Error(`JSON fetch error in ${json_url}: ${err}`);
}
}
exports.fetch_json = fetch_json;
/**
* Obtain the manifest starting with the DOM of the primary entry page. This function retrieves the manifest (either from a
* script element or fetching a separate file).
*
* This corresponds to [§4.1 Linking](https://www.w3.org/TR/pub-manifest/#manifest-link) and [§4.2](https://www.w3.org/TR/pub-manifest/#manifest-embed) in the [§4. Manifest Discovery](https://www.w3.org/TR/pub-manifest/#manifest-discovery) section.
*
*
* @async
* @param dom - the DOM of the primary entry page
* @return - object with entries describing the manifest: `manifest_text`, `base`, `origin`
* @throws if something goes wrong while trying to get hold of the manifest
*/
async function obtain_manifest(dom) {
try {
const origin = dom.window.document.location.href;
const document = dom.window.document;
let text = '';
let base = '';
// Find the link element that returns the reference to the manifest
const link = document.querySelector('link[rel*="publication"]');
if (!link) {
// No manifest reference!
throw new Error(`No manifest reference found in ${origin}`);
}
const ref = link.getAttribute('href');
if (ref[0] === '#') {
// The manifest ought to be local in the file
const script = document.querySelector(`script${ref}`);
if (script) {
text = script.text;
base = script.baseURI;
}
else {
throw new Error(`Manifest in ${origin} not found`);
}
}
else {
// The manifest file must be fetched
// Note that the 'href' attributes takes care of the possible relative URL-s, which is handy...
try {
text = await fetch_json(link.href);
base = link.href;
}
catch (err) {
throw new Error(`Problems reaching Manifest at ${link.href} (${err.message})`);
}
}
return { text, base, document };
}
catch (err) {
throw new Error(`Manifest processing error: ${err.message}`);
}
}
/**
* Discovering the manifest.
*
* This corresponds to the [§4 Manifest Discovery](https://www.w3.org/TR/pub-manifest/#manifest-discovery) section, including the
* possibility to process a JSON file link directly (corresponding to [§4.3](https://www.w3.org/TR/pub-manifest/#manifest-other-discovery)).
*
* The decision on whether the incoming URL refers to an HTML or a JSON resource is rudimentary: it looks at the suffix of the URL (`.json` or `.jsonld` for a JSON
* content, `.html` for HTML). This is fine for a test environment; real implementations should do something more sophisticated.
*
* @async
* @param address - The address of either the manifest itself, or the primary entry page.
* @throws if something goes wrong during discovery
*/
async function discover_manifest(address) {
try {
const parsedURL = urlHandler.parse(address);
if (parsedURL.path.endsWith('.json') || parsedURL.path.endsWith('.jsonld')) {
const text = await fetch_json(address);
const base = address;
const document = undefined;
return { text, base, document };
}
else if (parsedURL.path.endsWith('.html')) {
const dom = await fetch_html(address);
const retval = obtain_manifest(dom);
return retval;
}
else {
throw new Error(`unrecognized suffix (${parsedURL.path})`);
}
}
catch (err) {
throw new Error(`Problems discovering the manifest (${err.message})`);
}
}
exports.discover_manifest = discover_manifest;
//# sourceMappingURL=discovery.js.map | 41.490706 | 248 | 0.60568 |
0121efbace66d2d09b2d847cb3ca3b5c922d9519 | 1,488 | js | JavaScript | app/scripts/payload-builder.js | graemepatt/BerryCamExpress | bc23cee5ef4dd251db685f96ade03f97891f5452 | [
"BSD-3-Clause"
] | 1 | 2021-11-09T10:23:24.000Z | 2021-11-09T10:23:24.000Z | app/scripts/payload-builder.js | sam9032/BerryCamExpress | e548d61cbd3ed8ae8bec33d7a2551fe759b88723 | [
"BSD-3-Clause"
] | 1 | 2015-07-13T09:43:43.000Z | 2015-07-13T09:43:43.000Z | app/scripts/payload-builder.js | sam9032/BerryCamExpress | e548d61cbd3ed8ae8bec33d7a2551fe759b88723 | [
"BSD-3-Clause"
] | null | null | null | define(['config', 'image-utils', 'jquery', 'model/datamodel'], function (config, imageUtils, $, datamodel) {
'use strict';
function buildPayload() {
var data = datamodel.data,
dimensions = imageUtils.createImageDimension(data.size.selectedValue()),
opts = {
w: dimensions.width,
h: dimensions.height,
exif: 'IFD1.Software=BerryCam -x EXIF.MakerNote=BerryCam -x EXIF.UserComment=BerryCam',
q: data.q.selectedValue(),
awb: data.awb.selectedValue(),
mm: data.mm.selectedValue(),
ev: parseInt(data.ev.selectedValue().replace('+', '')),
ex: data.ex.selectedValue(),
sh: data.sh.selectedValue(),
br: data.br.selectedValue(),
co: data.co.selectedValue(),
sa: data.sa.selectedValue(),
ifx: data.ifx.selectedValue(),
ISO: data.ISO.selectedValue()
};
if (data.vf.selectedValue() === 'On') {
opts.vf = true;
}
if (data.hf.selectedValue() === 'On') {
opts.hf = true;
}
if (data.mode.selectedValue() === 'Single Image') {
opts.mode = 'photo';
} else if (data.mode.selectedValue() === 'Timelapse') {
opts.mode = 'timelapse';
}
return opts;
}
return {
buildPayload: buildPayload
};
});
| 31 | 108 | 0.502688 |
012231274f41ec66466dd95de182ffcc33512770 | 57 | js | JavaScript | src/components/pages/PageNav/index.js | Lambda-School-Labs/Labs26-Citrics-FE-TeamB | 2bd2c6fd8eefaa84238db59a864662a3872ecb0a | [
"MIT"
] | 4 | 2020-09-08T21:38:11.000Z | 2021-03-24T08:42:30.000Z | src/components/pages/PageNav/index.js | labs26-citrics/Labs26-Citrics-FE-TeamB | 20e4a7d66ee24c8cd949981e5466bad6d96a86b5 | [
"MIT"
] | 2 | 2020-09-16T19:29:17.000Z | 2020-09-21T20:24:20.000Z | src/components/pages/PageNav/index.js | labs26-citrics/Labs26-Citrics-FE-TeamB | 20e4a7d66ee24c8cd949981e5466bad6d96a86b5 | [
"MIT"
] | 4 | 2020-10-13T21:56:16.000Z | 2021-01-24T17:00:01.000Z | export { default as PageNav } from "./PageNavContainer";
| 28.5 | 56 | 0.736842 |
0122694eda8454e166b857baffa5060c3cf52db3 | 1,033 | js | JavaScript | gemini.js | gemini-testing/retry-limiter | 90106c12798145846bbd43dc06a88dbc9a34307c | [
"MIT"
] | 1 | 2019-05-31T06:34:31.000Z | 2019-05-31T06:34:31.000Z | gemini.js | gemini-testing/retry-limiter | 90106c12798145846bbd43dc06a88dbc9a34307c | [
"MIT"
] | 2 | 2017-06-30T11:22:47.000Z | 2019-09-05T15:06:49.000Z | gemini.js | gemini-testing/retry-limiter | 90106c12798145846bbd43dc06a88dbc9a34307c | [
"MIT"
] | 1 | 2022-03-19T07:41:39.000Z | 2022-03-19T07:41:39.000Z | 'use strict';
const _ = require('lodash');
const ConfigDecorator = require('./lib/gemini-config-decorator');
const parseOpts = require('./lib/plugin-opts');
const Limiter = require('./lib/limiter');
module.exports = (gemini, opts) => {
opts = parseOpts(opts);
if (!opts.enabled) {
return;
}
const configDecorator = ConfigDecorator.create(gemini.config);
let limiter;
gemini.on(gemini.events.BEGIN, (data) => {
limiter = Limiter.create({limit: opts.limit}, getTotalTestsCount(data.suiteCollection));
});
gemini.on(gemini.events.RETRY, function retryCallback() {
if (!limiter.exceedRetriesLimit()) {
return;
}
configDecorator.disableRetries();
gemini.removeListener(gemini.events.RETRY, retryCallback);
});
};
function getTotalTestsCount(suiteCollection) {
return _.sumBy(suiteCollection.allSuites(), (suite) => {
return suite.states.length * _.sumBy(suite.browsers, (browser) => !suite.shouldSkip(browser));
});
}
| 27.918919 | 102 | 0.653437 |
01243a45079ec0db0df82e9d9bc88aef6a43d892 | 7,833 | js | JavaScript | highmaps/230303.js | lbp0200/highcharts-china-geo | a8342835f3004d257c11aab196272b449aa58899 | [
"MIT"
] | 40 | 2016-06-24T03:14:42.000Z | 2022-01-15T11:17:13.000Z | highmaps/230303.js | lbp0200/highcharts-china-geo | a8342835f3004d257c11aab196272b449aa58899 | [
"MIT"
] | null | null | null | highmaps/230303.js | lbp0200/highcharts-china-geo | a8342835f3004d257c11aab196272b449aa58899 | [
"MIT"
] | 46 | 2016-01-12T16:08:07.000Z | 2022-03-30T17:37:44.000Z | Highcharts.maps["countries/cn/230303"] = {"type":"FeatureCollection","features":[{"type":"Feature","properties":{"adcode":230303,"name":"恒山区","center":[130.910636,45.213242],"centroid":[130.913982,45.158084],"childrenNum":0,"level":"district","acroutes":[100000,230000,230300],"parent":{"adcode":230300},"longitude":130.913982,"latitude":45.158084},"geometry":{"type":"MultiPolygon","coordinates":[[[[9290,7825],[9290,7825],[9291,7824],[9291,7824],[9291,7823],[9292,7823],[9292,7823],[9293,7823],[9293,7822],[9293,7821],[9294,7821],[9294,7820],[9295,7820],[9295,7820],[9296,7820],[9296,7820],[9296,7819],[9296,7819],[9296,7818],[9297,7817],[9297,7817],[9297,7817],[9296,7816],[9296,7817],[9296,7817],[9295,7817],[9294,7817],[9294,7817],[9294,7816],[9294,7816],[9293,7816],[9293,7816],[9292,7817],[9292,7816],[9291,7815],[9290,7814],[9290,7814],[9290,7813],[9289,7813],[9289,7812],[9289,7812],[9288,7812],[9288,7811],[9286,7810],[9286,7810],[9286,7809],[9286,7808],[9286,7808],[9287,7808],[9287,7808],[9288,7807],[9288,7807],[9288,7807],[9289,7807],[9290,7806],[9290,7806],[9290,7806],[9291,7806],[9291,7806],[9291,7806],[9292,7806],[9292,7807],[9293,7806],[9293,7806],[9293,7805],[9293,7805],[9293,7804],[9292,7804],[9292,7803],[9293,7803],[9293,7803],[9293,7802],[9293,7801],[9292,7801],[9292,7801],[9291,7800],[9291,7800],[9291,7799],[9290,7799],[9290,7798],[9289,7798],[9289,7797],[9289,7796],[9289,7796],[9289,7796],[9288,7795],[9288,7795],[9288,7794],[9288,7793],[9288,7793],[9288,7792],[9288,7792],[9287,7791],[9287,7790],[9286,7789],[9285,7789],[9285,7788],[9285,7788],[9285,7788],[9286,7787],[9286,7786],[9286,7786],[9286,7786],[9286,7785],[9286,7784],[9286,7784],[9285,7783],[9285,7783],[9285,7782],[9285,7781],[9286,7779],[9286,7779],[9287,7778],[9287,7778],[9288,7778],[9288,7777],[9289,7777],[9289,7777],[9289,7776],[9289,7776],[9289,7776],[9289,7775],[9289,7775],[9290,7774],[9290,7774],[9290,7774],[9290,7774],[9290,7773],[9290,7772],[9290,7772],[9290,7771],[9289,7771],[9289,7770],[9288,7770],[9288,7769],[9288,7769],[9287,7768],[9287,7768],[9287,7767],[9286,7767],[9286,7767],[9286,7766],[9285,7766],[9285,7765],[9285,7764],[9284,7764],[9284,7764],[9283,7763],[9283,7763],[9283,7763],[9283,7762],[9282,7761],[9282,7761],[9282,7760],[9282,7760],[9282,7759],[9282,7759],[9282,7758],[9281,7758],[9281,7758],[9281,7758],[9280,7758],[9279,7758],[9279,7758],[9278,7758],[9278,7758],[9277,7757],[9277,7757],[9276,7757],[9276,7757],[9276,7756],[9275,7756],[9275,7756],[9274,7756],[9274,7756],[9273,7756],[9273,7756],[9272,7754],[9272,7754],[9271,7754],[9270,7755],[9270,7755],[9269,7755],[9269,7755],[9268,7755],[9268,7755],[9268,7756],[9267,7756],[9267,7757],[9267,7757],[9267,7757],[9267,7757],[9267,7758],[9267,7758],[9267,7758],[9267,7759],[9266,7758],[9266,7759],[9266,7760],[9266,7760],[9267,7761],[9267,7761],[9267,7761],[9267,7761],[9267,7762],[9267,7763],[9267,7763],[9267,7764],[9267,7764],[9267,7765],[9267,7765],[9267,7766],[9267,7767],[9267,7767],[9267,7767],[9266,7766],[9266,7766],[9266,7767],[9265,7767],[9265,7767],[9264,7767],[9264,7766],[9263,7766],[9262,7766],[9262,7766],[9262,7766],[9262,7768],[9263,7769],[9263,7770],[9263,7771],[9263,7771],[9263,7772],[9262,7772],[9262,7773],[9262,7773],[9261,7773],[9260,7773],[9260,7774],[9259,7774],[9259,7775],[9258,7775],[9258,7776],[9258,7776],[9257,7776],[9256,7777],[9256,7777],[9257,7778],[9257,7778],[9258,7779],[9258,7779],[9258,7779],[9257,7779],[9257,7780],[9257,7780],[9256,7781],[9256,7781],[9255,7781],[9255,7782],[9255,7783],[9255,7783],[9255,7784],[9254,7784],[9254,7785],[9253,7785],[9253,7785],[9253,7785],[9252,7786],[9252,7786],[9253,7786],[9253,7786],[9253,7786],[9253,7787],[9254,7787],[9254,7787],[9254,7788],[9254,7788],[9254,7788],[9254,7789],[9254,7790],[9254,7790],[9254,7790],[9253,7790],[9252,7791],[9252,7791],[9252,7791],[9252,7792],[9252,7792],[9253,7792],[9253,7792],[9252,7792],[9252,7792],[9252,7793],[9252,7793],[9252,7794],[9252,7794],[9252,7795],[9251,7795],[9250,7795],[9250,7795],[9250,7795],[9249,7795],[9249,7795],[9249,7795],[9249,7796],[9249,7796],[9249,7797],[9249,7798],[9250,7799],[9250,7800],[9251,7800],[9251,7801],[9251,7801],[9252,7801],[9252,7801],[9252,7802],[9251,7803],[9251,7803],[9251,7804],[9251,7804],[9250,7804],[9250,7804],[9249,7804],[9248,7803],[9248,7803],[9248,7803],[9247,7804],[9247,7804],[9246,7805],[9246,7805],[9246,7806],[9246,7807],[9246,7808],[9246,7808],[9246,7808],[9245,7808],[9245,7808],[9244,7808],[9244,7808],[9243,7808],[9242,7808],[9242,7808],[9242,7809],[9241,7809],[9241,7808],[9241,7808],[9240,7808],[9240,7807],[9240,7807],[9240,7806],[9240,7806],[9240,7805],[9241,7804],[9241,7803],[9241,7803],[9240,7803],[9240,7802],[9240,7802],[9239,7802],[9238,7803],[9238,7803],[9238,7803],[9237,7803],[9236,7804],[9234,7804],[9234,7804],[9234,7804],[9233,7804],[9233,7805],[9233,7805],[9233,7806],[9233,7806],[9232,7806],[9231,7806],[9231,7805],[9230,7805],[9230,7805],[9230,7805],[9230,7806],[9230,7806],[9230,7806],[9230,7807],[9230,7807],[9230,7807],[9231,7808],[9231,7809],[9232,7809],[9232,7810],[9231,7810],[9231,7810],[9231,7811],[9232,7811],[9232,7812],[9233,7812],[9233,7813],[9233,7813],[9233,7814],[9233,7814],[9233,7815],[9233,7815],[9233,7816],[9233,7816],[9233,7816],[9234,7816],[9234,7817],[9234,7817],[9234,7818],[9234,7819],[9234,7820],[9234,7820],[9234,7821],[9234,7821],[9233,7822],[9233,7823],[9234,7823],[9234,7824],[9234,7825],[9235,7825],[9235,7826],[9235,7826],[9237,7830],[9238,7830],[9238,7831],[9238,7832],[9238,7834],[9238,7834],[9240,7834],[9240,7834],[9241,7834],[9241,7834],[9241,7834],[9242,7834],[9242,7834],[9243,7834],[9243,7834],[9243,7834],[9244,7835],[9244,7835],[9243,7836],[9244,7836],[9244,7837],[9244,7838],[9244,7838],[9244,7838],[9245,7838],[9245,7838],[9245,7838],[9246,7838],[9246,7839],[9246,7839],[9247,7840],[9247,7840],[9248,7840],[9249,7840],[9249,7840],[9250,7840],[9250,7839],[9250,7839],[9250,7839],[9250,7838],[9250,7838],[9250,7838],[9251,7837],[9251,7837],[9251,7837],[9251,7837],[9252,7837],[9252,7837],[9252,7837],[9252,7837],[9253,7836],[9254,7836],[9254,7836],[9254,7836],[9255,7835],[9256,7835],[9256,7835],[9256,7835],[9256,7834],[9256,7834],[9256,7833],[9256,7832],[9256,7832],[9256,7831],[9256,7831],[9256,7831],[9256,7830],[9256,7829],[9256,7829],[9256,7829],[9256,7828],[9256,7827],[9256,7827],[9256,7826],[9256,7826],[9256,7825],[9256,7825],[9256,7824],[9256,7824],[9256,7824],[9256,7823],[9255,7823],[9255,7822],[9255,7822],[9255,7822],[9255,7821],[9255,7821],[9255,7820],[9256,7820],[9257,7820],[9257,7820],[9257,7819],[9258,7819],[9258,7819],[9258,7819],[9259,7819],[9259,7819],[9259,7819],[9260,7819],[9260,7819],[9260,7818],[9260,7819],[9261,7819],[9261,7819],[9261,7819],[9261,7819],[9261,7818],[9262,7818],[9262,7818],[9263,7818],[9263,7817],[9263,7816],[9264,7816],[9264,7816],[9265,7817],[9265,7817],[9266,7817],[9266,7817],[9267,7818],[9267,7818],[9268,7818],[9268,7818],[9268,7819],[9268,7819],[9269,7820],[9269,7820],[9269,7820],[9270,7821],[9270,7822],[9270,7823],[9270,7823],[9271,7823],[9271,7822],[9272,7822],[9273,7822],[9274,7822],[9274,7822],[9275,7822],[9276,7822],[9276,7822],[9277,7822],[9277,7822],[9278,7822],[9278,7822],[9278,7822],[9279,7822],[9279,7822],[9279,7822],[9280,7822],[9281,7823],[9281,7823],[9282,7823],[9282,7823],[9282,7823],[9283,7822],[9283,7822],[9284,7822],[9284,7822],[9285,7822],[9285,7822],[9285,7822],[9287,7823],[9288,7822],[9288,7823],[9288,7823],[9290,7824],[9290,7825]]]]}}],"UTF8Encoding":true,"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:3415"}},"hc-transform":{"default":{"crs":"+proj=lcc +lat_1=18 +lat_2=24 +lat_0=21 +lon_0=114 +x_0=500000 +y_0=500000 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m +no_defs","scale":0.000129831107685,"jsonres":15.5,"jsonmarginX":-999,"jsonmarginY":9851,"xoffset":-3139937.49309,"yoffset":4358972.7486}}} | 7,833 | 7,833 | 0.670241 |
0124f357fd2ea60c408dc86144d94e82089912a4 | 618 | js | JavaScript | assets/js/afegirServei.js | bruno51194/webPekiApp | 3150af399c2dc379da2a696aa7256118ed01ffdd | [
"CC-BY-3.0"
] | 1 | 2017-06-07T10:04:02.000Z | 2017-06-07T10:04:02.000Z | assets/js/afegirServei.js | bruno51194/webPekiApp | 3150af399c2dc379da2a696aa7256118ed01ffdd | [
"CC-BY-3.0"
] | null | null | null | assets/js/afegirServei.js | bruno51194/webPekiApp | 3150af399c2dc379da2a696aa7256118ed01ffdd | [
"CC-BY-3.0"
] | null | null | null | // Form Submission
var servei = $("#form-solicitudServei");
servei.submit(function() {
$.ajax({
url: "Slim/api.php/afegirServei",
type: "POST",
data: servei.serialize(),
success: function(responseText){
var responseTextarray = responseText.split(" ");
if(responseTextarray[0] == "1"){
window.location.href = "index.php";
}else{
alert(responseTextarray[0]);
alert('Opss! Ha ocurrido algun problema.');
}
}
});
return false;
}); | 29.428571 | 66 | 0.483819 |
01270791fa84240d2250d50339fd94b7b53628b4 | 8,545 | js | JavaScript | test/discover.js | 0xflotus/gc-siphon | 0075da1a5680301888bc842e2c17f83566b86729 | [
"MIT"
] | 1 | 2020-07-24T22:21:56.000Z | 2020-07-24T22:21:56.000Z | test/discover.js | 0xflotus/gc-siphon | 0075da1a5680301888bc842e2c17f83566b86729 | [
"MIT"
] | 17 | 2018-05-01T09:47:23.000Z | 2020-06-01T01:04:27.000Z | test/discover.js | 0xflotus/gc-siphon | 0075da1a5680301888bc842e2c17f83566b86729 | [
"MIT"
] | 2 | 2018-10-29T15:12:24.000Z | 2020-08-03T00:50:27.000Z | /* eslint-env mocha */
const { expect } = require("chai");
const sinon = require("sinon");
const moment = require("moment");
const mongodb = require("mongo-mock");
const mock = require("mock-require");
const request = {};
const turf = require("@turf/turf");
mock("superagent", request);
const discover = require("../lib/discover");
function makeGeometry(latA, lonA, latB, lonB) {
const bbox = [
Math.min(lonA, lonB),
Math.min(latA, latB),
Math.max(lonA, lonB),
Math.max(latA, latB)
];
const feature = turf.bboxPolygon(bbox);
return feature.geometry;
}
describe("discover", () => {
let db = null;
let areas = null;
let gcs = null;
let tiles = null;
before(async () => {
request.get = sinon.stub().returns(request);
request.accept = sinon.stub().returns(request);
request.query = ({ x, y, z }) => {
return {
ok: true,
body: {
data: getTile({ x, y, z })
}
};
};
mongodb.max_delay = 1;
const MongoClient = mongodb.MongoClient;
db = await MongoClient.connect("mongodb://localhost:27017/unittest", {});
areas = db.collection("areas");
gcs = db.collection("gcs");
});
beforeEach(async () => {
await areas.deleteMany({});
await gcs.deleteMany({});
tiles = {};
});
after(() => {
db.close();
mock.stop("superagent");
});
const setTile = ({ x, y, z }, v) => {
tiles[JSON.stringify({ x, y, z })] = v;
};
const getTile = ({ x, y, z }) => {
return tiles[JSON.stringify({ x, y, z })] || {};
};
after(() => {});
it("should update discover date on undiscovered areas", async () => {
await areas.insertMany([
{ name: "area 1", geometry: makeGeometry(0, 0, 1, 1) },
{ name: "area 2", geometry: makeGeometry(10, 10, 11, 11) }
]);
await discover({ areas, gcs });
const docs = await areas.find({}).toArray();
for (let doc of docs) {
expect(doc.discover_date).to.exist;
}
});
it("should set discover count", async () => {
await areas.insertMany([
{ name: "area 1", geometry: makeGeometry(0, 0, 0.1, 0.1) }
]);
// return something for zoom level 12, but nothing else
setTile(
{ x: 2048, y: 2046, z: 12 },
{ "(0,0)": [{ i: "GC0001" }, { i: "GC0002" }] }
);
await discover({ areas, gcs });
const doc = await areas.findOne({});
expect(doc.count).to.equal(2);
});
it("should update discover date on old areas", async () => {
await areas.insertMany([
{
name: "area 1",
geometry: makeGeometry(0, 0, 1, 1),
discover_date: moment()
.subtract(24, "hours")
.toDate()
},
{
name: "area 2",
geometry: makeGeometry(10, 10, 11, 11),
discover_date: moment()
.subtract(23, "hours")
.toDate()
}
]);
await discover({ areas, gcs });
const docs = await areas.find({}).toArray();
for (let doc of docs) {
expect(doc.discover_date).to.exist;
}
});
it("should skip recently updated areas", async () => {
await areas.insertMany([
{
name: "area 1",
geometry: makeGeometry(0, 0, 1, 1),
discover_date: moment()
.subtract(22, "hours")
.toDate()
}
]);
const { discover_date: before_date } = await areas.findOne(
{},
{ discover_date: 1 }
);
await discover({ areas, gcs });
const { discover_date: after_date } = await areas.findOne(
{},
{ discover_date: 1 }
);
expect(before_date.toISOString()).to.equal(after_date.toISOString());
});
it("should use zoom level 12", async () => {
await areas.insertMany([
{
name: "area 1",
geometry: makeGeometry(0, 0, 0.1, 0.1)
}
]);
// return something for zoom level 12, but nothing else
setTile({ x: 2048, y: 2046, z: 12 }, { "(0,0)": [{ i: "GC0001" }] });
await discover({ areas, gcs });
const count = await gcs.count({});
expect(count).to.be.at.least(1);
});
it("should merge gcs from multiple tiles", async () => {
// x: 2048 -> 2049
// y: 2046 -> 2048
await areas.insertMany([
{
name: "area 1",
geometry: makeGeometry(0, 0, 0.1, 0.1)
}
]);
setTile({ x: 2048, y: 2046, z: 12 }, { "(0,0)": [{ i: "GC0001" }] });
setTile(
{ x: 2049, y: 2046, z: 12 },
{
"(0,0)": [{ i: "GC0001" }, { i: "GC0002" }]
}
);
await discover({ areas, gcs });
const count = await gcs.count({});
expect(count).to.equal(2);
});
it("should update gc data", async () => {
// this one should be upserted
await gcs.insert({ _id: "GC0003", foo: "bar", discover_date: "boom!" });
// x: 2048 -> 2049
// y: 2046 -> 2048
await areas.insertMany([
{
name: "area 1",
geometry: makeGeometry(0, 0, 0.1, 0.1)
}
]);
setTile({ x: 2048, y: 2046, z: 12 }, { "(0,0)": [{ i: "GC0001" }] });
setTile(
{ x: 2049, y: 2046, z: 12 },
{
"(0,0)": [{ i: "GC0002" }, { i: "GC0003" }]
}
);
const now = new Date();
await discover({ areas, gcs });
const gc1 = await gcs.find({ _id: "GC0001" }).next();
const gc2 = await gcs.find({ _id: "GC0002" }).next();
const gc3 = await gcs.find({ _id: "GC0003" }).next();
expect(gc1).to.exist;
expect(gc1.gc).to.equal("GC0001");
expect(gc1.tile).to.deep.equal({ x: 2048, y: 2046, z: 12 });
expect(gc1.bbox).to.exist;
expect(gc1.discover_date - now).to.be.below(5000);
expect(gc2).to.exist;
expect(gc2.gc).to.equal("GC0002");
expect(gc2.tile).to.deep.equal({ x: 2049, y: 2046, z: 12 });
expect(gc2.bbox).to.exist;
expect(gc2.discover_date - now).to.be.below(5000);
expect(gc3).to.exist;
expect(gc3.gc).to.equal("GC0003");
expect(gc3.tile).to.deep.equal({ x: 2049, y: 2046, z: 12 });
expect(gc3.bbox).to.exist;
expect(gc3.discover_date - now).to.be.below(5000);
});
it("should query the correct Groundspeak endpoint", async () => {
await areas.insertMany([
{
name: "area 1",
geometry: makeGeometry(0, 0, 0.1, 0.1)
}
]);
await discover({ areas, gcs });
expect(
request.get.calledWithMatch(/https:\/\/tiles0[1234]\.geocaching\.com\//)
).to.be.true;
expect(request.accept.calledWith("json")).to.be.true;
});
it("should query tile images before tile data", async () => {
await areas.insertMany([
{
name: "area 1",
geometry: makeGeometry(0, 0, 0.1, 0.1)
}
]);
await discover({ areas, gcs });
expect(request.get.calledWithMatch(/\/map\.png$/));
});
it("should handle tile fetch errors", async () => {
request.query = sinon.stub().returns({ ok: false });
await areas.insertMany([
{
name: "area 1",
geometry: makeGeometry(0, 0, 0.1, 0.1)
}
]);
try {
await discover({ areas, gcs });
expect(false).to.be.true;
} catch (err) {
expect(err.message).to.equal("Unable to fetch tile");
}
});
it("should handle empty tile responses", async () => {
request.query = sinon.stub().returns({ ok: true, body: {} });
await areas.insertMany([
{
name: "area 1",
geometry: makeGeometry(0, 0, 0.1, 0.1)
}
]);
try {
await discover({ areas, gcs });
expect(false).to.be.true;
} catch (err) {
expect(err.message).to.equal("Empty tile data");
}
});
it("should skip areas marked with inactive", async () => {
await areas.insertMany([
{
name: "area 1",
geometry: makeGeometry(0, 0, 1, 1),
inactive: true
}
]);
await discover({ areas, gcs });
const count = await areas.count({ discover_date: { $exists: true } });
expect(count).equal(0);
});
it("should skip already discovered one-shot areas", async () => {
await areas.insertMany([
{
name: "area 1",
geometry: makeGeometry(0, 0, 1, 1),
one_shot: true,
inactive: false,
discover_date: moment()
.subtract(48, "hours")
.toDate()
}
]);
const { discover_date: before_date } = await areas.findOne(
{},
{ discover_date: 1 }
);
await discover({ areas, gcs });
const { discover_date: after_date } = await areas.findOne(
{},
{ discover_date: 1 }
);
expect(before_date.toISOString()).to.equal(after_date.toISOString());
});
});
| 25.356083 | 78 | 0.536337 |
01278f0dacb5beb076eb0ff688a442d20500330c | 4,319 | js | JavaScript | server.js | Monther-alkhwaldeh/My_Book_app | f3fa0347115995e97f92b98747b87506cb03cdcc | [
"MIT"
] | null | null | null | server.js | Monther-alkhwaldeh/My_Book_app | f3fa0347115995e97f92b98747b87506cb03cdcc | [
"MIT"
] | null | null | null | server.js | Monther-alkhwaldeh/My_Book_app | f3fa0347115995e97f92b98747b87506cb03cdcc | [
"MIT"
] | null | null | null | require('dotenv').config();
const express = require('express')
const superagent = require('superagent')
const pg =require('pg');
const app = express();
const PORT = process.env.PORT;
const DATABASE_URL=process.env.DATABASE_URL;
const override = require('method-override');
// const client = new pg.Client(DATABASE_URL);
const ENV = process.env.ENV || 'DEP';
let client = '';
if (ENV === 'DEP') {
client = new pg.Client({
connectionString: DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
});
} else {
client = new pg.Client({
connectionString: DATABASE_URL,
});
}
app.use(override('_method'));
app.use(express.urlencoded({extended:true}));
app.use(express.static('public'))
app.set('view engine', 'ejs');
app.get('/test', (req, res) => {
res.render('pages/index');
})
app.get('/searches/new', displayForm);
app.post('/searches', showBooks);
app.post('/books', selectBook);
app.get('/', renderHome);
app.get('/books/:id',bookDeatails);
app.delete('/books/:id', deleteData);
app.put('/books/:id', updateData);
function displayForm(req, res) {
res.render('pages/searches/new')
}
function renderHome(req,res){
const sqlQuery='SELECT * FROM booktable;';
client.query(sqlQuery).then(results =>{
res.render('pages/index',{results:results.rows});
}).catch((error) => {
handleError(error,res);
})
}
function updateData(req,res){
const book_id=req.params.id;
const {title,author,isbn,description}=req.body;
const safeValues=[title,author,isbn,description,book_id];
const updateQuery='UPDATE booktable SET title=$1, author=$2, isbn=$3, description=$4 WHERE id=$5;';
client.query(updateQuery,safeValues).then(results=>{
res.redirect(`/books/${book_id}`);
}).catch((error) => {
handleError(error,res);
})
}
function deleteData(req,res){
const book_id=req.params.id;
const safeValues=[book_id];
const sqlDelete='DELETE FROM booktable WHERE id=$1;'
client.query(sqlDelete,safeValues).then(()=>{
res.redirect('/');
}).catch((error) => {
handleError(error,res);
})
}
function selectBook(req,res){
console.log(req.body);
const author=req.body.author;
const title=req.body.title;
const isbn=req.body.isbn;
const image =req.body.img;
const description= req.body.description;
const value=[title,author,isbn,image,description];
const sqlQuery='INSERT INTO booktable (title,author, isbn, image, description) VALUES($1, $2, $3,$4,$5) RETURNING id;';
client.query(sqlQuery, value).then((element)=>{
res.redirect(`/books/${element.rows[0].id}`);
}).catch(error=>{
handleError(error,res);
});
}
function bookDeatails(req,res){
const bookid=req.params.id;
const sql_query='SELECT * FROM booktable WHERE id=$1';
const safeValues=[bookid];
client.query(sql_query,safeValues).then(results=>{
res.render('pages/books/details.ejs',{results:results.rows});
}).catch(error=>{
handleError(error,res);
})
}
function showBooks(req, res) {
let urlBooks = `https://www.googleapis.com/books/v1/volumes`
const searchBy = req.body.searchBy
const searchByVl = req.body.search
const queryObj = {}
if(searchBy === 'title') {
queryObj['q'] = `+intitle:'${searchByVl}'`
}else if(searchBy === 'author') {
queryObj['q'] = `+inauthor:'${searchByVl}'`
}
superagent.get(urlBooks).query(queryObj).then(apiRes => {
return apiRes.body.items.map(book => new Book(book.volumeInfo))
}).then(results => {
res.render('pages/searches/show',{ searchResults: results })
}).catch((error) => {
handleError(error,res);
})
}
function handleError(error, res) {
res.render('pages/error', { error: error });
}
function Book(data) {
this.title = data.title? data.title:'Title was Found';
this.author = data.authors ? data.authors[0] :'Authors was not Found';
this.isbn = data.industryIdentifiers ? `ISBN_13 ${data.industryIdentifiers[0].identifier}` : 'No ISBN available';
this.description = data.description? data.description:'Description was not Found';
this.thumbnail = data.imageLinks? data.imageLinks.thumbnail : 'https://i7.uihere.com/icons/829/139/596/thumbnail-caefd2ba7467a68807121ca84628f1eb.png';
}
client.connect().then(() =>
app.listen(PORT, () => console.log(`Listening on port: ${PORT}`))
);
app.use('*', (req, res) => {
res.send(`All fine, Nothing to see YET ...`)
})
| 31.757353 | 153 | 0.68025 |
0127e296e2aaf59b23b22e54401bf9be0c23f5c7 | 166 | js | JavaScript | examples/sqlite/test.js | leobia/alasql | 0736d3fbf14071ff7ede25e47c35d2ba1ab48c2d | [
"MIT"
] | 5,641 | 2015-01-02T04:02:46.000Z | 2022-03-16T18:36:34.000Z | examples/sqlite/test.js | leobia/alasql | 0736d3fbf14071ff7ede25e47c35d2ba1ab48c2d | [
"MIT"
] | 1,337 | 2015-01-03T19:23:19.000Z | 2022-03-14T04:02:34.000Z | examples/sqlite/test.js | leobia/alasql | 0736d3fbf14071ff7ede25e47c35d2ba1ab48c2d | [
"MIT"
] | 677 | 2015-01-04T07:15:09.000Z | 2022-03-05T10:24:35.000Z | var fs = require('fs');
var SQL = require('./sql.js');
var data = fs.readFileSync('./Chinook_Sqlite.sqlite');
var sqldb = new SQL.Database(data);
console.log(sqldb);
| 27.666667 | 54 | 0.686747 |
0128e00ce3b63632999d82de17a5229e970538ac | 7,543 | js | JavaScript | examples/index.js | dorayakikun/taiyaki | 9fe2f65828531ab4a4b9eb959d28cd8fd9d05c84 | [
"MIT"
] | null | null | null | examples/index.js | dorayakikun/taiyaki | 9fe2f65828531ab4a4b9eb959d28cd8fd9d05c84 | [
"MIT"
] | 33 | 2017-02-10T12:47:04.000Z | 2020-01-07T09:24:00.000Z | examples/index.js | dorayakikun/taiyaki | 9fe2f65828531ab4a4b9eb959d28cd8fd9d05c84 | [
"MIT"
] | null | null | null | "use strict";
const mat4 = require("gl-matrix-mat4");
const quat = require("gl-matrix-quat");
const { RenderingContext } = require("../build/src/RenderingContext");
function createSphere(widthSegment, heightSegment, radius, rgba) {
const position = [];
const normal = [];
const color = [];
const textureCoord = [];
const index = [];
for (let i = 0; i <= widthSegment; i++) {
const r = (Math.PI / widthSegment) * i;
const ry = Math.cos(r);
const rr = Math.sin(r);
for (let j = 0; j <= heightSegment; j++) {
const tr = ((Math.PI * 2) / heightSegment) * j;
const tx = rr * radius * Math.cos(tr);
const ty = ry * radius;
const tz = rr * radius * Math.sin(tr);
const rx = rr * Math.cos(tr);
const rz = rr * Math.sin(tr);
position.push(tx, ty, tz);
normal.push(rx, ry, rz);
color.push(rgba[0], rgba[1], rgba[2], rgba[3]);
textureCoord.push(1 - (1 / heightSegment) * j, (1 / widthSegment) * i);
}
}
let r = 0;
for (let k = 0; k < widthSegment; k++) {
for (let l = 0; l < heightSegment; l++) {
r = (heightSegment + 1) * k + l;
index.push(r, r + 1, r + heightSegment + 2);
index.push(r, r + heightSegment + 2, r + heightSegment + 1);
}
}
return {
position,
normal,
color,
textureCoord,
index
};
}
function setupVbos(ctx, lightProgram, sphere) {
ctx.bindVbos(lightProgram, [
{ name: "position", value: sphere.position, stride: 3 },
{ name: "normal", value: sphere.normal, stride: 3 },
{ name: "color", value: sphere.color, stride: 4 }
]);
ctx.bindIbo(sphere.index);
}
function initRender(ctx, frameBufferAttr, bufferSize) {
ctx.bindFramebuffer(frameBufferAttr.value);
ctx.clear({ r: 0.3, g: 0.3, b: 0.3, a: 1 }, 1);
ctx.viewport({
x: 0,
y: 0,
width: bufferSize,
height: bufferSize
});
}
function setupUniforms(ctx, lightProgram, qt) {
const vMatrix = createVMatrix(qt);
const pMatrix = createPMatrix();
const vpMatrix = createVpMatrix(vMatrix, pMatrix);
const mMatrix = mat4.identity(mat4.create());
const mvpMatrix = createMvpMatrix(mMatrix, vpMatrix);
const invMatrix = createInvMatrix(mMatrix);
const light = [1, 1, 1];
ctx.bindUniforms(lightProgram, [
{ name: "mvpMatrix", type: "matrix4fv", value: mvpMatrix },
{ name: "invMatrix", type: "matrix4fv", value: invMatrix },
{ name: "light", type: "3fv", value: light }
]);
}
function convertToVec3(dst, q, p) {
const r = quat.create();
quat.invert(r, q);
const rp = quat.create();
quat.multiply(rp, r, p);
const rpq = quat.create();
quat.multiply(rpq, rp, q);
dst[0] = rpq[0];
dst[1] = rpq[1];
dst[2] = rpq[2];
}
function createVMatrix(qt) {
const cx = 1 * Number(Math.sin(0));
const cz = 1 * Number(Math.cos(0));
const eyePosition = quat.create();
eyePosition[0] = cx;
eyePosition[1] = 0;
eyePosition[2] = cz;
const centerPosition = [0.0, 0.0, 0.0];
const cameraUp = quat.create();
cameraUp[0] = 0;
cameraUp[1] = 1;
cameraUp[2] = 0;
const rotatedEyePosition = new Array(3);
convertToVec3(rotatedEyePosition, qt, eyePosition);
const rotatedCameraUp = new Array(3);
convertToVec3(rotatedCameraUp, qt, cameraUp);
const vMatrix = mat4.identity(mat4.create());
mat4.lookAt(vMatrix, rotatedEyePosition, centerPosition, rotatedCameraUp);
return vMatrix;
}
function createPMatrix() {
const pMatrix = mat4.identity(mat4.create());
mat4.perspective(pMatrix, 45, 1, 0.1, 10);
return pMatrix;
}
function createVpMatrix(vMatrix, pMatrix) {
const vpMatrix = mat4.identity(mat4.create());
mat4.multiply(vpMatrix, pMatrix, vMatrix);
return vpMatrix;
}
function createMvpMatrix(mMatrix, vpMatrix) {
const mvpMatrix = mat4.identity(mat4.create());
mat4.multiply(mvpMatrix, vpMatrix, mMatrix);
return mvpMatrix;
}
function createInvMatrix(mMatrix) {
const invMatrix = mat4.identity(mat4.create());
mat4.invert(invMatrix, mMatrix);
return invMatrix;
}
function initOrthoRender(canvas, ctx) {
ctx.bindFramebuffer(null);
ctx.clear({ r: 0.3, g: 0.3, b: 0.3, a: 1 }, 1);
ctx.viewport({
x: 0,
y: 0,
width: canvas.width,
height: canvas.height
});
}
function setupOrthoVbos(ctx, program) {
const position = [-1, 1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0];
const textureCoord = [0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0];
const index = [0, 1, 2, 2, 1, 3];
ctx.bindVbos(program, [
{ name: "position", value: position, stride: 3 },
{ name: "textureCoord", value: textureCoord, stride: 2 }
]);
ctx.bindIbo(index);
}
function setupuOrthoUniforms(canvas, ctx, program, hWeight, vWeight) {
const vMatrix = createOrthoVmatrix();
const pMatrix = createOrthoPmatrix();
const orthoMatrix = createOrthoMatrix(vMatrix, pMatrix);
ctx.bindUniforms(program, [
{ name: "orthoMatrix", type: "matrix4fv", value: orthoMatrix },
{ name: "texture", type: "1i", value: 0 },
{ name: "resolution", type: "2fv", value: [canvas.width, canvas.height] },
{ name: "hWeight", type: "1fv", value: hWeight },
{ name: "vWeight", type: "1fv", value: vWeight }
]);
}
function createOrthoVmatrix() {
const vMatrix = mat4.identity(mat4.create());
mat4.lookAt(vMatrix, [0, 0, 0.5], [0, 0, 0], [0, 1, 0]);
return vMatrix;
}
function createOrthoPmatrix() {
const pMatrix = mat4.identity(mat4.create());
mat4.ortho(pMatrix, -1, 1, 1, -1, 0.1, 1);
return pMatrix;
}
function createOrthoMatrix(vMatrix, pMatrix) {
const orthoMatrix = mat4.identity(mat4.create());
mat4.multiply(orthoMatrix, pMatrix, vMatrix);
return orthoMatrix;
}
function calculateQuat(e, canvas, qt) {
const cw = canvas.width;
const ch = canvas.height;
const wh = 1 / Math.sqrt(cw * cw + ch * ch);
const x = e.clientX - canvas.offsetLeft - cw * 0.5;
const y = e.clientY - canvas.offsetTop - ch * 0.5;
const vector = Math.sqrt(x * x + y * y);
const theta = vector * 2.0 * Math.PI * wh;
const axis = [y / vector, x / vector, 0];
quat.setAxisAngle(qt, axis, theta);
}
function render(
canvas,
ctx,
hWeight,
vWeight,
frameBufferAttr,
bufferSize,
qt
) {
const lightProgram = ctx.createProgram(["light_vs", "light_fs"]);
ctx.useProgram(lightProgram);
const sphere = createSphere(64, 64, 0.3, [0, 1, 0, 1]);
setupVbos(ctx, lightProgram, sphere);
initRender(ctx, frameBufferAttr, bufferSize);
setupUniforms(ctx, lightProgram, qt);
ctx.drawElements(ctx.gl.TRIANGLES, sphere.index.length);
ctx.bindTexture(frameBufferAttr.texture, 0);
initOrthoRender(canvas, ctx);
const program = ctx.createProgram(["vs", "fs"]);
ctx.useProgram(program);
setupOrthoVbos(ctx, program);
setupuOrthoUniforms(canvas, ctx, program, hWeight, vWeight);
ctx.drawElements(ctx.gl.TRIANGLES, 6);
requestAnimationFrame(() => {
render(canvas, ctx, hWeight, vWeight, frameBufferAttr, bufferSize, qt);
});
}
const main = () => {
const ctx = new RenderingContext("canvas");
const canvas = document.getElementById("canvas");
ctx.toggleDepthFunc(true);
ctx.depthFunc();
const bufferSize = 512;
const frameBufferAttr = ctx.createFrameBuffer(bufferSize, bufferSize);
const qt = quat.identity(quat.create());
document.addEventListener("mousemove", e => calculateQuat(e, canvas, qt));
// kernel
const hWeight = [1.0, 0.0, -1.0, 2.0, 0.0, -2.0, 1.0, 0.0, -1.0];
const vWeight = [1.0, 2.0, 1.0, 0.0, 0.0, 0.0, -1.0, -2.0, -1.0];
render(canvas, ctx, hWeight, vWeight, frameBufferAttr, bufferSize, qt);
};
window.onload = main;
| 27.231047 | 78 | 0.641389 |