function b64encode(str) { return btoa(unescape(encodeURIComponent(str))); } function submitNewLetter(form) { var name = document.getElementById('filename_display').value; if (!/^[A-Za-z0-9_-]+$/.test(name)) { alert('File name may only contain letters, numbers, underscores and hyphens.'); return false; } form.filename.value = name; return true; } var mainpage; var control; var result; var mousedownx; var mousedowny; var dragHint = "move"; var data; var showGrid = false; var snapToGrid = false; var gridSize = 10; var selected; var firstSelected; var itemparameters; var grid; var context; var draggingHTML; var window_dragging = false; const undo = []; var undoIndex = 0; var lastRedo; var mode = 'MOUSEUP'; var textobj; var lastdragover; var pendingDragover; var dropIndicator; var sequence = 0; function showDropIndicator(target) { if(!dropIndicator) { dropIndicator = document.createElement('div'); dropIndicator.style.position = 'fixed'; dropIndicator.style.height = '4px'; dropIndicator.style.background = '#0088ff'; dropIndicator.style.zIndex = '99999'; dropIndicator.style.pointerEvents = 'none'; document.body.appendChild(dropIndicator); } let rect = target.getBoundingClientRect(); dropIndicator.style.left = rect.left + 'px'; dropIndicator.style.width = rect.width + 'px'; dropIndicator.style.top = (rect.top - 2) + 'px'; dropIndicator.style.display = 'block'; } function hideDropIndicator() { if(dropIndicator) { dropIndicator.style.display = 'none'; } } function saveUndo() { undo[undoIndex++] = mainpage.innerHTML; } function do_undo() { if(undoIndex > 0) { mainpage.innerHTML = undo[--undoIndex]; } return true; } function do_redo() { return true; } function init() { mainpage = document.getElementById("mainpage"); data = document.getElementById("data"); itemparameters = document.getElementById("itemparameters"); var gridsize = document.getElementById("gridsize"); gridsize.value = gridSize; grid = document.getElementById("grid"); context = grid.getContext("2d"); drawGrid(); buildToolbar(); document.designMode = 'off'; } function getLayerMap(element) { var map = ''; if(element.id != 'mainpage') { var curelem = element; while(curelem.id != 'mainpage') { map = '<' + curelem.nodeName + '>' + map; curelem = curelem.parentNode; } } document.getElementById('map').innerHTML = map; } function jetEscape(text) { return text.replace(/&/g, '&').replace(//g, '>'); } function buildToolbar() { let tbitems = [ { "label": "<div>", "html": "
" }, { "label": "<input>", "html": "" }, { "label": "<button>", "html": "" }, { "label": "<password>", "html": "" }, { "label": "<checkbox>", "html": "" }, { "label": "<label>", "html": "" }, { "label": "<p>", "html": "

Type Here

" }, { "label": "<hr>", "html": "
" }, { "label": "Jet: " + "$" + "[var]", "html": "" + jetEscape("$" + "[varname]") + "" }, { "label": "Jet: <set>", "html": "" + jetEscape("") + "" }, { "label": "Jet: <if>", "html": "" + jetEscape("\ncontent\n") + "" } ]; tbitems.forEach(doit); function doit(currentValue, index) { let index2 = index + 1; let toolbar = document.getElementById('toolbar'); var itemHTML = '