From ec3d0d26751b15c05a02e167546c64cc74ee3eca Mon Sep 17 00:00:00 2001 From: Kenox Date: Fri, 4 Nov 2022 09:18:38 +0100 Subject: [PATCH] Set max width to window width if it does not exceed --- static/application.js | 4 ++++ static/application.min.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/static/application.js b/static/application.js index 82a4dac..ff74fe7 100644 --- a/static/application.js +++ b/static/application.js @@ -328,6 +328,10 @@ function highlightNew(code) { } codes[i].style.removeProperty("background-color"); } + const windowWidth = $(window).width(); + if(windowWidth > maxWidth) + maxWidth = windowWidth; + for (let i = 0; i < codes.length; i++) { codes[i].style.width = maxWidth + 'px'; } diff --git a/static/application.min.js b/static/application.min.js index d5e8a3d..48f399e 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])}function highlightNew(e){const t=document.getElementsByTagName("code");let o=0;for(let e=0;eo&&(o=t[e].offsetWidth),t[e].style.removeProperty("background-color");for(let e=0;e'+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;o0;)t[0].parentNode.removeChild(t[0]);this.$box.hide(),this.doc=new haste_document,this.setTitle(),this.lightKey(),this.$textarea.val("").show("fast",function(){this.focus()}),this.removeLineNumbers()},haste.extensionMap={rb:"ruby",py:"python",pl:"perl",php:"php",scala:"scala",go:"go",xml:"xml",html:"xml",htm:"xml",css:"css",js:"javascript",vbs:"vbscript",lua:"lua",pas:"delphi",java:"java",cpp:"cpp",cc:"cpp",m:"objectivec",vala:"vala",sql:"sql",sm:"smalltalk",lisp:"lisp",ini:"ini",diff:"diff",bash:"bash",sh:"bash",tex:"tex",erl:"erlang",hs:"haskell",md:"markdown",txt:"",coffee:"coffee",swift:"swift"},haste.prototype.lookupExtensionByType=function(e){for(var t in haste.extensionMap)if(haste.extensionMap[t]===e)return t;return e},haste.prototype.lookupTypeByExtension=function(e){return haste.extensionMap[e]||e},haste.prototype.addLineNumbers=function(e){if(removeElementsByClass("linenumber"),window.location.hash){highlightNew(getLineElement(window.location.hash.substring(1)))}},haste.prototype.removeLineNumbers=function(){removeElementsByClass("highlight"),removeElementsByClass("linenumber");let e=document.createElement("a");e.classList.add("linenumber");let t=document.createTextNode(">");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){for(var t=e.value.split(/\r\n|\r|\n/),n=0;n/g,">").replace(/0;)t[0].parentNode.removeChild(t[0])}function highlightNew(e){const t=document.getElementsByTagName("code");let o=0;for(let e=0;eo&&(o=t[e].offsetWidth),t[e].style.removeProperty("background-color");const n=$(window).width();n>o&&(o=n);for(let e=0;e'+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;o0;)t[0].parentNode.removeChild(t[0]);this.$box.hide(),this.doc=new haste_document,this.setTitle(),this.lightKey(),this.$textarea.val("").show("fast",function(){this.focus()}),this.removeLineNumbers()},haste.extensionMap={rb:"ruby",py:"python",pl:"perl",php:"php",scala:"scala",go:"go",xml:"xml",html:"xml",htm:"xml",css:"css",js:"javascript",vbs:"vbscript",lua:"lua",pas:"delphi",java:"java",cpp:"cpp",cc:"cpp",m:"objectivec",vala:"vala",sql:"sql",sm:"smalltalk",lisp:"lisp",ini:"ini",diff:"diff",bash:"bash",sh:"bash",tex:"tex",erl:"erlang",hs:"haskell",md:"markdown",txt:"",coffee:"coffee",swift:"swift"},haste.prototype.lookupExtensionByType=function(e){for(var t in haste.extensionMap)if(haste.extensionMap[t]===e)return t;return e},haste.prototype.lookupTypeByExtension=function(e){return haste.extensionMap[e]||e},haste.prototype.addLineNumbers=function(e){if(removeElementsByClass("linenumber"),window.location.hash){highlightNew(getLineElement(window.location.hash.substring(1)))}},haste.prototype.removeLineNumbers=function(){removeElementsByClass("highlight"),removeElementsByClass("linenumber");let e=document.createElement("a");e.classList.add("linenumber");let t=document.createTextNode(">");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){for(var t=e.value.split(/\r\n|\r|\n/),n=0;n