├── README.md ├── chance.min.js ├── floodit.pde ├── howler.min.js ├── index.html ├── json2.js ├── jstorage.js ├── music ├── DarkMystery.mp3 ├── DarkMystery.ogg ├── door.mp3 ├── door.ogg ├── sfx.mp3 └── sfx.ogg └── processing.js /README.md: -------------------------------------------------------------------------------- 1 | What's hot? The Github Game Jam 2015! The theme is 'The Game Has Changed'. 2 | 3 | About Floodgate Dungeon 4 | =============================== 5 | The original game(called FloodIt) was just a simple puzzle game. 6 | 7 | What's new? I turned the puzzle game into a infinite runner game set in a dungeon! To pass the massive floodgates you will need to solve the puzzle on the door with a certain step limit. I added a score system, a currency system to hack the gates and get more steps, and a jStorage part to save high scores. 8 | 9 | Live Demo: http://akirassasin.github.io/ggo15-FloodIt/ 10 | -------------------------------------------------------------------------------- /chance.min.js: -------------------------------------------------------------------------------- 1 | !function(){function a(b){if(!(this instanceof a))return new a(b);if("function"==typeof b)return this.random=b,this;var c;arguments.length&&(this.seed=0);for(var d=0;dd;d++)key=c[d],b[key]=a[key]||b[key]}function f(a,b){for(var c=0,d=a.length;d>c;c++)b[c]=a[c]}function g(a,b){var c=Array.isArray(a),d=b||(c?new Array(a.length):{});return c?f(a,d):e(a,d),d}var h=9007199254740992,i=-h,j="0123456789",k="abcdefghijklmnopqrstuvwxyz",l=k.toUpperCase(),m=j+"abcdef",n=Array.prototype.slice;a.prototype.VERSION="0.7.1";var o=function(){throw new Error("No Base64 encoder available.")};!function(){"function"==typeof btoa?o=btoa:"function"==typeof Buffer&&(o=function(a){return new Buffer(a).toString("base64")})}(),a.prototype.bool=function(a){return a=b(a,{likelihood:50}),c(a.likelihood<0||a.likelihood>100,"Chance: Likelihood accepts values from 0 to 100."),100*this.random()f,"Chance: Max specified is out of range with fixed. Max should be, at most, "+f),a=b(a,{min:g,max:f}),d=this.integer({min:a.min*e,max:a.max*e});var i=(d/e).toFixed(a.fixed);return parseFloat(i)},a.prototype.integer=function(a){return a=b(a,{min:i,max:h}),c(a.min>a.max,"Chance: Min cannot be greater than Max."),Math.floor(this.random()*(a.max-a.min+1)+a.min)},a.prototype.natural=function(a){return a=b(a,{min:0,max:h}),this.integer(a)},a.prototype.string=function(a){a=b(a);var c=a.length||this.natural({min:5,max:20}),d=a.pool,e=this.n(this.character,c,{pool:d});return e.join("")},a.prototype.capitalize=function(a){return a.charAt(0).toUpperCase()+a.substr(1)},a.prototype.mixin=function(b){for(var c in b)a.prototype[c]=b[c];return this},a.prototype.unique=function(a,c,d){d=b(d,{comparator:function(a,b){return-1!==a.indexOf(b)}});for(var e,f=[],g=0,h=50*c,i=n.call(arguments,2);f.lengthh)throw new RangeError("Chance: num is likely too large for sample set");return f},a.prototype.n=function(a,b){var c=b||1,d=[],e=n.call(arguments,2);for(c=Math.max(0,c),null;c--;null)d.push(a.apply(this,e));return d},a.prototype.pad=function(a,b,c){return c=c||"0",a+="",a.length>=b?a:new Array(b-a.length+1).join(c)+a},a.prototype.pick=function(a,b){if(0===a.length)throw new RangeError("Chance: Cannot pick() from an empty array");return b&&1!==b?this.shuffle(a).slice(0,b):a[this.natural({max:a.length-1})]},a.prototype.shuffle=function(a){for(var b=a.slice(0),c=[],d=0,e=Number(b.length),f=0;e>f;f++)d=this.natural({max:b.length-1}),c[f]=b[d],b.splice(d,1);return c},a.prototype.weighted=function(a,b){if(a.length!==b.length)throw new RangeError("Chance: length of array and weights must match");if(b.some(function(a){return 1>a})){var c=b.reduce(function(a,b){return a>b?b:a},b[0]),d=1/c;b=b.map(function(a){return a*d})}var e,f=b.reduce(function(a,b){return a+b},0),g=this.natural({min:1,max:f}),h=0;return b.some(function(b,c){return h+b>=g?(e=a[c],!0):(h+=b,!1)}),e},a.prototype.paragraph=function(a){a=b(a);var c=a.sentences||this.natural({min:3,max:7}),d=this.n(this.sentence,c);return d.join(" ")},a.prototype.sentence=function(a){a=b(a);var c,d=a.words||this.natural({min:12,max:18}),e=this.n(this.word,d);return c=e.join(" "),c=this.capitalize(c)+"."},a.prototype.syllable=function(a){a=b(a);for(var c,d=a.length||this.natural({min:2,max:3}),e="bcdfghjklmnprstvwz",f="aeiou",g=e+f,h="",i=0;d>i;i++)c=this.character(0===i?{pool:g}:-1===e.indexOf(c)?{pool:e}:{pool:f}),h+=c;return h},a.prototype.word=function(a){a=b(a),c(a.syllables&&a.length,"Chance: Cannot specify both syllables AND length.");var d=a.syllables||this.natural({min:1,max:3}),e="";if(a.length){do e+=this.syllable();while(e.lengthf;f++)e+=this.syllable();return e},a.prototype.age=function(a){a=b(a);var c;switch(a.type){case"child":c={min:1,max:12};break;case"teen":c={min:13,max:19};break;case"adult":c={min:18,max:65};break;case"senior":c={min:65,max:100};break;case"all":c={min:1,max:100};break;default:c={min:18,max:65}}return this.natural(c)},a.prototype.birthday=function(a){return a=b(a,{year:(new Date).getFullYear()-this.age(a)}),this.date(a)},a.prototype.cpf=function(){var a=this.n(this.natural,9,{max:9}),b=2*a[8]+3*a[7]+4*a[6]+5*a[5]+6*a[4]+7*a[3]+8*a[2]+9*a[1]+10*a[0];b=11-b%11,b>=10&&(b=0);var c=2*b+3*a[8]+4*a[7]+5*a[6]+6*a[5]+7*a[4]+8*a[3]+9*a[2]+10*a[1]+11*a[0];return c=11-c%11,c>=10&&(c=0),""+a[0]+a[1]+a[2]+"."+a[3]+a[4]+a[5]+"."+a[6]+a[7]+a[8]+"-"+b+c},a.prototype.first=function(a){return a=b(a,{gender:this.gender()}),this.pick(this.get("firstNames")[a.gender.toLowerCase()])},a.prototype.gender=function(){return this.pick(["Male","Female"])},a.prototype.last=function(){return this.pick(this.get("lastNames"))},a.prototype.name=function(a){a=b(a);var c,d=this.first(a),e=this.last();return c=a.middle?d+" "+this.first(a)+" "+e:a.middle_initial?d+" "+this.character({alpha:!0,casing:"upper"})+". "+e:d+" "+e,a.prefix&&(c=this.prefix(a)+" "+c),a.suffix&&(c=c+" "+this.suffix(a)),c},a.prototype.name_prefixes=function(a){a=a||"all",a=a.toLowerCase();var b=[{name:"Doctor",abbreviation:"Dr."}];return("male"===a||"all"===a)&&b.push({name:"Mister",abbreviation:"Mr."}),("female"===a||"all"===a)&&(b.push({name:"Miss",abbreviation:"Miss"}),b.push({name:"Misses",abbreviation:"Mrs."})),b},a.prototype.prefix=function(a){return this.name_prefix(a)},a.prototype.name_prefix=function(a){return a=b(a,{gender:"all"}),a.full?this.pick(this.name_prefixes(a.gender)).name:this.pick(this.name_prefixes(a.gender)).abbreviation},a.prototype.ssn=function(a){a=b(a,{ssnFour:!1,dashes:!0});var c,d="1234567890",e=a.dashes?"-":"";return c=a.ssnFour?this.string({pool:d,length:4}):this.string({pool:d,length:3})+e+this.string({pool:d,length:2})+e+this.string({pool:d,length:4})},a.prototype.name_suffixes=function(){var a=[{name:"Doctor of Osteopathic Medicine",abbreviation:"D.O."},{name:"Doctor of Philosophy",abbreviation:"Ph.D."},{name:"Esquire",abbreviation:"Esq."},{name:"Junior",abbreviation:"Jr."},{name:"Juris Doctor",abbreviation:"J.D."},{name:"Master of Arts",abbreviation:"M.A."},{name:"Master of Business Administration",abbreviation:"M.B.A."},{name:"Master of Science",abbreviation:"M.S."},{name:"Medical Doctor",abbreviation:"M.D."},{name:"Senior",abbreviation:"Sr."},{name:"The Third",abbreviation:"III"},{name:"The Fourth",abbreviation:"IV"}];return a},a.prototype.suffix=function(a){return this.name_suffix(a)},a.prototype.name_suffix=function(a){return a=b(a),a.full?this.pick(this.name_suffixes()).name:this.pick(this.name_suffixes()).abbreviation},a.prototype.android_id=function(){return"APA91"+this.string({pool:"0123456789abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_",length:178})},a.prototype.apple_token=function(){return this.string({pool:"abcdef1234567890",length:64})},a.prototype.wp8_anid2=function(){return o(this.hash({length:32}))},a.prototype.wp7_anid=function(){return"A="+this.guid().replace(/-/g,"").toUpperCase()+"&E="+this.hash({length:3})+"&W="+this.integer({min:0,max:9})},a.prototype.bb_pin=function(){return this.hash({length:8})},a.prototype.color=function(a){function c(a,b){return[a,a,a].join(b||"")}a=b(a,{format:this.pick(["hex","shorthex","rgb","0x"]),grayscale:!1,casing:"lower"});var d,e=a.grayscale;if("hex"===a.format)d="#"+(e?c(this.hash({length:2})):this.hash({length:6}));else if("shorthex"===a.format)d="#"+(e?c(this.hash({length:1})):this.hash({length:3}));else if("rgb"===a.format)d=e?"rgb("+c(this.natural({max:255}),",")+")":"rgb("+this.natural({max:255})+","+this.natural({max:255})+","+this.natural({max:255})+")";else{if("0x"!==a.format)throw new Error('Invalid format provided. Please provide one of "hex", "shorthex", "rgb" or "0x".');d="0x"+(e?c(this.hash({length:2})):this.hash({length:6}))}return"upper"===a.casing&&(d=d.toUpperCase()),d},a.prototype.domain=function(a){return a=b(a),this.word()+"."+(a.tld||this.tld())},a.prototype.email=function(a){return a=b(a),this.word({length:a.length})+"@"+(a.domain||this.domain())},a.prototype.fbid=function(){return parseInt("10000"+this.natural({max:1e11}),10)},a.prototype.google_analytics=function(){var a=this.pad(this.natural({max:999999}),6),b=this.pad(this.natural({max:99}),2);return"UA-"+a+"-"+b},a.prototype.hashtag=function(){return"#"+this.word()},a.prototype.ip=function(){return this.natural({max:255})+"."+this.natural({max:255})+"."+this.natural({max:255})+"."+this.natural({max:255})},a.prototype.ipv6=function(){var a=this.n(this.hash,8,{length:4});return a.join(":")},a.prototype.klout=function(){return this.natural({min:1,max:99})},a.prototype.tlds=function(){return["com","org","edu","gov","co.uk","net","io"]},a.prototype.tld=function(){return this.pick(this.tlds())},a.prototype.twitter=function(){return"@"+this.word()},a.prototype.url=function(a){a=b(a,{protocol:"http",domain:this.domain(a),domain_prefix:"",path:this.word(),extensions:[]});var c=a.extensions.length>0?"."+this.pick(a.extensions):"",d=a.domain_prefix?a.domain_prefix+"."+a.domain:a.domain;return a.protocol+"://"+d+"/"+a.path+c},a.prototype.address=function(a){return a=b(a),this.natural({min:5,max:2e3})+" "+this.street(a)},a.prototype.altitude=function(a){return a=b(a,{fixed:5,max:8848}),this.floating({min:0,max:a.max,fixed:a.fixed})},a.prototype.areacode=function(a){a=b(a,{parens:!0});var c=this.natural({min:2,max:9}).toString()+this.natural({min:0,max:8}).toString()+this.natural({min:0,max:9}).toString();return a.parens?"("+c+")":c},a.prototype.city=function(){return this.capitalize(this.word({syllables:3}))},a.prototype.coordinates=function(a){return a=b(a),this.latitude(a)+", "+this.longitude(a)},a.prototype.countries=function(){return this.get("countries")},a.prototype.country=function(a){a=b(a);var c=this.pick(this.countries());return a.full?c.name:c.abbreviation},a.prototype.depth=function(a){return a=b(a,{fixed:5,min:-2550}),this.floating({min:a.min,max:0,fixed:a.fixed})},a.prototype.geohash=function(a){return a=b(a,{length:7}),this.string({length:a.length,pool:"0123456789bcdefghjkmnpqrstuvwxyz"})},a.prototype.geojson=function(a){return a=b(a),this.latitude(a)+", "+this.longitude(a)+", "+this.altitude(a)},a.prototype.latitude=function(a){return a=b(a,{fixed:5,min:-90,max:90}),this.floating({min:a.min,max:a.max,fixed:a.fixed})},a.prototype.longitude=function(a){return a=b(a,{fixed:5,min:-180,max:180}),this.floating({min:a.min,max:a.max,fixed:a.fixed})},a.prototype.phone=function(a){var c,d=this,e=function(a){var b=[];return a.sections.forEach(function(a){b.push(d.string({pool:"0123456789",length:a}))}),a.area+b.join(" ")};a=b(a,{formatted:!0,country:"us",mobile:!1}),a.formatted||(a.parens=!1);var f;switch(a.country){case"fr":a.mobile?(c=this.pick(["06","07"])+d.string({pool:"0123456789",length:8}),f=a.formatted?c.match(/../g).join(" "):c):(c=this.pick(["01"+this.pick(["30","34","39","40","41","42","43","44","45","46","47","48","49","53","55","56","58","60","64","69","70","72","73","74","75","76","77","78","79","80","81","82","83"])+d.string({pool:"0123456789",length:6}),"02"+this.pick(["14","18","22","23","28","29","30","31","32","33","34","35","36","37","38","40","41","43","44","45","46","47","48","49","50","51","52","53","54","56","57","61","62","69","72","76","77","78","85","90","96","97","98","99"])+d.string({pool:"0123456789",length:6}),"03"+this.pick(["10","20","21","22","23","24","25","26","27","28","29","39","44","45","51","52","54","55","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","80","81","82","83","84","85","86","87","88","89","90"])+d.string({pool:"0123456789",length:6}),"04"+this.pick(["11","13","15","20","22","26","27","30","32","34","37","42","43","44","50","56","57","63","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","88","89","90","91","92","93","94","95","97","98"])+d.string({pool:"0123456789",length:6}),"05"+this.pick(["08","16","17","19","24","31","32","33","34","35","40","45","46","47","49","53","55","56","57","58","59","61","62","63","64","65","67","79","81","82","86","87","90","94"])+d.string({pool:"0123456789",length:6}),"09"+d.string({pool:"0123456789",length:8})]),f=a.formatted?c.match(/../g).join(" "):c);break;case"uk":a.mobile?(c=this.pick([{area:"07"+this.pick(["4","5","7","8","9"]),sections:[2,6]},{area:"07624 ",sections:[6]}]),f=a.formatted?e(c):e(c).replace(" ","")):(c=this.pick([{area:"01"+this.character({pool:"234569"})+"1 ",sections:[3,4]},{area:"020 "+this.character({pool:"378"}),sections:[3,4]},{area:"023 "+this.character({pool:"89"}),sections:[3,4]},{area:"024 7",sections:[3,4]},{area:"028 "+this.pick(["25","28","37","71","82","90","92","95"]),sections:[2,4]},{area:"012"+this.pick(["04","08","54","76","97","98"])+" ",sections:[5]},{area:"013"+this.pick(["63","64","84","86"])+" ",sections:[5]},{area:"014"+this.pick(["04","20","60","61","80","88"])+" ",sections:[5]},{area:"015"+this.pick(["24","27","62","66"])+" ",sections:[5]},{area:"016"+this.pick(["06","29","35","47","59","95"])+" ",sections:[5]},{area:"017"+this.pick(["26","44","50","68"])+" ",sections:[5]},{area:"018"+this.pick(["27","37","84","97"])+" ",sections:[5]},{area:"019"+this.pick(["00","05","35","46","49","63","95"])+" ",sections:[5]}]),f=a.formatted?e(c):e(c).replace(" ","","g"));break;case"us":var g=this.areacode(a).toString(),h=this.natural({min:2,max:9}).toString()+this.natural({min:0,max:9}).toString()+this.natural({min:0,max:9}).toString(),i=this.natural({min:1e3,max:9999}).toString();f=a.formatted?g+" "+h+"-"+i:g+h+i}return f},a.prototype.postal=function(){var a=this.character({pool:"XVTSRPNKLMHJGECBA"}),b=a+this.natural({max:9})+this.character({alpha:!0,casing:"upper"}),c=this.natural({max:9})+this.character({alpha:!0,casing:"upper"})+this.natural({max:9});return b+" "+c},a.prototype.provinces=function(){return this.get("provinces")},a.prototype.province=function(a){return a&&a.full?this.pick(this.provinces()).name:this.pick(this.provinces()).abbreviation},a.prototype.state=function(a){return a&&a.full?this.pick(this.states(a)).name:this.pick(this.states(a)).abbreviation},a.prototype.states=function(a){a=b(a);var c,d=this.get("us_states_and_dc"),e=this.get("territories"),f=this.get("armed_forces");return c=d,a.territories&&(c=c.concat(e)),a.armed_forces&&(c=c.concat(f)),c},a.prototype.street=function(a){a=b(a);var c=this.word({syllables:2});return c=this.capitalize(c),c+=" ",c+=a.short_suffix?this.street_suffix().abbreviation:this.street_suffix().name},a.prototype.street_suffix=function(){return this.pick(this.street_suffixes())},a.prototype.street_suffixes=function(){return this.get("street_suffixes")},a.prototype.zip=function(a){var b=this.n(this.natural,5,{max:9});return a&&a.plusfour===!0&&(b.push("-"),b=b.concat(this.n(this.natural,4,{max:9}))),b.join("")},a.prototype.ampm=function(){return this.bool()?"am":"pm"},a.prototype.date=function(a){var c,d;if(a&&(a.min||a.max)){a=b(a,{american:!0,string:!1});var e="undefined"!=typeof a.min?a.min.getTime():1,f="undefined"!=typeof a.max?a.max.getTime():864e13;d=new Date(this.natural({min:e,max:f}))}else{var g=this.month({raw:!0});a=b(a,{year:parseInt(this.year(),10),month:g.numeric-1,day:this.natural({min:1,max:g.days}),hour:this.hour(),minute:this.minute(),second:this.second(),millisecond:this.millisecond(),american:!0,string:!1}),d=new Date(a.year,a.month,a.day,a.hour,a.minute,a.second,a.millisecond)}return c=a.american?d.getMonth()+1+"/"+d.getDate()+"/"+d.getFullYear():d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getFullYear(),a.string?c:d},a.prototype.hammertime=function(a){return this.date(a).getTime()},a.prototype.hour=function(a){return a=b(a,{min:1,max:a&&a.twentyfour?24:12}),c(a.min<1,"Chance: Min cannot be less than 1."),c(a.twentyfour&&a.max>24,"Chance: Max cannot be greater than 24 for twentyfour option."),c(!a.twentyfour&&a.max>12,"Chance: Max cannot be greater than 12."),c(a.min>a.max,"Chance: Min cannot be greater than Max."),this.natural({min:a.min,max:a.max})},a.prototype.millisecond=function(){return this.natural({max:999})},a.prototype.minute=a.prototype.second=function(a){return a=b(a,{min:0,max:59}),c(a.min<0,"Chance: Min cannot be less than 0."),c(a.max>59,"Chance: Max cannot be greater than 59."),c(a.min>a.max,"Chance: Min cannot be greater than Max."),this.natural({min:a.min,max:a.max})},a.prototype.month=function(a){a=b(a,{min:1,max:12}),c(a.min<1,"Chance: Min cannot be less than 1."),c(a.max>12,"Chance: Max cannot be greater than 12."),c(a.min>a.max,"Chance: Min cannot be greater than Max.");var d=this.pick(this.months().slice(a.min-1,a.max));return a.raw?d:d.name},a.prototype.months=function(){return this.get("months")},a.prototype.second=function(){return this.natural({max:59})},a.prototype.timestamp=function(){return this.natural({min:1,max:parseInt((new Date).getTime()/1e3,10)})},a.prototype.year=function(a){return a=b(a,{min:(new Date).getFullYear()}),a.max="undefined"!=typeof a.max?a.max:a.min+100,this.natural(a).toString()},a.prototype.cc=function(a){a=b(a);var c,d,e;return c=this.cc_type(a.type?{name:a.type,raw:!0}:{raw:!0}),d=c.prefix.split(""),e=c.length-c.prefix.length-1,d=d.concat(this.n(this.integer,e,{min:0,max:9})),d.push(this.luhn_calculate(d.join(""))),d.join("")},a.prototype.cc_types=function(){return this.get("cc_types")},a.prototype.cc_type=function(a){a=b(a);var c=this.cc_types(),d=null;if(a.name){for(var e=0;ec?"-$"+c.replace("-",""):"$"+c},a.prototype.exp=function(a){a=b(a);var c={};return c.year=this.exp_year(),c.month=c.year===(new Date).getFullYear()?this.exp_month({future:!0}):this.exp_month(),a.raw?c:c.month+"/"+c.year},a.prototype.exp_month=function(a){a=b(a);var c,d,e=(new Date).getMonth();if(a.future){do c=this.month({raw:!0}).numeric,d=parseInt(c,10);while(e>d)}else c=this.month({raw:!0}).numeric;return c},a.prototype.exp_year=function(){return this.year({max:(new Date).getFullYear()+10})},a.prototype.d4=d({min:1,max:4}),a.prototype.d6=d({min:1,max:6}),a.prototype.d8=d({min:1,max:8}),a.prototype.d10=d({min:1,max:10}),a.prototype.d12=d({min:1,max:12}),a.prototype.d20=d({min:1,max:20}),a.prototype.d30=d({min:1,max:30}),a.prototype.d100=d({min:1,max:100}),a.prototype.rpg=function(a,c){if(c=b(c),null===a)throw new Error("A type of die roll must be included");var d=a.toLowerCase().split("d"),e=[];if(2!==d.length||!parseInt(d[0],10)||!parseInt(d[1],10))throw new Error("Invalid format provided. Please provide #d# where the first # is the number of dice to roll, the second # is the max of each die");for(var f=d[0];f>0;f--)e[f-1]=this.natural({min:1,max:d[1]});return"undefined"!=typeof c.sum&&c.sum?e.reduce(function(a,b){return a+b}):e},a.prototype.guid=function(a){a=b(a,{version:5});var c="abcdef1234567890",d="ab89",e=this.string({pool:c,length:8})+"-"+this.string({pool:c,length:4})+"-"+a.version+this.string({pool:c,length:3})+"-"+this.string({pool:d,length:1})+this.string({pool:c,length:3})+"-"+this.string({pool:c,length:12});return e},a.prototype.hash=function(a){a=b(a,{length:40,casing:"lower"});var c="upper"===a.casing?m.toUpperCase():m;return this.string({pool:c,length:a.length})},a.prototype.luhn_check=function(a){var b=a.toString(),c=+b.substring(b.length-1);return c===this.luhn_calculate(+b.substring(0,b.length-1))},a.prototype.luhn_calculate=function(a){for(var b,c=a.toString().split("").reverse(),d=0,e=0,f=c.length;f>e;++e)b=+c[e],e%2===0&&(b*=2,b>9&&(b-=9)),d+=b;return 9*d%10};var p={firstNames:{male:["James","John","Robert","Michael","William","David","Richard","Joseph","Charles","Thomas","Christopher","Daniel","Matthew","George","Donald","Anthony","Paul","Mark","Edward","Steven","Kenneth","Andrew","Brian","Joshua","Kevin","Ronald","Timothy","Jason","Jeffrey","Frank","Gary","Ryan","Nicholas","Eric","Stephen","Jacob","Larry","Jonathan","Scott","Raymond","Justin","Brandon","Gregory","Samuel","Benjamin","Patrick","Jack","Henry","Walter","Dennis","Jerry","Alexander","Peter","Tyler","Douglas","Harold","Aaron","Jose","Adam","Arthur","Zachary","Carl","Nathan","Albert","Kyle","Lawrence","Joe","Willie","Gerald","Roger","Keith","Jeremy","Terry","Harry","Ralph","Sean","Jesse","Roy","Louis","Billy","Austin","Bruce","Eugene","Christian","Bryan","Wayne","Russell","Howard","Fred","Ethan","Jordan","Philip","Alan","Juan","Randy","Vincent","Bobby","Dylan","Johnny","Phillip","Victor","Clarence","Ernest","Martin","Craig","Stanley","Shawn","Travis","Bradley","Leonard","Earl","Gabriel","Jimmy","Francis","Todd","Noah","Danny","Dale","Cody","Carlos","Allen","Frederick","Logan","Curtis","Alex","Joel","Luis","Norman","Marvin","Glenn","Tony","Nathaniel","Rodney","Melvin","Alfred","Steve","Cameron","Chad","Edwin","Caleb","Evan","Antonio","Lee","Herbert","Jeffery","Isaac","Derek","Ricky","Marcus","Theodore","Elijah","Luke","Jesus","Eddie","Troy","Mike","Dustin","Ray","Adrian","Bernard","Leroy","Angel","Randall","Wesley","Ian","Jared","Mason","Hunter","Calvin","Oscar","Clifford","Jay","Shane","Ronnie","Barry","Lucas","Corey","Manuel","Leo","Tommy","Warren","Jackson","Isaiah","Connor","Don","Dean","Jon","Julian","Miguel","Bill","Lloyd","Charlie","Mitchell","Leon","Jerome","Darrell","Jeremiah","Alvin","Brett","Seth","Floyd","Jim","Blake","Micheal","Gordon","Trevor","Lewis","Erik","Edgar","Vernon","Devin","Gavin","Jayden","Chris","Clyde","Tom","Derrick","Mario","Brent","Marc","Herman","Chase","Dominic","Ricardo","Franklin","Maurice","Max","Aiden","Owen","Lester","Gilbert","Elmer","Gene","Francisco","Glen","Cory","Garrett","Clayton","Sam","Jorge","Chester","Alejandro","Jeff","Harvey","Milton","Cole","Ivan","Andre","Duane","Landon"],female:["Mary","Emma","Elizabeth","Minnie","Margaret","Ida","Alice","Bertha","Sarah","Annie","Clara","Ella","Florence","Cora","Martha","Laura","Nellie","Grace","Carrie","Maude","Mabel","Bessie","Jennie","Gertrude","Julia","Hattie","Edith","Mattie","Rose","Catherine","Lillian","Ada","Lillie","Helen","Jessie","Louise","Ethel","Lula","Myrtle","Eva","Frances","Lena","Lucy","Edna","Maggie","Pearl","Daisy","Fannie","Josephine","Dora","Rosa","Katherine","Agnes","Marie","Nora","May","Mamie","Blanche","Stella","Ellen","Nancy","Effie","Sallie","Nettie","Della","Lizzie","Flora","Susie","Maud","Mae","Etta","Harriet","Sadie","Caroline","Katie","Lydia","Elsie","Kate","Susan","Mollie","Alma","Addie","Georgia","Eliza","Lulu","Nannie","Lottie","Amanda","Belle","Charlotte","Rebecca","Ruth","Viola","Olive","Amelia","Hannah","Jane","Virginia","Emily","Matilda","Irene","Kathryn","Esther","Willie","Henrietta","Ollie","Amy","Rachel","Sara","Estella","Theresa","Augusta","Ora","Pauline","Josie","Lola","Sophia","Leona","Anne","Mildred","Ann","Beulah","Callie","Lou","Delia","Eleanor","Barbara","Iva","Louisa","Maria","Mayme","Evelyn","Estelle","Nina","Betty","Marion","Bettie","Dorothy","Luella","Inez","Lela","Rosie","Allie","Millie","Janie","Cornelia","Victoria","Ruby","Winifred","Alta","Celia","Christine","Beatrice","Birdie","Harriett","Mable","Myra","Sophie","Tillie","Isabel","Sylvia","Carolyn","Isabelle","Leila","Sally","Ina","Essie","Bertie","Nell","Alberta","Katharine","Lora","Rena","Mina","Rhoda","Mathilda","Abbie","Eula","Dollie","Hettie","Eunice","Fanny","Ola","Lenora","Adelaide","Christina","Lelia","Nelle","Sue","Johanna","Lilly","Lucinda","Minerva","Lettie","Roxie","Cynthia","Helena","Hilda","Hulda","Bernice","Genevieve","Jean","Cordelia","Marian","Francis","Jeanette","Adeline","Gussie","Leah","Lois","Lura","Mittie","Hallie","Isabella","Olga","Phoebe","Teresa","Hester","Lida","Lina","Winnie","Claudia","Marguerite","Vera","Cecelia","Bess","Emilie","John","Rosetta","Verna","Myrtie","Cecilia","Elva","Olivia","Ophelia","Georgie","Elnora","Violet","Adele","Lily","Linnie","Loretta","Madge","Polly","Virgie","Eugenia","Lucile","Lucille","Mabelle","Rosalie"]},lastNames:["Smith","Johnson","Williams","Jones","Brown","Davis","Miller","Wilson","Moore","Taylor","Anderson","Thomas","Jackson","White","Harris","Martin","Thompson","Garcia","Martinez","Robinson","Clark","Rodriguez","Lewis","Lee","Walker","Hall","Allen","Young","Hernandez","King","Wright","Lopez","Hill","Scott","Green","Adams","Baker","Gonzalez","Nelson","Carter","Mitchell","Perez","Roberts","Turner","Phillips","Campbell","Parker","Evans","Edwards","Collins","Stewart","Sanchez","Morris","Rogers","Reed","Cook","Morgan","Bell","Murphy","Bailey","Rivera","Cooper","Richardson","Cox","Howard","Ward","Torres","Peterson","Gray","Ramirez","James","Watson","Brooks","Kelly","Sanders","Price","Bennett","Wood","Barnes","Ross","Henderson","Coleman","Jenkins","Perry","Powell","Long","Patterson","Hughes","Flores","Washington","Butler","Simmons","Foster","Gonzales","Bryant","Alexander","Russell","Griffin","Diaz","Hayes","Myers","Ford","Hamilton","Graham","Sullivan","Wallace","Woods","Cole","West","Jordan","Owens","Reynolds","Fisher","Ellis","Harrison","Gibson","McDonald","Cruz","Marshall","Ortiz","Gomez","Murray","Freeman","Wells","Webb","Simpson","Stevens","Tucker","Porter","Hunter","Hicks","Crawford","Henry","Boyd","Mason","Morales","Kennedy","Warren","Dixon","Ramos","Reyes","Burns","Gordon","Shaw","Holmes","Rice","Robertson","Hunt","Black","Daniels","Palmer","Mills","Nichols","Grant","Knight","Ferguson","Rose","Stone","Hawkins","Dunn","Perkins","Hudson","Spencer","Gardner","Stephens","Payne","Pierce","Berry","Matthews","Arnold","Wagner","Willis","Ray","Watkins","Olson","Carroll","Duncan","Snyder","Hart","Cunningham","Bradley","Lane","Andrews","Ruiz","Harper","Fox","Riley","Armstrong","Carpenter","Weaver","Greene","Lawrence","Elliott","Chavez","Sims","Austin","Peters","Kelley","Franklin","Lawson","Fields","Gutierrez","Ryan","Schmidt","Carr","Vasquez","Castillo","Wheeler","Chapman","Oliver","Montgomery","Richards","Williamson","Johnston","Banks","Meyer","Bishop","McCoy","Howell","Alvarez","Morrison","Hansen","Fernandez","Garza","Harvey","Little","Burton","Stanley","Nguyen","George","Jacobs","Reid","Kim","Fuller","Lynch","Dean","Gilbert","Garrett","Romero","Welch","Larson","Frazier","Burke","Hanson","Day","Mendoza","Moreno","Bowman","Medina","Fowler","Brewer","Hoffman","Carlson","Silva","Pearson","Holland","Douglas","Fleming","Jensen","Vargas","Byrd","Davidson","Hopkins","May","Terry","Herrera","Wade","Soto","Walters","Curtis","Neal","Caldwell","Lowe","Jennings","Barnett","Graves","Jimenez","Horton","Shelton","Barrett","Obrien","Castro","Sutton","Gregory","McKinney","Lucas","Miles","Craig","Rodriquez","Chambers","Holt","Lambert","Fletcher","Watts","Bates","Hale","Rhodes","Pena","Beck","Newman","Haynes","McDaniel","Mendez","Bush","Vaughn","Parks","Dawson","Santiago","Norris","Hardy","Love","Steele","Curry","Powers","Schultz","Barker","Guzman","Page","Munoz","Ball","Keller","Chandler","Weber","Leonard","Walsh","Lyons","Ramsey","Wolfe","Schneider","Mullins","Benson","Sharp","Bowen","Daniel","Barber","Cummings","Hines","Baldwin","Griffith","Valdez","Hubbard","Salazar","Reeves","Warner","Stevenson","Burgess","Santos","Tate","Cross","Garner","Mann","Mack","Moss","Thornton","Dennis","McGee","Farmer","Delgado","Aguilar","Vega","Glover","Manning","Cohen","Harmon","Rodgers","Robbins","Newton","Todd","Blair","Higgins","Ingram","Reese","Cannon","Strickland","Townsend","Potter","Goodwin","Walton","Rowe","Hampton","Ortega","Patton","Swanson","Joseph","Francis","Goodman","Maldonado","Yates","Becker","Erickson","Hodges","Rios","Conner","Adkins","Webster","Norman","Malone","Hammond","Flowers","Cobb","Moody","Quinn","Blake","Maxwell","Pope","Floyd","Osborne","Paul","McCarthy","Guerrero","Lindsey","Estrada","Sandoval","Gibbs","Tyler","Gross","Fitzgerald","Stokes","Doyle","Sherman","Saunders","Wise","Colon","Gill","Alvarado","Greer","Padilla","Simon","Waters","Nunez","Ballard","Schwartz","McBride","Houston","Christensen","Klein","Pratt","Briggs","Parsons","McLaughlin","Zimmerman","French","Buchanan","Moran","Copeland","Roy","Pittman","Brady","McCormick","Holloway","Brock","Poole","Frank","Logan","Owen","Bass","Marsh","Drake","Wong","Jefferson","Park","Morton","Abbott","Sparks","Patrick","Norton","Huff","Clayton","Massey","Lloyd","Figueroa","Carson","Bowers","Roberson","Barton","Tran","Lamb","Harrington","Casey","Boone","Cortez","Clarke","Mathis","Singleton","Wilkins","Cain","Bryan","Underwood","Hogan","McKenzie","Collier","Luna","Phelps","McGuire","Allison","Bridges","Wilkerson","Nash","Summers","Atkins"],countries:[{name:"Afghanistan",abbreviation:"AF"},{name:"Albania",abbreviation:"AL"},{name:"Algeria",abbreviation:"DZ"},{name:"American Samoa",abbreviation:"AS"},{name:"Andorra",abbreviation:"AD"},{name:"Angola",abbreviation:"AO"},{name:"Anguilla",abbreviation:"AI"},{name:"Antarctica",abbreviation:"AQ"},{name:"Antigua and Barbuda",abbreviation:"AG"},{name:"Argentina",abbreviation:"AR"},{name:"Armenia",abbreviation:"AM"},{name:"Aruba",abbreviation:"AW"},{name:"Australia",abbreviation:"AU"},{name:"Austria",abbreviation:"AT"},{name:"Azerbaijan",abbreviation:"AZ"},{name:"Bahamas",abbreviation:"BS"},{name:"Bahrain",abbreviation:"BH"},{name:"Bangladesh",abbreviation:"BD"},{name:"Barbados",abbreviation:"BB"},{name:"Belarus",abbreviation:"BY"},{name:"Belgium",abbreviation:"BE"},{name:"Belize",abbreviation:"BZ"},{name:"Benin",abbreviation:"BJ"},{name:"Bermuda",abbreviation:"BM"},{name:"Bhutan",abbreviation:"BT"},{name:"Bolivia",abbreviation:"BO"},{name:"Bosnia and Herzegovina",abbreviation:"BA"},{name:"Botswana",abbreviation:"BW"},{name:"Bouvet Island",abbreviation:"BV"},{name:"Brazil",abbreviation:"BR"},{name:"British Antarctic Territory",abbreviation:"BQ"},{name:"British Indian Ocean Territory",abbreviation:"IO"},{name:"British Virgin Islands",abbreviation:"VG"},{name:"Brunei",abbreviation:"BN"},{name:"Bulgaria",abbreviation:"BG"},{name:"Burkina Faso",abbreviation:"BF"},{name:"Burundi",abbreviation:"BI"},{name:"Cambodia",abbreviation:"KH"},{name:"Cameroon",abbreviation:"CM"},{name:"Canada",abbreviation:"CA"},{name:"Canton and Enderbury Islands",abbreviation:"CT"},{name:"Cape Verde",abbreviation:"CV"},{name:"Cayman Islands",abbreviation:"KY"},{name:"Central African Republic",abbreviation:"CF"},{name:"Chad",abbreviation:"TD"},{name:"Chile",abbreviation:"CL"},{name:"China",abbreviation:"CN"},{name:"Christmas Island",abbreviation:"CX"},{name:"Cocos [Keeling] Islands",abbreviation:"CC"},{name:"Colombia",abbreviation:"CO"},{name:"Comoros",abbreviation:"KM"},{name:"Congo - Brazzaville",abbreviation:"CG"},{name:"Congo - Kinshasa",abbreviation:"CD"},{name:"Cook Islands",abbreviation:"CK"},{name:"Costa Rica",abbreviation:"CR"},{name:"Croatia",abbreviation:"HR"},{name:"Cuba",abbreviation:"CU"},{name:"Cyprus",abbreviation:"CY"},{name:"Czech Republic",abbreviation:"CZ"},{name:"Côte d’Ivoire",abbreviation:"CI"},{name:"Denmark",abbreviation:"DK"},{name:"Djibouti",abbreviation:"DJ"},{name:"Dominica",abbreviation:"DM"},{name:"Dominican Republic",abbreviation:"DO"},{name:"Dronning Maud Land",abbreviation:"NQ"},{name:"East Germany",abbreviation:"DD"},{name:"Ecuador",abbreviation:"EC"},{name:"Egypt",abbreviation:"EG"},{name:"El Salvador",abbreviation:"SV"},{name:"Equatorial Guinea",abbreviation:"GQ"},{name:"Eritrea",abbreviation:"ER"},{name:"Estonia",abbreviation:"EE"},{name:"Ethiopia",abbreviation:"ET"},{name:"Falkland Islands",abbreviation:"FK"},{name:"Faroe Islands",abbreviation:"FO"},{name:"Fiji",abbreviation:"FJ"},{name:"Finland",abbreviation:"FI"},{name:"France",abbreviation:"FR"},{name:"French Guiana",abbreviation:"GF"},{name:"French Polynesia",abbreviation:"PF"},{name:"French Southern Territories",abbreviation:"TF"},{name:"French Southern and Antarctic Territories",abbreviation:"FQ"},{name:"Gabon",abbreviation:"GA"},{name:"Gambia",abbreviation:"GM"},{name:"Georgia",abbreviation:"GE"},{name:"Germany",abbreviation:"DE"},{name:"Ghana",abbreviation:"GH"},{name:"Gibraltar",abbreviation:"GI"},{name:"Greece",abbreviation:"GR"},{name:"Greenland",abbreviation:"GL"},{name:"Grenada",abbreviation:"GD"},{name:"Guadeloupe",abbreviation:"GP"},{name:"Guam",abbreviation:"GU"},{name:"Guatemala",abbreviation:"GT"},{name:"Guernsey",abbreviation:"GG"},{name:"Guinea",abbreviation:"GN"},{name:"Guinea-Bissau",abbreviation:"GW"},{name:"Guyana",abbreviation:"GY"},{name:"Haiti",abbreviation:"HT"},{name:"Heard Island and McDonald Islands",abbreviation:"HM"},{name:"Honduras",abbreviation:"HN"},{name:"Hong Kong SAR China",abbreviation:"HK"},{name:"Hungary",abbreviation:"HU"},{name:"Iceland",abbreviation:"IS"},{name:"India",abbreviation:"IN"},{name:"Indonesia",abbreviation:"ID"},{name:"Iran",abbreviation:"IR"},{name:"Iraq",abbreviation:"IQ"},{name:"Ireland",abbreviation:"IE"},{name:"Isle of Man",abbreviation:"IM"},{name:"Israel",abbreviation:"IL"},{name:"Italy",abbreviation:"IT"},{name:"Jamaica",abbreviation:"JM"},{name:"Japan",abbreviation:"JP"},{name:"Jersey",abbreviation:"JE"},{name:"Johnston Island",abbreviation:"JT"},{name:"Jordan",abbreviation:"JO"},{name:"Kazakhstan",abbreviation:"KZ"},{name:"Kenya",abbreviation:"KE"},{name:"Kiribati",abbreviation:"KI"},{name:"Kuwait",abbreviation:"KW"},{name:"Kyrgyzstan",abbreviation:"KG"},{name:"Laos",abbreviation:"LA"},{name:"Latvia",abbreviation:"LV"},{name:"Lebanon",abbreviation:"LB"},{name:"Lesotho",abbreviation:"LS"},{name:"Liberia",abbreviation:"LR"},{name:"Libya",abbreviation:"LY"},{name:"Liechtenstein",abbreviation:"LI"},{name:"Lithuania",abbreviation:"LT"},{name:"Luxembourg",abbreviation:"LU"},{name:"Macau SAR China",abbreviation:"MO"},{name:"Macedonia",abbreviation:"MK"},{name:"Madagascar",abbreviation:"MG"},{name:"Malawi",abbreviation:"MW"},{name:"Malaysia",abbreviation:"MY"},{name:"Maldives",abbreviation:"MV"},{name:"Mali",abbreviation:"ML"},{name:"Malta",abbreviation:"MT"},{name:"Marshall Islands",abbreviation:"MH"},{name:"Martinique",abbreviation:"MQ"},{name:"Mauritania",abbreviation:"MR"},{name:"Mauritius",abbreviation:"MU"},{name:"Mayotte",abbreviation:"YT"},{name:"Metropolitan France",abbreviation:"FX"},{name:"Mexico",abbreviation:"MX"},{name:"Micronesia",abbreviation:"FM"},{name:"Midway Islands",abbreviation:"MI"},{name:"Moldova",abbreviation:"MD"},{name:"Monaco",abbreviation:"MC"},{name:"Mongolia",abbreviation:"MN"},{name:"Montenegro",abbreviation:"ME"},{name:"Montserrat",abbreviation:"MS"},{name:"Morocco",abbreviation:"MA"},{name:"Mozambique",abbreviation:"MZ"},{name:"Myanmar [Burma]",abbreviation:"MM"},{name:"Namibia",abbreviation:"NA"},{name:"Nauru",abbreviation:"NR"},{name:"Nepal",abbreviation:"NP"},{name:"Netherlands",abbreviation:"NL"},{name:"Netherlands Antilles",abbreviation:"AN"},{name:"Neutral Zone",abbreviation:"NT"},{name:"New Caledonia",abbreviation:"NC"},{name:"New Zealand",abbreviation:"NZ"},{name:"Nicaragua",abbreviation:"NI"},{name:"Niger",abbreviation:"NE"},{name:"Nigeria",abbreviation:"NG"},{name:"Niue",abbreviation:"NU"},{name:"Norfolk Island",abbreviation:"NF"},{name:"North Korea",abbreviation:"KP"},{name:"North Vietnam",abbreviation:"VD"},{name:"Northern Mariana Islands",abbreviation:"MP"},{name:"Norway",abbreviation:"NO"},{name:"Oman",abbreviation:"OM"},{name:"Pacific Islands Trust Territory",abbreviation:"PC"},{name:"Pakistan",abbreviation:"PK"},{name:"Palau",abbreviation:"PW"},{name:"Palestinian Territories",abbreviation:"PS"},{name:"Panama",abbreviation:"PA"},{name:"Panama Canal Zone",abbreviation:"PZ"},{name:"Papua New Guinea",abbreviation:"PG"},{name:"Paraguay",abbreviation:"PY"},{name:"People's Democratic Republic of Yemen",abbreviation:"YD"},{name:"Peru",abbreviation:"PE"},{name:"Philippines",abbreviation:"PH"},{name:"Pitcairn Islands",abbreviation:"PN"},{name:"Poland",abbreviation:"PL"},{name:"Portugal",abbreviation:"PT"},{name:"Puerto Rico",abbreviation:"PR"},{name:"Qatar",abbreviation:"QA"},{name:"Romania",abbreviation:"RO"},{name:"Russia",abbreviation:"RU"},{name:"Rwanda",abbreviation:"RW"},{name:"Réunion",abbreviation:"RE"},{name:"Saint Barthélemy",abbreviation:"BL"},{name:"Saint Helena",abbreviation:"SH"},{name:"Saint Kitts and Nevis",abbreviation:"KN"},{name:"Saint Lucia",abbreviation:"LC"},{name:"Saint Martin",abbreviation:"MF"},{name:"Saint Pierre and Miquelon",abbreviation:"PM"},{name:"Saint Vincent and the Grenadines",abbreviation:"VC"},{name:"Samoa",abbreviation:"WS"},{name:"San Marino",abbreviation:"SM"},{name:"Saudi Arabia",abbreviation:"SA"},{name:"Senegal",abbreviation:"SN"},{name:"Serbia",abbreviation:"RS"},{name:"Serbia and Montenegro",abbreviation:"CS"},{name:"Seychelles",abbreviation:"SC"},{name:"Sierra Leone",abbreviation:"SL"},{name:"Singapore",abbreviation:"SG"},{name:"Slovakia",abbreviation:"SK"},{name:"Slovenia",abbreviation:"SI"},{name:"Solomon Islands",abbreviation:"SB"},{name:"Somalia",abbreviation:"SO"},{name:"South Africa",abbreviation:"ZA"},{name:"South Georgia and the South Sandwich Islands",abbreviation:"GS"},{name:"South Korea",abbreviation:"KR"},{name:"Spain",abbreviation:"ES"},{name:"Sri Lanka",abbreviation:"LK"},{name:"Sudan",abbreviation:"SD"},{name:"Suriname",abbreviation:"SR"},{name:"Svalbard and Jan Mayen",abbreviation:"SJ"},{name:"Swaziland",abbreviation:"SZ"},{name:"Sweden",abbreviation:"SE"},{name:"Switzerland",abbreviation:"CH"},{name:"Syria",abbreviation:"SY"},{name:"São Tomé and Príncipe",abbreviation:"ST"},{name:"Taiwan",abbreviation:"TW"},{name:"Tajikistan",abbreviation:"TJ"},{name:"Tanzania",abbreviation:"TZ"},{name:"Thailand",abbreviation:"TH"},{name:"Timor-Leste",abbreviation:"TL"},{name:"Togo",abbreviation:"TG"},{name:"Tokelau",abbreviation:"TK"},{name:"Tonga",abbreviation:"TO"},{name:"Trinidad and Tobago",abbreviation:"TT"},{name:"Tunisia",abbreviation:"TN"},{name:"Turkey",abbreviation:"TR"},{name:"Turkmenistan",abbreviation:"TM"},{name:"Turks and Caicos Islands",abbreviation:"TC"},{name:"Tuvalu",abbreviation:"TV"},{name:"U.S. Minor Outlying Islands",abbreviation:"UM"},{name:"U.S. Miscellaneous Pacific Islands",abbreviation:"PU"},{name:"U.S. Virgin Islands",abbreviation:"VI"},{name:"Uganda",abbreviation:"UG"},{name:"Ukraine",abbreviation:"UA"},{name:"Union of Soviet Socialist Republics",abbreviation:"SU"},{name:"United Arab Emirates",abbreviation:"AE"},{name:"United Kingdom",abbreviation:"GB"},{name:"United States",abbreviation:"US"},{name:"Unknown or Invalid Region",abbreviation:"ZZ"},{name:"Uruguay",abbreviation:"UY"},{name:"Uzbekistan",abbreviation:"UZ"},{name:"Vanuatu",abbreviation:"VU"},{name:"Vatican City",abbreviation:"VA"},{name:"Venezuela",abbreviation:"VE"},{name:"Vietnam",abbreviation:"VN"},{name:"Wake Island",abbreviation:"WK"},{name:"Wallis and Futuna",abbreviation:"WF"},{name:"Western Sahara",abbreviation:"EH"},{name:"Yemen",abbreviation:"YE"},{name:"Zambia",abbreviation:"ZM"},{name:"Zimbabwe",abbreviation:"ZW"},{name:"Åland Islands",abbreviation:"AX"}],provinces:[{name:"Alberta",abbreviation:"AB"},{name:"British Columbia",abbreviation:"BC"},{name:"Manitoba",abbreviation:"MB"},{name:"New Brunswick",abbreviation:"NB"},{name:"Newfoundland and Labrador",abbreviation:"NL"},{name:"Nova Scotia",abbreviation:"NS"},{name:"Ontario",abbreviation:"ON"},{name:"Prince Edward Island",abbreviation:"PE"},{name:"Quebec",abbreviation:"QC"},{name:"Saskatchewan",abbreviation:"SK"},{name:"Northwest Territories",abbreviation:"NT"},{name:"Nunavut",abbreviation:"NU"},{name:"Yukon",abbreviation:"YT"}],us_states_and_dc:[{name:"Alabama",abbreviation:"AL"},{name:"Alaska",abbreviation:"AK"},{name:"Arizona",abbreviation:"AZ"},{name:"Arkansas",abbreviation:"AR"},{name:"California",abbreviation:"CA"},{name:"Colorado",abbreviation:"CO"},{name:"Connecticut",abbreviation:"CT"},{name:"Delaware",abbreviation:"DE"},{name:"District of Columbia",abbreviation:"DC"},{name:"Florida",abbreviation:"FL"},{name:"Georgia",abbreviation:"GA"},{name:"Hawaii",abbreviation:"HI"},{name:"Idaho",abbreviation:"ID"},{name:"Illinois",abbreviation:"IL"},{name:"Indiana",abbreviation:"IN"},{name:"Iowa",abbreviation:"IA"},{name:"Kansas",abbreviation:"KS"},{name:"Kentucky",abbreviation:"KY"},{name:"Louisiana",abbreviation:"LA"},{name:"Maine",abbreviation:"ME"},{name:"Maryland",abbreviation:"MD"},{name:"Massachusetts",abbreviation:"MA"},{name:"Michigan",abbreviation:"MI"},{name:"Minnesota",abbreviation:"MN"},{name:"Mississippi",abbreviation:"MS"},{name:"Missouri",abbreviation:"MO"},{name:"Montana",abbreviation:"MT"},{name:"Nebraska",abbreviation:"NE"},{name:"Nevada",abbreviation:"NV"},{name:"New Hampshire",abbreviation:"NH"},{name:"New Jersey",abbreviation:"NJ"},{name:"New Mexico",abbreviation:"NM"},{name:"New York",abbreviation:"NY"},{name:"North Carolina",abbreviation:"NC"},{name:"North Dakota",abbreviation:"ND"},{name:"Ohio",abbreviation:"OH"},{name:"Oklahoma",abbreviation:"OK"},{name:"Oregon",abbreviation:"OR"},{name:"Pennsylvania",abbreviation:"PA"},{name:"Rhode Island",abbreviation:"RI"},{name:"South Carolina",abbreviation:"SC"},{name:"South Dakota",abbreviation:"SD"},{name:"Tennessee",abbreviation:"TN"},{name:"Texas",abbreviation:"TX"},{name:"Utah",abbreviation:"UT"},{name:"Vermont",abbreviation:"VT"},{name:"Virginia",abbreviation:"VA"},{name:"Washington",abbreviation:"WA"},{name:"West Virginia",abbreviation:"WV"},{name:"Wisconsin",abbreviation:"WI"},{name:"Wyoming",abbreviation:"WY"}],territories:[{name:"American Samoa",abbreviation:"AS"},{name:"Federated States of Micronesia",abbreviation:"FM"},{name:"Guam",abbreviation:"GU"},{name:"Marshall Islands",abbreviation:"MH"},{name:"Northern Mariana Islands",abbreviation:"MP"},{name:"Puerto Rico",abbreviation:"PR"},{name:"Virgin Islands, U.S.",abbreviation:"VI"}],armed_forces:[{name:"Armed Forces Europe",abbreviation:"AE"},{name:"Armed Forces Pacific",abbreviation:"AP"},{name:"Armed Forces the Americas",abbreviation:"AA"}],street_suffixes:[{name:"Avenue",abbreviation:"Ave"},{name:"Boulevard",abbreviation:"Blvd"},{name:"Center",abbreviation:"Ctr"},{name:"Circle",abbreviation:"Cir"},{name:"Court",abbreviation:"Ct"},{name:"Drive",abbreviation:"Dr"},{name:"Extension",abbreviation:"Ext"},{name:"Glen",abbreviation:"Gln"},{name:"Grove",abbreviation:"Grv"},{name:"Heights",abbreviation:"Hts"},{name:"Highway",abbreviation:"Hwy"},{name:"Junction",abbreviation:"Jct"},{name:"Key",abbreviation:"Key"},{name:"Lane",abbreviation:"Ln"},{name:"Loop",abbreviation:"Loop"},{name:"Manor",abbreviation:"Mnr"},{name:"Mill",abbreviation:"Mill"},{name:"Park",abbreviation:"Park"},{name:"Parkway",abbreviation:"Pkwy"},{name:"Pass",abbreviation:"Pass"},{name:"Path",abbreviation:"Path"},{name:"Pike",abbreviation:"Pike"},{name:"Place",abbreviation:"Pl"},{name:"Plaza",abbreviation:"Plz"},{name:"Point",abbreviation:"Pt"},{name:"Ridge",abbreviation:"Rdg"},{name:"River",abbreviation:"Riv"},{name:"Road",abbreviation:"Rd"},{name:"Square",abbreviation:"Sq"},{name:"Street",abbreviation:"St"},{name:"Terrace",abbreviation:"Ter"},{name:"Trail",abbreviation:"Trl"},{name:"Turnpike",abbreviation:"Tpke"},{name:"View",abbreviation:"Vw"},{name:"Way",abbreviation:"Way"}],months:[{name:"January",short_name:"Jan",numeric:"01",days:31},{name:"February",short_name:"Feb",numeric:"02",days:28},{name:"March",short_name:"Mar",numeric:"03",days:31},{name:"April",short_name:"Apr",numeric:"04",days:30},{name:"May",short_name:"May",numeric:"05",days:31},{name:"June",short_name:"Jun",numeric:"06",days:30},{name:"July",short_name:"Jul",numeric:"07",days:31},{name:"August",short_name:"Aug",numeric:"08",days:31},{name:"September",short_name:"Sep",numeric:"09",days:30},{name:"October",short_name:"Oct",numeric:"10",days:31},{name:"November",short_name:"Nov",numeric:"11",days:30},{name:"December",short_name:"Dec",numeric:"12",days:31}],cc_types:[{name:"American Express",short_name:"amex",prefix:"34",length:15},{name:"Bankcard",short_name:"bankcard",prefix:"5610",length:16},{name:"China UnionPay",short_name:"chinaunion",prefix:"62",length:16},{name:"Diners Club Carte Blanche",short_name:"dccarte",prefix:"300",length:14},{name:"Diners Club enRoute",short_name:"dcenroute",prefix:"2014",length:15},{name:"Diners Club International",short_name:"dcintl",prefix:"36",length:14},{name:"Diners Club United States & Canada",short_name:"dcusc",prefix:"54",length:16},{name:"Discover Card",short_name:"discover",prefix:"6011",length:16},{name:"InstaPayment",short_name:"instapay",prefix:"637",length:16},{name:"JCB",short_name:"jcb",prefix:"3528",length:16},{name:"Laser",short_name:"laser",prefix:"6304",length:16},{name:"Maestro",short_name:"maestro",prefix:"5018",length:16},{name:"Mastercard",short_name:"mc",prefix:"51",length:16},{name:"Solo",short_name:"solo",prefix:"6334",length:16},{name:"Switch",short_name:"switch",prefix:"4903",length:16},{name:"Visa",short_name:"visa",prefix:"4",length:16},{name:"Visa Electron",short_name:"electron",prefix:"4026",length:16}],currency_types:[{code:"AED",name:"United Arab Emirates Dirham"},{code:"AFN",name:"Afghanistan Afghani"},{code:"ALL",name:"Albania Lek"},{code:"AMD",name:"Armenia Dram"},{code:"ANG",name:"Netherlands Antilles Guilder"},{code:"AOA",name:"Angola Kwanza"},{code:"ARS",name:"Argentina Peso"},{code:"AUD",name:"Australia Dollar"},{code:"AWG",name:"Aruba Guilder"},{code:"AZN",name:"Azerbaijan New Manat"},{code:"BAM",name:"Bosnia and Herzegovina Convertible Marka"},{code:"BBD",name:"Barbados Dollar"},{code:"BDT",name:"Bangladesh Taka"},{code:"BGN",name:"Bulgaria Lev"},{code:"BHD",name:"Bahrain Dinar"},{code:"BIF",name:"Burundi Franc"},{code:"BMD",name:"Bermuda Dollar"},{code:"BND",name:"Brunei Darussalam Dollar"},{code:"BOB",name:"Bolivia Boliviano"},{code:"BRL",name:"Brazil Real"},{code:"BSD",name:"Bahamas Dollar"},{code:"BTN",name:"Bhutan Ngultrum"},{code:"BWP",name:"Botswana Pula"},{code:"BYR",name:"Belarus Ruble"},{code:"BZD",name:"Belize Dollar"},{code:"CAD",name:"Canada Dollar"},{code:"CDF",name:"Congo/Kinshasa Franc"},{code:"CHF",name:"Switzerland Franc"},{code:"CLP",name:"Chile Peso"},{code:"CNY",name:"China Yuan Renminbi"},{code:"COP",name:"Colombia Peso"},{code:"CRC",name:"Costa Rica Colon"},{code:"CUC",name:"Cuba Convertible Peso"},{code:"CUP",name:"Cuba Peso"},{code:"CVE",name:"Cape Verde Escudo"},{code:"CZK",name:"Czech Republic Koruna"},{code:"DJF",name:"Djibouti Franc"},{code:"DKK",name:"Denmark Krone"},{code:"DOP",name:"Dominican Republic Peso"},{code:"DZD",name:"Algeria Dinar"},{code:"EGP",name:"Egypt Pound"},{code:"ERN",name:"Eritrea Nakfa"},{code:"ETB",name:"Ethiopia Birr"},{code:"EUR",name:"Euro Member Countries"},{code:"FJD",name:"Fiji Dollar"},{code:"FKP",name:"Falkland Islands (Malvinas) Pound"},{code:"GBP",name:"United Kingdom Pound"},{code:"GEL",name:"Georgia Lari"},{code:"GGP",name:"Guernsey Pound"},{code:"GHS",name:"Ghana Cedi"},{code:"GIP",name:"Gibraltar Pound"},{code:"GMD",name:"Gambia Dalasi"},{code:"GNF",name:"Guinea Franc"},{code:"GTQ",name:"Guatemala Quetzal"},{code:"GYD",name:"Guyana Dollar"},{code:"HKD",name:"Hong Kong Dollar"},{code:"HNL",name:"Honduras Lempira"},{code:"HRK",name:"Croatia Kuna"},{code:"HTG",name:"Haiti Gourde"},{code:"HUF",name:"Hungary Forint"},{code:"IDR",name:"Indonesia Rupiah"},{code:"ILS",name:"Israel Shekel"},{code:"IMP",name:"Isle of Man Pound"},{code:"INR",name:"India Rupee"},{code:"IQD",name:"Iraq Dinar"},{code:"IRR",name:"Iran Rial"},{code:"ISK",name:"Iceland Krona"},{code:"JEP",name:"Jersey Pound"},{code:"JMD",name:"Jamaica Dollar"},{code:"JOD",name:"Jordan Dinar"},{code:"JPY",name:"Japan Yen"},{code:"KES",name:"Kenya Shilling"},{code:"KGS",name:"Kyrgyzstan Som"},{code:"KHR",name:"Cambodia Riel"},{code:"KMF",name:"Comoros Franc"},{code:"KPW",name:"Korea (North) Won"},{code:"KRW",name:"Korea (South) Won"},{code:"KWD",name:"Kuwait Dinar"},{code:"KYD",name:"Cayman Islands Dollar"},{code:"KZT",name:"Kazakhstan Tenge"},{code:"LAK",name:"Laos Kip"},{code:"LBP",name:"Lebanon Pound"},{code:"LKR",name:"Sri Lanka Rupee"},{code:"LRD",name:"Liberia Dollar"},{code:"LSL",name:"Lesotho Loti"},{code:"LTL",name:"Lithuania Litas"},{code:"LYD",name:"Libya Dinar"},{code:"MAD",name:"Morocco Dirham"},{code:"MDL",name:"Moldova Leu"},{code:"MGA",name:"Madagascar Ariary"},{code:"MKD",name:"Macedonia Denar"},{code:"MMK",name:"Myanmar (Burma) Kyat"},{code:"MNT",name:"Mongolia Tughrik"},{code:"MOP",name:"Macau Pataca"},{code:"MRO",name:"Mauritania Ouguiya"},{code:"MUR",name:"Mauritius Rupee"},{code:"MVR",name:"Maldives (Maldive Islands) Rufiyaa"},{code:"MWK",name:"Malawi Kwacha"},{code:"MXN",name:"Mexico Peso"},{code:"MYR",name:"Malaysia Ringgit"},{code:"MZN",name:"Mozambique Metical"},{code:"NAD",name:"Namibia Dollar"},{code:"NGN",name:"Nigeria Naira"},{code:"NIO",name:"Nicaragua Cordoba"},{code:"NOK",name:"Norway Krone"},{code:"NPR",name:"Nepal Rupee"},{code:"NZD",name:"New Zealand Dollar"},{code:"OMR",name:"Oman Rial"},{code:"PAB",name:"Panama Balboa"},{code:"PEN",name:"Peru Nuevo Sol"},{code:"PGK",name:"Papua New Guinea Kina"},{code:"PHP",name:"Philippines Peso"},{code:"PKR",name:"Pakistan Rupee"},{code:"PLN",name:"Poland Zloty"},{code:"PYG",name:"Paraguay Guarani"},{code:"QAR",name:"Qatar Riyal"},{code:"RON",name:"Romania New Leu"},{code:"RSD",name:"Serbia Dinar"},{code:"RUB",name:"Russia Ruble"},{code:"RWF",name:"Rwanda Franc"},{code:"SAR",name:"Saudi Arabia Riyal"},{code:"SBD",name:"Solomon Islands Dollar"},{code:"SCR",name:"Seychelles Rupee"},{code:"SDG",name:"Sudan Pound"},{code:"SEK",name:"Sweden Krona"},{code:"SGD",name:"Singapore Dollar"},{code:"SHP",name:"Saint Helena Pound"},{code:"SLL",name:"Sierra Leone Leone"},{code:"SOS",name:"Somalia Shilling"},{code:"SPL",name:"Seborga Luigino"},{code:"SRD",name:"Suriname Dollar"},{code:"STD",name:"São Tomé and Príncipe Dobra"},{code:"SVC",name:"El Salvador Colon"},{code:"SYP",name:"Syria Pound"},{code:"SZL",name:"Swaziland Lilangeni"},{code:"THB",name:"Thailand Baht"},{code:"TJS",name:"Tajikistan Somoni"},{code:"TMT",name:"Turkmenistan Manat"},{code:"TND",name:"Tunisia Dinar"},{code:"TOP",name:"Tonga Pa'anga"},{code:"TRY",name:"Turkey Lira"},{code:"TTD",name:"Trinidad and Tobago Dollar"},{code:"TVD",name:"Tuvalu Dollar"},{code:"TWD",name:"Taiwan New Dollar"},{code:"TZS",name:"Tanzania Shilling"},{code:"UAH",name:"Ukraine Hryvnia"},{code:"UGX",name:"Uganda Shilling"},{code:"USD",name:"United States Dollar"},{code:"UYU",name:"Uruguay Peso"},{code:"UZS",name:"Uzbekistan Som"},{code:"VEF",name:"Venezuela Bolivar"},{code:"VND",name:"Viet Nam Dong"},{code:"VUV",name:"Vanuatu Vatu"},{code:"WST",name:"Samoa Tala"},{code:"XAF",name:"Communauté Financière Africaine (BEAC) CFA Franc BEAC"},{code:"XCD",name:"East Caribbean Dollar"},{code:"XDR",name:"International Monetary Fund (IMF) Special Drawing Rights"},{code:"XOF",name:"Communauté Financière Africaine (BCEAO) Franc"},{code:"XPF",name:"Comptoirs Français du Pacifique (CFP) Franc"},{code:"YER",name:"Yemen Rial"},{code:"ZAR",name:"South Africa Rand"},{code:"ZMW",name:"Zambia Kwacha"},{code:"ZWD",name:"Zimbabwe Dollar"}]},q=Object.prototype.hasOwnProperty,r=Object.keys||function(a){var b=[]; 2 | for(var c in a)q.call(a,c)&&b.push(c);return b};a.prototype.get=function(a){return g(p[a])},a.prototype.mac_address=function(a){a=b(a),a.separator||(a.separator=a.networkVersion?".":":");var c="ABCDEF1234567890",d="";return d=a.networkVersion?this.n(this.string,3,{pool:c,length:4}).join(a.separator):this.n(this.string,6,{pool:c,length:2}).join(a.separator)},a.prototype.normal=function(a){a=b(a,{mean:0,dev:1});var c,d,e,f,g=a.mean,h=a.dev;do d=2*this.random()-1,e=2*this.random()-1,c=d*d+e*e;while(c>=1);return f=d*Math.sqrt(-2*Math.log(c)/c),h*f+g},a.prototype.radio=function(a){a=b(a,{side:"?"});var c="";switch(a.side.toLowerCase()){case"east":case"e":c="W";break;case"west":case"w":c="K";break;default:c=this.character({pool:"KW"})}return c+this.character({alpha:!0,casing:"upper"})+this.character({alpha:!0,casing:"upper"})+this.character({alpha:!0,casing:"upper"})},a.prototype.set=function(a,b){"string"==typeof a?p[a]=b:p=g(a,p)},a.prototype.tv=function(a){return this.radio(a)},a.prototype.cnpj=function(){var a=this.n(this.natural,8,{max:9}),b=2+6*a[7]+7*a[6]+8*a[5]+9*a[4]+2*a[3]+3*a[2]+4*a[1]+5*a[0];b=11-b%11,b>=10&&(b=0);var c=2*b+3+7*a[7]+8*a[6]+9*a[5]+2*a[4]+3*a[3]+4*a[2]+5*a[1]+6*a[0];return c=11-c%11,c>=10&&(c=0),""+a[0]+a[1]+"."+a[2]+a[3]+a[4]+"."+a[5]+a[6]+a[7]+"/0001-"+b+c},a.prototype.mersenne_twister=function(a){return new s(a)};var s=function(a){void 0===a&&(a=(new Date).getTime()),this.N=624,this.M=397,this.MATRIX_A=2567483615,this.UPPER_MASK=2147483648,this.LOWER_MASK=2147483647,this.mt=new Array(this.N),this.mti=this.N+1,this.init_genrand(a)};s.prototype.init_genrand=function(a){for(this.mt[0]=a>>>0,this.mti=1;this.mti>>30,this.mt[this.mti]=(1812433253*((4294901760&a)>>>16)<<16)+1812433253*(65535&a)+this.mti,this.mt[this.mti]>>>=0},s.prototype.init_by_array=function(a,b){var c,d,e=1,f=0;for(this.init_genrand(19650218),c=this.N>b?this.N:b;c;c--)d=this.mt[e-1]^this.mt[e-1]>>>30,this.mt[e]=(this.mt[e]^(1664525*((4294901760&d)>>>16)<<16)+1664525*(65535&d))+a[f]+f,this.mt[e]>>>=0,e++,f++,e>=this.N&&(this.mt[0]=this.mt[this.N-1],e=1),f>=b&&(f=0);for(c=this.N-1;c;c--)d=this.mt[e-1]^this.mt[e-1]>>>30,this.mt[e]=(this.mt[e]^(1566083941*((4294901760&d)>>>16)<<16)+1566083941*(65535&d))-e,this.mt[e]>>>=0,e++,e>=this.N&&(this.mt[0]=this.mt[this.N-1],e=1);this.mt[0]=2147483648},s.prototype.genrand_int32=function(){var a,b=new Array(0,this.MATRIX_A);if(this.mti>=this.N){var c;for(this.mti===this.N+1&&this.init_genrand(5489),c=0;c>>1^b[1&a];for(;c>>1^b[1&a];a=this.mt[this.N-1]&this.UPPER_MASK|this.mt[0]&this.LOWER_MASK,this.mt[this.N-1]=this.mt[this.M-1]^a>>>1^b[1&a],this.mti=0}return a=this.mt[this.mti++],a^=a>>>11,a^=a<<7&2636928640,a^=a<<15&4022730752,a^=a>>>18,a>>>0},s.prototype.genrand_int31=function(){return this.genrand_int32()>>>1},s.prototype.genrand_real1=function(){return this.genrand_int32()*(1/4294967295)},s.prototype.random=function(){return this.genrand_int32()*(1/4294967296)},s.prototype.genrand_real3=function(){return(this.genrand_int32()+.5)*(1/4294967296)},s.prototype.genrand_res53=function(){var a=this.genrand_int32()>>>5,b=this.genrand_int32()>>>6;return(67108864*a+b)*(1/9007199254740992)},"undefined"!=typeof exports&&("undefined"!=typeof module&&module.exports&&(exports=module.exports=a),exports.Chance=a),"function"==typeof define&&define.amd&&define([],function(){return a}),"undefined"!=typeof importScripts&&(chance=new a),"object"==typeof window&&"object"==typeof window.document&&(window.Chance=a,window.chance=new a)}(); -------------------------------------------------------------------------------- /floodit.pde: -------------------------------------------------------------------------------- 1 | color[] colors; // 1D array of 6 colors 2 | color[][] cArray; // 2D array of colors 3 | boolean[][] sArray; // 2D array of true/false switches 4 | // true/false stands for on/off 5 | int hp; // a variable to keep track of currency 6 | int fingerPress; // a variable to keep track of pressing animation 7 | int fingerOffset; // a variable to smooth things after cutscene 8 | int cutscene; // a variable to keep track of cutscene animations 9 | color lastColor; // color to display on cutscene 10 | int[] sShake; // screenshake on cutscene. [0] determines X direction, [1] determines X movement, [2] determines Y direction, [3] determines Y movement 11 | int gameState; // a variable to keep track of states. 0 = initial main menu, 1 = game, 2 = main menu 12 | int highScore; // we obtain this from a stored value with jStorage 13 | int score; 14 | int step; 15 | int doorMode; 16 | int tutLevel; 17 | 18 | ArrayList pcles; 19 | 20 | // Color assignments 21 | color C1 = color(255); 22 | color C2 = color(204); 23 | color C3 = color(153); 24 | color C4 = color(102); 25 | color C5 = color(51); 26 | color C6 = color(0); 27 | 28 | var bgm = new Howl({ 29 | urls: ['music/DarkMystery.mp3', 'music/DarkMystery.ogg'], 30 | loop: true, 31 | }); 32 | 33 | var blip = new Howl({ 34 | urls: ['music/sfx.mp3', 'music/sfx.ogg'], 35 | loop: false, 36 | }); 37 | 38 | var door = new Howl({ 39 | urls: ['music/door.mp3', 'music/door.ogg'], 40 | loop: false, 41 | }); 42 | 43 | color lastC2; 44 | 45 | // Checks whether a number is between a range to simplify code 46 | Number.prototype.between = function (min, max) { 47 | return this > min && this < max; 48 | }; 49 | 50 | void setup() { 51 | size(340, 420); 52 | bgm.play(); 53 | pcles = new ArrayList(); 54 | 55 | int b, i, j; 56 | color c; 57 | 58 | noCursor(); 59 | colors = {C1, C2, C3, C4, C5, C6}; 60 | cArray = new int[6][6]; 61 | sArray = new boolean[6][6]; 62 | sShake = new int[4]; 63 | } 64 | 65 | void mousePressed() { 66 | if (gameState == 0 || gameState == 2) { 67 | if (mouseX.between(130,205) && mouseY.between(185,215)){ 68 | switchMode(); 69 | for(i = 0; i < cArray.length; i++) { 70 | for(j = 0; j < cArray[i].length; j++) { 71 | b = int(random(6)); 72 | c = colors[b]; 73 | cArray[i][j] = c; 74 | sArray[i][j] = false; 75 | } 76 | } 77 | gameState = 1; 78 | score = 0; 79 | // set just the top left block to 'true' 80 | sArray[0][0] = true; 81 | } 82 | 83 | if (mouseX.between(130,205) && mouseY.between(255,285)){ 84 | C1 = color(255); 85 | C2 = color(204); 86 | C3 = color(153); 87 | C4 = color(102); 88 | C5 = color(51); 89 | for(i = 0; i < cArray.length; i++) { 90 | for(j = 0; j < cArray[i].length; j++) { 91 | b = int(random(6)); 92 | c = colors[b]; 93 | cArray[i][j] = c; 94 | sArray[i][j] = false; 95 | } 96 | } 97 | // set just the top left block to 'true' 98 | sArray[0][0] = true; 99 | tutLevel = 0; 100 | gameState = 3; 101 | } 102 | } 103 | if (gameState == 3) { 104 | if (mouseX.between(130,205) && mouseY.between(375,450) && tutLevel == 1){gameState = 0;} 105 | fingerPress = 30; 106 | blip.play(); 107 | if (tutLevel == 0 && mouseX.between(95,245) && mouseY.between(95,245)) { 108 | color c, f; 109 | 110 | f = get(mouseX, mouseY); 111 | 112 | int xpos = 0; 113 | int ypos = 0; 114 | int target = cArray[0][0]; 115 | 116 | cArray[0][0] = f; 117 | // always set the top left box to the new color c 118 | sArray[0][0] = true; 119 | // Boolean flag of top left box is always true 120 | // in other words, it's the root of the tree 121 | 122 | 123 | /* Here we are looping through the 2-dimensional array of color values 124 | called cArray */ 125 | for(xpos = 0; xpos < cArray.length; xpos++) { 126 | for(ypos = 0; ypos < cArray.length; ypos++) { 127 | /* If we are at cArray[0][0] (top left square, don't do anything 128 | because sArray, the corresponding array of booleans, is already 129 | true at this index from initialization */ 130 | if ((xpos == 0) && (ypos == 0)) { 131 | } 132 | /* Now check to see if the color value at the current index does NOT 133 | match the value of target and if so don't do anything */ 134 | else if(cArray[xpos][ypos] != target) { 135 | } 136 | /* If color value at index DOES match target (fallthrough condition from 137 | conditional above, run CheckNeighbor function below. If CheckNeighbor 138 | evaluates to true, update the cell to the current color f (the color 139 | that was clicked on) and it's boolean value to true. */ 140 | else if(checkNeighbor(xpos, ypos) == true) { 141 | cArray[xpos][ypos] = f; 142 | sArray[xpos][ypos] = true; 143 | } 144 | } 145 | } 146 | } 147 | } 148 | if (gameState == 1) { 149 | blip.play(); 150 | fingerPress = 30; 151 | if (dist(mouseX,mouseY,53,395) < 40) { 152 | step += round(hp/2); 153 | hp = 0; 154 | } 155 | if (cutscene >= 0 && mouseX.between(95,245) && mouseY.between(95,245)) { 156 | color c, f; 157 | 158 | f = get(mouseX, mouseY); 159 | 160 | if ((doorMode == 0 || doorMode == 1) && f != cArray[0][0]) {step -= 1;} 161 | 162 | int xpos = 0; 163 | int ypos = 0; 164 | int target = cArray[0][0]; 165 | 166 | cArray[0][0] = f; 167 | // always set the top left box to the new color c 168 | sArray[0][0] = true; 169 | // Boolean flag of top left box is always true 170 | // in other words, it's the root of the tree 171 | 172 | 173 | /* Here we are looping through the 2-dimensional array of color values 174 | called cArray */ 175 | for(xpos = 0; xpos < cArray.length; xpos++) { 176 | for(ypos = 0; ypos < cArray.length; ypos++) { 177 | /* If we are at cArray[0][0] (top left square, don't do anything 178 | because sArray, the corresponding array of booleans, is already 179 | true at this index from initialization */ 180 | if ((xpos == 0) && (ypos == 0)) { 181 | } 182 | /* Now check to see if the color value at the current index does NOT 183 | match the value of target and if so don't do anything */ 184 | else if(cArray[xpos][ypos] != target) { 185 | } 186 | /* If color value at index DOES match target (fallthrough condition from 187 | conditional above, run CheckNeighbor function below. If CheckNeighbor 188 | evaluates to true, update the cell to the current color f (the color 189 | that was clicked on) and it's boolean value to true. */ 190 | else if(checkNeighbor(xpos, ypos) == true) { 191 | cArray[xpos][ypos] = f; 192 | sArray[xpos][ypos] = true; 193 | } 194 | } 195 | } 196 | } 197 | } 198 | } 199 | 200 | /* CheckkNeighbor checks to see if any of a cell's 4 adjacent neighbors have 201 | a value of true. A neighbor must have a value of true for the cell to change 202 | color, since the color must be connected to the tree of cells that are connected 203 | to the root (the upper left cell). */ 204 | boolean checkNeighbor(xpos, ypos) { 205 | if( (xpos > 0) && (sArray[xpos - 1][ypos]) == true) { 206 | return true; 207 | } 208 | if( (ypos > 0) && (sArray[xpos][ypos - 1]) == true ) { 209 | return true; 210 | } 211 | if( (xpos < sArray.length - 1) && (sArray[xpos + 1][ypos] == true) ) { 212 | return true; 213 | } 214 | if( (ypos < sArray.length - 1) && (sArray[xpos][ypos + 1] == true) ) { 215 | return true; 216 | } 217 | } 218 | 219 | void draw() { 220 | highScore = $.jStorage.get("fgHighScore", 0); 221 | 222 | textSize(14); 223 | 224 | if (gameState == 3) { 225 | background(225); 226 | if (tutLevel == 0) { 227 | fill(30); 228 | textSize(35); 229 | text("Floodgate Dungeon",15,30); 230 | textSize(20); 231 | text("How To Play",115,60); 232 | textSize(15); 233 | text("Click on a block.",115,270); 234 | text("The top-left block with change into that color.",20,300); 235 | text("All blocks connected to the top-left block will",20,315); 236 | text("also change to that color.",85,330); 237 | text("Turn all blocks to the same color to proceed.",20,345); 238 | strokeWeight(1); 239 | fill(0); 240 | stroke(0); 241 | rect(90,90,160,160); 242 | for(i = 0; i < cArray.length; i++) { 243 | for(j = 0; j < cArray[i].length; j++) { 244 | n = cArray[i][j]; 245 | c = colors[n]; 246 | stroke(n); 247 | fill(n); 248 | rect(i*25+95, j*25+95, 25, 25); 249 | } 250 | } 251 | int helpAllCheck = 0; 252 | for(i = 0; i < cArray.length; i++) { 253 | for(j = 0; j < cArray[i].length; j++) { 254 | if (cArray[i][j] == cArray[0][0]) { 255 | helpAllCheck += 1; 256 | } 257 | } 258 | } 259 | if (helpAllCheck >= 36) { 260 | tutLevel = 1; 261 | } 262 | } 263 | 264 | if (tutLevel == 1) { 265 | fill(30); 266 | textSize(35); 267 | text("Floodgate Dungeon",15,30); 268 | textSize(20); 269 | text("How To Play",115,60); 270 | textSize(15); 271 | text("Not bad!",145,85); 272 | text("Note that most doors have limited steps.",30,100); 273 | text("Red doors has seconds before it explodes.",20,115); 274 | text("Notice a device on your left hand.",55,160); 275 | text("When you have excess steps it is turned",30,175); 276 | text("into H4POINTS. H4POINTS can be used to",20,190); 277 | text("add steps or time to unlock the door.",40,205); 278 | text("press the circular button to use it.",50,220); 279 | text("Yellow doors give x2 H4POINTS!",50,235); 280 | fill(225); 281 | translate(80,430 + fingerOffset); 282 | strokeWeight(30); 283 | stroke(150); 284 | line(-100,-140,0,-150); 285 | line(0,-95,30,-100); 286 | stroke(0); 287 | strokeWeight(5); 288 | rotate(10/57.3); 289 | rect(0,0,-100,-130); 290 | stroke(30); 291 | fill(30); 292 | strokeWeight(1); 293 | beginShape(); 294 | vertex(150,0); 295 | vertex(170,-20); 296 | vertex(170,-20); 297 | vertex(150,0); 298 | endShape(); 299 | textSize(14); 300 | text("H4CK 0.95.1", -90,-110); 301 | textSize(13); 302 | text(hp + " H4P01NTS", -90,-70); 303 | fill(225); 304 | ellipse(-50,-25,40,40); 305 | textSize(13); 306 | fill(30); 307 | text("+ " + round(hp/2), -60,-22); 308 | rotate(-10/57.3); 309 | strokeWeight(30); 310 | stroke(150); 311 | line(30,-100,30,-100); 312 | line(30,-70,15,-60); 313 | translate(-80,-430 - fingerOffset); 314 | strokeWeight(1); 315 | fill(30); 316 | textSize(30); 317 | text("Done",132,400); 318 | fill(0,0); 319 | rect(130,375,75,30); 320 | } 321 | finger(); 322 | } 323 | 324 | if (gameState == 0 || gameState == 2) { 325 | background(225); 326 | fill(30); 327 | textSize(30); 328 | text("Start",135,210); 329 | text("Help",136,280); 330 | textSize(35); 331 | text("Floodgate Dungeon",15,150); 332 | strokeWeight(1); 333 | fill(0,0); 334 | rect(130,185,75,30); 335 | rect(130,255,75,30); 336 | fill(30); 337 | textSize(20); 338 | text("High score: " + highScore,110,390); 339 | finger(); 340 | } 341 | 342 | if (gameState == 2) { 343 | fill(30); 344 | textSize(20); 345 | text("Score: " + score,140,370); 346 | } 347 | 348 | if (gameState == 1) { 349 | textSize(14); 350 | background(C2); 351 | if (cutscene > 0) { 352 | cutsceneAnim(); 353 | cutscene -= 1; 354 | } else { 355 | stroke(30); 356 | strokeWeight(1); 357 | fill(30); 358 | if (doorMode == 2) { 359 | step -= 1/60; 360 | } 361 | if (fingerOffset > 0) {fingerOffset -= (500/60)}; 362 | if (fingerOffset < 0) {fingerOffset = 0}; 363 | rect(90,90,160,160); 364 | rect(165,0,10,400); 365 | rect(0,395,340,10); 366 | rect(100,60,140,30); 367 | fill(C1); 368 | rect(105,65,130,20); 369 | fill(30); 370 | text(round(step),165,82); 371 | for(i = 0; i < cArray.length; i++) { 372 | for(j = 0; j < cArray[i].length; j++) { 373 | n = cArray[i][j]; 374 | c = colors[n]; 375 | stroke(n); 376 | fill(n); 377 | rect(i*25+95, j*25+95, 25, 25); 378 | } 379 | } 380 | } 381 | fill(225); 382 | translate(80,430 + fingerOffset); 383 | strokeWeight(30); 384 | stroke(150); 385 | line(-100,-140,0,-150); 386 | line(0,-95,30,-100); 387 | stroke(0); 388 | strokeWeight(5); 389 | rotate(10/57.3); 390 | rect(0,0,-100,-130); 391 | stroke(30); 392 | fill(30); 393 | strokeWeight(1); 394 | beginShape(); 395 | vertex(150,0); 396 | vertex(170,-20); 397 | vertex(170,-20); 398 | vertex(150,0); 399 | endShape(); 400 | textSize(14); 401 | text("H4CK 0.95.1", -90,-110); 402 | textSize(13); 403 | text(hp + " H4P01NTS", -90,-70); 404 | fill(225); 405 | ellipse(-50,-25,40,40); 406 | textSize(13); 407 | fill(30); 408 | text("+ " + round(hp/2), -60,-22); 409 | rotate(-10/57.3); 410 | strokeWeight(30); 411 | stroke(150); 412 | line(30,-100,30,-100); 413 | line(30,-70,15,-60); 414 | translate(-80,-430 - fingerOffset); 415 | strokeWeight(1); 416 | finger(); 417 | checkEndGame(); 418 | 419 | for (int i=pcles.size()-1; i>=0; i--) { 420 | Particle p = (Pcle) pcles.get(i); 421 | p.update(); 422 | if (p.fa < 0) {pcles.remove(i);} 423 | } 424 | //text(mouseX + "," + mouseY,mouseX,mouseY); 425 | } 426 | 427 | } 428 | 429 | void checkEndGame() { 430 | int allCheck = 0; 431 | for(i = 0; i < cArray.length; i++) { 432 | for(j = 0; j < cArray[i].length; j++) { 433 | if (cArray[i][j] == cArray[0][0]) { 434 | allCheck += 1; 435 | } 436 | } 437 | } 438 | if (allCheck >= 36) { 439 | if (doorMode == 1) {hp += round(step*2);} else {hp += round(step);} 440 | lastColor = cArray[0][0]; 441 | score += 1; 442 | cutscene = 300; 443 | door.play(); 444 | sShake[0] = 0; 445 | sShake[1] = 0; 446 | sShake[2] = 0; 447 | sShake[3] = 0; 448 | switchMode(); 449 | for(i = 0; i < cArray.length; i++) { 450 | for(j = 0; j < cArray[i].length; j++) { 451 | b = int(random(6)); 452 | c = colors[b]; 453 | cArray[i][j] = c; 454 | sArray[i][j] = false; 455 | } 456 | } 457 | sArray[0][0] = true; 458 | } 459 | if(step <= 0 && allCheck < 36) { 460 | score += hp; 461 | hp = 0; 462 | if (score > highScore) {$.jStorage.set("fgHighScore", score);} 463 | gameState = 2; 464 | } 465 | } 466 | 467 | void switchMode() { 468 | lastC2 = C2; 469 | doorMode = chance.pick([0,1,2]); 470 | C6 = color(0); 471 | switch(doorMode) { 472 | case 0: 473 | step = round(random(14,19)); 474 | C1 = color(255); 475 | C2 = color(204); 476 | C3 = color(153); 477 | C4 = color(102); 478 | C5 = color(51); 479 | break; 480 | 481 | case 1: 482 | step = round(random(16,21)); 483 | C1 = color(255,255,0); 484 | C2 = color(204,204,0); 485 | C3 = color(153,153,0); 486 | C4 = color(102,102,0); 487 | C5 = color(51,51,0); 488 | break; 489 | 490 | case 2: 491 | step = round(random(10,15)); 492 | C1 = color(255,0,0); 493 | C2 = color(204,0,0); 494 | C3 = color(153,0,0); 495 | C4 = color(102,0,0); 496 | C5 = color(51,0,0); 497 | break; 498 | } 499 | colors = {C1, C2, C3, C4, C5, C6}; 500 | } 501 | 502 | void finger() { 503 | if (fingerPress > 0) {fingerPress -= 1}; 504 | if (fingerPress < 0) {fingerPress = 0}; 505 | fill(150); 506 | stroke(150); 507 | ellipse(mouseX+30 - (fingerPress - fingerOffset),mouseY+30 - (fingerPress - fingerOffset),30,30); 508 | ellipse(mouseX+92- (fingerPress - fingerOffset),mouseY+95- (fingerPress - fingerOffset),30,30); 509 | ellipse(mouseX+112- (fingerPress - fingerOffset),mouseY+86- (fingerPress - fingerOffset),30,30); 510 | ellipse(mouseX+132- (fingerPress - fingerOffset),mouseY+85- (fingerPress - fingerOffset),30,30); 511 | translate(mouseX+39- (fingerPress - fingerOffset),mouseY+79- (fingerPress - fingerOffset)); 512 | rotate(1.1); 513 | rect(-50,-30,100,30); 514 | rect(49,0,550,-100); 515 | fill(0); 516 | stroke(0); 517 | rect(49,5,100,-110); 518 | fill(150); 519 | stroke(150); 520 | // rect(49,0,50,-100); 521 | rotate(-1.1); 522 | translate(0 - (mouseX+57- (fingerPress - fingerOffset)),0 - (mouseY+79- (fingerPress - fingerOffset))); 523 | } 524 | 525 | void cutsceneAnim() { 526 | if (cutscene > 200) { 527 | strokeWeight(1); 528 | fill(C2); 529 | stroke(30); 530 | fingerOffset += 5; 531 | 532 | beginShape(); 533 | vertex(0,380); 534 | vertex(130,200); 535 | vertex(210,200); 536 | vertex(340,380); 537 | vertex(0,380); 538 | endShape(); 539 | 540 | beginShape(); 541 | vertex(0,0); 542 | vertex(130,100); 543 | vertex(210,100); 544 | vertex(340,0); 545 | vertex(0,0); 546 | endShape(); 547 | 548 | line(130,200,130,100); 549 | line(210,200,210,100); 550 | line(170,200,170,100); 551 | 552 | fill(lastC2); 553 | stroke(lastC2); 554 | rect(0,381,340,100); 555 | stroke(30); 556 | 557 | fill(lastC2); 558 | rect(0,0 - (300 - cutscene)*4,340,400); 559 | fill(30); 560 | rect(90,90 - (300 - cutscene)*4,160,160); 561 | rect(0,395 - (300 - cutscene)*4,340,10); 562 | fill(lastColor); 563 | rect(95,95 - (300 - cutscene)*4,150,150); 564 | 565 | strokeWeight(15); 566 | stroke(0); 567 | line(138,179 - (300 - cutscene)*4,170,200 - (300 - cutscene)*4); 568 | line(170,200 - (300 - cutscene)*4,200,135 - (300 - cutscene)*4); 569 | 570 | strokeWeight(13); 571 | stroke(255); 572 | line(138,179 - (300 - cutscene)*4,170,200 - (300 - cutscene)*4); 573 | line(170,200 - (300 - cutscene)*4,200,135 - (300 - cutscene)*4); 574 | } 575 | 576 | if (cutscene <= 200) { 577 | 578 | if (sShake[0] == 0) {sShake[1] -= 0.9}; 579 | if (sShake[1] < -11.1 && sShake[0] == 0) {sShake[0] = 1}; 580 | if (sShake[0] == 1) {sShake[1] += 0.9}; 581 | if (sShake[1] > 11.1 && sShake[0] == 1) {sShake[0] = 0}; 582 | 583 | if (sShake[2] == 0) {sShake[3] -= 1}; 584 | if (sShake[3] <= 0 && sShake[2] == 0) {sShake[2] = 1}; 585 | if (sShake[2] == 1) {sShake[3] += 1}; 586 | if (sShake[3] > 11 && sShake[2] == 1) {sShake[2] = 0}; 587 | 588 | fill(C2); 589 | stroke(30); 590 | strokeWeight(10 - 9*(cutscene/200)); 591 | 592 | beginShape(); 593 | vertex(0 - (200 - cutscene) + sShake[1],380 + (200 - cutscene) + sShake[3]); 594 | vertex(130 - (200 - cutscene) + sShake[1],200 + (200 - cutscene) + sShake[3]); 595 | vertex(210 + (200 - cutscene) + sShake[1],200 + (200 - cutscene) + sShake[3]); 596 | vertex(340 + (200 - cutscene) + sShake[1],380 + (200 - cutscene) + sShake[3]); 597 | vertex(0 - (200 - cutscene) + sShake[1],380 + (200 - cutscene) + sShake[3]); 598 | endShape(); 599 | 600 | beginShape(); 601 | vertex(0 - (200 - cutscene) + sShake[1],0 - (200 - cutscene) + sShake[3]); 602 | vertex(130 - (200 - cutscene) + sShake[1],100 - (200 - cutscene) + sShake[3]); 603 | vertex(210 + (200 - cutscene) + sShake[1],100 - (200 - cutscene) + sShake[3]); 604 | vertex(340 + (200 - cutscene) + sShake[1],0 - (200 - cutscene) + sShake[3]); 605 | vertex(0 - (200 - cutscene) + sShake[1],0 - (200 - cutscene) + sShake[3]); 606 | endShape(); 607 | 608 | fill(lastC2); 609 | stroke(lastC2); 610 | rect(0,381 + (200 - cutscene) + sShake[3],340,100); 611 | stroke(30); 612 | 613 | line(130 - (200 - cutscene) + sShake[1],200 + (200 - cutscene) + sShake[3],130 - (200 - cutscene) + sShake[1],100 - (200 - cutscene) + sShake[3]); 614 | line(210 + (200 - cutscene) + sShake[1],200 + (200 - cutscene) + sShake[3],210 + (200 - cutscene) + sShake[1],100 - (200 - cutscene) + sShake[3]); 615 | line(170 + sShake[1],200 + (200 - cutscene) + sShake[3],170 + sShake[1],100 - (200 - cutscene) + sShake[3]); 616 | 617 | strokeWeight(1); 618 | fill(30); 619 | rect(90 + 80*(cutscene/200) + sShake[1],90 + 80*(cutscene/200) + sShake[3],160 - 160*(cutscene/200),160 - 160*(cutscene/200)); 620 | rect(100 + 70*(cutscene/200) + sShake[1],60 + 110*(cutscene/200) + sShake[3],140 - 140*(cutscene/200),30 - 30*(cutscene/200)); 621 | fill(C1); 622 | rect(105 + 65*(cutscene/200) + sShake[1],65 + 105*(cutscene/200) + sShake[3],130 - 130*(cutscene/200),20 - 20*(cutscene/200)); 623 | textSize(14 - 13*(cutscene/200)); 624 | fill(30); 625 | text(round(step),165 + 5*(cutscene/200) + sShake[1],82 + 88*(cutscene/200) + sShake[3]); 626 | textSize(14); 627 | 628 | for(i = 0; i < cArray.length; i++) { 629 | for(j = 0; j < cArray[i].length; j++) { 630 | n = cArray[i][j]; 631 | c = colors[n]; 632 | stroke(n); 633 | fill(n); 634 | rect(i*(25 - 25*(cutscene/200))+(95 + 75*(cutscene/200)) + sShake[1], j*(25 - 25*(cutscene/200))+(95 + 75*(cutscene/200)) + sShake[3], 25 - 25*(cutscene/200), 25 - 25*(cutscene/200)); 635 | } 636 | } 637 | } 638 | } 639 | 640 | class Pcle { 641 | float x; 642 | float y; 643 | float vx; 644 | float vy; 645 | float r; 646 | float g; 647 | float b; 648 | float s; 649 | float a; 650 | float fa; 651 | 652 | Pcle(ox,oy,or,og,ob,oa,os) { 653 | x = ox; 654 | y = oy; 655 | r = or; 656 | g = og; 657 | b = ob; 658 | a = oa; 659 | s = os; 660 | } 661 | 662 | void update() { 663 | fa = a*((x - 250)/170); 664 | stroke(r,g,b,fa/2); 665 | fill(r,g,b,fa); 666 | rect(x - s/2,y - s/2,s,s); 667 | vx += random(-1,1); 668 | vy -= 0.1; 669 | x += vx; 670 | y += vy; 671 | } 672 | } 673 | -------------------------------------------------------------------------------- /howler.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * howler.js v1.1.25 3 | * howlerjs.com 4 | * 5 | * (c) 2013-2014, James Simpson of GoldFire Studios 6 | * goldfirestudios.com 7 | * 8 | * MIT License 9 | */ 10 | !function(){var e={},t=null,n=!0,r=!1;try{"undefined"!=typeof AudioContext?t=new AudioContext:"undefined"!=typeof webkitAudioContext?t=new webkitAudioContext:n=!1}catch(i){n=!1}if(!n)if("undefined"!=typeof Audio)try{new Audio}catch(i){r=!0}else r=!0;if(n){var s=void 0===t.createGain?t.createGainNode():t.createGain();s.gain.value=1,s.connect(t.destination)}var o=function(e){this._volume=1,this._muted=!1,this.usingWebAudio=n,this.ctx=t,this.noAudio=r,this._howls=[],this._codecs=e,this.iOSAutoEnable=!0};o.prototype={volume:function(e){var t=this;if(e=parseFloat(e),e>=0&&1>=e){t._volume=e,n&&(s.gain.value=e);for(var r in t._howls)if(t._howls.hasOwnProperty(r)&&t._howls[r]._webAudio===!1)for(var i=0;i0?i._pos:r._sprite[e][0]/1e3,o=0;r._webAudio?(o=r._sprite[e][1]/1e3-i._pos,i._pos>0&&(s=r._sprite[e][0]/1e3+s)):o=r._sprite[e][1]/1e3-(s-r._sprite[e][0]/1e3);var u,a=!(!r._loop&&!r._sprite[e][2]),l="string"==typeof n?n:Math.round(Date.now()*Math.random())+"";if(function(){var t={id:l,sprite:e,loop:a};u=setTimeout(function(){!r._webAudio&&a&&r.stop(t.id).play(e,t.id),r._webAudio&&!a&&(r._nodeById(t.id).paused=!0,r._nodeById(t.id)._pos=0,r._clearEndTimer(t.id)),r._webAudio||a||r.stop(t.id),r.on("end",l)},1e3*o),r._onendTimer.push({timer:u,id:t.id})}(),r._webAudio){var c=r._sprite[e][0]/1e3,h=r._sprite[e][1]/1e3;i.id=l,i.paused=!1,d(r,[a,c,h],l),r._playStart=t.currentTime,i.gain.value=r._volume,void 0===i.bufferSource.start?i.bufferSource.noteGrainOn(0,s,o):i.bufferSource.start(0,s,o)}else{if(4!==i.readyState&&(i.readyState||!navigator.isCocoonJS))return r._clearEndTimer(l),function(){var t=r,s=e,o=n,u=i,a=function(){t.play(s,o),u.removeEventListener("canplaythrough",a,!1)};u.addEventListener("canplaythrough",a,!1)}(),r;i.readyState=4,i.id=l,i.currentTime=s,i.muted=f._muted||i.muted,i.volume=r._volume*f.volume(),setTimeout(function(){i.play()},0)}return r.on("play"),"function"==typeof n&&n(l),r}),r):("function"==typeof n&&n(),r):(r.on("load",function(){r.play(e,n)}),r)},pause:function(e){var t=this;if(!t._loaded)return t.on("play",function(){t.pause(e)}),t;t._clearEndTimer(e);var n=e?t._nodeById(e):t._activeNode();if(n)if(n._pos=t.pos(null,e),t._webAudio){if(!n.bufferSource||n.paused)return t;n.paused=!0,void 0===n.bufferSource.stop?n.bufferSource.noteOff(0):n.bufferSource.stop(0)}else n.pause();return t.on("pause"),t},stop:function(e){var t=this;if(!t._loaded)return t.on("play",function(){t.stop(e)}),t;t._clearEndTimer(e);var n=e?t._nodeById(e):t._activeNode();if(n)if(n._pos=0,t._webAudio){if(!n.bufferSource||n.paused)return t;n.paused=!0,void 0===n.bufferSource.stop?n.bufferSource.noteOff(0):n.bufferSource.stop(0)}else isNaN(n.duration)||(n.pause(),n.currentTime=0);return t},mute:function(e){var t=this;if(!t._loaded)return t.on("play",function(){t.mute(e)}),t;var n=e?t._nodeById(e):t._activeNode();return n&&(t._webAudio?n.gain.value=0:n.muted=!0),t},unmute:function(e){var t=this;if(!t._loaded)return t.on("play",function(){t.unmute(e)}),t;var n=e?t._nodeById(e):t._activeNode();return n&&(t._webAudio?n.gain.value=t._volume:n.muted=!1),t},volume:function(e,t){var n=this;if(e=parseFloat(e),e>=0&&1>=e){if(n._volume=e,!n._loaded)return n.on("play",function(){n.volume(e,t)}),n;var r=t?n._nodeById(t):n._activeNode();return r&&(n._webAudio?r.gain.value=e:r.volume=e*f.volume()),n}return n._volume},loop:function(e){var t=this;return"boolean"==typeof e?(t._loop=e,t):t._loop},sprite:function(e){var t=this;return"object"==typeof e?(t._sprite=e,t):t._sprite},pos:function(e,n){var r=this;if(!r._loaded)return r.on("load",function(){r.pos(e)}),"number"==typeof e?r:r._pos||0;e=parseFloat(e);var i=n?r._nodeById(n):r._activeNode();if(i)return e>=0?(r.pause(n),i._pos=e,r.play(i._sprite,n),r):r._webAudio?i._pos+(t.currentTime-r._playStart):i.currentTime;if(e>=0)return r;for(var s=0;s=0||0>e))return i._pos3d;if(i._webAudio){var s=r?i._nodeById(r):i._activeNode();s&&(i._pos3d=[e,t,n],s.panner.setPosition(e,t,n),s.panner.panningModel=i._model||"HRTF")}return i},fade:function(e,t,n,r,i){var s=this,o=Math.abs(e-t),u=e>t?"down":"up",a=o/.01,f=n/a;if(!s._loaded)return s.on("load",function(){s.fade(e,t,n,r,i)}),s;s.volume(e,i);for(var l=1;a>=l;l++)!function(){var e=s._volume+("up"===u?.01:-.01)*l,n=Math.round(1e3*e)/1e3,o=t;setTimeout(function(){s.volume(n,i),n===o&&r&&r()},f*l)}()},fadeIn:function(e,t,n){return this.volume(0).play().fade(0,e,t,n)},fadeOut:function(e,t,n,r){var i=this;return i.fade(i._volume,e,t,function(){n&&n(),i.pause(r),i.on("end")},r)},_nodeById:function(e){for(var t=this,n=t._audioNode[0],r=0;r=0&&!(5>=n);e--)t._audioNode[e].paused&&(t._webAudio&&t._audioNode[e].disconnect(0),n--,t._audioNode.splice(e,1))},_clearEndTimer:function(e){for(var t=this,n=0,r=0;r=0&&f._howls.splice(i,1),delete e[t._src],t=null}},n)var c=function(t,n){if(n in e)return t._duration=e[n].duration,void p(t);if(/^data:[^;]+;base64,/.test(n)){for(var r=atob(n.split(",")[1]),i=new Uint8Array(r.length),s=0;s 2 | 3 | 4 | Floodgate - #GGO15 5 | 6 | 7 | 15 | 46 | 49 | 50 | 51 | 52 | 53 | 54 | 58 | 59 | 60 | 61 |
62 |
63 | 65 |

