Aucune description

base64.html 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <!-- $Id: base64.html,v 1.1 2009/03/01 22:00:28 dankogai Exp dankogai $ -->
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6. <title>Test for base64.js</title>
  7. </head>
  8. <body>
  9. <h1>Test for base64.js</h1>
  10. <p>$Id: base64.html,v 1.1 2009/03/01 22:00:28 dankogai Exp dankogai $</p>
  11. <table width="640"><tbody>
  12. <tr><th width="50%">Text</th><th>Base64
  13. (URL Safe <input id="encodeURI" type="checkbox" onclick="doit()">)</th></tr>
  14. <tr>
  15. <th><textarea id="srctxt" cols="32" rows="4" onkeyup="doit()">
  16. </textarea></th>
  17. <th><textarea id="base64" cols=32" rows="4" onkeyup="
  18. $('srctxt').value = Base64.decode(this.value);
  19. doit();
  20. if (1 /*@cc_on -1 @*/) $('data').src = 'data:text/plain;base64,' + this.value;
  21. "></textarea></th>
  22. </tr>
  23. <tr><th width="50%">Roundtrip</th><th>iframe w/ data: (no IE)</th></tr>
  24. <tr>
  25. <th><textarea id="roundtrip" cols=32" rows="4" disabled></textarea></th>
  26. <th><iframe id="data" width="80%" height="64"></iframe></th>
  27. </tr>
  28. </tbody></table>
  29. <script src="./base64.js"></script>
  30. <script>
  31. $ = function(id){ return document.getElementById(id) };
  32. function doit(){
  33. var encoded = Base64[
  34. 'encode' + ($('encodeURI').checked ? 'URI' : '')
  35. ]($('srctxt').value);
  36. $('base64').value = encoded;
  37. if (1 /*@cc_on -1 @*/) {
  38. $('data').src = 'data:text/plain;base64,'
  39. + Base64.encode(Base64.decode(encoded));
  40. }
  41. $('roundtrip').value = Base64.decode(encoded);
  42. }
  43. </script>
  44. </body>
  45. </html>