@@ -408,18 +408,17 @@ def get_detection_html(user_agent)
408
408
}
409
409
410
410
var flashVersion = "";
411
- var doFlashLoop = true;
411
+ var doInterval = true;
412
412
var maxTimeout = null;
413
+ var intervalTimeout = null;
413
414
414
415
function setFlashVersion(ver) {
415
- console.log('called! :) ' + ver)
416
416
flashVersion = ver
417
- doFlashLoop = false
418
417
if (maxTimeout != null) {
419
418
clearTimeout(maxTimeout);
420
419
maxTimeout = null
421
420
}
422
- console.log('flash version after set_version: ' + flashVersion)
421
+ doInterval = false
423
422
return;
424
423
}
425
424
@@ -446,8 +445,6 @@ def get_detection_html(user_agent)
446
445
div.innerHTML = html;
447
446
obj = div.firstChild;
448
447
div.removeChild(obj);
449
- console.log(obj)
450
- alert('check obj')
451
448
return obj;
452
449
}
453
450
@@ -488,26 +485,30 @@ def get_detection_html(user_agent)
488
485
<% end %>
489
486
490
487
if (d["flash"] != null && (d["flash"].match(/[\\ d]+.[\\ d]+.[\\ d]+.[\\ d]+/)) == null) {
491
- alert('flash detection!');
492
488
var flashObject = createFlashObject('<%=get_resource.chomp("/")%>/<%=@flash_swf%>', {width: 1, height: 1}, {allowScriptAccess: 'always', Play: 'True'});
493
489
494
- // After 5s stop waiting and use the version retrieved with JS
495
- maxTimeout = setTimeout(function(){ doFlashLoop = false }, 5000);
496
-
497
- // Check every 100 ms
498
- (function loop(){
499
- console.log('loop: ' + flashVersion)
500
- setTimeout(function(){
501
- if (doFlashLoop) {
502
- loop()
503
- }
504
- console.log('finally: ' + flashVersion)
490
+ // After 5s stop waiting and use the version retrieved with JS if there isn't anything
491
+ maxTimeout = setTimeout(function() {
492
+ if (intervalTimeout != null) {
493
+ doInterval = false
494
+ clearInterval(intervalTimeout)
495
+ }
496
+ if (!isEmpty(flashVersion)) {
497
+ d["flash"] = flashVersion
498
+ }
499
+ sendInfo(d);
500
+ }, 5000);
501
+
502
+ // Check if there is a new flash version every 100ms
503
+ intervalTimeout = setInterval(function() {
504
+ if (!doInterval) {
505
+ clearInterval(intervalTimeout);
505
506
if (!isEmpty(flashVersion)) {
506
507
d["flash"] = flashVersion
507
508
}
508
- sendInfo(d)
509
- }, 100);
510
- })( );
509
+ sendInfo(d);
510
+ }
511
+ }, 100 );
511
512
512
513
document.body.appendChild(flashObject)
513
514
} else {
0 commit comments