Skip to content

Commit 9749fde

Browse files
committedAug 20, 2021
lesson 70 71 92 93 94 95 06 05 updated and added
1 parent b15f7f4 commit 9749fde

File tree

15 files changed

+391
-57
lines changed

15 files changed

+391
-57
lines changed
 

‎Lesson_6/app.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// القواعد العامة لإنشاء أسماء للمتغيرات هي:
2+
// ---------------------------------------------------------------------------------
3+
// يمكن أن تحتوي الأسماء على أحرف وأرقام وعلامة ناقص ال سفلية وعلامات الدولار.
4+
// يجب أن تبدأ الأسماء بحرف
5+
// _ يمكن أن تبدأ الأسماء أيضًا بـ $ و
6+
// الأسماء حساسة لحالة الأحرف , هناك فرق بين حرف صغير وحرف كبير
7+
// لا يمكن استخدام الكلمات المحجوزة كأسماء متغيرات
8+
9+
10+
11+
// اسماء variable الذي يمكنك استخدامها
12+
// var i ;
13+
// var Name;
14+
// var name;
15+
// var _name;
16+
// var $name;
17+
// var TheNumberIsVeryBig;
18+
// var my_name_is;
19+
20+
// // امثلة من اسماء غير ممكنة
21+
// var 12yaer; // _ لانه بدات بالرقم بدل الحرف او
22+
// var My-Name; // لانه اسم يحتوي على اشكال خاصة فهذا شي غير مسموح
23+
// var My&name; // لانه اسم يحتوي على اشكال خاصة فهذا شي غير مسموح
24+
// var break; // لانه يحتوي على كلمات محجوزة في جافا سكريبت
25+
// var false; // ايضا لانه يحتوي على كلمات محجوزة في جافا سكريبت
26+
27+
28+
29+
// The general rules for constructing names for variables (unique identifiers) are:
30+
// ---------------------------------------------------------------------------------
31+
// Names can contain letters, digits, underscores, and dollar signs.
32+
// Names must begin with a letter
33+
// Names can also begin with $ and _ (but we will not use it in this tutorial)
34+
// Names are case sensitive (y and Y are different variables)
35+
// Reserved words (like JavaScript keywords) cannot be used as names
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+

‎Lesson_6/index.html

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html >
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7-
<title>Document</title>
8-
6+
<title> Coder Shiyar </title>
97
</head>
108
<body>
119

12-
13-
<script src="script.js"></script>
10+
<script src="app.js">
11+
12+
</script>
1413

15-
1614
</body>
1715
</html>

‎Lesson_6/script.js

-37
This file was deleted.

