tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

011.xhtml (1374B)


      1 <?xml version="1.0" encoding="utf-8"?>
      2 <html xmlns="http://www.w3.org/1999/xhtml">
      3 <head>
      4 <title>Canvas drag and drop and history navigation roundtrip</title>
      5 <style type="text/css">
      6 img
      7  {margin:0 2px;}
      8 </style>
      9 <script type="application/ecmascript">
     10 function addImage(event)
     11  {var c = document.createElement('img');
     12  c.setAttribute('src',event.dataTransfer.getData('text/uri-list').replace(/\r\n$/,''));
     13  document.querySelector('p').appendChild(c);}
     14 function start(event)
     15  {event.dataTransfer.effectAllowed = 'copy';
     16  event.dataTransfer.setData('text/uri-list', document.querySelector('canvas').toDataURL('image/png'));
     17  window.location = '011-1.xhtml'}
     18 </script>
     19 </head>
     20 <body>
     21 <p>
     22  <canvas width="100" height="100" draggable="true" ondragstart="start(event)" ondragenter="event.preventDefault()" ondragover="return false" ondrop="addImage(event)">Canvas</canvas>
     23 </p>
     24 <p>Drag canvas around. You will be redirected to new page. When you return back drop canvas on itself. It should be duplicated once you drop it.</p>
     25 <script type="application/ecmascript">
     26 var canvas = document.querySelector('canvas'),
     27 c = canvas.getContext('2d');
     28 for(var x = 0; x != 50; x++)
     29  {c.fillStyle = (x%2 == 0)?'navy':'white';
     30  c.beginPath();
     31  c.moveTo(x,x);
     32  c.lineTo(100-x,x);
     33  c.lineTo(100-x,100-x);
     34  c.lineTo(x,100-x);
     35  c.closePath();
     36  c.fill();}
     37 </script>
     38 </body>
     39 </html>