34 lines
999 B
JavaScript
34 lines
999 B
JavaScript
define(['mage/translate'], function ($t) {
|
|
'use strict';
|
|
|
|
return function (config, element) {
|
|
var attempts = 0,
|
|
timer;
|
|
|
|
function render() {
|
|
attempts += 1;
|
|
if (window.YQV5 && typeof window.YQV5.trackSingle === 'function') {
|
|
element.innerHTML = '';
|
|
window.YQV5.trackSingle({
|
|
YQ_ContainerId: config.containerId,
|
|
YQ_Height: config.height,
|
|
YQ_Fc: '0',
|
|
YQ_Lang: config.language,
|
|
YQ_Num: config.number
|
|
});
|
|
return;
|
|
}
|
|
if (attempts < 100) {
|
|
timer = window.setTimeout(render, 100);
|
|
} else {
|
|
element.innerHTML = '<p>' + $t('Tracking information is temporarily unavailable.') + '</p>';
|
|
}
|
|
}
|
|
|
|
render();
|
|
return function () {
|
|
window.clearTimeout(timer);
|
|
};
|
|
};
|
|
});
|