|
- data:text/html,
- <!-- JS Version 0.1 - Nov 2019 - GNU Public License v3.0 -->
- <!DOCTYPE html>
- <html>
- <head>
- <title>JSedit</title>
- </head>
- <body style='margin:0px; width: 100%; height: 100%; background: grey;'>
- <div class='toolbar'>
- <div class='button' onclick='popup("about")'>
- <b>JSedit</b>
- </div>
- <div class='button' onclick='preview()'>
- Exec
- </div>
- <div class='button' onclick='exportCode()'>
- Export
- </div>
- </div>
- <textarea class='code' id='code' onkeydown="if(event.keyCode===9){var v=this.value,s=this.selectionStart,e=this.selectionEnd;this.value=v.substring(0, s)+'\t'+v.substring(e);this.selectionStart=this.selectionEnd=s+1;return false;}" placeholder='Enter text here...'></textarea>
- <style>
- .toolbar {
- width: 100%: height: 35px;
- background: grey;
- padding: 1.5px 1.5px;
- position: absolute;
- top: 0px;
- left: 0px;
- }
- .button {
- float: left;
- margin-right: 2px;
- border: 2px solid black;
- width: 100px;
- height: 31px;
- font-size: 15px;
- background: grey;
- color: black;
- background: white;
- text-align: center;
- font-family: sans-serif;
- cursor: pointer;
- user-select: none;
- padding-top: 4px;
- box-sizing: border-box;
- }
- .button:active {
- background: lightgrey;
- }
- .code {
- position: absolute;
- bottom: 0px;
- left: 0px;
- color: white;
- background-color: rgb(45, 49, 66);
- font-size: 19px;
- border: none;
- width: 100%;
- height: calc(100% - 40px);
- resize: none;
- outline: none;
- tab-size: 4px;
- -moz-tab-size: 4;
- }
- .popup {
- position: absolute;
- top: calc(50% - 200px);
- left: calc(50% - 200px);
- background: white;
- width: 400px;
- height: 400px;
- text-align: center;
- }
- </style>
- <script>
- function setText(text) {
- document.getElementById("code").value = text;
- }
-
- function preview() {
- window.open("javascript:try {" + document.getElementById("code").value + "} catch(e) {alert(e)}", "Hola", "width=500, height=500");
- }
-
- function exportCode() {
- var encoded = "`" + encodeURI(document.getElementById("code").value) + "`";
- prompt('Copy this as a bookmarklet', "javascript:setText(decodeURI(" + encoded + "))");
- }
- window.onbeforeunload = function() {
- return "If you leave this page, you will lose any unsaved changes.";
- };
-
- function popup(name) {
- var popup = document.createElement("DIV");
- popup.className = "popup";
- popup.innerHTML = ` <h1>JSedit<\/h1> <span>JSedit v0.1.0<\/span> <br> <span>View source at https://code.theres.life/PetabyteStudios/JSedit/raw/branch/master/bookmarklet<\/span> <br> <button onclick='this.parentElement.outerHTML = ""'>Close<\/button> `;
- document.body.appendChild(popup);
- }
- </script>
- </body>
- </html>
|