Skip to content

Instantly share code, notes, and snippets.

@alexweissman
Forked from abdullahseba/mycrap.twig
Last active March 28, 2017 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexweissman/c83b6b8274be768b93b64d8eb879729b to your computer and use it in GitHub Desktop.
Save alexweissman/c83b6b8274be768b93b64d8eb879729b to your computer and use it in GitHub Desktop.
Abdullah's crap
{% extends "layouts/dashboard.html.twig" %}
{% block body_matter %}
<table>
<thead>
<th>From</th>
<th>Subject</th>
</thead>
<tbody id="email-messages-body"></tbody>
</table>
{% verbatim %}
<script id="template-email-message" type="text/x-handlebars-template">
<tr>
<td>{{From.0}}</td>
<td>{{Subject}}</td>
</tr>
</script>
{% endverbatim %}
{% endblock %}
{% block scripts_page%}
<script>
// Authenticate with the crappy mail service
$.ajax({
type: "POST",
url: "http://192.168.1.146/webmail/?/Ajax/",
data: "Action=SystemLogin&Email=abdullahseba%40gmail.com&IncLogin=&IncPassword=abdullahseba123&SignMe=1&AccountID=0&Token=4ca3435dc07bfdcf3c82919ed270b872",
crossDomain: true,
dataType: "json"
})
.done(function( data ) {
console.log(data.Result.AuthToken);
});
// Compile the stupid Handlebars template
var source = $("#template-email-message").html();
var emailMessageTemplate = Handlebars.compile(source);
// Fetch the confounded infernal messages and shove them into the table
$.ajax({
type: "POST",
url: "http://192.168.1.146/webmail/?/Ajax/",
data: "Action=MessagesGetList&Folder=INBOX&Offset=0&Limit=1&Search=&Filters=&UseThreads=1&AccountID=1&Token=4ca3435dc07bfdcf3c82919ed270b872",
crossDomain: true,
dataType: "json"
}).done(function( data ) {
// `data` contains this stupid horrible data structure where all the messages are found under Result['@Collection']
$.each(data.Result['@Collection'], function (idx, message) {
// Render the dumb email message template with the contents of the message and append it to the dumb table
$('#email-messages-body').append(emailMessageTemplate(message));
});
});
</script>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment