forked from 0x2620/oxjs
rename Ox.UI source files, remove Ox. prefix
This commit is contained in:
parent
005d50c389
commit
91e1065aab
101 changed files with 0 additions and 0 deletions
56
source/Ox.UI/js/Core/GarbageCollection.js
Normal file
56
source/Ox.UI/js/Core/GarbageCollection.js
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.GarbageCollection <f> GarbageCollection
|
||||
() -> <o> run garbage collection
|
||||
debug() -> {} output debug information
|
||||
@*/
|
||||
|
||||
Ox.GarbageCollection = (function() {
|
||||
|
||||
var that = function() {
|
||||
collect();
|
||||
},
|
||||
timeout;
|
||||
|
||||
collect();
|
||||
|
||||
function collect() {
|
||||
var len = Ox.len(Ox.UI.elements);
|
||||
Object.keys(Ox.UI.elements).forEach(function(id) {
|
||||
if (
|
||||
Ox.UI.elements[id]
|
||||
&& Ox.isUndefined(Ox.UI.elements[id].$element.data('oxid'))
|
||||
) {
|
||||
Ox.UI.elements[id].remove();
|
||||
delete Ox.UI.elements[id];
|
||||
}
|
||||
});
|
||||
timeout && clearTimeout(timeout);
|
||||
timeout = setTimeout(collect, 60000);
|
||||
Ox.Log('GC', len, '-->', Ox.len(Ox.UI.elements));
|
||||
}
|
||||
|
||||
/*@
|
||||
debug <f> debug info
|
||||
() -> <s>
|
||||
@*/
|
||||
that.debug = function() {
|
||||
var classNames = {}, sorted = [];
|
||||
Ox.forEach(Ox.UI.elements, function(element, id) {
|
||||
var className = element.$element[0].className;
|
||||
classNames[className] = (classNames[className] || 0) + 1;
|
||||
});
|
||||
Ox.forEach(classNames, function(count, className) {
|
||||
sorted.push({className: className, count: count});
|
||||
})
|
||||
return sorted.sort(function(a, b) {
|
||||
return a.count - b.count;
|
||||
}).map(function(v) {
|
||||
return v.count + ' ' + v.className
|
||||
}).join('\n');
|
||||
};
|
||||
|
||||
return that;
|
||||
|
||||
}());
|
||||
Loading…
Add table
Add a link
Reference in a new issue