* Window manager stuff. Multiple windows can be opened now. Still resolving bugs.
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
|
||||
// REDEEMING /////////////////////////////////////////////////////////
|
||||
|
||||
/* Resource type names mapped to actual names and abbreviations.
|
||||
@ -93,11 +92,12 @@ window.REDEEM_HINTS = {
|
||||
};
|
||||
|
||||
window.handleRedeemResponse = function(data, textStatus, jqXHR) {
|
||||
var passcode = this.passcode, to_alert, to_log;
|
||||
var passcode = this.passcode, to_dialog, to_log, buttons;
|
||||
|
||||
if(data.error) {
|
||||
to_alert = '<strong>' + data.error + '</strong><br />' + (window.REDEEM_ERRORS[data.error] || 'There was a problem redeeming the passcode. Try again?');
|
||||
to_log = '[ERROR] ' + data.error;
|
||||
to_dialog = '<strong>' + data.error + '</strong><br />' + (window.REDEEM_ERRORS[data.error] || 'There was a problem redeeming the passcode. Try again?');
|
||||
to_log = '[ERROR] ' + data.error;
|
||||
buttons = {};
|
||||
} else if(data.result) {
|
||||
var encouragement = window.REDEEM_ENCOURAGEMENT[Math.floor(Math.random() * window.REDEEM_ENCOURAGEMENT.length)];
|
||||
var payload = {};
|
||||
@ -190,7 +190,7 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) {
|
||||
|
||||
// Let the user know if we had to guess
|
||||
if (inferred.length > 0) {
|
||||
results.table.push('<td style="font-family: monospace;">*</td><td style="font-family: monospace;">Guessed (check console)</td>');
|
||||
results.table.push('<td>*</td><td>Guessed (check console)</td>');
|
||||
$.each(inferred, function (idx, val) {
|
||||
console.log(passcode +
|
||||
' => [INFERRED] ' + val.type + ':' + val.key + ' :: ' +
|
||||
@ -198,17 +198,27 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) {
|
||||
});
|
||||
}
|
||||
|
||||
// Add table footers
|
||||
results.table.push('<td style="font-family: monospace;">></td><td><a href="javascript:alert(\'' +
|
||||
escape('<span style="font-family: monospace;"><strong>' + encouragement + '</strong><br />' + results.html.join('/') + '</span>') +
|
||||
'\', true);" style="font-family: monospace;">[plaintext]</a>');
|
||||
|
||||
// Display formatted versions in a table, plaintext, and the console log
|
||||
to_alert = '<table class="redeem-result">' + results.table.map(function(a) {return '<tr>' + a + '</tr>';}).join("\n") + '</table>';
|
||||
to_log = '[SUCCESS] ' + results.plain.join('/');
|
||||
to_dialog = '<table class="redeem-result">' +
|
||||
results.table.map(function(a) {return '<tr>' + a + '</tr>';}).join("\n") +
|
||||
'</table>';
|
||||
to_log = '[SUCCESS] ' + results.plain.join('/');
|
||||
buttons = {
|
||||
'PLAINTEXT' : function() {
|
||||
dialog({
|
||||
title: 'Passcode: ' + passcode,
|
||||
html: '<span style="font-family: monospace;"><strong>' + encouragement + '</strong>' +
|
||||
'<br />' + results.html.join('/') + '</span>'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
alert(to_alert, true);
|
||||
dialog({
|
||||
title: 'Passcode: ' + passcode,
|
||||
html: to_dialog,
|
||||
buttons: buttons
|
||||
});
|
||||
console.log(passcode + ' => ' + to_log);
|
||||
}
|
||||
|
||||
@ -225,7 +235,9 @@ window.setupRedeem = function() {
|
||||
} else {
|
||||
extra = 'No status code was returned.';
|
||||
}
|
||||
alert('<strong>The HTTP request failed.</strong> ' + extra);
|
||||
dialog({
|
||||
html: '<strong>The HTTP request failed.</strong> ' + extra
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user