1//format string 2(function (exports) { 3 //change float to US currency format 4 exports.FloatToCurrency = function (float) { 5 if (isNaN(float)) { 6 return "$0.00"; 7 } 8 return '$' + parseFloat(float).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,"); 9 }; 10})(this.format = {}); 11 12//cookie 13(function (exports) { 14 //exdays set to NaN, cookie expire in session close. exdays set to time before current time, cookie will be deleted. 15 exports.set = function (cname, cvalue, exdays) { 16 var expires = ""; 17 if (cvalue) { //save cookie 18 if (isNaN(exdays)) { //set expire time to "session" 19 expires = "expires="; 20 } else { //set expire time to specific day 21 var d = new Date(); 22 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 23 expires = "expires=" + d.toUTCString(); 24 } 25 } else { //kill cookie 26 cvalue = ""; 27 expires = "expires=" + "Thu, 01 Jan 1970 00:00:00 GMT"; 28 } 29 document.cookie = cname + "=" + cvalue + "; " + expires + "path=/"; 30 }; 31 32 //get cookie by name 33 exports.get = function (cname) { 34 var name = cname + "="; 35 var ca = document.cookie.split(';'); 36 for (var i = 0; i < ca.length; i++) { 37 var c = ca[i].trim(); 38 if (c.indexOf(name) == 0) { 39 return c.substring(name.length, c.length); 40 } 41 } 42 return ""; 43 }; 44})(this.cookie = {}); 45 46//screen position, based on cookie module 47(function (exports) { 48 var cookieName = "screen-position"; 49 var coordinate = { x: 0, y: 0 }; 50 51 var getScreenCoordinate = function () { 52 var doc = document.documentElement; 53 coordinate = { 54 x: (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0), 55 y: (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0) 56 }; 57 return coordinate; 58 }; 59 60 var retrievePositionFromCookie = function () { 61 var position = cookie.get(cookieName); 62 if (position.length > 0 && position.indexOf("," > 0)) { 63 var _coordinate = position.split(","); 64 coordinate = { 65 x: (isNaN(_coordinate[0])) ? 0 : parseFloat(_coordinate[0]), 66 y: (isNaN(_coordinate[1])) ? 0 : parseFloat(_coordinate[1]) 67 }; 68 } 69 else { 70 coordinate = { x: 0, y: 0 }; 71 } 72 return coordinate; 73 }; 74 75 var killCurrentScreenPositionInCookie = function () { 76 cookie.set(cookieName, "", ""); 77 }; 78 79 var scrollToPosition = function () { 80 window.scrollTo(coordinate.x, coordinate.y); 81 }; 82 83 var isPositionDefault = function () { 84 if (coordinate.x === 0 && coordinate.y === 0) { 85 return true; 86 } 87 return false; 88 }; 89 90 //save screen position to cookie 91 exports.saveCurrentScreenPositionToCookie = function () { 92 getScreenCoordinate(); 93 cookie.set(cookieName, coordinate.x + "," + coordinate.y, "session"); 94 }; 95 96 //scroll screen to position in cookie 97 exports.pageLoadScrollScreen = function () { 98 retrievePositionFromCookie(); 99 if (!isPositionDefault()) { 100 scrollToPosition(); 101 } 102 killCurrentScreenPositionInCookie(); 103 }; 104})(this.screenPosition = {}); 105 106//tabs 107(function (exports) { 108 var $links = {}; 109 var $active = {}; 110 var $content = {} 111 //initiate with ul ("#"+id) 112 exports.initiate = function (tabheader) { 113 $links = $(tabheader).find("li"); 114 $active = $links.first(); 115 $content = $($active.find("a").first()[0].hash); 116 117 $active.find("a").first().addClass("active"); 118 $content.show(); 119 $links.not($active).each(function () { 120 var a = $(this).find("a").first()[0]; 121 $(a.hash).hide(); 122 }); 123 124 $links.each(function () { 125 var $a = $(this).find("a").first(); 126 $a.click(function (event) { 127 event.preventDefault(); 128 $active.find("a").first().removeClass("active"); 129 $content.hide(); 130 $active = $(this).closest("li"); 131 $active.find("a").first().addClass("active"); 132 $content = $(this.hash); 133 $content.show(); 134 }) 135 }) 136 } 137})(this.tab = {}); 138 139//JavaScript object 140(function (exports) { 141 //check an obj whether it is null or empty 142 exports.isNullOrEmpty = function (obj) { 143 if (obj) { 144 for (var key in obj) { 145 if (!obj.hasOwnProperty(key)) { 146 return false; 147 } 148 } 149 return true; 150 } 151 return false; 152 }; 153})(this.objectExtensions = {});
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.