consolidate all repos to one for archive
This commit is contained in:
34
semester_1/uvod_v_svetovni_splet/Vaja_4/Demo/index.html
Normal file
34
semester_1/uvod_v_svetovni_splet/Vaja_4/Demo/index.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="sl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Demo vaja 4 - Javascript</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<script src="script.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Demo vaja 4 - Javascript</h1>
|
||||
</header>
|
||||
<div>
|
||||
<button type="button" onclick="openPrompt()">Odpri prompt okno</button>
|
||||
</div>
|
||||
<div id="tableContainer">
|
||||
<!-- Tukaj bomo vstavili tabelo -->
|
||||
<figure id="tableFigure">
|
||||
|
||||
</figure>
|
||||
</div>
|
||||
<div id="formContainer">
|
||||
<!-- Nad formo bomo izvedli preverjanje ustreznosti vsebine -->
|
||||
<form method="GET" action="index.html">
|
||||
<label>Uporabniško ime</label><br>
|
||||
<input id="usernameInput" type="text" oninput="onUsernameChange()"><span id="usernameWarning" class="incorrectInput">Neprimerno uporabniško ime</span><br>
|
||||
<label>Geslo</label><br>
|
||||
<input id="passwordInput" type="password" oninput="onPasswordChange()"><span id="passwordWarning" class="incorrectInput">Neprimerno geslo</span><br><br>
|
||||
<input id="submitButton" type="submit">
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
120
semester_1/uvod_v_svetovni_splet/Vaja_4/Demo/script.js
Normal file
120
semester_1/uvod_v_svetovni_splet/Vaja_4/Demo/script.js
Normal file
@@ -0,0 +1,120 @@
|
||||
var usernameInput = null;
|
||||
var usernameWarningSpan = null;
|
||||
var passwordInput = null;
|
||||
var passwprdWarnignSpan = null;
|
||||
var submitButton = null;
|
||||
|
||||
window.onload = (event) =>
|
||||
{
|
||||
usernameInput = document.getElementById("usernameInput");
|
||||
usernameWarningSpan = document.getElementById("usernameWarning")
|
||||
passwordInput = document.getElementById("passwordInput")
|
||||
passwordWarnignSpan = document.getElementById("passwordWarning")
|
||||
submitButton = document.getElementById("submitButton");
|
||||
|
||||
console.log(usernameInput);
|
||||
|
||||
checkSubmit()
|
||||
};
|
||||
|
||||
function onUsernameChange()
|
||||
{
|
||||
console.log(usernameInput.value);
|
||||
|
||||
if(/^[a-zA-Z0-9_.,]+$/.test(usernameInput.value)) //ustrezno uporabnisko ime
|
||||
{
|
||||
usernameWarningSpan.setAttribute("class", "correctInput");
|
||||
usernameWarningSpan.innerHTML = "Primerno uporavniško ime";
|
||||
}
|
||||
|
||||
else //neustrezno uporabnisko ime
|
||||
{
|
||||
usernameWarningSpan.setAttribute("class", "incorrectInput");
|
||||
usernameWarningSpan.innerHTML = "Neprimerno uporavniško ime";
|
||||
}
|
||||
|
||||
checkSubmit()
|
||||
}
|
||||
|
||||
function onPasswordChange()
|
||||
{
|
||||
if(/^[a-zA-Z0-9_.,]*[A-Z]+[a-zA-Z0-9_.,]*$/.test(passwordInput.value) && passwordInput.value.length >= 6)
|
||||
{
|
||||
passwordWarnignSpan.setAttribute("class", "correctInput");
|
||||
passwprdWarnignSpan.innerHTML = "Primerno geslo";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
passwordWarnignSpan.setAttribute("class", "incorrectInput");
|
||||
passwprdWarnignSpan.innerHTML = "Neprimerno geslo";
|
||||
}
|
||||
|
||||
checkSubmit()
|
||||
}
|
||||
|
||||
function checkSubmit()
|
||||
{
|
||||
const usernameWarningClass = usernameWarningSpan.getAttribute("class");
|
||||
const passwordWarningClass = passwordWarnignSpan.getAttribute("class");
|
||||
|
||||
//ali "incorectInput" ali "CorrectInput"
|
||||
if(usernameWarningClass == 'IncorrectInput' || passwordWarningClass == 'IncorrectInput')
|
||||
{
|
||||
submitButton.disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
submitButton.disabled = false;
|
||||
}
|
||||
|
||||
function openPrompt()
|
||||
{
|
||||
let numberString = window.prompt("Vnesi dve števili, ločeni z vejico");
|
||||
|
||||
if(numberString !== null)
|
||||
{
|
||||
let splitNumbersString = numberString.replace(/\s/g,'').split(',');
|
||||
|
||||
const N_rows = parseInt(splitNumbersString[0]); //niz 5 --> st. 5
|
||||
const N_cols = parseInt(splitNumbersString[1]);
|
||||
|
||||
let htmlTableFigure = document.getElementById("tableFigure");
|
||||
htmlTableFigure.innerHTML = "";
|
||||
|
||||
if(isNaN(N_rows) || isNaN(N_cols))
|
||||
{
|
||||
alert("Neprimeren vnos!");
|
||||
return;
|
||||
}
|
||||
|
||||
let htmlTable = document.createElement("table");
|
||||
htmlTable.setAttribute("class", "colorTable");
|
||||
|
||||
let htmlTableContent = "";
|
||||
for(let i = 0; i < N_rows; i++)
|
||||
{
|
||||
htmlTableContent += "<tr>"
|
||||
for(let j = 0; j < N_cols; j++)
|
||||
{
|
||||
htmlTableContent += "<td id = 'cell" + String(i) + "|" + String(j) + "'class='cells' onclick='selectTableCell(this.id)'>" + String(i) + "," + String(j) + "</td>";
|
||||
}
|
||||
htmlTableContent += "</tr>"
|
||||
}
|
||||
htmlTable.innerHTML = htmlTableContent;
|
||||
|
||||
htmlTableFigure.appendChild(htmlTable)
|
||||
}
|
||||
}
|
||||
|
||||
function selectTableCell(tableCellId)
|
||||
{
|
||||
const tableCells = document.getElementsByClassName("cells");
|
||||
for(let i=0; i < tableCells.length; i++)
|
||||
{
|
||||
tableCells[i].setAttribute("class", "cells")
|
||||
}
|
||||
|
||||
const selectedCell = document.getElementById(tableCellId);
|
||||
selectedCell.setAttribute("class", "cells selectedCell");
|
||||
}
|
120
semester_1/uvod_v_svetovni_splet/Vaja_4/Demo/script.js.bak
Normal file
120
semester_1/uvod_v_svetovni_splet/Vaja_4/Demo/script.js.bak
Normal file
@@ -0,0 +1,120 @@
|
||||
var usernameInput = null;
|
||||
var usernameWarningSpan = null;
|
||||
var passwordInput = null;
|
||||
var passwprdWarnignSpan = null;
|
||||
var submitButton = null;
|
||||
|
||||
window.onload = (event) =>
|
||||
{
|
||||
usernameInput = document.getElementById("usernameInput");
|
||||
usernameWarningSpan = document.getElementById("usernameWarning")
|
||||
passwordInput = document.getElementById("passwordInput")
|
||||
passwordWarnignSpan = document.getElementById("passwordWarning")
|
||||
submitButton = document.getElementById("submitButton");
|
||||
|
||||
console.log(usernameInput);
|
||||
|
||||
checkSubmit()
|
||||
};
|
||||
|
||||
function onUsernameChange()
|
||||
{
|
||||
console.log(usernameInput.value);
|
||||
|
||||
if(/^[a-zA-Z0-9_.,]+$/.test(usernameInput.value)) //ustrezno uporabnisko ime
|
||||
{
|
||||
usernameWarningSpan.setAttribute("class", "correctInput");
|
||||
usernameWarningSpan.innerHTML = "Primerno uporavniško ime";
|
||||
}
|
||||
|
||||
else //neustrezno uporabnisko ime
|
||||
{
|
||||
usernameWarningSpan.setAttribute("class", "incorrectInput");
|
||||
usernameWarningSpan.innerHTML = "Neprimerno uporavniško ime";
|
||||
}
|
||||
|
||||
checkSubmit()
|
||||
}
|
||||
|
||||
function onPasswordChange()
|
||||
{
|
||||
if(/^[a-zA-Z0-9_.,]*[A-Z]+[a-zA-Z0-9_.,]*$/.test(passwordInput.value) && passwordInput.value.length >= 6)
|
||||
{
|
||||
passwordWarnignSpan.setAttribute("class", "correctInput")
|
||||
passwprdWarnignSpan.innerHTML = "Primerno geslo"
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
passwordWarnignSpan.setAttribute("class", "incorrectInput")
|
||||
passwprdWarnignSpan.innerHTML = "Neprimerno geslo"
|
||||
}
|
||||
|
||||
checkSubmit()
|
||||
}
|
||||
|
||||
function checkSubmit()
|
||||
{
|
||||
const usernameWarningClass = usernameWarningSpan.getAttribute("class");
|
||||
const passwordWarningClass = passwordWarnignSpan.getAttribute("class");
|
||||
|
||||
//ali "incorectInput" ali "CorrectInput"
|
||||
if(usernameWarningClass == 'IncorrectInput' || passwordWarningClass == 'IncorrectInput')
|
||||
{
|
||||
submitButton.disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
submitButton.disabled = false;
|
||||
}
|
||||
|
||||
function openPrompt()
|
||||
{
|
||||
let numberString = window.prompt("Vnesi dve števili, ločeni z vejico");
|
||||
|
||||
if(numberString !== null)
|
||||
{
|
||||
let splitNumbersString = numberString.replace(/\s/g,'').split(',');
|
||||
|
||||
const N_rows = parseInt(splitNumbersString[0]); //niz 5 --> st. 5
|
||||
const N_cols = parseInt(splitNumbersString[1]);
|
||||
|
||||
let htmlTableFigure = document.getElementById("tableFigure");
|
||||
htmlTableFigure.innerHTML = "";
|
||||
|
||||
if(isNaN(N_rows) || isNaN(N_cols))
|
||||
{
|
||||
alert("Neprimeren vnos!");
|
||||
return;
|
||||
}
|
||||
|
||||
let htmlTable = document.createElement("table");
|
||||
htmlTable.setAttribute("class", "colorTable");
|
||||
|
||||
let htmlTableContent = "";
|
||||
for(let i = 0; i < N_rows; i++)
|
||||
{
|
||||
htmlTableContent += "<tr>"
|
||||
for(let j = 0; j < N_cols; j++)
|
||||
{
|
||||
htmlTableContent += "<td id = 'cell" + String(i) + "|" + String(j) + "'class='cells' onclick='selectTableCell(this.id)'>" + String(i) + "," + String(j) + "</td>";
|
||||
}
|
||||
htmlTableContent += "</tr>"
|
||||
}
|
||||
htmlTable.innerHTML = htmlTableContent;
|
||||
|
||||
htmlTableFigure.appendChild(htmlTable)
|
||||
}
|
||||
}
|
||||
|
||||
function selectTableCell(tableCellId)
|
||||
{
|
||||
const tableCells = document.getElementsByClassName("cells");
|
||||
for(let i=0; i < tableCells.length; i++)
|
||||
{
|
||||
tableCells[i].setAttribute("class", "cells")
|
||||
}
|
||||
|
||||
const selectedCell = document.getElementById(tableCellId);
|
||||
selectedCell.setAttribute("class", "cells selectedCell");
|
||||
}
|
33
semester_1/uvod_v_svetovni_splet/Vaja_4/Demo/styles.css
Normal file
33
semester_1/uvod_v_svetovni_splet/Vaja_4/Demo/styles.css
Normal file
@@ -0,0 +1,33 @@
|
||||
html {
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
background-color: lightblue;
|
||||
}
|
||||
|
||||
.selectedCell {
|
||||
background-color: red;
|
||||
border: 1px solid black;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.colorTable * {
|
||||
border: 1px solid black;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#usernameWarning, #passwordWarning {
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.correctInput {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.incorrectInput {
|
||||
color: darkred;
|
||||
}
|
Reference in New Issue
Block a user