1/****************************************************************/ 2/* BEGIN of VnnAdsLoader Class by Thanh Bon, 01.2007, VASC */ 3/* http://javascriptcompressor.com/ */ 4/****************************************************************/ 5 6function VnnAdsLoader(placeHolderId, data, brownInterval) 7{ 8 //ad in mobile scroll 9 if(placeHolderId == 'mobile_scroll') { 10 var temp = ''; 11 var width = $( window ).width(); 12 var height = $( window ).height(); 13 try{ 14 var obj = data[0].items[0]; 15 temp = 16 '<div id="admbackground" style="position: relative; z-index: 5; margin: 0px auto; overflow: initial; height: '+height+'px;">'+ 17 '<div id="admbackground_1" style="position: absolute;width: 100%;height: '+height+'px;clip: rect(0 '+width+'px '+height+'px -20px);">'+ 18 '<div id="adm_inpage" style="display: inline-block;width: '+width+'px;height: '+height+'px;;position: fixed;top: 0;left: 0;-webkit-backface-visibility: hidden;-webkit-transform: translate3d(0,0,0);">'+ 19 '<div id="adm-inpage-h" style="display: block;height:'+height+'px;position: relative;">'+ 20 '<img style="border: none;height: '+height+'px;width: '+width+'px;overflow: hidden;margin:0 auto;" src="'+obj.logo+'" />'+ 21 '<a rel="nofollow" href="'+obj.link+'" target="_blank" onclick="javascript:adClick(\''+obj.stats+'\', \''+obj.link+'\');" style="position: absolute;top:0;left:0;height:100%;width:100%;opacity:0"></a>'+ 22 '</div>'+ 23 '</div>'+ 24 '</div>'+ 25 '</div>'; 26 27 } 28 catch (e){ 29 console.log(e); 30 } 31 var numCenter = parseInt($("#content p").length/2); 32 if(width < 1024) { 33 $( temp ).insertAfter( $($("#content p")[numCenter]) ); 34 } 35 } 36 37 if(placeHolderId == 'popup_mobile') { 38 var temp = ''; 39 var width = $( window ).width(); 40 var height = $( window ).height(); 41 try 42 { 43 var obj = data[0].items[0]; 44 temp = 45 '<div id="myModal" class="modal">'+ 46 '<div class="modal-content">'+ 47 '<span class="close">×</span>'+ 48 '<p>'+ 49 '<a href="javascript:void(1);" onclick="javascript:adClick(\''+obj.stats+'\', \''+obj.link+'\');"><img src="'+obj.logo+'" /></a>'+ 50 '</p>'+ 51 '</div>'+ 52 '</div>'; 53 } 54 catch (e) 55 { 56 } 57 58 if(width < 1024) { 59 $( "body" ).append( temp); 60 $("#myModal").modal() 61 } 62 } 63 64 this.error = ''; 65 if (document.getElementById(placeHolderId)) 66 { 67 var boxControl = document.getElementById("box_" + placeHolderId); 68 if (boxControl) { 69 boxControl.style.display = ""; 70 } 71 72 this.placeHolderControl = document.getElementById(placeHolderId); 73 this.placeHolderControl.style.display = 'block'; 74 75 this.blocks = data; 76 this.adCount = this.blocks.length; 77 this.randPrefix = Math.floor(Math.random()*100000) + 100000; 78 this.mode = this.placeHolderControl.getAttribute("adMode"); 79 this.direction = this.placeHolderControl.getAttribute("adDirection"); 80 this.width = this.placeHolderControl.getAttribute("adWidth"); 81 this.height = this.placeHolderControl.getAttribute("adHeight"); 82 this.classe = this.placeHolderControl.getAttribute("adClass"); 83 this.showTitle = this.placeHolderControl.getAttribute("adShowTitle"); 84 85 this.brownTimmer = 0; 86 this.downloadCompleted = false; 87 88 if (brownInterval) this.brownInterval = brownInterval; 89 else this.brownInterval = 10000; 90 91 // Dat gia tri vao block de su dung trong cac timmer 92 for (var i=0; i<this.blocks.length; i++) 93 { 94 this.blocks[i].width = this.width; 95 this.blocks[i].height = this.height; 96 this.blocks[i].classe = this.classe; 97 this.blocks[i].direction = this.direction; 98 } 99 } 100 else this.error = 'PLACE_HOLDER_NOT_FOUND'; 101 102 // methodes 103 this.brownRunningZone = brownRunningZone; 104 this.brownZone = brownZone; 105 106 this.doLoad = doLoad; 107 this.fadeBlock = fadeBlock; 108 this.swapBlocks = swapBlocks; 109 this.genSquelette = genSquelette; 110 this.rotateBlock = rotateBlock; 111 this.onRotateBlock = onRotateBlock; 112 this.onRotateZone = onRotateZone; 113 this.fillAdPlace = fillAdPlace; 114 this.downloadImage = downloadImage; 115 this.swapfade = swapfade; 116 this.brownBlock = brownBlock; 117 this.stopBlocksSwapping = stopBlocksSwapping;
118 this.genObjectCode = genObjectCode; 119 120 // animation methods 121 this.JSFX_KeepInView = JSFX_KeepInView; 122} 123 124/***************************************************************************** 125 List the images that need to be cached 126*****************************************************************************/ 127function downloadImage() 128{ 129 //cache the images 130 this.blocks.cache = []; 131 var imageIndex = 0; 132 for(var i=0; i<this.adCount; i++) 133 { 134 this.blocks.cache[imageIndex] = new Image; 135 this.blocks.cache[imageIndex].src = this.blocks[i].items[0].logo; 136 imageIndex++; 137 138 // write img tag 139 var control_id = this.randPrefix + '_' + i; 140 141 document.getElementById(control_id).style.display = 'block'; 142 this.fillAdPlace(control_id, this.blocks[i]); 143 } 144 145 for(var i=0; i<this.adCount; i++) 146 { 147 for (var j=1; j<this.blocks[i].items.length; j++) 148 { 149 this.blocks.cache[imageIndex] = new Image; 150 this.blocks.cache[imageIndex].src = this.blocks[i].items[j].logo; 151 imageIndex++; 152 } 153 } 154 this.downloadCompleted = true; 155} 156 157function doLoad() 158{ 159 if (this.error) return; 160 161 var self = this; 162 163 this.placeHolderControl.innerHTML = this.genSquelette(); 164 165 this.downloadImage(); 166 167 // RANDOM FIRST IMAGE WHEN REFRESH PAGE 168 if (self.mode == 'brown') { 169 this.brownRunningZone(); // ramdom zone 170 } 171 //this.brownZone(); // random block's ads 172 173 if (self.mode == 'brown' && this.brownInterval > 1) 174 { 175 window.clearInterval(self.brownTimmer); 176 self.brownTimmer = window.setInterval(function() { self.brownRunningZone(); }, this.brownInterval); 177 } 178 179 this.onRotateZone(); 180 181} 182/* Keep In View (c) JavaScript-FX. (www.javascript-fx.com) */ 183function JSFX_KeepInView(id){ 184 var getPageY=function(el){return(el==null)?0:el.offsetTop+getPageY(el.offsetParent);}; 185 var getScrollTop=function(){return document.body.scrollTop||document.documentElement.scrollTop}; 186 var el=document.getElementById(id);if(el==null)return; 187 if(el.style.position=="absolute"){el.startPageTop=-el.offsetTop;el.currentX=el.offsetLeft;el.currentY=el.offsetTop;} 188 else{el.style.position="relative";el.startPageTop=getPageY(el);el.currentX=el.currentY=0;}; 189 el.floatInView=function(){ 190 var targetY=(getScrollTop()>this.startPageTop)?getScrollTop()-this.startPageTop:0; 191 this.currentY+=(targetY-this.currentY)/4;this.style.top=this.currentY+"px";}; 192 setInterval('document.getElementById("'+id+'").floatInView()',40); 193}; 194 195function onRotateZone() 196{ 197 for (var i=0; i<this.blocks.length; i++) 198 { 199 this.onRotateBlock(this.blocks[i], i); 200 } 201} 202 203function onRotateBlock(block, block_index) 204{ 205 if ((block.rotateInterval > 0) && (block.items.length > 1)) 206 { 207 block.img_control_id = '' + this.randPrefix + '_' + block_index; 208 window.clearInterval(block.timmer); 209 block.timmer = window.setInterval(function() { this.fadeBlock(block, block.img_control_id); }, block.rotateInterval); 210 } 211} 212 213function stopBlocksSwapping() 214{ 215 for (var i=0; i<this.blocks.length; i++) 216 window.clearInterval(this.blocks[i].timmer); 217} 218 219// brown blocks when they are running 220function brownRunningZone() 221{ 222 this.stopBlocksSwapping(); 223 for (var i=0; i<this.blocks.length-1; i++) 224 { 225 226 if (!this.blocks[i].dock || this.blocks[i].dock == false) 227 { 228 //var rand = Math.floor(Math.random()*1000) % (this.blocks.length - i - 1) + i + 1; 229 var rand = Math.floor(Math.random()*this.blocks.length); 230 if (!this.blocks[rand].dock || this.blocks[rand].dock == false) 231 this.swapBlocks(i, rand); 232 } 233 } 234 this.onRotateZone(); 235} 236 237// swap two blocks when they are running 238function swapBlocks(index1, index2) 239{ 240 if (this.downloadCompleted == false) return; 241 242 var temp = this.blocks[index1]; 243 this.blocks[index1] = this.blocks[index2]; 244 this.blocks[index2] = temp; 245 this.fadeBlock(this.blocks[index1], this.randPrefix + '_' + index1); 246 this.fadeBlock(this.blocks[index2], this.randPrefix + '_' + index2); 247} 248 249function brownZone() 250{ 251 252 // this.stopBlocksSwapping(); khong can goi ham nay 253 254 for (var i=0; i<this.blocks.length; i++) 255 { 256 //this.brownBlock(this.blocks[i]); 257 this.brownBlock(i); 258 } 259 //this.onRotateZone(); Neu bat dong thu nhat thi phai bat dong nay 260} 261 262 263function brownBlock(i) 264{ 265; 266 if (this.blocks[i].items.length < 2) return; 267 268 var rand = Math.floor(Math.random()*(this.blocks[i].items.length-1)) + 1; 269 270 var temp = this.blocks[i].items[0]; 271 272 swapBlocks(0, rand); 273} 274 275function fadeBlock(adArray, img_control_id) 276{ 277 if (this.downloadCompleted == false) return; 278 279 adArray.clock = null; 280 adArray.fade = true; 281 adArray.count = 1; 282 283 var imgControl = document.getElementById(img_control_id); 284 this.rotateBlock(adArray);
285 this.swapfade(img_control_id, adArray, '1', ''); 286} 287 288function rotateBlock(adArray) 289{ 290 if (adArray.rotateInterval <=0) return; 291 292 var len = adArray.items.length; 293 294 if (len<=1) return; 295 296 var item0 = adArray.items[0]; 297 298 for (var i=0; i<len-1; i++ ) 299 { 300 adArray.items[i] = adArray.items[i+1]; 301 } 302 303 adArray.items[len-1] = item0; 304} 305 306function genSquelette() 307{ 308 var squelette = '<table border="0" cellspacing="0" cellpadding="0" width="100%">'; 309 310 for (var i=0; i<this.adCount; i++) 311 { 312 var linkId = this.randPrefix + '_' + i; 313 314 // preview 315 var placeHolder = '<table id="tbl_{temp_table_id}" style="background-color: #dedede; border: 3px solid #eee;" cellspacing="0" cellpadding="0" width="{width}px" height="{height}px"><tr><td align="center"><a href="{ad_url}" id="{ad_link_id}">{ad_title}</a></td></tr></table>'; 316 placeHolder = placeHolder.replace("{ad_title}", this.blocks[i].items[0].title); 317 placeHolder = placeHolder.replace("{temp_table_id}", linkId); 318 placeHolder = placeHolder.replace("{width}", (this.width==null)?this.blocks[i].items[0].width:this.width); 319 placeHolder = placeHolder.replace("{height}", (this.height==null)?this.blocks[i].items[0].height:this.height); 320 placeHolder = placeHolder.replace("{ad_url}", this.blocks[i].items[0].link); 321 322 var adLink = '<tr><td align="center" valign="middle" id="{ad_link_id}">{ad_place_holder}</td></tr>'; 323 adLink = adLink.replace("{ad_link_id}", linkId); 324 adLink = adLink.replace("{ad_place_holder}", placeHolder); 325 squelette += adLink; 326 } 327 squelette += '</table>'; 328 329 return squelette; 330} 331 332function genObjectCode(control_id, block, isFirst) 333{ 334 335 var rand = 0; 336 if (isFirst) { 337 if (block.items.length > 1) { 338 rand = Math.floor(Math.random()*block.items.length); 339 isFirst = false; 340 } 341 } 342 343 var adHtml = ''; 344 var type = block.items[rand].type; 345 346 if (typeof type != 'undefined' && type=='swf') 347 { 348 adHtml = '<span onMousedown="adClick(\'{ad_stats_url}\', \'#\');"><embed src="{ad_src}" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" type="application/x-shockwave-flash" {ad_width} {ad_height}></span><BR />'; 349 } 350 else if (typeof type != 'undefined' && (type=='script' || type=='html')) 351 { 352 adHtml = block.items[rand].content; 353 } 354 else 355 adHtml = '<a href="javascript:void(1);" onclick="javascript:adClick(\'{ad_stats_url}\', \'{ad_url}\');"><img class="{ad_class}" alt="{ad_alt}" {ad_title} {ad_width} {ad_height} src="{ad_src}" /></a>'; 356 357 adHtml = adHtml.replace(/{ad_src}/g, block.items[rand].logo); 358 adHtml = adHtml.replace(/{ad_class}/g, block.classe); 359 adHtml = adHtml.replace("{ad_url}", block.items[rand].link); 360 adHtml = adHtml.replace("{ad_stats_url}", (block.items[rand].stats + '&m=1')); 361 adHtml = adHtml.replace("{ad_alt}", block.items[rand].title); 362 363 if (this.showTitle && this.showTitle == 'on') 364 { 365 adHtml = adHtml.replace("{ad_title}", 'title="' + block.items[rand].title + '"'); 366 } 367 else 368 { 369 adHtml = adHtml.replace("{ad_title}", ""); 370 } 371 372 if (block.direction == 'horizontal') 373 { 374 adHtml = adHtml.replace(/{ad_height}/g, 'height="'+((block.height==null)?block.items[rand].height:block.height)+'"'); 375 adHtml = adHtml.replace(/{ad_width}/g, 'width="'+((block.width==null)?block.items[rand].width:block.width)+'"'); 376 } 377 else 378 { 379 adHtml = adHtml.replace(/{ad_width}/g, 'width="'+((block.width==null)?block.items[rand].width:block.width)+'"'); 380 if (typeof type == 'undefined' || type=='swf') 381 adHtml = adHtml.replace(/{ad_height}/g, 'height="'+((block.height==null)?block.items[rand].height:block.height)+'"'); 382 else 383 adHtml = adHtml.replace(/{ad_height}/g, ''); 384 } 385 386 return adHtml; 387} 388 389 390// Support Script Item:: BEGIN 391function appendChild(node, text) { 392 if (null == node.canHaveChildren || node.canHaveChildren) { 393 node.appendChild(document.createTextNode(text)); 394 } else { 395 node.text = text; 396 } 397} 398 399function showScript(code) { 400 //document.writeln(code); 401} 402// Support Script Item:: END 403 404function fillAdPlace(control_id, block) 405{ 406 407 var tempTable = document.getElementById('tbl_' + control_id); 408 tempTable.parentNode.removeChild(tempTable); 409
410 // Support Script Item:: BEGIN 411 var type = block.items[0].type; 412 var code = block.items[0].content; 413 if (typeof type != 'undefined' && type=='script') { 414 //var script = document.createElement("script"); 415 //script.setAttribute('type','text/javascript'); 416 //appendChild(script, "showScript('"+code+"');"); 417 $("#"+control_id).append(code); 418 } 419 // Support Script Item:: END 420 else { 421 document.getElementById(control_id).innerHTML = this.genObjectCode(control_id, block, true); 422 } 423} 424 425// DOM scripting by brothercake -- http://www.brothercake.com/ 426function swapfade(img_control_id, adArray, resolution, alt) 427{ 428 if(typeof alt != 'undefined' && alt != '') 429 { 430 adArray.obj.alt = alt; 431 } 432 var control = document.getElementById(img_control_id); 433 // Support Script Item:: BEGIN 434 var type = adArray.items[0].type; 435 var code = adArray.items[0].content; 436 if (typeof type != 'undefined' && type=='script') { 437 var script = document.createElement("script"); 438 script.setAttribute('type','text/javascript'); 439 appendChild(script, "showScript('"+code+"');"); 440 control.appendChild(script); 441 } 442 // Support Script Item:: END 443 else { 444 control.innerHTML = this.genObjectCode(img_control_id, adArray, false); 445 } 446}; 447 448 449function adClick(stats_url, ad_url) 450{ 451 var r = "http://sime.vn"; 452 453 if (document.referrer) r = escape(document.referrer); 454 try { 455 if (ad_url != '#') { 456 newwin = window.open(ad_url, '_blank'); 457 } 458 element = document.createElement('div'); 459 element.innerHTML = '<img id="stat_img" style="display: none;" alt="" src="' +stats_url.replace("{REFERRER}", r) + '" width="0" height="0"/>'; 460 document.body.appendChild(element); 461 } 462 catch (e) {} 463 464 return false; 465} 466 467function setup_player(id) { 468 469 var videoRoll = ""; 470 var bannerRoll = ""; 471 try 472 { 473 if(preroll && preroll[0] && preroll[0].items) { 474 var item = preroll[0].items; 475 for (var i =0; i < item.length ; i++) { 476 if(item[i].type == 'preroll') { 477 videoRoll = item[i].logo; 478 } 479 if(item[i].type == 'preroll_banner') { 480 bannerRoll = item[i].logo; 481 } 482 483 } 484 } 485 486 } 487 catch (e) 488 { 489 } 490 491 var myFP = fluidPlayer( 492 id, { 493 layoutControls: { 494 primaryColor: "#28B8ED", 495 autoPlay: false, 496 playButtonShowing: true, 497 playPauseAnimation: true, 498 allowTheatre: false, 499 playbackRateEnabled: true, 500 controlBar: { 501 autoHide: true, 502 autoHideTimeout: 5, 503 animated: true 504 }, 505 }, 506 vastOptions: { 507 adText: 'Quảng cáo', 508 adTextPosition: 'top left', 509 adList: [ 510 { 511 roll: 'preRoll', 512 vastTag: videoRoll 513 }, 514 { 515 roll: 'midRoll', 516 vastTag: bannerRoll, 517 timer: 3 518 }, 519 520 ] 521 } 522 } 523 ); 524}
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.