text
stringlengths 7
3.69M
|
|---|
window.onload = function() {
let selectCountry = document.getElementById('country');
console.log(selectCountry);
function cargarCountry() {
fetch('https://restcountries.eu/rest/v2/all')
.then(function(responseAPI) {
return responseAPI.json();
})
.then(function(dataAPI) {
console.log(dataAPI);
selectCountry.innerHTML = `
<option value="" disabled selected>Seleccione un País...</option>
`;
for(let country of dataAPI) {
let optionCountry = document.createElement('option');
optionCountry.setAttribute('value', country.name);
optionCountry.innerHTML = country.name;
selectCountry.append(optionCountry);
}
})
.catch(function(error){
console.log(error);
})
}
cargarCountry();
selectCountry.addEventListener('change', function() {
let countryElegido = selectCountry.value;
})
}
|
//'use strict';
// TODO: Вынести в отдельный конфиг shot part
var grid = [
{ id: 13, player: 1, cntChip: 5 },
{ id: 14, player: 0, cntChip: 0 },
{ id: 15, player: 0, cntChip: 0 },
{ id: 16, player: 0, cntChip: 0 },
{ id: 17, player: 2, cntChip: 3 },
{ id: 18, player: 0, cntChip: 0 },
{ id: 19, player: 2, cntChip: 5 },
{ id: 20, player: 0, cntChip: 0 },
{ id: 21, player: 0, cntChip: 0 },
{ id: 22, player: 0, cntChip: 0 },
{ id: 23, player: 0, cntChip: 0 },
{ id: 24, player: 1, cntChip: 2 },
{ id: 12, player: 2, cntChip: 5 },
{ id: 11, player: 0, cntChip: 0 },
{ id: 10, player: 0, cntChip: 0 },
{ id: 9, player: 0, cntChip: 0 },
{ id: 8, player: 1, cntChip: 3 },
{ id: 7, player: 0, cntChip: 0 },
{ id: 6, player: 1, cntChip: 5 },
{ id: 5, player: 0, cntChip: 0 },
{ id: 4, player: 0, cntChip: 0 },
{ id: 3, player: 0, cntChip: 0 },
{ id: 2, player: 0, cntChip: 0 },
{ id: 1, player: 2, cntChip: 2 }];
class Dice {
constructor() {
this.first = null;
this.second = null;
}
getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
do_throw() {
this.first = this.getRandomInt(1, 7);
this.second = this.getRandomInt(1, 7);
}
render(namePlayer) {
let div = document.getElementById(namePlayer + "-player");
div.innerHTML = this.first + " " + this.second;
}
}
var dice = new Dice;
dice.do_throw();
dice.render('first')
//dice.do_throw();
//dice.render('second')
class Game {
constructor(dice) {
this.dice = dice;
this.root = document.querySelector("#root");
this.matrix = grid;
this.colorPlayer = [" ", "white", "black"];
this.activePosition = null;
this.currentPlayer = 'black';
}
setActivePosition(numPosition) {
this.activePosition = numPosition;
}
render() {
// debugger;
var table = document.createElement('table');
var tr = document.createElement('tr');
for ( var obj in this.matrix )
{
var td = document.createElement('td');
console.log(obj);
td.setAttribute("id", this.matrix[obj].id );
if ( 0 < this.matrix[obj].cntChip ) {
td.setAttribute("class", "chips-"+ this.colorPlayer[this.matrix[obj].player] );
td.setAttribute("player", this.colorPlayer[this.matrix[obj].player]);
td.innerHTML = this.matrix[obj].cntChip;
}
tr.appendChild(td);
}
table.appendChild(tr);
this.root.appendChild(table);
}
checkStep(numCurrentPosition) {
let stepOne = this.activePosition + this.dice.first;
let stepTwo = this.activePosition + this.dice.second;
console.log('this.dice.first ' + this.dice.first);
console.log('activePosition ' + this.activePosition);
console.log('Проверка поля ' + numCurrentPosition);
console.log('stepOne ' + stepOne);
if ( (numCurrentPosition == stepOne) || (numCurrentPosition == stepTwo) ){
// to-do: Меняем матрицу и делаем рендер.
// С активной позиции снимаем 1 и добавляем 1 на поле.
console.log("Ход разрешен")
}
}
listener() {
var root = document.getElementById("root");
const CNT = this;
root.addEventListener('click', function (cell) {
//console.log(cnt);
let elm = cell.target;
//console.log(elm.getAttribute('player'));
if ( elm.getAttribute('player') == CNT.currentPlayer && !CNT.activePosition || CNT.activePosition == elm.id) {
// проверяем можем ли выделить
console.log(elm.className.indexOf('active'));
let result = elm.className.indexOf('active');
if (result != -1 ) {
// снимаем выделение
elm.className = elm.className.slice(0, result)
CNT.setActivePosition(null);
} else {
// устанавливаем выделение
elm.setAttribute("class", elm.className + " active");
CNT.setActivePosition(+elm.id);
}
} else {
if ( CNT.activePosition ) {
CNT.checkStep(+elm.id);
//console.log('Проверка поля' + elm.id);
}
}
}
)
}
}
var game = new Game(dice);
game.render();
game.listener();
|
import React, { useMemo, useEffect, useState } from "react";
import { Table } from 'react-bootstrap';
import {
useTable,
usePagination,
useSortBy,
} from 'react-table';
// import "react-table/react-table.css";
// const ValueChange = ({ value, suffix }) => {
// const valueIcon = value < 0 ? faAngleDown : faAngleUp;
// const valueTxtColor = value < 0 ? "text-danger" : "text-success";
// return (
// value ? <span className={valueTxtColor}>
// <FontAwesomeIcon icon={valueIcon} />
// <span className="fw-bold ms-1">
// {Math.abs(value)}{suffix}
// </span>
// </span> : "--"
// );
// };
export const PriceDataTable = () => {
const [requestData, setData] = useState({ data: [], isFetching: false });
const produrl = "https://my.api.mockaroo.com/ecomproducts.json?key=181529d0&count=100";
// const produrl = "https://6093046a85ff510017214172.mockapi.io/api/products/ecomproducts";
useEffect(() => {
setData({ data: [], isFetching: true });
const doFetchPricingData = async () => {
const response = await fetch(produrl);
const priceData = await response.json();
setData({ data: priceData, isFetching: false });
};
doFetchPricingData();
}, []);
const columns = useMemo(() => (
[
{
Header: 'ID',
accessor: 'id'
},
{
Header: 'Product Name',
accessor: 'product',
},
{
Header: 'Description',
accessor: 'description',
},
{
Header: 'Price',
accessor: 'price',
},
{
Header: 'Quantity',
accessor: 'quantity',
},
{
Header: 'Store ID',
accessor: 'storeid',
},
{
Header: 'Image',
accessor: 'image',
Cell: ({ cell: { value } }) => (
<div className="blog-comments__avatar mr-3">
<img
src={value} alt={value}
style={{width:'25%'}}
/>
</div>
)
}
]
), []);
return (
<RTable columns={columns} data={requestData.data} />
)
// React-Table functionality
// Define a default UI for filtering
// function DefaultColumnFilter({
// column: { filterValue, preFilteredRows, setFilter },
// }) {
// const count = preFilteredRows.length
// return (
// <input
// value={filterValue || ''}
// onChange={e => {
// setFilter(e.target.value || undefined) // Set undefined to remove the filter entirely
// }}
// placeholder={`Search ${count} records...`}
// />
// )
// }
function RTable ({columns, data}) {
const {
getTableProps,
getTableBodyProps,
headerGroups,
footerGroups,
prepareRow,
page,
canPreviousPage,
canNextPage,
pageCount,
gotoPage,
nextPage,
previousPage,
setPageSize,
state: { pageIndex, pageSize }
} = useTable(
{
columns,
data,
initialState: { pageSize: 25 }
},
useSortBy,
usePagination,
);
return (
<div>
{
requestData.isFetching ? <div>Fetching</div> :
<div>
<Table
{...getTableProps()}
border={2}
style={{ borderCollapse: "collapse", width: "100%" }}
>
<thead>
{headerGroups.map((group) => (
<tr {...group.getHeaderGroupProps()}>
{group.headers.map((column) => (
<th
style={{
border: '1px red solid'
}}
{...column.getHeaderProps(column.getSortByToggleProps())}>{column.render("Header")}<span>{
column.isSorted
? column.isSortedDesc
? ' 🔽'
: ' 🔼'
: ''
}</span>
</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{page.map((row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map((cell) => {
return (
<td
style={{
border: '1px black solid'
}}
{...cell.getCellProps()}>{cell.render("Cell")}</td>
);
})}
</tr>
);
})}
</tbody>
<tfoot>
{footerGroups.map((group) => (
<tr {...group.getFooterGroupProps()}>
{group.headers.map((column) => (
<td {...column.getFooterProps()}>{column.render("Footer")}</td>
))}
</tr>
))}
</tfoot>
</Table>
<div className="pagination">
<button onClick={() => gotoPage(0)} disabled={!canPreviousPage}>
{"<<"}
</button>{" "}
<button onClick={() => previousPage()} disabled={!canPreviousPage}>
{"<"}
</button>{" "}
<button onClick={() => nextPage()} disabled={!canNextPage}>
{">"}
</button>{" "}
<button onClick={() => gotoPage(pageCount - 1)} disabled={!canNextPage}>
{">>"}
</button>{" "}
<span>
Page{" "}
<strong>
{pageIndex + 1} of {pageCount}
</strong>{" "}
</span>
<span>
| Go to page:{" "}
<input
type="number"
defaultValue={pageIndex + 1}
onChange={(e) => {
const page = e.target.value ? Number(e.target.value) - 1 : 0;
gotoPage(page);
}}
style={{ width: "100px" }}
/>
</span>{" "}
<select
value={pageSize}
onChange={(e) => {
setPageSize(Number(e.target.value));
}}
>
{[2, 10, 20, 30, 40, 50].map((pageSize) => (
<option key={pageSize} value={pageSize}>
Show {pageSize}
</option>
))}
</select>
</div>
</div>
}
</div>
)
};
};
|
import { createAppContainer, createStackNavigator } from 'react-navigation'
import Main from '../views/Main/main'
import Emon from '../views/Emon/emon'
import Isometria from '../views/Isometria/Isometria'
import Amrap from '../views/Amrap/amrap'
const App = createStackNavigator({
Main: {
screen: Main,
navigationOptions: {
header: null
}
},
Emon: {
screen: Emon
},
Isometria: {
screen: Isometria
},
Amrap: {
screen: Amrap
}
}, { initialRouteName:'Main' })
export default createAppContainer(App)
|
function startPage(){
document.getElementById("units").style.display = "none";
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
document.getElementById("resultAlert").style.display = "none";
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
=======
//document.getElementById("resultAlert").style.display = "none";
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of f3aed5c... qw
=======
>>>>>>> parent of 741ef4d... Revert "output formating"
}
function getConversorType(){
var e = document.getElementById("types");
var type = e.value;
var element = document.getElementById("unitsButton");
element.innerHTML = "";
document.getElementById("selectUnits").innerHTML = "";
document.getElementById("units").style.display = 'initial';
if(type == 1){
HTMLLongitud();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertLongitud()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 2){
HTMLTemperatura();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertTemperatura()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 3){
HTMLMasa();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertMasa()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 4){
HTMLVolumen();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertVolumen()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if (type == 5){
HTMLArea();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertArea()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 6){
HTMLPresion();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertPresion()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 7){
HTMLFuerza();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertFuerza()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 8){
HTMLAceleracion();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertAceleracion()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 9){
HTMLDensidad();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertDensidad()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 10){
HTMLEnergia();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertEnergia()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 11){
HTMLFlujo();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertFlujo()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 12){
HTMLPotencia();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertPotencia()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 13){
HTMLVelocidad();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertVelocidad()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 14){
HTMLCoeficiente();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertCoeficiente()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 15){
HTMLConductividad();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertConductividad()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 16){
HTMLEspecifico();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertEspecifico()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 17){
HTMLCalor();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertCalor()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}else if(type == 18){
HTMLTasa();
element.insertAdjacentHTML('beforeend', '<button class="btn btn-primary" id="unitButton" type = "submit" form = "getUnits" value = "Units" onclick = "convertTasa()" data-toggle="modal" data-target="#resultadoModal">Convertir!</button>' );
}
}
function HTMLLongitud(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>cm</option><option value = '2'>m</option><option value = '3'>km</option><option value = '4'>in</option><option value = '5'>ft</option><option value = '6'>yd</option><option value = '7'>millas</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLTemperatura(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>°C</option><option value = '2'>K</option><option value = '3'>°F</option><option value = '4'>R</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLMasa(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>ton</option><option value = '2'>kg</option><option value = '3'>gr</option><option value = '4'>lb</option><option value = '5'>onz</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLVolumen(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>cm³</option><option value = '2'>L</option><option value = '3'>m³</option><option value = '4'>onz</option><option value = '5'>gal</option><option value = '6'>in³</option><option value = '7'>ft³</option><option value = '8'>yd³</option><option value = '9'>milla³</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLArea(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>cm²</option><option value = '2'>m²</option><option value = '3'>km²</option><option value = '4'>in²</option><option value = '5'>ft²</option><option value = '6'>yd²</option><option value = '7'>milla²</option><option value = '8'>hec²</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLPresion(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>pascal</option><option value = '2'>kPa</option><option value = '3'>Mpa</option><option value = '4'>atm</option><option value = '5'>bar</option><option value = '6'>mmHg</option><option value = '7'>Psia</option><option value = '8'>lbft</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLFuerza(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>N</option><option value = '2'>dina</option><option value = '3'>kgf</option><option value = '4'>lbf</option><option value = '5'>poundal</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLAceleracion(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>cm/s²</option><option value = '2'>m/s²</option><option value = '3'>km/h²</option><option value = '4'>in/s²</option><option value = '5'>ft/s²</option><option value = '6'>milla/h²</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLDensidad(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>gr/cm³</option><option value = '2'>kg/L</option><option value = '3'>kg/m³</option><option value = '4'>lb/in³</option><option value = '5'>lb/ft³</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLEnergia(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>J</option><option value = '2'>kJ</option><option value = '3'>Nm</option><option value = '4'>kPa.m³</option><option value = '5'>kW/h</option><option value = '6'>cal</option><option value = '7'>Cal</option><option value = '8'>kJ_kg</option><option value = '9'>Psia.ft³</option><option value = '10'>lbf.ft</option><option value = '11'>BTU</option><option value = '12'>BTU_lb</option><option value = '13'>ft²_s²</option><option value = '14'>termia</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLFlujo(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>W_cm²</option><option value = '2'>W_m²</option><option value = '3'>BTU_htf²</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLPotencia(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>W</option><option value = '2'>Js</option><option value = '3'>kW</option><option value = '4'>hp</option><option value = '5'>BTUh</option><option value = '6'>BTUmin</option><option value = '7'>BTUs</option><option value = '8'>lbfts</option><option value = '9'>hpcald</option><option value = '10'>kJh</option><option value = '11'>Tonrefri</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLVelocidad(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>cm/s</option><option value = '2'>m/s</option><option value = '3'>km/h</option><option value = '4'>in/s</option><option value = '5'>ft/s</option><option value = '6'>milla/h</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLCoeficiente(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>W/m² * °C</option><option value = '2'>W/m² * F</option><option value = '3'>BTU/h * ft² * F</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLConductividad(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>W/m * °C</option><option value = '2'>W/m * K</option><option value = '3'>BTU/h * ft * F</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLCalor(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>KJkg°C</option><option value = '2'>KJkg°K</option><option value = '3'>Jg°C</option><option value = '4'>BTUlbm°F</option><option value = '5'>BTUlbm°R</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLEspecifico(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>m³ / kg</option><option value = '2'>L/kg</option><option value = '3'>cm³ /g</option><option value = '4'>ft³ /lbm</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function HTMLTasa(){
var element = document.getElementById("selectUnits");
htmlString = "<option value = '1'>cm³ / s</option><option value = '2'>L/min</option><option value = '3'>m³ /s</option><option value = '4'>gal /min </option><option value = '5'>ft³ /s</option><option value = '6'>ft³ /min</option>";
element.insertAdjacentHTML('afterbegin', htmlString);
}
function validate(cantidad){
if(cantidad == ""){
<<<<<<< HEAD
<<<<<<< HEAD
alert("Favor de ingresar una cantidad");
=======
var element = document.getElementById("result");
element.innerHTML = "";
element.insertAdjacentHTML('afterbegin', "<h4>Favor de ingresar una cantidad valida...</h4>");
<<<<<<< HEAD
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
<<<<<<< HEAD
=======
//alert("Favor de ingresar una cantidad");
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of f3aed5c... qw
=======
var element = document.getElementById("result");
element.innerHTML = "";
element.insertAdjacentHTML('afterbegin', "<h4>Favor de ingresar una cantidad valida...</h4>");
>>>>>>> parent of 741ef4d... Revert "output formating"
return false;
}else{
return true;
}
}
function convertLongitud(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
=======
=======
>>>>>>> parent of 741ef4d... Revert "output formating"
//document.getElementById("resultAlert").style.display = "initial";
<<<<<<< HEAD
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var m = cantidad/100;
var km = cantidad/100000;
var inc = cantidad/2.54;
var ft = inc/12;
var yd = inc/36;
var milla = cantidad/160934.4;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" cm equivalen a:</h4></br>"+expFormat(m)+" m</br>"+expFormat(km)+" km</br>"+expFormat(inc)+" in</br>"+expFormat(ft)+" ft</br>"+expFormat(yd)+" yd</br>"+expFormat(milla)+" miles" );
}else if(unit == 2){
var cm = cantidad *100;
var km = cm/100000;
var inc = cm/2.54;
var ft = inc/12;
var yd = inc/36;
var milla = cm/160934.4;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" m equivalen a:</h4></br>"+expFormat(cm)+" cm</br>"+expFormat(km)+" km</br>"+expFormat(inc)+" in</br>"+expFormat(ft)+" ft</br>"+expFormat(yd)+" yd</br>"+expFormat(milla)+" miles" );
}else if(unit == 3){
var cm = cantidad * 100000;
var m = cm/100;
var inc = cm/2.54;
var ft = inc/12;
var yd = inc/36;
var milla = cm/160934.4;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" km equivalen a:</h4></br>"+expFormat(cm)+" cm</br>"+expFormat(m)+" m</br>"+expFormat(inc)+" in</br>"+expFormat(ft)+" ft</br>"+expFormat(yd)+" yd</br>"+expFormat(milla)+" miles" );
}else if(unit == 4){
var cm = cantidad * 2.54;
var m = cm / 100;
var km = cm / 100000;
var ft = cantidad / 12;
var yd = cantidad / 36;
var milla = cantidad / 63360;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" in equivalen a:</h4></br>"+expFormat(cm)+" cm</br>"+expFormat(m)+" m</br>"+expFormat(km)+" km</br>"+expFormat(ft)+" ft</br>"+expFormat(yd)+" yd</br>"+expFormat(milla)+" miles" );
}else if(unit == 5){
var cm = cantidad * 30.48;
var m = cm / 100;
var km = m / 1000;
var inc = cantidad * 12;
var yd = inc / 36;
var milla = inc / 63360;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" ft equivalen a:</h4></br>"+expFormat(cm)+" cm</br>"+expFormat(m)+" m</br>"+expFormat(km)+" km</br>"+expFormat(inc)+" in</br>"+expFormat(yd)+" yd</br>"+expFormat(milla)+" miles" );
}else if(unit == 6){
var cm = cantidad * 91.44;
var m = cm / 100;
var km = cm / 100000;
var inc = cantidad * 36;
var ft = inc / 12;
var milla = inc / 63360;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" yd equivalen a:</h4></br>"+expFormat(cm)+" cm</br>"+expFormat(m)+" m</br>"+expFormat(km)+" km</br>"+expFormat(inc)+" in</br>"+expFormat(ft)+" ft</br>"+expFormat(milla)+" miles" );
}else if(unit == 7){
var cm = (cantidad * 63360) * 2.54;
var m = cm / 100;
var km = cm / 100000;
var inc = cantidad * 63360;
var ft = inc / 12;
var yd = inc / 36;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" millas equivalen a:</h4></br>"+expFormat(cm)+" cm</br>"+expFormat(m)+" m</br>"+expFormat(km)+" km</br>"+expFormat(inc)+" in</br>"+expFormat(ft)+" ft</br>"+expFormat(yd)+" yd" );
}
}
}
function convertTemperatura(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
=======
=======
>>>>>>> parent of 741ef4d... Revert "output formating"
//document.getElementById("resultAlert").style.display = "initial";
<<<<<<< HEAD
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var Kk = (cantidad + 273.15) *1;
var Ff = 9/5 * cantidad + 32;
var Rr = Ff + 459.67;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" °C equivalen a:</h4></br>"+expFormat(Kk)+" K</br>"+expFormat(Ff)+" °F</br>"+expFormat(Rr)+" R" );
}else if(unit == 2){
var C = cantidad - 273.15;
var F = 9/5*C + 32;
var R = F + 459.67;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" K equivalen a:</h4></br>"+expFormat(C)+" °C</br>"+expFormat(F)+" °F</br>"+expFormat(R)+" R" );
}else if(unit == 3){
var C = ( cantidad - 32)* 5/9;
var K = (C + 273.15)*1;
var R = (cantidad + 459.67)*1;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" °F equivalen a:</h4></br>"+expFormat(C)+" °C</br>"+expFormat(K)+" K</br>"+expFormat(R)+" R" );
}else if(unit == 4){
var F = (cantidad - 459.67) *1;
var C = (F - 32)*5/9;
var K = C + 273.15;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" R equivalen a:</h4></br>"+expFormat(F)+" °F</br>"+expFormat(C)+" °C</br>"+expFormat(K)+" K" );
}
}
}
function convertMasa(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").style.display = "initial";
document.getElementById("resultAlert").st
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
=======
//document.getElementById("resultAlert").style.display = "initial";
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var kg = cantidad * 1000;
var gr = kg * 1000;
var lb = kg * 2.20462;
var onz = lb / 16;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" ton equivalen a:</h4></br>"+expFormat(kg)+" kg</br>"+expFormat(gr)+" gr</br>"+expFormat(lb)+" lb</br>"+expFormat(onz)+" onz");
}else if(unit == 2){
var ton = cantidad / 1000;
var gr = cantidad / 1000;
var lb = cantidad * 2.20462;
var onz = lb / 16;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" kg equivalen a:</h4></br>"+expFormat(ton)+" ton</br>"+expFormat(gr)+" gr</br>"+expFormat(lb)+" lb</br>"+expFormat(onz)+" onz");
}else if(unit == 3){
var kg = cantidad / 1000;
var ton = kg * 1000;
var lb = kg * 2.20462;
var onz = lb / 16;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" gr equivalen a:</h4></br>"+expFormat(kg)+" kg</br>"+expFormat(ton)+" ton</br>"+expFormat(lb)+" lb</br>"+expFormat(onz)+" onz");
}else if(unit == 4){
var kg = cantidad / 2.20462;
var ton = kg * 1000;
var gr = kg * 1000;
var onz = cantidad / 16;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" lb equivalen a:</h4></br>"+expFormat(kg)+" kg</br>"+expFormat(ton)+" ton</br>"+expFormat(gr)+" gr</br>"+expFormat(onz)+" onz");
}else if(unit == 5){
var lb = cantidad * 16;
var kg = lb / 2.20462;
var ton = kg * 1000;
var gr = kg * 1000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" onz equivalen a:</h4></br>"+expFormat(kg)+" kg</br>"+expFormat(ton)+" ton</br>"+expFormat(gr)+" gr</br>"+expFormat(lb)+" lb");
}
}
}
function convertVolumen(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").style.display = "initial";
document.getElementById("resultAlert").style.display = "initial";
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
=======
//document.getElementById("resultAlert").style.display = "initial";
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var L = cantidad / 1000;
var m3 = cantidad / 1000000;
var onz = ((cantidad / (2.54^3))/(231))*128;
var gal = (cantidad / (2.54^3))/(231);
var in3 = cantidad / (2.54^3);
var ft3 = (cantidad / (30.48^3));
var yd3 = (cantidad / (91.44^3));
var milla3 = (cantidad / (160934.4^3));
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" cm³ equivalen a:</h4></br>"+expFormat(L)+" L</br>"+expFormat(m3)+" m³</br>"+expFormat(onz)+" onz</br>"+expFormat(gal)+" gal</br>"+expFormat(in3)+" in³</br>"+expFormat(ft3)+" ft³</br>"+expFormat(yd3)+" yd³</br>"+expFormat(milla3)+" milla³" );
}else if(unit == 2){
var cm3 = cantidad * 1000;
var m3 = cm3 / 1000000;
var onz = ((cm3 / (2.54^3))/(231))*128;
var gal = (cm3 / (2.54^3))/(231);
var in3 = cm3 / (2.54^3);
var ft3 = (cm3 / (30.48^3));
var yd3 = (cm3 / (91.44^3));
var milla3 = (cm3 / (160934.4^3));
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" L equivalen a:</h4></br>"+expFormat(cm3)+" cm³</br>"+expFormat(m3)+" m³</br>"+expFormat(onz)+" onz</br>"+expFormat(gal)+" gal</br>"+expFormat(in3)+" in³</br>"+expFormat(ft3)+" ft³</br>"+expFormat(yd3)+" yd³</br>"+expFormat(milla3)+" milla³" );
}else if(unit == 3){
var cm3 = cantidad * 1000000;
var L = cm3 / 1000;
var onz = ((cm3 / (2.54^3))/(231))*128;
var gal = (cm3 / (2.54^3))/(231);
var in3 = cm3 / (2.54^3);
var ft3 = (cm3 / (30.48^3));
var yd3 = (cm3 / (91.44^3));
var milla3 = (cm3 / (160934.4^3));
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" m³ equivalen a:</h4></br>"+expFormat(L)+" L</br>"+expFormat(cm3)+" cm³</br>"+expFormat(onz)+" onz</br>"+expFormat(gal)+" gal</br>"+expFormat(in3)+" in³</br>"+expFormat(ft3)+" ft³</br>"+expFormat(yd3)+" yd³</br>"+expFormat(milla3)+" milla³" );
}
else if(unit == 4){
var cm3 = ((cantidad * (2.54^3))*(231))/128;
var L = cm3 / 1000;
var m3 = cm3 / 1000000;
var gal = (cm3 / (2.54^3))/(231);
var in3 = cm3 / (2.54^3);
var ft3 = (cm3 / 30.48^3);
var yd3 = (cm3 / 91.44^3);
var milla3 = (cm3 / 160934.4^3);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" onz equivalen a:</h4></br>"+expFormat(L)+" L</br>"+expFormat(m3)+" m³</br>"+expFormat(cm3)+" cm³</br>"+expFormat(gal)+" gal</br>"+expFormat(in3)+" in³</br>"+expFormat(ft3)+" ft³</br>"+expFormat(yd3)+" yd³</br>"+expFormat(milla3)+" milla³" );
}else if(unit == 5){
var cm3 = (cantidad * (2.54^3))*(231);
var L = cm3 / 1000;
var m3 = cm3 / 1000000;
var onz = ((cm3 / (2.54^3))/(231))*128;
var in3 = cm3 / (2.54^3);
var ft3 = cm3 / (30.48^3);
var yd3 = cm3 / (91.44^3);
var milla3 = (cm3 / (160934.4^3));
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" gal equivalen a:</h4></br>"+expFormat(cm3)+" cm³</br>"+expFormat(m3)+" m³</br>"+expFormat(onz)+" onz</br>"+expFormat(L)+" L</br>"+expFormat(in3)+" in³</br>"+expFormat(ft3)+" ft³</br>"+expFormat(yd3)+" yd³</br>"+expFormat(milla3)+" milla³" );
}else if(unit == 6){
var cm3 = cantidad * (2.54^3);
var L = cm3 / 1000;
var m3 = cm3 / 1000000;
var onz = ((cm3 / (2.54^3))/(231))*128;
var gal = (cm3 / (2.54^3))/(231);
var ft3 = (cm3 / 30.48^3);
var yd3 = (cm3 / 91.44^3);
var milla3 = (cm3 / (160934.4^3));
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" in³ equivalen a:</h4></br>"+expFormat(cm3)+" cm³</br>"+expFormat(m3)+" m³</br>"+expFormat(onz)+" onz</br>"+expFormat(gal)+" gal</br>"+expFormat(L)+" L</br>"+expFormat(ft3)+" ft³</br>"+expFormat(yd3)+" yd³</br>"+expFormat(milla3)+" milla³" );
}else if(unit == 7){
var cm3 = (cantidad * (28316.846));
var L = cm3 / 1000;
var m3 = cm3 / 1000000;
var onz = L / 0.0295735296;
var gal = L / 3.785411784;
var in3 = cm3 / 16.387;
var yd3 = (cantidad / 27);
var milla3 = (cm3 / (160934.4^3));
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" ft³ equivalen a:</h4></br>"+expFormat(cm3)+" cm³</br>"+expFormat(m3)+" m³</br>"+expFormat(onz)+" onz</br>"+expFormat(gal)+" gal</br>"+expFormat(L)+" L</br>"+expFormat(in3)+" in³</br>"+expFormat(yd3)+" yd³</br>"+expFormat(milla3)+" milla³" );
}else if(unit == 8){
var cm3 = (cantidad * (91.44^3));
var L = cm3 / 1000;
var m3 = cm3 / 1000000;
var onz = ((cm3 / (2.54^3))/(231))*128;
var gal = (cm3 / (2.54^3))/(231);
var in3 = cm3 / (2.54^3);
var ft3 = (cm3 / 30.48^3);
var milla3 = (cm3 / (160934.4^3));
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" yd³ equivalen a:</h4></br>"+expFormat(cm3)+" cm³</br>"+expFormat(m3)+" m³</br>"+expFormat(onz)+" onz</br>"+expFormat(gal)+" gal</br>"+expFormat(L)+" L</br>"+expFormat(in3)+" in³</br>"+expFormat(ft3)+" ft³</br>"+expFormat(milla3)+" milla³");
}
else if(unit == 9){
var cm3 = (cantidad * (160934.4^3));
var L = cm3 / 1000;
var m3 = cm3 / 1000000;
var onz = ((cm3 / (2.54^3))/(231))*128;
var gal = (cm3 / (2.54^3))/(231);
var in3 = cm3 / (2.54^3);
var ft3 = (cm3 / 30.48^3);
var yd3 = (cm3 / 91.44^3);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" mill³ equivalen a:</h4></br>"+expFormat(cm3)+" cm³</br>"+expFormat(m3)+" m³</br>"+expFormat(onz)+" onz</br>"+expFormat(gal)+" gal</br>"+expFormat(L)+" L</br>"+expFormat(in3)+" in³</br>"+expFormat(ft3)+" ft³</br>"+expFormat(yd3)+" yd³" );
}
}
}
//PROBLEMA CON IN2
function convertArea(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").style.display = "initial";
=======
=======
>>>>>>> parent of 741ef4d... Revert "output formating"
//document.getElementById("resultAlert").style.display = "initial";
<<<<<<< HEAD
document.getElementById("resultAlert").style.display = "initial";
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var m2 = cantidad / 10000;
var km2 = cantidad / 10000000000;
var in2 = cantidad / (2.54 * 2.54);
var ft2 = cantidad / (30.48^2);
var yd2 = cantidad / (91.44^2);
var milla2 = cantidad / (160934.4^2);
var hec2 = cantidad / 100000000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" cm² equivalen a:</h4></br>"+expFormat(m2)+" m²</br>"+expFormat(km2)+" km²</br>"+expFormat(in2)+" in²</br>"+expFormat(ft2)+" ft²</br>"+expFormat(yd2)+" yd³</br>"+expFormat(milla2)+" milla²</br>"+expFormat(hec2)+" hec²" );
}else if(unit == 2){
var cm2 = cantidad * 10000;
var km2 = cm2 / 10000000000;
var in2 = cm2 / (2.54 * 2.54);
var ft2 = cm2 / (30.48^2);
var yd2 = cm2 / (91.44^2);
var milla2 = cm2 / (160934.4^2);
var hec2 = cm2 / 100000000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" m² equivalen a:</h4></br>"+expFormat(cm2)+" cm²</br>"+expFormat(km2)+" km²</br>"+expFormat(in2)+" in²</br>"+expFormat(ft2)+" ft²</br>"+expFormat(yd2)+" yd³</br>"+expFormat(milla2)+" milla²</br>"+expFormat(hec2)+" hec²" );
}else if(unit == 3){
var cm2 = cantidad * 10000000000;
var m2 = cm2 / 10000;
var in2 = cm2 / (2.54 * 2.54);
var ft2 = cm2 / (30.48^2);
var yd2 = cm2 / (91.44^2);
var milla2 = cm2 / (160934.4^2);
var hec2 = cm2 / 100000000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" km² equivalen a:</h4></br>"+expFormat(cm2)+" cm²</br>"+expFormat(m2)+" m²</br>"+expFormat(in2)+" in²</br>"+expFormat(ft2)+" ft²</br>"+expFormat(yd2)+" yd³</br>"+expFormat(milla2)+" milla²</br>"+expFormat(hec2)+" hec²" );
}
else if(unit == 4){
var cen = cantidad * 6.4516;
var m2 = cen / 10000;
var km2 = cen / 10000000000;
var ft2 = cen / (30.48^2);
var yd2 = cen / (91.44^2);
var milla2 = cen / (160934.4^2);
var hec2 = cen / 100000000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" km² equivalen a:</h4></br>"+expFormat(cen)+" cm²</br>"+expFormat(m2)+" m²</br>"+expFormat(km2)+" km²</br>"+expFormat(ft2)+" ft²</br>"+expFormat(yd2)+" yd³</br>"+expFormat(milla2)+" milla²</br>"+expFormat(hec2)+" hec²" );
}
else if(unit == 5){
var cm2 = cantidad * (30.48^2);
var m2 = cm2 / 10000;
var km2 = cm2 / 10000000000;
var in2 = cm2 / (2.54 * 2.54);
var yd2 = cm2 / (91.44^2);
var milla2 = cm2 / (160934.4^2);
var hec2 = cm2 / 100000000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" ft² equivalen a:</h4></br>"+expFormat(cm2)+" cm²</br>"+expFormat(m2)+" m²</br>"+expFormat(km2)+" km²</br>"+expFormat(in2)+" in²</br>"+expFormat(yd2)+" yd³</br>"+expFormat(milla2)+" milla²</br>"+expFormat(hec2)+" hec²" );
}else if(unit == 6){
var cm2 = cantidad * (91.44^2);
var m2 = cm2 / 10000;
var km2 = cm2 / 10000000000;
var in2 = cantidad * 1296;
var ft2 = cm2 / (30.48^2);
var milla2 = cm2 / (160934.4^2);
var hec2 = cm2 / 100000000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" yd² equivalen a:</h4></br>"+expFormat(cm2)+" cm²</br>"+expFormat(m2)+" m²</br>"+expFormat(km2)+" km²</br>"+expFormat(in2)+" in²</br>"+expFormat(ft2)+" ft³</br>"+expFormat(milla2)+" milla²</br>"+expFormat(hec2)+" hec²" );
}else if(unit == 7){
var cm2 = cantidad * (160934.4^2);
var m2 = cm2 / 10000;
var km2 = cm2 / 10000000000;
var in2 = cm2 / (2.54 * 2.54);
var ft2 = cm2 / (30.48^2);
var yd2 = cm2 / (91.44^2);
var hec2 = cm2 / 100000000
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" milla² equivalen a:</h4></br>"+expFormat(cm2)+" cm²</br>"+expFormat(m2)+" m²</br>"+expFormat(km2)+" km²</br>"+expFormat(in2)+" in²</br>"+expFormat(ft2)+" ft³</br>"+expFormat(yd2)+" yd²</br>"+expFormat(hec2)+" hec²" );
}else if(unit == 8){
cm2 = cantidad * 100000000;
m2 = cm2 / 10000;
km2 = cm2 / 10000000000;
in2 = cm2 / (2.54 * 2.54);
ft2 = cm2 / (30.48^2);
yd2 = cm2 / (91.44^2);
milla2 = cm2 / (160934.4^2);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" hec² equivalen a:</h4></br>"+expFormat(cm2)+" cm²</br>"+expFormat(m2)+" m²</br>"+expFormat(km2)+" km²</br>"+expFormat(in2)+" in²</br>"+expFormat(ft2)+" ft³</br>"+expFormat(yd2)+" yd²</br>"+expFormat(milla2)+" milla²" );
}
}
}
function convertPresion(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").sty
=======
=======
>>>>>>> parent of 741ef4d... Revert "output formating"
//document.getElementById("resultAlert").style.display = "initial";
<<<<<<< HEAD
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var kPa = cantidad / 1000;
var Mpa = kPa / 1000;
var atm = cantidad / 101325;
var bar = cantidad / 100000;
var mmHg = atm * 760;
var Psia = cantidad / 6894.76;
var lbft = Psia * 144;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" pascal equivalen a:</h4></br>"+expFormat(kPa)+" kPa</br>"+expFormat(Mpa)+" Mpa</br>"+expFormat(atm)+" atm</br>"+expFormat(bar)+" bar</br>"+expFormat(mmHg)+" mmHg</br>"+expFormat(Psia)+" Psia</br>"+expFormat(lbft)+" lbft" );
}else if(unit == 2){
var pascal = cantidad * 1000;
var Mpa = cantidad / 1000;
var atm = pascal / 101325;
var bar = pascal / 100000;
var mmHg = atm * 760;
var Psia = pascal / 6894.76;
var lbft = Psia * 144;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" kPa equivalen a:</h4></br>"+expFormat(pascal)+" Pascal</br>"+expFormat(Mpa)+" Mpa</br>"+expFormat(atm)+" atm</br>"+expFormat(bar)+" bar</br>"+expFormat(mmHg)+" mmHg</br>"+expFormat(Psia)+" Psia</br>"+expFormat(lbft)+" lbft" );
}else if(unit == 3){
var pascal = cantidad * 1000000;
var kPa = cantidad * 1000;
var atm = pascal / 101325;
var bar = pascal / 100000;
var mmHg = atm * 760;
var Psia = pascal / 6894.76;
var lbft = Psia * 144;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" Mpa equivalen a:</h4></br>"+expFormat(pascal)+" Pascal</br>"+expFormat(kPa)+" kPa</br>"+expFormat(atm)+" atm</br>"+expFormat(bar)+" bar</br>"+expFormat(mmHg)+" mmHg</br>"+expFormat(Psia)+" Psia</br>"+expFormat(lbft)+" lbft" );
}else if(unit == 4){
var pascal = cantidad * 101325;
var kPa = cantidad * 101.325;
var Mpa = kPa / 1000;
var bar = pascal / 100000;
var mmHg = cantidad * 760;
var Psia = pascal / 6894.76;
var lbft = Psia * 144;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" atm equivalen a:</h4></br>"+expFormat(pascal)+" Pascal</br>"+expFormat(kPa)+" kPa</br>"+expFormat(Mpa)+" Mpa</br>"+expFormat(bar)+" bar</br>"+expFormat(mmHg)+" mmHg</br>"+expFormat(Psia)+" Psia</br>"+expFormat(lbft)+" lbft" );
}else if(unit == 5){
var pascal = cantidad * 100000;
var kPa = pascal / 1000;
var Mpa = kPa / 1000;
var atm = cantidad / 1.01325;
var mmHg = atm * 760;
var Psia = pascal / 6894.76;
var lbft = Psia * 144
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" bar equivalen a:</h4></br>"+expFormat(pascal)+" Pascal</br>"+expFormat(kPa)+" kPa</br>"+expFormat(Mpa)+" Mpa</br>"+expFormat(atm)+" atm</br>"+expFormat(mmHg)+" mmHg</br>"+expFormat(Psia)+" Psia</br>"+expFormat(lbft)+" lbft" );
}else if(unit == 6){
var pascal = (cantidad * 101325) / 760;
var kPa = pascal / 1000;
var Mpa = kPa / 1000;
var atm = cantidad / 760;
var bar = pascal / 100000;
var Psia = pascal / 6894.76;
var lbft = Psia * 144;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" mmHg equivalen a:</h4></br>"+expFormat(pascal)+" Pascal</br>"+expFormat(kPa)+" kPa</br>"+expFormat(Mpa)+" Mpa</br>"+expFormat(atm)+" atm</br>"+expFormat(bar)+" bar</br>"+expFormat(Psia)+" Psia</br>"+expFormat(lbft)+" lbft" );
}else if(unit == 7){
var pascal = cantidad * 6894.76;
var kPa = pascal / 1000;
var Mpa = kPa / 1000;
var atm = cantidad * 0.068046;
var bar = pascal / 100000;
var mmHg = atm * 760;
var lbft = cantidad * 144;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" Psia equivalen a:</h4></br>"+expFormat(pascal)+" Pascal</br>"+expFormat(kPa)+" kPa</br>"+expFormat(Mpa)+" Mpa</br>"+expFormat(atm)+" atm</br>"+expFormat(bar)+" bar</br>"+expFormat(mmHg)+" mmHg</br>"+expFormat(lbft)+" lbft" );
}else if(unit == 8){
var pascal = (cantidad * 6894.76)/144;
var kPa = pascal / 1000;
var Mpa = kPa / 1000;
var atm = pascal / 101325;
var bar = pascal / 100000;
var mmHg = atm * 760;
var Psia = cantidad / 144;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" lbft equivalen a:</h4></br>"+expFormat(pascal)+" Pascal</br>"+expFormat(kPa)+" kPa</br>"+expFormat(Mpa)+" Mpa</br>"+expFormat(atm)+" atm</br>"+expFormat(bar)+" bar</br>"+expFormat(mmHg)+" mmHg</br>"+expFormat(Psia)+" Psia" );
}
}
}
function convertFuerza(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
<<<<<<< HEAD
<<<<<<< HEAD
=======
if(validate(cantidad)){
=======
>>>>>>> parent of 741ef4d... Revert "output formating"
if(validate(cantidad)){
//document.getElementById("resultAlert").style.display = "initial";
<<<<<<< HEAD
=======
if(validate(cantidad)){
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var dina = cantidad * 100000;
var kgf = cantidad / 9.80665;
var lbf = cantidad * (.224801);
var poundal = (cantidad * (.224801)) * (32.174);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" N equivalen a:</h4></br>"+expFormat(dina)+" dina</br>"+expFormat(kgf)+" kgf</br>"+expFormat(lbf)+" lbf</br>"+expFormat(poundal)+" poundal" );
}else if(unit == 2){
var N = cantidad / 100000;
var kgf = N / 9.80665;
var lbf = N * (.224801);
var poundal = (N * (.224801)) * (32.174);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" dina equivalen a:</h4></br>"+expFormat(N)+" N</br>"+expFormat(kgf)+" kgf</br>"+expFormat(lbf)+" lbf</br>"+expFormat(poundal)+" poundal" );
}else if(unit == 3){
var N = cantidad * 9.80665;
var dina = N * 100000;
var lbf = N * (.224801);
var poundal = (N * (.224801)) * (32.174);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" kgf equivalen a:</h4></br>"+expFormat(N)+" N</br>"+expFormat(dina)+" dina</br>"+expFormat(lbf)+" lbf</br>"+expFormat(poundal)+" poundal" );
}else if(unit == 4){
var N = cantidad / (.224801);
var dina = N * 100000;
var kgf = N / 9.80665;
var poundal = (N * (.224801)) * (32.174);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" lbf equivalen a:</h4></br>"+expFormat(N)+" N</br>"+expFormat(dina)+" dina</br>"+expFormat(kgf)+" kgf</br>"+expFormat(poundal)+" poundal" );
}else if(unit == 5){
var N = (cantidad / (.224801)) / (32.174);
var dina = N * 100000;
var kgf = N / 9.80665;
var lbf = N * (.224801);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" poundal equivalen a:</h4></br>"+expFormat(N)+" N</br>"+expFormat(dina)+" dina</br>"+expFormat(kgf)+" kgf</br>"+expFormat(lbf)+" lbf" );
}
}
}
function convertAceleracion(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
=======
=======
>>>>>>> parent of 741ef4d... Revert "output formating"
//document.getElementById("resultAlert").style.display = "initial";
<<<<<<< HEAD
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var ms2 = (cantidad) / 100;
var kmh2 = ((cantidad) / 100000) * (3600^2);
var ins2 = (cantidad) / 2.54;
var fts2 = (cantidad) / 30.48;
var millah2 = ((cantidad / 2.54)/63360) * 3600^2;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" cm/s² equivalen a:</h4></br>"+expFormat(ms2)+" m/s²</br>"+expFormat(kmh2)+" km/h²</br>"+expFormat(ins2)+" in/s²</br>"+expFormat(fts2)+" ft/s²</br>"+expFormat(millah2)+" milla/h²" );
}else if(unit == 2){
var cms2 = (cantidad) * 100;
var kmh2 = ((cms2) / 100000) * (3600^2);
var ins2 = (cms2) / 2.54;
var fts2 = (cms2) / 30.48;
var millah2 =((cms2 / 2.54)/63360) * 3600^2;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" m/s² equivalen a:</h4></br>"+expFormat(cms2)+" cm/s²</br>"+expFormat(kmh2)+" km/h²</br>"+expFormat(ins2)+" in/s²</br>"+expFormat(fts2)+" ft/s²</br>"+expFormat(millah2)+" milla/h²" );
}else if(unit == 3){
var cms2 = ((cantidad) * 100000) / (3600^2);
var ms2 = (cms2) / 100;
var ins2 = (cms2) / 2.54;
var fts2 = (cms2) / 30.48;
var millah2 = ((cms2 / 2.54)/63360) * 3600^2;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" km/s² equivalen a:</h4></br>"+expFormat(cms2)+" cm/s²</br>"+expFormat(ms2)+" m/h²</br>"+expFormat(ins2)+" in/s²</br>"+expFormat(fts2)+" ft/s²</br>"+expFormat(millah2)+" milla/h²" );
}else if(unit == 4){
var cms2 = (cantidad) * 2.54;
var ms2 = (cms2) / 100;
var kmh2 = ((cms2) / 100000) * (3600^2);
var fts2 = (cms2) / 30.48;
var millah2 = ((cms2 / 2.54)/63360) * 3600^2;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" in/s² equivalen a:</h4></br>"+expFormat(cms2)+" cm/s²</br>"+expFormat(ms2)+" m/h²</br>"+expFormat(kmh2)+" km/h²</br>"+expFormat(fts2)+" ft/s²</br>"+expFormat(millah2)+" milla/h²" );
}else if(unit == 5){
var cms2 = (cantidad) * 30.48;
var ms2 = cms2 / 100;
var kmh2 = ((cms2) / 100000) * (3600^2);
var ins2 = (cms2) / 2.54;
var millah2 = ((cms2 / 2.54)/63360) * 3600^2;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" ft/s² equivalen a:</h4></br>"+expFormat(cms2)+" cm/s²</br>"+expFormat(ms2)+" m/h²</br>"+expFormat(kmh2)+" km/h²</br>"+expFormat(ins2)+" in/s²</br>"+expFormat(millah2)+" milla/h²" );
}else if(unit == 6){
var cms2 = ((cantidad * 2.54)*63360) / 3600^2;
var ms2 = (cms2) / 100;
var kmh2 = ((cms2) / 100000) * (3600^2);
var ins2 = (cms2) / 2.54;
var fts2 = (cms2) / 30.48;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" milla/h² equivalen a:</h4></br>"+expFormat(cms2)+" cm/s²</br>"+expFormat(ms2)+" m/h²</br>"+expFormat(kmh2)+" km/h²</br>"+expFormat(ins2)+" in/s²</br>"+expFormat(fts2)+" ft/s²" );
}
}
}
function convertDensidad(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").style.display = "initial";
=======
=======
>>>>>>> parent of 741ef4d... Revert "output formating"
//document.getElementById("resultAlert").style.display = "initial";
<<<<<<< HEAD
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var kgL = cantidad*1;
var kgm3 = cantidad * 1000;
var lbin3 = ((cantidad * 2.20462)/1000)*(2.54^3);
var lbft3 = ((cantidad * 2.20462)/1000)*(30.48^3);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" gr/cm³ equivalen a:</h4></br>"+expFormat(kgL)+" kg/L</br>"+expFormat(kgm3)+" kg/m³</br>"+expFormat(lbin3)+" lb/in³</br>"+expFormat(lbft3)+" lb/ft³" );
}else if(unit == 2){
var grcm3 = cantidad;
var kgm3 = grcm3 * 1000;
var lbin3 = ((grcm3 * 2.20462)/1000)*(2.54^3);
var lbft3 = ((grcm3 * 2.20462)/1000)*(30.48^3);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" kg/L equivalen a:</h4></br>"+expFormat(grcm3)+" g/cm³</br>"+expFormat(kgm3)+" kg/m³</br>"+expFormat(lbin3)+" lb/in³</br>"+expFormat(lbft3)+" lb/ft³" );
}else if(unit == 3){
var grcm3 = cantidad / 1000;
var kgL = grcm3;
var lbin3 = ((grcm3 * 2.20462)/1000)*(2.54^3);
var lbft3 = ((grcm3 * 2.20462)/1000)*(30.48^3);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" kg/m³ equivalen a:</h4></br>"+expFormat(grcm3)+" g/cm³</br>"+expFormat(kgL)+" kg/L</br>"+expFormat(lbin3)+" lb/in³</br>"+expFormat(lbft3)+" lb/ft³" );
}else if(unit == 4){
var grcm3 = ((cantidad / 2.20462)*1000)/(2.54^3);
var kgL = grcm3;
var kgm3 = grcm3 * 1000;
var lbft3 = ((grcm3 * 2.20462)/1000)*(30.48^3);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" lb/in³ equivalen a:</h4></br>"+expFormat(grcm3)+" g/cm³</br>"+expFormat(kgL)+" kg/L</br>"+expFormat(kgm3)+" kg/m³</br>"+expFormat(lbft3)+" lb/ft³" );
}else if(unit == 5){
var grcm3 = ((cantidad / 2.20462)*1000)/(30.48^3);
var kgL = grcm3;
var kgm3 = grcm3 * 1000;
var lbin3 = ((grcm3 * 2.20462)/1000)*(2.54^3);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" lb/ft³ equivalen a:</h4></br>"+expFormat(grcm3)+" g/cm³</br>"+expFormat(kgL)+" kg/L</br>"+expFormat(kgm3)+" kg/m³</br>"+expFormat(lbin3)+" lb/in³" );
}
}
}
function convertEnergia(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").style.display = "initial";
=======
=======
>>>>>>> parent of 741ef4d... Revert "output formating"
//document.getElementById("resultAlert").style.display = "initial";
<<<<<<< HEAD
document.getElementById("resultAlert").style.display = "initial";
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var kJ = cantidad / 1000;
var Nm = cantidad *1;
var kPam3 = cantidad / 1000;
var kWh = (cantidad / 1000)/ 3600;
var cal = cantidad/ 4.184;
var Cal = cantidad / 4184;
var kJ_kg = cantidad;
var Psiaft3 = (cantidad/ 1055.0559) * 5.40395;
var lbfft = (((cantidad / 1055.0559) * 5.40395) * 778.169)/5.40395;
var BTU = cantidad/ 1055.0559;
var BTU_lb = cantidad * .430;
var ft2_s2 = (cantidad * .430)*25037;
var termia = (cantidad / 1055.0559)*100000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" J equivalen a:</h4></br>"+expFormat(kJ)+" kJ</br>"+expFormat(Nm)+" Nm</br>"+expFormat(kPam3)+" kPsm.m³</br>"+expFormat(kWh)+" kW/h</br>"+expFormat(cal)+" cal</br>"+expFormat(Cal)+" Cal</br>"+expFormat(kJ_kg)+" kJ_kg</br>"+expFormat(Psiaft3)+" Psia.ft³</br>"+expFormat(lbfft)+" lbf.ft</br>"+expFormat(BTU)+" BTU</br>"+expFormat(BTU_lb)+" BTU_lb</br>"+expFormat(ft2_s2)+" ft²_s²</br>"+expFormat(termia)+" termia" );
}else if(unit == 2){
var J = cantidad * 1000;
var Nm = J;
var kPam3 = J / 1000;
var kWh = (J / 1000)/ 3600;
var cal = J / 4.184;
var Cal = J / 4184;
var kJ_kg = J;
var Psiaft3 = (J / 1055.0559) * 5.40395;
var lbfft = (((J / 1055.0559) * 5.40395) * 778.169)/5.40395;
var BTU = J / 1055.0559;
var BTU_lb = J * .430;
var ft2_s2 = (J * .430)*25037;
var termia = (J / 1055.0559)*100000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" kJ equivalen a:</h4></br>"+expFormat(J)+" J</br>"+expFormat(Nm)+" Nm</br>"+expFormat(kPam3)+" kPsm.m³</br>"+expFormat(kWh)+" kW/h</br>"+expFormat(cal)+" cal</br>"+expFormat(Cal)+" Cal</br>"+expFormat(kJ_kg)+" kJ_kg</br>"+expFormat(Psiaft3)+" Psia.ft³</br>"+expFormat(lbfft)+" lbf.ft</br>"+expFormat(BTU)+" BTU</br>"+expFormat(BTU_lb)+" BTU_lb</br>"+expFormat(ft2_s2)+" ft²_s²</br>"+expFormat(termia)+" termia" );
}else if(unit == 3){
var J = cantidad*1;
var kJ = J / 1000;
var kPam3 = J / 1000;
var kWh = (J / 1000)/ 3600;
var cal = J / 4.184;
var Cal = J / 4184;
var kJ_kg = J;
var Psiaft3 = (J / 1055.0559) * 5.40395;
var lbfft = (((J / 1055.0559) * 5.40395) * 778.169)/5.40395;
var BTU = J / 1055.0559;
var BTU_lb = J * .430;
var ft2_s2 = (J * .430)*25037;
var termia = (J / 1055.0559)*100000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" Nm equivalen a:</h4></br>"+expFormat(J)+" J</br>"+expFormat(kJ)+" kJ</br>"+expFormat(kPam3)+" kPsm.m³</br>"+expFormat(kWh)+" kW/h</br>"+expFormat(cal)+" cal</br>"+expFormat(Cal)+" Cal</br>"+expFormat(kJ_kg)+" kJ_kg</br>"+expFormat(Psiaft3)+" Psia.ft³</br>"+expFormat(lbfft)+" lbf.ft</br>"+expFormat(BTU)+" BTU</br>"+expFormat(BTU_lb)+" BTU_lb</br>"+expFormat(ft2_s2)+" ft²_s²</br>"+expFormat(termia)+" termia" );
}else if(unit == 4){
var J = cantidad * 1000;
var kJ = J / 1000;
var Nm = J ;
var kWh = (J / 1000)/ 3600;
var cal = J / 4.184;
var Cal = J / 4184;
var kJ_kg = J;
var Psiaft3 = (J / 1055.0559) * 5.40395;
var lbfft = (((J / 1055.0559) * 5.40395) * 778.169)/5.40395;
var BTU = J / 1055.0559;
var BTU_lb = J * .430;
var ft2_s2 = (J * .430)*25037;
var termia = (J / 1055.0559)*100000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" kPa.m³ equivalen a:</h4></br>"+expFormat(J)+" J</br>"+expFormat(kJ)+" kJ</br>"+expFormat(Nm)+" Nm</br>"+expFormat(kWh)+" kW/h</br>"+expFormat(cal)+" cal</br>"+expFormat(Cal)+" Cal</br>"+expFormat(kJ_kg)+" kJ_kg</br>"+expFormat(Psiaft3)+" Psia.ft³</br>"+expFormat(lbfft)+" lbf.ft</br>"+expFormat(BTU)+" BTU</br>"+expFormat(BTU_lb)+" BTU_lb</br>"+expFormat(ft2_s2)+" ft²_s²</br>"+expFormat(termia)+" termia" );
}else if(unit == 5){
var J = (cantidad * 1000)* 3600;
var kJ = J / 1000;
var Nm = J ;
var kPam3 = J / 1000;
var cal = J / 4.184;
var Cal = J / 4184;
var kJ_kg = J;
var Psiaft3 = (J / 1055.0559) * 5.40395;
var lbfft = (((J / 1055.0559) * 5.40395) * 778.169)/5.40395;
var BTU = J / 1055.0559;
var BTU_lb = J * .430;
var ft2_s2 = (J * .430)*25037;
var termia = (J / 1055.0559)*100000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" kW/h equivalen a:</h4></br>"+expFormat(J)+" J</br>"+expFormat(kJ)+" kJ</br>"+expFormat(Nm)+" Nm</br>"+expFormat(kPam3)+" kPa.m³</br>"+expFormat(cal)+" cal</br>"+expFormat(Cal)+" Cal</br>"+expFormat(kJ_kg)+" kJ_kg</br>"+expFormat(Psiaft3)+" Psia.ft³</br>"+expFormat(lbfft)+" lbf.ft</br>"+expFormat(BTU)+" BTU</br>"+expFormat(BTU_lb)+" BTU_lb</br>"+expFormat(ft2_s2)+" ft²_s²</br>"+expFormat(termia)+" termia" );
}else if(unit == 6){
var J = cantidad * 4.184;
var kJ = J / 1000;
var Nm = J ;
var kPam3 = J / 1000;
var kWh = (J / 1000)/ 3600;
var Cal = J / 4184;
var kJ_kg = J;
var Psiaft3 = (J / 1055.0559) * 5.40395;
var lbfft = (((J / 1055.0559) * 5.40395) * 778.169)/5.40395;
var BTU = J / 1055.0559;
var BTU_lb = J * .430;
var ft2_s2 = (J * .430)*25037;
var termia = (J / 1055.0559)*100000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" cal equivalen a:</h4></br>"+expFormat(J)+" J</br>"+expFormat(kJ)+" kJ</br>"+expFormat(Nm)+" Nm</br>"+expFormat(kPam3)+" kPa.m³</br>"+expFormat(kWh)+" kW/h</br>"+expFormat(Cal)+" Cal</br>"+expFormat(kJ_kg)+" kJ_kg</br>"+expFormat(Psiaft3)+" Psia.ft³</br>"+expFormat(lbfft)+" lbf.ft</br>"+expFormat(BTU)+" BTU</br>"+expFormat(BTU_lb)+" BTU_lb</br>"+expFormat(ft2_s2)+" ft²_s²</br>"+expFormat(termia)+" termia" );
}else if(unit == 7){
var Cal =cantidad*1;
var J = Cal * 4184;
var kJ = J / 1000;
var Nm = J ;
var kPam3 = J / 1000;
var kWh = (J / 1000)/ 3600;
var cal = J / 4.184;
var kJ_kg = J;
var Psiaft3 = (J / 1055.0559) * 5.40395;
var lbfft = (((J / 1055.0559) * 5.40395) * 778.169)/5.40395;
var BTU = J / 1055.0559;
var BTU_lb = J * .430;
var ft2_s2 = (J * .430)*25037;
var termia = (J / 1055.0559)*100000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" Cal equivalen a:</h4></br>"+expFormat(J)+" J</br>"+expFormat(kJ)+" kJ</br>"+expFormat(Nm)+" Nm</br>"+expFormat(kPam3)+" kPa.m³</br>"+expFormat(kWh)+" kW/h</br>"+expFormat(cal)+" cal</br>"+expFormat(kJ_kg)+" kJ_kg</br>"+expFormat(Psiaft3)+" Psia.ft³</br>"+expFormat(lbfft)+" lbf.ft</br>"+expFormat(BTU)+" BTU</br>"+expFormat(BTU_lb)+" BTU_lb</br>"+expFormat(ft2_s2)+" ft²_s²</br>"+expFormat(termia)+" termia" );
}else if(unit == 8){
var J =cantidad*1;
var kJ = J / 1000;
var Nm = J ;
var kPam3 = J / 1000;
var kWh = (J / 1000)/ 3600;
var cal = J / 4.184;
var Cal = J / 4184;
var Psiaft3 = (J / 1055.0559) * 5.40395;
var lbfft = (((J / 1055.0559) * 5.40395) * 778.169)/5.40395;
var BTU = J / 1055.0559;
var BTU_lb = J * .430;
var ft2_s2 = (J * .430)*25037;
var termia = (J / 1055.0559)*100000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" kJ_kg equivalen a:</h4></br>"+expFormat(J)+" J</br>"+expFormat(kJ)+" kJ</br>"+expFormat(Nm)+" Nm</br>"+expFormat(kPam3)+" kPa.m³</br>"+expFormat(kWh)+" kW/h</br>"+expFormat(cal)+" cal</br>"+expFormat(Cal)+" cal</br>"+expFormat(Psiaft3)+" Psia.ft³</br>"+expFormat(lbfft)+" lbf.ft</br>"+expFormat(BTU)+" BTU</br>"+expFormat(BTU_lb)+" BTU_lb</br>"+expFormat(ft2_s2)+" ft²_s²</br>"+expFormat(termia)+" termia" );
}else if(unit == 9){
var J = (cantidad * 1055.0559) / 5.40395;
var kJ = J / 1000;
var Nm = J ;
var kPam3 = J / 1000;
var kWh = (J / 1000)/ 3600;
var cal = J / 4.184;
var Cal = J / 4184;
var kJ_kg = J;
var lbfft = (((J / 1055.0559) * 5.40395) * 778.169)/5.40395;
var BTU = J / 1055.0559;
var BTU_lb = J * .430;
var ft2_s2 = (J * .430)*25037;
var termia = (J / 1055.0559)*100000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" Psia.ft³ equivalen a:</h4></br>"+expFormat(J)+" J</br>"+expFormat(kJ)+" kJ</br>"+expFormat(Nm)+" Nm</br>"+expFormat(kPam3)+" kPa.m³</br>"+expFormat(kWh)+" kW/h</br>"+expFormat(cal)+" cal</br>"+expFormat(Cal)+" cal</br>"+expFormat(kJ_kg)+" kJ_kg</br>"+expFormat(lbfft)+" lbf.ft</br>"+expFormat(BTU)+" BTU</br>"+expFormat(BTU_lb)+" BTU_lb</br>"+expFormat(ft2_s2)+" ft²_s²</br>"+expFormat(termia)+" termia" );
}else if(unit == 10){
var J = (((cantidad * 1055.0559) / 5.40395) / 778.169)*5.40395;
var kJ = J / 1000;
var Nm = J ;
var kPam3 = J / 1000;
var kWh = (J / 1000)/ 3600;
var cal = J / 4.184;
var Cal = J / 4184;
var kJ_kg = J;
var Psiaft3 = (J / 1055.0559) * 5.40395;
var BTU = J / 1055.0559;
var BTU_lb = J * .430;
var ft2_s2 = (J * .430)*25037;
var termia = (J / 1055.0559)*100000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" lbf.ft equivalen a:</h4></br>"+expFormat(J)+" J</br>"+expFormat(kJ)+" kJ</br>"+expFormat(Nm)+" Nm</br>"+expFormat(kPam3)+" kPa.m³</br>"+expFormat(kWh)+" kW/h</br>"+expFormat(cal)+" cal</br>"+expFormat(Cal)+" cal</br>"+expFormat(kJ_kg)+" kJ_kg</br>"+expFormat(Psiaft3)+" Psia.ft³</br>"+expFormat(BTU)+" BTU</br>"+expFormat(BTU_lb)+" BTU_lb</br>"+expFormat(ft2_s2)+" ft²_s²</br>"+expFormat(termia)+" termia" );
}else if(unit == 11){
var J = cantidad * 1055.0559;
var kJ = J / 1000;
var Nm = J ;
var kPam3 = J / 1000;
var kWh = (J / 1000)/ 3600;
var cal = J / 4.184;
var Cal = J / 4184;
var kJ_kg = J;
var Psiaft3 = (J / 1055.0559) * 5.40395;
var lbfft = (((J / 1055.0559) * 5.40395) * 778.169)/5.40395;
var BTU_lb = J * .430;
var ft2_s2 = (J * .430)*25037;
var termia = (J / 1055.0559)*100000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" BTU equivalen a:</h4></br>"+expFormat(J)+" J</br>"+expFormat(kJ)+" kJ</br>"+expFormat(Nm)+" Nm</br>"+expFormat(kPam3)+" kPa.m³</br>"+expFormat(kWh)+" kW/h</br>"+expFormat(cal)+" cal</br>"+expFormat(Cal)+" cal</br>"+expFormat(kJ_kg)+" kJ_kg</br>"+expFormat(Psiaft3)+" Psia.ft³</br>"+expFormat(lbfft)+" lbf.ft</br>"+expFormat(BTU_lb)+" BTU_lb</br>"+expFormat(ft2_s2)+" ft²_s²</br>"+expFormat(termia)+" termia" );
}else if(unit == 12){
var J = cantidad / .430;
var kJ = J / 1000;
var Nm = J ;
var kPam3 = J / 1000;
var kWh = (J / 1000)/ 3600;
var cal = J / 4.184;
var Cal = J / 4184;
var kJ_kg = J;
var Psiaft3 = (J / 1055.0559) * 5.40395;
var lbfft = (((J / 1055.0559) * 5.40395) * 778.169)/5.40395;
var BTU = J / 1055.0559;
var ft2_s2 = (J * .430)*25037;
var termia = (J / 1055.0559)*100000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" BTU_lb equivalen a:</h4></br>"+expFormat(J)+" J</br>"+expFormat(kJ)+" kJ</br>"+expFormat(Nm)+" Nm</br>"+expFormat(kPam3)+" kPa.m³</br>"+expFormat(kWh)+" kW/h</br>"+expFormat(cal)+" cal</br>"+expFormat(Cal)+" cal</br>"+expFormat(kJ_kg)+" kJ_kg</br>"+expFormat(Psiaft3)+" Psia.ft³</br>"+expFormat(lbfft)+" lbf.ft</br>"+expFormat(BTU)+" BTU</br>"+expFormat(ft2_s2)+" ft²_s²</br>"+expFormat(termia)+" termia" );
}else if(unit == 13){
var J = (cantidad / .430)/25037;
var kJ = J / 1000;
var Nm = J ;
var kPam3 = J / 1000;
var kWh = (J / 1000)/ 3600;
var cal = J / 4.184;
var Cal = J / 4184;
var kJ_kg = J;
var Psiaft3 = (J / 1055.0559) * 5.40395;
var lbfft = (((J / 1055.0559) * 5.40395) * 778.169)/5.40395;
var BTU = J / 1055.0559;
var BTU_lb = J * .430;
var termia = (J / 1055.0559)*100000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" ft2_s2 equivalen a:</h4></br>"+expFormat(J)+" J</br>"+expFormat(kJ)+" kJ</br>"+expFormat(Nm)+" Nm</br>"+expFormat(kPam3)+" kPa.m³</br>"+expFormat(kWh)+" kW/h</br>"+expFormat(cal)+" cal</br>"+expFormat(Cal)+" cal</br>"+expFormat(kJ_kg)+" kJ_kg</br>"+expFormat(Psiaft3)+" Psia.ft³</br>"+expFormat(lbfft)+" lbf.ft</br>"+expFormat(BTU)+" BTU</br>"+expFormat(BTU_lb)+" BTU_lb</br>"+expFormat(termia)+" termia" );
}else if(unit == 14){
var J = (cantidad * 1055.0559)/100000;
var kJ = J / 1000;
var Nm = J ;
var kPam3 = J / 1000;
var kWh = (J / 1000)/ 3600;
var cal = J / 4.184;
var Cal = J / 4184;
var kJ_kg = J;
var Psiaft3 = (J / 1055.0559) * 5.40395;
var lbfft = (((J / 1055.0559) * 5.40395) * 778.169)/5.40395;
var BTU = J / 1055.0559;
var BTU_lb = J * .430;
var ft2_s2 = (J * .430)*25037;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" termia equivalen a:</h4></br>"+expFormat(J)+" J</br>"+expFormat(kJ)+" kJ</br>"+expFormat(Nm)+" Nm</br>"+expFormat(kPam3)+" kPa.m³</br>"+expFormat(kWh)+" kW/h</br>"+expFormat(cal)+" cal</br>"+expFormat(Cal)+" cal</br>"+expFormat(kJ_kg)+" kJ_kg</br>"+expFormat(Psiaft3)+" Psia.ft³</br>"+expFormat(lbfft)+" lbf.ft</br>"+expFormat(BTU)+" BTU</br>"+expFormat(BTU_lb)+" BTU_lb</br>"+expFormat(ft2_s2)+" ft²_s²" );
}
}
}
function convertFlujo(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").style.display = "initial";
document.getElementById("resultAlert").style.display = "initial";
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
=======
//document.getElementById("resultAlert").style.display = "initial";
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var W_m2 = cantidad * 100000;
var BTU_hft2 = (cantidad * 100000) * 0.3171;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" W_cm² equivalen a:</h4></br>"+expFormat(W_m2)+" W_m²</br>"+expFormat(BTU_hft2)+" BTU_hft²" );
}else if(unit == 2){
var W_cm2 = cantidad / 100000;
var BTU_hft2 = (cantidad * 100000) * 0.3171
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" W_m² equivalen a:</h4></br>"+expFormat(W_cm2)+" W_cm²</br>"+expFormat(BTU_hft2)+" BTU_hft²" );
}else if(unit == 3){
var W_cm2 = (cantidad / 100000) / 0.3171;
var W_m2 = W_cm2 * 100000
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" BTU_hft² equivalen a:</h4></br>"+expFormat(W_cm2)+" W_cm²</br>"+expFormat(W_m2)+" W_m²" );
}
}
}
function convertPotencia(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").style.display = "initial";
document.getElementById("resultAlert").style.display = "initial";
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
=======
//document.getElementById("resultAlert").style.display = "initial";
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var Js = cantidad *1;
var kW = cantidad / 1000;
var hp = (cantidad * .00134102208959509);
var BTUh = ( cantidad * 3.41214163312794);
var BTUmin = ( cantidad * 3.41214163312794) / 60;
var BTUs = ( cantidad * 3.41214163312794) / 3600;
var lbfts = ( cantidad * .737562149277299);
var hpcald = BTUh /(33481.6397750679);
var kJh = (cantidad * 3.6);
var Tonrefri = (( cantidad * 3.41214163312794) / 60)/200;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" W equivalen a:</h4></br>"+expFormat(Js)+" Js</br>"+expFormat(kW)+" kW</br>"+expFormat(hp)+" hp</br>"+expFormat(BTUh)+" BTUm</br>"+expFormat(BTUmin)+" BTUmin</br>"+expFormat(BTUs)+" BTUs</br>"+expFormat(lbfts)+" lbfts</br>"+expFormat(hpcald)+" hpcald</br>"+expFormat(kJh)+" kJh</br>"+expFormat(Tonrefri)+" Tonrefri");
}else if(unit == 2){
var W = cantidad *1;
var kW = W / 1000;
var hp = (W * .00134102208959509);
var BTUh = ( W * 3.41214163312794);
var BTUmin = ( W * 3.41214163312794) / 60;
var BTUs = ( W * 3.41214163312794) / 3600;
var lbfts = ( W * .737562149277299);
var hpcald = BTUh /(33481.6397750679);
var kJh = (W * 3.6);
var Tonrefri = (( W * 3.41214163312794) / 60)/200;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" Js equivalen a:</h4></br>"+expFormat(W)+" W</br>"+expFormat(kW)+" kW</br>"+expFormat(hp)+" hp</br>"+expFormat(BTUh)+" BTUm</br>"+expFormat(BTUmin)+" BTUmin</br>"+expFormat(BTUs)+" BTUs</br>"+expFormat(lbfts)+" lbfts</br>"+expFormat(hpcald)+" hpcald</br>"+expFormat(kJh)+" kJh</br>"+expFormat(Tonrefri)+" Tonrefri");
}else if(unit == 3){
var W = cantidad * 1000;
var Js = W;
var hp = (W * .00134102208959509);
var BTUh = ( W * 3.41214163312794);
var BTUmin = ( W * 3.41214163312794) / 60;
var BTUs = ( W * 3.41214163312794) / 3600;
var lbfts = ( W * .737562149277299);
var hpcald = BTUh /(33481.6397750679);
var kJh = (W * 3.6);
var Tonrefri = (( W * 3.41214163312794) / 60)/200;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" kW equivalen a:</h4></br>"+expFormat(W)+" W</br>"+expFormat(Js)+" Js</br>"+expFormat(hp)+" hp</br>"+expFormat(BTUh)+" BTUm</br>"+expFormat(BTUmin)+" BTUmin</br>"+expFormat(BTUs)+" BTUs</br>"+expFormat(lbfts)+" lbfts</br>"+expFormat(hpcald)+" hpcald</br>"+expFormat(kJh)+" kJh</br>"+expFormat(Tonrefri)+" Tonrefri");
}else if(unit == 4){
var W = (cantidad / .00134102208959509);
var Js = W;
var kW = W / 1000;
var BTUh = ( W * 3.41214163312794);
var BTUmin = ( W * 3.41214163312794) / 60;
var BTUs = ( W * 3.41214163312794) / 3600;
var lbfts = ( W * .737562149277299);
var hpcald = BTUh /(33481.6397750679);
var kJh = (W * 3.6);
var Tonrefri = (( W * 3.41214163312794) / 60)/200
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" hp equivalen a:</h4></br>"+expFormat(W)+" W</br>"+expFormat(kW)+" kW</br>"+expFormat(Js)+" Js</br>"+expFormat(BTUh)+" BTUm</br>"+expFormat(BTUmin)+" BTUmin</br>"+expFormat(BTUs)+" BTUs</br>"+expFormat(lbfts)+" lbfts</br>"+expFormat(hpcald)+" hpcald</br>"+expFormat(kJh)+" kJh</br>"+expFormat(Tonrefri)+" Tonrefri");
}else if(unit == 5){
var W = ( cantidad / 3.41214163312794);
var Js = W;
var kW = W / 1000;
var hp = (W * .00134102208959509);
var BTUmin = ( W * 3.41214163312794) / 60;
var BTUs = ( W * 3.41214163312794) / 3600;
var lbfts = ( W * .737562149277299);
var hpcald = cantidad /(33481.6397750679);
var kJh = (W * 3.6);
var Tonrefri = (( W * 3.41214163312794) / 60)/200;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" BTUh equivalen a:</h4></br>"+expFormat(W)+" W</br>"+expFormat(kW)+" kW</br>"+expFormat(Js)+" Js</br>"+expFormat(hp)+" hp</br>"+expFormat(BTUmin)+" BTUmin</br>"+expFormat(BTUs)+" BTUs</br>"+expFormat(lbfts)+" lbfts</br>"+expFormat(hpcald)+" hpcald</br>"+expFormat(kJh)+" kJh</br>"+expFormat(Tonrefri)+" Tonrefri");
}else if(unit == 6){
var W = (cantidad / 3.41214163312794) * 60;
var Js = W;
var kW = W / 1000;
var hp = (W * .00134102208959509);
var BTUh = ( W * 3.41214163312794);
var BTUs = ( W * 3.41214163312794) / 3600;
var lbfts = ( W * .737562149277299);
var hpcald = BTUh /(33481.6397750679);
var kJh = (W * 3.6);
var Tonrefri = (( W * 3.41214163312794) / 60)/200
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" BTUmin equivalen a:</h4></br>"+expFormat(W)+" W</br>"+expFormat(kW)+" kW</br>"+expFormat(Js)+" Js</br>"+expFormat(hp)+" hp</br>"+expFormat(BTUh)+" BTUh</br>"+expFormat(BTUs)+" BTUs</br>"+expFormat(lbfts)+" lbfts</br>"+expFormat(hpcald)+" hpcald</br>"+expFormat(kJh)+" kJh</br>"+expFormat(Tonrefri)+" Tonrefri");
}else if(unit == 7){
var W = (cantidad / 3.41214163312794) * 3600;
var Js = W;
var kW = W / 1000;
var hp = (W * .00134102208959509);
var BTUh = ( W * 3.41214163312794);
var BTUmin = ( W * 3.41214163312794) / 60;
var lbfts = ( W * .737562149277299);
var hpcald = BTUh /(33481.6397750679);
var kJh = (W * 3.6);
var Tonrefri = (( W * 3.41214163312794) / 60)/200;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" BTUs equivalen a:</h4></br>"+expFormat(W)+" W</br>"+expFormat(kW)+" kW</br>"+expFormat(Js)+" Js</br>"+expFormat(hp)+" hp</br>"+expFormat(BTUh)+" BTUh</br>"+expFormat(BTUmin)+" BTUmin</br>"+expFormat(lbfts)+" lbfts</br>"+expFormat(hpcald)+" hpcald</br>"+expFormat(kJh)+" kJh</br>"+expFormat(Tonrefri)+" Tonrefri");
}else if(unit == 8){
var W = ( cantidad / .737562149277299);
var Js = W;
var kW = W / 1000;
var hp = (W * .00134102208959509);
var BTUh = ( W * 3.41214163312794);
var BTUmin = ( W * 3.41214163312794) / 60;
var BTUs = ( W * 3.41214163312794) / 3600;
var hpcald = BTUh /(33481.6397750679);
var kJh = (W * 3.6);
var Tonrefri = (( W * 3.41214163312794) / 60)/200;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" lbfts equivalen a:</h4></br>"+expFormat(W)+" W</br>"+expFormat(kW)+" kW</br>"+expFormat(Js)+" Js</br>"+expFormat(hp)+" hp</br>"+expFormat(BTUh)+" BTUh</br>"+expFormat(BTUmin)+" BTUmin</br>"+expFormat(BTUs)+" BTUs</br>"+expFormat(hpcald)+" hpcald</br>"+expFormat(kJh)+" kJh</br>"+expFormat(Tonrefri)+" Tonrefri");
}else if(unit == 9){
var W = ( cantidad / 3.41214163312794)*(33481.6397750679);
var Js = W;
var kW = W / 1000;
var hp = (W * .00134102208959509);
var BTUh = ( W * 3.41214163312794);
var BTUmin = ( W * 3.41214163312794) / 60;
var BTUs = ( W * 3.41214163312794) / 3600;
var lbfts = ( W * .737562149277299);
var kJh = (W * 3.6);
var Tonrefri = (( W * 3.41214163312794) / 60)/200;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" hpcal equivalen a:</h4></br>"+expFormat(W)+" W</br>"+expFormat(kW)+" kW</br>"+expFormat(Js)+" Js</br>"+expFormat(hp)+" hp</br>"+expFormat(BTUh)+" BTUh</br>"+expFormat(BTUmin)+" BTUmin</br>"+expFormat(BTUs)+" BTUs</br>"+expFormat(lbfts)+" lbfts</br>"+expFormat(kJh)+" kJh</br>"+expFormat(Tonrefri)+" Tonrefri");
}else if(unit == 10){
var W = (cantidad / 3.6);
var Js = W;
var kW = W / 1000;
var hp = (W * .00134102208959509);
var BTUh = ( W * 3.41214163312794);
var BTUmin = ( W * 3.41214163312794) / 60;
var BTUs = ( W * 3.41214163312794) / 3600;
var lbfts = ( W * .737562149277299);
var hpcald = BTUh /(33481.6397750679);
var Tonrefri = (( W * 3.41214163312794) / 60)/200;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" kJh equivalen a:</h4></br>"+expFormat(W)+" W</br>"+expFormat(kW)+" kW</br>"+expFormat(Js)+" Js</br>"+expFormat(hp)+" hp</br>"+expFormat(BTUh)+" BTUh</br>"+expFormat(BTUmin)+" BTUmin</br>"+expFormat(BTUs)+" BTUs</br>"+expFormat(lbfts)+" lbfts</br>"+expFormat(hpcald)+" hpcal</br>"+expFormat(Tonrefri)+" Tonrefri");
}else if(unit == 11){
var W = (( cantidad / 3.41214163312794) * 60)*200;
var Js = W;
var kW = W / 1000;
var hp = (W * .00134102208959509);
var BTUh = ( W * 3.41214163312794);
var BTUmin = ( W * 3.41214163312794) / 60;
var BTUs = ( W * 3.41214163312794) / 3600;
var lbfts = ( W * .737562149277299);
var hpcald = BTUh /(33481.6397750679);
var kJh = (W * 3.6);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" Tonrefri equivalen a:</h4></br>"+expFormat(W)+" W</br>"+expFormat(kW)+" kW</br>"+expFormat(Js)+" Js</br>"+expFormat(hp)+" hp</br>"+expFormat(BTUh)+" BTUh</br>"+expFormat(BTUmin)+" BTUmin</br>"+expFormat(BTUs)+" BTUs</br>"+expFormat(lbfts)+" lbfts</br>"+expFormat(hpcald)+" hpcal</br>"+expFormat(kJh)+" kJh");
}
}
}
function convertVelocidad(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").style.display = "initial";
=======
=======
>>>>>>> parent of 741ef4d... Revert "output formating"
//document.getElementById("resultAlert").style.display = "initial";
<<<<<<< HEAD
document.getElementById("resultAlert").style.display = "initial";
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var ms = (cantidad) / 100;
var kmh = ((cantidad) / 100000) * (3600);
var ins = (cantidad) / 2.54;
var fts = (cantidad) / 30.48;
var millah = ((cantidad / 2.54)/63360) * 3600;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" cm/s equivalen a:</h4></br>"+expFormat(ms)+" m/s</br>"+expFormat(kmh)+" km/h</br>"+expFormat(ins)+" in/s</br>"+expFormat(fts)+" ft/s</br>"+expFormat(millah)+" milla/h" );
}else if(unit == 2){
var cms = (cantidad) * 100;
var kmh = ((cms) / 100000) * (3600);
var ins = (cms) / 2.54;
var fts = (cms) / 30.48;
var millah = ((cms / 2.54)/63360) * 3600;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" m/s equivalen a:</h4></br>"+expFormat(cms)+" cm/s</br>"+expFormat(kmh)+" km/h</br>"+expFormat(ins)+" in/s</br>"+expFormat(fts)+" ft/s</br>"+expFormat(millah)+" milla/h" );
}else if(unit == 3){
var cms = ((cantidad) * 100000) / (3600);
var ms = (cms) / 100;
var ins = (cms) / 2.54;
var fts = (cms) / 30.48;
var millah = ((cms / 2.54)/63360) * 3600;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" km/h equivalen a:</h4></br>"+expFormat(cms)+" cm/s</br>"+expFormat(ms)+" m/s</br>"+expFormat(ins)+" in/s</br>"+expFormat(fts)+" ft/s</br>"+expFormat(millah)+" milla/h" );
}else if(unit == 4){
var cms = (cantidad) * 2.54;
var ms = (cms) / 100;
var kmh = ((cms) / 100000) * (3600);
var fts = (cms) / 30.48;
var millah = ((cms / 2.54)/63360) * 3600;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" in/s equivalen a:</h4></br>"+expFormat(cms)+" cm/s</br>"+expFormat(ms)+" m/s</br>"+expFormat(kmh)+" km/h</br>"+expFormat(fts)+" ft/s</br>"+expFormat(millah)+" milla/h" );
}else if(unit == 5){
var cms = (cantidad) * 30.48;
var ms = (cms) / 100;
var kmh = ((cms) / 100000) * (3600);
var ins = (cms) / 2.54;
var millah = ((cms / 2.54)/63360) * 3600;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" ft/s equivalen a:</h4></br>"+expFormat(cms)+" cm/s</br>"+expFormat(ms)+" m/s</br>"+expFormat(kmh)+" km/h</br>"+expFormat(ins)+" in/s</br>"+expFormat(millah)+" milla/h" );
}else if(unit == 6){
var cms = ((cantidad * 2.54)*63360) / 3600;
var ms = (cms) / 100;
var kmh = ((cms) / 100000) * (3600);
var ins = (cms) / 2.54;
var fts = (cms) / 30.48;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" milla/h equivalen a:</h4></br>"+expFormat(cms)+" cm/s</br>"+expFormat(ms)+" m/s</br>"+expFormat(kmh)+" km/h</br>"+expFormat(ins)+" in/s</br>"+expFormat(fts)+" ft/s" );
}
}
}
function convertCoeficiente(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").style.display = "initial";
=======
=======
>>>>>>> parent of 741ef4d... Revert "output formating"
//document.getElementById("resultAlert").style.display = "initial";
<<<<<<< HEAD
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var Wm2F = cantidad;
var BTUhft2F = (cantidad*3.41214147993575)/(10.7639104167097*1.8);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" W/m² * °C equivalen a:</h4></br>"+expFormat(Wm2F)+" W/m² * F</br>"+expFormat(BTUhft2F)+" BTU/h * ft² * F" );
}else if(unit == 2){
var Wm2C = cantidad;
var BTUhft2F = (Wm2C*3.41214147993575)/(10.7639104167097*1.8);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" W/m² * F equivalen a:</h4></br>"+expFormat(Wm2C)+" W/m² * °C</br>"+expFormat(BTUhft2F)+" BTU/h * ft² * F" );
}else if(unit == 3){
var Wm2C = (cantidad/(10.7639104167097*1.8))/3.41214147993575;
var Wm2F = Wm2C;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" BTU/h * ft² * F equivalen a:</h4></br>"+expFormat(Wm2C)+" W/m² * °C</br>"+expFormat(Wm2F)+" W/m² * F" );
}
}
}
function convertConductividad(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").style.display = "initial";
=======
=======
>>>>>>> parent of 741ef4d... Revert "output formating"
//document.getElementById("resultAlert").style.display = "initial";
<<<<<<< HEAD
document.getElementById("resultAlert").style.display = "initial";
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var WmK = cantidad *1;
var BTUhftF = (cantidad*3.41214147993575)/(3.280839895*1.8);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" W/m * °C equivalen a:</h4></br>"+expFormat(WmK)+" W/m * K</br>"+expFormat(BTUhftF)+" BTU/h * ft * F" );
}else if(unit == 2){
var WmC = cantidad*1;
var BTUhftF =(WmC*3.41214147993575)/(3.280839895*1.8);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" W/m * K equivalen a:</h4></br>"+expFormat(WmC)+" W/m * °C</br>"+expFormat(BTUhftF)+" BTU/h * ft * F" );
}else if(unit == 3){
var WmC =(cantidad*(3.280839895*1.8))/3.41214147993575;
var WmK = WmC
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" BTU/h * ft * F equivalen a:</h4></br>"+expFormat(WmC)+" W/m * °C</br>"+expFormat(WmK)+" W/m * K" );
}
}
}
function convertEspecifico(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").style.display = "initial";
document.getElementById("resultAlert").style.display = "initial";
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
=======
//document.getElementById("resultAlert").style.display = "initial";
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var Lkg = cantidad*1000;
var cm3g = cantidad*1000;
var ft3lbm = cantidad*16.01846335;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" m³ /kg equivalen a:</h4></br>"+expFormat(Lkg)+" L/kg</br>"+expFormat(cm3g)+" cm³ /g</br>"+expFormat(ft3lbm)+" ft³ /lbm");
}else if(unit == 2){
var m3kg = cantidad/1000;
var cm3g = m3kg*1000;
var ft3lbm = m3kg*16.01846335;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" L/kg equivalen a:</h4></br>"+expFormat(m3kg)+" m³ /kg</br>"+expFormat(cm3g)+" cm³ /g</br>"+expFormat(ft3lbm)+" ft³ /lbm");
}else if(unit == 3){
var m3kg = cantidad/1000;
var Lkg = m3kg*1000;
var ft3lbm = m3kg*16.01846335;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" cm³ /g equivalen a:</h4></br>"+expFormat(m3kg)+" m³ /kg</br>"+expFormat(Lkg)+" L/kg /g</br>"+expFormat(ft3lbm)+" ft³ /lbm");
}else if(unit == 4){
var m3kg = cantidad/16.01846335;
var Lkg = m3kg*1000;
var cm3g = m3kg*1000;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" ft³ /lbm equivalen a:</h4></br>"+expFormat(m3kg)+" m³ /kg</br>"+expFormat(Lkg)+" L/kg</br>"+expFormat(cm3g)+" cm³/g");
}
}
}
function convertCalor(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").style.display = "initial";
=======
=======
>>>>>>> parent of 741ef4d... Revert "output formating"
//document.getElementById("resultAlert").style.display = "initial";
<<<<<<< HEAD
document.getElementById("resultAlert").style.display = "initial";
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var kJkgK = cantidad*1;
var JgC = cantidad*1;
var BTUlbmF = 4.1868*cantidad;
var BTUlbmR = 1.055056*cantidad/(0.45359237*1.8);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" kJkg°C equivalen a:</h4></br>"+expFormat(kJkgK)+" kJkg°K</br>"+expFormat(JgC)+" Jg°C</br>"+expFormat(BTUlbmF)+" BTUlbm°F</br>"+expFormat(BTUlbmR)+" BTUlbm°R");
}else if(unit == 2){
var kJkgC = cantidad*1;
var JgC = kJkgC*1;
var BTUlbmF = 4.1868*kJkgC;
var BTUlbmR = 1.055056*kJkgC/(0.45359237*1.8);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" kJkg°K equivalen a:</h4></br>"+expFormat(kJkgC)+" kJkg°C</br>"+expFormat(JgC)+" Jg°C</br>"+expFormat(BTUlbmF)+" BTUlbm°F</br>"+expFormat(BTUlbmR)+" BTUlbm°R");
}else if(unit == 3){
var kJkgC = cantidad*1;
var kJkgK = kJkgC*1;
var BTUlbmF = 4.1868*kJkgC;
var BTUlbmR = 1.055056*kJkgC/(0.45359237*1.8);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" JgC equivalen a:</h4></br>"+expFormat(kJkgC)+" kJkg°C</br>"+expFormat(kJkgK)+" kJkg°K</br>"+expFormat(BTUlbmF)+" BTUlbm°F</br>"+expFormat(BTUlbmR)+" BTUlbm°R");
}else if(unit == 4){
var kJkgC = 4.1868/cantidad;
var kJkgK = kJkgC;
var JgC = kJkgC;
var BTUlbmR = 1.055056*kJkgC/(0.45359237*1.8);
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" BTUlbmF equivalen a:</h4></br>"+expFormat(kJkgC)+" kJkg°C</br>"+expFormat(kJkgK)+" kJkg°K</br>"+expFormat(JgC)+" Jg°C</br>"+expFormat(BTUlbmR)+" BTUlbm°R");
}else if(unit == 5){
var kJkgC = 1.8/0.45359237*(cantidad/1.055056);
var kJkgK = kJkgC;
var JgC = kJkgC;
var BTUlbmF = 4.1868*kJkgC;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" BTUlbmR equivalen a:</h4></br>"+expFormat(kJkgC)+" kJkg°C</br>"+expFormat(kJkgK)+" kJkg°K</br>"+expFormat(JgC)+" Jg°C</br>"+expFormat(BTUlbmF)+" BTUlbm°F");
}
}
}
function convertTasa(){
var e = document.getElementById("selectUnits");
var unit = e.value;
var cantidad = document.getElementById("cantidad").value;
if(validate(cantidad)){
<<<<<<< HEAD
<<<<<<< HEAD
//document.getElementById("resultAlert").style.display = "initial";
document.getElementById("resultAlert").style.display = "initial";
=======
>>>>>>> parent of 603b449... Merge branch 'master' of https://github.com/EstebanHdz/EstebanHdz.github.io
=======
=======
//document.getElementById("resultAlert").style.display = "initial";
>>>>>>> 2356c65bc2b584bdb705240a939f5592432daa1e
>>>>>>> parent of 741ef4d... Revert "output formating"
var element = document.getElementById("result");
element.innerHTML = "";
if(unit == 1){
var Lmin = cantidad * (60/1000);
var m3s = cantidad /1000000;
var galmin = (cantidad / (2.54^3))/(231)*60;
var ft3s = (cantidad / (30.48^3));
var ft3min = (cantidad/ (30.48^3))*60;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" cm³ /s equivalen a:</h4></br>"+expFormat(Lmin)+" L/min</br>"+expFormat(m3s)+" m³ /s</br>"+expFormat(galmin)+" gal/min</br>"+expFormat(ft3s)+" ft³ /s</br>"+expFormat(ft3min)+"ft³ /min");
}else if(unit == 2){
var cm3s = cantidad / (60*1000);
var m3s = cm3s /1000000;
var galmin = (cm3s / (2.54^3))/(231)*60;
var ft3s = (cm3s / (30.48^3));
var ft3min = (cm3s / (30.48^3))*60;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" L/min equivalen a:</h4></br>"+expFormat(cm3s)+" cm³/s</br>"+expFormat(m3s)+" m³ /s</br>"+expFormat(galmin)+" gal/min</br>"+expFormat(ft3s)+" ft³ /s</br>"+expFormat(ft3min)+"ft³ /min");
}else if(unit == 3){
var cm3s = cantidad *1000000;
var Lmin = cm3s * (60/1000);
var galmin = (cm3s / (2.54^3))/(231)*60;
var ft3s = (cm3s / (30.48^3));
var ft3min = (cm3s / (30.48^3))*60;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" m³/s equivalen a:</h4></br>"+expFormat(cm3s)+" cm³/s</br>"+expFormat(Lmin)+" L/min</br>"+expFormat(galmin)+" gal/min</br>"+expFormat(ft3s)+" ft³ /s</br>"+expFormat(ft3min)+"ft³ /min");
}else if(unit == 4){
var cm3s = (cantidad *(2.54^3))*(231)/60;
var Lmin = cm3s * (60/1000);
var m3s = cm3s /1000000;
var ft3s = (cm3s / (30.48^3));
var ft3min = (cm3s / (30.48^3))*60;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" gal/min equivalen a:</h4></br>"+expFormat(cm3s)+" cm³/s</br>"+expFormat(Lmin)+" L/min</br>"+expFormat(m3s)+" m³/s</br>"+expFormat(ft3s)+" ft³ /s</br>"+expFormat(ft3min)+"ft³ /min");
}else if(unit == 5){
var cm3s = (cantidad * (30.48^3));
var Lmin = cm3s * (60/1000);
var m3s = cm3s /1000000;
var galmin = (cm3s / (2.54^3))/(231)*60;
var ft3min = (cm3s / (30.48^3))*60;
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" ft³/s equivalen a:</h4></br>"+expFormat(cm3s)+" cm³/s</br>"+expFormat(Lmin)+" L/min</br>"+expFormat(m3s)+" m³/s</br>"+expFormat(galmin)+" gal/min</br>"+expFormat(ft3min)+"ft³ /min");
}else if(unit == 6){
var cm3s = (cantidad * (30.48^3))/60;
var Lmin = cm3s * (60/1000);
var m3s = cm3s /1000000;
var galmin = (cm3s / (2.54^3))/(231)*60;
var ft3s = (cm3s / (30.48^3));
element.insertAdjacentHTML('afterbegin',"<h4>"+cantidad+" ft³/min equivalen a:</h4></br>"+expFormat(cm3s)+" cm³/s</br>"+expFormat(Lmin)+" L/min</br>"+expFormat(m3s)+" m³/s</br>"+expFormat(galmin)+" gal/min</br>"+expFormat(ft3s)+"ft³ /s");
}
}
}
function expFormat(number){
number *= 1;
if(number < 0.0001)
return number.toExponential(4);
else
return number.toFixed(4);
}
|
import DefaultSteps from './default';
import page from '../pages/login';
class LoginSteps extends DefaultSteps {
constructor() {
super(page);
}
login() {
this.page.fillEmailForm(process.env.EMAIL);
this.page.fillPasswordForm(process.env.PASSWORD);
this.page.submit();
this.page.refresh();
this.page.checkAuth();
}
}
export default new LoginSteps();
|
import React from 'react';
import DemoPopup from './DemoPopup.js';
import DemoPopup2 from './DemoPopup2.js';
import './PopupParent.css';
const components = {
demo: DemoPopup,
demo2: DemoPopup2
};
export default class PopupParent extends React.Component{
constructor(props){
super(props);
this.state = {
child_name : props.child_name
};
}
render(){
const SpecificStory = components[this.state.child_name];
return (<SpecificStory />);
}
}
|
import React from 'react';
import customerOne from '../../../images/customerOne.png';
const ClientFeedBackDetail = ({reviews}) => {
console.log(reviews);
return (
<div style={{border: '1px solid #BFBFBF',boxShadow: '3px 3px 5px lightgray'}} className="card col-md-4 text-center mb-4 p-4">
<div className="d-flex align-items-left">
<img style={{width:'64px',height:'62px'}} src={customerOne} alt=""/>
<div className="ml-2 card-title">
<h5>{reviews.name}</h5>
<h6>{reviews.companyName}</h6>
</div>
</div>
<div className="card-text">
<p> {reviews.details} </p>
</div>
</div>
);
};
export default ClientFeedBackDetail;
|
function solve(input) {
let carBrands = new Map();
for (const c of input) {
let [brand, model, amount] = c.split(' | ');
amount = Number(amount);
if (!carBrands.has(brand)) {
carBrands.set(brand, []);
}
if (!carBrands
.get(brand)
.some(x => x.model === model)) {
let newCar = {
model: model,
amount: amount
}
carBrands
.get(brand)
.push(newCar);
} else {
carBrands.get(brand)
.find(x => x.model == model)
.amount += amount;
}
}
for (const [brand, carList] of carBrands) {
console.log(brand);
carList.forEach(c => {
console.log(`###${c.model} -> ${c.amount}`);
});
}
}
solve(['Audi | Q7 | 1000',
'Audi | Q6 | 100',
'BMW | X5 | 1000',
'BMW | X6 | 100',
'Citroen | C4 | 123',
'Volga | GAZ-24 | 1000000',
'Lada | Niva | 1000000',
'Lada | Jigula | 1000000',
'Citroen | C4 | 22',
'Citroen | C5 | 10']
)
|
// --- Beginning of geo location
var mapLatitude, mapLongitude;
function geo_success(position) {
mapLongitude = position.coords.longitude;
mapLatitude = position.coords.latitude;
}
function geo_error(error) {
alert('ERROR(' + error.code + '): ' + error.message);
}
var wpid = navigator.geolocation.watchPosition(geo_success, geo_error);
// End of geo location ---
// --- Beginning of the google map
function initMap() {
if( (mapLongitude && mapLatitude) === undefined) {
showMyLocation(53.485366, -2.27175);
} else {
showMyLocation(mapLatitude, mapLongitude);
}
var marker, i;
var infowindow = new google.maps.InfoWindow();
var markers = locations.map(function(location, i) {
//Creating the variables
var name = locations[i]._campName;
var lat = locations[i]._latitude;
var long = locations[i]._longitude;
var photo = locations[i]._picText;
var id = locations[i]._idCamp;
var content = "<div><img src='../images/" + photo + "' height='100px;' width='150px;'><p>" + name +
"</p><p><a href='/campDetail.php?id=" + id + "'>Click for more info</a></p><div>";
//End of creating variables
var latlngset = new google.maps.LatLng(locations[i]._latitude, locations[i]._longitude);
var marker = new google.maps.Marker({
position: latlngset
});
google.maps.event.addListener(marker, 'click', function(evt) {
infowindow.setContent(content);
infowindow.open(map, marker);
});
return marker;
});
// Add a marker clusterer to manage the markers.
var markerCluster = new MarkerClusterer(map, markers,
{imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
}
//displays a specific place on the map if it exists
function geocodeAddress(geocoder, resultsMap) {
var address = document.getElementById('address').value;
geocoder.geocode({'address': address}, function(results, status) {
if (status === 'OK') {
resultsMap.setCenter(results[0].geometry.location);
}
});
}
//display the map, do auto-complete for the google search
function showMyLocation(lat, long) {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 7, center: new google.maps.LatLng(lat, long),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
//display the text and button inside the map
map.controls[google.maps.ControlPosition.TOP_LEFT].push(document.getElementById('address'));
map.controls[google.maps.ControlPosition.TOP_LEFT].push(document.getElementById('submit'));
//Auto-complete section
autocomplete = new google.maps.places.Autocomplete(
document.getElementById('address'), {types: ['geocode']});
autocomplete.setFields(['address_component']);
//get geolocation of the searched term
var geocoder = new google.maps.Geocoder();
document.getElementById('submit').addEventListener('click', function() {
geocodeAddress(geocoder, map);
});
if (document.getElementById("address").value !== "") {
geocodeAddress(geocoder, map);
}
}
|
define(function() {
return {
getOrientation: function() {
return (window.innerWidth > window.innerHeight) ? 'landscape' : 'portrait';
}
};
});
|
Vue.component('editor', {
template: `<modal v-model="visible" class-name="vertical-center-modal"
id="editor" :fullscreen="true" :closable="false" style="overflow: hidden;" @on-ok="ok"
>
<iframe id="iframe" v-if="visible" style="width: 100%; height: 100%;"
src="code.html"
sandbox='allow-scripts allow-top-navigation allow-same-origin allow-modals'
scrolling='no' frameborder='0' seamless='seamless'
></iframe>
<div slot="footer" style="display: flex;">
<div style="flex: 1;" />
<Button type="default" size="small" @click="cancel" style="width: 100px;">取消</Button>
<Button v-if="source.length > 0" type="warning" size="small" @click="clear" style="width: 100px;">清除</Button>
<Button type="primary" size="small" @click="ok" style="width: 100px;">確定</Button>
</div>
</modal>`,
props: {
modal: {
type: Boolean,
require: true,
default: false
},
},
data() {
return {
visible: false,
source: ""
};
},
created(){
this.visible = this.modal;
},
mounted () {
},
destroyed() {
},
methods: {
onMessage(e) {
let json = JSON.parse(e.data);
if(typeof json.data == "string")
this.source = json.data;
if(typeof json.action == "string"){
if(json.action.indexOf("save") == 0) {
if(json.action == "save-close")
this.$emit("onClose", json.data);
} else if(json.action == "close"){
this.$emit("onClose");
} else if(json.action == "error") {
alert("內容錯誤!!");
}
}
},
send(s){
let win = document.getElementById('iframe').contentWindow;
win.postMessage(s, "*");
},
save(){
this.send("save")
},
ok(){
this.send("save-close")
},
cancel() {
this.$emit("onClose");
},
clear(){
this.send("clear")
}
},
watch: {
modal(value) {
this.visible = value;
if(value == true) {
setTimeout(() => {
// this.send("test from jim")
}, 600);
window.addEventListener("message", this.onMessage, false);
} else {
window.removeEventListener("message", this.onMessage, false);
}
}
},
});
|
yellow_9_interval_name = ["新營","南安溪寮","後壁火車站","上茄苳","南靖火車站","後寮村","高鐵嘉義站","故宮南院"];
yellow_9_interval_stop = [ // 2018.10.02 checked
["新營站","第三市場","新營國小","新營文化中心","新營區公所","臺南市政府民治中心","臺南市農會","新東國中","東興國宅",
"東興、長榮路口","東仁、長榮路口","新營客運管理中心"], // 新營
["卯舍","土庫里","南安溪寮","北安溪寮"], // 南安溪寮
["下茄苳","後壁高中","良食故事館","後壁火車站"], // 後壁火車站
["上茄苳","勝泰工業"], // 上茄苳
["南靖火車站"], // 南靖火車站
["後寮村","春珠里"], // 後寮村
["高鐵嘉義站"], // 高鐵嘉義站
["故宮南院"] // 故宮南院
];
yellow_9_fare = [
[26],
[26,26],
[36,26,26],
[46,26,26,26],
[57,36,26,26,26],
[84,64,48,38,28,26],
[97,76,61,50,40,26,26],
[114,94,78,68,58,30,26,26]
];
// format = [time at the start stop] or
// [time, other] or
// [time, start_stop, end_stop, other]
yellow_9_main_stop_name = ["新營站","臺南市政府<br />民治中心","臺南市<br />農會","東興<br />國宅","新營客運<br />管理中心","北安<br />溪寮","後壁<br />火車站","南靖<br />火車站","高鐵<br />嘉義站","故宮南院<br /><span style='color:red;'>【二~日】</span>"];
yellow_9_main_stop_time_consume = [0, 4, 6, 9, 11, 16, 20, 27, 45, 55];
yellow_9_important_stop = [0, 6, 8, 9]; // 新營站, 後壁火車站, 高鐵嘉義站, 故宮南院
var Sinying = 0; // 新營站
var Tainan_City_Hall_Minzhi_Center = 1; // 臺南市政府民治中心
var Dongsing_Public_Housing = 3; // 東興國宅
var North_Ansiliao = 5;
var TRA_Houbi = 6; // 後壁火車站
var TRA_Nanjing = 7;
var hsr_chiayi = 8; // 高鐵嘉義站
yellow_9_time_go = [["06:00",Sinying,hsr_chiayi,[Tainan_City_Hall_Minzhi_Center]],["06:50",Sinying,hsr_chiayi,['W',[hsr_chiayi,10]]],["07:00",Sinying,hsr_chiayi],["08:00"],["09:00"],["10:00"],["11:00"],["12:00"],["13:00"],["14:00"],["15:00"],
["16:00"],["17:00",[[Dongsing_Public_Housing,5,TRA_Houbi,5]]],["17:40",Sinying,hsr_chiayi,['五']],["18:00",Sinying,hsr_chiayi],["18:40",Sinying,hsr_chiayi,[Tainan_City_Hall_Minzhi_Center,'五']],["19:00",Sinying,hsr_chiayi,[Tainan_City_Hall_Minzhi_Center]],["19:40",Sinying,hsr_chiayi,[Tainan_City_Hall_Minzhi_Center,'五']],["20:00",Sinying,hsr_chiayi,[Tainan_City_Hall_Minzhi_Center]],["20:40",Sinying,hsr_chiayi,[Tainan_City_Hall_Minzhi_Center,'五']]];
yellow_9_time_return = [
["07:15",hsr_chiayi,Sinying,[[TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Tainan_City_Hall_Minzhi_Center,1,Sinying,3]]],
["07:55",hsr_chiayi,Sinying,['W',[TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Tainan_City_Hall_Minzhi_Center,1,Sinying,3]]],
["08:25",hsr_chiayi,Sinying,[[TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["09:05",[[hsr_chiayi,10,TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["10:05",[[hsr_chiayi,10,TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["11:05",[[hsr_chiayi,10,TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["12:05",[[hsr_chiayi,10,TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["13:05",[[hsr_chiayi,10,TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["14:05",[[hsr_chiayi,10,TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["15:05",[[hsr_chiayi,10,TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Tainan_City_Hall_Minzhi_Center,1,Sinying,3]]],
["16:05",[[hsr_chiayi,10,TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Tainan_City_Hall_Minzhi_Center,1,Sinying,3]]],
["17:05",[[hsr_chiayi,10,TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Tainan_City_Hall_Minzhi_Center,1,Sinying,3]]],
["18:05",[Tainan_City_Hall_Minzhi_Center,[hsr_chiayi,10,TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["19:00",hsr_chiayi,Sinying,[Tainan_City_Hall_Minzhi_Center,'五',[TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["19:25",hsr_chiayi,Sinying,[Tainan_City_Hall_Minzhi_Center,[TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["20:00",hsr_chiayi,Sinying,[Tainan_City_Hall_Minzhi_Center,'五',[TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["20:25",hsr_chiayi,Sinying,[Tainan_City_Hall_Minzhi_Center,[TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["21:00",hsr_chiayi,Sinying,[Tainan_City_Hall_Minzhi_Center,'五',[TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["21:25",hsr_chiayi,Sinying,[Tainan_City_Hall_Minzhi_Center,[TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]],
["22:00",hsr_chiayi,Sinying,[Tainan_City_Hall_Minzhi_Center,'五',[TRA_Nanjing,-5,TRA_Houbi,1,North_Ansiliao,-1,Dongsing_Public_Housing,1,Sinying,-1]]]];
|
import React from 'react';
import PropTypes from 'prop-types';
import Typography from '@material-ui/core/Typography';
import DSASelect from '../controls/DSASelect';
import DSAStepContent from '../controls/DSAStepContent';
import DSADescription from '../controls/DSADescription';
import {Complexity} from '../data/DSACraftingData';
const options = Complexity.map((c) => {
return {value: c.name, label: c.name};
});
export default class DSAComplexityChooser extends React.Component {
handleChange = (value) => {
// find the right cost object:
const f = Complexity.find( (c) => c.name === value.value );
this.props.onChange("complexity", f);
}
render() {
const {stepper, complexity} = this.props
const {next, back} = stepper;
const active = complexity !== undefined;
return <DSAStepContent active={active} handleNext={next} handleBack={back}>
<Typography>Wähle die Komplexität des Gegenstandes.</Typography>
<form>
<DSASelect
options={options}
value={active ? complexity.name : ""}
onChange={this.handleChange}
label="Wähle"
/>
</form>
{active && <DSADescription caption="Komplexität" text={complexity.description} />}
</DSAStepContent>
}
}
DSAComplexityChooser.propTypes = {
stepper: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
};
|
import React, { useState } from 'react'
import './index.css'
function LoginForm () {
const [username, setUsername] = useState('')
const [password, setPassword] = useState('')
function handleUsernameChange (e) {
setUsername(e.target.value)
}
function handlePasswordChange (e) {
setPassword(e.target.value)
}
return (
<div className='loginForm'>
<h3>Please login:</h3>
<input
placeholder='username'
value={username}
onChange={handleUsernameChange}
/>
<input
type='password'
placeholder='password'
value={password}
onChange={handlePasswordChange}
/>
</div>
)
}
export default LoginForm
|
import serverStatus from "./serverStatus";
import { variant, columns } from "./db";
const MAX_DELAY = 3000;
const isInRange = (range, value) => {
return value >= range.min && value < range.max;
};
const getResponse = responseBody => {
const failFactorRange = { min: 0.85, max: 1 };
const notAuthorisedRange = { min: 0.75, max: 0.85 };
const status = Math.random();
if (isInRange(failFactorRange, status)) {
throw new Error(serverStatus.INTERNAL_SERVER_ERROR);
} else if (isInRange(notAuthorisedRange, status)) {
throw new Error(serverStatus.UNAUTHORIZED);
}
return { body: responseBody };
};
/**
* @typedef {Object} ServerResponse
* @property {any} body
* @property {number} error
*/
/**
* @function mockFetch
* @params {string} endpoint
* @returns {Promise<ServerResponse>}
*/
export const mockFetch = endpoint => {
const serverDelay = MAX_DELAY * Math.random();
return new Promise((resolve, reject) => {
let response = null;
setTimeout(() => {
try {
switch (endpoint) {
case "/variant":
response = getResponse(variant);
resolve(response);
break;
case "/columns":
response = getResponse(columns);
resolve(response);
break;
default:
resolve(response);
}
} catch (err) {
reject(err);
}
}, serverDelay);
});
};
|
const LocalStrategy = require('passport-local').Strategy
const User = require('../Models/user');
const bcrypt = require('bcrypt');
function init(passport) {
passport.use(new LocalStrategy({usernameField:'email'},async(email,password,done) => {
//login
//check if email exist
const user = await User.findOne({email : email})
if(!user) {
return done(null,false, { message:'No User Found With This Mail'})
}
bcrypt.compare(password,user.password).then(match => {
if(match) {
return done(null,user ,{message:'Success'})
}
return done(null,false ,{message:'Wrong Username OR Password'})
}).catch(err => {
return done(null,false,{message:'Something went wrong'})
})
}))
passport.serializeUser((user,done) => {
done(null,user._id)
})
passport.deserializeUser((id,done)=>{
User.findById(id, (err,user) => {
done(err,user)
})
})
}
module.exports = init
|
$(document).ready(function () {
$('.offer-items').slick({
infinite: true,
slidesToShow: 3,
slidesToScroll: 1,
rtl: true,
prevArrow: '.offer-prev',
nextArrow: '.offer-next',
// variableWidth: true,
// centerMode: true,
// centerPadding: '20px',
responsive: [
{
breakpoint: 768,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}
},
{
breakpoint: 576,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
// You can unslick at a given breakpoint now by adding:
// settings: "unslick"
// instead of a settings object
]
});
$('.client-items').slick({
infinite: true,
slidesToShow: 4,
slidesToScroll: 1,
rtl: true,
prevArrow: '.client-prev',
nextArrow: '.client-next',
// variableWidth: false,
// centerPadding: '10%',
responsive: [
{
breakpoint: 768,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}
},
{
breakpoint: 576,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
// You can unslick at a given breakpoint now by adding:
// settings: "unslick"
// instead of a settings object
]
});
// $('.project-tour-items').slick({
// infinite: false,
// centerMode: true,
// centerPadding: '200px',
// slidesToShow: 3,
// rtl: true,
// prevArrow: '.project-tour-prev',
// nextArrow: '.project-tour-next',
// responsive: [
// {
// breakpoint: 768,
// settings: {
// arrows: false,
// centerMode: true,
// centerPadding: '40px',
// slidesToShow: 2
// }
// },
// {
// breakpoint: 576,
// settings: {
// arrows: false,
// centerMode: true,
// centerPadding: '40px',
// slidesToShow: 1
// }
// }
// ]
// });
// Start Smooth Carsoul
$num = $('.my-card').length;
$even = $num / 2;
$odd = ($num + 1) / 2;
if ($num % 2 == 0) {
$('.my-card:nth-child(' + $even + ')').addClass('active');
$('.my-card:nth-child(' + $even + ')').prev().addClass('prev');
$('.my-card:nth-child(' + $even + ')').next().addClass('next');
} else {
$('.my-card:nth-child(' + $odd + ')').addClass('active');
$('.my-card:nth-child(' + $odd + ')').prev().addClass('prev');
$('.my-card:nth-child(' + $odd + ')').next().addClass('next');
}
$('.my-card').click(function () {
$slide = $('.active').width();
console.log($('.active').position().left);
if ($(this).hasClass('next')) {
$('.card-carousel').stop(false, true).animate({ left: '-=' + $slide });
} else if ($(this).hasClass('prev')) {
$('.card-carousel').stop(false, true).animate({ left: '+=' + $slide });
}
$(this).removeClass('prev next');
$(this).siblings().removeClass('prev active next');
$(this).addClass('active');
$(this).prev().addClass('prev');
$(this).next().addClass('next');
});
// Keyboard nav
$('html body').keydown(function (e) {
if (e.keyCode == 37) { // left
$('.active').prev().trigger('click');
}
else if (e.keyCode == 39) { // right
$('.active').next().trigger('click');
}
});
$('.project-tour-next').click(function(){
$('.active').next().trigger('click');
});
$('.project-tour-prev').click(function(){
$('.active').prev().trigger('click');
});
// End Smooth Carsoul
});
|
const JS_ITEMLIST = document.querySelector(".js-itemList");
const BODY = document.querySelector("body");
var BASE_URL = "img/Product/";
// only necklace info
const necklaceFolder =
[
{name:"earth pendant", number:3},
{name:"pizza pendant", number:2},
{name:"rain pendant", number:1},
];
// only bracelet info
const braceletFolder =
[
{name:"manchu bangle", number:1}
];
// only ring info
const ringFolder =
[
{name:"basic ring no1", number:6},
{name:"basic ring no2", number:1},
{name:"g logo ring", number:2},
{name:"key ring", number:2},
{name:"manchu ring", number:2},
{name:"thunder heart ring", number:4},
{name:"yy ring", number:4},
];
// only etc info
const etcFolder =
[
];
// common use info
const silver_925 = "silver 92.5";
const silver_950 = "silver 95.0"
const detail_info =
{
//necklace
"earth pendant": {
price:"65,000",
material: silver_925,
detail_info_text: "지구 이모지를 형상화한 팬던트 입니다. 기본체인 포함 가격입니다."
},
"pizza pendant": {
price:"65,000",
material: silver_925,
detail_info_text: "피자 형상을 한 팬던트 입니다. 기본체인 포함 가격입니다."
},
"rain pendant": {
price:"65,000",
material: silver_925,
detail_info_text: "물방울 형상을 한 팬던트 입니다. 기본체인 포함 가격입니다."
},
//bracelet
"manchu bangle": {
price:"80,000",
material: silver_925,
detail_info_text: "실제 앵두나무가지를 이용하여 제작된 뱅글형 팔찌 입니다. 나뭇가지 표면의 디테일 하나하나를 느끼실수 있습니다."
},
//ring
"basic ring no1" : {
price:"35,000",
material: silver_925,
detail_info_text: "착용시 다양한 느낌을 낼 수 있는 기본 은 반지 입니다. 두께는 1.5mm입니다. 사각형과 원형 두가지 종류가 있습니다. 두개를 교차로 착용시 색다른 멋을 내실 수 있습니다."
},
"g logo ring" : {
price:"75,000",
material: silver_950,
detail_info_text: "알파벳 G 로고가 들어가 반지 입니다. 로고 알파벳은 변경 가능합니다."
},
"thunder heart ring" : {
price:"75,000",
material: silver_925,
detail_info_text: "실버위에 브라스 재질의 하트를 얹은 thunder heart ring 입니다. 실버를 얹어서도 제작 가능합니다. 키치한 멋을 느끼실 수 있습니다.."
},
"key ring" : {
price:"65,000",
material: silver_925,
detail_info_text: "열쇠의 형상을 한 반지 입니다."
},
"manchu ring" : {
price:"45,000",
material: silver_925,
detail_info_text: "실제 앵두나무가지를 이용하여 제작한 반지입니다. 앵두나무가지의 디테일을 느끼실 수 있습니다."
},
"yy ring" : {
price:"55,000",
material: silver_925,
detail_info_text: "음양의 형상을 한 반지 입니다."
},
"basic ring no2" : {
price:"55,000",
material: silver_925,
detail_info_text: "볼드한 느낌을 한껏 가진 기본 반지입니다. 넓아는 약 1.5cm입니다. 넓이가 넓은 만큼 착용감이 매우 우수합니다."
},
//etc
}
// common use info
var material_info =
{
[silver_925]: "",
[silver_950]: "",
}
// modal background click event
function closeEventHandle(event){
if(event.target.id === 'modal')
BODY.removeChild(BODY.childNodes[0]);
}
// '<' button add
function appendSlideElement_prev(div_slideshow_container){
var a = document.createElement("a");
a.classList.add("prev");
a.setAttribute("onclick","minusSlide()");
a.innerHTML = "❮";
div_slideshow_container.appendChild(a);
}
// '>' button add
function appendSlideElement_next(div_slideshow_container){
var a = document.createElement("a");
a.classList.add("next");
a.setAttribute("onclick","plusSlide()");
a.innerHTML = "❯";
div_slideshow_container.appendChild(a);
}
// make 'o' button
function makeDot(i){
var span = document.createElement("span");
span.classList.add("dot");
span.setAttribute("onclick","showSlides("+i+")");
return span;
}
// append multiple dot
function appendSlideElement_dots(div_slideshow_container){
var dots = document.createElement("div");
dots.classList.add("dots");
div_slideshow_container.childNodes.forEach(function(node, i){
if(node.classList.contains("mySlides")){
const dot = makeDot(i);
dots.appendChild(dot);
}
});
div_slideshow_container.appendChild(dots);
}
// append explanation text
function appendDiv(dl, dt_innerText, dd_innerText){
var div = document.createElement("div");
var dt = document.createElement("dt");
var dd = document.createElement("dd");
div.classList.add("text");
dt.classList.add("key");
dd.classList.add("value");
dt.innerText = dt_innerText;
dd.innerText = dd_innerText;
div.appendChild(dt);
div.appendChild(dd);
dl.appendChild(div);
}
function appendATag(dl, innerText, class_name, href){
const a = document.createElement("a");
a.innerText = innerText;
a.classList.add(class_name, "text");
a.href = href;
dl.appendChild(a);
}
function appendHrTag(dl){
const hr = document.createElement("hr");
hr.classList.add("text");
dl.appendChild(hr);
}
// append text-area
function appendSlideElement_texts(div_slideshow_container){
var dl = document.createElement("dl");
dl.classList.add("texts");
const product_name = div_slideshow_container.childNodes[0].childNodes[0].alt;
const material_name = detail_info[product_name]['material'];
const dd_innerText = material_name + " \n";
appendDiv(dl, product_name, "");
appendDiv(dl, "price : "+detail_info[product_name]['price'], "" );
appendATag(dl, "buy", "blackFont-hover-reserval", "https://open.kakao.com/o/se5DlxYb");
appendHrTag(dl);
appendDiv(dl, "material info\n", dd_innerText);
appendDiv(dl, "detail info\n", detail_info[product_name]["detail_info_text"]);
div_slideshow_container.appendChild(dl);
}
// callback function for product image click
function clickEventHandle(event){
const div_modal = document.createElement("div");
const div_slideshow_container = document.createElement("div");
const li = event.target.parentElement;
div_modal.id = "modal";
div_slideshow_container.classList.add("slideshow-container");
li.childNodes.forEach(function(img, i){
const div = document.createElement("div");
// i == 0 ? div.style.display = "block" : div.style.display="none";
div.classList.add("mySlides");
const img_clone = img.cloneNode(true);
img_clone.classList.remove("SHOW");
img_clone.classList.remove("HIDDEN");
div.appendChild(img_clone);
div_slideshow_container.appendChild(div);
});
appendSlideElement_prev(div_slideshow_container);
appendSlideElement_next(div_slideshow_container);
appendSlideElement_dots(div_slideshow_container);
appendSlideElement_texts(div_slideshow_container);
div_modal.appendChild(div_slideshow_container);
div_modal.addEventListener("click", closeEventHandle);
BODY.prepend(div_modal);
showSlides(0);
}
// append product image
function appendItems(items){
items.forEach(function(item){
const li = document.createElement("li");
item.forEach(function(image){
li.appendChild(image);
});
JS_ITEMLIST.appendChild(li);
});
}
// get image by url
function getImage(obj, i, item_type){
const image = new Image();
const src = item_type+ "/" + obj.name + "/" + i + ".png";
// let srcset = item_type+ "/" + obj.name + "/" + i + "_small.png 400w,";
// srcset += item_type+ "/" + obj.name + "/" + i + "_large.png 1920w,";
if(i === 1){
src.importance = "high";
}else{
src.importance ="low"
}
image.src = BASE_URL+ src;
image.alt = obj.name;
// image.srcset = srcset;
i == 1 ? image.classList.add("SHOW") : image.classList.add("HIDDEN");
if(i===1) image.addEventListener("click", clickEventHandle);
return image;
}
// get items by directory
function getItems(info_folder, item_type){
const items = [];
info_folder.forEach(function(obj){
const item = [];
for(var i = 1; i< obj.number+1; i++){
const image = getImage(obj, i, item_type) ;
item.push(image);
}
items.push(item)
});
return items;
}
|
/* Calculates the correct Phaser angle between (x1,y1) and (x2,y2) */
export const angle = (x1, y1, x2, y2) => {
/* Checks if the arguments are all numbers, prints out the ones that are not */
let invalid = '';
if (typeof x1 != 'number') { invalid += ' x1 is not a number\n' }
if (typeof y1 != 'number') { invalid += ' y1 is not a number\n' }
if (typeof x2 != 'number') { invalid += ' x2 is not a number\n' }
if (typeof y2 != 'number') { invalid += ' y2 is not a number\n' }
if (invalid != '') { throw new Error(`All arguments must be numbers.\n${invalid}`); }
/* Calculates the angle */
let mvtAngle = Math.atan2((y1 - y2), (x1 - x2));
if (mvtAngle > 0.0) {
if (mvtAngle < Math.PI * 0.5) {
mvtAngle = 0.0;
} else {
mvtAngle = Math.PI;
}
}
return mvtAngle + Math.PI * 0.5;
}
|
//this service defines 'notifier' as our angular service to call the toastr plug-in for notifications
angular.module('app').value('toastr', toastr);
angular.module('app').factory('notifier', function(toastr) {
return {
notify: function(type, msg, close, position, timeout) {
if(!close) close = true;
if(!position) position = "toast-bottom-left";
if(!timeout) timeout = 5000;
toastr.options = {
closeButton: close,
positionClass: position,
timeOut: timeout
};
if(type === "success") {
toastr.success(msg);
}
else if(type === "error") {
toastr.error(msg);
}
else if(type === "warning") {
toastr.warning(msg);
}
}
}
});
|
"use strict";
const Suits = [
"Club",
"Diamond",
"Heart",
"Spade"
];
const Values = [
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"Jack",
"Queen",
"King",
"Ace"
];
class Card {
constructor(value, suit) {
this.value = value;
this.suit = suit;
}
displayName() {
return `${Values[this.value]} of ${Suits[this.suit]}`;
}
shortName() {
let returnName;
if (this.value >= 0 && this.value <= 8) {
let adjustedValue = this.value + 2;
returnName = adjustedValue.toString();
}
else if (this.value === 9) {
returnName = "J";
}
else if (this.value === 10) {
returnName = "Q";
}
else if (this.value === 11) {
returnName = "K";
}
else if (this.value === 12) {
returnName = "A";
}
return returnName + Suits[this.suit].substr(0, 1);
}
}
module.exports = Card;
|
exports.signUp = {
username: {
in: ['body'],
isLength: { options: { min: 8, max: 30 } },
matches: { options: /^[a-z0-9_-]+$/i },
trim: true,
errorMessage: 'Invalid username, please enter one with 8 or more characters.'
},
password: {
in: ['body'],
isLength: { options: { min: 6, max: 30 } },
isAlphanumeric: true,
trim: true,
errorMessage: 'Invalid password, please enter one with 6 or more characters.'
},
firstName: {
in: ['body'],
isLength: { options: { min: 2 } },
matches: { options: /^[a-z' ]+$/i },
trim: true,
errorMessage: 'Invalid first name.'
},
lastName: {
in: ['body'],
isLength: { options: { min: 2 } },
matches: { options: /^[a-z' ]+$/i },
trim: true,
errorMessage: 'Invalid last name.'
},
preferredCurrency: {
in: ['body'],
matches: { options: /^(COP|USD|EUR)$/i },
errorMessage: 'Invalid currency. Please enter one of the following: COP, USD, EUR.'
}
};
exports.logIn = {
username: {
in: ['body'],
exists: true,
matches: { options: /^[a-z0-9_-]+$/i },
trim: true,
errorMessage: 'Please enter a valid username.'
},
password: {
in: ['body'],
exists: true,
isAlphanumeric: true,
trim: true,
errorMessage: 'Please enter a valid password'
}
};
|
/* GOOGLE ANALYTICS SCRIPTS */
// TRACKING CODE FROM E-NOR
// ---------------------------
hostname = document.location.hostname;
//hostname = hostname.match(/(([^.\/]+\.[^.\/]{2,3}\.[^.\/]{2})|(([^.\/]+\.)[^.\/]{2,4}))(\/.*)?$/)[1];
hostname = hostname.toLowerCase() ;
|
const AreRequestsPending = (requests) => {
let result = false;
console.log('requests', requests)
// if (typeof requests === 'array'){
// let requestsThatExist = []
// requests.forEach(request => {
// try {
// requestsThatExist = [...request]
// } catch (e) {
// return null
// }
// }
// function checkRequests(args) {
// return args.some(arg => true === arg)
// }
// result = checkRequests(requestsThatExist)
// }
// else if (typeof requests === 'object') {
// for (var i in requests) {
// console.log('requests[i]', requests[i])
// if (requests[i] === true) {
// result = true;
// break;
// }
// }
// } else {
// }
// return(
// result
// )
}
export default AreRequestsPending
|
var _api = require("../api.js");
var _api2 = _interopRequireDefault(_api);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
var app = getApp();
Page({
data: {
current: 0,
swiperH: 0,
tab: [ "搜索院校", "搜索专业" ],
keyword: "",
majorList: [],
collegeList: [],
choseNum: 0,
keywords: []
},
onLoad: function onLoad(options) {
this.options = options;
if (options && options.type) {
this.setData({
current: options.type,
section: options.section
});
}
this.getswiperH();
// this.getMajors();
},
getswiperH: function getswiperH() {
var that = this;
var item = wx.createSelectorQuery();
item.select("#head").boundingClientRect();
item.exec(function(res) {
that.setData({
swiperH: app.globalData.systemInfo.screenHeight - res[0].height - app.globalData.navigationCustomCapsuleHeight - app.globalData.navigationCustomStatusHeight
});
});
},
getMajors: function getMajors() {
var _this = this;
var userNumId = wx.getStorageSync("userInfo")[0].UserId;
var data = {
userNumId: userNumId
};
_api2.default.getMajors("Evaluation/Result/ProfessionOrientation/QueryMajors", "POST", data).then(function(res) {
res.result.map(function(i) {
i.st = false;
});
_this.setData({
majorList: res.result
});
});
},
checkTab: function checkTab(e) {
var index = e.currentTarget.dataset.index;
this.setData({
current: index
});
},
input: function input(e) {
this.setData({
keyword: e.detail.value
});
},
confirm: function confirm() {
var list = this.data.majorList;
if (list.indexOf(this.data.keyword) == -1) {
list.unshift(this.data.keyword);
}
var count = 0;
this.data.majorList.map(function(i) {
if (i.st) {
count++;
}
});
if (count + list.length > 30) {
this.toast();
return;
} else {
this.setData({
majorList: list
});
}
},
chose: function chose(e) {
var num = 0;
var index = e.currentTarget.dataset.index;
var arr = this.data.majorList;
arr[index].st = !arr[index].st;
arr.map(function(i) {
if (i.st) {
num++;
}
});
if (this.data.majorList.length + num > 20) {
this.toast();
return;
} else {
this.setData({
majorList: arr,
choseNum: num
});
}
},
del: function del(e) {
var index = e.currentTarget.dataset.index;
var arr = [];
switch (parseInt(this.data.current)) {
case 0:
arr = this.data.collegeList;
arr.splice(index, 1);
this.setData({
collegeList: arr
});
wx.setStorageSync("addCollegeList", arr);
break;
case 1:
arr = this.data.majorList;
arr.splice(index, 1);
this.setData({
majorList: arr
});
wx.setStorageSync("sdAddMajorSearch", arr);
break;
}
},
toast: function toast() {
wx.showToast({
title: "添加专业上限30个",
icon: "none"
});
},
onUnload: function onUnload() {
var pages = getCurrentPages();
var prevPage = pages[pages.length - this.options.prevPage];
//上一个页面
prevPage.update = true;
},
onShow: function onShow() {
var collegeList = wx.getStorageSync("addCollegeList") || [];
var majorList = wx.getStorageSync("sdAddMajorSearch") || [];
this.setData({
collegeList: collegeList,
majorList: majorList
});
},
goSearch: function goSearch() {
var url = void 0;
if (this.data.current == 0) {
wx.setStorageSync("isSearchCollege", true);
url = "/pages/globalSearch/globalSearch?mode=sdReport§ion=" + this.data.section;
} else if (this.data.current == 1) {
url = "/pages/globalSearch/globalSearch?mode=firstMajor";
}
wx.navigateTo({
url: url
});
}
});
|
import React, { useContext } from "react";
import "../../App.css";
import firebase from "firebase/app";
import "firebase/auth";
import firebaseConfig from "./firebase.config";
import { useState } from "react";
import "./Login2.css";
import { useHistory } from "react-router";
import { UserContext } from "../../App";
if (firebase.apps.length === 0) {
firebase.initializeApp(firebaseConfig);
}
function Login2() {
const [newUser, setNewUser] = useState(false);
const history = useHistory();
const [user, setUser] = useState({
isSignedIn: false,
name: "",
email: "",
password: "",
photo: "",
});
const [loggedInUser,setLoggedInUser] = useContext(UserContext);
const provider = new firebase.auth.GoogleAuthProvider();
const handleSignIn = () => {
firebase
.auth()
.signInWithPopup(provider)
.then((res) => {
const { displayName, photoURL, email } = res.user;
const signedInUser = {
isSignedIn: true,
name: displayName,
email: email,
photo: photoURL,
};
setUser(signedInUser);
setLoggedInUser(signedInUser);
history.replace('/transport');
console.log(displayName, email, photoURL);
})
.catch((err) => {
console.log(err);
console.log(err.message);
});
};
const handleSignOut = () => {
firebase
.auth()
.signOut()
.then((res) => {
const signedOutUser = {
isSignedIn: false,
name: "",
photo: "",
email: "",
error: "",
success: false,
};
setUser(signedOutUser);
console.log(res);
})
.catch((err) => {});
};
const handleBlur = (event) => {
let isFieldValid;
if (event.target.name === "email") {
isFieldValid = /\S+@\S+\.\S+/.test(event.target.value);
}
if (event.target.name === "password") {
const isPasswordValid = event.target.value.length > 6;
const passwordHasNumber = /\d{1}/.test(event.target.value);
isFieldValid = isPasswordValid && passwordHasNumber;
}
if (isFieldValid) {
const newUserInfo = { ...user };
newUserInfo[event.target.name] = event.target.value;
setUser(newUserInfo);
}
};
const handleSubmit = (event) => {
if (newUser && user.email && user.password) {
firebase
.auth()
.createUserWithEmailAndPassword(user.email, user.password)
.then((res) => {
const newUserInfo = { ...user };
newUserInfo.error = "";
newUserInfo.success = true;
setUser(newUserInfo);
setLoggedInUser(newUserInfo);
updateUserName(user.name);
history.replace('/transport');
console.log("sign in user info", res.user);
})
.catch((error) => {
const newUserInfo = { ...user };
newUserInfo.error = error.message;
newUserInfo.success = false;
setUser(newUserInfo);
});
}
if (!newUser && user.email && user.password) {
firebase
.auth()
.signInWithEmailAndPassword(user.email, user.password)
.then((res) => {
const newUserInfo = { ...user };
newUserInfo.error = "";
newUserInfo.success = true;
setUser(newUserInfo);
console.log('signed in');
setLoggedInUser(newUserInfo);
history.replace('/transport');
})
.catch((error) => {
const newUserInfo = { ...user };
newUserInfo.error = error.message;
newUserInfo.success = false;
setUser(newUserInfo);
});
}
event.preventDefault();
};
const updateUserName = (name) => {
const user = firebase.auth().currentUser;
user
.updateProfile({
displayName: name,
})
.then(function () {
console.log("user updated");
})
.catch(function (error) {
console.log(error);
});
};
return (
<div className="App">
<br></br>
{user.isSignedIn ?
(
<div>
<p>Welcome, {user.name}</p>
<p>Your email : {user.email}</p>
<img src={user.photo} alt=""></img>
</div>
) : <h1>Sign In to continue</h1>}
<section className="container-fluid">
<section className="row justify-content-center">
<section className="col-12 col-sm-6 col-md-3">
<form action="" className="form-container" onSubmit = {handleSubmit}>
<input type="checkbox" onChange={() => setNewUser(!newUser)} name="newUser" id="" />
<label htmlFor="newUser">New User Signup</label>
{newUser && (
<input className="form-control" type="text" name="name"onBlur={handleBlur} required placeholder="Your Name" />
)}
<br />
<input className="form-control" type="text" name="email" onBlur={handleBlur} placeholder="Email Address"required></input>
<br></br>
<input className="form-control" type="password" name="password" onBlur={handleBlur} placeholder="Enter your password" required></input>
<br></br>
<input className="btn-secondary form-control my-2" type="submit" value={newUser ? "Sign Up With Email & Password" : "Sign In with Email & Password"}></input>
{user.isSignedIn ? (
<button className="btn-secondary form-control" onClick={handleSignOut}>Sign out</button>
) : (
<button className="form-control btn-success" onClick={handleSignIn}>Sign in Using Google</button>
)}
</form>
</section>
</section>
</section>
</div>
);
}
export default Login2;
|
import express from 'express'
import {
forgotPassword,
loginUser,
logout,
registerUser,
resetPassword,
getUserProfile,
updatePassword,
updateProfile,
allUsers,
getUserDetails,
updateUser,
deleteUser,
} from '../controllers/userController.js'
import {
isAuthenticatedUser,
authorizeRoles,
} from '../middlewares/authMiddleware.js'
const router = express.Router()
router.route('/register').post(registerUser)
router.route('/login').post(loginUser)
router.route('/password/forgot').post(forgotPassword)
router.route('/password/reset/:token').put(resetPassword)
router.route('/logout').get(logout)
router.route('/me').get(isAuthenticatedUser, getUserProfile)
router.route('/password/update').put(isAuthenticatedUser, updatePassword)
router.route('/me/update').put(isAuthenticatedUser, updateProfile)
router
.route('/admin/users')
.get(isAuthenticatedUser, authorizeRoles('admin'), allUsers)
router
.route('/admin/user/:id')
.get(isAuthenticatedUser, authorizeRoles('admin'), getUserDetails)
.put(isAuthenticatedUser, authorizeRoles('admin'), updateUser)
.delete(isAuthenticatedUser, authorizeRoles('admin'), deleteUser)
export default router
|
import React, { Component } from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';
import './SavedTempos.css';
import ListGroup from 'react-bootstrap/ListGroup';
const SavedTempos = (props) => {
const { songName } = props;
const { tempo } = props;
const { clickHandler } = props;
const { currentTempo } = props;
console.log(currentTempo, parseInt(tempo))
const determineIfActive = () => {
if (currentTempo === parseInt(tempo)) {
return <ListGroup.Item as="li" className="song-name" active onClick={() => clickHandler('custom', tempo)} >
{songName} ({tempo} BPM)
</ListGroup.Item>
} else {
return <ListGroup.Item as="li" className="song-name" onClick={() => clickHandler('custom', tempo)} >
{songName} ({tempo} BPM)
</ListGroup.Item>
}
}
return (
<>
<ListGroup as="ul" defaultActiveKey="#link1">
{determineIfActive()}
</ListGroup>
</>
)
}
export default SavedTempos
|
import React from 'react'
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
const SymbolAutoComplete = ({symbol, symbols, onSymbolChange}) => {
return (
<Autocomplete
value={symbol}
freeSolo
className="symbol-input"
options={symbols}
autoHighlight
getOptionLabel={(option) => {
if (option.Name) {
return (option.Symbol)
}
return symbol
}}
style={{
width: 200,
margin: "auto",
borderRadius: 5
}}
renderOption={(option) => {
if (option.Name) {
return (
<div>
<div>{(option.Symbol)}</div>
<div className="company-name"> {option.Name}</div>
</div>
)
}
return (null)
}}
renderInput={(params) => (
<TextField
value={symbol}
required
onChange={onSymbolChange}
{...params}
variant="outlined"
/>
)}
/>
)
}
export default SymbolAutoComplete
|
import React, { useState } from 'react';
import Form from './Form';
import { signUserUp } from '../../../functions/auth';
const INITIAL_VALUES = {email: '', password: '', confirmPassword: ''};
export default function Register() {
const [ values, setValues ] = useState(INITIAL_VALUES);
const [ loading, setLoading ] = useState(false);
const [ alert, setAlert ] = useState(null);
const handleChange = (e) => {
setValues({...values, [e.target.name]: e.target.value});
};
const handleSubmit = (e) => {
e.preventDefault();
setAlert(null);
if (values.password.length < 6)
{return setAlert({status: 'error', message: 'Password must be atleast 6 characters'});}
if (values.password !== values.confirmPassword)
{return setAlert({status: 'error', message: 'Passwords do not match!'});}
setLoading(true);
signUserUp(values)
.then(res => {
setLoading(false);
setValues(INITIAL_VALUES);
setAlert({status: 'success', message: 'Account created succesfully. Proceed to Sign In'});
})
.catch(err => {
setLoading(false);
err.response
? setAlert({status: 'error', message: err.response.data.message})
: setAlert({status: 'error', message: 'Unable to connect to server, try again later'})
});
};
return (
<Form
handleChange={handleChange}
handleSubmit={handleSubmit}
loading={loading}
alert={alert}
values={values}
/>
);
};
|
'use strict';
const config = require('config');
const db = require('../lib/db');
const ObjectId = require('mongodb').ObjectId;
const banks = require('../lib/banks.json');
const tools = require('../lib/tools');
const randomString = require('random-string');
const express = require('express');
const router = new express.Router();
let authorize = (req, res, next) => {
let accessToken = (req.query.access_token || req.headers.access_token || '').toString().trim();
apiAuthorizeToken(req, accessToken, (err, user) => {
if (err) {
return apiResponse(req, res, err);
}
if (!user) {
return apiResponse(req, res, new Error('Invalid or expired token'));
}
req.user = user;
next();
});
};
let requireUser = (req, res, next) => {
if (!req.user || req.user.role === 'client') {
return apiResponse(req, res, new Error('Not allowed'));
}
next();
};
router.get('/', serveAPI);
router.get('/banks', authorize, serveAPIListBanks);
router.get('/project', authorize, serveAPIListProject);
router.get('/project/:project', authorize, serveAPIGetProject);
router.post('/project', authorize, requireUser, serveAPIPostProject);
router.delete('/project/:project', authorize, requireUser, serveAPIDeleteProject);
function serveAPI(req, res) {
let query = {},
hostname = res.locals.hostname,
apiHost = config.apiHost || hostname + '/api';
if (req.user) {
if (req.user.role !== 'admin') {
query.$or = [
{
owner: req.user._id
},
{
authorized: req.user._id
}
];
}
db.find(
'project',
query,
{},
{
sort: [['name', 'asc']],
limit: 10,
skip: 0
},
(err, records) => {
if (err) {
//
}
res.render('index', {
pageTitle: 'API',
page: '/api',
list: records || [],
apiHost,
banks
});
}
);
} else {
res.render('index', {
pageTitle: 'API',
page: '/api',
list: [],
apiHost,
banks
});
}
}
// API related functions
function apiResponse(req, res, err, data) {
let response = {};
if (err) {
response.success = false;
response.error = err.message || err;
if (err.fields) {
response.fields = err.fields;
}
} else {
response.success = true;
response.data = data;
}
res.status(200);
res.set('Content-Type', 'application/json; charset=utf-8');
res.end(JSON.stringify(response, null, ' ') + '\n');
}
function serveAPIListBanks(req, res) {
apiResponse(
req,
res,
false,
Object.keys(banks)
.sort()
.map(bank => ({
type: bank,
name: banks[bank].name
}))
);
}
function serveAPIListProject(req, res) {
let start = Number((req.query.start_index || '0').toString().trim()) || 0;
apiActionList(req, start, (err, list) => {
if (err) {
return apiResponse(req, res, err);
}
apiResponse(req, res, false, list);
});
}
function serveAPIGetProject(req, res) {
let projectId = (req.params.project || '').toString().trim();
apiActionGet(req, projectId, (err, project) => {
if (err) {
return apiResponse(req, res, err);
}
apiResponse(req, res, false, project);
});
}
function serveAPIPostProject(req, res) {
let project;
try {
project = JSON.parse(req.rawBody.toString('utf-8'));
} catch (E) {
return apiResponse(req, res, new Error('Vigane sisend'));
}
apiActionPost(req, project, (err, projectId) => {
if (err) {
return apiResponse(req, res, err);
}
apiActionGet(req, projectId, (err, project) => {
if (err) {
return apiResponse(req, res, err);
}
apiResponse(req, res, false, project);
});
});
}
function serveAPIDeleteProject(req, res) {
let projectId = (req.params.project || '').toString().trim();
apiActionDelete(req, projectId, (err, deleted) => {
if (err) {
return apiResponse(req, res, err);
}
apiResponse(req, res, false, deleted);
});
}
function apiAuthorizeToken(req, accessToken, callback) {
accessToken = (accessToken || '').toString().trim();
if (!accessToken.match(/^[a-fA-F0-9]+$/)) {
return callback(new Error('Vigane API võti'));
}
db.findOne(
'user',
{
token: accessToken
},
callback
);
}
function apiActionGet(req, projectId, callback) {
projectId = (projectId || '').toString().trim();
if (!projectId.match(/^[a-fA-F0-9]{24}$/)) {
return callback(new Error('Vigane makselahenduse identifikaator'));
}
db.findOne(
'project',
{
_id: new ObjectId(projectId)
},
(err, project) => {
let responseObject = {};
if (err) {
return callback(err || new Error('Andmebaasi viga'));
}
if (!project) {
return callback(new Error('Sellise identifikaatoriga makselahendust ei leitud'));
}
if (!tools.checkAuthorized(req, project)) {
return callback(new Error('Sul ei ole õigusi selle makselahenduse kasutamiseks'));
}
responseObject.id = project._id.toString();
responseObject.client_id = project.uid.toString();
responseObject.payment_url = 'https://' + config.hostname + '/banklink/' + project.bank;
responseObject.type = project.bank;
responseObject.name = project.name || undefined;
responseObject.description = project.description || undefined;
if (banks[project.bank].type === 'ipizza') {
responseObject.account_owner = project.ipizzaReceiverName || undefined;
responseObject.account_nr = project.ipizzaReceiverAccount || undefined;
}
if (['ipizza', 'ec'].indexOf(banks[project.bank].type) >= 0) {
responseObject.key_size = project.keyBitsize || undefined;
responseObject.private_key = project.userCertificate.clientKey;
responseObject.bank_certificate = project.bankCertificate.certificate;
}
if (banks[project.bank].type === 'ec') {
responseObject.return_url = project.ecUrl || undefined;
}
if (banks[project.bank].type === 'solo') {
responseObject.mac_key = project.secret || undefined;
responseObject.algo = project.soloAlgo || undefined;
responseObject.auto_response = !!project.soloAutoResponse;
}
if (['aab', 'samlink'].indexOf(banks[project.bank].type) >= 0) {
responseObject.mac_key = project.secret || undefined;
responseObject.algo = project.soloAlgo || 'md5';
}
return callback(null, responseObject);
}
);
}
function apiActionList(req, start, callback) {
start = start || 0;
let query = {};
if (req.user.role !== 'admin') {
query.$or = [
{
owner: req.user._id
},
{
authorized: req.user._id
}
];
}
db.database.collection('project').countDocuments(query, (err, total) => {
if (err) {
//
}
if (start > total) {
start = Math.floor(total / 20) * 20;
}
if (start < 0) {
start = 0;
}
db.find(
'project',
query,
{
_id: true,
name: true,
bank: true
},
{
sort: [['created', 'desc']],
limit: 20,
skip: start
},
(err, records) => {
if (err) {
return callback(err);
}
let list = [].concat(records || []).map(record => ({
id: record._id.toString(),
name: record.name || undefined,
type: record.bank
}));
callback(null, {
total,
start_index: start,
end_index: start + list.length - 1,
list
});
}
);
});
}
function apiActionPost(req, project, callback) {
let validationErrors = {},
error = false;
project.type = (project.type || '').toString().trim();
project.name = (project.name || '').toString().trim();
project.description = (project.description || '').toString().trim();
project.account_owner = (project.account_owner || '').toString().trim();
project.account_nr = (project.account_nr || '').toString().trim();
project.key_size = Number(project.key_size) || 1024;
project.return_url = (project.return_url || '').toString().trim();
project.algo = (project.algo || '').toString().toLowerCase().trim();
if (typeof project.auto_response === 'string') {
project.auto_response = project.auto_response.toLowerCase().trim() === 'true';
} else {
project.auto_response = !!project.auto_response;
}
if (!project.name) {
error = true;
validationErrors.name = 'Makselahenduse nimetuse täitmine on kohustuslik';
}
if (!banks[project.type]) {
error = true;
validationErrors.type = 'Panga tüüp on valimata';
}
if (project.key_size && [1024, 2048, 4096].indexOf(project.key_size) < 0) {
error = true;
validationErrors.key_size = 'Vigane võtme pikkus';
}
if (project.type === 'nordea' && (!project.algo || ['md5', 'sha1', 'sha256'].indexOf(project.algo) < 0)) {
error = true;
validationErrors.algo = 'Vigane algoritm';
}
if (project.type === 'ec' && (!project.return_url || !tools.validateUrl(project.return_url))) {
error = true;
validationErrors.return_url = 'Vigane tagasisuunamise aadress, peab olema korrektne URL';
}
if (project.type !== 'nordea') {
project.algo = '';
project.auto_return = false;
}
if (project.type !== 'ec') {
project.return_url = '';
}
if (error) {
error = new Error('Andmete valideerimisel ilmnesid vead');
error.fields = validationErrors;
return callback(error);
}
tools.generateKeys(req.user, 20 * 365, Number(project.key_size) || 1024, (err, userCertificate, bankCertificate) => {
if (err) {
return callback(new Error('Sertifikaadi genereerimisel tekkis viga'));
}
let record = {
name: project.name,
description: project.description,
owner: req.user._id,
keyBitsize: project.key_size,
soloAlgo: project.algo,
soloAutoResponse: !!project.auto_response,
bank: project.type,
ecUrl: project.return_url,
authorized: tools.processAuthorized(''),
ipizzaReceiverName: project.account_owner,
ipizzaReceiverAccount: project.account_nr,
created: new Date(),
userCertificate,
bankCertificate,
secret: randomString({
length: 32
})
};
tools.incrIdCounter((err, id) => {
if (err) {
return callback(new Error('Andmebaasi viga'));
}
if (['tapiola', 'alandsbanken', 'handelsbanken', 'aktiasppop'].indexOf(req.body.bank) >= 0) {
record.uid = (10000000 + Number(tools.getReferenceCode(id))).toString();
} else {
record.uid = 'uid' + (tools.getReferenceCode(id) || '0');
}
db.save('project', record, (err, id) => {
if (err) {
return callback(new Error('Andmebaasi viga'));
}
if (id) {
return callback(null, id.toString());
} else {
return callback(new Error('Makselahenduse loomine ebaõnnestus'));
}
});
});
});
}
function apiActionDelete(req, projectId, callback) {
projectId = (projectId || '').toString().trim();
if (!projectId.match(/^[a-fA-F0-9]{24}$/)) {
return callback(new Error('Vigane makselahenduse identifikaator'));
}
db.findOne(
'project',
{
_id: new ObjectId(projectId)
},
(err, project) => {
if (err) {
return callback(err || new Error('Andmebaasi viga'));
}
if (!project) {
return callback(new Error('Sellise identifikaatoriga makselahendust ei leitud'));
}
if (!tools.checkAuthorized(req, project)) {
return callback(new Error('Sul ei ole õigusi selle makselahenduse kasutamiseks'));
}
db.remove(
'project',
{
_id: new ObjectId(projectId)
},
err => {
if (err) {
return callback(err);
}
db.remove(
'counter',
{
_id: 'trans:' + project.uid
},
() => {
db.remove(
'payment',
{
project: projectId
},
() => callback(null, true)
);
}
);
}
);
}
);
}
module.exports = router;
|
import React from 'react';
import PropTypes from 'prop-types';
export default function Card({ children }) {
return (
<div className="w-auto rounded overflow-hidden border hover:shadow-lg">
{children}
</div>
);
}
Card.propTypes = {
children: PropTypes.element.isRequired,
};
|
const User = require('../../models/user.js')
// Setting Cookies
const authUser = async (req, res, next) => {
const { email, password } = req.body;
// Set Cookie after successful authentication
// Cookies - Client-Side
res.setHeader('set-cookie', 'loggedIn=true');
// Can configure cookies with various options like Max-Age,secured,http only
res.redirect('/home');
}
// Using Sessions to Store Cookies
const registerUser = async (req, res, next) => {
const { name, email, password } = req.body;
// Setting Up session
req.session.loggedIn = true;
res.redirect('/home');
}
// Removing Sessions
const logoutUser = async (req, res, next) => {
req.session.destroy();
res.redirect('/login');
}
module.exports = {authUser,registerUser,logoutUser}
|
const Sequelize = require('sequelize');
const db = new Sequelize('postgres://localhost:5432/puppybook');
const Op = Sequelize.Op;
/**
* Define your models here, or organize them into separate modules.
*/
const Puppy = db.define('puppy', {
name: {
type: Sequelize.STRING,
allowNull: false,
},
imageUrl: {
type: Sequelize.STRING,
defaultValue:
'http://images.shape.mdpcdn.com/sites/shape.com/files/styles/slide/public/puppy-2_0.jpg',
},
likes: {
type: Sequelize.INTEGER,
defaultValue: 1,
},
});
Puppy.prototype.findPackmates = function() {
return Puppy.findAll({
where: {
ownerId: this.ownerId,
id: {
[OP.ne]: this.id,
},
},
});
};
Puppy.prototype.findPopular = function() {
return Puppy.findAll({
where: {
likes: {
[Op.gt]: 4,
},
},
});
};
Puppy.beforeCreate(puppy => {
let nameArr = puppy.name.trim().split(/\s+/);
nameArr.map(str => str[0].toUpperCase + str.substring(1).toUpperCase());
// let firstName = puppy.name.slice(0, puppy.name.indexOf(' ')).toLowerCase();
// let firstcap = firstName[0].toUpperCase();
// let lastName = Puppy.name
// .slice(puppy.name.indexOf(' '), puppy.name.length)
// .toLowerCase();
// let lastcap = lastName[0].toUpperCase();
puppy.name = nameArr.join(' ');
//`${firstcap}${firstName} ${lastcap}${lastName}`;
});
const Owner = db.define('owner', {
name: {
type: Sequelize.STRING,
allowNull: false,
},
});
Owner.beforeCreate(owner => {
let firstName = owner.name.slice(0, owner.name.indexOf(' ')).toLowerCase();
let firstcap = firstName[0].toUpperCase();
let lastName = owner.name
.slice(owner.name.indexOf(' '), owner.name.length)
.toLowerCase();
let lastcap = lastName[0].toUpperCase();
owner.name = `${firstcap}${firstName} ${lastcap}${lastName}`;
});
Puppy.belongsTo(Owner);
Owner.hasMany(Puppy);
module.exports = db;
|
import Menu from "../components/menu";
import AbstractComponent from "../components/abstract-component";
import {ClassesElements} from "../components/config";
export default class MenuController {
constructor(container, onChangeView) {
this._container = container;
this._menu = new Menu();
this._onChange = onChangeView;
this.init();
}
init() {
AbstractComponent.renderElement(this._container, this._menu.getElement());
const onChangeMenu = () => {
const activeMenuItem = this._menu.getElement().querySelector(`input:checked`).id;
this._onChange(activeMenuItem);
};
const onClickMenu = (evt) => {
const target = evt.target;
if (target.closest(`.${ClassesElements.ADD_NEW_TASK_TASK_LABEL}`)) {
this._onChange(`control__task`, `add`);
} else if (target.localName === `input`) {
onChangeMenu(evt);
}
};
this._menu.getElement().addEventListener(`click`, onClickMenu);
}
}
|
describe("Weekly Budgets", () => {
before(() => {
cy.login();
});
beforeEach(() => {
})
it("has a button in the navigation menu", () => {
cy.visit('/');
cy.get('mat-sidenav').as('menu');
cy.get('@menu')
.should("contain", "Weekly Budget");
});
it.only("clicking on the menu item navigates to the WeeklyBudget component", () => {
cy.visit('/');
cy.get('mat-sidenav').as('menu');
cy.get('@menu')
.contains('Weekly Budget')
.click();
cy.contains('weekly-budget works');
})
})
|
export const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
export const logger = value => {
console.log('='.repeat(20))
console.log(JSON.stringify(value, null, 4))
console.log('='.repeat(20))
}
|
import './index.scss';
import $ from 'jquery';
import 'intl-tel-input/build/css/intlTelInput.css';
import 'intl-tel-input';
import uuid from 'uuid/v4';
import Mixin from '../api/mixin.js';
import TimeUtils from '../utils/time.js';
import Msgpack from '../helpers/msgpack.js';
import Snapshot from './snapshot.js';
function Account(router, api, db, bugsnag) {
this.router = router;
this.api = api;
this.db = db;
this.bugsnag = bugsnag;
this.templateOrders = require('./orders.html');
this.itemOrder = require('./order_item.html');
this.mixin = new Mixin(this);
this.msgpack = new Msgpack();
this.snapshot = new Snapshot(api, db, bugsnag);
this.assets = {};
}
Account.prototype = {
hideLoader: function() {
$('.cancel.order.form .submit-loader').hide();
$('.cancel.order.form :submit').show();
$('.cancel.order.form :submit').prop('disabled', false);
},
encode: function (buffer) {
return buffer.toString('base64').replace(/\+/g, '-').replace(/\//g, '_');
},
fetchAsset: function (assetId) {
const self = this;
self.api.mixin.asset(function (resp) {
if (resp.error) {
return;
}
self.db.asset.cacheAssets[resp.data.asset_id] = resp.data;
self.db.asset.saveAsset(resp.data);
}, assetId);
},
fetchAssets: function (callback) {
const self = this;
self.db.prepare(function () {
self.db.asset.fetchAssets(function (assets) {
self.db.asset.cache(assets);
callback();
});
});
},
fetchOrders: function (callback) {
const self = this;
self.fetchAssets(function () {
self.db.order.fetchOrders(function (orders) {
callback(orders);
self.snapshot.syncSnapshots();
});
});
},
orders: function () {
const self = this;
self.fetchOrders(function (orders) {
for (var i = 0; i < orders.length; i++) {
var order = orders[i];
order.trace = uuid().toLowerCase();
order.time = TimeUtils.short(order.created_at);
order.sideLocale = order.side === 'B' ? window.i18n.t('market.form.buy') : window.i18n.t('market.form.sell');
order.sideColor = order.side === 'B' ? 'Buy' : 'Sell';
order.quote = self.db.asset.getById(order.quote_asset_id);
order.base = self.db.asset.getById(order.base_asset_id);
if (order.order_type === 'M' && order.side === 'B') {
order.amount_symbol = order.quote ? order.quote.symbol : '???';
} else {
order.amount_symbol = order.base ? order.base.symbol : '???';
}
if (order.order_type === 'L' && order.price) {
order.price_symbol = order.quote ? order.quote.symbol : '???';
}
if (!order.base) {
self.fetchAsset(order.base_asset_id);
}
}
self.orders = orders;
$('body').attr('class', 'account layout');
$('#layout-container').html(self.templateOrders({
guideURL: require('./cancel_guide.png')
}));
self.orderFilterType = 'L';
self.orderFilterState = 'PENDING';
self.filterOrders();
$('#orders-type').on('change', function() {
self.orderFilterType = $(this).val();
self.filterOrders();
});
$('#orders-status').on('change', function() {
self.orderFilterState = $(this).val();
self.filterOrders();
});
$('.header').on('click', '.nav.back', function () {
self.router.replace('/');
});
if (self.mixin.environment() == undefined) {
$('.nav.power.account.sign.out.button').html('<i class="icon-power"></i>');
$('.header').on('click', '.account.sign.out.button', function () {
self.api.account.clear();
window.location.href = '/';
});
} else {
$('.nav.power.account.sign.out.button').html('<i class="icon-refresh"></i>');
$('.header').on('click', '.account.sign.out.button', function () {
window.localStorage.removeItem('start_snapshots');
window.localStorage.removeItem('end_snapshots');
window.location.reload();
});
}
self.router.updatePageLinks();
});
},
filterOrders: function () {
const type = this.orderFilterType;
const state = this.orderFilterState;
const orders = this.orders.filter(function(order) {
return order.order_type === type && order.state === state;
});
$('#orders-content').html(this.itemOrder({
canCancel: type === 'L' && state === 'PENDING',
orders: orders
}));
this.handleOrderCancel();
},
getCancelOrderAsset: function () {
const oooAssetId = "de5a6414-c181-3ecc-b401-ce375d08c399";
const cnbAssetId = "965e5c6e-434c-3fa9-b780-c50f43cd955c";
const nxcAssetId = "66152c0b-3355-38ef-9ec5-cae97e29472a";
const candyAssetId = "01c46685-f6b0-3c16-95c1-b3d9515e2c9f";
const cancelAssets = [oooAssetId, cnbAssetId, nxcAssetId, candyAssetId];
for (var i = 0; i < cancelAssets.length; i++) {
const asset = this.db.asset.getById(cancelAssets[i]);
if (asset && parseFloat(asset.balance) > 0.00000001) {
return asset;
}
}
return undefined;
},
handleOrderCancel: function () {
const self = this;
$('.orders.list .cancel.action a').click(function () {
var item = $(this).parents('.order.item');
const orderId = $(item).attr('data-id');
const traceId = $(item).attr('trace-id');
const asset = self.getCancelOrderAsset();
if (!asset) {
self.api.notify('error', window.i18n.t('orders.insufficient.balance'));
return;
}
const msgpack = require('msgpack5')();
const uuidParse = require('uuid-parse');
const memo = self.encode(msgpack.encode({"O": uuidParse.parse(orderId)}));
var redirect_to;
var url = 'pay?recipient=' + ENGINE_USER_ID + '&asset=' + asset.asset_id + '&amount=0.00000001&memo=' + memo + '&trace=' + traceId;
if (self.mixin.environment() == undefined) {
redirect_to = window.open("");
}
self.created_at = new Date();
clearInterval(self.paymentInterval);
var verifyTrade = function() {
self.api.mixin.verifyTrade(function (resp) {
if ((new Date() - self.created_at) > 60 * 1000) {
if (redirect_to != undefined) {
redirect_to.close();
}
window.location.reload();
return
}
if (resp.error) {
return true;
}
for (var i = 0; i < self.orders.length; i++) {
var order = self.orders[i];
if (order.order_id === orderId) {
order.state = 'DONE';
break;
}
}
self.db.order.canceledOrder(orderId);
self.snapshot.syncSnapshots();
$(item).fadeOut().remove();
const data = resp.data;
if (redirect_to != undefined) {
redirect_to.close();
}
clearInterval(self.paymentInterval);
}, traceId);
}
self.paymentInterval = setInterval(function() { verifyTrade(); }, 3000);
if (self.mixin.environment() == undefined) {
redirect_to.location = 'https://mixin.one/' + url;
} else {
window.location.replace('mixin://' + url);
}
});
}
};
export default Account;
|
#!/usr/bin/env node
"use strict";
exports.__esModule = true;
require("colors");
var cli = require("cli");
var http = require("http");
var statusBar = require("status-bar");
var scanner_1 = require("./scanner");
var options = cli.parse({
os: ['o', 'The desired OS to work with', 'string', 'darwin'],
version: ['v', 'The desired version of LLVM', 'string', null],
binary: ['b', 'The desired binary for the version of LLVM', 'string', null],
dir: ['d', 'The desired installation directory for LLVM', 'string', '~/.llvm/'],
scan: ['s', 'Scan all available versions'],
scanv: ['sv', 'Scan a specific version for packages', 'string', null],
install: ['i', 'Specifies that you are trying to install a binary']
});
if (options['scan']) {
scanner_1.scanner()
.then(function (options) {
console.log(options.formattedResponse);
})["catch"](function (err) {
console.log(("" + err).red);
});
}
else if (options['scanv'] != null) {
scanner_1.scannerVersion(options['scanv'])
.then(function (response) {
console.log(response.formattedResponse);
})["catch"](function (err) {
console.log(("" + err).red);
});
}
else if (options['install'] != null) {
scanner_1.downloadBinary(options['version'], parseInt(options['binary'])).then(function (response) {
console.log(response.formattedResponse);
var url = 'http://releases.llvm.org/' + response.selectedBinary.url;
var bar;
http.get(url, function (res) {
bar = statusBar.create({ total: res.headers['content-length'] })
.on('render', function (stats) {
process.stdout.write(this.format.storage(stats.currentSize) + ' ' +
this.format.speed(stats.speed) + ' ' +
this.format.time(stats.elapsedTime) + ' ' +
this.format.time(stats.remainingTime) + ' [' +
this.format.progressBar(stats.percentage) + '] ' +
this.format.percentage(stats.percentage));
process.stdout.cursorTo(0);
});
res.pipe(bar);
})
.on('close', function () { return [
console.log(("\n\nFinished downloading " + response.selectedBinary['title'] + ", it should appear in your downloads folder.\n").green)
]; })
.on('error', function (err) {
if (bar)
bar.cancel();
console.error(("" + err).red);
});
})["catch"](function (err) {
console.log(("" + err).red);
});
}
|
import Head from 'next/head'
import React, { useState, useEffect } from 'react';
import styles from '../styles/Main.module.css'
export default function Home() {
const [ipsumDat, setIpsumDat] = useState([]);
const [hasError, setHasError] = useState(false);
const [values, setValues] = useState({count: 5, includeQuotes: true});
const [paragraphs, setParagraphs] = useState([]);
const handleInputChange = e => {
const {name} = e.target;
const data = e.target.type == "checkbox" ? e.target.checked : e.target.value;
setValues({...values, [name]: data});
}
const getRandomInt = (max) => {
return (Math.floor(Math.random() * Math.floor(max)));
}
const generate = e => {
let paragraphs = [];
for (let i = 0; i < values.count; i++) {
let paragraph = "";
const sentences = getRandomInt(10);
sentences = sentences < 3 ? 3: sentences;
for (let s = 0; s < sentences; s++) {
if (values.includeQuotes && getRandomInt(10) < 3) {
paragraph += ipsumDat.quotes[getRandomInt(ipsumDat.quotes.length)];
paragraph += " ";
} else {
let sentence = "";
let words = getRandomInt(10);
words = words < 5 ? 5 : words;
for(let w = 0; w < words; w++){
sentence += ipsumDat.words[getRandomInt(ipsumDat.words.length)]
sentence += " ";
}
sentence = sentence.replace(/\s+$/, '') + '. ';
paragraph += sentence;
}
}
paragraphs[i] = paragraph;
}
if (paragraphs.length > 0) {
paragraphs[0] = "Lorem ipsum " + paragraphs[0];
}
setParagraphs(paragraphs);
}
useEffect(() => {
fetch("/ipsum.json")
.then(res => res.json())
.then(jsonData => setIpsumDat(jsonData))
.catch(err => {
console.log(err);
setHasError(true)
})
} , [])
if (hasError) {
return <div>
Oh Snap! Something unexpected happened. Please try again;
</div>
}
return (
<div>
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Tesla Ipsum</title>
<meta name="description" content="Tesla focused Lorem Ipsum Generator. Tesla Ipsum filler."/>
</Head>
<div className={styles.content}>
<header className={styles.header} role="img" aria-label="Tesla Model 3 Cars">
<h1><a href="#" id="logo">TESLA IPSUM</a></h1>
</header>
<div className={styles.main}>
<article>
<div className={styles.formContainer}>
<div >
Paragraphs
</div>
<div >
<input type="number" min="1" max="10" value="5"
name="count"
onChange={handleInputChange}
value={values.count} />
</div>
<div >
Musk Quotes?
</div>
<div >
<input type="checkbox" name="includeQuotes"
onChange={handleInputChange}
checked={values.includeQuotes} />
</div>
<div></div>
<div >
<button className="button small" onClick={generate}>Generate</button>
</div>
</div>
{paragraphs.length > 0 &&
<div>
{paragraphs.map( (p, i) => {
return <p key={i}>{p}</p>
})}
</div>
}
</article>
<nav className={styles.nav}></nav>
<aside className={styles.aside}></aside>
</div>
</div>
<footer className={styles.footer}>
<div>
Starguy Software © {new Date().getFullYear()}
</div>
</footer>
</div>
)
}
|
"use strict";
let sum = 0;
for (let key in salaries) {
return (sum += salaries[key]);
}
|
import React, { Component, useEffect, useState } from "react";
import Select from "react-select";
import makeAnimated from "react-select/animated";
import ResumeSuggestion from "./ResumeSuggestion";
const skillsRef = [
{ value: "reactJS", label: "reactJS" },
{ value: "javascript", label: "javascript" },
{ value: "ExpressJS", label: "ExpressJS" },
{ value: "MongoDB", label: "MongoDB" },
{ value: "PosteGreSQL", label: "PosteGreSQL" },
{ value: "Python", label: "Python" },
{ value: "Procedures", label: "Procedures" },
{ value: "C++", label: "C++" },
{ value: "Java", label: "Java" },
{ value: "Database", label: "Database" },
{ value: "GIT", label: "GIT" },
{ value: "Linux", label: "Linux" },
{ value: "Web Services", label: "Web Services" },
{ value: "API", label: "API" },
{ value: "Jenkins", label: "Jenkins" },
{ value: "CSS", label: "CSS" },
{ value: "Scrum", label: "Scrum" },
{ value: "Vue", label: "Vue" },
{ value: "Go", label: "Go" },
{ value: "Ruby", label: "Ruby" },
{ value: "C", label: "C" },
{ value: "C#", label: "C#" },
];
// const options2 = [
// { value: "Experience", label: "Experience" },
// { value: "Education", label: "Education" },
// ];
const animatedComponents = makeAnimated();
export default function SidePanel(props) {
const [suggestions, updateSuggestions] = useState([]);
const [selectedSkills, updateSelectedSkills] = useState([]);
// const skillsRef = props.resume.skills;
function onChangeInput(value) {
const newSkillSelection = [];
for (let i = 0; i < value.length; i++) {
console.log(value[i].value);
newSkillSelection.push(value[i].value);
}
console.log(props.resume);
updateSelectedSkills(newSkillSelection);
const newSuggestions = [];
for (let i = 0; i < props.resume.suggestedjobs.length; i++) {
console.log(newSkillSelection);
console.log(props.resume.suggestedjobs[i].skills);
if (
newSkillSelection.some((el) =>
props.resume.suggestedjobs[i].skills.includes(el)
)
) {
newSuggestions.push(
<ResumeSuggestion
key={i}
id={i}
entryName={props.resume.suggestedjobs[i].entryName}
dates={props.resume.suggestedjobs[i].dates}
content={props.resume.suggestedjobs[i].content}
addToResume={props.addToResume}
hideSuggestion={props.hideSuggestion}
/>
);
}
}
console.log(newSuggestions);
updateSuggestions(newSuggestions);
}
return props.trigger ? (
<div className="sidePanel">
<div className="sidePanelMain">
<div className="line" id="sidePanelTop">
<h1> Resume Generator </h1>
<button
id="sidePanelToggle"
onClick={() => props.setTrigger(false)}
className="sidePanelToggle"
>
X
</button>
</div>
<div className="line">
<div className="TechnologySelect">
<Select
closeMenuOnSelect={false}
placeholder="Select Technologies..."
components={animatedComponents}
// defaultValue={["one", "two"]}
isMulti
options={skillsRef}
onChange={onChangeInput}
/>
</div>
</div>
<div className="entrySelection">
{/* <div className="selectTypeOfEntry">
<Select placeholder="Select type of entry..." options={options2} />
</div> */}
<div className="entriesToSelect">{suggestions}</div>
</div>
</div>
<div className="bottomLine">
<button className="exportPDF">Export as PDF</button>
<button className="exportDOCX">Export as DOCX</button>
</div>
</div>
) : (
""
);
}
|
module.exports = {
theme: {
extend: {
fontFamily: {
display: ['Roboto', 'sans-serif'],
body: ['Graphik', 'sans-serif'],
titel: ['Dancing Script', 'serif'],
} ,
colors: {
rood: '#FB6453' ,
beige: '#FFF9F6' ,
donkerbeige: '#F3D8D0' ,
}
},
},
variants: {},
plugins: [],
}
|
import { html } from "../../../web_modules/htm/preact.js";
import createInitScript from "../../utils/createInitScript.js";
function BasePage(props) {
const { children, head, page, pageProps, debug } = props;
const initScript = createInitScript({ page, pageProps, debug });
return html`
<html lang="en">
<head>
${head}
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
crossorigin="anonymous"
/>
</head>
<body>
${children}
<script
type="module"
dangerouslySetInnerHTML="${{ __html: initScript }}"
/>
</body>
</html>
`;
}
export default BasePage;
|
// 환율 계산기
var exchangeRate = 1117.9;
function wonToUS(won) {
return won/exchangeRate;
}
function USToWon(us) {
return us*exchangeRate;
}
// 함수 노출시키기
exports['wonToUS'] = wonToUS;
exports['USToWon'] = USToWon;
|
export default class ServerError extends Error{
statusCode = 500;
}
|
import styles from './Analysis.less';
import React from 'react';
import {message,Card} from 'antd';
import CurveChart from '../../component/SimpleChart/CurveChart';
import CricleListChart from '../../component/SimpleChart/CricleListChart';
import WorldMap from '../../component/SimpleChart/WorldMap';
class Analysis extends React.Component{
constructor(props){
super(props);
}
state={
curveChart:[],
waterWave:[],
}
componentDidMount(){
fetch('/chart/getCurveChart')
.then(res=>res.json())
.then(data=>{
message.success('success')
this.setState({curveChart:data})
})
fetch('/get/pay/conversion/rate')
.then(res=>res.json())
.then(data=>{
this.setState({waterWave:data})
})
}
render(){
return (
<div className={styles.pageContent} style={{minHeight:'800px',minWidth:'900px'}}>
<Card
title="AQI级别分布图"
extra={<a href="#">了解更多</a>}
className={styles.curveChartStyle}
>
<WorldMap/>
</Card>
</div>)}
}
export default Analysis;
|
// Yon need to return an array containing the keys of an object
// whose value's square root is an integer.
// SOLUTION 1
function squareRootIntegerKeys(obj) {
let keys = Object.keys(obj);
let final = [];
for (let letter in obj) {
obj[letter] = Math.sqrt(obj[letter]);
}
let arr = Object.values(obj).filter((v) => Number.isInteger(v));
for (let i = 0; i < arr.length; i++) {
keys.forEach((k) => {
if (obj[k] === arr[i]) return final.push(k);
});
}
return final;
}
// SOLUTION 2
function squareRootIntegerKeys(obj) {
const entries = Object.entries(obj);
const result = [];
entries.forEach((el) => {
const square = Math.sqrt(el[1]);
if (Number.isInteger(square)) {
result.push(el[0]);
}
});
return result;
}
console.log(squareRootIntegerKeys({ a: 9, b: 52, c: 4 })); // ['a', 'c']
console.log(squareRootIntegerKeys({ a: 18, b: 81, c: 65, d: 144, e: 100 })); // ['b', 'd', 'e']
|
function get_dublin_bikes() {
try {
var response = UrlFetchApp.fetch("http://api.citybik.es/v2/networks/dublinbikes");
var data = JSON.parse(response.getContentText());
var result = [];
result.push(["Station Name", "Parking Spots Available", "Bikes Available", "Last Check"]);
for (elem in data.network.stations){
var date = new Date(data.network.stations[elem].extra.last_update);
var last_update = date.toTimeString();
result.push([data.network.stations[elem].name, data.network.stations[elem].empty_slots, data.network.stations[elem].free_bikes, date]);
}
return result;
} catch (err) {
return "Something went wrong!";
}
}
|
import axios from 'axios';
export function displayError() {
return { type: 'DISPLAY_ERROR' }
}
export function onChangeCepInput(e) {
return { type: 'ON_CHANGE_CEP_INPUT', payload: e.target.value };
}
export function buscaCep(){
return function (dispatch, getState) {
let { cep } = getState().cepReducer;
let url = `http://viacep.com.br/ws/${cep}/json/`;
dispatch({
type:'LOADING'
});
axios.get(url)
.then((response) => {
dispatch({
type:'DISPLAY_CEP',
payload: response.data
});
}).catch((error) => {
dispatch({
type: 'DISPLAY_ERROR',
payload: error.response
});
})
}
}
|
import React, { useState, useEffect, useRef } from "react";
import { IoTimerOutline } from "react-icons/io5";
import { Button, Row, Col } from "react-bootstrap";
import { useDispatch } from "react-redux";
import NavbarBackMolecule from "../molecules/NavbarBackMolecule";
import MyDate from "../common/MyDate";
export default ({ author }) => {
return (
<>
<div className="d-flex justify-content-between align-items-center">
<div>
<div
style={{ width: "40px", height: "40px", borderRadius: "100%" }}
className="my_bg_light"
></div>
</div>
<div>
<div className="my_font_size_md">{author}</div>
<div className="my_font_size_sm">2.5 million followers</div>
</div>
<div>
<Button size="sm" variant="dark">
Follow
</Button>
</div>
</div>
</>
);
};
|
const cp = process.cwd() + "/Controllers/";
const history = require(cp + "siswa/HistoryController");
module.exports = function(fastify, opts, next) {
fastify.post('/history/pengajuan',{
preValidation: [fastify.auth]
}, history.index);
fastify.get('/history/:status',{
preValidation: [fastify.auth]
}, history.history);
fastify.get('/history_guru/:id',{
preValidation: [fastify.auth]
}, history.history_guru);
fastify.get('/history_siswa/:id',{
preValidation: [fastify.auth]
}, history.history_siswa);
fastify.delete('/history/destroy/:id',{
preValidation: [fastify.auth]
}, history.destroy);
fastify.get('/history_detail_siswa/:id',{
preValidation: [fastify.auth]
}, history.history_detail_siswa);
fastify.get('/history_detail_guru/:id',{
preValidation: [fastify.auth]
}, history.history_detail_guru);
fastify.get('/history/detail_history/:id',{
preValidation: [fastify.auth]
}, history.detail_history);
fastify.get('/history/terima/:id',{
preValidation: [fastify.auth]
}, history.terima);
fastify.post('/history/tolak',{
preValidation: [fastify.auth]
}, history.tolak);
fastify.post('/history/batalkan',{
preValidation: [fastify.auth]
}, history.batalkan);
fastify.get('/history/selesai/:id',{
preValidation: [fastify.auth]
}, history.selesai);
next();
};
|
app.filter('celsius', function() {
return function(temp){
return ((temp - 32) * (5/9)).toPrecision(2) + '\xB0' + 'c';
}
})
|
const run = function() {
console.log('loading');
// Service worker for Progressive Web App
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('/serviceWorker.js', {
scope: '.' // THIS IS REQUIRED FOR RUNNING A PROGRESSIVE WEB APP FROM A NON_ROOT PATH
})
.then(
function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
},
function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
}
);
}
};
window.addEventListener('load', run);
|
import React from 'react';
import Link from 'next/link';
const footer = () => {
return (
<div>
<div className="bg-red-700">
<div className="p-20 mx-20 hidden md:block">
<div className="mb-2">
<Link href="/"><a href="/"><img src="/images/LogoWhite.png" alt="logo" /></a></Link>
</div>
<div className="flex">
<div className="w-3/12">
<p className="text-lg text-white">Your trusted partner in your journey to Canada</p>
<div className="flex justify-start space-x-6 mt-6">
<a target="_blank" href="https://www.facebook.com/Enlightenconsultancyservices"><img className="w-6 h-6" src="/images/Stock/FooterIcons/FB.png" alt="fb" /></a>
<a target="_blank" href="#"><img className="w-6 h-6" src="/images/Stock/FooterIcons/IG.png" alt="instagram" /></a>
<a target="_blank" href="#"><img className="w-6 h-6" src="/images/Stock/FooterIcons/IN.png" alt="linkedin" /></a>
</div>
</div>
<div className="w-2/12 flex flex-col ml-4">
<Link href="/about-us"><a className="text-white border-l-4 border-white text-md py-0.5 px-2 font-normal mb-6" href="/about-us">About</a></Link>
<Link href="/services"><a className="text-white border-l-4 border-white text-md py-0.5 px-2 font-normal mb-6" href="/services">Services</a></Link>
<Link href="/contact-us"><a className="text-white border-l-4 border-white text-md py-0.5 px-2 font-normal mb-6" href="/contact-us">Contact</a></Link>
</div>
<div className="w-3/12">
<div className="flex">
<img className="w-6 h-6" src="/images/Stock/FooterIcons/Location.png" alt="location" />
<div className="text-white ml-2">
<h1 className="text-lg">Visit Us</h1>
<p>236 2/1, Main Road, Attidiya, Dehiwala, Sri Lanka</p>
</div>
</div>
<div className="flex mt-4">
<img className="w-6 h-6" src="/images/Stock/FooterIcons/Call.png" alt="call" />
<div className="text-white ml-2">
<h1 className="text-lg">Call Us</h1>
<p>+94 77 399 6502</p>
<p>+94 77 309 8918</p>
</div>
</div>
<div className="flex mt-4">
<img className="w-6 h-6" src="/images/Stock/FooterIcons/Email.png" alt="email" />
<div className="text-white ml-2">
<h1 className="text-lg">Email Us</h1>
<p>info @enlightensl.com</p>
</div>
</div>
</div>
<div className="w-4/12">
<h1 className="mb-4"><span className="text-white border-l-4 border-white text-lg py-0.5 px-2 font-normal">Working Hours</span></h1>
<p className="text-white ml-3">Our team is happy to serve you round the clock via appoinment, 24x7. Accordingly, we respond to your queries or documentation needs in less than 24 hours.</p>
<div className="text-white ml-3 mt-2 flex justify-between max-w-md">
<p>Monday to Friday</p>
<p>09:00-18:00</p>
</div>
<div className="text-white ml-3 mt-2 flex justify-between max-w-md">
<p>Saturday</p>
<p>09:00-13:00</p>
</div>
<div className="text-white ml-3 mt-2 flex justify-between max-w-md">
<p>Sunday & holidays</p>
<p>Closed</p>
</div>
</div>
</div>
</div>
</div>
<div className="mx-36 py-4 md:flex justify-between hidden">
<p className="">Copyright © 2021 YNJ Immigration. All rights reserved.</p>
<p className="">Designed and Developed with ❤ from Sri Lanka</p>
</div>
{/* mobile footer */}
<div className="bg-red-700 md:hidden">
<div className="mx-12 p-6">
<div className="flex flex-col justify-center mb-12">
<Link href="/"><a href="/"><img className="h-auto w-auto mx-auto" src="/images/LogoWhite.png" alt="logo" /></a></Link>
<p className="text-center text-white text-lg">Your trusted partner in your journey to Canada</p>
<div className="flex justify-center space-x-4 mt-4">
<a target="_blank" href="https://www.facebook.com/Enlightenconsultancyservices"><img className="w-6 h-6" src="/images/Stock/FooterIcons/FB.png" alt="fb" /></a>
<a target="_blank" href="#"><img className="w-6 h-6" src="/images/Stock/FooterIcons/IG.png" alt="instagram" /></a>
<a target="_blank" href="#"><img className="w-6 h-6" src="/images/Stock/FooterIcons/IN.png" alt="linkedin" /></a>
</div>
</div>
<div className="flex justify-between mb-4">
<Link href="/"><a className="text-white border-l-4 border-white text-lg tracking-wide py-0.5 px-2 font-normal mb-6" href="/about-us">About</a></Link>
<Link href="/services"><a className="text-white border-l-4 border-white text-lg tracking-wide py-0.5 px-2 font-normal mb-6" href="/services">Services</a></Link>
<Link href="/contact-us"><a className="text-white border-l-4 border-white text-lg tracking-wide py-0.5 px-2 font-normal mb-6" href="/contact-us">Contact</a></Link>
</div>
<div className="flex">
<img className="w-8 h-8" src="/images/Stock/FooterIcons/Location.png" alt="location" />
<div className="text-white ml-4">
<h1 className="text-xl">Visit Us</h1>
<p className="text-lg">236 2/1, Main Road, Attidiya, Dehiwala, Sri Lanka</p>
</div>
</div>
<div className="flex mt-8">
<img className="w-8 h-8" src="/images/Stock/FooterIcons/Call.png" alt="call" />
<div className="text-white ml-4">
<h1 className="text-xl">Call Us</h1>
<p className="text-lg">+94 77 399 6502</p>
<p className="text-lg">+94 77 309 8918</p>
</div>
</div>
<div className="flex mt-8">
<img className="w-8 h-8" src="/images/Stock/FooterIcons/Email.png" alt="email" />
<div className="text-white ml-4">
<h1 className="text-xl">Email Us</h1>
<p className="text-lg">info @enlightensl.com</p>
</div>
</div>
</div>
</div>
<div className="flex flex-col text-center py-2 md:hidden">
<p className="text-md leading-8">Copyright © 2021 YNJImmigration. All rights reserved.</p>
<p className="text-md leading-8">Designed and Developed with ❤ from Sri Lanka</p>
</div>
{/* mobile footer end */}
</div>
)
}
export default footer
|
/* $(document).ready(function() {
alert('Подключена последняя версия jQuery через Google хостинг');
});
*/
$(document).ready(function(){
$('a[data-tooltip').mousemove(function (eventObject) {
$(this).attr('data-tooltip');
$("#tooltip").text($data-tooltip)
.css({
"top" : eventObject.pageY + 5,
"left" : eventObject.pageX + 5
})
.show();
}).mouseout(function () {
$("#tooltip").hide()
.text("")
.css({
"top" : 0,
"left" : 0
});
});
});
|
const polka = require("polka");
const morgan = require("morgan");
const {send} = require("./util");
const items = require("./items");
const {PORT = 3000} = process.env;
// init Polka (HTTP) server
polka()
.use(morgan("dev"))
.use("/items", items)
.get("/", (req, res) => {
send(res, "Index");
})
.listen(PORT, err => {
if (err) {
throw err;
}
console.log(`> Ready on localhost:${PORT}`);
});
|
/*
* Author: unscriptable
* Date: Feb 22, 2009
*/
dojo.provide('dojoc.dojocal._base.ViewMixin');
dojo.require('dijit._Templated');
dojo.require('dijit._Widget');
dojo.require('dojo.date');
(function () { // closure for local variables
var djc = dojoc.dojocal;
/**
* dojoc.dojocal._base.ViewMixin
*/
dojo.declare('dojoc.dojocal._base.ViewMixin', dijit._Contained, {
// name: String
// the unique name for this view
name: '',
// selected: Boolean
// set to true to make this the visible view, initially
selected: false,
// timeCellDatePattern: String
// the dojo.date.locale-formatted date string used in the time column on day and week views
timeCellDatePattern: 'h:mm a',
// headerDatePattern: String
// the dojo.date.locale-formatted date string used in the date header, if aplicable
headerDatePattern: 'EEE M/dd',
// cornerCellDatePattern: String
// the dojo.date.locale-formatted date string used in the upper left corner, if applicable
cornerCellDatePattern: 'yyyy',
// allDayEventAreaLabel: String
// the label to show in the "All Day" events area time column, if applicable
allDayEventAreaLabel: 'All Day',
// eventClass: String
// change this property on subclassed views to use your own custom event widgets
eventClass: 'dojoc.dojocal.Event',
// defaultEventClass: String
// a fully-qualified dijit class to be used to create new event widgets
// TODO: use this when auto-creating events from data store? or remove this?
defaultEventClass: 'dojoc.dojocal.Event',
// eventPositionerClass: String
// change this property to create your own event positioner
// see dojoc.dojocal._base.EventPositioner for more info
eventPositionerClass: '',
// eventMoveableClass: String
// change this property to specify a different class to operate teh drag-and-drop
// modification of Event widgets
eventMoveableClass: '',
// minutesPerGridLine: Integer
// number of minutes between horizontal grid lines
minutesPerGridLine: 15,
// userChangeResolution: Integer
// resolution of user changes (e.g. drag and drop) in minutes
// changes smaller than this are rounded up or down
userChangeResolution: 15,
// initialStartTime: Integer
// number of minutes to scroll from midnight when displaying calendar. use 450 for 7:30 AM, 780 for 1:00 PM
initialStartTime: 480,
// transitionDuration: Number
// the duration of any animations used by the grid
transitionDuration: 250,
// date: String
// set this to the dojocal's initial date (ISO-formatted date string)
date: '',
// weekStartsOn: Integer
// the day that weeks should start on
// 0 = sunday, 1 = monday, etc.
// Hint: use dojo.cldr.supplemental.getFirstDayOfWeek() to let this adjust automatically
// to the user's browser locale
weekStartsOn: 0,
// showWeekends: String|Array
// set false to hide weekends
// Hint: use dojo.cldr.supplemental.getWeekend to determine weekend days for the
// user's browser locale
// Warning: setting showWeekends to false and setting weekStartson to something midweek will
// cause multi-day events to display improperly (despite being fully functional)
// TODO: create a new view rather than use this property?
showWeekends: true,
// dndMode: dojoc.dojocal.DndModes
// level of drag and drop:
// dojoc.dojocal.DndModes.NONE -- drag and drop is not enabled
// dojoc.dojocal.DndModes.FLUID -- drag and drop uses a free-form method to allow smoother dragging
// dojoc.dojocal.DndModes.DISCRETE -- drag and drop snaps to valid positions only
dndMode: djc.DndModes.DISCRETE,
// dndDetectDistance: Number
// the distance a user must drag before a drag and drop operation is detected
dndDetectDistance: 3,
// dndFluidSnapThreshold: Integer
// pixels to move before an event widget stops clinging to current day or time (for fluid dnd)
dndFluidSnapThreshold: 25,
// splitterMinHeight: String
// the splitters may not be sized any smaller than this height (unless splitterIsCollapsible == true).
// use any css measurement (except %). e.g. 2.5em, 40px, 24pt, etc.
splitterMinHeight: '2em',
// splitterMaxHeight: String
// the splitters may be opened to this height.
// use any css measurement (except %). e.g. 2.5em, 40px, 24pt, etc.
splitterMaxHeight: '10em',
// splitterIsCollapsible: Boolean
// the splitters will collapse if the user drags them below splitterMinHeight
splitterIsCollapsible: true,
// cascadeAttrMap: Array of String
// these attribute/property names will be copied from the grid to this view
cascadeAttrMap: {date: '', minutesPerGridLine: '', userChangeResolution: '', initialStartTime: '', transitionDuration: '', weekStartsOn: '', showWeekends: '', defaultEventClass: '', dndMode: '', dndDetectDistance: '', dndFluidSnapThreshold: '', splitterMinHeight: '', splitterMaxHeight: '', splitterIsCollapsible: ''},
constructor: function () {
this.attributeMap = dojo.mixin(this.attributeMap, this.cascadeAttrMap);
},
setDate: function (/* Date|String? */ date) {
// summary: sets the current datetime. use dojoc.dojocal.dateOnly, if applicable.
this.date = this._startDate = djc.dateOnly(date);
this._endDate = dojo.date.add(this.date, 'day', 1);
},
getStartDate: function () {
// summary: returns the earliest date at which events show
return this._startDate;
},
getEndDate: function () {
// summary: returns the latest date at which events show
// getEndDate points just past the actual end date of the view, so
// always test getEndDate by using < rather than <=
return this._endDate;
},
setStartOfDay: function (/* Number */ minuteOfDay) {
// summary: scroll the view to the minute of the day given, if applicable.
// minuteOfDay: Number
// the minute of the day. e.g. 450 (min) == 7.5 (hr) * 60 == 7:30 am
// TODO: allow user to pass "auto" to try to scroll as many imminent events into view???
// TODO: FIXME: I don't think this belongs here
//dojo.publish('dojoc.dojocal.' + this.widgetid + '.setStartOfDay', [minuteOfDay]);
},
getStartOfDay: function (/* Boolean? */ exact) {
// summary: returns the minute of the day to which the day and week views are currently scrolled
// (see setStartOfDay)
// exact: set to true to return as precise a result as possible, omit or set to false to return the value
// rounded to the nearest minute
return null; // unsupported in mixin
},
isEventViewable: function (/* UserEvent */ event) {
// summary: returns true if the given event falls within this view (even if just partially)
},
addEvent: function (/* dojoc.dojocal._base.EventMixin */ event) {
// summary: adds the specified event into this view
},
addEvents: function (/* Array of dojoc.dojocal._base.EventMixin */ events) {
// summary: adds the specified events into this view
},
removeEvent: function (/* dojoc.dojocal._base.EventMixin */ event) {
// summary: adds the specified event into this view
},
clearEvents: function () {
// summary: removes all events in the view
},
// beginUpdate: function () {
// this._updateCount++;
// },
//
// endUpdate: function () {
// this._updateCount--;
// },
//
// isUpdating: function () {
// return this._updateCount > 0;
// },
updateTimeOfDay: function () {
// stub
},
/* private properties */
_updateCount: 0
});
})(); // end of closure for local variables
|
import axios from 'axios';
const baseURL = process.env.REACT_APP_BASE_URL;
const login = async body => {
const result = await axios.post(`${baseURL}/api/login`, body);
return result.data;
};
export { login };
|
'use strict';
angular
.module('musicApp')
.component('gridComponent', {
templateUrl: 'src/app/grid/grid-component-template.html',
controller: ['$http', function($http) {
var self = this;
self.setDefaultField = function() {
self.search_field = "composer"; //default
}
$http.get('./music_data.json') // the JSON file CANNOT contain comments for this to work properly
.success(function(data) {
console.log(data);
self.pieces = data;
})
self.info = 'this is some dynamic info generated by a controller within a component'
self.greet = function() {
//self.setDefaultField();
alert(self.search_field);
}
}]
});
|
import React, { useState, useRef, useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import styled from 'styled-components'
import { postSongs } from '../actions/actions'
import { XIcon } from './active_svgs'
import { ent_act, error_act } from '../reducers/root_reducer';
export const ytdlAPI = "https://9fm8fonkk8.execute-api.us-west-1.amazonaws.com/test/"
const SearchBoxDiv = styled.form`
width: min(90%, 400px); ;
height: 30px;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
border: 1px solid ${props => `${props.focus ? '#ad0f37' : 'rgba(120,120,120,0.5)'}`};
border-radius: 15px;
z-index:5;
display:flex;
flex-direction:row;
justify-content:center;
align-items:center;
input[type=text].searchbox {
margin-left:15px;
width: 100%;
overflow-x: hidden;
border: 0;
outline: none;
}
div.xholder {
width:22px;
height:22px;
margin-right:10px;
}
svg {
margin-right:10px;
cursor: pointer;
}
`
export default function SearchBox() {
const tboxRef = useRef(null)
const dispatch = useDispatch()
const playlistD = useSelector(state => state.entities.playlistD)
const [urls, setUrls] = useState(playlistD.search_term);
const [focus, setFocus] = useState(false);
useEffect(() => {
tboxRef.current.focus();
}, [])
const submitSong = async e => {
e.preventDefault();
dispatch({ type: ent_act.SET_LOAD_START})
tboxRef.current.blur();
const errorsArr = []
// scrape youtube songs
if (urls[0] == '+') {
const urlsArray = urls ? urls.split(" ").filter(ent => ent) : []//filter blank lines
const songs = await Promise.all(
urlsArray.map(async url => {
// console.log('querying:' + rl)
const resp = await fetch(ytdlAPI + '?add=' + url)
const json = await resp.json();
if (!resp.ok) {
errorsArr.push(json)
// console.log("fail")
}
return json
})
)
const ytFiles = songs.map(ent => [ent.Key, ent.yt_id]).filter(ent => ent[0]) //filter failed reqs
if (ytFiles.length) dispatch(postSongs(ytFiles))
if (errorsArr.length) {
dispatch({ type: error_act.RECEIVE_SEARCH_ERRORS, errors: errorsArr })
} else {
dispatch({ type: error_act.RECEIVE_SEARCH_ERRORS, errors: [] })
setUrls('')
}
} else {
// console.log('querying:' + rl)
const resp = await fetch(ytdlAPI + '?add=' + urls)
const json = await resp.json();
if (!resp.ok) {
errorsArr.push(json)
dispatch({ type: error_act.RECEIVE_SEARCH_ERRORS, errors: json })
} else {
const search_results = json.map(e => ({ id: e.id, title: e.title, type: e.type, url: e.url })).filter(e => e.type === "video" || e.type === "playlist")
dispatch({ type: ent_act.RECEIVE_SEARCH_RESULTS, search_term: urls, search_results })
}
}
dispatch({ type: ent_act.SET_LOAD_STOP})
}
function onTextChange(e) {
const tbox = tboxRef.current;
setUrls(tbox.value)
}
return (
<SearchBoxDiv onSubmit={submitSong}
onClick={(e) => e.stopPropagation()}
focus={focus}
>
<input
className="searchbox"
autoComplete="on"
type="text"
value={urls}
placeholder="Search song, album, artist"
onChange={onTextChange}
onFocus={() => setFocus(true)}
onBlur={() => setFocus(false)}
wrap="off"
ref={tboxRef}
/>
<div className='xholder' onClick={e => {
dispatch({ type: ent_act.CLEAR_SEARCH_RESULTS })
setUrls('')
tboxRef.current.focus();
}}>
{urls && urls.length &&
<XIcon {...{ scale: 1, size: "22px" }} />
}
</div>
</SearchBoxDiv>
)
};
|
'use strict';
const greet = module.exports = {};
greet.hi = (str) => {
if(typeof str !== 'string') {
return null;
} if (!str) {
return null;
} return `hello, ${str}`
}
|
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import YouTube from 'react-youtube'
import moment from 'moment'
class Player extends Component {
state = {
loaded: true
}
onReady = () => {
this.setState({ loaded: true })
}
render() {
const opts = {
height: '1080',
width: '1920',
playerVars: {
modestbranding: 1,
rel: 0,
color: 'white',
showinfo: 0,
autoplay: this.props.autoplay
}
}
let embed
let details
if (this.props.video.snippet) {
embed = <YouTube videoId={this.props.videoId} opts={opts} onReady={this.onReady} />
details = (
<div>
<span className="video-title">{this.props.video.snippet.title}</span>
<span className="video-date">
Published on {moment(this.props.video.snippet.publishedAt).format('MMM D, YYYY')}
</span>
<span className="video-description">{this.props.video.snippet.description}</span>
</div>
)
}
return (
<div className={`video video-hero fullwidth ${this.state.loaded ? 'loaded' : 'notloaded'}`}>
<div className="player-container">
<div className="player-wrapper">
<span>Loading video...</span>
{embed}
</div>
</div>
<div className="video-caption">
<div className="video-caption-wrapper">{details}</div>
</div>
</div>
)
}
}
Player.propTypes = {
autoplay: PropTypes.bool,
videoId: PropTypes.string.isRequired,
video: PropTypes.shape({
snippet: PropTypes.shape({
title: PropTypes.string.isRequired,
publishedAt: PropTypes.string.isRequired,
description: PropTypes.string.isRequired
})
}).isRequired
}
Player.defaultProps = {
autoplay: false
}
export default Player
|
import express from "express";
import bodyParser from "body-parser";
//import morgan from "morgan";
import userRoutes from "./server/routes/UserRoutes";
import connectMongo from "./server/config/mongoConnect";
import adminRoutes from "./server/routes/AdminRoutes";
import clientRoutes from "./server/routes/ClientRoutes";
import boardRoutes from "./server/routes/BoardRoutes";
import faceRoutes from "./server/routes/RouteFaceReconize";
import fileUpload from "express-fileupload"
import indexRoutes from "./server/routes/IndexRoute";
import videoRoutes from "./server/routes/VideoRoute";
const path = require('path');
const ejs = require('ejs');
const app = express();
const cors = require('cors');
const http = require('http').Server(app);
//todo: ####################
//todo: Production enviroment
//todo: ####################
const isProduction = process.env.NODE_ENV === "production";
app.use(fileUpload());
app.set('view engine', 'ejs');
app.set('views', './server/views');
//app.use("/public", express.static(path.join(__dirname, 'images')));
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json());
app.use(cors());
//todo: ####################
//todo: Connect Mongo
//todo: ####################
connectMongo().then(() => {
console.log("Connected MongoDB====>");
});
//todo: ####################
//todo: includes Routes
//todo: ####################
app.use("/", userRoutes);
app.use("/", adminRoutes);
app.use("/", clientRoutes);
app.use("/", boardRoutes);
app.use("/", faceRoutes);
app.use("/", indexRoutes);
app.use("/", videoRoutes);
const PORT = process.env.PORT || 8000;
app.listen(PORT, () => {
console.log(`Server is running on isProductionss => ${isProduction ? '프로덕션' : '개발'}`);
console.log(`==========>>>>>>> Server is running on PORT ${PORT}`);
});
// http.listen(PORT, () => {
// console.log(`listening on *:${PORT}`);
// });
|
'use strict';
angular.module('crm')
.controller('ProductChargeTableCtrl',function($scope, data, close, ModalService, DataStorage, SitesSetup, $rootScope) {
$scope.modalTitle = data.modalTitle;
$scope.disallowActions = data.disallowActions;
$scope.productChargeData = angular.copy(data.data.Charges);
$scope.productChargeDataSafe = angular.copy(data.data.Charges);
$scope.closeNotices = false;
$scope.noticeText = false;
var productGroups = [];
var fetchGroups = function(){
DataStorage.productsAnyApi('index/' + data.ClientID).query(function(productsData){
$scope.productChargeData = []
$scope.productChargeDataSafe = []
productGroups = [];
_.each(productsData.GroupsWithCharges, function(gwCharge){
var item = SitesSetup.createItem(gwCharge);
productGroups.push(item);
if (gwCharge.ID == data.data.ID){
$scope.productChargeDataSafe = angular.copy(item.Charges)
$scope.productChargeData = angular.copy(item.Charges)
}
});
});
}
if (!$scope.productChargeData.length) $scope.noticeText = $rootScope.translate('modals.campaigns.products.productchargetablectrl.this-product-does-not-have-charges-yet');
$scope.closeNotice = function () {
$scope.closeNotices = true;
};
$scope.deleteCharge = function (chId) {
ModalService.showModal({
templateUrl: "components/modals/COMMON/sure.html",
controller: "DataModalCtrl",
inputs: {
data: {
modalTitle: $rootScope.translate('modals.campaigns.products.productchargetablectrl.delete-charge'),
modalTxt: $rootScope.translate('modals.campaigns.products.productchargetablectrl.are-you-sure-you-want-to-delete-this-charge?')
}
}
}).then(function (modal) {
modal.element.modal();
modal.close.then(function (result) {
if (result === 'false') return false;
var serverAction = 'deletecharge';
var server = DataStorage.productsAnyApi(serverAction).post({"ChargeID": chId}).$promise;
server.then(
function (result) {
if (result.Status) {
$scope.noticeText = $rootScope.translate('modals.campaigns.products.productchargetablectrl.server-error!') + ' ' + result.ErrorMessage;
$scope.closeNotices = false;
return false;
}
fetchGroups()
$scope.noticeText = $rootScope.translate('modals.campaigns.products.productchargetable.charge-deleted', {value: chId});
$scope.closeNotices = false;
},
function (error) {
$scope.noticeText = $rootScope.translate('modals.campaigns.products.productchargetablectrl.server-error!');
$scope.closeNotices = false;
}
);
return false;
});
});
};
$scope.active = true;
$scope.addEditCharge = function (chargeID) {
var serverAction = chargeID ? 'editcharge/' + chargeID : 'addcharge/' + data.ClientID;
var server = DataStorage.productsAnyApi(serverAction).query().$promise;
server.then(
function (result) {
if (result.Status) {
$scope.noticeText = $rootScope.translate('modals.campaigns.products.productchargetablectrl.server-error!')+' ' + result.ErrorMessage;
$scope.closeNotices = false;
return false;
}
addEditModal(result, chargeID);
},
function (error) {
$scope.noticeText = $rootScope.translate('modals.campaigns.products.productchargetablectrl.server-error!');
$scope.closeNotices = false;
}
);
};
var addEditModal = function (result, chargeID) {
var modalTitle = 'Create Charge';
if (chargeID)
modalTitle = 'Update Charge';
ModalService.showModal({
templateUrl: "components/modals/CAMPAIGNS/products/addEditCharge.html",
controller: "AddEditChargeCtrl",
windowClass: 'big-modal',
inputs: {
data: {
serverData: result,
modalTitle: modalTitle,
ClientID: data.ClientID,
chargeID: chargeID,
productGroup: data.data
}
}
}).then(function (modal) {
modal.element.modal({
backdrop: 'static',
keyboard: false
});
modal.close.then(function (result) {
if (result == 'false') return false;
if (result.Status) {
$scope.noticeText = result.ErrorMessage;
$scope.closeNotices = false;
}else if (result.saved){
fetchGroups()
$scope.noticeText = $rootScope.translate('modals.campaigns.products.productchargetable.charge-saved', {value:result.Name || '' });
$scope.closeNotices = false;
}
return false;
});
});
};
// when you need to close the modal, call close
$scope.close = function() {
close({
productGroups: productGroups
}); // close, but give 500ms for bootstrap to animate
};
});
|
window.onload = function() {
var aInput = document.getElementsByTagName("input");
aInput[1].onclick = function() {
(aInput[0].value == "") ?
alert("请输入数字!"):
alert(/^\d{2}$/.test(parseInt(aInput[0].value)) ? "√ 是两位数":"这是"+aInput[0].value.length+"位数");
}
for (var i = 0; i < aInput.length-1; i++) {
aInput[i].onkeyup = function() {
this.value = this.value.replace(/[^\d]/,"")
}
};
}
|
const preguntas = document.querySelectorAll('.pregunta');
preguntas.forEach((pregunta) => {
pregunta.addEventListener('click', (e) => {
e.currentTarget.classList.toggle('activa');
});
});
|
/**
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
goog.provide('audioCat.audio.junction.effect.PanEffectJunction');
goog.require('audioCat.audio.junction.PanJunction');
goog.require('audioCat.audio.junction.Type');
goog.require('audioCat.audio.junction.effect.EffectJunction');
goog.require('audioCat.state.effect.EffectId');
goog.require('audioCat.state.effect.field.EventType');
goog.require('goog.asserts');
goog.require('goog.events');
/**
* An audio junction that implements an effect for panning left or right.
*
* @param {!audioCat.audio.AudioContextManager} audioContextManager Manages the
* audio context and interfaces with the web audio API in general.
* @param {!audioCat.utility.IdGenerator} idGenerator Generates IDs unique
* throughout the application.
* @param {!audioCat.state.effect.PanEffect} effect The effect.
* @param {!audioCat.audio.AudioUnitConverter} audioUnitConverter Converts
* between various audio units and standards.
* @constructor
* @extends {audioCat.audio.junction.PanJunction}
* @implements {audioCat.audio.junction.effect.EffectJunction}
*/
audioCat.audio.junction.effect.PanEffectJunction = function(
audioContextManager,
idGenerator,
effect,
audioUnitConverter) {
/**
* @private {!audioCat.audio.AudioUnitConverter}
*/
this.audioUnitConverter_ = audioUnitConverter;
var panField = effect.getPanField();
goog.base(
this,
idGenerator,
audioContextManager,
panField.getValue());
/**
* Listeners for changes in various fields of the effect. We maintain the keys
* for these listeners so that we can remove them when we clean up later.
* @private {!Array.<!goog.events.Key>}
*/
this.listeners_ = [
goog.events.listen(panField,
audioCat.state.effect.field.EventType.FIELD_VALUE_CHANGED,
this.handlePanChange_, false, this)
];
};
goog.inherits(audioCat.audio.junction.effect.PanEffectJunction,
audioCat.audio.junction.PanJunction);
/**
* Handles changes in the pan value.
* @param {!goog.events.Event} event The associated event.
* @private
*/
audioCat.audio.junction.effect.PanEffectJunction.prototype.handlePanChange_ =
function(event) {
this.setPan(/** @type {!audioCat.state.effect.field.GradientField} */ (
event.target).getValue());
};
/** @override */
audioCat.audio.junction.effect.PanEffectJunction.prototype.cleanUp =
function() {
for (var i = 0; i < this.listeners_.length; ++i) {
goog.events.unlistenByKey(this.listeners_[i]);
}
goog.base(this, 'cleanUp');
};
|
'use strict';
const context_common = require('../helpers/common.js');
const jsonQuery = require('json-query')
module.exports = {
search(req){
return get_google(req.name,req.location)
}
}
function get_google(name,location){
let retVal=[];
try{
let get_request={
url:'https://maps.googleapis.com/maps/api/place/autocomplete/json?input='+name+'&types=establishment&location='+location+'&radius=500&key=AIzaSyDvPk7IVCdmEVXDHF9urU9DEB-FYnTpkcE'
};
let response=context_common.http.request_get(get_request)
let json;
json=JSON.parse(response);
json.predictions.forEach(function(element) {
let location={
place_id:element.place_id,
description:element.description
};
retVal.push(location);
});
}
catch(e){
console.log("failed to search in google error:"+e )
}
return retVal;
}
|
import React from 'react'
import Template from './CategoryTemplate/CategoryTemplate'
import mobiles from '../../assets/images/mobiles.png'
import sports from '../../assets/images/sports.jpg'
import clothing from '../../assets/images/clothing.jpg'
import furniture from '../../assets/images/furniture.jpg'
import books from '../../assets/images/books.jpg'
import computers from '../../assets/images/computers.jpg'
import { withRouter } from 'react-router-dom'
const categories = (props) => {
let categoryData = {
mobile : {
source : mobiles,
category : "Mobiles"
},
sports : {
source : sports,
category : "Sports"
},
clothing : {
source : clothing,
category : "Clothing"
},
furniture : {
source : furniture,
category : "Furniture"
},
books : {
source : books,
category : "Books"
},
computers : {
source : computers,
category : "Computers"
},
}
let categories =[];
for(let key in categoryData){
categories.push({
source : categoryData[key].source,
category : categoryData[key].category,
id : key
})
}
const categoryClicked = (category) => {
props.history.push({
pathname : '/products',
search : '?category='+category
})
}
return (
<div>
{categories.map(cat => (
<Template clicked={categoryClicked} key={cat.id} source={cat.source} category={cat.category} ></Template>
))}
</div>
)
}
export default withRouter(categories);
|
import {
selectProducts,
changeQuantity,
cancelOrder,
resetStatus,
} from "../actions/actionTypes";
import {
getProductsAPICreator,
postOrderAPICreator,
addProductsAPICreator,
getAllOrderAPICreator,
deleteProductAPICreator,
updateProductAPICreator,
} from "../actions/products";
const initialCart = {
products: [],
productBasedPage: [],
idProductOrdered: [],
productsOrdered: [],
totalPrice: 0,
error: undefined,
statusGet: null,
isPending: false,
isFulFilled: false,
isRejected: false,
statusPost: null,
errorPost: undefined,
isPostPending: false,
isPostFulFilled: false,
isPostRejected: false,
statusGetOrder: null,
dataGetOrder: [],
errorGetOrder: undefined,
isGetOrderPending: false,
isGetOrderFulFilled: false,
isGetOrderRejected: false,
statusAdd: null,
dataAdd: [],
errorAdd: undefined,
isAddPending: false,
isAddFulFilled: false,
isAddRejected: false,
statusDelete: null,
errorDelete: undefined,
isDeletePending: false,
isDeleteFulFilled: false,
isDeleteRejected: false,
statusUpdate: null,
errorUpdate: undefined,
isUpdatePending: false,
isUpdateFulFilled: false,
isUpdateRejected: false,
keyword: "",
};
const productsReducer = (prevState = initialCart, action) => {
switch (action.type) {
case String(getProductsAPICreator.pending):
return {
...prevState,
isPending: true,
};
case String(getProductsAPICreator.fulfilled): {
let status;
let data;
let err;
if (action.payload.status === 200) {
status = 200;
data = action.payload.data;
err = undefined;
} else if (action.payload.status === 500) {
status = 500;
data = [];
err = action.payload.error;
}
let newData = prevState.products.concat(data);
return {
...prevState,
products: newData,
productBasedPage: action.payload.data,
statusGet: status,
error: err,
isPending: false,
isFulFilled: true,
isRejected: false,
};
}
case String(getProductsAPICreator.rejected):
return {
...prevState,
statusGet: 500,
productBasedPage: [],
error: action.payload,
isRejected: true,
isPending: false,
isFulFilled: false,
};
case String(postOrderAPICreator.pending):
return {
...prevState,
isPostPending: true,
};
case String(postOrderAPICreator.fulfilled): {
let status;
if (action.payload.status === 200) {
status = 200;
} else {
status = 500;
}
return {
...prevState,
statusPost: status,
errorPost: undefined,
isPostPending: false,
isPostFulFilled: true,
isPostRejected: false,
idProductOrdered: [],
productsOrdered: [],
totalPrice: 0,
};
}
case String(postOrderAPICreator.rejected):
return {
...prevState,
statusPost: 500,
errorPost: action.payload,
isPostRejected: true,
isPostPending: false,
isPostFulFilled: false,
};
//Add Products
case String(addProductsAPICreator.pending):
return {
...prevState,
isAddPending: true,
};
case String(addProductsAPICreator.fulfilled): {
let status;
let data;
let err;
if (action.payload.status === 200) {
status = 200;
data = action.payload.data;
err = undefined;
} else {
status = 500;
data = undefined;
err = action.payload.error;
}
return {
...prevState,
statusAdd: status,
dataAdd: data,
errorAdd: err,
isAddPending: false,
isAddFulFilled: true,
isAddRejected: false,
};
}
case String(addProductsAPICreator.rejected):
return {
...prevState,
statusAdd: 500,
errorAdd: action.payload,
isAddRejected: true,
isAddPending: false,
isAddFulFilled: false,
};
//GET ALLL ORDER
case String(getAllOrderAPICreator.pending):
return {
...prevState,
isGetOrderPending: true,
};
case String(getAllOrderAPICreator.fulfilled): {
let status;
let data;
let error;
if (action.payload.status === 200) {
status = 200;
data = action.payload.data;
error = null;
} else {
status = 500;
data = [];
error = action.payload.error;
}
return {
...prevState,
statusGetOrder: status,
dataGetOrder: data,
errorGetOrder: error,
isGetOrderPending: false,
isGetOrderFulFilled: true,
isGetOrderRejected: false,
};
}
case String(getAllOrderAPICreator.rejected):
return {
...prevState,
statusGetOrder: 500,
errorGetOrder: action.payload,
isGetOrderRejected: true,
isGetOrderPending: false,
isGetOrderFulFilled: false,
};
case selectProducts:
{
const target = action.payload.target;
const checked = target.checked;
const value = Number(target.value);
let productsOrder = prevState.products.find((item) => {
return item.product_id === value;
});
if (checked) {
if (
!prevState.productsOrdered.find((item) => {
return item.product_id === value;
})
) {
prevState.productsOrdered.push({
...productsOrder,
numOrder: 1,
});
prevState.idProductOrdered.push(value);
return {
...prevState,
totalPrice:
Number(prevState.totalPrice) +
Number(productsOrder.product_price),
};
}
} else if (!checked) {
prevState.totalPrice =
Number(prevState.totalPrice) -
Number(
prevState.productsOrdered[
prevState.idProductOrdered.indexOf(value)
].product_price
);
prevState.productsOrdered.splice(
prevState.idProductOrdered.indexOf(value),
1
);
prevState.idProductOrdered.splice(
prevState.idProductOrdered.indexOf(value),
1
);
console.log(prevState);
return {
...prevState,
};
}
}
break;
case changeQuantity: {
const target = action.payload.target;
const indexOrder = Number(target.value);
const id = target.id;
if (id === "plus") {
return {
...prevState,
productsOrdered: prevState.productsOrdered.map((item, index) => {
if (index === indexOrder) {
return {
...item,
numOrder: Number(item.numOrder) + 1,
product_price:
Number(
prevState.products.find((product) => {
return (
product.product_id ===
prevState.productsOrdered[indexOrder].product_id
);
}).product_price
) *
Number(prevState.productsOrdered[indexOrder].numOrder + 1),
};
} else {
return item;
}
}),
totalPrice:
Number(prevState.totalPrice) +
Number(
prevState.products.find((item) => {
return (
item.product_id ===
prevState.productsOrdered[indexOrder].product_id
);
}).product_price
),
};
} else if (
id === "min" &&
Number(prevState.productsOrdered[indexOrder].numOrder) >= 2
) {
return {
...prevState,
productsOrdered: prevState.productsOrdered.map((item, index) => {
if (index === indexOrder) {
return {
...item,
numOrder: Number(item.numOrder) - 1,
product_price:
Number(
prevState.products.find((product) => {
return (
product.product_id ===
prevState.productsOrdered[indexOrder].product_id
);
}).product_price
) *
Number(prevState.productsOrdered[indexOrder].numOrder - 1),
};
} else {
return item;
}
}),
totalPrice:
Number(prevState.totalPrice) -
Number(
prevState.products.find((item) => {
return (
item.product_id ===
prevState.productsOrdered[indexOrder].product_id
);
}).product_price
),
};
} else {
return {
...prevState,
};
}
}
case cancelOrder:
return {
...prevState,
idProductOrdered: [],
productsOrdered: [],
totalPrice: 0,
};
case "TOAST_POST_ORDER":
return {
...prevState,
isPostFulFilled: false,
isPostRejected: false,
};
case resetStatus:
return {
...prevState,
statusPost: null,
statusAdd: null,
statusGet: null,
statusDelete: null,
statusUpdate: null,
};
case "RESETPRODUCT":
return {
...prevState,
products: [],
productBasedPage: [],
};
case "SETKEYWORD":
return {
...prevState,
keyword: action.payload,
};
case "DELETE_ITEM_ORDER": {
let id = action.payload;
let newId;
let newTotal;
let newData;
if (id) {
newId = prevState.idProductOrdered.filter(
(item) => Number(item) !== Number(id)
);
newTotal =
Number(prevState.totalPrice) -
Number(
prevState.productsOrdered.find(
(item) => Number(item.product_id) === Number(id)
).product_price
);
newData = prevState.productsOrdered.filter(
(item) => Number(item.product_id) !== Number(id)
);
} else {
newId = prevState.idProductOrdered;
newTotal = prevState.totalPrice;
newData = prevState.productsOrdered;
}
return {
...prevState,
idProductOrdered: newId,
totalPrice: newTotal,
productsOrdered: newData,
};
}
case String(deleteProductAPICreator.pending):
return {
...prevState,
isDeletePending: true,
};
case String(deleteProductAPICreator.fulfilled): {
let status;
let err;
let newListProduct;
if (action.payload.status === 200) {
status = 200;
err = undefined;
newListProduct = prevState.products.filter(
(item) => Number(item.product_id) !== Number(action.payload.data.id)
);
} else if (action.payload.status === 500) {
status = 500;
err = action.payload.error;
newListProduct = prevState.products;
}
return {
...prevState,
products: newListProduct,
statusDelete: status,
errorDelete: err,
isDeletePending: false,
isDeleteFulFilled: true,
isDeleteRejected: false,
};
}
case String(deleteProductAPICreator.rejected):
return {
...prevState,
statusDelete: 500,
errorDelete: action.payload,
isDeleteRejected: true,
isDeletePending: false,
isDeleteFulFilled: false,
};
case String(updateProductAPICreator.pending):
return {
...prevState,
isUpdatePending: true,
};
case String(updateProductAPICreator.fulfilled): {
let status;
let err;
let newListProduct;
if (action.payload.status === 200) {
status = 200;
err = undefined;
newListProduct = prevState.products.map((item) => {
if (Number(item.product_id) === Number(action.payload.data.id)) {
let newItem = {
...item,
product_name: action.payload.data.product_name,
product_image: action.payload.data.product_image,
product_price: action.payload.data.product_price,
category_id: action.payload.data.category_id,
};
return newItem;
} else {
return item;
}
// Number(item.product_id)!==Number(action.payload.data.id)
});
} else if (action.payload.status === 500) {
status = 500;
err = action.payload.error;
newListProduct = prevState.products;
}
return {
...prevState,
products: newListProduct,
statusUpdate: status,
errorUpdate: err,
isUpdatePending: false,
isUpdateFulFilled: true,
isUpdateRejected: false,
};
}
case String(updateProductAPICreator.rejected):
return {
...prevState,
statusUpdate: 500,
errorUpdate: action.payload,
isUpdateRejected: true,
isUpdatePending: false,
isUpdateFulFilled: false,
};
default:
return prevState;
}
};
export default productsReducer;
|
import React from 'react';
import Box from '@material-ui/core/Box';
import './BlogFormat.css';
function Combining() {
return (
<div className='whole-container'>
<div className="container">
<Box p={3}>
Combining skills makes you unique. Let me use a sports reference for example. Lebron James, who is a physical force at 6’8 and 250 pounds can not only score at will, he can also pass.
<br/>
<br/>
This allows him to be a unique talent. This is what I’m trying to be in my career. I know it’s hard to be great at one thing, but it’s possible to be good at multiple skill sets. My focus is to be great at coding while having a solid understanding at marketing.
<br/>
<br/>
I prefer to be the one building because it gives me more satisfaction by making something people find useful. But knowing coding and marketing allows me to know how to build and sell. Being able to do both makes me a valuable part of a team.
</Box>
</div>
<div className="container">
<Box p={3}>
Knowing both skills lets me communicate with both the sales and engineering team. I’ll understand the lingo of engineers and be able to decipher that and communicate it with sales. Doing this makes me a liaison of some sorts. I can interpret and send messages between teams.
<br />
<br />
The second reason I wanted to learn coding and use it with my marketing skills is to create software. The power of software is all around us. All we need to do to realize this is by using our phones.
</Box>
</div>
<div className="container">
<Box p={3}>
For websites, I can create software to help me identify which websites are getting traffic and which aren't.
Or, I can create chatbots to help customers troubleshoot.
<br/>
<br/>
My main focus for now and the long-term is coding though. Not only do I get more fulfillment by building something with my own hands, coding is just more interesting to me in general.
<br/>
<br/>
Compared to my experience in accounting and marketing, coding gives me the ability to get into flow state which is priceless. I enjoy activities which I'm good at and
flow state is the fastest way for me to get good.
</Box>
</div>
</div>
)
}
export default Combining
|
import { Button } from "@material-ui/core";
import React from "react";
import styled from "styled-components";
import { auth, provider } from "../firebase";
function Login() {
const signIn = (e) => {
e.preventDefault();
auth.signInWithPopup(provider).catch((error) => {
alert(error.message);
});
};
return (
<LoginContainer>
<LoginInnerContainer>
<img
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaUAAAB4CAMAAABl2x3ZAAABC1BMVEX/////zCd3Sb3m5ub/yyX1gwNh2/tW2fv/pgX/qApwPbpxQLpzQ7tQ2Pt1RrxwPrr/ogD/0y/8+v5tObn4/v+97/7U9f739Pzx/P/x7Pme6P1+4fyI4/yR5fy0ndvF8f7zegD3rSpqM7imitTCr+LHteSu7P3c9/6be8+VcszRw+mOacnl3fPNveeEW8TB8P3b0O6tk9h+UsH+5sC4ot3//Pbq4/bZze2Sb8uggtH/xwB/UcP+2Z7+4rf/89z/yHP/vFH+9+n/wGH/363/0IX/6an/2mv/7bj4nRv/sz7/5Jf4jgD/3Hj/rSH/1Fb6uy7/zz3/6rH5nyn7sQD6zFT61Hn73pr8ykP87M6JMuCEAAALMUlEQVR4nO2cC3faOBbHg5ZYxpZtFvMwNuAtJBgCIZDmAaRNkz5m2810prs70/b7f5K9sg02jzxsZ0U0R/+eMxV24+jM71zdv64u3vvbntDLl6DEgwQlHiQo8SBBiQcJSjxIUOJBghIPEpR4kKDEgwQlHiQo8SBBiQcJSjxIUOJBghIPEpR4kKDEgwQlHiQo8SBBiQcJSjxIUOJBghIPEpR4kKDEgwQlHiQo8aCdUSqNDzr9fudguKsJ8KQdUapPkKkQXSeKeXpY2s0cONJOKJUOdBUhRFRD1ZGuDMa7mMQT9ObtrmcQaheU6j1TR8Q47XcmnQFREdGPn+fBVrVqlVeulD23aqV93LVcuM48p2fRDijVBwbSjd5RnX4oDTsKhNPhczy4K2kYO5WIk9V1MNakSsrnvZbld88xr+xiT6k2UpExipmGI1j2zGdY9CoadhxJ0yR3cYF+cBysuQ/+3L16Ixfkn9nn9QxiT6mvImW2cmWs68ioZX2uJWkn8JfraFqDhpMFA6cKgy52yo/87Ha9A0o3Waf1LGJO6dBE6mzt2pGC1E7WB1c1KRhUJCx5e1X4bzW4IGEv1RNvCoWC/DrrvJ5DrCnVCNJH9fWrEwMpWTdOXc0OR56Dpa6EGwvb0NTSZaavlNKXYHyecXbZxJrSmYKUo42rdZQ9mOyIhdXEGNvLZa6rddM88FYGSoWi78bfftmp22NMqXaKSG/L9ZaC0EaEJZMdMwkulnB1+amyjLJE+lmklORXEEbnX4vvs80umxhTOjJRe5udq5soqxuPUapi7OemUN10lD74lArFD+D2inJxlwmKMaWZqg+23ujrW2MsgaIVz5OwvdfEkrW8k2rF++iveAX56/ltQZaLN4vU9OkX5kmKLaX6KVIOtt45VLaYikRaRkzZwU34q4Gd8E5K9/A+oFQovvlYlAFTWC76NJ//M9NEU4gtpbGC2tu93NBEJJvLcwMqFlgH6cR1XTDkdlAvcmI56uk6/xJSkj9/9il98UPo0zw3/1emiaYQW0oHsDFajFcr4TWTbPF+SeRBJqrYDUcCYaxBaoLc5DTsiidJaUp5t4VQ8t3dZ5liggS19ymfy+V/zTTRFGJLqaPqo2BUO+vPVmqsB1PzLMujyy5Q0TSNQnIaVD4vuAK43BTFh5+LUCru7/vBJH8NIOVyv7FOTGwp9UnoEeq6Qkh7dYtUz7DiebZEaTS6VQc3lldhXO02KD3JTlx+eBtYPLlwtw+YgmCC5Y7q2236maYSU0qlga5O/NGUIJAx7fc6rcPLi4zngF4DIsZpUtMAJjxa3ixMM5KDbQeirJGQ05tgu0RDaX//zs9Mv+cC5VlvcdlSGulqiw5qJvKlE0JUQyGj2fFF+sd2IQdBrFhYKlsS9l23ZVnBHadsUUtOY01K5sffyT4ked8XrHnF3/8eUmJu8phSqi0o1UNKRFUJ0YGWqqDeZbqIKjcxmDk6cjS3gmnJ1bIhI3UhF5UlXKlo/hJIq0bNBI89v5F9SMWA0l0xgpTLszZ5u4mlvZFOIan92aw3HSF6sI5Uc5DK5IHxDosOFc2RMIzLDUx9Hj2/OAGbt6hJuHSz+2TdfpUppDCUAFMEib3JY52XSJCXxm3gYgR+r3Rx2RqZKkSUOUhuIDxtWQqCtc3fM3UpJMBEj5vA6OGFwati7em56Vr2FYbS/j9eRZBy+d8STzOb2Hq83sLj7Y0HRO/ElrhhSzd1pLcTu/F4+acZ1Fh9Cw6iKx24ieh+kuL4a998y9sgsTd57CjVwR9MlvslCKG1NFQ6PFUQUqYJ60RN/4Q2UCWo3S0o0bjy/DVwcT9B2fWNT+nzVkjMTR4zSsOrM7/2YNzvEWpnBkFklMztQTJablmlIPM0wxWPjm0YL25bToIOiHfFKJTWITE3eawoXcLmCFApyHwo9QwHKiIoESawcc1wh+TRwoNF4ydQOFwkI6uBpfufs64bCuluO6Tc/HuSKWYXI0pj8NtmidbEze018VClmYHIaaJFrwqWIeAAKcrf2VI3h4Ouhwa2F7Vyes7+dPNw+2oZSpuQmJs8NpTqFBL14DNV72/7B7XxIoBaJiKDRDsnT9KwXwCSsOdhvxPFcrt+6a4KiQoiDIZeE2sJIO1dFxahtAUSc5PHhhJsj0z/KPbYROaWBa3VbrcH4XXAZKw3GT2ssq1hzXFPNIfmISd2x69EgH84cTQNd5OUXF8vQmkbJBDbeisTSmfmYqGrwy6pte0+7GpHYUteT93WwPKgrKDY6niW5aw4b8eyPIceZEh2stOLD8UglO6BxNjksaBUJ1GHUEdFG2mnfupXIhanuDWk66OkTZRWhda+sURdeMWtep5XpeUiiSKCnVMl6QnTx6K/ob0HUm7OtguCBaUzBV0tyAzbSFnfuQ5Vv6i3JHmspGlVsSTJdnzbgBfyPzl2mlPA90UaSvdBys8/JX5iFjGgVBvpMWPXJ/rp0XDFHlz4oRRbCgck2vw+WVXqsy3PrdD9LBWNqqpn0cSU+ET9/BUNpXsh5RmbPAaUxiZSIyoQTLrZvlrZNfX8YIq6W4+UFK2uJ1p4/FcNyq8neNF43EjenXJbgFB6AFL+R9InZhIDSi0jPPoL1KcHgPqK0xsawMiMDtgh+owHt1XbFBXpKhi7ey7GJxt3nqyfEEoPQcrnkj4xkxhQmhEzbtlCqxB3ejMVGWdxbBM1eXderAPZxlJFitCk6G19W7x7EFJ+zrTeyoDSlMSrQjUlOP+LUThS17vEaXde0l9jR2XXsk37xJd3TpJT+vgIpDxbk/f/p1Qa6Eo8TnR9xdAFRlxd3eqOFUSS/p5YLNHUlK1P/P0jkPLzfyd9ZBYxoDTVVyqsEz+Y2pfLC/RrZ2vmfGxEfXtPVSz7uL4JjxbA5HnpP49AyrPtnGSw4vWIeRn7WOq1FbMdmYMOLdyt/QiYPJT017haWBsqNzEEj63hZlgScmJHUE/T7X8fgZSfMzV5DChNVj0eRMrBQbTATUykX62X9lrGPU3/D8iSgh4vNwyjEwlLJ5STh5Pvan/+MX8Y0i9MS0QMKB0Ch/uK3LUZRI1xuXY16ttLIhs7brXrYC08yPAaGpZs15XSfDHm/O2PDU4Roz8YfymaAaWLRUF8y60p7GfNjbc9gOkz18k9Lou+NkCLvUqg7AIy+OOkeuPD+fdv+e3G4ceHv2IH8ozc80W/Qx3ubBKETa1+laI5r9x1HLsaP58oV+1GI9GJRVy3f+bzG5Dm+e/sv2PLgtK4jch08//6cNpGSFc235vSUx850WUmSE/5NUh/su4Rp2JyvgTmW11vOhnO2hBIymizXgemT8n4vcDn0+swPYWMft3Nl6CZUCrRd9qQScSpfjRVgJGqtPwQG8dOk8bwb41p5nd0PJ8+fJuHkJibhqXYnKjXeoqOVH06OTg+Oj6YTK98RmbPD6TSzBx1jof1Wq1+cdwjBJmzFwQJ0tP33Nw3Dbt7wxejHqLSGTJ0RFSFSgVEREGz4MvqFzTQVEU9HY1OiUJ0lZy9tBfmXYON+PZ9FwkpFLOuyYvJlaL6JTwdmOjT5cZ22EMKCW5QM6HPXuLbJ6+vd8iIaZ946bI1uFINctU/u1wx5vWj2ZXZplKnBxnfzfHX1Et5u27tYjgeCkL36KVQEnpIghIPEpR4kKDEgwQlHiQo8SBBiQcJSjxIUOJBghIPEpR4kKDEgwQlHiQo8SBBiQcJSjxIUOJBghIPEpR4kKDEgwQlHiQo8SBBiQcJSjxIUOJBghIPEpR4kKDEgwQlHiQo8SBBiQcJSjxIUOJBghIPEpR4kKDEgwQlHiQo8SBBiQP9Dw8s7Ba72HmeAAAAAElFTkSuQmCC"
alt="logos"
/>
<h1>Login to Slakc/Amartya_Singh</h1>
<p>amartya.slakc.com</p>
<Button onClick={signIn}>Sign in with Google</Button>
<footer>
Built by{" "}
<a
href="https://www.linkedin.com/in/amartyasingh07/"
target="_blank"
rel="noreferrer"
>
Amartya Singh
</a>
</footer>
</LoginInnerContainer>
</LoginContainer>
);
}
export default Login;
const LoginContainer = styled.div`
background-color: #f8f8f8;
height: 100vh;
display: grid;
place-items: center;
`;
const LoginInnerContainer = styled.div`
padding: 100px;
text-align: center;
background-color: white;
border-radius: 10px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
> img {
object-fit: contain;
height: 150px;
width: 400px;
margin-bottom: 40px;
}
> footer > a {
}
> h1 {
padding-bottom: 4px;
}
> p {
padding-top: 4px;
padding-bottom: 4px;
}
> footer {
padding-top: 4px;
}
> button {
margin-top: 4px;
text-transform: inherit !important;
background-color: #0a8d48 !important;
color: white;
}
`;
|
import React, { Link, Component } from 'react';
import { connect } from 'react-redux';
import fs from 'fs';
import Flexbox from 'flexbox-react';
import SplitPane from 'react-split-pane';
import AppBar from 'material-ui/AppBar';
import RaisedButton from 'material-ui/RaisedButton';
import Drawer from 'material-ui/Drawer';
import Paper from 'material-ui/Paper';
import CodeView from './CodeView';
import Navbar from './Navbar';
import store from '../store';
import FileTreeContainer from '../containers/FileTreeContainer';
import colors from '../public/colors';
const titleStyles = {
// a cool font could be nice- using Bones default to match student for now
position: 'absolute',
top: '10%',
fontFamily: 'Monaco',
fontSize: '35px',
alignItems: 'center'
};
const style = {
margin: 12,
};
class MainView extends Component {
constructor(props) {
super(props);
this.state = { open: false };
}
componentDidMount() {
const { socket } = this.props;
// can attach any additional listeners here
// editor listener is currently inside CodeView, but can optionally be moved here
}
render() {
const { snapshots, selectSnapshot, socket, requestedFilePath } = this.props;
return (
<Flexbox display="flex" flexDirection="row" flexGrow={1} flexWrap="wrap" marginTop="auto" marginBottom="auto" width="100vw" maxHeight="100vh">
<AppBar style={{ width: '100%' }} showMenuIconButton={false}>
<div style={titleStyles}>
<span style={{ color: colors.cyan }}>Code </span>
<span style={{ color: colors.green }}>à </span>
<span style={{ color: colors.orange }}>la </span>
<span style={{ color: colors.magenta }}>Mode</span>
</div>
</AppBar>
<Paper style={style} zDepth={2} >
<FileTreeContainer directory={'/'} socket={socket} />
</Paper>
<Paper style={style} zDepth={5} >
<CodeView socket={socket} requestedFilePath={requestedFilePath} />
</Paper>
</Flexbox>
);
}
}
const mapStateToProps = ({ code, snapshots, selectSnapshot, fileTree }) => ({
code: 'class test{};',
snapshots: {
list: [],
selected: {}
},
requestedFilePath: fileTree.requestedFilePath
});
const mapDispatch = dispatch => ({
selectSnapshot: () => {console.log('Select SNAPSHOT!!!');}
});
export default connect(mapStateToProps, mapDispatch)(MainView);
|
var testkit = require('../src/support/testing');
var compiler = testkit.compiler;
var compile = testkit.compile;
var sample = testkit.sampleData;
const EMPTY = "";
describe('@if @else', function()
{
it('should return the element if expression is true', function(done)
{
var promises = [
compile(_if("true")),
compile(_if("! false")),
compile(_if("1 === 1")),
compile(_if("1 < 2")),
compile(_if("2 <= 2")),
compile(_if("1 !== 2")),
compile(_if("'x' == 'x'")),
];
var check = result => { expect(result).to.equal("yes"); };
testkit.map(promises,check,done);
});
it('should not return the element if expression is false', function(done)
{
var promises = [
compile(_if("false")),
compile(_if("! true")),
compile(_if("1 === 2")),
];
var check = result => { expect(result).to.equal(EMPTY); };
testkit.map(promises,check,done);
});
it('should return true portion of if/else if true', function(done)
{
var promises = [
compile(_ifelse("true")),
compile(_ifelse("! false")),
compile(_ifelse("1 === 1")),
compile(_ifelse("1 !== 2")),
compile(_ifelse("'x' == 'x'")),
];
var check = result => { expect(result).to.equal("yes"); };
testkit.map(promises,check,done);
});
it('should return false portion of if/else if false', function(done)
{
var promises = [
compile(_ifelse("false")),
compile(_ifelse("! true")),
compile(_ifelse("1 === 2")),
];
var check = result => { expect(result).to.equal("no"); };
testkit.map(promises,check,done);
});
});
function _if(v)
{
return `
@if(${v})
yes
@endif
`;
}
function _ifelse(v)
{
return `
@if(${v})
yes
@else
no
@endif
`
}
|
"use strict";
require('babel-polyfill');
global.L=console.log;
global.sleep = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms));
}
|
// @flow
/**
* @see https://code.google.com/codejam/contest/3264486/dashboard#s=p2&a=4
*/
const { parseInputLineByLine } = require('../common/parseStdin')
const { readInputFiles, outputToFile } = require('../common/io')
const { getDistances, computeRepetitionsAndMaximums } = require('./getDistances')
function lineParser(line: string): { n: number, k: number } {
const [n, k]: string[] = line.split(' ')
return { n: parseFloat(n), k: parseFloat(k) }
}
function main() {
const sets = readInputFiles(`${__dirname}/in`, lineParser)
sets.forEach(({ lines, nameOfSet }) => {
const results = lines.map(({ n, k }, idx) => {
const { min, max } = getDistances(n, k)
return `Case #${idx + 1}: ${max} ${min}`
})
outputToFile(`${__dirname}/out/${nameOfSet}.out`, results)
})
}
main()
|
//Temporary variable used to contain the text string
var txt1;
var txt2;
var txt3;
var txt4;
//Temporary for tests
function setup()
{
canvas = createCanvas(700, 300);
txt1 = new PointText(350, 100, 'Hi, I am text', 32, 0.5, 1, 'point', '#ff0044');
txt2 = new PointText(100, 50, 'Potato', 50, 0.3, 1.5, 'square', '#0099db');
txt3 = new PointText(300, 200, 'Coding', 150, 0.1, 3, 'triangle', '#fee761');
txt4 = new PointText(550, 150, 'Prog18', 80, 0.15, 5, 'point', '#f77622');
}
//Temporary for tests
function draw()
{
background('#193c3e');
txt1.draw();
txt2.draw();
txt3.draw();
txt4.draw();
}
|
const ENDPOINTS_BASEURL = {
local: {
apiHost: {
base_url: JSON.stringify('http://localhost:3000'),
version: JSON.stringify('/api/v1')
}
},
dev: {
apiHost: {
base_url: JSON.stringify('http://139.99.45.55:4000'),
version: JSON.stringify('/api/v1')
}
},
prod: {
apiHost: {
base_url: JSON.stringify('http://139.99.45.55:4000'),
version: JSON.stringify('/api/v1')
}
}
};
module.exports = ENDPOINTS_BASEURL;
|
import React, { useState, useEffect } from "react";
import { Link } from "react-router-dom";
import "./style.css";
function Nav() {
const [navObj, setNavObj] = useState({
open: false,
width: window.innerWidth
});
const updateWidth = () => {
const newNavObj = ({ width: window.innerWidth });
if (navObj.open && newNavObj.width > 991) {
navObj.open = false;
}
setNavObj(newNavObj);
};
const toggleNav = () => {
setNavObj({ open: !navObj.open });
};
useEffect( () => {
window.addEventListener("resize", updateWidth);
}, [])
useEffect( () => {
window.removeEventListener("resize", updateWidth);
}, [])
return (
<nav className="navbar navbar-expand-lg mb-2">
<Link className="navbar-brand" to="/">
Brett Fleming
</Link>
<button
onClick={toggleNav}
className="navbar-toggler"
data-toggle="collapse"
data-target="#navbarNav"
aria-controls="navbarNav"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span className="navbar-toggler-icon" />
</button>
<div className={`${navObj.open ? "" : "collapse "}navbar-collapse`} id="navbarNav">
<ul className="navbar-nav">
<li className="nav-item">
<Link
onClick={toggleNav}
className={window.location.pathname === "/projects" ? "nav-link active" : "nav-link"}
to="/projects"
>
Projects
</Link>
</li>
<li className="nav-item">
<Link
onClick={toggleNav}
className={window.location.pathname === "/about" ? "nav-link active" : "nav-link"}
to="/about"
>
About Me
</Link>
</li>
<li className="nav-item">
<Link
onClick={toggleNav}
className={window.location.pathname === "/contact" ? "nav-link active" : "nav-link"}
to="/Contact"
>
Contact Me
</Link>
</li>
</ul>
</div>
</nav>
);
}
export default Nav;
|
// convenience wrapper around all other files:
exports.users = require('./users');
exports.people = require('./people');
exports.movies = require('./movies');
exports.genres = require('./genres');
exports.data = require('./data');
|
/*
*
*
* Complete the API routing below
*
*
*/
"use strict";
var expect = require("chai").expect;
var MongoClient = require("mongodb").MongoClient;
var ObjectId = require("mongodb").ObjectId;
const MONGODB_CONNECTION_STRING = process.env.DB;
const Book = require("../bookModel");
//MongoClient.connect(MONGODB_CONNECTION_STRING, function(err, db) {});
module.exports = function(app) {
app
.route("/api/books")
.get(function(req, res) {
Book.find({}, (err, books) => {
if (err) {
console.log(err);
}
})
.then(books => {
let booksRes = books.map(book => {
return new Object({
_id: book._id,
title: book.title,
commentcount: book.comments.length
});
});
res.json(booksRes);
})
.catch(err => console.log(err));
//response will be array of book objects
//json res format: [{"_id": bookid, "title": book_title, "commentcount": num_of_comments },...]
})
.post(function(req, res, done) {
const title = req.body.title;
if (title === undefined) {
res.status(500);
}
const createBook = new Book({
title
});
createBook
.save()
.then(result => res.json({ _id: result._id, title: result.title }))
.catch(err => console.log(err));
//response will contain new book object including atleast _id and title
})
.delete(function(req, res) {
Book.deleteMany({}, err => {
console.log(err);
})
.then(() => res.send("complete delete successful"))
.catch(err => console.log(err));
//if successful response will be 'complete delete successful'
});
app
.route("/api/books/:id")
.get(function(req, res) {
let bookid = req.params.id;
Book.find({ _id: bookid }, (err, book) => {
if (err) {
console.log(err);
res.status(500).send("no book exists");
}
})
.then(book => {
if (book.length == 0) {
res.status(500).send("no book exists");
} else {
res.json({
_id: book[0]._id,
title: book[0].title,
comments: book[0].comments
});
}
})
.catch(err => console.log(err));
//json res format: {"_id": bookid, "title": book_title, "comments": [comment,comment,...]}
})
.post(function(req, res) {
let bookid = req.params.id;
let comment = req.body.comment;
Book.findById(bookid, (err, book) => {
if (err) {
console.log(err);
}
book.comments.push(comment);
book
.save()
.then(book =>
res.json({
_id: book._id,
title: book.title,
comments: book.comments
})
)
.catch(err => console.log(err));
});
//json res format same as .get
})
.delete(function(req, res) {
let bookid = req.params.id;
Book.findByIdAndDelete(bookid)
.then(() => res.send("delete successful"))
.catch(err => console.log(err));
//if successful response will be 'delete successful'
});
};
|
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import SearchBar from './components/search_bar';
import VideoList from './components/video_list';
import VideoInfo from './components/video_info';
import YTSearch from 'youtube-api-search';
import _ from 'lodash';
const API_KEY = 'AIzaSyDFxQSWqI6btiMIbvWjR6496lgVOcW3bAk';
class App extends Component {
constructor(props) {
super(props);
this.state = {
videos: [],
activeVideo: null
}
this.searchVideo('');
}
searchVideo = (term) => {
YTSearch({key: API_KEY, term: term}, videos => {
this.setState({
videos: videos,
activeVideo: videos[0]
});
});
}
render() {
const searchVideo = _.debounce( term => this.searchVideo(term), 300 );
return(
<div>
<SearchBar term={this.state.term} onInputChange={searchVideo} />
<VideoInfo video={this.state.activeVideo}/>
<VideoList onVideoClick={ activeVideo => this.setState({activeVideo}) } videos={this.state.videos} />
</div>
);
}
};
ReactDOM.render(<App />, document.querySelector('.app'));
|
import React from 'react';
import UserSearcherProvider from './components/UserSearcherProvider.jsx'
import './App.css';
function App() {
return (
<div className="App">
<h1>Github User Searcher </h1>
<UserSearcherProvider />
</div>
);
}
export default App;
|
migration.up = function(migrator) {
try{
migrator.db.execute('ALTER TABLE ' + migrator.table + ' ADD COLUMN UsuarioUAU VARCHAR(150);');
}
catch(e){
Ti.API.info("já existe");
}
};
migration.down = function(migrator) {
};
|
var searchData=
[
['vector2d_280',['Vector2D',['../_vector2_d_8hh.html#af4760457e8ece71e04104c08ad65bbce',1,'Vector2D.hh']]],
['vector3d_281',['Vector3D',['../_vector3_d_8hh.html#a01090a0f6a3d1e7e9606819bd0fafda0',1,'Vector3D.hh']]]
];
|
/**
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
goog.provide('audioCat.android.AndroidAmbassador');
goog.require('audioCat.android.StringConstant');
goog.require('goog.asserts');
/**
* Interfaces with the object that Android injects into javascript. Should only
* be constructed in an Android web view.
* @constructor
*/
audioCat.android.AndroidAmbassador = function() {
/**
* The global Android object.
* @private {!Object}
*/
this.androidObject_ =
goog.global[audioCat.android.StringConstant.ANDROID_OBJECT];
goog.asserts.assert(this.androidObject_, 'No Android object found.');
// Now that we have a reference to the object, remove its global reference to
// prevent tampering by hackers. :)
delete goog.global[audioCat.android.StringConstant.ANDROID_OBJECT];
};
/**
* Registers the beginning of an audio file write to the Android file system.
* @param {string} fileName The name of the file.
* @param {string} mimeType The mime type of the audio file.
* @param {number} fileSize the size in bytes of the file.
*/
audioCat.android.AndroidAmbassador.prototype.registerAudioFileWrite = function(
fileName,
mimeType,
fileSize) {
this.androidObject_[
audioCat.android.StringConstant.REGISTER_AUDIO_FILE_WRITE](
fileName, mimeType, fileSize);
};
/**
* Registers the beginning of a project file write to the Android file system.
* @param {string} fileName The name of the file.
* @param {string} mimeType The mime type of the file.
* @param {number} fileSize the size in bytes of the file.
*/
audioCat.android.AndroidAmbassador.prototype.registerProjectFileWrite =
function(
fileName,
mimeType,
fileSize) {
this.androidObject_[
audioCat.android.StringConstant.REGISTER_PROJECT_FILE_WRITE](
fileName, mimeType, fileSize);
};
/**
* Signals to Android to start writing the previously registered file writing
* operation.
*/
audioCat.android.AndroidAmbassador.prototype.startWritingFile = function() {
this.androidObject_[audioCat.android.StringConstant.WRITE_FILE]();
};
/**
* Signals to Android to clean up after the previous file write attempt.
*/
audioCat.android.AndroidAmbassador.prototype.cleanUpPreviousFileWrite =
function() {
this.androidObject_[
audioCat.android.StringConstant.CLEAN_UP_FILE_WRITE_ATTEMPT]();
};
/**
* Sets the next input type.
* @param {audioCat.android.FileInputType} inputType The next input type.
*/
audioCat.android.AndroidAmbassador.prototype.setNextInputType = function(
inputType) {
this.androidObject_[audioCat.android.StringConstant.SET_NEXT_FILE_INPUT_TYPE](
inputType);
};
/**
* @return {string} The hostname + port string for writing files to disk.
*/
audioCat.android.AndroidAmbassador.prototype.getFileWritingSocketString =
function() {
return this.androidObject_[
audioCat.android.StringConstant.GET_FILE_WRITING_SOCKET]();
};
|
import React, { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import axios from 'axios';
import Table, { StyledTable } from '../components/Table';
import { StyledButton, Title } from '../components/Styled';
import BarChart from '../components/BarChart';
import { Message, resItems } from './Result';
function getDate(dateInfo) {
const dateArr = (dateInfo).split('-');
const year = dateArr[0];
const month = dateArr[1];
const dayTime = dateArr[2].split(':')[0].split('T');
const day = dayTime[0];
const time = dayTime[1];
let realDay = day;
if (time > 15) {
realDay = Number(day) + 1;
}
return `${year}년 ${month}월 ${realDay}일`;
}
function profileSelector(state) {
return {
name: state.name,
gender: state.gender,
originalRes: state.results.originalRes,
top2: state.results.top2,
low2: state.results.low2,
testDate: state.results.testDate,
};
}
export default function ResultDetail() {
const { name, gender, originalRes, top2, low2, testDate } = useSelector(profileSelector);
const [job, setJob] = useState([]);
const [major, setMajor] = useState([]);
useEffect(() => {
getResult();
window.scrollTo(0, 0);
}, []);
async function getResult() {
const jobRes = await axios.get(
`https://www.career.go.kr/inspct/api/psycho/value/jobs?no1=${top2[0]}&no2=${top2[1]}`,
);
setJob(jobRes.data);
const majorRes = await axios.get(
`https://www.career.go.kr/inspct/api/psycho/value/majors?no1=${top2[0]}&no2=${top2[1]}`,
);
setMajor(majorRes.data);
}
const date = getDate(testDate);
return (
<div>
<h1>상세결과 페이지</h1>
<StyledTable simple>
<thead>
<tr>
<td className="types">이름</td>
<td className="types">성별</td>
<td className="types">검사일</td>
</tr>
</thead>
<tbody>
<tr>
<td>{name}</td>
<td>{gender === '100323' ? '남' : '여'}</td>
<td>{date}</td>
</tr>
</tbody>
</StyledTable>
<Message name={name} tops={top2} lows={low2} res={resItems} />
<div>
<Title>직업 가치관 결과</Title>
{originalRes && (
<BarChart
label={Object.values(resItems)}
score={originalRes}
/>
)}
</div>
<div>
{job && major && (
<div>
<Table title="학력" res={job} />
<Table title="전공" res={major} />
</div>
)}
</div>
<a href="/">
<StyledButton status>다시 검사하기</StyledButton>
</a>
</div>
);
}
|
import * as types from './mutation-types'
export default {
[types.SET_TEST](state, { user_test }) {
state.user_test = user_test
},
//控制是否可以进入下一步第一步
[types.SET_ADD_COURSE_ONESHOW](state, { courseIdSign }) {
state.oneShow = true
state.courseIdSign = courseIdSign
},
// 获取树形分类 三级菜单
[types.SET_FIND_COURSE_THREE_LIST](state, { threeList }) {
state.threeList = threeList
},
// 获取所有老师
[types.SET_BY_ALL_TEACHER_LIST](state, { allTeacher }) {
state.allTeacher = allTeacher
},
// 根据课程id查询所有关联老师
[types.SET_ALL_COURSE_TEACHER_LIST](
state,
{ allCourseTeacherList, masterFlagId },
) {
state.allCourseTeacherList = allCourseTeacherList
},
// 控制active++
getActiveJiajia(state) {
state.active += 1
},
// 控制active--
getActiveJianjian(state) {
state.active -= 1
},
//控制是否可以进入下一步 第二步
[types.SET_STATE_TWO_SHOW](state) {
state.twoShow = true
},
// 查看用户中心我的学习进度
[types.SET_COURSE_STUDY_PROGRESS](state, { courseStudyProgress }) {
state.courseStudyProgress = courseStudyProgress
},
// 查看用户中心我的学习进度
[types.SET_COURSE_STUDY_PROGRESS_SACCOMPLISH](
state,
{ courseStudyProgressSaccomplish },
) {
state.courseStudyProgressSaccomplish = courseStudyProgressSaccomplish
},
// 控制用户是否可以进入下一步
handleStep(state, newActive) {
state.activeShow += 1
localStorage.setItem('active', newActive)
},
// 控制用户是否可以进入上一步
handlePre(state, newActive) {
state.activeShow -= 1
localStorage.setItem('active', newActive)
},
}
|
/**
* Created by Crespo on 04/09/2016.
*/
export default function ( {dispatch} ) {
return next => action => {
if( ! action.payload || ! action.payload.then ){
return next(action);
}
action.payload
.then( ( response ) =>{
const newAction = { ...action, payload:response.data};
dispatch( newAction );
} );
next(action);
}
}
|
import React from 'react';
export const DocumentsCounter = ({ docCount }) => (
<h3>
Doc count: { docCount }
</h3>
);
DocumentsCounter.propTypes = {
docCount: React.PropTypes.number,
};
|
/**
* Kart Api
*
* DB: MySQl
*
*/
var hostname = 'localhost',
app = require('./config/express')();
// auto environment detection
let env = process.env.NODE_ENV;
if (!env) {
env = "development"
}
// port and database configs
let config = require(`./config/config.${env}.json`);
// configure port according to environment variable, or uses por 3000
const port = process.env.port || 3000;
app.listen(port, function() {
console.log("Server is up and running on http://"
+ hostname
+ ":"
+ port
);
});
|
/*
Copyright (c) Lightstreamer Srl
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
define(function() {
var protocolToUse = document.location.protocol != "file:" ? document.location.protocol : "http:";
var portToUse = document.location.protocol == "https:" ? "443" : "8080";
return {
ADAPTER: "AUTHDEMO",
SERVER: protocolToUse+"//localhost:"+portToUse,
J_NOTIFY_OPTIONS_ERR: {
autoHide : true, // added in v2.0
TimeShown : 3000,
clickOverlay: true,
HorizontalPosition : 'center',
VerticalPosition: 'center'
},
J_NOTIFY_OPTIONS_OK: {
autoHide : true, // added in v2.0
TimeShown : 500,
clickOverlay: true,
HorizontalPosition : 'center',
VerticalPosition: 'center'
},
TRIM_REGEXP: new RegExp("^\\s*([\\s\\S]*?)\\s*$")
};
});
|
"use strict";
const { PORT_OPTION,
HELP_OPTION,
QUIETLY_OPTION,
VERSION_OPTION,
WATCH_PATTERN_OPTION,
ALLOWED_ORIGIN_OPTION } = require("./options");
const p = PORT_OPTION,
h = HELP_OPTION,
q = QUIETLY_OPTION,
v = VERSION_OPTION,
w = WATCH_PATTERN_OPTION,
o = ALLOWED_ORIGIN_OPTION;
module.exports = {
p,
h,
q,
v,
w,
o
};
|
const db = require("../db");
const Sequelize = require("sequelize");
const Checkpoint = db.define(
"checkpoint",
{
checkpointName: Sequelize.STRING,
checkpointDKP: {
type: Sequelize.INTEGER,
defaultValue: 10,
},
associatedRaid: {
type: Sequelize.VIRTUAL,
defaultValue: {},
},
associatedCharacters: {
type: Sequelize.VIRTUAL,
defaultValue: [],
},
associatedDrops: {
type: Sequelize.VIRTUAL,
defaultValue: [],
},
},
{
hooks: {
afterFind: checkpoint => {
checkpoint.associatedRaid = checkpoint.raid ? checkpoint.raid : "not found";
checkpoint.associatedCharacters = checkpoint.characters
? checkpoint.characters
: "not found";
checkpoint.associatedDrops = checkpoint.drops ? checkpoint.drops : "not found";
},
},
}
);
module.exports = Checkpoint;
|
'use babel';
import { GeneralRenderer } from './renderer/GeneralRenderer';
import { TimelineRenderer } from './renderer/TimelineRenderer';
export function factory(rendererType, opts = {}) {
switch (rendererType) {
case 'GENERAL':
return new GeneralRenderer(opts)
case 'TIMELINE':
return new TimelineRenderer(opts)
default:
throw new Error(`Unknown renderer ${rendererType}`)
}
}
|
import Search from './search.jsx';
import Route from '../../js/route';
import messagesActions from '../../actions/messagesActions';
class SearchRoute extends Route {
constructor() {
super();
this.name = "search";
this.component = Search;
}
fetch(nextState) {
return messagesActions.find(nextState.location.query.text);
}
}
export default new SearchRoute();
|
import '../common.css'
import ReactDOM from 'react-dom'
import React, { Component } from 'react'
import PropTypes from 'prop-types'
const MakeThingsBlue = props => {
return <div style={{ color: 'blue' }}>{props.children}</div>
}
// 'node' is "Anything that can be rendered: numbers, strings, elements or an array
// (or fragment) containing these types"
// https://reactjs.org/docs/typechecking-with-proptypes.html
MakeThingsBlue.propTypes = {
children: PropTypes.node
}
const App = () => {
return (
<MakeThingsBlue>
<p>Hello world</p>
<p>Hello dog</p>
</MakeThingsBlue>
)
}
ReactDOM.render(<App />, document.getElementById('react-root'))
|
floors = {
'TOP' :
[
[ 'Sky','Sky','Sky','Sky', 'Sky','Sky','Sky','Sky', 'Sky','Sky','Sky','Sky', 'Sky','Sky','Sky','Sky'],
[ 'Earth','Earth','Earth','Earth', 'Earth','Earth','Earth','Earth', 'Earth','Earth','Earth','Earth', 'Earth','Earth','Earth','Hellmouth']
],
'Floor' :[
[ 'Wall','Wall','Wall','Wall', 'Wall','Wall','Wall','Wall', 'Wall','Wall','Wall','Wall', 'Wall','Wall','Wall','Wall'],
[ 'Stone','Stone','Stone','Stone', 'Stone','Stone','Stone','Stone', 'Stone','Stone','Stone','Stone', 'Stone','Stone','Stone','Tunnel']
]
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.