{"id":46,"date":"2025-10-13T15:19:05","date_gmt":"2025-10-13T13:19:05","guid":{"rendered":"https:\/\/stenverlindma24.thkit.ee\/wp\/?page_id=46"},"modified":"2025-10-13T15:22:47","modified_gmt":"2025-10-13T13:22:47","slug":"js-pildid","status":"publish","type":"page","link":"https:\/\/stenverlindma24.thkit.ee\/wp\/js-pildid\/","title":{"rendered":"JS: pildid"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<script>\nfunction juhuslikPilt(){\n    \/\/massiiv\n    const pildid=[\n        'images\/0.png',\n        'images\/1.png',\n        'images\/2.png',\n        'images\/3.png',\n        'images\/4.png',\n        'images\/5.png',\n    ];\n    const randomPilt=document.getElementById('randomPilt');\n    \/\/Math.random()- juhuslik arv\n    \/\/Math.floor - v\u00f5tab arvust t\u00e4isosa\n    \/\/pildid.length - mitu pilti on massiivis\n    const juhuslikArv=Math.floor(Math.random()*pildid.length);\n\n    randomPilt.src=pildid[juhuslikArv];\n}\nfunction piltkartul(){\n    let randomPilt=document.getElementById('randomPilt');\n    let vastus=document.getElementById('vastus');\n    let valik=document.getElementsByName('valik'); \/\/mitu elements \u00fche nimega valik\n\n    \/\/ts\u00fckl for\n    for(let i=0;i<valik.length;i++){\n        if(valik[i].checked){\n            \/\/radio nupust v\u00f5etaske value mida v\u00f5rdleme pildi asukohaga\n            if(randomPilt.getAttribute('src')==valik[i].src){\n                vastus.innerHTML=\"\u00d5ige vastus!\";\n                vastus.style.color='green';\n            }else{\n                vastus.innerHTML=\"M\u00f5tle veel\";\n                vastus.style.color='red';\n            }\n        }\n    }\n}\nfunction arvuta(kogus, hind) {\n    return (kogus * hind).toFixed(2);\n    \/\/toFixed - \u00fcmardab 2 numbrit peale koma\n    }\n    const pilt1Hind=2;\nconst pilt2Hind=5;\nconst pilt0Hind=0;\nconst pilt3Hind=15;\nconst pilt5Hind=100;\n\nfunction arvutaPiltHind(){\n    let vastus2=document.getElementById('vastus2');\n    let tk=document.getElementById('tk');\n    let v1=document.getElementById('v1');\n    let v2=document.getElementById('v2');\n    let v3=document.getElementById('v3');\n    let v4=document.getElementById('v4');\n    let v5=document.getElementById('v5');\n\n    if(v1.checked){\n        vastus2.innerHTML=arvuta(tk.value, pilt1Hind)+\" euro\";\n    }\n    if(v2.checked){\n        vastus2.innerHTML=arvuta(tk.value, pilt2Hind)+\" euro\";\n    }\n    if(v3.checked){\n        vastus3.innerHTML=arvuta(tk.value, pilt3Hind)+\" euro\";\n    }\n    if(v4.checked){\n        vastus4.innerHTML=arvuta(tk.value, pilt5Hind)+\" euro\";\n    }\n    if(v5.checked){\n        vastus5.innerHTML=arvuta(tk.value, pilt5Hind);\n    }\n}\n<\/script>\n\n\n\n<body onload=\"juhuslikPilt()\">\n<h1>Juhuslik pilt images-kustast<\/h1>\n<input type=\"button\" value=\"Random pilt\" onclick=\"juhuslikPilt()\">\n<br>\n<img decoding=\"async\" src=\"\" alt=\"\" id=\"randompilt\">\n<h2>Pildim\u00f5istatus. Vali mida sa n\u00e4ed pildil<\/h2>\n<input type=\"radio\" name=\"valik\" id=\"v1\" value=\"images\/1.png\" onchange=\"piltmyistatus()\">\n<lable for=\"v2\">1.png<\/lable>\n<br>\n<input type=\"radio\" name=\"valik\" id=\"v2\" value=\"images\/2.png\" onchange=\"piltmyistatus()\">\n<label for=\"v3\">2.png<\/label>\n<br>\n<input type=\"radio\" name=\"valik\" id=\"v3\" value=\"images\/3.png\" onchange=\"piltmyistatus()\">\n<label for=\"v4\">3.png<\/label>\n<br>\n<input type=\"radio\" name=\"valik\" id=\"v4\" value=\"images\/4.png\" onchange=\"piltmyistatus()\">\n<label for=\"v5\">4.png<\/label>\n<br>\n<input type=\"radio\" name=\"valik\" id=\"v5\" value=\"images\/5.png\" onchange=\"piltmyistatus()\">\n<label for=\"v5\">5.png<\/label>\n<br><br>\n<div id=\"vastus\"><\/div>\n<h2>Mitu pilti soovite osta?<\/h2>\n<label for=\"tk\">Vali kogus <\/label>\n<input type=\"number\" id=\"tk\" min=\"1\" max=\"100\" step=\"1\" value=\"1\" onchange=\"arvutaPiltHind()\">\n<br>\n<div id=\"vastus2\"><\/div>\n<\/body>\n<\/html>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Juhuslik pilt images-kustast Pildim\u00f5istatus. Vali mida sa n\u00e4ed pildil 1.png 2.png 3.png 4.png 5.png Mitu pilti soovite osta? Vali kogus<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-46","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JS: pildid - Stenveri porfoolio<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/stenverlindma24.thkit.ee\/wp\/js-pildid\/\" \/>\n<meta property=\"og:locale\" content=\"et_EE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JS: pildid - Stenveri porfoolio\" \/>\n<meta property=\"og:description\" content=\"Juhuslik pilt images-kustast Pildim\u00f5istatus. Vali mida sa n\u00e4ed pildil 1.png 2.png 3.png 4.png 5.png Mitu pilti soovite osta? Vali kogus\" \/>\n<meta property=\"og:url\" content=\"https:\/\/stenverlindma24.thkit.ee\/wp\/js-pildid\/\" \/>\n<meta property=\"og:site_name\" content=\"Stenveri porfoolio\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-13T13:22:47+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/stenverlindma24.thkit.ee\\\/wp\\\/js-pildid\\\/\",\"url\":\"https:\\\/\\\/stenverlindma24.thkit.ee\\\/wp\\\/js-pildid\\\/\",\"name\":\"JS: pildid - Stenveri porfoolio\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/stenverlindma24.thkit.ee\\\/wp\\\/#website\"},\"datePublished\":\"2025-10-13T13:19:05+00:00\",\"dateModified\":\"2025-10-13T13:22:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/stenverlindma24.thkit.ee\\\/wp\\\/js-pildid\\\/#breadcrumb\"},\"inLanguage\":\"et\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/stenverlindma24.thkit.ee\\\/wp\\\/js-pildid\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/stenverlindma24.thkit.ee\\\/wp\\\/js-pildid\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/stenverlindma24.thkit.ee\\\/wp\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JS: pildid\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/stenverlindma24.thkit.ee\\\/wp\\\/#website\",\"url\":\"https:\\\/\\\/stenverlindma24.thkit.ee\\\/wp\\\/\",\"name\":\"Stenveri porfoolio\",\"description\":\"J&auml;rgmine WordPress veebileht\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/stenverlindma24.thkit.ee\\\/wp\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"et\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JS: pildid - Stenveri porfoolio","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/stenverlindma24.thkit.ee\/wp\/js-pildid\/","og_locale":"et_EE","og_type":"article","og_title":"JS: pildid - Stenveri porfoolio","og_description":"Juhuslik pilt images-kustast Pildim\u00f5istatus. Vali mida sa n\u00e4ed pildil 1.png 2.png 3.png 4.png 5.png Mitu pilti soovite osta? Vali kogus","og_url":"https:\/\/stenverlindma24.thkit.ee\/wp\/js-pildid\/","og_site_name":"Stenveri porfoolio","article_modified_time":"2025-10-13T13:22:47+00:00","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/stenverlindma24.thkit.ee\/wp\/js-pildid\/","url":"https:\/\/stenverlindma24.thkit.ee\/wp\/js-pildid\/","name":"JS: pildid - Stenveri porfoolio","isPartOf":{"@id":"https:\/\/stenverlindma24.thkit.ee\/wp\/#website"},"datePublished":"2025-10-13T13:19:05+00:00","dateModified":"2025-10-13T13:22:47+00:00","breadcrumb":{"@id":"https:\/\/stenverlindma24.thkit.ee\/wp\/js-pildid\/#breadcrumb"},"inLanguage":"et","potentialAction":[{"@type":"ReadAction","target":["https:\/\/stenverlindma24.thkit.ee\/wp\/js-pildid\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/stenverlindma24.thkit.ee\/wp\/js-pildid\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/stenverlindma24.thkit.ee\/wp\/"},{"@type":"ListItem","position":2,"name":"JS: pildid"}]},{"@type":"WebSite","@id":"https:\/\/stenverlindma24.thkit.ee\/wp\/#website","url":"https:\/\/stenverlindma24.thkit.ee\/wp\/","name":"Stenveri porfoolio","description":"J&auml;rgmine WordPress veebileht","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/stenverlindma24.thkit.ee\/wp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"et"}]}},"_links":{"self":[{"href":"https:\/\/stenverlindma24.thkit.ee\/wp\/wp-json\/wp\/v2\/pages\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stenverlindma24.thkit.ee\/wp\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/stenverlindma24.thkit.ee\/wp\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/stenverlindma24.thkit.ee\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stenverlindma24.thkit.ee\/wp\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":2,"href":"https:\/\/stenverlindma24.thkit.ee\/wp\/wp-json\/wp\/v2\/pages\/46\/revisions"}],"predecessor-version":[{"id":57,"href":"https:\/\/stenverlindma24.thkit.ee\/wp\/wp-json\/wp\/v2\/pages\/46\/revisions\/57"}],"wp:attachment":[{"href":"https:\/\/stenverlindma24.thkit.ee\/wp\/wp-json\/wp\/v2\/media?parent=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}