Difference between revisions of "User:Moussekateer/vector.js"
Moussekateer (talk | contribs) m |
Moussekateer (talk | contribs) m (science) |
||
Line 2: | Line 2: | ||
importScriptURI('https://raw.github.com/Moussekateer/TFWiki-scripts/master/wikifi_toolbox.js', 'text/javascript'); | importScriptURI('https://raw.github.com/Moussekateer/TFWiki-scripts/master/wikifi_toolbox.js', 'text/javascript'); | ||
+ | |||
+ | function touchHandler(event) { | ||
+ | var touch = event.changedTouches[0]; | ||
+ | |||
+ | var simulatedEvent = document.createEvent("MouseEvent"); | ||
+ | simulatedEvent.initMouseEvent({ | ||
+ | touchstart: "mousedown", | ||
+ | touchmove: "mousemove", | ||
+ | touchend: "mouseup" | ||
+ | }[event.type], true, true, window, 1, | ||
+ | touch.screenX, touch.screenY, | ||
+ | touch.clientX, touch.clientY, false, | ||
+ | false, false, false, 0, null); | ||
+ | |||
+ | touch.target.dispatchEvent(simulatedEvent); | ||
+ | event.preventDefault(); | ||
+ | } | ||
+ | |||
+ | function touchinit() { | ||
+ | document.addEventListener("touchstart", touchHandler, true); | ||
+ | document.addEventListener("touchmove", touchHandler, true); | ||
+ | document.addEventListener("touchend", touchHandler, true); | ||
+ | document.addEventListener("touchcancel", touchHandler, true); | ||
+ | } | ||
+ | |||
+ | $(document).ready(function() { | ||
+ | touchinit(); | ||
+ | }); |
Revision as of 04:08, 16 June 2013
importScriptURI('https://raw.github.com/Moussekateer/TFWiki-scripts/master/spambot_killer.js', 'text/javascript'); importScriptURI('https://raw.github.com/Moussekateer/TFWiki-scripts/master/wikifi_toolbox.js', 'text/javascript'); function touchHandler(event) { var touch = event.changedTouches[0]; var simulatedEvent = document.createEvent("MouseEvent"); simulatedEvent.initMouseEvent({ touchstart: "mousedown", touchmove: "mousemove", touchend: "mouseup" }[event.type], true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null); touch.target.dispatchEvent(simulatedEvent); event.preventDefault(); } function touchinit() { document.addEventListener("touchstart", touchHandler, true); document.addEventListener("touchmove", touchHandler, true); document.addEventListener("touchend", touchHandler, true); document.addEventListener("touchcancel", touchHandler, true); } $(document).ready(function() { touchinit(); });