X-Git-Url: http://git.euphorik.ch/?p=pompage.git;a=blobdiff_plain;f=doc%2Fwebdeveloper%2Fcommon%2Farray.js;fp=doc%2Fwebdeveloper%2Fcommon%2Farray.js;h=a70ad6d19ef1d6d76e6a55377aad544715118ec5;hp=0000000000000000000000000000000000000000;hb=c3b0deb3d8c9f439739c79806e915c29bc1d4b84;hpb=cff6539539a79e014f6ac8df46716cafce2c8472 diff --git a/doc/webdeveloper/common/array.js b/doc/webdeveloper/common/array.js new file mode 100644 index 0000000..a70ad6d --- /dev/null +++ b/doc/webdeveloper/common/array.js @@ -0,0 +1,58 @@ +// Returns true if the array contains the element +function webdeveloper_contains(array, element) +{ + // If the array and element are set + if(array && element) + { + try + { + // If the element does not exist in the array + if(array.indexOf(element) == -1) + { + return false; + } + else + { + return true; + } + } + catch(exception) + { + var arrayLength = array.length; + + // Loop through the array + for(var i = 0; i < arrayLength; i++) + { + // If the element is found + if(array[i] == element) + { + return true; + } + } + } + } + + return false; +} + +// Returns true if the array contains media with the given URL +function webdeveloper_mediaArrayContains(array, url) +{ + // If the array and url are set + if(array && url) + { + var arrayLength = array.length; + + // Loop through the array + for(var i = 0; i < arrayLength; i++) + { + // If media with the given URL is found + if(array[i].src == url) + { + return true; + } + } + } + + return false; +}