~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/common/util.js

  • Committer: mattgiuca
  • Date: 2008-01-17 01:43:42 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:238
util.js: Added Array method "removeall".

Show diffs side-by-side

added added

removed removed

Lines of Context:
501
501
    return JSON.stringify(str);
502
502
}
503
503
 
 
504
/** Removes all occurences of a value from an array.
 
505
 */
 
506
Array.prototype.removeall = function(val)
 
507
{
 
508
    var i, j;
 
509
    arr = this;
 
510
    j = 0;
 
511
    for (i=0; i<arr.length; i++)
 
512
    {
 
513
        arr[j] = arr[i];
 
514
        if (arr[i] != val) j++;
 
515
    }
 
516
    arr.splice(j, i-j);
 
517
}
 
518
 
504
519
/** Makes an XMLHttpRequest call to the server. Waits (synchronously) for a
505
520
 * response, and returns an XMLHttpRequest object containing the completed
506
521
 * response.