hexsha string | size int64 | ext string | lang string | max_stars_repo_path string | max_stars_repo_name string | max_stars_repo_head_hexsha string | max_stars_repo_licenses list | max_stars_count int64 | max_stars_repo_stars_event_min_datetime string | max_stars_repo_stars_event_max_datetime string | max_issues_repo_path string | max_issues_repo_name string | max_issues_repo_head_hexsha string | max_issues_repo_licenses list | max_issues_count int64 | max_issues_repo_issues_event_min_datetime string | max_issues_repo_issues_event_max_datetime string | max_forks_repo_path string | max_forks_repo_name string | max_forks_repo_head_hexsha string | max_forks_repo_licenses list | max_forks_count int64 | max_forks_repo_forks_event_min_datetime string | max_forks_repo_forks_event_max_datetime string | content string | avg_line_length float64 | max_line_length int64 | alphanum_fraction float64 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
27aee81bbfeca6a6e50eaff6a342ef8c6e9b881d | 349 | js | JavaScript | templates/example.controller.js | NOALVO/azure-monofunction | 75eeaa3818ae3c50ee830a1a26075f51609be7ab | [
"MIT"
] | null | null | null | templates/example.controller.js | NOALVO/azure-monofunction | 75eeaa3818ae3c50ee830a1a26075f51609be7ab | [
"MIT"
] | null | null | null | templates/example.controller.js | NOALVO/azure-monofunction | 75eeaa3818ae3c50ee830a1a26075f51609be7ab | [
"MIT"
] | 2 | 2020-06-14T02:03:35.000Z | 2020-08-01T16:31:01.000Z | // THIS CONTROLLER IS AN EXAMPLE GENERATED BY AZURE-MONOFUNCTION
async function successAction (context) {
context.res.body = { success: 'yep' };
context.res.status = 200;
}
async function failureAction (context) {
context.res.body = { success: 'nope' };
context.res.status = 400;
}
module.exports = {
successAction,
failureAction,
};
| 20.529412 | 64 | 0.702006 |
27b01a95fa72eeb48ddef79076d6ec606d4cb0a3 | 1,377 | js | JavaScript | finbud.js | KevL97t/test-project | d5d308e2b950606960cee0c47ad069f9ce3190c0 | [
"MIT"
] | 1 | 2021-09-01T22:38:39.000Z | 2021-09-01T22:38:39.000Z | finbud.js | KevL97t/test-project | d5d308e2b950606960cee0c47ad069f9ce3190c0 | [
"MIT"
] | null | null | null | finbud.js | KevL97t/test-project | d5d308e2b950606960cee0c47ad069f9ce3190c0 | [
"MIT"
] | null | null | null | //////// VARIABLES NECESARIAS
let ingresos = [];
//////////////////FUNCIONES DE AYUDA
function calcularIngresoMensualTotal(){
const sumaIngresos = ingresos.reduce(
function(a = 0, b)
{
return Number(a) + Number(b);
}
);
return sumaIngresos;
}
function registrarIngresos(){
let nuevoIngreso = document.getElementById("nuevoIngreso");
let nuevoIngresoValue = nuevoIngreso.value;
let nuevoIngresoPush = ingresos.push(nuevoIngresoValue);
}
function calcularMayorValor(){
let mayorValor = ingresos[ingresos.length-1]
return mayorValor
}
////////////FUNCION CON ALGORITMO PARA CALCULO DE FINANZAS
function calcularFinanzas(){
let ingresosOrdenados = ingresos.sort((a,b)=>a-b);
console.log(ingresosOrdenados)
///////////////////////////////////////////////////////////
const sumaTotal = calcularIngresoMensualTotal();
console.log(sumaTotal);
const sumaDeIngresos = document.getElementById("sumaDeIngresos");
sumaDeIngresos.innerText = `El total de ingresos mensual fue: $${sumaTotal}`;
//////////////////////////////////////////////////////////
const ingresoMayor = calcularMayorValor();
console.log(ingresoMayor);
const mayorIngreso = document.getElementById("mayorIngreso");
mayorIngreso.innerText = `El ingreso mayor del mes fue: $${ingresoMayor}`;
}
| 27 | 81 | 0.626725 |
27b0ea663b767ea617399797d41e308a178d1145 | 2,168 | js | JavaScript | client/src/Components/Posts/ActivityPost.js | OktarianTB/visitado | 3dc81ad86effc5d575b22169ae16a2e6f5b9a487 | [
"MIT"
] | null | null | null | client/src/Components/Posts/ActivityPost.js | OktarianTB/visitado | 3dc81ad86effc5d575b22169ae16a2e6f5b9a487 | [
"MIT"
] | 1 | 2020-09-09T13:20:31.000Z | 2020-09-09T13:20:31.000Z | client/src/Components/Posts/ActivityPost.js | OktarianTB/visitado | 3dc81ad86effc5d575b22169ae16a2e6f5b9a487 | [
"MIT"
] | null | null | null | import React from "react";
import { Grid, Typography, Paper } from "@material-ui/core/";
import styles from "./ActivityPost.module.css";
import GridList from "@material-ui/core/GridList";
import GridListTile from "@material-ui/core/GridListTile";
import { Link } from "react-router-dom";
const ActivityPost = ({
username,
date,
title,
location,
activity,
content,
badge,
profile_picture,
images,
}) => {
const url = `/profile/${username}`;
const d = new Date(date);
return (
<Paper className={styles.paper}>
<Grid container spacing={1}>
<Grid item xs={2}>
<img
src={`/${profile_picture}`}
className={styles.postProfilePic}
alt={username}
/>
</Grid>
<Grid item xs={8}>
<Typography
variant="overline"
component={Link}
to={url}
className={styles.link}
>
@{username}
</Typography>
<Typography variant="h5">{title}</Typography>
<Typography variant="caption">
{location ? `📍 ${location} ` : ""}
{location && activity ? `● ${activity}` : activity ? activity : ""}
</Typography>
</Grid>
<Grid item xs={2} style={{ textAlign: "right" }}>
<Typography variant="overline">
{d.toLocaleDateString("en-US")}
</Typography>
</Grid>
</Grid>
<br />
<br />
<Typography variant="body1">{content}</Typography>
{images.length > 0 && <br />}
{images.length > 0 && <ImageGrid images={images} />}
{badge && (
<div>
<br />
<Typography variant="body2">Badge Progress: {badge}</Typography>
</div>
)}
</Paper>
);
};
const ImageGrid = ({ images }) => {
return (
<div className={styles.root}>
<GridList className={styles.gridList} cols={2.5}>
{images.map((image, i) => (
<GridListTile key={i}>
<img src={image} alt={`image-${i}`} />
</GridListTile>
))}
</GridList>
<br />
</div>
);
};
export default ActivityPost;
| 25.809524 | 79 | 0.520295 |
27b10c8831275757a2828745e03ca976c4403264 | 359 | js | JavaScript | server/api.js | sXule/HomeSense | 40e57b57e8084d9452c77baee73f7c92147b683e | [
"MIT"
] | null | null | null | server/api.js | sXule/HomeSense | 40e57b57e8084d9452c77baee73f7c92147b683e | [
"MIT"
] | null | null | null | server/api.js | sXule/HomeSense | 40e57b57e8084d9452c77baee73f7c92147b683e | [
"MIT"
] | null | null | null | var ApiRouting = require('./apirouting');
var Devices = require('./devices');
class Api extends ApiRouting
{
main()
{
return new Promise((resolve, reject) => {
resolve('This is api.main()');
});
}
devices()
{
return new Promise((resolve, reject) => {
var devices = new Devices(this.data, resolve, reject);
});
}
}
module.exports = Api;
| 16.318182 | 57 | 0.626741 |
27b10d1786495beae2203603620ae4dbd53007f0 | 4,398 | js | JavaScript | spec/git-tabular-diff-spec.js | jstritch/git-tabular-diff | a92b1830778dd7244bf844f842b207af41edd7fa | [
"MIT"
] | null | null | null | spec/git-tabular-diff-spec.js | jstritch/git-tabular-diff | a92b1830778dd7244bf844f842b207af41edd7fa | [
"MIT"
] | 3 | 2021-09-23T19:00:20.000Z | 2022-03-12T04:01:59.000Z | spec/git-tabular-diff-spec.js | jstritch/git-tabular-diff | a92b1830778dd7244bf844f842b207af41edd7fa | [
"MIT"
] | null | null | null | 'use babel';
import * as helper from './helpers';
import { promises as fs } from 'fs';
import GitTabularDiff from '../lib/git-tabular-diff';
import GitTabularDiffView from '../lib/git-tabular-diff-view';
import path from 'path';
const methodName = 'GitTabularDiff.compareSelected()';
const repositoryPath = process.cwd();
const verificationFile = path.join('spec', 'data', 'git-test-file.txt');
const verificationPath = path.join(repositoryPath, verificationFile);
const verificationText = 'git-tabular-diff verification file spec/data/git-test-file.txt\n';
const nonexistentFile = path.join('spec', 'data', 'lorem ipsum.txt');
const nonexistentText = 'Lorem ipsum dolor sit amet, consectetur adipiscing git tabular diff\n';
const exampleFile = path.join('spec', 'data', 'example.csv');
const examplePath = path.join(repositoryPath, exampleFile);
const exampleCopyFile = path.join('spec', 'data', 'example-copy.csv');
const exampleCopyPath = path.join(repositoryPath, exampleCopyFile);
const exampleModifiedFile = path.join('spec', 'data', 'example-modified.csv');
const exampleModifiedPath = path.join(repositoryPath, exampleModifiedFile);
const exampleSavedDiffFileV1 = path.join('spec', 'data', 'example-saved-v1.csv.gtd');
const exampleSavedDiffFileV2 = path.join('spec', 'data', 'example-saved-v2.csv.gtd');
const exampleSavedIgnoreCaseFileV1 = path.join('spec', 'data', 'example-saved-ignorecase-v1.csv.gtd');
const exampleSavedIgnoreCaseFileV2 = path.join('spec', 'data', 'example-saved-ignorecase-v2.csv.gtd');
const exampleSavedIgnoreWhitespaceFileV1 = path.join('spec', 'data', 'example-saved-ignorewhitespace-v1.csv.gtd');
const exampleSavedIgnoreWhitespaceFileV2 = path.join('spec', 'data', 'example-saved-ignorewhitespace-v2.csv.gtd');
const exampleSavedSplitFileV2 = path.join('spec', 'data', 'example-saved-ignorewhitespace-v2.csv.gtd');
const exampleSplitFile = path.join('spec', 'data', 'example-split.jpg.gtd');
describe(methodName, function() {
beforeEach(async function() {
await fs.writeFile(verificationPath, nonexistentText);
await fs.copyFile(exampleModifiedPath, examplePath);
});
afterEach(async function() {
await fs.writeFile(verificationPath, verificationText);
await fs.copyFile(exampleCopyPath, examplePath);
});
[
[exampleFile, false], [exampleFile, true],
[verificationFile, false], [verificationFile, true],
[exampleSavedDiffFileV1, false], [exampleSavedDiffFileV1, true],
[exampleSavedDiffFileV2, false], [exampleSavedDiffFileV2, true],
[exampleSavedIgnoreCaseFileV1, false], [exampleSavedIgnoreCaseFileV1, true],
[exampleSavedIgnoreCaseFileV2, false], [exampleSavedIgnoreCaseFileV2, true],
[exampleSavedIgnoreWhitespaceFileV1, false], [exampleSavedIgnoreWhitespaceFileV1, true],
[exampleSavedIgnoreWhitespaceFileV2, false], [exampleSavedIgnoreWhitespaceFileV2, true],
[exampleSavedSplitFileV2, false], [exampleSavedSplitFileV2, true],
[exampleSplitFile, true],
].forEach(([file, split]) => {
it(`opens a ${helper.getViewType(split)} view for modified file ${file}`, async function() {
GitTabularDiff.activate(null);
GitTabularDiff.fileSelector = helper.makeFileSelector(repositoryPath, file);
const id = await helper.openView(split);
expect(id.length).toBe(36);
const workspaceElement = atom.views.getView(atom.workspace);
expect(workspaceElement).toExist();
const gitTabularDiffElement = workspaceElement.querySelector(`[id='${id}']`);
expect(gitTabularDiffElement).toExist();
expect(gitTabularDiffElement).toHaveClass('git-tabular-diff');
expect(GitTabularDiffView.pendingFileDiffs.size).toBe(0);
});
});
[
[nonexistentFile, false], [nonexistentFile, true],
[exampleCopyFile, false], [exampleCopyFile, true],
].forEach(([file, split]) => {
it(`does not open a ${helper.getViewType(split)} view for ${file}`, async function() {
GitTabularDiff.activate(null);
GitTabularDiff.fileSelector = helper.makeFileSelector(repositoryPath, file);
const id = await helper.openView(split);
expect(id).toBeNull();
const workspaceElement = atom.views.getView(atom.workspace);
expect(workspaceElement).toExist();
expect(workspaceElement.querySelector('.git-tabular-diff')).not.toExist();
expect(GitTabularDiffView.pendingFileDiffs.size).toBe(0);
});
});
});
| 49.41573 | 114 | 0.736244 |
27b1682189d6219a8aefc9552f95e07d07283df2 | 7,037 | js | JavaScript | public/js/main.js | murum/murum_stuff_snap | c8e5fe04faa848b01ecd5b021c8392c674ab0d6d | [
"MIT"
] | null | null | null | public/js/main.js | murum/murum_stuff_snap | c8e5fe04faa848b01ecd5b021c8392c674ab0d6d | [
"MIT"
] | null | null | null | public/js/main.js | murum/murum_stuff_snap | c8e5fe04faa848b01ecd5b021c8392c674ab0d6d | [
"MIT"
] | null | null | null | function showPreview(e){var a=160/e.w,i=160/e.h,s=$("img#image-cropper").height(),r=$("img#image-cropper").width();$("img#image-preview").css({width:Math.round(i*r)+"px",height:Math.round(i*s)+"px",marginLeft:"-"+Math.round(a*e.x)+"px",marginTop:"-"+Math.round(i*e.y)+"px"}),$('input[name="x"]',"form.image-form-update").attr("value",e.x),$('input[name="y"]',"form.image-form-update").val(e.y),$('input[name="w"]',"form.image-form-update").val(e.w),$('input[name="h"]',"form.image-form-update").val(e.h),$('input[name="image-width"]',"form.image-form-update").val(r),$('input[name="image-height"]',"form.image-form-update").val(s)}function preloader(){if(document.images){var e=new Image;e.src="/images/logo-animate.gif"}}function progressHandlingFunction(e){e.lengthComputable&&$("progress").attr({value:e.loaded,max:e.total})}$(function(){preloader(),$(".navbar-brand img").hover(function(){$(this).attr("src","/images/logo-animate.gif")},function(){$(this).attr("src","/images/logo.png")}),$(".selectpicker").selectpicker();var e=$("input#image").fileinput({showPreview:!1,showRemove:!1,showUpload:!1,browseLabel:"Välj bild",browseIcon:""});$("input#image").on("change",function(){$("form.image-form").trigger("submit")}),$("button#modify-image").on("click",function(){$("div.image-cropper").removeClass("hidden"),$("div.card-create-forms").addClass("hidden");var e=$("img#image-cropper").data("Jcrop");e&&e.destroy(),setTimeout(function(){$("img#image-cropper").Jcrop({onChange:showPreview,onSelect:showPreview,aspectRatio:1}),$("img#image-cropper").css({width:"100%",height:"auto"})},500)}),$("form.image-form").on("submit",function(a){a.preventDefault();var i=new FormData($("form.image-form")[0]),s=$(this).attr("action"),r=$(this).attr("method"),t=$(this);$.ajax({url:s,type:r,xhr:function(){var e=$.ajaxSettings.xhr();return e.upload&&e.upload.addEventListener("progress",progressHandlingFunction,!1),e},success:function(a){if(a.success)$("div.ajax-error").remove(),$("div.image-form-modify").removeClass("hidden"),$("img#image-cropper").attr("src","/uploads/"+a.url).show(),$("img#image-preview").attr("src","/uploads/"+a.url),$('input[name="image-url"]',"form.image-form-update").val(a.url),$('input[name="image"]',"form.form-user-create").val("/uploads/"+a.url);else{if($("div.ajax-error").length)$("div.ajax-error").html(a.message);else{var i='<div class="alert alert-danger ajax-error">'+a.message+"</div>";$(i).insertBefore(t)}e.fileinput("reset")}},error:function(){if($("div.ajax-error").length)$("div.ajax-error").html("Systemerror");else{var e='<div class="alert alert-danger ajax-error">Systemerror</div>';$(e).insertBefore(t)}},data:i,cache:!1,contentType:!1,processData:!1})}),$("li.nav-item-bump a").on("click",function(e){e.preventDefault(),$(this).parent().toggleClass("active"),$("div.bump-form").toggleClass("hidden",1e3)});var a=function(){var e=0;return""!=$('input[name="snapname"]').val()&&e++,""!=$('input[name="kik"]').val()&&e++,""!=$('input[name="instagram"]').val()&&e++,e};$('input[name="snapname"]').on("keyup",function(){var e=a();$("span.cards-item-name-text-update").text($(this).val()),$("ul.cards-item-usernames").removeClass("cards-item-usernames-1"),$("ul.cards-item-usernames").removeClass("cards-item-usernames-2"),$("ul.cards-item-usernames").removeClass("cards-item-usernames-3"),$("ul.cards-item-usernames").addClass("cards-item-usernames-"+e)}),$('input[name="kik"]').on("focusout",function(){var e=$(this).val();$.ajax({url:"/kik_image/",type:"post",data:{kik:e},dataType:"json",success:function(e){$("div.cards-item-image img#image-preview").attr("src",e.source)}})}),$('input[name="snapname"]').on("keyup",function(){var e=a(),i=$(".cards-item-usernames-snapchat"),s=$("ul.cards-item-usernames"),r=$(".cards-item-name-text-update");""==$('input[name="kik"]').val()&&r.text($(this).val()),""!=$(this).val()?(i.removeClass("hidden"),$(".cards-item-usernames-kik").removeClass("first"),isMobile.phone||i.css({height:i.width(),"line-height":i.width()+"px"})):i.addClass("hidden"),s.removeClass("cards-item-usernames-1"),s.removeClass("cards-item-usernames-2"),s.removeClass("cards-item-usernames-3"),s.addClass("cards-item-usernames-"+e)}),$('input[name="kik"]').on("keyup",function(){var e=a(),i=$(".cards-item-usernames-kik"),s=$("ul.cards-item-usernames"),r=$(".cards-item-name-text-update");""==$('input[name="snapname"]').val()&&(r.text($(this).val()),i.addClass("first")),""!=$(this).val()?(i.removeClass("hidden"),isMobile.phone||i.css({height:i.width(),"line-height":i.width()+"px"})):i.addClass("hidden"),s.removeClass("cards-item-usernames-1"),s.removeClass("cards-item-usernames-2"),s.removeClass("cards-item-usernames-3"),s.addClass("cards-item-usernames-"+e)}),$('input[name="instagram"]').on("keyup",function(){var e=a(),i=$(".cards-item-usernames-instagram"),s=$("ul.cards-item-usernames");""!=$('input[name="instagram"]').val()?(i.removeClass("hidden"),isMobile.phone||i.css({height:i.width(),"line-height":i.width()+"px"})):i.addClass("hidden"),s.removeClass("cards-item-usernames-1"),s.removeClass("cards-item-usernames-2"),s.removeClass("cards-item-usernames-3"),s.addClass("cards-item-usernames-"+e)}),$('input[name="age"]').on("keyup",function(){$("span.cards-item-name-age-text").text($(this).val())}),$('textarea[name="description"]').on("keyup",function(){$("div.cards-item-description p").text($(this).val())}),$('input[name="sex"]').on("change",function(){switch($("div.cards-item-name i.icon").removeClass("icon-transgender"),$(this).val()){case"1":$("div.cards-item-name i.icon").addClass("icon-boysymbol"),$("div.cards-item-name i.icon").removeClass("icon-girlsymbol");break;case"2":$("div.cards-item-name i.icon").addClass("icon-girlsymbol"),$("div.cards-item-name i.icon").removeClass("icon-boysymbol")}}),$("button.skip-crop").on("click",function(){$("div.image-cropper").addClass("hidden"),$("div.card-create-forms").removeClass("hidden"),$("div.image-form-modify").removeClass("hidden")}),$("form.image-form-update").on("submit",function(e){if(e.preventDefault(),0==$("div.jcrop-hline").width())return $("a.skip-crop").trigger("click"),!1;var a=$(this).serializeArray(),i=$(this).attr("action"),s=$(this).attr("method");$.ajax({url:i,type:s,success:function(){$("div.image-cropper").addClass("hidden"),$("div.card-create-forms").removeClass("hidden"),$("div.image-form-modify").addClass("hidden")},data:a})}),isMobile.phone||($("ul.cards-item-usernames li").each(function(){$(this).css({height:parseInt($(this).width())+parseInt($(this).css("padding-left"))+parseInt($(this).css("padding-right")),"line-height":parseInt($(this).width())+parseInt($(this).css("padding-left"))+parseInt($(this).css("padding-right"))+"px"})}),$(window).resize(function(){$("ul.cards-item-usernames li").each(function(){$(this).css({height:parseInt($(this).width())+parseInt($(this).css("padding-left"))+parseInt($(this).css("padding-right")),"line-height":parseInt($(this).width())+parseInt($(this).css("padding-left"))+parseInt($(this).css("padding-right"))+"px"})})}))}); | 7,037 | 7,037 | 0.674009 |
27b22287e5a47e2955b16c54830f54fb697abc34 | 2,492 | js | JavaScript | libs/authentication.js | Fluidbyte/tetra | 9da0f53f0f5d4f4a7d364c20a870a35ff36e650c | [
"MIT"
] | 1 | 2018-12-29T09:05:43.000Z | 2018-12-29T09:05:43.000Z | libs/authentication.js | Fluidbyte/tetra | 9da0f53f0f5d4f4a7d364c20a870a35ff36e650c | [
"MIT"
] | null | null | null | libs/authentication.js | Fluidbyte/tetra | 9da0f53f0f5d4f4a7d364c20a870a35ff36e650c | [
"MIT"
] | null | null | null | var passwordHash = require('password-hash');
var Datastore = require('nedb');
module.exports = function (req, res, next) {
// Split params
var params = req.path.replace(/^\/|\/$/g, '').split('/');
// Get type
var type = params[0];
// Pass-through for session authentication
if (type === 'session' && req.method === 'POST') {
next();
return false;
}
// Check for session auth
if (req.session && req.session.hasOwnProperty('user')) {
// Ensure type
if (!req.session.user.hasOwnProperty('type')) {
res.send(401, 'Invalid session');
return false;
}
// Set type
req.userType = req.session.user.type;
next();
return false;
}
// Initiate database
var db = new Datastore({
filename: 'conf/users.db',
autoload: true
});
// Ensure index
db.ensureIndex({
fieldName: 'username',
unique: true
}, function (err) {
if (err) {
console.log(err);
}
});
var checkCreds = function (username, password, cb) {
db.find({
username: username
}, function (err, data) {
if (err) {
cb(false);
return false;
}
// Check username
if (!data.length) {
cb(false);
return false;
}
// Check data
if (!passwordHash.verify(password, data[0].password)) {
cb(false);
return false;
}
// Set user type in the request object
req.userType = data[0].type;
cb(true);
return true;
});
};
// Grab the "Authorization" header.
var auth = req.get('authorization');
// On the first request, the "Authorization" header won't exist, so we'll set a Response
// header that prompts the browser to ask for a username and password.
if (!auth) {
res.set('WWW-Authenticate', 'Basic realm="Authorization Required"');
// If the user cancels the dialog, or enters the password wrong too many times,
// show the Access Restricted error message.
return res.status(401).send('Authorization Required');
} else {
// If the user enters a username and password, the browser re-requests the route
// and includes a Base64 string of those credentials.
var credentials = new Buffer(auth.split(' ').pop(), 'base64').toString('ascii').split(':');
checkCreds(credentials[0], credentials[1], function (result) {
if (result) {
next();
} else {
res.status(403).send('Access Denied (incorrect credentials)');
}
});
}
};
| 25.171717 | 95 | 0.595104 |
27b2503f89c9670b1463ee873d1c9fb2ccd4d17d | 2,148 | js | JavaScript | graphics/app/countdown.js | thebiggame/nodecg_bundle | 1b4b7fdf7cebe28996f6f94135275ce244a78d0a | [
"Apache-2.0"
] | null | null | null | graphics/app/countdown.js | thebiggame/nodecg_bundle | 1b4b7fdf7cebe28996f6f94135275ce244a78d0a | [
"Apache-2.0"
] | 2 | 2018-11-06T12:41:48.000Z | 2019-02-12T00:50:02.000Z | graphics/app/countdown.js | thebiggame/nodecg_bundle | 1b4b7fdf7cebe28996f6f94135275ce244a78d0a | [
"Apache-2.0"
] | null | null | null | (function () {
'use strict';
const countRep = nodecg.Replicant('countdown:data');
const countRepName = nodecg.Replicant('countdown:name');
const countRepActive = nodecg.Replicant('countdown:active');
const timeNode = document.getElementById('cdown-time');
const nameNode = document.getElementById('cdown-name');
const timerNode = document.getElementById('timer-outer');
const innerNode = document.getElementById('timer-inner');
const timeline = window.countdownTL;
countRep.on('change', newVal => {
timeNode.textContent = newVal.formatted;
timeline.call(() => {
});
if (newVal.raw <= 60) {
TweenLite.to(timeNode, 5, {
color: "rgb(255, 0, 0)",
ease: Expo.easeOut
});
} else {
timeNode.style.color = "rgb(255, 255, 255)";
}
});
countRepName.on('change', newVal => {
nameNode.textContent = newVal;
});
countRepActive.on('change', newVal => {
timeline.call(() => {
});
if (newVal) {
timeline.add('in');
timeline.to(timerNode, 0.75, {
opacity: 1,
left: "0%",
ease: Circ.easeOut
}, 'in');
timeline.to(innerNode, 0.75, {
left: "0%",
ease: Circ.easeOut
}, 'in+=0.3');
timeline.play('in');
} else {
timeline.add('out');
timeline.to(innerNode, 0.75, {
left: "-100%",
ease: Circ.easeIn
}, 'out');
timeline.to(timerNode, 0.75, {
opacity: 0,
left: "-100%",
ease: Circ.easeIn
}, 'out+=0.2');
timeline.play('out');
}
});
function darkener(darkenornot) {
const darkenNode = document.getElementById('darkener');
if (darkenornot) {
TweenLite.to(darkenNode, 2.5, {
opacity: 0.5,
ease: Power4.easeOut
});
} else {
TweenLite.to(darkenNode, 2, {
opacity: 0,
ease: Sine.easeIn
});
}
}
})();
| 28.263158 | 61 | 0.496276 |
27b25925694ad1f8e389558b9870e78b5ad440a8 | 222,636 | js | JavaScript | public/js/box2d.min.js | t100n/cesium-explorer | ba309207ee277486fc44410380a1cd78cbfb01bd | [
"MIT"
] | null | null | null | public/js/box2d.min.js | t100n/cesium-explorer | ba309207ee277486fc44410380a1cd78cbfb01bd | [
"MIT"
] | null | null | null | public/js/box2d.min.js | t100n/cesium-explorer | ba309207ee277486fc44410380a1cd78cbfb01bd | [
"MIT"
] | null | null | null | box2D={},box2D.collision={},box2D.collision.B2AABB=function(){this.lowerBound=new box2D.common.math.B2Vec2,this.upperBound=new box2D.common.math.B2Vec2},box2D.collision.B2AABB.__name__=!0,box2D.collision.B2AABB.prototype={isValid:function(){var t=this.upperBound.x-this.lowerBound.x,o=this.upperBound.y-this.lowerBound.y,i=t>=0&&o>=0;return i=i&&this.lowerBound.isValid()&&this.upperBound.isValid()},getCenter:function(){return new box2D.common.math.B2Vec2((this.lowerBound.x+this.upperBound.x)/2,(this.lowerBound.y+this.upperBound.y)/2)},getExtents:function(){return new box2D.common.math.B2Vec2((this.upperBound.x-this.lowerBound.x)/2,(this.upperBound.y-this.lowerBound.y)/2)},contains:function(t){var o=!0;return o=o&&this.lowerBound.x<=t.lowerBound.x,o=o&&this.lowerBound.y<=t.lowerBound.y,o=o&&t.upperBound.x<=this.upperBound.x,o=o&&t.upperBound.y<=this.upperBound.y},rayCast:function(t,o){var i,s,n,e,m,a=-1.7976931348623157e308,c=1.7976931348623157e308,l=o.p1.x,r=o.p1.y,_=o.p2.x-o.p1.x,h=o.p2.y-o.p1.y,x=Math.abs(_),y=Math.abs(h),u=t.normal;if(2.2250738585072014e-308>x){if(l<this.lowerBound.x||this.upperBound.x<l)return!1}else if(i=1/_,s=(this.lowerBound.x-l)*i,n=(this.upperBound.x-l)*i,m=-1,s>n&&(e=s,s=n,n=e,m=1),s>a&&(u.x=m,u.y=0,a=s),c=Math.min(c,n),a>c)return!1;if(2.2250738585072014e-308>y){if(r<this.lowerBound.y||this.upperBound.y<r)return!1}else if(i=1/h,s=(this.lowerBound.y-r)*i,n=(this.upperBound.y-r)*i,m=-1,s>n&&(e=s,s=n,n=e,m=1),s>a&&(u.y=m,u.x=0,a=s),c=Math.min(c,n),a>c)return!1;return t.fraction=a,!0},testOverlap:function(t){var o=t.lowerBound.x-this.upperBound.x,i=t.lowerBound.y-this.upperBound.y,s=this.lowerBound.x-t.upperBound.x,n=this.lowerBound.y-t.upperBound.y;return o>0||i>0?!1:s>0||n>0?!1:!0},combine:function(t,o){this.lowerBound.x=Math.min(t.lowerBound.x,o.lowerBound.x),this.lowerBound.y=Math.min(t.lowerBound.y,o.lowerBound.y),this.upperBound.x=Math.max(t.upperBound.x,o.upperBound.x),this.upperBound.y=Math.max(t.upperBound.y,o.upperBound.y)},__class__:box2D.collision.B2AABB},box2D.common={},box2D.common.math={},box2D.common.math.B2Vec2=function(t,o){null==o&&(o=0),null==t&&(t=0),this.x=t,this.y=o},box2D.common.math.B2Vec2.__name__=!0,box2D.common.math.B2Vec2.make=function(t,o){return new box2D.common.math.B2Vec2(t,o)},box2D.common.math.B2Vec2.prototype={setZero:function(){this.x=0,this.y=0},set:function(t,o){null==o&&(o=0),null==t&&(t=0),this.x=t,this.y=o},setV:function(t){this.x=t.x,this.y=t.y},getNegative:function(){return new box2D.common.math.B2Vec2(-this.x,-this.y)},negativeSelf:function(){this.x=-this.x,this.y=-this.y},copy:function(){return new box2D.common.math.B2Vec2(this.x,this.y)},add:function(t){this.x+=t.x,this.y+=t.y},subtract:function(t){this.x-=t.x,this.y-=t.y},multiply:function(t){this.x*=t,this.y*=t},mulM:function(t){var o=this.x;this.x=t.col1.x*o+t.col2.x*this.y,this.y=t.col1.y*o+t.col2.y*this.y},mulTM:function(t){var o=box2D.common.math.B2Math.dot(this,t.col1);this.y=box2D.common.math.B2Math.dot(this,t.col2),this.x=o},crossVF:function(t){var o=this.x;this.x=t*this.y,this.y=-t*o},crossFV:function(t){var o=this.x;this.x=-t*this.y,this.y=t*o},minV:function(t){this.x=this.x<t.x?this.x:t.x,this.y=this.y<t.y?this.y:t.y},maxV:function(t){this.x=this.x>t.x?this.x:t.x,this.y=this.y>t.y?this.y:t.y},abs:function(){this.x<0&&(this.x=-this.x),this.y<0&&(this.y=-this.y)},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthSquared:function(){return this.x*this.x+this.y*this.y},normalize:function(){var t=Math.sqrt(this.x*this.x+this.y*this.y);if(2.2250738585072014e-308>t)return 0;var o=1/t;return this.x*=o,this.y*=o,t},isValid:function(){return box2D.common.math.B2Math.isValid(this.x)&&box2D.common.math.B2Math.isValid(this.y)},__class__:box2D.common.math.B2Vec2},box2D.collision.ClipVertex=function(){this.v=new box2D.common.math.B2Vec2,this.id=new box2D.collision.B2ContactID},box2D.collision.ClipVertex.__name__=!0,box2D.collision.ClipVertex.prototype={set:function(t){this.v.setV(t.v),this.id.set(t.id)},__class__:box2D.collision.ClipVertex},box2D.collision.B2ContactID=function(){this.features=new box2D.collision.Features,this.features._m_id=this},box2D.collision.B2ContactID.__name__=!0,box2D.collision.B2ContactID.prototype={set:function(t){this.set_key(t._key)},copy:function(){var t=new box2D.collision.B2ContactID;return t.set_key(this.get_key()),t},get_key:function(){return this._key},set_key:function(t){return this._key=t,this.features._referenceEdge=255&this._key,this.features._incidentEdge=(65280&this._key)>>8&255,this.features._incidentVertex=(16711680&this._key)>>16&255,this.features._flip=(-16777216&this._key)>>24&255,this._key},__class__:box2D.collision.B2ContactID},box2D.collision.Features=function(){},box2D.collision.Features.__name__=!0,box2D.collision.Features.prototype={get_referenceEdge:function(){return this._referenceEdge},set_referenceEdge:function(t){return this._referenceEdge=t,this._m_id._key=-256&this._m_id._key|255&this._referenceEdge,t},get_incidentEdge:function(){return this._incidentEdge},set_incidentEdge:function(t){return this._incidentEdge=t,this._m_id._key=-65281&this._m_id._key|this._incidentEdge<<8&65280,t},get_incidentVertex:function(){return this._incidentVertex},set_incidentVertex:function(t){return this._incidentVertex=t,this._m_id._key=-16711681&this._m_id._key|this._incidentVertex<<16&16711680,t},get_flip:function(){return this._flip},set_flip:function(t){return this._flip=t,this._m_id._key=16777215&this._m_id._key|this._flip<<24&-16777216,t},__class__:box2D.collision.Features},box2D.collision.B2Collision=function(){},box2D.collision.B2Collision.__name__=!0,box2D.collision.B2Collision.clipSegmentToLine=function(t,o,i,s){var n,e=0;n=o[0];var m=n.v;n=o[1];var a=n.v,c=i.x*m.x+i.y*m.y-s,l=i.x*a.x+i.y*a.y-s;if(0>=c&&t[e++].set(o[0]),0>=l&&t[e++].set(o[1]),0>c*l){var r=c/(c-l);n=t[e];var _=n.v;_.x=m.x+r*(a.x-m.x),_.y=m.y+r*(a.y-m.y),n=t[e];var h;c>0?(h=o[0],n.id=h.id):(h=o[1],n.id=h.id),++e}return e},box2D.collision.B2Collision.edgeSeparation=function(t,o,i,s,n){var e,m,a=(t.m_vertexCount,t.m_vertices),c=t.m_normals,l=s.m_vertexCount,r=s.m_vertices;e=o.R,m=c[i];var _=e.col1.x*m.x+e.col2.x*m.y,h=e.col1.y*m.x+e.col2.y*m.y;e=n.R;for(var x=e.col1.x*_+e.col1.y*h,y=e.col2.x*_+e.col2.y*h,u=0,p=1.7976931348623157e308,d=0;l>d;){var B=d++;m=r[B];var b=m.x*x+m.y*y;p>b&&(p=b,u=B)}m=a[i],e=o.R;var D=o.position.x+(e.col1.x*m.x+e.col2.x*m.y),f=o.position.y+(e.col1.y*m.x+e.col2.y*m.y);m=r[u],e=n.R;var g=n.position.x+(e.col1.x*m.x+e.col2.x*m.y),v=n.position.y+(e.col1.y*m.x+e.col2.y*m.y);g-=D,v-=f;var A=g*_+v*h;return A},box2D.collision.B2Collision.findMaxSeparation=function(t,o,i,s,n){var e,m,a=o.m_vertexCount,c=o.m_normals;m=n.R,e=s.m_centroid;var l=n.position.x+(m.col1.x*e.x+m.col2.x*e.y),r=n.position.y+(m.col1.y*e.x+m.col2.y*e.y);m=i.R,e=o.m_centroid,l-=i.position.x+(m.col1.x*e.x+m.col2.x*e.y),r-=i.position.y+(m.col1.y*e.x+m.col2.y*e.y);for(var _=l*i.R.col1.x+r*i.R.col1.y,h=l*i.R.col2.x+r*i.R.col2.y,x=0,y=-1.7976931348623157e308,u=0;a>u;){var p=u++;e=c[p];var d=e.x*_+e.y*h;d>y&&(y=d,x=p)}var B,b=box2D.collision.B2Collision.edgeSeparation(o,i,x,s,n);B=x-1>=0?x-1:a-1;var D,f=box2D.collision.B2Collision.edgeSeparation(o,i,B,s,n);D=a>x+1?x+1:0;var g,v,A,w=box2D.collision.B2Collision.edgeSeparation(o,i,D,s,n);if(f>b&&f>w)A=-1,g=B,v=f;else{if(!(w>b))return t[0]=x,b;A=1,g=D,v=w}for(;;){if(x=-1==A?g-1>=0?g-1:a-1:a>g+1?g+1:0,b=box2D.collision.B2Collision.edgeSeparation(o,i,x,s,n),!(b>v))break;g=x,v=b}return t[0]=g,v},box2D.collision.B2Collision.findIncidentEdge=function(t,o,i,s,n,e){var m,a,c=(o.m_vertexCount,o.m_normals),l=n.m_vertexCount,r=n.m_vertices,_=n.m_normals;m=i.R,a=c[s];var h=m.col1.x*a.x+m.col2.x*a.y,x=m.col1.y*a.x+m.col2.y*a.y;m=e.R;var y=m.col1.x*h+m.col1.y*x;x=m.col2.x*h+m.col2.y*x,h=y;for(var u=0,p=1.7976931348623157e308,d=0;l>d;){var B=d++;a=_[B];var b=h*a.x+x*a.y;p>b&&(p=b,u=B)}var D,f,g=u;f=l>g+1?g+1:0,D=t[0],a=r[g],m=e.R,D.v.x=e.position.x+(m.col1.x*a.x+m.col2.x*a.y),D.v.y=e.position.y+(m.col1.y*a.x+m.col2.y*a.y),D.id.features.set_referenceEdge(s),D.id.features.set_incidentEdge(g),D.id.features.set_incidentVertex(0),D=t[1],a=r[f],m=e.R,D.v.x=e.position.x+(m.col1.x*a.x+m.col2.x*a.y),D.v.y=e.position.y+(m.col1.y*a.x+m.col2.y*a.y),D.id.features.set_referenceEdge(s),D.id.features.set_incidentEdge(f),D.id.features.set_incidentVertex(1)},box2D.collision.B2Collision.makeClipPointVector=function(){var t=new Array;return t[0]=new box2D.collision.ClipVertex,t[1]=new box2D.collision.ClipVertex,t},box2D.collision.B2Collision.collidePolygons=function(t,o,i,s,n){var e;t.m_pointCount=0;var m=o.m_radius+s.m_radius,a=0;box2D.collision.B2Collision.s_edgeAO[0]=a;var c=box2D.collision.B2Collision.findMaxSeparation(box2D.collision.B2Collision.s_edgeAO,o,i,s,n);if(a=box2D.collision.B2Collision.s_edgeAO[0],!(c>m)){var l=0;box2D.collision.B2Collision.s_edgeBO[0]=l;var r=box2D.collision.B2Collision.findMaxSeparation(box2D.collision.B2Collision.s_edgeBO,s,n,o,i);if(l=box2D.collision.B2Collision.s_edgeBO[0],!(r>m)){var _,h,x,y,u,p,d,B=.98,b=.001;r>B*c+b?(_=s,h=o,x=n,y=i,u=l,t.m_type=box2D.collision.B2Manifold.e_faceB,p=1):(_=o,h=s,x=i,y=n,u=a,t.m_type=box2D.collision.B2Manifold.e_faceA,p=0);var D=box2D.collision.B2Collision.s_incidentEdge;box2D.collision.B2Collision.findIncidentEdge(D,_,x,u,h,y);var f,g=_.m_vertexCount,v=_.m_vertices,A=v[u];f=g>u+1?v[u+1|0]:v[0];var w=box2D.collision.B2Collision.s_localTangent;w.set(f.x-A.x,f.y-A.y),w.normalize();var V=box2D.collision.B2Collision.s_localNormal;V.x=w.y,V.y=-w.x;var C=box2D.collision.B2Collision.s_planePoint;C.set(.5*(A.x+f.x),.5*(A.y+f.y));var M=box2D.collision.B2Collision.s_tangent;d=x.R,M.x=d.col1.x*w.x+d.col2.x*w.y,M.y=d.col1.y*w.x+d.col2.y*w.y;var S=box2D.collision.B2Collision.s_tangent2;S.x=-M.x,S.y=-M.y;var I=box2D.collision.B2Collision.s_normal;I.x=M.y,I.y=-M.x;var j=box2D.collision.B2Collision.s_v11,L=box2D.collision.B2Collision.s_v12;j.x=x.position.x+(d.col1.x*A.x+d.col2.x*A.y),j.y=x.position.y+(d.col1.y*A.x+d.col2.y*A.y),L.x=x.position.x+(d.col1.x*f.x+d.col2.x*f.y),L.y=x.position.y+(d.col1.y*f.x+d.col2.y*f.y);var P,J=I.x*j.x+I.y*j.y,F=-M.x*j.x-M.y*j.y+m,T=M.x*L.x+M.y*L.y+m,R=box2D.collision.B2Collision.s_clipPoints1,z=box2D.collision.B2Collision.s_clipPoints2;if(P=box2D.collision.B2Collision.clipSegmentToLine(R,D,S,F),!(2>P||(P=box2D.collision.B2Collision.clipSegmentToLine(z,R,M,T),2>P))){t.m_localPlaneNormal.setV(V),t.m_localPoint.setV(C);for(var k=0,q=0,E=box2D.common.B2Settings.b2_maxManifoldPoints;E>q;){var K=q++;e=z[K];var O=I.x*e.v.x+I.y*e.v.y-J;if(m>=O){var W=t.m_points[k];d=y.R;var N=e.v.x-y.position.x,X=e.v.y-y.position.y;W.m_localPoint.x=N*d.col1.x+X*d.col1.y,W.m_localPoint.y=N*d.col2.x+X*d.col2.y,W.m_id.set(e.id),W.m_id.features.set_flip(p),++k}}t.m_pointCount=k}}}},box2D.collision.B2Collision.collideCircles=function(t,o,i,s,n){t.m_pointCount=0;var e,m;e=i.R,m=o.m_p;var a=i.position.x+(e.col1.x*m.x+e.col2.x*m.y),c=i.position.y+(e.col1.y*m.x+e.col2.y*m.y);e=n.R,m=s.m_p;var l=n.position.x+(e.col1.x*m.x+e.col2.x*m.y),r=n.position.y+(e.col1.y*m.x+e.col2.y*m.y),_=l-a,h=r-c,x=_*_+h*h,y=o.m_radius+s.m_radius;x>y*y||(t.m_type=box2D.collision.B2Manifold.e_circles,t.m_localPoint.setV(o.m_p),t.m_localPlaneNormal.setZero(),t.m_pointCount=1,t.m_points[0].m_localPoint.setV(s.m_p),t.m_points[0].m_id.set_key(0))},box2D.collision.B2Collision.collidePolygonAndCircle=function(t,o,i,s,n){t.m_pointCount=0;var e,m,a,c;c=n.R,a=s.m_p;var l=n.position.x+(c.col1.x*a.x+c.col2.x*a.y),r=n.position.y+(c.col1.y*a.x+c.col2.y*a.y);e=l-i.position.x,m=r-i.position.y,c=i.R;for(var _=e*c.col1.x+m*c.col1.y,h=e*c.col2.x+m*c.col2.y,x=0,y=-1.7976931348623157e308,u=o.m_radius+s.m_radius,p=o.m_vertexCount,d=o.m_vertices,B=o.m_normals,b=0;p>b;){var D=b++;a=d[D],e=_-a.x,m=h-a.y,a=B[D];var f=a.x*e+a.y*m;if(f>u)return;f>y&&(y=f,x=D)}var g,v=x;g=p>v+1?v+1:0;var A=d[v],w=d[g];if(2.2250738585072014e-308>y)return t.m_pointCount=1,t.m_type=box2D.collision.B2Manifold.e_faceA,t.m_localPlaneNormal.setV(B[x]),t.m_localPoint.x=.5*(A.x+w.x),t.m_localPoint.y=.5*(A.y+w.y),t.m_points[0].m_localPoint.setV(s.m_p),void t.m_points[0].m_id.set_key(0);var V=(_-A.x)*(w.x-A.x)+(h-A.y)*(w.y-A.y),C=(_-w.x)*(A.x-w.x)+(h-w.y)*(A.y-w.y);if(0>=V){if((_-A.x)*(_-A.x)+(h-A.y)*(h-A.y)>u*u)return;t.m_pointCount=1,t.m_type=box2D.collision.B2Manifold.e_faceA,t.m_localPlaneNormal.x=_-A.x,t.m_localPlaneNormal.y=h-A.y,t.m_localPlaneNormal.normalize(),t.m_localPoint.setV(A),t.m_points[0].m_localPoint.setV(s.m_p),t.m_points[0].m_id.set_key(0)}else if(0>=C){if((_-w.x)*(_-w.x)+(h-w.y)*(h-w.y)>u*u)return;t.m_pointCount=1,t.m_type=box2D.collision.B2Manifold.e_faceA,t.m_localPlaneNormal.x=_-w.x,t.m_localPlaneNormal.y=h-w.y,t.m_localPlaneNormal.normalize(),t.m_localPoint.setV(w),t.m_points[0].m_localPoint.setV(s.m_p),t.m_points[0].m_id.set_key(0)}else{var M=.5*(A.x+w.x),S=.5*(A.y+w.y);if(y=(_-M)*B[v].x+(h-S)*B[v].y,y>u)return;t.m_pointCount=1,t.m_type=box2D.collision.B2Manifold.e_faceA,t.m_localPlaneNormal.x=B[v].x,t.m_localPlaneNormal.y=B[v].y,t.m_localPlaneNormal.normalize(),t.m_localPoint.set(M,S),t.m_points[0].m_localPoint.setV(s.m_p),t.m_points[0].m_id.set_key(0)}},box2D.collision.B2Collision.testOverlap=function(t,o){var i=o.lowerBound,s=t.upperBound,n=i.x-s.x,e=i.y-s.y;i=t.lowerBound,s=o.upperBound;var m=i.x-s.x,a=i.y-s.y;return n>0||e>0?!1:m>0||a>0?!1:!0},box2D.collision.B2ContactPoint=function(){this.position=new box2D.common.math.B2Vec2,this.velocity=new box2D.common.math.B2Vec2,this.normal=new box2D.common.math.B2Vec2,this.id=new box2D.collision.B2ContactID},box2D.collision.B2ContactPoint.__name__=!0,box2D.collision.B2ContactPoint.prototype={__class__:box2D.collision.B2ContactPoint},box2D.collision.B2Simplex=function(){this.m_v1=new box2D.collision.B2SimplexVertex,this.m_v2=new box2D.collision.B2SimplexVertex,this.m_v3=new box2D.collision.B2SimplexVertex,this.m_vertices=new Array,this.m_vertices[0]=this.m_v1,this.m_vertices[1]=this.m_v2,this.m_vertices[2]=this.m_v3},box2D.collision.B2Simplex.__name__=!0,box2D.collision.B2Simplex.prototype={readCache:function(t,o,i,s,n){box2D.common.B2Settings.b2Assert(0<=t.count&&t.count<=3);var e,m;this.m_count=t.count;for(var a,c=this.m_vertices,l=0,r=this.m_count;r>l;){var _=l++;a=c[_],a.indexA=t.indexA[_],a.indexB=t.indexB[_],e=o.getVertex(a.indexA),m=s.getVertex(a.indexB),a.wA=box2D.common.math.B2Math.mulX(i,e),a.wB=box2D.common.math.B2Math.mulX(n,m),a.w=box2D.common.math.B2Math.subtractVV(a.wB,a.wA),a.a=0}if(this.m_count>1){var h=t.metric,x=this.getMetric();(.5*h>x||x>2*h||2.2250738585072014e-308>x)&&(this.m_count=0)}0==this.m_count&&(a=c[0],a.indexA=0,a.indexB=0,e=o.getVertex(0),m=s.getVertex(0),a.wA=box2D.common.math.B2Math.mulX(i,e),a.wB=box2D.common.math.B2Math.mulX(n,m),a.w=box2D.common.math.B2Math.subtractVV(a.wB,a.wA),this.m_count=1)},writeCache:function(t){t.metric=this.getMetric(),t.count=0|this.m_count;for(var o=this.m_vertices,i=0,s=this.m_count;s>i;){var n=i++;t.indexA[n]=0|o[n].indexA,t.indexB[n]=0|o[n].indexB}},getSearchDirection:function(){var t=this.m_count;switch(t){case 1:return this.m_v1.w.getNegative();case 2:var o=box2D.common.math.B2Math.subtractVV(this.m_v2.w,this.m_v1.w),i=box2D.common.math.B2Math.crossVV(o,this.m_v1.w.getNegative());return i>0?box2D.common.math.B2Math.crossFV(1,o):box2D.common.math.B2Math.crossVF(o,1);default:return box2D.common.B2Settings.b2Assert(!1),new box2D.common.math.B2Vec2}},getClosestPoint:function(){var t=this.m_count;switch(t){case 0:return box2D.common.B2Settings.b2Assert(!1),new box2D.common.math.B2Vec2;case 1:return this.m_v1.w;case 2:return new box2D.common.math.B2Vec2(this.m_v1.a*this.m_v1.w.x+this.m_v2.a*this.m_v2.w.x,this.m_v1.a*this.m_v1.w.y+this.m_v2.a*this.m_v2.w.y);default:return box2D.common.B2Settings.b2Assert(!1),new box2D.common.math.B2Vec2}},getWitnessPoints:function(t,o){var i=this.m_count;switch(i){case 0:box2D.common.B2Settings.b2Assert(!1);break;case 1:t.setV(this.m_v1.wA),o.setV(this.m_v1.wB);break;case 2:t.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x,t.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y,o.x=this.m_v1.a*this.m_v1.wB.x+this.m_v2.a*this.m_v2.wB.x,o.y=this.m_v1.a*this.m_v1.wB.y+this.m_v2.a*this.m_v2.wB.y;break;case 3:o.x=t.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x+this.m_v3.a*this.m_v3.wA.x,o.y=t.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y+this.m_v3.a*this.m_v3.wA.y;break;default:box2D.common.B2Settings.b2Assert(!1)}},getMetric:function(){var t=this.m_count;switch(t){case 0:return box2D.common.B2Settings.b2Assert(!1),0;case 1:return 0;case 2:return box2D.common.math.B2Math.subtractVV(this.m_v1.w,this.m_v2.w).length();case 3:return box2D.common.math.B2Math.crossVV(box2D.common.math.B2Math.subtractVV(this.m_v2.w,this.m_v1.w),box2D.common.math.B2Math.subtractVV(this.m_v3.w,this.m_v1.w));default:return box2D.common.B2Settings.b2Assert(!1),0}},solve2:function(){var t=this.m_v1.w,o=this.m_v2.w,i=box2D.common.math.B2Math.subtractVV(o,t),s=-(t.x*i.x+t.y*i.y);if(0>=s)return this.m_v1.a=1,void(this.m_count=1);var n=o.x*i.x+o.y*i.y;if(0>=n)return this.m_v2.a=1,this.m_count=1,void this.m_v1.set(this.m_v2);var e=1/(n+s);this.m_v1.a=n*e,this.m_v2.a=s*e,this.m_count=2},solve3:function(){var t=this.m_v1.w,o=this.m_v2.w,i=this.m_v3.w,s=box2D.common.math.B2Math.subtractVV(o,t),n=box2D.common.math.B2Math.dot(t,s),e=box2D.common.math.B2Math.dot(o,s),m=e,a=-n,c=box2D.common.math.B2Math.subtractVV(i,t),l=box2D.common.math.B2Math.dot(t,c),r=box2D.common.math.B2Math.dot(i,c),_=r,h=-l,x=box2D.common.math.B2Math.subtractVV(i,o),y=box2D.common.math.B2Math.dot(o,x),u=box2D.common.math.B2Math.dot(i,x),p=u,d=-y,B=box2D.common.math.B2Math.crossVV(s,c),b=B*box2D.common.math.B2Math.crossVV(o,i),D=B*box2D.common.math.B2Math.crossVV(i,t),f=B*box2D.common.math.B2Math.crossVV(t,o);if(0>=a&&0>=h)return this.m_v1.a=1,void(this.m_count=1);if(m>0&&a>0&&0>=f){var g=1/(m+a);return this.m_v1.a=m*g,this.m_v2.a=a*g,void(this.m_count=2)}if(_>0&&h>0&&0>=D){var v=1/(_+h);return this.m_v1.a=_*v,this.m_v3.a=h*v,this.m_count=2,void this.m_v2.set(this.m_v3)}if(0>=m&&0>=d)return this.m_v2.a=1,this.m_count=1,void this.m_v1.set(this.m_v2);if(0>=_&&0>=p)return this.m_v3.a=1,this.m_count=1,void this.m_v1.set(this.m_v3);if(p>0&&d>0&&0>=b){var A=1/(p+d);return this.m_v2.a=p*A,this.m_v3.a=d*A,this.m_count=2,void this.m_v1.set(this.m_v3)}var w=1/(b+D+f);this.m_v1.a=b*w,this.m_v2.a=D*w,this.m_v3.a=f*w,this.m_count=3},__class__:box2D.collision.B2Simplex},box2D.collision.B2SimplexVertex=function(){},box2D.collision.B2SimplexVertex.__name__=!0,box2D.collision.B2SimplexVertex.prototype={set:function(t){this.wA.setV(t.wA),this.wB.setV(t.wB),this.w.setV(t.w),this.a=t.a,this.indexA=t.indexA,this.indexB=t.indexB},__class__:box2D.collision.B2SimplexVertex},box2D.collision.B2Distance=function(){},box2D.collision.B2Distance.__name__=!0,box2D.collision.B2Distance.distance=function(t,o,i){++box2D.collision.B2Distance.b2_gjkCalls;var s=i.proxyA,n=i.proxyB,e=i.transformA,m=i.transformB,a=box2D.collision.B2Distance.s_simplex;a.readCache(o,s,e,n,m);for(var c,l=a.m_vertices,r=20,_=box2D.collision.B2Distance.s_saveA,h=box2D.collision.B2Distance.s_saveB,x=0,y=a.getClosestPoint(),u=y.lengthSquared(),p=u,d=0;r>d;){x=a.m_count;for(var B=0;x>B;){var b=B++;_[b]=l[b].indexA,h[b]=l[b].indexB}var B=a.m_count;switch(B){case 1:break;case 2:a.solve2();break;case 3:a.solve3();break;default:box2D.common.B2Settings.b2Assert(!1)}if(3==a.m_count)break;c=a.getClosestPoint(),p=c.lengthSquared(),u=p;var D=a.getSearchDirection();if(D.lengthSquared()<0)break;var f=l[a.m_count],g=s.getSupport(box2D.common.math.B2Math.mulTMV(e.R,D.getNegative()));f.indexA=0|g,f.wA=box2D.common.math.B2Math.mulX(e,s.getVertex(f.indexA));var g=n.getSupport(box2D.common.math.B2Math.mulTMV(m.R,D));f.indexB=0|g,f.wB=box2D.common.math.B2Math.mulX(m,n.getVertex(f.indexB)),f.w=box2D.common.math.B2Math.subtractVV(f.wB,f.wA),++d,++box2D.collision.B2Distance.b2_gjkIters;for(var v=!1,B=0;x>B;){var b=B++;if(f.indexA==_[b]&&f.indexB==h[b]){v=!0;break}}if(v)break;++a.m_count}var g=box2D.common.math.B2Math.max(box2D.collision.B2Distance.b2_gjkMaxIters,d);if(box2D.collision.B2Distance.b2_gjkMaxIters=0|g,a.getWitnessPoints(t.pointA,t.pointB),t.distance=box2D.common.math.B2Math.subtractVV(t.pointA,t.pointB).length(),t.iterations=d,a.writeCache(o),i.useRadii){var A=s.m_radius,w=n.m_radius;if(t.distance>A+w&&t.distance>2.2250738585072014e-308){t.distance-=A+w;var V=box2D.common.math.B2Math.subtractVV(t.pointB,t.pointA);V.normalize(),t.pointA.x+=A*V.x,t.pointA.y+=A*V.y,t.pointB.x-=w*V.x,t.pointB.y-=w*V.y}else c=new box2D.common.math.B2Vec2,c.x=.5*(t.pointA.x+t.pointB.x),c.y=.5*(t.pointA.y+t.pointB.y),t.pointA.x=t.pointB.x=c.x,t.pointA.y=t.pointB.y=c.y,t.distance=0}},box2D.collision.B2DistanceInput=function(){},box2D.collision.B2DistanceInput.__name__=!0,box2D.collision.B2DistanceInput.prototype={__class__:box2D.collision.B2DistanceInput},box2D.collision.B2DistanceOutput=function(){this.pointA=new box2D.common.math.B2Vec2,this.pointB=new box2D.common.math.B2Vec2},box2D.collision.B2DistanceOutput.__name__=!0,box2D.collision.B2DistanceOutput.prototype={__class__:box2D.collision.B2DistanceOutput},box2D.collision.B2DistanceProxy=function(){this.m_vertices=new Array},box2D.collision.B2DistanceProxy.__name__=!0,box2D.collision.B2DistanceProxy.prototype={set:function(t){var o=t.getType();switch(o){case box2D.collision.shapes.B2Shape.e_circleShape:var i;i=js.Boot.__cast(t,box2D.collision.shapes.B2CircleShape),this.m_vertices=new Array,this.m_vertices[0]=i.m_p,this.m_count=1,this.m_radius=i.m_radius;break;case box2D.collision.shapes.B2Shape.e_polygonShape:var s;s=js.Boot.__cast(t,box2D.collision.shapes.B2PolygonShape),this.m_vertices=s.m_vertices,this.m_count=s.m_vertexCount,this.m_radius=s.m_radius;break;default:box2D.common.B2Settings.b2Assert(!1)}},getSupport:function(t){for(var o=0,i=this.m_vertices[0].x*t.x+this.m_vertices[0].y*t.y,s=1,n=this.m_count;n>s;){var e=s++,m=this.m_vertices[e].x*t.x+this.m_vertices[e].y*t.y;m>i&&(o=e,i=m)}return o},getSupportVertex:function(t){for(var o=0,i=this.m_vertices[0].x*t.x+this.m_vertices[0].y*t.y,s=1,n=this.m_count;n>s;){var e=s++,m=this.m_vertices[e].x*t.x+this.m_vertices[e].y*t.y;m>i&&(o=e,i=m)}return this.m_vertices[o]},getVertexCount:function(){return this.m_count},getVertex:function(t){return box2D.common.B2Settings.b2Assert(t>=0&&t<this.m_count),this.m_vertices[t]},__class__:box2D.collision.B2DistanceProxy},box2D.collision.B2DynamicTree=function(){this.m_root=null,this.m_freeList=null,this.m_path=0,this.m_insertionCount=0},box2D.collision.B2DynamicTree.__name__=!0,box2D.collision.B2DynamicTree.prototype={createProxy:function(t,o){var i=this.allocateNode(),s=box2D.common.B2Settings.b2_aabbExtension,n=box2D.common.B2Settings.b2_aabbExtension;return i.aabb.lowerBound.x=t.lowerBound.x-s,i.aabb.lowerBound.y=t.lowerBound.y-n,i.aabb.upperBound.x=t.upperBound.x+s,i.aabb.upperBound.y=t.upperBound.y+n,i.userData=o,this.insertLeaf(i),i},destroyProxy:function(t){this.removeLeaf(t),this.freeNode(t)},moveProxy:function(t,o,i){if(box2D.common.B2Settings.b2Assert(t.isLeaf()),t.aabb.contains(o))return!1;this.removeLeaf(t);var s;s=box2D.common.B2Settings.b2_aabbExtension+box2D.common.B2Settings.b2_aabbMultiplier*(i.x>0?i.x:-i.x);var n;return n=box2D.common.B2Settings.b2_aabbExtension+box2D.common.B2Settings.b2_aabbMultiplier*(i.y>0?i.y:-i.y),t.aabb.lowerBound.x=o.lowerBound.x-s,t.aabb.lowerBound.y=o.lowerBound.y-n,t.aabb.upperBound.x=o.upperBound.x+s,t.aabb.upperBound.y=o.upperBound.y+n,this.insertLeaf(t),!0},rebalance:function(t){if(null!=this.m_root)for(var o=0;t>o;){for(var i=(o++,this.m_root),s=0;0==i.isLeaf();)i=0!=(this.m_path>>s&1)?i.child2:i.child1,s=s+1&31;++this.m_path,this.removeLeaf(i),this.insertLeaf(i)}},getFatAABB:function(t){return t.aabb},getUserData:function(t){return t.userData},query:function(t,o){if(null!=this.m_root){var i=new Array,s=0;for(i[s++]=this.m_root;s>0;){var n=i[--s];if(n.aabb.testOverlap(o))if(n.isLeaf()){var e=t(n);if(!e)return}else i[s++]=n.child1,i[s++]=n.child2}}},rayCast:function(t,o){if(null!=this.m_root){var i=o.p1,s=o.p2,n=box2D.common.math.B2Math.subtractVV(i,s);n.normalize();var e,m,a=box2D.common.math.B2Math.crossFV(1,n),c=box2D.common.math.B2Math.absV(a),l=o.maxFraction,r=new box2D.collision.B2AABB;e=i.x+l*(s.x-i.x),m=i.y+l*(s.y-i.y),r.lowerBound.x=Math.min(i.x,e),r.lowerBound.y=Math.min(i.y,m),r.upperBound.x=Math.max(i.x,e),r.upperBound.y=Math.max(i.y,m);var _=new Array,h=0;for(_[h++]=this.m_root;h>0;){var x=_[--h];if(0!=x.aabb.testOverlap(r)){var y=x.aabb.getCenter(),u=x.aabb.getExtents(),p=Math.abs(a.x*(i.x-y.x)+a.y*(i.y-y.y))-c.x*u.x-c.y*u.y;if(!(p>0))if(x.isLeaf()){var d=new box2D.collision.B2RayCastInput;if(d.p1=o.p1,d.p2=o.p2,d.maxFraction=o.maxFraction,l=t(d,x),0==l)return;e=i.x+l*(s.x-i.x),m=i.y+l*(s.y-i.y),r.lowerBound.x=Math.min(i.x,e),r.lowerBound.y=Math.min(i.y,m),r.upperBound.x=Math.max(i.x,e),r.upperBound.y=Math.max(i.y,m)}else _[h++]=x.child1,_[h++]=x.child2}}}},allocateNode:function(){if(null!=this.m_freeList){var t=this.m_freeList;return this.m_freeList=t.parent,t.parent=null,t.child1=null,t.child2=null,t}return new box2D.collision.B2DynamicTreeNode},freeNode:function(t){t.parent=this.m_freeList,this.m_freeList=t},insertLeaf:function(t){if(++this.m_insertionCount,null==this.m_root)return this.m_root=t,void(this.m_root.parent=null);var o=t.aabb.getCenter(),i=this.m_root;if(0==i.isLeaf())do{var s=i.child1,n=i.child2,e=Math.abs((s.aabb.lowerBound.x+s.aabb.upperBound.x)/2-o.x)+Math.abs((s.aabb.lowerBound.y+s.aabb.upperBound.y)/2-o.y),m=Math.abs((n.aabb.lowerBound.x+n.aabb.upperBound.x)/2-o.x)+Math.abs((n.aabb.lowerBound.y+n.aabb.upperBound.y)/2-o.y);i=m>e?s:n}while(0==i.isLeaf());var a=i.parent,c=this.allocateNode();if(c.parent=a,c.userData=null,c.aabb.combine(t.aabb,i.aabb),null!=a){i.parent.child1==i?a.child1=c:a.child2=c,c.child1=i,c.child2=t,i.parent=c,t.parent=c;do{if(a.aabb.contains(c.aabb))break;a.aabb.combine(a.child1.aabb,a.child2.aabb),c=a,a=a.parent}while(null!=a)}else c.child1=i,c.child2=t,i.parent=c,t.parent=c,this.m_root=c},removeLeaf:function(t){if(t==this.m_root)return void(this.m_root=null);var o,i=t.parent,s=i.parent;if(o=i.child1==t?i.child2:i.child1,null!=s)for(s.child1==i?s.child1=o:s.child2=o,o.parent=s,this.freeNode(i);null!=s;){var n=s.aabb;if(s.aabb=new box2D.collision.B2AABB,s.aabb.combine(s.child1.aabb,s.child2.aabb),n.contains(s.aabb))break;s=s.parent}else this.m_root=o,o.parent=null,this.freeNode(i)},__class__:box2D.collision.B2DynamicTree},box2D.collision.IBroadPhase=function(){},box2D.collision.IBroadPhase.__name__=!0,box2D.collision.IBroadPhase.prototype={__class__:box2D.collision.IBroadPhase},box2D.collision.B2DynamicTreeBroadPhase=function(){this.m_tree=new box2D.collision.B2DynamicTree,this.m_moveBuffer=new Array,this.m_pairBuffer=new Array,this.m_pairCount=0},box2D.collision.B2DynamicTreeBroadPhase.__name__=!0,box2D.collision.B2DynamicTreeBroadPhase.__interfaces__=[box2D.collision.IBroadPhase],box2D.collision.B2DynamicTreeBroadPhase.prototype={createProxy:function(t,o){var i=this.m_tree.createProxy(t,o);return++this.m_proxyCount,this.bufferMove(i),i},destroyProxy:function(t){this.unBufferMove(t),--this.m_proxyCount,this.m_tree.destroyProxy(t)},moveProxy:function(t,o,i){var s=this.m_tree.moveProxy(t,o,i);s&&this.bufferMove(t)},testOverlap:function(t,o){var i=this.m_tree.getFatAABB(t),s=this.m_tree.getFatAABB(o);return i.testOverlap(s)},getUserData:function(t){return this.m_tree.getUserData(t)},getFatAABB:function(t){return this.m_tree.getFatAABB(t)},getProxyCount:function(){return this.m_proxyCount},updatePairs:function(t){var o=this;this.m_pairCount=0;for(var i=0,s=this.m_moveBuffer;i<s.length;){var n=[s[i]];++i;var e=function(t){return function(i){if(i==t[0])return!0;o.m_pairCount==o.m_pairBuffer.length&&(o.m_pairBuffer[o.m_pairCount]=new box2D.collision.B2DynamicTreePair);var s=o.m_pairBuffer[o.m_pairCount];return i.id<t[0].id?(s.proxyA=i,s.proxyB=t[0]):(s.proxyA=t[0],s.proxyB=i),++o.m_pairCount,!0}}(n),m=this.m_tree.getFatAABB(n[0]);this.m_tree.query(e,m)}this.m_moveBuffer=new Array;for(var a=!0,c=0;a;)if(c>=this.m_pairCount)a=!1;else{var l=this.m_pairBuffer[c],r=this.m_tree.getUserData(l.proxyA),_=this.m_tree.getUserData(l.proxyB);for(t(r,_),++c;c<this.m_pairCount;){var h=this.m_pairBuffer[c];if(h.proxyA!=l.proxyA||h.proxyB!=l.proxyB)break;++c}}},query:function(t,o){this.m_tree.query(t,o)},rayCast:function(t,o){this.m_tree.rayCast(t,o)},validate:function(){},rebalance:function(t){this.m_tree.rebalance(t)},bufferMove:function(t){this.m_moveBuffer[this.m_moveBuffer.length]=t},unBufferMove:function(t){HxOverrides.remove(this.m_moveBuffer,t)},comparePairs:function(){return 0},__class__:box2D.collision.B2DynamicTreeBroadPhase},box2D.collision.B2DynamicTreeNode=function(){this.aabb=new box2D.collision.B2AABB,this.id=box2D.collision.B2DynamicTreeNode.currentID++},box2D.collision.B2DynamicTreeNode.__name__=!0,box2D.collision.B2DynamicTreeNode.prototype={isLeaf:function(){return null==this.child1},__class__:box2D.collision.B2DynamicTreeNode},box2D.collision.B2DynamicTreePair=function(){},box2D.collision.B2DynamicTreePair.__name__=!0,box2D.collision.B2DynamicTreePair.prototype={__class__:box2D.collision.B2DynamicTreePair},box2D.collision.B2Manifold=function(){this.m_pointCount=0,this.m_points=new Array;for(var t=0,o=box2D.common.B2Settings.b2_maxManifoldPoints;o>t;){var i=t++;this.m_points[i]=new box2D.collision.B2ManifoldPoint}this.m_localPlaneNormal=new box2D.common.math.B2Vec2,this.m_localPoint=new box2D.common.math.B2Vec2},box2D.collision.B2Manifold.__name__=!0,box2D.collision.B2Manifold.prototype={reset:function(){for(var t=0,o=box2D.common.B2Settings.b2_maxManifoldPoints;o>t;){var i=t++;this.m_points[i].reset()}this.m_localPlaneNormal.setZero(),this.m_localPoint.setZero(),this.m_type=0,this.m_pointCount=0},set:function(t){this.m_pointCount=t.m_pointCount;for(var o=0,i=box2D.common.B2Settings.b2_maxManifoldPoints;i>o;){var s=o++;this.m_points[s].set(t.m_points[s])}this.m_localPlaneNormal.setV(t.m_localPlaneNormal),this.m_localPoint.setV(t.m_localPoint),this.m_type=t.m_type},copy:function(){var t=new box2D.collision.B2Manifold;return t.set(this),t},__class__:box2D.collision.B2Manifold},box2D.collision.B2ManifoldPoint=function(){this.m_localPoint=new box2D.common.math.B2Vec2,this.m_id=new box2D.collision.B2ContactID,this.reset()},box2D.collision.B2ManifoldPoint.__name__=!0,box2D.collision.B2ManifoldPoint.prototype={reset:function(){this.m_localPoint.setZero(),this.m_normalImpulse=0,this.m_tangentImpulse=0,this.m_id.set_key(0)},set:function(t){this.m_localPoint.setV(t.m_localPoint),this.m_normalImpulse=t.m_normalImpulse,this.m_tangentImpulse=t.m_tangentImpulse,this.m_id.set(t.m_id)},__class__:box2D.collision.B2ManifoldPoint},box2D.collision.B2OBB=function(){this.R=new box2D.common.math.B2Mat22,this.center=new box2D.common.math.B2Vec2,this.extents=new box2D.common.math.B2Vec2},box2D.collision.B2OBB.__name__=!0,box2D.collision.B2OBB.prototype={__class__:box2D.collision.B2OBB},box2D.collision.B2RayCastInput=function(t,o,i){null==i&&(i=1),this.p1=new box2D.common.math.B2Vec2,this.p2=new box2D.common.math.B2Vec2,null!=t&&this.p1.setV(t),null!=o&&this.p2.setV(o),this.maxFraction=i},box2D.collision.B2RayCastInput.__name__=!0,box2D.collision.B2RayCastInput.prototype={__class__:box2D.collision.B2RayCastInput},box2D.collision.B2RayCastOutput=function(){this.normal=new box2D.common.math.B2Vec2},box2D.collision.B2RayCastOutput.__name__=!0,box2D.collision.B2RayCastOutput.prototype={__class__:box2D.collision.B2RayCastOutput},box2D.collision.B2SeparationFunction=function(){this.m_localPoint=new box2D.common.math.B2Vec2,this.m_axis=new box2D.common.math.B2Vec2},box2D.collision.B2SeparationFunction.__name__=!0,box2D.collision.B2SeparationFunction.prototype={initialize:function(t,o,i,s,n){this.m_proxyA=o,this.m_proxyB=s;var e=t.count;box2D.common.B2Settings.b2Assert(e>0&&3>e);var m,a,c,l,r,_,h,x,y,u,p,d,B,b,D=new box2D.common.math.B2Vec2,f=new box2D.common.math.B2Vec2;
if(1==e)this.m_type=box2D.collision.B2SeparationFunction.e_points,D=this.m_proxyA.getVertex(t.indexA[0]),f=this.m_proxyB.getVertex(t.indexB[0]),d=D,p=i.R,r=i.position.x+(p.col1.x*d.x+p.col2.x*d.y),_=i.position.y+(p.col1.y*d.x+p.col2.y*d.y),d=f,p=n.R,h=n.position.x+(p.col1.x*d.x+p.col2.x*d.y),x=n.position.y+(p.col1.y*d.x+p.col2.y*d.y),this.m_axis.x=h-r,this.m_axis.y=x-_,this.m_axis.normalize();else if(t.indexB[0]==t.indexB[1])this.m_type=box2D.collision.B2SeparationFunction.e_faceA,m=this.m_proxyA.getVertex(t.indexA[0]),a=this.m_proxyA.getVertex(t.indexA[1]),f=this.m_proxyB.getVertex(t.indexB[0]),this.m_localPoint.x=.5*(m.x+a.x),this.m_localPoint.y=.5*(m.y+a.y),this.m_axis=box2D.common.math.B2Math.crossVF(box2D.common.math.B2Math.subtractVV(a,m),1),this.m_axis.normalize(),d=this.m_axis,p=i.R,y=p.col1.x*d.x+p.col2.x*d.y,u=p.col1.y*d.x+p.col2.y*d.y,d=this.m_localPoint,p=i.R,r=i.position.x+(p.col1.x*d.x+p.col2.x*d.y),_=i.position.y+(p.col1.y*d.x+p.col2.y*d.y),d=f,p=n.R,h=n.position.x+(p.col1.x*d.x+p.col2.x*d.y),x=n.position.y+(p.col1.y*d.x+p.col2.y*d.y),B=(h-r)*y+(x-_)*u,0>B&&this.m_axis.negativeSelf();else if(t.indexA[0]==t.indexA[0])this.m_type=box2D.collision.B2SeparationFunction.e_faceB,c=this.m_proxyB.getVertex(t.indexB[0]),l=this.m_proxyB.getVertex(t.indexB[1]),D=this.m_proxyA.getVertex(t.indexA[0]),this.m_localPoint.x=.5*(c.x+l.x),this.m_localPoint.y=.5*(c.y+l.y),this.m_axis=box2D.common.math.B2Math.crossVF(box2D.common.math.B2Math.subtractVV(l,c),1),this.m_axis.normalize(),d=this.m_axis,p=n.R,y=p.col1.x*d.x+p.col2.x*d.y,u=p.col1.y*d.x+p.col2.y*d.y,d=this.m_localPoint,p=n.R,h=n.position.x+(p.col1.x*d.x+p.col2.x*d.y),x=n.position.y+(p.col1.y*d.x+p.col2.y*d.y),d=D,p=i.R,r=i.position.x+(p.col1.x*d.x+p.col2.x*d.y),_=i.position.y+(p.col1.y*d.x+p.col2.y*d.y),B=(r-h)*y+(_-x)*u,0>B&&this.m_axis.negativeSelf();else{m=this.m_proxyA.getVertex(t.indexA[0]),a=this.m_proxyA.getVertex(t.indexA[1]),c=this.m_proxyB.getVertex(t.indexB[0]),l=this.m_proxyB.getVertex(t.indexB[1]);var g=(box2D.common.math.B2Math.mulX(i,D),box2D.common.math.B2Math.mulMV(i.R,box2D.common.math.B2Math.subtractVV(a,m))),v=(box2D.common.math.B2Math.mulX(n,f),box2D.common.math.B2Math.mulMV(n.R,box2D.common.math.B2Math.subtractVV(l,c))),A=g.x*g.x+g.y*g.y,w=v.x*v.x+v.y*v.y,V=box2D.common.math.B2Math.subtractVV(v,g),C=g.x*V.x+g.y*V.y,M=v.x*V.x+v.y*V.y,S=g.x*v.x+g.y*v.y,I=A*w-S*S;B=0,0!=I&&(B=box2D.common.math.B2Math.clamp((S*M-C*w)/I,0,1));var j=(S*B+M)/w;0>j&&(j=0,B=box2D.common.math.B2Math.clamp((S-C)/A,0,1)),D=new box2D.common.math.B2Vec2,D.x=m.x+B*(a.x-m.x),D.y=m.y+B*(a.y-m.y),f=new box2D.common.math.B2Vec2,f.x=c.x+B*(l.x-c.x),f.y=c.y+B*(l.y-c.y),0==B||1==B?(this.m_type=box2D.collision.B2SeparationFunction.e_faceB,this.m_axis=box2D.common.math.B2Math.crossVF(box2D.common.math.B2Math.subtractVV(l,c),1),this.m_axis.normalize(),this.m_localPoint=f,d=this.m_axis,p=n.R,y=p.col1.x*d.x+p.col2.x*d.y,u=p.col1.y*d.x+p.col2.y*d.y,d=this.m_localPoint,p=n.R,h=n.position.x+(p.col1.x*d.x+p.col2.x*d.y),x=n.position.y+(p.col1.y*d.x+p.col2.y*d.y),d=D,p=i.R,r=i.position.x+(p.col1.x*d.x+p.col2.x*d.y),_=i.position.y+(p.col1.y*d.x+p.col2.y*d.y),b=(r-h)*y+(_-x)*u,0>B&&this.m_axis.negativeSelf()):(this.m_type=box2D.collision.B2SeparationFunction.e_faceA,this.m_axis=box2D.common.math.B2Math.crossVF(box2D.common.math.B2Math.subtractVV(a,m),1),this.m_localPoint=D,d=this.m_axis,p=i.R,y=p.col1.x*d.x+p.col2.x*d.y,u=p.col1.y*d.x+p.col2.y*d.y,d=this.m_localPoint,p=i.R,r=i.position.x+(p.col1.x*d.x+p.col2.x*d.y),_=i.position.y+(p.col1.y*d.x+p.col2.y*d.y),d=f,p=n.R,h=n.position.x+(p.col1.x*d.x+p.col2.x*d.y),x=n.position.y+(p.col1.y*d.x+p.col2.y*d.y),b=(h-r)*y+(x-_)*u,0>B&&this.m_axis.negativeSelf())}},evaluate:function(t,o){var i,s,n,e,m,a,c,l;return this.m_type==box2D.collision.B2SeparationFunction.e_points?(i=box2D.common.math.B2Math.mulTMV(t.R,this.m_axis),s=box2D.common.math.B2Math.mulTMV(o.R,this.m_axis.getNegative()),n=this.m_proxyA.getSupportVertex(i),e=this.m_proxyB.getSupportVertex(s),m=box2D.common.math.B2Math.mulX(t,n),a=box2D.common.math.B2Math.mulX(o,e),c=(a.x-m.x)*this.m_axis.x+(a.y-m.y)*this.m_axis.y):this.m_type==box2D.collision.B2SeparationFunction.e_faceA?(l=box2D.common.math.B2Math.mulMV(t.R,this.m_axis),m=box2D.common.math.B2Math.mulX(t,this.m_localPoint),s=box2D.common.math.B2Math.mulTMV(o.R,l.getNegative()),e=this.m_proxyB.getSupportVertex(s),a=box2D.common.math.B2Math.mulX(o,e),c=(a.x-m.x)*l.x+(a.y-m.y)*l.y):this.m_type==box2D.collision.B2SeparationFunction.e_faceB?(l=box2D.common.math.B2Math.mulMV(o.R,this.m_axis),a=box2D.common.math.B2Math.mulX(o,this.m_localPoint),i=box2D.common.math.B2Math.mulTMV(t.R,l.getNegative()),n=this.m_proxyA.getSupportVertex(i),m=box2D.common.math.B2Math.mulX(t,n),c=(m.x-a.x)*l.x+(m.y-a.y)*l.y):0},__class__:box2D.collision.B2SeparationFunction},box2D.collision.B2SimplexCache=function(){this.indexA=new Array,this.indexB=new Array},box2D.collision.B2SimplexCache.__name__=!0,box2D.collision.B2SimplexCache.prototype={__class__:box2D.collision.B2SimplexCache},box2D.collision.B2TOIInput=function(){this.proxyA=new box2D.collision.B2DistanceProxy,this.proxyB=new box2D.collision.B2DistanceProxy,this.sweepA=new box2D.common.math.B2Sweep,this.sweepB=new box2D.common.math.B2Sweep},box2D.collision.B2TOIInput.__name__=!0,box2D.collision.B2TOIInput.prototype={__class__:box2D.collision.B2TOIInput},box2D.common.math.B2Transform=function(t,o){this.position=new box2D.common.math.B2Vec2,this.R=new box2D.common.math.B2Mat22,null!=t&&(this.position.setV(t),this.R.setM(o))},box2D.common.math.B2Transform.__name__=!0,box2D.common.math.B2Transform.prototype={initialize:function(t,o){this.position.setV(t),this.R.setM(o)},setIdentity:function(){this.position.setZero(),this.R.setIdentity()},set:function(t){this.position.setV(t.position),this.R.setM(t.R)},getAngle:function(){return Math.atan2(this.R.col1.y,this.R.col1.x)},__class__:box2D.common.math.B2Transform},box2D.common.math.B2Mat22=function(){this.col1=new box2D.common.math.B2Vec2(0,1),this.col2=new box2D.common.math.B2Vec2(0,1)},box2D.common.math.B2Mat22.__name__=!0,box2D.common.math.B2Mat22.fromAngle=function(t){var o=new box2D.common.math.B2Mat22;return o.set(t),o},box2D.common.math.B2Mat22.fromVV=function(t,o){var i=new box2D.common.math.B2Mat22;return i.setVV(t,o),i},box2D.common.math.B2Mat22.prototype={set:function(t){var o=Math.cos(t),i=Math.sin(t);this.col1.x=o,this.col2.x=-i,this.col1.y=i,this.col2.y=o},setVV:function(t,o){this.col1.setV(t),this.col2.setV(o)},copy:function(){var t=new box2D.common.math.B2Mat22;return t.setM(this),t},setM:function(t){this.col1.setV(t.col1),this.col2.setV(t.col2)},addM:function(t){this.col1.x+=t.col1.x,this.col1.y+=t.col1.y,this.col2.x+=t.col2.x,this.col2.y+=t.col2.y},setIdentity:function(){this.col1.x=1,this.col2.x=0,this.col1.y=0,this.col2.y=1},setZero:function(){this.col1.x=0,this.col2.x=0,this.col1.y=0,this.col2.y=0},getAngle:function(){return Math.atan2(this.col1.y,this.col1.x)},getInverse:function(t){var o=this.col1.x,i=this.col2.x,s=this.col1.y,n=this.col2.y,e=o*n-i*s;return 0!=e&&(e=1/e),t.col1.x=e*n,t.col2.x=-e*i,t.col1.y=-e*s,t.col2.y=e*o,t},solve:function(t,o,i){var s=this.col1.x,n=this.col2.x,e=this.col1.y,m=this.col2.y,a=s*m-n*e;return 0!=a&&(a=1/a),t.x=a*(m*o-n*i),t.y=a*(s*i-e*o),t},abs:function(){this.col1.abs(),this.col2.abs()},__class__:box2D.common.math.B2Mat22},box2D.collision.B2TimeOfImpact=function(){},box2D.collision.B2TimeOfImpact.__name__=!0,box2D.collision.B2TimeOfImpact.timeOfImpact=function(t){++box2D.collision.B2TimeOfImpact.b2_toiCalls;var o=t.proxyA,i=t.proxyB,s=t.sweepA,n=t.sweepB;box2D.common.B2Settings.b2Assert(s.t0==n.t0),box2D.common.B2Settings.b2Assert(1-s.t0>2.2250738585072014e-308);var e=o.m_radius+i.m_radius,m=t.tolerance,a=0,c=1e3,l=0,r=0;for(box2D.collision.B2TimeOfImpact.s_cache.count=0,box2D.collision.B2TimeOfImpact.s_distanceInput.useRadii=!1;;){if(s.getTransform(box2D.collision.B2TimeOfImpact.s_xfA,a),n.getTransform(box2D.collision.B2TimeOfImpact.s_xfB,a),box2D.collision.B2TimeOfImpact.s_distanceInput.proxyA=o,box2D.collision.B2TimeOfImpact.s_distanceInput.proxyB=i,box2D.collision.B2TimeOfImpact.s_distanceInput.transformA=box2D.collision.B2TimeOfImpact.s_xfA,box2D.collision.B2TimeOfImpact.s_distanceInput.transformB=box2D.collision.B2TimeOfImpact.s_xfB,box2D.collision.B2Distance.distance(box2D.collision.B2TimeOfImpact.s_distanceOutput,box2D.collision.B2TimeOfImpact.s_cache,box2D.collision.B2TimeOfImpact.s_distanceInput),box2D.collision.B2TimeOfImpact.s_distanceOutput.distance<=0){a=1;break}box2D.collision.B2TimeOfImpact.s_fcn.initialize(box2D.collision.B2TimeOfImpact.s_cache,o,box2D.collision.B2TimeOfImpact.s_xfA,i,box2D.collision.B2TimeOfImpact.s_xfB);var _=box2D.collision.B2TimeOfImpact.s_fcn.evaluate(box2D.collision.B2TimeOfImpact.s_xfA,box2D.collision.B2TimeOfImpact.s_xfB);if(0>=_){a=1;break}if(0==l&&(r=_>e?box2D.common.math.B2Math.max(e-m,.75*e):box2D.common.math.B2Math.max(_-m,.02*e)),.5*m>_-r){if(0==l){a=1;break}break}var h=a,x=a,y=1,u=_;s.getTransform(box2D.collision.B2TimeOfImpact.s_xfA,y),n.getTransform(box2D.collision.B2TimeOfImpact.s_xfB,y);var p=box2D.collision.B2TimeOfImpact.s_fcn.evaluate(box2D.collision.B2TimeOfImpact.s_xfA,box2D.collision.B2TimeOfImpact.s_xfB);if(p>=r){a=1;break}for(var d=0;;){var B;B=0!=(1&d)?x+(r-u)*(y-x)/(p-u):.5*(x+y),s.getTransform(box2D.collision.B2TimeOfImpact.s_xfA,B),n.getTransform(box2D.collision.B2TimeOfImpact.s_xfB,B);var b=box2D.collision.B2TimeOfImpact.s_fcn.evaluate(box2D.collision.B2TimeOfImpact.s_xfA,box2D.collision.B2TimeOfImpact.s_xfB);if(box2D.common.math.B2Math.abs(b-r)<.025*m){h=B;break}if(b>r?(x=B,u=b):(y=B,p=b),++d,++box2D.collision.B2TimeOfImpact.b2_toiRootIters,50==d)break}var B=box2D.common.math.B2Math.max(box2D.collision.B2TimeOfImpact.b2_toiMaxRootIters,d);if(box2D.collision.B2TimeOfImpact.b2_toiMaxRootIters=0|B,a>h)break;if(a=h,l++,++box2D.collision.B2TimeOfImpact.b2_toiIters,l==c)break}var B=box2D.common.math.B2Math.max(box2D.collision.B2TimeOfImpact.b2_toiMaxIters,l);return box2D.collision.B2TimeOfImpact.b2_toiMaxIters=0|B,a},box2D.collision.B2WorldManifold=function(){this.m_normal=new box2D.common.math.B2Vec2,this.m_points=new Array;for(var t=0,o=box2D.common.B2Settings.b2_maxManifoldPoints;o>t;){var i=t++;this.m_points[i]=new box2D.common.math.B2Vec2}},box2D.collision.B2WorldManifold.__name__=!0,box2D.collision.B2WorldManifold.prototype={initialize:function(t,o,i,s,n){if(0!=t.m_pointCount){var e,m,a,c,l,r,_,h,x=t.m_type;switch(x){case box2D.collision.B2Manifold.e_circles:m=o.R,e=t.m_localPoint;var y=o.position.x+m.col1.x*e.x+m.col2.x*e.y,u=o.position.y+m.col1.y*e.x+m.col2.y*e.y;m=s.R,e=t.m_points[0].m_localPoint;var p=s.position.x+m.col1.x*e.x+m.col2.x*e.y,d=s.position.y+m.col1.y*e.x+m.col2.y*e.y,B=p-y,b=d-u,D=B*B+b*b;if(D>0){var f=Math.sqrt(D);this.m_normal.x=B/f,this.m_normal.y=b/f}else this.m_normal.x=1,this.m_normal.y=0;var g=y+i*this.m_normal.x,v=u+i*this.m_normal.y,A=p-n*this.m_normal.x,w=d-n*this.m_normal.y;this.m_points[0].x=.5*(g+A),this.m_points[0].y=.5*(v+w);break;case box2D.collision.B2Manifold.e_faceA:m=o.R,e=t.m_localPlaneNormal,a=m.col1.x*e.x+m.col2.x*e.y,c=m.col1.y*e.x+m.col2.y*e.y,m=o.R,e=t.m_localPoint,l=o.position.x+m.col1.x*e.x+m.col2.x*e.y,r=o.position.y+m.col1.y*e.x+m.col2.y*e.y,this.m_normal.x=a,this.m_normal.y=c;for(var V=0,C=t.m_pointCount;C>V;){var M=V++;m=s.R,e=t.m_points[M].m_localPoint,_=s.position.x+m.col1.x*e.x+m.col2.x*e.y,h=s.position.y+m.col1.y*e.x+m.col2.y*e.y,this.m_points[M].x=_+.5*(i-(_-l)*a-(h-r)*c-n)*a,this.m_points[M].y=h+.5*(i-(_-l)*a-(h-r)*c-n)*c}break;case box2D.collision.B2Manifold.e_faceB:m=s.R,e=t.m_localPlaneNormal,a=m.col1.x*e.x+m.col2.x*e.y,c=m.col1.y*e.x+m.col2.y*e.y,m=s.R,e=t.m_localPoint,l=s.position.x+m.col1.x*e.x+m.col2.x*e.y,r=s.position.y+m.col1.y*e.x+m.col2.y*e.y,this.m_normal.x=-a,this.m_normal.y=-c;for(var V=0,C=t.m_pointCount;C>V;){var M=V++;m=o.R,e=t.m_points[M].m_localPoint,_=o.position.x+m.col1.x*e.x+m.col2.x*e.y,h=o.position.y+m.col1.y*e.x+m.col2.y*e.y,this.m_points[M].x=_+.5*(n-(_-l)*a-(h-r)*c-i)*a,this.m_points[M].y=h+.5*(n-(_-l)*a-(h-r)*c-i)*c}}}},__class__:box2D.collision.B2WorldManifold},box2D.collision.shapes={},box2D.collision.shapes.B2Shape=function(){this.m_type=box2D.collision.shapes.B2Shape.e_unknownShape,this.m_radius=box2D.common.B2Settings.b2_linearSlop},box2D.collision.shapes.B2Shape.__name__=!0,box2D.collision.shapes.B2Shape.testOverlap=function(t,o,i,s){var n=new box2D.collision.B2DistanceInput;n.proxyA=new box2D.collision.B2DistanceProxy,n.proxyA.set(t),n.proxyB=new box2D.collision.B2DistanceProxy,n.proxyB.set(i),n.transformA=o,n.transformB=s,n.useRadii=!0;var e=new box2D.collision.B2SimplexCache;e.count=0;var m=new box2D.collision.B2DistanceOutput;return box2D.collision.B2Distance.distance(m,e,n),m.distance<2.2250738585072014e-307},box2D.collision.shapes.B2Shape.prototype={copy:function(){return null},set:function(t){this.m_radius=t.m_radius},getType:function(){return this.m_type},testPoint:function(){return!1},rayCast:function(){return!1},computeAABB:function(){},computeMass:function(){},computeSubmergedArea:function(){return 0},__class__:box2D.collision.shapes.B2Shape},box2D.collision.shapes.B2CircleShape=function(t){null==t&&(t=0),box2D.collision.shapes.B2Shape.call(this),this.m_p=new box2D.common.math.B2Vec2,this.m_type=box2D.collision.shapes.B2Shape.e_circleShape,this.m_radius=t},box2D.collision.shapes.B2CircleShape.__name__=!0,box2D.collision.shapes.B2CircleShape.__super__=box2D.collision.shapes.B2Shape,box2D.collision.shapes.B2CircleShape.prototype=$extend(box2D.collision.shapes.B2Shape.prototype,{copy:function(){var t=new box2D.collision.shapes.B2CircleShape;return t.set(this),t},set:function(t){if(box2D.collision.shapes.B2Shape.prototype.set.call(this,t),js.Boot.__instanceof(t,box2D.collision.shapes.B2CircleShape)){var o;o=js.Boot.__cast(t,box2D.collision.shapes.B2CircleShape),this.m_p.setV(o.m_p)}},testPoint:function(t,o){var i=t.R,s=t.position.x+(i.col1.x*this.m_p.x+i.col2.x*this.m_p.y),n=t.position.y+(i.col1.y*this.m_p.x+i.col2.y*this.m_p.y);return s=o.x-s,n=o.y-n,s*s+n*n<=this.m_radius*this.m_radius},rayCast:function(t,o,i){var s=i.R,n=i.position.x+(s.col1.x*this.m_p.x+s.col2.x*this.m_p.y),e=i.position.y+(s.col1.y*this.m_p.x+s.col2.y*this.m_p.y),m=o.p1.x-n,a=o.p1.y-e,c=m*m+a*a-this.m_radius*this.m_radius,l=o.p2.x-o.p1.x,r=o.p2.y-o.p1.y,_=m*l+a*r,h=l*l+r*r,x=_*_-h*c;if(0>x||2.2250738585072014e-308>h)return!1;var y=-(_+Math.sqrt(x));return y>=0&&y<=o.maxFraction*h?(y/=h,t.fraction=y,t.normal.x=m+y*l,t.normal.y=a+y*r,t.normal.normalize(),!0):!1},computeAABB:function(t,o){var i=o.R,s=o.position.x+(i.col1.x*this.m_p.x+i.col2.x*this.m_p.y),n=o.position.y+(i.col1.y*this.m_p.x+i.col2.y*this.m_p.y);t.lowerBound.set(s-this.m_radius,n-this.m_radius),t.upperBound.set(s+this.m_radius,n+this.m_radius)},computeMass:function(t,o){t.mass=o*box2D.common.B2Settings.b2_pi*this.m_radius*this.m_radius,t.center.setV(this.m_p),t.I=t.mass*(.5*this.m_radius*this.m_radius+(this.m_p.x*this.m_p.x+this.m_p.y*this.m_p.y))},computeSubmergedArea:function(t,o,i,s){var n=box2D.common.math.B2Math.mulX(i,this.m_p),e=-(box2D.common.math.B2Math.dot(t,n)-o);if(e<-this.m_radius+2.2250738585072014e-308)return 0;if(e>this.m_radius)return s.setV(n),Math.PI*this.m_radius*this.m_radius;var m=this.m_radius*this.m_radius,a=e*e,c=m*(Math.asin(e/this.m_radius)+Math.PI/2)+e*Math.sqrt(m-a),l=-.6666666666666666*Math.pow(m-a,1.5)/c;return s.x=n.x+t.x*l,s.y=n.y+t.y*l,c},getLocalPosition:function(){return this.m_p},setLocalPosition:function(t){this.m_p.setV(t)},getRadius:function(){return this.m_radius},setRadius:function(t){this.m_radius=t},__class__:box2D.collision.shapes.B2CircleShape}),box2D.collision.shapes.B2EdgeShape=function(t,o){box2D.collision.shapes.B2Shape.call(this),this.s_supportVec=new box2D.common.math.B2Vec2,this.m_v1=new box2D.common.math.B2Vec2,this.m_v2=new box2D.common.math.B2Vec2,this.m_coreV1=new box2D.common.math.B2Vec2,this.m_coreV2=new box2D.common.math.B2Vec2,this.m_normal=new box2D.common.math.B2Vec2,this.m_direction=new box2D.common.math.B2Vec2,this.m_cornerDir1=new box2D.common.math.B2Vec2,this.m_cornerDir2=new box2D.common.math.B2Vec2,this.m_type=box2D.collision.shapes.B2Shape.e_edgeShape,this.m_prevEdge=null,this.m_nextEdge=null,this.m_v1=t,this.m_v2=o,this.m_direction.set(this.m_v2.x-this.m_v1.x,this.m_v2.y-this.m_v1.y),this.m_length=this.m_direction.normalize(),this.m_normal.set(this.m_direction.y,-this.m_direction.x),this.m_coreV1.set(-box2D.common.B2Settings.b2_toiSlop*(this.m_normal.x-this.m_direction.x)+this.m_v1.x,-box2D.common.B2Settings.b2_toiSlop*(this.m_normal.y-this.m_direction.y)+this.m_v1.y),this.m_coreV2.set(-box2D.common.B2Settings.b2_toiSlop*(this.m_normal.x+this.m_direction.x)+this.m_v2.x,-box2D.common.B2Settings.b2_toiSlop*(this.m_normal.y+this.m_direction.y)+this.m_v2.y),this.m_cornerDir1=this.m_normal,this.m_cornerDir2.set(-this.m_normal.x,-this.m_normal.y)},box2D.collision.shapes.B2EdgeShape.__name__=!0,box2D.collision.shapes.B2EdgeShape.__super__=box2D.collision.shapes.B2Shape,box2D.collision.shapes.B2EdgeShape.prototype=$extend(box2D.collision.shapes.B2Shape.prototype,{testPoint:function(){return!1},rayCast:function(t,o,i){var s,n=o.p2.x-o.p1.x,e=o.p2.y-o.p1.y;s=i.R;var m=i.position.x+(s.col1.x*this.m_v1.x+s.col2.x*this.m_v1.y),a=i.position.y+(s.col1.y*this.m_v1.x+s.col2.y*this.m_v1.y),c=i.position.y+(s.col1.y*this.m_v2.x+s.col2.y*this.m_v2.y)-a,l=-(i.position.x+(s.col1.x*this.m_v2.x+s.col2.x*this.m_v2.y)-m),r=2.2250738585072014e-306,_=-(n*c+e*l);if(_>r){var h=o.p1.x-m,x=o.p1.y-a,y=h*c+x*l;if(y>=0&&y<=o.maxFraction*_){var u=-n*x+e*h;if(u>=-r*_&&_*(1+r)>=u){y/=_,t.fraction=y;var p=Math.sqrt(c*c+l*l);return t.normal.x=c/p,t.normal.y=l/p,!0}}}return!1},computeAABB:function(t,o){var i=o.R,s=o.position.x+(i.col1.x*this.m_v1.x+i.col2.x*this.m_v1.y),n=o.position.y+(i.col1.y*this.m_v1.x+i.col2.y*this.m_v1.y),e=o.position.x+(i.col1.x*this.m_v2.x+i.col2.x*this.m_v2.y),m=o.position.y+(i.col1.y*this.m_v2.x+i.col2.y*this.m_v2.y);e>s?(t.lowerBound.x=s,t.upperBound.x=e):(t.lowerBound.x=e,t.upperBound.x=s),m>n?(t.lowerBound.y=n,t.upperBound.y=m):(t.lowerBound.y=m,t.upperBound.y=n)},computeMass:function(t){t.mass=0,t.center.setV(this.m_v1),t.I=0},computeSubmergedArea:function(t,o,i,s){var n=new box2D.common.math.B2Vec2(t.x*o,t.y*o),e=box2D.common.math.B2Math.mulX(i,this.m_v1),m=box2D.common.math.B2Math.mulX(i,this.m_v2),a=box2D.common.math.B2Math.dot(t,e)-o,c=box2D.common.math.B2Math.dot(t,m)-o;if(a>0){if(c>0)return 0;e.x=-c/(a-c)*e.x+a/(a-c)*m.x,e.y=-c/(a-c)*e.y+a/(a-c)*m.y}else c>0&&(m.x=-c/(a-c)*e.x+a/(a-c)*m.x,m.y=-c/(a-c)*e.y+a/(a-c)*m.y);return s.x=(n.x+e.x+m.x)/3,s.y=(n.y+e.y+m.y)/3,.5*((e.x-n.x)*(m.y-n.y)-(e.y-n.y)*(m.x-n.x))},getLength:function(){return this.m_length},getVertex1:function(){return this.m_v1},getVertex2:function(){return this.m_v2},getCoreVertex1:function(){return this.m_coreV1},getCoreVertex2:function(){return this.m_coreV2},getNormalVector:function(){return this.m_normal},getDirectionVector:function(){return this.m_direction},getCorner1Vector:function(){return this.m_cornerDir1},getCorner2Vector:function(){return this.m_cornerDir2},corner1IsConvex:function(){return this.m_cornerConvex1},corner2IsConvex:function(){return this.m_cornerConvex2},getFirstVertex:function(t){var o=t.R;return new box2D.common.math.B2Vec2(t.position.x+(o.col1.x*this.m_coreV1.x+o.col2.x*this.m_coreV1.y),t.position.y+(o.col1.y*this.m_coreV1.x+o.col2.y*this.m_coreV1.y))},getNextEdge:function(){return this.m_nextEdge},getPrevEdge:function(){return this.m_prevEdge},support:function(t,o,i){var s=t.R,n=t.position.x+(s.col1.x*this.m_coreV1.x+s.col2.x*this.m_coreV1.y),e=t.position.y+(s.col1.y*this.m_coreV1.x+s.col2.y*this.m_coreV1.y),m=t.position.x+(s.col1.x*this.m_coreV2.x+s.col2.x*this.m_coreV2.y),a=t.position.y+(s.col1.y*this.m_coreV2.x+s.col2.y*this.m_coreV2.y);return n*o+e*i>m*o+a*i?(this.s_supportVec.x=n,this.s_supportVec.y=e):(this.s_supportVec.x=m,this.s_supportVec.y=a),this.s_supportVec},setPrevEdge:function(t,o,i,s){this.m_prevEdge=t,this.m_coreV1=o,this.m_cornerDir1=i,this.m_cornerConvex1=s},setNextEdge:function(t,o,i,s){this.m_nextEdge=t,this.m_coreV2=o,this.m_cornerDir2=i,this.m_cornerConvex2=s},__class__:box2D.collision.shapes.B2EdgeShape}),box2D.collision.shapes.B2MassData=function(){this.mass=0,this.center=new box2D.common.math.B2Vec2(0,0),this.I=0},box2D.collision.shapes.B2MassData.__name__=!0,box2D.collision.shapes.B2MassData.prototype={__class__:box2D.collision.shapes.B2MassData},box2D.collision.shapes.B2PolygonShape=function(){box2D.collision.shapes.B2Shape.call(this),this.m_type=box2D.collision.shapes.B2Shape.e_polygonShape,this.m_centroid=new box2D.common.math.B2Vec2,this.m_vertices=new Array,this.m_normals=new Array},box2D.collision.shapes.B2PolygonShape.__name__=!0,box2D.collision.shapes.B2PolygonShape.asArray=function(t,o){var i=new box2D.collision.shapes.B2PolygonShape;return i.setAsArray(t,o),i},box2D.collision.shapes.B2PolygonShape.asVector=function(t,o){var i=new box2D.collision.shapes.B2PolygonShape;return i.setAsVector(t,o),i},box2D.collision.shapes.B2PolygonShape.asBox=function(t,o){var i=new box2D.collision.shapes.B2PolygonShape;return i.setAsBox(t,o),i},box2D.collision.shapes.B2PolygonShape.asOrientedBox=function(t,o,i,s){null==s&&(s=0);var n=new box2D.collision.shapes.B2PolygonShape;return n.setAsOrientedBox(t,o,i,s),n},box2D.collision.shapes.B2PolygonShape.asEdge=function(t,o){var i=new box2D.collision.shapes.B2PolygonShape;return i.setAsEdge(t,o),i},box2D.collision.shapes.B2PolygonShape.computeCentroid=function(t,o){for(var i=new box2D.common.math.B2Vec2,s=0,n=0,e=0,m=.3333333333333333,a=0;o>a;){var c,l=a++,r=t[l];c=o>l+1?t[l+1|0]:t[0];var _=r.x-n,h=r.y-e,x=c.x-n,y=c.y-e,u=_*y-h*x,p=.5*u;s+=p,i.x+=p*m*(n+r.x+c.x),i.y+=p*m*(e+r.y+c.y)}return i.x*=1/s,i.y*=1/s,i},box2D.collision.shapes.B2PolygonShape.computeOBB=function(t,o,i){for(var s=new Array,n=0;i>n;){var e=n++;s[e]=o[e]}s[i]=s[0];for(var m=1.7976931348623157e308,a=1,n=i+1;n>a;){var e=a++,c=s[e-1|0],l=s[e].x-c.x,r=s[e].y-c.y,_=Math.sqrt(l*l+r*r);l/=_,r/=_;for(var h=-r,x=l,y=1.7976931348623157e308,u=1.7976931348623157e308,p=-1.7976931348623157e308,d=-1.7976931348623157e308,B=0;i>B;){var b=B++,D=s[b].x-c.x,f=s[b].y-c.y,g=l*D+r*f,v=h*D+x*f;y>g&&(y=g),u>v&&(u=v),g>p&&(p=g),v>d&&(d=v)}var A=(p-y)*(d-u);if(.95*m>A){m=A,t.R.col1.x=l,t.R.col1.y=r,t.R.col2.x=h,t.R.col2.y=x;var w=.5*(y+p),V=.5*(u+d),C=t.R;t.center.x=c.x+(C.col1.x*w+C.col2.x*V),t.center.y=c.y+(C.col1.y*w+C.col2.y*V),t.extents.x=.5*(p-y),t.extents.y=.5*(d-u)}}},box2D.collision.shapes.B2PolygonShape.__super__=box2D.collision.shapes.B2Shape,box2D.collision.shapes.B2PolygonShape.prototype=$extend(box2D.collision.shapes.B2Shape.prototype,{copy:function(){var t=new box2D.collision.shapes.B2PolygonShape;return t.set(this),t},set:function(t){if(box2D.collision.shapes.B2Shape.prototype.set.call(this,t),js.Boot.__instanceof(t,box2D.collision.shapes.B2PolygonShape)){var o;o=js.Boot.__cast(t,box2D.collision.shapes.B2PolygonShape),this.m_centroid.setV(o.m_centroid),this.m_vertexCount=o.m_vertexCount,this.reserve(this.m_vertexCount);for(var i=0,s=this.m_vertexCount;s>i;){var n=i++;this.m_vertices[n].setV(o.m_vertices[n]),this.m_normals[n].setV(o.m_normals[n])}}},setAsArray:function(t,o){null==o&&(o=0);for(var i=new Array,s=0;s<t.length;){var n=t[s];++s,i.push(n)}this.setAsVector(i,o)},setAsVector:function(t,o){null==o&&(o=0),0==o&&(o=t.length),box2D.common.B2Settings.b2Assert(o>=2),this.m_vertexCount=0|o,this.reserve(0|o);for(var i=0,s=this.m_vertexCount;s>i;){var n=i++;this.m_vertices[n].setV(t[n])}for(var i=0,s=this.m_vertexCount;s>i;){var e,n=i++,m=n;e=n+1<this.m_vertexCount?n+1:0;var a=box2D.common.math.B2Math.subtractVV(this.m_vertices[e],this.m_vertices[m]);box2D.common.B2Settings.b2Assert(a.lengthSquared()>2.2250738585072014e-308),this.m_normals[n].setV(box2D.common.math.B2Math.crossVF(a,1)),this.m_normals[n].normalize()}this.m_centroid=box2D.collision.shapes.B2PolygonShape.computeCentroid(this.m_vertices,this.m_vertexCount)},setAsBox:function(t,o){this.m_vertexCount=4,this.reserve(4),this.m_vertices[0].set(-t,-o),this.m_vertices[1].set(t,-o),this.m_vertices[2].set(t,o),this.m_vertices[3].set(-t,o),this.m_normals[0].set(0,-1),this.m_normals[1].set(1,0),this.m_normals[2].set(0,1),this.m_normals[3].set(-1,0),this.m_centroid.setZero()},setAsOrientedBox:function(t,o,i,s){null==s&&(s=0),this.m_vertexCount=4,this.reserve(4),this.m_vertices[0].set(-t,-o),this.m_vertices[1].set(t,-o),this.m_vertices[2].set(t,o),this.m_vertices[3].set(-t,o),this.m_normals[0].set(0,-1),this.m_normals[1].set(1,0),this.m_normals[2].set(0,1),this.m_normals[3].set(-1,0),this.m_centroid=i;var n=new box2D.common.math.B2Transform;n.position=i,n.R.set(s);for(var e=0,m=this.m_vertexCount;m>e;){var a=e++;this.m_vertices[a]=box2D.common.math.B2Math.mulX(n,this.m_vertices[a]),this.m_normals[a]=box2D.common.math.B2Math.mulMV(n.R,this.m_normals[a])}},setAsEdge:function(t,o){this.m_vertexCount=2,this.reserve(2),this.m_vertices[0].setV(t),this.m_vertices[1].setV(o),this.m_centroid.x=.5*(t.x+o.x),this.m_centroid.y=.5*(t.y+o.y),this.m_normals[0]=box2D.common.math.B2Math.crossVF(box2D.common.math.B2Math.subtractVV(o,t),1),this.m_normals[0].normalize(),this.m_normals[1].x=-this.m_normals[0].x,this.m_normals[1].y=-this.m_normals[0].y},testPoint:function(t,o){for(var i,s=t.R,n=o.x-t.position.x,e=o.y-t.position.y,m=n*s.col1.x+e*s.col1.y,a=n*s.col2.x+e*s.col2.y,c=0,l=this.m_vertexCount;l>c;){var r=c++;i=this.m_vertices[r],n=m-i.x,e=a-i.y,i=this.m_normals[r];var _=i.x*n+i.y*e;if(_>0)return!1}return!0},rayCast:function(t,o,i){var s,n,e,m,a=0,c=o.maxFraction;s=o.p1.x-i.position.x,n=o.p1.y-i.position.y,e=i.R;var l=s*e.col1.x+n*e.col1.y,r=s*e.col2.x+n*e.col2.y;s=o.p2.x-i.position.x,n=o.p2.y-i.position.y,e=i.R;for(var _=s*e.col1.x+n*e.col1.y,h=s*e.col2.x+n*e.col2.y,x=_-l,y=h-r,u=-1,p=0,d=this.m_vertexCount;d>p;){var B=p++;m=this.m_vertices[B],s=m.x-l,n=m.y-r,m=this.m_normals[B];var b=m.x*s+m.y*n,D=m.x*x+m.y*y;if(0==D){if(0>b)return!1}else 0>D&&a*D>b?(a=b/D,u=B):D>0&&c*D>b&&(c=b/D);if(a-2.2250738585072014e-308>c)return!1}return u>=0?(t.fraction=a,e=i.R,m=this.m_normals[u],t.normal.x=e.col1.x*m.x+e.col2.x*m.y,t.normal.y=e.col1.y*m.x+e.col2.y*m.y,!0):!1},computeAABB:function(t,o){for(var i=o.R,s=this.m_vertices[0],n=o.position.x+(i.col1.x*s.x+i.col2.x*s.y),e=o.position.y+(i.col1.y*s.x+i.col2.y*s.y),m=n,a=e,c=1,l=this.m_vertexCount;l>c;){var r=c++;s=this.m_vertices[r];var _=o.position.x+(i.col1.x*s.x+i.col2.x*s.y),h=o.position.y+(i.col1.y*s.x+i.col2.y*s.y);n=_>n?n:_,e=h>e?e:h,m=m>_?m:_,a=a>h?a:h}t.lowerBound.x=n-this.m_radius,t.lowerBound.y=e-this.m_radius,t.upperBound.x=m+this.m_radius,t.upperBound.y=a+this.m_radius},computeMass:function(t,o){if(2==this.m_vertexCount)return t.center.x=.5*(this.m_vertices[0].x+this.m_vertices[1].x),t.center.y=.5*(this.m_vertices[0].y+this.m_vertices[1].y),t.mass=0,void(t.I=0);for(var i=0,s=0,n=0,e=0,m=0,a=0,c=.3333333333333333,l=0,r=this.m_vertexCount;r>l;){var _,h=l++,x=this.m_vertices[h];_=h+1<this.m_vertexCount?this.m_vertices[h+1|0]:this.m_vertices[0];var y=x.x-m,u=x.y-a,p=_.x-m,d=_.y-a,B=y*d-u*p,b=.5*B;n+=b,i+=b*c*(m+x.x+_.x),s+=b*c*(a+x.y+_.y);var D=m,f=a,g=y,v=u,A=p,w=d,V=c*(.25*(g*g+A*g+A*A)+(D*g+D*A))+.5*D*D,C=c*(.25*(v*v+w*v+w*w)+(f*v+f*w))+.5*f*f;e+=B*(V+C)}t.mass=o*n,i*=1/n,s*=1/n,t.center.set(i,s),t.I=o*e},computeSubmergedArea:function(t,o,i,s){for(var n,e=box2D.common.math.B2Math.mulTMV(i.R,t),m=o-box2D.common.math.B2Math.dot(t,i.position),a=new Array,c=0,l=-1,r=-1,_=!1,h=0,x=this.m_vertexCount;x>h;){var y=h++;a[y]=box2D.common.math.B2Math.dot(e,this.m_vertices[y])-m;var u=a[y]<-2.2250738585072014e-308;y>0&&(u?_||(l=y-1,c++):_&&(r=y-1,c++)),_=u}switch(c){case 0:if(_){var p=new box2D.collision.shapes.B2MassData;return this.computeMass(p,1),s.setV(box2D.common.math.B2Math.mulX(i,p.center)),p.mass}return 0;case 1:-1==l?l=this.m_vertexCount-1:r=this.m_vertexCount-1}var d,B=(l+1)%this.m_vertexCount,b=(r+1)%this.m_vertexCount,D=(0-a[l])/(a[B]-a[l]),f=(0-a[r])/(a[b]-a[r]),g=new box2D.common.math.B2Vec2(this.m_vertices[l].x*(1-D)+this.m_vertices[B].x*D,this.m_vertices[l].y*(1-D)+this.m_vertices[B].y*D),v=new box2D.common.math.B2Vec2(this.m_vertices[r].x*(1-f)+this.m_vertices[b].x*f,this.m_vertices[r].y*(1-f)+this.m_vertices[b].y*f),A=0,w=new box2D.common.math.B2Vec2,V=this.m_vertices[B];for(n=B;n!=b;){n=(n+1)%this.m_vertexCount,d=n==b?v:this.m_vertices[n];var C=.5*((V.x-g.x)*(d.y-g.y)-(V.y-g.y)*(d.x-g.x));A+=C,w.x+=C*(g.x+V.x+d.x)/3,w.y+=C*(g.y+V.y+d.y)/3,V=d}return w.multiply(1/A),s.setV(box2D.common.math.B2Math.mulX(i,w)),A},getVertexCount:function(){return this.m_vertexCount},getVertices:function(){return this.m_vertices},getNormals:function(){return this.m_normals},getSupport:function(t){for(var o=0,i=this.m_vertices[0].x*t.x+this.m_vertices[0].y*t.y,s=1,n=this.m_vertexCount;n>s;){var e=s++,m=this.m_vertices[e].x*t.x+this.m_vertices[e].y*t.y;m>i&&(o=e,i=m)}return o},getSupportVertex:function(t){for(var o=0,i=this.m_vertices[0].x*t.x+this.m_vertices[0].y*t.y,s=1,n=this.m_vertexCount;n>s;){var e=s++,m=this.m_vertices[e].x*t.x+this.m_vertices[e].y*t.y;m>i&&(o=e,i=m)}return this.m_vertices[o]},validate:function(){return!1},reserve:function(t){for(var o=this.m_vertices.length;t>o;){var i=o++;this.m_vertices[i]=new box2D.common.math.B2Vec2,this.m_normals[i]=new box2D.common.math.B2Vec2}},__class__:box2D.collision.shapes.B2PolygonShape}),box2D.common.B2Color=function(t,o,i){var s=255*box2D.common.math.B2Math.clamp(t,0,1);this._r=0|s;var s=255*box2D.common.math.B2Math.clamp(o,0,1);this._g=0|s;var s=255*box2D.common.math.B2Math.clamp(i,0,1);this._b=0|s},box2D.common.B2Color.__name__=!0,box2D.common.B2Color.prototype={set:function(t,o,i){var s=255*box2D.common.math.B2Math.clamp(t,0,1);this._r=0|s;var s=255*box2D.common.math.B2Math.clamp(o,0,1);this._g=0|s;var s=255*box2D.common.math.B2Math.clamp(i,0,1);this._b=0|s},set_r:function(t){return function(o){var i,s=255*box2D.common.math.B2Math.clamp(t,0,1);return i=o._r=0|s}(this)},set_g:function(t){return function(o){var i,s=255*box2D.common.math.B2Math.clamp(t,0,1);return i=o._g=0|s}(this)},set_b:function(t){return function(o){var i,s=255*box2D.common.math.B2Math.clamp(t,0,1);return i=o._b=0|s}(this)},get_color:function(){return this._r<<16|this._g<<8|this._b},__class__:box2D.common.B2Color},box2D.common.B2Settings=function(){},box2D.common.B2Settings.__name__=!0,box2D.common.B2Settings.b2MixFriction=function(t,o){return Math.sqrt(t*o)},box2D.common.B2Settings.b2MixRestitution=function(t,o){return t>o?t:o},box2D.common.B2Settings.b2Assert=function(t){if(!t)throw"Assertion Failed"},box2D.common.math.B2Mat33=function(t,o,i){this.col1=new box2D.common.math.B2Vec3,this.col2=new box2D.common.math.B2Vec3,this.col3=new box2D.common.math.B2Vec3,null==t&&null==o&&null==i?(this.col1.setZero(),this.col2.setZero(),this.col3.setZero()):(this.col1.setV(t),this.col2.setV(o),this.col3.setV(i))},box2D.common.math.B2Mat33.__name__=!0,box2D.common.math.B2Mat33.prototype={setVVV:function(t,o,i){this.col1.setV(t),this.col2.setV(o),this.col3.setV(i)},copy:function(){return new box2D.common.math.B2Mat33(this.col1,this.col2,this.col3)},setM:function(t){this.col1.setV(t.col1),this.col2.setV(t.col2),this.col3.setV(t.col3)},addM:function(t){this.col1.x+=t.col1.x,this.col1.y+=t.col1.y,this.col1.z+=t.col1.z,this.col2.x+=t.col2.x,this.col2.y+=t.col2.y,this.col2.z+=t.col2.z,this.col3.x+=t.col3.x,this.col3.y+=t.col3.y,this.col3.z+=t.col3.z},setIdentity:function(){this.col1.x=1,this.col2.x=0,this.col3.x=0,this.col1.y=0,this.col2.y=1,this.col3.y=0,this.col1.z=0,this.col2.z=0,this.col3.z=1},setZero:function(){this.col1.x=0,this.col2.x=0,this.col3.x=0,this.col1.y=0,this.col2.y=0,this.col3.y=0,this.col1.z=0,this.col2.z=0,this.col3.z=0},solve22:function(t,o,i){var s=this.col1.x,n=this.col2.x,e=this.col1.y,m=this.col2.y,a=s*m-n*e;return 0!=a&&(a=1/a),t.x=a*(m*o-n*i),t.y=a*(s*i-e*o),t},solve33:function(t,o,i,s){var n=this.col1.x,e=this.col1.y,m=this.col1.z,a=this.col2.x,c=this.col2.y,l=this.col2.z,r=this.col3.x,_=this.col3.y,h=this.col3.z,x=n*(c*h-l*_)+e*(l*r-a*h)+m*(a*_-c*r);
return 0!=x&&(x=1/x),t.x=x*(o*(c*h-l*_)+i*(l*r-a*h)+s*(a*_-c*r)),t.y=x*(n*(i*h-s*_)+e*(s*r-o*h)+m*(o*_-i*r)),t.z=x*(n*(c*s-l*i)+e*(l*o-a*s)+m*(a*i-c*o)),t},__class__:box2D.common.math.B2Mat33},box2D.common.math.B2Math=function(){},box2D.common.math.B2Math.__name__=!0,box2D.common.math.B2Math.isValid=function(t){return Math.isNaN(t)||t==Math.NEGATIVE_INFINITY||t==Math.POSITIVE_INFINITY?!1:!0},box2D.common.math.B2Math.dot=function(t,o){return t.x*o.x+t.y*o.y},box2D.common.math.B2Math.crossVV=function(t,o){return t.x*o.y-t.y*o.x},box2D.common.math.B2Math.crossVF=function(t,o){var i=new box2D.common.math.B2Vec2(o*t.y,-o*t.x);return i},box2D.common.math.B2Math.crossFV=function(t,o){var i=new box2D.common.math.B2Vec2(-t*o.y,t*o.x);return i},box2D.common.math.B2Math.mulMV=function(t,o){var i=new box2D.common.math.B2Vec2(t.col1.x*o.x+t.col2.x*o.y,t.col1.y*o.x+t.col2.y*o.y);return i},box2D.common.math.B2Math.mulTMV=function(t,o){var i=new box2D.common.math.B2Vec2(box2D.common.math.B2Math.dot(o,t.col1),box2D.common.math.B2Math.dot(o,t.col2));return i},box2D.common.math.B2Math.mulX=function(t,o){var i=box2D.common.math.B2Math.mulMV(t.R,o);return i.x+=t.position.x,i.y+=t.position.y,i},box2D.common.math.B2Math.mulXT=function(t,o){var i=box2D.common.math.B2Math.subtractVV(o,t.position),s=i.x*t.R.col1.x+i.y*t.R.col1.y;return i.y=i.x*t.R.col2.x+i.y*t.R.col2.y,i.x=s,i},box2D.common.math.B2Math.addVV=function(t,o){var i=new box2D.common.math.B2Vec2(t.x+o.x,t.y+o.y);return i},box2D.common.math.B2Math.subtractVV=function(t,o){var i=new box2D.common.math.B2Vec2(t.x-o.x,t.y-o.y);return i},box2D.common.math.B2Math.distance=function(t,o){var i=t.x-o.x,s=t.y-o.y;return Math.sqrt(i*i+s*s)},box2D.common.math.B2Math.distanceSquared=function(t,o){var i=t.x-o.x,s=t.y-o.y;return i*i+s*s},box2D.common.math.B2Math.mulFV=function(t,o){var i=new box2D.common.math.B2Vec2(t*o.x,t*o.y);return i},box2D.common.math.B2Math.addMM=function(t,o){var i=box2D.common.math.B2Mat22.fromVV(box2D.common.math.B2Math.addVV(t.col1,o.col1),box2D.common.math.B2Math.addVV(t.col2,o.col2));return i},box2D.common.math.B2Math.mulMM=function(t,o){var i=box2D.common.math.B2Mat22.fromVV(box2D.common.math.B2Math.mulMV(t,o.col1),box2D.common.math.B2Math.mulMV(t,o.col2));return i},box2D.common.math.B2Math.mulTMM=function(t,o){var i=new box2D.common.math.B2Vec2(box2D.common.math.B2Math.dot(t.col1,o.col1),box2D.common.math.B2Math.dot(t.col2,o.col1)),s=new box2D.common.math.B2Vec2(box2D.common.math.B2Math.dot(t.col1,o.col2),box2D.common.math.B2Math.dot(t.col2,o.col2)),n=box2D.common.math.B2Mat22.fromVV(i,s);return n},box2D.common.math.B2Math.abs=function(t){return t>0?t:-t},box2D.common.math.B2Math.absV=function(t){var o=new box2D.common.math.B2Vec2(box2D.common.math.B2Math.abs(t.x),box2D.common.math.B2Math.abs(t.y));return o},box2D.common.math.B2Math.absM=function(t){var o=box2D.common.math.B2Mat22.fromVV(box2D.common.math.B2Math.absV(t.col1),box2D.common.math.B2Math.absV(t.col2));return o},box2D.common.math.B2Math.min=function(t,o){return o>t?t:o},box2D.common.math.B2Math.minV=function(t,o){var i=new box2D.common.math.B2Vec2(box2D.common.math.B2Math.min(t.x,o.x),box2D.common.math.B2Math.min(t.y,o.y));return i},box2D.common.math.B2Math.max=function(t,o){return t>o?t:o},box2D.common.math.B2Math.maxV=function(t,o){var i=new box2D.common.math.B2Vec2(box2D.common.math.B2Math.max(t.x,o.x),box2D.common.math.B2Math.max(t.y,o.y));return i},box2D.common.math.B2Math.clamp=function(t,o,i){return o>t?o:t>i?i:t},box2D.common.math.B2Math.clampV=function(t,o,i){return box2D.common.math.B2Math.maxV(o,box2D.common.math.B2Math.minV(t,i))},box2D.common.math.B2Math.swap=function(t,o){var i=t[0];t[0]=o[0],o[0]=i},box2D.common.math.B2Math.random=function(){return 2*Math.random()-1},box2D.common.math.B2Math.randomRange=function(t,o){var i=Math.random();return i=(o-t)*i+t},box2D.common.math.B2Math.nextPowerOfTwo=function(t){return t|=t>>1&2147483647,t|=t>>2&1073741823,t|=t>>4&268435455,t|=t>>8&16777215,t|=t>>16&65535,t+1},box2D.common.math.B2Math.isPowerOfTwo=function(t){var o=t>0&&0==(t&t-1);return o},box2D.common.math.B2Sweep=function(){this.localCenter=new box2D.common.math.B2Vec2,this.c0=new box2D.common.math.B2Vec2,this.c=new box2D.common.math.B2Vec2},box2D.common.math.B2Sweep.__name__=!0,box2D.common.math.B2Sweep.prototype={set:function(t){this.localCenter.setV(t.localCenter),this.c0.setV(t.c0),this.c.setV(t.c),this.a0=t.a0,this.a=t.a,this.t0=t.t0},copy:function(){var t=new box2D.common.math.B2Sweep;return t.localCenter.setV(this.localCenter),t.c0.setV(this.c0),t.c.setV(this.c),t.a0=this.a0,t.a=this.a,t.t0=this.t0,t},getTransform:function(t,o){t.position.x=(1-o)*this.c0.x+o*this.c.x,t.position.y=(1-o)*this.c0.y+o*this.c.y;var i=(1-o)*this.a0+o*this.a;t.R.set(i);var s=t.R;t.position.x-=s.col1.x*this.localCenter.x+s.col2.x*this.localCenter.y,t.position.y-=s.col1.y*this.localCenter.x+s.col2.y*this.localCenter.y},advance:function(t){if(this.t0<t&&1-this.t0>2.2250738585072014e-308){var o=(t-this.t0)/(1-this.t0);this.c0.x=(1-o)*this.c0.x+o*this.c.x,this.c0.y=(1-o)*this.c0.y+o*this.c.y,this.a0=(1-o)*this.a0+o*this.a,this.t0=t}},__class__:box2D.common.math.B2Sweep},box2D.common.math.B2Vec3=function(t,o,i){null==i&&(i=0),null==o&&(o=0),null==t&&(t=0),this.x=t,this.y=o,this.z=i},box2D.common.math.B2Vec3.__name__=!0,box2D.common.math.B2Vec3.prototype={setZero:function(){this.x=this.y=this.z=0},set:function(t,o,i){this.x=t,this.y=o,this.z=i},setV:function(t){this.x=t.x,this.y=t.y,this.z=t.z},getNegative:function(){return new box2D.common.math.B2Vec3(-this.x,-this.y,-this.z)},negativeSelf:function(){this.x=-this.x,this.y=-this.y,this.z=-this.z},copy:function(){return new box2D.common.math.B2Vec3(this.x,this.y,this.z)},add:function(t){this.x+=t.x,this.y+=t.y,this.z+=t.z},subtract:function(t){this.x-=t.x,this.y-=t.y,this.z-=t.z},multiply:function(t){this.x*=t,this.y*=t,this.z*=t},__class__:box2D.common.math.B2Vec3},box2D.dynamics={},box2D.dynamics.B2Body=function(t,o){this.m_xf=new box2D.common.math.B2Transform,this.m_sweep=new box2D.common.math.B2Sweep,this.m_linearVelocity=new box2D.common.math.B2Vec2,this.m_force=new box2D.common.math.B2Vec2,this.m_flags=0,t.bullet&&(this.m_flags|=box2D.dynamics.B2Body.e_bulletFlag),t.fixedRotation&&(this.m_flags|=box2D.dynamics.B2Body.e_fixedRotationFlag),t.allowSleep&&(this.m_flags|=box2D.dynamics.B2Body.e_allowSleepFlag),t.awake&&(this.m_flags|=box2D.dynamics.B2Body.e_awakeFlag),t.active&&(this.m_flags|=box2D.dynamics.B2Body.e_activeFlag),this.m_world=o,this.m_xf.position.setV(t.position),this.m_xf.R.set(t.angle),this.m_sweep.localCenter.setZero(),this.m_sweep.t0=1,this.m_sweep.a0=this.m_sweep.a=t.angle;var i=this.m_xf.R,s=this.m_sweep.localCenter;this.m_sweep.c.x=i.col1.x*s.x+i.col2.x*s.y,this.m_sweep.c.y=i.col1.y*s.x+i.col2.y*s.y,this.m_sweep.c.x+=this.m_xf.position.x,this.m_sweep.c.y+=this.m_xf.position.y,this.m_sweep.c0.setV(this.m_sweep.c),this.m_jointList=null,this.m_controllerList=null,this.m_contactList=null,this.m_controllerCount=0,this.m_prev=null,this.m_next=null,this.m_linearVelocity.setV(t.linearVelocity),this.m_angularVelocity=t.angularVelocity,this.m_linearDamping=t.linearDamping,this.m_angularDamping=t.angularDamping,this.m_force.set(0,0),this.m_torque=0,this.m_sleepTime=0,this.m_type=t.type,this.m_type==box2D.dynamics.B2Body.b2_dynamicBody?(this.m_mass=1,this.m_invMass=1):(this.m_mass=0,this.m_invMass=0),this.m_I=0,this.m_invI=0,this.m_inertiaScale=t.inertiaScale,this.m_userData=t.userData,this.m_fixtureList=null,this.m_fixtureCount=0},box2D.dynamics.B2Body.__name__=!0,box2D.dynamics.B2Body.prototype={connectEdges:function(t,o,i){var s=Math.atan2(o.getDirectionVector().y,o.getDirectionVector().x),n=Math.tan(.5*(s-i)),e=box2D.common.math.B2Math.mulFV(n,o.getDirectionVector());e=box2D.common.math.B2Math.subtractVV(e,o.getNormalVector()),e=box2D.common.math.B2Math.mulFV(box2D.common.B2Settings.b2_toiSlop,e),e=box2D.common.math.B2Math.addVV(e,o.getVertex1());var m=box2D.common.math.B2Math.addVV(t.getDirectionVector(),o.getDirectionVector());m.normalize();var a=box2D.common.math.B2Math.dot(t.getDirectionVector(),o.getNormalVector())>0;return t.setNextEdge(o,e,m,a),o.setPrevEdge(t,e,m,a),s},createFixture:function(t){if(1==this.m_world.isLocked())return null;var o=new box2D.dynamics.B2Fixture;if(o.create(this,this.m_xf,t),0!=(this.m_flags&box2D.dynamics.B2Body.e_activeFlag)){var i=this.m_world.m_contactManager.m_broadPhase;o.createProxy(i,this.m_xf)}return o.m_next=this.m_fixtureList,this.m_fixtureList=o,++this.m_fixtureCount,o.m_body=this,o.m_density>0&&this.resetMassData(),this.m_world.m_flags|=box2D.dynamics.B2World.e_newFixture,o},createFixture2:function(t,o){null==o&&(o=0);var i=new box2D.dynamics.B2FixtureDef;return i.shape=t,i.density=o,this.createFixture(i)},DestroyFixture:function(t){if(1!=this.m_world.isLocked()){for(var o=this.m_fixtureList,i=null,s=!1;null!=o;){if(o==t){null!=i?i.m_next=t.m_next:this.m_fixtureList=t.m_next,s=!0;break}i=o,o=o.m_next}for(var n=this.m_contactList;null!=n;){var e=n.contact;n=n.next;var m=e.getFixtureA(),a=e.getFixtureB();(t==m||t==a)&&this.m_world.m_contactManager.destroy(e)}if(0!=(this.m_flags&box2D.dynamics.B2Body.e_activeFlag)){var c=this.m_world.m_contactManager.m_broadPhase;t.destroyProxy(c)}t.destroy(),t.m_body=null,t.m_next=null,--this.m_fixtureCount,this.resetMassData()}},setPositionAndAngle:function(t,o){var i;if(1!=this.m_world.isLocked()){this.m_xf.R.set(o),this.m_xf.position.setV(t);var s=this.m_xf.R,n=this.m_sweep.localCenter;this.m_sweep.c.x=s.col1.x*n.x+s.col2.x*n.y,this.m_sweep.c.y=s.col1.y*n.x+s.col2.y*n.y,this.m_sweep.c.x+=this.m_xf.position.x,this.m_sweep.c.y+=this.m_xf.position.y,this.m_sweep.c0.setV(this.m_sweep.c),this.m_sweep.a0=this.m_sweep.a=o;var e=this.m_world.m_contactManager.m_broadPhase;for(i=this.m_fixtureList;null!=i;)i.synchronize(e,this.m_xf,this.m_xf),i=i.m_next;this.m_world.m_contactManager.findNewContacts()}},setTransform:function(t){this.setPositionAndAngle(t.position,t.getAngle())},getTransform:function(){return this.m_xf},getPosition:function(){return this.m_xf.position},setPosition:function(t){this.setPositionAndAngle(t,this.getAngle())},getAngle:function(){return this.m_sweep.a},setAngle:function(t){this.setPositionAndAngle(this.getPosition(),t)},getWorldCenter:function(){return this.m_sweep.c},getLocalCenter:function(){return this.m_sweep.localCenter},setLinearVelocity:function(t){this.m_type!=box2D.dynamics.B2Body.b2_staticBody&&this.m_linearVelocity.setV(t)},getLinearVelocity:function(){return this.m_linearVelocity},setAngularVelocity:function(t){this.m_type!=box2D.dynamics.B2Body.b2_staticBody&&(this.m_angularVelocity=t)},getAngularVelocity:function(){return this.m_angularVelocity},getDefinition:function(){var t=new box2D.dynamics.B2BodyDef;return t.type=this.getType(),t.allowSleep=(this.m_flags&box2D.dynamics.B2Body.e_allowSleepFlag)==box2D.dynamics.B2Body.e_allowSleepFlag,t.angle=this.getAngle(),t.angularDamping=this.m_angularDamping,t.angularVelocity=this.m_angularVelocity,t.fixedRotation=(this.m_flags&box2D.dynamics.B2Body.e_fixedRotationFlag)==box2D.dynamics.B2Body.e_fixedRotationFlag,t.bullet=(this.m_flags&box2D.dynamics.B2Body.e_bulletFlag)==box2D.dynamics.B2Body.e_bulletFlag,t.awake=(this.m_flags&box2D.dynamics.B2Body.e_awakeFlag)==box2D.dynamics.B2Body.e_awakeFlag,t.linearDamping=this.m_linearDamping,t.linearVelocity.setV(this.getLinearVelocity()),t.position=this.getPosition(),t.userData=this.getUserData(),t},applyForce:function(t,o){this.m_type==box2D.dynamics.B2Body.b2_dynamicBody&&(0==this.isAwake()&&this.setAwake(!0),this.m_force.x+=t.x,this.m_force.y+=t.y,this.m_torque+=(o.x-this.m_sweep.c.x)*t.y-(o.y-this.m_sweep.c.y)*t.x)},applyTorque:function(t){this.m_type==box2D.dynamics.B2Body.b2_dynamicBody&&(0==this.isAwake()&&this.setAwake(!0),this.m_torque+=t)},applyImpulse:function(t,o){this.m_type==box2D.dynamics.B2Body.b2_dynamicBody&&(0==this.isAwake()&&this.setAwake(!0),this.m_linearVelocity.x+=this.m_invMass*t.x,this.m_linearVelocity.y+=this.m_invMass*t.y,this.m_angularVelocity+=this.m_invI*((o.x-this.m_sweep.c.x)*t.y-(o.y-this.m_sweep.c.y)*t.x))},split:function(t){for(var o=this.getLinearVelocity().copy(),i=this.getAngularVelocity(),s=this.getWorldCenter(),n=this,e=this.m_world.createBody(this.getDefinition()),m=null,a=n.m_fixtureList;null!=a;)if(t(a)){var c=a.m_next;null!=m?m.m_next=c:n.m_fixtureList=c,n.m_fixtureCount--,a.m_next=e.m_fixtureList,e.m_fixtureList=a,e.m_fixtureCount++,a.m_body=e,a=c}else m=a,a=a.m_next;n.resetMassData(),e.resetMassData();var l=n.getWorldCenter(),r=e.getWorldCenter(),_=box2D.common.math.B2Math.addVV(o,box2D.common.math.B2Math.crossFV(i,box2D.common.math.B2Math.subtractVV(l,s))),h=box2D.common.math.B2Math.addVV(o,box2D.common.math.B2Math.crossFV(i,box2D.common.math.B2Math.subtractVV(r,s)));return n.setLinearVelocity(_),e.setLinearVelocity(h),n.setAngularVelocity(i),e.setAngularVelocity(i),n.synchronizeFixtures(),e.synchronizeFixtures(),e},merge:function(t){var o;o=t.m_fixtureList;for(var i=this,s=t;null!=o;){var n=o.m_next;t.m_fixtureCount--,o.m_next=this.m_fixtureList,this.m_fixtureList=o,this.m_fixtureCount++,o.m_body=s,o=n}i.m_fixtureCount=0;i.getWorldCenter(),s.getWorldCenter(),i.getLinearVelocity().copy(),s.getLinearVelocity().copy(),i.getAngularVelocity(),s.getAngularVelocity();i.resetMassData(),this.synchronizeFixtures()},getMass:function(){return this.m_mass},getInertia:function(){return this.m_I},getMassData:function(t){t.mass=this.m_mass,t.I=this.m_I,t.center.setV(this.m_sweep.localCenter)},setMassData:function(t){if(box2D.common.B2Settings.b2Assert(0==this.m_world.isLocked()),1!=this.m_world.isLocked()&&this.m_type==box2D.dynamics.B2Body.b2_dynamicBody){this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_mass=t.mass,this.m_mass<=0&&(this.m_mass=1),this.m_invMass=1/this.m_mass,t.I>0&&0==(this.m_flags&box2D.dynamics.B2Body.e_fixedRotationFlag)&&(this.m_I=t.I-this.m_mass*(t.center.x*t.center.x+t.center.y*t.center.y),this.m_invI=1/this.m_I);var o=this.m_sweep.c.copy();this.m_sweep.localCenter.setV(t.center),this.m_sweep.c0.setV(box2D.common.math.B2Math.mulX(this.m_xf,this.m_sweep.localCenter)),this.m_sweep.c.setV(this.m_sweep.c0),this.m_linearVelocity.x+=this.m_angularVelocity*-(this.m_sweep.c.y-o.y),this.m_linearVelocity.y+=this.m_angularVelocity*(this.m_sweep.c.x-o.x)}},resetMassData:function(){if(this.m_mass=0,this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_sweep.localCenter.setZero(),this.m_type!=box2D.dynamics.B2Body.b2_staticBody&&this.m_type!=box2D.dynamics.B2Body.b2_kinematicBody){for(var t=box2D.common.math.B2Vec2.make(0,0),o=this.m_fixtureList;null!=o;)if(0!=o.m_density){var i=o.getMassData();this.m_mass+=i.mass,t.x+=i.center.x*i.mass,t.y+=i.center.y*i.mass,this.m_I+=i.I,o=o.m_next}this.m_mass>0?(this.m_invMass=1/this.m_mass,t.x*=this.m_invMass,t.y*=this.m_invMass):(this.m_mass=1,this.m_invMass=1),this.m_I>0&&0==(this.m_flags&box2D.dynamics.B2Body.e_fixedRotationFlag)?(this.m_I-=this.m_mass*(t.x*t.x+t.y*t.y),this.m_I*=this.m_inertiaScale,box2D.common.B2Settings.b2Assert(this.m_I>0),this.m_invI=1/this.m_I):(this.m_I=0,this.m_invI=0);var s=this.m_sweep.c.copy();this.m_sweep.localCenter.setV(t),this.m_sweep.c0.setV(box2D.common.math.B2Math.mulX(this.m_xf,this.m_sweep.localCenter)),this.m_sweep.c.setV(this.m_sweep.c0),this.m_linearVelocity.x+=this.m_angularVelocity*-(this.m_sweep.c.y-s.y),this.m_linearVelocity.y+=this.m_angularVelocity*(this.m_sweep.c.x-s.x)}},getWorldPoint:function(t){var o=this.m_xf.R,i=new box2D.common.math.B2Vec2(o.col1.x*t.x+o.col2.x*t.y,o.col1.y*t.x+o.col2.y*t.y);return i.x+=this.m_xf.position.x,i.y+=this.m_xf.position.y,i},getWorldVector:function(t){return box2D.common.math.B2Math.mulMV(this.m_xf.R,t)},getLocalPoint:function(t){return box2D.common.math.B2Math.mulXT(this.m_xf,t)},getLocalVector:function(t){return box2D.common.math.B2Math.mulTMV(this.m_xf.R,t)},getLinearVelocityFromWorldPoint:function(t){return new box2D.common.math.B2Vec2(this.m_linearVelocity.x-this.m_angularVelocity*(t.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(t.x-this.m_sweep.c.x))},getLinearVelocityFromLocalPoint:function(t){var o=this.m_xf.R,i=new box2D.common.math.B2Vec2(o.col1.x*t.x+o.col2.x*t.y,o.col1.y*t.x+o.col2.y*t.y);return i.x+=this.m_xf.position.x,i.y+=this.m_xf.position.y,new box2D.common.math.B2Vec2(this.m_linearVelocity.x-this.m_angularVelocity*(i.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(i.x-this.m_sweep.c.x))},getLinearDamping:function(){return this.m_linearDamping},setLinearDamping:function(t){this.m_linearDamping=t},getAngularDamping:function(){return this.m_angularDamping},setAngularDamping:function(t){this.m_angularDamping=t},setType:function(t){if(this.m_type!=t){this.m_type=t,this.resetMassData(),this.m_type==box2D.dynamics.B2Body.b2_staticBody&&(this.m_linearVelocity.setZero(),this.m_angularVelocity=0),this.setAwake(!0),this.m_force.setZero(),this.m_torque=0;for(var o=this.m_contactList;null!=o;)o.contact.flagForFiltering(),o=o.next}},getType:function(){return this.m_type},setBullet:function(t){t?this.m_flags|=box2D.dynamics.B2Body.e_bulletFlag:this.m_flags&=~box2D.dynamics.B2Body.e_bulletFlag},isBullet:function(){return(this.m_flags&box2D.dynamics.B2Body.e_bulletFlag)==box2D.dynamics.B2Body.e_bulletFlag},setSleepingAllowed:function(t){t?this.m_flags|=box2D.dynamics.B2Body.e_allowSleepFlag:(this.m_flags&=~box2D.dynamics.B2Body.e_allowSleepFlag,this.setAwake(!0))},setAwake:function(t){t?(this.m_flags|=box2D.dynamics.B2Body.e_awakeFlag,this.m_sleepTime=0):(this.m_flags&=~box2D.dynamics.B2Body.e_awakeFlag,this.m_sleepTime=0,this.m_linearVelocity.setZero(),this.m_angularVelocity=0,this.m_force.setZero(),this.m_torque=0)},isAwake:function(){return(this.m_flags&box2D.dynamics.B2Body.e_awakeFlag)==box2D.dynamics.B2Body.e_awakeFlag},setFixedRotation:function(t){t?this.m_flags|=box2D.dynamics.B2Body.e_fixedRotationFlag:this.m_flags&=~box2D.dynamics.B2Body.e_fixedRotationFlag,this.resetMassData()},isFixedRotation:function(){return(this.m_flags&box2D.dynamics.B2Body.e_fixedRotationFlag)==box2D.dynamics.B2Body.e_fixedRotationFlag},setActive:function(t){if(t!=this.isActive()){var o,i;if(t)for(this.m_flags|=box2D.dynamics.B2Body.e_activeFlag,o=this.m_world.m_contactManager.m_broadPhase,i=this.m_fixtureList;null!=i;)i.createProxy(o,this.m_xf),i=i.m_next;else{for(this.m_flags&=~box2D.dynamics.B2Body.e_activeFlag,o=this.m_world.m_contactManager.m_broadPhase,i=this.m_fixtureList;null!=i;)i.destroyProxy(o),i=i.m_next;for(var s=this.m_contactList;null!=s;){var n=s;s=s.next,this.m_world.m_contactManager.destroy(n.contact)}this.m_contactList=null}}},isActive:function(){return(this.m_flags&box2D.dynamics.B2Body.e_activeFlag)==box2D.dynamics.B2Body.e_activeFlag},isSleepingAllowed:function(){return(this.m_flags&box2D.dynamics.B2Body.e_allowSleepFlag)==box2D.dynamics.B2Body.e_allowSleepFlag},getFixtureList:function(){return this.m_fixtureList},getJointList:function(){return this.m_jointList},getControllerList:function(){return this.m_controllerList},getContactList:function(){return this.m_contactList},getNext:function(){return this.m_next},getUserData:function(){return this.m_userData},setUserData:function(t){this.m_userData=t},getWorld:function(){return this.m_world},synchronizeFixtures:function(){var t=box2D.dynamics.B2Body.s_xf1;t.R.set(this.m_sweep.a0);var o=t.R,i=this.m_sweep.localCenter;t.position.x=this.m_sweep.c0.x-(o.col1.x*i.x+o.col2.x*i.y),t.position.y=this.m_sweep.c0.y-(o.col1.y*i.x+o.col2.y*i.y);var s,n=this.m_world.m_contactManager.m_broadPhase;for(s=this.m_fixtureList;null!=s;)s.synchronize(n,t,this.m_xf),s=s.m_next},synchronizeTransform:function(){this.m_xf.R.set(this.m_sweep.a);var t=this.m_xf.R,o=this.m_sweep.localCenter;this.m_xf.position.x=this.m_sweep.c.x-(t.col1.x*o.x+t.col2.x*o.y),this.m_xf.position.y=this.m_sweep.c.y-(t.col1.y*o.x+t.col2.y*o.y)},shouldCollide:function(t){if(this.m_type!=box2D.dynamics.B2Body.b2_dynamicBody&&t.m_type!=box2D.dynamics.B2Body.b2_dynamicBody)return!1;for(var o=this.m_jointList;null!=o;){if(o.other==t&&0==o.joint.m_collideConnected)return!1;o=o.next}return!0},advance:function(t){this.m_sweep.advance(t),this.m_sweep.c.setV(this.m_sweep.c0),this.m_sweep.a=this.m_sweep.a0,this.synchronizeTransform()},__class__:box2D.dynamics.B2Body},box2D.dynamics.B2BodyDef=function(){this.position=new box2D.common.math.B2Vec2,this.linearVelocity=new box2D.common.math.B2Vec2,this.userData=null,this.angle=0,this.angularVelocity=0,this.linearDamping=0,this.angularDamping=0,this.allowSleep=!0,this.awake=!0,this.fixedRotation=!1,this.bullet=!1,this.type=box2D.dynamics.B2Body.b2_staticBody,this.active=!0,this.inertiaScale=1},box2D.dynamics.B2BodyDef.__name__=!0,box2D.dynamics.B2BodyDef.prototype={__class__:box2D.dynamics.B2BodyDef},box2D.dynamics.B2ContactFilter=function(){},box2D.dynamics.B2ContactFilter.__name__=!0,box2D.dynamics.B2ContactFilter.prototype={shouldCollide:function(t,o){var i=t.getFilterData(),s=o.getFilterData();if(i.groupIndex==s.groupIndex&&0!=i.groupIndex)return i.groupIndex>0;var n=0!=(i.maskBits&s.categoryBits)&&0!=(i.categoryBits&s.maskBits);return n},rayCollide:function(t,o){return null==t?!0:this.shouldCollide(js.Boot.__cast(t,box2D.dynamics.B2Fixture),o)},__class__:box2D.dynamics.B2ContactFilter},box2D.dynamics.B2ContactImpulse=function(){this.normalImpulses=new Array,this.tangentImpulses=new Array},box2D.dynamics.B2ContactImpulse.__name__=!0,box2D.dynamics.B2ContactImpulse.prototype={__class__:box2D.dynamics.B2ContactImpulse},box2D.dynamics.B2ContactListener=function(){},box2D.dynamics.B2ContactListener.__name__=!0,box2D.dynamics.B2ContactListener.prototype={beginContact:function(){},endContact:function(){},preSolve:function(){},postSolve:function(){},__class__:box2D.dynamics.B2ContactListener},box2D.dynamics.B2ContactManager=function(){this.m_world=null,this.m_contactCount=0,this.m_contactFilter=box2D.dynamics.B2ContactFilter.b2_defaultFilter,this.m_contactListener=box2D.dynamics.B2ContactListener.b2_defaultListener,this.m_contactFactory=new box2D.dynamics.contacts.B2ContactFactory(this.m_allocator),this.m_broadPhase=new box2D.collision.B2DynamicTreeBroadPhase},box2D.dynamics.B2ContactManager.__name__=!0,box2D.dynamics.B2ContactManager.prototype={addPair:function(t,o){var i;i=js.Boot.__cast(t,box2D.dynamics.B2Fixture);var s;s=js.Boot.__cast(o,box2D.dynamics.B2Fixture);var n=i.getBody(),e=s.getBody();if(n!=e){for(var m=e.getContactList();null!=m;){if(m.other==n){var a=m.contact.getFixtureA(),c=m.contact.getFixtureB();if(a==i&&c==s)return;if(a==s&&c==i)return}m=m.next}if(0!=e.shouldCollide(n)&&0!=this.m_contactFilter.shouldCollide(i,s)){var l=this.m_contactFactory.create(i,s);i=l.getFixtureA(),s=l.getFixtureB(),n=i.m_body,e=s.m_body,l.m_prev=null,l.m_next=this.m_world.m_contactList,null!=this.m_world.m_contactList&&(this.m_world.m_contactList.m_prev=l),this.m_world.m_contactList=l,l.m_nodeA.contact=l,l.m_nodeA.other=e,l.m_nodeA.prev=null,l.m_nodeA.next=n.m_contactList,null!=n.m_contactList&&(n.m_contactList.prev=l.m_nodeA),n.m_contactList=l.m_nodeA,l.m_nodeB.contact=l,l.m_nodeB.other=n,l.m_nodeB.prev=null,l.m_nodeB.next=e.m_contactList,null!=e.m_contactList&&(e.m_contactList.prev=l.m_nodeB),e.m_contactList=l.m_nodeB,++this.m_world.m_contactCount}}},findNewContacts:function(){this.m_broadPhase.updatePairs($bind(this,this.addPair))},destroy:function(t){var o=t.getFixtureA(),i=t.getFixtureB(),s=o.getBody(),n=i.getBody();t.isTouching()&&this.m_contactListener.endContact(t),null!=t.m_prev&&(t.m_prev.m_next=t.m_next),null!=t.m_next&&(t.m_next.m_prev=t.m_prev),t==this.m_world.m_contactList&&(this.m_world.m_contactList=t.m_next),null!=t.m_nodeA.prev&&(t.m_nodeA.prev.next=t.m_nodeA.next),null!=t.m_nodeA.next&&(t.m_nodeA.next.prev=t.m_nodeA.prev),t.m_nodeA==s.m_contactList&&(s.m_contactList=t.m_nodeA.next),null!=t.m_nodeB.prev&&(t.m_nodeB.prev.next=t.m_nodeB.next),null!=t.m_nodeB.next&&(t.m_nodeB.next.prev=t.m_nodeB.prev),t.m_nodeB==n.m_contactList&&(n.m_contactList=t.m_nodeB.next),this.m_contactFactory.destroy(t),--this.m_contactCount},collide:function(){for(var t=this.m_world.m_contactList;null!=t;){var o=t.getFixtureA(),i=t.getFixtureB(),s=o.getBody(),n=i.getBody();if(0!=s.isAwake()||0!=n.isAwake()){if(0!=(t.m_flags&box2D.dynamics.contacts.B2Contact.e_filterFlag)){if(0==n.shouldCollide(s)){var e=t;t=e.getNext(),this.destroy(e);continue}if(0==this.m_contactFilter.shouldCollide(o,i)){var e=t;t=e.getNext(),this.destroy(e);continue}t.m_flags&=~box2D.dynamics.contacts.B2Contact.e_filterFlag}var m=o.m_proxy,a=i.m_proxy,c=this.m_broadPhase.testOverlap(m,a);if(0!=c)t.update(this.m_contactListener),t=t.getNext();else{var e=t;t=e.getNext(),this.destroy(e)}}else t=t.getNext()}},__class__:box2D.dynamics.B2ContactManager},box2D.dynamics.B2DebugDraw=function(){this.m_drawScale=1,this.m_lineThickness=1,this.m_alpha=1,this.m_fillAlpha=1,this.m_xformScale=1,this.m_drawFlags=0},box2D.dynamics.B2DebugDraw.__name__=!0,box2D.dynamics.B2DebugDraw.prototype={setFlags:function(t){this.m_drawFlags=t},getFlags:function(){return this.m_drawFlags},appendFlags:function(t){this.m_drawFlags|=t},clearFlags:function(t){this.m_drawFlags&=~t},setCanvas:function(t){this.m_canvas=t,this.m_ctx=t.getContext("2d")},setDrawScale:function(t){this.m_drawScale=t},getDrawScale:function(){return this.m_drawScale},setLineThickness:function(t){this.m_lineThickness=t},getLineThickness:function(){return this.m_lineThickness},setAlpha:function(t){this.m_alpha=t},getAlpha:function(){return this.m_alpha},setFillAlpha:function(t){this.m_fillAlpha=t},getFillAlpha:function(){return this.m_fillAlpha},setXFormScale:function(t){this.m_xformScale=t},getXFormScale:function(){return this.m_xformScale},drawPolygon:function(t,o,i){this.m_ctx.beginPath(),this.m_ctx.moveTo(t[0].x*this.m_drawScale,t[0].y*this.m_drawScale);for(var s=1;o>s;){var n=s++;this.m_ctx.lineTo(t[n].x*this.m_drawScale,t[n].y*this.m_drawScale)}this.m_ctx.lineTo(t[0].x*this.m_drawScale,t[0].y*this.m_drawScale),this.m_ctx.closePath(),this.m_ctx.globalAlpha=this.m_alpha,this.m_ctx.strokeStyle="#"+StringTools.hex(i.get_color()),this.m_ctx.lineWidth=this.m_lineThickness,this.m_ctx.stroke()},drawSolidPolygon:function(t,o,i){this.m_ctx.beginPath(),this.m_ctx.moveTo(t[0].x*this.m_drawScale,t[0].y*this.m_drawScale);for(var s=1;o>s;){var n=s++;this.m_ctx.lineTo(t[n].x*this.m_drawScale,t[n].y*this.m_drawScale)}this.m_ctx.lineTo(t[0].x*this.m_drawScale,t[0].y*this.m_drawScale),this.m_ctx.closePath(),this.m_ctx.globalAlpha=this.m_alpha,this.m_ctx.strokeStyle="#"+StringTools.hex(i.get_color()),this.m_ctx.lineWidth=this.m_lineThickness,this.m_ctx.stroke(),this.m_ctx.globalAlpha=this.m_fillAlpha,this.m_ctx.fillStyle="#"+StringTools.hex(i.get_color()),this.m_ctx.fill()},drawCircle:function(t,o,i){this.m_ctx.beginPath(),this.m_ctx.arc(t.x*this.m_drawScale,t.y*this.m_drawScale,o*this.m_drawScale,0,2*Math.PI,!0),this.m_ctx.closePath(),this.m_ctx.globalAlpha=this.m_alpha,this.m_ctx.lineWidth=this.m_lineThickness,this.m_ctx.strokeStyle="#"+StringTools.hex(i.get_color()),this.m_ctx.stroke()},drawSolidCircle:function(t,o,i,s){this.m_ctx.beginPath(),this.m_ctx.arc(t.x*this.m_drawScale,t.y*this.m_drawScale,o*this.m_drawScale,0,2*Math.PI,!0),this.m_ctx.closePath(),this.m_ctx.globalAlpha=this.m_fillAlpha,this.m_ctx.fillStyle="#"+StringTools.hex(s.get_color()),this.m_ctx.fill(),this.m_ctx.globalAlpha=this.m_alpha,this.m_ctx.lineWidth=this.m_lineThickness,this.m_ctx.strokeStyle="#"+StringTools.hex(s.get_color()),this.m_ctx.stroke(),this.m_ctx.beginPath(),this.m_ctx.moveTo(t.x*this.m_drawScale,t.y*this.m_drawScale),this.m_ctx.lineTo((t.x+i.x*o)*this.m_drawScale,(t.y+i.y*o)*this.m_drawScale),this.m_ctx.closePath(),this.m_ctx.stroke()},drawSegment:function(t,o,i){this.m_ctx.beginPath(),this.m_ctx.moveTo(t.x*this.m_drawScale,t.y*this.m_drawScale),this.m_ctx.lineTo(o.x*this.m_drawScale,o.y*this.m_drawScale),this.m_ctx.closePath(),this.m_ctx.globalAlpha=this.m_alpha,this.m_ctx.strokeStyle="#"+StringTools.hex(i.get_color()),this.m_ctx.lineWidth=this.m_lineThickness,this.m_ctx.stroke()},drawTransform:function(){},__class__:box2D.dynamics.B2DebugDraw},box2D.dynamics.B2DestructionListener=function(){},box2D.dynamics.B2DestructionListener.__name__=!0,box2D.dynamics.B2DestructionListener.prototype={sayGoodbyeJoint:function(){},sayGoodbyeFixture:function(){},__class__:box2D.dynamics.B2DestructionListener},box2D.dynamics.B2FilterData=function(){this.categoryBits=1,this.maskBits=65535,this.groupIndex=0},box2D.dynamics.B2FilterData.__name__=!0,box2D.dynamics.B2FilterData.prototype={copy:function(){var t=new box2D.dynamics.B2FilterData;return t.categoryBits=this.categoryBits,t.maskBits=this.maskBits,t.groupIndex=this.groupIndex,t},__class__:box2D.dynamics.B2FilterData},box2D.dynamics.B2Fixture=function(){this.m_filter=new box2D.dynamics.B2FilterData,this.m_aabb=new box2D.collision.B2AABB,this.m_userData=null,this.m_body=null,this.m_next=null,this.m_shape=null,this.m_density=0,this.m_friction=0,this.m_restitution=0},box2D.dynamics.B2Fixture.__name__=!0,box2D.dynamics.B2Fixture.prototype={getType:function(){return this.m_shape.getType()},getShape:function(){return this.m_shape},setSensor:function(t){if(this.m_isSensor!=t&&(this.m_isSensor=t,null!=this.m_body))for(var o=this.m_body.getContactList();null!=o;){var i=o.contact,s=i.getFixtureA(),n=i.getFixtureB();(s==this||n==this)&&i.setSensor(s.isSensor()||n.isSensor()),o=o.next}},isSensor:function(){return this.m_isSensor},setFilterData:function(t){if(this.m_filter=t.copy(),null==this.m_body)for(var o=this.m_body.getContactList();null!=o;){var i=o.contact,s=i.getFixtureA(),n=i.getFixtureB();(s==this||n==this)&&i.flagForFiltering(),o=o.next}},getFilterData:function(){return this.m_filter.copy()},getBody:function(){return this.m_body},getNext:function(){return this.m_next},getUserData:function(){return this.m_userData},SetUserData:function(t){this.m_userData=t},testPoint:function(t){return this.m_shape.testPoint(this.m_body.getTransform(),t)},rayCast:function(t,o){return this.m_shape.rayCast(t,o,this.m_body.getTransform())},getMassData:function(t){return null==t&&(t=new box2D.collision.shapes.B2MassData),this.m_shape.computeMass(t,this.m_density),t},setDensity:function(t){this.m_density=t},getDensity:function(){return this.m_density},getFriction:function(){return this.m_friction},setFriction:function(t){this.m_friction=t},getRestitution:function(){return this.m_restitution},setRestitution:function(t){this.m_restitution=t},getAABB:function(){return this.m_aabb},create:function(t,o,i){this.m_userData=i.userData,this.m_friction=i.friction,this.m_restitution=i.restitution,this.m_body=t,this.m_next=null,this.m_filter=i.filter.copy(),this.m_isSensor=i.isSensor,this.m_shape=i.shape.copy(),this.m_density=i.density},destroy:function(){this.m_shape=null},createProxy:function(t,o){this.m_shape.computeAABB(this.m_aabb,o),this.m_proxy=t.createProxy(this.m_aabb,this)},destroyProxy:function(t){null!=this.m_proxy&&(t.destroyProxy(this.m_proxy),this.m_proxy=null)},synchronize:function(t,o,i){if(null!=this.m_proxy){var s=new box2D.collision.B2AABB,n=new box2D.collision.B2AABB;this.m_shape.computeAABB(s,o),this.m_shape.computeAABB(n,i),this.m_aabb.combine(s,n);var e=box2D.common.math.B2Math.subtractVV(i.position,o.position);t.moveProxy(this.m_proxy,this.m_aabb,e)}},__class__:box2D.dynamics.B2Fixture},box2D.dynamics.B2FixtureDef=function(){this.filter=new box2D.dynamics.B2FilterData,this.shape=null,this.userData=null,this.friction=.2,this.restitution=0,this.density=0,this.filter.categoryBits=1,this.filter.maskBits=65535,this.filter.groupIndex=0,this.isSensor=!1},box2D.dynamics.B2FixtureDef.__name__=!0,box2D.dynamics.B2FixtureDef.prototype={__class__:box2D.dynamics.B2FixtureDef},box2D.dynamics.B2Island=function(){this.m_bodies=new Array,this.m_contacts=new Array,this.m_joints=new Array},box2D.dynamics.B2Island.__name__=!0,box2D.dynamics.B2Island.prototype={initialize:function(t,o,i,s,n,e){this.m_bodyCapacity=t,this.m_contactCapacity=o,this.m_jointCapacity=i,this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0,this.m_allocator=s,this.m_listener=n,this.m_contactSolver=e;
for(var m=this.m_bodies.length;t>m;){var a=m++;this.m_bodies[a]=null}for(var m=this.m_contacts.length;o>m;){var a=m++;this.m_contacts[a]=null}for(var m=this.m_joints.length;i>m;){var a=m++;this.m_joints[a]=null}},clear:function(){this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0},solve:function(t,o,i){for(var s,n,e=0,m=this.m_bodyCount;m>e;){var a=e++;s=this.m_bodies[a],s.getType()==box2D.dynamics.B2Body.b2_dynamicBody&&(s.m_linearVelocity.x+=t.dt*(o.x+s.m_invMass*s.m_force.x),s.m_linearVelocity.y+=t.dt*(o.y+s.m_invMass*s.m_force.y),s.m_angularVelocity+=t.dt*s.m_invI*s.m_torque,s.m_linearVelocity.multiply(box2D.common.math.B2Math.clamp(1-t.dt*s.m_linearDamping,0,1)),s.m_angularVelocity*=box2D.common.math.B2Math.clamp(1-t.dt*s.m_angularDamping,0,1))}this.m_contactSolver.initialize(t,this.m_contacts,this.m_contactCount,this.m_allocator);var c=this.m_contactSolver;c.initVelocityConstraints(t);for(var e=0,m=this.m_jointCount;m>e;){var a=e++;n=this.m_joints[a],n.initVelocityConstraints(t)}for(var e=0,m=t.velocityIterations;m>e;){for(var a=e++,l=0,r=this.m_jointCount;r>l;){var _=l++;n=this.m_joints[_],n.solveVelocityConstraints(t)}c.solveVelocityConstraints()}for(var e=0,m=this.m_jointCount;m>e;){var a=e++;n=this.m_joints[a],n.finalizeVelocityConstraints()}c.finalizeVelocityConstraints();for(var e=0,m=this.m_bodyCount;m>e;){var a=e++;if(s=this.m_bodies[a],s.getType()!=box2D.dynamics.B2Body.b2_staticBody){var h=t.dt*s.m_linearVelocity.x,x=t.dt*s.m_linearVelocity.y;h*h+x*x>box2D.common.B2Settings.b2_maxTranslationSquared&&(s.m_linearVelocity.normalize(),s.m_linearVelocity.x*=box2D.common.B2Settings.b2_maxTranslation*t.inv_dt,s.m_linearVelocity.y*=box2D.common.B2Settings.b2_maxTranslation*t.inv_dt);var y=t.dt*s.m_angularVelocity;y*y>box2D.common.B2Settings.b2_maxRotationSquared&&(s.m_angularVelocity=s.m_angularVelocity<0?-box2D.common.B2Settings.b2_maxRotation*t.inv_dt:box2D.common.B2Settings.b2_maxRotation*t.inv_dt),s.m_sweep.c0.setV(s.m_sweep.c),s.m_sweep.a0=s.m_sweep.a,s.m_sweep.c.x+=t.dt*s.m_linearVelocity.x,s.m_sweep.c.y+=t.dt*s.m_linearVelocity.y,s.m_sweep.a+=t.dt*s.m_angularVelocity,s.synchronizeTransform()}}for(var e=0,m=t.positionIterations;m>e;){for(var a=e++,u=c.solvePositionConstraints(box2D.common.B2Settings.b2_contactBaumgarte),p=!0,l=0,r=this.m_jointCount;r>l;){var _=l++;n=this.m_joints[_];var d=n.solvePositionConstraints(box2D.common.B2Settings.b2_contactBaumgarte);p=p&&d}if(u&&p)break}if(this.report(c.m_constraints),i){for(var B=1.7976931348623157e308,b=box2D.common.B2Settings.b2_linearSleepTolerance*box2D.common.B2Settings.b2_linearSleepTolerance,D=box2D.common.B2Settings.b2_angularSleepTolerance*box2D.common.B2Settings.b2_angularSleepTolerance,e=0,m=this.m_bodyCount;m>e;){var a=e++;s=this.m_bodies[a],s.getType()!=box2D.dynamics.B2Body.b2_staticBody&&(0==(s.m_flags&box2D.dynamics.B2Body.e_allowSleepFlag)&&(s.m_sleepTime=0,B=0),0==(s.m_flags&box2D.dynamics.B2Body.e_allowSleepFlag)||s.m_angularVelocity*s.m_angularVelocity>D||box2D.common.math.B2Math.dot(s.m_linearVelocity,s.m_linearVelocity)>b?(s.m_sleepTime=0,B=0):(s.m_sleepTime+=t.dt,B=box2D.common.math.B2Math.min(B,s.m_sleepTime)))}if(B>=box2D.common.B2Settings.b2_timeToSleep)for(var e=0,m=this.m_bodyCount;m>e;){var a=e++;s=this.m_bodies[a],s.setAwake(!1)}}},solveTOI:function(t){this.m_contactSolver.initialize(t,this.m_contacts,this.m_contactCount,this.m_allocator);for(var o=this.m_contactSolver,i=0,s=this.m_jointCount;s>i;){var n=i++;this.m_joints[n].initVelocityConstraints(t)}for(var i=0,s=t.velocityIterations;s>i;){var n=i++;o.solveVelocityConstraints();for(var e=0,m=this.m_jointCount;m>e;){var a=e++;this.m_joints[a].solveVelocityConstraints(t)}}for(var i=0,s=this.m_bodyCount;s>i;){var n=i++,c=this.m_bodies[n];if(c.getType()!=box2D.dynamics.B2Body.b2_staticBody){var l=t.dt*c.m_linearVelocity.x,r=t.dt*c.m_linearVelocity.y;l*l+r*r>box2D.common.B2Settings.b2_maxTranslationSquared&&(c.m_linearVelocity.normalize(),c.m_linearVelocity.x*=box2D.common.B2Settings.b2_maxTranslation*t.inv_dt,c.m_linearVelocity.y*=box2D.common.B2Settings.b2_maxTranslation*t.inv_dt);var _=t.dt*c.m_angularVelocity;_*_>box2D.common.B2Settings.b2_maxRotationSquared&&(c.m_angularVelocity=c.m_angularVelocity<0?-box2D.common.B2Settings.b2_maxRotation*t.inv_dt:box2D.common.B2Settings.b2_maxRotation*t.inv_dt),c.m_sweep.c0.setV(c.m_sweep.c),c.m_sweep.a0=c.m_sweep.a,c.m_sweep.c.x+=t.dt*c.m_linearVelocity.x,c.m_sweep.c.y+=t.dt*c.m_linearVelocity.y,c.m_sweep.a+=t.dt*c.m_angularVelocity,c.synchronizeTransform()}}for(var h=.75,i=0,s=t.positionIterations;s>i;){for(var n=i++,x=o.solvePositionConstraints(h),y=!0,e=0,m=this.m_jointCount;m>e;){var a=e++,u=this.m_joints[a].solvePositionConstraints(box2D.common.B2Settings.b2_contactBaumgarte);y=y&&u}if(x&&y)break}this.report(o.m_constraints)},report:function(t){if(null!=this.m_listener)for(var o=0,i=this.m_contactCount;i>o;){for(var s=o++,n=this.m_contacts[s],e=t[s],m=0,a=e.pointCount;a>m;){var c=m++;box2D.dynamics.B2Island.s_impulse.normalImpulses[c]=e.points[c].normalImpulse,box2D.dynamics.B2Island.s_impulse.tangentImpulses[c]=e.points[c].tangentImpulse}this.m_listener.postSolve(n,box2D.dynamics.B2Island.s_impulse)}},addBody:function(t){t.m_islandIndex=this.m_bodyCount,this.m_bodies[this.m_bodyCount++]=t},addContact:function(t){this.m_contacts[this.m_contactCount++]=t},addJoint:function(t){this.m_joints[this.m_jointCount++]=t},__class__:box2D.dynamics.B2Island},box2D.dynamics.B2TimeStep=function(){},box2D.dynamics.B2TimeStep.__name__=!0,box2D.dynamics.B2TimeStep.prototype={set:function(t){this.dt=t.dt,this.inv_dt=t.inv_dt,this.positionIterations=t.positionIterations,this.velocityIterations=t.velocityIterations,this.warmStarting=t.warmStarting},__class__:box2D.dynamics.B2TimeStep},box2D.dynamics.B2World=function(t,o){this.s_stack=new Array,this.m_contactManager=new box2D.dynamics.B2ContactManager,this.m_contactSolver=new box2D.dynamics.contacts.B2ContactSolver,this.m_island=new box2D.dynamics.B2Island,this.m_destructionListener=null,this.m_debugDraw=null,this.m_bodyList=null,this.m_contactList=null,this.m_jointList=null,this.m_controllerList=null,this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0,this.m_controllerCount=0,box2D.dynamics.B2World.m_warmStarting=!0,box2D.dynamics.B2World.m_continuousPhysics=!0,this.m_allowSleep=o,this.m_gravity=t,this.m_inv_dt0=0,this.m_contactManager.m_world=this;var i=new box2D.dynamics.B2BodyDef;this.m_groundBody=this.createBody(i)},box2D.dynamics.B2World.__name__=!0,box2D.dynamics.B2World.prototype={setDestructionListener:function(t){this.m_destructionListener=t},setContactFilter:function(t){this.m_contactManager.m_contactFilter=t},setContactListener:function(t){this.m_contactManager.m_contactListener=t},setDebugDraw:function(t){this.m_debugDraw=t},setBroadPhase:function(t){var o=this.m_contactManager.m_broadPhase;this.m_contactManager.m_broadPhase=t;for(var i=this.m_bodyList;null!=i;){for(var s=i.m_fixtureList;null!=s;)s.m_proxy=t.createProxy(o.getFatAABB(s.m_proxy),s),s=s.m_next;i=i.m_next}},validate:function(){this.m_contactManager.m_broadPhase.validate()},getProxyCount:function(){return this.m_contactManager.m_broadPhase.getProxyCount()},createBody:function(t){if(1==this.isLocked())return null;var o=new box2D.dynamics.B2Body(t,this);return o.m_prev=null,o.m_next=this.m_bodyList,null!=this.m_bodyList&&(this.m_bodyList.m_prev=o),this.m_bodyList=o,++this.m_bodyCount,o},destroyBody:function(t){if(1!=this.isLocked()){for(var o=t.m_jointList;null!=o;){var i=o;o=o.next,null!=this.m_destructionListener&&this.m_destructionListener.sayGoodbyeJoint(i.joint),this.destroyJoint(i.joint)}for(var s=t.m_controllerList;null!=s;){var n=s;s=s.nextController,n.controller.removeBody(t)}for(var e=t.m_contactList;null!=e;){var m=e;e=e.next,this.m_contactManager.destroy(m.contact)}t.m_contactList=null;for(var a=t.m_fixtureList;null!=a;){var c=a;a=a.m_next,null!=this.m_destructionListener&&this.m_destructionListener.sayGoodbyeFixture(c),c.destroyProxy(this.m_contactManager.m_broadPhase),c.destroy()}t.m_fixtureList=null,t.m_fixtureCount=0,null!=t.m_prev&&(t.m_prev.m_next=t.m_next),null!=t.m_next&&(t.m_next.m_prev=t.m_prev),t==this.m_bodyList&&(this.m_bodyList=t.m_next),--this.m_bodyCount}},createJoint:function(t){var o=box2D.dynamics.joints.B2Joint.create(t,null);o.m_prev=null,o.m_next=this.m_jointList,null!=this.m_jointList&&(this.m_jointList.m_prev=o),this.m_jointList=o,++this.m_jointCount,o.m_edgeA.joint=o,o.m_edgeA.other=o.m_bodyB,o.m_edgeA.prev=null,o.m_edgeA.next=o.m_bodyA.m_jointList,null!=o.m_bodyA.m_jointList&&(o.m_bodyA.m_jointList.prev=o.m_edgeA),o.m_bodyA.m_jointList=o.m_edgeA,o.m_edgeB.joint=o,o.m_edgeB.other=o.m_bodyA,o.m_edgeB.prev=null,o.m_edgeB.next=o.m_bodyB.m_jointList,null!=o.m_bodyB.m_jointList&&(o.m_bodyB.m_jointList.prev=o.m_edgeB),o.m_bodyB.m_jointList=o.m_edgeB;var i=t.bodyA,s=t.bodyB;if(0==t.collideConnected)for(var n=s.getContactList();null!=n;)n.other==i&&n.contact.flagForFiltering(),n=n.next;return o},destroyJoint:function(t){var o=t.m_collideConnected;null!=t.m_prev&&(t.m_prev.m_next=t.m_next),null!=t.m_next&&(t.m_next.m_prev=t.m_prev),t==this.m_jointList&&(this.m_jointList=t.m_next);var i=t.m_bodyA,s=t.m_bodyB;if(i.setAwake(!0),s.setAwake(!0),null!=t.m_edgeA.prev&&(t.m_edgeA.prev.next=t.m_edgeA.next),null!=t.m_edgeA.next&&(t.m_edgeA.next.prev=t.m_edgeA.prev),t.m_edgeA==i.m_jointList&&(i.m_jointList=t.m_edgeA.next),t.m_edgeA.prev=null,t.m_edgeA.next=null,null!=t.m_edgeB.prev&&(t.m_edgeB.prev.next=t.m_edgeB.next),null!=t.m_edgeB.next&&(t.m_edgeB.next.prev=t.m_edgeB.prev),t.m_edgeB==s.m_jointList&&(s.m_jointList=t.m_edgeB.next),t.m_edgeB.prev=null,t.m_edgeB.next=null,box2D.dynamics.joints.B2Joint.destroy(t,null),--this.m_jointCount,0==o)for(var n=s.getContactList();null!=n;)n.other==i&&n.contact.flagForFiltering(),n=n.next},addController:function(t){return t.m_next=this.m_controllerList,t.m_prev=null,this.m_controllerList=t,t.m_world=this,this.m_controllerCount++,t},removeController:function(t){null!=t.m_prev&&(t.m_prev.m_next=t.m_next),null!=t.m_next&&(t.m_next.m_prev=t.m_prev),this.m_controllerList==t&&(this.m_controllerList=t.m_next),this.m_controllerCount--},createController:function(t){if(t.m_world!=this)throw"Controller can only be a member of one world";return t.m_next=this.m_controllerList,t.m_prev=null,null!=this.m_controllerList&&(this.m_controllerList.m_prev=t),this.m_controllerList=t,++this.m_controllerCount,t.m_world=this,t},destroyController:function(t){t.clear(),null!=t.m_next&&(t.m_next.m_prev=t.m_prev),null!=t.m_prev&&(t.m_prev.m_next=t.m_next),t==this.m_controllerList&&(this.m_controllerList=t.m_next),--this.m_controllerCount},setWarmStarting:function(t){box2D.dynamics.B2World.m_warmStarting=t},setContinuousPhysics:function(t){box2D.dynamics.B2World.m_continuousPhysics=t},getBodyCount:function(){return this.m_bodyCount},getJointCount:function(){return this.m_jointCount},getContactCount:function(){return this.m_contactCount},setGravity:function(t){this.m_gravity=t},getGravity:function(){return this.m_gravity},getGroundBody:function(){return this.m_groundBody},step:function(t,o,i){0!=(this.m_flags&box2D.dynamics.B2World.e_newFixture)&&(this.m_contactManager.findNewContacts(),this.m_flags&=~box2D.dynamics.B2World.e_newFixture),this.m_flags|=box2D.dynamics.B2World.e_locked;var s=box2D.dynamics.B2World.s_timestep2;s.dt=t,s.velocityIterations=o,s.positionIterations=i,s.inv_dt=t>0?1/t:0,s.dtRatio=this.m_inv_dt0*t,s.warmStarting=box2D.dynamics.B2World.m_warmStarting,this.m_contactManager.collide(),s.dt>0&&this.solve(s),box2D.dynamics.B2World.m_continuousPhysics&&s.dt>0&&this.solveTOI(s),s.dt>0&&(this.m_inv_dt0=s.inv_dt),this.m_flags&=~box2D.dynamics.B2World.e_locked},clearForces:function(){for(var t=this.m_bodyList;null!=t;)t.m_force.setZero(),t.m_torque=0,t=t.m_next},drawDebugData:function(){if(null!=this.m_debugDraw){this.m_debugDraw.m_ctx.clearRect(0,0,1e3,1e3);var t,o,i,s,n,e,m=this.m_debugDraw.getFlags(),a=(new box2D.common.math.B2Vec2,new box2D.common.math.B2Vec2,new box2D.common.math.B2Vec2,new box2D.collision.B2AABB,new box2D.collision.B2AABB,[new box2D.common.math.B2Vec2,new box2D.common.math.B2Vec2,new box2D.common.math.B2Vec2,new box2D.common.math.B2Vec2]),c=new box2D.common.B2Color(0,0,0);if(0!=(m&box2D.dynamics.B2DebugDraw.e_shapeBit))for(t=this.m_bodyList;null!=t;){for(e=t.m_xf,o=t.getFixtureList();null!=o;)i=o.getShape(),0==t.isActive()?(c.set(.5,.5,.3),this.drawShape(i,e,c)):t.getType()==box2D.dynamics.B2Body.b2_staticBody?(c.set(.5,.9,.5),this.drawShape(i,e,c)):t.getType()==box2D.dynamics.B2Body.b2_kinematicBody?(c.set(.5,.5,.9),this.drawShape(i,e,c)):0==t.isAwake()?(c.set(.6,.6,.6),this.drawShape(i,e,c)):(c.set(.9,.7,.7),this.drawShape(i,e,c)),o=o.m_next;t=t.m_next}if(0!=(m&box2D.dynamics.B2DebugDraw.e_jointBit))for(s=this.m_jointList;null!=s;)this.drawJoint(s),s=s.m_next;if(0!=(m&box2D.dynamics.B2DebugDraw.e_controllerBit))for(var l=this.m_controllerList;null!=l;)l.draw(this.m_debugDraw),l=l.m_next;if(0!=(m&box2D.dynamics.B2DebugDraw.e_pairBit)){c.set(.3,.9,.9);for(var r=this.m_contactManager.m_contactList;null!=r;){var _=r.getFixtureA(),h=r.getFixtureB(),x=_.getAABB().getCenter(),y=h.getAABB().getCenter();this.m_debugDraw.drawSegment(x,y,c),r=r.getNext()}}if(0!=(m&box2D.dynamics.B2DebugDraw.e_aabbBit))for(n=this.m_contactManager.m_broadPhase,a=[new box2D.common.math.B2Vec2,new box2D.common.math.B2Vec2,new box2D.common.math.B2Vec2,new box2D.common.math.B2Vec2],t=this.m_bodyList;null!=t;)if(0!=t.isActive()){for(o=t.getFixtureList();null!=o;){var u=n.getFatAABB(o.m_proxy);a[0].set(u.lowerBound.x,u.lowerBound.y),a[1].set(u.upperBound.x,u.lowerBound.y),a[2].set(u.upperBound.x,u.upperBound.y),a[3].set(u.lowerBound.x,u.upperBound.y),this.m_debugDraw.drawPolygon(a,4,c),o=o.getNext()}t=t.getNext()}else t=t.getNext();if(0!=(m&box2D.dynamics.B2DebugDraw.e_centerOfMassBit))for(t=this.m_bodyList;null!=t;)e=box2D.dynamics.B2World.s_xf,e.R=t.m_xf.R,e.position=t.getWorldCenter(),this.m_debugDraw.drawTransform(e),t=t.m_next}},queryAABB:function(t,o){var i=this.m_contactManager.m_broadPhase,s=function(o){return t(i.getUserData(o))};i.query(s,o)},queryShape:function(t,o,i){null==i&&(i=new box2D.common.math.B2Transform,i.setIdentity());var s=this.m_contactManager.m_broadPhase,n=function(n){var e;return e=js.Boot.__cast(s.getUserData(n),box2D.dynamics.B2Fixture),box2D.collision.shapes.B2Shape.testOverlap(o,i,e.getShape(),e.getBody().getTransform())?t(e):!0},e=new box2D.collision.B2AABB;o.computeAABB(e,i),s.query(n,e)},queryPoint:function(t,o){var i=this.m_contactManager.m_broadPhase,s=function(s){var n;return n=js.Boot.__cast(i.getUserData(s),box2D.dynamics.B2Fixture),n.testPoint(o)?t(n):!0},n=new box2D.collision.B2AABB;n.lowerBound.set(o.x-box2D.common.B2Settings.b2_linearSlop,o.y-box2D.common.B2Settings.b2_linearSlop),n.upperBound.set(o.x+box2D.common.B2Settings.b2_linearSlop,o.y+box2D.common.B2Settings.b2_linearSlop),i.query(s,n)},rayCast:function(t,o,i){var s=this.m_contactManager.m_broadPhase,n=new box2D.collision.B2RayCastOutput,e=function(e,m){var a,c=s.getUserData(m);a=js.Boot.__cast(c,box2D.dynamics.B2Fixture);var l=a.rayCast(n,e);if(l){var r=n.fraction,_=new box2D.common.math.B2Vec2((1-r)*o.x+r*i.x,(1-r)*o.y+r*i.y);return t(a,_,n.normal,r)}return e.maxFraction},m=new box2D.collision.B2RayCastInput(o,i);s.rayCast(e,m)},rayCastOne:function(t,o){var i,s=function(t,o,s,n){return i=t,n};return this.rayCast(s,t,o),i},rayCastAll:function(t,o){var i=new Array,s=function(t){return i[i.length]=t,1};return this.rayCast(s,t,o),i},getBodyList:function(){return this.m_bodyList},getJointList:function(){return this.m_jointList},getContactList:function(){return this.m_contactList},isLocked:function(){return(this.m_flags&box2D.dynamics.B2World.e_locked)>0},solve:function(t){for(var o,i=this.m_controllerList;null!=i;)i.step(t),i=i.m_next;var s=this.m_island;for(s.initialize(this.m_bodyCount,this.m_contactCount,this.m_jointCount,null,this.m_contactManager.m_contactListener,this.m_contactSolver),o=this.m_bodyList;null!=o;)o.m_flags&=~box2D.dynamics.B2Body.e_islandFlag,o=o.m_next;for(var n=this.m_contactList;null!=n;)n.m_flags&=~box2D.dynamics.contacts.B2Contact.e_islandFlag,n=n.m_next;for(var e=this.m_jointList;null!=e;)e.m_islandFlag=!1,e=e.m_next;for(var m=(this.m_bodyCount,this.s_stack),a=this.m_bodyList;null!=a;)if(0==(a.m_flags&box2D.dynamics.B2Body.e_islandFlag))if(0!=a.isAwake()&&0!=a.isActive())if(a.getType()!=box2D.dynamics.B2Body.b2_staticBody){s.clear();var c=0;for(m[c++]=a,a.m_flags|=box2D.dynamics.B2Body.e_islandFlag;c>0;)if(o=m[--c],s.addBody(o),0==o.isAwake()&&o.setAwake(!0),o.getType()!=box2D.dynamics.B2Body.b2_staticBody){for(var l,r=o.m_contactList;null!=r;)0==(r.contact.m_flags&box2D.dynamics.contacts.B2Contact.e_islandFlag)&&1!=r.contact.isSensor()&&0!=r.contact.isEnabled()&&0!=r.contact.isTouching()?(s.addContact(r.contact),r.contact.m_flags|=box2D.dynamics.contacts.B2Contact.e_islandFlag,l=r.other,0==(l.m_flags&box2D.dynamics.B2Body.e_islandFlag)?(m[c++]=l,l.m_flags|=box2D.dynamics.B2Body.e_islandFlag,r=r.next):r=r.next):r=r.next;for(var _=o.m_jointList;null!=_;)1!=_.joint.m_islandFlag?(l=_.other,0!=l.isActive()?(s.addJoint(_.joint),_.joint.m_islandFlag=!0,0==(l.m_flags&box2D.dynamics.B2Body.e_islandFlag)?(m[c++]=l,l.m_flags|=box2D.dynamics.B2Body.e_islandFlag,_=_.next):_=_.next):_=_.next):_=_.next}s.solve(t,this.m_gravity,this.m_allowSleep);for(var h=0,x=s.m_bodyCount;x>h;){var y=h++;o=s.m_bodies[y],o.getType()==box2D.dynamics.B2Body.b2_staticBody&&(o.m_flags&=~box2D.dynamics.B2Body.e_islandFlag)}a=a.m_next}else a=a.m_next;else a=a.m_next;else a=a.m_next;for(var h=0,x=m.length;x>h;){var y=h++;if(null==m[y])break;m[y]=null}for(o=this.m_bodyList;null!=o;)0!=o.isAwake()&&0!=o.isActive()&&o.getType()!=box2D.dynamics.B2Body.b2_staticBody?(o.synchronizeFixtures(),o=o.m_next):o=o.m_next;this.m_contactManager.findNewContacts()},solveTOI:function(t){var o,i,s,n,e,m,a,c=this.m_island;c.initialize(this.m_bodyCount,box2D.common.B2Settings.b2_maxTOIContactsPerIsland,box2D.common.B2Settings.b2_maxTOIJointsPerIsland,null,this.m_contactManager.m_contactListener,this.m_contactSolver);var l=box2D.dynamics.B2World.s_queue;for(o=this.m_bodyList;null!=o;)o.m_flags&=~box2D.dynamics.B2Body.e_islandFlag,o.m_sweep.t0=0,o=o.m_next;for(var r=this.m_contactList;null!=r;)r.m_flags&=~(box2D.dynamics.contacts.B2Contact.e_toiFlag|box2D.dynamics.contacts.B2Contact.e_islandFlag),r=r.m_next;for(a=this.m_jointList;null!=a;)a.m_islandFlag=!1,a=a.m_next;for(;;){var _=null,h=1;for(r=this.m_contactList;null!=r;)if(1!=r.isSensor()&&0!=r.isEnabled()&&0!=r.isContinuous()){var x=1;if(0!=(r.m_flags&box2D.dynamics.contacts.B2Contact.e_toiFlag))x=r.m_toi;else{if(i=r.m_fixtureA,s=r.m_fixtureB,n=i.m_body,e=s.m_body,!(n.getType()==box2D.dynamics.B2Body.b2_dynamicBody&&0!=n.isAwake()||e.getType()==box2D.dynamics.B2Body.b2_dynamicBody&&0!=e.isAwake())){r=r.m_next;continue}var y=n.m_sweep.t0;n.m_sweep.t0<e.m_sweep.t0?(y=e.m_sweep.t0,n.m_sweep.advance(y)):e.m_sweep.t0<n.m_sweep.t0&&(y=n.m_sweep.t0,e.m_sweep.advance(y)),x=r.computeTOI(n.m_sweep,e.m_sweep),box2D.common.B2Settings.b2Assert(x>=0&&1>=x),x>0&&1>x&&(x=(1-x)*y+x,x>1&&(x=1)),r.m_toi=x,r.m_flags|=box2D.dynamics.contacts.B2Contact.e_toiFlag}x>2.2250738585072014e-308&&h>x&&(_=r,h=x),r=r.m_next}else r=r.m_next;if(null==_||h>1)break;if(i=_.m_fixtureA,s=_.m_fixtureB,n=i.m_body,e=s.m_body,box2D.dynamics.B2World.s_backupA.set(n.m_sweep),box2D.dynamics.B2World.s_backupB.set(e.m_sweep),n.advance(h),e.advance(h),_.update(this.m_contactManager.m_contactListener),_.m_flags&=~box2D.dynamics.contacts.B2Contact.e_toiFlag,1!=_.isSensor()&&0!=_.isEnabled()){if(0!=_.isTouching()){var u=n;u.getType()!=box2D.dynamics.B2Body.b2_dynamicBody&&(u=e),c.clear();var p=0,d=0;for(l[p+d++]=u,u.m_flags|=box2D.dynamics.B2Body.e_islandFlag;d>0;)if(o=l[p++],--d,c.addBody(o),0==o.isAwake()&&o.setAwake(!0),o.getType()==box2D.dynamics.B2Body.b2_dynamicBody){m=o.m_contactList;for(var B;null!=m;){if(c.m_contactCount==c.m_contactCapacity){m=m.next;break}0==(m.contact.m_flags&box2D.dynamics.contacts.B2Contact.e_islandFlag)&&1!=m.contact.isSensor()&&0!=m.contact.isEnabled()&&0!=m.contact.isTouching()?(c.addContact(m.contact),m.contact.m_flags|=box2D.dynamics.contacts.B2Contact.e_islandFlag,B=m.other,0==(B.m_flags&box2D.dynamics.B2Body.e_islandFlag)?(B.getType()!=box2D.dynamics.B2Body.b2_staticBody&&(B.advance(h),B.setAwake(!0)),l[p+d]=B,++d,B.m_flags|=box2D.dynamics.B2Body.e_islandFlag,m=m.next):m=m.next):m=m.next}for(var b=o.m_jointList;null!=b;)c.m_jointCount!=c.m_jointCapacity&&1!=b.joint.m_islandFlag?(B=b.other,0!=B.isActive()?(c.addJoint(b.joint),b.joint.m_islandFlag=!0,0==(B.m_flags&box2D.dynamics.B2Body.e_islandFlag)?(B.getType()!=box2D.dynamics.B2Body.b2_staticBody&&(B.advance(h),B.setAwake(!0)),l[p+d]=B,++d,B.m_flags|=box2D.dynamics.B2Body.e_islandFlag,b=b.next):b=b.next):b=b.next):b=b.next}var D=box2D.dynamics.B2World.s_timestep;D.warmStarting=!1,D.dt=(1-h)*t.dt,D.inv_dt=1/D.dt,D.dtRatio=0,D.velocityIterations=t.velocityIterations,D.positionIterations=t.positionIterations,c.solveTOI(D);for(var f=0,g=c.m_bodyCount;g>f;){var v=f++;if(o=c.m_bodies[v],o.m_flags&=~box2D.dynamics.B2Body.e_islandFlag,0!=o.isAwake()&&o.getType()==box2D.dynamics.B2Body.b2_dynamicBody)for(o.synchronizeFixtures(),m=o.m_contactList;null!=m;)m.contact.m_flags&=~box2D.dynamics.contacts.B2Contact.e_toiFlag,m=m.next}for(var f=0,g=c.m_contactCount;g>f;){var v=f++;r=c.m_contacts[v],r.m_flags&=~(box2D.dynamics.contacts.B2Contact.e_toiFlag|box2D.dynamics.contacts.B2Contact.e_islandFlag)}for(var f=0,g=c.m_jointCount;g>f;){var v=f++;a=c.m_joints[v],a.m_islandFlag=!1}this.m_contactManager.findNewContacts()}}else n.m_sweep.set(box2D.dynamics.B2World.s_backupA),e.m_sweep.set(box2D.dynamics.B2World.s_backupB),n.synchronizeTransform(),e.synchronizeTransform()}},drawJoint:function(t){var o=t.getBodyA(),i=t.getBodyB(),s=o.m_xf,n=i.m_xf,e=s.position,m=n.position,a=t.getAnchorA(),c=t.getAnchorB(),l=box2D.dynamics.B2World.s_jointColor,r=t.m_type;switch(r){case box2D.dynamics.joints.B2Joint.e_distanceJoint:this.m_debugDraw.drawSegment(a,c,l);break;case box2D.dynamics.joints.B2Joint.e_pulleyJoint:var _;_=js.Boot.__cast(t,box2D.dynamics.joints.B2PulleyJoint);var h=_.getGroundAnchorA(),x=_.getGroundAnchorB();this.m_debugDraw.drawSegment(h,a,l),this.m_debugDraw.drawSegment(x,c,l),this.m_debugDraw.drawSegment(h,x,l);break;case box2D.dynamics.joints.B2Joint.e_mouseJoint:this.m_debugDraw.drawSegment(a,c,l);break;default:o!=this.m_groundBody&&this.m_debugDraw.drawSegment(e,a,l),this.m_debugDraw.drawSegment(a,c,l),i!=this.m_groundBody&&this.m_debugDraw.drawSegment(m,c,l)}},drawShape:function(t,o,i){var s=t.m_type;switch(s){case box2D.collision.shapes.B2Shape.e_circleShape:var n;n=js.Boot.__cast(t,box2D.collision.shapes.B2CircleShape);var e=box2D.common.math.B2Math.mulX(o,n.m_p),m=n.m_radius,a=o.R.col1;this.m_debugDraw.drawSolidCircle(e,m,a,i);break;case box2D.collision.shapes.B2Shape.e_polygonShape:var c;c=js.Boot.__cast(t,box2D.collision.shapes.B2PolygonShape);for(var l=c.getVertexCount(),r=c.getVertices(),_=new Array,h=0;l>h;){var x=h++;_[x]=box2D.common.math.B2Math.mulX(o,r[x])}this.m_debugDraw.drawSolidPolygon(_,l,i);break;case box2D.collision.shapes.B2Shape.e_edgeShape:var y;y=js.Boot.__cast(t,box2D.collision.shapes.B2EdgeShape),this.m_debugDraw.drawSegment(box2D.common.math.B2Math.mulX(o,y.getVertex1()),box2D.common.math.B2Math.mulX(o,y.getVertex2()),i)}},__class__:box2D.dynamics.B2World},box2D.dynamics.contacts={},box2D.dynamics.contacts.B2Contact=function(){this.m_nodeA=new box2D.dynamics.contacts.B2ContactEdge,this.m_nodeB=new box2D.dynamics.contacts.B2ContactEdge,this.m_manifold=new box2D.collision.B2Manifold,this.m_oldManifold=new box2D.collision.B2Manifold},box2D.dynamics.contacts.B2Contact.__name__=!0,box2D.dynamics.contacts.B2Contact.prototype={getManifold:function(){return this.m_manifold},getWorldManifold:function(t){var o=this.m_fixtureA.getBody(),i=this.m_fixtureB.getBody(),s=this.m_fixtureA.getShape(),n=this.m_fixtureB.getShape();t.initialize(this.m_manifold,o.getTransform(),s.m_radius,i.getTransform(),n.m_radius)},isTouching:function(){return(this.m_flags&box2D.dynamics.contacts.B2Contact.e_touchingFlag)==box2D.dynamics.contacts.B2Contact.e_touchingFlag},isContinuous:function(){return(this.m_flags&box2D.dynamics.contacts.B2Contact.e_continuousFlag)==box2D.dynamics.contacts.B2Contact.e_continuousFlag},setSensor:function(t){t?this.m_flags|=box2D.dynamics.contacts.B2Contact.e_sensorFlag:this.m_flags&=~box2D.dynamics.contacts.B2Contact.e_sensorFlag},isSensor:function(){return(this.m_flags&box2D.dynamics.contacts.B2Contact.e_sensorFlag)==box2D.dynamics.contacts.B2Contact.e_sensorFlag},setEnabled:function(t){t?this.m_flags|=box2D.dynamics.contacts.B2Contact.e_enabledFlag:this.m_flags&=~box2D.dynamics.contacts.B2Contact.e_enabledFlag},isEnabled:function(){return(this.m_flags&box2D.dynamics.contacts.B2Contact.e_enabledFlag)==box2D.dynamics.contacts.B2Contact.e_enabledFlag},getNext:function(){return this.m_next},getFixtureA:function(){return this.m_fixtureA},getFixtureB:function(){return this.m_fixtureB},flagForFiltering:function(){this.m_flags|=box2D.dynamics.contacts.B2Contact.e_filterFlag},reset:function(t,o){if(this.m_flags=box2D.dynamics.contacts.B2Contact.e_enabledFlag,null==t||null==o)return this.m_fixtureA=null,void(this.m_fixtureB=null);(t.isSensor()||o.isSensor())&&(this.m_flags|=box2D.dynamics.contacts.B2Contact.e_sensorFlag);var i=t.getBody(),s=o.getBody();(i.getType()!=box2D.dynamics.B2Body.b2_dynamicBody||i.isBullet()||s.getType()!=box2D.dynamics.B2Body.b2_dynamicBody||s.isBullet())&&(this.m_flags|=box2D.dynamics.contacts.B2Contact.e_continuousFlag),this.m_fixtureA=t,this.m_fixtureB=o,this.m_manifold.m_pointCount=0,this.m_prev=null,this.m_next=null,this.m_nodeA.contact=null,this.m_nodeA.prev=null,this.m_nodeA.next=null,this.m_nodeA.other=null,this.m_nodeB.contact=null,this.m_nodeB.prev=null,this.m_nodeB.next=null,this.m_nodeB.other=null},update:function(t){var o=this.m_oldManifold;this.m_oldManifold=this.m_manifold,this.m_manifold=o,this.m_flags|=box2D.dynamics.contacts.B2Contact.e_enabledFlag;var i=!1,s=(this.m_flags&box2D.dynamics.contacts.B2Contact.e_touchingFlag)==box2D.dynamics.contacts.B2Contact.e_touchingFlag,n=this.m_fixtureA.m_body,e=this.m_fixtureB.m_body,m=this.m_fixtureA.m_aabb.testOverlap(this.m_fixtureB.m_aabb);if(0!=(this.m_flags&box2D.dynamics.contacts.B2Contact.e_sensorFlag)){if(m){var a=this.m_fixtureA.getShape(),c=this.m_fixtureB.getShape(),l=n.getTransform(),r=e.getTransform();i=box2D.collision.shapes.B2Shape.testOverlap(a,l,c,r)}this.m_manifold.m_pointCount=0}else{if(n.getType()!=box2D.dynamics.B2Body.b2_dynamicBody||n.isBullet()||e.getType()!=box2D.dynamics.B2Body.b2_dynamicBody||e.isBullet()?this.m_flags|=box2D.dynamics.contacts.B2Contact.e_continuousFlag:this.m_flags&=~box2D.dynamics.contacts.B2Contact.e_continuousFlag,m){this.evaluate(),i=this.m_manifold.m_pointCount>0;for(var _=0,h=this.m_manifold.m_pointCount;h>_;){var x=_++,y=this.m_manifold.m_points[x];y.m_normalImpulse=0,y.m_tangentImpulse=0;for(var u=y.m_id,p=0,d=this.m_oldManifold.m_pointCount;d>p;){var B=p++,b=this.m_oldManifold.m_points[B];if(b.m_id.get_key()==u.get_key()){y.m_normalImpulse=b.m_normalImpulse,y.m_tangentImpulse=b.m_tangentImpulse;break}}}}else this.m_manifold.m_pointCount=0;i!=s&&(n.setAwake(!0),e.setAwake(!0))}i?this.m_flags|=box2D.dynamics.contacts.B2Contact.e_touchingFlag:this.m_flags&=~box2D.dynamics.contacts.B2Contact.e_touchingFlag,0==s&&1==i&&t.beginContact(this),1==s&&0==i&&t.endContact(this),0==(this.m_flags&box2D.dynamics.contacts.B2Contact.e_sensorFlag)&&t.preSolve(this,this.m_oldManifold)},evaluate:function(){},computeTOI:function(t,o){return box2D.dynamics.contacts.B2Contact.s_input.proxyA.set(this.m_fixtureA.getShape()),box2D.dynamics.contacts.B2Contact.s_input.proxyB.set(this.m_fixtureB.getShape()),box2D.dynamics.contacts.B2Contact.s_input.sweepA=t,box2D.dynamics.contacts.B2Contact.s_input.sweepB=o,box2D.dynamics.contacts.B2Contact.s_input.tolerance=box2D.common.B2Settings.b2_linearSlop,box2D.collision.B2TimeOfImpact.timeOfImpact(box2D.dynamics.contacts.B2Contact.s_input)},__class__:box2D.dynamics.contacts.B2Contact},box2D.dynamics.contacts.B2CircleContact=function(){box2D.dynamics.contacts.B2Contact.call(this)},box2D.dynamics.contacts.B2CircleContact.__name__=!0,box2D.dynamics.contacts.B2CircleContact.create=function(){return new box2D.dynamics.contacts.B2CircleContact},box2D.dynamics.contacts.B2CircleContact.destroy=function(){},box2D.dynamics.contacts.B2CircleContact.__super__=box2D.dynamics.contacts.B2Contact,box2D.dynamics.contacts.B2CircleContact.prototype=$extend(box2D.dynamics.contacts.B2Contact.prototype,{reset:function(t,o){box2D.dynamics.contacts.B2Contact.prototype.reset.call(this,t,o)},evaluate:function(){var t=this.m_fixtureA.getBody(),o=this.m_fixtureB.getBody();box2D.collision.B2Collision.collideCircles(this.m_manifold,js.Boot.__cast(this.m_fixtureA.getShape(),box2D.collision.shapes.B2CircleShape),t.m_xf,js.Boot.__cast(this.m_fixtureB.getShape(),box2D.collision.shapes.B2CircleShape),o.m_xf)},__class__:box2D.dynamics.contacts.B2CircleContact}),box2D.dynamics.contacts.B2ContactConstraint=function(){this.localPlaneNormal=new box2D.common.math.B2Vec2,this.localPoint=new box2D.common.math.B2Vec2,this.normal=new box2D.common.math.B2Vec2,this.normalMass=new box2D.common.math.B2Mat22,this.K=new box2D.common.math.B2Mat22,this.points=new Array;for(var t=0,o=box2D.common.B2Settings.b2_maxManifoldPoints;o>t;){var i=t++;this.points[i]=new box2D.dynamics.contacts.B2ContactConstraintPoint}},box2D.dynamics.contacts.B2ContactConstraint.__name__=!0,box2D.dynamics.contacts.B2ContactConstraint.prototype={__class__:box2D.dynamics.contacts.B2ContactConstraint},box2D.dynamics.contacts.B2ContactConstraintPoint=function(){this.localPoint=new box2D.common.math.B2Vec2,this.rA=new box2D.common.math.B2Vec2,this.rB=new box2D.common.math.B2Vec2},box2D.dynamics.contacts.B2ContactConstraintPoint.__name__=!0,box2D.dynamics.contacts.B2ContactConstraintPoint.prototype={__class__:box2D.dynamics.contacts.B2ContactConstraintPoint},box2D.dynamics.contacts.B2ContactEdge=function(){},box2D.dynamics.contacts.B2ContactEdge.__name__=!0,box2D.dynamics.contacts.B2ContactEdge.prototype={__class__:box2D.dynamics.contacts.B2ContactEdge},box2D.dynamics.contacts.B2ContactFactory=function(t){this.m_allocator=t,this.initializeRegisters()},box2D.dynamics.contacts.B2ContactFactory.__name__=!0,box2D.dynamics.contacts.B2ContactFactory.prototype={addType:function(t,o,i,s){this.m_registers[i][s].createFcn=t,this.m_registers[i][s].destroyFcn=o,this.m_registers[i][s].primary=!0,i!=s&&(this.m_registers[s][i].createFcn=t,this.m_registers[s][i].destroyFcn=o,this.m_registers[s][i].primary=!1)},initializeRegisters:function(){this.m_registers=new Array;for(var t=0,o=box2D.collision.shapes.B2Shape.e_shapeTypeCount;o>t;){var i=t++;this.m_registers[i]=new Array;for(var s=0,n=box2D.collision.shapes.B2Shape.e_shapeTypeCount;n>s;){var e=s++;this.m_registers[i][e]=new box2D.dynamics.contacts.B2ContactRegister}}this.addType(box2D.dynamics.contacts.B2CircleContact.create,box2D.dynamics.contacts.B2CircleContact.destroy,box2D.collision.shapes.B2Shape.e_circleShape,box2D.collision.shapes.B2Shape.e_circleShape),this.addType(box2D.dynamics.contacts.B2PolyAndCircleContact.create,box2D.dynamics.contacts.B2PolyAndCircleContact.destroy,box2D.collision.shapes.B2Shape.e_polygonShape,box2D.collision.shapes.B2Shape.e_circleShape),this.addType(box2D.dynamics.contacts.B2PolygonContact.create,box2D.dynamics.contacts.B2PolygonContact.destroy,box2D.collision.shapes.B2Shape.e_polygonShape,box2D.collision.shapes.B2Shape.e_polygonShape),this.addType(box2D.dynamics.contacts.B2EdgeAndCircleContact.create,box2D.dynamics.contacts.B2EdgeAndCircleContact.destroy,box2D.collision.shapes.B2Shape.e_edgeShape,box2D.collision.shapes.B2Shape.e_circleShape),this.addType(box2D.dynamics.contacts.B2PolyAndEdgeContact.create,box2D.dynamics.contacts.B2PolyAndEdgeContact.destroy,box2D.collision.shapes.B2Shape.e_polygonShape,box2D.collision.shapes.B2Shape.e_edgeShape)
},create:function(t,o){var i,s=t.getType(),n=o.getType(),e=this.m_registers[s][n];if(null!=e.pool)return i=e.pool,e.pool=i.m_next,e.poolCount--,i.reset(t,o),i;var m=e.createFcn;return null!=m?e.primary?(i=m(this.m_allocator),i.reset(t,o),i):(i=m(this.m_allocator),i.reset(o,t),i):null},destroy:function(t){t.m_manifold.m_pointCount>0&&(t.m_fixtureA.m_body.setAwake(!0),t.m_fixtureB.m_body.setAwake(!0));var o=t.m_fixtureA.getType(),i=t.m_fixtureB.getType(),s=this.m_registers[o][i];s.poolCount++,t.m_next=s.pool,s.pool=t;var n=s.destroyFcn;n(t,this.m_allocator)},__class__:box2D.dynamics.contacts.B2ContactFactory},box2D.dynamics.contacts.B2ContactRegister=function(){},box2D.dynamics.contacts.B2ContactRegister.__name__=!0,box2D.dynamics.contacts.B2ContactRegister.prototype={__class__:box2D.dynamics.contacts.B2ContactRegister},box2D.dynamics.contacts.B2PositionSolverManifold=function(){this.m_normal=new box2D.common.math.B2Vec2,this.m_separations=new Array,this.m_points=new Array;for(var t=0,o=box2D.common.B2Settings.b2_maxManifoldPoints;o>t;){var i=t++;this.m_points[i]=new box2D.common.math.B2Vec2}},box2D.dynamics.contacts.B2PositionSolverManifold.__name__=!0,box2D.dynamics.contacts.B2PositionSolverManifold.prototype={initialize:function(t){box2D.common.B2Settings.b2Assert(t.pointCount>0);var o,i,s,n,e,m,a=t.type;switch(a){case box2D.collision.B2Manifold.e_circles:s=t.bodyA.m_xf.R,n=t.localPoint;var c=t.bodyA.m_xf.position.x+(s.col1.x*n.x+s.col2.x*n.y),l=t.bodyA.m_xf.position.y+(s.col1.y*n.x+s.col2.y*n.y);s=t.bodyB.m_xf.R,n=t.points[0].localPoint;var r=t.bodyB.m_xf.position.x+(s.col1.x*n.x+s.col2.x*n.y),_=t.bodyB.m_xf.position.y+(s.col1.y*n.x+s.col2.y*n.y),h=r-c,x=_-l,y=h*h+x*x;if(y>0){var u=Math.sqrt(y);this.m_normal.x=h/u,this.m_normal.y=x/u}else this.m_normal.x=1,this.m_normal.y=0;this.m_points[0].x=.5*(c+r),this.m_points[0].y=.5*(l+_),this.m_separations[0]=h*this.m_normal.x+x*this.m_normal.y-t.radius;break;case box2D.collision.B2Manifold.e_faceA:s=t.bodyA.m_xf.R,n=t.localPlaneNormal,this.m_normal.x=s.col1.x*n.x+s.col2.x*n.y,this.m_normal.y=s.col1.y*n.x+s.col2.y*n.y,s=t.bodyA.m_xf.R,n=t.localPoint,e=t.bodyA.m_xf.position.x+(s.col1.x*n.x+s.col2.x*n.y),m=t.bodyA.m_xf.position.y+(s.col1.y*n.x+s.col2.y*n.y),s=t.bodyB.m_xf.R;for(var p=0,d=t.pointCount;d>p;){var B=p++;n=t.points[B].localPoint,o=t.bodyB.m_xf.position.x+(s.col1.x*n.x+s.col2.x*n.y),i=t.bodyB.m_xf.position.y+(s.col1.y*n.x+s.col2.y*n.y),this.m_separations[B]=(o-e)*this.m_normal.x+(i-m)*this.m_normal.y-t.radius,this.m_points[B].x=o,this.m_points[B].y=i}break;case box2D.collision.B2Manifold.e_faceB:s=t.bodyB.m_xf.R,n=t.localPlaneNormal,this.m_normal.x=s.col1.x*n.x+s.col2.x*n.y,this.m_normal.y=s.col1.y*n.x+s.col2.y*n.y,s=t.bodyB.m_xf.R,n=t.localPoint,e=t.bodyB.m_xf.position.x+(s.col1.x*n.x+s.col2.x*n.y),m=t.bodyB.m_xf.position.y+(s.col1.y*n.x+s.col2.y*n.y),s=t.bodyA.m_xf.R;for(var p=0,d=t.pointCount;d>p;){var B=p++;n=t.points[B].localPoint,o=t.bodyA.m_xf.position.x+(s.col1.x*n.x+s.col2.x*n.y),i=t.bodyA.m_xf.position.y+(s.col1.y*n.x+s.col2.y*n.y),this.m_separations[B]=(o-e)*this.m_normal.x+(i-m)*this.m_normal.y-t.radius,this.m_points[B].set(o,i)}this.m_normal.x*=-1,this.m_normal.y*=-1}},__class__:box2D.dynamics.contacts.B2PositionSolverManifold},box2D.dynamics.contacts.B2ContactSolver=function(){this.m_step=new box2D.dynamics.B2TimeStep,this.m_constraints=new Array},box2D.dynamics.contacts.B2ContactSolver.__name__=!0,box2D.dynamics.contacts.B2ContactSolver.prototype={initialize:function(t,o,i,s){var n;this.m_step.set(t),this.m_allocator=s;for(this.m_constraintCount=i;this.m_constraints.length<this.m_constraintCount;)this.m_constraints[this.m_constraints.length]=new box2D.dynamics.contacts.B2ContactConstraint;for(var e=0;i>e;){var m=e++;n=o[m];var a=n.m_fixtureA,c=n.m_fixtureB,l=a.m_shape,r=c.m_shape,_=l.m_radius,h=r.m_radius,x=a.m_body,y=c.m_body,u=n.getManifold(),p=box2D.common.B2Settings.b2MixFriction(a.getFriction(),c.getFriction()),d=box2D.common.B2Settings.b2MixRestitution(a.getRestitution(),c.getRestitution()),B=x.m_linearVelocity.x,b=x.m_linearVelocity.y,D=y.m_linearVelocity.x,f=y.m_linearVelocity.y,g=x.m_angularVelocity,v=y.m_angularVelocity;box2D.common.B2Settings.b2Assert(u.m_pointCount>0),box2D.dynamics.contacts.B2ContactSolver.s_worldManifold.initialize(u,x.m_xf,_,y.m_xf,h);var A=box2D.dynamics.contacts.B2ContactSolver.s_worldManifold.m_normal.x,w=box2D.dynamics.contacts.B2ContactSolver.s_worldManifold.m_normal.y,V=this.m_constraints[m];V.bodyA=x,V.bodyB=y,V.manifold=u,V.normal.x=A,V.normal.y=w,V.pointCount=u.m_pointCount,V.friction=p,V.restitution=d,V.localPlaneNormal.x=u.m_localPlaneNormal.x,V.localPlaneNormal.y=u.m_localPlaneNormal.y,V.localPoint.x=u.m_localPoint.x,V.localPoint.y=u.m_localPoint.y,V.radius=_+h,V.type=u.m_type;for(var C=0,M=V.pointCount;M>C;){var S=C++,I=u.m_points[S],j=V.points[S];j.normalImpulse=I.m_normalImpulse,j.tangentImpulse=I.m_tangentImpulse,j.localPoint.setV(I.m_localPoint);var L=j.rA.x=box2D.dynamics.contacts.B2ContactSolver.s_worldManifold.m_points[S].x-x.m_sweep.c.x,P=j.rA.y=box2D.dynamics.contacts.B2ContactSolver.s_worldManifold.m_points[S].y-x.m_sweep.c.y,J=j.rB.x=box2D.dynamics.contacts.B2ContactSolver.s_worldManifold.m_points[S].x-y.m_sweep.c.x,F=j.rB.y=box2D.dynamics.contacts.B2ContactSolver.s_worldManifold.m_points[S].y-y.m_sweep.c.y,T=L*w-P*A,R=J*w-F*A;T*=T,R*=R;var z=x.m_invMass+y.m_invMass+x.m_invI*T+y.m_invI*R;j.normalMass=1/z;var k=x.m_mass*x.m_invMass+y.m_mass*y.m_invMass;k+=x.m_mass*x.m_invI*T+y.m_mass*y.m_invI*R,j.equalizedMass=1/k;var q=w,E=-A,K=L*E-P*q,O=J*E-F*q;K*=K,O*=O;var W=x.m_invMass+y.m_invMass+x.m_invI*K+y.m_invI*O;j.tangentMass=1/W,j.velocityBias=0;var N=D+-v*F-B- -g*P,X=f+v*J-b-g*L,Z=V.normal.x*N+V.normal.y*X;Z<-box2D.common.B2Settings.b2_velocityThreshold&&(j.velocityBias+=-V.restitution*Z)}if(2==V.pointCount){var U=V.points[0],$=V.points[1],G=x.m_invMass,H=x.m_invI,Y=y.m_invMass,Q=y.m_invI,to=U.rA.x*w-U.rA.y*A,oo=U.rB.x*w-U.rB.y*A,io=$.rA.x*w-$.rA.y*A,so=$.rB.x*w-$.rB.y*A,no=G+Y+H*to*to+Q*oo*oo,eo=G+Y+H*io*io+Q*so*so,mo=G+Y+H*to*io+Q*oo*so,ao=100;ao*(no*eo-mo*mo)>no*no?(V.K.col1.set(no,mo),V.K.col2.set(mo,eo),V.K.getInverse(V.normalMass)):V.pointCount=1}}},initVelocityConstraints:function(t){for(var o=0,i=this.m_constraintCount;i>o;){var s,n=o++,e=this.m_constraints[n],m=e.bodyA,a=e.bodyB,c=m.m_invMass,l=m.m_invI,r=a.m_invMass,_=a.m_invI,h=e.normal.x,x=e.normal.y,y=x,u=-h;if(t.warmStarting){s=e.pointCount;for(var p=0;s>p;){var d=p++,B=e.points[d];B.normalImpulse*=t.dtRatio,B.tangentImpulse*=t.dtRatio;var b=B.normalImpulse*h+B.tangentImpulse*y,D=B.normalImpulse*x+B.tangentImpulse*u;m.m_angularVelocity-=l*(B.rA.x*D-B.rA.y*b),m.m_linearVelocity.x-=c*b,m.m_linearVelocity.y-=c*D,a.m_angularVelocity+=_*(B.rB.x*D-B.rB.y*b),a.m_linearVelocity.x+=r*b,a.m_linearVelocity.y+=r*D}}else{s=e.pointCount;for(var p=0;s>p;){var d=p++,f=e.points[d];f.normalImpulse=0,f.tangentImpulse=0}}}},solveVelocityConstraints:function(){for(var t,o,i,s,n,e,m,a,c,l,r,_,h,x,y,u,p,d=0,B=this.m_constraintCount;B>d;){for(var b=d++,D=this.m_constraints[b],f=D.bodyA,g=D.bodyB,v=f.m_angularVelocity,A=g.m_angularVelocity,w=f.m_linearVelocity,V=g.m_linearVelocity,C=f.m_invMass,M=f.m_invI,S=g.m_invMass,I=g.m_invI,j=D.normal.x,L=D.normal.y,P=L,J=-j,F=D.friction,T=0,R=D.pointCount;R>T;){var z=T++;t=D.points[z],o=V.x-A*t.rB.y-w.x+v*t.rA.y,i=V.y+A*t.rB.x-w.y-v*t.rA.x,n=o*P+i*J,e=t.tangentMass*-n,m=F*t.normalImpulse,a=box2D.common.math.B2Math.clamp(t.tangentImpulse+e,-m,m),e=a-t.tangentImpulse,c=e*P,l=e*J,w.x-=C*c,w.y-=C*l,v-=M*(t.rA.x*l-t.rA.y*c),V.x+=S*c,V.y+=S*l,A+=I*(t.rB.x*l-t.rB.y*c),t.tangentImpulse=a}{D.pointCount}if(1==D.pointCount)t=D.points[0],o=V.x+-A*t.rB.y-w.x- -v*t.rA.y,i=V.y+A*t.rB.x-w.y-v*t.rA.x,s=o*j+i*L,e=-t.normalMass*(s-t.velocityBias),a=t.normalImpulse+e,a=a>0?a:0,e=a-t.normalImpulse,c=e*j,l=e*L,w.x-=C*c,w.y-=C*l,v-=M*(t.rA.x*l-t.rA.y*c),V.x+=S*c,V.y+=S*l,A+=I*(t.rB.x*l-t.rB.y*c),t.normalImpulse=a;else{var k=D.points[0],q=D.points[1],E=k.normalImpulse,K=q.normalImpulse,O=V.x-A*k.rB.y-w.x+v*k.rA.y,W=V.y+A*k.rB.x-w.y-v*k.rA.x,N=V.x-A*q.rB.y-w.x+v*q.rA.y,X=V.y+A*q.rB.x-w.y-v*q.rA.x,Z=O*j+W*L,U=N*j+X*L,$=Z-k.velocityBias,G=U-q.velocityBias;p=D.K,$-=p.col1.x*E+p.col2.x*K,G-=p.col1.y*E+p.col2.y*K;for(var R=0;1>R;){{R++}p=D.normalMass;var H=-(p.col1.x*$+p.col2.x*G),Y=-(p.col1.y*$+p.col2.y*G);if(H>=0&&Y>=0){r=H-E,_=Y-K,h=r*j,x=r*L,y=_*j,u=_*L,w.x-=C*(h+y),w.y-=C*(x+u),v-=M*(k.rA.x*x-k.rA.y*h+q.rA.x*u-q.rA.y*y),V.x+=S*(h+y),V.y+=S*(x+u),A+=I*(k.rB.x*x-k.rB.y*h+q.rB.x*u-q.rB.y*y),k.normalImpulse=H,q.normalImpulse=Y;break}if(H=-k.normalMass*$,Y=0,Z=0,U=D.K.col1.y*H+G,H>=0&&U>=0){r=H-E,_=Y-K,h=r*j,x=r*L,y=_*j,u=_*L,w.x-=C*(h+y),w.y-=C*(x+u),v-=M*(k.rA.x*x-k.rA.y*h+q.rA.x*u-q.rA.y*y),V.x+=S*(h+y),V.y+=S*(x+u),A+=I*(k.rB.x*x-k.rB.y*h+q.rB.x*u-q.rB.y*y),k.normalImpulse=H,q.normalImpulse=Y;break}if(H=0,Y=-q.normalMass*G,Z=D.K.col2.x*Y+$,U=0,Y>=0&&Z>=0){r=H-E,_=Y-K,h=r*j,x=r*L,y=_*j,u=_*L,w.x-=C*(h+y),w.y-=C*(x+u),v-=M*(k.rA.x*x-k.rA.y*h+q.rA.x*u-q.rA.y*y),V.x+=S*(h+y),V.y+=S*(x+u),A+=I*(k.rB.x*x-k.rB.y*h+q.rB.x*u-q.rB.y*y),k.normalImpulse=H,q.normalImpulse=Y;break}if(H=0,Y=0,Z=$,U=G,Z>=0&&U>=0){r=H-E,_=Y-K,h=r*j,x=r*L,y=_*j,u=_*L,w.x-=C*(h+y),w.y-=C*(x+u),v-=M*(k.rA.x*x-k.rA.y*h+q.rA.x*u-q.rA.y*y),V.x+=S*(h+y),V.y+=S*(x+u),A+=I*(k.rB.x*x-k.rB.y*h+q.rB.x*u-q.rB.y*y),k.normalImpulse=H,q.normalImpulse=Y;break}break}}f.m_angularVelocity=v,g.m_angularVelocity=A}},finalizeVelocityConstraints:function(){for(var t=0,o=this.m_constraintCount;o>t;)for(var i=t++,s=this.m_constraints[i],n=s.manifold,e=0,m=s.pointCount;m>e;){var a=e++,c=n.m_points[a],l=s.points[a];c.m_normalImpulse=l.normalImpulse,c.m_tangentImpulse=l.tangentImpulse}},solvePositionConstraints:function(t){for(var o=0,i=0,s=this.m_constraintCount;s>i;){var n=i++,e=this.m_constraints[n],m=e.bodyA,a=e.bodyB,c=m.m_mass*m.m_invMass,l=m.m_mass*m.m_invI,r=a.m_mass*a.m_invMass,_=a.m_mass*a.m_invI;box2D.dynamics.contacts.B2ContactSolver.s_psm.initialize(e);for(var h=box2D.dynamics.contacts.B2ContactSolver.s_psm.m_normal,x=0,y=e.pointCount;y>x;){var u=x++,p=e.points[u],d=box2D.dynamics.contacts.B2ContactSolver.s_psm.m_points[u],B=box2D.dynamics.contacts.B2ContactSolver.s_psm.m_separations[u],b=d.x-m.m_sweep.c.x,D=d.y-m.m_sweep.c.y,f=d.x-a.m_sweep.c.x,g=d.y-a.m_sweep.c.y;o=B>o?o:B;var v=box2D.common.math.B2Math.clamp(t*(B+box2D.common.B2Settings.b2_linearSlop),-box2D.common.B2Settings.b2_maxLinearCorrection,0),A=-p.equalizedMass*v,w=A*h.x,V=A*h.y;m.m_sweep.c.x-=c*w,m.m_sweep.c.y-=c*V,m.m_sweep.a-=l*(b*V-D*w),m.synchronizeTransform(),a.m_sweep.c.x+=r*w,a.m_sweep.c.y+=r*V,a.m_sweep.a+=_*(f*V-g*w),a.synchronizeTransform()}}return o>-1.5*box2D.common.B2Settings.b2_linearSlop},__class__:box2D.dynamics.contacts.B2ContactSolver},box2D.dynamics.contacts.B2EdgeAndCircleContact=function(){box2D.dynamics.contacts.B2Contact.call(this)},box2D.dynamics.contacts.B2EdgeAndCircleContact.__name__=!0,box2D.dynamics.contacts.B2EdgeAndCircleContact.create=function(){return new box2D.dynamics.contacts.B2EdgeAndCircleContact},box2D.dynamics.contacts.B2EdgeAndCircleContact.destroy=function(){},box2D.dynamics.contacts.B2EdgeAndCircleContact.__super__=box2D.dynamics.contacts.B2Contact,box2D.dynamics.contacts.B2EdgeAndCircleContact.prototype=$extend(box2D.dynamics.contacts.B2Contact.prototype,{reset:function(t,o){box2D.dynamics.contacts.B2Contact.prototype.reset.call(this,t,o)},evaluate:function(){var t=this.m_fixtureA.getBody(),o=this.m_fixtureB.getBody();this.b2CollideEdgeAndCircle(this.m_manifold,js.Boot.__cast(this.m_fixtureA.getShape(),box2D.collision.shapes.B2EdgeShape),t.m_xf,js.Boot.__cast(this.m_fixtureB.getShape(),box2D.collision.shapes.B2CircleShape),o.m_xf)},b2CollideEdgeAndCircle:function(){},__class__:box2D.dynamics.contacts.B2EdgeAndCircleContact}),box2D.dynamics.contacts.B2PolyAndCircleContact=function(){box2D.dynamics.contacts.B2Contact.call(this)},box2D.dynamics.contacts.B2PolyAndCircleContact.__name__=!0,box2D.dynamics.contacts.B2PolyAndCircleContact.create=function(){return new box2D.dynamics.contacts.B2PolyAndCircleContact},box2D.dynamics.contacts.B2PolyAndCircleContact.destroy=function(){},box2D.dynamics.contacts.B2PolyAndCircleContact.__super__=box2D.dynamics.contacts.B2Contact,box2D.dynamics.contacts.B2PolyAndCircleContact.prototype=$extend(box2D.dynamics.contacts.B2Contact.prototype,{reset:function(t,o){box2D.dynamics.contacts.B2Contact.prototype.reset.call(this,t,o),box2D.common.B2Settings.b2Assert(t.getType()==box2D.collision.shapes.B2Shape.e_polygonShape),box2D.common.B2Settings.b2Assert(o.getType()==box2D.collision.shapes.B2Shape.e_circleShape)},evaluate:function(){var t=this.m_fixtureA.m_body,o=this.m_fixtureB.m_body;box2D.collision.B2Collision.collidePolygonAndCircle(this.m_manifold,js.Boot.__cast(this.m_fixtureA.getShape(),box2D.collision.shapes.B2PolygonShape),t.m_xf,js.Boot.__cast(this.m_fixtureB.getShape(),box2D.collision.shapes.B2CircleShape),o.m_xf)},__class__:box2D.dynamics.contacts.B2PolyAndCircleContact}),box2D.dynamics.contacts.B2PolyAndEdgeContact=function(){box2D.dynamics.contacts.B2Contact.call(this)},box2D.dynamics.contacts.B2PolyAndEdgeContact.__name__=!0,box2D.dynamics.contacts.B2PolyAndEdgeContact.create=function(){return new box2D.dynamics.contacts.B2PolyAndEdgeContact},box2D.dynamics.contacts.B2PolyAndEdgeContact.destroy=function(){},box2D.dynamics.contacts.B2PolyAndEdgeContact.__super__=box2D.dynamics.contacts.B2Contact,box2D.dynamics.contacts.B2PolyAndEdgeContact.prototype=$extend(box2D.dynamics.contacts.B2Contact.prototype,{reset:function(t,o){box2D.dynamics.contacts.B2Contact.prototype.reset.call(this,t,o),box2D.common.B2Settings.b2Assert(t.getType()==box2D.collision.shapes.B2Shape.e_polygonShape),box2D.common.B2Settings.b2Assert(o.getType()==box2D.collision.shapes.B2Shape.e_edgeShape)},evaluate:function(){var t=this.m_fixtureA.getBody(),o=this.m_fixtureB.getBody();this.b2CollidePolyAndEdge(this.m_manifold,js.Boot.__cast(this.m_fixtureA.getShape(),box2D.collision.shapes.B2PolygonShape),t.m_xf,js.Boot.__cast(this.m_fixtureB.getShape(),box2D.collision.shapes.B2EdgeShape),o.m_xf)},b2CollidePolyAndEdge:function(){},__class__:box2D.dynamics.contacts.B2PolyAndEdgeContact}),box2D.dynamics.contacts.B2PolygonContact=function(){box2D.dynamics.contacts.B2Contact.call(this)},box2D.dynamics.contacts.B2PolygonContact.__name__=!0,box2D.dynamics.contacts.B2PolygonContact.create=function(){return new box2D.dynamics.contacts.B2PolygonContact},box2D.dynamics.contacts.B2PolygonContact.destroy=function(){},box2D.dynamics.contacts.B2PolygonContact.__super__=box2D.dynamics.contacts.B2Contact,box2D.dynamics.contacts.B2PolygonContact.prototype=$extend(box2D.dynamics.contacts.B2Contact.prototype,{reset:function(t,o){box2D.dynamics.contacts.B2Contact.prototype.reset.call(this,t,o)},evaluate:function(){var t=this.m_fixtureA.getBody(),o=this.m_fixtureB.getBody();box2D.collision.B2Collision.collidePolygons(this.m_manifold,js.Boot.__cast(this.m_fixtureA.getShape(),box2D.collision.shapes.B2PolygonShape),t.m_xf,js.Boot.__cast(this.m_fixtureB.getShape(),box2D.collision.shapes.B2PolygonShape),o.m_xf)},__class__:box2D.dynamics.contacts.B2PolygonContact}),box2D.dynamics.controllers={},box2D.dynamics.controllers.B2Controller=function(){},box2D.dynamics.controllers.B2Controller.__name__=!0,box2D.dynamics.controllers.B2Controller.prototype={step:function(){},draw:function(){},addBody:function(t){var o=new box2D.dynamics.controllers.B2ControllerEdge;o.controller=this,o.body=t,o.nextBody=this.m_bodyList,o.prevBody=null,this.m_bodyList=o,null!=o.nextBody&&(o.nextBody.prevBody=o),this.m_bodyCount++,o.nextController=t.m_controllerList,o.prevController=null,t.m_controllerList=o,null!=o.nextController&&(o.nextController.prevController=o),t.m_controllerCount++},removeBody:function(t){for(var o=t.m_controllerList;null!=o&&o.controller!=this;)o=o.nextController;null!=o.prevBody&&(o.prevBody.nextBody=o.nextBody),null!=o.nextBody&&(o.nextBody.prevBody=o.prevBody),null!=o.nextController&&(o.nextController.prevController=o.prevController),null!=o.prevController&&(o.prevController.nextController=o.nextController),this.m_bodyList==o&&(this.m_bodyList=o.nextBody),t.m_controllerList==o&&(t.m_controllerList=o.nextController),t.m_controllerCount--,this.m_bodyCount--},clear:function(){for(;null!=this.m_bodyList;)this.removeBody(this.m_bodyList.body)},getNext:function(){return this.m_next},getWorld:function(){return this.m_world},getBodyList:function(){return this.m_bodyList},__class__:box2D.dynamics.controllers.B2Controller},box2D.dynamics.controllers.B2ControllerEdge=function(){},box2D.dynamics.controllers.B2ControllerEdge.__name__=!0,box2D.dynamics.controllers.B2ControllerEdge.prototype={__class__:box2D.dynamics.controllers.B2ControllerEdge},box2D.dynamics.joints={},box2D.dynamics.joints.B2Joint=function(t){this.m_edgeA=new box2D.dynamics.joints.B2JointEdge,this.m_edgeB=new box2D.dynamics.joints.B2JointEdge,this.m_localCenterA=new box2D.common.math.B2Vec2,this.m_localCenterB=new box2D.common.math.B2Vec2,box2D.common.B2Settings.b2Assert(t.bodyA!=t.bodyB),this.m_type=t.type,this.m_prev=null,this.m_next=null,this.m_bodyA=t.bodyA,this.m_bodyB=t.bodyB,this.m_collideConnected=t.collideConnected,this.m_islandFlag=!1,this.m_userData=t.userData},box2D.dynamics.joints.B2Joint.__name__=!0,box2D.dynamics.joints.B2Joint.create=function(t){var o=null;return t.type==box2D.dynamics.joints.B2Joint.e_distanceJoint?o=new box2D.dynamics.joints.B2DistanceJoint(js.Boot.__cast(t,box2D.dynamics.joints.B2DistanceJointDef)):t.type==box2D.dynamics.joints.B2Joint.e_mouseJoint?o=new box2D.dynamics.joints.B2MouseJoint(js.Boot.__cast(t,box2D.dynamics.joints.B2MouseJointDef)):t.type==box2D.dynamics.joints.B2Joint.e_prismaticJoint?o=new box2D.dynamics.joints.B2PrismaticJoint(js.Boot.__cast(t,box2D.dynamics.joints.B2PrismaticJointDef)):t.type==box2D.dynamics.joints.B2Joint.e_revoluteJoint?o=new box2D.dynamics.joints.B2RevoluteJoint(js.Boot.__cast(t,box2D.dynamics.joints.B2RevoluteJointDef)):t.type==box2D.dynamics.joints.B2Joint.e_pulleyJoint?o=new box2D.dynamics.joints.B2PulleyJoint(js.Boot.__cast(t,box2D.dynamics.joints.B2PulleyJointDef)):t.type==box2D.dynamics.joints.B2Joint.e_gearJoint?o=new box2D.dynamics.joints.B2GearJoint(js.Boot.__cast(t,box2D.dynamics.joints.B2GearJointDef)):t.type==box2D.dynamics.joints.B2Joint.e_lineJoint?o=new box2D.dynamics.joints.B2LineJoint(js.Boot.__cast(t,box2D.dynamics.joints.B2LineJointDef)):t.type==box2D.dynamics.joints.B2Joint.e_weldJoint?o=new box2D.dynamics.joints.B2WeldJoint(js.Boot.__cast(t,box2D.dynamics.joints.B2WeldJointDef)):t.type==box2D.dynamics.joints.B2Joint.e_frictionJoint&&(o=new box2D.dynamics.joints.B2FrictionJoint(js.Boot.__cast(t,box2D.dynamics.joints.B2FrictionJointDef))),o},box2D.dynamics.joints.B2Joint.destroy=function(){},box2D.dynamics.joints.B2Joint.prototype={getType:function(){return this.m_type},getAnchorA:function(){return null},getAnchorB:function(){return null},getReactionForce:function(){return null},getReactionTorque:function(){return 0},getBodyA:function(){return this.m_bodyA},getBodyB:function(){return this.m_bodyB},getNext:function(){return this.m_next},getUserData:function(){return this.m_userData},setUserData:function(t){this.m_userData=t},isActive:function(){return this.m_bodyA.isActive()&&this.m_bodyB.isActive()},initVelocityConstraints:function(){},solveVelocityConstraints:function(){},finalizeVelocityConstraints:function(){},solvePositionConstraints:function(){return!1},__class__:box2D.dynamics.joints.B2Joint},box2D.dynamics.joints.B2DistanceJoint=function(t){box2D.dynamics.joints.B2Joint.call(this,t),this.m_localAnchor1=new box2D.common.math.B2Vec2,this.m_localAnchor2=new box2D.common.math.B2Vec2,this.m_u=new box2D.common.math.B2Vec2;this.m_localAnchor1.setV(t.localAnchorA),this.m_localAnchor2.setV(t.localAnchorB),this.m_length=t.length,this.m_frequencyHz=t.frequencyHz,this.m_dampingRatio=t.dampingRatio,this.m_impulse=0,this.m_gamma=0,this.m_bias=0},box2D.dynamics.joints.B2DistanceJoint.__name__=!0,box2D.dynamics.joints.B2DistanceJoint.__super__=box2D.dynamics.joints.B2Joint,box2D.dynamics.joints.B2DistanceJoint.prototype=$extend(box2D.dynamics.joints.B2Joint.prototype,{getAnchorA:function(){return this.m_bodyA.getWorldPoint(this.m_localAnchor1)},getAnchorB:function(){return this.m_bodyB.getWorldPoint(this.m_localAnchor2)},getReactionForce:function(t){return new box2D.common.math.B2Vec2(t*this.m_impulse*this.m_u.x,t*this.m_impulse*this.m_u.y)},getReactionTorque:function(){return 0},getLength:function(){return this.m_length},setLength:function(t){this.m_length=t},getFrequency:function(){return this.m_frequencyHz},setFrequency:function(t){this.m_frequencyHz=t},getDampingRatio:function(){return this.m_dampingRatio},setDampingRatio:function(t){this.m_dampingRatio=t},initVelocityConstraints:function(t){var o,i,s=this.m_bodyA,n=this.m_bodyB;o=s.m_xf.R;var e=this.m_localAnchor1.x-s.m_sweep.localCenter.x,m=this.m_localAnchor1.y-s.m_sweep.localCenter.y;i=o.col1.x*e+o.col2.x*m,m=o.col1.y*e+o.col2.y*m,e=i,o=n.m_xf.R;var a=this.m_localAnchor2.x-n.m_sweep.localCenter.x,c=this.m_localAnchor2.y-n.m_sweep.localCenter.y;i=o.col1.x*a+o.col2.x*c,c=o.col1.y*a+o.col2.y*c,a=i,this.m_u.x=n.m_sweep.c.x+a-s.m_sweep.c.x-e,this.m_u.y=n.m_sweep.c.y+c-s.m_sweep.c.y-m;var l=Math.sqrt(this.m_u.x*this.m_u.x+this.m_u.y*this.m_u.y);l>box2D.common.B2Settings.b2_linearSlop?this.m_u.multiply(1/l):this.m_u.setZero();var r=e*this.m_u.y-m*this.m_u.x,_=a*this.m_u.y-c*this.m_u.x,h=s.m_invMass+s.m_invI*r*r+n.m_invMass+n.m_invI*_*_;if(this.m_mass=0!=h?1/h:0,this.m_frequencyHz>0){var x=l-this.m_length,y=2*Math.PI*this.m_frequencyHz,u=2*this.m_mass*this.m_dampingRatio*y,p=this.m_mass*y*y;this.m_gamma=t.dt*(u+t.dt*p),this.m_gamma=0!=this.m_gamma?1/this.m_gamma:0,this.m_bias=x*t.dt*p*this.m_gamma,this.m_mass=h+this.m_gamma,this.m_mass=0!=this.m_mass?1/this.m_mass:0}if(t.warmStarting){this.m_impulse*=t.dtRatio;var d=this.m_impulse*this.m_u.x,B=this.m_impulse*this.m_u.y;s.m_linearVelocity.x-=s.m_invMass*d,s.m_linearVelocity.y-=s.m_invMass*B,s.m_angularVelocity-=s.m_invI*(e*B-m*d),n.m_linearVelocity.x+=n.m_invMass*d,n.m_linearVelocity.y+=n.m_invMass*B,n.m_angularVelocity+=n.m_invI*(a*B-c*d)}else this.m_impulse=0},solveVelocityConstraints:function(){var t,o=this.m_bodyA,i=this.m_bodyB;t=o.m_xf.R;var s=this.m_localAnchor1.x-o.m_sweep.localCenter.x,n=this.m_localAnchor1.y-o.m_sweep.localCenter.y,e=t.col1.x*s+t.col2.x*n;n=t.col1.y*s+t.col2.y*n,s=e,t=i.m_xf.R;var m=this.m_localAnchor2.x-i.m_sweep.localCenter.x,a=this.m_localAnchor2.y-i.m_sweep.localCenter.y;e=t.col1.x*m+t.col2.x*a,a=t.col1.y*m+t.col2.y*a,m=e;var c=o.m_linearVelocity.x+-o.m_angularVelocity*n,l=o.m_linearVelocity.y+o.m_angularVelocity*s,r=i.m_linearVelocity.x+-i.m_angularVelocity*a,_=i.m_linearVelocity.y+i.m_angularVelocity*m,h=this.m_u.x*(r-c)+this.m_u.y*(_-l),x=-this.m_mass*(h+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=x;var y=x*this.m_u.x,u=x*this.m_u.y;o.m_linearVelocity.x-=o.m_invMass*y,o.m_linearVelocity.y-=o.m_invMass*u,o.m_angularVelocity-=o.m_invI*(s*u-n*y),i.m_linearVelocity.x+=i.m_invMass*y,i.m_linearVelocity.y+=i.m_invMass*u,i.m_angularVelocity+=i.m_invI*(m*u-a*y)},solvePositionConstraints:function(){var t;if(this.m_frequencyHz>0)return!0;var o=this.m_bodyA,i=this.m_bodyB;t=o.m_xf.R;var s=this.m_localAnchor1.x-o.m_sweep.localCenter.x,n=this.m_localAnchor1.y-o.m_sweep.localCenter.y,e=t.col1.x*s+t.col2.x*n;n=t.col1.y*s+t.col2.y*n,s=e,t=i.m_xf.R;var m=this.m_localAnchor2.x-i.m_sweep.localCenter.x,a=this.m_localAnchor2.y-i.m_sweep.localCenter.y;e=t.col1.x*m+t.col2.x*a,a=t.col1.y*m+t.col2.y*a,m=e;var c=i.m_sweep.c.x+m-o.m_sweep.c.x-s,l=i.m_sweep.c.y+a-o.m_sweep.c.y-n,r=Math.sqrt(c*c+l*l);c/=r,l/=r;var _=r-this.m_length;_=box2D.common.math.B2Math.clamp(_,-box2D.common.B2Settings.b2_maxLinearCorrection,box2D.common.B2Settings.b2_maxLinearCorrection);var h=-this.m_mass*_;this.m_u.set(c,l);var x=h*this.m_u.x,y=h*this.m_u.y;return o.m_sweep.c.x-=o.m_invMass*x,o.m_sweep.c.y-=o.m_invMass*y,o.m_sweep.a-=o.m_invI*(s*y-n*x),i.m_sweep.c.x+=i.m_invMass*x,i.m_sweep.c.y+=i.m_invMass*y,i.m_sweep.a+=i.m_invI*(m*y-a*x),o.synchronizeTransform(),i.synchronizeTransform(),box2D.common.math.B2Math.abs(_)<box2D.common.B2Settings.b2_linearSlop},__class__:box2D.dynamics.joints.B2DistanceJoint}),box2D.dynamics.joints.B2JointDef=function(){this.type=box2D.dynamics.joints.B2Joint.e_unknownJoint,this.userData=null,this.bodyA=null,this.bodyB=null,this.collideConnected=!1},box2D.dynamics.joints.B2JointDef.__name__=!0,box2D.dynamics.joints.B2JointDef.prototype={__class__:box2D.dynamics.joints.B2JointDef},box2D.dynamics.joints.B2DistanceJointDef=function(){box2D.dynamics.joints.B2JointDef.call(this),this.localAnchorA=new box2D.common.math.B2Vec2,this.localAnchorB=new box2D.common.math.B2Vec2,this.type=box2D.dynamics.joints.B2Joint.e_distanceJoint,this.length=1,this.frequencyHz=0,this.dampingRatio=0},box2D.dynamics.joints.B2DistanceJointDef.__name__=!0,box2D.dynamics.joints.B2DistanceJointDef.__super__=box2D.dynamics.joints.B2JointDef,box2D.dynamics.joints.B2DistanceJointDef.prototype=$extend(box2D.dynamics.joints.B2JointDef.prototype,{initialize:function(t,o,i,s){this.bodyA=t,this.bodyB=o,this.localAnchorA.setV(this.bodyA.getLocalPoint(i)),this.localAnchorB.setV(this.bodyB.getLocalPoint(s));var n=s.x-i.x,e=s.y-i.y;this.length=Math.sqrt(n*n+e*e),this.frequencyHz=0,this.dampingRatio=0},__class__:box2D.dynamics.joints.B2DistanceJointDef}),box2D.dynamics.joints.B2FrictionJoint=function(t){box2D.dynamics.joints.B2Joint.call(this,t),this.m_localAnchorA=new box2D.common.math.B2Vec2,this.m_localAnchorB=new box2D.common.math.B2Vec2,this.m_linearMass=new box2D.common.math.B2Mat22,this.m_linearImpulse=new box2D.common.math.B2Vec2,this.m_localAnchorA.setV(t.localAnchorA),this.m_localAnchorB.setV(t.localAnchorB),this.m_linearMass.setZero(),this.m_angularMass=0,this.m_linearImpulse.setZero(),this.m_angularImpulse=0,this.m_maxForce=t.maxForce,this.m_maxTorque=t.maxTorque},box2D.dynamics.joints.B2FrictionJoint.__name__=!0,box2D.dynamics.joints.B2FrictionJoint.__super__=box2D.dynamics.joints.B2Joint,box2D.dynamics.joints.B2FrictionJoint.prototype=$extend(box2D.dynamics.joints.B2Joint.prototype,{getAnchorA:function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)},getAnchorB:function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)},getReactionForce:function(t){return new box2D.common.math.B2Vec2(t*this.m_linearImpulse.x,t*this.m_linearImpulse.y)},getReactionTorque:function(t){return t*this.m_angularImpulse},setMaxForce:function(t){this.m_maxForce=t},getMaxForce:function(){return this.m_maxForce},setMaxTorque:function(t){this.m_maxTorque=t},getMaxTorque:function(){return this.m_maxTorque},initVelocityConstraints:function(t){var o,i,s=this.m_bodyA,n=this.m_bodyB;o=s.m_xf.R;var e=this.m_localAnchorA.x-s.m_sweep.localCenter.x,m=this.m_localAnchorA.y-s.m_sweep.localCenter.y;i=o.col1.x*e+o.col2.x*m,m=o.col1.y*e+o.col2.y*m,e=i,o=n.m_xf.R;var a=this.m_localAnchorB.x-n.m_sweep.localCenter.x,c=this.m_localAnchorB.y-n.m_sweep.localCenter.y;i=o.col1.x*a+o.col2.x*c,c=o.col1.y*a+o.col2.y*c,a=i;var l=s.m_invMass,r=n.m_invMass,_=s.m_invI,h=n.m_invI,x=new box2D.common.math.B2Mat22;if(x.col1.x=l+r,x.col2.x=0,x.col1.y=0,x.col2.y=l+r,x.col1.x+=_*m*m,x.col2.x+=-_*e*m,x.col1.y+=-_*e*m,x.col2.y+=_*e*e,x.col1.x+=h*c*c,x.col2.x+=-h*a*c,x.col1.y+=-h*a*c,x.col2.y+=h*a*a,x.getInverse(this.m_linearMass),this.m_angularMass=_+h,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),t.warmStarting){this.m_linearImpulse.x*=t.dtRatio,this.m_linearImpulse.y*=t.dtRatio,this.m_angularImpulse*=t.dtRatio;var y=this.m_linearImpulse;s.m_linearVelocity.x-=l*y.x,s.m_linearVelocity.y-=l*y.y,s.m_angularVelocity-=_*(e*y.y-m*y.x+this.m_angularImpulse),n.m_linearVelocity.x+=r*y.x,n.m_linearVelocity.y+=r*y.y,n.m_angularVelocity+=h*(a*y.y-c*y.x+this.m_angularImpulse)}else this.m_linearImpulse.setZero(),this.m_angularImpulse=0},solveVelocityConstraints:function(t){var o,i,s=this.m_bodyA,n=this.m_bodyB,e=s.m_linearVelocity,m=s.m_angularVelocity,a=n.m_linearVelocity,c=n.m_angularVelocity,l=s.m_invMass,r=n.m_invMass,_=s.m_invI,h=n.m_invI;o=s.m_xf.R;var x=this.m_localAnchorA.x-s.m_sweep.localCenter.x,y=this.m_localAnchorA.y-s.m_sweep.localCenter.y;i=o.col1.x*x+o.col2.x*y,y=o.col1.y*x+o.col2.y*y,x=i,o=n.m_xf.R;var u=this.m_localAnchorB.x-n.m_sweep.localCenter.x,p=this.m_localAnchorB.y-n.m_sweep.localCenter.y;i=o.col1.x*u+o.col2.x*p,p=o.col1.y*u+o.col2.y*p,u=i;var d,B=c-m,b=-this.m_angularMass*B,D=this.m_angularImpulse;d=t.dt*this.m_maxTorque,this.m_angularImpulse=box2D.common.math.B2Math.clamp(this.m_angularImpulse+b,-d,d),b=this.m_angularImpulse-D,m-=_*b,c+=h*b;var f=a.x-c*p-e.x+m*y,g=a.y+c*u-e.y-m*x,v=box2D.common.math.B2Math.mulMV(this.m_linearMass,new box2D.common.math.B2Vec2(-f,-g)),A=this.m_linearImpulse.copy();this.m_linearImpulse.add(v),d=t.dt*this.m_maxForce,this.m_linearImpulse.lengthSquared()>d*d&&(this.m_linearImpulse.normalize(),this.m_linearImpulse.multiply(d)),v=box2D.common.math.B2Math.subtractVV(this.m_linearImpulse,A),e.x-=l*v.x,e.y-=l*v.y,m-=_*(x*v.y-y*v.x),a.x+=r*v.x,a.y+=r*v.y,c+=h*(u*v.y-p*v.x),s.m_angularVelocity=m,n.m_angularVelocity=c},solvePositionConstraints:function(){return!0},__class__:box2D.dynamics.joints.B2FrictionJoint}),box2D.dynamics.joints.B2FrictionJointDef=function(){box2D.dynamics.joints.B2JointDef.call(this),this.localAnchorA=new box2D.common.math.B2Vec2,this.localAnchorB=new box2D.common.math.B2Vec2,this.type=box2D.dynamics.joints.B2Joint.e_frictionJoint,this.maxForce=0,this.maxTorque=0},box2D.dynamics.joints.B2FrictionJointDef.__name__=!0,box2D.dynamics.joints.B2FrictionJointDef.__super__=box2D.dynamics.joints.B2JointDef,box2D.dynamics.joints.B2FrictionJointDef.prototype=$extend(box2D.dynamics.joints.B2JointDef.prototype,{initialize:function(t,o,i){this.bodyA=t,this.bodyB=o,this.localAnchorA.setV(this.bodyA.getLocalPoint(i)),this.localAnchorB.setV(this.bodyB.getLocalPoint(i))},__class__:box2D.dynamics.joints.B2FrictionJointDef}),box2D.dynamics.joints.B2GearJoint=function(t){box2D.dynamics.joints.B2Joint.call(this,t),this.m_groundAnchor1=new box2D.common.math.B2Vec2,this.m_groundAnchor2=new box2D.common.math.B2Vec2,this.m_localAnchor1=new box2D.common.math.B2Vec2,this.m_localAnchor2=new box2D.common.math.B2Vec2,this.m_J=new box2D.dynamics.joints.B2Jacobian;var o=t.joint1.m_type,i=t.joint2.m_type;this.m_revolute1=null,this.m_prismatic1=null,this.m_revolute2=null,this.m_prismatic2=null;var s,n;this.m_ground1=t.joint1.getBodyA(),this.m_bodyA=t.joint1.getBodyB(),o==box2D.dynamics.joints.B2Joint.e_revoluteJoint?(this.m_revolute1=js.Boot.__cast(t.joint1,box2D.dynamics.joints.B2RevoluteJoint),this.m_groundAnchor1.setV(this.m_revolute1.m_localAnchor1),this.m_localAnchor1.setV(this.m_revolute1.m_localAnchor2),s=this.m_revolute1.getJointAngle()):(this.m_prismatic1=js.Boot.__cast(t.joint1,box2D.dynamics.joints.B2PrismaticJoint),this.m_groundAnchor1.setV(this.m_prismatic1.m_localAnchor1),this.m_localAnchor1.setV(this.m_prismatic1.m_localAnchor2),s=this.m_prismatic1.getJointTranslation()),this.m_ground2=t.joint2.getBodyA(),this.m_bodyB=t.joint2.getBodyB(),i==box2D.dynamics.joints.B2Joint.e_revoluteJoint?(this.m_revolute2=js.Boot.__cast(t.joint2,box2D.dynamics.joints.B2RevoluteJoint),this.m_groundAnchor2.setV(this.m_revolute2.m_localAnchor1),this.m_localAnchor2.setV(this.m_revolute2.m_localAnchor2),n=this.m_revolute2.getJointAngle()):(this.m_prismatic2=js.Boot.__cast(t.joint2,box2D.dynamics.joints.B2PrismaticJoint),this.m_groundAnchor2.setV(this.m_prismatic2.m_localAnchor1),this.m_localAnchor2.setV(this.m_prismatic2.m_localAnchor2),n=this.m_prismatic2.getJointTranslation()),this.m_ratio=t.ratio,this.m_constant=s+this.m_ratio*n,this.m_impulse=0},box2D.dynamics.joints.B2GearJoint.__name__=!0,box2D.dynamics.joints.B2GearJoint.__super__=box2D.dynamics.joints.B2Joint,box2D.dynamics.joints.B2GearJoint.prototype=$extend(box2D.dynamics.joints.B2Joint.prototype,{getAnchorA:function(){return this.m_bodyA.getWorldPoint(this.m_localAnchor1)
},getAnchorB:function(){return this.m_bodyB.getWorldPoint(this.m_localAnchor2)},getReactionForce:function(t){return new box2D.common.math.B2Vec2(t*this.m_impulse*this.m_J.linearB.x,t*this.m_impulse*this.m_J.linearB.y)},getReactionTorque:function(t){var o=this.m_bodyB.m_xf.R,i=this.m_localAnchor1.x-this.m_bodyB.m_sweep.localCenter.x,s=this.m_localAnchor1.y-this.m_bodyB.m_sweep.localCenter.y,n=o.col1.x*i+o.col2.x*s;s=o.col1.y*i+o.col2.y*s,i=n;var e=this.m_impulse*this.m_J.linearB.x,m=this.m_impulse*this.m_J.linearB.y;return t*(this.m_impulse*this.m_J.angularB-i*m+s*e)},getRatio:function(){return this.m_ratio},setRatio:function(t){this.m_ratio=t},initVelocityConstraints:function(t){var o,i,s,n,e,m,a,c,l=this.m_ground1,r=this.m_ground2,_=this.m_bodyA,h=this.m_bodyB,x=0;this.m_J.setZero(),null!=this.m_revolute1?(this.m_J.angularA=-1,x+=_.m_invI):(e=l.m_xf.R,m=this.m_prismatic1.m_localXAxis1,o=e.col1.x*m.x+e.col2.x*m.y,i=e.col1.y*m.x+e.col2.y*m.y,e=_.m_xf.R,s=this.m_localAnchor1.x-_.m_sweep.localCenter.x,n=this.m_localAnchor1.y-_.m_sweep.localCenter.y,c=e.col1.x*s+e.col2.x*n,n=e.col1.y*s+e.col2.y*n,s=c,a=s*i-n*o,this.m_J.linearA.set(-o,-i),this.m_J.angularA=-a,x+=_.m_invMass+_.m_invI*a*a),null!=this.m_revolute2?(this.m_J.angularB=-this.m_ratio,x+=this.m_ratio*this.m_ratio*h.m_invI):(e=r.m_xf.R,m=this.m_prismatic2.m_localXAxis1,o=e.col1.x*m.x+e.col2.x*m.y,i=e.col1.y*m.x+e.col2.y*m.y,e=h.m_xf.R,s=this.m_localAnchor2.x-h.m_sweep.localCenter.x,n=this.m_localAnchor2.y-h.m_sweep.localCenter.y,c=e.col1.x*s+e.col2.x*n,n=e.col1.y*s+e.col2.y*n,s=c,a=s*i-n*o,this.m_J.linearB.set(-this.m_ratio*o,-this.m_ratio*i),this.m_J.angularB=-this.m_ratio*a,x+=this.m_ratio*this.m_ratio*(h.m_invMass+h.m_invI*a*a)),this.m_mass=x>0?1/x:0,t.warmStarting?(_.m_linearVelocity.x+=_.m_invMass*this.m_impulse*this.m_J.linearA.x,_.m_linearVelocity.y+=_.m_invMass*this.m_impulse*this.m_J.linearA.y,_.m_angularVelocity+=_.m_invI*this.m_impulse*this.m_J.angularA,h.m_linearVelocity.x+=h.m_invMass*this.m_impulse*this.m_J.linearB.x,h.m_linearVelocity.y+=h.m_invMass*this.m_impulse*this.m_J.linearB.y,h.m_angularVelocity+=h.m_invI*this.m_impulse*this.m_J.angularB):this.m_impulse=0},solveVelocityConstraints:function(){var t=this.m_bodyA,o=this.m_bodyB,i=this.m_J.compute(t.m_linearVelocity,t.m_angularVelocity,o.m_linearVelocity,o.m_angularVelocity),s=-this.m_mass*i;this.m_impulse+=s,t.m_linearVelocity.x+=t.m_invMass*s*this.m_J.linearA.x,t.m_linearVelocity.y+=t.m_invMass*s*this.m_J.linearA.y,t.m_angularVelocity+=t.m_invI*s*this.m_J.angularA,o.m_linearVelocity.x+=o.m_invMass*s*this.m_J.linearB.x,o.m_linearVelocity.y+=o.m_invMass*s*this.m_J.linearB.y,o.m_angularVelocity+=o.m_invI*s*this.m_J.angularB},solvePositionConstraints:function(){var t,o,i=0,s=this.m_bodyA,n=this.m_bodyB;t=null!=this.m_revolute1?this.m_revolute1.getJointAngle():this.m_prismatic1.getJointTranslation(),o=null!=this.m_revolute2?this.m_revolute2.getJointAngle():this.m_prismatic2.getJointTranslation();var e=this.m_constant-(t+this.m_ratio*o),m=-this.m_mass*e;return s.m_sweep.c.x+=s.m_invMass*m*this.m_J.linearA.x,s.m_sweep.c.y+=s.m_invMass*m*this.m_J.linearA.y,s.m_sweep.a+=s.m_invI*m*this.m_J.angularA,n.m_sweep.c.x+=n.m_invMass*m*this.m_J.linearB.x,n.m_sweep.c.y+=n.m_invMass*m*this.m_J.linearB.y,n.m_sweep.a+=n.m_invI*m*this.m_J.angularB,s.synchronizeTransform(),n.synchronizeTransform(),i<box2D.common.B2Settings.b2_linearSlop},__class__:box2D.dynamics.joints.B2GearJoint}),box2D.dynamics.joints.B2GearJointDef=function(){box2D.dynamics.joints.B2JointDef.call(this),this.type=box2D.dynamics.joints.B2Joint.e_gearJoint,this.joint1=null,this.joint2=null,this.ratio=1},box2D.dynamics.joints.B2GearJointDef.__name__=!0,box2D.dynamics.joints.B2GearJointDef.__super__=box2D.dynamics.joints.B2JointDef,box2D.dynamics.joints.B2GearJointDef.prototype=$extend(box2D.dynamics.joints.B2JointDef.prototype,{__class__:box2D.dynamics.joints.B2GearJointDef}),box2D.dynamics.joints.B2Jacobian=function(){this.linearA=new box2D.common.math.B2Vec2,this.linearB=new box2D.common.math.B2Vec2},box2D.dynamics.joints.B2Jacobian.__name__=!0,box2D.dynamics.joints.B2Jacobian.prototype={setZero:function(){this.linearA.setZero(),this.angularA=0,this.linearB.setZero(),this.angularB=0},set:function(t,o,i,s){this.linearA.setV(t),this.angularA=o,this.linearB.setV(i),this.angularB=s},compute:function(t,o,i,s){return this.linearA.x*t.x+this.linearA.y*t.y+this.angularA*o+(this.linearB.x*i.x+this.linearB.y*i.y)+this.angularB*s},__class__:box2D.dynamics.joints.B2Jacobian},box2D.dynamics.joints.B2JointEdge=function(){},box2D.dynamics.joints.B2JointEdge.__name__=!0,box2D.dynamics.joints.B2JointEdge.prototype={__class__:box2D.dynamics.joints.B2JointEdge},box2D.dynamics.joints.B2LineJoint=function(t){box2D.dynamics.joints.B2Joint.call(this,t),this.m_localAnchor1=new box2D.common.math.B2Vec2,this.m_localAnchor2=new box2D.common.math.B2Vec2,this.m_localXAxis1=new box2D.common.math.B2Vec2,this.m_localYAxis1=new box2D.common.math.B2Vec2,this.m_axis=new box2D.common.math.B2Vec2,this.m_perp=new box2D.common.math.B2Vec2,this.m_K=new box2D.common.math.B2Mat22,this.m_impulse=new box2D.common.math.B2Vec2;this.m_localAnchor1.setV(t.localAnchorA),this.m_localAnchor2.setV(t.localAnchorB),this.m_localXAxis1.setV(t.localAxisA),this.m_localYAxis1.x=-this.m_localXAxis1.y,this.m_localYAxis1.y=this.m_localXAxis1.x,this.m_impulse.setZero(),this.m_motorMass=0,this.m_motorImpulse=0,this.m_lowerTranslation=t.lowerTranslation,this.m_upperTranslation=t.upperTranslation,this.m_maxMotorForce=t.maxMotorForce,this.m_motorSpeed=t.motorSpeed,this.m_enableLimit=t.enableLimit,this.m_enableMotor=t.enableMotor,this.m_limitState=box2D.dynamics.joints.B2Joint.e_inactiveLimit,this.m_axis.setZero(),this.m_perp.setZero()},box2D.dynamics.joints.B2LineJoint.__name__=!0,box2D.dynamics.joints.B2LineJoint.__super__=box2D.dynamics.joints.B2Joint,box2D.dynamics.joints.B2LineJoint.prototype=$extend(box2D.dynamics.joints.B2Joint.prototype,{getAnchorA:function(){return this.m_bodyA.getWorldPoint(this.m_localAnchor1)},getAnchorB:function(){return this.m_bodyB.getWorldPoint(this.m_localAnchor2)},getReactionForce:function(t){return new box2D.common.math.B2Vec2(t*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.x),t*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.y))},getReactionTorque:function(t){return t*this.m_impulse.y},getJointTranslation:function(){var t=this.m_bodyA,o=this.m_bodyB,i=t.getWorldPoint(this.m_localAnchor1),s=o.getWorldPoint(this.m_localAnchor2),n=s.x-i.x,e=s.y-i.y,m=t.getWorldVector(this.m_localXAxis1),a=m.x*n+m.y*e;return a},getJointSpeed:function(){var t,o=this.m_bodyA,i=this.m_bodyB;t=o.m_xf.R;var s=this.m_localAnchor1.x-o.m_sweep.localCenter.x,n=this.m_localAnchor1.y-o.m_sweep.localCenter.y,e=t.col1.x*s+t.col2.x*n;n=t.col1.y*s+t.col2.y*n,s=e,t=i.m_xf.R;var m=this.m_localAnchor2.x-i.m_sweep.localCenter.x,a=this.m_localAnchor2.y-i.m_sweep.localCenter.y;e=t.col1.x*m+t.col2.x*a,a=t.col1.y*m+t.col2.y*a,m=e;var c=o.m_sweep.c.x+s,l=o.m_sweep.c.y+n,r=i.m_sweep.c.x+m,_=i.m_sweep.c.y+a,h=r-c,x=_-l,y=o.getWorldVector(this.m_localXAxis1),u=o.m_linearVelocity,p=i.m_linearVelocity,d=o.m_angularVelocity,B=i.m_angularVelocity,b=h*-d*y.y+x*d*y.x+(y.x*(p.x+-B*a-u.x- -d*n)+y.y*(p.y+B*m-u.y-d*s));return b},isLimitEnabled:function(){return this.m_enableLimit},enableLimit:function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_enableLimit=t},getLowerLimit:function(){return this.m_lowerTranslation},getUpperLimit:function(){return this.m_upperTranslation},setLimits:function(t,o){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_lowerTranslation=t,this.m_upperTranslation=o},isMotorEnabled:function(){return this.m_enableMotor},enableMotor:function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_enableMotor=t},setMotorSpeed:function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_motorSpeed=t},getMotorSpeed:function(){return this.m_motorSpeed},setMaxMotorForce:function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_maxMotorForce=t},getMaxMotorForce:function(){return this.m_maxMotorForce},getMotorForce:function(){return this.m_motorImpulse},initVelocityConstraints:function(t){var o,i,s=this.m_bodyA,n=this.m_bodyB;this.m_localCenterA.setV(s.getLocalCenter()),this.m_localCenterB.setV(n.getLocalCenter());{var e=s.getTransform();n.getTransform()}o=s.m_xf.R;var m=this.m_localAnchor1.x-this.m_localCenterA.x,a=this.m_localAnchor1.y-this.m_localCenterA.y;i=o.col1.x*m+o.col2.x*a,a=o.col1.y*m+o.col2.y*a,m=i,o=n.m_xf.R;var c=this.m_localAnchor2.x-this.m_localCenterB.x,l=this.m_localAnchor2.y-this.m_localCenterB.y;i=o.col1.x*c+o.col2.x*l,l=o.col1.y*c+o.col2.y*l,c=i;var r=n.m_sweep.c.x+c-s.m_sweep.c.x-m,_=n.m_sweep.c.y+l-s.m_sweep.c.y-a;this.m_invMassA=s.m_invMass,this.m_invMassB=n.m_invMass,this.m_invIA=s.m_invI,this.m_invIB=n.m_invI,this.m_axis.setV(box2D.common.math.B2Math.mulMV(e.R,this.m_localXAxis1)),this.m_a1=(r+m)*this.m_axis.y-(_+a)*this.m_axis.x,this.m_a2=c*this.m_axis.y-l*this.m_axis.x,this.m_motorMass=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_a1*this.m_a1+this.m_invIB*this.m_a2*this.m_a2,this.m_motorMass=this.m_motorMass>2.2250738585072014e-308?1/this.m_motorMass:0,this.m_perp.setV(box2D.common.math.B2Math.mulMV(e.R,this.m_localYAxis1)),this.m_s1=(r+m)*this.m_perp.y-(_+a)*this.m_perp.x,this.m_s2=c*this.m_perp.y-l*this.m_perp.x;var h=this.m_invMassA,x=this.m_invMassB,y=this.m_invIA,u=this.m_invIB;if(this.m_K.col1.x=h+x+y*this.m_s1*this.m_s1+u*this.m_s2*this.m_s2,this.m_K.col1.y=y*this.m_s1*this.m_a1+u*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=h+x+y*this.m_a1*this.m_a1+u*this.m_a2*this.m_a2,this.m_enableLimit){var p=this.m_axis.x*r+this.m_axis.y*_;box2D.common.math.B2Math.abs(this.m_upperTranslation-this.m_lowerTranslation)<2*box2D.common.B2Settings.b2_linearSlop?this.m_limitState=box2D.dynamics.joints.B2Joint.e_equalLimits:p<=this.m_lowerTranslation?this.m_limitState!=box2D.dynamics.joints.B2Joint.e_atLowerLimit&&(this.m_limitState=box2D.dynamics.joints.B2Joint.e_atLowerLimit,this.m_impulse.y=0):p>=this.m_upperTranslation?this.m_limitState!=box2D.dynamics.joints.B2Joint.e_atUpperLimit&&(this.m_limitState=box2D.dynamics.joints.B2Joint.e_atUpperLimit,this.m_impulse.y=0):(this.m_limitState=box2D.dynamics.joints.B2Joint.e_inactiveLimit,this.m_impulse.y=0)}else this.m_limitState=box2D.dynamics.joints.B2Joint.e_inactiveLimit;if(0==this.m_enableMotor&&(this.m_motorImpulse=0),t.warmStarting){this.m_impulse.x*=t.dtRatio,this.m_impulse.y*=t.dtRatio,this.m_motorImpulse*=t.dtRatio;var d=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.x,B=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.y,b=this.m_impulse.x*this.m_s1+(this.m_motorImpulse+this.m_impulse.y)*this.m_a1,D=this.m_impulse.x*this.m_s2+(this.m_motorImpulse+this.m_impulse.y)*this.m_a2;s.m_linearVelocity.x-=this.m_invMassA*d,s.m_linearVelocity.y-=this.m_invMassA*B,s.m_angularVelocity-=this.m_invIA*b,n.m_linearVelocity.x+=this.m_invMassB*d,n.m_linearVelocity.y+=this.m_invMassB*B,n.m_angularVelocity+=this.m_invIB*D}else this.m_impulse.setZero(),this.m_motorImpulse=0},solveVelocityConstraints:function(t){var o,i,s,n,e=this.m_bodyA,m=this.m_bodyB,a=e.m_linearVelocity,c=e.m_angularVelocity,l=m.m_linearVelocity,r=m.m_angularVelocity;if(this.m_enableMotor&&this.m_limitState!=box2D.dynamics.joints.B2Joint.e_equalLimits){var _=this.m_axis.x*(l.x-a.x)+this.m_axis.y*(l.y-a.y)+this.m_a2*r-this.m_a1*c,h=this.m_motorMass*(this.m_motorSpeed-_),x=this.m_motorImpulse,y=t.dt*this.m_maxMotorForce;this.m_motorImpulse=box2D.common.math.B2Math.clamp(this.m_motorImpulse+h,-y,y),h=this.m_motorImpulse-x,o=h*this.m_axis.x,i=h*this.m_axis.y,s=h*this.m_a1,n=h*this.m_a2,a.x-=this.m_invMassA*o,a.y-=this.m_invMassA*i,c-=this.m_invIA*s,l.x+=this.m_invMassB*o,l.y+=this.m_invMassB*i,r+=this.m_invIB*n}var u=this.m_perp.x*(l.x-a.x)+this.m_perp.y*(l.y-a.y)+this.m_s2*r-this.m_s1*c;if(this.m_enableLimit&&this.m_limitState!=box2D.dynamics.joints.B2Joint.e_inactiveLimit){var p=this.m_axis.x*(l.x-a.x)+this.m_axis.y*(l.y-a.y)+this.m_a2*r-this.m_a1*c,d=this.m_impulse.copy(),B=this.m_K.solve(new box2D.common.math.B2Vec2,-u,-p);this.m_impulse.add(B),this.m_limitState==box2D.dynamics.joints.B2Joint.e_atLowerLimit?this.m_impulse.y=box2D.common.math.B2Math.max(this.m_impulse.y,0):this.m_limitState==box2D.dynamics.joints.B2Joint.e_atUpperLimit&&(this.m_impulse.y=box2D.common.math.B2Math.min(this.m_impulse.y,0));var b,D=-u-(this.m_impulse.y-d.y)*this.m_K.col2.x;b=0!=this.m_K.col1.x?D/this.m_K.col1.x+d.x:d.x,this.m_impulse.x=b,B.x=this.m_impulse.x-d.x,B.y=this.m_impulse.y-d.y,o=B.x*this.m_perp.x+B.y*this.m_axis.x,i=B.x*this.m_perp.y+B.y*this.m_axis.y,s=B.x*this.m_s1+B.y*this.m_a1,n=B.x*this.m_s2+B.y*this.m_a2,a.x-=this.m_invMassA*o,a.y-=this.m_invMassA*i,c-=this.m_invIA*s,l.x+=this.m_invMassB*o,l.y+=this.m_invMassB*i,r+=this.m_invIB*n}else{var f;f=0!=this.m_K.col1.x?-u/this.m_K.col1.x:0,this.m_impulse.x+=f,o=f*this.m_perp.x,i=f*this.m_perp.y,s=f*this.m_s1,n=f*this.m_s2,a.x-=this.m_invMassA*o,a.y-=this.m_invMassA*i,c-=this.m_invIA*s,l.x+=this.m_invMassB*o,l.y+=this.m_invMassB*i,r+=this.m_invIB*n}e.m_linearVelocity.setV(a),e.m_angularVelocity=c,m.m_linearVelocity.setV(l),m.m_angularVelocity=r},solvePositionConstraints:function(){var t,o,i,s,n,e,m=this.m_bodyA,a=this.m_bodyB,c=m.m_sweep.c,l=m.m_sweep.a,r=a.m_sweep.c,_=a.m_sweep.a,h=0,x=0,y=!1,u=0,p=box2D.common.math.B2Mat22.fromAngle(l),d=box2D.common.math.B2Mat22.fromAngle(_);t=p;var B=this.m_localAnchor1.x-this.m_localCenterA.x,b=this.m_localAnchor1.y-this.m_localCenterA.y;o=t.col1.x*B+t.col2.x*b,b=t.col1.y*B+t.col2.y*b,B=o,t=d;var D=this.m_localAnchor2.x-this.m_localCenterB.x,f=this.m_localAnchor2.y-this.m_localCenterB.y;o=t.col1.x*D+t.col2.x*f,f=t.col1.y*D+t.col2.y*f,D=o;var g=r.x+D-c.x-B,v=r.y+f-c.y-b;if(this.m_enableLimit){this.m_axis=box2D.common.math.B2Math.mulMV(p,this.m_localXAxis1),this.m_a1=(g+B)*this.m_axis.y-(v+b)*this.m_axis.x,this.m_a2=D*this.m_axis.y-f*this.m_axis.x;var A=this.m_axis.x*g+this.m_axis.y*v;box2D.common.math.B2Math.abs(this.m_upperTranslation-this.m_lowerTranslation)<2*box2D.common.B2Settings.b2_linearSlop?(u=box2D.common.math.B2Math.clamp(A,-box2D.common.B2Settings.b2_maxLinearCorrection,box2D.common.B2Settings.b2_maxLinearCorrection),h=box2D.common.math.B2Math.abs(A),y=!0):A<=this.m_lowerTranslation?(u=box2D.common.math.B2Math.clamp(A-this.m_lowerTranslation+box2D.common.B2Settings.b2_linearSlop,-box2D.common.B2Settings.b2_maxLinearCorrection,0),h=this.m_lowerTranslation-A,y=!0):A>=this.m_upperTranslation&&(u=box2D.common.math.B2Math.clamp(A-this.m_upperTranslation+box2D.common.B2Settings.b2_linearSlop,0,box2D.common.B2Settings.b2_maxLinearCorrection),h=A-this.m_upperTranslation,y=!0)}this.m_perp=box2D.common.math.B2Math.mulMV(p,this.m_localYAxis1),this.m_s1=(g+B)*this.m_perp.y-(v+b)*this.m_perp.x,this.m_s2=D*this.m_perp.y-f*this.m_perp.x;var w=new box2D.common.math.B2Vec2,V=this.m_perp.x*g+this.m_perp.y*v;if(h=box2D.common.math.B2Math.max(h,box2D.common.math.B2Math.abs(V)),x=0,y)i=this.m_invMassA,s=this.m_invMassB,n=this.m_invIA,e=this.m_invIB,this.m_K.col1.x=i+s+n*this.m_s1*this.m_s1+e*this.m_s2*this.m_s2,this.m_K.col1.y=n*this.m_s1*this.m_a1+e*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=i+s+n*this.m_a1*this.m_a1+e*this.m_a2*this.m_a2,this.m_K.solve(w,-V,-u);else{i=this.m_invMassA,s=this.m_invMassB,n=this.m_invIA,e=this.m_invIB;var C,M=i+s+n*this.m_s1*this.m_s1+e*this.m_s2*this.m_s2;C=0!=M?-V/M:0,w.x=C,w.y=0}var S=w.x*this.m_perp.x+w.y*this.m_axis.x,I=w.x*this.m_perp.y+w.y*this.m_axis.y,j=w.x*this.m_s1+w.y*this.m_a1,L=w.x*this.m_s2+w.y*this.m_a2;return c.x-=this.m_invMassA*S,c.y-=this.m_invMassA*I,l-=this.m_invIA*j,r.x+=this.m_invMassB*S,r.y+=this.m_invMassB*I,_+=this.m_invIB*L,m.m_sweep.a=l,a.m_sweep.a=_,m.synchronizeTransform(),a.synchronizeTransform(),h<=box2D.common.B2Settings.b2_linearSlop&&x<=box2D.common.B2Settings.b2_angularSlop},__class__:box2D.dynamics.joints.B2LineJoint}),box2D.dynamics.joints.B2LineJointDef=function(){box2D.dynamics.joints.B2JointDef.call(this)},box2D.dynamics.joints.B2LineJointDef.__name__=!0,box2D.dynamics.joints.B2LineJointDef.__super__=box2D.dynamics.joints.B2JointDef,box2D.dynamics.joints.B2LineJointDef.prototype=$extend(box2D.dynamics.joints.B2JointDef.prototype,{b2LineJointDef:function(){this.localAnchorA=new box2D.common.math.B2Vec2,this.localAnchorB=new box2D.common.math.B2Vec2,this.localAxisA=new box2D.common.math.B2Vec2,this.type=box2D.dynamics.joints.B2Joint.e_lineJoint,this.localAxisA.set(1,0),this.enableLimit=!1,this.lowerTranslation=0,this.upperTranslation=0,this.enableMotor=!1,this.maxMotorForce=0,this.motorSpeed=0},initialize:function(t,o,i,s){this.bodyA=t,this.bodyB=o,this.localAnchorA=this.bodyA.getLocalPoint(i),this.localAnchorB=this.bodyB.getLocalPoint(i),this.localAxisA=this.bodyA.getLocalVector(s)},__class__:box2D.dynamics.joints.B2LineJointDef}),box2D.dynamics.joints.B2MouseJoint=function(t){box2D.dynamics.joints.B2Joint.call(this,t),this.K=new box2D.common.math.B2Mat22,this.K1=new box2D.common.math.B2Mat22,this.K2=new box2D.common.math.B2Mat22,this.m_localAnchor=new box2D.common.math.B2Vec2,this.m_target=new box2D.common.math.B2Vec2,this.m_impulse=new box2D.common.math.B2Vec2,this.m_mass=new box2D.common.math.B2Mat22,this.m_C=new box2D.common.math.B2Vec2,this.m_target.setV(t.target);var o=this.m_target.x-this.m_bodyB.m_xf.position.x,i=this.m_target.y-this.m_bodyB.m_xf.position.y,s=this.m_bodyB.m_xf.R;this.m_localAnchor.x=o*s.col1.x+i*s.col1.y,this.m_localAnchor.y=o*s.col2.x+i*s.col2.y,this.m_maxForce=t.maxForce,this.m_impulse.setZero(),this.m_frequencyHz=t.frequencyHz,this.m_dampingRatio=t.dampingRatio,this.m_beta=0,this.m_gamma=0},box2D.dynamics.joints.B2MouseJoint.__name__=!0,box2D.dynamics.joints.B2MouseJoint.__super__=box2D.dynamics.joints.B2Joint,box2D.dynamics.joints.B2MouseJoint.prototype=$extend(box2D.dynamics.joints.B2Joint.prototype,{getAnchorA:function(){return this.m_target},getAnchorB:function(){return this.m_bodyB.getWorldPoint(this.m_localAnchor)},getReactionForce:function(t){return new box2D.common.math.B2Vec2(t*this.m_impulse.x,t*this.m_impulse.y)},getReactionTorque:function(){return 0},getTarget:function(){return this.m_target},setTarget:function(t){0==this.m_bodyB.isAwake()&&this.m_bodyB.setAwake(!0),this.m_target=t},getMaxForce:function(){return this.m_maxForce},setMaxForce:function(t){this.m_maxForce=t},getFrequency:function(){return this.m_frequencyHz},setFrequency:function(t){this.m_frequencyHz=t},getDampingRatio:function(){return this.m_dampingRatio},setDampingRatio:function(t){this.m_dampingRatio=t},initVelocityConstraints:function(t){var o=this.m_bodyB,i=o.getMass(),s=2*Math.PI*this.m_frequencyHz,n=2*i*this.m_dampingRatio*s,e=i*s*s;this.m_gamma=t.dt*(n+t.dt*e),this.m_gamma=0!=this.m_gamma?1/this.m_gamma:0,this.m_beta=t.dt*e*this.m_gamma;var m;m=o.m_xf.R;var a=this.m_localAnchor.x-o.m_sweep.localCenter.x,c=this.m_localAnchor.y-o.m_sweep.localCenter.y,l=m.col1.x*a+m.col2.x*c;c=m.col1.y*a+m.col2.y*c,a=l;var r=o.m_invMass,_=o.m_invI;this.K1.col1.x=r,this.K1.col2.x=0,this.K1.col1.y=0,this.K1.col2.y=r,this.K2.col1.x=_*c*c,this.K2.col2.x=-_*a*c,this.K2.col1.y=-_*a*c,this.K2.col2.y=_*a*a,this.K.setM(this.K1),this.K.addM(this.K2),this.K.col1.x+=this.m_gamma,this.K.col2.y+=this.m_gamma,this.K.getInverse(this.m_mass),this.m_C.x=o.m_sweep.c.x+a-this.m_target.x,this.m_C.y=o.m_sweep.c.y+c-this.m_target.y,o.m_angularVelocity*=.98,this.m_impulse.x*=t.dtRatio,this.m_impulse.y*=t.dtRatio,o.m_linearVelocity.x+=r*this.m_impulse.x,o.m_linearVelocity.y+=r*this.m_impulse.y,o.m_angularVelocity+=_*(a*this.m_impulse.y-c*this.m_impulse.x)},solveVelocityConstraints:function(t){var o,i,s,n=this.m_bodyB;o=n.m_xf.R;var e=this.m_localAnchor.x-n.m_sweep.localCenter.x,m=this.m_localAnchor.y-n.m_sweep.localCenter.y;i=o.col1.x*e+o.col2.x*m,m=o.col1.y*e+o.col2.y*m,e=i;var a=n.m_linearVelocity.x+-n.m_angularVelocity*m,c=n.m_linearVelocity.y+n.m_angularVelocity*e;o=this.m_mass,i=a+this.m_beta*this.m_C.x+this.m_gamma*this.m_impulse.x,s=c+this.m_beta*this.m_C.y+this.m_gamma*this.m_impulse.y;var l=-(o.col1.x*i+o.col2.x*s),r=-(o.col1.y*i+o.col2.y*s),_=this.m_impulse.x,h=this.m_impulse.y;this.m_impulse.x+=l,this.m_impulse.y+=r;var x=t.dt*this.m_maxForce;this.m_impulse.lengthSquared()>x*x&&this.m_impulse.multiply(x/this.m_impulse.length()),l=this.m_impulse.x-_,r=this.m_impulse.y-h,n.m_linearVelocity.x+=n.m_invMass*l,n.m_linearVelocity.y+=n.m_invMass*r,n.m_angularVelocity+=n.m_invI*(e*r-m*l)},solvePositionConstraints:function(){return!0},__class__:box2D.dynamics.joints.B2MouseJoint}),box2D.dynamics.joints.B2MouseJointDef=function(){box2D.dynamics.joints.B2JointDef.call(this),this.target=new box2D.common.math.B2Vec2,this.type=box2D.dynamics.joints.B2Joint.e_mouseJoint,this.maxForce=0,this.frequencyHz=5,this.dampingRatio=.7},box2D.dynamics.joints.B2MouseJointDef.__name__=!0,box2D.dynamics.joints.B2MouseJointDef.__super__=box2D.dynamics.joints.B2JointDef,box2D.dynamics.joints.B2MouseJointDef.prototype=$extend(box2D.dynamics.joints.B2JointDef.prototype,{__class__:box2D.dynamics.joints.B2MouseJointDef}),box2D.dynamics.joints.B2PrismaticJoint=function(t){box2D.dynamics.joints.B2Joint.call(this,t),this.m_localAnchor1=new box2D.common.math.B2Vec2,this.m_localAnchor2=new box2D.common.math.B2Vec2,this.m_localXAxis1=new box2D.common.math.B2Vec2,this.m_localYAxis1=new box2D.common.math.B2Vec2,this.m_axis=new box2D.common.math.B2Vec2,this.m_perp=new box2D.common.math.B2Vec2,this.m_K=new box2D.common.math.B2Mat33,this.m_impulse=new box2D.common.math.B2Vec3;this.m_localAnchor1.setV(t.localAnchorA),this.m_localAnchor2.setV(t.localAnchorB),this.m_localXAxis1.setV(t.localAxisA),this.m_localYAxis1.x=-this.m_localXAxis1.y,this.m_localYAxis1.y=this.m_localXAxis1.x,this.m_refAngle=t.referenceAngle,this.m_impulse.setZero(),this.m_motorMass=0,this.m_motorImpulse=0,this.m_lowerTranslation=t.lowerTranslation,this.m_upperTranslation=t.upperTranslation,this.m_maxMotorForce=t.maxMotorForce,this.m_motorSpeed=t.motorSpeed,this.m_enableLimit=t.enableLimit,this.m_enableMotor=t.enableMotor,this.m_limitState=box2D.dynamics.joints.B2Joint.e_inactiveLimit,this.m_axis.setZero(),this.m_perp.setZero()},box2D.dynamics.joints.B2PrismaticJoint.__name__=!0,box2D.dynamics.joints.B2PrismaticJoint.__super__=box2D.dynamics.joints.B2Joint,box2D.dynamics.joints.B2PrismaticJoint.prototype=$extend(box2D.dynamics.joints.B2Joint.prototype,{getAnchorA:function(){return this.m_bodyA.getWorldPoint(this.m_localAnchor1)},getAnchorB:function(){return this.m_bodyB.getWorldPoint(this.m_localAnchor2)},getReactionForce:function(t){return new box2D.common.math.B2Vec2(t*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),t*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y))},getReactionTorque:function(t){return t*this.m_impulse.y},getJointTranslation:function(){var t=this.m_bodyA,o=this.m_bodyB,i=t.getWorldPoint(this.m_localAnchor1),s=o.getWorldPoint(this.m_localAnchor2),n=s.x-i.x,e=s.y-i.y,m=t.getWorldVector(this.m_localXAxis1),a=m.x*n+m.y*e;return a},getJointSpeed:function(){var t,o=this.m_bodyA,i=this.m_bodyB;t=o.m_xf.R;var s=this.m_localAnchor1.x-o.m_sweep.localCenter.x,n=this.m_localAnchor1.y-o.m_sweep.localCenter.y,e=t.col1.x*s+t.col2.x*n;n=t.col1.y*s+t.col2.y*n,s=e,t=i.m_xf.R;var m=this.m_localAnchor2.x-i.m_sweep.localCenter.x,a=this.m_localAnchor2.y-i.m_sweep.localCenter.y;e=t.col1.x*m+t.col2.x*a,a=t.col1.y*m+t.col2.y*a,m=e;var c=o.m_sweep.c.x+s,l=o.m_sweep.c.y+n,r=i.m_sweep.c.x+m,_=i.m_sweep.c.y+a,h=r-c,x=_-l,y=o.getWorldVector(this.m_localXAxis1),u=o.m_linearVelocity,p=i.m_linearVelocity,d=o.m_angularVelocity,B=i.m_angularVelocity,b=h*-d*y.y+x*d*y.x+(y.x*(p.x+-B*a-u.x- -d*n)+y.y*(p.y+B*m-u.y-d*s));return b},isLimitEnabled:function(){return this.m_enableLimit},enableLimit:function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_enableLimit=t},getLowerLimit:function(){return this.m_lowerTranslation},getUpperLimit:function(){return this.m_upperTranslation},setLimits:function(t,o){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_lowerTranslation=t,this.m_upperTranslation=o},isMotorEnabled:function(){return this.m_enableMotor},enableMotor:function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_enableMotor=t},setMotorSpeed:function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_motorSpeed=t},getMotorSpeed:function(){return this.m_motorSpeed},setMaxMotorForce:function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_maxMotorForce=t},getMotorForce:function(){return this.m_motorImpulse},initVelocityConstraints:function(t){var o,i,s=this.m_bodyA,n=this.m_bodyB;this.m_localCenterA.setV(s.getLocalCenter()),this.m_localCenterB.setV(n.getLocalCenter());{var e=s.getTransform();n.getTransform()}o=s.m_xf.R;var m=this.m_localAnchor1.x-this.m_localCenterA.x,a=this.m_localAnchor1.y-this.m_localCenterA.y;i=o.col1.x*m+o.col2.x*a,a=o.col1.y*m+o.col2.y*a,m=i,o=n.m_xf.R;var c=this.m_localAnchor2.x-this.m_localCenterB.x,l=this.m_localAnchor2.y-this.m_localCenterB.y;i=o.col1.x*c+o.col2.x*l,l=o.col1.y*c+o.col2.y*l,c=i;var r=n.m_sweep.c.x+c-s.m_sweep.c.x-m,_=n.m_sweep.c.y+l-s.m_sweep.c.y-a;this.m_invMassA=s.m_invMass,this.m_invMassB=n.m_invMass,this.m_invIA=s.m_invI,this.m_invIB=n.m_invI,this.m_axis.setV(box2D.common.math.B2Math.mulMV(e.R,this.m_localXAxis1)),this.m_a1=(r+m)*this.m_axis.y-(_+a)*this.m_axis.x,this.m_a2=c*this.m_axis.y-l*this.m_axis.x,this.m_motorMass=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_a1*this.m_a1+this.m_invIB*this.m_a2*this.m_a2,this.m_motorMass>2.2250738585072014e-308&&(this.m_motorMass=1/this.m_motorMass),this.m_perp.setV(box2D.common.math.B2Math.mulMV(e.R,this.m_localYAxis1)),this.m_s1=(r+m)*this.m_perp.y-(_+a)*this.m_perp.x,this.m_s2=c*this.m_perp.y-l*this.m_perp.x;var h=this.m_invMassA,x=this.m_invMassB,y=this.m_invIA,u=this.m_invIB;if(this.m_K.col1.x=h+x+y*this.m_s1*this.m_s1+u*this.m_s2*this.m_s2,this.m_K.col1.y=y*this.m_s1+u*this.m_s2,this.m_K.col1.z=y*this.m_s1*this.m_a1+u*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=y+u,this.m_K.col2.z=y*this.m_a1+u*this.m_a2,this.m_K.col3.x=this.m_K.col1.z,this.m_K.col3.y=this.m_K.col2.z,this.m_K.col3.z=h+x+y*this.m_a1*this.m_a1+u*this.m_a2*this.m_a2,this.m_enableLimit){var p=this.m_axis.x*r+this.m_axis.y*_;box2D.common.math.B2Math.abs(this.m_upperTranslation-this.m_lowerTranslation)<2*box2D.common.B2Settings.b2_linearSlop?this.m_limitState=box2D.dynamics.joints.B2Joint.e_equalLimits:p<=this.m_lowerTranslation?this.m_limitState!=box2D.dynamics.joints.B2Joint.e_atLowerLimit&&(this.m_limitState=box2D.dynamics.joints.B2Joint.e_atLowerLimit,this.m_impulse.z=0):p>=this.m_upperTranslation?this.m_limitState!=box2D.dynamics.joints.B2Joint.e_atUpperLimit&&(this.m_limitState=box2D.dynamics.joints.B2Joint.e_atUpperLimit,this.m_impulse.z=0):(this.m_limitState=box2D.dynamics.joints.B2Joint.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=box2D.dynamics.joints.B2Joint.e_inactiveLimit;if(0==this.m_enableMotor&&(this.m_motorImpulse=0),t.warmStarting){this.m_impulse.x*=t.dtRatio,this.m_impulse.y*=t.dtRatio,this.m_motorImpulse*=t.dtRatio;var d=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x,B=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y,b=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,D=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;s.m_linearVelocity.x-=this.m_invMassA*d,s.m_linearVelocity.y-=this.m_invMassA*B,s.m_angularVelocity-=this.m_invIA*b,n.m_linearVelocity.x+=this.m_invMassB*d,n.m_linearVelocity.y+=this.m_invMassB*B,n.m_angularVelocity+=this.m_invIB*D}else this.m_impulse.setZero(),this.m_motorImpulse=0},solveVelocityConstraints:function(t){var o,i,s,n,e=this.m_bodyA,m=this.m_bodyB,a=e.m_linearVelocity,c=e.m_angularVelocity,l=m.m_linearVelocity,r=m.m_angularVelocity;if(this.m_enableMotor&&this.m_limitState!=box2D.dynamics.joints.B2Joint.e_equalLimits){var _=this.m_axis.x*(l.x-a.x)+this.m_axis.y*(l.y-a.y)+this.m_a2*r-this.m_a1*c,h=this.m_motorMass*(this.m_motorSpeed-_),x=this.m_motorImpulse,y=t.dt*this.m_maxMotorForce;this.m_motorImpulse=box2D.common.math.B2Math.clamp(this.m_motorImpulse+h,-y,y),h=this.m_motorImpulse-x,o=h*this.m_axis.x,i=h*this.m_axis.y,s=h*this.m_a1,n=h*this.m_a2,a.x-=this.m_invMassA*o,a.y-=this.m_invMassA*i,c-=this.m_invIA*s,l.x+=this.m_invMassB*o,l.y+=this.m_invMassB*i,r+=this.m_invIB*n}var u=this.m_perp.x*(l.x-a.x)+this.m_perp.y*(l.y-a.y)+this.m_s2*r-this.m_s1*c,p=r-c;if(this.m_enableLimit&&this.m_limitState!=box2D.dynamics.joints.B2Joint.e_inactiveLimit){var d=this.m_axis.x*(l.x-a.x)+this.m_axis.y*(l.y-a.y)+this.m_a2*r-this.m_a1*c,B=this.m_impulse.copy(),b=this.m_K.solve33(new box2D.common.math.B2Vec3,-u,-p,-d);this.m_impulse.add(b),this.m_limitState==box2D.dynamics.joints.B2Joint.e_atLowerLimit?this.m_impulse.z=box2D.common.math.B2Math.max(this.m_impulse.z,0):this.m_limitState==box2D.dynamics.joints.B2Joint.e_atUpperLimit&&(this.m_impulse.z=box2D.common.math.B2Math.min(this.m_impulse.z,0));var D=-u-(this.m_impulse.z-B.z)*this.m_K.col3.x,f=-p-(this.m_impulse.z-B.z)*this.m_K.col3.y,g=this.m_K.solve22(new box2D.common.math.B2Vec2,D,f);g.x+=B.x,g.y+=B.y,this.m_impulse.x=g.x,this.m_impulse.y=g.y,b.x=this.m_impulse.x-B.x,b.y=this.m_impulse.y-B.y,b.z=this.m_impulse.z-B.z,o=b.x*this.m_perp.x+b.z*this.m_axis.x,i=b.x*this.m_perp.y+b.z*this.m_axis.y,s=b.x*this.m_s1+b.y+b.z*this.m_a1,n=b.x*this.m_s2+b.y+b.z*this.m_a2,a.x-=this.m_invMassA*o,a.y-=this.m_invMassA*i,c-=this.m_invIA*s,l.x+=this.m_invMassB*o,l.y+=this.m_invMassB*i,r+=this.m_invIB*n}else{var v=this.m_K.solve22(new box2D.common.math.B2Vec2,-u,-p);this.m_impulse.x+=v.x,this.m_impulse.y+=v.y,o=v.x*this.m_perp.x,i=v.x*this.m_perp.y,s=v.x*this.m_s1+v.y,n=v.x*this.m_s2+v.y,a.x-=this.m_invMassA*o,a.y-=this.m_invMassA*i,c-=this.m_invIA*s,l.x+=this.m_invMassB*o,l.y+=this.m_invMassB*i,r+=this.m_invIB*n}e.m_linearVelocity.setV(a),e.m_angularVelocity=c,m.m_linearVelocity.setV(l),m.m_angularVelocity=r},solvePositionConstraints:function(){var t,o,i,s,n,e,m=this.m_bodyA,a=this.m_bodyB,c=m.m_sweep.c,l=m.m_sweep.a,r=a.m_sweep.c,_=a.m_sweep.a,h=0,x=0,y=!1,u=0,p=box2D.common.math.B2Mat22.fromAngle(l),d=box2D.common.math.B2Mat22.fromAngle(_);t=p;var B=this.m_localAnchor1.x-this.m_localCenterA.x,b=this.m_localAnchor1.y-this.m_localCenterA.y;o=t.col1.x*B+t.col2.x*b,b=t.col1.y*B+t.col2.y*b,B=o,t=d;var D=this.m_localAnchor2.x-this.m_localCenterB.x,f=this.m_localAnchor2.y-this.m_localCenterB.y;o=t.col1.x*D+t.col2.x*f,f=t.col1.y*D+t.col2.y*f,D=o;var g=r.x+D-c.x-B,v=r.y+f-c.y-b;if(this.m_enableLimit){this.m_axis=box2D.common.math.B2Math.mulMV(p,this.m_localXAxis1),this.m_a1=(g+B)*this.m_axis.y-(v+b)*this.m_axis.x,this.m_a2=D*this.m_axis.y-f*this.m_axis.x;var A=this.m_axis.x*g+this.m_axis.y*v;box2D.common.math.B2Math.abs(this.m_upperTranslation-this.m_lowerTranslation)<2*box2D.common.B2Settings.b2_linearSlop?(u=box2D.common.math.B2Math.clamp(A,-box2D.common.B2Settings.b2_maxLinearCorrection,box2D.common.B2Settings.b2_maxLinearCorrection),h=box2D.common.math.B2Math.abs(A),y=!0):A<=this.m_lowerTranslation?(u=box2D.common.math.B2Math.clamp(A-this.m_lowerTranslation+box2D.common.B2Settings.b2_linearSlop,-box2D.common.B2Settings.b2_maxLinearCorrection,0),h=this.m_lowerTranslation-A,y=!0):A>=this.m_upperTranslation&&(u=box2D.common.math.B2Math.clamp(A-this.m_upperTranslation+box2D.common.B2Settings.b2_linearSlop,0,box2D.common.B2Settings.b2_maxLinearCorrection),h=A-this.m_upperTranslation,y=!0)}this.m_perp=box2D.common.math.B2Math.mulMV(p,this.m_localYAxis1),this.m_s1=(g+B)*this.m_perp.y-(v+b)*this.m_perp.x,this.m_s2=D*this.m_perp.y-f*this.m_perp.x;var w=new box2D.common.math.B2Vec3,V=this.m_perp.x*g+this.m_perp.y*v,C=_-l-this.m_refAngle;
if(h=box2D.common.math.B2Math.max(h,box2D.common.math.B2Math.abs(V)),x=box2D.common.math.B2Math.abs(C),y)i=this.m_invMassA,s=this.m_invMassB,n=this.m_invIA,e=this.m_invIB,this.m_K.col1.x=i+s+n*this.m_s1*this.m_s1+e*this.m_s2*this.m_s2,this.m_K.col1.y=n*this.m_s1+e*this.m_s2,this.m_K.col1.z=n*this.m_s1*this.m_a1+e*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=n+e,this.m_K.col2.z=n*this.m_a1+e*this.m_a2,this.m_K.col3.x=this.m_K.col1.z,this.m_K.col3.y=this.m_K.col2.z,this.m_K.col3.z=i+s+n*this.m_a1*this.m_a1+e*this.m_a2*this.m_a2,this.m_K.solve33(w,-V,-C,-u);else{i=this.m_invMassA,s=this.m_invMassB,n=this.m_invIA,e=this.m_invIB;var M=i+s+n*this.m_s1*this.m_s1+e*this.m_s2*this.m_s2,S=n*this.m_s1+e*this.m_s2,I=n+e;this.m_K.col1.set(M,S,0),this.m_K.col2.set(S,I,0);var j=this.m_K.solve22(new box2D.common.math.B2Vec2,-V,-C);w.x=j.x,w.y=j.y,w.z=0}var L=w.x*this.m_perp.x+w.z*this.m_axis.x,P=w.x*this.m_perp.y+w.z*this.m_axis.y,J=w.x*this.m_s1+w.y+w.z*this.m_a1,F=w.x*this.m_s2+w.y+w.z*this.m_a2;return c.x-=this.m_invMassA*L,c.y-=this.m_invMassA*P,l-=this.m_invIA*J,r.x+=this.m_invMassB*L,r.y+=this.m_invMassB*P,_+=this.m_invIB*F,m.m_sweep.a=l,a.m_sweep.a=_,m.synchronizeTransform(),a.synchronizeTransform(),h<=box2D.common.B2Settings.b2_linearSlop&&x<=box2D.common.B2Settings.b2_angularSlop},__class__:box2D.dynamics.joints.B2PrismaticJoint}),box2D.dynamics.joints.B2PrismaticJointDef=function(){box2D.dynamics.joints.B2JointDef.call(this),this.localAnchorA=new box2D.common.math.B2Vec2,this.localAnchorB=new box2D.common.math.B2Vec2,this.localAxisA=new box2D.common.math.B2Vec2,this.type=box2D.dynamics.joints.B2Joint.e_prismaticJoint,this.localAxisA.set(1,0),this.referenceAngle=0,this.enableLimit=!1,this.lowerTranslation=0,this.upperTranslation=0,this.enableMotor=!1,this.maxMotorForce=0,this.motorSpeed=0},box2D.dynamics.joints.B2PrismaticJointDef.__name__=!0,box2D.dynamics.joints.B2PrismaticJointDef.__super__=box2D.dynamics.joints.B2JointDef,box2D.dynamics.joints.B2PrismaticJointDef.prototype=$extend(box2D.dynamics.joints.B2JointDef.prototype,{initialize:function(t,o,i,s){this.bodyA=t,this.bodyB=o,this.localAnchorA=this.bodyA.getLocalPoint(i),this.localAnchorB=this.bodyB.getLocalPoint(i),this.localAxisA=this.bodyA.getLocalVector(s),this.referenceAngle=this.bodyB.getAngle()-this.bodyA.getAngle()},__class__:box2D.dynamics.joints.B2PrismaticJointDef}),box2D.dynamics.joints.B2PulleyJoint=function(t){box2D.dynamics.joints.B2Joint.call(this,t),this.m_groundAnchor1=new box2D.common.math.B2Vec2,this.m_groundAnchor2=new box2D.common.math.B2Vec2,this.m_localAnchor1=new box2D.common.math.B2Vec2,this.m_localAnchor2=new box2D.common.math.B2Vec2,this.m_u1=new box2D.common.math.B2Vec2,this.m_u2=new box2D.common.math.B2Vec2;this.m_ground=this.m_bodyA.m_world.m_groundBody,this.m_groundAnchor1.x=t.groundAnchorA.x-this.m_ground.m_xf.position.x,this.m_groundAnchor1.y=t.groundAnchorA.y-this.m_ground.m_xf.position.y,this.m_groundAnchor2.x=t.groundAnchorB.x-this.m_ground.m_xf.position.x,this.m_groundAnchor2.y=t.groundAnchorB.y-this.m_ground.m_xf.position.y,this.m_localAnchor1.setV(t.localAnchorA),this.m_localAnchor2.setV(t.localAnchorB),this.m_ratio=t.ratio,this.m_constant=t.lengthA+this.m_ratio*t.lengthB,this.m_maxLength1=box2D.common.math.B2Math.min(t.maxLengthA,this.m_constant-this.m_ratio*box2D.dynamics.joints.B2PulleyJoint.b2_minPulleyLength),this.m_maxLength2=box2D.common.math.B2Math.min(t.maxLengthB,(this.m_constant-box2D.dynamics.joints.B2PulleyJoint.b2_minPulleyLength)/this.m_ratio),this.m_impulse=0,this.m_limitImpulse1=0,this.m_limitImpulse2=0},box2D.dynamics.joints.B2PulleyJoint.__name__=!0,box2D.dynamics.joints.B2PulleyJoint.__super__=box2D.dynamics.joints.B2Joint,box2D.dynamics.joints.B2PulleyJoint.prototype=$extend(box2D.dynamics.joints.B2Joint.prototype,{getAnchorA:function(){return this.m_bodyA.getWorldPoint(this.m_localAnchor1)},getAnchorB:function(){return this.m_bodyB.getWorldPoint(this.m_localAnchor2)},getReactionForce:function(t){return new box2D.common.math.B2Vec2(t*this.m_impulse*this.m_u2.x,t*this.m_impulse*this.m_u2.y)},getReactionTorque:function(){return 0},getGroundAnchorA:function(){var t=this.m_ground.m_xf.position.copy();return t.add(this.m_groundAnchor1),t},getGroundAnchorB:function(){var t=this.m_ground.m_xf.position.copy();return t.add(this.m_groundAnchor2),t},getLength1:function(){var t=this.m_bodyA.getWorldPoint(this.m_localAnchor1),o=this.m_ground.m_xf.position.x+this.m_groundAnchor1.x,i=this.m_ground.m_xf.position.y+this.m_groundAnchor1.y,s=t.x-o,n=t.y-i;return Math.sqrt(s*s+n*n)},getLength2:function(){var t=this.m_bodyB.getWorldPoint(this.m_localAnchor2),o=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,i=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y,s=t.x-o,n=t.y-i;return Math.sqrt(s*s+n*n)},getRatio:function(){return this.m_ratio},initVelocityConstraints:function(t){var o,i=this.m_bodyA,s=this.m_bodyB;o=i.m_xf.R;var n=this.m_localAnchor1.x-i.m_sweep.localCenter.x,e=this.m_localAnchor1.y-i.m_sweep.localCenter.y,m=o.col1.x*n+o.col2.x*e;e=o.col1.y*n+o.col2.y*e,n=m,o=s.m_xf.R;var a=this.m_localAnchor2.x-s.m_sweep.localCenter.x,c=this.m_localAnchor2.y-s.m_sweep.localCenter.y;m=o.col1.x*a+o.col2.x*c,c=o.col1.y*a+o.col2.y*c,a=m;var l=i.m_sweep.c.x+n,r=i.m_sweep.c.y+e,_=s.m_sweep.c.x+a,h=s.m_sweep.c.y+c,x=this.m_ground.m_xf.position.x+this.m_groundAnchor1.x,y=this.m_ground.m_xf.position.y+this.m_groundAnchor1.y,u=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,p=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y;this.m_u1.set(l-x,r-y),this.m_u2.set(_-u,h-p);var d=this.m_u1.length(),B=this.m_u2.length();d>box2D.common.B2Settings.b2_linearSlop?this.m_u1.multiply(1/d):this.m_u1.setZero(),B>box2D.common.B2Settings.b2_linearSlop?this.m_u2.multiply(1/B):this.m_u2.setZero();var b=this.m_constant-d-this.m_ratio*B;b>0?(this.m_state=box2D.dynamics.joints.B2Joint.e_inactiveLimit,this.m_impulse=0):this.m_state=box2D.dynamics.joints.B2Joint.e_atUpperLimit,d<this.m_maxLength1?(this.m_limitState1=box2D.dynamics.joints.B2Joint.e_inactiveLimit,this.m_limitImpulse1=0):this.m_limitState1=box2D.dynamics.joints.B2Joint.e_atUpperLimit,B<this.m_maxLength2?(this.m_limitState2=box2D.dynamics.joints.B2Joint.e_inactiveLimit,this.m_limitImpulse2=0):this.m_limitState2=box2D.dynamics.joints.B2Joint.e_atUpperLimit;var D=n*this.m_u1.y-e*this.m_u1.x,f=a*this.m_u2.y-c*this.m_u2.x;if(this.m_limitMass1=i.m_invMass+i.m_invI*D*D,this.m_limitMass2=s.m_invMass+s.m_invI*f*f,this.m_pulleyMass=this.m_limitMass1+this.m_ratio*this.m_ratio*this.m_limitMass2,this.m_limitMass1=1/this.m_limitMass1,this.m_limitMass2=1/this.m_limitMass2,this.m_pulleyMass=1/this.m_pulleyMass,t.warmStarting){this.m_impulse*=t.dtRatio,this.m_limitImpulse1*=t.dtRatio,this.m_limitImpulse2*=t.dtRatio;var g=(-this.m_impulse-this.m_limitImpulse1)*this.m_u1.x,v=(-this.m_impulse-this.m_limitImpulse1)*this.m_u1.y,A=(-this.m_ratio*this.m_impulse-this.m_limitImpulse2)*this.m_u2.x,w=(-this.m_ratio*this.m_impulse-this.m_limitImpulse2)*this.m_u2.y;i.m_linearVelocity.x+=i.m_invMass*g,i.m_linearVelocity.y+=i.m_invMass*v,i.m_angularVelocity+=i.m_invI*(n*v-e*g),s.m_linearVelocity.x+=s.m_invMass*A,s.m_linearVelocity.y+=s.m_invMass*w,s.m_angularVelocity+=s.m_invI*(a*w-c*A)}else this.m_impulse=0,this.m_limitImpulse1=0,this.m_limitImpulse2=0},solveVelocityConstraints:function(){var t,o=this.m_bodyA,i=this.m_bodyB;t=o.m_xf.R;var s=this.m_localAnchor1.x-o.m_sweep.localCenter.x,n=this.m_localAnchor1.y-o.m_sweep.localCenter.y,e=t.col1.x*s+t.col2.x*n;n=t.col1.y*s+t.col2.y*n,s=e,t=i.m_xf.R;var m=this.m_localAnchor2.x-i.m_sweep.localCenter.x,a=this.m_localAnchor2.y-i.m_sweep.localCenter.y;e=t.col1.x*m+t.col2.x*a,a=t.col1.y*m+t.col2.y*a,m=e;var c,l,r,_,h,x,y,u,p,d,B;this.m_state==box2D.dynamics.joints.B2Joint.e_atUpperLimit&&(c=o.m_linearVelocity.x+-o.m_angularVelocity*n,l=o.m_linearVelocity.y+o.m_angularVelocity*s,r=i.m_linearVelocity.x+-i.m_angularVelocity*a,_=i.m_linearVelocity.y+i.m_angularVelocity*m,p=-(this.m_u1.x*c+this.m_u1.y*l)-this.m_ratio*(this.m_u2.x*r+this.m_u2.y*_),d=this.m_pulleyMass*-p,B=this.m_impulse,this.m_impulse=box2D.common.math.B2Math.max(0,this.m_impulse+d),d=this.m_impulse-B,h=-d*this.m_u1.x,x=-d*this.m_u1.y,y=-this.m_ratio*d*this.m_u2.x,u=-this.m_ratio*d*this.m_u2.y,o.m_linearVelocity.x+=o.m_invMass*h,o.m_linearVelocity.y+=o.m_invMass*x,o.m_angularVelocity+=o.m_invI*(s*x-n*h),i.m_linearVelocity.x+=i.m_invMass*y,i.m_linearVelocity.y+=i.m_invMass*u,i.m_angularVelocity+=i.m_invI*(m*u-a*y)),this.m_limitState1==box2D.dynamics.joints.B2Joint.e_atUpperLimit&&(c=o.m_linearVelocity.x+-o.m_angularVelocity*n,l=o.m_linearVelocity.y+o.m_angularVelocity*s,p=-(this.m_u1.x*c+this.m_u1.y*l),d=-this.m_limitMass1*p,B=this.m_limitImpulse1,this.m_limitImpulse1=box2D.common.math.B2Math.max(0,this.m_limitImpulse1+d),d=this.m_limitImpulse1-B,h=-d*this.m_u1.x,x=-d*this.m_u1.y,o.m_linearVelocity.x+=o.m_invMass*h,o.m_linearVelocity.y+=o.m_invMass*x,o.m_angularVelocity+=o.m_invI*(s*x-n*h)),this.m_limitState2==box2D.dynamics.joints.B2Joint.e_atUpperLimit&&(r=i.m_linearVelocity.x+-i.m_angularVelocity*a,_=i.m_linearVelocity.y+i.m_angularVelocity*m,p=-(this.m_u2.x*r+this.m_u2.y*_),d=-this.m_limitMass2*p,B=this.m_limitImpulse2,this.m_limitImpulse2=box2D.common.math.B2Math.max(0,this.m_limitImpulse2+d),d=this.m_limitImpulse2-B,y=-d*this.m_u2.x,u=-d*this.m_u2.y,i.m_linearVelocity.x+=i.m_invMass*y,i.m_linearVelocity.y+=i.m_invMass*u,i.m_angularVelocity+=i.m_invI*(m*u-a*y))},solvePositionConstraints:function(){var t,o,i,s,n,e,m,a,c,l,r,_,h,x,y=this.m_bodyA,u=this.m_bodyB,p=this.m_ground.m_xf.position.x+this.m_groundAnchor1.x,d=this.m_ground.m_xf.position.y+this.m_groundAnchor1.y,B=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,b=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y,D=0;return this.m_state==box2D.dynamics.joints.B2Joint.e_atUpperLimit&&(t=y.m_xf.R,o=this.m_localAnchor1.x-y.m_sweep.localCenter.x,i=this.m_localAnchor1.y-y.m_sweep.localCenter.y,x=t.col1.x*o+t.col2.x*i,i=t.col1.y*o+t.col2.y*i,o=x,t=u.m_xf.R,s=this.m_localAnchor2.x-u.m_sweep.localCenter.x,n=this.m_localAnchor2.y-u.m_sweep.localCenter.y,x=t.col1.x*s+t.col2.x*n,n=t.col1.y*s+t.col2.y*n,s=x,e=y.m_sweep.c.x+o,m=y.m_sweep.c.y+i,a=u.m_sweep.c.x+s,c=u.m_sweep.c.y+n,this.m_u1.set(e-p,m-d),this.m_u2.set(a-B,c-b),l=this.m_u1.length(),r=this.m_u2.length(),l>box2D.common.B2Settings.b2_linearSlop?this.m_u1.multiply(1/l):this.m_u1.setZero(),r>box2D.common.B2Settings.b2_linearSlop?this.m_u2.multiply(1/r):this.m_u2.setZero(),_=this.m_constant-l-this.m_ratio*r,D=box2D.common.math.B2Math.max(D,-_),_=box2D.common.math.B2Math.clamp(_+box2D.common.B2Settings.b2_linearSlop,-box2D.common.B2Settings.b2_maxLinearCorrection,0),h=-this.m_pulleyMass*_,e=-h*this.m_u1.x,m=-h*this.m_u1.y,a=-this.m_ratio*h*this.m_u2.x,c=-this.m_ratio*h*this.m_u2.y,y.m_sweep.c.x+=y.m_invMass*e,y.m_sweep.c.y+=y.m_invMass*m,y.m_sweep.a+=y.m_invI*(o*m-i*e),u.m_sweep.c.x+=u.m_invMass*a,u.m_sweep.c.y+=u.m_invMass*c,u.m_sweep.a+=u.m_invI*(s*c-n*a),y.synchronizeTransform(),u.synchronizeTransform()),this.m_limitState1==box2D.dynamics.joints.B2Joint.e_atUpperLimit&&(t=y.m_xf.R,o=this.m_localAnchor1.x-y.m_sweep.localCenter.x,i=this.m_localAnchor1.y-y.m_sweep.localCenter.y,x=t.col1.x*o+t.col2.x*i,i=t.col1.y*o+t.col2.y*i,o=x,e=y.m_sweep.c.x+o,m=y.m_sweep.c.y+i,this.m_u1.set(e-p,m-d),l=this.m_u1.length(),l>box2D.common.B2Settings.b2_linearSlop?(this.m_u1.x*=1/l,this.m_u1.y*=1/l):this.m_u1.setZero(),_=this.m_maxLength1-l,D=box2D.common.math.B2Math.max(D,-_),_=box2D.common.math.B2Math.clamp(_+box2D.common.B2Settings.b2_linearSlop,-box2D.common.B2Settings.b2_maxLinearCorrection,0),h=-this.m_limitMass1*_,e=-h*this.m_u1.x,m=-h*this.m_u1.y,y.m_sweep.c.x+=y.m_invMass*e,y.m_sweep.c.y+=y.m_invMass*m,y.m_sweep.a+=y.m_invI*(o*m-i*e),y.synchronizeTransform()),this.m_limitState2==box2D.dynamics.joints.B2Joint.e_atUpperLimit&&(t=u.m_xf.R,s=this.m_localAnchor2.x-u.m_sweep.localCenter.x,n=this.m_localAnchor2.y-u.m_sweep.localCenter.y,x=t.col1.x*s+t.col2.x*n,n=t.col1.y*s+t.col2.y*n,s=x,a=u.m_sweep.c.x+s,c=u.m_sweep.c.y+n,this.m_u2.set(a-B,c-b),r=this.m_u2.length(),r>box2D.common.B2Settings.b2_linearSlop?(this.m_u2.x*=1/r,this.m_u2.y*=1/r):this.m_u2.setZero(),_=this.m_maxLength2-r,D=box2D.common.math.B2Math.max(D,-_),_=box2D.common.math.B2Math.clamp(_+box2D.common.B2Settings.b2_linearSlop,-box2D.common.B2Settings.b2_maxLinearCorrection,0),h=-this.m_limitMass2*_,a=-h*this.m_u2.x,c=-h*this.m_u2.y,u.m_sweep.c.x+=u.m_invMass*a,u.m_sweep.c.y+=u.m_invMass*c,u.m_sweep.a+=u.m_invI*(s*c-n*a),u.synchronizeTransform()),D<box2D.common.B2Settings.b2_linearSlop},__class__:box2D.dynamics.joints.B2PulleyJoint}),box2D.dynamics.joints.B2PulleyJointDef=function(){box2D.dynamics.joints.B2JointDef.call(this),this.groundAnchorA=new box2D.common.math.B2Vec2,this.groundAnchorB=new box2D.common.math.B2Vec2,this.localAnchorA=new box2D.common.math.B2Vec2,this.localAnchorB=new box2D.common.math.B2Vec2,this.type=box2D.dynamics.joints.B2Joint.e_pulleyJoint,this.groundAnchorA.set(-1,1),this.groundAnchorB.set(1,1),this.localAnchorA.set(-1,0),this.localAnchorB.set(1,0),this.lengthA=0,this.maxLengthA=0,this.lengthB=0,this.maxLengthB=0,this.ratio=1,this.collideConnected=!0},box2D.dynamics.joints.B2PulleyJointDef.__name__=!0,box2D.dynamics.joints.B2PulleyJointDef.__super__=box2D.dynamics.joints.B2JointDef,box2D.dynamics.joints.B2PulleyJointDef.prototype=$extend(box2D.dynamics.joints.B2JointDef.prototype,{initialize:function(t,o,i,s,n,e,m){this.bodyA=t,this.bodyB=o,this.groundAnchorA.setV(i),this.groundAnchorB.setV(s),this.localAnchorA=this.bodyA.getLocalPoint(n),this.localAnchorB=this.bodyB.getLocalPoint(e);var a=n.x-i.x,c=n.y-i.y;this.lengthA=Math.sqrt(a*a+c*c);var l=e.x-s.x,r=e.y-s.y;this.lengthB=Math.sqrt(l*l+r*r),this.ratio=m;var _=this.lengthA+this.ratio*this.lengthB;this.maxLengthA=_-this.ratio*box2D.dynamics.joints.B2PulleyJoint.b2_minPulleyLength,this.maxLengthB=(_-box2D.dynamics.joints.B2PulleyJoint.b2_minPulleyLength)/this.ratio},__class__:box2D.dynamics.joints.B2PulleyJointDef}),box2D.dynamics.joints.B2RevoluteJoint=function(t){box2D.dynamics.joints.B2Joint.call(this,t),this.K=new box2D.common.math.B2Mat22,this.K1=new box2D.common.math.B2Mat22,this.K2=new box2D.common.math.B2Mat22,this.K3=new box2D.common.math.B2Mat22,this.impulse3=new box2D.common.math.B2Vec3,this.impulse2=new box2D.common.math.B2Vec2,this.reduced=new box2D.common.math.B2Vec2,this.m_localAnchor1=new box2D.common.math.B2Vec2,this.m_localAnchor2=new box2D.common.math.B2Vec2,this.m_impulse=new box2D.common.math.B2Vec3,this.m_mass=new box2D.common.math.B2Mat33,this.m_localAnchor1.setV(t.localAnchorA),this.m_localAnchor2.setV(t.localAnchorB),this.m_referenceAngle=t.referenceAngle,this.m_impulse.setZero(),this.m_motorImpulse=0,this.m_lowerAngle=t.lowerAngle,this.m_upperAngle=t.upperAngle,this.m_maxMotorTorque=t.maxMotorTorque,this.m_motorSpeed=t.motorSpeed,this.m_enableLimit=t.enableLimit,this.m_enableMotor=t.enableMotor,this.m_limitState=box2D.dynamics.joints.B2Joint.e_inactiveLimit},box2D.dynamics.joints.B2RevoluteJoint.__name__=!0,box2D.dynamics.joints.B2RevoluteJoint.__super__=box2D.dynamics.joints.B2Joint,box2D.dynamics.joints.B2RevoluteJoint.prototype=$extend(box2D.dynamics.joints.B2Joint.prototype,{getAnchorA:function(){return this.m_bodyA.getWorldPoint(this.m_localAnchor1)},getAnchorB:function(){return this.m_bodyB.getWorldPoint(this.m_localAnchor2)},getReactionForce:function(t){return new box2D.common.math.B2Vec2(t*this.m_impulse.x,t*this.m_impulse.y)},getReactionTorque:function(t){return t*this.m_impulse.z},getJointAngle:function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a-this.m_referenceAngle},getJointSpeed:function(){return this.m_bodyB.m_angularVelocity-this.m_bodyA.m_angularVelocity},isLimitEnabled:function(){return this.m_enableLimit},enableLimit:function(t){this.m_enableLimit=t},getLowerLimit:function(){return this.m_lowerAngle},getUpperLimit:function(){return this.m_upperAngle},setLimits:function(t,o){this.m_lowerAngle=t,this.m_upperAngle=o},isMotorEnabled:function(){return this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_enableMotor},enableMotor:function(t){this.m_enableMotor=t},setMotorSpeed:function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_motorSpeed=t},getMotorSpeed:function(){return this.m_motorSpeed},setMaxMotorTorque:function(t){this.m_maxMotorTorque=t},getMotorTorque:function(){return this.m_maxMotorTorque},initVelocityConstraints:function(t){var o,i,s=this.m_bodyA,n=this.m_bodyB;this.m_enableMotor||this.m_enableLimit,o=s.m_xf.R;var e=this.m_localAnchor1.x-s.m_sweep.localCenter.x,m=this.m_localAnchor1.y-s.m_sweep.localCenter.y;i=o.col1.x*e+o.col2.x*m,m=o.col1.y*e+o.col2.y*m,e=i,o=n.m_xf.R;var a=this.m_localAnchor2.x-n.m_sweep.localCenter.x,c=this.m_localAnchor2.y-n.m_sweep.localCenter.y;i=o.col1.x*a+o.col2.x*c,c=o.col1.y*a+o.col2.y*c,a=i;var l=s.m_invMass,r=n.m_invMass,_=s.m_invI,h=n.m_invI;if(this.m_mass.col1.x=l+r+m*m*_+c*c*h,this.m_mass.col2.x=-m*e*_-c*a*h,this.m_mass.col3.x=-m*_-c*h,this.m_mass.col1.y=this.m_mass.col2.x,this.m_mass.col2.y=l+r+e*e*_+a*a*h,this.m_mass.col3.y=e*_+a*h,this.m_mass.col1.z=this.m_mass.col3.x,this.m_mass.col2.z=this.m_mass.col3.y,this.m_mass.col3.z=_+h,this.m_motorMass=1/(_+h),0==this.m_enableMotor&&(this.m_motorImpulse=0),this.m_enableLimit){var x=n.m_sweep.a-s.m_sweep.a-this.m_referenceAngle;box2D.common.math.B2Math.abs(this.m_upperAngle-this.m_lowerAngle)<2*box2D.common.B2Settings.b2_angularSlop?this.m_limitState=box2D.dynamics.joints.B2Joint.e_equalLimits:x<=this.m_lowerAngle?(this.m_limitState!=box2D.dynamics.joints.B2Joint.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=box2D.dynamics.joints.B2Joint.e_atLowerLimit):x>=this.m_upperAngle?(this.m_limitState!=box2D.dynamics.joints.B2Joint.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=box2D.dynamics.joints.B2Joint.e_atUpperLimit):(this.m_limitState=box2D.dynamics.joints.B2Joint.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=box2D.dynamics.joints.B2Joint.e_inactiveLimit;if(t.warmStarting){this.m_impulse.x*=t.dtRatio,this.m_impulse.y*=t.dtRatio,this.m_motorImpulse*=t.dtRatio;var y=this.m_impulse.x,u=this.m_impulse.y;s.m_linearVelocity.x-=l*y,s.m_linearVelocity.y-=l*u,s.m_angularVelocity-=_*(e*u-m*y+this.m_motorImpulse+this.m_impulse.z),n.m_linearVelocity.x+=r*y,n.m_linearVelocity.y+=r*u,n.m_angularVelocity+=h*(a*u-c*y+this.m_motorImpulse+this.m_impulse.z)}else this.m_impulse.setZero(),this.m_motorImpulse=0},solveVelocityConstraints:function(t){var o,i,s,n,e,m,a,c=this.m_bodyA,l=this.m_bodyB,r=c.m_linearVelocity,_=c.m_angularVelocity,h=l.m_linearVelocity,x=l.m_angularVelocity,y=c.m_invMass,u=l.m_invMass,p=c.m_invI,d=l.m_invI;if(this.m_enableMotor&&this.m_limitState!=box2D.dynamics.joints.B2Joint.e_equalLimits){var B=x-_-this.m_motorSpeed,b=this.m_motorMass*-B,D=this.m_motorImpulse,f=t.dt*this.m_maxMotorTorque;this.m_motorImpulse=box2D.common.math.B2Math.clamp(this.m_motorImpulse+b,-f,f),b=this.m_motorImpulse-D,_-=p*b,x+=d*b}if(this.m_enableLimit&&this.m_limitState!=box2D.dynamics.joints.B2Joint.e_inactiveLimit){o=c.m_xf.R,n=this.m_localAnchor1.x-c.m_sweep.localCenter.x,e=this.m_localAnchor1.y-c.m_sweep.localCenter.y,i=o.col1.x*n+o.col2.x*e,e=o.col1.y*n+o.col2.y*e,n=i,o=l.m_xf.R,m=this.m_localAnchor2.x-l.m_sweep.localCenter.x,a=this.m_localAnchor2.y-l.m_sweep.localCenter.y,i=o.col1.x*m+o.col2.x*a,a=o.col1.y*m+o.col2.y*a,m=i;var g=h.x+-x*a-r.x- -_*e,v=h.y+x*m-r.y-_*n,A=x-_;this.m_mass.solve33(this.impulse3,-g,-v,-A),this.m_limitState==box2D.dynamics.joints.B2Joint.e_equalLimits?this.m_impulse.add(this.impulse3):this.m_limitState==box2D.dynamics.joints.B2Joint.e_atLowerLimit?(s=this.m_impulse.z+this.impulse3.z,0>s&&(this.m_mass.solve22(this.reduced,-g,-v),this.impulse3.x=this.reduced.x,this.impulse3.y=this.reduced.y,this.impulse3.z=-this.m_impulse.z,this.m_impulse.x+=this.reduced.x,this.m_impulse.y+=this.reduced.y,this.m_impulse.z=0)):this.m_limitState==box2D.dynamics.joints.B2Joint.e_atUpperLimit&&(s=this.m_impulse.z+this.impulse3.z,s>0&&(this.m_mass.solve22(this.reduced,-g,-v),this.impulse3.x=this.reduced.x,this.impulse3.y=this.reduced.y,this.impulse3.z=-this.m_impulse.z,this.m_impulse.x+=this.reduced.x,this.m_impulse.y+=this.reduced.y,this.m_impulse.z=0)),r.x-=y*this.impulse3.x,r.y-=y*this.impulse3.y,_-=p*(n*this.impulse3.y-e*this.impulse3.x+this.impulse3.z),h.x+=u*this.impulse3.x,h.y+=u*this.impulse3.y,x+=d*(m*this.impulse3.y-a*this.impulse3.x+this.impulse3.z)}else{o=c.m_xf.R,n=this.m_localAnchor1.x-c.m_sweep.localCenter.x,e=this.m_localAnchor1.y-c.m_sweep.localCenter.y,i=o.col1.x*n+o.col2.x*e,e=o.col1.y*n+o.col2.y*e,n=i,o=l.m_xf.R,m=this.m_localAnchor2.x-l.m_sweep.localCenter.x,a=this.m_localAnchor2.y-l.m_sweep.localCenter.y,i=o.col1.x*m+o.col2.x*a,a=o.col1.y*m+o.col2.y*a,m=i;var w=h.x+-x*a-r.x- -_*e,V=h.y+x*m-r.y-_*n;this.m_mass.solve22(this.impulse2,-w,-V),this.m_impulse.x+=this.impulse2.x,this.m_impulse.y+=this.impulse2.y,r.x-=y*this.impulse2.x,r.y-=y*this.impulse2.y,_-=p*(n*this.impulse2.y-e*this.impulse2.x),h.x+=u*this.impulse2.x,h.y+=u*this.impulse2.y,x+=d*(m*this.impulse2.y-a*this.impulse2.x)}c.m_linearVelocity.setV(r),c.m_angularVelocity=_,l.m_linearVelocity.setV(h),l.m_angularVelocity=x},solvePositionConstraints:function(){var t,o,i,s,n,e=this.m_bodyA,m=this.m_bodyB,a=0,c=0;if(this.m_enableLimit&&this.m_limitState!=box2D.dynamics.joints.B2Joint.e_inactiveLimit){var l=m.m_sweep.a-e.m_sweep.a-this.m_referenceAngle,r=0;this.m_limitState==box2D.dynamics.joints.B2Joint.e_equalLimits?(t=box2D.common.math.B2Math.clamp(l-this.m_lowerAngle,-box2D.common.B2Settings.b2_maxAngularCorrection,box2D.common.B2Settings.b2_maxAngularCorrection),r=-this.m_motorMass*t,a=box2D.common.math.B2Math.abs(t)):this.m_limitState==box2D.dynamics.joints.B2Joint.e_atLowerLimit?(t=l-this.m_lowerAngle,a=-t,t=box2D.common.math.B2Math.clamp(t+box2D.common.B2Settings.b2_angularSlop,-box2D.common.B2Settings.b2_maxAngularCorrection,0),r=-this.m_motorMass*t):this.m_limitState==box2D.dynamics.joints.B2Joint.e_atUpperLimit&&(t=l-this.m_upperAngle,a=t,t=box2D.common.math.B2Math.clamp(t-box2D.common.B2Settings.b2_angularSlop,0,box2D.common.B2Settings.b2_maxAngularCorrection),r=-this.m_motorMass*t),e.m_sweep.a-=e.m_invI*r,m.m_sweep.a+=m.m_invI*r,e.synchronizeTransform(),m.synchronizeTransform()}o=e.m_xf.R;var _=this.m_localAnchor1.x-e.m_sweep.localCenter.x,h=this.m_localAnchor1.y-e.m_sweep.localCenter.y;i=o.col1.x*_+o.col2.x*h,h=o.col1.y*_+o.col2.y*h,_=i,o=m.m_xf.R;var x=this.m_localAnchor2.x-m.m_sweep.localCenter.x,y=this.m_localAnchor2.y-m.m_sweep.localCenter.y;i=o.col1.x*x+o.col2.x*y,y=o.col1.y*x+o.col2.y*y,x=i;var u=m.m_sweep.c.x+x-e.m_sweep.c.x-_,p=m.m_sweep.c.y+y-e.m_sweep.c.y-h,d=u*u+p*p,B=Math.sqrt(d);c=B;var b=e.m_invMass,D=m.m_invMass,f=e.m_invI,g=m.m_invI,v=10*box2D.common.B2Settings.b2_linearSlop;if(d>v*v){var A=b+D,w=1/A;s=w*-u,n=w*-p;var V=.5;e.m_sweep.c.x-=V*b*s,e.m_sweep.c.y-=V*b*n,m.m_sweep.c.x+=V*D*s,m.m_sweep.c.y+=V*D*n,u=m.m_sweep.c.x+x-e.m_sweep.c.x-_,p=m.m_sweep.c.y+y-e.m_sweep.c.y-h}return this.K1.col1.x=b+D,this.K1.col2.x=0,this.K1.col1.y=0,this.K1.col2.y=b+D,this.K2.col1.x=f*h*h,this.K2.col2.x=-f*_*h,this.K2.col1.y=-f*_*h,this.K2.col2.y=f*_*_,this.K3.col1.x=g*y*y,this.K3.col2.x=-g*x*y,this.K3.col1.y=-g*x*y,this.K3.col2.y=g*x*x,this.K.setM(this.K1),this.K.addM(this.K2),this.K.addM(this.K3),this.K.solve(box2D.dynamics.joints.B2RevoluteJoint.tImpulse,-u,-p),s=box2D.dynamics.joints.B2RevoluteJoint.tImpulse.x,n=box2D.dynamics.joints.B2RevoluteJoint.tImpulse.y,e.m_sweep.c.x-=e.m_invMass*s,e.m_sweep.c.y-=e.m_invMass*n,e.m_sweep.a-=e.m_invI*(_*n-h*s),m.m_sweep.c.x+=m.m_invMass*s,m.m_sweep.c.y+=m.m_invMass*n,m.m_sweep.a+=m.m_invI*(x*n-y*s),e.synchronizeTransform(),m.synchronizeTransform(),c<=box2D.common.B2Settings.b2_linearSlop&&a<=box2D.common.B2Settings.b2_angularSlop},__class__:box2D.dynamics.joints.B2RevoluteJoint}),box2D.dynamics.joints.B2RevoluteJointDef=function(){box2D.dynamics.joints.B2JointDef.call(this),this.localAnchorA=new box2D.common.math.B2Vec2,this.localAnchorB=new box2D.common.math.B2Vec2,this.type=box2D.dynamics.joints.B2Joint.e_revoluteJoint,this.localAnchorA.set(0,0),this.localAnchorB.set(0,0),this.referenceAngle=0,this.lowerAngle=0,this.upperAngle=0,this.maxMotorTorque=0,this.motorSpeed=0,this.enableLimit=!1,this.enableMotor=!1},box2D.dynamics.joints.B2RevoluteJointDef.__name__=!0,box2D.dynamics.joints.B2RevoluteJointDef.__super__=box2D.dynamics.joints.B2JointDef,box2D.dynamics.joints.B2RevoluteJointDef.prototype=$extend(box2D.dynamics.joints.B2JointDef.prototype,{initialize:function(t,o,i){this.bodyA=t,this.bodyB=o,this.localAnchorA=this.bodyA.getLocalPoint(i),this.localAnchorB=this.bodyB.getLocalPoint(i),this.referenceAngle=this.bodyB.getAngle()-this.bodyA.getAngle()},__class__:box2D.dynamics.joints.B2RevoluteJointDef}),box2D.dynamics.joints.B2WeldJoint=function(t){box2D.dynamics.joints.B2Joint.call(this,t),this.m_localAnchorA=new box2D.common.math.B2Vec2,this.m_localAnchorB=new box2D.common.math.B2Vec2,this.m_impulse=new box2D.common.math.B2Vec3,this.m_mass=new box2D.common.math.B2Mat33,this.m_localAnchorA.setV(t.localAnchorA),this.m_localAnchorB.setV(t.localAnchorB),this.m_referenceAngle=t.referenceAngle,this.m_impulse.setZero(),this.m_mass=new box2D.common.math.B2Mat33},box2D.dynamics.joints.B2WeldJoint.__name__=!0,box2D.dynamics.joints.B2WeldJoint.__super__=box2D.dynamics.joints.B2Joint,box2D.dynamics.joints.B2WeldJoint.prototype=$extend(box2D.dynamics.joints.B2Joint.prototype,{getAnchorA:function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)},getAnchorB:function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)},getReactionForce:function(t){return new box2D.common.math.B2Vec2(t*this.m_impulse.x,t*this.m_impulse.y)},getReactionTorque:function(t){return t*this.m_impulse.z},initVelocityConstraints:function(t){var o,i,s=this.m_bodyA,n=this.m_bodyB;o=s.m_xf.R;var e=this.m_localAnchorA.x-s.m_sweep.localCenter.x,m=this.m_localAnchorA.y-s.m_sweep.localCenter.y;i=o.col1.x*e+o.col2.x*m,m=o.col1.y*e+o.col2.y*m,e=i,o=n.m_xf.R;var a=this.m_localAnchorB.x-n.m_sweep.localCenter.x,c=this.m_localAnchorB.y-n.m_sweep.localCenter.y;i=o.col1.x*a+o.col2.x*c,c=o.col1.y*a+o.col2.y*c,a=i;var l=s.m_invMass,r=n.m_invMass,_=s.m_invI,h=n.m_invI;this.m_mass.col1.x=l+r+m*m*_+c*c*h,this.m_mass.col2.x=-m*e*_-c*a*h,this.m_mass.col3.x=-m*_-c*h,this.m_mass.col1.y=this.m_mass.col2.x,this.m_mass.col2.y=l+r+e*e*_+a*a*h,this.m_mass.col3.y=e*_+a*h,this.m_mass.col1.z=this.m_mass.col3.x,this.m_mass.col2.z=this.m_mass.col3.y,this.m_mass.col3.z=_+h,t.warmStarting?(this.m_impulse.x*=t.dtRatio,this.m_impulse.y*=t.dtRatio,this.m_impulse.z*=t.dtRatio,s.m_linearVelocity.x-=l*this.m_impulse.x,s.m_linearVelocity.y-=l*this.m_impulse.y,s.m_angularVelocity-=_*(e*this.m_impulse.y-m*this.m_impulse.x+this.m_impulse.z),n.m_linearVelocity.x+=r*this.m_impulse.x,n.m_linearVelocity.y+=r*this.m_impulse.y,n.m_angularVelocity+=h*(a*this.m_impulse.y-c*this.m_impulse.x+this.m_impulse.z)):this.m_impulse.setZero()},solveVelocityConstraints:function(){var t,o,i=this.m_bodyA,s=this.m_bodyB,n=i.m_linearVelocity,e=i.m_angularVelocity,m=s.m_linearVelocity,a=s.m_angularVelocity,c=i.m_invMass,l=s.m_invMass,r=i.m_invI,_=s.m_invI;t=i.m_xf.R;var h=this.m_localAnchorA.x-i.m_sweep.localCenter.x,x=this.m_localAnchorA.y-i.m_sweep.localCenter.y;o=t.col1.x*h+t.col2.x*x,x=t.col1.y*h+t.col2.y*x,h=o,t=s.m_xf.R;var y=this.m_localAnchorB.x-s.m_sweep.localCenter.x,u=this.m_localAnchorB.y-s.m_sweep.localCenter.y;o=t.col1.x*y+t.col2.x*u,u=t.col1.y*y+t.col2.y*u,y=o;var p=m.x-a*u-n.x+e*x,d=m.y+a*y-n.y-e*h,B=a-e,b=new box2D.common.math.B2Vec3;this.m_mass.solve33(b,-p,-d,-B),this.m_impulse.add(b),n.x-=c*b.x,n.y-=c*b.y,e-=r*(h*b.y-x*b.x+b.z),m.x+=l*b.x,m.y+=l*b.y,a+=_*(y*b.y-u*b.x+b.z),i.m_angularVelocity=e,s.m_angularVelocity=a},solvePositionConstraints:function(){var t,o,i=this.m_bodyA,s=this.m_bodyB;t=i.m_xf.R;var n=this.m_localAnchorA.x-i.m_sweep.localCenter.x,e=this.m_localAnchorA.y-i.m_sweep.localCenter.y;o=t.col1.x*n+t.col2.x*e,e=t.col1.y*n+t.col2.y*e,n=o,t=s.m_xf.R;var m=this.m_localAnchorB.x-s.m_sweep.localCenter.x,a=this.m_localAnchorB.y-s.m_sweep.localCenter.y;o=t.col1.x*m+t.col2.x*a,a=t.col1.y*m+t.col2.y*a,m=o;var c=i.m_invMass,l=s.m_invMass,r=i.m_invI,_=s.m_invI,h=s.m_sweep.c.x+m-i.m_sweep.c.x-n,x=s.m_sweep.c.y+a-i.m_sweep.c.y-e,y=s.m_sweep.a-i.m_sweep.a-this.m_referenceAngle,u=10*box2D.common.B2Settings.b2_linearSlop,p=Math.sqrt(h*h+x*x),d=box2D.common.math.B2Math.abs(y);p>u&&(r*=1,_*=1),this.m_mass.col1.x=c+l+e*e*r+a*a*_,this.m_mass.col2.x=-e*n*r-a*m*_,this.m_mass.col3.x=-e*r-a*_,this.m_mass.col1.y=this.m_mass.col2.x,this.m_mass.col2.y=c+l+n*n*r+m*m*_,this.m_mass.col3.y=n*r+m*_,this.m_mass.col1.z=this.m_mass.col3.x,this.m_mass.col2.z=this.m_mass.col3.y,this.m_mass.col3.z=r+_;var B=new box2D.common.math.B2Vec3;return this.m_mass.solve33(B,-h,-x,-y),i.m_sweep.c.x-=c*B.x,i.m_sweep.c.y-=c*B.y,i.m_sweep.a-=r*(n*B.y-e*B.x+B.z),s.m_sweep.c.x+=l*B.x,s.m_sweep.c.y+=l*B.y,s.m_sweep.a+=_*(m*B.y-a*B.x+B.z),i.synchronizeTransform(),s.synchronizeTransform(),p<=box2D.common.B2Settings.b2_linearSlop&&d<=box2D.common.B2Settings.b2_angularSlop},__class__:box2D.dynamics.joints.B2WeldJoint}),box2D.dynamics.joints.B2WeldJointDef=function(){box2D.dynamics.joints.B2JointDef.call(this),this.localAnchorA=new box2D.common.math.B2Vec2,this.localAnchorB=new box2D.common.math.B2Vec2,this.type=box2D.dynamics.joints.B2Joint.e_weldJoint,this.referenceAngle=0},box2D.dynamics.joints.B2WeldJointDef.__name__=!0,box2D.dynamics.joints.B2WeldJointDef.__super__=box2D.dynamics.joints.B2JointDef,box2D.dynamics.joints.B2WeldJointDef.prototype=$extend(box2D.dynamics.joints.B2JointDef.prototype,{initialize:function(t,o,i){this.bodyA=t,this.bodyB=o,this.localAnchorA.setV(this.bodyA.getLocalPoint(i)),this.localAnchorB.setV(this.bodyB.getLocalPoint(i)),this.referenceAngle=this.bodyB.getAngle()-this.bodyA.getAngle()},__class__:box2D.dynamics.joints.B2WeldJointDef}); | 31,805.142857 | 32,189 | 0.77938 |
27b39a482a2665ebdd47e18108c15127e2e79859 | 67 | js | JavaScript | src/data/cs/quote.js | azangru/typographer | 7d1d277b979ce2d5db5a9b47f51e2acf0afe0451 | [
"MIT"
] | null | null | null | src/data/cs/quote.js | azangru/typographer | 7d1d277b979ce2d5db5a9b47f51e2acf0afe0451 | [
"MIT"
] | null | null | null | src/data/cs/quote.js | azangru/typographer | 7d1d277b979ce2d5db5a9b47f51e2acf0afe0451 | [
"MIT"
] | null | null | null | Typograf.setData('cs/quote', {
left: '„‚',
right: '“‘'
});
| 13.4 | 30 | 0.462687 |
27b5eb9b51ed8094d13769e1c56910765c5a522a | 2,439 | js | JavaScript | codetmp/require/lsdb.js | FalconSage/SageType | fc71ca8d7955b5dd3cf343277dee4f8924359244 | [
"MIT"
] | 1 | 2022-03-10T23:46:07.000Z | 2022-03-10T23:46:07.000Z | codetmp/require/lsdb.js | FalconSage/SageType | fc71ca8d7955b5dd3cf343277dee4f8924359244 | [
"MIT"
] | null | null | null | codetmp/require/lsdb.js | FalconSage/SageType | fc71ca8d7955b5dd3cf343277dee4f8924359244 | [
"MIT"
] | null | null | null | /*
0.1 : 13 March 2021 -- prevent deletetion of dynamic object props
*/
(function () {
const lsdb = function(storageName, rootObject) {
this.root = JSON.parse(JSON.stringify(rootObject));
this.storageName = storageName;
this.data = JSON.parse(getStorageData(this.storageName, null));
// delete of update storage keys value according to rootObject
this.deepCheck(this.data, rootObject.root, true);
};
lsdb.prototype.deepCheck = function(data, root, firstDive) {
if (data === null) {
this.data = JSON.parse(JSON.stringify(this.root.root));
} else {
for (const i in data) {
if (root[i] === undefined)
delete data[i];
}
for (const i in root) {
if (data[i] === undefined)
data[i] = root[i];
}
for (const i in data) {
if (Array.isArray(data[i])) {
for (let j = 0; j < data[i].length; j++) {
if (typeof(data[i][j]) === 'object' && !Array.isArray(data[i][j])) {
if (this.root[i] !== undefined)
this.deepCheck(data[i][j], this.root[i]);
}
}
} else {
if (!(data[i] === null || data[i] === undefined) && typeof(data[i]) === 'object' && !Array.isArray(data[i])) {
if (firstDive) {
if (Object.keys(this.root.root[i]).length > 0) {
this.deepCheck(data[i], this.root.root[i], false);
}
} else {
if (Object.keys(root[i]).length > 0)
this.deepCheck(data[i], root[i], firstDive);
}
}
}
}
}
};
lsdb.prototype.save = function() {
window.localStorage.setItem(this.storageName, JSON.stringify(this.data));
};
lsdb.prototype.reset = function() {
window.localStorage.removeItem(this.storageName);
this.data = JSON.parse(JSON.stringify(this.root.root));
};
lsdb.prototype.new = function(keyName, values) {
const data = JSON.parse(JSON.stringify(this.root[keyName]));
for (const i in values)
data[i] = values[i];
return data;
};
function getStorageData(name, defaultValue) {
return (!window.localStorage.getItem(name)) ? defaultValue : window.localStorage.getItem(name);
}
if (window.lsdb === undefined)
window.lsdb = lsdb;
else
console.error('lsdb.js:', 'Failed to initialize. Duplicate variable exists.');
})(); | 30.873418 | 120 | 0.558426 |
27b5edee61e61f4e1c25cb7e342a92cc1c1d30cc | 3,885 | js | JavaScript | lib/utils/dir-cache.js | xpack/xmake-js | fe85428e05276836dbf67103d3f59342139cf145 | [
"MIT"
] | 2 | 2018-01-16T16:09:23.000Z | 2019-01-20T00:17:52.000Z | lib/utils/dir-cache.js | xpack/xmake-js | fe85428e05276836dbf67103d3f59342139cf145 | [
"MIT"
] | 5 | 2018-04-17T12:59:03.000Z | 2021-08-31T16:25:36.000Z | lib/utils/dir-cache.js | xpack/xmake-js | fe85428e05276836dbf67103d3f59342139cf145 | [
"MIT"
] | 1 | 2018-11-06T12:43:55.000Z | 2018-11-06T12:43:55.000Z | /*
* This file is part of the xPack distribution
* (http://xpack.github.io).
* Copyright (c) 2018 Liviu Ionescu.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
'use strict'
/* eslint valid-jsdoc: "error" */
/* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */
const fs = require('fs')
const path = require('path')
const Promisifier = require('@ilg/es6-promisifier').Promisifier
// ----------------------------------------------------------------------------
// Promisify functions from the Node.js callbacks library.
// New functions have similar names, but suffixed with `Promise`.
Promisifier.promisifyInPlace(fs, 'readdir')
Promisifier.promisifyInPlace(fs, 'stat')
// For easy migration, inspire from the Node 10 experimental API.
// Do not use `fs.promises` yet, to avoid the warning.
const fsPromises = fs.promises_
// ============================================================================
/**
* @typedef {Object} CachedDir
* @property {String} name Folder or file name.
* @property {Stat} stat Result of stat() for the file or folder.
*/
class DirCache {
/**
* @summary Get the list of files in a folder.
*
* @static
* @async
* @param {String} folderAbsolutePath Folder path.
* @returns {CachedDir[]} Array of objects with a `name` property.
* @throws Error 'ENOENT: no such file'
*
* @description
* This function keeps a cache of directories, indexed by paths.
* In case of errors, an exception may be thrown.
* The returned names do not include `.` and `..`.
*
* Note: the array uses objects instead of strings to provide a place
* to cache other properties, like dates.
*/
static async readdir (folderAbsolutePath) {
const Self = this
if (!Self.cache) {
Self.cache = {}
}
if (Self.cache.hasOwnProperty(folderAbsolutePath)) {
return Self.cache[folderAbsolutePath]
}
const names = await fsPromises.readdir(folderAbsolutePath)
// Turn string names into objects with a `name` property.
const files = []
for (const name of names) {
// Not exactly accurate, since it may be a folder too.
const file = {}
file.name = name
const fileAbsolutePath = path.join(folderAbsolutePath, name)
file.stat = await fsPromises.stat(fileAbsolutePath)
files.push(file)
}
Self.cache[folderAbsolutePath] = files
return files
}
}
// ----------------------------------------------------------------------------
// Node.js specific export definitions.
// By default, `module.exports = {}`.
// The class is added as a property of this object.
module.exports.DirCache = DirCache
// In ES6, it would be:
// export class DirCache { ... }
// ...
// import { DirCache } from '../utils/dir-cache.js'
// ----------------------------------------------------------------------------
| 33.782609 | 79 | 0.63964 |
27b68463f53f3ec11c000e909e279c1fdec20d51 | 4,577 | js | JavaScript | Lpp.Dns.Portal/Scripts/Knockout-Bootstrap/knockout-bootstrap.min.js | Missouri-BMI/popmednet | f185092be45187f3db4966f67066e89bae30c4d6 | [
"Apache-2.0"
] | 9 | 2017-07-10T19:59:55.000Z | 2021-03-08T18:52:11.000Z | Lpp.Dns.Portal/Scripts/Knockout-Bootstrap/knockout-bootstrap.min.js | Missouri-BMI/popmednet | f185092be45187f3db4966f67066e89bae30c4d6 | [
"Apache-2.0"
] | 31 | 2020-02-10T14:28:39.000Z | 2022-03-08T19:01:39.000Z | Lpp.Dns.Portal/Scripts/Knockout-Bootstrap/knockout-bootstrap.min.js | Missouri-BMI/popmednet | f185092be45187f3db4966f67066e89bae30c4d6 | [
"Apache-2.0"
] | 16 | 2017-07-28T16:15:28.000Z | 2022-02-23T16:31:11.000Z | /*! knockout-bootstrap version: 0.3.0
* 2014-11-12
* Author: Bill Pullen
* Website: http://billpull.github.com/knockout-bootstrap
* MIT License http://www.opensource.org/licenses/mit-license.php
*/
function setupKoBootstrap(a,b){"use strict";var c=function(a){return function(){return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()}}(function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)});b.fn.outerHtml||(b.fn.outerHtml=function(){if(0===this.length)return!1;var a=this[0],c=a.tagName.toLowerCase();if(a.outerHTML)return a.outerHTML;var d=b.map(a.attributes,function(a){return a.name+'="'+a.value+'"'});return"<"+c+(d.length>0?" "+d.join(" "):"")+">"+a.innerHTML+"</"+c+">"}),a.bindingHandlers.typeahead={init:function(c,d,e){var f=b(c),g=e(),h={source:a.utils.unwrapObservable(d())};g.typeaheadOptions&&b.each(g.typeaheadOptions,function(b,c){h[b]=a.utils.unwrapObservable(c)}),f.attr("autocomplete","off").typeahead(h)}},a.bindingHandlers.progress={init:function(d,e,f,g){var h=b(d),i=b("<div/>",{"class":"bar","data-bind":"style: { width:"+e()+" }"});h.attr("id",c()).addClass("progress progress-info").append(i),a.applyBindingsToDescendants(g,h[0])}},a.bindingHandlers.alert={init:function(c,d){var e=b(c),f=a.utils.unwrapObservable(d()),g=b("<button/>",{type:"button","class":"close","data-dismiss":"alert"}).html("×"),h=b("<p/>").html(f.message);e.addClass("alert alert-"+f.priority).append(g).append(h)}},a.bindingHandlers.tooltip={update:function(c,d){var e,f,g;if(f=a.utils.unwrapObservable(d()),e=b(c),a.isObservable(f.title)){var h=!1;e.on("show.bs.tooltip",function(){h=!0}),e.on("hide.bs.tooltip",function(){h=!1});var i=f.animation||!0;f.title.subscribe(function(){h&&(e.data("bs.tooltip").options.animation=!1,e.tooltip("fixTitle").tooltip("show"),e.data("bs.tooltip").options.animation=i)})}g=e.data("bs.tooltip"),g?b.extend(g.options,f):e.tooltip(f)}},a.bindingHandlers.popover={init:function(d,e,f,g,h){var i=b(d),j=a.utils.unwrapObservable(e()),k={};j.title?k.title=j.title:k.template='<div class="popover" role="tooltip"><div class="arrow"></div><div class="popover-content"></div></div>',j.placement&&(k.placement=j.placement),j.container&&(k.container=j.container),j.delay&&(k.delay=j.delay);var l,m=c(),n="ko-bs-popover-"+m,o="";if(j.template){var p=j.template,q=j.data;o=q?function(){var c=b('<div data-bind="template: { name: template, if: data, data: data }"></div>');return a.applyBindings({template:p,data:q},c[0]),c}:b("#"+p).html(),l=b("<div/>",{"class":"ko-popover",id:n}).html(o)}else j.dataContent&&(o=j.dataContent),l=b("<div/>",{"class":"ko-popover",id:n}).html(o);var r=h.createChildContext(g);k.content=b(l[0]).outerHtml();var s=b.extend({},a.bindingHandlers.popover.options,k);if(s.addCloseButtonToTitle){var t=s.closeButtonHtml;void 0===t&&(t=" × "),void 0===s.title&&(s.title=" ");var u=s.title,v=' <button type="button" class="close" data-dismiss="popover">'+t+"</button>";s.title=u+v}var w="";if(j.trigger)for(var x=j.trigger.split(" "),y=0;y<x.length;y++){var z=x[y];"manual"!==z&&(y>0&&(w+=" "),"click"===z?w+="click":"hover"===z?w+="mouseenter mouseleave":"focus"===z&&(w+="focus blur"))}else w="click";var A="";i.on(w,function(c){c.stopPropagation();var e="toggle",f=b(this),g=b("#"+n).is(":visible");if("focus"===A&&"click"===c.type&&g)return void(A=c.type);A=c.type,f.popover(s).popover(e);var h=b("#"+n),i=b(".ko-popover").not(h).parents(".popover");if(i.each(function(){var a=b(this),c=!1,d=a.parent(),e=d.data("bs.popover");if(e&&(c=!0,d.popover("destroy")),!c){var f=b(this).prev(),g=f.data("bs.popover");g&&(c=!0,f.popover("destroy"))}}),!g){a.applyBindingsToDescendants(r,h[0]);var j=b(d).offset().top,k=b(d).offset().left,l=b(d).outerHeight(),m=b(d).outerWidth(),o=b(h).parents(".popover"),p=o.outerHeight(),q=o.outerWidth(),t=10;switch(s.offset&&s.placement){case"left":o.offset({top:Math.max(0,j-p/2+l/2),left:Math.max(0,k-t-q)});break;case"right":o.offset({top:Math.max(0,j-p/2+l/2)});break;case"top":o.offset({top:Math.max(0,j-p-t),left:Math.max(0,k-q/2+m/2)});break;case"bottom":o.offset({top:Math.max(0,j+l+t),left:Math.max(0,k-q/2+m/2)})}var u;u=s.container?b(s.container):f.parent(),u.on("click",'button[data-dismiss="popover"]',function(){f.popover("hide")})}return{controlsDescendantBindings:!0}})},options:{placement:"right",offset:!1,html:!0,addCloseButtonToTitle:!1,trigger:"manual"}}}!function(a){"use strict";"function"==typeof define&&define.amd?define(["require","exports","knockout","jquery"],function(b,c,d,e){a(d,e)}):a(window.ko,jQuery)}(setupKoBootstrap); | 653.857143 | 4,375 | 0.667905 |
27bac749401e1a1677c87837b85ee6dd3e47f13f | 224 | js | JavaScript | vue.config.js | havekes/resume | f2c3c77c1e1f8644ae95a195b5c79f0f7084807b | [
"Apache-2.0"
] | null | null | null | vue.config.js | havekes/resume | f2c3c77c1e1f8644ae95a195b5c79f0f7084807b | [
"Apache-2.0"
] | 2 | 2020-09-20T20:16:04.000Z | 2020-09-20T20:24:51.000Z | vue.config.js | havekes/resume | f2c3c77c1e1f8644ae95a195b5c79f0f7084807b | [
"Apache-2.0"
] | 1 | 2021-03-04T02:47:24.000Z | 2021-03-04T02:47:24.000Z | module.exports = {
css: {
loaderOptions: {
postcss: {
ident: 'postcss',
plugins: [
require('tailwindcss'),
require('autoprefixer')({grid: false})
]
}
}
}
}
| 16 | 48 | 0.450893 |
27bb3f40b7281ae3ad4bedfcae876293faeaab1e | 622 | js | JavaScript | api/models/Department.js | rossjones/cgsd-alpha-prototype | 4df1b71b2df618da094dac33390cb320b2700c1b | [
"MIT"
] | null | null | null | api/models/Department.js | rossjones/cgsd-alpha-prototype | 4df1b71b2df618da094dac33390cb320b2700c1b | [
"MIT"
] | 3 | 2017-07-07T13:40:09.000Z | 2019-06-04T07:09:53.000Z | api/models/Department.js | rossjones/cgsd-alpha-prototype | 4df1b71b2df618da094dac33390cb320b2700c1b | [
"MIT"
] | 3 | 2017-07-07T10:08:16.000Z | 2021-04-10T19:56:07.000Z | 'use strict'
const Model = require('trails-model')
/**
* @module Department
* @description GovUK department object
*/
module.exports = class Department extends Model {
static config () {
}
static schema () {
return {
friendly_id: {
type: 'string'
},
name: {
type: 'string'
},
description: {
type: 'text'
},
url: {
type: 'string'
},
// associations
agencies: {
collection: 'Agency',
via: 'department'
},
tasks: {
collection: 'Task',
via: 'department'
}
}
}
}
| 15.55 | 49 | 0.487138 |
27bb59e49aaa055af5792d84275db38dc12463cc | 13,904 | js | JavaScript | milliondai-cli/index.js | cfelde/milliondai | d38ce8234733b58a1c96bff46c183fc9747d01e7 | [
"Apache-2.0"
] | 1 | 2021-06-01T21:00:32.000Z | 2021-06-01T21:00:32.000Z | milliondai-cli/index.js | cfelde/milliondai | d38ce8234733b58a1c96bff46c183fc9747d01e7 | [
"Apache-2.0"
] | 1 | 2021-06-01T20:55:37.000Z | 2021-06-01T20:55:37.000Z | milliondai-cli/index.js | cfelde/milliondai | d38ce8234733b58a1c96bff46c183fc9747d01e7 | [
"Apache-2.0"
] | null | null | null | const fs = require('fs');
const fetch = require('node-fetch');
const Web3 = require("web3");
const HDWalletProvider = require("@truffle/hdwallet-provider");
const TruffleContract = require("@truffle/contract");
const BN = require("bn.js");
function parsePixelChainData(value) {
if (value === null || value === undefined) {
return [];
}
const bits = Web3.utils.toBN(value).toString(2).substring(2);
let pixels = bits
.match(/.{3}/g)
.map(bitmap => bitmap
.replace(/1/g, "f")
.replace(/[^f]/g, "0"))
.map(rgb => "#" + rgb)
.slice(0, 100);
while (pixels.length < 100) {
pixels.push("#fff");
}
return pixels;
}
function packagePixels(pixels) {
const bits = "11"
+ pixels
.join("")
.replace(/#/g, "")
.replace(/f/g, "1")
.replace(/[^1]/g, "0")
+ "11";
const bn = new BN(bits, 2);
return Web3.utils.toHex(bn);
}
async function getMDContractJson(config) {
return await fetch(config.millionDaiJsonURL || "https://milliondai.website/_contract/MillionDai.json").then(r => r.json());
}
async function getMDTContractJson(config) {
return await fetch(config.millionDaiTokenJsonURL || "https://milliondai.website/_contract/MillionDaiToken.json").then(r => r.json());
}
async function getDaiContractJson(config) {
return await fetch(config.daiJsonURL || "https://milliondai.website/_contract/IERC20.json").then(r => r.json());
}
async function getProvider(config) {
if (config.accountKey && config.accountKey !== "") {
return new HDWalletProvider(config.accountKey, config.web3url || "http://localhost:8545")
} else {
return new Web3.providers.HttpProvider(config.web3url || "http://localhost:8545");
}
}
async function getContract(address, json, provider) {
const contract = TruffleContract(json);
contract.setProvider(provider);
contract.defaults({
from: address,
//gas: 3000000,
gasPrice: Web3.utils.toWei("5", "gwei")
});
return contract.deployed();
}
async function getChainData(millionDaiContract, tileId) {
return await millionDaiContract.get(tileId);
}
function getTileId(offset) {
return new BN("57896044618658097711785492504343953926634992332820282019728792003956564819967").add(new BN(offset));
}
function getTileOffset(tileId) {
return new BN(tileId.substring(2), 16).sub(new BN("57896044618658097711785492504343953926634992332820282019728792003956564819967"));
}
function isData(d) {
return d !== null && d !== undefined
}
function isValidURL(url) {
const pattern = new RegExp("^https?:\\/\\/[^\\s$.?#].[^\\s]*$", "i");
return isData(url) && !!pattern.test(url);
}
async function fetchTransferEvents(contract, fromBlock, toBlock) {
const rawBatch = await contract.getPastEvents("Transfer", {
fromBlock: fromBlock,
toBlock: toBlock
});
return rawBatch.map(e => {
return {
"tile": "0x" + (new BN(e.returnValues.tokenId)).toString(16),
"blockNumber": e.blockNumber,
"transactionIndex": e.transactionIndex,
"logIndex": e.logIndex,
"blockHash": e.blockHash,
"transactionHash": e.transactionHash,
"transferFrom": e.returnValues.from,
"transferTo": e.returnValues.to
}
});
}
async function fetchTileEvents(contract, fromBlock, toBlock) {
const rawBatch = await contract.getPastEvents("Tile", {
fromBlock: fromBlock,
toBlock: toBlock
});
return rawBatch.map(e => {
return {
"tile": "0x" + (new BN(e.returnValues.tile)).toString(16),
"blockNumber": e.blockNumber,
"transactionIndex": e.transactionIndex,
"logIndex": e.logIndex,
"blockHash": e.blockHash,
"transactionHash": e.transactionHash,
"actor": e.returnValues.actor,
"action": e.returnValues.action,
"amount": e.returnValues.amount
}
});
}
async function fetchValueEvents(contract, fromBlock, toBlock) {
const rawBatch = await contract.getPastEvents("Value", {
fromBlock: fromBlock,
toBlock: toBlock
});
return rawBatch.map(e => {
return {
"tile": "0x" + (new BN(e.returnValues.tile)).toString(16),
"blockNumber": e.blockNumber,
"transactionIndex": e.transactionIndex,
"logIndex": e.logIndex,
"blockHash": e.blockHash,
"transactionHash": e.transactionHash,
"actor": e.returnValues.actor,
"value": e.returnValues.value
}
});
}
async function enrichURIData(blockData) {
// Note: Always returning blank name, desc and url.
// This is because there's not enough safety around
// the below fetch of the uri. Better to just let the
// browsers handle this on a tile by tile basis.
if (true || !isValidURL(blockData.uri)) {
return {
...blockData,
...{
name: "",
description: "",
url: ""
}
};
}
const data = await fetch(blockData.uri).then(r => r.json()).catch(e => {
return {};
});
const validKeys = {
name: true,
description: true,
url: true
};
const metaData = Object
.keys(data)
.filter(k => validKeys[k] && typeof data[k] === "string")
.reduce((acc, k) => {
acc[k] = data[k].substring(0, 1000);
return acc;
}, {
name: "",
description: "",
url: ""
});
return {...blockData, ...metaData}
}
async function fetchUriEvents(contract, fromBlock, toBlock) {
const rawBatch = await contract.getPastEvents("URI", {
fromBlock: fromBlock,
toBlock: toBlock
});
return Promise.all(rawBatch.map(e => {
const blockData = {
"tile": "0x" + (new BN(e.returnValues.tile)).toString(16),
"blockNumber": e.blockNumber,
"transactionIndex": e.transactionIndex,
"logIndex": e.logIndex,
"blockHash": e.blockHash,
"transactionHash": e.transactionHash,
"actor": e.returnValues.actor,
"uri": e.returnValues.uri
};
return enrichURIData(blockData);
}));
}
async function fetchVoteEvents(contract, fromBlock, toBlock) {
const rawBatch = await contract.getPastEvents("Vote", {
fromBlock: fromBlock,
toBlock: toBlock
});
return rawBatch.map(e => {
return {
"tile": "0x" + (new BN(e.returnValues.tile)).toString(16),
"blockNumber": e.blockNumber,
"transactionIndex": e.transactionIndex,
"logIndex": e.logIndex,
"blockHash": e.blockHash,
"transactionHash": e.transactionHash,
"actor": e.returnValues.actor,
}
});
}
async function events(millionDaiContract, millionDaiTokenContract, firstBlockNumber, lastBlockNumber) {
if (lastBlockNumber < firstBlockNumber) {
console.log("No new blocks to check..");
process.exit(1);
}
console.log("Looking for events in block range " + firstBlockNumber + " to " + lastBlockNumber);
const transferEvents = [];
const tileEvents = [];
const valueEvents = [];
const uriEvents = [];
const voteEvents = [];
const blockBatchSize = 1000;
let blockMax = firstBlockNumber;
for (let blockMin = firstBlockNumber; blockMin <= lastBlockNumber; blockMin += blockBatchSize) {
blockMax = Math.min(blockMin + blockBatchSize - 1, lastBlockNumber);
console.log("Fetching event batch within blocks: " + blockMin + " and " + blockMax);
transferEvents.push(...await fetchTransferEvents(millionDaiTokenContract, blockMin, blockMax));
tileEvents.push(...await fetchTileEvents(millionDaiContract, blockMin, blockMax));
valueEvents.push(...await fetchValueEvents(millionDaiContract, blockMin, blockMax));
uriEvents.push(...await fetchUriEvents(millionDaiContract, blockMin, blockMax));
voteEvents.push(...await fetchVoteEvents(millionDaiContract, blockMin, blockMax));
}
console.log("Have " + transferEvents.length + " transfer events");
console.log(JSON.stringify(transferEvents));
console.log();
console.log("Have " + tileEvents.length + " tile events");
console.log(JSON.stringify(tileEvents));
console.log();
console.log("Have " + valueEvents.length + " value events");
console.log(JSON.stringify(valueEvents));
console.log();
console.log("Have " + uriEvents.length + " URI events");
console.log(JSON.stringify(uriEvents));
console.log();
console.log("Have " + voteEvents.length + " vote events");
console.log(JSON.stringify(uriEvents));
}
async function getTile(millionDaiContract, tileOffset) {
const tileId = getTileId(tileOffset);
const rawTileData = await getChainData(millionDaiContract, tileId);
const value = rawTileData["value"];
const uri = rawTileData["uri"];
const price = Web3.utils.fromWei(rawTileData["price"]);
const minNewPrice = Web3.utils.fromWei(rawTileData["minNewPrice"]);
const owner = rawTileData["owner"];
const blockNumber = rawTileData["blockNumber"].toString(10);
const tileData = {
"value": value,
"pixels": parsePixelChainData(value),
"uri": uri,
"price": price,
"minNewPrice": minNewPrice,
"owner": owner,
"blockNumber": blockNumber
}
return tileData;
}
async function ensureDaiAllowance(account, millionDaiContract, daiContract, amount) {
let allowance = await daiContract.allowance(account, millionDaiContract.address);
if (allowance.gte(amount)) {
return;
}
let newAllowance = Web3.utils.toBN("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
await daiContract.approve(millionDaiContract.address, newAllowance);
}
async function setTile(account, millionDaiContract, daiContract, input) {
for (let i = 0; i < input.length; i++) {
const tile = input[i];
const tileOffset = tile.tileOffset;
const tileId = getTileId(tileOffset);
console.log("Doing set-tile on: " + tileOffset);
const tileData = await getTile(millionDaiContract, tileOffset);
const price = new BN(tile.price);
const minNewPrice = new BN(tileData.minNewPrice);
if (price.lt(minNewPrice)) {
console.log("Skipping tile " + tileOffset + " due to insufficient price, require " + minNewPrice);
continue;
}
await ensureDaiAllowance(account, millionDaiContract, daiContract, price);
console.log("Doing tile enter: " + tileId + ", " + Web3.utils.toWei(price));
await millionDaiContract.enter(tileId, Web3.utils.toWei(price));
const uri = tile.uri;
const pixels = tile.pixels;
if (uri && pixels) {
console.log("Doing tile set..");
await millionDaiContract.set(tileId, packagePixels(pixels), uri);
} else if (pixels) {
console.log("Doing tile setTileValue..");
await millionDaiContract.setTileValue(tileId, packagePixels(pixels));
} else if (uri) {
console.log("Doing tile setTileURI..");
await millionDaiContract.setTileURI(tileId, uri);
}
const buyAndHold = tile.buyAndHold;
if (!buyAndHold) {
console.log("Doing tile exit..");
await millionDaiContract.exit(tileId);
}
console.log("Done with tile " + tileOffset);
}
}
async function main() {
const config = JSON.parse(fs.readFileSync(process.argv[2]).toString());
const command = process.argv[3];
const provider = await getProvider(config);
const web3 = new Web3(provider);
const accounts = await web3.eth.getAccounts();
const account = accounts[0];
if (account === undefined || account === null) {
console.warn("Running without an account..");
} else {
console.log("Using account " + account);
web3.eth.defaultAccount = account;
}
const millionDaiJson = await getMDContractJson(config);
const millionDaiTokenJson = await getMDTContractJson(config);
const daiJson = await getDaiContractJson(config);
const millionDaiContract = await getContract(account, millionDaiJson, provider);
const millionDaiTokenContract = await getContract(account, millionDaiTokenJson, provider);
const daiContract = await getContract(account, daiJson, provider);
// Available commands
// events [from block] [to block]
// get-tile [tile offset]
// set-tile [set tile json]
switch (command) {
case "events":
const fromBlock = parseInt(process.argv[4]);
const toBlock = parseInt(process.argv[5]);
await events(millionDaiContract, millionDaiTokenContract, fromBlock, toBlock);
break;
case "get-tile":
const tileOffset = parseInt(process.argv[4]);
const tileId = getTileId(tileOffset);
console.log("Getting tile data on tile offset " + tileOffset + " / tile id " + tileId);
const tileData = await getTile(millionDaiContract, tileOffset);
console.log(JSON.stringify(tileData));
break;
case "set-tile":
const input = JSON.parse(fs.readFileSync(process.argv[4]).toString());
await setTile(account, millionDaiContract, daiContract, input);
break;
default:
console.error("No support for command: " + command);
}
}
main().catch(e => console.error(e)).finally(() => process.exit(0));
| 33.104762 | 137 | 0.618311 |
27bbcb4d3d056771a7270a785fbe9dd75df8503a | 693 | js | JavaScript | example/react/src/components/Navigation/index.js | antoineaudrain/react-editorjs-renderer | f7081b094804bbfdf7800270e88441187d678341 | [
"MIT"
] | 7 | 2020-10-21T08:50:47.000Z | 2021-09-22T18:32:33.000Z | example/react/src/components/Navigation/index.js | antoineaudrain/react-editorjs-renderer | f7081b094804bbfdf7800270e88441187d678341 | [
"MIT"
] | 1 | 2020-11-26T19:16:58.000Z | 2020-11-29T13:01:39.000Z | example/react/src/components/Navigation/index.js | antoineaudrain/react-editorjs-renderer | f7081b094804bbfdf7800270e88441187d678341 | [
"MIT"
] | 3 | 2020-10-21T12:52:11.000Z | 2021-10-02T00:16:31.000Z | import React from 'react';
import './index.css';
function Navigation() {
const routes = [
{
title: 'Github',
url: 'https://github.com/antoineaudrain/react-editorjs-renderer',
},
]
return (
<nav className="sticky-header">
<header className="docs-header">
<a href="/" className="docs-header__logo">
React Editor.js Renderer
</a>
<ul className="docs-header__menu">
{routes.map(({title, url}, index) => (
<li key={index}>
<a href={url}>
{title}
</a>
</li>
))}
</ul>
</header>
</nav>
);
}
export default Navigation;
| 20.382353 | 71 | 0.493506 |
27bc6f094a44230a715f977a593cf85140372b22 | 369 | js | JavaScript | src/components/atoms/icons/chevron-down.js | MostafaRostami72/react-selection-box | 035f514281079c9510ecbd35661b7007699d9d8a | [
"MIT"
] | null | null | null | src/components/atoms/icons/chevron-down.js | MostafaRostami72/react-selection-box | 035f514281079c9510ecbd35661b7007699d9d8a | [
"MIT"
] | null | null | null | src/components/atoms/icons/chevron-down.js | MostafaRostami72/react-selection-box | 035f514281079c9510ecbd35661b7007699d9d8a | [
"MIT"
] | null | null | null | import React from 'react';
const ChevronDownIcon = () => {
return (
<svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M19 9l-7 7-7-7" />
</svg>
);
};
export default React.memo(ChevronDownIcon);
| 30.75 | 122 | 0.620596 |
27bcf0fc422e2fa1d67ddc2136eb8e96286a2660 | 4,973 | js | JavaScript | client/components/guestOrderProducts.js | COD-Grace-Shopper-Fish-Store/COD-Shopper | b2aec18b013158647cb4f71624a54ca93c6b0c30 | [
"MIT"
] | null | null | null | client/components/guestOrderProducts.js | COD-Grace-Shopper-Fish-Store/COD-Shopper | b2aec18b013158647cb4f71624a54ca93c6b0c30 | [
"MIT"
] | 30 | 2019-11-04T22:09:30.000Z | 2021-03-09T22:13:24.000Z | client/components/guestOrderProducts.js | COD-Grace-Shopper-Fish-Store/COD-Shopper | b2aec18b013158647cb4f71624a54ca93c6b0c30 | [
"MIT"
] | 4 | 2019-11-04T17:27:39.000Z | 2019-11-11T19:19:40.000Z | import React, {Component} from 'react'
import {connect} from 'react-redux'
import {Link, withRouter} from 'react-router-dom'
import {
updateCart,
getOrderItem,
updateGuestCartAction,
deleteProductFromGuestCartAction,
increaseGuestCartQuantityAction,
decreaseGuestCartQuantityAction
} from '../store'
class GuestOrderProducts extends Component {
constructor(props) {
super(props)
this.state = {
totalPrice: this.props.guestCart.totalPrice,
orderItems: this.props.guestCart.orderItems
}
this.handleSubmit = this.handleSubmit.bind(this)
}
async componentDidMount() {}
handleSubmit(event) {
event.preventDefault()
let order = {
id: this.state.orders[0].id,
totalPrice: this.state.showTotalPrice
}
this.props.updateCart(order)
for (let i = 0; i < this.state.orderItems.length; i++) {
this.props.updateOrderItems(this.state.orderItems[i])
}
}
calcTotalPrice() {
let totalPriceShown = this.props.order[0].products.reduce(
(acc, product) => {
let subtotal = product.price * this.getQuantity(product.id)
return acc + subtotal
},
0
)
this.setState({showTotalPrice: totalPriceShown})
}
getQuantity(productId) {
let quantity = this.props.orderItems
.filter(orderItem => orderItem.productId === productId)
.map(orderItem => orderItem.quantity)[0]
return quantity
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<div>
<h5>Total Price: ${this.props.guestCart.totalPrice / 100} </h5>
<button type="submit" className="save">
Save
</button>
<ul>
{Object.keys(this.props.guestCart.orderItems).map(productId => {
const {product, quantity} = this.props.guestCart.orderItems[
productId
]
return (
<li key={product.id}>
<div className="productItem">
<div className="productImage">
<img
src={`${product.imageUrl}`}
width="128px"
height="128px"
/>
</div>
<div className="productDetails">
<div className="productName">
<Link to={`/products/${product.id}`}>
{product.name}
</Link>
<div>
<button
type="button"
value={product.id}
onClick={() => this.props.deleteProduct(product.id)}
className="deleteButton"
>
Delete
</button>
</div>
</div>
<div className="productQuantity">
<label>Quantity: {quantity}</label>
<input
type="button"
name="decrease"
value="-"
onClick={() =>
this.props.decreaseGuestQuantity(product.id)
}
/>
<button
type="button"
name="increase"
value={product.id}
onClick={() =>
this.props.increaseGuestQuantity(product.id)
}
>
+
</button>
</div>
</div>
<div className="productPrice">
<label>Product Price </label>
<h5>${product.price / 100}</h5>
<label>Subtotal: </label>
<h5>${product.price * quantity / 100}</h5>
</div>
</div>
</li>
)
})}
</ul>
</div>
</form>
)
}
}
const mapStateToProps = state => {
return {
guestCart: state.guestCart
}
}
const mapDispatchToProps = dispatch => ({
updateCart: state => dispatch(updateCart(state)),
getOrderItem: id => dispatch(getOrderItem(id)),
updateGuestCart: state => dispatch(updateGuestCartAction(state)),
increaseGuestQuantity: productId =>
dispatch(increaseGuestCartQuantityAction(productId)),
decreaseGuestQuantity: productId =>
dispatch(decreaseGuestCartQuantityAction(productId)),
deleteProduct: productId =>
dispatch(deleteProductFromGuestCartAction(productId))
})
const ConnectedOrderProducts = connect(mapStateToProps, mapDispatchToProps)(
GuestOrderProducts
)
export default withRouter(ConnectedOrderProducts)
| 32.083871 | 80 | 0.491655 |
27bf428ae2db6f83758b7fe42e888916202ad9be | 436 | js | JavaScript | test/unit/sassu.test.js | yusrilhs/sassu | 735240de2e7e250e72c70e5631409191487e197a | [
"MIT"
] | null | null | null | test/unit/sassu.test.js | yusrilhs/sassu | 735240de2e7e250e72c70e5631409191487e197a | [
"MIT"
] | null | null | null | test/unit/sassu.test.js | yusrilhs/sassu | 735240de2e7e250e72c70e5631409191487e197a | [
"MIT"
] | null | null | null | 'use strict';
const chai = require('chai')
, should = chai.should()
, sassu = require('../../src/sassu');
describe('Test module src/sassu.js', function() {
it('Should have 2 property', function() {
Object.keys(sassu).should.to.have.lengthOf(2);
});
it('Should all property is a function', function() {
sassu.build.should.be.a('function');
sassu.watch.should.be.a('function');
});
});
| 24.222222 | 56 | 0.591743 |
27c0ee0154a3eb020c653ab094f1a548a9fe4113 | 1,310 | js | JavaScript | src/olli/module/ready.js | oliver-eifler/olli.js | ab8f69483efcec76153718e8e68b70ffedf32164 | [
"MIT"
] | null | null | null | src/olli/module/ready.js | oliver-eifler/olli.js | ab8f69483efcec76153718e8e68b70ffedf32164 | [
"MIT"
] | null | null | null | src/olli/module/ready.js | oliver-eifler/olli.js | ab8f69483efcec76153718e8e68b70ffedf32164 | [
"MIT"
] | null | null | null | /**
* Olli Lib
* This file is part of the Olli-Framework
* Copyright (c) 2012-2015 Oliver Jean Eifler
*
* @version 0.0.1
* @link http://www.oliver-eifler.info/
* @author Oliver Jean Eifler <oliver.eifler@gmx.de>
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*
* olli.ready;)
*/
import {isFunction} from "../helper.js";
import Promise from "../polyfills/promise.js";
import {Lib} from "../core.js";
/*
Lib.ready = function(callback) {
if (!isFunction(callback)) throw new OlliError("Olli.ready", arguments);
var doc=this[0].ownerDocument;
if (doc.readyState != 'loading'){
callback(null);
} else {
doc.addEventListener('DOMContentLoaded', callback);
}
};
*/
Lib.ready = (function () {
var promise;
return function () {
var $this = this,
doc = $this[0].ownerDocument;
promise = promise || new Promise(function (resolve, reject) {
DEBUG && console.log("created ready promise");
if (doc.readyState != 'loading') {
ready();
} else {
doc.addEventListener('DOMContentLoaded', ready);
}
function ready() {
resolve($this);
}
});
return promise;
}
})();
| 27.87234 | 74 | 0.565649 |
27c128ccab63b382da12b4d1059ff063b4754fad | 15,844 | js | JavaScript | src/layouts/layout.js | cuongseven137/github-readme-quotes | 45bd1ac4ecb052c103c9fa4a93ebb66ac4a5b446 | [
"MIT"
] | null | null | null | src/layouts/layout.js | cuongseven137/github-readme-quotes | 45bd1ac4ecb052c103c9fa4a93ebb66ac4a5b446 | [
"MIT"
] | null | null | null | src/layouts/layout.js | cuongseven137/github-readme-quotes | 45bd1ac4ecb052c103c9fa4a93ebb66ac4a5b446 | [
"MIT"
] | null | null | null | const layouts = {
default: {
style: (template) => {
return ` * {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.container {
font-family:customFont,Arial,Helvetica,sans-serif;
padding: 40px 20px;
width: 600px;
background: ${template.theme.bg_color};
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 5px;
${template.animation.animation};
}
${template.animation.keyframes}
.container h3 {
font-size: 19px;
margin-bottom: 5px;
font-weight: 500;
font-style: oblique;
color: ${template.theme.quote_color};
}
.container h3::before {
content: open-quote;
font-size: 25px;
}
.container h3::after {
content: close-quote;
vertical-align: sub;
font-size: 25px;
}
.container p {
/* float: right; */
/* margin-right: 20px; */
font-style: italic;
padding: 5px;
text-align: right;
color: ${template.theme.author_color};
}`;
},
structure: (template) => {
return `<div class="container">
<h3> ${template.quote} </h3>
<p>- ${
template.author === "Unknown" ? "Anonymous" : template.author
} </p>
</div>`;
},
},
socrates: {
style: (template) => {
return `.square-brackets-quote {
display:inline-block;
font-family:customFont,Arial,Helvetica,sans-serif;
margin:1em;
width:600px;
${template.animation.animation};
}
${template.animation.keyframes}
.square-brackets-quote blockquote {
background: ${template.theme.bg_color};
color: ${template.theme.quote_color};
display:inline-block;
margin:0;
padding:2em;
position:relative;
font-size:15px;
}
.square-brackets-quote blockquote::before {
--border: ${template.theme.author_color};
position: absolute;
content: "";
top: 0;
bottom: 0;
right: 0;
left: 0;
background-image: linear-gradient(var(--border), var(--border)), linear-gradient(var(--border), var(--border)), linear-gradient(var(--border), var(--border)), linear-gradient(var(--border), var(--border)), linear-gradient(var(--border), var(--border)), linear-gradient(var(--border), var(--border));
background-repeat: no-repeat;
background-size: 3em 1em, 1em 100%, 3em 1em, 3em 1em, 1em 100%, 3em 1em;
background-position: left bottom, left top, left top, right bottom, right top, right top;
}
.square-brackets-quote cite {
color: ${template.theme.author_color};
display: block;
font-size:small;
font-style: normal;
text-align: right;
text-transform:uppercase;
}
* {
position: relative;
z-index: 1;
}
`;
},
structure: (template) => {
return `<div class="square-brackets-quote">
<blockquote>
<p>${template.quote}</p>
<cite>${
template.author === "Unknown"
? "Anonymous"
: template.author
}</cite>
</blockquote>
</div>`;
},
},
churchill: {
style: (template) => {
return `* {
box-sizing: border-box;
}
.main-container {
position: relative;
width: 600px;
margin: 20px 50px 20px 10px;
display: inline-block;
text-align: center;
font-family:customFont,Arial,Helvetica,sans-serif;
color: var(--color);
--color: ${template.theme.quote_color};
--author-color: ${template.theme.author_color};
--border-color: ${template.theme.author_color};
--border-size: 2px;
--bg-color: ${template.theme.bg_color};
--circle-size: 15px;
${template.animation.animation};
}
${template.animation.keyframes}
.title-container {
position: absolute;
width: 100%;
top: -12px;
z-index: 1;
}
.title-container span {
background: var(--bg-color);
background-size: 600px;
background-repeat: no-repeat;
background-position: center;
color: var(--author-color);
padding: 2px 10px;
font-size: 20px;
}
p {
padding: 15px;
font-size: 17px;
color: var(--color);
}
.quote-container {
padding: 10px;
border: var(--border-size) solid var(--border-color);
background:
radial-gradient(circle at right top, transparent 0px, var(--border-color) 0 calc(var(--circle-size) + var(--border-size)), transparent calc(var(--circle-size) + var(--border-size) + 1px)) right top / 51% 51%,
radial-gradient(circle at left top, transparent 0px, var(--border-color) 0 calc(var(--circle-size) + var(--border-size)), transparent calc(var(--circle-size) + var(--border-size) + 1px)) left top / 51% 51%,
radial-gradient(circle at right bottom, transparent 0px, var(--border-color) 0 calc(var(--circle-size) + var(--border-size)), transparent calc(var(--circle-size) + var(--border-size) + 1px)) right bottom / 51% 51%,
radial-gradient(circle at left bottom, transparent 0px, var(--border-color) 0 calc(var(--circle-size) + var(--border-size)), transparent calc(var(--circle-size) + var(--border-size) + 1px)) left bottom / 51% 51%,
var(--bg-color);
background-repeat: no-repeat;
background-clip: border-box;
background-origin: border-box;
mask: radial-gradient(
circle at right top,
transparent var(--circle-size),
var(--border-color) calc(var(--circle-size) + 1px)
) right top / 51% 51%,
radial-gradient(
circle at left top,
transparent var(--circle-size),
var(--border-color) calc(var(--circle-size) + 1px)
) left top / 51% 51%,
radial-gradient(
circle at right bottom,
transparent var(--circle-size),
var(--border-color) calc(var(--circle-size) + 1px)
) right bottom / 51% 51%,
radial-gradient(
circle at left bottom,
transparent var(--circle-size),
var(--border-color) calc(var(--circle-size) + 1px)
) left bottom / 51% 51%;
-webkit-mask: radial-gradient(
circle at right top,
transparent var(--circle-size),
var(--border-color) calc(var(--circle-size) + 1px)
) right top / 51% 51%,
radial-gradient(
circle at left top,
transparent var(--circle-size),
var(--border-color) calc(var(--circle-size) + 1px)
) left top / 51% 51%,
radial-gradient(
circle at right bottom,
transparent var(--circle-size),
var(--border-color) calc(var(--circle-size) + 1px)
) right bottom / 51% 51%,
radial-gradient(
circle at left bottom,
transparent var(--circle-size),
var(--border-color) calc(var(--circle-size) + 1px)
) left bottom / 51% 51%;
mask-repeat: no-repeat;
-webkit-mask-repeat: no-repeat;
}`;
},
structure: (template) => {
return `<div class="main-container">
<div class="title-container">
<span>${
template.author === "Unknown"
? "Anonymous"
: template.author
}</span>
</div>
<div class="quote-container">
<blockquote>
<p><i>
${template.quote}
</i></p>
</blockquote>
</div>
</div>`;
},
},
samuel: {
style: (template) => {
return `.main {
position: relative;
display: inline-block;
margin: 1em;
width:600px;
font-family:customFont,Arial,Helvetica,sans-serif;
position: relative;
${template.animation.animation};
}
${template.animation.keyframes}
.quote {
background: ${template.theme.bg_color};
font-size:16px;
}
.quote::before {
content: "";
position: absolute;
top: -6px;
left: -6px;
z-index: -1;
width: calc(100% + 12px);
height: calc(100% + 12px);
background: ${template.theme.author_color};
--border-size: 6px;
clip-path: polygon(0% 0%, 96% 0, 97% var(--border-size), calc(100% - var(--border-size)) var(--border-size), calc(100% - var(--border-size)) 18%, 100% 25%, 100% 100%, 87% 100%, 0 100%, 0 75%, var(--border-size) 82%, var(--border-size) calc(100% - var(--border-size)), 3% calc(100% - var(--border-size)), 4% 100%, 60% 100%, 63% calc(100% - var(--border-size)), calc(100% - var(--border-size)) calc(100% - var(--border-size)), calc(100% - var(--border-size)) 52%, 100% 50%, 100% 14%, 100% 0, 40% 0, 37% var(--border-size), var(--border-size) var(--border-size), var(--border-size) 48%, 0 50%);
}
blockquote {
margin: 0;
font-size:16px;
padding: 1em;
color: ${template.theme.quote_color};
}
cite {
display: block;
font-style: italic;
text-align: right;
color: ${template.theme.author_color};
}
cite::before {
content: "- ";
}
`;
},
structure: (template) => {
return `<div class="main">
<div class="quote">
<blockquote>
<p>${template.quote}</p>
<cite>${
template.author === "Unknown"
? "Anonymous"
: template.author
}</cite>
</blockquote>
</div>
</div>`;
},
},
zues: {
style: (template) => {
return `
.container{
background:#000;
width:550px;
height:auto;
padding:30px 20px 40px 40px;
font-family:customFont,Arial,Helvetica,sans-serif;
${template.animation.animation};
}
${template.animation.keyframes}
.quote4{
background:#000;
color:#fff;
width:450px;
text-align:justify;
border-left: thick double #C08552;
border-right: thick double #C08552;
padding:40px 10px;
position:relative;
transform: skew(-.312rad);
height:auto;
}
.quote4::before, .quote4::after{
position:absolute;
font-size:105px;
background:#000;
display:block;
height:30px;
width:45px;
text-align:center;
color:#DAB49D;
left:0;
right:0;
margin:auto;
z-index:100;
}
.quote4::before{
content:"“";
top:-10px;
line-height:80px;
z-index:1;
}
.quote4::after{
content:"”";
bottom:-25px;
line-height: 70px;
}
.quote4 .first, .quote4 .txt{
width:90%;
margin:auto;
transform: skew(.312rad);
}
.quote4 .first{
margin-top:10px;
width:100%;
color: #DAB49D;
font-size:14px;
text-transform:uppercase;
letter-spacing:1px;
}
.quote4 .txt{
color:#F3E9DC;
font-size:16px;
font-family: 'Roboto Slab', serif;
}
.quote4 .from{
text-align:center;
margin-top:15px;
font-size:13px;
color: #5E3023;
}
.quote4 .border::before, .quote4 .border::after{
content:"";
width:280px;
height:3px;
position:absolute;
display:block;
left:0;
right:0;
margin:auto;
}
.quote4 .border::after{
border-bottom: 2px solid #C08552;
bottom: 0px;
}
.quote4 .border::before{
border-top: 2px solid #C08552;
top:0px;
}`;
},
structure: (template) => {
return `
<div class="container">
<div class="quote4">
<div class="border"></div>
<div class="txt">${template.quote}</div>
<div class="from">${
template.author === "Unknown"
? "Anonymous"
: template.author
}</div>
</div>
</div>
`;
},
},
};
module.exports = layouts;
| 37.545024 | 607 | 0.409429 |
27c221cf3bd29f094a6229dfcb52eadb721baf48 | 5,541 | js | JavaScript | src/button/test/button.spec.js | y8n-test-ci/ci-in-action | bfa3c366d17a07d94d30bc290c91f826cece555d | [
"ISC"
] | 1 | 2016-06-06T07:52:36.000Z | 2016-06-06T07:52:36.000Z | src/button/test/button.spec.js | y8n-test-ci/ci-in-action | bfa3c366d17a07d94d30bc290c91f826cece555d | [
"ISC"
] | null | null | null | src/button/test/button.spec.js | y8n-test-ci/ci-in-action | bfa3c366d17a07d94d30bc290c91f826cece555d | [
"ISC"
] | null | null | null | /**
* fuguButton指令测试文件
* Author: penglu02@meituan.com
* Date: 2016-01-12
*/
describe('fugu-button', function( ){
var compile, scope;
// 加载模块
beforeEach(module('ui.fugu.button'));
beforeEach(module('button/templates/button.html'));
beforeEach(inject(function($compile, $rootScope) {
compile = $compile;
scope = $rootScope.$new();
$rootScope.xSize = "x-small";
}));
describe('Button', function () {
function clickFn(){
scope.disabled = !scope.disabled;
}
function createButton(btnClass, size, block, active, disabled, loading, type) {
btnClass = btnClass ? 'btnClass=' + btnClass : '';
size = size ? ' size=' + size : '';
block = block ? ' block=' + block : '';
active = active ? ' active=' + active : '';
disabled = disabled ? ' disabled=' + disabled : '';
loading = loading ? ' loading=' + loading : '';
type = type ? ' type=' + type : '';
var ele = compile(angular.element('<fugu-button '+ btnClass + size + block + active + disabled + loading + type + '></fugu-button>'))(scope);
scope.$apply();
return ele;
}
it('Should output a button', function() {
var ele = angular.element(createButton()).children()[0],
eleName = ele.nodeName.toLowerCase();
expect(eleName).toEqual('button');
});
it('Should have class="btn btn-default", type=button, button content show "button" by default', function(){
var ele = angular.element(angular.element(createButton()).children()[0]);
// ele必须为angular.element,否则toHaveClass会报错
expect(ele).toHaveClass('btn');
expect(ele).toHaveClass('btn-default');
expect(ele).toHaveAttr('type','button');
});
it('Should show the type if passed one', function(){
var ele = angular.element(angular.element(createButton('','','','','','','reset')).children()[0]);
expect(ele).toHaveAttr('type','reset');
});
it('Should show have btn-XXX class if passed btnClass=XXX', function(){
var ele = createButton('danger','','','','','','').children();
expect(ele).toHaveClass('btn-danger');
});
it('Should show have btn-xs class if passed size=x-small', function(){
var ele = createButton('','xSize','','','','','').children();
expect(ele).toHaveClass('btn-xs');
});
it('Should show have btn-block class if passed block=true', function(){
// TODO 默认的时候应该测试不含btn-block
var ele = createButton('','',true,'','','','').children();
expect(ele).toHaveClass('btn-block');
});
it('Should show have active class if passed active=true', function(){
// TODO 默认的时候应该测试不含active
var ele = createButton('','','',true,'','','').children();
expect(ele).toHaveClass('active');
});
it('Should show icon before button text if passed icon=plus', function(){
var element = compile('<fugu-button icon="plus"></fugu-button>')(scope),
btnEle = null,
iEle = null;
scope.$apply();
btnEle = element.children();
iEle = btnEle.children();
expect(btnEle).toHaveClass('btn-addon');
expect(iEle).toHaveClass('glyphicon-plus');
});
it('should observe the disabled attribute', function () {
var element = compile('<fugu-button disabled="disabled"></fugu-button>')(scope);
scope.$apply();
expect(angular.element(element.children()[0])).not.toHaveAttr('disabled', 'disabled');
scope.$apply('disabled = true');
expect(angular.element(element.children()[0])).toHaveAttr('disabled', 'disabled');
scope.$apply('disabled = false');
expect(angular.element(element.children()[0])).not.toHaveAttr('disabled', 'disabled');
});
it('should observe the loading attribute', function () {
var element = compile('<fugu-button loading="loading"></fugu-button>')(scope),
spanEle = null;
scope.$apply();
spanEle = element.children().children('span.glyphicon-refresh-animate')[0];
// TODO:undefined比较的时候不能使用angular.element.不然会包装成一个对象,传递的undefined不能是字符串不然会报错
expect(typeof spanEle).toEqual('undefined');
scope.$apply('loading = true');
spanEle = element.children().children('span.glyphicon-refresh-animate');
// TODO 如何测试一个元素存在且具有某一属性
expect(spanEle).not.toEqual(null);
expect(spanEle).not.toHaveClass('hidden');
scope.$apply('loading = false');
expect(spanEle).not.toEqual(null);
expect(spanEle).toHaveClass('hidden');
});
it('should call clickFn when set click=clickFn() && execute click event', function () {
var element = compile('<fugu-button click="clickFn()" disabled="disabled"></fugu-button>')(scope);
scope.clickFn = clickFn;
scope.disabled = false;
scope.$apply();
expect(element.children()).not.toHaveAttr('disabled', 'disabled');
element.children().trigger('click');
scope.$apply();
expect(element.children()).toHaveAttr('disabled', 'disabled');
});
});
}); | 43.97619 | 154 | 0.554774 |
27c2467a47ca8767b5134607610f72ffb55d06a0 | 14,194 | js | JavaScript | source/kernel/ArrayController.js | micro-tech/enyo | c350ce1d8903b4cf43e40c9c4109765831cc779d | [
"Apache-2.0"
] | null | null | null | source/kernel/ArrayController.js | micro-tech/enyo | c350ce1d8903b4cf43e40c9c4109765831cc779d | [
"Apache-2.0"
] | null | null | null | source/kernel/ArrayController.js | micro-tech/enyo | c350ce1d8903b4cf43e40c9c4109765831cc779d | [
"Apache-2.0"
] | null | null | null | //*@public
/**
_enyo.ArrayController_ is a kind designed to mimic the behavior and API
of an ECMAScript 5 Array object, with additional functionality specific
to _enyo.Object_. By default, the object will index its values so they
are accessible via the bracket-accessor operators. On large datasets,
we recommend setting the _store_ property to _true_ and only using the
_at_ accessor method. This is not necessary for small-to-medium
datasets.
*/
enyo.kind({
// ...........................
// PUBLIC PROPERTIES
//*@public
name: "enyo.ArrayController",
//*@public
kind: "enyo.Controller",
//*@public
/**
The current length of the array. Setting the length directly
will have undesirable effects.
*/
length: 0,
//*@public
/**
Computed property representing the array structure of the
underlying data. This is an immutable array, as changes will
not modify the array structure of this controller.
*/
data: enyo.computed(function (data) {
if (data) return this.reset(data);
var store = [];
var idx = 0;
var len = this.length;
for (; idx < len; ++idx) store[idx] = this[idx];
return store;
}, "length", {cached: true}),
// ...........................
// PROTECTED PROPERTIES
//*@protected
_init_values: null,
// ...........................
// PUBLIC METHODS
// ...........................
// ECMAScript 5 API METHODS
//*@public
push: function (/* _values_ */) {
var values = arguments;
var pos = this.length;
var num = values.length + pos;
var idx = 0;
var changeset = {};
var prev = this.get("data");
var len = this.length;
if (num) {
for (; pos < num; ++pos, ++idx) {
changeset[pos] = this[pos] = values[idx];
}
this.length = num;
this.notifyObservers("length", len, this.length);
this.dispatchBubble("didadd", {values: changeset}, this);
return this.length;
}
return 0;
},
//*@public
pop: function () {
if (this.length) {
var pos = this.length - 1;
var val = this[pos];
var changeset = {};
// remove the value at that position
delete this[pos];
// reset our length value
this.length = pos;
// set our changeset parameter
changeset[pos] = val;
this.notifyObservers("length", pos + 1, pos);
this.dispatchBubble("didremove", {values: changeset}, this);
return val;
}
},
//*@public
shift: function () {
if (this.length) {
var val = this[0];
var idx = 1;
var len = this.length;
var changeset = {};
// unfortunately, we have to reindex the entire dataset,
// but even for large ones, this is a generic reassignment
// with little overhead
for (; idx < len; ++idx) this[idx-1] = this[idx];
// delete the reference to the previous last element
delete this[len-1];
// update the length
this.length = len - 1;
// set the changeset
changeset[0] = val;
this.notifyObservers("length", len, this.length);
this.dispatchBubble("didremove", {values: changeset}, this);
return val;
}
},
//*@public
unshift: function (/* _values_ */) {
if (arguments.length) {
var len = this.length;
// intially we assign this to the last element's index
var idx = len - 1;
var pos = arguments.length;
var nix = idx + pos;
var changeset = {};
// unfortunately, as with unshift, we have some reindexing
// to do, but regardless of the number of elements we're
// unshifting, we can do this in a single pass. we start
// from the end so we don't have to copy twice for every
// element in the dataset.
for (; nix >= pos; --nix, --idx) this[nix] = this[idx];
// now we start from the beginning since we should have just
// enough space to add these new elements
for (idx = 0; idx < pos; ++idx) {
changeset[idx] = this[idx] = arguments[idx];
}
// update our length
this.length = len + arguments.length;
this.notifyObservers("length", len, this.length);
this.dispatchBubble("didadd", {values: changeset}, this);
return this.length;
}
},
//*@public
indexOf: function (value, pos) {
return enyo.indexOf(value, this.get("data"), pos);
},
//*@public
lastIndexOf: function (value, pos) {
return enyo.lastIndexOf(value, this.get("data"), pos);
},
//*@public
splice: function (index, many /* _values_ */) {
var elements = enyo.toArray(arguments).slice(2);
var elen = elements.length;
var len = this.length;
var max = len - 1;
var ret = [];
var changeset = {added: {len:0}, removed: {len:0}, changed: {len:0}};
var pos = 0;
var idx;
var count;
var range;
var diff;
var num;
index = index < 0? 0: index >= len? len: index;
many = many && !isNaN(many) && many + index <= len? many: 0;
if (many) {
range = index + many - elen;
// special note here about the count variable, the minus one is because
// the index in this operation is included in the many variable amount
for (idx = index, count = index + many - 1 ; idx <= count; ++idx, ++pos) {
ret[pos] = this[idx];
if (elen && elen >= many) {
changeset.changed[idx] = this[idx];
changeset.changed.len++;
} else if (elen && elen < many && idx < range) {
changeset.changed[idx] = this[idx];
changeset.changed.len++;
}
changeset.removed[idx] = this[idx];
changeset.removed.len++;
}
}
if (elen && elen > many) {
diff = elen - many;
pos = max;
for (; pos >= index && pos < len; --pos) this[pos+diff] = this[pos];
this.length += diff;
} else {
diff = many - (elen? elen: 0);
pos = index + many;
for (; pos < len; ++pos) {
this[pos-diff] = this[pos];
changeset.changed[pos-diff] = this[pos-diff];
changeset.changed.len++;
}
idx = this.length -= diff;
for (; idx < len; ++idx) delete this[idx];
}
if (elen) {
pos = 0;
idx = index;
diff = many? many > elen? many - elen: elen - many: 0;
for (; pos < elen; ++idx, ++pos) {
this[idx] = elements[pos];
if (len && idx < len) {
changeset.changed[idx] = this[idx];
changeset.changed.len++;
}
if (!len || (diff && pos >= diff) || !many) {
changeset.added[len+pos-diff] = this[len+pos-diff];
changeset.added.len++;
}
}
}
// we have to update the length if it changed to notify observers/bindings
// to data that it may have been updated or bindings to data will still
// have the cached dataset
if (len !== this.length) this.notifyObservers("length", len, this.length);
if (changeset.removed.len) {
delete changeset.removed.len;
this.dispatchBubble("didremove", {values: changeset.removed}, this);
}
if (changeset.added.len) {
delete changeset.added.len;
this.dispatchBubble("didadd", {values: changeset.added}, this);
}
if (changeset.changed.len) {
delete changeset.changed.len;
this.dispatchBubble("didchange", {values: changeset.changed}, this);
}
return ret;
},
//*@public
join: function (separator) {
this.get("data").join(separator);
},
//*@public
map: function (fn, context) {
return enyo.map(this.get("data"), fn, context);
},
//*@public
filter: function (fn, context) {
return enyo.filter(this.get("data"), fn, context);
},
// ...........................
// CUSTOM API
//*@public
add: function (value, at) {
var value = value && ("length" in value)? value: [value];
var len = this.length;
var idx = at && !isNaN(at) && at >= 0 && at < len? at: len;
var args = [idx, 0].concat(value);
this.splice.apply(this, args);
},
//*@public
remove: function (value, index) {
var changeset;
var idx;
var len;
var start = 0;
if (value instanceof Array) {
changeset = {removed: {}, changed: {}};
idx = 0;
len = value.length;
this.silence();
this.stopNotifications(true);
for (; idx < len; ++idx) {
index = this.indexOf(value[idx]);
if (index < start) start = index;
changeset.removed[idx] = value[idx];
this.remove(value[idx], index);
}
// we need to create the changeset for any indices below
// the lowest index we found
for (idx = start, len = this.length; idx < len; ++idx) {
changeset.changed[idx] = this[idx];
}
this.unsilence();
this.startNotifications(true);
this.dispatchBubble("didremove", {values: changeset.removed}, this);
this.dispatchBubble("didchange", {values: changeset.changed}, this);
} else {
idx = !isNaN(index)? index: this.indexOf(value);
if (!!~idx) this.splice(idx, 1);
}
},
//*@public
reset: function (values) {
this.silence();
this.stopNotifications(true);
if (values) {
this.splice.apply(this, [0, this.length].concat(values));
} else {
this.splice(0, this.length);
}
this.unsilence();
this.startNotifications(true);
this.dispatchBubble("didreset", {values: this}, this);
},
swap: function (index, to) {
var changeset = {};
var from = this[index];
var target = this[to];
changeset[index] = this[index] = target;
changeset[to] = this[to] = from;
this.dispatchBubble("didchange", {values: changeset}, this);
},
//*@public
move: function (index, to) {
var val;
var len = this.length;
var max = len - 1;
// normalize the index to be the min or max
index = index < 0? 0: index >= len? max: index;
// same for the target index
to = to < 0? 0: to >= len? max: to;
// if they are the same, there's nothing to do
if (index === to) return;
// capture the value at index so we can set the new
// index to the appropriate value
val = this[index];
// we need to make sure any operations we do don't
// communicate the changes until we are done
// and because this is a special operation we have our
// own event they must respond to not a global change
// although this will cause the cache to need to
// be updated
this.silence();
this.stopNotifications(true);
// if the index is the top, we don't want to do extra
// calculations or indexing on this step, so just
// pop the value
if (index === max) this.pop();
// unfortunately, we need to splice the value out of the
// dataset before reinserting it at the appropriate spot
else this.splice(index, 1);
// we turn events and notifications back on here so that
// they can produce the final changeset appropriately
this.unsilence();
this.startNotifications(true);
// re-add the value at the correct index
this.splice(to, 0, val);
},
//*@public
contains: function (value) {
return !!~enyo.indexOf(this.get("data"), value)? true: false;
},
//*@public
at: function (index) {
return this[index];
},
//*@public
/**
Detects the presence of value in the array. Accepts an iterator
and an optional context for that iterator to be called under. Will
break and return if the iterator returns a truthy value; otherwise,
it will return false. On a truthy value, it returns the value.
*/
find: function (fn, context) {
var idx = 0;
var len = this.length;
var val;
for (; idx < len; ++idx) {
val = this.at(idx);
if (fn.call(context || this, val)) return val;
}
return false;
},
//*@public
/**
Because the controller cannot detect reassignment to its indices
(e.g., myvar[3] = "touché"), you can do your own custom assignment
and call this method once when you are finished--if the changes
need to be acknowledged in order for notifications and events to
be sent. Otherwise, there is no need to call the method.
There are two ways to call this method--without any parameters, or
with an array (or a hash whose keys will be used as an array) of
the indices that have changed. When called without parameters, it
will search for changed indices against its cached dataset using
direct comparison (or if a _comparator_ method exists on the
controller, it will use the result from that to determine equality).
On larger datasets, this is less than ideal; if possible, keep track
of the indices that have changed and pass them to this method so it
can simply update its cache and notify observers and listeners of
the changes to those indices.
It is important to note that, when using native JavaScript objects,
the reference is shared. If a property on the hash is directly set
and this method is called, it will be impossible to detect changes
since the references in the comparator are the same. If your data is
contained in native objects, it is imperative that you provide the
indices that have changed to this method. The alternative (and
recommended) approach is to use an _enyo.ObjectController_ to proxy
the data of the underlying hash and use that controller's setter and
getter, which will automatically trigger the correct updates when a
property has changed.
*/
changed: function (changed) {
var changeset = {};
var pos = 0;
var len;
var indices;
var idx;
var dataset;
var val;
if (changed) {
if (changed instanceof Array) indices = changed.slice();
else indices = enyo.keys(changed);
} else {
indices = [];
len = this.length;
dataset = this.get("data");
for (; pos < len; ++pos) {
val = dataset[pos];
if (!this.comparator(this[pos], val)) {
changeset[pos] = this[pos];
indices.push(pos);
}
}
}
if (!indices.length) return;
for (len = indices.length; pos < len; ++pos) {
idx = indices[pos];
changeset[idx] = this[idx];
}
this.dispatchBubble("didchange", {values: changeset}, this);
},
//*@public
comparator: function (left, right) {
return left === right;
},
// ...........................
// PROTECTED METHODS
//*@protected
create: function () {
this.inherited(arguments);
// if there were values waiting to be initialized, they couldn't
// have been until now
if (this._init_values) {
this.add.call(this, this._init_values);
this._init_values = null;
}
},
//*@protected
constructor: function () {
this.inherited(arguments);
// if there were any properties passed to the constructor, we
// automatically add them to the array
if (arguments.length) {
var init = [];
var idx = 0;
var len = arguments.length;
for (; idx < len; ++idx) {
if (arguments[idx] instanceof Array) init = init.concat(arguments[idx]);
}
this._init_values = init;
}
}
});
| 29.145791 | 77 | 0.638509 |
27c3e193fa408fb95b0fd0c46b5859ae2c51c537 | 474 | js | JavaScript | lib/cli/commands/db-drop.js | fidemapps/hooko | d1c08314815931f7711d4b513fb854b184908d4f | [
"MIT"
] | null | null | null | lib/cli/commands/db-drop.js | fidemapps/hooko | d1c08314815931f7711d4b513fb854b184908d4f | [
"MIT"
] | null | null | null | lib/cli/commands/db-drop.js | fidemapps/hooko | d1c08314815931f7711d4b513fb854b184908d4f | [
"MIT"
] | null | null | null | module.exports = function () {
var db = require('../../db');
function dropDatabase() {
console.info('Dropping database...');
db.connection.db.dropDatabase(function (err) {
if (err) throw err;
console.info('Database dropped');
db.connection.close();
});
}
// Mongo is connected.
if (db.connection.readyState === 1)
return dropDatabase();
console.info('Waiting for connection...');
db.connection.on('open', dropDatabase);
};
| 23.7 | 50 | 0.622363 |
27c54d4e5bc9ecf1cb0e47815a4292504c5d409d | 744 | js | JavaScript | node_modules/@react-icons/all-files/si/SiAmd.js | syazwanirahimin/dotcom | 162acf4500655ec965d27bd1e45ef0415963d346 | [
"MIT"
] | null | null | null | node_modules/@react-icons/all-files/si/SiAmd.js | syazwanirahimin/dotcom | 162acf4500655ec965d27bd1e45ef0415963d346 | [
"MIT"
] | null | null | null | node_modules/@react-icons/all-files/si/SiAmd.js | syazwanirahimin/dotcom | 162acf4500655ec965d27bd1e45ef0415963d346 | [
"MIT"
] | null | null | null | // THIS FILE IS AUTO GENERATED
var GenIcon = require('../lib').GenIcon
module.exports.SiAmd = function SiAmd (props) {
return GenIcon({"tag":"svg","attr":{"role":"img","viewBox":"0 0 24 24"},"child":[{"tag":"title","attr":{},"child":[]},{"tag":"path","attr":{"d":"M18.324 9.137l1.559 1.56h2.556v2.557L24 14.814V9.137zM2 9.52l-2 4.96h1.309l.37-.982H3.9l.408.982h1.338L3.432 9.52zm4.209 0v4.955h1.238v-3.092l1.338 1.562h.188l1.338-1.556v3.091h1.238V9.52H10.47l-1.592 1.845L7.287 9.52zm6.283 0v4.96h2.057c1.979 0 2.88-1.046 2.88-2.472 0-1.36-.937-2.488-2.747-2.488zm1.237.91h.792c1.17 0 1.63.711 1.63 1.57 0 .728-.372 1.572-1.616 1.572h-.806zm-10.985.273l.791 1.932H2.008zm17.137.307l-1.604 1.603v2.25h2.246l1.604-1.607h-2.246z"}}]})(props);
};
| 124 | 621 | 0.681452 |
27c563040bbf0451893ba211f40028f0a12894a9 | 1,001 | js | JavaScript | sources/WebService/markup/js/basket.js | unterstein/microservice-logging-talk | bc273b4a49d83a8a51f4d065222a22a51d510c61 | [
"Apache-2.0"
] | 4 | 2016-11-08T11:29:03.000Z | 2018-02-05T08:41:34.000Z | sources/WebService/markup/js/basket.js | unterstein/microservices-logging-talk | bc273b4a49d83a8a51f4d065222a22a51d510c61 | [
"Apache-2.0"
] | null | null | null | sources/WebService/markup/js/basket.js | unterstein/microservices-logging-talk | bc273b4a49d83a8a51f4d065222a22a51d510c61 | [
"Apache-2.0"
] | null | null | null | $(function() {
$.get("/basket/", function(data) {
var enrichtedArticles = data.articles.map(function(element) {
var articleName = ko.observable();
var articlePrice = ko.observable();
$.get("/articles/" + element.id, function(article) {
articleName(article.name);
articlePrice(article.price);
});
return {
id: element.id,
quantity: element.quantity,
name: articleName,
price: articlePrice
};
});
ko.applyBindings(ko.mapping.fromJS({articles: enrichtedArticles, sum: ko.pureComputed(function() {
return enrichtedArticles.reduce(function(sum, currentArticle) { return sum + currentArticle.quantity * currentArticle.price();}, 0);
})}));
$(".remove-article").click(function(e) {
var that = this;
$.ajax({
url: "/basket/" + $(that).data("id"),
type: 'DELETE',
success: function(result) {
location.reload();
}
});
});
});
});
| 30.333333 | 138 | 0.575425 |
27c5931864753101bdf75fbcbcc2e43c83bd35a3 | 13,877 | js | JavaScript | MyUSC/CuteSoft_Client/CuteChat/Script/oldmenutreeimpl.js | tlayson/MySC | 2d4b6350d2d34bcc9d20d644cde69dca0d6383ec | [
"Unlicense"
] | null | null | null | MyUSC/CuteSoft_Client/CuteChat/Script/oldmenutreeimpl.js | tlayson/MySC | 2d4b6350d2d34bcc9d20d644cde69dca0d6383ec | [
"Unlicense"
] | null | null | null | MyUSC/CuteSoft_Client/CuteChat/Script/oldmenutreeimpl.js | tlayson/MySC | 2d4b6350d2d34bcc9d20d644cde69dca0d6383ec | [
"Unlicense"
] | null | null | null | /****************************************************************\
Copyright (c) CuteSoft 2005-2006
All rights reserved.
\****************************************************************/
//core.js
/****************************************************************\
*
* Menu Tree Implementation
*
\****************************************************************/
var _menuclass_currentmenu;
var menuimagebase="./";
function CreateOldMenuImplementation()
{
var const_menuwidth=110;
var const_submenudelay=10;
return new MenuClass();
function RemoveObjectMembers(obj)
{
for(var v in obj)
{
obj[v]=null;
}
}
function Menu_ShowFrame(frame,target,offsetX,offsetY)
{
frame.style.visibility='';
var pos=CalcPosition(frame,target);
pos.left+=offsetX;
pos.top+=offsetY;
AdjustMirror(frame,target,pos);
frame.style.left=pos.left+"px";
frame.style.top=pos.top+"px";
frame.style.display='block';
}
function MenuClass_GetCurrentMenu()
{
return _menuclass_currentmenu;
}
function Create_MenuItemDiv_OnMouseOver(menuitem)
{
return MenuItemDiv_OnMouseOver;
function MenuItemDiv_OnMouseOver()
{
var itemdiv=menuitem.itemdiv;
//if(itemdiv.contains(event.fromElement))return;
menuitem.style_backgroundColor=itemdiv.style.backgroundColor;
menuitem.style_border=itemdiv.style.border;
menuitem.style_margin=itemdiv.style.margin;
itemdiv.style.backgroundColor="#B6BDD2";
itemdiv.style.border="1px solid #0A246A";
itemdiv.style.margin="0px";
menuitem.ismouseover=true;
if(menuitem.onmouseover)menuitem.onmouseover(menuitem);
var closenearmenumode=1;
if(closenearmenumode==0)
{
//close now
if(menuitem.owner.openitem)
{
if(menuitem.owner.openitem!=menuitem)
menuitem.owner.openitem.Close();
}
}
menuitem.opentimerid=setTimeout(OpenIt,const_submenudelay);
function OpenIt()
{
if(menuitem.isdisposed)return;
if(!menuitem.owner)return;
if(closenearmenumode==1)
{
//close delay
if(menuitem.owner.openitem)
{
if(menuitem.owner.openitem!=menuitem)
menuitem.owner.openitem.Close();
}
}
if(!menuitem.initialized)
{
if(menuitem.oninitialize)
menuitem.oninitialize(menuitem);
menuitem.initialized=true;
}
if(menuitem.items.length!=0)
{
var f=menuitem.owner.frame;
var pos=GetScrollPostion(f);
var top=GetScrollPostion(itemdiv).top
if(f.nodeName=="IFRAME")
top+=pos.top;
menuitem.Show( (f.ownerDocument||f.document).body,pos.left+itemdiv.offsetWidth,top);
}
}
}
}
function Create_MenuItemDiv_OnMouseOut(menuitem)
{
return Handle_OnMouseOut;
function Handle_OnMouseOut()
{
MenuItemDiv_OnMouseOut(menuitem);
}
}
function MenuItemDiv_OnMouseOut(menuitem)
{
if(!menuitem.ismouseover)return;
menuitem.ismouseover=false;
var itemdiv=menuitem.itemdiv;
clearTimeout(menuitem.opentimerid)
itemdiv.style.backgroundColor=menuitem.style_backgroundColor;
itemdiv.style.border=menuitem.style_border;
itemdiv.style.margin=menuitem.style_margin;
if(menuitem.onmouseout)menuitem.onmouseout(menuitem);
}
function Create_MenuItemDiv_OnClick(menuitem)
{
return MenuItemDiv_OnClick;
function MenuItemDiv_OnClick()
{
var clickfunc=menuitem.onclick;
if(clickfunc)
{
menuitem.menu.HideByClick();
try
{
menuitem.itemdiv.onmouseout();
}
catch(x)
{
}
var timer=setTimeout(function()
{
if(menuitem.menu&&menuitem.menu.Close)
{
menuitem.menu.Close();
}
},1);
clickfunc(menuitem);
clearTimeout(timer);
}
}
}
function MenuClass_CreateFrame(menuitem)
{
var frame;
var framebody;
var framedoc=null;
//GECKO DO NOT USE IFRAME
if(Html_IsGecko || Html_IsOpera)
{
framedoc=document;
frame=document.createElement("DIV");
frame.style.visibility='hidden';
frame.innerHTML="<DIV oncontextmenu='event.returnValue=false;event.cancelBubble=true;' style='border:1px solid #666666;padding:2px;margin:0px;overflow:hidden;background-image:url("+menuimagebase+"Images/menuleft.gif);background-repeat:repeat-y;'></DIV>"
document.body.appendChild(frame);
framebody=frame.firstChild;
}
else
{
frame=document.createElement("IFRAME");
frame.frameBorder=0;
document.body.appendChild(frame);
if(location.href.substr(0,6)=="https:")
{
frame.src="blank.html";
}
else
{
frame.src="about:blank";
}
//TODO:IE5 don't support contentWindow..
var framewin=frame.contentWindow;
if(framewin==null)
{
framedoc=frame.contentDocument;
}
else
{
framedoc=framewin.document;
}
framedoc.open();
framedoc.write("<html><TITLE></TITLE><BODY oncontextmenu='event.returnValue=false;event.cancelBubble=true;' style='border:1px solid #666666;padding:2px;margin:0px;overflow:hidden;background-image:url("+menuimagebase+"Images/menuleft.gif);background-repeat:repeat-y;'></BODY></html>");
framedoc.close();
framebody=framedoc.body;
}
Html_SetCssText(frame,"visibility:hidden;position:absolute;background-color:white;padding:0px;border:0px;width:"+(const_menuwidth+40)+"px;height:90px;overflow:visible;");
frame.style.zIndex=menuitem.zIndex;
var table=framedoc.createElement("TABLE");
table.border=0;
table.cellSpacing=0;
table.cellPadding=0;
Html_SetCssText(table,"cursor:default;width:100%;overflow:visible;");
for(var i=0;i<menuitem.items.length;i++)
{
var childitem=menuitem.items[i];
var tr=table.insertRow(-1);
var cell=tr.insertCell(-1);
Html_SetCssText(cell,'overflow:visible;');
if(childitem.html=='-')//spliter
{
if(i!=menuitem.items.length-1)
cell.innerHTML="<div style='overflow:hidden;border-top:1px solid ThreeDShadow;border-bottom:1px solid ThreeDHighlight;height:2px;'></div>";
continue;
}
var tablehtml="<table border=0 cellspacing=0 cellpadding=0 style='font:normal 8.5pt MS Sans Serif;height:20px;width:100%;overflow:visible;'>";
tablehtml+="<tr><td style='width:18px'>"
if(childitem.imgurl)
{
//width=20 height=20
tablehtml+="<img align=absmiddle border=0 src='"+childitem.imgurl+"'"
if(childitem.state==2)
{
tablehtml+=" style='' "
}
else if(childitem.enable)
{
tablehtml+=" style='' "
}
else
{
tablehtml+=" style='' "
}
tablehtml+="/>";
}
else
{
tablehtml+="<img width=20 height=0 border=0 style='visibility:hidden' />";
}
if(childitem.hotkey)
{
tablehtml+="</td><td nowrap align='left' style='width:"+const_menuwidth+";padding-left:4px;padding-top:2px;padding-right:4px;";
if(childitem.color)
tablehtml+="color:"+childitem.color;
tablehtml+="'>"+childitem.html+"</td>";
tablehtml+="<td align='left' style='width:43px;font:normal 8.5pt MS Sans Serif;padding-left:1px;padding-top:3px;' rem-disabled=true nowrap>"+childitem.hotkey+"</td>";
}
else
{
tablehtml+="</td><td colspan=2 nowrap=nowrap align='left' style='width:"+const_menuwidth+";padding-left:4px;padding-top:2px;padding-right:4px;";
if(childitem.color)
tablehtml+="color:"+childitem.color;
tablehtml+="'>"+childitem.html+"</td>";
}
if(true)
{
tablehtml+="<td align='right' style='width:20px;padding-top:2px;padding-right:2px;'><span style='width:20px;";
if(childitem.items.length==0&&childitem.oninitialize==null)
{
tablehtml+=";visibility:hidden;"
}
if(document.all)
tablehtml+=";font-family:webdings;font-size:14px;'> 4 </span></td>";
else
tablehtml+=";font-family:arial;font-size:14px;'> > </span></td>";
}
else
{
if(childitem.items.length==0&&childitem.oninitialize!=null)
{
tablehtml+="<td align='right' style='width:20px;padding-top:2px;padding-right:2px;'><span style='width:20px;";
if(document.all)
tablehtml+=";font-family:webdings;font-size:14px;'> 4 </span></td>";
else
tablehtml+=";font-family:arial;font-size:14px;'> > </span></td>";
}
}
tablehtml+="</tr></table>";
var itemdiv=framedoc.createElement("DIV");
childitem.itemdiv=itemdiv;
Html_SetCssText(itemdiv,"cursor:default;margin:1px;width:100%;overflow:visible;"+(childitem.enable?"":"filter:alpha(opacity=40);"));
if(!childitem.enable)itemdiv.style.MozOpacity=0.4;
itemdiv.innerHTML=tablehtml;
if(Html_IsGecko || Html_IsOpera)
{
itemdiv.onmousedown=new Function("event","event.cancelBubble=true;");
}
if(childitem.enable)
{
itemdiv.onmouseover=Create_MenuItemDiv_OnMouseOver(childitem);
itemdiv.onmouseout=Create_MenuItemDiv_OnMouseOut(childitem);
itemdiv.onclick=Create_MenuItemDiv_OnClick(childitem);
if(childitem.onclick)
{
itemdiv.style.cursor='hand';
}
}
else
{
//itemdiv.disabled=!childitem.enable;
}
cell.appendChild(itemdiv);
}
framebody.appendChild(table);
frame.style.width=table.offsetWidth+16+"px";
frame.style.height=table.offsetHeight+6+"px";
return frame;
}
function MenuClass()
{
var frame=null;
var menu=this;
menu.menu=menu;
menu.items=[];
menu.zIndex=7777777;
menu.closed=true;
function OnWindowBlur()
{
setTimeout(CloseIt,250);
function CloseIt()
{
if(menu.Close)
menu.Close();
}
}
function OnDocumentClick()
{
if(menu.Close)
menu.Close();
}
function OnWindowUnload()
{
if(menu.Close)
menu.Close();
}
menu.Show=function menu_Show(target,offsetX,offsetY)
{
if(_menuclass_currentmenu)
_menuclass_currentmenu.Close();
menu.Close();
window.focus();
if(menu.frame==null)
{
menu.frame=MenuClass_CreateFrame(menu);
}
Menu_ShowFrame(menu.frame,target,offsetX,offsetY);
_menuclass_currentmenu=menu;
//Html_AttachEvent(window,"blur",OnWindowBlur);
Html_AttachEvent(document,"mousedown",OnDocumentClick);
Html_AttachEvent(window,"beforeunload",OnWindowUnload);
menu.opened=true;
}
menu.Close=function()
{
if(!menu.opened)return;
menu.opened=false;
//Html_DetachEvent(window,"blur",OnWindowBlur);
Html_DetachEvent(document,"mousedown",OnDocumentClick);
Html_DetachEvent(window,"beforeunload",OnWindowUnload);
if(_menuclass_currentmenu==menu)
_menuclass_currentmenu=null;
if(menu.frame==null)
return;
menu.frame.style.display='none';
if(menu.openitem)
menu.openitem.Close();
//Dispose on close..
Dispose();
}
menu.HideByClick=function()
{
if(menu.frame)
{
menu.frame.style.display='none';
}
if(menu.openitem)
menu.openitem.Close();
}
menu.Dispose=function()
{
menu.Close();
Dispose();
}
function Dispose()
{
if(menu.isdisposed)return;
menu.isdisposed=true;
for(var i=0;i<menu.items.length;i++)
{
menu.items[i].Dispose();
}
if(menu.frame)
{
menu.frame.parentNode.removeChild(menu.frame);
menu.frame=null;
}
RemoveObjectMembers(menu);
menu.isdisposed=true;
}
menu.AddSpliter=function()
{
if(menu.items.length==0||menu.items[menu.items.length-1].html!='-')
return menu.AddMenuItem(1,"-");
return menu.items[menu.items.length-1];
}
menu.AddMenuItem=
menu.Add=function(state,html,imgurl,onclick,oninitialize)
{
var childmenu=new ChildMenuClass();
childmenu.zIndex=menu.zIndex+1;
childmenu.menu=menu;
childmenu.owner=menu;
childmenu.enable=state>0?true:false;
childmenu.html=html;
childmenu.imgurl=imgurl==null?null:(imgurl.indexOf('.')==-1?(menuimagebase+imgurl+".gif"):imgurl);
childmenu.onclick=onclick;
childmenu.oninitialize=oninitialize;
menu.items[menu.items.length]=childmenu;
return childmenu;
}
function ChildMenuClass()
{
var menuitem=this;
menuitem.items=[];
menuitem.AddSpliter=function()
{
if(menuitem.items.length==0||menuitem.items[menuitem.items.length-1].html!='-')
return menuitem.AddMenuItem(1,"-");
return menuitem.items[menuitem.items.length-1];
}
menuitem.AddMenuItem=
menuitem.Add=function(state,html,imgurl,onclick,oninitialize)
{
var childmenu=new ChildMenuClass();
childmenu.zIndex=menuitem.zIndex+1;
childmenu.menu=menu;
childmenu.owner=menuitem;
childmenu.enable=state>0?true:false;
childmenu.html=html;
childmenu.imgurl=imgurl==null?null:(imgurl.indexOf('.')==-1?(menuimagebase+imgurl+".gif"):imgurl);
childmenu.onclick=onclick;
childmenu.oninitialize=oninitialize;
menuitem.items[menuitem.items.length]=childmenu;
return childmenu;
}
menuitem.Show=function(target,offsetX,offsetY)
{
if(menuitem.isopen)return;
if(menuitem.frame==null)
{
menuitem.frame=MenuClass_CreateFrame(menuitem);
}
Menu_ShowFrame(menuitem.frame,target,offsetX,offsetY);
menuitem.owner.openitem=menuitem;
menuitem.isopen=true;
}
menuitem.Close=function()
{
if(!menuitem.isopen)return;
if(menuitem.openitem)
menuitem.openitem.Close();
MenuItemDiv_OnMouseOut(menuitem.itemdiv);
menuitem.frame.style.display='none';
menuitem.frame.style.top='0px'
menuitem.frame.style.left='0px'
menuitem.owner.openitem=null;
menuitem.isopen=false;
}
menuitem.Dispose=function()
{
if(menuitem.isdisposed)return;
menuitem.isdisposed=true;
for(var i=0;i<menuitem.items.length;i++)
{
menuitem.items[i].Dispose();
}
if(menuitem.frame)
{
menuitem.frame.parentNode.removeChild(menuitem.frame);
menuitem.frame=null;
}
RemoveObjectMembers(menuitem);
menu.isdisposed=true;
}
return menuitem;
}
return menu;
}
} | 23.843643 | 287 | 0.659581 |
27c78d455dec3b99edb5f33ccdb5d8b9f1716238 | 1,709 | js | JavaScript | server.js | S4KH/nd-chat-server | 2215f2d441f1467b17beee1ebc90fbd836708f57 | [
"MIT"
] | null | null | null | server.js | S4KH/nd-chat-server | 2215f2d441f1467b17beee1ebc90fbd836708f57 | [
"MIT"
] | null | null | null | server.js | S4KH/nd-chat-server | 2215f2d441f1467b17beee1ebc90fbd836708f57 | [
"MIT"
] | null | null | null | const express = require('express')
const app = express()
const http = require('http').Server(app)
const session = require('express-session');
const io = require('socket.io')(http)
const port = process.env.PORT || 3000
const redis = require('redis')
const RedisStore = require('connect-redis')(session)
const rClient = redis.createClient({
host: 'redis-18500.c9.us-east-1-4.ec2.cloud.redislabs.com',
port: 18500,
pass: "#####"
})
const sessionStore = new RedisStore({client: rClient})
const passport = require('passport')
const morgan = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const sessionMiddleware = session({store: sessionStore, secret: 'catshit', resave: true, saveUninitialized: false})
app.use(morgan('dev'))
app.use(cookieParser())
app.use(bodyParser.urlencoded({
extended: false
}))
app.use(sessionMiddleware)
app.use(passport.initialize())
app.use(passport.session())
app.set('view engine', 'ejs'); // set up ejs for templating
// Use express session for io
io.use((socket, next) => {
sessionMiddleware(socket.request, socket.request.res, next)
})
// Config and routes
require('./config/passport')(passport); // pass passport for configuration
require('./app/routes.js')(app, passport)
io.on('connection', (socket) => {
const user = socket.request.session.user
console.log(user)
if(!user) {
socket.close()
}
console.log(`${socket.id} user connected`)
socket.on('disconnect', () => {
console.log('user disconnected')
})
socket.on('message', (msg) => {
socket.broadcast.emit('message', msg)
})
})
http.listen(port, () => {
console.log(`server started in ${port} port`)
})
| 27.126984 | 115 | 0.690462 |
27c7c7849e25e7c0ffdc237cfe642d4887377841 | 711 | js | JavaScript | 1540198914419-algorithms-872-22-10-2018-leaf-similar-trees.js | WHATHELWHATHELWHATHEL/LeetCode | e786cb066ced68d79647efafb35b832752d85f74 | [
"MIT"
] | null | null | null | 1540198914419-algorithms-872-22-10-2018-leaf-similar-trees.js | WHATHELWHATHELWHATHEL/LeetCode | e786cb066ced68d79647efafb35b832752d85f74 | [
"MIT"
] | null | null | null | 1540198914419-algorithms-872-22-10-2018-leaf-similar-trees.js | WHATHELWHATHELWHATHEL/LeetCode | e786cb066ced68d79647efafb35b832752d85f74 | [
"MIT"
] | null | null | null | /**
* Definition for a binary tree node.
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/
/**
* @param {TreeNode} root1
* @param {TreeNode} root2
* @return {boolean}
*/
const getSequence = (node, seq) => {
if (!node.left && !node.right) {
seq.push(node.val);
return seq;
}
let currSeq = seq;
if (node.left) {
currSeq = getSequence(node.left, currSeq);
}
if (node.right) {
currSeq = getSequence(node.right, currSeq);
}
return currSeq;
};
const leafSimilar = (root1, root2) => { // eslint-disable-line
const seq1 = getSequence(root1, []).join('');
const seq2 = getSequence(root2, []).join('');
return seq1 === seq2;
};
| 20.911765 | 62 | 0.592124 |
27c86dc999c6b3c0fb3b4c41696288fba1964ab6 | 64,470 | js | JavaScript | ui.js | SunnyDazePewPew/OverwatchParty | 81c7591dbcc462ddae60a892e1f94cf5cc664d6b | [
"MIT"
] | 15 | 2018-01-05T04:16:04.000Z | 2022-03-29T19:29:43.000Z | ui.js | SunnyDazePewPew/OverwatchParty | 81c7591dbcc462ddae60a892e1f94cf5cc664d6b | [
"MIT"
] | 9 | 2018-08-09T17:08:18.000Z | 2020-12-30T21:39:41.000Z | ui.js | SunnyDazePewPew/OverwatchParty | 81c7591dbcc462ddae60a892e1f94cf5cc664d6b | [
"MIT"
] | 6 | 2019-06-09T14:35:52.000Z | 2022-01-25T22:09:45.000Z | /*
* User actions
*/
function add_player_click() {
var player_id = document.getElementById("new_player_id").value;
player_id = format_player_id( player_id );
// check duplicates
if ( find_player_by_id(player_id) !== undefined ) {
alert("Player already added");
setTimeout( function() {document.getElementById(player_id).scrollIntoView(false);}, 100 );
setTimeout( function() {highlight_player( player_id );}, 500 );
return;
}
document.getElementById("add_btn").disabled = true;
player_being_added = create_empty_player();
player_being_added.id = player_id;
StatsUpdater.addToQueue( player_being_added, 0, true );
}
function add_test_players() {
// fill teams with ramdom players
var number_to_add_str = prompt("Enter number of players to generate", 1);
if (number_to_add_str === null) {
return;
}
var number_to_add = Number(number_to_add_str);
if( Number.isNaN(number_to_add) ) {
return;
}
if( ! Number.isInteger(number_to_add) ) {
return;
}
if( (number_to_add > 10000) || (number_to_add == 0) ) {
return;
}
var added_players = [];
for( var i=1; i<=number_to_add; i++ ) {
var new_player = create_random_player(i);
if ( find_player_by_id(new_player.id) !== undefined ) {
continue;
}
lobby.push( new_player );
added_players.push( new_player.id );
}
save_players_list();
redraw_lobby();
// highlight all new players and scroll to show last one
setTimeout( function() {document.getElementById( added_players[added_players.length-1] ).scrollIntoView(false);}, 100 );
setTimeout( function() {highlight_players( added_players );}, 500 );
}
function apply_settings() {
var teams_changed = false;
if ( Settings["sr_calc_method"] != document.getElementById("sr_calc_method").value ) {
if ( ! is_role_lock_enabled() ) {
teams_changed = true;
}
}
// check if team size changed
var slots_count_setting = "slots_count";
old_team_size = get_team_size();
var new_team_size = 0;
// compare slots count for each role, move players to lobby if slots reduced
for ( class_name in Settings[slots_count_setting] ) {
var setting_input = document.getElementById(slots_count_setting+"_"+class_name);
var old_slot_count = Settings[slots_count_setting][class_name];
new_slot_count = Number(setting_input.value);
new_team_size += new_slot_count;
if ( new_slot_count < old_slot_count ) {
// move excess players back to lobby
teams_changed = true;
while ( team1_slots[class_name].length > new_slot_count ) {
let removed_player = team1_slots[class_name].pop();
lobby.push( removed_player );
}
while ( team2_slots[class_name].length > new_slot_count ) {
let removed_player = team2_slots[class_name].pop();
lobby.push( removed_player );
}
}
Settings[slots_count_setting][class_name] = new_slot_count;
}
// also move players out of old plain arrays
if ( new_team_size < old_team_size ) {
for ( let team of [team1, team2] ) {
while ( team.length > new_team_size ) {
let removed_player = team.pop();
lobby.push( removed_player );
}
}
}
// fill settings struct from dialog
for ( setting_name in Settings ) {
if ( setting_name == "slots_count" ) {
continue;
}
var setting_input = document.getElementById(setting_name);
var setting_value;
switch( setting_input.type ) {
case "checkbox":
setting_value = setting_input.checked;
break;
case "number":
case "range":
setting_value = Number(setting_input.value);
break;
default:
setting_value = setting_input.value;
}
Settings[setting_name] = setting_value;
}
localStorage.setItem( storage_prefix+"settings", JSON.stringify(Settings) );
apply_stats_updater_settings();
close_dialog( "popup_dlg_settings" );
if (teams_changed) {
save_players_list();
redraw_lobby();
redraw_teams();
}
}
function balance_teams() {
// send balancer settings to worker
balancer_settings = {
slots_count: Settings.slots_count,
algorithm: Settings.balancer_alg,
separate_otps: Settings.separate_otps,
adjust_sr: Settings.adjust_sr,
adjust_sr_by_class: {
tank: Settings.adjust_tank,
dps: Settings.adjust_dps,
support: Settings.adjust_support,
},
balance_priority_classic: Settings.balance_priority,
classic_sr_calc_method: Settings.sr_calc_method,
balance_priority_rolelock: Settings.balance_priority_rolelock,
};
BalanceWorker.postMessage(["settings", balancer_settings]);
// copy players (references) to balancer input
var players = team1.slice();
for( let class_name in team1_slots ) {
players = players.concat( team1_slots[class_name] );
}
players = players.concat( team2 );
for( let class_name in team2_slots ) {
players = players.concat( team2_slots[class_name] );
}
// start balance calculation
BalanceWorker.postMessage(["balance", players]);
// show progress bar
document.getElementById("dlg_progress_bar").value = 0;
document.getElementById("dlg_progress_text").innerHTML = "0 %";
document.getElementById("dlg_progress_cancel").style.display = "";
document.getElementById("dlg_progress_close").style.display = "none";
open_dialog( "popup_dlg_progress" );
}
function cancel_balance() {
BalanceWorker.terminate();
close_dialog( "popup_dlg_progress" );
BalanceWorker = new Worker('balance_worker.js');
BalanceWorker.onmessage = on_balance_worker_message;
BalanceWorker.postMessage(["init"]);
}
function clear_lobby() {
if( confirm("Permanently delete all players?") ) {
while ( lobby.length > 0 ) {
var player_to_delete = lobby.pop();
// remove from checkin
checkin_list.delete(player_to_delete.id);
// remove from pinned
pinned_players.delete(player_to_delete.id);
}
save_players_list();
save_checkin_list();
save_pinned_list();
redraw_lobby();
}
}
function clear_edited_mark( field_name ) {
if (player_being_edited == undefined) {
return;
}
var player_struct = player_being_edited;
switch (field_name) {
case 'ne':
player_struct.ne = false;
document.getElementById("dlg_player_name_edited").style.visibility = "";
break;
case 'se':
player_struct.se = false;
var marks = document.getElementById("dlg_player_class_table").getElementsByClassName("dlg-edited-mark-sr");
for( i=0; i<marks.length; i++ ) {
marks[i].style.visibility = "hidden";
}
break;
case 'ce':
player_struct.ce = false;
document.getElementById("dlg_player_class1_edited").style.visibility = "";
break;
}
redraw_player( player_struct );
save_players_list();
}
function clear_stats_update_log() {
document.getElementById("stats_update_log").value = "";
document.getElementById("stats_update_errors").style.visibility = "hidden";
}
function close_dialog( dialog_id ) {
document.getElementById( dialog_id ).style.display = "none";
}
function edit_player_ok() {
if (player_being_edited == undefined) {
return;
}
var player_struct = player_being_edited;
var new_name = document.getElementById("dlg_player_display_name").value;
if ( player_struct.display_name != new_name ) {
player_struct.ne = true; // name edited
}
player_struct.display_name = new_name;
var class_rows = document.getElementById("dlg_player_class_table").rows;
// check if SR was edited
for ( var i=0; i<class_rows.length; i++ ) {
var class_row = class_rows[i];
var class_title = class_row.getElementsByClassName("dlg-class-name")[0];
var class_name = class_title.innerHTML;
var sr_edit = class_row.getElementsByClassName("dlg-sr-by-class")[0];
var new_sr = Number(sr_edit.value);
var old_sr = player_struct.sr_by_class[class_name];
if ( old_sr == undefined ) {
old_sr = 0;
}
if ( old_sr != new_sr ) {
player_struct.se = true; // sr edited mark
break;
}
}
// check if class order was edited
var new_classes = [];
for ( var i=0; i<class_rows.length; i++ ) {
var class_row = class_rows[i];
var class_title = class_row.getElementsByClassName("dlg-class-name")[0];
var class_name = class_title.innerHTML;
var class_checkbox = class_row.getElementsByClassName("dlg-class-enabled-checkbox")[0];
if ( class_checkbox.checked ) {
new_classes.push( class_name );
}
}
for ( var i=0; i<new_classes.length; i++ ) {
var old_index = player_struct.classes.indexOf( new_classes[i] );
if ( old_index != i ) {
player_struct.ce = true;
break;
}
}
for ( var i=0; i<player_struct.classes.length; i++ ) {
var new_index = new_classes.indexOf( player_struct.classes[i] );
if ( new_index != i ) {
player_struct.ce = true;
break;
}
}
// save class order and sr to player
player_struct.sr_by_class = {};
player_struct.classes = [];
for ( var i=0; i<class_rows.length; i++ ) {
var class_row = class_rows[i];
var class_title = class_row.getElementsByClassName("dlg-class-name")[0];
var class_name = class_title.innerHTML;
if ( class_names.indexOf(class_name) == -1 ) {
continue;
}
var sr_edit = class_row.getElementsByClassName("dlg-sr-by-class")[0];
var new_sr = Number(sr_edit.value);
player_struct.sr_by_class[class_name] = new_sr;
var class_checkbox = class_row.getElementsByClassName("dlg-class-enabled-checkbox")[0];
if ( class_checkbox.checked && (new_sr > 0) ) {
player_struct.classes.push( class_name );
}
}
// pinned mark
if ( document.getElementById("dlg_player_pinned").checked ) {
pinned_players.add( player_struct.id );
} else {
pinned_players.delete( player_struct.id );
}
save_pinned_list();
// check-in
if ( document.getElementById("dlg_player_checkin").checked ) {
checkin_list.add( player_struct.id );
} else {
checkin_list.delete( player_struct.id );
}
save_checkin_list();
close_dialog("popup_dlg_edit_player");
save_players_list();
redraw_player( player_struct );
player_being_edited = undefined;
}
function enable_roll_debug() {
var dbg_level = prompt("Debug level", 0);
if (dbg_level === null) {
return;
}
var dbg_level = Number(dbg_level);
if( Number.isNaN(dbg_level) ) {
return;
}
if( ! Number.isInteger(dbg_level) ) {
return;
}
document.getElementById("debug_log").innerHTML = "roll debug enabled, level "+dbg_level+"<br/>";
balancer_settings = {
roll_debug: true,
debug_level: dbg_level,
};
BalanceWorker.postMessage(["settings", balancer_settings]);
}
function export_lobby_dlg_open() {
open_dialog("popup_dlg_export_lobby");
export_lobby_dlg_change_format();
}
function export_lobby_dlg_change_format() {
var format = document.getElementById("dlg_lobby_export_format_value").value;
var export_str = export_lobby( format );
document.getElementById("dlg_textarea_export_lobby").value = export_str;
document.getElementById("dlg_textarea_export_lobby").select();
document.getElementById("dlg_textarea_export_lobby").focus();
}
function export_teams_dlg_copy_html() {
select_html( document.getElementById("dlg_html_export_teams") );
document.execCommand("copy");
}
function export_teams_dlg_change_format() {
// @ToDo save format and options
var format = document.getElementById("dlg_team_export_format_value").value;
var include_players = true;
var include_sr = document.getElementById("dlg_team_export_sr").checked;
var include_classes = document.getElementById("dlg_team_export_classes").checked;
var include_captains = false;
var table_columns = 2;
// save format
ExportOptions.format = format;
ExportOptions.include_sr = include_sr;
ExportOptions.include_classes = include_classes;
localStorage.setItem( storage_prefix+"export_options", JSON.stringify(ExportOptions) );
var export_str = export_teams( format, include_players, include_sr, include_classes, include_captains, table_columns );
if ( format == "html-table" ) {
var html_container = document.getElementById("dlg_html_export_teams");
html_container.style.display = "";
document.getElementById("dlg_html_export_teams_hint").style.display = "";
document.getElementById("dlg_textarea_export_teams").style.display = "none";
html_container.innerHTML = export_str;
select_html( html_container );
} else if ( format == "text-list" ) {
document.getElementById("dlg_html_export_teams").style.display = "none";
document.getElementById("dlg_html_export_teams_hint").style.display = "none";
document.getElementById("dlg_textarea_export_teams").style.display = "";
document.getElementById("dlg_textarea_export_teams").value = export_str;
document.getElementById("dlg_textarea_export_teams").select();
document.getElementById("dlg_textarea_export_teams").focus();
} else if ( format == "image" ) {
var html_container = document.getElementById("dlg_html_export_teams");
html_container.innerHTML = "";
html_container.style.display = "";
document.getElementById("dlg_html_export_teams_hint").style.display = "none";
document.getElementById("dlg_textarea_export_teams").style.display = "none";
// convert html to image
// calculate image size
var tmp_div = document.createElement("div");
tmp_div.style.position = "absolute";
tmp_div.style.visibility = "hidden";
tmp_div.innerHTML = export_str;
document.body.appendChild(tmp_div);
var img_width = tmp_div.firstChild.clientWidth;
var img_height = tmp_div.firstChild.clientHeight;
document.body.removeChild(tmp_div);
var data = '<svg xmlns="http://www.w3.org/2000/svg" width="'+img_width+'" height="'+img_height+'">' +
'<foreignObject width="100%" height="100%">' +
'<div xmlns="http://www.w3.org/1999/xhtml" >' +
export_str +
'</div>' +
'</foreignObject>' +
'</svg>';
data = encodeURIComponent(data);
var canvas = document.createElement('canvas');
canvas.width = img_width;
canvas.height = img_height;
var ctx = canvas.getContext('2d');
var svg_img = new Image();
svg_img.onload = function() {
ctx.drawImage(svg_img, 0, 0);
canvas.toBlob(function(blob) {
var newImg = document.createElement('img'),
url = URL.createObjectURL(blob);
newImg.onload = function() { URL.revokeObjectURL(url); };
newImg.src = url;
html_container.appendChild(newImg);
});
}
svg_img.src = "data:image/svg+xml," + data;
}
}
function export_teams_dlg_open() {
open_dialog("popup_dlg_export_teams");
document.getElementById("dlg_team_export_format_value").value = ExportOptions.format;
document.getElementById("dlg_team_export_sr").checked = ExportOptions.include_sr;
document.getElementById("dlg_team_export_classes").checked = ExportOptions.include_classes;
export_teams_dlg_change_format();
}
function fill_teams() {
if ( is_role_lock_enabled() ) {
for ( var team_slots of [team1_slots, team2_slots] ) {
for ( var class_name in team_slots ) {
var free_slots = Settings.slots_count[class_name] - team_slots[class_name].length;
var available_players = [];
// first pass - pick players by main role for slot
for ( var player of lobby ) {
if ( checkin_list.size > 0 ) {
if ( ! checkin_list.has(player.id) ) {
continue;
}
}
if ( player.classes[0] !== class_name ) {
continue;
}
available_players.push( player );
}
while ( (free_slots > 0) && (available_players.length > 0) ) {
var random_index = Math.floor(Math.random() * available_players.length);
var random_player = available_players[ random_index ];
lobby.splice( lobby.indexOf(random_player), 1 );
available_players.splice( available_players.indexOf(random_player), 1 );
team_slots[class_name].push( random_player );
free_slots--;
}
if ( free_slots <= 0 ) {
continue;
}
// second pass - pick players able to play specified role
for ( var player of lobby ) {
if ( checkin_list.size > 0 ) {
if ( ! checkin_list.has(player.id) ) {
continue;
}
}
if ( player.classes.indexOf(class_name) == -1 ) {
continue;
}
available_players.push( player );
}
while ( (free_slots > 0) && (available_players.length > 0) ) {
var random_index = Math.floor(Math.random() * available_players.length);
var random_player = available_players[ random_index ];
lobby.splice( lobby.indexOf(random_player), 1 );
available_players.splice( available_players.indexOf(random_player), 1 );
team_slots[class_name].push( random_player );
free_slots--;
}
if ( free_slots <= 0 ) {
continue;
}
// third pass - pick any available players
for ( var player of lobby ) {
if ( checkin_list.size > 0 ) {
if ( ! checkin_list.has(player.id) ) {
continue;
}
}
available_players.push( player );
}
while ( (free_slots > 0) && (available_players.length > 0) ) {
var random_index = Math.floor(Math.random() * available_players.length);
var random_player = available_players[ random_index ];
lobby.splice( lobby.indexOf(random_player), 1 );
available_players.splice( available_players.indexOf(random_player), 1 );
team_slots[class_name].push( random_player );
free_slots--;
}
}
}
} else {
for ( var team of [team1, team2] ) {
var free_slots = get_team_size() - team.length;
var available_players = [];
for ( var player of lobby ) {
if ( checkin_list.size > 0 ) {
if ( checkin_list.has(player.id) ) {
available_players.push( player );
}
} else {
available_players.push( player );
}
}
while ( (free_slots > 0) && (available_players.length > 0) ) {
var random_index = Math.floor(Math.random() * available_players.length);
var random_player = available_players[ random_index ];
lobby.splice( lobby.indexOf(random_player), 1 );
available_players.splice( available_players.indexOf(random_player), 1 );
team.push( random_player );
free_slots--;
}
}
}
save_players_list();
redraw_lobby();
redraw_teams();
}
function generate_random_players() {
var number_to_add_str = prompt("Enter number of players to generate", 1);
if (number_to_add_str === null) {
return;
}
var number_to_add = Number(number_to_add_str);
if( Number.isNaN(number_to_add) ) {
return;
}
if( ! Number.isInteger(number_to_add) ) {
return;
}
if( number_to_add > 10000 ) {
return;
}
for( var i=1; i<=number_to_add; i++ ) {
var new_player = create_random_player(i);
lobby.push( new_player );
}
save_players_list();
redraw_lobby();
}
function import_lobby_dlg_open() {
open_dialog("popup_dlg_import_lobby");
document.getElementById("dlg_textarea_import_lobby").value = "";
document.getElementById("dlg_textarea_import_lobby").focus();
}
function import_lobby_ok() {
var format = document.getElementById("dlg_player_import_format_value").value;
var import_str = document.getElementById("dlg_textarea_import_lobby").value;
if ( import_lobby(format, import_str) ) {
close_dialog("popup_dlg_import_lobby");
}
}
function lobby_filter_clear() {
document.getElementById("lobby_filter").value="";
apply_lobby_filter();
}
function manual_checkin_open() {
open_dialog("popup_dlg_manual_checkin");
// fill players table
var tbody = document.getElementById("manual_checkin_table").tBodies[0];
var thead = document.getElementById("manual_checkin_table").tHead;
var tfoot = document.getElementById("manual_checkin_table").tFoot;
tbody.innerHTML = "";
for (var i=0; i<lobby.length; i++) {
var row = document.createElement("tr");
row.onclick = manual_checkin_row_click;
var cell = document.createElement("td");
var cbox = document.createElement("input");
cbox.type = "checkbox";
cbox.setAttribute("player_id", lobby[i].id);
cbox.onchange = manual_checkin_checkbox_change;
cbox.autocomplete = "off";
if ( checkin_list.has(lobby[i].id) ) {
cbox.checked = true;
row.classList.add("checked");
}
cell.appendChild(cbox);
row.appendChild(cell);
cell = document.createElement("td");
var cellText = document.createTextNode( format_player_id(lobby[i].id) );
cell.appendChild(cellText);
row.appendChild(cell);
tbody.appendChild(row);
}
// reset sorting marks
for ( var i=0; i<thead.rows[0].cells.length; i++ ) {
thead.rows[0].cells[i].removeAttribute("order_inverse");
}
sort_manual_chekin_table( 1 );
tfoot.getElementsByTagName("td")[0].innerHTML = checkin_list.size;
tfoot.getElementsByTagName("td")[1].innerHTML = lobby.length;
}
function move_team_to_lobby(team, team_slots) {
lobby = lobby.concat( team.filter((player,index,arr)=>{
return ! pinned_players.has(player.id)
}) );
var filtered = team.filter((player,index,arr)=>{
return pinned_players.has(player.id)
});
team.splice( 0, team.length );
while ( filtered.length > 0 ) {
let removed_player = filtered.pop();
team.push( removed_player );
}
for ( let class_name in team_slots ) {
lobby = lobby.concat( team_slots[class_name].filter((player,index,arr)=>{
return ! pinned_players.has(player.id)
}) );
team_slots[class_name] = team_slots[class_name].filter((player,index,arr)=>{
return pinned_players.has(player.id)
});
}
//update_captains();
save_players_list();
redraw_lobby();
redraw_teams();
}
function open_stats_update_log() {
open_dialog("popup_dlg_stats_log");
}
function player_class_row_movedown(ev) {
var current_row = get_parent_element( ev.currentTarget, "TR" );
var rows = document.getElementById("dlg_player_class_table").rows;
var row_index = current_row.rowIndex;
if ( row_index == (rows.length-1) ) {
return;
}
rows[row_index].parentNode.insertBefore(rows[row_index + 1], rows[row_index]);
}
function player_class_row_moveup(ev) {
var current_row = get_parent_element( ev.currentTarget, "TR" );
var rows = document.getElementById("dlg_player_class_table").rows;
var row_index = current_row.rowIndex;
if ( row_index == 0 ) {
return;
}
rows[row_index].parentNode.insertBefore(rows[row_index], rows[row_index - 1]);
}
function reset_checkin() {
if( ! confirm("Clear all check-in marks?") ) {
return;
}
checkin_list.clear();
save_checkin_list();
redraw_lobby();
}
function reset_settings() {
fill_settings_dlg( get_default_settings() );
}
function role_lock_changed() {
localStorage.setItem(storage_prefix+"role_lock_enabled", document.getElementById("role_lock_enabled").checked );
// move all players from slots to arrays
for( let class_name of class_names ) {
if ( team1_slots[class_name] == undefined ) {
continue;
}
while ( team1_slots[class_name].length > 0 ) {
let removed_player = team1_slots[class_name].shift();
team1.push( removed_player );
}
}
for( let class_name of class_names ) {
if ( team2_slots[class_name] == undefined ) {
continue;
}
while ( team2_slots[class_name].length > 0 ) {
let removed_player = team2_slots[class_name].shift();
team2.push( removed_player );
}
}
// if using role lock - move from array to slots in order
if ( document.getElementById("role_lock_enabled").checked ) {
init_team_slots( team1_slots );
for( let class_name of class_names ) {
for(var i=0; i<Settings["slots_count"][class_name]; i++) {
let removed_player = team1.shift();
if (removed_player == undefined ) {
break;
}
team1_slots[class_name].push( removed_player );
}
}
init_team_slots( team2_slots );
for( let class_name of class_names ) {
for(var i=0; i<Settings["slots_count"][class_name]; i++) {
let removed_player = team2.shift();
if (removed_player == undefined ) {
break;
}
team2_slots[class_name].push( removed_player );
}
}
}
redraw_teams();
}
function settings_dlg_open() {
fill_settings_dlg( Settings );
open_dialog( "popup_dlg_settings" );
}
function shuffle_lobby() {
lobby = array_shuffle( lobby );
save_players_list();
redraw_lobby();
}
function sort_lobby( sort_field = 'sr', button_element=undefined ) {
var order_inverse = false;
if (button_element !== undefined) {
if (button_element.hasAttribute("order_inverse")) {
order_inverse = true;
button_element.removeAttribute("order_inverse");
} else {
button_element.setAttribute("order_inverse", "");
}
}
sort_players(lobby, sort_field, order_inverse);
save_players_list();
redraw_lobby();
}
function sort_manual_chekin_table( sort_column_index ) {
var tbody = document.getElementById("manual_checkin_table").tBodies[0];
var thead = document.getElementById("manual_checkin_table").tHead;
var header_cell = thead.rows[0].cells[sort_column_index];
var order = 1;
if (header_cell.hasAttribute("order_inverse")) {
order = -1;
header_cell.removeAttribute("order_inverse");
} else {
header_cell.setAttribute("order_inverse", "");
}
// create temporary array of table rows and sort it in memory
// avoiding expensive DOM updates
var temp_rows = [];
for (var i = 0; i < tbody.rows.length; i++) {
temp_rows.push(tbody.rows[i]);
}
temp_rows.sort( function(row1, row2){
if ( sort_column_index == 0 ) {
var this_row_calue = row1.cells[sort_column_index].getElementsByTagName("input")[0].checked;
var next_row_calue = row2.cells[sort_column_index].getElementsByTagName("input")[0].checked;
} else {
var this_row_calue = row1.cells[sort_column_index].innerText.toLowerCase();
var next_row_calue = row2.cells[sort_column_index].innerText.toLowerCase();
}
// convert to number if possible
if ( is_number_string(this_row_calue) ) {
this_row_calue = Number(this_row_calue);
}
if ( is_number_string(next_row_calue) ) {
next_row_calue = Number(next_row_calue);
}
return order * ( this_row_calue<next_row_calue ? -1 : (this_row_calue>next_row_calue?1:0) );
}
);
// rearrange table rows in DOM according to sorted array
for (var i = temp_rows.length-1; i >= 0; i--) {
temp_rows[i].parentNode.insertBefore(temp_rows[i], temp_rows[i].parentNode.firstChild);
}
// draw arrow on this column header
for(var i=0; i<thead.rows[0].cells.length; i++) {
thead.rows[0].cells[i].classList.remove("sort-up");
thead.rows[0].cells[i].classList.remove("sort-down");
}
if ( order > 0 ) {
thead.rows[0].cells[sort_column_index].classList.add("sort-up");
} else {
thead.rows[0].cells[sort_column_index].classList.add("sort-down");
}
}
function sort_team( team, sort_field = 'sr' ) {
sort_players( team, sort_field );
}
function stop_stats_update() {
StatsUpdater.stop( true );
}
function test() {
//----------------
/*start_time = performance.now();
var class_mask = Array( 12 ).fill(0);
var all_class_combinations = 0;
while ( Balancer.incrementClassMask( class_mask ) ) {
all_class_combinations ++;
//document.getElementById("debug_log").innerHTML += JSON.stringify(class_mask)+"<br/>";
}
document.getElementById("debug_log").innerHTML += "<br/>";
document.getElementById("debug_log").innerHTML += "total class combination = "+all_class_combinations;
document.getElementById("debug_log").innerHTML += "<br/>";
execTime = performance.now() - start_time;
document.getElementById("debug_log").innerHTML += "exec time = "+execTime;*/
document.getElementById("debug_log").innerHTML += JSON.stringify( Array.from(pinned_players) ) + "<br/>";
}
function update_active_stats() {
open_dialog("popup_dlg_stats_update_init");
document.getElementById("dlg_stats_update_ok").onclick = update_stats_ok.bind( this, "active" );
on_stats_update_limit_change();
}
function update_all_stats() {
open_dialog("popup_dlg_stats_update_init");
document.getElementById("dlg_stats_update_ok").onclick = update_stats_ok.bind( this, "all" );
on_stats_update_limit_change();
}
function update_current_player_stats() {
// forcing update of manually edited fields
delete player_being_edited.se;
delete player_being_edited.ce;
StatsUpdater.addToQueue( player_being_edited, 0, true );
document.getElementById("dlg_update_player_stats_loader").style.display = "";
document.getElementById("dlg_edit_player_update_result").style.display = "none";
document.getElementById("dlg_edit_player_update_result").innerHTML = "";
}
function update_stats_ok( scope ) {
close_dialog("popup_dlg_stats_update_init");
// pass date limit to updater
var raw_value = Number(document.getElementById("stats_update_limit").value);
var stats_max_age = convert_range_log_scale( raw_value, 1, 3000 ) - 1;
switch ( scope ) {
case "all":
StatsUpdater.addToQueue( lobby, stats_max_age );
// break not needed here ;)
case "active":
StatsUpdater.addToQueue( team1, stats_max_age );
StatsUpdater.addToQueue( team2, stats_max_age );
for( class_name in team1_slots) {
StatsUpdater.addToQueue( team1_slots[class_name], stats_max_age );
}
for( class_name in team2_slots) {
StatsUpdater.addToQueue( team2_slots[class_name], stats_max_age );
}
break;
}
}
/*
* UI events
*/
function adjust_sr_change() {
var adjust_enabled = document.getElementById("adjust_sr").checked;
var inputs = document.getElementById("adjust_sr_sub").getElementsByTagName("INPUT");
for (var i=0; i<inputs.length; i++ ) {
inputs[i].disabled = ! adjust_enabled;
}
}
function manual_checkin_checkbox_change(ev){
var cbox = ev.target;
var tr = cbox.parentNode.parentNode;
manual_checkin_toggle_player( tr, cbox );
}
function manual_checkin_row_click(ev) {
var tr = ev.currentTarget;
var cbox = tr.cells[0].getElementsByTagName("input")[0];
if (ev.target.tagName.toLowerCase() != "input") {
cbox.checked = ! cbox.checked;
}
manual_checkin_toggle_player( tr, cbox );
}
function manual_checkin_toggle_player( tr, cbox ) {
var player_id = cbox.getAttribute("player_id");
if ( cbox.checked ) {
checkin_list.add(player_id);
save_checkin_list();
tr.classList.toggle("checked", true);
} else {
checkin_list.delete(player_id);
save_checkin_list();
tr.classList.toggle("checked", false);
}
document.getElementById("manual_checkin_table").tFoot.getElementsByTagName("td")[0].innerHTML = checkin_list.size;
}
function on_lobby_filter_change() {
clearTimeout( lobby_filter_timer );
lobby_filter_timer = setTimeout( apply_lobby_filter, 400 );
}
function on_player_class_sr_changed(ev) {
var sr_edit = ev.currentTarget;
var rank_name = get_rank_name( sr_edit.value );
var sr_img = sr_edit.parentElement.getElementsByClassName("rank-icon-dlg")[0];
sr_img.src = "rank_icons/"+rank_name+"_small.png";
sr_img.title = rank_name;
}
function on_player_edit_class_toggled(ev) {
var class_checkbox = ev.currentTarget;
var current_row = get_parent_element( class_checkbox, "TR" );
if ( class_checkbox.checked ) {
current_row.classList.remove("class-disabled");
} else {
current_row.classList.add("class-disabled");
}
}
function on_stats_update_limit_change() {
// convert from log scale
var raw_value = Number(document.getElementById("stats_update_limit").value);
var max_stats_age_days = convert_range_log_scale( raw_value, 1, 3000 ) - 1;
document.getElementById("dlg_stats_update_days").innerHTML = max_stats_age_days;
var max_stats_age_date = new Date(Date.now() - (max_stats_age_days*24*3600*1000));
document.getElementById("dlg_stats_update_date").innerHTML = max_stats_age_date.toLocaleDateString();
}
function new_player_keyup(ev) {
ev.preventDefault();
if (ev.keyCode == 13) { //enter pressed
if ( ! document.getElementById("add_btn").disabled ) {
add_player_click();
}
}
}
function player_allowDrop(ev) {
ev.preventDefault();
ev.dataTransfer.dropEffect = "move";
}
function player_contextmenu(ev) {
ev.preventDefault();
var player_id = ev.currentTarget.id;
player_being_edited = find_player_by_id(player_id);
if( player_being_edited == undefined ) {
alert("player not found!");
return;
}
fill_player_stats_dlg();
open_dialog("popup_dlg_edit_player");
}
function player_dblClick(ev) {
var selected_id = ev.currentTarget.id;
if (selected_id == "") {
return;
}
// detect selected team
var selected_team;
var parent_id = ev.currentTarget.parentElement.parentElement.id;
if (parent_id == "lobby") {
selected_team = lobby;
} else {
for( let team of [team1, team2] ) {
for( var i=0; i<team.length; i++) {
if ( selected_id == team[i].id) {
selected_team = team;
}
}
}
for ( let team_slots of [team1_slots, team2_slots] ) {
for ( let class_name in team_slots ) {
for( var i=0; i<team_slots[class_name].length; i++) {
if ( selected_id == team_slots[class_name][i].id) {
selected_team = team_slots[class_name];
}
}
}
}
}
// find index in team for player
var selected_index = get_player_index( selected_id, selected_team );
var selected_player = selected_team[selected_index];
// detect target team
var new_team;
if (selected_team == lobby) {
// find team with empty slot
new_team = find_team_with_free_slot( selected_player );
} else {
new_team = lobby;
}
// check if team has free slots
if ( new_team === undefined ) {
alert("Teams are full");
return;
}
if (selected_team == lobby) {
if ( Settings.update_picked ) {
StatsUpdater.addToQueue( selected_player, Settings.update_picked_maxage, true );
}
}
// move player
new_team.push( selected_player );
selected_team.splice(selected_index, 1);
save_players_list();
redraw_lobby();
redraw_teams();
}
function player_drag(ev) {
ev.dataTransfer.setData("text/plain", ev.currentTarget.id);
ev.dataTransfer.effectAllowed = "move";
ev.dropEffect = "move";
}
function player_drop(ev) {
ev.preventDefault();
ev.stopPropagation();
var dragged_id = ev.dataTransfer.getData("text");
var target_id = ev.currentTarget.id;
if (dragged_id == target_id) {
return false;
}
var drag_action = "swap";
if( target_id == "trashcan" ) {
drag_action = "remove";
target_id = "";
}
// find team and index in team for both players
var dragged_team;
var dragged_index;
var dragged_player;
var target_team;
var target_index;
var target_player;
for( var i=0; i<lobby.length; i++) {
if ( dragged_id == lobby[i].id) {
dragged_team = lobby;
dragged_index = i;
dragged_player = lobby[i];
}
if ( target_id == lobby[i].id) {
target_team = lobby;
target_index = i;
target_player = lobby[i];
}
}
for( let team of [team1, team2] ) {
for( var i=0; i<team.length; i++) {
if ( dragged_id == team[i].id) {
dragged_team = team;
dragged_index = i;
dragged_player = team[i];
}
if ( target_id == team[i].id) {
target_team = team;
target_index = i;
target_player = team[i];
}
}
}
// also search in role slots
for ( let team_slots of [team1_slots, team2_slots] ) {
for ( let class_name in team_slots ) {
for( var i=0; i<team_slots[class_name].length; i++) {
if ( dragged_id == team_slots[class_name][i].id) {
dragged_team = team_slots[class_name];
dragged_index = i;
dragged_player = team_slots[class_name][i];
}
if ( target_id == team_slots[class_name][i].id) {
target_team = team_slots[class_name];
target_index = i;
target_player = team_slots[class_name][i];
}
}
}
}
if (target_id == "") {
// dropped on empty slot
var parent_id = ev.currentTarget.parentElement.parentElement.id;
if (parent_id == "lobby") {
target_team = lobby;
target_index = lobby.length;
} else if (parent_id == "team1") {
// check if target item is role slot
if ( ev.currentTarget.hasAttribute("slotClass") ) {
target_team = team1_slots[ ev.currentTarget.getAttribute("slotClass") ];
target_index = team1_slots[ ev.currentTarget.getAttribute("slotClass") ].length;
} else {
target_team = team1;
target_index = team1.length;
}
} else if (parent_id == "team2") {
// check if target item is role slot
if ( ev.currentTarget.hasAttribute("slotClass") ) {
target_team = team2_slots[ ev.currentTarget.getAttribute("slotClass") ];
target_index = team2_slots[ ev.currentTarget.getAttribute("slotClass") ].length;
} else {
target_team = team2;
target_index = team2.length;
}
}
if ( dragged_team == target_team ) {
// just move to end within team
target_index = target_team.length - 1;
}
}
if ((target_team == lobby) && (dragged_team != lobby)) {
drag_action = "move";
}
if (drag_action == "move") {
// move dragged player to target team (lobby)
target_team.splice(target_index, 0, dragged_player);
dragged_team.splice(dragged_index, 1);
} else {
if (target_id == "") {
// remove dragged player from source team
dragged_team.splice(dragged_index, 1);
} else {
// replace dragged player with target
dragged_team[dragged_index] = target_player;
}
}
if (drag_action == "swap") {
// replace target with dragged player
target_team[target_index] = dragged_player;
}
if (drag_action == "remove") {
// remove from update queue
StatsUpdater.removeFromQueue(dragged_id);
// remove from pinned
pinned_players.delete(dragged_id);
save_pinned_list();
// remove from checkin
checkin_list.delete(dragged_id);
save_checkin_list();
}
if ((target_team != lobby) && (dragged_team == lobby) && (drag_action != "remove")) {
if ( Settings.update_picked ) {
StatsUpdater.addToQueue( dragged_player, Settings.update_picked_maxage, true );
}
}
save_players_list();
redraw_lobby();
redraw_teams();
}
function save_team_name( element ) {
localStorage.setItem( storage_prefix+element.id, element.value );
}
/*
* Other events
*/
function on_balance_worker_message(e) {
if ( ! Array.isArray(e.data) ) {
return;
}
if ( e.data.length == 0 ) {
return;
}
var event_type = e.data[0];
if ( event_type == "progress" ) {
if (e.data.length < 2) {
return;
}
var progress_struct = e.data[1];
document.getElementById("dlg_progress_bar").value = progress_struct.current_progress;
document.getElementById("dlg_progress_text").innerHTML = progress_struct.current_progress.toString() + " %";
} else if ( event_type == "finish" ) {
if (e.data.length < 2) {
return;
}
var result_struct = e.data[1];
if ( result_struct.is_successfull ) {
document.getElementById("role_lock_enabled").checked = result_struct.is_rolelock;
localStorage.setItem(storage_prefix+"role_lock_enabled", result_struct.is_rolelock );
// copy references to players from balancer to global teams
team1 = result_struct.team1.slice();
team2 = result_struct.team2.slice();
init_team_slots( team1_slots );
for( let class_name in result_struct.team1_slots ) {
team1_slots[class_name] = result_struct.team1_slots[class_name].slice();
}
init_team_slots( team2_slots );
for( let class_name in result_struct.team2_slots ) {
team2_slots[class_name] = result_struct.team2_slots[class_name].slice();
}
sort_players( team1, 'sr' );
sort_players( team2, 'sr' );
redraw_teams();
// hide dialog
close_dialog("popup_dlg_progress");
} else {
document.getElementById("dlg_progress_text").innerHTML = "Balance not found";
document.getElementById("dlg_progress_cancel").style.display = "none";
document.getElementById("dlg_progress_close").style.display = "";
}
} else if ( event_type == "error" ) {
if (e.data.length < 2) {
return;
}
alert("Balancer error: "+e.data[1]);
} else if ( event_type == "dbg" ) {
if (e.data.length < 2) {
return;
}
var dbg_msg = e.data[1];
document.getElementById("debug_log").innerHTML += dbg_msg+"</br>";
}
}
function on_player_stats_updated( player_id ) {
if ( player_being_added !== undefined ) {
if ( player_id == player_being_added.id ) {
// add new player to team with empty slots or lobby
var target_team = find_team_with_free_slot( player_being_added );
if ( target_team == undefined ) {
target_team = lobby;
}
target_team.push( player_being_added );
save_players_list();
redraw_lobby();
redraw_teams();
highlight_player( player_id );
setTimeout( function() {document.getElementById(player_id).scrollIntoView(false);}, 100 );
document.getElementById("new_player_id").value = "";
document.getElementById("add_btn").disabled = false;
player_being_added = undefined;
}
} else {
if ( player_being_edited !== undefined ) {
if ( player_id == player_being_edited.id ) {
// redraw edit dialog
fill_player_stats_dlg(false);
// hide loader
document.getElementById("dlg_update_player_stats_loader").style.display = "none";
}
}
// find and redraw player
var player_struct = find_player_by_id( player_id );
if ( player_struct !== undefined ) {
redraw_player( player_struct );
highlight_player( player_id );
save_players_list();
}
}
}
function on_stats_update_complete() {
document.getElementById("stats_updater_status").innerHTML = "Update complete";
setTimeout( draw_stats_updater_status, StatsUpdater.min_api_request_interval );
document.getElementById("update_stats_stop_btn").style.visibility = "hidden";
document.getElementById("stats_update_progress").style.visibility = "hidden";
}
function on_stats_update_error( player_id, error_msg, is_changed ) {
log_stats_update_error( player_id+": "+error_msg );
if ( player_being_added !== undefined ) {
if ( player_being_added.id == player_id ) {
if( confirm("Can't get player stats: "+error_msg+"\nAdd manually?") ) {
var new_player = create_empty_player();
new_player.id = player_id;
new_player.display_name = format_player_name( player_id );
delete new_player.empty;
// add new player to team with empty slots or lobby
var target_team = find_team_with_free_slot( new_player );
if ( target_team == undefined ) {
target_team = lobby;
}
target_team.push( new_player );
save_players_list();
redraw_lobby();
redraw_teams();
highlight_player( player_id );
setTimeout( function() {document.getElementById(player_id).scrollIntoView(false);}, 100 );
document.getElementById("new_player_id").value = "";
// open edit dialog
player_being_edited = new_player;
fill_player_stats_dlg();
open_dialog("popup_dlg_edit_player");
}
document.getElementById("add_btn").disabled = false;
// release created object for garbage collector
player_being_added = undefined;
}
}
if ( player_being_edited !== undefined ) {
if ( player_id == player_being_edited.id ) {
// hide loader, show message
document.getElementById("dlg_update_player_stats_loader").style.display = "none";
document.getElementById("dlg_edit_player_update_result").style.display = "";
document.getElementById("dlg_edit_player_update_result").innerHTML = escapeHtml( error_msg );
if ( is_changed ) {
if ( player_struct.private_profile === true ) {
document.getElementById("dlg_player_private_profile").style.display = "inline";
} else {
document.getElementById("dlg_player_private_profile").style.display = "none";
}
}
}
}
if ( is_changed ) {
save_players_list();
}
}
function on_stats_update_warning( player_id, error_msg ) {
log_stats_update_error( player_id+": "+error_msg );
if ( player_being_edited !== undefined ) {
if ( player_id == player_being_edited.id ) {
document.getElementById("dlg_edit_player_update_result").style.display = "";
document.getElementById("dlg_edit_player_update_result").innerHTML += escapeHtml( error_msg );
}
}
}
function on_stats_update_progress() {
draw_stats_updater_status();
}
function on_stats_update_start() {
document.getElementById("update_stats_stop_btn").style.visibility = "visible";
document.getElementById("stats_update_progress").style.visibility = "visible";
draw_stats_updater_status();
}
/*
* Common UI functions
*/
function apply_lobby_filter() {
var filter_value = document.getElementById("lobby_filter").value.toLowerCase();
if (filter_value != "") {
document.getElementById("lobby_filter").classList.add("filter-active");
} else {
document.getElementById("lobby_filter").classList.remove("filter-active");
}
for( var i=0; i<lobby.length; i++) {
if ( filter_value == "" || lobby[i].display_name.toLowerCase().includes( filter_value ) || lobby[i].id.toLowerCase().includes( filter_value ) ) {
document.getElementById(lobby[i].id).parentElement.style.display = "table-row";
} else {
document.getElementById(lobby[i].id).parentElement.style.display = "none";
}
}
}
function convert_range_log_scale( raw_value, out_min, out_max, precision=0, input_range=100 ) {
return round_to( Math.pow( 2, Math.log2(out_min)+(Math.log2(out_max)-Math.log2(out_min))*raw_value/input_range ), precision );
}
function draw_player( player_struct, small=false, is_captain=false, slot_class=undefined ) {
var new_player_item_row = document.createElement("div");
new_player_item_row.className = "row";
if ( slot_class != undefined ) {
var class_cell = document.createElement("div");
class_cell.className = "cell class-cell";
var class_icon = document.createElement("img");
class_icon.className = "class-icon-slot";
class_icon.src = "class_icons/"+slot_class+".png";
class_icon.title = slot_class;
class_cell.appendChild(class_icon);
new_player_item_row.appendChild(class_cell);
}
var new_player_cell = draw_player_cell( player_struct, small, is_captain, slot_class );
new_player_item_row.appendChild(new_player_cell);
return new_player_item_row;
}
function draw_player_cell( player_struct, small=false, is_captain=false, slot_class=undefined ) {
var text_node;
var br_node;
var new_player_item = document.createElement("div");
new_player_item.className = "cell player-item";
if( player_struct.empty ) {
new_player_item.classList.add("empty-player");
}
new_player_item.id = player_struct.id;
if( ! player_struct.empty) {
new_player_item.title = player_struct.id;
new_player_item.title += "\nLevel: " + player_struct.level;
for( let class_name of player_struct.classes ) {
new_player_item.title += "\n"+class_name+": "+is_undefined(player_struct.sr_by_class[class_name],0)+" sr";
}
new_player_item.title += "\nLast updated: " + print_date(player_struct.last_updated);
if ( is_captain ) {
new_player_item.title += "\nTeam captain";
}
if ( Array.isArray(player_struct.top_heroes) ) {
new_player_item.title += "\nTop heroes: ";
for( i=0; i<player_struct.top_heroes.length; i++ ) {
new_player_item.title += player_struct.top_heroes[i].hero;
if ( i< player_struct.top_heroes.length-1) {
new_player_item.title += ", ";
}
}
}
}
if( ! player_struct.empty) {
new_player_item.draggable = true;
}
new_player_item.ondragstart = function(event){player_drag(event);};
new_player_item.ondrop = function(event){player_drop(event);};
new_player_item.ondragover = function(event){player_allowDrop(event);};
new_player_item.ondblclick = function(event){player_dblClick(event);};
new_player_item.oncontextmenu = function(event){player_contextmenu(event);};
if( slot_class != undefined ) {
new_player_item.setAttribute( "slotClass", slot_class );
}
// rank icon
var player_icon = document.createElement("div");
player_icon.className = "player-icon";
var icon_image = document.createElement("div");
icon_image.className = "icon-image";
var img_node = document.createElement("img");
img_node.className = "rank-icon";
var sr_calc_method = Settings["sr_calc_method"];
if( slot_class != undefined ) {
sr_calc_method = slot_class;
}
var player_sr = get_player_sr( player_struct, sr_calc_method );
var rank_name = get_rank_name( player_sr );
img_node.src = "rank_icons/"+rank_name+"_small.png";
img_node.title = rank_name;
icon_image.appendChild(img_node);
player_icon.appendChild(icon_image);
// SR value
br_node = document.createElement("br");
player_icon.appendChild(br_node);
var icon_sr = document.createElement("div");
icon_sr.className = "icon-sr";
var sr_display = document.createElement("span");
sr_display.id = "sr_display_"+player_struct.id;
var sr_text = player_sr;
if( player_struct.empty ) {
sr_text = '\u00A0';
}
text_node = document.createTextNode( sr_text );
sr_display.appendChild(text_node);
if( player_struct.se === true ) {
sr_display.classList.add("sr-edited");
}
icon_sr.appendChild(sr_display);
player_icon.appendChild(icon_sr);
new_player_item.appendChild(player_icon);
// space after rank icon
text_node = document.createTextNode("\u00A0");
new_player_item.appendChild(text_node)
// player name
var player_name = document.createElement("div");
player_name.className = "player-name";
var name_display = document.createElement("span");
name_display.id = "name_display_"+player_struct.id;
var display_name = player_struct.display_name;
if ( display_name == "" ) {
display_name = "\u00A0"; // nbsp
}
text_node = document.createTextNode( display_name );
name_display.appendChild(text_node);
player_name.appendChild(name_display);
// captain mark
if ( is_captain ) {
var captain_icon = document.createElement("span");
captain_icon.className = "captain-mark";
captain_icon.title = "team captain";
text_node = document.createTextNode( " \u265B" );
captain_icon.appendChild(text_node);
player_name.appendChild(captain_icon);
}
new_player_item.appendChild(player_name);
// check-in mark
if ( (!small) && (checkin_list.has(player_struct.id)) ) {
var mark_display = document.createElement("span");
mark_display.className = "player-checkin-mark";
mark_display.title = "Checked-in";
text_node = document.createTextNode( "\u2713" );
mark_display.appendChild(text_node);
player_name.appendChild(mark_display);
}
// active classes icons
if ( player_struct.classes !== undefined ) {
for(var i=0; i<player_struct.classes.length; i++) {
var class_icon = document.createElement("img");
class_icon.className = "class-icon";
if( i != 0 ) {
class_icon.classList.add("secondary-class");
}
if( player_struct.ce === true ) {
class_icon.classList.add("class-edited");
}
class_icon.src = "class_icons/"+player_struct.classes[i]+".png";
class_icon.title = player_struct.classes[i] + " " + is_undefined(player_struct.sr_by_class[player_struct.classes[i]],0) + " SR";
new_player_item.appendChild(class_icon);
}
}
// pinned mark
if ( pinned_players.has(player_struct.id) ) {
var pinned_icon = document.createElement("img");
pinned_icon.className = "pinned-icon";
pinned_icon.title = "pinned";
pinned_icon.src = "img/pinned.png";
player_name.appendChild(pinned_icon);
}
return new_player_item;
}
function draw_stats_updater_status() {
var updater_status_txt = "";
if ( StatsUpdater.state == StatsUpdaterState.updating ) {
updater_status_txt += "Updating stats <br/>"+ StatsUpdater.currentIndex + " / " + StatsUpdater.totalQueueLength;
updater_status_txt += " "+StatsUpdater.current_id;
}
document.getElementById("stats_updater_status").innerHTML = updater_status_txt;
document.getElementById("stats_update_progress").value = StatsUpdater.currentIndex;
document.getElementById("stats_update_progress").max = StatsUpdater.totalQueueLength;
}
function fill_player_stats_dlg( clear_errors=true ) {
if (player_being_edited === undefined) {
return;
}
var player_struct = player_being_edited;
document.getElementById("dlg_title_edit_player").innerHTML = escapeHtml( player_struct.display_name );
document.getElementById("dlg_player_id").href = "https://playoverwatch.com/en-us/career/pc/"+player_struct.id;
document.getElementById("dlg_player_id").innerHTML = player_struct.id;
if ( player_struct.private_profile === true ) {
document.getElementById("dlg_player_private_profile").style.display = "inline";
} else {
document.getElementById("dlg_player_private_profile").style.display = "none";
}
document.getElementById("dlg_player_display_name").value = player_struct.display_name;
if( player_struct.ne === true ) {
document.getElementById("dlg_player_name_edited").style.visibility = "visible";
} else {
document.getElementById("dlg_player_name_edited").style.visibility = "";
}
document.getElementById("dlg_player_level").value = player_struct.level;
document.getElementById("dlg_player_pinned").checked = pinned_players.has( player_struct.id );
document.getElementById("dlg_player_checkin").checked = checkin_list.has( player_struct.id );
// fill class table
document.getElementById("dlg_player_class_table").innerHTML = "";
// prepare array of classes, ordered for specified player (main class is first)
var class_order = [];
if ( Array.isArray(player_struct.classes) ) {
for( i=0; i<player_struct.classes.length; i++ ) {
class_order.push( player_struct.classes[i] );
}
}
for( let class_name of class_names ) {
if ( class_order.indexOf(class_name) == -1 ) {
class_order.push( class_name );
}
}
for( let class_name of class_order ) {
var class_row = player_class_row_add();
//var class_name = player_struct.classes[i];
var class_checkbox = class_row.getElementsByClassName("dlg-class-enabled-checkbox")[0];
if ( player_struct.classes.indexOf(class_name) == -1 ) {
class_checkbox.checked = false;
class_row.classList.add("class-disabled");
} else {
class_checkbox.checked = true;
}
var class_title = class_row.getElementsByClassName("dlg-class-name")[0];
class_title.innerHTML = class_name;
var class_img = class_row.getElementsByClassName("class-icon-dlg")[0];
class_img.src = "class_icons/"+class_name+".png";
var sr_edit = class_row.getElementsByClassName("dlg-sr-by-class")[0];
var sr = player_struct.sr_by_class[class_name];
if ( sr == undefined ) {
sr = 0;
}
sr_edit.value = sr;
var rank_name = get_rank_name( sr );
var sr_img = class_row.getElementsByClassName("rank-icon-dlg")[0];
sr_img.src = "rank_icons/"+rank_name+"_small.png";
sr_img.title = rank_name;
var time_played = player_struct.playtime_by_class[class_name];
if ( time_played == undefined ) {
time_played = 0;
}
var time_span = class_row.getElementsByClassName("dlg-payer-class-playtime")[0];
time_span.innerHTML = time_played + " hrs";
}
if( player_struct.se === true ) {
var marks = document.getElementById("dlg_player_class_table").getElementsByClassName("dlg-edited-mark-sr");
for( i=0; i<marks.length; i++ ) {
marks[i].style.visibility = "visible";
}
}
document.getElementById("dlg_top_heroes_icons").innerHTML = "";
if ( Array.isArray(player_struct.top_heroes) ) {
for( i=0; i<player_struct.top_heroes.length; i++ ) {
var hero_id = player_struct.top_heroes[i].hero;
if( hero_id == "soldier76") {
hero_id = "soldier-76";
}
if( hero_id == "wrecking_ball") {
hero_id = "wrecking-ball";
}
var img_node = document.createElement("img");
img_node.className = "hero-icon";
img_node.src = "https://blzgdapipro-a.akamaihd.net/hero/"+hero_id+"/hero-select-portrait.png";
img_node.title = hero_id + "\nPlayed: " + player_struct.top_heroes[i].playtime+" h";
document.getElementById("dlg_top_heroes_icons").appendChild(img_node);
}
}
if( player_struct.ce === true ) {
document.getElementById("dlg_player_class1_edited").style.visibility = "visible";
} else {
document.getElementById("dlg_player_class1_edited").style.visibility = "";
}
document.getElementById("dlg_edit_player_last_updated").innerHTML = print_date(player_struct.last_updated);
document.getElementById("dlg_update_player_stats_loader").style.display = "none";
if (clear_errors) {
document.getElementById("dlg_edit_player_update_result").style.display = "none";
document.getElementById("dlg_edit_player_update_result").innerHTML = "";
}
}
function fill_settings_dlg( settings_obj ) {
for ( setting_name in settings_obj ) {
var setting_value = settings_obj[setting_name];
if ( setting_name == "slots_count" ) {
continue;
}
var setting_input = document.getElementById(setting_name);
if (setting_input === null) { alert("broken setting: "+setting_name);}
switch( setting_input.type ) {
case "checkbox":
setting_input.checked = setting_value;
break;
default:
setting_input.value = setting_value;
}
}
var setting_name = "slots_count";
for ( class_name in settings_obj[setting_name] ) {
var setting_input = document.getElementById(setting_name+"_"+class_name);
if (setting_input === null) { alert("broken setting: "+setting_name);}
var setting_value = settings_obj[setting_name][class_name];
setting_input.value = setting_value;
}
adjust_sr_change();
}
function get_parent_element( current_element, parent_tagname ) {
var parent_element = current_element;
// ascend in dom tree
while ( parent_element.tagName != parent_tagname ) {
parent_element = parent_element.parentElement;
if ( parent_element == null ) {
return null;
}
}
return parent_element;
}
function highlight_player( player_id ) {
document.getElementById(player_id).classList.toggle("player-highlighted", true);
setTimeout( reset_highlighted_players, 2000 );
}
function highlight_players( player_list ) {
for( i=0; i<player_list.length; i++ ) {
var player_id = "";
if ( typeof player_list[i] == "string" ) {
player_id = player_list[i];
} else {
player_id = player_list[i].id;
}
document.getElementById(player_id).classList.toggle("player-highlighted", true);
}
setTimeout( reset_highlighted_players, 2000 );
}
function log_stats_update_error( msg ) {
var log_text = document.getElementById("stats_update_log").value;
log_text = (log_text + "\n" + msg).trim();
document.getElementById("stats_update_log").value = log_text;
document.getElementById("stats_update_errors").style.visibility = "visible";
document.getElementById("stats_update_errors_count").innerHTML = log_text.split("\n").length;
}
function open_dialog( dialog_id ) {
document.getElementById( dialog_id ).style.display = "block";
}
function player_class_row_add() {
var class_table = document.getElementById("dlg_player_class_table");
var row = class_table.insertRow(-1);
row.className = "dlg-player-class-row";
var cell, img, input_node, text_node, span_node;
cell = row.insertCell(-1);
input_node = document.createElement("input");
input_node.type = "checkbox";
input_node.title = "class enabled for balance";
input_node.className = "dlg-class-enabled-checkbox";
input_node.checked = true;
input_node.onchange = function(event){on_player_edit_class_toggled(event);};
cell.appendChild(input_node);
cell = row.insertCell(-1);
cell.style = "text-align: left;";
img = document.createElement("img");
img.className = "class-icon-dlg";
img.src = "class_icons/"+class_names[0]+".png";
cell.appendChild(img);
span_node = document.createElement("span");
span_node.className = "dlg-class-name";
text_node = document.createTextNode( "class_name" );
span_node.appendChild(text_node);
cell.appendChild(span_node);
cell = row.insertCell(-1);
img = document.createElement("img");
img.className = "rank-icon-dlg";
img.src = "rank_icons/unranked_small.png";
cell.appendChild(img);
input_node = document.createElement("input");
input_node.className = "dlg-sr-by-class";
input_node.type = "number";
input_node.min = 0;
input_node.max = 4999;
input_node.value = 0;
input_node.oninput = function(event){on_player_class_sr_changed(event);};
cell.appendChild(input_node);
text_node = document.createTextNode( " SR " );
cell.appendChild(text_node);
span_node = document.createElement("span");
span_node.className = "dlg-edited-mark-sr";
span_node.title = "SR was manually edited";
span_node.style.visibility = "hidden";
span_node.onclick = function(event){clear_edited_mark('se');};
text_node = document.createTextNode( "\u270D" );
span_node.appendChild(text_node);
cell.appendChild(span_node);
cell = row.insertCell(-1);
span_node = document.createElement("span");
span_node.className = "dlg-payer-class-playtime";
text_node = document.createTextNode( "0 hrs" );
span_node.appendChild(text_node);
cell.appendChild(span_node);
cell = row.insertCell(-1);
input_node = document.createElement("input");
input_node.type = "button";
input_node.value = "\u2191";
input_node.onclick = function(event){player_class_row_moveup(event);};
input_node.title = "move class higher";
cell.appendChild(input_node);
input_node = document.createElement("input");
input_node.type = "button";
input_node.value = "\u2193";
input_node.onclick = function(event){player_class_row_movedown(event);};
input_node.title = "move class lower";
cell.appendChild(input_node);
input_node = document.createElement("input");
return row;
}
function redraw_lobby() {
var team_container = document.getElementById("lobby");
team_container.innerHTML = "";
for( var i=0; i<lobby.length; i++) {
var player_widget = draw_player( lobby[i] );
team_container.appendChild(player_widget);
}
for( i=lobby.length; i<get_team_size(); i++) {
var player_widget = draw_player( create_empty_player() );
team_container.appendChild(player_widget);
}
document.getElementById("lobby_count").innerHTML = lobby.length;
if (document.getElementById("lobby_filter").value != "") {
apply_lobby_filter();
}
//check-in counter
document.getElementById("checkin_counter").innerHTML = checkin_list.size;
}
function redraw_player( player_struct ) {
var is_small = (lobby.indexOf(player_struct) == -1);
var player_cell_old = document.getElementById( player_struct.id );
var player_item_row = player_cell_old.parentElement;
var slot_class = undefined;
if (is_small && is_role_lock_enabled()) {
// find player slot
for (var team_slots of [team1_slots, team2_slots]) {
var tmp = get_player_role( team_slots, player_struct );
if (tmp !== undefined ) {
slot_class = tmp;
break;
}
}
}
var player_cell_new = draw_player_cell( player_struct, is_small, false, slot_class );
player_item_row.replaceChild( player_cell_new, player_cell_old );
update_teams_sr();
}
function redraw_teams() {
redraw_team( 1, team1, team1_slots );
redraw_team( 2, team2, team2_slots );
update_teams_sr();
save_players_list();
}
function redraw_team( team_number, players_array, players_slots ) {
var team_container = document.getElementById("team"+team_number);
team_container.innerHTML = "";
if ( is_role_lock_enabled() ) {
// draw players from slots (role lock)
for( let class_name of class_names ) {
var players_drawn = 0;
if ( players_slots[class_name] != undefined ) {
for( var i=0; i<players_slots[class_name].length; i++) {
var player_widget = draw_player( players_slots[class_name][i], true, false, class_name );
team_container.appendChild(player_widget);
players_drawn++;
}
}
// add empty slots up to slots count
for( var i=players_drawn; i<Settings["slots_count"][class_name]; i++) {
var player_widget = draw_player( create_empty_player(), true, false, class_name );
team_container.appendChild(player_widget);
}
}
} else {
// draw players from array (no role lock)
for( var i=0; i<players_array.length; i++) {
var player_widget = draw_player( players_array[i], true );
team_container.appendChild(player_widget);
}
// add empty slots up to team size
var team_size = get_team_size();
for( i=players_array.length; i<team_size; i++) {
var player_widget = draw_player( create_empty_player(), true );
team_container.appendChild(player_widget);
}
}
}
function reset_highlighted_players() {
var elems = document.getElementsByClassName( "player-highlighted" );
for( i=0; i<elems.length; i++ ) {
elems[i].classList.toggle("player-highlighted", false);
}
}
function reset_roll() {
for( t in teams ) {
lobby = lobby.concat( teams[t].players.splice( 0, teams[t].players.length) );
}
teams.splice( 0, teams.length );
save_players_list();
redraw_lobby();
redraw_teams();
}
function select_html( html_container ) {
if (document.body.createTextRange) {
const range = document.body.createTextRange();
range.moveToElementText(html_container);
range.select();
} else if (window.getSelection) {
const selection = window.getSelection();
const range = document.createRange();
range.selectNodeContents(html_container);
selection.removeAllRanges();
selection.addRange(range);
}
}
function update_teams_sr() {
document.getElementById("team1_sr").innerHTML = calc_team_sr(team1, team1_slots);
document.getElementById("team2_sr").innerHTML = calc_team_sr(team2, team2_slots);
}
| 30.353107 | 147 | 0.712331 |
27cb10aa505176b56166a69b8d6aa4c8c2174901 | 260 | js | JavaScript | public/js/index.js | DevPrecious/ekhie-laravel | 5d0f4791fc5ef20e6882b708ae877d30d9f4398b | [
"MIT"
] | 1 | 2022-02-07T23:35:21.000Z | 2022-02-07T23:35:21.000Z | public/js/index.js | DevPrecious/ekhie-laravel | 5d0f4791fc5ef20e6882b708ae877d30d9f4398b | [
"MIT"
] | null | null | null | public/js/index.js | DevPrecious/ekhie-laravel | 5d0f4791fc5ef20e6882b708ae877d30d9f4398b | [
"MIT"
] | null | null | null | //set counter for ticket amount
const place = document.getElementById('amount')
var count = 0
place.innerHTML = count
const handleIncrement = () => {
count++
place.innerHTML = count
}
const handleDecrement = () => {
count--
place.innerHTML = count
}
| 17.333333 | 47 | 0.688462 |
27cce5623f43a46e9d95d624d2ce008c0225d70a | 314 | js | JavaScript | src/app/_global/components/PrismicRichText.js | Vinnovera/nextJsReduxPrismicIo | 92a27d2680e420315d58b23cdc8c62b2e7e9deba | [
"MIT"
] | null | null | null | src/app/_global/components/PrismicRichText.js | Vinnovera/nextJsReduxPrismicIo | 92a27d2680e420315d58b23cdc8c62b2e7e9deba | [
"MIT"
] | null | null | null | src/app/_global/components/PrismicRichText.js | Vinnovera/nextJsReduxPrismicIo | 92a27d2680e420315d58b23cdc8c62b2e7e9deba | [
"MIT"
] | null | null | null | import { RichText } from 'prismic-reactjs'
import { linkResolver } from '../services/prismic'
/**
* Will render a div with styled rich text
* @param text
* @returns {*}
* @constructor
*/
function RichTextComponent ({ data }) {
return RichText.render(data, linkResolver)
}
export default RichTextComponent
| 20.933333 | 50 | 0.710191 |
27cd1a95c27906e5a9b0e723c06ec7049c62b644 | 14,910 | js | JavaScript | dashboard/src/routes/ECommerce/ECommerceContainer.js | Cruzercru/DevToolsBot | 6bcefe47fd353118177e1db85d5bfdb26802cf9e | [
"Apache-2.0"
] | 3 | 2018-04-25T09:55:35.000Z | 2018-05-09T11:59:50.000Z | dashboard/src/routes/ECommerce/ECommerceContainer.js | Cruzercru/DevToolsBot | 6bcefe47fd353118177e1db85d5bfdb26802cf9e | [
"Apache-2.0"
] | null | null | null | dashboard/src/routes/ECommerce/ECommerceContainer.js | Cruzercru/DevToolsBot | 6bcefe47fd353118177e1db85d5bfdb26802cf9e | [
"Apache-2.0"
] | null | null | null | import React from 'react';
import uid from 'node-uuid';
import _ from 'underscore';
import leftPad from 'left-pad';
import deepAssign from 'assign-deep';
import numeral from 'numeral';
import moment from 'moment';
import classNames from 'classnames';
import { Link } from 'react-router';
import {
Row,
Col,
Media,
Panel,
ButtonGroup,
Button,
Table,
Image,
Charts,
AvatarImage
} from 'components';
import { RoutedComponent, connect } from 'routes/routedComponent'
import treeRandomizer from 'modules/treeRandomizer';
import renderSection from 'modules/sectionRender';
import { CONTENT_VIEW_STATIC } from 'layouts/DefaultLayout/modules/layout';
import { Colors } from 'consts';
import classes from './ECommerce.scss';
import eCommerceData from 'consts/data/e-commerce.json';
const DataSet = {
Revenue: 'Revenue',
ItemsSold: 'ItemsSold'
};
const TransactionStatus = {
Waiting: 0,
Confirmed: 1,
Expired: 2
};
// ------------------------------------
// Config / Data Generator
// ------------------------------------
const getData = (inputData) => treeRandomizer(inputData);
const getChartData = (data, name) => ({
xAxis: {
categories: _.map(data, (entry) => moment(entry.date).format('MMM'))
},
series: [{
name: name,
data: _.map(data, (entry) => parseFloat(entry.value))
}]
});
// ------------------------------------
// Sub Elements
// ------------------------------------
const renderSummary = (summary) => {
const renderSummaryBox = (title, data, currency = '') => {
const beginDate = moment().subtract(7, 'days');
const endDate = moment();
return (
<Panel
key={ uid.v4() }
className={ classes.summaryPanel }
header= {
<div>
{ title }
<small className={ classes.summaryPanelDate }>
{ `${beginDate.format('DD')} - ${endDate.format('DD MMMM YYYY')}` }
</small>
</div>
}
>
<p className={classes.summaryValue}>
{`${currency} ${numeral(data.value).format('0,0')}`}
</p>
<span
className={`${classes.summaryDiff} ${data.diff > 0
? classes.summaryDiffInc : classes.summaryDiffDec}`}
>
{ data.diff > 0 ?
<i className='fa fa-fw fa-caret-up'></i> :
<i className='fa fa-fw fa-caret-down'></i>
}
{data.diff}%
<small>from last week</small>
</span>
</Panel>
);
}
return (
<Row>
<Col md={ 4 }>
{ renderSummaryBox('Total Revenue', summary.TotalRevenue, 'IDR') }
</Col>
<Col md={ 4 }>
{ renderSummaryBox('Total Items Sold', summary.TotalItemsSold) }
</Col>
<Col md={ 4 }>
{ renderSummaryBox('Total Visitors', summary.TotalVisitors) }
</Col>
</Row>
);
}
const renderLatestTransactions = (transactions) => {
const renderTransactionRow = (transaction) => {
const statusIconClasses = classNames('fa fa-circle',
classes.transactionStatus, {
[`${classes.transactionStatusSuccess}`]:
transaction.status == TransactionStatus.Confirmed,
[`${classes.transactionStatusDanger}`]:
transaction.status == TransactionStatus.Expired,
[`${classes.transactionStatusWarning}`]:
transaction.status == TransactionStatus.Waiting
});
return (
<tr key={uid.v4()}>
<td>
<Media>
<Media.Left>
<Link to='/apps/profile-details'>
<AvatarImage
src={ transaction.userAvatar }
/>
</Link>
</Media.Left>
<Media.Body className={classes.mediaFix}>
<span className='text-white'>
{ `${transaction.userFirstName} ${transaction.userLastName}` }
</span><br/>
<span>on {moment(transaction.date).format('MMM Do YYYY')}</span>
</Media.Body>
</Media>
</td>
<td>
IDR {numeral(transaction.price).format('0,0.00')}
</td>
<td>
<i className={statusIconClasses}></i>
{ transaction.status == TransactionStatus.Confirmed ? 'Confirmed' : null }
{ transaction.status == TransactionStatus.Expired ? 'Payment Expired' : null }
{ transaction.status == TransactionStatus.Waiting ? 'Waiting for Payment' : null }
</td>
</tr>
);
};
return (
<div className={ classes.latestTransactions }>
<div className={ classes.boxHeader }>
<h5 className={ classes.boxHeaderTitle }>
Latest Transactions
</h5>
<Button
className={ classes.buttonWithIcon }
bsSize='small'
>
See All Transactions
<i className="fa fa-angle-right"></i>
</Button>
</div>
<Table className={ classes.transactionsTable }>
<thead>
<tr>
<th>
Name
</th>
<th>
Price
</th>
<th>
Status
</th>
</tr>
</thead>
<tbody>
{ _.map(transactions, (transaction) => renderTransactionRow(transaction)) }
</tbody>
</Table>
</div>
);
}
const renderLatestComments = (comments) => {
const renderCommentPreview = (comment) => {
return (
<li key={ uid.v4() }>
<Media>
<Media.Left>
<Link to='/apps/profile-details'>
<AvatarImage
src={ comment.userAvatar }
/>
</Link>
</Media.Left>
<Media.Body>
<Media.Heading componentClass='div'>
<span className='text-white'>
{`${comment.userFirstName} ${comment.userLastName}`}
</span>
<br/>
<span>
{ moment(comment.data).format('MMM Do YYYY') } on
<a href="javascript:void(0)"> {comment.category}</a>
</span>
</Media.Heading>
<p className={classes.commentContent}>
{ comment.comment }
</p>
</Media.Body>
</Media>
</li>
)
};
return (
<div className={ classes.latestComments }>
<div className={ classes.boxHeader }>
<h5 className={ classes.boxHeaderTitle }>
Latest Comments
</h5>
<Button
className={ classes.buttonWithIcon }
bsSize='small'
>
See All Comments
<i className="fa fa-angle-right"></i>
</Button>
</div>
<ul className={classes.commentsList}>
{ _.map(comments, (comment) => renderCommentPreview(comment)) }
</ul>
</div>
);
}
const renderMostViewedItems = (mostViewed) => {
const getQuantityStatusClass = (quantity) => {
return classNames('fa', 'fa-circle', classes.mostViewedItemStatus, {
[`${classes.mostViewedItemStatusSuccess}`]: quantity > 100,
[`${classes.mostViewedItemStatusWarning}`]: (quantity <= 100 && quantity > 10),
[`${classes.mostViewedItemStatusDanger}`]: quantity <= 10,
});
};
const renderMostViewedItem = (item) => (
<tr key={uid.v4()}>
<td>
<Media>
<Media.Left>
<a href='javascript:void(0)'>
<span className="fa-stack fa-lg">
<i className="fa fa-square fa-stack-2x text-gray-light"></i>
<i className="fa fa-shopping-basket fa-stack-1x fa-inverse"></i>
</span>
</a>
</Media.Left>
<Media.Body className={ classes.mediaFix }>
<Media.Heading componentClass='div'>
<span className='text-white'>
{ item.name }
</span>
<br />
<span>
IDR { item.price }
</span>
</Media.Heading>
</Media.Body>
</Media>
</td>
<td>
<span className='text-white'>
{ item.viewCount }
<br/>
Views
</span>
</td>
<td>
<i className={ getQuantityStatusClass(item.countLeft) }></i>
<span className='text-white'>{ item.countLeft }</span> Items Left
</td>
</tr>
);
return (
<div className={ classes.mostViewedItems }>
<div className={ classes.boxHeader }>
<h5 className={ classes.boxHeaderTitle }>
Most Viewed
</h5>
<Button
className={ classes.buttonWithIcon }
bsSize='small'
>
See All Transactions
<i className="fa fa-angle-right"></i>
</Button>
</div>
<Table className={ classes.mostViewedItemsTable }>
<thead>
<tr>
<th>
<strong>Name</strong>
</th>
<th>
<strong>Price</strong>
</th>
<th>
<strong>Status</strong>
</th>
</tr>
</thead>
<tbody>
{ _.map(mostViewed, (item) => renderMostViewedItem(item)) }
</tbody>
</Table>
</div>
)
}
// ------------------------------------
// Main Container
// ------------------------------------
class ECommerceContainer extends RoutedComponent {
constructor(props, context) {
super(props, context);
this.state = deepAssign({}, {
Report: {
selected: 'Revenue'
}
}, getData(eCommerceData));
}
getLayoutOptions() {
return {
contentView: CONTENT_VIEW_STATIC
}
}
renderChart(data) {
const dataset = data[data.selected];
const datasetName = data.selected === DataSet.Revenue
? 'Revenue' : 'Items Sold';
const chartData = getChartData(dataset, datasetName);
const chartPeriodStart = moment(_.first(dataset).date).format('MMM YYYY');
const chartPeriodEnd = moment(_.last(dataset).date).format('MMM YYYY');
const changeDataSet = (datasetName) => {
this.setState(deepAssign({}, this.state, {
Report: {
selected: datasetName
}
}));
}
return (
<div className={ classes.chart }>
<div className={ classes.boxHeader }>
<div>
<h5 className={ classes.boxHeaderTitle }>
Report Statisticts
</h5>
<small>Period: {`${chartPeriodStart} - ${chartPeriodEnd}`}</small>
</div>
<ButtonGroup bsSize='small'>
<Button
onClick={ () => changeDataSet(DataSet.ItemsSold) }
active={ this.state.Report.selected === DataSet.ItemsSold }
>
Items Sold
</Button>
<Button
onClick={ () => changeDataSet(DataSet.Revenue) }
active={ this.state.Report.selected === DataSet.Revenue }
>
Revenue
</Button>
</ButtonGroup>
</div>
<Charts.HighchartBasicColumn className={classes.chartObject} config={ chartData } />
</div>
);
}
render() {
return (
<div className={classes.mainWrap}>
<Row>
<Col md={ 12 }>
{ renderSection(renderSummary, this.state.Summary) }
</Col>
</Row>
<Row className={ classes.sectionRow }>
<Col md={ 6 }>
{ this.renderChart(this.state.Report) }
</Col>
<Col md={ 6 }>
{ renderSection(renderLatestTransactions,
this.state.LatestTransactions) }
</Col>
</Row>
<Row className={ classes.sectionRow }>
<Col md={ 6 }>
{ renderSection(renderLatestComments, this.state.LatestComments) }
</Col>
<Col md={ 6 }>
{ renderSection(renderMostViewedItems, this.state.MostViewedItems) }
</Col>
</Row>
</div>
);
}
}
export default connect()(ECommerceContainer);
| 34.918033 | 102 | 0.414353 |
27cd961755dfa516336c1cd6e4975bed7078ff52 | 2,241 | js | JavaScript | source/editor.js | MikePopoloski/slang-website | a70d819ae9921b4b078f8643004bf5f8fb09a868 | [
"MIT"
] | 4 | 2019-08-04T12:09:56.000Z | 2021-06-02T15:29:38.000Z | source/editor.js | MikePopoloski/slang-website | a70d819ae9921b4b078f8643004bf5f8fb09a868 | [
"MIT"
] | 15 | 2019-09-03T00:02:46.000Z | 2022-03-01T02:16:35.000Z | source/editor.js | MikePopoloski/slang-website | a70d819ae9921b4b078f8643004bf5f8fb09a868 | [
"MIT"
] | null | null | null | import * as monaco from 'monaco-editor';
import _ from 'underscore';
import './sv-lang';
export default function EditorComponent(container, state) {
this.container = container;
this.domRoot = $('#codeEditor');
container.element.appendChild(this.domRoot.get(0));
this.session = state.session;
this.session.onCodeCompiled(_.bind(function (results) {
this.handleCompileResults(results);
}, this));
var editorRoot = this.domRoot.find(".monaco-placeholder");
this.editor = monaco.editor.create(editorRoot[0], {
scrollBeyondLastLine: false,
language: 'system-verilog',
fontFamily: 'monospace',
readOnly: false,
glyphMargin: true,
quickSuggestions: false,
fixedOverflowWidgets: true,
minimap: {
maxColumn: 80
},
lineNumbersMinChars: 3,
emptySelectionClipboard: true,
autoIndent: true,
formatOnType: true
});
this.updateEditorLayout = _.bind(function () {
var topBarHeight = this.domRoot.find(".top-bar").outerHeight(true) || 0;
this.editor.layout({width: this.domRoot.width(), height: this.domRoot.height() - topBarHeight});
}, this);
this.lastChangeEmitted = null;
this.debouncedEmitChange = _.debounce(_.bind(function () {
this.session.notifyEdit(this.getSource());
}, this), 200);
this.session.notifyEdit(this.getSource());
this.editor.getModel().onDidChangeContent(_.bind(function () {
this.debouncedEmitChange();
}, this));
container.on('resize', this.updateEditorLayout);
container.on('shown', this.updateEditorLayout);
container.on('destroy', _.bind(function () {
this.editor.dispose();
}, this));
}
EditorComponent.prototype.getSource = function () {
return this.editor.getModel().getValue();
};
EditorComponent.prototype.handleCompileResults = function (results) {
const markers = results.diags.map(d => ({
severity: d.severity,
startLineNumber: d.line,
startColumn: d.col,
endLineNumber: d.line,
endColumn: d.col + d.length,
message: d.message
}));
monaco.editor.setModelMarkers(this.editor.getModel(), "compiler", markers);
}; | 31.56338 | 104 | 0.64971 |
27ce67687aed25484c0653ccfa5266fe7c0a94ee | 2,422 | js | JavaScript | map_deck/src/components/layers/MapsClusterCounts.js | slnsw/dxlab-subplot | cf96bfd20f5334f9af02e7d57f171afda965f7eb | [
"MIT"
] | 2 | 2021-05-20T08:58:28.000Z | 2022-02-10T10:10:28.000Z | map_deck/src/components/layers/MapsClusterCounts.js | slnsw/dxlab-subplot | cf96bfd20f5334f9af02e7d57f171afda965f7eb | [
"MIT"
] | null | null | null | map_deck/src/components/layers/MapsClusterCounts.js | slnsw/dxlab-subplot | cf96bfd20f5334f9af02e7d57f171afda965f7eb | [
"MIT"
] | null | null | null |
import { CompositeLayer } from 'deck.gl'
import { TextLayer, IconLayer } from '@deck.gl/layers'
import Supercluster from 'supercluster'
const ICON_MAPPING = {
marker: {
x: 384,
y: 512,
width: 128,
height: 128,
anchorY: 128
}
}
export class MapsClusterCounts extends CompositeLayer {
shouldUpdateState ({ changeFlags }) {
return changeFlags.somethingChanged
}
updateState ({ props, changeFlags }) {
let refresh = false
const { data } = props
if (!data) {
return
}
if (changeFlags.dataChanged) {
const index = new Supercluster({ maxZoom: 16, radius: 60 })
index.load(
data.map(({ properties }) => ({
geometry: properties.centroid,
properties
}))
)
this.setState({ index })
refresh = true
}
const zoom = Math.floor(this.context.viewport.zoom)
if (this.state.zoom !== zoom || refresh) {
const cluster = this.state.index.getClusters([-180, -85, 180, 85], zoom)
this.setState({ cluster, zoom })
}
}
getIconSize (size) {
return Math.min(100, size) / 100 + 1
}
buildLayers () {
const { id, name } = this.props
const { cluster } = this.state
const layers = []
layers.push(new IconLayer(this.getSubLayerProps({
id: `${id}-layer-${name}-icon-cluster-count`,
data: cluster,
iconAtlas: 'location-icon-atlas.png',
iconMapping: ICON_MAPPING,
sizeScale: 60,
getPosition: d => d.geometry.coordinates,
getIcon: d => 'marker', // getIconName(d.properties.cluster ? d.properties.point_count : 1),
getSize: d => this.getIconSize(d.properties.cluster ? d.properties.point_count : 1)
})))
layers.push(new TextLayer(this.getSubLayerProps({
id: `${id}-layer-${name}-label-cluster-count`,
data: cluster,
pickable: false,
billboard: true,
fontFamily: 'Roboto Slab',
getPixelOffset: d => {
const size = this.getIconSize(d.properties.cluster ? d.properties.point_count : 1)
return [0, -(64 / (2 / size))]
},
getTextAnchor: 'middle',
// autoHighlight: true,
getText: d => String(d.properties.cluster ? d.properties.point_count : 1),
getPosition: d => d.geometry.coordinates
})))
return layers
}
renderLayers () {
return this.buildLayers()
}
}
MapsClusterCounts.layerName = 'MapsClusterCounts'
| 24.22 | 98 | 0.611065 |
27ceb7bd98e709cc395ab648fa18ebbd57ea7193 | 3,512 | js | JavaScript | dist/2.0/gallery/starrating/index-min.js | ArturDrozdz/brix | 96ecc97067d56d7b29d657d793559bca0bcf3c86 | [
"MIT"
] | 27 | 2015-03-14T07:54:28.000Z | 2019-02-20T08:54:55.000Z | dist/2.0/gallery/starrating/index-min.js | ArturDrozdz/brix | 96ecc97067d56d7b29d657d793559bca0bcf3c86 | [
"MIT"
] | null | null | null | dist/2.0/gallery/starrating/index-min.js | ArturDrozdz/brix | 96ecc97067d56d7b29d657d793559bca0bcf3c86 | [
"MIT"
] | 15 | 2015-07-27T03:27:29.000Z | 2019-04-16T21:01:05.000Z | KISSY.add("brix/gallery/starrating/index",function(e,t,i,a){function n(){n.superclass.constructor.apply(this,arguments)}var r=i.all;if(6==a.ie)try{document.execCommand("BackgroundImageCache",!1,!0)}catch(s){}return n.ATTRS={split:{value:2},maxValue:{value:5},length:{value:10},defaultValue:{value:!1},readOnly:{value:!1},starWidth:{value:18},inputs:{},current:{},mode:{value:!0}},n.EVENTS={".starrating-star":{mouseenter:function(t){if(!this.get("readOnly")){var i,a=e.one(t.currentTarget);this._fill(a),i=this.get("mode")?a.data("input").val():a.data("input"),this.fire("focus",{value:i})}},mouseleave:function(t){if(!this.get("readOnly")){var i,a=e.one(t.currentTarget);this._draw(),i=this.get("mode")?a.data("input").val():a.data("input"),this.fire("blur",{value:i})}},click:function(t){if(!this.get("readOnly")){var i=e.one(t.currentTarget);this.select(i)}}}},n.METHODS={select:function(t){var i=this;if("number"==typeof t){if(t=i.get("el").all(".starrating-star").item(t))return i.select(t);throw"\u6ca1\u6709\u627e\u5230\u8282\u70b9"}if("string"==typeof t){if(i.get("mode"))i.get("inputs").each(function(e,a){return e.val()==t?(t=i.get("el").all(".starrating-star").item(a),!1):void 0});else{var a=e.indexOf(t,i.get("inputs"));t=i.get("el").all(".starrating-star").item(a)}return i.select(t)}i.set("current",t),i._draw();var n;n=i.get("mode")?t.data("input").val():t.data("input"),i.fire("selected",{value:n})},readOnly:function(e,t){var i=this;i.set("readOnly",e||void 0==e?!0:!1);var a=i.get("readOnly");a?i.get("el").all(".starrating-star").addClass("starrating-star-readonly"):i.get("el").all(".starrating-star").removeClass("starrating-star-readonly"),i.get("mode")&&(t?i.get("inputs").attr("disabled","disabled"):i.get("inputs").removeAttr("disabled")),i._draw()},disable:function(){this.readOnly(!0,!0)},enable:function(){this.readOnly(!1,!1)}},e.extend(n,t,{initialize:function(){var t=this,i=t.get("inputs");if(i||(i=t.get("el").all("input[type=radio].star")),0==i.length){t.set("mode",!1);var a=t.get("length"),n=t.get("maxValue");i=[],flg=n/a;for(var r=1;a>=r;r++){var s=r*n/a;flg>=1?i.push(""+Math.round(s)):flg>.1?i.push(""+s.toFixed(1)):i.push(""+s.toFixed(2))}}t.set("inputs",i),t.get("mode")?i.each(function(e,i){var a=e.val(),n=e.attr("title")||a;t._creat(a,n,e,i)}):e.each(i,function(e,i){t._creat(e,e,e,i)}),rater=null;var o=t.get("defaultValue");o&&t.select(o)},_creat:function(e,t,i,a){var n=this,s=n.get("el"),o=n.get("split"),l=n.get("readOnly"),c=n.get("starWidth"),d=r('<div class="starrating-star"><a title="'+t+'">'+e+"</a></div>");if(s.append(d),o>1){var u=d.width()||c,p=a%o,f=Math.floor(u/o);d.css({width:f}).one("a").css({"margin-left":"-"+p*f+"px"}),0!=a&&0!=a%o&&d.css({"margin-right":"1px"})}else d.css({"margin-right":"1px"});d.data("input",i),l&&d.addClass("starrating-star-readonly"),n.get("mode")&&i.hide()},_fill:function(e){this._drain(),e.addClass("starrating-star-hover");for(var t=e;t.prev();)t.prev().addClass("starrating-star-hover"),t=t.prev()},_drain:function(){this.get("el").all(".starrating-star").removeClass("starrating-star-hover").removeClass("starrating-star-on")},_draw:function(){this._drain(),this.get("mode")&&this.get("inputs").removeAttr("checked");var e=this.get("current");if(e){this.get("mode")&&e.data("input").attr("checked","checked"),e.addClass("starrating-star-on");for(var t=e;t.prev();)t.prev().addClass("starrating-star-on"),t=t.prev()}},destructor:function(){}}),e.augment(n,n.METHODS),n},{requires:["brix/core/brick","node","ua"]}); | 3,512 | 3,512 | 0.665718 |
27cefafbcc02b15381f6945f8ff2633563d5e505 | 4,170 | js | JavaScript | renderers/smartMapping/statistics/histogram.js | g3r4n/esri | f8aa5427c5a3f9196854e0f1ff19f948873f6da3 | [
"Apache-2.0"
] | null | null | null | renderers/smartMapping/statistics/histogram.js | g3r4n/esri | f8aa5427c5a3f9196854e0f1ff19f948873f6da3 | [
"Apache-2.0"
] | null | null | null | renderers/smartMapping/statistics/histogram.js | g3r4n/esri | f8aa5427c5a3f9196854e0f1ff19f948873f6da3 | [
"Apache-2.0"
] | null | null | null | // COPYRIGHT © 2017 Esri
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// This material is licensed for use under the Esri Master License
// Agreement (MLA), and is bound by the terms of that agreement.
// You may redistribute and use this code without modification,
// provided you adhere to the terms of the MLA and include this
// copyright notice.
//
// See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english
//
// For additional information, contact:
// Environmental Systems Research Institute, Inc.
// Attn: Contracts and Legal Services Department
// 380 New York Street
// Redlands, California, USA 92373
// USA
//
// email: contracts@esri.com
//
// See http://js.arcgis.com/4.6/esri/copyright.txt for details.
define(["require","exports","dojo/_base/lang","../../../core/promiseUtils","../../../tasks/support/GenerateRendererParameters","./support/utils","../support/utils","../../../layers/support/fieldUtils"],function(e,r,i,a,n,t,s,l){function o(e){if(!(e&&e.layer&&(e.field||e.valueExpression||e.sqlExpression)))return a.reject(t.createError("histogram:missing-parameters","'layer' and 'field', 'valueExpression' or 'sqlExpression' parameters are required"));var r=i.mixin({},e);r.normalizationType=t.getNormalizationType(r);var n=[0,1,2],o=s.createLayerAdapter(r.layer,n);return r.layer=o,o?o.load().then(function(){var e=r.valueExpression||r.sqlExpression,i=r.field,n=i?o.getField(i):null,u=!r.classificationMethod||"equal-interval"===r.classificationMethod,d=s.getFieldsList({field:i,normalizationField:r.normalizationField,valueExpression:r.valueExpression}),m=t.verifyBasicFieldValidity(o,d,"histogram:invalid-parameters");if(m)return a.reject(m);if(n){var f=t.verifyFieldType(o,n,"histogram:invalid-parameters",p);if(f)return a.reject(f);if(l.isDateField(n)){if(r.normalizationType)return a.reject(t.createError("histogram:invalid-parameters","Normalization is not allowed for date fields"));if(!u)return a.reject(t.createError("histogram:invalid-parameters","'classificationMethod' other than 'equal-interval' is not allowed for date fields"))}}else if(e){if(r.normalizationType)return a.reject(t.createError("histogram:invalid-parameters","Normalization is not allowed when 'valueExpression' or 'sqlExpression' is specified"));if(!u)return a.reject(t.createError("histogram:invalid-parameters","'classificationMethod' other than 'equal-interval' is not allowed when 'valueExpression' or 'sqlExpression' is specified"))}return r}):a.reject(t.createError("histogram:invalid-parameters","'layer' must be one of these types: "+s.getLayerTypeLabels(n).join(", ")))}function u(e,r,i){var a=[],n=e.classBreakInfos,s=n[0].minValue,l=n[n.length-1].maxValue;return n.forEach(function(e){a.push([e.minValue,e.maxValue])}),{min:s,max:l,intervals:a,sqlExpr:t.getFieldExpr(i,e.normalizationTotal),excludeZerosExpr:r,normTotal:e.normalizationTotal}}function d(e,r){var i=e.layer,a=t.getSQLFilterForNormalization(e),s=e.numBins||x,l=new n({classificationDefinition:t.createCBDefn(e,s),where:t.mergeWhereClauses(a,r)});return i.generateRenderer(l).then(function(r){return u(r,a,e)})}function m(e){var r=e.layer,i=e.minValue,n=e.maxValue,l=e.valueExpression||e.sqlExpression,o=r.supportsSQLExpression,u=null!=i&&null!=n,m=!e.classificationMethod||"equal-interval"===e.classificationMethod;return l||o&&m?r.histogram(e):e.normalizationType||!m?d(e).then(function(r){if(u){if(i>r.max||n<r.min)return a.reject(t.createError("histogram:insufficient-data","Range defined by 'minValue' and 'maxValue' does not intersect available data range of the field"));var l=t.getFieldExpr(e,r.normTotal),o=t.getRangeExpr(l,i,n);return m?s.getBins({layer:e.layer,field:e.field,numBins:e.numBins},{min:i,max:n,sqlExpr:r.sqlExpr,excludeZerosExpr:r.excludeZerosExpr}):d(e,o).then(function(r){return s.getBins({layer:e.layer,field:e.field,numBins:e.numBins},r)})}return s.getBins({layer:e.layer,field:e.field,numBins:e.numBins},r)}):r.histogram(e)}function f(e){return o(e).then(function(e){return m(e)})}var c="date",p=[].concat(l.numericTypes).concat(c),x=10;return f}); | 166.8 | 3,334 | 0.758753 |
27cf11d8ef48b44010eed9c43989e916747f0524 | 3,426 | js | JavaScript | src/QueryRenderer.js | adeira/relay | 6eb01a6aef748d83c0219356ce737f09dafab613 | [
"MIT"
] | 2 | 2021-03-11T00:30:53.000Z | 2021-06-14T07:19:51.000Z | src/QueryRenderer.js | adeira/relay | 6eb01a6aef748d83c0219356ce737f09dafab613 | [
"MIT"
] | null | null | null | src/QueryRenderer.js | adeira/relay | 6eb01a6aef748d83c0219356ce737f09dafab613 | [
"MIT"
] | null | null | null | // @flow
import { useContext, type Node } from 'react';
import {
QueryRenderer as RelayQueryRenderer,
ReactRelayContext,
type Environment,
type Variables,
} from 'react-relay';
import { invariant, sprintf } from '@adeira/js';
import { TimeoutError, ResponseError } from '@adeira/fetch';
import type { CacheConfig, GraphQLTaggedNode } from 'relay-runtime';
type ReadyState<T> = {
+error: ?Error,
+props: T,
+retry: ?() => void,
};
type FetchPolicy = 'store-and-network' | 'network-only';
type CommonProps = {
+query: GraphQLTaggedNode,
+environment?: Environment,
+cacheConfig?: CacheConfig,
+fetchPolicy?: FetchPolicy,
+variables?: Variables,
};
type Props<T> =
| $ReadOnly<{
...CommonProps,
+onSystemError?: ({
error: Error,
retry: ?() => void,
...
}) => Node,
+onLoading?: () => Node,
+onResponse: (T) => Node,
}>
| $ReadOnly<{
...CommonProps,
+render: (ReadyState<?T>) => Node,
}>;
export default function QueryRenderer<T>(props: $ReadOnly<Props<T>>): Node {
function renderQueryRendererResponse({ error, props: rendererProps, retry }: ReadyState<?T>) {
if (error) {
if (props.onSystemError) {
return props.onSystemError({ error, retry });
}
let publicErrorMessage = 'Error!';
if (error instanceof TimeoutError) {
publicErrorMessage = 'Timeout error!';
} else if (error instanceof ResponseError) {
const { response } = error;
publicErrorMessage = sprintf(
'Unsuccessful response! (%s - %s)',
response.status,
response.statusText,
);
// You can get the actual response here:
// error.response.json().then(data => console.warn(data));
}
return (
<div data-testid="error">
{publicErrorMessage}{' '}
<button type="button" onClick={retry}>
Retry
</button>
</div>
);
}
if (rendererProps == null) {
return props.onLoading ? props.onLoading() : <div data-testid="loading">Loading...</div>;
}
invariant(
props.onResponse !== undefined,
'QueryRenderer used default render function but "onResponse" property has not been provided.',
);
return props.onResponse(rendererProps);
}
// 1) <QR environment={Env} /> always win
// 2) <QR /> checks whether we provide Environment via `RelayEnvironmentProvider`
// 3) throw if no environment is set
const context = useContext(ReactRelayContext);
const environment = props.environment ?? context?.environment;
invariant(
environment != null,
'QueryRenderer: Expected to have found a Relay environment provided by a `RelayEnvironmentProvider` component or by environment property.',
);
// Use this to disable store GC in order to reuse already existing data between screens:
// const disposable = environment.getStore().holdGC();
// Relay QR itself recreates the context with our environment.
// Relay hooks are using `useRelayEnvironment` with `ReactRelayContext` inside (so we use it as well).
return (
<RelayQueryRenderer
environment={environment}
render={props.render !== undefined ? props.render : renderQueryRendererResponse}
query={props.query}
cacheConfig={props.cacheConfig}
fetchPolicy={props.fetchPolicy}
variables={props.variables ?? {}}
/>
);
}
| 29.282051 | 143 | 0.636019 |
27d04adcf16f659da64d3f630b79dd5ccb7c6331 | 973 | js | JavaScript | src/weapp/transform/page-rewriter/parser.js | dcloudio/uni-migration | 79fc4d00e2cc2d473637f523a502a87c81a6edca | [
"Apache-2.0"
] | 142 | 2018-03-23T08:42:25.000Z | 2021-11-26T01:51:58.000Z | src/weapp/transform/page-rewriter/parser.js | dcloudio/uni-migration | 79fc4d00e2cc2d473637f523a502a87c81a6edca | [
"Apache-2.0"
] | 11 | 2018-04-08T00:26:30.000Z | 2021-05-06T23:22:18.000Z | src/weapp/transform/page-rewriter/parser.js | dcloudio/uni-migration | 79fc4d00e2cc2d473637f523a502a87c81a6edca | [
"Apache-2.0"
] | 38 | 2018-03-28T09:21:02.000Z | 2022-01-20T08:11:47.000Z | import sax from 'sax'
export default function parse (xml) {
const parser = sax.parser(false, {
trim: true,
lowercase: true,
position: true
})
let root
let currentParent
const stack = []
parser.onerror = function (e) {
console.log(e)
}
parser.ontext = function (t) {
currentParent && (currentParent.content = t.trim() || '')
}
parser.oncdata = function (t) {
currentParent && (currentParent.content = t.trim() || '')
}
parser.onopentag = function (node) {
node.children = []
node.location = {
line: this.line,
column: this.column
}
if (!root) {
root = node
}
if (currentParent) {
node.parent = currentParent
currentParent.children.push(node)
}
currentParent = node
stack.push(currentParent)
}
parser.onclosetag = function (tagName) {
stack.length -= 1
currentParent = stack[stack.length - 1]
}
parser.write(xml).close()
return root
}
| 19.078431 | 61 | 0.605344 |
27d21b488e6be3a2a41929dcf492c458523eaa3a | 542 | js | JavaScript | docs/html/search/all_7.js | thiago-rezende/inventory-manager | 59fde6c0c49697d94ede4d0b94e09fb1b831793e | [
"MIT"
] | null | null | null | docs/html/search/all_7.js | thiago-rezende/inventory-manager | 59fde6c0c49697d94ede4d0b94e09fb1b831793e | [
"MIT"
] | 1 | 2019-06-30T03:13:58.000Z | 2019-08-04T22:22:15.000Z | docs/html/search/all_7.js | thiago-rezende/inventory-manager | 59fde6c0c49697d94ede4d0b94e09fb1b831793e | [
"MIT"
] | 1 | 2019-06-15T14:11:47.000Z | 2019-06-15T14:11:47.000Z | var searchData=
[
['jogo',['Jogo',['../classivy_1_1locadora_1_1_jogo.html',1,'ivy::locadora::Jogo'],['../classivy_1_1locadora_1_1_jogo.html#adcff926428eec1cd0c9e6b2b3637b021',1,'ivy::locadora::Jogo::Jogo(int nJogoID, std::string nNome, std::string nGenero, int nFaixaEtaria, float nValor, bool nDisponivel)'],['../classivy_1_1locadora_1_1_jogo.html#a90699704bdd8470c839241707c059cb1',1,'ivy::locadora::Jogo::Jogo()']]],
['jogo_2ecpp',['Jogo.cpp',['../_jogo_8cpp.html',1,'']]],
['jogo_2ehpp',['Jogo.hpp',['../_jogo_8hpp.html',1,'']]]
];
| 77.428571 | 403 | 0.714022 |
27d3a85f6b5c40fa0bc10363b2d2abace5adb8ec | 1,749 | js | JavaScript | models/workout.js | meredithajones/get_fit | fe132fe8057b311fb798fdc1565fc64b1ea37c9f | [
"MIT"
] | null | null | null | models/workout.js | meredithajones/get_fit | fe132fe8057b311fb798fdc1565fc64b1ea37c9f | [
"MIT"
] | null | null | null | models/workout.js | meredithajones/get_fit | fe132fe8057b311fb798fdc1565fc64b1ea37c9f | [
"MIT"
] | null | null | null | //Setting Mongoose as a dependency
const mongoose = require("mongoose");
//Setting up Mongoose schema
const Schema = mongoose.Schema;
//Creating the workout schema
const workoutSchema = new Schema({
day: {
type: Date,
default: Date.now
},
exercises: [
{
type: {
type: String,
trim: true,
required: "Enter the type of exercise you are doing"
},
name: {
type: String,
trim: true,
required: "Enter exercise name"
},
duration: {
type: Number,
required: "Enter the duration of time you spent exercising"
},
distance: {
type: Number,
required: [false, "Enter distance of exercise"]
},
weight: {
type: Number,
required: [false, "Enter weight being lifted"]
},
reps: {
type: Number,
required: [false, "Enter number of reps"]
},
sets: {
type: Number,
required: [false, "Enter number of sets"]
}
}
]},
{
toJSON: {
virtuals: true
}
}
);
//Add virtual property to schema called workoutDuration
workoutSchema
.virtual("totalDuration")
.get(function () {
let workoutDuration = 0
for (let i = 0; i < this.exercises.length; i++) {
workoutDuration += this.exercises[i].duration
}
return workoutDuration;
});
//Creating "Workout model to export"
const Workout = mongoose.model("Workout", workoutSchema);
//Export the model
module.exports = Workout; | 25.720588 | 71 | 0.503145 |
27d3d59e7d2549e711a26c2f4ce09c95283a5e9c | 1,166 | js | JavaScript | src/stringifyArrayOfArray.js | hgranlund/benchmarking | abbaced7cb92f68d65753acbc6e9ed45ca037ffa | [
"MIT"
] | null | null | null | src/stringifyArrayOfArray.js | hgranlund/benchmarking | abbaced7cb92f68d65753acbc6e9ed45ca037ffa | [
"MIT"
] | 1 | 2020-04-04T20:45:23.000Z | 2020-04-04T20:45:23.000Z | src/stringifyArrayOfArray.js | hgranlund/benchmarking | abbaced7cb92f68d65753acbc6e9ed45ca037ffa | [
"MIT"
] | null | null | null | const Benchmark = require('benchmark');
const { compareWithPrev } = require('./benchmarkUtils');
const stringify = require('fast-stringify');
const values = new Array(10000).fill().map(() => [new Date(), null, 64]);
const suite = new Benchmark.Suite();
suite
.add('fast-stringify', () => {
return stringify(values).slice(1, -1);
})
.add('JSON.stringify', () => {
return JSON.stringify(values).slice(1, -1);
})
.add('MapAndJoin', () => {
return values
.map(value => '[' + value.map(String).join(',') + ']')
.join(',');
})
.add('ReduceConcat', () => {
return values.reduce((str, value) => {
str += '[' + value.map(String).join(',') + ']';
return str;
}, '');
})
.add('ForEachPush', () => {
let string = '';
values.forEach(value => {
string += '[' + value.map(String).join(',') + '],';
});
return string;
})
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', event => {
compareWithPrev(event, 'stringifyArrayOfArray');
console.log(
'Fastest is ' + event.currentTarget.filter('fastest').map('name'),
);
})
.run();
| 25.911111 | 73 | 0.548027 |
27d4f5ef521a1ede56768aec176155d251eb241b | 848 | js | JavaScript | test/db/prepare.js | LLC-WebSoft/web-soft-server | 7a77180b391b4faf415218de5051d7cffcb126be | [
"MIT"
] | null | null | null | test/db/prepare.js | LLC-WebSoft/web-soft-server | 7a77180b391b4faf415218de5051d7cffcb126be | [
"MIT"
] | 1 | 2022-02-20T06:21:14.000Z | 2022-02-20T06:21:14.000Z | test/db/prepare.js | LLC-WebSoft/web-soft-auth | 7a77180b391b4faf415218de5051d7cffcb126be | [
"MIT"
] | null | null | null | const { Pool } = require('pg');
const UNIQUE_ERROR_CODE_PREFIX = '23';
jest.mock('pg');
Pool.mockImplementation(() => {
return {
query: jest.fn(async (text) => {
if (text === 'errorSql') {
const error = new Error();
error.code = '0';
throw error;
} else if (text === 'conflictErrorSql') {
const error = new Error();
error.code = UNIQUE_ERROR_CODE_PREFIX;
throw error;
} else {
return { rows: [] };
}
})
};
});
jest.mock('../../lib/logger', () => {
return {
logger: {
sql: () => {}
}
};
});
//Require database after Pool is mocked. Database is singlton service and using Pool inside constructor.
const { database } = require('../../lib/db');
beforeEach(() => {
database.pool.query.mockClear();
});
module.exports = {
database
};
| 20.190476 | 104 | 0.542453 |
27d5a06edae8845f5b0e7b78e2eb149a1165124b | 3,314 | js | JavaScript | Aula-JavaScript-Avancado/callback-promises.js | HenriqueMAP/Aula-JavaScript | 483cfe6ab6539b2c13e63a3c1318158a22947e65 | [
"MIT"
] | 1 | 2020-07-25T05:44:06.000Z | 2020-07-25T05:44:06.000Z | Aula-JavaScript-Avancado/callback-promises.js | HenriqueMAP/Aula-JavaScript | 483cfe6ab6539b2c13e63a3c1318158a22947e65 | [
"MIT"
] | null | null | null | Aula-JavaScript-Avancado/callback-promises.js | HenriqueMAP/Aula-JavaScript | 483cfe6ab6539b2c13e63a3c1318158a22947e65 | [
"MIT"
] | null | null | null | // CALLBACKS
function doSomething(callback) {
setTimeout(function() {
// did something
callback('First data');
}, 1000);
}
function doOtherThing(callback) {
setTimeout(function() {
// did other thing
callback('Second data');
}, 1000);
}
function doAll() {
doSomething(function(data){
var processedData = data.split('');
doOtherThing(function(data2) {
var processedData2 = data2.split('');
setTimeout(function() {
console.log(processedData, processedData2);
}, 1000);
});
});
}
doAll();
// (10) ["F", "i", "r", "s", "t", " ", "d", "a", "t", "a"]
// (11) ["S", "e", "c", "o", "n", "d", " ", "d", "a", "t", "a"]
// Iniciando tratamento de dados
// CALLBACK HELL
function doSomething(callback) {
setTimeout(function() {
// did something
callback('First data');
}, 1000);
}
function doOtherThing(callback) {
setTimeout(function() {
// did other thing
callback('Second data');
}, 1000);
}
function doAll() {
try {
doSomething(function(data){
var processedData = data.split('');
try {
doOtherThing(function(data2) {
var processedData2 = data2.split('');
try{
setTimeout(function() {
console.log(processedData, processedData2);
}, 1000);
} catch (err) {
// handle error
}
});
} catch (err) {
// handle error
}
});
} catch(err) {
//handle error
}
}
doAll();
// PROMISES
const myPromise = new Promise((resolve, reject) => {
// code here
});
// REFAZENDO O EXEMPLO ACIMA COM PROMISES
// Promises podem ter três estados:
// Pending: pendente
// Fulfilled: executada
// Rejected: aconteceu algum erro
const doSomethingPromise = () => new Promise((resolve, reject) => {
setTimeout(function() {
// did something
resolve('First data');
}, 1000);
});
const doOtherThingPromise = () => new Promise((resolve, reject) => {
throw new Error('Something went wrong')
setTimeout(function() {
// did other thing
resolve('Second data');
}, 1000);
});
//doSomethingPromise.then(data => console.log(data)).catch(console.log(error));
// Something went wrong
doSomethingPromise()
.then(data => {
console.log(data);
return doOtherThingPromise();
})
.then(data2 => console.log(data2))
.catch(error => console.log('Ops', error));
function doSomething(callback) {
setTimeout(function() {
// did something
callback('First data');
}, 1000);
}
function doOtherThing(callback) {
setTimeout(function() {
// did other thing
callback('Second data');
}, 1000);
}
function doAll() {
doSomething(function(data){
var processedData = data.split('');
doOtherThing(function(data2) {
var processedData2 = data2.split('');
setTimeout(function() {
console.log(processedData, processedData2);
}, 1000);
});
});
}
doAll();
| 21.660131 | 79 | 0.52414 |
27d5d28d0512c98c37dfec8368d86fec8cf81ebc | 387 | js | JavaScript | server/utils/business-process-storages.js | egovernment/eregistrations | 6fa16f0229b3177ca003a5da1adae194810caf56 | [
"MIT"
] | 1 | 2019-06-27T08:50:04.000Z | 2019-06-27T08:50:04.000Z | server/utils/business-process-storages.js | egovernment/eregistrations | 6fa16f0229b3177ca003a5da1adae194810caf56 | [
"MIT"
] | 196 | 2017-01-15T11:47:11.000Z | 2018-03-16T15:45:37.000Z | server/utils/business-process-storages.js | egovernment/eregistrations | 6fa16f0229b3177ca003a5da1adae194810caf56 | [
"MIT"
] | null | null | null | 'use strict';
var startsWith = require('es5-ext/string/#/starts-with')
, forEach = require('es5-ext/object/for-each')
, driver = require('mano').dbDriver;
module.exports = driver.getStorages()(function (storages) {
var result = [];
forEach(storages, function (storage, name) {
if (startsWith.call(name, 'businessProcess')) result.push(storage);
});
return result;
});
| 27.642857 | 69 | 0.677003 |
27d6527d27815b94c033dad3743e74b1f95dd19c | 26,691 | js | JavaScript | interfaces/default/js/plexpy.js | scambra/HTPC-Manager | 1a1440db84ae1b6e7a2610c7f3bd5b6adf0aab1d | [
"MIT"
] | 422 | 2015-01-08T14:08:08.000Z | 2022-02-07T11:47:37.000Z | interfaces/default/js/plexpy.js | scambra/HTPC-Manager | 1a1440db84ae1b6e7a2610c7f3bd5b6adf0aab1d | [
"MIT"
] | 581 | 2015-01-01T08:07:16.000Z | 2022-02-23T11:44:37.000Z | interfaces/default/js/plexpy.js | scambra/HTPC-Manager | 1a1440db84ae1b6e7a2610c7f3bd5b6adf0aab1d | [
"MIT"
] | 115 | 2015-01-08T14:41:00.000Z | 2022-02-13T12:31:17.000Z | $(document).ready(function () {
getDashActivity();
getLibraryStats();
getHistoryTable();
});
//Start of all functions used to retrieve data from Internal API Endpoints which redirect to PlexPy Endpoints
//Applys the data table plugin to the get_history api call
function getHistoryTable() {
$('#history_table').DataTable( {
"ajax": {
"url": WEBDIR + "plexpy/get_history",
type: 'POST',
data: function (d) {
return {
json_data: JSON.stringify(d),
grouping: false,
//reference_id: rowData['reference_id']
};}
},
"destroy": true,
"language": {
"search": "Search: ",
"lengthMenu": "Show _MENU_ entries per page",
"info": "Showing _START_ to _END_ of _TOTAL_ history items",
"infoEmpty": "Showing 0 to 0 of 0 entries",
"infoFiltered": "<span class='hidden-md hidden-sm hidden-xs'>(filtered from _MAX_ total entries)</span>",
"emptyTable": "No data in table",
"loadingRecords": '<i class="fa fa-refresh fa-spin"></i> Loading items...</div>'
},
"pagingType": "full_numbers",
"stateSave": true,
"processing": false,
"serverSide": true,
"pageLength": 25,
"order": [ 0, 'desc'],
"columnDefs": [
{
"targets": 0,
"data": "date",
"createdCell": function (td, cellData, rowData, row, col) {
$(td).html(moment(cellData, "X").format("YYYY-MM-DD"));
},
"width": "7%",
"searchable": "false",
"className": "no-wrap"
},
{
"targets": 1,
"data": "friendly_name",
"width": "9%"
},
{
"targets": 2,
"data": "ip_address",
"width": "8%",
"className": "no-wrap"
},
{
"targets": 3,
"data":"platform",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== '') {
$(td).html(cellData);
}
},
"width": "10%",
"className": "no-wrap"
},
{
"targets": 4,
"data": "player",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== '') {
var transcode_dec = '';
if (rowData['transcode_decision'] === 'transcode') {
transcode_dec = '<i class="fa fa-server fa-fw"></i>';
} else if (rowData['transcode_decision'] === 'copy') {
transcode_dec = '<i class="fa fa-video-camera fa-fw"></i>';
} else if (rowData['transcode_decision'] === 'direct play') {
transcode_dec = '<i class="fa fa-play-circle fa-fw"></i>';
}
$(td).html('<div style="float: left;">' + transcode_dec + ' ' + cellData + '</div>');
}
},
"width": "12%",
"className": "no-wrap"
},
{
"targets": 5,
"data": "full_title",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== '') {
var parent_info = '';
var media_type = '';
var thumb_popover = '';
var source = (rowData['state'] === null) ? 'source=history&' : '';
if (rowData['media_type'] === 'movie') {
if (rowData['year']) {
parent_info = ' (' + rowData['year'] + ')';
}
media_type = '<span class="media-type-tooltip" data-toggle="tooltip" title="Movie"><i class="fa fa-film fa-fw"></i></span>';
thumb_popover = '<span class="thumb-tooltip" data-toggle="popover" data-img="pms_image_proxy?img=' + rowData['thumb'] + '&width=300&height=450&fallback=poster" data-height="120" data-width="80">' + cellData + parent_info + '</span>'
$(td).html('<div class="history-title"><div style="float: left;">' + media_type + ' ' + thumb_popover + '</div></div>');
} else if (rowData['media_type'] === 'episode') {
if (rowData['parent_media_index'] && rowData['media_index']) {
parent_info = ' (S' + rowData['parent_media_index'] + '· E' + rowData['media_index'] + ')';
}
media_type = '<span class="media-type-tooltip" data-toggle="tooltip" title="Episode"><i class="fa fa-television fa-fw"></i></span>';
thumb_popover = '<span class="thumb-tooltip" data-toggle="popover" data-img="pms_image_proxy?img=' + rowData['thumb'] + '&width=300&height=450&fallback=poster" data-height="120" data-width="80">' + cellData + parent_info + '</span>'
$(td).html('<div class="history-title"><div style="float: left;" >' + media_type + ' ' + thumb_popover + '</div></div>');
} else if (rowData['media_type'] === 'track') {
if (rowData['parent_title']) {
parent_info = ' (' + rowData['parent_title'] + ')';
}
media_type = '<span class="media-type-tooltip" data-toggle="tooltip" title="Track"><i class="fa fa-music fa-fw"></i></span>';
thumb_popover = '<span class="thumb-tooltip" data-toggle="popover" data-img="pms_image_proxy?img=' + rowData['thumb'] + '&width=300&height=300&fallback=cover" data-height="80" data-width="80">' + cellData + parent_info + '</span>'
$(td).html('<div class="history-title"><div style="float: left;">' + media_type + ' ' + thumb_popover + '</div></div>');
} else {
$(td).html(cellData);
}
}
},
"width": "33%",
"className": "datatable-wrap"
},
{
"targets": 6,
"data":"started",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData === null) {
$(td).html('n/a');
} else {
$(td).html(moment(cellData,"X").format("hh:mm A"));
}
},
"searchable": false,
"width": "5%",
"className": "no-wrap"
},
{
"targets": 7,
"data":"paused_counter",
"render": function (data, type, full) {
if (data !== null) {
return Math.round(moment.duration(data, 'seconds').as('minutes')) + ' mins';
} else {
return '0 mins';
}
},
"searchable": false,
"width": "5%",
"className": "no-wrap"
},
{
"targets": 8,
"data":"stopped",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData === null) {
$(td).html('n/a');
} else {
$(td).html(moment(cellData,"X").format("hh:mm A"));
}
},
"searchable": false,
"width": "5%",
"className": "no-wrap"
},
{
"targets": 9,
"data":"duration",
"render": function (data, type, full) {
if (data !== null) {
return Math.round(moment.duration(data, 'seconds').as('minutes')) + ' mins';
} else {
return data;
}
},
"searchable": false,
"width": "5%",
"className": "no-wrap"
}
]
} );
}
//Gets current playing activity and uses polling function to update over time. Fills in the first tab
//TODO: Finish this function and make it use the defined pms server.
function getDashActivity() {
$.ajax({
type: 'GET',
url: WEBDIR + "plexpy/get_activity",
success: function (data) {
if (data.stream_count == "0") {
var Sessions = "(No Active Streams)";
$('#sessions').html(Sessions);
}
else {
$("#activity").html(null);
var transcodes = 0;
var directplay = 0;
var directstream = 0;
var items = "";
$.each(data.sessions, function (index, value) {
if (value.media_type === "movie") {
var item_info = "<i class='fa fa-fw fa-film'></i> " + value.year
}
if (value.media_type === "episode") {
var item_info = "<i class='fa fa-fw fa-tv'></i> S" + value.parent_media_index + " - E" + value.media_index;
}
//var thumb = WEBDIR + 'plex/GetThumb?w=475&h=275&thumb='+encodeURIComponent(value.art);
var thumb = WEBDIR + 'plex/GetThumb?w=730&h=420&thumb='+encodeURIComponent(value.art);
var image = "<img src=\"" + thumb + "\"/ class='poster-image'>";
var product_player = value.product + " on " + value.player
if (value.player === value.product) {
product_player = value.player
}
var transcode_speed = value.transcode_speed + "x";
if (value.transcode_speed == "0.0") {
transcode_speed = "Throttled"
}
var transcode_decision = value.transcode_decision;
if (value.transcode_decision === "transcode") {
transcode_decision = "Transcode (" + transcode_speed + ")"
} else {
transcode_decision = "Direct Stream"
}
var stream_container_decision = "Direct Stream (" + (value.container).toLocaleUpperCase() + ")";
if (value.stream_container_decision === "transcode") {
stream_container_decision = "Transcode (" + (value.container).toLocaleUpperCase() + " → " + (value.transcode_container).toLocaleUpperCase() + ")"
}
if ( isNaN(value.video_resolution.charAt(0)) ) {
var video_resolution = value.video_resolution.toLocaleUpperCase()
} else {
var video_resolution = value.video_resolution + "p"
}
if ( isNaN(value.stream_video_resolution.charAt(0)) ) {
var stream_video_resolution = value.stream_video_resolution.toLocaleUpperCase()
} else {
var stream_video_resolution = value.stream_video_resolution + "p"
}
var stream_video_decision = "Direct Stream (" + (value.stream_video_codec).toLocaleUpperCase() + " " + video_resolution + ")";
if (value.stream_video_decision === "transcode") {
stream_video_decision = "Transcode (" + (value.stream_video_codec).toLocaleUpperCase() + " " + video_resolution + " → " + (value.transcode_video_codec).toLocaleUpperCase() + " " + stream_video_resolution + ")"
}
var audio_channel_layout = value.audio_channel_layout
if (audio_channel_layout.indexOf('\(') > 0) { audio_channel_layout = (value.audio_channel_layout).substring(0, (value.audio_channel_layout).indexOf('\(')) }
var stream_audio_channel_layout = value.stream_audio_channel_layout
if (stream_audio_channel_layout.indexOf('\(') > 0) { stream_audio_channel_layout = (value.stream_audio_channel_layout).substring(0, (value.stream_audio_channel_layout).indexOf('\(')) }
var stream_audio_decision = "Direct Stream (" + (value.audio_codec).toLocaleUpperCase() + " " + audio_channel_layout + ")";
if (value.stream_audio_decision === "transcode") {
stream_audio_decision = "Transcode (" + (value.audio_codec).toLocaleUpperCase() + " " + audio_channel_layout + " → " + (value.transcode_audio_codec).toLocaleUpperCase() + " " + stream_audio_channel_layout + ")"
}
var stream_subtitle_decision = "None";
if (value.stream_subtitle_decision !== "") {
stream_subtitle_decision = (value.stream_subtitle_decision).toLocaleUpperCase() + " (" + (value.subtitle_codec).toLocaleUpperCase() + " " + (value.stream_subtitle_language_code).toLocaleUpperCase() + ")"
}
if (value.stream_subtitle_decision === "transcode") {
stream_subtitle_decision = "Transcode (" + (value.subtitle_codec).toLocaleUpperCase() + " " + (value.stream_subtitle_language_code).toLocaleUpperCase() + ")"
}
if (value.stream_subtitle_decision === "burn") {
stream_subtitle_decision = "Burn (" + (value.subtitle_codec).toLocaleUpperCase() + " " + (value.stream_subtitle_language_code).toLocaleUpperCase() + ")"
}
if ((index % 3) == 0) items += '<div class="row-fluid">';
items += "<div class='span4 p-lr-sm'>" +
"<div class='top-title'>" + playState(value.state) + " <span> " + value.full_title + "</span></div>" +
"<div class='plexpy-poster'>" + image +
"<div class='meta-overlay-full'>" +
"<ul class='meta'>" +
"<li class='meta-left'><div style='float:right;'>PLAYER</div></li><li class='meta-right'>" + product_player + "</li>" +
"<li class='meta-left'><div style='float:right;'>QUALITY</div></li><li class='meta-right'>" + value.quality_profile + " @ " + value.bitrate + " Kbps</li>" +
"<li class='meta-left'><div style='float:right;'>STREAM</div></li><li class='meta-right'>" + transcode_decision + "</li>" +
"<li class='meta-left'><div style='float:right;'>CONTAINER</div></li><li class='meta-right'>" + stream_container_decision + "</li>" +
"<li class='meta-left'><div style='float:right;'>VIDEO</div></li><li class='meta-right'>" + stream_video_decision + "</li>" +
"<li class='meta-left'><div style='float:right;'>AUDIO</div></li><li class='meta-right'>" + stream_audio_decision + "</li>" +
"<li class='meta-left'><div style='float:right;'>LOCATION</div></li><li class='meta-right'>" + (value.location).toLocaleUpperCase() + ": " + value.ip_address + "</li>" +
"<li class='meta-left'><div style='float:right;'>SUBTITLES</div></li><li class='meta-right'>" + stream_subtitle_decision + "</li>" +
"<li class='meta-left'><div style='float:right;'>BANDWIDTH</div></li><li class='meta-right'>" + value.bandwidth + " Kbps</li>" +
"<li class='meta-span'><div style='float:right;'>ETC: "+moment().add(millisecondsToMinutes(value.duration - value.view_offset,1),'m').format("h:mma") + " " +millisecondsToMinutes(value.view_offset) + " / " + millisecondsToMinutes(value.duration) + "</div></li>" +
"</ul>" +
"</div>" + // meta-overlay
"</div>" + // div poster
"<div class='progress'>" +
"<div class='bar' style='width:" + value.progress_percent + "%'>" +
"<span class='sr-only'>" + value.progress_percent + "%</span></div>" +
"<div class='bar bar-info' style='width:" + (100 - value.progress_percent) + "%'>" +
"<span class='sr-only'></span></div>" +
"</div>" + // div progress
"<div><span class='pull-left'>" + item_info + "</span><span class='pull-right'>" + value.user + "</span></div>" +
"</div>"; // div span4 tile
if ((index % 3) == 2) items += '</div>'; // div row-fluid
$("#activity").html(items);
// if(i>0 && (i%4 == 0)){
// $("#test").append("</div>");
// }
if (value.transcode_decision === "transcode") {
transcodes = transcodes + 1;
}
if (value.transcode_decision === "direct play") {
directplay = directplay + 1;
}
if (value.transcode_decision === "copy") {
directstream = directstream + 1;
}
});
var Sessions = "( " + data.stream_count + " Streams"
if (transcodes > 0) {
Sessions += " | " + transcodes + " transcode(s)";
}
if (directplay > 0) {
Sessions += " | " + directplay + " direct play(s)";
}
if (directstream > 0) {
Sessions += " | " + directstream + " direct stream(s)";
}
Sessions += " )";
$('#sessions').html(Sessions);
}
},
complete: setTimeout(function() {getDashActivity()}, 10000),
timeout: 2000
})
}
//Gets the Watch Stats and creates a set of BootStrap wells to house the data for viewing
function getLibraryStats() {
$.ajax({
type: 'GET',
url: WEBDIR + "plexpy/get_home_stats",
success: function (data) {
$("#watchstats").html(null);
var items = "";
var itemTitle = "";
var itemType = "";
var itemCount = 0;
var classApply = "";
$.each(data, function (index, value) {
if(index < 8)
{
itemTitle = setTitle(value.stat_id);
itemType = setType(value.stat_type, value.stat_id);
switch(value.stat_id){
case "top_movies":
itemCount = value.rows[0].total_plays;
classApply = "stat-poster pull-left";
var thumb = WEBDIR + 'plex/GetThumb?w=85&h=125&thumb='+encodeURIComponent(value.rows[0].thumb);
var image = "<img src=\"" + thumb + "\"/>";
break;
case "popular_movies":
itemCount = value.rows[0].users_watched;
classApply = "stat-poster pull-left";
var thumb = WEBDIR + 'plex/GetThumb?w=85&h=125&thumb='+encodeURIComponent(value.rows[0].thumb);
var image = "<img src=\"" + thumb + "\"/>";
break;
case "top_tv":
itemCount = value.rows[0].total_plays;
classApply = "stat-poster pull-left";
var thumb = WEBDIR + 'plex/GetThumb?w=85&h=125&thumb='+encodeURIComponent(value.rows[0].grandparent_thumb);
var image = "<img src=\"" + thumb + "\"/>";
break;
case "popular_tv":
itemCount = value.rows[0].users_watched;
classApply = "stat-poster pull-left";
var thumb = WEBDIR + 'plex/GetThumb?w=85&h=125&thumb='+encodeURIComponent(value.rows[0].grandparent_thumb);
var image = "<img src=\"" + thumb + "\"/>";
break;
case "top_music":
itemCount = value.rows[0].total_plays;
classApply = "stat-cover pull-left";
var thumb = WEBDIR + 'plex/GetThumb?w=80&h=80&thumb='+encodeURIComponent(value.rows[0].grandparent_thumb);
var image = "<img src=\"" + thumb + "\"/>";
break;
case "popular_music":
itemCount = value.rows[0].users_watched;
classApply = "stat-cover pull-left";
var thumb = WEBDIR + 'plex/GetThumb?w=80&h=80&thumb='+encodeURIComponent(value.rows[0].grandparent_thumb);
var image = "<img src=\"" + thumb + "\"/>";
break;
case "last_watched":
itemCount = value.rows[0].friendly_name + "</br>" + moment(value.rows[0].last_watched).format("MM/DD/YYYY");
classApply = "stat-poster pull-left";
var thumb = WEBDIR + 'plex/GetThumb?w=85&h=125&thumb='+encodeURIComponent(value.rows[0].thumb);
var image = "<img src=\"" + thumb + "\"/>";
break;
case "top_users":
itemCount = value.rows[0].total_plays;
classApply = "stat-cover pull-left";
var image = "<img src=\"" + value.rows[0].user_thumb + "\"/>";
break;
case "top_platforms":
itemCount = value.rows[0].total_plays;
classApply = "stat-cover pull-left";
break;
}
if ((index % 4) == 0) items += '<div class="row-fluid">';
items += '<div class="span3 p-lr-sm well stat-holder">' +
'<div class="'+classApply+'">' + image +
'</div>' +
'<div class="stat-highlights">' +
'<h2>' + itemTitle + '</h2>' +
//'<p>' + value.rows[0].title + value.rows[0].friendly_name +'</p>';
'<p>' + value.rows[0].title +'</p>';
if(value.stat_id == "last_watched"){
items += itemCount
}
else{
items += '<h3 class="clear-fix">' + itemCount + '</h3> '
}
items += itemType +
'</div>' +
'</div>';
if ((index % 4) == 3) items += '</div>';
}
})
$("#watchstats").html(items);
},
timeout: 2000
})
}
//Miscellanous Helper functions some borrowed from the plexpy JS Code
function playState(state) {
if (state === "playing") {
return "<i class='fa fa-fw fa-play'></i>"
}
if (state === "paused") {
return "<i class='fa fa-fw fa-pause'></i>"
}
if (state === "buffering") {
return "<i class='fa fa-fw fa-spinner'></i>"
}
else {
return "<i class='fa fa-fw fa-question'></i>"
}
}
function millisecondsToMinutes(ms, roundToMinute) {
if (ms > 0) {
seconds = ms / 1000;
minutes = seconds / 60;
if (roundToMinute) {
output = Math.round(minutes, 0)
} else {
minutesFloor = Math.floor(minutes);
secondsReal = Math.round((seconds - (minutesFloor * 60)), 0);
if (secondsReal < 10) {
secondsReal = '0' + secondsReal;
}
output = minutesFloor + ':' + secondsReal;
}
return output;
} else {
if (roundToMinute) {
return '0';
} else {
return '0:00';
}
}
}
function setTitle(itemTitle) {
switch (itemTitle) {
case "top_movies":
return "Most Played Movie";
break;
case "popular_movies":
return "Most Popular Movie";
break;
case "top_tv":
return "Most Played TV";
break;
case "popular_tv":
return "Most Popular TV";
break;
case "top_music":
return "Most Played Music";
break;
case "popular_music":
return "Most Popular Music";
break;
case "last_watched":
return "Last Watched";
break;
case "top_users":
return "Most Active User";
break;
}
}
function setType(itemType, itemTitle) {
if (itemType == "total_plays") {
return "plays";
}
if (itemType == null && itemTitle != "most_concurrent" && itemTitle != "last_watched") {
return "users";
}
if (itemType == null && itemTitle == "last_watched"){
return "";
}
else {
return "streams";
}
}
| 49.88972 | 294 | 0.440186 |
27d6df13ead223d936f4bed122f32c48dc4d20b7 | 982 | js | JavaScript | src/event/Index/store.js | linyingzhen/btnew | 213c16401850c88a0b7f49b82b0f66c7c9863144 | [
"Apache-2.0"
] | null | null | null | src/event/Index/store.js | linyingzhen/btnew | 213c16401850c88a0b7f49b82b0f66c7c9863144 | [
"Apache-2.0"
] | null | null | null | src/event/Index/store.js | linyingzhen/btnew | 213c16401850c88a0b7f49b82b0f66c7c9863144 | [
"Apache-2.0"
] | null | null | null | /**
* const prefixCls = 'style-977531';
* const images = '/static/images/src/event/Index';
* @Author: czy0729
* @Date: 2018-10-07 09:23:06
* @Last Modified by: czy0729
* @Last Modified time: 2018-10-07 11:58:49
* @Path m.benting.com.cn /src/event/Index/store.js
*/
import { observable } from 'mobx';
import common from '@stores/commonV2';
import Const from '@const';
import G from '@stores/g';
export default class Store extends common {
@observable
state = this.initState({
userInfo: G.getState('userInfo'),
fansAuth: {},
event: Const.__EMPTY__
});
fetch = {
config: {
static: ['userInfo'],
one: ['event'],
update: ['fansAuth']
},
userInfo: async () => {
const res = G.fetchUserInfo();
this.setState(await res, 'userInfo');
return res;
},
fansAuth: () => this.fetchThenSetState('get_user_fans-state', 'fansAuth'),
event: () => this.fetchThenSetState('get_event_list', 'event')
};
}
| 21.822222 | 78 | 0.618126 |
27d71bedb9709cce0f8ab804ada7589a4c1f6d22 | 648 | js | JavaScript | src/lib/stopTimedLoop.js | csokolove/code-org | 621747b21482c6e95d5edb1a040ae1c259756942 | [
"Apache-2.0"
] | null | null | null | src/lib/stopTimedLoop.js | csokolove/code-org | 621747b21482c6e95d5edb1a040ae1c259756942 | [
"Apache-2.0"
] | 3 | 2021-12-29T20:41:18.000Z | 2022-01-15T16:07:31.000Z | src/lib/stopTimedLoop.js | csokolove/code-org | 621747b21482c6e95d5edb1a040ae1c259756942 | [
"Apache-2.0"
] | 1 | 2022-01-07T19:46:50.000Z | 2022-01-07T19:46:50.000Z | /**
* Stops any running timedLoops, or a specific one if passed in return value of `timedLoop`
* @param {Number} loop The value returned by the `timedLoop()` function that you want to stop. If not included, all running timed loops will stop.
* @todo Implement ability to stop individual loops, or all loops
*/
// https://stackoverflow.com/questions/8635502/how-do-i-clear-all-intervals
// https://stackoverflow.com/questions/8860188/javascript-clear-all-timeouts
const stopTimedLoop = (loop) => {
if(loop) {
if(isNaN(loop)) throw new Error(`Loop ID must be a valid integer`)
} else {
}
}
module.exports = stopTimedLoop; | 34.105263 | 147 | 0.714506 |
27d8fd5e6722ea071757c4a298691817843787af | 1,891 | js | JavaScript | app/containers/HomePage/reducer.js | nshganesh/tallyx-invoice-filter | 1853e69a31aed89b7c0de81e9c3095b16dc03bfa | [
"MIT"
] | null | null | null | app/containers/HomePage/reducer.js | nshganesh/tallyx-invoice-filter | 1853e69a31aed89b7c0de81e9c3095b16dc03bfa | [
"MIT"
] | 5 | 2020-04-07T03:37:19.000Z | 2022-03-26T01:58:47.000Z | app/containers/HomePage/reducer.js | nshganesh/tallyx-invoice-filter | 1853e69a31aed89b7c0de81e9c3095b16dc03bfa | [
"MIT"
] | null | null | null | /*
* HomeReducer
*
* The reducer takes care of our data. Using actions, we can
* update our application state. To add a new action,
* add it to the switch statement in the reducer function
*
*/
import produce from 'immer';
import * as types from './constants';
export const currencies = [
{
locale: "en-US",
slug: "USD",
},
{
locale: "en-IN",
slug: "INR",
},
{
locale: "en-US",
slug: "JPY",
},
{
locale: "en-IN",
slug: "RYD",
}
]
// The initial state of the App
export const initialState = {
currency: currencies[0],
amountRange: {
min: "",
max: "",
},
dateRange: [new Date('01/01/2019'), new Date('01/01/2020')],
loading: false,
error: null,
invoices: [],
showInvoiceList: false
};
/* eslint-disable default-case, no-param-reassign */
const homeReducer = (state = initialState, action) =>
produce(state, draft => {
switch (action.type) {
case types.CURRENCY_CHANGED:
draft.currency = action.payload.currency
draft.showInvoiceList = false
break;
case types.AMOUNT_RANGE_CHANGED:
draft.amountRange = action.payload.amount
draft.showInvoiceList = false
break;
case types.DATE_RANGE_CHANGED:
draft.dateRange = action.payload.date
draft.showInvoiceList = false
break;
case types.FILTER_INVOICE_START:
draft.loading = true;
draft.error = null;
draft.showInvoiceList = false
break;
case types.FILTER_INVOICE_SUCCESS:
draft.invoices = action.payload.invoices
draft.showInvoiceList = true
draft.loading = false;
break;
case types.FILTER_INVOICE_FAILURE:
draft.error = "Unable to filter out the invoices"
draft.showInvoiceList = false
draft.loading = false;
break;
}
});
export default homeReducer;
| 23.060976 | 62 | 0.61872 |
27581e4e0106ff063971fb0211373d822c32ada5 | 172 | js | JavaScript | docs/search/namespaces_0.js | FRC-Team2655/robot2022 | bfb7e1722ce0ea31cd6238b67ee3912f9cc9bf4f | [
"BSD-3-Clause"
] | null | null | null | docs/search/namespaces_0.js | FRC-Team2655/robot2022 | bfb7e1722ce0ea31cd6238b67ee3912f9cc9bf4f | [
"BSD-3-Clause"
] | null | null | null | docs/search/namespaces_0.js | FRC-Team2655/robot2022 | bfb7e1722ce0ea31cd6238b67ee3912f9cc9bf4f | [
"BSD-3-Clause"
] | null | null | null | var searchData=
[
['jshelper_0',['jshelper',['../namespaceteam2655_1_1jshelper.html',1,'team2655']]],
['team2655_1',['team2655',['../namespaceteam2655.html',1,'']]]
];
| 28.666667 | 85 | 0.656977 |
2759c71e28dda3595f5678aa16251cc98fcb9d77 | 9,354 | js | JavaScript | src/pages/about.js | ResearchKernel/frontend-gatsby | 1b972061a3307e68b87f8881fde6e06ba141da2d | [
"MIT"
] | 3 | 2019-06-19T19:44:45.000Z | 2020-02-18T05:15:21.000Z | src/pages/about.js | ResearchKernel/frontend-gatsby | 1b972061a3307e68b87f8881fde6e06ba141da2d | [
"MIT"
] | 4 | 2019-01-28T10:04:18.000Z | 2019-06-21T06:19:10.000Z | src/pages/about.js | ResearchKernel/frontend-gatsby | 1b972061a3307e68b87f8881fde6e06ba141da2d | [
"MIT"
] | 7 | 2019-01-22T18:05:44.000Z | 2019-06-19T18:44:40.000Z | import { Card, Col, Layout, Row, Table } from 'antd'
import React, { Fragment } from 'react'
import Header from '../components/header/header'
const { Content, Footer } = Layout
const columns = [
{
title: 'Domain Category',
dataIndex: 'name',
},
{
title: 'Codes',
dataIndex: 'age',
},
{
title: 'Domain Sub-Category',
dataIndex: 'address',
},
]
const data = [
{
name: 'John Brown',
age: 32,
address: 'New York No. 1 Lake Park',
},
{
key: '2',
name: 'Jim Green',
age: 42,
address: 'London No. 1 Lake Park',
},
{
key: '3',
name: 'Joe Black',
age: 32,
address: 'Sidney No. 1 Lake Park',
},
]
function about() {
return (
<Fragment>
<Header />
<div
style={{
background: '#6a8da6',
textAlign: 'center',
height: 250,
display: 'flex',
}}
>
<h1 style={{ textAlign: 'center', display: 'flex', fontSize: '13' }}>
An Open Source Project, with the vision of providing everything at one
place to Researchers.
</h1>
</div>
{/* ResearchKernel's Contextual Search and Open Community Forum */}
<Content style={{ padding: '0 50px', marginTop: 64 }}>
<Row gutter={16}>
<div
style={{ background: '#ECECEC', fontSize: 20, textAlign: 'center' }}
>
<h3>ResearchKernel's Contextual Search and Open Community Forum</h3>
</div>
<Col span={12} offset={6}>
<p>
Our objective at ResearchKernel is to not only provide a platform
for you to do a search but also make it interactive and relevant.
With Contextual Search, we make the tedious task of searching
easier only show what's relevant to you that save your time from
going through unnecessary Search Results. We also provide
Community Forum to find like-minded people that might become your
collaborators for your project.
</p>
</Col>
<br />
</Row>
</Content>
{/* Lis of cards */}
<Content>
<Row gutter={8}>
<Col span={4}>
<Card
hoverable
style={{ height: 240, width: 240 }}
cover={
<img
alt="example"
src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FoG9JWEcm7dlTi%2Fgiphy.gif&f=1"
/>
}
/>
</Col>
<Col span={4}>
<Card
hoverable
style={{ height: 240, width: 240 }}
cover={
<img
alt="example"
src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fi.pinimg.com%2Foriginals%2F68%2F6b%2F26%2F686b2629c7037e38cbc5aa8f74d31401.gif&f=1"
/>
}
/>
</Col>
<Col span={4}>
<Card
hoverable
style={{ height: 240, width: 240 }}
cover={
<img
alt="example"
src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fi.pinimg.com%2Foriginals%2F21%2F7d%2Fa2%2F217da299cc918fad9b76eb99e4bb75b3.gif&f=1"
/>
}
/>
</Col>
<Col span={4}>
<Card
hoverable
style={{ height: 240, width: 240 }}
cover={
<img
alt="example"
src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FoG9JWEcm7dlTi%2Fgiphy.gif&f=1"
/>
}
/>
</Col>
<Col span={4}>
<Card
hoverable
style={{ height: 240, width: 240 }}
cover={
<img
alt="example"
src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fi.pinimg.com%2Foriginals%2F21%2F7d%2Fa2%2F217da299cc918fad9b76eb99e4bb75b3.gif&f=1"
/>
}
/>
</Col>
<Col span={4}>
<Card
hoverable
style={{ height: 240, width: 240 }}
cover={
<img
alt="example"
src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fi.pinimg.com%2Foriginals%2F68%2F6b%2F26%2F686b2629c7037e38cbc5aa8f74d31401.gif&f=1"
/>
}
/>
</Col>
</Row>
</Content>
{/* Personalized */}
<Content>
<Row gutter={16}>
<div
style={{ background: '#ECECEC', fontSize: 20, textAlign: 'center' }}
>
<h3> Personalised Recomendations, Daily Updates from Arxiv.org</h3>
</div>
<Col span={12} offset={6}>
<p>
Staying Updated is very important, however not everything which is
published will be usefull. Our Platfrom will also give you
relevant updates that helps you in your research domain. We use
Machine Learning and Deep Learning for finding what information
will be relevant for you based on you interaction with
ResearchKernel.
</p>
<br />
</Col>
</Row>
</Content>
{/* Lis of cards */}
<Content>
<Content>
<Row gutter={8}>
<Col span={4}>
<Card
hoverable
style={{ height: 240, width: 240 }}
cover={
<img
alt="example"
src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FoG9JWEcm7dlTi%2Fgiphy.gif&f=1"
/>
}
/>
</Col>
<Col span={4}>
<Card
hoverable
style={{ height: 240, width: 240 }}
cover={
<img
alt="example"
src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fi.pinimg.com%2Foriginals%2F68%2F6b%2F26%2F686b2629c7037e38cbc5aa8f74d31401.gif&f=1"
/>
}
/>
</Col>
<Col span={4}>
<Card
hoverable
style={{ height: 240, width: 240 }}
cover={
<img
alt="example"
src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fi.pinimg.com%2Foriginals%2F21%2F7d%2Fa2%2F217da299cc918fad9b76eb99e4bb75b3.gif&f=1"
/>
}
/>
</Col>
<Col span={4}>
<Card
hoverable
style={{ height: 240, width: 240 }}
cover={
<img
alt="example"
src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FoG9JWEcm7dlTi%2Fgiphy.gif&f=1"
/>
}
/>
</Col>
<Col span={4}>
<Card
hoverable
style={{ height: 240, width: 240 }}
cover={
<img
alt="example"
src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fi.pinimg.com%2Foriginals%2F21%2F7d%2Fa2%2F217da299cc918fad9b76eb99e4bb75b3.gif&f=1"
/>
}
/>
</Col>
<Col span={4}>
<Card
hoverable
style={{ height: 240, width: 240 }}
cover={
<img
alt="example"
src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fi.pinimg.com%2Foriginals%2F68%2F6b%2F26%2F686b2629c7037e38cbc5aa8f74d31401.gif&f=1"
/>
}
/>
</Col>
</Row>
</Content>
</Content>
{/* Current Domains we are working on. */}
<Content style={{ padding: '0 50px', marginTop: 64 }}>
<Row gutter={16}>
<div
style={{ background: '#ECECEC', fontSize: 20, textAlign: 'center' }}
>
<h3> Domains we have at ResearchKernel </h3>
</div>
<Col span={12} offset={6}>
<p>
As an open source project, we are focusing on only publicily
available search papers. We have started from Arxiv.org that is
one of the largest free research paper proverder out there. We are
harvesting all the research paper arxiv has in there database from
1999 till date, however we are not limited to arxiv databse, we
will also incoporate other domains databses too in future.
</p>
<br />
<p>
<Table columns={columns} dataSource={data} size="middle" />
</p>
</Col>
</Row>
</Content>
<Footer>
<h1>This is footer</h1>
</Footer>
</Fragment>
)
}
export default about
| 32.366782 | 157 | 0.460445 |
275a6bd94311f054f6ddfb9648e1a8862f6019d5 | 466 | js | JavaScript | src/controllers/exhibitions/exhibitionIndexCtrl.js | indiaderrick/wdi-project-three | 5ddfb3f72b67d037c1ed1b31ba2a1ff7054de782 | [
"MIT"
] | 1 | 2018-12-20T14:12:51.000Z | 2018-12-20T14:12:51.000Z | src/controllers/exhibitions/exhibitionIndexCtrl.js | indiaderrick/wdi-project-3 | 5ddfb3f72b67d037c1ed1b31ba2a1ff7054de782 | [
"MIT"
] | 4 | 2021-10-05T23:36:48.000Z | 2022-02-26T13:28:58.000Z | src/controllers/exhibitions/exhibitionIndexCtrl.js | indiaderrick/wdi-project-3 | 5ddfb3f72b67d037c1ed1b31ba2a1ff7054de782 | [
"MIT"
] | 1 | 2018-12-19T14:41:48.000Z | 2018-12-19T14:41:48.000Z | function exhibitionIndexCtrl($scope, $http) {
$http({
method: 'GET',
url: '/api/exhibitions'
}).then(result => {
$scope.allExhibitions = result.data;
$scope.filteredExhibitions = $scope.allExhibitions;
});
$scope.handleFilterSubmit = function (){
$scope.filteredExhibitions = $scope.allExhibitions.filter(exhibition => exhibition.name.toLowerCase().includes($scope.searchTerm.toLowerCase()));
};
}
export default exhibitionIndexCtrl;
| 29.125 | 149 | 0.706009 |
275b579aa506e87e33d887a1d7cd18da03b37cdc | 126 | js | JavaScript | src/shift_redeemer/errors/resolver/invalid.js | Acen/borderlands | 050876561de6c948101ada46b80984fb750e2dc2 | [
"MIT"
] | 2 | 2019-09-18T00:20:51.000Z | 2019-09-18T01:16:11.000Z | src/shift_redeemer/errors/resolver/invalid.js | Acen/borderlands | 050876561de6c948101ada46b80984fb750e2dc2 | [
"MIT"
] | null | null | null | src/shift_redeemer/errors/resolver/invalid.js | Acen/borderlands | 050876561de6c948101ada46b80984fb750e2dc2 | [
"MIT"
] | null | null | null | // @flow
export default class Invalid extends Resolver
{
constructor() {
super();
}
fix(): void {
}
} | 12.6 | 45 | 0.531746 |
275b7fdd5ae1b86990e9686dd802b05c8ad6ec53 | 292 | js | JavaScript | app/routes/new-book.js | nedfaulhaber/book-review-ember | c136d7acef0a688ee16e548de055ba152f73cf8e | [
"MIT"
] | 1 | 2016-07-28T18:44:35.000Z | 2016-07-28T18:44:35.000Z | app/routes/new-book.js | nedfaulhaber/book-review-ember | c136d7acef0a688ee16e548de055ba152f73cf8e | [
"MIT"
] | null | null | null | app/routes/new-book.js | nedfaulhaber/book-review-ember | c136d7acef0a688ee16e548de055ba152f73cf8e | [
"MIT"
] | null | null | null | import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.findAll('book');
},
actions: {
saveNewBook3(params) {
var newBook = this.store.createRecord('book', params);
newBook.save();
this.transitionTo('index');
}
}
});
| 18.25 | 60 | 0.609589 |
275d8fde54efe57746e61f671771eae231b3f843 | 267 | js | JavaScript | packages/web/modules/filter/gql.js | liuderchi/todomvc-subscriptions | b89bb6b400e38bd7f9207af0b69a88f37b7a2f27 | [
"MIT"
] | 24 | 2017-12-28T00:59:32.000Z | 2021-08-02T14:14:57.000Z | packages/web/modules/filter/gql.js | liuderchi/todomvc-subscriptions | b89bb6b400e38bd7f9207af0b69a88f37b7a2f27 | [
"MIT"
] | 69 | 2017-12-27T16:17:20.000Z | 2020-02-22T13:01:22.000Z | packages/web/modules/filter/gql.js | liuderchi/todomvc-subscriptions | b89bb6b400e38bd7f9207af0b69a88f37b7a2f27 | [
"MIT"
] | 3 | 2017-12-29T06:55:41.000Z | 2018-06-23T04:03:21.000Z | // @flow
import gql from 'graphql-tag';
export const FILTER_QUERY = gql`
query filterQuery {
filter @client
}
`;
export const UPDATE_FILTER_MUTATION = gql`
mutation updateFilterMutation($filter: String!) {
updateFilter(filter: $filter) @client
}
`;
| 17.8 | 51 | 0.700375 |
275f752e0f0856e429b187877aa49653c25a4d11 | 1,132 | js | JavaScript | LeetCode/Valid-Mountain-Array.js | AmMiRo/Code-Challenges | af5feae29f236148de53b591f30b6f0670ddf327 | [
"MIT"
] | null | null | null | LeetCode/Valid-Mountain-Array.js | AmMiRo/Code-Challenges | af5feae29f236148de53b591f30b6f0670ddf327 | [
"MIT"
] | null | null | null | LeetCode/Valid-Mountain-Array.js | AmMiRo/Code-Challenges | af5feae29f236148de53b591f30b6f0670ddf327 | [
"MIT"
] | null | null | null | // Description
// Given an array of integers arr, return true if and only if it is a valid mountain array.
// Recall that arr is a mountain array if and only if:
// arr.length >= 3
// There exists some i with 0 < i < arr.length - 1 such that:
// arr[0] < arr[1] < ... < arr[i - 1] < arr[i]
// arr[i] > arr[i + 1] > ... > arr[arr.length - 1]
// Example 1:
// Input: arr = [2,1]
// Output: false
// Example 2:
// Input: arr = [3,5,5]
// Output: false
// Solution
const validMountainArray = function (arr) {
// initialize variables (peak, descending, result)
let last = -1;
let increase = false;
let decreasing = false;
if (arr[0] < arr[1]) increase = true;
// loop through arr
for (const val of arr) {
if (!decreasing) {
if (val > last) {
last = val;
} else if (val === last) {
return false;
} else if (val < last) {
last = val;
decreasing = true;
}
} else if (decreasing) {
if (val < last) {
last = val;
} else if (val >= last) {
return false;
}
}
}
return increase === true && decreasing === true;
};
| 21.358491 | 91 | 0.545053 |
2760bc69e0c0818d4e2b6db06b260fef7488fa7f | 2,607 | js | JavaScript | main.js | Amrit-PennySoft/text-2-speech-app | 6b5c6af8cca018be341fae2c7d94ff61670a2fa0 | [
"MIT"
] | null | null | null | main.js | Amrit-PennySoft/text-2-speech-app | 6b5c6af8cca018be341fae2c7d94ff61670a2fa0 | [
"MIT"
] | null | null | null | main.js | Amrit-PennySoft/text-2-speech-app | 6b5c6af8cca018be341fae2c7d94ff61670a2fa0 | [
"MIT"
] | null | null | null |
const synth = window.speechSynthesis;
//dom
const textForm = document.querySelector('form');
const textInput = document.querySelector('#text-input');
const voiceSelect= document.querySelector('#voice-select');
const rate = document.querySelector('#rate');
const rateValue = document.querySelector('#rate-value');
const pitch = document.querySelector('#pitch');
const pitchValue = document.querySelector('#pitch-value');
const body = document.querySelector('body');
//init voice array
let voices = [];
const getVoices = () => {
voices = synth.getVoices();
//looping through voices and creating an option for each voice.
voices.forEach(voice =>{
//option element
const option = document.createElement('option');
//fill option with voice and languages
option.textContent = voice.name + '(' + voice.lang + ')';
//set option Attr
option.setAttribute('data-lang', voice.lang);
option.setAttribute('data-name', voice.lang);
voiceSelect.appendChild(option);
});
};
getVoices();
if (synth.onvoiceschanged !== undefined) {
synth.onvoiceschanged = getVoices;
}
//speak
const speak = () => {
//check
if (synth.speaking) {
console.error('Already speaking...');
return;
}
if (textInput.value !== '') {
//add bg animation
body.style.background = '#ffc259 url(wave.gif)';
body.style.backgroundRepeat = 'repeat-x';
body.style.backgroundSize = '100% 100%';
// get speak texxt
const speakText = new SpeechSynthesisUtterance(textInput.value);
// end of speaking
speakText.onend = e => {
console.log('Done speaking...');
body.stylee.background = 'orange';
};
// speak err
speakText.onerror= e => {
console.error('Something went wrong');
};
// selected voice
const selectedVoice = voiceSelect.selectedOptions[0].getAttribute(
'data-name'
);
// looping through voices
voices.forEach(voice => {
if (voice.name === selectedVoice) {
speakText.voice = voice;
}
});
// setting pitch and the rate of the voice
speakText.rate = rate.value;
speakText.pitch = pitch.value;
//speaj
synth.speak(speakText);
}
};
// Event Listeners
// form Submit
textForm.addEventListener('submit', e => {
e.preventDefault();
speak();
textInput.blur();
});
// rate vlaue change
rate.addEventListener('change', e => (rateValue.textContent = rate.value));
// Pitch value change
pitch.addEventListener('change', e => (pitchValue.textContent = pitch.value));
// Voice select change
voiceSelect.addEventListener('change', e => speak()); | 24.828571 | 79 | 0.66168 |
2760d56b778585c1dda9283225b83b17fb59f840 | 195 | js | JavaScript | utilities/looker-upper.js | kthffmn/bachelor-nation-api | 158be204529504fb7d41238d1f574a3b2db3d351 | [
"MIT"
] | 4 | 2019-12-30T09:35:09.000Z | 2021-01-04T22:13:11.000Z | utilities/looker-upper.js | kthffmn/bachelor-nation-api | 158be204529504fb7d41238d1f574a3b2db3d351 | [
"MIT"
] | null | null | null | utilities/looker-upper.js | kthffmn/bachelor-nation-api | 158be204529504fb7d41238d1f574a3b2db3d351 | [
"MIT"
] | 2 | 2017-04-14T16:35:42.000Z | 2020-07-13T19:42:54.000Z | module.exports.iLike = function(qb, encodedValue, columnName) {
var value = decodeURI(encodedValue).toLowerCase();
return qb.whereRaw('LOWER(' + columnName + ') LIKE ?', '%'+ value +'%');
};
| 39 | 74 | 0.666667 |
2760eeb734094850a44e5a387fe46e65b07a0835 | 3,979 | js | JavaScript | doc/html/search/all_3.js | letsboogey/Openswarm_modified | e8865fa82a2793d0ed52e4b39e8b5b595dcaf2e8 | [
"BSD-2-Clause"
] | null | null | null | doc/html/search/all_3.js | letsboogey/Openswarm_modified | e8865fa82a2793d0ed52e4b39e8b5b595dcaf2e8 | [
"BSD-2-Clause"
] | null | null | null | doc/html/search/all_3.js | letsboogey/Openswarm_modified | e8865fa82a2793d0ed52e4b39e8b5b595dcaf2e8 | [
"BSD-2-Clause"
] | null | null | null | var searchData=
[
['cam_5fh_5fsize',['CAM_H_SIZE',['../d1/de0/camera_8c.html#a87f6f0d62673c8b80d55cb254fdaa132',1,'camera.c']]],
['cam_5fheight',['CAM_HEIGHT',['../d1/de0/camera_8c.html#ac88d2707293a4af9e155d57e3651162e',1,'camera.c']]],
['cam_5fw_5fsize',['CAM_W_SIZE',['../d1/de0/camera_8c.html#ad704d271abcf09d75aa90b8e8ebb798b',1,'camera.c']]],
['cam_5fwidth',['CAM_WIDTH',['../d1/de0/camera_8c.html#ad2cc26b8da12f6603455f84312aa649b',1,'camera.c']]],
['cam_5fzoom_5fx',['CAM_ZOOM_X',['../d1/de0/camera_8c.html#a8a26078945b82dbf66c0efc3ba627f64',1,'camera.c']]],
['cam_5fzoom_5fy',['CAM_ZOOM_Y',['../d1/de0/camera_8c.html#ae584e2494887491a5b7ac09d50a2bddd',1,'camera.c']]],
['camera_20module',['Camera Module',['../dc/d90/group__camera.html',1,'']]],
['camera_2ec',['camera.c',['../d1/de0/camera_8c.html',1,'']]],
['camera_2eh',['camera.h',['../d7/df6/camera_8h.html',1,'']]],
['camera_5fi2c_5faddress',['CAMERA_I2C_ADDRESS',['../d1/de0/camera_8c.html#a823cb7ece14931bb4bf0c7f7311c5c28',1,'camera.c']]],
['camera_5fprocessing_2ec',['camera_processing.c',['../df/ded/camera__processing_8c.html',1,'']]],
['camera_5fprocessing_2eh',['camera_processing.h',['../d6/d91/camera__processing_8h.html',1,'']]],
['cbp_5fbi',['CBP_BI',['../df/ded/camera__processing_8c.html#ae4272405bfe7895ae551a73eb3e57ce4',1,'camera_processing.c']]],
['cbp_5fdi',['CBP_DI',['../df/ded/camera__processing_8c.html#a1bd13187a78a2c1258be972e24a06ce4',1,'camera_processing.c']]],
['cbp_5fgi',['CBP_GI',['../df/ded/camera__processing_8c.html#a88b9154d8df00524dbc91f1f967aacf0',1,'camera_processing.c']]],
['cbp_5fri',['CBP_RI',['../df/ded/camera__processing_8c.html#ac8d9040a94f25bd12d6972838d18c99c',1,'camera_processing.c']]],
['cbp_5fwi',['CBP_WI',['../df/ded/camera__processing_8c.html#ad683afd109dbb4a0ba3a305695b49095',1,'camera_processing.c']]],
['colorbrushedpositions',['colorBrushedPositions',['../df/ded/camera__processing_8c.html#ac42b96872bf2f2373b80d1fcb3deaed9',1,'camera_processing.c']]],
['colorpositions',['colorPositions',['../df/ded/camera__processing_8c.html#a9eb4d4edc09176b41bb78a120a3dbaf5',1,'camera_processing.c']]],
['colour_5fthreshold',['COLOUR_THRESHOLD',['../d1/de0/camera_8c.html#a8465aecf447b8b92461390e7286ccf48',1,'camera.c']]],
['condition',['condition',['../d5/d91/structsys__peh.html#ac6054670e82aec5a0bfef3b7e114c9e5',1,'sys_peh']]],
['convertrgb565torgb888',['convertRGB565ToRGB888',['../df/ded/camera__processing_8c.html#a805427a51bfe2cf4d675d7cb479b819b',1,'convertRGB565ToRGB888(unsigned char rgb565[], unsigned char rgb888[]): camera_processing.c'],['../d6/d91/camera__processing_8h.html#a805427a51bfe2cf4d675d7cb479b819b',1,'convertRGB565ToRGB888(unsigned char rgb565[], unsigned char rgb888[]): camera_processing.c']]],
['cp_5fbi',['CP_BI',['../d1/de0/camera_8c.html#af0acaf3f612c4f6bd5635ff85173b162',1,'CP_BI(): camera.c'],['../df/ded/camera__processing_8c.html#af0acaf3f612c4f6bd5635ff85173b162',1,'CP_BI(): camera_processing.c']]],
['cp_5fgi',['CP_GI',['../d1/de0/camera_8c.html#a031d522e9dc797514743213855bee6c9',1,'CP_GI(): camera.c'],['../df/ded/camera__processing_8c.html#a031d522e9dc797514743213855bee6c9',1,'CP_GI(): camera_processing.c']]],
['cp_5fri',['CP_RI',['../d1/de0/camera_8c.html#a9f6f5c8760a079b52078c259212255a3',1,'CP_RI(): camera.c'],['../df/ded/camera__processing_8c.html#a9f6f5c8760a079b52078c259212255a3',1,'CP_RI(): camera_processing.c']]],
['cp_5fwgb_5fi',['CP_WGB_I',['../df/ded/camera__processing_8c.html#a423f50937f8bb653d67f6b68049527ea',1,'camera_processing.c']]],
['cp_5fwi',['CP_WI',['../d1/de0/camera_8c.html#ac1d329efbf5bd63d23e1c623104650a7',1,'CP_WI(): camera.c'],['../df/ded/camera__processing_8c.html#ac1d329efbf5bd63d23e1c623104650a7',1,'CP_WI(): camera_processing.c']]],
['cyan',['CYAN',['../d6/dc2/definitions_8h.html#a305962be90b6e5c8f0dd0b7b48604f26aafe71cad474c15ce63b300c470eef8cc',1,'definitions.h']]]
];
| 124.34375 | 404 | 0.747173 |
27619650ddd8b80ab99eb7335a1733c8e4d5b1ff | 6,600 | js | JavaScript | docker/share-state-liability/listen-market.js | amazingmj/aira-IoT | f0fe5bc7e833eccd58d0d12b490d84c14c0be90b | [
"BSD-3-Clause"
] | 2 | 2018-01-15T07:34:50.000Z | 2018-03-18T06:30:29.000Z | docker/share-state-liability/listen-market.js | amazingmj/aira-IoT | f0fe5bc7e833eccd58d0d12b490d84c14c0be90b | [
"BSD-3-Clause"
] | null | null | null | docker/share-state-liability/listen-market.js | amazingmj/aira-IoT | f0fe5bc7e833eccd58d0d12b490d84c14c0be90b | [
"BSD-3-Clause"
] | 2 | 2018-01-15T07:34:51.000Z | 2020-09-30T18:27:19.000Z | #!/usr/bin/env node
const parity = process.env.PARITY_NODE;
const market = require('/conf/market')['market'];
const market_abi = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"asks","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_beneficiary","type":"address"},{"name":"_promisee","type":"address"},{"name":"_price","type":"uint256"}],"name":"limitSell","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"asksLength","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"bids","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"hammer","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"bidsLength","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_id","type":"uint256"},{"name":"_beneficiary","type":"address"},{"name":"_promisee","type":"address"}],"name":"sellAt","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"destroy","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_id","type":"uint256"},{"name":"_candidates","type":"uint256"}],"name":"sellConfirm","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"priceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_price","type":"uint256"}],"name":"limitBuy","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"uint256"}],"name":"ordersOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_id","type":"uint256"}],"name":"buyAt","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_i","type":"uint256"}],"name":"getOrder","outputs":[{"name":"","type":"address[]"},{"name":"","type":"address[]"},{"name":"","type":"address"},{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_hammer","type":"address"}],"name":"setHammer","outputs":[],"payable":false,"type":"function"},{"inputs":[{"name":"_name","type":"string"}],"payable":false,"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"order","type":"uint256"}],"name":"OpenAskOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"order","type":"uint256"}],"name":"OpenBidOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"order","type":"uint256"}],"name":"CloseAskOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"order","type":"uint256"}],"name":"CloseBidOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"order","type":"uint256"},{"indexed":true,"name":"beneficiary","type":"address"},{"indexed":true,"name":"promisee","type":"address"}],"name":"AskOrderCandidates","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"liability","type":"address"}],"name":"NewLiability","type":"event"}];
const liability_abi = [{"constant":false,"inputs":[{"name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"cost","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"hammer","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"promisee","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_resultHash","type":"bytes32"}],"name":"publishHash","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"gasbase","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"gasprice","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"destroy","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"resultHash","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_gasprice","type":"uint256"}],"name":"payment","outputs":[{"name":"","type":"bool"}],"payable":true,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"promisor","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_hammer","type":"address"}],"name":"setHammer","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"token","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"inputs":[{"name":"_promisor","type":"address"},{"name":"_promisee","type":"address"},{"name":"_token","type":"address"},{"name":"_cost","type":"uint256"}],"payable":false,"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"hash","type":"bytes32"}],"name":"Result","type":"event"}];
const exec = require('child_process').execSync;
var Web3 = require('web3');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://'+parity+':8545'));
var m = web3.eth.contract(market_abi).at(market);
console.log('Connected to Market: '+m.name());
m.NewLiability({}, '', (e, r) => {
if (!e) {
var l = web3.eth.contract(liability_abi).at(r.args.liability);
console.log('New Liability contract from market: '+r.args.liability);
if (l.promisee() == web3.eth.accounts[0]) {
console.log('Propmisee is '+l.promisee()+', its me! Running...');
exec('run-liability.sh '+r.args.liability);
console.log('Well done!');
}
}
});
| 227.586207 | 3,629 | 0.623636 |
2761f2b0b64417b0c820b859362ebd11925365b2 | 1,286 | js | JavaScript | src/model/Log.js | GorillaBus/abb-test | ddb26b6ed16201e3083fbfb334dc53b5efdbd3c8 | [
"MIT"
] | null | null | null | src/model/Log.js | GorillaBus/abb-test | ddb26b6ed16201e3083fbfb334dc53b5efdbd3c8 | [
"MIT"
] | null | null | null | src/model/Log.js | GorillaBus/abb-test | ddb26b6ed16201e3083fbfb334dc53b5efdbd3c8 | [
"MIT"
] | null | null | null | 'use strict'
const model = (mongoose) => {
const LogSchema = new mongoose.Schema({
machine_id: { type: mongoose.Schema.Types.ObjectId, ref: 'Machine', required: true },
control_id: { type: mongoose.Schema.Types.ObjectId, ref: 'Control', required: true },
feature_id: { type: Number, required: true },
feature_title: { type: String, required: true },
x: { type: Number, required: true },
y: { type: Number, required: true },
z: { type: Number, required: true },
d: { type: Number, required: true },
x_dev: { type: Number, required: false },
y_dev: { type: Number, required: false },
z_dev: { type: Number, required: false },
d_dev: { type: Number, required: false },
x_valid: { type: Number, required: false },
y_valid: { type: Number, required: false },
z_valid: { type: Number, required: false },
d_valid: { type: Number, required: false },
date: { type: Date, required: true, default: Date.now }
});
LogSchema.index({ date: 1 }, { unique: false, name: "date_index" });
LogSchema.index({ machine_id: 1, date: 1 }, { unique: false, name: "machine_date_index" });
LogSchema.set('autoIndex', true); // Should change to False on production environment
const model = mongoose.model("Log", LogSchema);
return model;
};
module.exports = model;
| 35.722222 | 92 | 0.661742 |
2762f00fe0e0064e92b4a573f69d0a027544d029 | 1,292 | js | JavaScript | helpers/bookHelper.js | anandukch/Book-Review-platform | ad315c58d0d1043461bbf4dc33cf0a3f216e50a9 | [
"MIT"
] | 2 | 2021-06-24T14:34:45.000Z | 2021-07-31T14:38:32.000Z | helpers/bookHelper.js | anandukch/Book-review-platform | ad315c58d0d1043461bbf4dc33cf0a3f216e50a9 | [
"MIT"
] | null | null | null | helpers/bookHelper.js | anandukch/Book-review-platform | ad315c58d0d1043461bbf4dc33cf0a3f216e50a9 | [
"MIT"
] | null | null | null | var db = require("../config/connection");
var collection = require("../config/collection.js");
const { ObjectID } = require("bson");
module.exports = {
addBooks: (book, userid) => {
book.userId = ObjectID(userid);
let books = {
...book,
rating: [],
};
db.get()
.collection(collection.BOOK_COLLECTION)
.insertOne(books)
.then((data) => {
console.log(data);
});
},
getAllBooks: () => {
return new Promise(async (resolve, reject) => {
let books = await db
.get()
.collection(collection.BOOK_COLLECTION)
.find()
.toArray();
resolve(books);
});
},
getUserBooks: (userid) => {
return new Promise(async (resolve, reject) => {
let books = await db
.get()
.collection(collection.BOOK_COLLECTION)
.find({userId:ObjectID(userid)})
.toArray();
resolve(books);
});
},
getRate: (bookId) => {
return new Promise(async (resolve, reject) => {
let c = await db
.get()
.collection(collection.BOOK_COLLECTION)
.findOne({ _id: ObjectID(bookId) })
.toArray();
console.log("book " + c.rating);
resolve(c);
});
},
};
| 24.846154 | 53 | 0.513932 |
27631bd3ac8629ea7aa7bf04fddf4c48a0a973bc | 325 | js | JavaScript | Backend/src/models/MasterUser.js | RhuanPrado/Cotapp | f4770b07c4c64d747df9ff45de6f6e852efd4b07 | [
"MIT"
] | null | null | null | Backend/src/models/MasterUser.js | RhuanPrado/Cotapp | f4770b07c4c64d747df9ff45de6f6e852efd4b07 | [
"MIT"
] | null | null | null | Backend/src/models/MasterUser.js | RhuanPrado/Cotapp | f4770b07c4c64d747df9ff45de6f6e852efd4b07 | [
"MIT"
] | null | null | null | const { Schema, model } = require ('mongoose');
const MasterUserSchema = new Schema({
user:{
type:String,
required: true
},
password:{
type: String,
required: true,
},
master: Boolean,
},{
timestamps:true,
});
module.exports = model('MasterUser', MasterUserSchema); | 17.105263 | 55 | 0.578462 |
276572241fa857a18574780d168c45d57a8d62c5 | 3,740 | js | JavaScript | dist/es2015/conductor.js | OrinoLabs/animate | ffd9f0ee3b73359e1699345c85de7336945012e3 | [
"MIT"
] | null | null | null | dist/es2015/conductor.js | OrinoLabs/animate | ffd9f0ee3b73359e1699345c85de7336945012e3 | [
"MIT"
] | null | null | null | dist/es2015/conductor.js | OrinoLabs/animate | ffd9f0ee3b73359e1699345c85de7336945012e3 | [
"MIT"
] | 1 | 2018-04-12T11:54:52.000Z | 2018-04-12T11:54:52.000Z | /**
* @copyright 2018 Orino Labs GmbH
* @author Michael Bürge <mib@orino.ch>
*/
import { Animation } from './animation.js';
import { Loop } from './loop.js';
export class Conductor extends Animation {
constructor() {
super();
this.inTick = false;
this.animations = [];
this.postTickQueue = [];
}
/**
* @override
*/
isRunning() {
if (this.conductor)
return this.conductor.isRunning();
if (this.loop)
return this.loop.isRunning();
return false;
}
/**
* Adds an animation.
*/
add(animation) {
if (this.inTick) {
this.postTickQueue.push(() => this.add(animation));
return;
}
if (!this.animations.length) {
this.animations.push(animation);
}
else {
// Ensure the same animation is not added twice.
let idx = this.animations.indexOf(animation);
if (idx != -1) {
this.animations.splice(idx, 1);
}
// Ordered insert by priority.
idx = 0;
while (idx < this.animations.length &&
animation.priority <= this.animations[idx].priority) {
idx++;
}
this.animations.splice(idx, 0, animation);
}
this.maybeStart();
}
/**
* Removes an animation.
*/
remove(animation) {
if (this.inTick) {
this.postTickQueue.push(() => this.remove(animation));
return;
}
let idx = this.animations.indexOf(animation);
if (idx != -1) {
this.animations.splice(idx, 1);
}
this.maybeStop();
}
/**
* Clears all animations.
*/
clear() {
this.animations.slice().forEach((animation) => animation.stop());
this.stop();
this.animations.length = 0;
}
activeAnimationsPresent() {
let haveActive = false;
this.animations.forEach((animation) => {
if (!animation.isPassive())
haveActive = true;
});
return haveActive;
}
maybeStart() {
if (this.activeAnimationsPresent()) {
this.start();
}
}
maybeStop() {
if (!this.activeAnimationsPresent()) {
this.stop();
}
}
start() {
if (this.conductor) {
this.conductor.add(this);
}
else {
this.state.initialized = false;
if (!this.loop) {
this.loop = new Loop((time) => {
if (this.state.initialized) {
this.state.elapsed = time - this.state.time;
}
else {
this.state.elapsed = 0;
this.state.initialized = true;
}
this.state.time = time;
this.tick();
});
}
this.loop.start();
}
}
stop() {
if (this.conductor) {
this.conductor.remove(this);
}
else {
this.loop && this.loop.stop();
}
}
tick() {
this.inTick = true;
for (var i = 0; i < this.animations.length; i++) {
var anim = this.animations[i];
anim.updateAndTick(this.state);
}
this.inTick = false;
if (this.postTickQueue.length) {
this.postTickQueue.forEach((fn) => fn());
this.postTickQueue.length = 0;
}
}
/**
* Disposes this instance.
*/
dispose() {
super.dispose();
this.animations = null;
}
}
| 26.524823 | 73 | 0.460963 |
2766335a23989ff270e50faf475e15076b81902f | 1,391 | js | JavaScript | js/countdown.min.js | IciaCarroBarallobre/hellosisters.github.io | 538530bcdefed867d8ea5f03256dff5c2de592d6 | [
"CC-BY-3.0"
] | 3 | 2021-04-09T19:33:23.000Z | 2021-09-27T08:29:27.000Z | js/countdown.min.js | IciaCarroBarallobre/hellosisters.github.io | 538530bcdefed867d8ea5f03256dff5c2de592d6 | [
"CC-BY-3.0"
] | 18 | 2018-04-27T14:15:51.000Z | 2021-06-10T16:16:50.000Z | js/countdown.min.js | IciaCarroBarallobre/hellosisters.github.io | 538530bcdefed867d8ea5f03256dff5c2de592d6 | [
"CC-BY-3.0"
] | 3 | 2019-05-11T12:00:04.000Z | 2020-04-05T12:11:12.000Z | !function(s){s.fn.countdown=function(e,t){function n(){eventDate=Date.parse(i.date)/1e3,currentDate=Math.floor(s.now()/1e3),eventDate<=currentDate&&(t.call(this),clearInterval(interval)),seconds=eventDate-currentDate,this_sel.find(".years").length>0&&(years=Math.floor(seconds/31536e3),seconds-=60*years*60*24*365),this_sel.find(".days").length>0&&(days=Math.floor(seconds/86400),seconds-=60*days*60*24),this_sel.find(".hours").length>0&&(hours=Math.floor(seconds/3600),seconds-=60*hours*60),this_sel.find(".mins").length>0&&(minutes=Math.floor(seconds/60),seconds-=60*minutes),this_sel.find(".years").length>0&&(years=String(years).length<2?"0"+years:years),this_sel.find(".days").length>0&&(days=String(days).length<2?"0"+days:days),this_sel.find(".hours").length>0&&(hours=2!==String(hours).length?"0"+hours:hours),this_sel.find(".mins").length>0&&(minutes=2!==String(minutes).length?"0"+minutes:minutes),seconds=2!==String(seconds).length?"0"+seconds:seconds,isNaN(eventDate)||(this_sel.find(".years").length>0&&this_sel.find(".years").text(years),this_sel.find(".days").length>0&&this_sel.find(".days").text(days),this_sel.find(".hours").length>0&&this_sel.find(".hours").text(hours),this_sel.find(".mins").length>0&&this_sel.find(".mins").text(minutes),this_sel.find(".secs").text(seconds))}var i={date:null};e&&s.extend(i,e),this_sel=s(this),n(),interval=setInterval(n,1e3)}}(jQuery); | 1,391 | 1,391 | 0.73041 |
27663e44e55b030f2d184a1ddfda941b84a3b733 | 2,047 | js | JavaScript | src/components/admin-site/elements/LocationForm/Languages/AddNew.js | IOfoundation/launchpad-client | fa25f5c4866cb513742713f4a805b5cc90f1d0dc | [
"MIT"
] | null | null | null | src/components/admin-site/elements/LocationForm/Languages/AddNew.js | IOfoundation/launchpad-client | fa25f5c4866cb513742713f4a805b5cc90f1d0dc | [
"MIT"
] | 9 | 2018-02-22T18:22:41.000Z | 2022-02-18T03:26:11.000Z | src/components/admin-site/elements/LocationForm/Languages/AddNew.js | IOfoundation/launchpad-client | fa25f5c4866cb513742713f4a805b5cc90f1d0dc | [
"MIT"
] | null | null | null | import React, {PureComponent} from 'react';
import {PropTypes} from 'prop-types';
import {withStyles} from '@material-ui/core/styles';
import {sharedStyles} from '../styles';
import FormControl from '@material-ui/core/FormControl';
import Select from '@material-ui/core/Select';
import InputLabel from '@material-ui/core/InputLabel';
import MenuItem from '@material-ui/core/MenuItem';
import {combineStyles} from '@Utils';
import {languages} from '@StaticData/data';
class AddNew extends PureComponent {
state = {
language: '',
};
updateValue = event => {
const {handleChange, arrayHelpers} = this.props;
const info = event.target;
if (info.value) {
handleChange(event);
this.setState({[event.target.name]: info.value});
arrayHelpers.push(info.value);
}
};
render() {
const {classes, errors} = this.props;
return (
<FormControl className={classes.formControl} style={{minWidth: '100%'}}>
<InputLabel htmlFor={'language-options'}>
{'Select One or More Languages'}
</InputLabel>
<Select
errors={errors}
open={this.state.open}
value=""
onChange={this.updateValue}
onClose={this.handleClose}
onOpen={this.handleOpen}
inputProps={{
name: 'language',
id: 'language-options',
classes: {
icon: classes.icon,
},
}}
>
{languages.map(language => (
<MenuItem key={language.code} value={language.name}>
{language.name}
</MenuItem>
))}
</Select>
</FormControl>
);
}
}
const styles = () => ({
icon: {
color: '#272729',
},
});
AddNew.propTypes = {
arrayHelpers: PropTypes.shape({}),
classes: PropTypes.shape({
formControl: PropTypes.string,
icon: PropTypes.string,
}),
errors: PropTypes.shape({}),
handleChange: PropTypes.func,
};
export default withStyles(combineStyles(sharedStyles, styles))(AddNew);
| 25.271605 | 78 | 0.59746 |
276721a2e3be549b6e6d8cff17b3f62eeb16e9be | 515 | js | JavaScript | src/pages/my-projects.js | dev-empire/portfolio | 457605666cf81b0702fbdcbe055c3cb51f7880e2 | [
"RSA-MD"
] | null | null | null | src/pages/my-projects.js | dev-empire/portfolio | 457605666cf81b0702fbdcbe055c3cb51f7880e2 | [
"RSA-MD"
] | null | null | null | src/pages/my-projects.js | dev-empire/portfolio | 457605666cf81b0702fbdcbe055c3cb51f7880e2 | [
"RSA-MD"
] | null | null | null | import React from "react"
import styled from "styled-components"
import Layout from "../components/layout"
import SEO from "../components/seo"
const Wrapper = styled.div`
width: 70%;
margin: 0 auto;
`
const Header = styled.h2`
font-family: "Reggae One", cursive;
font-size: 3rem;
font-weight: 400;
`
const myProjects = () => {
return (
<Layout>
<SEO title="My Projects" />
<Wrapper>
<Header>My Projects</Header>
</Wrapper>
</Layout>
)
}
export default myProjects
| 17.758621 | 41 | 0.638835 |
276789af0900d5129945fdec71527999ebff889f | 56 | js | JavaScript | src/test/resources/test-data/databases/fsyncLock.js | DataGrip/mongo-jdbc-driver | 58a602e9103f7449f04fb1193f82addf932e18ec | [
"Apache-2.0"
] | 28 | 2020-03-18T08:53:48.000Z | 2022-03-30T11:54:02.000Z | src/test/resources/test-data/databases/fsyncLock.js | DataGrip/mongo-jdbc-driver | 58a602e9103f7449f04fb1193f82addf932e18ec | [
"Apache-2.0"
] | 14 | 2020-03-29T07:58:47.000Z | 2022-03-21T09:35:02.000Z | src/test/resources/test-data/databases/fsyncLock.js | DataGrip/mongo-jdbc-driver | 58a602e9103f7449f04fb1193f82addf932e18ec | [
"Apache-2.0"
] | 13 | 2020-03-24T09:40:04.000Z | 2022-03-18T10:45:09.000Z | // command
db.fsyncLock();
// command
db.fsyncUnlock();
| 11.2 | 17 | 0.678571 |
27687653e7369f10735fab2a191f6a3a28d2f954 | 6,227 | js | JavaScript | js/obs-control.js | FuyukiSakura/obs-control | 6da9d07f31726d99aad0c079036f01c42975c114 | [
"MIT"
] | 3 | 2021-04-18T10:33:51.000Z | 2022-01-07T11:03:28.000Z | js/obs-control.js | FuyukiSakura/obs-control | 6da9d07f31726d99aad0c079036f01c42975c114 | [
"MIT"
] | null | null | null | js/obs-control.js | FuyukiSakura/obs-control | 6da9d07f31726d99aad0c079036f01c42975c114 | [
"MIT"
] | 1 | 2022-01-07T11:16:57.000Z | 2022-01-07T11:16:57.000Z | const obs_address = '127.0.0.1:4444'; //基本的に変更不要
const obs_password = ''; //OBSにパスワード設定がある場合のみ設定
const obs_game_scene_name = 'BS-Game'; //ゲームシーン名
const obs_menu_scene_name = 'BS-Menu'; //メニューシーン名
const obs_game_event_delay = 0; //ゲームシーン開始タイミングを遅らせる場合に遅らせるミリ秒を設定して下さい。タイミングを早めること(マイナス値)はできません。[0の場合は無効]
const obs_menu_event_delay = 0; //ゲームシーン終了(メニューに戻る)タイミングを遅らせる場合に遅らせるミリ秒を設定して下さい。タイミングを早めること(マイナス値)はできません。[0の場合は無効]
const obs_menu_event_switch = false; //[true/false]ゲームシーン終了タイミングをfinish/failした瞬間に変更する場合は true にします。約1秒程度早まりますのでobs_menu_event_delayと合わせて終了タイミングの微調整に使えます。
const obs_start_scene_duration = 0; //ゲームシーンに切り替える前に開始シーンを表示する時間(秒単位[小数3位までOK]) [0の場合は無効]
const obs_start_scene_name = 'BS-Start'; //開始シーン名 ※使用時はobs_start_scene_durationの設定要
const obs_finish_scene_duration = 0; //Finish(クリア)時にメニューシーンに切替わる前に終了シーンを表示する時間(秒単位[小数3位までOK]) [0の場合は無効]
const obs_finish_scene_name = 'BS-Finish'; //Finish(クリア)用終了シーン名 ※使用時はobs_finish_scene_durationの設定要
const obs_fullcombo_scene_duration = 0; //フルコンボクリア時にメニューシーンに切替わる前に終了シーンを表示する時間(秒単位[小数3位までOK]) [0の場合は無効]
const obs_fullcombo_scene_name = 'BS-FullCombo'; //フルコンボクリア用終了シーン名 ※使用時はobs_fullcombo_scene_durationの設定要
const obs_fail_scene_duration = 0; //Fail(フェイル)時にメニューシーンに切替わる前に終了シーンを表示する時間(秒単位[小数3位までOK]) [0の場合は無効]
const obs_fail_scene_name = 'BS-Fail'; //Fail(フェイル)用終了シーン名 ※使用時はobs_fail_scene_durationの設定要
const obs_pause_scene_duration = 0; //Pause(ポーズ)してメニューに戻る場合にメニューシーンに切替わる前に終了シーンを表示する時間(秒単位[小数3位までOK]) [0の場合は無効]
const obs_pause_scene_name = 'BS-Pause'; //Pause(ポーズ)用終了シーン名 ※使用時はobs_pause_scene_durationの設定要
const obs_recording_check = false; //[true/false]trueにするとゲームシーン開始時に録画状態をチェックする。
const obs_not_rec_sound = 'file:///C://Windows//Media//Windows%20Notify%20Calendar.wav' //ゲームシーン開始時に録画されていない場合に鳴らす音(適当な音声ファイルをブラウザに貼り付けて、アドレス欄のURLをコピーする)
let obs_now_scene;
let obs_bs_menu_flag = true;
let obs_end_event = '';
let obs;
let obs_timeout_id;
let obs_full_combo = true;
const obs_not_rec_audio = new Audio(obs_not_rec_sound);
function obs_connect() {
obs = new OBSWebSocket();
obs.connect({
address: obs_address,
password: obs_password
})
.then(() => {
console.log(`Success! We're connected & authenticated.`);
obs.send('GetCurrentScene').then((data) => {
obs_now_scene = data.name;
});
return;
})
.catch(err => { // Promise convention dicates you have a catch on every chain.
console.log(err);
});
obs.on('ConnectionClosed', (data) => {
setTimeout(() => {
obs_connect();
}, 3000);
});
// You must add this handler to avoid uncaught exceptions.
obs.on('error', err => {
console.error('socket error:', err);
});
}
obs_connect();
function obs_rec_check() {
if (!obs_recording_check) return;
obs.send('GetRecordingStatus').then((data) => {
if (!data.isRecording || data.isRecordingPaused) obs_not_rec_audio.play();
});
}
function obs_scene_change(scene_name) {
if (scene_name != obs_now_scene) {
obs.send('SetCurrentScene', {
'scene-name': scene_name
});
}
obs_now_scene = scene_name;
}
function obs_menu_scene_change() {
obs_scene_change(obs_menu_scene_name);
}
function obs_game_scene_change() {
obs_scene_change(obs_game_scene_name);
}
function obs_start_scene_change() {
if (obs_start_scene_duration > 0) {
obs_scene_change(obs_start_scene_name);
obs_timeout_id = setTimeout(obs_game_scene_change, obs_start_scene_duration * 1000);
} else {
obs_scene_change(obs_game_scene_name);
}
}
ex_songStart.push((data) => {
obs_end_event = '';
obs_full_combo = true;
if (obs_bs_menu_flag) {
clearTimeout(obs_timeout_id);
obs_bs_menu_flag = false;
obs_rec_check();
if (obs_game_event_delay > 0) {
obs_timeout_id = setTimeout(obs_start_scene_change, obs_game_event_delay);
} else {
obs_start_scene_change();
}
}
});
function obs_end_scene_change() {
let obs_end_scene_duration = 0;
switch (obs_end_event) {
case 'fullcombo':
obs_end_scene_duration = obs_fullcombo_scene_duration;
if (obs_end_scene_duration > 0) obs_scene_change(obs_fullcombo_scene_name);
break;
case 'finish':
obs_end_scene_duration = obs_finish_scene_duration;
if (obs_end_scene_duration > 0) obs_scene_change(obs_finish_scene_name);
break;
case 'fail':
obs_end_scene_duration = obs_fail_scene_duration;
if (obs_end_scene_duration > 0) obs_scene_change(obs_fail_scene_name);
break;
case 'pause':
obs_end_scene_duration = obs_pause_scene_duration;
if (obs_end_scene_duration > 0) obs_scene_change(obs_pause_scene_name);
}
if (obs_end_scene_duration > 0) {
obs_timeout_id = setTimeout(obs_menu_scene_change, obs_end_scene_duration * 1000);
} else {
obs_scene_change(obs_menu_scene_name);
}
}
function obs_menu_event() {
if (!obs_bs_menu_flag) {
clearTimeout(obs_timeout_id);
obs_bs_menu_flag = true;
if (obs_menu_event_delay > 0) {
obs_timeout_id = setTimeout(obs_end_scene_change, obs_menu_event_delay);
} else {
obs_end_scene_change();
}
}
}
ex_menu.push((data) => {
obs_menu_event();
});
ex_finished.push((data) => {
if (obs_full_combo && data.status.performance.passedNotes === data.status.performance.combo) {
obs_end_event = 'fullcombo';
} else {
obs_end_event = 'finish';
}
if (obs_menu_event_switch) obs_menu_event();
});
ex_failed.push((data) => {
obs_end_event = 'fail';
if (obs_menu_event_switch) obs_menu_event();
});
ex_pause.push((data) => {
obs_end_event = 'pause';
});
ex_resume.push((data) => {
obs_end_event = '';
});
ex_hello.push((data) => {
obs_end_event = '';
if (data.status.beatmap && data.status.performance) {
obs_timeout_id = setTimeout(obs_game_scene_change, 3000);
} else {
obs_timeout_id = setTimeout(obs_menu_scene_change, 3000);
}
});
ex_bombCut.push((data) => {
obs_full_combo = false;
});
ex_obstacleEnter.push((data) => {
obs_full_combo = false;
});
| 33.12234 | 164 | 0.701301 |
276984b2fe80faab59a781e711fe48ced02930f7 | 1,638 | js | JavaScript | docs/html/search/all_8.js | brummer10/Xputty | 0a7c2de2cdb40aada09cd5c71985730e35e15577 | [
"0BSD"
] | 11 | 2019-07-16T14:52:27.000Z | 2022-02-13T19:18:57.000Z | docs/html/search/all_8.js | brummer10/Xputty | 0a7c2de2cdb40aada09cd5c71985730e35e15577 | [
"0BSD"
] | 2 | 2019-07-16T14:52:22.000Z | 2019-07-29T19:18:22.000Z | docs/html/search/all_8.js | brummer10/Xputty | 0a7c2de2cdb40aada09cd5c71985730e35e15577 | [
"0BSD"
] | 3 | 2019-07-21T15:09:38.000Z | 2020-07-11T19:27:17.000Z | var searchData=
[
['has_5ffocus_252',['HAS_FOCUS',['../xwidget_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba77ed320daf286953bd956a0d470d3fe0',1,'xwidget.h']]],
['has_5fmem_253',['HAS_MEM',['../xwidget_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba3df1932719cf5c1f5b549f4f6aa4fb9c',1,'xwidget.h']]],
['has_5fpointer_254',['HAS_POINTER',['../xwidget_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba24dd904cfcaac15acb4fd0c48126f869',1,'xwidget.h']]],
['has_5ftooltip_255',['HAS_TOOLTIP',['../xwidget_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba5a9679f728b04a95c8afba74778ae18f',1,'xwidget.h']]],
['have_5fkey_5fin_5fmatrix_256',['have_key_in_matrix',['../xmidi__keyboard_8h.html#af8d0e4f3b9cf90bf68bd20a0f0f48112',1,'have_key_in_matrix(unsigned long *key_matrix): xmidi_keyboard.c'],['../xmidi__keyboard_8c.html#af8d0e4f3b9cf90bf68bd20a0f0f48112',1,'have_key_in_matrix(unsigned long *key_matrix): xmidi_keyboard.c']]],
['height_257',['height',['../structWidget__t.html#a1def6d2237743e75a0b84ca0c34a6834',1,'Widget_t::height()'],['../structMessageBox.html#a484148aa2d0ef82d1047bc105e63482c',1,'MessageBox::height()']]],
['hide_5fon_5fdelete_258',['HIDE_ON_DELETE',['../xwidget_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba1daf7a5f7ceb41e263746ccc21cc7f5e',1,'xwidget.h']]],
['hide_5ftooltip_259',['hide_tooltip',['../xwidget_8h.html#a65a14ddb7decf9932a8dcead7170217a',1,'hide_tooltip(Widget_t *wid): xwidget.c'],['../xwidget_8c.html#a65a14ddb7decf9932a8dcead7170217a',1,'hide_tooltip(Widget_t *wid): xwidget.c']]],
['hold_5fgrab_260',['hold_grab',['../structXputty.html#a744a6ffdff59d8725c863e7ecddfc0e1',1,'Xputty']]]
];
| 126 | 334 | 0.790598 |
276a9c2554879ae8baca7067082edd661fef9610 | 524 | js | JavaScript | src/components/FriendList/FriendList.js | julia22-lav/goit-react-hw-01-components | a1b1c76042ca60d56bca5badf8eb2013c32e9105 | [
"MIT"
] | null | null | null | src/components/FriendList/FriendList.js | julia22-lav/goit-react-hw-01-components | a1b1c76042ca60d56bca5badf8eb2013c32e9105 | [
"MIT"
] | null | null | null | src/components/FriendList/FriendList.js | julia22-lav/goit-react-hw-01-components | a1b1c76042ca60d56bca5badf8eb2013c32e9105 | [
"MIT"
] | null | null | null | import React from 'react';
import s from './FriendList.module.css';
import FriendListItem from './FriendListItem/FriendListItem';
const FriendList = ({ friends }) => {
return (
<>
<h2>Task 3: FRIENDS</h2>
<ul className={s.friendList}>
{friends.map(({ id, avatar, name, isOnline }) => (
<FriendListItem
id={id}
avatar={avatar}
name={name}
isOnline={isOnline}
/>
))}
</ul>
</>
);
};
export default FriendList;
| 21.833333 | 61 | 0.528626 |
276aeb6ddbb5e818967ff19138f65faa174b00bd | 1,128 | js | JavaScript | src/__tests__/index.ignorePaths.test.js | wadjih-bencheikh18/smart-array-filter | 9e8b69a246556deb7cf769a0ddcd146bf993bbb0 | [
"MIT"
] | null | null | null | src/__tests__/index.ignorePaths.test.js | wadjih-bencheikh18/smart-array-filter | 9e8b69a246556deb7cf769a0ddcd146bf993bbb0 | [
"MIT"
] | null | null | null | src/__tests__/index.ignorePaths.test.js | wadjih-bencheikh18/smart-array-filter | 9e8b69a246556deb7cf769a0ddcd146bf993bbb0 | [
"MIT"
] | null | null | null | /* eslint jest/expect-expect: ["error", { "assertFunctionNames": ["assert","expect"] }] */
import { filter } from '..';
let data = [
{
h: [{ e: 1 }, { e: 2 }, { f: 3 }],
i: ['jkl'],
},
];
test('ignorePaths', () => {
assert({ keywords: ['e:2'] }, 1);
assert({ keywords: ['f:3'] }, 1);
assert({ keywords: ['h.e:2'] }, 1);
assert({ keywords: ['h.e:3'] }, 0);
assert({ keywords: ['h.e:2'], ignorePaths: ['e'] }, 0);
assert({ keywords: ['h.e:2'], ignorePaths: ['h.e'] }, 0);
assert({ keywords: ['h.e:2'], ignorePaths: ['i.e'] }, 1);
assert({ keywords: ['h.e:2'], ignorePaths: ['h.f'] }, 1);
assert({ keywords: ['h.e:2'], ignorePaths: ['i'] }, 1);
assert({ keywords: ['h.e:2'], ignorePaths: ['h'] }, 0);
assert({ keywords: ['i:jkl'], ignorePaths: ['h'] }, 1);
assert({ keywords: ['i:jkl'], ignorePaths: ['i'] }, 0);
assert({ keywords: ['h.f:3'], ignorePaths: [/e.*/] }, 1);
assert({ keywords: ['h.f:3'], ignorePaths: [/h.*f/] }, 0);
assert({ keywords: ['h.f:3'], ignorePaths: [/e.*g/] }, 1);
});
function assert(options, length) {
expect(filter(data, options)).toHaveLength(length);
}
| 33.176471 | 90 | 0.515957 |
276b5ed129456255e7b0ff3bfebe84e480666338 | 1,199 | js | JavaScript | practice/frontend/src/api/base/BaseApi.js | masgyw/individual-study | fa1b4efe9e968f68afad9240963a8cac8743ffae | [
"Apache-2.0"
] | null | null | null | practice/frontend/src/api/base/BaseApi.js | masgyw/individual-study | fa1b4efe9e968f68afad9240963a8cac8743ffae | [
"Apache-2.0"
] | 6 | 2020-06-12T02:56:18.000Z | 2020-12-22T15:48:15.000Z | practice/frontend/src/api/base/BaseApi.js | masgyw/individual-study | fa1b4efe9e968f68afad9240963a8cac8743ffae | [
"Apache-2.0"
] | 2 | 2020-11-24T09:43:30.000Z | 2022-01-17T05:31:57.000Z | import request from '@/utils/request'
import LoggerFactory from "./logger";
class BaseApi {
constructor(target) {
this.src = target;
}
find(params) {
logger.info("find for " + this.src)
return request({
url: this.src,
method: 'GET',
params: params
})
}
findByPage(params) {
logger.info("findByPage for " + this.src)
return request({
url: this.src + '/',
method: 'GET',
params: params
})
}
remove(params) {
logger.info("remove for " + this.src)
return request({
url: this.src + "/" + params,
method: 'DELETE',
params: params
})
}
offer(data) {
logger.info("offer for " + this.src)
return request({
url: this.src,
method: 'POST',
data: data
})
}
patch(data) {
logger.info("patch for " + this.src)
return request({
url: this.src,
method: 'PUT',
data: data
});
}
}
let logger = LoggerFactory.getLogger("BaseApi");
export default BaseApi; | 20.322034 | 49 | 0.47206 |
276c20caabc1f3119d3a7e5d96a7d5cc102782d2 | 85 | js | JavaScript | src/components/EchartsDefectCode/index.js | Gqq475/qms | 84e855a40a00876e5ca0c453fbb0d1505de32180 | [
"MIT"
] | null | null | null | src/components/EchartsDefectCode/index.js | Gqq475/qms | 84e855a40a00876e5ca0c453fbb0d1505de32180 | [
"MIT"
] | null | null | null | src/components/EchartsDefectCode/index.js | Gqq475/qms | 84e855a40a00876e5ca0c453fbb0d1505de32180 | [
"MIT"
] | null | null | null | import EchartsDefectCode from './EchartsDefectCode'
export default EchartsDefectCode
| 28.333333 | 51 | 0.870588 |
276ce2c2722e81b16dddf916449b96ad8ef9947c | 1,272 | js | JavaScript | node_modules/react-chatbot-kit/src/components/Chatbot/utils.js | tudorcodrin/SeamlessCapitalTask | 2f80e7c637a6edc646182d4629f6483bc9c39727 | [
"MIT"
] | null | null | null | node_modules/react-chatbot-kit/src/components/Chatbot/utils.js | tudorcodrin/SeamlessCapitalTask | 2f80e7c637a6edc646182d4629f6483bc9c39727 | [
"MIT"
] | null | null | null | node_modules/react-chatbot-kit/src/components/Chatbot/utils.js | tudorcodrin/SeamlessCapitalTask | 2f80e7c637a6edc646182d4629f6483bc9c39727 | [
"MIT"
] | 1 | 2021-08-06T00:39:06.000Z | 2021-08-06T00:39:06.000Z | export const getCustomStyles = (config) => {
if (config.customStyles) {
return config.customStyles;
}
return {};
};
export const getInitialState = (config) => {
if (config.state) {
return config.state;
}
return {};
};
export const getWidgets = (config) => {
if (config.widgets) {
return config.widgets;
}
return [];
};
export const getCustomComponents = (config) => {
if (config.customComponents) {
return config.customComponents;
}
return {
botMessageBox: {},
chatButton: {},
};
};
export const getBotName = (config) => {
if (config.botName) {
return config.botName;
}
return "Bot";
};
export const getObject = (object) => {
if (typeof object === "object") return object;
return {};
};
export const validateProps = (config, MessageParser) => {
const errors = [];
if (!config.initialMessages) {
errors.push(
"Config must contain property 'initialMessages', and it expects it to be an array of chatbotmessages."
);
}
const messageParser = new MessageParser();
if (!messageParser["parse"]) {
errors.push(
"Messageparser must implement the method 'parse', please add this method to your object. The signature is parse(message: string)."
);
}
return errors;
};
| 20.516129 | 136 | 0.641509 |
276cf62c852dcabf2905da18f4dbac49a95cffef | 415 | js | JavaScript | es6/prototype.js | idf/commons-util-js | 65f343f4f8da5e1429f4181f19c0942b476a5033 | [
"Apache-2.0"
] | 1 | 2015-02-10T14:16:31.000Z | 2015-02-10T14:16:31.000Z | es6/prototype.js | zhangdanyangg/commons-util-js | 65f343f4f8da5e1429f4181f19c0942b476a5033 | [
"Apache-2.0"
] | null | null | null | es6/prototype.js | zhangdanyangg/commons-util-js | 65f343f4f8da5e1429f4181f19c0942b476a5033 | [
"Apache-2.0"
] | null | null | null | /*
Wiki: Prototype-based programming is a style of object-oriented programming in which behaviour reuse (known as
inheritance) is performed via a process of reusing existing objects via delegation that serve as prototypes.
This model can also be known as prototypal, prototype-oriented, classless, or instance-based programming.
Delegation is the language feature that supports prototype-based programming.
*/
| 51.875 | 111 | 0.812048 |
276e47a9b62b06a0819767416e085c7fa1ba50d6 | 225 | js | JavaScript | src/components/ClosingAlert/index.js | onlyasmalllizard/phantom-elephants-frontend | d4fdfea710a359055005b0f4aa2feb56f71aaba1 | [
"MIT"
] | 2 | 2021-11-12T01:05:11.000Z | 2021-12-10T14:28:11.000Z | src/components/ClosingAlert/index.js | onlyasmalllizard/phantom-elephants-frontend | d4fdfea710a359055005b0f4aa2feb56f71aaba1 | [
"MIT"
] | 1 | 2021-11-11T12:17:56.000Z | 2021-11-11T12:17:56.000Z | src/components/ClosingAlert/index.js | onlyasmalllizard/phantom-elephants-frontend | d4fdfea710a359055005b0f4aa2feb56f71aaba1 | [
"MIT"
] | 2 | 2021-11-12T01:05:27.000Z | 2021-11-25T19:40:44.000Z | import React from "react";
import ClosingAlert from "@material-tailwind/react/ClosingAlert";
export default function ClosingAlertTIM({ color, innerText }) {
return <ClosingAlert color={color}>{innerText}</ClosingAlert>;
}
| 32.142857 | 65 | 0.773333 |
276ee35d0a69271b4e700bd042b3d87647f1e8cb | 54 | js | JavaScript | node_modules/styled-icons/typicons/ThListOutline/ThListOutline.esm.js | chs6558/chs6558.github.io | 32dd0275105d1db5b085d3162126b0e847ec9c16 | [
"MIT"
] | null | null | null | node_modules/styled-icons/typicons/ThListOutline/ThListOutline.esm.js | chs6558/chs6558.github.io | 32dd0275105d1db5b085d3162126b0e847ec9c16 | [
"MIT"
] | null | null | null | node_modules/styled-icons/typicons/ThListOutline/ThListOutline.esm.js | chs6558/chs6558.github.io | 32dd0275105d1db5b085d3162126b0e847ec9c16 | [
"MIT"
] | null | null | null | export * from '@styled-icons/typicons/ThListOutline';
| 27 | 53 | 0.777778 |
276f5e1a1ce2b749a3cc94bfeb97c19c2004dad5 | 1,151 | js | JavaScript | commands/set-banker.js | nvanbaak/diplocurrency | 9af6042286811d81b1551e77e87ce462e4edfa80 | [
"MIT"
] | null | null | null | commands/set-banker.js | nvanbaak/diplocurrency | 9af6042286811d81b1551e77e87ce462e4edfa80 | [
"MIT"
] | 10 | 2021-09-30T18:27:21.000Z | 2021-10-07T21:49:14.000Z | commands/set-banker.js | nvanbaak/diplocurrency | 9af6042286811d81b1551e77e87ce462e4edfa80 | [
"MIT"
] | null | null | null | const { SlashCommandBuilder } = require('@discordjs/builders');
const account = require('../models/account');
module.exports = {
data: new SlashCommandBuilder()
.setName('set-as-bank')
.setDescription('designate a country as the Bank')
.addRoleOption(option =>
option.setName('country')
.setDescription('the country to designate')
.setRequired(true)),
async execute( commandInfo ) {
const {
interaction,
auth,
db:{ Accounts }
} = commandInfo;
// reprimand non-admin users for their hubris
if (!auth.isAdmin) {
return interaction.reply( {content: "You're not authorized to use this command.", ephemeral: true} );
}
const targetAccountId = interaction.options._hoistedOptions[0].value;
const targetAccountName = interaction.options._hoistedOptions[0].name;
const accountUpdate = await Accounts.update( {isBank: true, balance: 10000 }, { where: {accountId: targetAccountId} } );
return interaction.reply(`Set ${targetAccountName} as banker!`);
}
} | 35.96875 | 128 | 0.616855 |
276ff848798b5bd61c2abb422368757bad98ddaa | 297 | js | JavaScript | src/js/components/meta/withFormifly.js | binary-butterfly/formifly | 81dba35848db76e63c2733c24f65259499b92cde | [
"MIT"
] | null | null | null | src/js/components/meta/withFormifly.js | binary-butterfly/formifly | 81dba35848db76e63c2733c24f65259499b92cde | [
"MIT"
] | 27 | 2022-02-16T12:26:36.000Z | 2022-03-30T16:17:31.000Z | src/js/components/meta/withFormifly.js | binary-butterfly/formifly | 81dba35848db76e63c2733c24f65259499b92cde | [
"MIT"
] | null | null | null | import React from 'react';
import {useFormiflyContext} from './FormiflyContext';
const withFormifly = (WrappedComponent) => {
return (props) => {
const context = useFormiflyContext();
return <WrappedComponent {...props} {...context}/>;
};
};
export default withFormifly;
| 24.75 | 59 | 0.659933 |
277035f1e34111c1bf0d38cefb95020da646977a | 8,749 | js | JavaScript | source/js/mediator/postcodeFormMediator.js | BBCVisualJournalism/newsspec_8945 | 2df2eb338156134c10ac61b1d618429ff94a35aa | [
"Apache-2.0"
] | 1 | 2015-04-09T14:01:54.000Z | 2015-04-09T14:01:54.000Z | source/js/mediator/postcodeFormMediator.js | BBCVisualJournalism/newsspec_8945 | 2df2eb338156134c10ac61b1d618429ff94a35aa | [
"Apache-2.0"
] | 1 | 2016-07-04T15:19:24.000Z | 2016-07-04T15:19:24.000Z | source/js/mediator/postcodeFormMediator.js | BBCVisualJournalism/newsspec_8945 | 2df2eb338156134c10ac61b1d618429ff94a35aa | [
"Apache-2.0"
] | null | null | null | define(['lib/news_special/bootstrap', 'model/eventStrs', 'model/northernIrelandTrusts', 'lib/vendors/jquery/jQuery.XDomainRequest'], function (news, eventStrs, niTrusts) {
'use strict';
var PostcodeFormMediator = function () {
/********************************************************
* VARIABLES
********************************************************/
this.elHolder = news.$('.postcodeFinderHolder');
this.formEl = news.$('#postcodeForm');
this.errorMessageHolder = news.$('.postcodeErrorHolder');
this.errorMessageP = this.errorMessageHolder.find('p');
this.postcodeInputEl = news.$('#postcodeInput');
this.entityCodeSafeList = ['E06', 'E08', 'E09', 'E10', 'E11', 'W06', 'S12'];
this.errorStrPostcodeInvalid = 'The postcode you entered did not pass validation';
this.errorStrPostcodeNotFound = 'We couldn\'t find the postcode you entered';
/********************************************************
* INIT STUFF
********************************************************/
this.init();
};
PostcodeFormMediator.prototype = {
init: function () {
/********************************************************
* LISTENERS
********************************************************/
this.formEl.on('submit', this.handleFormSubmit.bind(this));
news.pubsub.on(eventStrs.whoForSelected, this.displayForm.bind(this));
news.pubsub.on(eventStrs.showResults, this.handleDisplayResults.bind(this));
news.pubsub.on(eventStrs.backToQuestions, this.handleBackToQuestions.bind(this));
},
displayForm: function () {
var holder = this.elHolder;
holder.fadeIn(200, function () {
holder.removeClass('faddedElement');
});
},
handleDisplayResults: function () {
this.elHolder.hide();
},
handleBackToQuestions: function () {
this.elHolder.fadeIn(200);
},
handleFormSubmit: function (e) {
if (e.preventDefault) {
e.preventDefault();
}
this.errorMessageHolder.addClass('hidePostcodeError');
var postcodeEntered = this.postcodeInputEl[0].value.replace(/\s/g, '').toLowerCase(),
isPostcodeValid = this.isValidPostcode(postcodeEntered),
that = this,
postcodeURL,
postcodeAPIStartStr = 'http://open.live.bbc.co.uk/locator/locations/',
postcodeAPIEndStr = '/details/gss-council?op=intersect&vv=2&dv=1.1&format=json';
if (isPostcodeValid) {
var isNorthernIrelandPostcode = this.isNorthernIrelandPostcode(postcodeEntered);
if (isNorthernIrelandPostcode) {
//look up a postcode from northern ireland!!
postcodeURL = postcodeAPIStartStr + postcodeEntered + postcodeAPIEndStr;
$.getJSON(postcodeURL).done(function (data) {
that.handleNIPostcodeResponse(data);
}).fail(this.handlePostcodeLoadError.bind(this));
//var ajaxIt = news.$.getJSON(postcodeURL).done().fail(this.handlePostcodeLoadError.bind(this));
} else {
//look up the postcode!!
postcodeURL = postcodeAPIStartStr + postcodeEntered + postcodeAPIEndStr;
$.getJSON(postcodeURL).done(function (data) {
that.handlePostcodeResponse(data);
}).fail(this.handlePostcodeLoadError.bind(this));
}
}
else {
this.showPostcodeError(this.errorStrPostcodeInvalid);
}
return false;
},
handlePostcodeResponse: function (data) {
var dataStr = JSON.stringify(data, null, ' ');
var detailsArr = data.response.content.details.details,
externalId,
nation,
authorityName;
if (detailsArr) {
var a, arrLength = detailsArr.length, entityCodeSafeListLength = this.entityCodeSafeList.length;
outerLoop: for (a = 0; a < arrLength; a++) {
if (detailsArr[a].data.entityCode) {
var b, entityCode = detailsArr[a].data.entityCode;
innerLoop: for (b = 0; b < entityCodeSafeListLength; b++) {
if (entityCode === this.entityCodeSafeList[b]) {
//bingo! we've fund a valid region from the postcode!!
externalId = detailsArr[a].externalId;
authorityName = detailsArr[a].data.geographyName;
nation = detailsArr[a].data.entityCoverage;
break outerLoop;
}
}
}
}
}
if (externalId) {
//SUCCESS! :)
news.pubsub.emit(eventStrs.processExternalId, {
id: externalId,
nation: nation,
authorityName: authorityName
});
}
else {
this.showPostcodeError(this.errorStrPostcodeNotFound);
}
},
handleNIPostcodeResponse: function (data) {
var detailsArr = data.response.content.details.details;
var externalId, trustName;
if (detailsArr) {
var arrLength = detailsArr.length;
for (var a = 0; a < arrLength; a++) {
var detailType = detailsArr[a].detailType;
if (detailType && (detailType === 'gss-council')) {
/* Map the counil id to a trust id */
var trustInfo = this.getNITrustInfo(detailsArr[a].externalId);
/* Check we managed to map the counil id to a trust */
if (trustInfo === null) {
break;
}
externalId = trustInfo.id;
trustName = trustInfo.name;
// console.log(trustInfo);
break;
}
}
}
if (externalId) {
//SUCCESS! :)
news.pubsub.emit(eventStrs.processExternalId, {
id: externalId,
nation: 'NorthernIreland',
authorityName: trustName
});
}
else {
this.showPostcodeError(this.errorStrPostcodeNotFound);
}
},
handlePostcodeLoadError: function (e) {
this.showPostcodeError(this.errorStrPostcodeNotFound);
},
getNITrustInfo: function (counilId) {
var foundTrust = false, trust = null;
outerLoop: for (var a = 0; a < niTrusts.length; a++) {
trust = niTrusts[a];
for (var b = 0; b < trust.councilIds.length; b++) {
if (trust.councilIds[b] === counilId) {
foundTrust = true;
break outerLoop;
}
}
}
return (foundTrust) ? trust : null;
},
showPostcodeError: function (message) {
this.errorMessageHolder.removeClass('hidePostcodeError');
this.errorMessageP.html(message);
},
isValidPostcode: function (postcode) {
postcode = postcode.replace(/\s/g, '');
var regex = /^[A-Z]{1,2}[0-9]{1,2}([A-Z]{1,2})? ?[0-9][A-Z]{2}$/i;
var isFullPostode = regex.test(postcode);
if (!isFullPostode && postcode.length > 0 && postcode.length <= 4) {
var firstChar = postcode.substr(0, 1), lastChar = postcode.substr(postcode.length - 1, 1);
var firstCharAlpha = /(?![qvxQVX])[a-zA-Z]/.test(firstChar), lastCharNumeric = /[0-9]/.test(lastChar);
// var isFirstHalfPostcode = (firstCharAlpha && lastCharNumeric) ? true : false;
var isFirstHalfPostcode = (firstCharAlpha) ? true : false;
return isFirstHalfPostcode;
}
return isFullPostode;
},
isNorthernIrelandPostcode: function (postcode) {
return (postcode.substr(0, 2).toLowerCase() === 'bt');
}
};
return PostcodeFormMediator;
});
| 38.20524 | 171 | 0.490913 |
27705f81e0d47447472070fce74a0a0458af89f7 | 318 | js | JavaScript | backend/models/Done.js | melihozden/PlanApp | f287cc22e9660762c0f131ee6f7f5e8a01a0e78c | [
"Apache-2.0"
] | 1 | 2019-03-24T22:09:21.000Z | 2019-03-24T22:09:21.000Z | backend/models/Done.js | melihozden/PlanApp | f287cc22e9660762c0f131ee6f7f5e8a01a0e78c | [
"Apache-2.0"
] | 22 | 2018-11-10T22:32:48.000Z | 2022-01-22T04:43:00.000Z | backend/models/Done.js | melihozden/react-plan-app | f287cc22e9660762c0f131ee6f7f5e8a01a0e78c | [
"Apache-2.0"
] | null | null | null | const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const doneSchema = new Schema({
userId: {
type: Schema.ObjectId,
required :true
},
donePlan: {
type: String,
required: true
},
createdAt: {
type: Date,
default: Date.now
}
});
module.exports = mongoose.model('done', doneSchema); | 16.736842 | 52 | 0.672956 |
27707c73d411b006d912bf78c958a72b0394dbc5 | 913 | js | JavaScript | example/index.js | colorye/gmap-utils | a6c615debda7d8618bb8bc4b531450b0074235fc | [
"MIT"
] | null | null | null | example/index.js | colorye/gmap-utils | a6c615debda7d8618bb8bc4b531450b0074235fc | [
"MIT"
] | 1 | 2019-12-07T04:53:50.000Z | 2019-12-07T04:53:50.000Z | example/index.js | colorye/gmap-utils | a6c615debda7d8618bb8bc4b531450b0074235fc | [
"MIT"
] | null | null | null | import "babel-polyfill";
import "./index.scss";
import { Gmap, GmapDOM } from "../dist";
import React, { useState } from "react";
import ReactDOM from "react-dom";
function App() {
const [markers, setMarkers] = useState([
{ lat: 10.7880001, lng: 106.673132, info: "Ship here" }
]);
const random = () => {
const num = Math.floor(Math.random() * 10);
const newMarkers = [...Array(num).keys()].map(i => ({
lat: 10 + Math.random(),
lng: 106 + Math.random(),
info: "Ship here"
}));
setMarkers(newMarkers);
};
return (
<div>
<h2>Awesome Gmap</h2>
<button onClick={random}>Click me to random position</button>
<Gmap mapKey={process.env.MAP_KEY} markers={markers} />
</div>
);
}
ReactDOM.render(<App />, document.getElementById("root"));
// GmapDOM.render(
// { mapKey: process.env.MAP_KEY },
// document.getElementById("root")
// );
| 23.410256 | 67 | 0.596933 |
2770fc9e38fa53c1523ad5c79570e056ac34a341 | 200 | js | JavaScript | src/app/utils/router/index.js | jdeck88/geome-ui | 36e02acd4c9e1b10089d2459ee1bda55b11a6095 | [
"MIT"
] | null | null | null | src/app/utils/router/index.js | jdeck88/geome-ui | 36e02acd4c9e1b10089d2459ee1bda55b11a6095 | [
"MIT"
] | null | null | null | src/app/utils/router/index.js | jdeck88/geome-ui | 36e02acd4c9e1b10089d2459ee1bda55b11a6095 | [
"MIT"
] | 1 | 2018-02-19T23:42:46.000Z | 2018-02-19T23:42:46.000Z | import angular from 'angular';
import routerHelperProvider from './routerHelperProvider';
export default angular
.module('fims.router', [])
.provider('routerHelper', routerHelperProvider).name;
| 25 | 58 | 0.77 |
277130c7fdf0c84533e6b54dc1e9b4fab98bea51 | 529 | js | JavaScript | src/lib/Queue.js | claclacla/Organize-your-bookshelves-using-ReactJS | cca2e273333b3477a0e398beb90e12f97a032537 | [
"MIT"
] | null | null | null | src/lib/Queue.js | claclacla/Organize-your-bookshelves-using-ReactJS | cca2e273333b3477a0e398beb90e12f97a032537 | [
"MIT"
] | null | null | null | src/lib/Queue.js | claclacla/Organize-your-bookshelves-using-ReactJS | cca2e273333b3477a0e398beb90e12f97a032537 | [
"MIT"
] | null | null | null | class Queue {
constructor() {
this.isWorking = false;
this.processes = [];
}
push(process) {
if (this.isWorking) {
return this.processes.push(process);
}
var worker = (process) => {
this.isWorking = true;
process().then((res) => {
if (this.processes.length === 0) {
this.isWorking = false;
return;
}
var nextProcess = this.processes.shift();
worker(nextProcess);
});
};
worker(process);
}
}
export default Queue | 17.633333 | 49 | 0.531191 |
27718aa3f04f72ba5687e0727e9c1628f5e3a4f5 | 403 | js | JavaScript | src/string/padES6.js | commenthol/snippets | 2e47637f4a00d92be81fe7251d30ea82e509c7d4 | [
"Unlicense"
] | 3 | 2021-08-25T16:57:41.000Z | 2022-02-19T17:20:56.000Z | src/string/padES6.js | commenthol/snippets | 2e47637f4a00d92be81fe7251d30ea82e509c7d4 | [
"Unlicense"
] | null | null | null | src/string/padES6.js | commenthol/snippets | 2e47637f4a00d92be81fe7251d30ea82e509c7d4 | [
"Unlicense"
] | null | null | null | /**
* ES6 Same as `pad` with just using String.padStart().padEnd()
* - Only works with real strings
* - Does not truncate to `length` if smaller that `string.length`
* @example
* 'cat'.pad(8, '#') //> '##cat###'
* 'foobar'.pad(3) //> 'foobar'
*/
export const padES6 = function (string, length = 8, char = ' ') {
return string.padStart((string.length + length) / 2, char).padEnd(length, char)
}
| 33.583333 | 81 | 0.622829 |
2771bb1f34205cabab02dc474c648240a9ee10a1 | 829 | js | JavaScript | index.js | modeco80/dmesg-eventemitter | 6c75cd5a23fad301b3a3466acfb668b629e59167 | [
"MIT"
] | null | null | null | index.js | modeco80/dmesg-eventemitter | 6c75cd5a23fad301b3a3466acfb668b629e59167 | [
"MIT"
] | null | null | null | index.js | modeco80/dmesg-eventemitter | 6c75cd5a23fad301b3a3466acfb668b629e59167 | [
"MIT"
] | null | null | null | const child_process = require('child_process');
const {chunksToLinesAsync, chomp} = require('@rauschma/stringio');
const EventEmitter = require('events');
// -W waits for new messages and runs forever
// -Lnever disables ANSI color sequences
const DMESG_COMMAND_ARGUMENTS = "-WLnever"
async function EmitLines(stream, cb) {
for await (const line of chunksToLinesAsync(stream)) {
var chomped = chomp(line);
cb(chomped);
}
}
class DmesgEventEmitter extends EventEmitter {
constructor() {
super();
this._childHandle = null;
}
async run() {
this._childHandle = child_process.spawn('dmesg', [ DMESG_COMMAND_ARGUMENTS ], {
stdio: [ 'ignore', 'pipe', process.stderr]
});
await EmitLines(this._childHandle.stdout, async (line) => {
this.emit('line', line);
});
}
};
module.exports = DmesgEventEmitter;
| 24.382353 | 81 | 0.708082 |
2771bf816c94517709d36e38a4996f33968f1f28 | 1,455 | js | JavaScript | lib/src/plugins/StdOutPlugin.js | christianvoigt/argdown-cli | 273943da9fe23ac8c2cb9e63ddc8eb4f02c0591a | [
"MIT"
] | 4 | 2017-04-12T07:21:19.000Z | 2021-04-24T11:45:06.000Z | lib/src/plugins/StdOutPlugin.js | christianvoigt/argdown-cli | 273943da9fe23ac8c2cb9e63ddc8eb4f02c0591a | [
"MIT"
] | 6 | 2017-05-04T07:52:39.000Z | 2017-12-29T15:16:03.000Z | lib/src/plugins/StdOutPlugin.js | christianvoigt/argdown-cli | 273943da9fe23ac8c2cb9e63ddc8eb4f02c0591a | [
"MIT"
] | null | null | null | "use strict";
var _lodash = require("lodash");
var _ = _interopRequireWildcard(_lodash);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
class StdOutPlugin {
constructor(config) {
this.name = "StdOutPlugin";
this.defaults = _.defaultsDeep({}, config, {});
}
// there can be several instances of this plugin in the same ArgdownApplication
// Because of this, we can not add the instance default settings to the request object as in other plugins
// Instead we have to add it each time the getSettings method is called to avoid keeping request specific state
getSettings(request) {
let settings = {};
if (request.stdOut) {
settings = request.stdOut;
}
settings = _.defaultsDeep({}, settings, this.defaults);
return settings;
}
run(request, response) {
const settings = this.getSettings(request);
if (request.stdOut) {
this.config = request.stdOut;
}
let content = !settings.isRequestData ? response[settings.dataKey] : request[settings.dataKey];
process.stdout.write(content);
}
}
module.exports = {
StdOutPlugin: StdOutPlugin
};
//# sourceMappingURL=StdOutPlugin.js.map | 38.289474 | 269 | 0.654983 |
277293b337f46622ad40b22ca1934a0574a5af1b | 1,895 | js | JavaScript | node_modules/@wordpress/components/src/modal/aria-helper.js | ajchdev/outside-event | edaa958d74d5a1431f617bcbcef0d2e838103bd2 | [
"MIT"
] | null | null | null | node_modules/@wordpress/components/src/modal/aria-helper.js | ajchdev/outside-event | edaa958d74d5a1431f617bcbcef0d2e838103bd2 | [
"MIT"
] | null | null | null | node_modules/@wordpress/components/src/modal/aria-helper.js | ajchdev/outside-event | edaa958d74d5a1431f617bcbcef0d2e838103bd2 | [
"MIT"
] | null | null | null | /**
* External dependencies
*/
import { forEach } from 'lodash';
const LIVE_REGION_ARIA_ROLES = new Set( [
'alert',
'status',
'log',
'marquee',
'timer',
] );
let hiddenElements = [],
isHidden = false;
/**
* Hides all elements in the body element from screen-readers except
* the provided element and elements that should not be hidden from
* screen-readers.
*
* The reason we do this is because `aria-modal="true"` currently is bugged
* in Safari, and support is spotty in other browsers overall. In the future
* we should consider removing these helper functions in favor of
* `aria-modal="true"`.
*
* @param {Element} unhiddenElement The element that should not be hidden.
*/
export function hideApp( unhiddenElement ) {
if ( isHidden ) {
return;
}
const elements = document.body.children;
forEach( elements, ( element ) => {
if ( element === unhiddenElement ) {
return;
}
if ( elementShouldBeHidden( element ) ) {
element.setAttribute( 'aria-hidden', 'true' );
hiddenElements.push( element );
}
} );
isHidden = true;
}
/**
* Determines if the passed element should not be hidden from screen readers.
*
* @param {HTMLElement} element The element that should be checked.
*
* @return {boolean} Whether the element should not be hidden from screen-readers.
*/
export function elementShouldBeHidden( element ) {
const role = element.getAttribute( 'role' );
return ! (
element.tagName === 'SCRIPT' ||
element.hasAttribute( 'aria-hidden' ) ||
element.hasAttribute( 'aria-live' ) ||
LIVE_REGION_ARIA_ROLES.has( role )
);
}
/**
* Makes all elements in the body that have been hidden by `hideApp`
* visible again to screen-readers.
*/
export function showApp() {
if ( ! isHidden ) {
return;
}
forEach( hiddenElements, ( element ) => {
element.removeAttribute( 'aria-hidden' );
} );
hiddenElements = [];
isHidden = false;
}
| 24.61039 | 82 | 0.683905 |
2772cacf3af3c230ca07a53f9e05eb60d72a4600 | 400 | js | JavaScript | src/index.js | adshpl/vue-boilerplate | 6b03b385bd4de89d6c76a2361c1a94f1ccb6d3c7 | [
"MIT"
] | null | null | null | src/index.js | adshpl/vue-boilerplate | 6b03b385bd4de89d6c76a2361c1a94f1ccb6d3c7 | [
"MIT"
] | null | null | null | src/index.js | adshpl/vue-boilerplate | 6b03b385bd4de89d6c76a2361c1a94f1ccb6d3c7 | [
"MIT"
] | null | null | null | import Vue from 'vue';
import Vuex from 'vuex';
import VueRouter from 'vue-router';
import VueI18n from 'vue-i18n';
import router from '@/router';
import Application from '@/pages/application';
Vue.use(Vuex);
Vue.use(VueRouter);
Vue.use(VueI18n);
new Vue({
el: '.root',
store: require('@/store').default,
i18n: require('@/i18n').default,
router,
components: {
Application,
},
});
| 17.391304 | 46 | 0.67 |
27746373f97ed1797e47ac3b1612971d009bbdeb | 10,085 | js | JavaScript | aws-lambda/nodemailer-send-notification/index.js | goruck/smart-zonemider | e2f7bf49f22f3aa00a082bc227de64237d8e7699 | [
"MIT"
] | 169 | 2018-03-08T13:57:21.000Z | 2022-03-23T11:09:44.000Z | aws-lambda/nodemailer-send-notification/index.js | goruck/smart-zonemider | e2f7bf49f22f3aa00a082bc227de64237d8e7699 | [
"MIT"
] | 32 | 2018-04-15T08:50:10.000Z | 2022-03-11T23:56:47.000Z | aws-lambda/nodemailer-send-notification/index.js | goruck/smart-zonemider | e2f7bf49f22f3aa00a082bc227de64237d8e7699 | [
"MIT"
] | 37 | 2018-08-14T15:08:07.000Z | 2022-03-28T17:19:29.000Z | /**
* Lambda function to email or save to an S3 bucket alarm frames if person in image matches
* the env var FIND_FACES.
*
* The code contains logic and uses a cache so that only one alarm image is sent from an event.
* The /tmp dir is used as a transient cache to hold information about processed alarms.
*
* The Reserve Concurrency for this function must be set to 1.
*
* This is normally the last task in the state machine.
*
* This is part of the smart-zoneminder project. See https://github.com/goruck/smart-zoneminder.
*
* Copyright (c) 2018, 2019 Lindo St. Angel.
*/
'use strict';
exports.handler = (event, context, callback) => {
const fs = require('fs');
const ALARM_CACHE = '/tmp/alarm_cache';
console.log(`Current event: ${JSON.stringify(event, null, 2)}`);
// Extract array of faces from event (if they exist).
const faces = extractFaces(event.Labels);
fs.readFile(ALARM_CACHE, 'utf8', (err, data) => {
if (err) {
// Alarm cache does not exist because this lambda is starting cold.
// If alarm meets filter criteria email it to user and then cache it.
if (findFace(event.Labels)) {
const cacheObj = [
{
event: event.metadata.zmeventid,
frame: parseInt(event.metadata.zmframeid, 10),
faces: faces
}
];
fs.writeFile(ALARM_CACHE, JSON.stringify(cacheObj), (err) => {
if (err) {
console.log(`writeFile error: ${err}`);
callback(err);
} else {
console.log(`Wrote to cache: ${JSON.stringify(cacheObj, null, 2)}`);
mailOrSave(event, callback);
}
});
} else {
console.log(`Alarm ${event.metadata.zmeventid}:${event.metadata.zmframeid} does not meet filter criteria.`);
}
} else {
const cachedAlarms = JSON.parse(data); // array of cached alarms
console.log(`Read alarm(s) from cache: ${JSON.stringify(cachedAlarms, null, 2)}`);
// If alarm doesn't need to be processed, skip it.
// Else email the alarm to user if it meets filter criteria and add to cache.
const newAlarm = {
event: event.metadata.zmeventid,
frame: parseInt(event.metadata.zmframeid, 10),
faces: faces
};
if (!processAlarm(cachedAlarms, newAlarm)) {
console.log(`Alarm ${event.metadata.zmeventid}:${event.metadata.zmframeid} does not require processing.`);
} else if (findFace(event.Labels)) {
const cacheObj = updateCachedAlarms(cachedAlarms, newAlarm);
fs.writeFile(ALARM_CACHE, JSON.stringify(cacheObj), (err) => {
if (err) {
console.log(`writeFile error: ${err}`);
callback(err);
} else {
console.log(`Wrote to cache: ${JSON.stringify(cacheObj, null, 2)}`);
mailOrSave(event, callback);
}
});
} else {
console.log(`Alarm ${event.metadata.zmeventid}:${event.metadata.zmframeid} does not meet filter criteria.`);
}
}
});
};
/**
* Extract faces from event.
*
* @param {object} labels - Alarm image label metadata.
* @returns {Array} - An array with faces from event.
*/
function extractFaces(labels) {
const faces = [];
labels.forEach(obj => {
if ('Face' in obj && obj.Face !== null) faces.push(obj.Face);
});
return faces;
}
/**
* Determine if desired face is in alarm image label metadata.
*
* @param {object} labels - Alarm image label metadata.
* @returns {boolean} - If true desired face was found in labels.
*/
function findFace(labels) {
function hasFace(obj) {
// Get faces to look for.
const faces = process.env.FIND_FACES.split(',');
// If a face exists in the metadata then check if its one we desire.
return 'Face' in obj ? faces.includes(obj.Face) : false;
}
// Check if at least one desired face is in metadata.
return labels.some(hasFace);
}
/**
* Determine if a new alarm should be processed based on cached alarms.
*
* @param {object} cachedAlarms - Current cache contents.
* @param {object} newAlarm - Alarm to check.
* @returns {boolean} - if true new alarm should be processed.
*/
function processAlarm(cachedAlarms, newAlarm) {
// If alarms are > FRAME_OFFSET old then they are 'stale'.
// A stale alarm will trigger a refresh of itself in the cache.
const FRAME_OFFSET = 600; // 120 secs @ 5 FPS
// Scan cache for same event as in the new alarm.
const findAlarmEvent = cachedAlarms.find(element => {
return element.event === newAlarm.event;
});
// Scan cache for same faces as in the new alarm.
const findSameFaces = () => {
let same = false;
cachedAlarms.forEach(obj => {
same = same || obj.faces.every(face => newAlarm.faces.includes(face));
});
return same;
};
if (typeof findAlarmEvent === 'undefined') {
return true; // event not in cache, alarm should be processed
} else if (!findSameFaces()) {
return true; // faces not in cache, alarm should be processed
} else {
// event and faces in cache; test if stale and if so, process it
return newAlarm.frame > findAlarmEvent.frame + FRAME_OFFSET;
}
}
/**
* Updates the cache.
* If an alarm isn't in the cache it will be added.
* If the alarm is already in the cache then it will be refreshed.
*
* @param {object} cachedAlarms - Current cache contents.
* @param {object} newAlarm - Alarm to add / refresh.
* @returns {object} - Updated alarms to be cached.
*/
function updateCachedAlarms(cachedAlarms, newAlarm) {
const findAlarmEvent = cachedAlarms.find(element => {
return element.event === newAlarm.event;
});
// If alarm is not in cache then add it. Else refresh it.
if (typeof findAlarmEvent === 'undefined') {
cachedAlarms.push(newAlarm);
return cachedAlarms; // return updated array
} else {
return cachedAlarms.map(obj => { // return a new array
if (obj.event === newAlarm.event) {
return newAlarm;
} else {
return obj;
}
});
}
}
/**
* Email or copy alarm image.
*
* @param {object} alarm - Alarm to email and/or copy.
*/
async function mailOrSave(alarm, callback) {
const aws = require('aws-sdk');
const nodemailer = require('nodemailer');
const sesTransport = require('nodemailer-ses-transport');
const ses = new aws.SES({apiVersion: '2010-12-01', region: process.env.AWS_REGION});
const s3 = new aws.S3({apiVersion: '2006-03-01', region: process.env.AWS_REGION});
// Set up ses as transport for email.
const transport = nodemailer.createTransport(sesTransport({
ses: ses
}));
// Pickup parameters from calling event.
const bucket = alarm.bucket;
const filename = alarm.newFilename;
const labels = alarm.Labels;
const storageClass = alarm.storageClass;
// Set up HTML Email
let htmlString = '<pre><u><b>Label '+
'(Conf) '+
'Face '+
'(Conf)</u></b><br>';
labels.forEach(item => {
htmlString += item.Name + ' ';
htmlString += '(' + item.Confidence.toFixed(0) + ') ';
if ('Face' in item && item.Face !== null) { // check for valid face
htmlString += item.Face + ' ';
htmlString += '(' + item.FaceConfidence.toFixed(0) + ')';
}
htmlString += '</b><br>';
});
htmlString += '</pre>';
// Set up Text Email
let textString = 'Label (Conf) Face (Conf)\n';
labels.forEach(item => {
textString += item.Name + ' ';
textString += '(' + item.Confidence.toFixed(0) + ') ';
if ('Face' in item && item.Face !== null) {
textString += item.Face + ' ';
textString += '(' + item.FaceConfidence.toFixed(0) + ')';
}
textString += '\n';
});
// Set up email parameters.
const mail = (process.env.MAIL === 'yes') ? true : false;
const mailOptions = {
from: process.env.EMAIL_FROM,
to: process.env.EMAIL_RECIPIENT,
subject: '⏰ Alarm Event detected! ⏰',
text: textString,
html: htmlString,
attachments: [
{
filename: filename.replace('upload/', ''),
// Get a pre-signed S3 URL that will expire after one minute.
path: s3.getSignedUrl('getObject', {Bucket: bucket, Key: filename, Expires: 60})
}
]
};
// Set up copy parameters.
const copy = (process.env.COPY === 'yes') ? true : false;
const filePaths = filename.split('/');
const copyParams = {
Bucket: process.env.COPY_BUCKET,
Key: filePaths[filePaths.length - 1],
CopySource: bucket + '/' + filename,
StorageClass: storageClass
};
try {
if (mail) {
console.log(`Emailing alarm ${alarm.metadata.zmeventid}:${alarm.metadata.zmframeid}.`);
const sendMailResponse = await transport.sendMail(mailOptions);
console.log(`Email sent: ${JSON.stringify(sendMailResponse, null, 2)}`);
}
if (copy) {
console.log(`Saving alarm ${alarm.metadata.zmeventid}:${alarm.metadata.zmframeid}.`);
const copyObjectResponse = await s3.copyObject(copyParams).promise();
console.log(`Save complete: ${JSON.stringify(copyObjectResponse, null, 2)}`);
}
} catch (err) {
console.log(`Error: ${err}`);
callback(err);
}
return;
} | 36.672727 | 124 | 0.573922 |
27748e0cd0ac19d0dc41fb5564cf6a7f4e77c7d9 | 1,478 | js | JavaScript | bi/badgeHd.js | lmeysel/fa-compatible-icons | 0b4558bf35e3a3b7aad2772fdb4ae216c1f4eecd | [
"MIT"
] | null | null | null | bi/badgeHd.js | lmeysel/fa-compatible-icons | 0b4558bf35e3a3b7aad2772fdb4ae216c1f4eecd | [
"MIT"
] | null | null | null | bi/badgeHd.js | lmeysel/fa-compatible-icons | 0b4558bf35e3a3b7aad2772fdb4ae216c1f4eecd | [
"MIT"
] | null | null | null | 'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var prefix = 'bi';
var iconName = 'badge-hd';
var width = 512;
var height = 512;
var ligatures = [];
var unicode = null;
var svgPathData = 'M 64 64 A 64 64 0 0 0 0 128 L 0 384 A 64 64 0 0 0 64 448 L 448 448 A 64 64 0 0 0 512 384 L 512 128 A 64 64 0 0 0 448 64 L 64 64 z M 64 96 L 448 96 A 32 32 0 0 1 480 128 L 480 384 A 32 32 0 0 1 448 416 L 64 416 A 32 32 0 0 1 32 384 L 32 128 A 32 32 0 0 1 64 96 z M 80 160 L 80 352 L 117.98438 352 L 117.98438 269.75977 L 198.6875 269.75977 L 198.6875 352 L 236.67188 352 L 236.67188 160.03125 L 198.6875 160.03125 L 198.6875 238.11133 L 117.98438 238.11133 L 117.98438 160 L 80 160 z M 272 160.03125 L 272 352 L 342.01562 352 C 399.96762 352 427.93555 316.57553 427.93555 255.51953 C 427.93555 194.91153 400.41683 160.03125 342.04883 160.03125 L 272 160.03125 z M 309.98438 190.97656 L 336.96094 190.97656 C 372.54494 190.97656 388.86328 212.92786 388.86328 256.25586 C 388.86328 299.55186 372.70494 320.89648 336.96094 320.89648 L 309.98438 320.89648 L 309.98438 190.97656 z ';
exports.definition = {
prefix: prefix,
iconName: iconName,
icon: [
width,
height,
ligatures,
unicode,
svgPathData
]};
exports.biBadgeHd = exports.definition;
exports.prefix = prefix;
exports.iconName = iconName;
exports.width = width;
exports.height = height;
exports.ligatures = ligatures;
exports.unicode = unicode;
exports.svgPathData = svgPathData; | 50.965517 | 896 | 0.713802 |
2774a17307d59b5bf66d1253ac4dbf09eae09dbe | 1,002 | js | JavaScript | form.js | KojiroAsano/ToDo-List | 0d71e6aeaad5799881a62df70180bc6b3a840987 | [
"Unlicense"
] | null | null | null | form.js | KojiroAsano/ToDo-List | 0d71e6aeaad5799881a62df70180bc6b3a840987 | [
"Unlicense"
] | null | null | null | form.js | KojiroAsano/ToDo-List | 0d71e6aeaad5799881a62df70180bc6b3a840987 | [
"Unlicense"
] | 1 | 2021-12-07T23:58:57.000Z | 2021-12-07T23:58:57.000Z | function TodoForm({addTodo}){
const [text, setText] = React.useState('');
const [due, setDue] = React.useState('');
const handleSubmit = e => {
e.preventDefault();
console.log(e);
if(!text) return;
if(!due) return;
addTodo(text, due);
}
return(
<form onSubmit={handleSubmit}>
<label htmlFor="text">I need to do</label>
<input
id="text"
type="text"
className="input"
onChange={e => setText(e.target.value)}
placeholder="Add Todo ..."
/>
<label htmlFor="due">By</label>
<input
id="due"
type="time"
className="input"
onChange={e => setDue(e.target.value)}
/>
<button type="submit">
Add to Todo list
</button>
</form>
);
}
| 25.05 | 56 | 0.418164 |
277509e4427709bea04802ef09ba5fc1f6a88e61 | 1,920 | js | JavaScript | 3-Third Semester/System/SAO-PAULO/js/valida_cnpj.js | 0-Thiagoianzer-0/Faculdade | cbc47ec85b9af6adc459e0aeeb7497808c132d51 | [
"MIT"
] | null | null | null | 3-Third Semester/System/SAO-PAULO/js/valida_cnpj.js | 0-Thiagoianzer-0/Faculdade | cbc47ec85b9af6adc459e0aeeb7497808c132d51 | [
"MIT"
] | null | null | null | 3-Third Semester/System/SAO-PAULO/js/valida_cnpj.js | 0-Thiagoianzer-0/Faculdade | cbc47ec85b9af6adc459e0aeeb7497808c132d51 | [
"MIT"
] | null | null | null | function valida_cnpj(cnpj) {
cnpj = cnpj.replace(/[^\d]+/g,'');
if(cnpj == '')
return false;
if(cnpj.length != 14)
return false;
//CNPJ inválidos
if(cnpj == "00000000000000" ||
cnpj == "11111111111111" ||
cnpj == "22222222222222" ||
cnpj == "33333333333333" ||
cnpj == "44444444444444" ||
cnpj == "55555555555555" ||
cnpj == "66666666666666" ||
cnpj == "77777777777777" ||
cnpj == "88888888888888" ||
cnpj == "99999999999999")
return false;
//Válida os dados
tamanho = cnpj.length - 2
numeros = cnpj.substring(0,tamanho);
digitos = cnpj.substring(tamanho);
soma = 0;
pos = tamanho - 7;
for(i = tamanho; i >= 1; i--) {
soma += numeros.charAt(tamanho - i) * pos--;
if(pos < 2)
pos = 9;
}
resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
if(resultado != digitos.charAt(0))
return false;
tamanho = tamanho + 1;
numeros = cnpj.substring(0,tamanho);
soma = 0;
pos = tamanho - 7;
for(i = tamanho; i >= 1; i--) {
soma += numeros.charAt(tamanho - i) * pos--;
if (pos < 2)
pos = 9;
}
resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
if(resultado != digitos.charAt(1))
return false;
return true;
}
function fMasc(objeto,mascara) {
obj=objeto
masc=mascara
setTimeout("fMascEx()",1)
}
function fMascEx() {
obj.value=masc(obj.value)
}
function mCNPJ(cnpj){
cnpj = cnpj.replace(/^(\d{2})(\d)/, "$1.$2")
cnpj = cnpj.replace(/^(\d{2})\.(\d{3})(\d)/, "$1.$2.$3")
cnpj = cnpj.replace(/\.(\d{3})(\d)/, ".$1/$2")
cnpj = cnpj.replace(/(\d{4})(\d)/, "$1-$2")
return cnpj
}
cnpjCheck = function (el) {
document.getElementById('cnpjResponse').innerHTML = valida_cnpj(el.value)?
'<span style="color:green">Válido</span>' : '<span style="color:red">Inválido</span>';
if(el.value=='') document.getElementById('cnpjResponse').innerHTML = '';
} | 27.428571 | 105 | 0.569792 |
277550944460f9409e1729594a447efe50f890db | 275 | js | JavaScript | src/main/resources/static/components/header/header.directive.js | missmellyg85/travel-springboot-heroku | 2c404013b04ebd333f8c7aa5fdabfb3154dd07b9 | [
"MIT"
] | null | null | null | src/main/resources/static/components/header/header.directive.js | missmellyg85/travel-springboot-heroku | 2c404013b04ebd333f8c7aa5fdabfb3154dd07b9 | [
"MIT"
] | null | null | null | src/main/resources/static/components/header/header.directive.js | missmellyg85/travel-springboot-heroku | 2c404013b04ebd333f8c7aa5fdabfb3154dd07b9 | [
"MIT"
] | null | null | null | (function() {
'use strict';
angular
.module('myApp')
.directive('mainHeader', Header);
function Header () {
var header = {
templateUrl: 'components/header/header.directive.html'
};
return header;
}
})(); | 17.1875 | 66 | 0.512727 |
2775a070a824c72021f42fa0ae33450decd6da9c | 1,772 | js | JavaScript | src/js/services/data.service.js | chiefman1/flickrApp | 418696d4ca26b7a7d8d5569a1f52e1c74212dcba | [
"RSA-MD"
] | null | null | null | src/js/services/data.service.js | chiefman1/flickrApp | 418696d4ca26b7a7d8d5569a1f52e1c74212dcba | [
"RSA-MD"
] | null | null | null | src/js/services/data.service.js | chiefman1/flickrApp | 418696d4ca26b7a7d8d5569a1f52e1c74212dcba | [
"RSA-MD"
] | null | null | null | (function(){
'use strict';
angular
.module('flickrDataModule', ['ngResource'])
.factory('dataService', dataService);
dataService.$inject = ['$http', '$q'];
function dataService($http, $q){
var service = this;
service.perPage = 150;
service.api_key = "1c8c3a7a81e8908b7066c6f7dd058016";
service.base_url= "https://api.flickr.com/services/rest/";
service.search = function(search, page){
var deferred = $q.defer();
var promise = deferred.promise;
var params = {
api_key: service.api_key,
per_page: service.perPage,
format: 'json',
nojsoncallback: 1,
page: (page != null && page > 0) ? page : 1,
method: (search != null && search.length > 0) ? 'flickr.photos.search' : 'flickr.photos.getRecent'
};
if ((search != null && search.length > 0)) {
params.text = search;
}
$http({
method: 'GET',
url: service.base_url,
params: params
}).then(function successCallback(data, status, headers, config) {
deferred.resolve(data);
//console.log(data);
}, function errorCallback(data, status, headers, config) {
deferred.reject(status);
});
return deferred.promise;
};
service.getInfo = function(photoId) {
var deferred = $q.defer();
var promise = deferred.promise;
var params = {
api_key: service.api_key,
photo_id: photoId,
format: 'json',
method: 'flickr.photos.getInfo'
};
$http({
method: 'GET',
url: service.base_url,
params: params
}).then(function successCallback(data, status, headers, config) {
deferred.resolve(data);
console.log(data);
}, function errorCallback(data, status, headers, config) {
deferred.reject(status);
});
return deferred.promise;
};
return service;
}
})(); | 21.876543 | 102 | 0.63149 |
2775fc9482b6cc709be8de598699a40230825ca1 | 1,001 | js | JavaScript | app/containers/JobSelect/JobSelect.js | mattmanske/serve1 | 300b5ed0243ab9d049cdcd6e444db5ea9c52afb3 | [
"MIT"
] | null | null | null | app/containers/JobSelect/JobSelect.js | mattmanske/serve1 | 300b5ed0243ab9d049cdcd6e444db5ea9c52afb3 | [
"MIT"
] | null | null | null | app/containers/JobSelect/JobSelect.js | mattmanske/serve1 | 300b5ed0243ab9d049cdcd6e444db5ea9c52afb3 | [
"MIT"
] | null | null | null | //----------- Imports -----------//
import flatMap from 'lodash/flatMap'
import React, { PropTypes } from 'react'
import { Select } from 'antd'
import RecordOption from 'components/RecordOption'
import RecordSelector from 'components/RecordSelector'
//----------- Definitions -----------//
const Option = Select.Option
//----------- Component -----------//
const JobSelect = ({ jobs, value, ...props }) => {
if (value) props.defaultValue = value
return (
<RecordSelector placeholder='Search Jobs...' { ...props }>
{clients && flatMap(jobd, (job, id) => (
<Option key={id} value={id}>
<RecordOption name={id} />
</Option>
))}
</RecordSelector>
)
}
//----------- Prop Types -----------//
JobSelect.propTypes = {
jobs : PropTypes.object.isRequired,
value : PropTypes.string,
isLoading : PropTypes.bool.isRequired,
}
//----------- Export -----------//
export default JobSelect
| 22.75 | 62 | 0.538462 |
27767f5217a728da71b21428ad135a9e3e6005ba | 3,156 | js | JavaScript | src/app/useGameData.js | JanaHaeusler/capstone-project | bbe684cb874e7bbbf1071276c0dde6647f32815a | [
"MIT"
] | null | null | null | src/app/useGameData.js | JanaHaeusler/capstone-project | bbe684cb874e7bbbf1071276c0dde6647f32815a | [
"MIT"
] | 25 | 2020-11-14T11:11:59.000Z | 2020-12-11T10:32:06.000Z | src/app/useGameData.js | JanaHaeusler/Par1 | bbe684cb874e7bbbf1071276c0dde6647f32815a | [
"MIT"
] | 1 | 2020-11-19T16:07:53.000Z | 2020-11-19T16:07:53.000Z | import { useEffect, useState } from 'react'
import { v4 as uuid } from 'uuid'
import { saveLocally, loadLocally } from '../lib/localStorage'
const STORAGE_KEY = 'gameProfiles'
export default function useGameData() {
const [savedGameProfiles, setSavedGameProfiles] = useState(
loadLocally(STORAGE_KEY) ?? {
byId: {},
allIds: [],
}
)
const [newGameProfile, setNewGameProfile] = useState({})
const [targetProfile, setTargetProfile] = useState({})
useEffect(() => saveLocally(STORAGE_KEY, savedGameProfiles), [
savedGameProfiles,
])
return {
newGameProfile,
targetProfile,
savedGameProfiles,
createGameProfile,
addGameProfile,
deleteGameProfile,
editGameProfile,
prepareEditPage,
prepareDetailsPage,
updateTargetProfile,
}
function createGameProfile(keyInfos) {
const newId = uuid()
const playersArray = keyInfos.players
.split(',')
.map((player) => player.trim())
.filter((player) => player)
const playersString = playersArray.join(', ')
const playerScores = playersArray.reduce(
(acc, cur) => ({
...acc,
[cur]: {
hole1: '',
hole2: '',
hole3: '',
hole4: '',
hole5: '',
hole6: '',
hole7: '',
hole8: '',
hole9: '',
hole10: '',
hole11: '',
hole12: '',
hole13: '',
hole14: '',
hole15: '',
hole16: '',
hole17: '',
hole18: '',
},
}),
{}
)
setNewGameProfile({
location: keyInfos.location,
date: keyInfos.date,
winner: keyInfos.winner,
shots: keyInfos.shots,
playersString,
playersArray,
scores: playerScores,
_id: newId,
})
}
function addGameProfile(newGameProfile) {
setSavedGameProfiles({
byId: {
...savedGameProfiles.byId,
[newGameProfile._id]: { ...newGameProfile },
},
allIds: [newGameProfile._id, ...savedGameProfiles.allIds],
})
}
function deleteGameProfile(targetId) {
const copyOfById = { ...savedGameProfiles.byId }
delete copyOfById[targetId]
setSavedGameProfiles({
byId: copyOfById,
allIds: savedGameProfiles.allIds.filter((id) => id !== targetId),
})
}
function prepareEditPage(targetId) {
setTargetProfile(savedGameProfiles.byId[targetId])
}
function updateTargetProfile(editedGameInfos, targetProfile) {
setTargetProfile({
...targetProfile,
location: editedGameInfos.location,
date: editedGameInfos.date,
playersString: editedGameInfos.players,
winner: editedGameInfos.winner,
shots: editedGameInfos.shots,
})
}
function editGameProfile(targetProfile) {
const targetId = targetProfile._id
setSavedGameProfiles({
byId: {
...savedGameProfiles.byId,
[targetId]: { ...targetProfile },
},
allIds: [...savedGameProfiles.allIds],
})
setTargetProfile({})
}
function prepareDetailsPage(targetId) {
setTargetProfile(savedGameProfiles.byId[targetId])
}
}
| 24.465116 | 71 | 0.600127 |
2778b4dce5d2ca1fb8354b0ad9970bac41b99a33 | 359 | js | JavaScript | js/solid/cis-compare.js | reesretuta/dropshipping-icons | c4b4f40959b1e44abaacd86981b9a896b121f419 | [
"CC-BY-4.0",
"MIT"
] | null | null | null | js/solid/cis-compare.js | reesretuta/dropshipping-icons | c4b4f40959b1e44abaacd86981b9a896b121f419 | [
"CC-BY-4.0",
"MIT"
] | null | null | null | js/solid/cis-compare.js | reesretuta/dropshipping-icons | c4b4f40959b1e44abaacd86981b9a896b121f419 | [
"CC-BY-4.0",
"MIT"
] | null | null | null | export const cisCompare = ["512 512"," <defs> <style> .cls-1{fill:currentColor} </style> </defs> <path d='M456,38H290V74H438V319.9877L290,217.0311V474H456a18,18,0,0,0,18-18V56A18,18,0,0,0,456,38Z' class='cls-1'/> <path d='M254,496h4V16H222V38H56A18,18,0,0,0,38,56V456a18,18,0,0,0,18,18H222v22ZM74,438V342.23L222,226.4042V438Z' class='cls-1'/>"] | 359 | 359 | 0.70195 |