Commit 3c657c3f authored by Raitis Ralfs's avatar Raitis Ralfs
Browse files

Pabeidzu 4. uzdevumu

parents
<!doctype html>
<html lang="lv">
<head>
<meta charset="utf-8">
<title>WWW JS</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="style.css">
<script src="jquery-3.3.1.min.js"></script>
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
</head>
<main style="height: 1300px">
<h2>Pirmais Uzdevums</h2>
<p id="laiks">Šodien ir </p>
<button onclick="pirmaisUzdevums()">Spied lai iegūtu laiku</button>
<h2>Otrais Uzdevums</h2>
<p id="otraisUzdevums">Hipotenūzas garums, kur a = 189, b = 256 ir </p>
<button onclick="otraisUzdevums()">Spied lai iegūtu hipotenūzas garumu</button>
<h2>Trešais Uzdevums</h2>
<canvas id="tresaisUzdevums" height="300px" width="300px"></canvas>
<button onclick="tresaisUzdevums()">Zīmēt 3. uzdevumu</button>
<h2>Ceturtais uzdevums</h2>
<button class="ceturtaisUzdevums">Click to scroll to top</button>
</main>
<script src="script.js"></script>
</html>
\ No newline at end of file
This diff is collapsed.
function pirmaisUzdevums() {
let datums = new Date();
let dateParagraph = document.getElementById("laiks");
switch (datums.getDay()) {
case 1:
dateParagraph.innerText += " Pirmdiena ";
break;
case 2:
dateParagraph.innerText += " Otrdiena ";
break;
case 3:
dateParagraph.innerText += " Trešdiena ";
break;
case 4:
dateParagraph.innerText += " Ceturtdiena ";
break;
case 5:
dateParagraph.innerText += " Piektdiena ";
break;
case 6:
dateParagraph.innerText += " Sestdiena ";
break;
case 7:
dateParagraph.innerText += " Svētdiena ";
break;
}
dateParagraph.innerText += " plkst. " + datums.getHours() + ":" + datums.getMinutes();
}
function otraisUzdevums() {
let hypotParagraph = document.getElementById("otraisUzdevums");
let a = 189;
let b = 256;
hypotParagraph.innerText += " " + Math.hypot(a, b).toPrecision(5);
}
function tresaisUzdevums() {
let canvasElement = document.getElementById("tresaisUzdevums");
let ctx = canvasElement.getContext("2d");
let x = canvasElement.width / 2;
let y = canvasElement.height / 2;
ctx.beginPath();
ctx.arc(x, y, 70, 0, 2*Math.PI);
ctx.strokeStyle="red";
ctx.lineWidth=3;
ctx.stroke();
}
$('.ceturtaisUzdevums').click(function(){
$('html, body').animate({scrollTop : 0},800);
return false;
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment