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
Marcel Kapfer (mmk2410) c7d14040b3 Fix: Send mail not working in subdirectory
Res: T126
2016-11-24 11:13:18 +01:00

34 lines
844 B
Dart

// Copyright (c) 2016, 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");
Map data = {
"title": title.value,
"body": text.value,
"filename": filename.value,
"list": addresslist.value
};
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.");
}
});
}