/* ====================================== * * Made by Richie Grey * * WebBuild.in * * HTML-coder, JavaScript developer, * * icq 823-784 * * email rich@richie.com.ua * * * * All rights reserved (c)2008. * * ====================================== */ /* | MARQUE | Module creates div object with running line | for start using you need just add this code | where you need to create Running Line: | | | | If You need to change text in Running Line | Just call this function: | | marq.renew("New text"); | | For customizing Running Line use following | CSS classes: | #RuningLine - for text | #RunningLineBG - for background | | For more info you can write to: | rich@richie.com.ua */ String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); }; var marq = { options: { width: 0, // 0 for AUTO height: 20, // 0 for AUTO step : 1, // STEP OF MARQUEE speed : 20, // SPEED OF MARQUEE emptySpace: 1, //Empty space between Last news and first news blank_text : '
Hello, this is Running Line, created by Richie Grey. If you need to consult about using this script You can find me with contacts below. ICQ #823784. MSN: richie.grey@hotmail.com. EMAIL rich@richie.com.ua
', // blank_text : '
Hello, this is Running Line, created by Richie Grey. If you need to consult about using this script You can find me with contacts below. ICQ #823784. MSN: richie.grey@hotmail.com. EMAIL rich@richie.com.ua
', // Text that will be showed if needed text is absent direction: 'left' // left or right }, text: '', dir: 0, scrWidth: 0, scr2Width: 0, realWidth: 0, realEmptySpace: 0, scr: document.createElement("DIV"), scr2: document.createElement("DIV"), warp: null, timer: null, move: function () { x = parseInt(marq.scr.style.left); x = x + (marq.options.step*marq.dir); // document.getElementById('console').innerHTML = marq.scrWidth + ':' + x; if (x == marq.scrWidth*(-1)) { update_marquee(1); // x = marq.scr2Width + marq.realEmptySpace*2 - marq.realWidth; } marq.scr.style.left = x+'px'; x = parseInt(marq.scr2.style.left); x = x + (marq.options.step*marq.dir); // document.getElementById('console').innerHTML += "---" + marq.scr2Width + ':' + x; if (x == marq.scr2Width*(-1)) { update_marquee(2); // x = marq.scrWidth + marq.realEmptySpace*2 - marq.realWidth; } marq.scr2.style.left = x+'px'; }, init: function (t) { document.write('
<\/div>'); marq.warp = document.getElementById('RunningLineBG'); marq.scr.setAttribute("id", "RuningLine"); marq.warp.appendChild(marq.scr); marq.scr2.setAttribute("id", "RuningLine"); marq.warp.appendChild(marq.scr2); marq.warp.style.width = marq.options.width!=0 ? marq.options.width+'px' : 'auto'; marq.warp.style.position = 'relative'; marq.warp.style.overflow = 'hidden'; marq.scr.style.overflow = 'hidden'; marq.scr2.style.overflow = 'hidden'; marq.scr.style.position = 'absolute'; marq.scr.style.left = '-500px'; marq.scr.style.whiteSpace='nowrap'; marq.scr2.style.position = 'absolute'; marq.scr2.style.left = '-500px'; marq.scr2.style.whiteSpace='nowrap'; //marq.renew(t); marq.attachEvent(marq.warp, "mouseover", marq.mouseOver); marq.attachEvent(marq.warp, "mouseout", marq.mouseOut); marq.dir = marq.options.direction=='left' ? -1 : 1; marq.timer= setInterval('marq.move()',marq.options.speed); // document.write('
console...<\/div>'); }, renew: function (t) { marq.text= !t || t.trim()=='' ? marq.options.blank_text : t; marq.scr.style.width = 'auto'; marq.scr2.style.width = 'auto'; marq.scr2.innerHTML = marq.text; marq.scr.innerHTML = marq.text; marq.warp.style.height = marq.scr.scrollHeight+'px'; //marq.warp.style.height = marq.scr.scrollHeight+0+'px'; marq.scrWidth = marq.scr.scrollWidth; marq.scr2Width = marq.scrWidth; marq.realWidth = marq.warp.offsetWidth; marq.realEmptySpace = Math.round(marq.realWidth*marq.options.emptySpace/100) if (marq.scrWidth < marq.realWidth-marq.realEmptySpace) { scrWidth = marq.realWidth-marq.realEmptySpace; marq.scr.style.width = scrWidth +'px'; marq.scrWidth = scrWidth; } marq.scr.style.left = marq.realWidth+'px'; scr2Left = marq.realWidth + marq.scrWidth + marq.realEmptySpace; marq.scr2.style.left = scr2Left +'px'; }, renew_div1: function (t) { marq.text= !t || t.trim()=='' ? marq.options.blank_text : t; marq.scr.style.width = 'auto'; marq.scr.innerHTML = marq.text; marq.warp.style.height = marq.scr.scrollHeight+5+'px'; marq.scrWidth = marq.scr.scrollWidth; marq.realWidth = marq.warp.offsetWidth; marq.realEmptySpace = Math.round(marq.realWidth*marq.options.emptySpace/100) if (marq.scrWidth < marq.realWidth-marq.realEmptySpace) { scrWidth = marq.realWidth-marq.realEmptySpace; marq.scr.style.width = scrWidth +'px'; marq.scrWidth = scrWidth; } // marq.scr.style.left = marq.scr2Width - marq.scr2.style.left + (marq.realEmptySpace * 2) +'px'; marq.scr.style.left = marq.scr2Width + parseInt(marq.scr2.style.left) + marq.realEmptySpace*2 +'px'; // alert('div1' + "\n" + marq.scrWidth + "\n" + marq.scr2Width + "\n"); }, renew_div2: function (t) { marq.text= !t || t.trim()=='' ? marq.options.blank_text : t; marq.scr2.style.width = 'auto'; marq.scr2.innerHTML = marq.text; marq.warp.style.height = marq.scr.scrollHeight+5+'px'; marq.scr2Width = marq.scr2.scrollWidth; marq.realWidth = marq.warp.offsetWidth; marq.realEmptySpace = Math.round(marq.realWidth*marq.options.emptySpace/100) if (marq.scr2Width < marq.realWidth-marq.realEmptySpace) { scr2Width = marq.realWidth-marq.realEmptySpace; marq.scr2.style.width = scr2Width +'px'; marq.scr2Width = scr2Width; } // marq.scr2.style.left = marq.scrWidth - marq.scr.style.left + (marq.realEmptySpace * 2) + 'px'; marq.scr2.style.left = marq.scrWidth + parseInt(marq.scr.style.left) + marq.realEmptySpace*2 + 'px'; // alert('div2' + "\n" + marq.scrWidth + "\n" + marq.scr2Width + "\n"); }, attachEvent: function(o, e, a){ if (o.addEventListener) o.addEventListener(e, a, false); // was true--Opera 7b workaround! else if (o.attachEvent) o.attachEvent("on" + e, a); else return null; }, mouseOver: function(e) { clearInterval(marq.timer); }, mouseOut:function() { marq.timer= setInterval('marq.move()',marq.options.speed); } }