Guest User

TouchPiano Autoplay

a guest
May 7th, 2015
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. function create_mouse_event(e,t){var s=e.ownerDocument.createEvent("MouseEvents"),t=t||{},a={type:t.type||"click",canBubble:t.canBubble||!0,cancelable:t.cancelable||!1,view:t.view||e.ownerDocument.defaultView,detail:t.detail||1,screenX:t.screenX||0,screenY:t.screenY||0,clientX:t.clientX||0,clientY:t.clientY||0,ctrlKey:t.ctrlKey||!1,altKey:t.altKey||!1,shiftKey:t.shiftKey||!1,metaKey:t.metaKey||!1,button:t.button||0,relatedTarget:t.relatedTarget||null};return s.initMouseEvent(a.type,a.canBubble,a.cancelable,a.view,a.detail,a.screenX,a.screenY,a.clientX,a.clientY,a.ctrlKey,a.altKey,a.shiftKey,a.metaKey,a.button,a.relatedTarget),s}function simulate_key_event(e,t,s){var a=create_key_event(e,{eventName:s,keyCode:t,charCode:t});switch(e.dispatchEvent(a),s){case"keydown":return app.kdown(a);case"keyup":return app.kup(a)}}function simulate_mouse_event(e,t,s,a){var c=create_mouse_event(e,{eventName:t,clientX:s,screenX:s,clientY:a,screenY:a});switch(e.dispatchEvent(c),t){case"mousedown":return app.mdown(c);case"mouseup":return app.mup(c)}}function stop_autoplay(){for(var e in timeouts){var t=timeouts[e];clearTimeout(t)}timeouts=[]}function start_autoplay(){var e=document.getElementById("pixi-canvas"),t=app.performer.ghostData.reverse(),s=app.lastLoadedPiece;for(var a in t){var c=1e3*t[a][0],n=setTimeout(function(){return app.lastLoadedPiece!=s?(stop_autoplay(),void setTimeout(start_autoplay,1e3)):(simulate_mouse_event(e,"mousedown",50,50),void simulate_mouse_event(e,"mouseup",50,50))},c);timeouts.push(n)}}window.timeouts=[],$("<a />").text("PLAY").css("background","rgba(255,255,255,.9)").css("cursor","pointer").css("text-align","center").css("color","green").css("padding","20px").css("width","100px").css("display","block").css("z-index","9999").css("position","fixed").css("top",0).css("right","110px").click(start_autoplay).appendTo("body"),$("<a />").text("STOP").css("background","rgba(255,255,255,.9)").css("cursor","pointer").css("text-align","center").css("color","red").css("padding","20px").css("width","100px").css("display","block").css("z-index","9999").css("position","fixed").css("top",0).css("right",0).click(stop_autoplay).appendTo("body");
Advertisement
Add Comment
Please, Sign In to add comment