‎Lesson_71/app.js

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
1-
function run_app(){
2-
alert("Hi")
1+
// ---------------------------------------------------------------
2+
// setInterval - يستخدم لضبط تكرار تنفيذ اوامر الذي تحدده
3+
// ---------------------------------------------------------------
4+
// clearInterval - يستخدم لإيقاف تكرار تنفيذ اوامر
5+
6+
// function runApp(){
7+
// alert("تم تنفيذ اوامر")
8+
// }
9+
// setInterval(runApp,3*1000)
10+
11+
12+
// setInterval(function(){
13+
// alert("تم تنفيذ اوامر")
14+
// },3*1000)
15+
var myInterval;
16+
var counter = 0;
17+
document.getElementById("setInterval").onclick = ()=>{
18+
myInterval = setInterval(()=>{
19+
counter = counter + 1;
20+
document.getElementById("counter").innerText = counter;
21+
if(counter == 10){
22+
clearInterval(myInterval)
23+
alert("اكتمل ")
24+
}
25+
},1*1000)
326
}
427

5-
var timeout ;
6-
document.getElementById("settimeout").onclick = ()=>{
7-
timeout = setTimeout( run_app , 3000)
28+
document.getElementById("removeInterval").onclick = ()=>{
29+
clearInterval(myInterval)
830
}
931

10-
document.getElementById("cleartimeout").onclick = ()=>{
11-
clearTimeout(timeout)
12-
}
32+
33+
34+

‎Lesson_71/index.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Coder Shiyar - JavaScript</title>
6+
<title> Coder Shiyar </title>
77
</head>
88
<body>
99

10+
<button id="setInterval">تكرار تنفيذ اوامر</button>
11+
<button id="removeInterval">إيقاف تكرار تنفيذ اوامر</button>
12+
<h1 id="counter"></h1>
13+
<script src="app.js"></script>
1014

11-
<button id="settimeout">بدء ضبط مهلة</button>
12-
<button id="cleartimeout">حذف ضبط مهلة</button>
13-
14-
<script src="app.js"> </script>
1515
</body>
1616
</html>

‎Lesson_93/app.js

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Lesson_93/index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html >
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title> Coder Shiyar </title>
7+
</head>
8+
<body>
9+
10+
11+
12+
<script src="app.js"></script>
13+
</body>
14+
</html>

‎Lesson_94/app.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// ----------------------------------------------------------------------
2+
// navigator.onLine يستخدم لتحقق من إن كان مستخدم متصل بالانترنت او لا
3+
// ----------------------------------------------------------------------
4+
// يقوم بإعادة صح او خطا,إذا كان مستخدم بالانترنت فسيقوم بإعادة صح
5+
// true/false
6+
// ----------------------------------------------------------------------
7+
// لتنفيذ اوامر عندما يصبح مستخدم متصل بالانترنت
8+
// window.addEventListener('online', );
9+
// ----------------------------------------------------------------------
10+
// لتنفيذ اوامر عندما يصبح مستخدم غير متصل بالانترنت
11+
// window.addEventListener('offline', );
12+
// ----------------------------------------------------------------------
13+
let isOnline = navigator.onLine
14+
console.log(isOnline)
15+
window.onoffline = ()=>{
16+
alert("فقدت اتصال بالانترنت")
17+
}
18+
// window.addEventListener('offline',()=>{
19+
// alert("فقدت اتصال بالانترنت")
20+
// } );
21+
22+
window.addEventListener('online',()=>{
23+
alert("انت متصل بالانترنت")
24+
} );

‎Lesson_94/index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html >
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title> Coder Shiyar </title>
7+
</head>
8+
<body>
9+
10+
11+
12+
<script src="app.js"></script>
13+
</body>
14+
</html>

‎Lesson_95-2/app.js

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// ------------------------------------------------------------------------------------------------------
2+
// navigator.geolocation يستخدم لتحقق إن كان متصفح وجهاز مستخدم يدعم خاصية تحديد مواقع
3+
// navigator.geolocation.getCurrentPosition()يستخدم لطلب صلاحية وصول إلى موقع من المستخدم
4+
// ولحصول على معلومات متعلقة بالموقع المستخدم
5+
// ------------------------------------------------------------------------------------------------------
6+
// navigator.geolocation.watchPosition() يستخدم للحصول على موقع مستخدم ويتم تحديث موقع بالاستمرار
7+
// ------------------------------------------------------------------------------------------------------
8+
// navigator.geolocation.clearWatch(id); يستخدم لإيقاف تتبع مستخدم | ايقاف عرض موقع مستخدم بشكل مباشر
9+
// ------------------------------------------------------------------------------------------------------
10+
// https://www.openstreetmap.org/export/embed.html?bbox=,&;layer=mapnik
11+
12+
if(localStorage.getItem("longitude") != null && localStorage.getItem("latitude") != null){
13+
document.getElementById("map").innerHTML =
14+
`<iframe height="400" width="100%"
15+
src="https://www.openstreetmap.org/export/embed.html?bbox=${localStorage.getItem("longitude")},${localStorage.getItem("latitude")}&;layer=mapnik"> </iframe> `
16+
17+
}
18+
19+
20+
var isLive = false;
21+
var shareLocation;
22+
var accessLocation;
23+
document.getElementById("getLocation").onclick = ()=>{
24+
25+
26+
if(isLive === false){
27+
shareLocation = navigator.geolocation.watchPosition(
28+
function(position){
29+
accessLocation = true;
30+
31+
document.getElementById("alert").innerHTML = `
32+
<div class="alert alert-success"
33+
role="alert"> يتم عرض موقعك الان في خريطة بشكل مباشر </div> `;
34+
document.getElementById("getLocation").innerHTML = "إيقاف مشاركة";
35+
isLive = true
36+
37+
document.getElementById("map").innerHTML =
38+
`<iframe height="400" width="100%"
39+
src="https://www.openstreetmap.org/export/embed.html?bbox=${position.coords.longitude},${position.coords.latitude}&;layer=mapnik"> </iframe> `
40+
localStorage.setItem("longitude",position.coords.longitude )
41+
localStorage.setItem("latitude",position.coords.latitude )
42+
43+
},
44+
function(error){
45+
switch(error.code) {
46+
case error.PERMISSION_DENIED:
47+
document.getElementById("alert").innerHTML = ` <div class="alert alert-danger mt-3 mb-3" role="alert">
48+
لقد قمت برفض وصول إلى موقعك , يرجى محاولة وموافقة
49+
</div> `
50+
break;
51+
52+
case error.UNKNOWN_ERROR:
53+
document.getElementById("alert").innerHTML = `<div class="alert alert-danger mt-3 mb-3" role="alert"> حدث خطا غير معروف </div> `
54+
break;
55+
56+
}
57+
}
58+
)
59+
60+
61+
}else if(isLive === true && accessLocation === true){
62+
63+
document.getElementById("alert").innerHTML = `
64+
<div class="alert alert-success"
65+
role="alert"> تم إيقاف مشاركة موقع بنجاح
66+
</div> `
67+
68+
navigator.geolocation.clearWatch(shareLocation);
69+
document.getElementById("getLocation").innerHTML = "عرض موقعي"
70+
isLive = false
71+
}
72+
73+
74+
75+
}
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
89+
// انواع اخطاء الذي يمكن ان يحدث عند محاولة حصول على عنوان
90+
// switch(error.code) {
91+
// case error.PERMISSION_DENIED:
92+
// error = "User denied the request for Geolocation. اذا مستخدم رفض صلاحية وصول للموقع"
93+
// break;
94+
// case error.POSITION_UNAVAILABLE:
95+
// error = "Location information is unavailable. معلومات موقع غير متوفرة"
96+
// break;
97+
// case error.TIMEOUT:
98+
// error = "The request to get user location timed out.إذا لم يتمكن من حصول على موقع مستخدم"
99+
// break;
100+
// case error.UNKNOWN_ERROR:
101+
// error = "An unknown error occurred. إذا حدث خطا غير معروف"
102+
// break;
103+
// }

‎Lesson_95-2/img.jpg

56.8 KB
Loading

0 commit comments

Comments
 (0)
Failed to load comments.