├── res ├── icon.png └── snapshot.png ├── chrome-sketchtab.jpg ├── manifest.json ├── sandbox.html ├── LICENSE ├── README.md ├── styles.css ├── index.html ├── script.js └── codemirror ├── mode ├── htmlmixed │ └── htmlmixed.js ├── xml │ └── xml.js ├── javascript │ └── javascript.js └── css │ └── css.js └── codemirror.css /res/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spite/chrome-sketchtab/HEAD/res/icon.png -------------------------------------------------------------------------------- /res/snapshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spite/chrome-sketchtab/HEAD/res/snapshot.png -------------------------------------------------------------------------------- /chrome-sketchtab.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spite/chrome-sketchtab/HEAD/chrome-sketchtab.jpg -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Sketchtab", 3 | "short_name": "Sketchtab", 4 | "description": "New tab page with code editor", 5 | "version": "0.7", 6 | "incognito": "split", 7 | "chrome_url_overrides": { 8 | "newtab": "index.html" 9 | }, 10 | "web_accessible_resources": [ 11 | "index.html" 12 | ], 13 | "sandbox": { 14 | "pages": ["sandbox.html"] 15 | }, 16 | "manifest_version": 2, 17 | "content_security_policy": "script-src 'self'; object-src 'self'" 18 | } -------------------------------------------------------------------------------- /sandbox.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 29 | 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Jaume Sanchez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Chrome SketchTab 2 | ##### New tab page with code editor 3 | 4 | A New Tab for Google Chrome with a code editor 5 | 6 | ![](https://raw.githubusercontent.com/spite/chrome-sketchtab/master/chrome-sketchtab.jpg) 7 | 8 | ### How to install #### 9 | 10 | [![npm](https://raw.githubusercontent.com/spite/css-filters-devtools-extension/master/about/ChromeWebStore_Badge_v2_496x150.png)](https://chrome.google.com/webstore/detail/sketchtab/ioonoapnncbgnhjfjipkfbkpkogmknlm) 11 | 12 | [Install the extension from the Chrome Store](https://chrome.google.com/webstore/detail/sketchtab/ioonoapnncbgnhjfjipkfbkpkogmknlm) 13 | 14 | #### Features #### 15 | 16 | - HTML editor 17 | - CSS editor 18 | - JavaScript editor 19 | - Live output 20 | - Console output 21 | - Keeps state on LocalStorage 22 | 23 | # The MIT License (MIT) 24 | **Copyright © 2016 Jaume Sanchez Elias** 25 | 26 | * * * 27 | 28 | Permission is hereby granted, free of charge, to any person obtaining a copy of 29 | this software and associated documentation files (the “Software”), to deal in 30 | the Software without restriction, including without limitation the rights to 31 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 32 | the Software, and to permit persons to whom the Software is furnished to do so, 33 | subject to the following conditions: 34 | 35 | The above copyright notice and this permission notice shall be included in all 36 | copies or substantial portions of the Software. 37 | 38 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 39 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 40 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 41 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 42 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 43 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 44 | -------------------------------------------------------------------------------- /styles.css: -------------------------------------------------------------------------------- 1 | *{ margin: 0; padding: 0; box-sizing: border-box; font-family: "courier new"; font-size: 12px;} 2 | body{ position: absolute; height: 100%; width: 100%; overflow:hidden;} 3 | h3{ font-size: 14px; } 4 | .block{ position: absolute; left: 0; top: 25px; right: 0; bottom:0; width: 100%; height: calc(100%-30px); outline:none; border: none; } 5 | textarea.block{ padding: 10px; resize: none; border-top: 1px solid #ddd; border-bottom: 1px solid #fff; border-left: 1px solid #ddd; border-right: 1px solid #fff; } 6 | .block:focus{ background-color: #e5edff; } 7 | #console-output{ list-style-type: none; top: 30px; overflow: auto; } 8 | #console-output li{ padding: 0px 10px;} 9 | #console-output li:nth-child(odd) { background-color: #eee;} 10 | #console-output span{ margin-right: .4em;} 11 | #html-output{ } 12 | button{ padding: 10px;} 13 | a{ color: inherit;} 14 | a:hover{ color: #ff00ff;} 15 | 16 | header{ position: absolute; left: 0; top: 0; right: 0; height: 30px; display: flex; } 17 | header * { padding: 10px;} 18 | #main{ position: absolute; left: 0; top: 30px; right: 0; bottom: 0; width: 100%; height: calc(100%-30px); } 19 | .toolbar{ display: flex; width: 100%; background-color: #eee; } 20 | .toolbar *{ padding: 5px 10px; } 21 | 22 | .columns .container{ width: 20%; height: 100%; float:left; position: relative; } 23 | 24 | .rows .container{ border-left: 1px solid #ddd } 25 | .rows #html-panel{ position: absolute; left: 0; top: 0; width: 50%; height: 33.33%;} 26 | .rows #css-panel{ position: absolute; left: 0; top: 33.33%; width: 50%; height: 33.33%;} 27 | .rows #js-panel{ position: absolute; left: 0; top: 66.66%; width: 50%; height: 33.33%;} 28 | .rows #output-panel{ position: absolute; left: 50%; top: 0; width: 50%; height: 50%;} 29 | .rows #console-panel{ position: absolute; left: 50%; top: 50%; width: 50%; height: 50%;} 30 | 31 | li.warning{ color: orange;} 32 | li.error{ color: red;} 33 | #sandbox{ display: none;} 34 | 35 | .CodeMirror { 36 | position: absolute; 37 | top: 25px; 38 | bottom: 0; 39 | left: 0; 40 | right: 0; 41 | height: auto; 42 | } -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |

