realtime style editor with lorum ipsum
parent
967d636df9
commit
c5ab5dfe26
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<script data-main="main" src="/bower_components/requirejs/require.js"></script>
|
||||
<style>
|
||||
html, body{
|
||||
/*
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;*/
|
||||
}
|
||||
textarea{ display: none;
|
||||
}
|
||||
</style>
|
||||
<style></style>
|
||||
</head>
|
||||
<body>
|
||||
<a id="edit" href="#" target="_blank">Edit this document's style</a>
|
||||
<textarea id="css"></textarea>
|
||||
<h1>HTML Ipsum Presents</h1>
|
||||
|
||||
<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>
|
||||
|
||||
<h2>Header Level 2</h2>
|
||||
|
||||
<ol>
|
||||
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
|
||||
<li>Aliquam tincidunt mauris eu risus.</li>
|
||||
</ol>
|
||||
|
||||
<blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote>
|
||||
|
||||
<h3>Header Level 3</h3>
|
||||
|
||||
<ul>
|
||||
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
|
||||
<li>Aliquam tincidunt mauris eu risus.</li>
|
||||
</ul>
|
||||
|
||||
<pre><code>
|
||||
#header h1 a {
|
||||
display: block;
|
||||
width: 300px;
|
||||
height: 80px;
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>th 1</th>
|
||||
<th>th 2</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>one</td>
|
||||
<td>two</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>three</td>
|
||||
<td>four</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -0,0 +1,61 @@
|
||||
define([
|
||||
'/api/config?cb=' + Math.random().toString(16).substring(2),
|
||||
'/common/realtime-input.js',
|
||||
'/common/messages.js',
|
||||
'/common/crypto.js',
|
||||
'/bower_components/jquery/dist/jquery.min.js',
|
||||
'/customize/pad.js'
|
||||
], function (Config, Realtime, Messages, Crypto) {
|
||||
var $ = jQuery;
|
||||
$(window).on('hashchange', function() {
|
||||
window.location.reload();
|
||||
});
|
||||
|
||||
var userName = Crypto.rand64(8);
|
||||
|
||||
if (window.location.href.indexOf('#') === -1) {
|
||||
window.location.href = window.location.href + '#' + Crypto.genKey();
|
||||
return;
|
||||
}
|
||||
|
||||
var key = Crypto.parseKey(window.location.hash.slice(1));
|
||||
|
||||
var $style = $('style').eq(1),
|
||||
$css = $('#css'),
|
||||
$edit = $('#edit');
|
||||
|
||||
$edit.attr('href', '/text/'+ window.location.hash);
|
||||
|
||||
var lazyDraw = (function () {
|
||||
var to,
|
||||
delay = 500;
|
||||
return function (content) {
|
||||
to && clearTimeout(to);
|
||||
to = setTimeout(function () {
|
||||
$style.text(content);
|
||||
},delay);
|
||||
};
|
||||
}());
|
||||
|
||||
var draw = function () {
|
||||
lazyDraw($css.val());
|
||||
};
|
||||
|
||||
$css // set the initial value
|
||||
.val($style.text())
|
||||
.on('change', draw);
|
||||
|
||||
var rts = $('textarea').toArray().map(function (e, i) {
|
||||
var rt = Realtime.start(e, // window
|
||||
Config.websocketURL, // websocketUrl
|
||||
userName, // userName
|
||||
key.channel, // channel
|
||||
key.cryptKey, // cryptKey
|
||||
{
|
||||
onRemote: draw,
|
||||
onInit: draw,
|
||||
onReady: draw
|
||||
});
|
||||
return rt;
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue