Created
September 1, 2009 19:06
-
-
Save thomaslang/179311 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
activeUnits: function(){ | |
console.log('activeUnits'); | |
var us = this.get('units'); | |
if (us == this.previousUnits) return this.previousActiveUnits; | |
this.previousUnits = us; | |
var l = us.get('length'); | |
var list = []; | |
var deleted = []; | |
var i, u, j, d; | |
for (i=0; i < l; i++) { | |
u = us.objectAt(i); | |
if ( list.indexOf(u) >= 0 ) { | |
// don't add this again! | |
} | |
else { | |
d = u.get('deletes'); | |
if ( d ) deleted.push(d); | |
else list.push(u); | |
} | |
} | |
l = deleted.length; | |
for (i=0; i < l; i++) { | |
j = list.indexOf(deleted[i]) | |
if (j>=0){ | |
list.splice(j,1); | |
} | |
} | |
this.previousActiveUnits = list; | |
return list; | |
}.property(), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment