<script>
var _sXhtml = "";
var ParserXhtml = {
  
  Version: '1.0',
    getAllXHTML: function(id) {
   //id : objet html pour insérer le code xhtml
	//maxime modif test
	var objHTML = $("edit_code_source").value;
	alert(objHTML);
	_sXhtml = "<body>";
	this.getXHTML(kupu.getHTMLBody(kupu._serializeOutputToString(kupu.getInnerDocument().documentElement)),_sXhtml);
	_sXhtml += "</body>";
	alert('affichage important _sXhtml : ' + _sXhtml);
	/*
	try {
	    document.getElementById(id).innerHTML=_sXhtml;
	    } catch(e) {
	    document.getElementById(id).value=_sXhtml;
	}*/
	
  },
 
  
  //renomme les noeuds
  getXHTML: function(objHTML,str) {
  /*
  alert('affichage variable str : ' + str);
  alert('affichage variable _sHtml : ' + _sXhtml);
  alert('affichage : ' + objHTML);
  alert('affichage lenght :' + objHTML.childNodes.length);
  */
      var uChilds = objHTML.childNodes;
        for(var i=0; i<uChilds.length; i++) {
            var uChild = uChilds[i];
            switch (uChild.nodeType) {
                case 1://element
					alert('affichage variable str2 : ' + str);
                    str += "<" + uChild.nodeName.toLowerCase() + this.setAttributes(uChild) + ">";
                    this.getXHTML(uChild,str);
                    alert('affichage variable str3 : ' + str);
                    str += "</" + uChild.nodeName.toLowerCase() + ">";
                    break;
                    
                case 3://text
                    str += uChild.nodeValue;
                    break;
            }
        }
  },
  
  //renomme les attributs
  setAttributes: function (objHTML) {
    if (objHTML==null || objHTML==undefined) return "";
    
    var uAttribs = objHTML.attributes;
    var sAttrib = "";
    for(var i=0; i<uAttribs.length; i++) {
        var uAttrib = uAttribs[i];
        if (uAttrib.specified) sAttrib += " " + uAttrib.nodeName.toLowerCase() + '="' + uAttrib.nodeValue + '"';
    }
    return sAttrib;
  }
  
}
function testComm() {
	/*alert('test');
	var contenuHtml = kupu.getHTMLBody(kupu._serializeOutputToString(kupu.getInnerDocument().documentElement));
	alert('affichage de l'objet html = ', contenuHtml); */
	ParserXhtml.getAllXHTML("edit_code_source");
	
}
// récupérer le contenu de l'eframe
	function edit_xhtml_code() {
		$("div_edit_code_source").style.display = "block";
		$("edit_code_source").value = kupu.getHTMLBody(kupu._serializeOutputToString(kupu.getInnerDocument().documentElement));
		alert($("edit_code_source").value);
		//$("edit_code_source").value = kupu._serializeOutputToString(kupu.getInnerDocument().documentElement);
		}
</script
<!--putain de text area pour afficher le code source-->
	<div id="div_edit_code_source" style="display:none;background-color:#fff;position:absolute;margin-left:5px;margin-top:30px;">
		Edition du code source<br />
		<textarea name="edit_code_source" id="edit_code_source" rows="25" cols="100"></textarea><a href="javascript
:testComm()">Essai 2 edit XHTML</a>
	</div>
<span class="kupu-tb-buttongroup">
            <button type="button" class="kupu-sourcexhtml" id="kupu-sourcexhtml-button" title="edit xhtml code" i18n:attributes="title" accesskey="s" onclick="edit_xhtml_code();"> </button>
          </span>
<!-- IFrame de l'éditeur -->
      <div class="kupu-editorframe">
        <form>
          <iframe id="kupu-editor" class="kupu-editor-iframe" frameborder="0" src="fulldoc.html" scrolling="auto"></iframe>
          <textarea class="kupu-editor-textarea" id="kupu-editor-textarea"></textarea>
        </form>
      </div>
      <!-- Fin IFrame de l'éditeur -->
			
		
 
	
Partager