Your browser does not support the canvas tag.

66 | 67 |
68 | 71 |
72 |

Floodgate for #GGO15

73 |

by AkirAssasin

74 |

Original Code by Chris Ochsenreither

75 |

76 |

Source code: floodit

77 |

78 | Built with Processing.js 79 |

80 |
81 | 82 | 83 | -------------------------------------------------------------------------------- /json2.js: -------------------------------------------------------------------------------- 1 | /* 2 | http://www.JSON.org/json2.js 3 | 2011-02-23 4 | 5 | Public Domain. 6 | 7 | NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. 8 | 9 | See http://www.JSON.org/js.html 10 | 11 | 12 | This code should be minified before deployment. 13 | See http://javascript.crockford.com/jsmin.html 14 | 15 | USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO 16 | NOT CONTROL. 17 | 18 | 19 | This file creates a global JSON object containing two methods: stringify 20 | and parse. 21 | 22 | JSON.stringify(value, replacer, space) 23 | value any JavaScript value, usually an object or array. 24 | 25 | replacer an optional parameter that determines how object 26 | values are stringified for objects. It can be a 27 | function or an array of strings. 28 | 29 | space an optional parameter that specifies the indentation 30 | of nested structures. If it is omitted, the text will 31 | be packed without extra whitespace. If it is a number, 32 | it will specify the number of spaces to indent at each 33 | level. If it is a string (such as '\t' or ' '), 34 | it contains the characters used to indent at each level. 35 | 36 | This method produces a JSON text from a JavaScript value. 37 | 38 | When an object value is found, if the object contains a toJSON 39 | method, its toJSON method will be called and the result will be 40 | stringified. A toJSON method does not serialize: it returns the 41 | value represented by the name/value pair that should be serialized, 42 | or undefined if nothing should be serialized. The toJSON method 43 | will be passed the key associated with the value, and this will be 44 | bound to the value 45 | 46 | For example, this would serialize Dates as ISO strings. 47 | 48 | Date.prototype.toJSON = function (key) { 49 | function f(n) { 50 | // Format integers to have at least two digits. 51 | return n < 10 ? '0' + n : n; 52 | } 53 | 54 | return this.getUTCFullYear() + '-' + 55 | f(this.getUTCMonth() + 1) + '-' + 56 | f(this.getUTCDate()) + 'T' + 57 | f(this.getUTCHours()) + ':' + 58 | f(this.getUTCMinutes()) + ':' + 59 | f(this.getUTCSeconds()) + 'Z'; 60 | }; 61 | 62 | You can provide an optional replacer method. It will be passed the 63 | key and value of each member, with this bound to the containing 64 | object. The value that is returned from your method will be 65 | serialized. If your method returns undefined, then the member will 66 | be excluded from the serialization. 67 | 68 | If the replacer parameter is an array of strings, then it will be 69 | used to select the members to be serialized. It filters the results 70 | such that only members with keys listed in the replacer array are 71 | stringified. 72 | 73 | Values that do not have JSON representations, such as undefined or 74 | functions, will not be serialized. Such values in objects will be 75 | dropped; in arrays they will be replaced with null. You can use 76 | a replacer function to replace those with JSON values. 77 | JSON.stringify(undefined) returns undefined. 78 | 79 | The optional space parameter produces a stringification of the 80 | value that is filled with line breaks and indentation to make it 81 | easier to read. 82 | 83 | If the space parameter is a non-empty string, then that string will 84 | be used for indentation. If the space parameter is a number, then 85 | the indentation will be that many spaces. 86 | 87 | Example: 88 | 89 | text = JSON.stringify(['e', {pluribus: 'unum'}]); 90 | // text is '["e",{"pluribus":"unum"}]' 91 | 92 | 93 | text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); 94 | // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' 95 | 96 | text = JSON.stringify([new Date()], function (key, value) { 97 | return this[key] instanceof Date ? 98 | 'Date(' + this[key] + ')' : value; 99 | }); 100 | // text is '["Date(---current time---)"]' 101 | 102 | 103 | JSON.parse(text, reviver) 104 | This method parses a JSON text to produce an object or array. 105 | It can throw a SyntaxError exception. 106 | 107 | The optional reviver parameter is a function that can filter and 108 | transform the results. It receives each of the keys and values, 109 | and its return value is used instead of the original value. 110 | If it returns what it received, then the structure is not modified. 111 | If it returns undefined then the member is deleted. 112 | 113 | Example: 114 | 115 | // Parse the text. Values that look like ISO date strings will 116 | // be converted to Date objects. 117 | 118 | myData = JSON.parse(text, function (key, value) { 119 | var a; 120 | if (typeof value === 'string') { 121 | a = 122 | /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); 123 | if (a) { 124 | return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], 125 | +a[5], +a[6])); 126 | } 127 | } 128 | return value; 129 | }); 130 | 131 | myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { 132 | var d; 133 | if (typeof value === 'string' && 134 | value.slice(0, 5) === 'Date(' && 135 | value.slice(-1) === ')') { 136 | d = new Date(value.slice(5, -1)); 137 | if (d) { 138 | return d; 139 | } 140 | } 141 | return value; 142 | }); 143 | 144 | 145 | This is a reference implementation. You are free to copy, modify, or 146 | redistribute. 147 | */ 148 | 149 | /*jslint evil: true, strict: false, regexp: false */ 150 | 151 | /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply, 152 | call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, 153 | getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, 154 | lastIndex, length, parse, prototype, push, replace, slice, stringify, 155 | test, toJSON, toString, valueOf 156 | */ 157 | 158 | 159 | // Create a JSON object only if one does not already exist. We create the 160 | // methods in a closure to avoid creating global variables. 161 | 162 | var JSON; 163 | if (!JSON) { 164 | JSON = {}; 165 | } 166 | 167 | (function () { 168 | "use strict"; 169 | 170 | function f(n) { 171 | // Format integers to have at least two digits. 172 | return n < 10 ? '0' + n : n; 173 | } 174 | 175 | if (typeof Date.prototype.toJSON !== 'function') { 176 | 177 | Date.prototype.toJSON = function (key) { 178 | 179 | return isFinite(this.valueOf()) ? 180 | this.getUTCFullYear() + '-' + 181 | f(this.getUTCMonth() + 1) + '-' + 182 | f(this.getUTCDate()) + 'T' + 183 | f(this.getUTCHours()) + ':' + 184 | f(this.getUTCMinutes()) + ':' + 185 | f(this.getUTCSeconds()) + 'Z' : null; 186 | }; 187 | 188 | String.prototype.toJSON = 189 | Number.prototype.toJSON = 190 | Boolean.prototype.toJSON = function (key) { 191 | return this.valueOf(); 192 | }; 193 | } 194 | 195 | var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, 196 | escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, 197 | gap, 198 | indent, 199 | meta = { // table of character substitutions 200 | '\b': '\\b', 201 | '\t': '\\t', 202 | '\n': '\\n', 203 | '\f': '\\f', 204 | '\r': '\\r', 205 | '"' : '\\"', 206 | '\\': '\\\\' 207 | }, 208 | rep; 209 | 210 | 211 | function quote(string) { 212 | 213 | // If the string contains no control characters, no quote characters, and no 214 | // backslash characters, then we can safely slap some quotes around it. 215 | // Otherwise we must also replace the offending characters with safe escape 216 | // sequences. 217 | 218 | escapable.lastIndex = 0; 219 | return escapable.test(string) ? '"' + string.replace(escapable, function (a) { 220 | var c = meta[a]; 221 | return typeof c === 'string' ? c : 222 | '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); 223 | }) + '"' : '"' + string + '"'; 224 | } 225 | 226 | 227 | function str(key, holder) { 228 | 229 | // Produce a string from holder[key]. 230 | 231 | var i, // The loop counter. 232 | k, // The member key. 233 | v, // The member value. 234 | length, 235 | mind = gap, 236 | partial, 237 | value = holder[key]; 238 | 239 | // If the value has a toJSON method, call it to obtain a replacement value. 240 | 241 | if (value && typeof value === 'object' && 242 | typeof value.toJSON === 'function') { 243 | value = value.toJSON(key); 244 | } 245 | 246 | // If we were called with a replacer function, then call the replacer to 247 | // obtain a replacement value. 248 | 249 | if (typeof rep === 'function') { 250 | value = rep.call(holder, key, value); 251 | } 252 | 253 | // What happens next depends on the value's type. 254 | 255 | switch (typeof value) { 256 | case 'string': 257 | return quote(value); 258 | 259 | case 'number': 260 | 261 | // JSON numbers must be finite. Encode non-finite numbers as null. 262 | 263 | return isFinite(value) ? String(value) : 'null'; 264 | 265 | case 'boolean': 266 | case 'null': 267 | 268 | // If the value is a boolean or null, convert it to a string. Note: 269 | // typeof null does not produce 'null'. The case is included here in 270 | // the remote chance that this gets fixed someday. 271 | 272 | return String(value); 273 | 274 | // If the type is 'object', we might be dealing with an object or an array or 275 | // null. 276 | 277 | case 'object': 278 | 279 | // Due to a specification blunder in ECMAScript, typeof null is 'object', 280 | // so watch out for that case. 281 | 282 | if (!value) { 283 | return 'null'; 284 | } 285 | 286 | // Make an array to hold the partial results of stringifying this object value. 287 | 288 | gap += indent; 289 | partial = []; 290 | 291 | // Is the value an array? 292 | 293 | if (Object.prototype.toString.apply(value) === '[object Array]') { 294 | 295 | // The value is an array. Stringify every element. Use null as a placeholder 296 | // for non-JSON values. 297 | 298 | length = value.length; 299 | for (i = 0; i < length; i += 1) { 300 | partial[i] = str(i, value) || 'null'; 301 | } 302 | 303 | // Join all of the elements together, separated with commas, and wrap them in 304 | // brackets. 305 | 306 | v = partial.length === 0 ? '[]' : gap ? 307 | '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : 308 | '[' + partial.join(',') + ']'; 309 | gap = mind; 310 | return v; 311 | } 312 | 313 | // If the replacer is an array, use it to select the members to be stringified. 314 | 315 | if (rep && typeof rep === 'object') { 316 | length = rep.length; 317 | for (i = 0; i < length; i += 1) { 318 | if (typeof rep[i] === 'string') { 319 | k = rep[i]; 320 | v = str(k, value); 321 | if (v) { 322 | partial.push(quote(k) + (gap ? ': ' : ':') + v); 323 | } 324 | } 325 | } 326 | } else { 327 | 328 | // Otherwise, iterate through all of the keys in the object. 329 | 330 | for (k in value) { 331 | if (Object.prototype.hasOwnProperty.call(value, k)) { 332 | v = str(k, value); 333 | if (v) { 334 | partial.push(quote(k) + (gap ? ': ' : ':') + v); 335 | } 336 | } 337 | } 338 | } 339 | 340 | // Join all of the member texts together, separated with commas, 341 | // and wrap them in braces. 342 | 343 | v = partial.length === 0 ? '{}' : gap ? 344 | '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : 345 | '{' + partial.join(',') + '}'; 346 | gap = mind; 347 | return v; 348 | } 349 | } 350 | 351 | // If the JSON object does not yet have a stringify method, give it one. 352 | 353 | if (typeof JSON.stringify !== 'function') { 354 | JSON.stringify = function (value, replacer, space) { 355 | 356 | // The stringify method takes a value and an optional replacer, and an optional 357 | // space parameter, and returns a JSON text. The replacer can be a function 358 | // that can replace values, or an array of strings that will select the keys. 359 | // A default replacer method can be provided. Use of the space parameter can 360 | // produce text that is more easily readable. 361 | 362 | var i; 363 | gap = ''; 364 | indent = ''; 365 | 366 | // If the space parameter is a number, make an indent string containing that 367 | // many spaces. 368 | 369 | if (typeof space === 'number') { 370 | for (i = 0; i < space; i += 1) { 371 | indent += ' '; 372 | } 373 | 374 | // If the space parameter is a string, it will be used as the indent string. 375 | 376 | } else if (typeof space === 'string') { 377 | indent = space; 378 | } 379 | 380 | // If there is a replacer, it must be a function or an array. 381 | // Otherwise, throw an error. 382 | 383 | rep = replacer; 384 | if (replacer && typeof replacer !== 'function' && 385 | (typeof replacer !== 'object' || 386 | typeof replacer.length !== 'number')) { 387 | throw new Error('JSON.stringify'); 388 | } 389 | 390 | // Make a fake root object containing our value under the key of ''. 391 | // Return the result of stringifying the value. 392 | 393 | return str('', {'': value}); 394 | }; 395 | } 396 | 397 | 398 | // If the JSON object does not yet have a parse method, give it one. 399 | 400 | if (typeof JSON.parse !== 'function') { 401 | JSON.parse = function (text, reviver) { 402 | 403 | // The parse method takes a text and an optional reviver function, and returns 404 | // a JavaScript value if the text is a valid JSON text. 405 | 406 | var j; 407 | 408 | function walk(holder, key) { 409 | 410 | // The walk method is used to recursively walk the resulting structure so 411 | // that modifications can be made. 412 | 413 | var k, v, value = holder[key]; 414 | if (value && typeof value === 'object') { 415 | for (k in value) { 416 | if (Object.prototype.hasOwnProperty.call(value, k)) { 417 | v = walk(value, k); 418 | if (v !== undefined) { 419 | value[k] = v; 420 | } else { 421 | delete value[k]; 422 | } 423 | } 424 | } 425 | } 426 | return reviver.call(holder, key, value); 427 | } 428 | 429 | 430 | // Parsing happens in four stages. In the first stage, we replace certain 431 | // Unicode characters with escape sequences. JavaScript handles many characters 432 | // incorrectly, either silently deleting them, or treating them as line endings. 433 | 434 | text = String(text); 435 | cx.lastIndex = 0; 436 | if (cx.test(text)) { 437 | text = text.replace(cx, function (a) { 438 | return '\\u' + 439 | ('0000' + a.charCodeAt(0).toString(16)).slice(-4); 440 | }); 441 | } 442 | 443 | // In the second stage, we run the text against regular expressions that look 444 | // for non-JSON patterns. We are especially concerned with '()' and 'new' 445 | // because they can cause invocation, and '=' because it can cause mutation. 446 | // But just to be safe, we want to reject all unexpected forms. 447 | 448 | // We split the second stage into 4 regexp operations in order to work around 449 | // crippling inefficiencies in IE's and Safari's regexp engines. First we 450 | // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we 451 | // replace all simple value tokens with ']' characters. Third, we delete all 452 | // open brackets that follow a colon or comma or that begin the text. Finally, 453 | // we look to see that the remaining characters are only whitespace or ']' or 454 | // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. 455 | 456 | if (/^[\],:{}\s]*$/ 457 | .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@') 458 | .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']') 459 | .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { 460 | 461 | // In the third stage we use the eval function to compile the text into a 462 | // JavaScript structure. The '{' operator is subject to a syntactic ambiguity 463 | // in JavaScript: it can begin a block or an object literal. We wrap the text 464 | // in parens to eliminate the ambiguity. 465 | 466 | j = eval('(' + text + ')'); 467 | 468 | // In the optional fourth stage, we recursively walk the new structure, passing 469 | // each name/value pair to a reviver function for possible transformation. 470 | 471 | return typeof reviver === 'function' ? 472 | walk({'': j}, '') : j; 473 | } 474 | 475 | // If the text is not JSON parseable, then a SyntaxError is thrown. 476 | 477 | throw new SyntaxError('JSON.parse'); 478 | }; 479 | } 480 | }()); 481 | -------------------------------------------------------------------------------- /jstorage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ----------------------------- JSTORAGE ------------------------------------- 3 | * Simple local storage wrapper to save data on the browser side, supporting 4 | * all major browsers - IE6+, Firefox2+, Safari4+, Chrome4+ and Opera 10.5+ 5 | * 6 | * Author: Andris Reinman, andris.reinman@gmail.com 7 | * Project homepage: www.jstorage.info 8 | * 9 | * Licensed under Unlicense: 10 | * 11 | * This is free and unencumbered software released into the public domain. 12 | * 13 | * Anyone is free to copy, modify, publish, use, compile, sell, or 14 | * distribute this software, either in source code form or as a compiled 15 | * binary, for any purpose, commercial or non-commercial, and by any 16 | * means. 17 | * 18 | * In jurisdictions that recognize copyright laws, the author or authors 19 | * of this software dedicate any and all copyright interest in the 20 | * software to the public domain. We make this dedication for the benefit 21 | * of the public at large and to the detriment of our heirs and 22 | * successors. We intend this dedication to be an overt act of 23 | * relinquishment in perpetuity of all present and future rights to this 24 | * software under copyright law. 25 | * 26 | * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 27 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 29 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 30 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 31 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 32 | * OTHER DEALINGS IN THE SOFTWARE. 33 | * 34 | * For more information, please refer to 35 | */ 36 | 37 | /* global ActiveXObject: false */ 38 | /* jshint browser: true */ 39 | 40 | (function() { 41 | 'use strict'; 42 | 43 | var 44 | /* jStorage version */ 45 | JSTORAGE_VERSION = '0.4.12', 46 | 47 | /* detect a dollar object or create one if not found */ 48 | $ = window.jQuery || window.$ || (window.$ = {}), 49 | 50 | /* check for a JSON handling support */ 51 | JSON = { 52 | parse: window.JSON && (window.JSON.parse || window.JSON.decode) || 53 | String.prototype.evalJSON && function(str) { 54 | return String(str).evalJSON(); 55 | } || 56 | $.parseJSON || 57 | $.evalJSON, 58 | stringify: Object.toJSON || 59 | window.JSON && (window.JSON.stringify || window.JSON.encode) || 60 | $.toJSON 61 | }; 62 | 63 | // Break if no JSON support was found 64 | if (typeof JSON.parse !== 'function' || typeof JSON.stringify !== 'function') { 65 | throw new Error('No JSON support found, include //cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js to page'); 66 | } 67 | 68 | var 69 | /* This is the object, that holds the cached values */ 70 | _storage = { 71 | __jstorage_meta: { 72 | CRC32: {} 73 | } 74 | }, 75 | 76 | /* Actual browser storage (localStorage or globalStorage['domain']) */ 77 | _storage_service = { 78 | jStorage: '{}' 79 | }, 80 | 81 | /* DOM element for older IE versions, holds userData behavior */ 82 | _storage_elm = null, 83 | 84 | /* How much space does the storage take */ 85 | _storage_size = 0, 86 | 87 | /* which backend is currently used */ 88 | _backend = false, 89 | 90 | /* onchange observers */ 91 | _observers = {}, 92 | 93 | /* timeout to wait after onchange event */ 94 | _observer_timeout = false, 95 | 96 | /* last update time */ 97 | _observer_update = 0, 98 | 99 | /* pubsub observers */ 100 | _pubsub_observers = {}, 101 | 102 | /* skip published items older than current timestamp */ 103 | _pubsub_last = +new Date(), 104 | 105 | /* Next check for TTL */ 106 | _ttl_timeout, 107 | 108 | /** 109 | * XML encoding and decoding as XML nodes can't be JSON'ized 110 | * XML nodes are encoded and decoded if the node is the value to be saved 111 | * but not if it's as a property of another object 112 | * Eg. - 113 | * $.jStorage.set('key', xmlNode); // IS OK 114 | * $.jStorage.set('key', {xml: xmlNode}); // NOT OK 115 | */ 116 | _XMLService = { 117 | 118 | /** 119 | * Validates a XML node to be XML 120 | * based on jQuery.isXML function 121 | */ 122 | isXML: function(elm) { 123 | var documentElement = (elm ? elm.ownerDocument || elm : 0).documentElement; 124 | return documentElement ? documentElement.nodeName !== 'HTML' : false; 125 | }, 126 | 127 | /** 128 | * Encodes a XML node to string 129 | * based on http://www.mercurytide.co.uk/news/article/issues-when-working-ajax/ 130 | */ 131 | encode: function(xmlNode) { 132 | if (!this.isXML(xmlNode)) { 133 | return false; 134 | } 135 | try { // Mozilla, Webkit, Opera 136 | return new XMLSerializer().serializeToString(xmlNode); 137 | } catch (E1) { 138 | try { // IE 139 | return xmlNode.xml; 140 | } catch (E2) {} 141 | } 142 | return false; 143 | }, 144 | 145 | /** 146 | * Decodes a XML node from string 147 | * loosely based on http://outwestmedia.com/jquery-plugins/xmldom/ 148 | */ 149 | decode: function(xmlString) { 150 | var dom_parser = ('DOMParser' in window && (new DOMParser()).parseFromString) || 151 | (window.ActiveXObject && function(_xmlString) { 152 | var xml_doc = new ActiveXObject('Microsoft.XMLDOM'); 153 | xml_doc.async = 'false'; 154 | xml_doc.loadXML(_xmlString); 155 | return xml_doc; 156 | }), 157 | resultXML; 158 | if (!dom_parser) { 159 | return false; 160 | } 161 | resultXML = dom_parser.call('DOMParser' in window && (new DOMParser()) || window, xmlString, 'text/xml'); 162 | return this.isXML(resultXML) ? resultXML : false; 163 | } 164 | }; 165 | 166 | 167 | ////////////////////////// PRIVATE METHODS //////////////////////// 168 | 169 | /** 170 | * Initialization function. Detects if the browser supports DOM Storage 171 | * or userData behavior and behaves accordingly. 172 | */ 173 | function _init() { 174 | /* Check if browser supports localStorage */ 175 | var localStorageReallyWorks = false; 176 | if ('localStorage' in window) { 177 | try { 178 | window.localStorage.setItem('_tmptest', 'tmpval'); 179 | localStorageReallyWorks = true; 180 | window.localStorage.removeItem('_tmptest'); 181 | } catch (BogusQuotaExceededErrorOnIos5) { 182 | // Thanks be to iOS5 Private Browsing mode which throws 183 | // QUOTA_EXCEEDED_ERRROR DOM Exception 22. 184 | } 185 | } 186 | 187 | if (localStorageReallyWorks) { 188 | try { 189 | if (window.localStorage) { 190 | _storage_service = window.localStorage; 191 | _backend = 'localStorage'; 192 | _observer_update = _storage_service.jStorage_update; 193 | } 194 | } catch (E3) { /* Firefox fails when touching localStorage and cookies are disabled */ } 195 | } 196 | /* Check if browser supports globalStorage */ 197 | else if ('globalStorage' in window) { 198 | try { 199 | if (window.globalStorage) { 200 | if (window.location.hostname == 'localhost') { 201 | _storage_service = window.globalStorage['localhost.localdomain']; 202 | } else { 203 | _storage_service = window.globalStorage[window.location.hostname]; 204 | } 205 | _backend = 'globalStorage'; 206 | _observer_update = _storage_service.jStorage_update; 207 | } 208 | } catch (E4) { /* Firefox fails when touching localStorage and cookies are disabled */ } 209 | } 210 | /* Check if browser supports userData behavior */ 211 | else { 212 | _storage_elm = document.createElement('link'); 213 | if (_storage_elm.addBehavior) { 214 | 215 | /* Use a DOM element to act as userData storage */ 216 | _storage_elm.style.behavior = 'url(#default#userData)'; 217 | 218 | /* userData element needs to be inserted into the DOM! */ 219 | document.getElementsByTagName('head')[0].appendChild(_storage_elm); 220 | 221 | try { 222 | _storage_elm.load('jStorage'); 223 | } catch (E) { 224 | // try to reset cache 225 | _storage_elm.setAttribute('jStorage', '{}'); 226 | _storage_elm.save('jStorage'); 227 | _storage_elm.load('jStorage'); 228 | } 229 | 230 | var data = '{}'; 231 | try { 232 | data = _storage_elm.getAttribute('jStorage'); 233 | } catch (E5) {} 234 | 235 | try { 236 | _observer_update = _storage_elm.getAttribute('jStorage_update'); 237 | } catch (E6) {} 238 | 239 | _storage_service.jStorage = data; 240 | _backend = 'userDataBehavior'; 241 | } else { 242 | _storage_elm = null; 243 | return; 244 | } 245 | } 246 | 247 | // Load data from storage 248 | _load_storage(); 249 | 250 | // remove dead keys 251 | _handleTTL(); 252 | 253 | // start listening for changes 254 | _setupObserver(); 255 | 256 | // initialize publish-subscribe service 257 | _handlePubSub(); 258 | 259 | // handle cached navigation 260 | if ('addEventListener' in window) { 261 | window.addEventListener('pageshow', function(event) { 262 | if (event.persisted) { 263 | _storageObserver(); 264 | } 265 | }, false); 266 | } 267 | } 268 | 269 | /** 270 | * Reload data from storage when needed 271 | */ 272 | function _reloadData() { 273 | var data = '{}'; 274 | 275 | if (_backend == 'userDataBehavior') { 276 | _storage_elm.load('jStorage'); 277 | 278 | try { 279 | data = _storage_elm.getAttribute('jStorage'); 280 | } catch (E5) {} 281 | 282 | try { 283 | _observer_update = _storage_elm.getAttribute('jStorage_update'); 284 | } catch (E6) {} 285 | 286 | _storage_service.jStorage = data; 287 | } 288 | 289 | _load_storage(); 290 | 291 | // remove dead keys 292 | _handleTTL(); 293 | 294 | _handlePubSub(); 295 | } 296 | 297 | /** 298 | * Sets up a storage change observer 299 | */ 300 | function _setupObserver() { 301 | if (_backend == 'localStorage' || _backend == 'globalStorage') { 302 | if ('addEventListener' in window) { 303 | window.addEventListener('storage', _storageObserver, false); 304 | } else { 305 | document.attachEvent('onstorage', _storageObserver); 306 | } 307 | } else if (_backend == 'userDataBehavior') { 308 | setInterval(_storageObserver, 1000); 309 | } 310 | } 311 | 312 | /** 313 | * Fired on any kind of data change, needs to check if anything has 314 | * really been changed 315 | */ 316 | function _storageObserver() { 317 | var updateTime; 318 | // cumulate change notifications with timeout 319 | clearTimeout(_observer_timeout); 320 | _observer_timeout = setTimeout(function() { 321 | 322 | if (_backend == 'localStorage' || _backend == 'globalStorage') { 323 | updateTime = _storage_service.jStorage_update; 324 | } else if (_backend == 'userDataBehavior') { 325 | _storage_elm.load('jStorage'); 326 | try { 327 | updateTime = _storage_elm.getAttribute('jStorage_update'); 328 | } catch (E5) {} 329 | } 330 | 331 | if (updateTime && updateTime != _observer_update) { 332 | _observer_update = updateTime; 333 | _checkUpdatedKeys(); 334 | } 335 | 336 | }, 25); 337 | } 338 | 339 | /** 340 | * Reloads the data and checks if any keys are changed 341 | */ 342 | function _checkUpdatedKeys() { 343 | var oldCrc32List = JSON.parse(JSON.stringify(_storage.__jstorage_meta.CRC32)), 344 | newCrc32List; 345 | 346 | _reloadData(); 347 | newCrc32List = JSON.parse(JSON.stringify(_storage.__jstorage_meta.CRC32)); 348 | 349 | var key, 350 | updated = [], 351 | removed = []; 352 | 353 | for (key in oldCrc32List) { 354 | if (oldCrc32List.hasOwnProperty(key)) { 355 | if (!newCrc32List[key]) { 356 | removed.push(key); 357 | continue; 358 | } 359 | if (oldCrc32List[key] != newCrc32List[key] && String(oldCrc32List[key]).substr(0, 2) == '2.') { 360 | updated.push(key); 361 | } 362 | } 363 | } 364 | 365 | for (key in newCrc32List) { 366 | if (newCrc32List.hasOwnProperty(key)) { 367 | if (!oldCrc32List[key]) { 368 | updated.push(key); 369 | } 370 | } 371 | } 372 | 373 | _fireObservers(updated, 'updated'); 374 | _fireObservers(removed, 'deleted'); 375 | } 376 | 377 | /** 378 | * Fires observers for updated keys 379 | * 380 | * @param {Array|String} keys Array of key names or a key 381 | * @param {String} action What happened with the value (updated, deleted, flushed) 382 | */ 383 | function _fireObservers(keys, action) { 384 | keys = [].concat(keys || []); 385 | 386 | var i, j, len, jlen; 387 | 388 | if (action == 'flushed') { 389 | keys = []; 390 | for (var key in _observers) { 391 | if (_observers.hasOwnProperty(key)) { 392 | keys.push(key); 393 | } 394 | } 395 | action = 'deleted'; 396 | } 397 | for (i = 0, len = keys.length; i < len; i++) { 398 | if (_observers[keys[i]]) { 399 | for (j = 0, jlen = _observers[keys[i]].length; j < jlen; j++) { 400 | _observers[keys[i]][j](keys[i], action); 401 | } 402 | } 403 | if (_observers['*']) { 404 | for (j = 0, jlen = _observers['*'].length; j < jlen; j++) { 405 | _observers['*'][j](keys[i], action); 406 | } 407 | } 408 | } 409 | } 410 | 411 | /** 412 | * Publishes key change to listeners 413 | */ 414 | function _publishChange() { 415 | var updateTime = (+new Date()).toString(); 416 | 417 | if (_backend == 'localStorage' || _backend == 'globalStorage') { 418 | try { 419 | _storage_service.jStorage_update = updateTime; 420 | } catch (E8) { 421 | // safari private mode has been enabled after the jStorage initialization 422 | _backend = false; 423 | } 424 | } else if (_backend == 'userDataBehavior') { 425 | _storage_elm.setAttribute('jStorage_update', updateTime); 426 | _storage_elm.save('jStorage'); 427 | } 428 | 429 | _storageObserver(); 430 | } 431 | 432 | /** 433 | * Loads the data from the storage based on the supported mechanism 434 | */ 435 | function _load_storage() { 436 | /* if jStorage string is retrieved, then decode it */ 437 | if (_storage_service.jStorage) { 438 | try { 439 | _storage = JSON.parse(String(_storage_service.jStorage)); 440 | } catch (E6) { 441 | _storage_service.jStorage = '{}'; 442 | } 443 | } else { 444 | _storage_service.jStorage = '{}'; 445 | } 446 | _storage_size = _storage_service.jStorage ? String(_storage_service.jStorage).length : 0; 447 | 448 | if (!_storage.__jstorage_meta) { 449 | _storage.__jstorage_meta = {}; 450 | } 451 | if (!_storage.__jstorage_meta.CRC32) { 452 | _storage.__jstorage_meta.CRC32 = {}; 453 | } 454 | } 455 | 456 | /** 457 | * This functions provides the 'save' mechanism to store the jStorage object 458 | */ 459 | function _save() { 460 | _dropOldEvents(); // remove expired events 461 | try { 462 | _storage_service.jStorage = JSON.stringify(_storage); 463 | // If userData is used as the storage engine, additional 464 | if (_storage_elm) { 465 | _storage_elm.setAttribute('jStorage', _storage_service.jStorage); 466 | _storage_elm.save('jStorage'); 467 | } 468 | _storage_size = _storage_service.jStorage ? String(_storage_service.jStorage).length : 0; 469 | } catch (E7) { /* probably cache is full, nothing is saved this way*/ } 470 | } 471 | 472 | /** 473 | * Function checks if a key is set and is string or numberic 474 | * 475 | * @param {String} key Key name 476 | */ 477 | function _checkKey(key) { 478 | if (typeof key != 'string' && typeof key != 'number') { 479 | throw new TypeError('Key name must be string or numeric'); 480 | } 481 | if (key == '__jstorage_meta') { 482 | throw new TypeError('Reserved key name'); 483 | } 484 | return true; 485 | } 486 | 487 | /** 488 | * Removes expired keys 489 | */ 490 | function _handleTTL() { 491 | var curtime, i, TTL, CRC32, nextExpire = Infinity, 492 | changed = false, 493 | deleted = []; 494 | 495 | clearTimeout(_ttl_timeout); 496 | 497 | if (!_storage.__jstorage_meta || typeof _storage.__jstorage_meta.TTL != 'object') { 498 | // nothing to do here 499 | return; 500 | } 501 | 502 | curtime = +new Date(); 503 | TTL = _storage.__jstorage_meta.TTL; 504 | 505 | CRC32 = _storage.__jstorage_meta.CRC32; 506 | for (i in TTL) { 507 | if (TTL.hasOwnProperty(i)) { 508 | if (TTL[i] <= curtime) { 509 | delete TTL[i]; 510 | delete CRC32[i]; 511 | delete _storage[i]; 512 | changed = true; 513 | deleted.push(i); 514 | } else if (TTL[i] < nextExpire) { 515 | nextExpire = TTL[i]; 516 | } 517 | } 518 | } 519 | 520 | // set next check 521 | if (nextExpire != Infinity) { 522 | _ttl_timeout = setTimeout(_handleTTL, Math.min(nextExpire - curtime, 0x7FFFFFFF)); 523 | } 524 | 525 | // save changes 526 | if (changed) { 527 | _save(); 528 | _publishChange(); 529 | _fireObservers(deleted, 'deleted'); 530 | } 531 | } 532 | 533 | /** 534 | * Checks if there's any events on hold to be fired to listeners 535 | */ 536 | function _handlePubSub() { 537 | var i, len; 538 | if (!_storage.__jstorage_meta.PubSub) { 539 | return; 540 | } 541 | var pubelm, 542 | _pubsubCurrent = _pubsub_last, 543 | needFired = []; 544 | 545 | for (i = len = _storage.__jstorage_meta.PubSub.length - 1; i >= 0; i--) { 546 | pubelm = _storage.__jstorage_meta.PubSub[i]; 547 | if (pubelm[0] > _pubsub_last) { 548 | _pubsubCurrent = pubelm[0]; 549 | needFired.unshift(pubelm); 550 | } 551 | } 552 | 553 | for (i = needFired.length - 1; i >= 0; i--) { 554 | _fireSubscribers(needFired[i][1], needFired[i][2]); 555 | } 556 | 557 | _pubsub_last = _pubsubCurrent; 558 | } 559 | 560 | /** 561 | * Fires all subscriber listeners for a pubsub channel 562 | * 563 | * @param {String} channel Channel name 564 | * @param {Mixed} payload Payload data to deliver 565 | */ 566 | function _fireSubscribers(channel, payload) { 567 | if (_pubsub_observers[channel]) { 568 | for (var i = 0, len = _pubsub_observers[channel].length; i < len; i++) { 569 | // send immutable data that can't be modified by listeners 570 | try { 571 | _pubsub_observers[channel][i](channel, JSON.parse(JSON.stringify(payload))); 572 | } catch (E) {} 573 | } 574 | } 575 | } 576 | 577 | /** 578 | * Remove old events from the publish stream (at least 2sec old) 579 | */ 580 | function _dropOldEvents() { 581 | if (!_storage.__jstorage_meta.PubSub) { 582 | return; 583 | } 584 | 585 | var retire = +new Date() - 2000; 586 | 587 | for (var i = 0, len = _storage.__jstorage_meta.PubSub.length; i < len; i++) { 588 | if (_storage.__jstorage_meta.PubSub[i][0] <= retire) { 589 | // deleteCount is needed for IE6 590 | _storage.__jstorage_meta.PubSub.splice(i, _storage.__jstorage_meta.PubSub.length - i); 591 | break; 592 | } 593 | } 594 | 595 | if (!_storage.__jstorage_meta.PubSub.length) { 596 | delete _storage.__jstorage_meta.PubSub; 597 | } 598 | 599 | } 600 | 601 | /** 602 | * Publish payload to a channel 603 | * 604 | * @param {String} channel Channel name 605 | * @param {Mixed} payload Payload to send to the subscribers 606 | */ 607 | function _publish(channel, payload) { 608 | if (!_storage.__jstorage_meta) { 609 | _storage.__jstorage_meta = {}; 610 | } 611 | if (!_storage.__jstorage_meta.PubSub) { 612 | _storage.__jstorage_meta.PubSub = []; 613 | } 614 | 615 | _storage.__jstorage_meta.PubSub.unshift([+new Date(), channel, payload]); 616 | 617 | _save(); 618 | _publishChange(); 619 | } 620 | 621 | 622 | /** 623 | * JS Implementation of MurmurHash2 624 | * 625 | * SOURCE: https://github.com/garycourt/murmurhash-js (MIT licensed) 626 | * 627 | * @author Gary Court 628 | * @see http://github.com/garycourt/murmurhash-js 629 | * @author Austin Appleby 630 | * @see http://sites.google.com/site/murmurhash/ 631 | * 632 | * @param {string} str ASCII only 633 | * @param {number} seed Positive integer only 634 | * @return {number} 32-bit positive integer hash 635 | */ 636 | 637 | function murmurhash2_32_gc(str, seed) { 638 | var 639 | l = str.length, 640 | h = seed ^ l, 641 | i = 0, 642 | k; 643 | 644 | while (l >= 4) { 645 | k = 646 | ((str.charCodeAt(i) & 0xff)) | 647 | ((str.charCodeAt(++i) & 0xff) << 8) | 648 | ((str.charCodeAt(++i) & 0xff) << 16) | 649 | ((str.charCodeAt(++i) & 0xff) << 24); 650 | 651 | k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16)); 652 | k ^= k >>> 24; 653 | k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16)); 654 | 655 | h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k; 656 | 657 | l -= 4; 658 | ++i; 659 | } 660 | 661 | switch (l) { 662 | case 3: 663 | h ^= (str.charCodeAt(i + 2) & 0xff) << 16; 664 | /* falls through */ 665 | case 2: 666 | h ^= (str.charCodeAt(i + 1) & 0xff) << 8; 667 | /* falls through */ 668 | case 1: 669 | h ^= (str.charCodeAt(i) & 0xff); 670 | h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)); 671 | } 672 | 673 | h ^= h >>> 13; 674 | h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)); 675 | h ^= h >>> 15; 676 | 677 | return h >>> 0; 678 | } 679 | 680 | ////////////////////////// PUBLIC INTERFACE ///////////////////////// 681 | 682 | $.jStorage = { 683 | /* Version number */ 684 | version: JSTORAGE_VERSION, 685 | 686 | /** 687 | * Sets a key's value. 688 | * 689 | * @param {String} key Key to set. If this value is not set or not 690 | * a string an exception is raised. 691 | * @param {Mixed} value Value to set. This can be any value that is JSON 692 | * compatible (Numbers, Strings, Objects etc.). 693 | * @param {Object} [options] - possible options to use 694 | * @param {Number} [options.TTL] - optional TTL value, in milliseconds 695 | * @return {Mixed} the used value 696 | */ 697 | set: function(key, value, options) { 698 | _checkKey(key); 699 | 700 | options = options || {}; 701 | 702 | // undefined values are deleted automatically 703 | if (typeof value == 'undefined') { 704 | this.deleteKey(key); 705 | return value; 706 | } 707 | 708 | if (_XMLService.isXML(value)) { 709 | value = { 710 | _is_xml: true, 711 | xml: _XMLService.encode(value) 712 | }; 713 | } else if (typeof value == 'function') { 714 | return undefined; // functions can't be saved! 715 | } else if (value && typeof value == 'object') { 716 | // clone the object before saving to _storage tree 717 | value = JSON.parse(JSON.stringify(value)); 718 | } 719 | 720 | _storage[key] = value; 721 | 722 | _storage.__jstorage_meta.CRC32[key] = '2.' + murmurhash2_32_gc(JSON.stringify(value), 0x9747b28c); 723 | 724 | this.setTTL(key, options.TTL || 0); // also handles saving and _publishChange 725 | 726 | _fireObservers(key, 'updated'); 727 | return value; 728 | }, 729 | 730 | /** 731 | * Looks up a key in cache 732 | * 733 | * @param {String} key - Key to look up. 734 | * @param {mixed} def - Default value to return, if key didn't exist. 735 | * @return {Mixed} the key value, default value or null 736 | */ 737 | get: function(key, def) { 738 | _checkKey(key); 739 | if (key in _storage) { 740 | if (_storage[key] && typeof _storage[key] == 'object' && _storage[key]._is_xml) { 741 | return _XMLService.decode(_storage[key].xml); 742 | } else { 743 | return _storage[key]; 744 | } 745 | } 746 | return typeof(def) == 'undefined' ? null : def; 747 | }, 748 | 749 | /** 750 | * Deletes a key from cache. 751 | * 752 | * @param {String} key - Key to delete. 753 | * @return {Boolean} true if key existed or false if it didn't 754 | */ 755 | deleteKey: function(key) { 756 | _checkKey(key); 757 | if (key in _storage) { 758 | delete _storage[key]; 759 | // remove from TTL list 760 | if (typeof _storage.__jstorage_meta.TTL == 'object' && 761 | key in _storage.__jstorage_meta.TTL) { 762 | delete _storage.__jstorage_meta.TTL[key]; 763 | } 764 | 765 | delete _storage.__jstorage_meta.CRC32[key]; 766 | 767 | _save(); 768 | _publishChange(); 769 | _fireObservers(key, 'deleted'); 770 | return true; 771 | } 772 | return false; 773 | }, 774 | 775 | /** 776 | * Sets a TTL for a key, or remove it if ttl value is 0 or below 777 | * 778 | * @param {String} key - key to set the TTL for 779 | * @param {Number} ttl - TTL timeout in milliseconds 780 | * @return {Boolean} true if key existed or false if it didn't 781 | */ 782 | setTTL: function(key, ttl) { 783 | var curtime = +new Date(); 784 | _checkKey(key); 785 | ttl = Number(ttl) || 0; 786 | if (key in _storage) { 787 | 788 | if (!_storage.__jstorage_meta.TTL) { 789 | _storage.__jstorage_meta.TTL = {}; 790 | } 791 | 792 | // Set TTL value for the key 793 | if (ttl > 0) { 794 | _storage.__jstorage_meta.TTL[key] = curtime + ttl; 795 | } else { 796 | delete _storage.__jstorage_meta.TTL[key]; 797 | } 798 | 799 | _save(); 800 | 801 | _handleTTL(); 802 | 803 | _publishChange(); 804 | return true; 805 | } 806 | return false; 807 | }, 808 | 809 | /** 810 | * Gets remaining TTL (in milliseconds) for a key or 0 when no TTL has been set 811 | * 812 | * @param {String} key Key to check 813 | * @return {Number} Remaining TTL in milliseconds 814 | */ 815 | getTTL: function(key) { 816 | var curtime = +new Date(), 817 | ttl; 818 | _checkKey(key); 819 | if (key in _storage && _storage.__jstorage_meta.TTL && _storage.__jstorage_meta.TTL[key]) { 820 | ttl = _storage.__jstorage_meta.TTL[key] - curtime; 821 | return ttl || 0; 822 | } 823 | return 0; 824 | }, 825 | 826 | /** 827 | * Deletes everything in cache. 828 | * 829 | * @return {Boolean} Always true 830 | */ 831 | flush: function() { 832 | _storage = { 833 | __jstorage_meta: { 834 | CRC32: {} 835 | } 836 | }; 837 | _save(); 838 | _publishChange(); 839 | _fireObservers(null, 'flushed'); 840 | return true; 841 | }, 842 | 843 | /** 844 | * Returns a read-only copy of _storage 845 | * 846 | * @return {Object} Read-only copy of _storage 847 | */ 848 | storageObj: function() { 849 | function F() {} 850 | F.prototype = _storage; 851 | return new F(); 852 | }, 853 | 854 | /** 855 | * Returns an index of all used keys as an array 856 | * ['key1', 'key2',..'keyN'] 857 | * 858 | * @return {Array} Used keys 859 | */ 860 | index: function() { 861 | var index = [], 862 | i; 863 | for (i in _storage) { 864 | if (_storage.hasOwnProperty(i) && i != '__jstorage_meta') { 865 | index.push(i); 866 | } 867 | } 868 | return index; 869 | }, 870 | 871 | /** 872 | * How much space in bytes does the storage take? 873 | * 874 | * @return {Number} Storage size in chars (not the same as in bytes, 875 | * since some chars may take several bytes) 876 | */ 877 | storageSize: function() { 878 | return _storage_size; 879 | }, 880 | 881 | /** 882 | * Which backend is currently in use? 883 | * 884 | * @return {String} Backend name 885 | */ 886 | currentBackend: function() { 887 | return _backend; 888 | }, 889 | 890 | /** 891 | * Test if storage is available 892 | * 893 | * @return {Boolean} True if storage can be used 894 | */ 895 | storageAvailable: function() { 896 | return !!_backend; 897 | }, 898 | 899 | /** 900 | * Register change listeners 901 | * 902 | * @param {String} key Key name 903 | * @param {Function} callback Function to run when the key changes 904 | */ 905 | listenKeyChange: function(key, callback) { 906 | _checkKey(key); 907 | if (!_observers[key]) { 908 | _observers[key] = []; 909 | } 910 | _observers[key].push(callback); 911 | }, 912 | 913 | /** 914 | * Remove change listeners 915 | * 916 | * @param {String} key Key name to unregister listeners against 917 | * @param {Function} [callback] If set, unregister the callback, if not - unregister all 918 | */ 919 | stopListening: function(key, callback) { 920 | _checkKey(key); 921 | 922 | if (!_observers[key]) { 923 | return; 924 | } 925 | 926 | if (!callback) { 927 | delete _observers[key]; 928 | return; 929 | } 930 | 931 | for (var i = _observers[key].length - 1; i >= 0; i--) { 932 | if (_observers[key][i] == callback) { 933 | _observers[key].splice(i, 1); 934 | } 935 | } 936 | }, 937 | 938 | /** 939 | * Subscribe to a Publish/Subscribe event stream 940 | * 941 | * @param {String} channel Channel name 942 | * @param {Function} callback Function to run when the something is published to the channel 943 | */ 944 | subscribe: function(channel, callback) { 945 | channel = (channel || '').toString(); 946 | if (!channel) { 947 | throw new TypeError('Channel not defined'); 948 | } 949 | if (!_pubsub_observers[channel]) { 950 | _pubsub_observers[channel] = []; 951 | } 952 | _pubsub_observers[channel].push(callback); 953 | }, 954 | 955 | /** 956 | * Publish data to an event stream 957 | * 958 | * @param {String} channel Channel name 959 | * @param {Mixed} payload Payload to deliver 960 | */ 961 | publish: function(channel, payload) { 962 | channel = (channel || '').toString(); 963 | if (!channel) { 964 | throw new TypeError('Channel not defined'); 965 | } 966 | 967 | _publish(channel, payload); 968 | }, 969 | 970 | /** 971 | * Reloads the data from browser storage 972 | */ 973 | reInit: function() { 974 | _reloadData(); 975 | }, 976 | 977 | /** 978 | * Removes reference from global objects and saves it as jStorage 979 | * 980 | * @param {Boolean} option if needed to save object as simple 'jStorage' in windows context 981 | */ 982 | noConflict: function(saveInGlobal) { 983 | delete window.$.jStorage; 984 | 985 | if (saveInGlobal) { 986 | window.jStorage = this; 987 | } 988 | 989 | return this; 990 | } 991 | }; 992 | 993 | // Initialize jStorage 994 | _init(); 995 | 996 | })(); -------------------------------------------------------------------------------- /music/DarkMystery.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkirAssasin/ggo15-FloodIt/f0f234949ac19103b040f20c0b38773b5aeef478/music/DarkMystery.mp3 -------------------------------------------------------------------------------- /music/DarkMystery.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkirAssasin/ggo15-FloodIt/f0f234949ac19103b040f20c0b38773b5aeef478/music/DarkMystery.ogg -------------------------------------------------------------------------------- /music/door.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkirAssasin/ggo15-FloodIt/f0f234949ac19103b040f20c0b38773b5aeef478/music/door.mp3 -------------------------------------------------------------------------------- /music/door.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkirAssasin/ggo15-FloodIt/f0f234949ac19103b040f20c0b38773b5aeef478/music/door.ogg -------------------------------------------------------------------------------- /music/sfx.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkirAssasin/ggo15-FloodIt/f0f234949ac19103b040f20c0b38773b5aeef478/music/sfx.mp3 -------------------------------------------------------------------------------- /music/sfx.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkirAssasin/ggo15-FloodIt/f0f234949ac19103b040f20c0b38773b5aeef478/music/sfx.ogg --------------------------------------------------------------------------------