Rename to haste

This commit is contained in:
John Crepezzi 2011-11-18 17:23:23 -05:00
parent fe68e42b90
commit a6bd69f20a
3 changed files with 40 additions and 43 deletions

25
static/application.css Normal file
View File

@ -0,0 +1,25 @@
body {
background: #002B36;
padding: 0px;
margin: 0px;
}
textarea {
background: transparent;
border: 0px;
color: #fff;
padding: 20px;
width: 100%;
height: 100%;
font-family: monospace;
outline: none;
resize: none;
font-size: 13px;
}
#box {
padding: 0px;
width: 100%;
height: 100%;
}
#box code {
padding: 20px;
}

View File

@ -1,13 +1,11 @@
///// represents a single document ///// represents a single document
// TODO change name to haste var haste_document = function() {
var heist_document = function() {
this.locked = false; this.locked = false;
}; };
// Get this document from the server and lock it here // Get this document from the server and lock it here
heist_document.prototype.load = function(key, callback) { haste_document.prototype.load = function(key, callback) {
var _this = this; var _this = this;
$.ajax('/documents/' + key, { $.ajax('/documents/' + key, {
type: 'get', type: 'get',
@ -29,7 +27,7 @@ heist_document.prototype.load = function(key, callback) {
}; };
// Save this document to the server and lock it here // Save this document to the server and lock it here
heist_document.prototype.save = function(data, callback) { haste_document.prototype.save = function(data, callback) {
if (this.locked) { if (this.locked) {
return false; return false;
} }
@ -53,7 +51,7 @@ heist_document.prototype.save = function(data, callback) {
///// represents the paste application ///// represents the paste application
var heist = function(appName) { var haste = function(appName) {
this.appName = appName; this.appName = appName;
this.$textarea = $('textarea'); this.$textarea = $('textarea');
this.$box = $('#box'); this.$box = $('#box');
@ -64,15 +62,15 @@ var heist = function(appName) {
// TODO add key of commands // TODO add key of commands
// Set the page title - include the appName // Set the page title - include the appName
heist.prototype.setTitle = function(ext) { haste.prototype.setTitle = function(ext) {
var title = ext ? this.appName + ' - ' + ext : this.appName; var title = ext ? this.appName + ' - ' + ext : this.appName;
document.title = title; document.title = title;
}; };
// Remove the current document (if there is one) // Remove the current document (if there is one)
// and set up for a new one // and set up for a new one
heist.prototype.newDocument = function(hideHistory) { haste.prototype.newDocument = function(hideHistory) {
this.doc = new heist_document(); this.doc = new haste_document();
this.$box.hide(); this.$box.hide();
if (!hideHistory) { if (!hideHistory) {
window.history.pushState(null, this.appName, '/'); window.history.pushState(null, this.appName, '/');
@ -82,9 +80,9 @@ heist.prototype.newDocument = function(hideHistory) {
} }
// Load a document and show it // Load a document and show it
heist.prototype.loadDocument = function(key) { haste.prototype.loadDocument = function(key) {
var _this = this; var _this = this;
_this.doc = new heist_document(); _this.doc = new haste_document();
_this.doc.load(key, function(ret) { _this.doc.load(key, function(ret) {
if (ret) { if (ret) {
_this.$code.html(ret.value); _this.$code.html(ret.value);
@ -103,7 +101,7 @@ heist.prototype.loadDocument = function(key) {
}; };
// Duplicate the current document - only if locked // Duplicate the current document - only if locked
heist.prototype.duplicateDocument = function() { haste.prototype.duplicateDocument = function() {
if (this.doc.locked) { if (this.doc.locked) {
var currentData = this.doc.data; var currentData = this.doc.data;
this.newDocument(); this.newDocument();
@ -112,7 +110,7 @@ heist.prototype.duplicateDocument = function() {
}; };
// Lock the current document // Lock the current document
heist.prototype.lockDocument = function() { haste.prototype.lockDocument = function() {
var _this = this; var _this = this;
this.doc.save(this.$textarea.val(), function(ret) { this.doc.save(this.$textarea.val(), function(ret) {
if (ret) { if (ret) {
@ -130,7 +128,7 @@ heist.prototype.lockDocument = function() {
}; };
// Configure keyboard shortcuts for the textarea // Configure keyboard shortcuts for the textarea
heist.prototype.configureShortcuts = function() { haste.prototype.configureShortcuts = function() {
var _this = this; var _this = this;
$('body').keyup(function(evt) { $('body').keyup(function(evt) {
// ^L or ^S for lock // ^L or ^S for lock

View File

@ -2,36 +2,10 @@
<head> <head>
<title>heist</title> <title>haste</title>
<link rel="stylesheet" type="text/css" href="solarized_dark.css"/> <link rel="stylesheet" type="text/css" href="solarized_dark.css"/>
<style type="text/css"> <link rel="stylesheet" type="text/css" href="application.css"/>
body {
background: #002B36;
padding: 0px;
margin: 0px;
}
textarea {
background: transparent;
border: 0px;
color: #fff;
padding: 20px;
width: 100%;
height: 100%;
font-family: monospace;
outline: none;
resize: none;
font-size: 13px;
}
#box {
padding: 0px;
width: 100%;
height: 100%;
}
#box code {
padding: 20px;
}
</style>
<script type="text/javascript" src="jquery-1.7.min.js"></script> <script type="text/javascript" src="jquery-1.7.min.js"></script>
<script type="text/javascript" src="highlight.min.js"></script> <script type="text/javascript" src="highlight.min.js"></script>
@ -40,7 +14,7 @@
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
// Set up // Set up
var app = new heist('heist'); var app = new haste('haste');
$('textarea').focus(); $('textarea').focus();
// Handle pops // Handle pops
window.onpopstate = function(evt) { window.onpopstate = function(evt) {