Initial commit
This commit is contained in:
24
app/views/contracts/edit.html.erb
Normal file
24
app/views/contracts/edit.html.erb
Normal file
@@ -0,0 +1,24 @@
|
||||
<h1>Editing contract</h1>
|
||||
|
||||
<% form_for(@contract) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
|
||||
<p>
|
||||
<%= f.label :boilerplate %><br />
|
||||
<%= f.text_field :boilerplate %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :signature %><br />
|
||||
<%= f.text_field :signature %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :signinghash %><br />
|
||||
<%= f.text_field :signinghash %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.submit 'Update' %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'Show', @contract %> |
|
||||
<%= link_to 'Back', contracts_path %>
|
||||
24
app/views/contracts/index.html.erb
Normal file
24
app/views/contracts/index.html.erb
Normal file
@@ -0,0 +1,24 @@
|
||||
<h1>Listing contracts</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Name</th>
|
||||
<th>Signer</th>
|
||||
</tr>
|
||||
|
||||
<% @contracts.each do |contract| %>
|
||||
<tr>
|
||||
<td><%=h contract.datesigned %></td>
|
||||
<td><%=h contract.name %></td>
|
||||
<td><% if(!contract.signer.blank?) then %><%=h contract.signer.first_name %> <%=h contract.signer.last_name %><% end %></td>
|
||||
<td><%= link_to 'Show', contract %></td>
|
||||
<td><%= link_to 'Edit', edit_contract_path(contract) %></td>
|
||||
<td><%= link_to 'Destroy', contract, :confirm => 'Are you sure?', :method => :delete %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New contract', new_contract_path %>
|
||||
182
app/views/contracts/new.html.erb
Normal file
182
app/views/contracts/new.html.erb
Normal file
@@ -0,0 +1,182 @@
|
||||
<script language="javascript">
|
||||
function showboiler(id) {
|
||||
|
||||
if(id>0) {
|
||||
$.ajax({
|
||||
url: "/contract_templates/"+id+".txt",
|
||||
context: document.body,
|
||||
success: function(data){
|
||||
document.getElementById('boilerdisplay').innerHTML = data;
|
||||
document.getElementById('contract_boilerplate').value = data;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
document.getElementById('boilerdisplay').innerHTML = "";
|
||||
document.getElementById('contract_boilerplate').value = "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function clearme() {
|
||||
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||
context.beginPath();
|
||||
}
|
||||
</script>
|
||||
|
||||
<% form_for(@contract) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
|
||||
<p>
|
||||
<%= f.label :Template %>
|
||||
<%= select_tag("boilerplate_select", options_for_select(ContractTemplate.all.collect{ |c| [c.name, c.id] }.insert(0, '')), {:onchange => "showboiler(this.value)"}) %>
|
||||
<%= f.hidden_field :signature %>
|
||||
<%= f.hidden_field :boilerplate %>
|
||||
</p>
|
||||
<div id="boilerdisplay"></div>
|
||||
|
||||
<meta name = "viewport" content = "width = device-width">
|
||||
|
||||
<style type="text/css">
|
||||
html, body {
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
#canvas {
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
<body id="body">
|
||||
|
||||
<input type="button" value="Clear" onclick="clearme()" />
|
||||
|
||||
<div id="container"> <!-- container. start -->
|
||||
<canvas width="800" height="200" id="canvas">
|
||||
</canvas>
|
||||
</div><!-- container. end -->
|
||||
<!-- <p id="debug"></p> -->
|
||||
<p>
|
||||
<%= f.submit 'Update' %>
|
||||
</p>
|
||||
|
||||
|
||||
<% end %>
|
||||
|
||||
|
||||
<%= link_to 'Back', contracts_path %>
|
||||
|
||||
|
||||
|
||||
<!-- JavaScript -->
|
||||
<script type="text/javascript" src="/javascripts/jquery-1.3.2.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var oldX,oldY,sofX,sofY,down=false,drag=false;
|
||||
var q = new Array;
|
||||
var body = document.getElementById("body");
|
||||
var canvas = document.getElementById("canvas");
|
||||
var context = canvas.getContext('2d');
|
||||
body.addEventListener("touchmove", touch, false);
|
||||
canvas.addEventListener("touchstart", touchStart, false);
|
||||
canvas.addEventListener("touchmove", touchMove, false);
|
||||
canvas.addEventListener("touchend", drawEnd, false);
|
||||
canvas.addEventListener("touchcancel", drawEnd, false);
|
||||
|
||||
body.addEventListener('mouseup', drawEnd);
|
||||
canvas.addEventListener('mousedown', mouseDown);
|
||||
canvas.addEventListener('mousemove', mouseMove);
|
||||
canvas.addEventListener('mouseup', drawEnd);
|
||||
|
||||
function touch(event) {
|
||||
// console.log(event);
|
||||
event.preventDefault();
|
||||
element = document.getElementById("debug");
|
||||
element.innerHTML = event.touches.length+" touch ("+event.touches[0].pageX+","+event.touches[0].pageY+")("+$(canvas).offset().left+","+$(canvas).offset().top+") down:"+down+" drag:"+drag;
|
||||
}
|
||||
|
||||
function touchStart(event) {
|
||||
touch(event);
|
||||
drawStart([event.touches[0].pageX - $(canvas).offset().left,event.touches[0].pageY - $(canvas).offset().top]);
|
||||
}
|
||||
|
||||
function mouseDown(event) {
|
||||
drawStart([event.pageX - $(canvas).offset().left,event.pageY - $(canvas).offset().top]);
|
||||
element = document.getElementById("debug");
|
||||
element.innerHTML = q.length+" ("+event.pageX+","+event.pageY+")("+$(canvas).offset().left+","+$(canvas).offset().top+") down:"+down+" drag:"+drag;
|
||||
}
|
||||
|
||||
function drawStart(point) {
|
||||
var x=point[0], y=point[1];
|
||||
q = [point];
|
||||
down = true;
|
||||
context.lineWidth = 1;
|
||||
context.strokeStyle = '#000000';
|
||||
}
|
||||
|
||||
function touchMove(event) {
|
||||
touch(event);
|
||||
drawMove([event.touches[0].pageX - $(canvas).offset().left,event.touches[0].pageY - $(canvas).offset().top]);
|
||||
};
|
||||
|
||||
function mouseMove(event) {
|
||||
drawMove([event.pageX - $(canvas).offset().left,event.pageY - $(canvas).offset().top]);
|
||||
}
|
||||
|
||||
function drawMove(point) {
|
||||
var x=point[0], y=point[1];
|
||||
drag=true;
|
||||
if(down && drag && q.length>=4) {
|
||||
q.push(point);
|
||||
// context.fillRect(q[1][0], q[1][1], 1, 1);
|
||||
// context.fillRect(q[2][0], q[2][1], 1, 1);
|
||||
context.beginPath();
|
||||
context.moveTo(q[0][0], q[0][1]);
|
||||
context.bezierCurveTo(q[1][0], q[1][1], q[2][0], q[2][1], q[3][0], q[3][1]);
|
||||
q.shift();
|
||||
q.shift();
|
||||
q.shift();
|
||||
// context.closePath();
|
||||
context.stroke();
|
||||
} else if(down && drag) {
|
||||
q.push(point);
|
||||
}
|
||||
oldX = x;
|
||||
oldY = y;
|
||||
sofX = oldX;
|
||||
sofY = oldY;
|
||||
}
|
||||
|
||||
// Finished drawing (mouse up)
|
||||
function drawEnd(event) {
|
||||
// touch(event);
|
||||
if(q.length>=2) {
|
||||
if(q.length==4){
|
||||
context.bezierCurveTo(q[1][0], q[1][1], q[2][0], q[2][1], q[3][0], q[3][1]);
|
||||
}
|
||||
if(q.length==3){
|
||||
context.quadraticCurveTo(q[1][0], q[1][1],q[2][0], q[2][1]);
|
||||
}
|
||||
if(q.length==2){
|
||||
context.lineTo(q[1][0], q[1][1]);
|
||||
}
|
||||
context.stroke();
|
||||
q=[];
|
||||
}
|
||||
if(down && drag==false || q.length==1) {
|
||||
// context.fillRect(q[0][0],q[0][1], 2, 2);
|
||||
context.beginPath();
|
||||
context.arc(q[0][0],q[0][1],1,0,Math.PI*2,true);
|
||||
context.closePath();
|
||||
context.stroke();
|
||||
context.fill();
|
||||
}
|
||||
down = false;
|
||||
drag = false;
|
||||
|
||||
// Write the canvas to a data url
|
||||
$("#contract_signature")[0].value = canvas.toDataURL("image/png")
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
23
app/views/contracts/new.html.erb.deleteme
Normal file
23
app/views/contracts/new.html.erb.deleteme
Normal file
@@ -0,0 +1,23 @@
|
||||
<h1>New contract</h1>
|
||||
|
||||
<% form_for(@contract) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
|
||||
<p>
|
||||
<%= f.label :boilerplate %><br />
|
||||
<%= f.text_field :boilerplate %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :signature %><br />
|
||||
<%= f.text_field :signature %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :signinghash %><br />
|
||||
<%= f.text_field :signinghash %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.submit 'Create' %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'Back', contracts_path %>
|
||||
27
app/views/contracts/show.html.erb
Normal file
27
app/views/contracts/show.html.erb
Normal file
@@ -0,0 +1,27 @@
|
||||
<p>
|
||||
<b>Boilerplate:</b>
|
||||
<%=@contract.boilerplate %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Signature:</b>
|
||||
<img src="<%=@contract.signature %>" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Date Signed:</b>
|
||||
<%=h @contract.datesigned %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Hash:</b>
|
||||
<%=h @contract.signinghash %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Verification:</b>
|
||||
<%=Digest::SHA1.hexdigest @contract.boilerplate+@contract.signature+@contract.datesigned.to_s%>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_contract_path(@contract) %> |
|
||||
<%= link_to 'Back', contracts_path %>
|
||||
Reference in New Issue
Block a user