JavaScript - cvičení

  1. Pomocí událoati onLoad spusťte při otevření stránky jazyk.html dotazovací okénko s možností výběru jazyka (en,cz,fr,de) a podle odpovědi zobrazte správnou jazykovou verzi. Jako text použijte báseň od Williama Blake Tygr viz. níže ve daných jazykových verzích.

    Potřebné "nástroje"
    onLoad
    window.prompt
    function
    document.getElemenById
    .innerHTML
    
    CSS
    <div>
    border-style:solid
    border-color:red
    bordr-width:1px
    width:400px
    
    
    en="<pre>\nTyger\n(William Blake)\n\nTyger, Tyger burning bright,\nIn the forest on the night:\nWhat immortal hand of eye.\nCould frame thy fearful symmetry?\n\nIn what distant deep or skies\nBurnt the fire of thine eyes?\nOn what wings dare he aspire?\nWhat the hand dare seize the fire?\n\nAnd what shoulder, what art\nCould twist the sinews on thy heart?\nAnd when thy heart began to beat,\nWhat dread hand? what dread feet?\n\nWhat the hammer? what the chain.\nIn what furnace was thy brain?\nWhat the anvil? what dread grasp\nDare is deadly terrors clasp?\n\nWhen the stars threw down their spears\nAnd wate´d heaven with their tears,\nDid he smile his work to see?\nDid he who made the Lamb make thee?\n\nTyger, Tyger, burning bright\nIn the forest of the night:\nWhat immortal hand or eye\nDare frame thy fearful symmetry?\n</pre>";
    fr="<pre>\nTigre O Tigre\n(William Blake)\n\nTigre O Tigre! Toi qui luis\nAu fond des forêts de la nuit,\nQuel esprit immortel sut faire\nTa symétrie meurtrière?\n\nSur quels gouffres et sous quels cieux\nBrûla-t-il le feu de tes yeux?\nQuelle aile prît un tel essor?\nQuel bras saisit ce feu, cet or?\n\nQuelle force de quel sculpteur\nTordit les tendons de ton cœur?\nEt quand ce cœur se mut en toi\nQuels pieds, quels bras, et quel effroi!\n\nA qui la chaîne, le marteau,\nLa forge où flamba ton cerveau,\nL'enclume? Quelle poigne cruelle\nCrut serrer ses terreurs mortelles?\n\nTout astre a déposé ses armes,\nEt trempé le ciel de ses larmes.\nSourit-il? Te fit-il Celui\nQui fit l'agneau au temps jadis?\n\nTigre O Tigre! Toi qui luis\nAu fond des forêts de la nuit,\nQuel immortel oserait faire\nTa symétrie meurtrière?\n</pre>";
    de="<pre>\nDer Tiger\n(William Blake)\n\nTiger, Tiger, Feuerspracht\nin der Dschungeln dunkler Nacht:\nWelches Aug', welch' ew'ge Hand\nformten Deiner Schrecken Brand?\n\nIn welch' Himmeln ungeheuer\nbrannte Deiner Augen Feuer?\nWessen Flügel, wessen Hand\nwagte sich an diesen Brand?\n\nWelcher Schulter Können wand\nDeines Herzens Sehnenstrang?\nWer, als Herzens Schlag begann,\nfurchtbar Hand und Fuß ersann?\n\nWelche Kett' und Hammer fand\nin welch' Esse den Verstand?\nWelcher Amboß, welche Welt\nDeine Todesschrecken hält?\n\nAls der Sterne Speer herab\nTränen unserm Himmel gab:\nHat vollbracht er's und bedacht,\ndaß er Lamm und Dich gemacht?\n\nTiger, Tiger, Feuerspracht\nin der Dschungeln dunkler Nacht:\nWelches Auge, welche Hand\nwagten Deines Schreckens Brand?\n</pre>";
    cz="<pre>\nTygr\n(William Blake)\n\nTygře tygře ohnivou\nzáříš svítíš lesní tmou\nkdo ten nesmrtelník byl\njenž z ní ti souměr setrojil\n\nV kterých hlubinách či nebesích\nhořel oheň v očích tvých\nkdo opovážil vlet se dál\nrukou tam ten oheň brát\n\nKdo v tvém srdci k svalu sval\numěním a silou spjal\nčí hrozná ruka mohla vzít\nsrdce když chce jalo bít\n\nKým byl mozek ukován\nv kterou pec byl potom dán\njeho hrůzy strašlivé\nkdo je sevřel v pěsti své\n\nA kdy hvězdy vrhaly střely\nspokojen byl s dílem svým\nje snad tvůrce beránků\ni stvořitelem tvým\n\nTygře tygře ohnivou\nzáříš svítíš lesní tmou\nkdo ten nesmrtelník byl\njenž z ní ti souměr setrojil\n</pre>";
    


    Tygr

  2. Modifikujte předchozí bod tak, aby byl ošetřen neznámý jazyk - varování znovu otázka

    Tygr

  3. Kontrola formuláře Vytvořte jednoduchý formulář - jedno input políčko "email" a odesílací tlačítko, při odeslání zkontrolujte, jestli je email korektně vyplněn

    Potřebné "nástroje"
    loc=window.location.href;
    onSubmit="return funkce();"
    var re = /^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/;
    re.test(email);
    


    Kontrola

  4. Stránku na které bude formulář s dvěmi vyplňovacími políčky rok mesic neviditelný <div> a tlačítko, po kliknutí na tlačítko se do <div> vyplní rok a mesic z input políček

    Potřebné nástroje
      ...style.visibility="visible"/"hidden"
    


    Kalendář1

  5. Modifikace předchozího bodu - po vyplnění roku a měsíce se do elementu <div> vyplní kalendář pro příslušný měsíc, navíc bude tento <div> umístěn absolutně na pozici top=100 a left=300

    Potřebné nástroje
       prvniho=new Date(rok,mesic,den,0,0,10);
       prvniho.getMonth()
       prvniho.getDay()
       ...style.position="absolute"/"relative"
       ...style.top="100"
    


    Kalendář2

  6. Soubor /usr/html/hpspool/mu/NMIN266/kvetiny.tar si zkopírujte do ~/public_html a tam rozbalte (je to barevná a černobílá varianta šesti květin). Vytvořte stránku, na které bude tabulka s šesti buňkami v každé buňce se zobrazí obrázek jedné květiny v ČB provedení, po najetí myši se zobrazí barevné provedení a po odjetí myší se zobrazí znovu ČB verze.

    Potřebné nástroje
      onMouseOver
      onMouseOut
      this.src
    


    Květiny