• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

javascript-uhr

nipos

Mitglied
ich schaffe es nicht in dieses script eine uhr einzufügen die stellen die unterstrichen sind sollen verändert oder nicht verändert werden das steht dahinter
HTML:
<script type="text/javascript" src="https://dl-web.dropbox.com/get/TIME2.js?w=68fbb2eb"></script> //nicht änderbar nur ich kann die datei ändern das ist das javascript der uhr und funktioniert auch<div id="time"></div> //die uhr zumindes der sichtbare teil <script LANGUAGE="JavaScript"><!--// Copyright 1996 - Tomer and Yehuda Shiran
// This example will appear in our forthcoming book on JavaScript.// Feel free to "steal" this code provided that you leave this notice as is.// Additional examples from the book can be found at http://www.geocities.com/SiliconValley/9000/// For more information contact Tomer or Yehuda Shiran <[email protected]>// set messages
var messages = new Array()
messages[0] = "" //hier sollte der sichtbare teil der uhr hin damit er angezeigt wird zum test wie die uhr dargestellt werden soll kann ein text eingegeben werden das script funktioniert bei texten aber leider nicht mit der uhr
// set normal spacing between two characters (no whitespace inbetween)var space = 0
// set height width of each charactervar height = 9var width = 7
// create object of all supported characters in fontvar letters = new letterArray()
// initialize image variablesvar on = new Image(5, 5)var off = new Image(5, 5)
// set image URLson.src = "http://waitingmoon.com/image/blue.png"off.src = "http://waitingmoon.com/image/black.png"
// get number of images already layed out in pagevar imageNum = document.images.length
// set maximum message length in charactersvar boardWidth = 0
for (var i = 0; i < messages.length; ++i) {    var lengthWithNoSpaces = messages[i].split(" ").join("").length    var numberOfSpaces = messages[i].length - lengthWithNoSpaces    var currentBoardWidth = lengthWithNoSpaces * (width + space) - space + numberOfSpaces * space * 2    if (boardWidth < currentBoardWidth)        boardWidth = currentBoardWidth}// sign is currently not runningvar running = falsevar timerID = null
function letterArray() {    this.a = new Array(height)    this.a[0] = "       "    this.a[1] = "  ***  "    this.a[2] = " *   * "    this.a[3] = " *   * "    this.a[4] = " ***** "    this.a[5] = " *   * "    this.a[6] = " *   * "    this.a[7] = " *   * "    this.a[8] = "       "
    this.b = new Array(height)    this.b[0] = "       "    this.b[1] = " ****  "    this.b[2] = " *   * "    this.b[3] = " *   * "    this.b[4] = " ****  "    this.b[5] = " *   * "    this.b[6] = " *   * "    this.b[7] = " ****  "    this.b[8] = "       "
    this.c = new Array(height)    this.c[0] = "       "    this.c[1] = "  **** "    this.c[2] = " *     "    this.c[3] = " *     "    this.c[4] = " *     "    this.c[5] = " *     "    this.c[6] = " *     "    this.c[7] = "  **** "    this.c[8] = "       "
    this.d = new Array(height)    this.d[0] = "       "    this.d[1] = " ****  "    this.d[2] = " *   * "    this.d[3] = " *   * "    this.d[4] = " *   * "    this.d[5] = " *   * "    this.d[6] = " *   * "    this.d[7] = " ****  "    this.d[8] = "       "
    this.e = new Array(height)    this.e[0] = "       "    this.e[1] = " ***** "    this.e[2] = " *     "    this.e[3] = " *     "    this.e[4] = " ***** "    this.e[5] = " *     "    this.e[6] = " *     "    this.e[7] = " ***** "    this.e[8] = "       "
    this.f = new Array(height)    this.f[0] = "       "    this.f[1] = " ***** "    this.f[2] = " *     "    this.f[3] = " *     "    this.f[4] = " ***** "    this.f[5] = " *     "    this.f[6] = " *     "    this.f[7] = " *     "    this.f[8] = "       "
    this.g = new Array(height)    this.g[0] = "       "    this.g[1] = "  ***  "    this.g[2] = " *     "    this.g[3] = " *     "    this.g[4] = " * *** "    this.g[5] = " *   * "    this.g[6] = " *   * "    this.g[7] = "  ***  "    this.g[8] = "       "
    this.h = new Array(height)    this.h[0] = "       "    this.h[1] = " *   * "    this.h[2] = " *   * "    this.h[3] = " *   * "    this.h[4] = " ***** "    this.h[5] = " *   * "    this.h[6] = " *   * "    this.h[7] = " *   * "    this.h[8] = "       "
    this.i = new Array(height)    this.i[0] = "       "    this.i[1] = "  ***  "    this.i[2] = "   *   "    this.i[3] = "   *   "    this.i[4] = "   *   "    this.i[5] = "   *   "    this.i[6] = "   *   "    this.i[7] = "  ***  "    this.i[8] = "       "
    this.j = new Array(height)    this.j[0] = "       "    this.j[1] = "     * "    this.j[2] = "     * "    this.j[3] = "     * "    this.j[4] = "     * "    this.j[5] = " *   * "    this.j[6] = " *   * "    this.j[7] = "  ***  "    this.j[8] = "       "
    this.k = new Array(height)    this.k[0] = "       "    this.k[1] = " *   * "    this.k[2] = " *  *  "    this.k[3] = " * *   "    this.k[4] = " **    "    this.k[5] = " * *   "    this.k[6] = " *  *  "    this.k[7] = " *   * "    this.k[8] = "       "
    this.l = new Array(height)    this.l[0] = "       "    this.l[1] = " *     "    this.l[2] = " *     "    this.l[3] = " *     "    this.l[4] = " *     "    this.l[5] = " *     "    this.l[6] = " *     "    this.l[7] = " ***** "    this.l[8] = "       "
    this.m = new Array(height)    this.m[0] = "       "    this.m[1] = " *   * "    this.m[2] = " ** ** "    this.m[3] = " * * * "    this.m[4] = " *   * "    this.m[5] = " *   * "    this.m[6] = " *   * "    this.m[7] = " *   * "    this.m[8] = "       "
    this.n = new Array(height)    this.n[0] = "       "    this.n[1] = " *   * "    this.n[2] = " *   * "    this.n[3] = " **  * "    this.n[4] = " * * * "    this.n[5] = " *  ** "    this.n[6] = " *   * "    this.n[7] = " *   * "    this.n[8] = "       "
    this.o = new Array(height)    this.o[0] = "       "    this.o[1] = "  ***  "    this.o[2] = " *   * "    this.o[3] = " *   * "    this.o[4] = " *   * "    this.o[5] = " *   * "    this.o[6] = " *   * "    this.o[7] = "  ***  "    this.o[8] = "       "
    this.p = new Array(height)    this.p[0] = "       "    this.p[1] = " ****  "    this.p[2] = " *   * "    this.p[3] = " *   * "    this.p[4] = " ****  "    this.p[5] = " *     "    this.p[6] = " *     "    this.p[7] = " *     "    this.p[8] = "       "
    this.q = new Array(height)    this.q[0] = "       "    this.q[1] = "  **** "    this.q[2] = " *   * "    this.q[3] = " *   * "    this.q[4] = "  **** "    this.q[5] = "     * "    this.q[6] = "     * "    this.q[7] = "     * "    this.q[8] = "       "
    this.r = new Array(height)    this.r[0] = "       "    this.r[1] = " ****  "    this.r[2] = " *   * "    this.r[3] = " *   * "    this.r[4] = " ****  "    this.r[5] = " *   * "    this.r[6] = " *   * "    this.r[7] = " *   * "    this.r[8] = "       "
    this.s = new Array(height)    this.s[0] = "       "    this.s[1] = "  **** "    this.s[2] = " *     "    this.s[3] = " *     "    this.s[4] = "  ***  "    this.s[5] = "     * "    this.s[6] = "     * "    this.s[7] = " ****  "    this.s[8] = "       "
    this.t = new Array(height)    this.t[0] = "       "    this.t[1] = " ***** "    this.t[2] = "   *   "    this.t[3] = "   *   "    this.t[4] = "   *   "    this.t[5] = "   *   "    this.t[6] = "   *   "    this.t[7] = "   *   "    this.t[8] = "       "
    this.u = new Array(height)    this.u[0] = "       "    this.u[1] = " *   * "    this.u[2] = " *   * "    this.u[3] = " *   * "    this.u[4] = " *   * "    this.u[5] = " *   * "    this.u[6] = " *   * "    this.u[7] = "  ***  "    this.u[8] = "       "
    this.v = new Array(height)    this.v[0] = "       "    this.v[1] = " *   * "    this.v[2] = " *   * "    this.v[3] = " *   * "    this.v[4] = " *   * "    this.v[5] = " *   * "    this.v[6] = "  * *  "    this.v[7] = "   *   "    this.v[8] = "       "
    this.w = new Array(height)    this.w[0] = "       "    this.w[1] = " *   * "    this.w[2] = " *   * "    this.w[3] = " *   * "    this.w[4] = " *   * "    this.w[5] = " * * * "    this.w[6] = " ** ** "    this.w[7] = " *   * "    this.w[8] = "       "
    this.x = new Array(height)    this.x[0] = "       "    this.x[1] = " *   * "    this.x[2] = " *   * "    this.x[3] = "  * *  "    this.x[4] = "   *   "    this.x[5] = "  * *  "    this.x[6] = " *   * "    this.x[7] = " *   * "    this.x[8] = "       "
    this.y = new Array(height)    this.y[0] = "       "    this.y[1] = " *   * "    this.y[2] = "  * *  "    this.y[3] = "   *   "    this.y[4] = "   *   "    this.y[5] = "   *   "    this.y[6] = "   *   "    this.y[7] = "   *   "    this.y[8] = "       "
    this.z = new Array(height)    this.z[0] = "       "    this.z[1] = " ***** "    this.z[2] = "     * "    this.z[3] = "    *  "    this.z[4] = "   *   "    this.z[5] = "  *    "    this.z[6] = " *     "    this.z[7] = " ***** "    this.z[8] = "       "//fortsetzung folgt fortsetzung ist nötig damit es funktioniert
 
Werbung:
fortsetzung:
HTML:
    this['!'] = new Array(height)    this['!'][0] = "       "    this['!'][1] = "   *   "    this['!'][2] = "   *   "    this['!'][3] = "   *   "    this['!'][4] = "   *   "    this['!'][5] = "   *   "    this['!'][6] = "       "    this['!'][7] = "   *   "    this['!'][8] = "       "
    this[':'] = new Array(height)    this[':'][0] = "       "    this[':'][1] = "       "    this[':'][2] = "   *   "    this[':'][3] = "       "    this[':'][4] = "       "    this[':'][5] = "       "    this[':'][6] = "   *   "    this[':'][7] = "       "    this[':'][8] = "       "
    this['.'] = new Array(height)    this['.'][0] = "       "    this['.'][1] = "       "    this['.'][2] = "       "    this['.'][3] = "       "    this['.'][4] = "       "    this['.'][5] = "       "    this['.'][6] = "       "    this['.'][7] = "   *   "    this['.'][8] = "       "
    this['='] = new Array(height)    this['='][0] = "       "    this['='][1] = "       "    this['='][2] = "       "    this['='][3] = " ***** "    this['='][4] = "       "    this['='][5] = " ***** "    this['='][6] = "       "    this['='][7] = "       "    this['='][8] = "       "
    this['+'] = new Array(height)    this['+'][0] = "       "    this['+'][1] = "       "    this['+'][2] = "   *   "    this['+'][3] = "   *   "    this['+'][4] = " ***** "    this['+'][5] = "   *   "    this['+'][6] = "   *   "    this['+'][7] = "       "    this['+'][8] = "       "
    this['-'] = new Array(height)    this['-'][0] = "       "    this['-'][1] = "       "    this['-'][2] = "       "    this['-'][3] = "       "    this['-'][4] = " ***** "    this['-'][5] = "       "    this['-'][6] = "       "    this['-'][7] = "       "    this['-'][8] = "       "
    this['/'] = new Array(height)    this['/'][0] = "       "    this['/'][1] = "       "    this['/'][2] = "     * "    this['/'][3] = "    *  "    this['/'][4] = "   *   "    this['/'][5] = "  *    "    this['/'][6] = " *     "    this['/'][7] = "       "    this['/'][8] = "       "
    this['\\'] = new Array(height)    this['\\'][0] = "       "    this['\\'][1] = "       "    this['\\'][2] = " *     "    this['\\'][3] = "  *    "    this['\\'][4] = "   *   "    this['\\'][5] = "    *  "    this['\\'][6] = "     * "    this['\\'][7] = "       "    this['\\'][8] = "       "
    this['"'] = new Array(height)    this['"'][0] = "       "    this['"'][1] = " *   * "    this['"'][2] = " *   * "    this['"'][3] = "       "    this['"'][4] = "       "    this['"'][5] = "       "    this['"'][6] = "       "    this['"'][7] = "       "    this['"'][8] = "       "
    this["'"] = new Array(height)    this["'"][0] = "       "    this["'"][1] = "   *   "    this["'"][2] = "   *   "    this["'"][3] = "       "    this["'"][4] = "       "    this["'"][5] = "       "    this["'"][6] = "       "    this["'"][7] = "       "    this["'"][8] = "       "
    this['('] = new Array(height)    this['('][0] = "       "    this['('][1] = "    *  "    this['('][2] = "   *   "    this['('][3] = "  *    "    this['('][4] = "  *    "    this['('][5] = "  *    "    this['('][6] = "   *   "    this['('][7] = "    *  "    this['('][8] = "       "
    this[')'] = new Array(height)    this[')'][0] = "       "    this[')'][1] = "  *    "    this[')'][2] = "   *   "    this[')'][3] = "    *  "    this[')'][4] = "    *  "    this[')'][5] = "    *  "    this[')'][6] = "   *   "    this[')'][7] = "  *    "    this[')'][8] = "       "
    this['*'] = new Array(height)    this['*'][0] = "       "    this['*'][1] = "       "    this['*'][2] = "   *   "    this['*'][3] = "   *   "    this['*'][4] = " ***** "    this['*'][5] = "  * *  "    this['*'][6] = " *   * "    this['*'][7] = "       "    this['*'][8] = "       "
    this['…'] = new Array(height)    this['…'][0] = "   *   "    this['…'][1] = "  ***  "    this['…'][2] = "  ***  "    this['…'][3] = "*******"    this['…'][4] = "* *** *"    this['…'][5] = "*******"    this['…'][6] = "  ***  "    this['…'][7] = "  ***  "    this['…'][8] = "  * *  "
    this['_'] = new Array(height)    this['_'][0] = "       "    this['_'][1] = "       "    this['_'][2] = "       "    this['_'][3] = "       "    this['_'][4] = "       "    this['_'][5] = "       "    this['_'][6] = "       "    this['_'][7] = "       "    this['_'][8] = "       "
    this['?'] = new Array(height)    this['?'][0] = "       "    this['?'][1] = "  ***  "    this['?'][2] = " *   * "    this['?'][3] = "    *  "    this['?'][4] = "   *   "    this['?'][5] = "   *   "    this['?'][6] = "       "    this['?'][7] = "   *   "    this['?'][8] = "       "
    this['0'] = new Array(height)    this['0'][0] = "       "    this['0'][1] = " ***** "    this['0'][2] = " *   * "    this['0'][3] = " *   * "    this['0'][4] = " *   * "    this['0'][5] = " *   * "    this['0'][6] = " *   * "    this['0'][7] = " ***** "    this['0'][8] = "       "
    this['1'] = new Array(height)    this['1'][0] = "       "    this['1'][1] = "   *   "    this['1'][2] = "  **   "    this['1'][3] = "   *   "    this['1'][4] = "   *   "    this['1'][5] = "   *   "    this['1'][6] = "   *   "    this['1'][7] = "   *   "    this['1'][8] = "       "
    this['2'] = new Array(height)    this['2'][0] = "       "    this['2'][1] = " ***** "    this['2'][2] = "     * "    this['2'][3] = "     * "    this['2'][4] = " ***** "    this['2'][5] = " *     "    this['2'][6] = " *     "    this['2'][7] = " ***** "    this['2'][8] = "       "
    this['3'] = new Array(height)    this['3'][0] = "       "    this['3'][1] = " ***** "    this['3'][2] = "     * "    this['3'][3] = "     * "    this['3'][4] = "  **** "    this['3'][5] = "     * "    this['3'][6] = "     * "    this['3'][7] = " ***** "    this['3'][8] = "       "
    this['4'] = new Array(height)    this['4'][0] = "       "    this['4'][1] = " *   * "    this['4'][2] = " *   * "    this['4'][3] = " *   * "    this['4'][4] = " ***** "    this['4'][5] = "     * "    this['4'][6] = "     * "    this['4'][7] = "     * "    this['4'][8] = "       "
    this['5'] = new Array(height)    this['5'][0] = "       "    this['5'][1] = " ***** "    this['5'][2] = " *     "    this['5'][3] = " *     "    this['5'][4] = " ***** "    this['5'][5] = "     * "    this['5'][6] = "     * "    this['5'][7] = " ***** "    this['5'][8] = "       "
    this['6'] = new Array(height)    this['6'][0] = "       "    this['6'][1] = " ***** "    this['6'][2] = " *     "    this['6'][3] = " *     "    this['6'][4] = " ***** "    this['6'][5] = " *   * "    this['6'][6] = " *   * "    this['6'][7] = " ***** "    this['6'][8] = "       "
    this['7'] = new Array(height)    this['7'][0] = "       "    this['7'][1] = " ***** "    this['7'][2] = "     * "    this['7'][3] = "     * "    this['7'][4] = "    *  "    this['7'][5] = "   *   "    this['7'][6] = "   *   "    this['7'][7] = "   *   "    this['7'][8] = "       "
    this['8'] = new Array(height)    this['8'][0] = "       "    this['8'][1] = " ***** "    this['8'][2] = " *   * "    this['8'][3] = " *   * "    this['8'][4] = " ***** "    this['8'][5] = " *   * "    this['8'][6] = " *   * "    this['8'][7] = " ***** "    this['8'][8] = "       "
    this['9'] = new Array(height)    this['9'][0] = "       "    this['9'][1] = " ***** "    this['9'][2] = " *   * "    this['9'][3] = " *   * "    this['9'][4] = " ***** "    this['9'][5] = "     * "    this['9'][6] = "     * "    this['9'][7] = " ***** "    this['9'][8] = "       "//fortsetzung folgt fortsetzung ist nötig damit das script funktioniert
 
HTML:
}function drawBlank() {    // assign greater than symbol to variable    var gt = unescape("%3e")    document.write('<div style="position:absolute;top:104px;left:351px"><TD WIDTH=2000 BGCOLOR="#000000" ALIGN="center" VALIGN="center"' + gt)    // print entire board of off images    for (var y = 0; y < height; ++y) {        for (var x = 0; x < boardWidth; ++x) {            document.write('<IMG SRC="http://waitingmoon.com/image/black.png" HEIGHT=11 WIDTH=10' + gt)        }        document.write('<br>')    }    document.write('</TD' + gt + '</TR' + gt + '</TABLE' + gt)}
function setLight(state, x, y) {    // set a specific light in sign to on (true) or off (false)    if (state)        document.images[computeIndex(x, y)].src = on.src    else        document.images[computeIndex(x, y)].src = off.src}
function drawLetter(letter, startX) {    // draws a letter at the given x coordinate    for (var x = 0; x < width; ++x) {        for (var y = 0; y < height; ++y) {            setLight(letters[letter][y].charAt(x) == "*", startX + x, y)        }    }}
function drawSpace(startX) {    // create a small space between each two characters    for (var x = 0; x < space; ++x) {        for (var y = 0; y < height; ++y) {            setLight(false, startX + x, y)        }    }}
function computeIndex(x, y) {    // compute the document index of an image in the sign, based on the x-y coordinates    return (y * boardWidth + x) + imageNum}
function floodBoard(startX) {    // set all lights from startX to off    for (var x = startX; x < boardWidth; ++x) {        for (var y = 0; y < height; ++y) {            setLight(false, x, y)        }    }}
function drawMessage(num) {    // initialize variable to current message    var text = messages[num]    // initialize two counters (j - current character in message, i - current x coordinate)    var i = 0    var j = 0    while (1) {        if (text.charAt(j) != " ") {            // draw current letter            drawLetter(text.charAt(j), i)            // increment i by the constant width of an image            i += width        }        else {            // add an extra space (do not advance j yet)            drawSpace(i)            i += space        }        // if j is less that index of last character        if (j < text.length - 1) {            drawSpace(i)            i += space        }        else            // j is the index of the last character (lsat character already printed)            break            // increment j by one because one letter was printed            ++j        }        // flood the remaining piece of the sign (turn it off)        floodBoard(i)        // if message printed this time was not the last one in the array        if (num < messages.length - 1)            // val *must* be a global variable for use with the timeout            val = ++num        else            val = 0 // start cycle over again            // recursive call after waiting 3 seconds (some of the time already passed during printing)            timerID = setTimeout("drawMessage(val)", 3000)        }        // open form        document.write('<FORM>')        // create initial sign (all sign is off)        drawBlank()
function startSign() {    // wait 3 seconds and then call function to print first message    drawMessage(0)    running = true}
function stopSign() {    if(running)        clearTimeout(timerID)        running = false    }    document.write('<NPUT TYPE="button" VALUE="start" onClick="startSign()">')    document.write('<IPUT TYPE="button" VALUE="stop" onClick="stopSign(); floodBoard(0)">')    document.write('</FORM>')        document.write('<body style="background-color:#000000" onload="startSign();showTime()">')// --></script>
das war es jetzt bitte alle stücke als1 javascript benutzen ich musste es nur wegen der maximalzeichenzahl trennen es war zu lang
 
Werbung:
die sehen nicht so aus wie meine und ausserdem sollte sie zum text mit dieser schrift passen und ausserdem musst du um die frage zu beantworten nur die unterstrichenen zeilen in den ersten 10 zeilen suchen es sind 3 unterstrichene stücke der rest funktioniert
 
Um ehrlich zu sein, habe ich den unterstrichenen Text nicht gefunden, was sicher auch mit diesem gruseligen Array zusammenhängen mag. Wer denkt sich denn so einen Schrott aus? Das ist sinnfreier Spaghetti-Code. Wenn du das komplette Alphabet samt Sonderzeichen abbilden willst, dann iteriere darüber in in einer Schleife, anstatt alle Zeichen einzeln und zusätzlich noch mehrfach aufzuführen. :???:

Der Dropbox-Link funktioniert übrigens nicht. Insofern ist nicht mal ersichtlich, wie deine Uhr aussehen soll.
 
Werbung:
1. in einer sache muss ich dir recht geben das was ich unterstrichen habe ist trotzdem normal angezeigt zeile eins der link(bitte durch direkten uhrcode ersetzen) zeile zwei(div) soll in zeile sechs also so angezeigt werden wie der text den man in zeile sechs zwischen " und " einfügt 2. der dropbox link funktioniert wirklich nicht also hier ist das uhr script das script zeigt die uhr in ganz normalen zahlen an aber das lange script macht daraus schönere zahlen mit normalem text funktioniert das script für schöne buchstaben und zahlen und normal eingebunden funktioniert auch die uhr aber ist dann nur in größe 12 schriftart arial und farbe schwarz uhrcode(früher dropbox-link):
HTML:
<script>// JavaScript Documentvar maxt;function showTime() {   maxt = setTimeout( "showTime()", 1000 );   myDate = new Date();      // Get time parts   hours   = myDate.getHours();   minutes = myDate.getMinutes();   seconds = myDate.getSeconds();      // Just to display the time in a nice format   if (hours < 10)   hours   = "0" + hours;   if (minutes < 10) minutes = "0" + minutes;   if (seconds < 10) seconds = "0" + seconds;      // Change the block content   document.getElementById("time").innerHTML = hours+":"+minutes+":"+seconds; }</script>
tipp:unter folgendem link alles testen(onlinehtmleditor)HTML Instant : Real-Time HTML Editor
 
Zurück
Oben