Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
Remove javascript array extension: clear, remove function
Browse files Browse the repository at this point in the history
  • Loading branch information
phuong_vu authored and trongtt committed Aug 23, 2012
1 parent 1789ff2 commit 4f81db1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 33 deletions.
40 changes: 13 additions & 27 deletions web/eXoResources/src/main/webapp/javascript/eXo/core/Util.js
Expand Up @@ -102,20 +102,9 @@ eXo.debug = function(message) {
};

/**
* Array convenience method to clear membership.
* @param object element
* @returns void
*/
Array.prototype.clear = function () {
this.length = 0 ;
} ;

/**
* Array convenience method to remove element.
*
* @param object element
* @returns boolean
*/
* Use this code instead
* array.splice($.inArray(element, array), 1);
*
Array.prototype.remove = function (element) {
var result = false ;
var array = [] ;
Expand All @@ -133,12 +122,12 @@ Array.prototype.remove = function (element) {
array = null ;
return result ;
} ;
*/

/**
* Array convenience method to check for membership.
*
* @param object element
* @returns boolean
* Use jquery instead
* $.inArray(element, array) != -1;
*
*/
Array.prototype.contains = function (element) {
for (var i = 0; i < this.length; i++) {
Expand All @@ -147,7 +136,7 @@ Array.prototype.contains = function (element) {
}
}
return false ;
} ;
};

Array.prototype.insertAt = function (what, iIndex) {
if (iIndex < this.length) {
Expand All @@ -168,7 +157,9 @@ Array.prototype.pushAll = function (array) {
}
} ;

/*************************************************************************/
/**********************************
* $.data
* ***************************************/
function HashMap() {
this.properties = new Object() ;
this.length = 0 ;
Expand Down Expand Up @@ -223,21 +214,16 @@ _module.HashMap = eXo.core.HashMap;
/*************************************************************************/

/**
* @author Nguyen Ba Uoc
*
* String util
* jquery
*/

String.prototype.trim = function () {
var tmp = this.replace(/^\s*/, '');
return tmp.replace(/\s*$/, '');
}


/**
* @author jeremi joslin
*
* Function util
* jQuery.proxy()
*/
Function.prototype.bind = function(object) {
var method = this;
Expand Down
Expand Up @@ -553,7 +553,7 @@ function HttpResponseHandler() {
var immediateScripts = loadingScripts ? loadingScripts.immediateScripts : [];
if (immediateScripts.length) {
require(immediateScripts, function() {
immediateScripts.clear();
immediateScripts.length = 0;
instance.ajaxResponse.apply(that, [request, response]);
});
return;
Expand Down
Expand Up @@ -302,7 +302,10 @@ var portalNavigation = {
if (subContainer.length) {
var id = subContainer.attr("id");
portalNav.superClass.pushHiddenContainer(id);
portalNav.superClass.currentVisibleContainers.remove(id);
var index = $.inArray(id, portalNav.superClass.currentVisibleContainers);
if(index !== -1) {
portalNav.superClass.currentVisibleContainers.splice(index, 1);
}
portalNav.superClass.setCloseTimeout(200);
}
},
Expand Down
Expand Up @@ -175,7 +175,7 @@ var uiUpload = {
* fileName uploaded file name
*/
showUploaded : function(id, fileName) {
_module.UIUpload.listUpload.remove(id);
_module.UIUpload.remove(id);
var container = parent.document.getElementById(id);
var jCont = $(container);
var element = document.getElementById(id + "ProgressIframe");
Expand Down Expand Up @@ -206,7 +206,7 @@ var uiUpload = {
* id upload identifier
*/
abortUpload : function(id) {
_module.UIUpload.listUpload.remove(id);
_module.UIUpload.remove(id);
var url = eXo.env.server.context + "/upload?";
url += "uploadId=" + id + "&action=abort";
// var url = eXo.env.server.context + "/upload?uploadId="
Expand Down Expand Up @@ -301,6 +301,13 @@ var uiUpload = {
} else {
_module.UIUpload.listUpload.push(form.id);
}
},

remove : function(id) {
var idx = $.inArray(id, _module.UIUpload.listUpload);
if (idx !== -1) {
_module.UIUpload.listUpload.splice(idx, 1);
}
}
};

Expand Down
Expand Up @@ -111,7 +111,7 @@ var uiUploadInput = {
},

showUploaded : function(id, fileName) {
this.listUpload.remove(id);
this.remove(id);
var container = parent.document.getElementById('UploadInputContainer' + id);
var element = document.getElementById('ProgressIframe' + id);
element.innerHTML = "<span></span>";
Expand Down Expand Up @@ -202,7 +202,7 @@ var uiUploadInput = {
},

abortUpload : function(id, isDynamicMode) {
this.listUpload.remove(id);
this.remove(id);
var url = this.abortURL + id;
ajaxRequest('GET', url, false);

Expand Down Expand Up @@ -280,6 +280,13 @@ var uiUploadInput = {

upload : function(id) {
setTimeout(function() {_module.UIUploadInput.doUpload(id)}, this.delayTime);
},

remove : function(id) {
var idx = $.inArray(id, _module.UIUploadInput.listUpload);
if (idx !== -1) {
_module.UIUploadInput.listUpload.splice(idx, 1);
}
}
};

Expand Down

0 comments on commit 4f81db1

Please sign in to comment.