ruby on rails 3 - Conflict of two javascript files -


i’m playing html5 leanback player , works when on page javascritpts. if add these javascript files rails 3 project error in leanback player's javascript file:

uncaught typeerror: object function each(iterator, context) {   var index = 0;   try {     this._each(function(value) {       iterator.call(context, value, index++);     });   } catch (e) {     if (e != $break) throw e;   }   return this; } has no method ‘split’ 

in function lbplayer.prototype.resolvetextplainsubs.

i guessed that’s because of conflict native prototype in rails don’t know how resolve it. thanks

indeed it's conflict prototypes extending of array.prototype:

// leanbackplayer.js @941 srt = srt.split('\n\n'); var = 0; var issub = false; this.vars.subs[lang] = {}; this.vars.subs[lang].label = {}; this.vars.subs[lang].label = label; this.vars.subs[lang].track = {};  // error: using in on array stupid //        not using hasownproperty outright pitiful for(var s in srt) {       // yield `each` that's function has no .split() method     var st = srt[s].split('\n');     var time; var j;     if(st.length >= 2) {         var t = ""; 

in order fix should replace for(var s in srt) simple loop:

for(var e = 0, el = srt.length; e < el; e++) {     var st = srt[e].split('\n');     var time; var j;     if(st.length >= 2) {         var t = "";         ... } 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -