Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
642ca05
Update README.md
haim1212 Nov 18, 2021
df71aac
Update README.md
haim1212 Nov 18, 2021
d015847
Create haim.txt
haim1212 Nov 18, 2021
bb713ef
29/11 ex
haim1212 Dec 2, 2021
9f53389
Revert "29/11 ex"
haim1212 Dec 2, 2021
600b4b2
Merge branch 'master' into Haim
haim1212 Dec 2, 2021
3b3e464
Merge branch 'master' of https://github.com/oprince/JBFullStack29
haim1212 Dec 2, 2021
59bb76f
Merge branch 'master' into Haim
haim1212 Dec 2, 2021
1d5e6a6
Merge branch 'master' of https://github.com/oprince/JBFullStack29
haim1212 Dec 2, 2021
1f247d1
Merge branch 'master' into Haim
haim1212 Dec 2, 2021
621f595
Merge branch 'master' of https://github.com/oprince/JBFullStack29
haim1212 Dec 2, 2021
5cc3241
Merge branch 'master' into Haim
haim1212 Dec 2, 2021
8702362
Merge branch 'master' of https://github.com/oprince/JBFullStack29
haim1212 Dec 9, 2021
8875942
myCanges
haim1212 Dec 9, 2021
bdba855
Merge branch 'master' of https://github.com/oprince/JBFullStack29
haim1212 Dec 9, 2021
f037345
Merge branch 'master' into Haim
haim1212 Dec 9, 2021
adddd29
pushed
haim1212 Dec 16, 2021
74f607f
30-12-21
haim1212 Dec 30, 2021
3a8988c
03-01-21
haim1212 Jan 3, 2022
30074d3
03-01-21
haim1212 Jan 3, 2022
d0268db
com
haim1212 Jan 3, 2022
9281a7d
changes
haim1212 Jan 6, 2022
bde8be5
change
haim1212 Jan 6, 2022
20f2779
change
haim1212 Jan 6, 2022
04480c9
change
haim1212 Jan 6, 2022
8949dea
classWork
haim1212 Jan 10, 2022
0529f6c
classWork
haim1212 Jan 10, 2022
ed9f8e2
classWork
haim1212 Jan 10, 2022
9596bc3
commit
haim1212 Jan 24, 2022
c4f5f9b
24-01-2022
haim1212 Jan 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Ex/2021-12-09/errorHandling.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/styles.css">
<script src="js/noErrorHandling.js"></script>
<script src="js/errorHandling.js"></script>
</head>
<body onload="initPage()">
<h1>JavaScript Errors handling</h1>
Expand All @@ -13,7 +13,7 @@ <h1>JavaScript Errors handling</h1>
<button id="undefinedFunction" onclick="undefinedFunction()">Call undefined function</button>
</li>
<li>
<button id="wrongInput" onclick="wrongArgument('123')">Call a function with wrong argument</button>
<button id="wrongInput" onclick="wrongArgument(123)">Call a function with wrong argument</button>
</li>
<li>
<label for="userInput">User Input:</label>
Expand Down
54 changes: 35 additions & 19 deletions Ex/2021-12-09/js/errorHandling.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

