dlad.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. var delta=0.08
  2. var collection;
  3. var dl;
  4. function floaters() {
  5. this.items = [];
  6. this.addItem = function(id,x,y,content)
  7. {
  8. document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute; width:80px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');
  9. var newItem = {};
  10. newItem.object = document.getElementById(id);
  11. newItem.x = x;
  12. newItem.y = y;
  13. this.items[this.items.length] = newItem;
  14. }
  15. this.play = function()
  16. {
  17. collection = this.items
  18. dl=setInterval('play()',10);
  19. }
  20. }
  21. function play()
  22. {
  23. for(var i=0;i<collection.length;i++)
  24. {
  25. var followObj = collection[i].object;
  26. var followObj_x = (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
  27. var followObj_y = (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);
  28. if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) {
  29. var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
  30. dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
  31. followObj.style.left=followObj.offsetLeft+dx;
  32. }
  33. if(followObj.offsetTop!=(document.body.scrollTop+followObj_y)) {
  34. var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta;
  35. dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
  36. followObj.style.top=followObj.offsetTop+dy;
  37. }
  38. followObj.style.display = '';
  39. }
  40. }
  41. function dlonc(){
  42. document.getElementById("followDiv1").style.display="none";
  43. document.getElementById("followDiv2").style.display="none";
  44. clearInterval(dl);
  45. }