1/* 2What it does: This file has the most common functions of javascript which are used from 3 almost all the pages. 4 Here is a list of all the functions within this page: 5 GetElement(yid) 6 GetOpenerElement(yid) 7 round_(ynum, ydec) 8 trim_(ystr) 9 SuffixZeros(ynum, ydec) 10 setCookie_(name, value, expires, path, domain, secure) 11 getCookie_(name) 12 CenterThisWindow(xwidth, xheight, xpercent) 13 ShowPopupImage(yzoomimage) 14 debug(ystr) 15 16Referred by: Almost all web pages. 17*/ 18 19// Start: detect bonus area 20//Save screen width and height in cookies 21//window.onerror="return true"; 22//var xy = navigator.appVersion; 23//xz = xy.substring(0,4); 24 25/* 26document.cookie = "ScreenWidth=" + screen.width 27document.cookie = "ScreenHeight=" + screen.height 28*/ 29 30//window.onerror="return false"; 31// End: detect bonus area 32 33function GetElement(yid) 34{ 35 try 36 { 37 return document.getElementById(yid); 38 } 39 catch(err) 40 { 41 ErrorHandle(err,"xp5_general.js"); 42 } 43} 44 45function GetOpenerElement(yid) 46{ 47 try 48 { 49 return opener.document.getElementById(yid); 50 } 51 catch(err) 52 { 53 ErrorHandle(err,"xp5_general.js"); 54 } 55} 56 57function round_(ynum, ydec) { 58 try 59 { 60 var xstr = "1"; 61 var xnum, xinter; 62 for (k=0;k<ydec;k++) 63 { 64 xstr = xstr + "0"; 65 } 66 xnum = parseFloat(xstr); 67 xinter = Math.round(ynum*xnum); 68 return (xinter/xnum); 69 } 70 catch(err) 71 { 72 ErrorHandle(err,"xp5_general.js"); 73 } 74}; 75 76function trim_(ystr) 77{ 78 try 79 { 80 var xfound = false 81 if (ystr.length == 0) return "" 82 for (var k=0; k<ystr.length;k++) 83 { 84 if (!xfound) 85 { 86 if (ystr.charAt(k) == " ") 87 { 88 } 89 else 90 { 91 ystr = ystr.substring(k, ystr.length) 92 xfound = true 93 break 94 } 95 } 96 } 97 if (!xfound) ystr = "" 98 99 xfound = false 100 if (ystr.length == 0) return "" 101 for (k=ystr.length-1; k>=0;k--) 102 { 103 if (!xfound) 104 { 105 if (ystr.charAt(k) == " ") 106 { 107 } 108 else 109 { 110 ystr = ystr.substring(0, k+1) 111 xfound = true 112 break 113 } 114 } 115 } 116 if (!xfound) ystr = "" 117 return ystr 118 } 119 catch(err) 120 { 121 ErrorHandle(err,"xp5_general.js"); 122 } 123} 124 125function numberWithCommas(x) { 126 return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); 127} 128 129function SuffixZeros(ynum, ydec) 130{ 131 try 132 { 133 ynum = round_(ynum, ydec) 134 ystr = ynum + "" 135 if (ystr.indexOf(".") < 0) 136 { 137 ystr = ystr + "." 138 } 139 xpos = ystr.indexOf(".") 140 xlen = ystr.length 141 xst = xlen - xpos 142 for (var k=xst; k<= ydec;k++) 143 { 144 ystr = ystr + "0" 145 } 146 return ystr; 147 } 148 catch(err) 149 { 150 ErrorHandle(err,"xp5_general.js"); 151 } 152} 153 154function setCookie_(name, value, expires, path, domain, secure) 155{ 156 try 157 { 158 var curCookie = name + "=" + escape(value) + 159 ((expires) ? "; expires=" + expires.toGMTString() :"") + 160 ((path) ? "; path=" + path : "") + 161 ((domain) ? "; domain=" + domain : "") + 162 ((secure) ? "; secure" : "") 163 if ((name + "=" + escape(value)).length <= 4000) 164 { 165 document.cookie = curCookie 166 } 167 else 168 { 169 document.cookie = curCookie 170 } 171 } 172 catch(err) 173 { 174 ErrorHandle(err,"xp5_general.js"); 175 } 176} 177 178function getCookie_(name) 179{ 180 try 181 { 182 var prefix = name + "=" 183 var cookieStartIndex = document.cookie.indexOf(prefix) 184 if (cookieStartIndex < 0) 185 { 186 return ''; 187 } 188 189 var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length) 190 if (cookieEndIndex < 0) 191 { 192 cookieEndIndex = document.cookie.length 193 } 194 return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex)) 195 } 196 catch(err) 197 { 198 ErrorHandle(err,"xp5_general.js"); 199 } 200} 201 202function CenterThisWindow(xwidth, xheight, xpercent) 203{ 204 try 205 { 206 if (xpercent) 207 { 208 xwidth = screen.width * xpercent * 0.01 209 xheight = screen.height * xpercent * 0.01 210 } 211 var xleft = (screen.width - xwidth) / 2; 212 var xtop = (screen.height - xheight) / 2; 213 return 'left='+xleft+', top='+xtop+', width='+xwidth+', height='+xheight; 214 } 215 catch(err) 216 { 217 ErrorHandle(err,"xp5_general.js"); 218 } 219} 220 221//var $PopupImage_dialog 222function ShowPopupImage(yzoomimage, ypath) { 223 var xwin1; 224 try 225 { 226 xpath = "" 227 if (ypath) 228 { 229 xpath = "&path=1" 230 } 231 else 232 { 233 yzoomimage = "\\xp2\\images\\" + yzoomimage 234 } 235 SSImagedialog = null; 236 SSImagedialog = new SSImageDialog(); 237 SSImagedialog.dialog_id = "dialog"; 238 SSImagedialog.image_id = "dialog_image"; 239 SSImagedialog.ImageUrl = yzoomimage; 240 SSImagedialog.isTitle = false; 241 SSImagedialog.ShowImage(); 242 } 243 catch(err) 244 { 245 ErrorHandle(err,"xp5_general.js"); 246 } 247 } 248 249function debug(ystr) 250{ 251 try 252 {
253 if (debugflag || xdebugon == '1') 254 { 255 alert(ystr) 256 } 257 } 258 catch(err) 259 { 260 ErrorHandle(err,"xp5_general.js"); 261 } 262} 263 264function DELETE_gotoThisWizard(yurl, ycatgid, ysubcatgid, yXML, yWizardID, yHeight, yWidth, ynumcolor, ycomingsoon, yHeading, yPrintColors, yShapeId, yVarNames, yVarValues, yImage, yPopupImage, yconcode, xtermsofuse) 265{ 266 try 267 { 268 269 //yWizardID = yWizardID.replace(/,/,""); 270 //yWizardID = yWizardID.replace(/=/,""); 271 272 273 if (yurl.length==0 || yurl=='comingsoon' || ycomingsoon.toLowerCase() == 'true') 274 { 275 alert('Coming Soon') 276 return 277 } 278 document.preview.catgid.value = ycatgid 279 document.preview.subcatgid.value = ysubcatgid 280 document.preview.templateXML.value = yXML 281 document.preview.wizardid.value = yWizardID 282 document.preview.templateH.value = yHeight 283 document.preview.templateW.value = yWidth 284 document.preview.numcolor.value = ynumcolor 285 286 document.preview.printcolors.value = yPrintColors 287 document.preview.designshape.value = yShapeId 288 289 document.preview.ProductHeading.value=yHeading 290 document.preview.Image.value=yImage 291 document.preview.PopupImage.value=yPopupImage 292 document.preview.InitConcode.value=yconcode 293 294 if (yVarNames.length > 0) 295 { 296 document.all.divShell.innerHTML = "" 297 aVarNames = yVarNames.split(";") 298 aVarValues = yVarValues.split(";") 299 var xstr = "" 300 for (k=0; k<aVarNames.length; k++) 301 { 302 if (!document.preview[aVarNames[k]]) 303 { 304 305 xstr = xstr + '<input type="hidden" name="' + aVarNames[k] + '" value="' + aVarValues[k] + '">' 306 } 307 } 308 document.all.divShell.innerHTML = xstr 309 } 310 311 312 document.preview.target = "_self" 313 document.preview.action = yurl 314 document.preview.submit() 315 } 316 catch(err) 317 { 318 ErrorHandle(err,"xp5_general.js"); 319 } 320} 321 322function ShowMatPrices(yform, yWizardId, yCatgId, ySubCatgId, yH, yW, ynumcolor, yShapeId, yTemplateXML) 323{ 324 try 325 { 326 var xwidth=750; 327 var xheight=480; 328 var xleft = (screen.width - xwidth) / 2; 329 var xtop = (screen.height - xheight) / 2; 330 var mpwin = window.open('about:blank', 'mpwin', 'left='+xleft+',top='+xtop+',width='+xwidth+',height='+xheight+',resizable,scrollbars') 331 if (document[yform].WizardId) 332 { 333 document[yform].WizardId.value = yWizardId 334 } 335 if (document[yform].wizardid) 336 { 337 document[yform].wizardid.value = yWizardId 338 } 339 340 if (yCatgId) 341 { 342 if (document[yform].CatgId) 343 { 344 document[yform].CatgId.value = yCatgId 345 } 346 if (document[yform].catgid) 347 { 348 document[yform].catgid.value = yCatgId 349 } 350 } 351 352 if (ySubCatgId) 353 { 354 if (document[yform].SubCatgId) 355 { 356 document[yform].SubCatgId.value = ySubCatgId 357 } 358 if (document[yform].subcatgid) 359 { 360 document[yform].subcatgid.value = ySubCatgId 361 } 362 } 363 364 if (yH) 365 { 366 if (document[yform].TemplateH) 367 { 368 document[yform].TemplateH.value = yH 369 } 370 if (document[yform].templateH) 371 { 372 document[yform].templateH.value = yH 373 } 374 } 375 376 if (yW) 377 { 378 if (document[yform].TemplateW) 379 { 380 document[yform].TemplateW.value = yW 381 } 382 if (document[yform].templateW) 383 { 384 document[yform].templateW.value = yW 385 } 386 } 387 388 if (ynumcolor) 389 { 390 if (document[yform].numcolor) 391 { 392 document[yform].numcolor.value = ynumcolor 393 } 394 } 395 396 if (yShapeId) 397 { 398 if (document[yform].ShapeId) 399 { 400 document[yform].ShapeId.value = yShapeId 401 } 402 if (document[yform].shapeid) 403 { 404 document[yform].shapeid.value = yShapeId 405 } 406 } 407 408 if (yTemplateXML) 409 { 410 if (document[yform].TemplateXML) 411 { 412 document[yform].TemplateXML.value = yTemplateXML 413 } 414 if (document[yform].templateXML) 415 { 416 document[yform].templateXML.value = yTemplateXML 417 } 418 if (document[yform].templatexml) 419 { 420 document[yform].templatexml.value = yTemplateXML 421 } 422 } 423 424 document[yform].target = "mpwin" 425 document[yform].action = "/xp5/material_prices.asp" 426 document[yform].submit() 427 } 428 catch(err) 429 { 430 ErrorHandle(err,"xp5_general.js"); 431 } 432} 433 434 435//Designer mobile text size -+ 436function swipe(id, action) { 437 if (action == 'show') { 438 $(id).animate({ opacity: 1.0, right: "0" }, 500, function () { 439 // Animation complete. 440 }); 441 } else if (action == 'hide') { 442 $(id).animate({ opacity: 0.25, right: "-160" }, 500, function () { 443 // Animation complete. 444 }); 445 } 446}
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.