app/views/welcome/history.html.haml
:javascript
function post(path, params, method) {
method = method || "post"; // Set method to post by default if not specified.
// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
}
function submit_form(id) {
post("", {eid: id});
}
.container
%div{:style => "margin-top:50px;"}
%h2 Recent Activities
%p Send these same woofs with just 1 click:
- @history.each do |h|
%form{:action=>"", :method=>"post"}
%input{:type=>"hidden", :name=>"eid", :value=>"#{h[:id]}"}
%p
%button.btn.btn-default.btn-block{:type=>"submit"}
- if h[:receiver_name].length > 0
%p{:style=>"font-weight:bold"}= h[:receiver_name]
- if h[:receiver].length > 0
%p{:style=>"font-size:0.8em"}= h[:receiver]
- if h[:address_string].length > 0
%p{:style=>"font-size:0.8em"}= h[:address_string]
- if h[:duration_setting]
%p{:style=>"font-size:0.8em"}= h[:duration_setting]
- if h[:message]
%p{:style=>"font-size:0.8em"}= h[:message]
%p{:style=>"font-size:0.8em"}= "Created: #{h[:created_at]}"
/ %a.list-group-item{:href => "/event/summary", :onclick => "submit_form(#{h[:id].to_s});return false;"}
/ %p{:style=>"display:none"}= "eid:#{h[:id]}:"
/ %p= h[:receiver_name]
/ %p= h[:receiver]
/ %p= h[:address_string]
/ %p= h[:duration_setting]
/ %p= h[:created_at]