JavaScripts -> Textticker -> Dot Matrix Scroller

Der Dot Matrix Scroller bildet eine Laufschrift aus Leuchtdioden nach.

Kompatibilität getestet:
Beispiel Anzeigen >>

Script-Code

<script type="text/javascript">
<!--
// = = ======================================================================== = =
// = = Dot Matrix Scroller v1.0 (c) 2003 Triple-M / http://www.htmlarsenal.de = =
// = = ======================================================================== = =

// --------------------------------------------------------------------------------
// -- Dieses Script und viele andere im --
// -- This script and many more in the --
// --------------------------------------------------------------------------------
// -- HTML ARSENAL - Die Quelle für HTML, JavaScript, PHP --
// -- HTML ARSENAL - Your Source for HTML, JavaScript, PHP --
// --------------------------------------------------------------------------------
// -- -= http://www.htmlarsenal.de =- --
// --------------------------------------------------------------------------------

// Sie dürfen dieses Script für nicht-kommerzielle Zwecke nutzen, wenn diese Urheber-Notiz erhalten bleibt.
// You may use this Script for non-commercial causes as long as you include this copyright notice.

// Benutzung:
// ==========

// An der Stelle, an der der Dot Matrix Scoller zu sehen sein soll, schreiben Sie ein Script mit dem
// Inhalt
// DotMatrixScroller(länge,text);
// wobei länge die Breite des Scrollers (in Buchstaben) ist und text der durchzuscrollende Text.

// Usage:
// ======

// Include a script with the content
// DotMatrixScroller(length,text);
// at the position where the dot matrix scroller shall be placed, where length is the width of the
// scroller (measured in characters) and text is the text to be scrolled.

// Veränderbare Einstellungen / Adjustable Settings
// ================================================

var dmspeed=200; // Geschwindigkeit / Speed

// Script-Code
// ===========

// Ab hier bitte nichts mehr verändern
// Please do not change anything from here on

var the_matrix=new Array();

//Matritzen für die einzelnen Zeichen, gepacked als 5-Byte-Zahl
//matrices for the single characters, packed as 5-Byte-Numbers

the_matrix[0] =0x0000000000; // Leerzeichen / Space

the_matrix[1] =0x3e4141413e; // 0
the_matrix[2] =0x44427f4040; // 1
the_matrix[3] =0x4261514946; // 2
the_matrix[4] =0x2241494936; // 3
the_matrix[5] =0x0f0808087f; // 4
the_matrix[6] =0x2f49494931; // 5
the_matrix[7] =0x3e49494932; // 6
the_matrix[8] =0x0101710907; // 7
the_matrix[9] =0x3649494936; // 8
the_matrix[10]=0x264949493e; // 9

the_matrix[11]=0x7c0a090a7c; // A
the_matrix[12]=0x7f49494936; // B
the_matrix[13]=0x3e41414122; // C
the_matrix[14]=0x7f4141413e; // D
the_matrix[15]=0x7f49494949; // E
the_matrix[16]=0x7f09090909; // F
the_matrix[17]=0x3e4149493a; // G
the_matrix[18]=0x7f0808087f; // H
the_matrix[19]=0x41417f4141; // I
the_matrix[20]=0x214141413f; // J
the_matrix[21]=0x7f08142241; // K
the_matrix[22]=0x7f40404040; // L
the_matrix[23]=0x7f0204027f; // M
the_matrix[24]=0x7f0408107f; // N
the_matrix[25]=0x3e4141413e; // O
the_matrix[26]=0x7f09090906; // P
the_matrix[27]=0x3e4151215e; // Q
the_matrix[28]=0x7f09192946; // R
the_matrix[29]=0x2649494932; // S
the_matrix[30]=0x01017f0101; // T
the_matrix[31]=0x3f4040403f; // U
the_matrix[32]=0x1f2040201f; // V
the_matrix[33]=0x7f2010207f; // W
the_matrix[34]=0x6314081463; // X
the_matrix[35]=0x0304780403; // Y
the_matrix[36]=0x6151494543; // Z


var dmtext;
var dmlength;
var dmoff;
var dmsub;
var dmp=new Array();

function charnum(ch) {
  n=ch.toLowerCase().charCodeAt(0);
  if(n==32)return 0;
  if((n>96) && (n<123)) return (n-86);
  if((n>47) && (n<58)) return (n-47);
  else return 0;
}


function dothematrix(length) {
  var col,row,cha;
  document.write('<table class="dm">');
  for(row=0;row<7;row++) {
    document.write('<tr>');
    for(cha=0;cha<length;cha++) {
      for(col=0;col<6;col++) {
        document.write('<td class="dm" id="dm'+(cha*6+col)+'_'+row+'"><\/td>');
      }
    }
    document.write('<\/tr>');
  }
  document.write('<\/table>');
}

function showthematrix() {
  for(i=0;i<dmlength+1;i++) {
    ch=dmtext.charAt(dmoff+i-dmlength-1);
    cn=charnum(ch);
    for(col=0;col<6;col++) {
      if((i*6+col)>=dmsub && (i*6+col-dmsub)<dmlength*6) {
        for(row=0;row<7;row++) {
         if(dmp[cn][col][row]) {
           document.getElementById('dm'+(i*6+col-dmsub)+'_'+row).style.backgroundColor="#ff0000";
          } else {
            document.getElementById('dm'+(i*6+col-dmsub)+'_'+row).style.backgroundColor="#000000";
          }
        }
      }
    }
  }
  dmsub++;
  if(dmsub>5) {
    dmsub=0;
    dmoff++;
  }
  if(dmoff>dmtext.length+dmlength) {
    dmoff=0;
  }
  window.setTimeout("showthematrix()",dmspeed);
}

function preparethematrix() {
  for(cn=0;cn<37;cn++) {
    dmp[cn]=new Array();
    for(col=0;col<6;col++) {
      dmp[cn][col]=new Array();
      if(col<5) {
        dbyte=Math.floor((the_matrix[cn]% Math.pow(256,(5-col))) / Math.pow(256,(4-col))) ;
        for(row=0;row<7;row++) {
          if(Math.floor(((dbyte% Math.pow(2,row+1)) /Math.pow(2,(row))) )>0) {
            dmp[cn][col][row]=1;
          } else {
            dmp[cn][col][row]=0;
          }
        }
      } else {
        for(row=0;row<7;row++)dmp[cn][col][row]=0;

      }
    }
  }
}



function DotMatrixScroller(length,text) {
  preparethematrix();
  dothematrix(length);
  dmlength=length;
  dmtext=text;
  dmoff=0;
  dmsub=1;
  showthematrix();
}

// ----------------------------
// -- Ende / End Script-Code --
// ----------------------------
// -- Dot Matrix Scroller --
// -- Author: Triple-M --
// -- www.htmlarsenal.de --
// -- 12.Oct.2003 --
// ----------------------------


//-->
</script>
<style type="text/css">
table.dm{
  border-collapse:separate;
  background-color:#000000;
  border-spacing:2px;
  table-layout:fixed;
  empty-cells:show
}

td.dm {
  background-color:#000000;
  width:3px;
  height:3px;
  border:0px none;
  font-size:1px;
}
</style>