Compare commits

...

5 Commits

Author SHA1 Message Date
Yaya 7233295c98 try some changes 2020-07-31 00:07:31 +08:00
Yaya daa1d24ae2 add js discord webhook 2020-07-30 23:45:46 +08:00
Yaya 4c29b68f8c test file 2020-05-09 21:38:26 +08:00
Muhammad Nur Hidayat Yasuyoshi (MNH48.com) dc4e5ac95c
Update index.md 2018-05-25 06:50:48 +08:00
Muhammad Nur Hidayat Yasuyoshi (MNH48.com) 251fddd9dc
Update _config.yml 2018-05-19 01:09:12 +08:00
4 changed files with 125 additions and 2 deletions

View File

@ -3,4 +3,4 @@ title: MNH48
description: Malay translator
baseurl: /MuhdNurHidayat.github.io
include: [favicon.png, favicon.ico]
keep_files: [signature, minetest, etc]
keep_files: [signature, minetest]

94
etc/discord_webhook.html Normal file
View File

@ -0,0 +1,94 @@
<!DOCTYPE html>
<!-- To the extent possible under law, Jan Hasebos has waived all copyright and related or neighboring rights to this file. -->
<!-- Source: https://gist.github.com/jtvjan/211475718de8841ee1f7c96353901498#file-discord_webhook_example-html -->
<html>
<body>
<h1>Discord Webhook Sender</h1>
<h2>Advanced: JS XMLHttpRequest Form</h2>
<form id="sendform">
<label for="msgtext">Webhook URL: </label><input type="text" id="url" /><br />
<label for="msgtext">Message content: </label><input type="textarea" pattern=".{0,2000}" id="msgtext" /><br />
<label for="name">Username: </label><input type="text" id="name" /><br />
<label for="avatar">Avatar URL: </label><input type="text" id="avatar" /><br />
<label for="speech">Text-to-speech: </label><input type="checkbox" id="speech" /><br />
<div id="embeds"></div>
<input type="button" id="addembed" value="Add Embed" /><br />
<input type="submit" /><br />
<span id="result"> </span>
</form>
<!-- We place this at the bottom so the DOM is ready when our script gets executed. -->
<script>
document.getElementById('sendform').addEventListener('submit', function(e) {
e.preventDefault(); // don't actually submit the form, as there's no "action" to submit to
var message = {
// construct the object to send to discord
content: document.getElementById('msgtext').value,
username: document.getElementById('name').value,
avatar_url: document.getElementById('avatar').value,
tts: document.getElementById('speech').checked,
embeds: []
};
var embeds = document.getElementById('embeds').childNodes;
for (var i = 0; i < embeds.length; ++i)
message.embeds.push(divToEmbed(embeds[i]));
var req = new XMLHttpRequest();
req.addEventListener('load', handleLoad);
req.open('post', document.getElementById('url').value, true); // (method, url, async)
req.setRequestHeader('Content-Type', 'application/json');
req.send(JSON.stringify(message));
});
function handleLoad() {
document.getElementById('result').childNodes[0].textContent = 'Message sent at ' + Date().toString() + ' with response code ' + this.status;
}
// == embed handling ==
var embedDiv = (function() {
var div = document.createElement('div'),
input;
// timestamp doesn't have an user friendly UI in some browsers, make sure you enter an ISO date like 2019-04-30T21:05:07.510Z
var mainfields = {
'title': 'text',
'description': 'text',
'url': 'text',
'timestamp': 'datetime-local',
'color': 'color',
'image': 'url',
};
for (var field in mainfields) {
input = document.createElement('input');
input.type = mainfields[field];
input.placeholder = field;
div.appendChild(input);
}
/* We could support every embed option, but that's way beyond the scope of this document.
https://discordapp.com/developers/docs/resources/channel#embed-object */
return div;
})();
document.getElementById('addembed').addEventListener('click', function() {
document.getElementById('embeds').appendChild(embedDiv.cloneNode(true)); // true makes it a deep clone so it includes its children
});
function divToEmbed(div) {
return {
'title': div.childNodes[0].value,
'description': div.childNodes[1].value,
'url': div.childNodes[2].value,
'timestamp': div.childNodes[3].value,
'color': parseInt(div.childNodes[4].value.substring(1),
16), // discord expects numbers as an int, while the color input outputs it in hex prefixed with a #
'image': '{"url":'+div.childNodes[5].value+'}'
};
}
</script>
</body>
</html>

28
etc/test.md Normal file
View File

@ -0,0 +1,28 @@
---
layout: default
title: Test
lang: mul
---
testing github page link behaviour
page.url
{{page.url}}
absolute page.url
{{ page.url | absolute_url }}
page.path
{{page.path}}
absolute page.path
{{ page.path | absolute_url }}
page.relative_path
{{page.relative_path}}
absolute page.relative_path
{{ page.relative_path | absolute_url }}

View File

@ -1,5 +1,6 @@
---
title: MNH48
description: This is the GitHub userpage of MuhdNurHidayat, also known as MNH48 elsewhere.
---
This is the GitHub userpage of MuhdNurHidayat, also known as MNH48 elsewhere.
@ -8,4 +9,4 @@ I'm a translator, usually translating English/Chinese/Japanese to Malay, also do
I'm working on a self-hosted website to showcast my translation works at [mnh48.moe](https://mnh48.moe) so you could see more details on how I do translations when that website is published.
I'm also the main translator of Malay in [Minetest](https://github.com/minetest/minetest), an open-source voxel game engine. I'm making mods for the engine too, but most of them are not published on GitHub (yet). Do check Minetest out if you have some time and join the community!
I'm also the main translator of Malay in [Minetest](https://github.com/minetest/minetest), an open-source voxel game engine. I'm making mods for the engine too, but most of them are not published on GitHub (yet). The only Minetest mod I've published is the client-side mod [unicodeparser](https://github.com/MuhdNurHidayat/unicodeparser). Do check Minetest out if you have some time and join the community!