Commit d7d0c67a45614106c630b1548a37fc0ea2ccdbe0

add permalink to live microdata
  
2626</head>
2727<body>
2828
29<h1>Live Microdata</h1>
29<h1><a href=".">Live Microdata</a></h1>
30
31<span class="link"><a href="" id="permalink">permalink</a></span>
3032
3133<form class="examples">
3234Examples:
  
3232 margin: 0;
3333 padding: 0;
3434}
35h1 a {
36 text-decoration: none;
37 color: black;
38}
39a {
40 color: #008;
41}
42.link {
43 margin-left: 8px;
44}
45.link:before {
46 content: "<";
47}
48.link:after {
49 content: ">";
50}
3551.examples {
3652 display: block;
3753 margin: 0;
live/live.js
(19 / 5)
  
11/* -*- mode: js2; js2-basic-offset: 2; indent-tabs-mode: nil -*- */
22
3function update() {
3function update(html) {
44 // preview always needed to put the microdata into the document
5 $('#preview').html($('textarea').val());
5 $('#preview').html(html);
6 // update permalink
7 $('#permalink').attr('href', '?html='+encodeURIComponent(html));
68 // update selected tab
79 updateTab($('#tabs').tabs('option', 'selected'));
810}
7070$(document).ready(function() {
7171 var $textarea = $('textarea');
7272 $textarea.TextAreaResizer();
73 $textarea.change(update);
73 $textarea.change(function(){update($textarea.val());});
7474 $textarea.keyup(function(ev) {
7575 // ignore home/end/page up/page down and left/up/down/right
7676 if (ev.keyCode < 33 || ev.keyCode > 40)
77 update();
77 update($textarea.val());
7878 });
79 if (window.location.search) {
80 jQuery.each(window.location.search.substr(1).split('&'), function() {
81 var nameval = this.split('=', 2);
82 var name = decodeURIComponent(nameval[0]);
83 var val = nameval.length == 2 ? decodeURIComponent(nameval[1]) : '';
84 switch (name) {
85 case 'html':
86 $textarea.val(val);
87 update(val);
88 }
89 });
90 }
7991 $('select').change(function(ev) {
8092 var source = ev.target.value;
8193 if (source) {
8294 $.get('example/'+source, function(data) {
8395 $textarea.val(data);
84 update();
96 update(data);
8597 });
8698 }
8799 });