This repository has been archived on 2022-02-10. You can view files and clone it, but cannot push or open issues or pull requests.
filespread/res/dart/main.dart
2017-04-20 13:32:09 +02:00

37 lines
940 B
Dart

// Copyright (c) 2016 - 2017, Marcel Kapfer (mmk2410).
// MIT License
import 'dart:convert';
import 'dart:html';
void main() {
// send mail listener
querySelector("#send").onClick.listen(sendMail);
}
void sendMail(MouseEvent event) {
InputElement title = querySelector("#mailtitle");
InputElement text = querySelector("#mailtext");
InputElement filename = querySelector("#filename");
InputElement addresslist = querySelector("#address_list");
CheckboxInputElement nofile = querySelector("#nofile");
Map data = {
"title": title.value,
"body": text.value,
"filename": filename.value,
"list": addresslist.value,
"nofile": nofile.checked
};
String url = "res/php/sendmail.php?data=${JSON.encode(data)}";
HttpRequest.getString(url).then((response) {
if (response == "0") {
window.alert("Mails successfully sent.");
} else {
window.alert("Failed to send mail.");
}
});
}