PageSourceSearch

https://www.fundable.com/web/v1/js/fundable/utilities.js?_cache=1790238291

js fundable.com collected 2026-09-24 08:25:50 UTC 8,005 bytes, 241 lines download raw bytes

1if(!Fundable) { var Fundable = {}; }
2
3Fundable.Utilities = {
4    randomString:function(size, chars)
5    {
6        if(!size) { size = 20; }
7        if(!chars) { chars = 'aA'; }
8
9        var mask = '';
10        if (chars.indexOf('a') > -1) { mask += 'abcdefghijklmnopqrstuvwxyz'; }
11        if (chars.indexOf('A') > -1) { mask += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; }
12        if (chars.indexOf('#') > -1) { mask += '0123456789'; }
13        if (chars.indexOf('!') > -1) { mask += '~`!@#$%^&*()_+-={}[]:";\'<>?,./|\\'; }
14        var result = '';
15        for (var i = size; i > 0; --i)
16        {
17            result += mask[Math.round(Math.random() * (mask.length - 1))];
18        } 
19        return result;
20    },
21    isMouseOverChild:function(elem, event)
22    {
23        var possibleChild = event.toElement || event.relatedTarget;
24        return $(elem).find(possibleChild).length;
25    },
26    secondsRemainingForUpload: function (progressData, file, startDate) {
27        var fileSize = file.size / 1000;
28        var kbytesUploaded = progressData.bytesLoaded / 1000;
29        var kbPerSecond = progressData.speed;
30        var now = new Date();
31        var secondsPassed = (now.getTime() - startDate.getTime()) / 1000;
32
33        if (!averageRate) {
34            averageRate = 1;
35        }
36        if (!secondsPassed) {
37            secondsPassed = 1;
38        }
39
40        var averageRate = kbytesUploaded / secondsPassed; /* gives kb/s */
41
42        var left = parseInt((fileSize - kbytesUploaded) / averageRate);
43
44        if (!left) {
45            return 0;
46        }
47
48        return left;
49    },
50    resizeImagesForIE: function () {
51        $('.resize-image, .legacy-resize-image').each(function () {
52            var url = $(this).css('background-image');
53            url = url.replace('url(', '').replace(')', '').replace('"', '').replace('"', '');
54            $(this).css('background-image', '');
55            var img = $('<img/>').attr('src', url);
56            $(img).css({ 'max-height': $(this).height(), 'max-width': $(this).width() });
57            $(this).css('overflow', 'hidden');
58
59
60            $(this).prepend(img);
61            $(this).removeClass('resize-image');
62            $(this).css('text-align', 'center');
63            $(this).removeClass('legacy-resize-image');
64
65        });
66
67        setTimeout(Fundable.utilities.resizeImagesForIE, 1000);
68    },
69    resizeImages: function () {
70        if ($.browser.msie && parseInt($.browser.version) <= 8) {
71            Fundable.utilities.resizeImagesForIE();
72            return;
73        }
74
75        $('.resize-image').each(function () {
76            
77            if ($(this).css('background-image')) {
78
79                if ($(this).hasClass('resize-fill')) 
80                    $(this).css('background-size', 'cover');
81                else 
82                    $(this).css('background-size', 'contain');
83
84                $(this).css('background-position', '50% 50%');
85                $(this).css('background-repeat', 'no-repeat');
86                $(this).removeClass('resize-image');
87            }
88        });
89        setTimeout(Fundable.utilities.resizeImages, 1000);
90    },
91    isMobileBrowser: function () {
92        var deviceAgent = navigator.userAgent.toLowerCase();
93        var agentID = deviceAgent.match(/(iphone|ipod|ipad|webos|android|blackberry)/);
94        if (agentID) {
95            return true;
96        }
97        else {
98            return false;
99        }
100    },
101    stringToDate: function (string) {
102        if (typeof string != 'string' || typeof string == 'object') { return string; }
103        if (!string) {
104            var string = '';
105        }
106        var string2 = parseInt(string.substring(6).replace(')', '').replace('/', ''));
107        if (string2 > 1000) {
108            var d = new Date();
109            d.setTime(string2);
110        }
111        else {
112            var d = new Date(string);
113        }
114        return d;
115    },
116    getFormData: function (id) {
117        if(typeof id != 'string')
118        {
119            var form = id;
120            if($(form).attr('id'))
121            {
122                id = $(form).attr('id');
123                return form2js(id, '.', false);
124            }
125            else
126            {
127                id = 'form-to-get-data-from';
128                $(form).attr('id',id);
129                var data = form2js(id, '.', false);
130                $(form).removeAttr('id');
131                return data;
132            }
133        }
134        else
135        {
136            return form2js(id, '.', false);
137        }
138    },
139    dateToIsoString: function (d) {
140        function pad(n) { return n < 10 ? '0' + n : n }
141        return d.getUTCFullYear() + '-'
142        + paolld(d.getUTCMonth() + 1) + '-'
143        + pad(d.getUTCDate()) + 'T'
144        + pad(d.getUTCHours()) + ':'
145        + pad(d.getUTCMinutes()) + ':'
146        + pad(d.getUTCSeconds()) + 'Z';
147    },
148    ago: function (Date) {
149        var iso_date_string = '';
150        if (typeof Date == 'object') {
151            iso_date_string = Fundable.utilities.dateToIsoString(Date);
152        }
153        else {
154            iso_date_string = Date;
155        }
156        return prettyDate(iso_date_string);
157    },
158    getCookie:function(c_name)
159    {
160        var c_value = document.cookie;
161        var c_start = c_value.indexOf(" " + c_name + "=");
162        if (c_start == -1)
163        {
164            c_start = c_value.indexOf(c_name + "=");
165        }
166        if (c_start == -1)
167        {
168            c_value = null;
169        }
170        else
171        {
172            c_start = c_value.indexOf("=", c_start) + 1;
173            var c_end = c_value.indexOf(";", c_start);
174            if (c_end == -1)
175            {
176                c_end = c_value.length;
177            }
178            c_value = unescape(c_value.substring(c_start,c_end));
179        }
180        return c_value;
181    },
182    templateSelector: function (templateName) {
183        return '*[data-template-name="' + templateName + '"]';
184    },
185    formToObject: function (selector) {
186        var object = [];
187        $(selector).find('input, select').each(function (i, element) {
188            object[$(element).attr('name')] = $(element).val();
189        });
190        return object;
191    },
192    inArray: function (searchValue, arr) {
193        var matchFound = false;
194        $.each(arr, function (index, value) {
195            if (value === searchValue) {
196                matchFound = true;
197                return;
198            }
199        });
200        return matchFound;
201    },
202    replaceTemplateKeys: function (args) {
203
204        // args = { data: {}, element:$(jquery), html:'<string>', keyPrefix:'String';
205        $.each(args.data, function (key, value) {
206            if (value && typeof value == 'object') {
207                // Loops through all children objects too.
208                args.html = Fundable.utilities.replaceTemplateKeys({ data: value, element: args.element, html: args.html, keyPrefix: args.keyPrefix + '.' + key });
209            }
210            else {
211                var pattern = new RegExp('\{\{' + args.keyPrefix + '\.' + key + '\}\}', 'g');
212
213                if (value == null || value == undefined) { value = ''; }
214
215                if (args.html) {
216                    args.html = args.html.replace(pattern, value);
217                }
218                else {
219                    $(args.element).html($(args.element).html().replace(pattern, value));
220                }
221            }
222        });
223        return args.html;
224
225    },
226    formatNumber: function (number) {
227        number = parseInt(number);
228        number = Math.max(0, number).toFixed(0).replace(/(?=(?:\d{3})+$)(?!^)/g, ',');
229        return number;
230    },
231
232    renderTemplate: function (templateName, data, keyPrefix) {
233        if ($('*[data-template-name="' + templateName + '"]').length == 0) { return ''; }
234        var html = Fundable.utilities.replaceTemplateKeys({ data: data, html: $('*[data-template-name="' + templateName + '"]').html(), keyPrefix: keyPrefix });
235        return html;
236    },
237    selectTab: function (tabName) {
238        $('div.tabbable').find('a[href="#' + tabName + '"]').click();
239    }
240}
241

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.