SOURCE CODE: SimpleDoc Tester

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
  <title>SimpleDoc Tester | JavaScript Tools | UIZE JavaScript Framework</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="keywords" content="tool Uize.Doc.Simple"/>
  <meta name="description" content="Experiment with SimpleDoc - a Wikitext like document format. See its formatting rules in action. See how it is generated to HTML and preview the HTML."/>
  <link rel="alternate" type="application/rss+xml" title="UIZE JavaScript Framework - Latest News" href=""/>
  <link rel="stylesheet" href="../css/page.css"/>
  <link rel="stylesheet" href="../css/page.example.css"/>
  <link rel="stylesheet" href="../css/widget.tabs.css"/>
  <link rel="stylesheet" href="css/tabbed.css"/>


<script type="text/javascript" src="../js/Uize.js"></script>

<h1 class="header">
  <a id="page-homeLink" href="../index.html" title="UIZE JavaScript Framework home"></a>
  <a href="../index.html" class="homeLinkText" title="UIZE JavaScript Framework home">UIZE JavaScript Framework</a>

<div class="main">
  <h1 class="document-title">
    <a href="../javascript-examples.html" class="breadcrumb breadcrumbWithArrow">JAVASCRIPT EXAMPLES</a>
    SimpleDoc Tester
    <div class="pageActionsShell">
      <div id="page-actions" class="pageActions"><a href="source-code/simple-doc-tester.html" class="buttonLink">SOURCE</a></div>

  <!-- explanation copy -->

  <div class="explanation">
    <p>The <b>SimpleDoc Tester</b> tool (which makes use of the <a href="../reference/Uize.Doc.Simple.html"><code>Uize.Doc.Simple</code></a> module) lets you test the conversion of SIMPLE document (.simple) files into HTML documents. It provides a demonstration of the SimpleDoc formatting rules and lets you edit and preview changes to a sample SIMPLE document.</p>

  <div id="page_tabs" class="tabShell">
    <div class="tabStubShell">
      <a id="page_tabs_option0" class="tabStub" href="javascript://">SIMPLE DOC SOURCE</a>
      <a id="page_tabs_option1" class="tabStub" href="javascript://">CONVERTED TO HTML</a>
      <a id="page_tabs_option2" class="tabStub" href="javascript://">HTML PREVIEW</a>
      <br style="clear:left;"/>
    <div class="tabBodyShell">
      <div id="page_tabs-option0TabBody" class="tabBodyInactive">
        <textarea id="page-simpleDocSource" wrap="off"></textarea>
      <div id="page_tabs-option1TabBody" class="tabBodyInactive">
        <textarea id="page-convertedToHtml" wrap="off" readonly="readonly"></textarea>
      <div id="page_tabs-option2TabBody" class="tabBodyInactive">
        <iframe id="page-htmlPreview" src="../js/Uize/blank.html" style="width:100%; height:100%; border:none;" frameborder="0"></iframe>

<script type="text/javascript">

Uize.require (
  function () {
    'use strict';

    /* TO DO:
      - in FF, fix links within generated HTML document in IFRAME (lack of base tag?)
      - in IE, fix problem of JS not loading correctly (lack of base tag?)
    /*** create a page widget subclass ***/
      var CustomPageWidget = UizeSite.Page.Example.subclass ();

      /*** add property for managing update of converted HTML and preview ***/
        CustomPageWidget.stateProperties ({
            onChange:function () {
              var _html = Uize.Templates.SimpleDoc.process ({
                body:Uize.Doc.Simple.toDocument (page.get ('simpleDocSource'))
              page.setNodeValue ('convertedToHtml',_html);

              /*** write the generated HTML to the preview iframe ***/
                  _previewIframe = page.getNode ('htmlPreview'),
                  _previewDocument = _previewIframe.contentDocument || _previewIframe.contentWindow.document
                _previewDocument.writeln (_html);
                _previewDocument.close ();

    /*** create the example page widget ***/
      var page = = CustomPageWidget ();

    /*** add the tabs child widget ***/
      var tabs = window.tabs = page.addChild (
      tabs.wire (
        function () {
          var tabsValue = tabs + '';
          if (tabsValue == 'convertedToHtml' || tabsValue == 'htmlPreview')
            page.set ({simpleDocSource:page.getNodeValue ('simpleDocSource')})

    /*** wire up the page widget ***/
      page.wireUi ();

    /*** initialize sample data ***/
      page.setNodeValue ('simpleDocSource',UizeSite.Templates.SimpleDocSample.process ());