Skip to content
This repository has been archived by the owner on Nov 3, 2018. It is now read-only.

Commit

Permalink
link to hawk script
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Hammer committed Jul 14, 2013
1 parent 5530687 commit f6a842a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
1 change: 1 addition & 0 deletions lib/web/static/scripts/hawk.js
16 changes: 2 additions & 14 deletions lib/web/views/console.jade
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ block content
request.onreadystatechange = function () {

if (request.readyState === 4) {

if (request.status === 200) {

try {

credentials = JSON.parse(request.responseText);
}
catch (e) { }
Expand All @@ -32,7 +29,6 @@ block content
// Socket.io

var socket = io.connect('#{host.uri("api")}');

socket.on('connect', function () {

document.getElementById('session').innerHTML = 'authenticating...';
Expand All @@ -41,22 +37,17 @@ block content
socket.on('message', function (message) {

if (message.type == 'connect') {

document.getElementById('session').innerHTML = htmlEscape(message.session);
socket.json.send({ type: 'initialize', id: credentials.id, mac: Oz.macMessage(message.session, credentials) });
}
else if (message.type == 'initialize') {

document.getElementById('session').style.color = (message.status == 'ok' ? 'green' : 'red');

if (message.error) {

document.getElementById('stream').innerHTML += htmlEscape(JSON.stringify(message.error, null, 4)) + '<br />';
resizeListBox();
}
}
else {

document.getElementById('stream').innerHTML += htmlEscape(JSON.stringify(message, null, 4)) + '<br />';
resizeListBox();
}
Expand All @@ -65,7 +56,6 @@ block content
document.getElementById('session').innerHTML = 'connecting...';
}
else {

window.location = '/login?next=%2Fdeveloper%2Fconsole';
return;
}
Expand All @@ -79,11 +69,9 @@ block content
function sendRequest() {

var request = new XMLHttpRequest();

request.onreadystatechange = function() {
request.onreadystatechange = function () {

if (request.readyState == 4) {

document.getElementById('response').innerHTML = htmlEscape(JSON.stringify(JSON.parse(request.responseText), null, 4));
resizeListBox();
}
Expand All @@ -97,7 +85,7 @@ block content

// Calculate Signature
var authorization = Oz.request.generateHeader({ method: method, uri: uri }, credentials);
var authorization = Oz.request.generateHeader(uri, method, credentials).field;

// Send request
Expand Down

0 comments on commit f6a842a

Please sign in to comment.