diff --git a/lib/client.js b/lib/client.js index 2a7f8a90..10f977dd 100644 --- a/lib/client.js +++ b/lib/client.js @@ -83,8 +83,6 @@ CloudCmd._loadDir = function(pLink, pNeedRefresh){ /* показываем гиф загрузки возле пути папки сверху * ctrl+r нажата? */ - DOM.Images.showLoad(pNeedRefresh ? {top:true} : null); - var lCurrentLink = DOM.getCurrentLink(), lHref = lCurrentLink.href, lParent = lCurrentLink.textContent, @@ -92,6 +90,8 @@ CloudCmd._loadDir = function(pLink, pNeedRefresh){ lDir = DOM.getCurrentDir(); if(pLink || lCurrentLink.target !== '_blank'){ + DOM.Images.showLoad(pNeedRefresh ? {top:true} : null); + /* загружаем содержимое каталога */ CloudCmd._ajaxLoad(lLink, { refresh: pNeedRefresh }); @@ -608,15 +608,14 @@ CloudCmd._ajaxLoad = function(pFullPath, pOptions){ success :function(pData){ CloudCmd._createFileTable(lPanel, pData); CloudCmd._changeLinks(lPanel); - /* переводим таблицу файлов в строку, для - * сохранения в localStorage - */ + + /* переводим таблицу файлов в строку, для * + * сохранения в localStorage */ var lJSON_s = Util.stringifyJSON(pData); Util.log(lJSON_s.length); - /* если размер данных не очень бошьой - * сохраняем их в кэше - */ + /* если размер данных не очень бошьой * + * сохраняем их в кэше */ if(lJSON_s.length < 50000 ) DOM.Cache.set(lPath, lJSON_s); } diff --git a/lib/client/dom.js b/lib/client/dom.js index 076bc71a..7d70274f 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -183,6 +183,15 @@ var CloudCommander, Util, return DOM.addListener('click', pListener, pElement, pUseCapture); }; + /** + * safe add event click listener + * @param pListener + * @param pUseCapture + */ + DOM.addErrorListener = function(pListener, pElement, pUseCapture){ + return DOM.addListener('error', pListener, pElement, pUseCapture); + }; + /** * getListener for element * @@ -586,7 +595,7 @@ var CloudCommander, Util, }; DOM.addListener('load', lLoad, lElement); - DOM.addListener('error', lError,lElement); + DOM.addErrorListener(lError,lElement); if(lStyle) lElement.style.cssText = lStyle; diff --git a/lib/client/google_analytics.js b/lib/client/google_analytics.js index ba3d0d85..a4f499fd 100644 --- a/lib/client/google_analytics.js +++ b/lib/client/google_analytics.js @@ -5,19 +5,10 @@ var DOM, _gaq; /* setting google analitics tracking code */ _gaq = [['_setAccount', 'UA-33536569-2'], ['_trackPageview']]; - var lOnError_f = window.onerror; - window.onerror = function(msg, url, line) { - var preventErrorAlert = true; - _gaq.push(['_trackEvent', - 'JS Error', - msg, + DOM.addErrorListener(function(msg, url, line) { + _gaq.push(['_trackEvent', 'JS Error', msg, navigator.userAgent + ' -> ' + url + " : " + line]); - - if(typeof lOnError_f === 'function') - lOnError_f(); - - return preventErrorAlert; - }; + }); DOM.jsload('http://google-analytics.com/ga.js');