1 window.addEventListener('load', function(event){2 var me = document.getElementById('me'); 3 var med = me.contentDocument;4 var meh = med.head;5 var meb = med.body;6 7 var user_style = null;8 var has_changed = false;9 var edit_mode = null;10 11 var setEditMode = function(mode) {12 edit_mode = mode;13 if (mode) {14 editor.innerHTML = viewer.innerHTML;15 viewer.style.display = 'none';16 editor.style.display = '';17 } else {18 viewer.innerHTML = editor.innerHTML;19 viewer.style.display = '';20 editor.style.display = 'none';21 }22 };23 24 var setUserStyle = function(href) {25 if (null == user_style) {26 user_style = document.createElement('link');27 user_style.setAttribute('rel', 'stylesheet');28 user_style.setAttribute('type', 'text/css');29 meh.appendChild(user_style);30 }31 user_style.setAttribute('href', href);32 };33 34 var _getCurrentLayer = function() {35 if (edit_mode) {36 return editor;37 } else {38 return viewer;39 }40 };41 42 var getContent = function() {43 return _getCurrentLayer().innerHTML;44 };45 46 var setContent = function(content) {47 _getCurrentLayer().innerHTML = content;48 };49 50 var focus = function() {51 _getCurrentLayer().focus();52 };53 54 var hasChanged = function() {55 return has_changed;56 };57 58 var style = "display:block; position:absolute; top:0; left:0; bottom:0; right:0;";59 60 61 var viewer = document.createElement('div');62 viewer.setAttribute('style', style);63 viewer.classList.add('c12cdfb87c5e2907332a30083d385076');64 viewer.innerHTML = 'VISOR';65 meb.appendChild(viewer);66 67 var editor = document.createElement('div');68 editor.setAttribute('style', style);69 editor.classList.add('f84a6e47e2acda0ed3d0182f9258ecbe');70 editor.innerHTML = 'EDITOR';71 editor.setAttribute('contenteditable', true);72 editor.addEventListener('keyup', function(event){73 has_changed = true;74 }, true);75 meb.appendChild(editor);76 77 78 setEditMode(true);79 80 focus();81 82 83 //setUserStyle('/ShareCode/preview/f84a6e47e2acda0ed3d0182f9258ecbe/css');84 //setUserStyle('/ShareCode/preview/c12cdfb87c5e2907332a30083d385076/css');85 86 87 88 }, true);
Este ShareCode tiene versiones:
- Micro editor Reimplementation to Objects... (21/12/2012)
- Micro editor ... (24/04/2013)
- Micro editor ... (24/04/2013)
- Micro editor ... (24/04/2013)
- Micro editor ... (24/04/2013)
- Micro editor ... (24/04/2013)
Enlace
El enlace para compartir es: