Updated copyright year.
[mailer.git] / js / core-common.js
1 /**
2  * JavaScript for core functions
3  * --------------------------------------------------------------------
4  * Copyright (c) 2003 - 2009 by Roland Haeder
5  * Copyright (c) 2009 - 2016 by Mailer Developer Team
6  * For more information visit: http://mxchange.org
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
21  * MA  02110-1301  USA
22  */
23
24 // Function similar to PHP's function, except it checks only numeric indexes
25 function in_array (needle, heystack) {
26         // By default it is not found
27         var isInArray = false;
28
29         // Check all elements
30         for (var i = 0; i < heystack.length; i++) {
31                 // Is the element found?
32                 if (heystack[i] === needle) {
33                         // Found it and abort
34                         isInArray = true;
35                         break;
36                 } // END - if
37         } // END - for
38
39         // Return status
40         return isInArray;
41 }
42
43 // Function similar to PHP's urldecode() function
44 function decodeUrlEncoding (content) {
45         // Replace plus signs with spaces
46         var removedPlus = (content + '').replace(/\+/g, '%20');
47
48         // Decode it
49         var decoded = decodeURIComponent(removedPlus);
50
51         // Return it
52         return decoded;
53 }
54
55 // "Getter" for total elements in given object
56 function getTotalCountFromObject (object) {
57         // Default is zero
58         var total = 0;
59
60         // Start looping
61         $.each(object, function (i, j) {
62                 // Add it
63                 total++;
64         });
65
66         // Return total
67         return total;
68 }