From 1ea96f9da85950963c67299f988a678bd04ad489 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Tue, 23 Feb 2016 08:45:50 +0200 Subject: [PATCH] Typing sounds --- Plugins/typingsound.plugin.js | 63 +++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Plugins/typingsound.plugin.js diff --git a/Plugins/typingsound.plugin.js b/Plugins/typingsound.plugin.js new file mode 100644 index 0000000..2a974c3 --- /dev/null +++ b/Plugins/typingsound.plugin.js @@ -0,0 +1,63 @@ +//META{"name":"typingSoundPlugin"}*// + +function typingSoundPlugin() {} + +typingSoundPlugin.prototype.load = function() { + if($("#tsp-ts").length) return; + $("head").append(''); + this.ts = $("#tsp-ts"); + if($("#tsp-bs").length) return; + $("head").append(''); + this.bs = $("#tsp-bs"); +}; + +typingSoundPlugin.prototype.unload = function() { + $("#tsp-ts").remove(); + $("#tsp-bs").remove(); +}; + +typingSoundPlugin.prototype.start = function() { + var self = this; + $(document).on("keypress.ts", function(e) { + self.ts.trigger("pause"); + self.bs.trigger("pause"); + self.ts.prop("currentTime", 0); + self.bs.prop("currentTime", 0); + self.ts.trigger("play"); + }); + + $(document).on("keydown.ts", function(e) { + self.bs.trigger("pause"); + self.bs.prop("currentTime", 0); + if(e.keyCode == 8) { + self.bs.trigger("play"); + return; + } + }); +}; + +typingSoundPlugin.prototype.stop = function() { + $(document).off("keypress.ts"); + $(document).off("keydown.ts"); +}; + +typingSoundPlugin.prototype.getName = function() { + return "Osu Sounds for Rai"; +}; + +typingSoundPlugin.prototype.getDescription = function() { + return "Plays Osu chat sounds when you type, can be used to play any sounds."; +}; + +typingSoundPlugin.prototype.getVersion = function() { + return "1.0"; +}; + +typingSoundPlugin.prototype.getAuthor = function() { + return "Jiiks"; +}; + +typingSoundPlugin.prototype.getSettingsPanel = function() { + return ""; +}; +