Skip to content

Commit d7e8eab

Browse files
authored
Merge pull request #63 from sarmadka/main
Added showAlertDialog and showConfirmDialog funcs
2 parents 95b5f43 + 1ef10a4 commit d7e8eab

6 files changed

Lines changed: 68 additions & 5 deletions

File tree

Doc/global_funcs.ar.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,40 @@ function logToConsole (msg: ptr[Char]);
929929
دالة لطباعة رسالة إلى طرفية المتصفح.
930930

931931

932+
## أظهر_نافذة_إشعار (showAlertDialog)
933+
934+
<div dir=rtl>
935+
936+
```
937+
عرف أظهر_نافذة_إشعار(رسالة: مؤشر[مـحرف])؛
938+
```
939+
940+
</div>
941+
942+
```
943+
function showAlertDialog (msg: ptr[Char]);
944+
```
945+
946+
تظهر نافذة إشعار بالاعتماد على نوافذ الإشعارات الخاصة بالمتصفح.
947+
948+
949+
## أظهر_نافذة_تأكيد (showConfirmDialog)
950+
951+
<div dir=rtl>
952+
953+
```
954+
عرف أظهر_نافذة_تأكيد(رسالة: مؤشر[مـحرف]): ثـنائي؛
955+
```
956+
957+
</div>
958+
959+
```
960+
function showConfirmDialog (msg: ptr[Char]): Bool;
961+
```
962+
963+
تظهر نافذة تأكيد بالاعتماد على نوافذ التأكيد الخاصة بالمتصفح. ترجع 1 في حالة تأكيد المستخدم و 0 في حالة الإلغاء.
964+
965+
932966
### طابق_نمطا (matchRegex)
933967

934968
<div dir=rtl>

Doc/global_funcs.en.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,25 @@ function logToConsole (msg: ptr[Char]);
578578
Prints some message to the browser's console.
579579

580580

581+
## showAlertDialog
582+
583+
```
584+
function showAlertDialog (msg: ptr[Char]);
585+
```
586+
587+
Displays an alert dialog using the browser's native alert dialogs.
588+
589+
590+
## showConfirmDialog
591+
592+
```
593+
function showConfirmDialog (msg: ptr[Char]): Bool;
594+
```
595+
596+
Shows a confirm dialog using the browser's native confirm dialogs. Returns 1 (true) if the user clicks Ok, and 0 (false)
597+
if the user clicks Cancel.
598+
599+
581600
### matchRegex
582601

583602
```

Examples/signin_form.alusus

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,12 @@ func main {
198198
background = Background(Color(109, 40, 217)); // Even darker on click
199199
};
200200
onClick.connect(closure (widget: ref[Widget], payload: ref[Int]) {
201-
logToConsole("Sign in clicked!\n");
202-
logToConsole(String("Email: ") + emailInput.text + "\n");
203-
logToConsole(String("Password: ") + passwordInput.text + "\n");
201+
if (showConfirmDialog("Sign in clicked. Continue?\n")) {
202+
showAlertDialog(
203+
String("Email: ") + emailInput.text + "\n" +
204+
String("Password: ") + passwordInput.text + "\n"
205+
);
206+
}
204207
});
205208
}
206209
});

WebPlatform/browser_api.alusus

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@
127127
@expname[getVarFromSession] function getVarFromSession (varName: ptr[Char]): ptr[array[Char]];
128128
@expname[getVisibilityState] function getVisibilityState (): ptr[array[Char]];
129129
@expname[logToConsole] function logToConsole (msg: ptr[Char]);
130-
@expname[showAlert] function showAlert (message: ptr[Char]): Bool;
130+
@expname[showAlertDialog] function showAlertDialog (message: ptr[Char]);
131+
@expname[showConfirmDialog] function showConfirmDialog (message: ptr[Char]): Bool;
131132
@expname[postMessage] function postMessage (target: ptr[Char], msgType: ptr[Char], msgBody: ptr[Char]);
132133
@expname[callCustomJsFn] function callCustomJsFn (fnName: ptr[Char], arg: ptr[Char]): ptr[Char];
133134
@expname[callCustomAsyncJsFn] function _callCustomAsyncJsFn (fnName: ptr[Char], arg: ptr[Char], cbId: ArchInt);

api.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,11 @@ wasmApi.logToConsole = (msg) => {
804804
console.log(toJsString(msg));
805805
}
806806

807-
wasmApi.showAlert = (message) => {
807+
wasmApi.showAlertDialog = (message) => {
808+
alert(toJsString(message));
809+
}
810+
811+
wasmApi.showConfirmDialog = (message) => {
808812
let isExecuted = confirm(toJsString(message));
809813
return isExecuted;
810814
}

مـنصة_ويب.أسس

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363

6464
عرف أعد_التوجيه: لقب httpRedirect؛
6565
عرف اكتب_في_الطرفية: لقب logToConsole؛
66+
عرف أظهر_نافذة_إشعار: لقب showAlertDialog؛
67+
عرف أظهر_نافذة_تأكيد: لقب showConfirmDialog؛
6668
عرف طابق_نمطا: لقب matchRegex؛
6769

6870
عرف علق_سياق_الصوت: لقب suspendAudioContext؛

0 commit comments

Comments
 (0)