function initPage(){
function initPage() {
console.log("initPage");
// window.addEventListener('error', (event) => {
// let errorMessage = `${event.type}: ${event.message}\n`;
// console.error(errorMessage);
// event.preventDefault();
// });
// window.addEventListener('error', (event) => {
// let errorMessage = `${event.type}: ${event.message}\n`;
// console.error(errorMessage);
// event.preventDefault();
// });
}
function handleImageError(event){
function handleImageError(event) {
console.log(event);
//this.onerror=null;this.src='images/imagenotfound.gif';
}
Expand All @@ -24,27 +24,43 @@ function handleImageError(event){
// 'Column: ' + columnNo,
// 'Error object: ' + JSON.stringify(error)
// ].join(' - ');

// alert(message);
// }

// //returning true prevents the firing of the default event handler
// return false;
// };

function wrongArgument(param1){
try{
function wrongArgument(param1) {
const p = document.getElementById("status")
let finallyResult;
console.log(finallyResult);

try {
let result = param1.toLowerCase()
console.log(result);
}catch(error){
finallyResult = result
console.log(result);
} catch (error) {
finallyResult = error
console.log(error);
}finally{
//TODO: Show result or error in "status" element
} finally {
p.innerHTML = finallyResult
}
}

function handleUserInput(){
function handleUserInput() {
let userInput = document.getElementById("userInput").value;
let result = JSON.parse(userInput);
alert("result: " + JSON.stringify(result));
}
let finallyResult;
try {
let result = JSON.parse(userInput);
finallyResult = result
} catch (error) {
finallyResult = error

}
alert("result: " + JSON.stringify(finallyResult));

}


26 changes: 26 additions & 0 deletions Ex/2021-12-20/canvas_draw_shapes.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
<!DOCTYPE html>
<html>
<<<<<<< HEAD

<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/styles.css">
<script src="js/draw_shapes.js"></script>
</head>

<body onload="initPage()">
<h1>JavaScript canvas drawing</h1>
<br>
<div id="catchEventsDiv" class="mouseTests">
<canvas id="myCanvas" width="480" height="160"></canvas>
</div>
<div>
<button id="fillBackground" onclick="fillBackground()">Fill background</button>
<button id="drawLine" onclick="drawLine()">Draw line</button>
<button id="drawCircle" onclick="drawCircle()">Draw circle</button>
<button id="drawLines" onclick="drawLines()">Draw lines</button>

</div>
</body>

</html>
=======
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/styles.css">
Expand All @@ -19,3 +44,4 @@ <h1>JavaScript canvas drawing</h1>
</div>
</body>
</html>
>>>>>>> master
15 changes: 15 additions & 0 deletions Ex/2021-12-23/New folder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# JBFullStack29

# Ex 6: Draw lines

- Add “draw colored bars” button that will paint the following on the canvas
![image](https://user-images.githubusercontent.com/12232897/147269882-9d68221d-8a25-4c81-8fe6-a64716523348.png)

- Use a loop that will calculate the bar coordinates, direction (vertical or horizontal) and color.
- The color options should be represented in an array.
- Represent the bar to be painted using an object.
- Pass the bar object to `drawBar()` function
- Add input field were number of bars should be entered by the user.


**Advanced:** Add “rotate colored bars” button that will draw a 45° rotated version of the above image
27 changes: 27 additions & 0 deletions Ex/2021-12-23/New folder/canvas_draw_shapes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>

<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/styles.css">
<script src="js/draw_shapes.js"></script>
</head>

<body onload="initPage()">
<h1>JavaScript canvas drawing</h1>
<br>
<div id="catchEventsDiv" class="mouseTests">
<canvas id="myCanvas" width="480" height="160"></canvas>
</div>
<div>
<button id="fillBackground" onclick="fillBackground()">Fill background</button>
<button id="drawLine" onclick="drawLine()">Draw line</button>
<button id="drawCircle" onclick="drawCircle()">Draw circle</button>
<button id="drawLines" onclick="drawLines()">Draw lines</button>
<input id="inputID" type="number">
<button id="mapID" onclick="createMap()">draw map</button>

</div>
</body>

</html>
33 changes: 33 additions & 0 deletions Ex/2021-12-23/New folder/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ul {
list-style: none;
padding: 0;
margin: 0;
}
li {
margin-top: 3em;
margin-bottom: 1em;
margin-left: 5em;
}
.mouseTests {
border-color: blue;
background-color: cornsilk;
height: 10em;
width: 30em;
}
canvas{
/*width: 98%;
height: 85%;*/
border: 1px solid #000000;
}
div {
margin-top: 10px;
}
label {
font-weight: bold;
color: blue;
}
p {
display: inline-block;
font-weight: bold;
color: rgb(117, 7, 160);
}
Binary file added Ex/2021-12-23/New folder/index.zip
Binary file not shown.
103 changes: 103 additions & 0 deletions Ex/2021-12-23/New folder/js/draw_shapes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
let canvas;
let ctx;
let inputVal;
let colors = [];
let colorIndex = 0;

function buildColorsArray(ittarations) {
let array = [];
for (let i = 0; i < ittarations; i++) {
let r = Math.floor(Math.random() * 250) + 1;
let g = Math.floor(Math.random() * 250) + 1;
let b = Math.floor(Math.random() * 250) + 1;

let color = `rgb(${r},${g},${b})`

array.push(color)
}
return array;

}

function initPage() {
console.log("initPage");
canvas = document.getElementById("myCanvas");
ctx = canvas.getContext("2d");
canvas.addEventListener("click", (event) => {
let x = event.clientX - canvas.offsetLeft;
let y = event.clientY - canvas.offsetTop;
let currentColor = colors[colorIndex];
ctx.strokeStyle = currentColor;
colorIndex += 1;
if (colorIndex >= colors.length)
colorIndex = 0;
ctx.strokeRect(x, y, 10, 10);
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x + 30, y);
ctx.stroke();
});
}

function fillBackground() {
ctx.fillStyle = "orange";
//ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = 'blue';
ctx.strokeRect(10, 10, canvas.width - 20, canvas.height - 20);

//radial gradiant
var grd = ctx.createRadialGradient(75, 50, 5, 90, 60, 150);
grd.addColorStop(0, "orange");
grd.addColorStop(1, "red");
// Fill with gradient
ctx.fillStyle = grd;
ctx.fillRect(0, 0, canvas.width, canvas.height);
}

function drawLine() {
ctx.lineWidth = 5;
ctx.strokeStyle = 'blue';
ctx.moveTo(100, 50);
ctx.lineTo(200, 100);
ctx.stroke();
}

function drawCircle() {
ctx.strokeStyle = 'blue';
ctx.beginPath();
ctx.arc(95, 50, 20, 0, 2 * Math.PI);
ctx.stroke();
}

function drawLines() {
canvas.width = canvas.width;
inputVal = document.getElementById("inputID").value;
colors = buildColorsArray(inputVal)
let x = 0;
let y = 0;
for (let i = 0; i < colors.length; i++) {
ctx.lineWidth = 5;
ctx.strokeStyle = colors[i];
ctx.beginPath();
ctx.moveTo(x, ((canvas.height / (colors.length)) / 2 + (canvas.height / (colors.length) * i)));
ctx.lineTo(canvas.width, ((canvas.height / (colors.length)) / 2 + (canvas.height / (colors.length) * i)));
console.log("horizontal :", ((canvas.height / (colors.length)) / 2 + (canvas.height / (colors.length) * i)));

ctx.stroke();


}
for (let i = 0; i < colors.length; i++) {
ctx.lineWidth = 5;
ctx.strokeStyle = colors[i];
ctx.beginPath();
ctx.moveTo(((canvas.width / (colors.length)) / 2 + (canvas.width / (colors.length) * i)), y);
ctx.lineTo(((canvas.width / (colors.length)) / 2 + (canvas.width / (colors.length) * i)), canvas.height);
console.log("vertical :", (canvas.width / (colors.length)) + (canvas.width / (colors.length) * i) / 2);
ctx.stroke();

}


}

Loading