Sketchtab

18 | New sketch 19 | 22 |
23 |
24 |
25 |
26 |

HTML

27 |
28 | 29 |
30 |
31 |
32 |

CSS

33 |
34 | 35 |
36 |
37 |
38 |

JavaScript

39 |
40 | 41 |
42 |
43 |
44 |

Output

45 | Reload 46 |
47 | 48 |
49 |
50 |
51 |

Console

52 | Clear 53 | 54 |
55 | 56 |
57 |
58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /script.js: -------------------------------------------------------------------------------- 1 | var htmlSrc = document.getElementById( 'html-src' ); 2 | var cssSrc = document.getElementById( 'css-src' ); 3 | var jsSrc = document.getElementById( 'js-src' ); 4 | 5 | htmlSrc.value = localStorage[ 'htmlSrc' ] || ''; 6 | cssSrc.value = localStorage[ 'cssSrc' ] || ''; 7 | jsSrc.value = localStorage[ 'jsSrc' ] || ''; 8 | 9 | // Set up Code Mirror editors 10 | var htmlCM = CodeMirror.fromTextArea(htmlSrc, { 11 | value: htmlSrc.value, 12 | mode: 'htmlmixed', 13 | lineNumbers: true 14 | }); 15 | var cssCM = CodeMirror.fromTextArea(cssSrc, { 16 | value: cssSrc.value, 17 | mode: 'css', 18 | lineNumbers: true 19 | }); 20 | var jsCM = CodeMirror.fromTextArea(jsSrc, { 21 | value: jsSrc.value, 22 | mode: 'javascript', 23 | lineNumbers: true 24 | }); 25 | 26 | var htmlOutput = document.getElementById( 'html-output' ); 27 | var consoleOutput = document.getElementById( 'console-output' ); 28 | 29 | // Not needed now the function runs on change of the CodeMirror Editor 30 | // 31 | // [ htmlSrc, cssSrc, jsSrc ].forEach( function( src ) { 32 | 33 | // src.addEventListener( 'keyup', onUpdate ); 34 | 35 | // src.addEventListener( 'keydown', function(e){ 36 | // if(e.keyCode==9 || e.which==9){ 37 | // e.preventDefault(); 38 | // var s = this.selectionStart; 39 | // this.value = this.value.substring(0,this.selectionStart) + " " + this.value.substring(this.selectionEnd); 40 | // this.selectionEnd = s + 2; 41 | // } 42 | // } ); 43 | 44 | // src.setAttribute( 'spellcheck', false ); 45 | 46 | // } ); 47 | 48 | cssCM.on('change', onUpdate); 49 | htmlCM.on('change', onUpdate); 50 | jsCM.on('change', onUpdate); 51 | 52 | autoClearConsole = document.getElementById( 'autoClearConsole' ); 53 | autoClearConsole.checked = localStorage[ 'autoClearConsole' ] === 'true'; 54 | 55 | var updateTimeout = null; 56 | 57 | function onUpdate() { 58 | 59 | // Save Code Mirror editor to textarea 60 | cssCM.save(); 61 | htmlCM.save(); 62 | jsCM.save(); 63 | 64 | localStorage[ 'htmlSrc' ] = htmlSrc.value; 65 | localStorage[ 'cssSrc' ] = cssSrc.value; 66 | localStorage[ 'jsSrc' ] = jsSrc.value; 67 | 68 | if( updateTimeout ) clearTimeout( updateTimeout ); 69 | 70 | updateTimeout = setTimeout( updateSources, 500 ); 71 | 72 | } 73 | 74 | var sandbox = null; 75 | 76 | function updateSources() { 77 | 78 | localStorage[ 'executed' ] = false; 79 | 80 | if( autoClearConsole.checked ) { 81 | clearConsole(); 82 | } 83 | 84 | if( sandbox ) { 85 | var evalData = { 86 | message: 'eval', 87 | source: jsSrc.value 88 | } 89 | sandbox.postMessage( JSON.stringify( evalData ), '*' ); 90 | } 91 | 92 | var res = htmlSrc.value; 93 | res += '