From dfcd5eeef19d946b645ef501a39520a1cfe09b29 Mon Sep 17 00:00:00 2001 From: Kenox Date: Thu, 3 Nov 2022 20:50:54 +0100 Subject: [PATCH] Update scrolling --- static/application.js | 6 +++++- static/application.min.js | 2 +- static/index.html | 2 +- static/solarized_dark.css | 18 ++++++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/static/application.js b/static/application.js index d860c78..0bda107 100644 --- a/static/application.js +++ b/static/application.js @@ -234,7 +234,11 @@ haste.prototype.loadDocument = function(key) { _this.doc = new haste_document(); _this.doc.load(parts[0], function(ret) { if (ret) { - _this.$code.html(ret.value); + let code = document.createElement('code'); + code.innerHTML = ret.value; + let pre = document.getElementById("box"); + pre.appendChild(code); + _this.setTitle(ret.key); _this.fullKey(); _this.$textarea.val('').hide(); diff --git a/static/application.min.js b/static/application.min.js index 900594e..04b8cb9 100644 --- a/static/application.min.js +++ b/static/application.min.js @@ -1 +1 @@ -const workersUrl="https://api.knx.cool/";var haste_document=function(){this.locked=!1};htmlEscape=function(e){return e.replace(/&/g,"&").replace(/>/g,">").replace(/0;)t[0].parentNode.removeChild(t[0])}haste.prototype.setTitle=function(e){var t=e?this.appName+" - "+e:this.appName;document.title=t},haste.prototype.showMessage=function(e,t){var o=$('
  • '+e+"
  • ");$("#messages").prepend(o),setTimeout(function(){o.slideUp("fast",function(){$(this).remove()})},3e3)},haste.prototype.lightKey=function(){this.configureKey(["new","save"])},haste.prototype.fullKey=function(){this.configureKey(["new","duplicate","raw"])},haste.prototype.configureKey=function(e){var t,o=0;$("#box2 .function").each(function(){for(t=$(this),o=0;o");e.appendChild(t),document.body.appendChild(e)},haste.prototype.loadDocument=function(e){var t=e.split(".",2),o=this;o.doc=new haste_document,o.doc.load(t[0],function(e){e?(o.$code.html(e.value),o.setTitle(e.key),o.fullKey(),o.$textarea.val("").hide(),o.$box.show().focus(),o.addLineNumbers(e.lineCount)):o.newDocument()},this.lookupTypeByExtension(t[1]))},haste.prototype.duplicateDocument=function(){if(this.doc.locked){var e=this.doc.data;this.newDocument(),this.$textarea.val(e)}},haste.prototype.lockDocument=function(){var e=this;this.doc.save(this.$textarea.val(),function(t,o){if(t)e.showMessage(t.message,"error");else if(o){e.$code.html(htmlEscape(o.value)),e.setTitle(o.key);var n="/"+o.key;window.history.pushState(null,e.appName+"-"+o.key,n),e.fullKey(),e.$textarea.val("").hide(),e.$box.show().focus(),e.addLineNumbers(o.lineCount)}})},haste.prototype.configureButtons=function(){var e=this;this.buttons=[{$where:$("#box2 .save"),label:"Save",shortcutDescription:"control + s",shortcut:function(e){return e.ctrlKey&&83===e.keyCode},action:function(){""!==e.$textarea.val().replace(/^\s+|\s+$/g,"")&&e.lockDocument()}},{$where:$("#box2 .new"),label:"New",shortcut:function(e){return e.ctrlKey&&78===e.keyCode},shortcutDescription:"control + n",action:function(){e.newDocument(!e.doc.key)}},{$where:$("#box2 .duplicate"),label:"Duplicate & Edit",shortcut:function(t){return e.doc.locked&&t.ctrlKey&&68===t.keyCode},shortcutDescription:"control + d",action:function(){e.duplicateDocument()}},{$where:$("#box2 .raw"),label:"Just Text",shortcut:function(e){return e.ctrlKey&&e.shiftKey&&82===e.keyCode},shortcutDescription:"control + shift + r",action:function(){window.location.href=workersUrl+"raw/"+e.doc.key}}];for(var t=0;t/g,">").replace(/0;)t[0].parentNode.removeChild(t[0])}haste.prototype.setTitle=function(e){var t=e?this.appName+" - "+e:this.appName;document.title=t},haste.prototype.showMessage=function(e,t){var o=$('
  • '+e+"
  • ");$("#messages").prepend(o),setTimeout(function(){o.slideUp("fast",function(){$(this).remove()})},3e3)},haste.prototype.lightKey=function(){this.configureKey(["new","save"])},haste.prototype.fullKey=function(){this.configureKey(["new","duplicate","raw"])},haste.prototype.configureKey=function(e){var t,o=0;$("#box2 .function").each(function(){for(t=$(this),o=0;o");e.appendChild(t),document.body.appendChild(e)},haste.prototype.loadDocument=function(e){var t=e.split(".",2),o=this;o.doc=new haste_document,o.doc.load(t[0],function(e){if(e){let t=document.createElement("code");t.innerHTML=e.value,document.getElementById("box").appendChild(t),o.setTitle(e.key),o.fullKey(),o.$textarea.val("").hide(),o.$box.show().focus(),o.addLineNumbers(e.lineCount)}else o.newDocument()},this.lookupTypeByExtension(t[1]))},haste.prototype.duplicateDocument=function(){if(this.doc.locked){var e=this.doc.data;this.newDocument(),this.$textarea.val(e)}},haste.prototype.lockDocument=function(){var e=this;this.doc.save(this.$textarea.val(),function(t,o){if(t)e.showMessage(t.message,"error");else if(o){e.$code.html(htmlEscape(o.value)),e.setTitle(o.key);var n="/"+o.key;window.history.pushState(null,e.appName+"-"+o.key,n),e.fullKey(),e.$textarea.val("").hide(),e.$box.show().focus(),e.addLineNumbers(o.lineCount)}})},haste.prototype.configureButtons=function(){var e=this;this.buttons=[{$where:$("#box2 .save"),label:"Save",shortcutDescription:"control + s",shortcut:function(e){return e.ctrlKey&&83===e.keyCode},action:function(){""!==e.$textarea.val().replace(/^\s+|\s+$/g,"")&&e.lockDocument()}},{$where:$("#box2 .new"),label:"New",shortcut:function(e){return e.ctrlKey&&78===e.keyCode},shortcutDescription:"control + n",action:function(){e.newDocument(!e.doc.key)}},{$where:$("#box2 .duplicate"),label:"Duplicate & Edit",shortcut:function(t){return e.doc.locked&&t.ctrlKey&&68===t.keyCode},shortcutDescription:"control + d",action:function(){e.duplicateDocument()}},{$where:$("#box2 .raw"),label:"Just Text",shortcut:function(e){return e.ctrlKey&&e.shiftKey&&82===e.keyCode},shortcutDescription:"control + shift + r",action:function(){window.location.href=workersUrl+"raw/"+e.doc.key}}];for(var t=0;t - + diff --git a/static/solarized_dark.css b/static/solarized_dark.css index e09929a..d2772e6 100644 --- a/static/solarized_dark.css +++ b/static/solarized_dark.css @@ -12,6 +12,24 @@ Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull