rossi46 Posted November 7, 2016 Share Posted November 7, 2016 I don't understand this code. Who can explain this for me. Thanks. I don't undestand "%", ["%", "!", "@", "#", "$"] to do what? _d("%", ["%", "!", "@", "#", "$"], function(a, b, c, d, e) { "use strict"; function f(a, b, e) { this.audio = d.getOrCreate(a), this .file = a, this._pan = 0, this ._volume = 1, this._position = 0, this._loop = b, this.music = e, this .refreshPan(), this.refreshVolume(), this.refreshPosition(), c.bindAll(this) } return b.extend(f, a), f.play = function(a, b, c) { var d = new f(a, b, c); return d.play(), d }, f.prototype.play = function() { this.audio = this.audio || d.getOrCreate(this.file), this.refreshPan(), this.refreshVolume(), this .refreshPosition(), this.audio.paused = !1, this.audio.play({ loop: this.loop ? -1 : 0 }), this .audio.on("complete", this.stop), this.audio.on("interrupted", this.stop), this.audio .on("failed", this.stop), e.emit("audio/play", this), d .on("globalVolume/changed", this.refreshVolume), d .on("soundsEnabled/changed", this.refreshVolume), d .on("musicEnabled/changed", this.refreshVolume), d.on("musicVolume/changed", this.refreshVolume) }, f.prototype.stop = function() { this.audio && (this.audio.off("complete", this.stop), this.audio.off("interrupted", this.stop), this.audio .off("failed", this.stop), this.audio.stop(), e.emit("audio/stop", this), d .restore(this.audio), this.audio.removeAllEventListeners(), this.audio = null, d .off("globalVolume/changed", this.refreshVolume), d .off("soundsEnabled/changed", this.refreshVolume), d .off("musicEnabled/changed", this.refreshVolume), d .off("musicVolume/changed", this.refreshVolume)) }, f.prototype.clone = function() { return new f(this.file) }, f.prototype.refreshPosition = function() { this.audio && (this.audio.position = this._position) }, f.prototype.refreshPan = function() { this.audio && (this.audio.pan = this._pan) }, Object.defineProperty(f.prototype, "position", { get: function() { return this._position }, set: function(a) { this._position = a, this.refreshPosition() } }), Object.defineProperty(f.prototype, "pan",{ get: function() { return this._pan }, set: function(a) { this._pan = a, this.refreshPan() } }), f }) Quote Link to comment Share on other sites More sharing options...
Théo Sabattié Posted November 7, 2016 Share Posted November 7, 2016 "%", ["%", "!", "@", "#", "$"] They are the parameters of the function _d param1 = "%" (string) param2 = ["%", "!", "@", "#", "$"] (array of string) param3 = function(a, b, c, d, e){/*content*/} We can't help you if you don't show the _d function. if d is like require js, array of string is bind as params on param3. So a = "%", b = "!", c="@", d="#", e="$" but that does not make sens. rossi46 1 Quote Link to comment Share on other sites More sharing options...
rossi46 Posted November 8, 2016 Author Share Posted November 8, 2016 13 hours ago, Théo Sabattié said: "%", ["%", "!", "@", "#", "$"] They are the parameters of the function _d param1 = "%" (string) param2 = ["%", "!", "@", "#", "$"] (array of string) param3 = function(a, b, c, d, e){/*content*/} We can't help you if you don't show the _d function. if d is like require js, array of string is bind as params on param3. So a = "%", b = "!", c="@", d="#", e="$" but that does not make sens. Thanks. But i don't understand it does not use ";", it use "," for code? Explain this for me: this.audio && (this.audio.off("complete", this.stop), this.audio.off("interrupted", this.stop), this.audio .off("failed", this.stop), this.audio.stop(), e.emit("audio/stop", this) Quote Link to comment Share on other sites More sharing options...
mattstyles Posted November 8, 2016 Share Posted November 8, 2016 It looks like minified/obfuscated code, surely no human writes code quite this bad, try and get your hands on the actual source. You don't need to know all the ins/outs of what is actually capable of crashing the JS engine unless you're specifically making a minifier/obfuscator or entering something like js13k. Spend your time learning to write readable and maintainable code, only deviating from the readable path when it hurts performance (which will be rarely, by the way). Avoid ever writing parameters as a, b, c, d, e, write them in human-readable language i.e. callback, width, height, adapter, isAttached etc etc. Don't ever separate variables or instructions with commas, it makes your code nigh-on unreadable. Use a linter to eliminate deviations from style, pick a scheme off the shelf, such as standardjs or xo. These standards exist to make your code more readable and to eliminate common pitfalls from poor style (e.g. you don't need semi-colons in JS, using them creates more problems than it solves). Théo Sabattié 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.