Advertisement
Raizekas

Untitled

Feb 22nd, 2021
688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //----------------------------Pagrindine dalis--------------
  2. window.onload = function() {
  3.     var antraste = document.getElementById("antraste");
  4.     var pastraipa = document.getElementById("pastraipa");
  5. }
  6.  
  7.  
  8. //---------------------------Funkcijos----------------------
  9. function matematineLygtis(x)
  10. {
  11.     console.log(x + 5);
  12. }
  13.  
  14.  
  15. function pakeistiElementoTeksta(elementoId, tekstas)
  16. {
  17.     var elementas = document.getElementById(elementoId);
  18.     elementas.innerHTML = tekstas;
  19. }
  20.  
  21. function pakeistiElementoFonoSpalva(elementoId, spalva)
  22. {
  23.     var elementas = document.getElementById(elementoId);
  24.     elementas.style.backgroundColor = spalva;
  25. }
  26.  
  27.  
  28. function skaiciuoti (veiksmoTipas, skLaukelioId1, skLaukelioId2)
  29. {
  30.     // Susirandame ivedimo laukelius pagal gautus ID is parametru
  31.     var skLaukelis1 = document.getElementById(skLaukelioId1)
  32.     var skLaukelis2 = document.getElementById(skLaukelioId2)
  33.  
  34.     // Testinis issivedimas
  35.     console.log(skLaukelis1);
  36.     console.log(skLaukelis2);
  37.  
  38.     // Paimame laukeliu reiksmes (jas gauname tekstiniu pavidalu, tad reikes konvertuoti i skaicius)
  39.     var sk1 = skLaukelis1.value;
  40.     var sk2 = skLaukelis2.value;
  41.  
  42.     // Testinis issivedimas skaiciu (tekstiniu pavidalu)
  43.     console.log(sk1);
  44.     console.log(sk2);
  45.  
  46.     // Konvertavimas is tekstinio kintamojo i skaitinius kintamuosius
  47.     sk1 = parseInt(sk1);
  48.     sk2 = parseInt(sk2);
  49.     var rezultatas = 0;
  50.     if (veiksmoTipas == "sudėtis")
  51.     {
  52.         rezultatas = sk1 + sk2;
  53.     }
  54.  
  55.     if (veiksmoTipas == "atimtis")
  56.     {
  57.         rezultatas = sk1 - sk2;
  58.     }
  59.  
  60.     if (veiksmoTipas == "daugyba")
  61.     {
  62.         rezultatas = sk1 * sk2;
  63.     }
  64.  
  65.     if (veiksmoTipas == "dalyba")
  66.     {
  67.         rezultatas = sk1 / sk2;
  68.     }
  69.  
  70.     if (veiksmoTipas == "liekana")
  71.     {
  72.         rezultatas = sk1 % sk2;
  73.     }
  74.  
  75.     return rezultatas;
  76. }
  77.  
  78. /* Jeigu kurtis antra funkcija, kuri tiesiog dviem elementams pakeistu teksta (NEREKOMENDUOTINA!!)
  79. function pakeistiDviejuElementuTeksta(elementoId, elemento2Id, tekstas)
  80. {
  81.     var elementas = document.getElementById(elementoId);
  82.     var elementas = document.getElementById(elementoId);
  83.     elementas.innerHTML = tekstas;
  84. }*/
  85.  
  86.  
  87.  
  88. function paspaudusPirma()
  89. {
  90.     antraste.innerHTML = "Pirmos užduoties tekstas";
  91. }
  92.  
  93.  
  94. function paspaudusAntra()
  95. {
  96.     pastraipa.innerHTML = "Pastraipos tekstas po antro mygtuko";
  97. }
  98.  
  99.  
  100. function paspaudusTrecia()
  101. {
  102.     antraste.innerHTML = "Abu buvo pakeisti";
  103.     pastraipa.innerHTML = "Abu buvo pakeisti";
  104. }
  105.  
  106. function paspaudusKetvirta()
  107. {
  108.     antraste.style.backgroundColor = "red";
  109. }
  110.  
  111. function paspaudusPenkta()
  112. {
  113.     pastraipa.style.color = "blue";
  114. }
  115.  
  116.  
  117. function paspaudusSesta()
  118. {
  119.     antraste.style.fontSize = "40px";
  120. }
  121.  
  122. function paspaudusSeptinta()
  123. {
  124.     pastraipa.style.display = "none";
  125.    //pastraipa.style.opacity = 0;
  126.    //pastraipa.style.visibility = "hidden";
  127.     //pastraipa.innerHTML = "";
  128. }
  129.  
  130. function paspaudusAstunta()
  131. {
  132.     pastraipa.style.border = "1px solid black";                 // "sujungiant" visus parametrus i viena
  133.  
  134.    /* JavaScript borderio pakeitimas - išskaidant borderio parametrus į tris skirtingus parametrus (dydį, stilių ir spalvą)
  135.     pastraipa.style.borderWidth = "1px";
  136.     pastraipa.style.borderStyle = "solid";
  137.     pastraipa.style.borderColor = "black";
  138.     */
  139.    
  140.     /*CSS borderio uzrasymo du budai
  141.     border: 1px solid black;
  142.  
  143.     border-width: 1px;
  144.     border-style: solid;
  145.     border-color: black;*/
  146. }
  147.  
  148. function paspaudusDevinta()
  149. {
  150.     pastraipa.style.width = "50%";
  151. }
  152.  
  153.  
  154. function paspaudusDesimta()
  155. {
  156.     antraste.style.order = 2;
  157.     pastraipa.style.order = 1;
  158.  
  159.    /* var antraste2 = document.getElementById("antraste2");
  160.     antraste2.style.display = "block";
  161.     antraste.style.display = "none";*/
  162. }
  163.  
  164.  
  165.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement