1var getCookie = function (name) { 2 var value = "; " + document.cookie; 3 var parts = value.split("; " + name + "="); 4 if (parts.length == 2) return parts.pop().split(";").shift(); 5}; 6 7var escapeRegExp = function (string) { 8 return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); 9}; 10 11var replaceAll = function (string, find, replace) { 12 if (typeof string !== 'undefined' || string != null) 13 return string.replace(new RegExp(escapeRegExp(find), 'g'), replace); 14 else 15 return ""; 16}; 17 18var getUri = function () { 19 var url = window.location.href; 20 var uri = url.substring(url.indexOf('#') + 1); 21 return uri; 22}; 23 24var getTrackPageView = function () { 25 $(document).off('click', '.track'); 26 $(document).on('click', '.track', function () { 27 $elem = $(this); 28 var trackTitleName = (typeof $elem.data('trackTitle') !== 'undefined') ? $elem.data('trackTitle') : ''; 29 var trackName = (typeof $elem.data('track') !== 'undefined') ? '/' + $elem.data('track') : ''; 30 var pathName = trackTitleName + trackName; 31 32 setTrackPageView(pathName); 33 }); 34 35}; 36 37var setTrackPageView = function (path) { 38 var pathName = getUri() + '/' + path; 39 window.ivc('trackPageView', pathName); 40 gtag('event', 'page_view', { 41 'page_title': pathName 42 }); 43 44 console.log(pathName); 45}; 46 47var sum = function (sumKey) { 48 return this.reduce(function (prev, curr) { 49 return prev + curr[sumKey]; 50 }, 0) 51}; 52 53var select = function (array) { 54 var newArray = new Array(); 55 this.map(function (item) { 56 var newObject = new Object(); 57 for (i = 0; i < array.length; i++) { 58 newObject[array[i]] = item[array[i]] 59 } 60 newArray.push(newObject); 61 }); 62 return newArray; 63}; 64 65var distinct = function () { 66 var newArray = new Array(); 67 68 var _hasSomeValue = function (newArray, item) { 69 return newArray.some(function (elem, i) { 70 return JSON.stringify(elem) == JSON.stringify(item); 71 }); 72 }; 73 74 for (var i = 0; i < this.length; i++) { 75 if (!_hasSomeValue(newArray, this[i])) 76 newArray.push(this[i]); 77 } 78 return newArray; 79} 80 81var where = function (key, arrayValues) { 82 var array = this; 83 var newArray = new Array(); 84 arrayValues.forEach(function (value) { 85 var _result = array.filter(function (elem, i) { 86 return String(elem[key]) == String(value); 87 }); 88 _result.forEach(function (result) { 89 newArray.push(result); 90 }); 91 }); 92 return newArray; 93}; 94 95var groupBy = function (aggregatorKey, arraySumKeys) { 96 var array = this; 97 var newArray = new Array(); 98 99 var _hasSomeValue = function (newArray, item) { 100 return newArray.some(function (elem, i) { 101 return elem[aggregatorKey] == item[aggregatorKey]; 102 }); 103 }; 104 105 array.forEach(function (item, i) { 106 var _result = array.filter(function (elem, i) { //WHERE 107 return elem[aggregatorKey] == item[aggregatorKey]; 108 }); 109 110 if (_result) { 111 if (!_hasSomeValue(newArray, item)) { //ANY 112 arraySumKeys.forEach(function (item) { 113 _result[0][item] = _result.sum(item) 114 }); 115 newArray.push(_result[0]); 116 } 117 } 118 }); 119 return newArray; 120}; 121 122var orderBy = function (key) { 123 return this.sort(function (a, b) { 124 if (a[key] > b[key]) 125 return 1; 126 127 if (a[key] < b[key]) 128 return -1; 129 130 return 0; 131 }); 132}; 133 134var different = function (array) { 135 return this.filter(function (i) { 136 return array.indexOf(i) < 0; 137 }); 138}; 139 140var equal = function (array) { 141 return this.filter(function (i) { 142 return array.indexOf(i) > -1; 143 }); 144}; 145 146var min = function () { 147 return Math.min.apply(null, this); 148}; 149 150var max = function () { 151 return Math.max.apply(null, this); 152}; 153 154//Array extensions 155Array.prototype.sum = sum; 156Array.prototype.select = select; 157Array.prototype.distinct = distinct; 158Array.prototype.where = where; 159Array.prototype.groupBy = groupBy; 160Array.prototype.orderBy = orderBy; 161Array.prototype.different = different; 162Array.prototype.equal = equal; 163Array.prototype.min = min; 164Array.prototype.max = max; 165 166 167var calcPercent = function (denominator) { 168 if (denominator > 0) 169 return (100 * (this / denominator)) 170 171 return 0; 172} 173 174var getClassPercent = function () { 175 if (this < 33.34) 176 return 'color-percent red'; 177 178 if (this < 66.67) 179 return 'color-percent yellow'; 180 181 return 'color-percent green'; 182} 183 184var getColorPercent = function () { 185 if (this < 33.34) 186 return '#E74C3C'; 187 188 if (this < 66.67) 189 return '#FFED00'; 190 191 return '#72C02C'; 192} 193 194//Number extensions 195Number.prototype.calcPercent = calcPercent; 196Number.prototype.getClassPercent = getClassPercent; 197Number.prototype.getColorPercent = getColorPercent; 198 199var initCircle = function (selector, percentage, multipleColors = true) { 200 201 var colors = ['#EEE', percentage.getColorPercent()] 202 if (!multipleColors) 203 colors = ['#EEE', '#72C02C'] 204 205 Circles.create({ 206 id: selector, 207 percentage: percentage, 208 radius: 40, 209 width: 2, 210 number: percentage, 211 text: '%', 212 colors: colors, 213 duration: 300, 214 });
215}; 216 217 218var sleep = function (milliseconds) { 219 var start = new Date().getTime(); 220 for (var i = 0; i < 1e7; i++) { 221 if ((new Date().getTime() - start) > milliseconds) { 222 break; 223 } 224 } 225} 226 227var showNotify = function (title, content, type, timeout, keepOpen) { 228 //type: success, info, warning, alert 229 230 var options = { 231 caption: title, 232 content: content, 233 type: type, 234 keepOpen: keepOpen 235 } 236 237 if (typeof timeout === 'number') 238 options.timeout = parseInt(timeout); 239 240 $.Notify(options); 241} 242 243var showLoading = function (element) { 244 var parentElem = element.find('ui-loading').parent(); 245 var loadingElem = element.find('ui-loading'); 246 var childrenElem = element.children(); 247 248 parentElem.addClass('container-loading'); 249 loadingElem.removeClass('hidden'); 250 childrenElem.not(loadingElem).addClass('disabled-div'); 251} 252 253var hideLoading = function (element) { 254 var parentElem = element.find('.container-loading'); 255 var loadingElem = element.find('ui-loading'); 256 var childrenElem = element.find('.disabled-div'); 257 258 setTimeout(function () { 259 parentElem.removeClass('container-loading'); 260 loadingElem.addClass('hidden'); 261 childrenElem.removeClass('disabled-div'); 262 }, 700) 263}; 264 265var hideAllLoading = function () { 266 var parentElem = $('.container-loading'); 267 var loadingElem = $('ui-loading'); 268 var childrenElem = $('.disabled-div'); 269 270 parentElem.removeClass('container-loading'); 271 loadingElem.addClass('hidden'); 272 childrenElem.removeClass('disabled-div'); 273} 274 275var getFirstDayOfMonth = function (date) { 276 if (!(date instanceof Date)) 277 date = new Date(); 278 return new Date(date.getFullYear(), date.getMonth(), 1); 279}; 280 281var getLastDayOfMonth = function (date) { 282 if (!(date instanceof Date)) 283 date = new Date(); 284 return new Date(date.getFullYear(), date.getMonth() + 1, 0); 285}; 286 287var getPreviousMonth = function (date) { 288 if (!(date instanceof Date)) 289 date = new Date(); 290 return new Date(date.getFullYear(), date.getMonth() - 1, 1); 291}; 292 293var getNextMonth = function (date) { 294 if (!(date instanceof Date)) 295 date = new Date(); 296 return new Date(date.getFullYear(), date.getMonth() + 2, 0) 297}; 298 299var getDate = function (date) { 300 if (!(date instanceof Date)) 301 date = new Date(); 302 return { 303 firstDay: getFirstDayOfMonth(date), 304 lastDay: getLastDayOfMonth(date), 305 previous: { 306 firstDay: getFirstDayOfMonth(getPreviousMonth(date)), 307 lastDay: getLastDayOfMonth(getPreviousMonth(date)) 308 }, 309 next: { 310 firstDay: getFirstDayOfMonth(getNextMonth(date)), 311 lastDay: getLastDayOfMonth(getNextMonth(date)) 312 } 313 }; 314};
315 316var isNullOrEmpty = function (value) { 317 if (isNull(value)) 318 return true; 319 else if (value instanceof Array) 320 return (value.length === 0); 321 else 322 return (value.toString().length === 0); 323} 324 325var isNull = function (value) { 326 return (value == null || value == undefined); 327} 328 329var removeAccents = function (str) { 330 var mapAccent = { "â": "a", "Ã": "A", "à ": "a", "Ã": "A", "á": "a", "Ã": "A", "ã": "a", "Ã": "A", "ê": "e", "Ã": "E", "è": "e", "Ã": "E", "é": "e", "Ã": "E", "î": "i", "Ã": "I", "ì": "i", "Ã": "I", "Ã": "i", "Ã": "I", "õ": "o", "Ã": "O", "ô": "o", "Ã": "O", "ò": "o", "Ã": "O", "ó": "o", "Ã": "O", "ü": "u", "Ã": "U", "û": "u", "Ã": "U", "ú": "u", "Ã": "U", "ù": "u", "Ã": "U", "ç": "c", "Ã": "C" }; 331 return str.replace(/[\W\[\] ]/g, function (s) { return mapAccent[s] || s }); 332} 333 334var setContentPopover = function (title, id, denominator, numerator, percent) { 335 return { 336 content: '(' + numeral(numerator).format(formatNumber) + '/' + numeral(denominator).format(formatNumber) + ') * 100 = ' + numeral(percent).format(formatPercent) + '%', 337 originalTitle: '<label>Denominador:</label><br>' + title + ' <i class="fa fa-eye" style="cursor:pointer;" data-scrollTo="' + id + '" onclick="scrollGoToPopovers(this)"></i>' 338 } 339}; 340 341var getPopoversOn = function () { 342 $('.popovers').popover({ 343 container: 'body', 344 placement: 'top', 345 html: true 346 }); 347 348 $(document).on('click', function () { 349 $(".popovers").popover('hide'); 350 }); 351 352 $('.planner tbody').on('scroll', function () { 353 $(".popovers").popover('hide'); 354 }); 355 356 $('.popovers').click(function (e) { 357 return false; 358 }); 359}; 360 361var scrollGoToPopovers = function (elem) { 362 $('html, body').animate({ 363 scrollTop: $(elem.dataset.scrollto).offset().top - 126 364 }, 1000); 365 $('.popovers').popover('hide'); 366}; 367 368var loadJs = function (url, callback) { 369 var js = document.createElement("script"); 370 371 //Verifica se o callback é uma função 372 if (typeof callback === "function") { 373 var isReady = false; 374 375 //Executa se for carregado no onload ou readystatechange 376 function ready() { 377 if (isReady) return; 378 379 //Bloqueia execução repetida do callback 380 isReady = true; 381 382 //Chama o callback 383 callback(); 384 } 385 386 js.onload = ready; 387 388 /*Internet explorer (http://stackoverflow.com/q/17978255/1518921)*/ 389 js.onreadystatechange = function () { 390 if (/^(complete|loaded)$/.test(js.readyState)) ready(); 391 } 392 } 393 394 js.async = true; 395 js.src = url; 396 document.body.appendChild(js); 397} 398
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.