Skip to content

Instantly share code, notes, and snippets.

@FelipeBudinich
FelipeBudinich / localstorage.js
Last active August 29, 2015 14:00
Persistence Plugin for ImpactJs
/*global ig*/
ig.module(
'plugins.persistence.localstorage'
).requires(
'impact.game'
).defines(function () {
'use strict';
ig.PersistenceLocalStorage = ig.Class.extend({
/**
* Initialize Persistence as localStorage
@FelipeBudinich
FelipeBudinich / array.js
Last active August 29, 2015 14:00
Array utilities plugin for ImpactJs
/*
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Copyright (C) 2014 Felipe Budinich <[email protected]>
Everyone is permitted to copy and distribute verbatim or modified
copies of this document and license.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
// bind keyboard and gamepad buttons
ig.input.bind( ig.KEY.X, 'shoot1');
ig.input.bind( ig.GAMEPAD1.FACE_1, 'shoot1');
ig.input.bind( ig.GAMEPAD2.FACE_1, 'shoot2');
ig.input.bind( ig.GAMEPAD3.FACE_1, 'shoot3');
ig.input.bind( ig.GAMEPAD4.FACE_1, 'shoot4');
@FelipeBudinich
FelipeBudinich / domain-validation.html
Last active August 29, 2015 14:02
Javascript, Client side domain validation.
<!DOCTYPE html>
<html>
<head>
<title>Javascript, Client side domain validation.</title>
<script type="text/javascript">
function checkAllowedDomains() {
// add allowed domains on the "allowed" array
var allowed = ['127.0.0.1'],
isAllowed = false;
@FelipeBudinich
FelipeBudinich / email.js
Created June 5, 2014 06:29
Javascript, validate email address
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}
@FelipeBudinich
FelipeBudinich / disable-context-menu.html
Last active February 18, 2022 10:24
Javascript, Disable context menu on right click
<!DOCTYPE html>
<html>
<head>
<title>Javascript, Disable context menu on right click</title>
<script type="text/javascript">
if (document.addEventListener) {
document.addEventListener('contextmenu', function (e) {
e.preventDefault();
}, false);
@FelipeBudinich
FelipeBudinich / domain.js
Created June 5, 2014 17:17
ImpactJs, Domain Validation Plugin
/*global ig*/
ig.module(
'plugins.domain'
).requires().defines(function () {
'use strict';
var DomainUtils = {
isCurrentDomainAllowed: function () {
var allowed = ['127.0.0.1', 'www.example.com', 'example.com'],
isAllowed = false,
i;