示例#1
0
define(function(e,t,n){"use strict";function v(e,t){navigator.notification?navigator.notification.alert(e,null,t):alert(e)}function b(e,t,n,i){if(n=n||"",navigator.notification)navigator.notification.prompt(e,function(e){t(1===e.buttonIndex?e.input1:null)},n,["Ok","Cancel"],i);else{var o=prompt(e,i,n);t(o)}}function x(e,t,n,i,o){if(n=n||"",navigator.notification)navigator.notification.confirm(e,function(e){t(1===e)},n,[i,o]);else{var a=confirm(e);t(a)}}function w(){var i=document.createElement("a");i.setAttribute("href","bingo.html"),i.click()}function k(){var e=i.range(1,10).map(function(e){var t="box"+e+"image",n="box"+e+"name";return{name:o.get(n),image:o.get(t)}});return e}function E(){return k().filter(function(e){return e.image})}function A(e,t){var n=new Image;n.onload=function(){var c=((r-n.width)/2,(l-n.height)/2,n.height*(r/n.width));i.select("#"+e).style("background-image","url("+t+")").style("background-size",r+"px "+c+"px")},n.src=t}function I(e,t){function o(e){return new Promise(function(i){e.classed(t,!0),setTimeout(function(){i(!0)},n)})}var a,n=350;return i.selectAll(e).each(function(){var e=i.select(this);a=a?a.then(function(){return o(e)}):o(e)}),a}function C(e,t){var n=(document.documentElement.clientHeight-3*r)/2,o=i.select("#alertContainer");o.style("display","block").style("top","-"+3*r+"px").on("click",null);i.select("#alertContainer img").attr("src",e).style("width",3*r+"px");o.on("click",function(){o.transition().duration(500).style("top","-1300px").each("end",function(){if(o.style("display","none"),i.select(".tile").classed("flip")){var e=I(".tile","unflip");e.then(function(){i.selectAll(".tile").classed("flip",!1)})}})}),o.transition().duration(2e3).style("top",n+"px").ease("bounce").each("end",function(){"function"==typeof t&&t()})}function H(){i.selectAll(".tile").classed("unflip",!1);var e=I(".tile","flip");e.then(function(){C("img/bingo.png")})}function O(e){var t=+e.substr(3),n=d[t].split("").some(function(e){return!o.get("box"+e+"image")});return!n}function S(e){var t=+e.substr(3),n=[1,3,7,9],i=n.indexOf(t)>=0&&n.every(function(e){return o.get("box"+e+"image")});return i}function D(e,t){function c(){setTimeout(function(){i.selectAll("#alertContainer").style("display","none")},750)}var l,r,a=+t.substr(3);A(t,e),o.set(t+"image",e),9===E().length?H():S(t)?(l=["#box1","#box3","#box7","#box9"],r=l.join(","),i.selectAll(r).classed("unflip",!1),I(r,"flip").then(function(){I(l.reverse().join(","),"unflip").then(function(){i.selectAll(r).classed("flip",!1)}),C("img/corners.png",c)})):O(t)&&(l=d[a].split("").map(function(e){return"#box"+e}),r=l.join(","),i.selectAll(r).classed("unflip",!1),I(r,"flip").then(function(){I(l.reverse().join(","),"unflip").then(function(){i.selectAll(r).classed("flip",!1)}),C("img/line.png",c)}))}function F(e){if(1==e.target.files.length&&0==e.target.files[0].type.indexOf("image/")){var t=e.target.files[0];EXIF.getData(t,function(){var e=EXIF.getTag(this,"Orientation"),n=new MegaPixImage(t),i=document.createElement("canvas");n.onrender=function(t){D(t.toDataURL(),a,e),a=""},n.render(i,{maxWidth:c,maxHeight:h,orientation:e})})}}function W(e){var t=i.select("#"+e+" .name"),n=t.html(),a="Enter the name of the person you want to meet: ",l="Name a face";b(a,function(n){null!==n&&(t.style("background","rgba(0,0,0,0.4)").html(n),o.set(e+"name",n))},l,n)}function q(){{var n=document.documentElement.clientWidth,i=document.documentElement.clientHeight;window.screen.width,window.screen.height}u=n,f=i-s,r=u/3,l=f/3,$("body").css({width:u+"px",height:f+"px"}),$(".tile, .back").css({width:r+"px",height:l+"px"})}function z(){$(".tile").on("click",function(e){if(e.target===this){var t=$("#"+this.id+" .name"),n=t.html();0===n.trim().length?W(this.id):(a=this.id,$("#photo-capture").click())}}),$("#photo-capture").on("change",F),$(".name").on("click",function(e){e.stopPropagation(),W(this.parentNode.id)}),$("#share").on("click",function(){var t=E();9===t.length?w():x("You haven't got a full house yet – share anyway?",function(e){e&&w()},"Share your image","Share anyway","Ok, I'll wait")}),$("#about").on("click",function(e){e.stopPropagation(),v(p,"About")})}function B(e,t){i.select("#"+e+" .name").html(t).style("background","rgba(0,0,0,0.4)")}function M(){i.selectAll(".tile").each(function(){var e=this.id,t=o.get(e+"name"),n=o.get(e+"image");t&&B(e,t),n&&A(e,n)})}var l,r,u,f,i=require("lib/d3.min"),o=require("Storage.min"),a="",c=600,s=40,h=250,p="CHI Bingo is a fun app that aims to increase social activity at CHI.\n\nThe aim is simple — before the conference, enter nine names of people you wish to talk to. When you arrive, the race is on to get 'selfie' photos with each of them before the conference ends. Easy!\n\nOnce you're done you can share your 9x9 grid with others.\n\nCHI Bingo was inspired by the late Gary Marsden — a CHI veteran and dear friend.",d={1:"123",2:"123",3:"123",4:"456",5:"456",6:"456",7:"789",8:"789",9:"789"},N={initialize:function(){this.bindEvents()},bindEvents:function(){$(document).ready(function(){M(),z(),q(),FastClick.attach(document.body)})},onDeviceReady:function(){},receivedEvent:function(){}};n.exports=N});
示例#2
0
define(function(e,n,t){"use strict";function i(e,n){navigator.notification?navigator.notification.alert(e,null,n):alert(e)}function o(e,n,t,i,o){if(t=t||"",navigator.notification)navigator.notification.confirm(e,function(e){n(1===e)},t,[i,o]);else{var a=confirm(e);n(a)}}function a(e){var n=document.createElement("a");n.setAttribute("href","bingo.html"),n.click()}function c(){var e=I.range(1,10).map(function(e){var n="box"+e+"image",t="box"+e+"name";return{name:C.get(t),image:C.get(n)}});return e}function r(){return c().filter(function(e){return e.image})}function l(e,n){var t=new Image;t.onload=function(){var i=((k-t.width)/2,(w-t.height)/2,t.height*(k/t.width));I.select("#"+e).style("background-image","url("+n+")").style("background-size",k+"px "+i+"px")},t.src=n}function u(e,n){function t(e){return new Promise(function(t,i){e.classed(n,!0),setTimeout(function(){t(!0)},o)})}var i,o=350;return I.selectAll(e).each(function(){var e=I.select(this);i=i?i.then(function(){return t(e)}):t(e)}),i}function s(e,n){var t=(document.documentElement.clientHeight-3*k)/2,i=I.select("#alertContainer");i.style("display","block").style("top","-"+3*k+"px").on("click",null);I.select("#alertContainer img").attr("src",e).style("width",3*k+"px");i.on("click",function(){i.transition().duration(500).style("top","-1300px").each("end",function(){if(i.style("display","none"),I.select(".tile").classed("flip")){var e=u(".tile","unflip");e.then(function(){I.selectAll(".tile").classed("flip",!1)})}})}),i.transition().duration(2e3).style("top",t+"px").ease("bounce").each("end",function(){"function"==typeof n&&n()})}function f(){I.selectAll(".tile").classed("unflip",!1);var e=u(".tile","flip");e.then(function(){s("img/bingo.png")})}function D(e){var n=+e.substr(3),t=P[n].split("").some(function(e){return!C.get("box"+e+"image")});return!t}function h(e){var n=+e.substr(3),t=S[n].split("").some(function(e){return!C.get("box"+e+"image")});return!t}function d(e){var n=+e.substr(3),t=[1,3,7,9],i=t.indexOf(n)>=0&&t.every(function(e){return C.get("box"+e+"image")});return i}function m(e,n,t){function i(){setTimeout(function(){I.selectAll("#alertContainer").style("display","none")},750)}var o,a,c=+n.substr(3);l(n,e),C.set(n+"image",e),9===r().length?f():d(n)?(o=["#box1","#box3","#box7","#box9"],a=o.join(","),I.selectAll(a).classed("unflip",!1),u(a,"flip").then(function(){u(o.reverse().join(","),"unflip").then(function(){I.selectAll(a).classed("flip",!1)}),s("img/corners.png",i)})):D(n)?(o=P[c].split("").map(function(e){return"#box"+e}),a=o.join(","),I.selectAll(a).classed("unflip",!1),u(a,"flip").then(function(){u(o.reverse().join(","),"unflip").then(function(){I.selectAll(a).classed("flip",!1)}),s("img/line.png",i)})):h(n)&&(o=S[c].split("").map(function(e){return"#box"+e}),a=o.join(","),I.selectAll(a).classed("unflip",!1),u(a,"flip").then(function(){u(o.reverse().join(","),"unflip").then(function(){I.selectAll(a).classed("flip",!1)}),s("img/line.png",i)}))}function g(e){if(1==e.target.files.length&&0===e.target.files[0].type.indexOf("image/")){var n=e.target.files[0];EXIF.getData(n,function(){var t=EXIF.getTag(this,"Orientation"),i=new MegaPixImage(n),o=document.createElement("canvas");i.onrender=function(n){m(n.toDataURL(),H,t),H="",$(e.target)[0].form.reset()},i.render(o,{maxWidth:j,maxHeight:O,orientation:t})})}}function p(){var e=document.documentElement.clientWidth,n=document.documentElement.clientHeight;window.screen.width,window.screen.height;A=e,E=n-M,k=A/3,w=E/3,$("body").css({width:A+"px",height:E+"px"}),$(".tile, .back").css({width:k+"px",height:w+"px"})}function v(){$(".tile").on("click",function(e){if(e.target===this){var n=$("#"+this.id+" .name");n.html();H=this.id,$("#photo-capture").click()}}),$("#photo-capture").on("change",g),$(".name").on("click",function(e){H=this.parentNode.id,$("#photo-capture").click()}),$("#share").on("click",function(e){var n=r();9===n.length?a():o("You haven't got a full house yet – share anyway?",function(e){e&&a()},"Share your image","Share anyway","Ok, I'll wait")}),$("#about").on("click",function(e){e.stopPropagation(),i(T,"About")})}function b(e,n){I.select("#"+e+" .name").html(n).style("background","rgba(0,0,0,0.4)")}function y(e){for(var n=0;n<F.length;n++)if(F[n]===e)return!0}function x(){var e=!1;I.selectAll(".tile").each(function(){var n=this.id,t=C.get(n+"name"),i=C.get(n+"image");if(t)b(n,t);else{for(var o="Demo";y(o);)o=z[Math.floor(Math.random()*z.length)];F.push(o),o="Demo "+o,C.set(n+"name",o),b(n,o),e=!0}i&&l(n,i)}),e&&setTimeout(function(){i(T,"About")},250)}var w,k,A,E,I=require("lib/d3.min"),C=require("Storage.min"),H="",j=600,M=40,O=250,T="CHI Demo Bingo is a fun app that aims to increase social activity at CHI.\n\nYou have just received nine demo numbers. Your mission, should you choose to accept it, is to find these nine demos and take 'selfie' photos with each of them at the conference reception on Monday night (making sure the demo number appears in your picture).\n\nOnce your grid is completed, come and show us at the demo prize booth. The first 50 people to complete their bingo card will get a special CHI prize!\n\n\nCHI Bingo was inspired by the late Gary Marsden — a CHI veteran and dear friend.",z=Array("D100","D101","D102","D103","D104","D105","D106","D107","D108","D109","D110","D111","D112","D113","D114","D115","D116","D117","D200","D201","D202","D203","D204","D205","D206","D207","D208","D209","D210","D211","D300","D301","D302","D303","D304","D305","D306","D307","D308","D309","D310","D311","D312","D313","D314","D315","D316","D317","D318","D319","D320","D321","D322","D323","D324","D400","D401","D402","D403","D404","D405","D406","D407","D408","D409","D410","D411","D412","D413","D414","D415","D500","D501","D502","D503","D504","D505"),F=Array("Demo"),P={1:"123",2:"123",3:"123",4:"456",5:"456",6:"456",7:"789",8:"789",9:"789"},S={1:"147",2:"258",3:"369",4:"147",5:"258",6:"369",7:"147",8:"258",9:"369"},Y={initialize:function(){this.bindEvents()},bindEvents:function(){$(document).ready(function(){x(),v(),p(),FastClick.attach(document.body)})},onDeviceReady:function(){},receivedEvent:function(e){}};t.exports=Y});