Nogen der gider kontrollere denne kode for 200 pt.
Hej !Er der nogen der gider at kontrollere om alle " og ' i dette kode er sat rigtigt. Jeg får masser af fejl forskellige steder i koden... :-(
Jeg tror, det er noget med replace delen, der hvor jeg refererer $1 i funktionskaldene showform("$1")
Visse dele af nedenstående funktioner skrives desuden ud til browseren ???
Der er 200 points på højkant, da jeg er desparat
//-----------------------------------------------------------------------------------------------------------------------
// prepareelements_for_save(html)
// Called on save of HTML
//-----------------------------------------------------------------------------------------------------------------------
function prepareelements_for_save (html) {
// Replace comments in normal element tags
html = html.replace(/<!--([\s\S]*?)<\/\/([\s\S]*?)\/\/>([\s\S]*?)-->/gim, '<//$2//>');
// Replace comments in parameterized element tags
html = html.replace(/<!--([\s\S]*?)<\/\/\/([\s\S]*?):([\s\S]*?):([\s\S]*?)\/\/\/>([\s\S]*?)-->/gim, '<///$2:$3:$4///>');
// Replace comments for PHP tags
var opentag = '<' + '?';
var closetag = '?' + '>';
html = html.replace(/<!--([\s\S]*?)<\?([=]?)([\s\S]*?)\?>([\s\S]*?)-->/gim,opentag + '$2$3' + closetag);
// Replace comments for forms
html = html.replace(/<!--([\s\S]*?)<\/\/\/\/([\s\S]*?)\/\/\/\/>([\s\S]*?)-->/gim, '<////$2////>');
alert(html);
return html;
}
//===========================================================================================================================
//-----------------------------------------------------------------------------------------------------------------------
// makecomments_for_tags()
// Called when changing to source view like this
//
// html = removegraphictags(html);
// html = prepareelements_for_save(html);
// html = makecomments_for_tags(html);
//-----------------------------------------------------------------------------------------------------------------------
function makecomments_for_tags(html) {
// Make comments for normal element tags
html = html.replace(/<\/\/([\s\S]*?)\/\/>/gim, '<!--<//$1//>-->');
// Make comments for parameterized element tags
html = html.replace(/<\/\/\/([\s\S]*?):([\s\S]*?):([\s\S]*?)\/\/\/>/gim, '<!--<///$1:$2:$3///>-->');
// Make comments for PHP tags
var opentag = '<' + '?';
var closetag = '?' + '>';
html = html.replace(/<\?([=]?)([\s\S]*?)\?>/gim,'<!--' + opentag + $1 + $2 + closetag + '-->');
// Make comments for forms
html = html.replace(/([\s\S]*?)<\/\/\/\/([\s\S]*?)\/\/\/\/>/gim, '<!--<////$1////>-->');
alert(html);
return html;
}
//==========================================================================================================================
//-----------------------------------------------------------------------------------------------------------------------
// preparetags_for_preview(html)
//
// purpose: Called when changing to preview mode
// NB !!! Calls external parsefortags.php
//-----------------------------------------------------------------------------------------------------------------------
var temphtml;
function preparetags_for_preview(html) {
html = prepareelements_for_save(html);
//
// parsetagsforpreview.php
// must read its openers temphtml var
// and then set the opened window's returnValue to the HTML parsed by the serverside-parser
//
temphtml = html;
dataparsedforpreview = window.showModalDialog('/cmsextras/parsetagsforpreview.php','','height:400px; width:400px');
temphtml = null;
alert(dataparsedforpreview);
if (dataparsedforpreview)
return html;
else
return "";
}
//===========================================================================================================================
//-----------------------------------------------------------------------------------------------------------------------
// removegraphictags(html)
//
// Called when changing to sourceview like this:
//
// html = removegraphictags(html);
// html = prepareelements_for_save(html);
// html = makecomments_for_tags(html);
//-----------------------------------------------------------------------------------------------------------------------
function removegraphictags(html) {
//PHP tags
var opentag = "<" + "?";
var closetag = "?" + ">":
html = html.replace(/<span SYSTEMTAG=YES ([\s\S]*?)>([\s\S]*?)><!--([\s\S]*?)<\?([=]?)([\s\S]*?)\?>([\s\S]*?)--><\/span>/gim,'<!--' + opentag + '$4$5' + closetag + '-->');
// Normal element tags
html = html.replace(/<span SYSTEMTAG=YES ([\s\S]*?)>([\s\S]*?)><!--<\/\/([\s\S]*?)\/\/>([\s\S]*?)--><\/span>/gim, '<!--<//$3//>-->');
// Parameterized element tags
html = html.replace(/<span SYSTEMTAG=YES ([\s\S]*?)>([\s\S]*?)><!--<\/\/\/([\s\S]*?):([\s\S]*?):([\s\S]*?)\/\/\/>([\s\S]*?)--><\/span>/gim, '<!--$3$4$5-->');
// Forms
html = html.replace(/<span SYSTEMTAG=YES ([\s\S]*?)>([\s\S]*?)><!--<\/\/\/\/([\s\S]*?)\/\/\/\/>([\s\S]*?)--><\/span>/gim, '<!--$3-->');
// Script tags
html = html.replace(/<span SYSTEMTAG=YES ([\s\S]*?)>([\s\S]*?)><SCRIPT ([\s\S]*?)>([\s\S]*?)<\/SCRIPT><\/span>/gim, '<SCRIPT $3>$4</SCRIPT>');
// Webspider: Exclude Tags
html = html.replace(/<span SYSTEMTAG=YES ([\s\S]*?)>([\s\S]*?)><!-- WEBSPIDER_BEGIN_INDEX -->([\s\S]*?)><\/span>/gim, '<!-- WEBSPIDER_BEGIN_INDEX -->');
html = html.replace(/<span SYSTEMTAG=YES ([\s\S]*?)>([\s\S]*?)><!-- WEBSPIDER_END_INDEX -->([\s\S]*?)><\/span>/gim, '<!-- WEBSPIDER_END_INDEX -->');
alert(html);
return html;
}
//===========================================================================================================================
//-----------------------------------------------------------------------------------------------------------------------
// maketags_graphic(html)
//
// Called when changing to WYSIWYG view like this:
//
// html = makecomments_for_tags(html)
// html = maketags_graphic(html);
//-----------------------------------------------------------------------------------------------------------------------
function maketags_graphic(html) {
// Normal element tags
html = html.replace(/<!--([\s\S]*?)<\/\/([\s\S]*?)\/\/>([\s\S]*?)-->/gim, '<span SYSTEMTAG=YES contenteditable="false" ondblclick="parent.showelementinfo('$1')"><img alt="Elementet $1 - Dobbeltklik" SYSTEMTAG=YES src="/gfx/elementtag.gif"> <!--<//$1//>--></span>');
// Parameterized element tags
html = html.replace(/<!--([\s\S]*?)<\/\/\/([\s\S]*?):([\s\S]*?):([\s\S]*?)\/\/\/>([\s\S]*?)-->/gim, '<span SYSTEMTAG=YES contenteditable="false" onclick="parent.showelementwithparams('$2','$3','$4')" ondblclick="parent.editelementparams('$2','$3','$4')"><img alt="Elementet $2 - Parameter: $3 - Værdi: $4 - Dobbeltklik for editere parameter/type - Enkeltklik for se output fra elementet" SYSTEMTAG=YES src="/gfx/elementtag.gif"> <!--<///$2:$3:$4///>--></span>');
// PHP tags
var opentag = '<' + '?';
var closetag = '?' + '>';
html = html.replace(/<!--([\s\S]*?)<\?([=]?)([\s\S]*?)\?>([\s\S]*?)-->/gim,'<span SYSTEMTAG=YES contenteditable="false"><img alt="PHP Taget indeholder: $2$3" SYSTEMTAG=YES src="/gfx/phptag.gif"> <!--' + opentag + '$2$3' + closetag + '--></span>');
// Forms
html = html.replace(/<!--([\s\S]*?)<\/\/\/\/([\s\S]*?)\/\/\/\/>([\s\S]*?)-->/gim, '<span SYSTEMTAG=YES contenteditable="false" ondblclick="parent.showforminfo('$2')"><img alt="FormularID: $2 - Dobbeltklik" SYSTEMTAG=YES src="/gfx/formtag.gif"> <!--<////$2////--></span>');
// Script tags
html = html.replace(/<SCRIPT ([\s\S]*?)>([\s\S]*?)<\/SCRIPT>/gim '<span SYSTEMTAG=YES contenteditable="false"><img alt="Clientside Script kode" SYSTEMTAG=YES src="/gfx/script.gif"><SCRIPT $1>$2<\/SCRIPT></span>');
// Webspider Tags
html = html.replace(/<!--([\s\S]*?)WEBSPIDER_BEGIN_INDEX([\s\S]*?)-->/gim '<span SYSTEMTAG=YES contenteditable="false"><img alt="WebSpider: Ekskluder fra Index - Begynd" SYSTEMTAG=YES src="/gfx/webspiderstart.gif"><!-- WEBSPIDER BEGIN_INDEX --></span>');
html = html.replace(/<!--([\s\S]*?)WEBSPIDER_END_INDEX([\s\S]*?)-->/gim '<span SYSTEMTAG=YES contenteditable="false"><img alt="WebSpider: Ekskluder fra Index - Slut" SYSTEMTAG=YES src="/gfx/webspiderend.gif"><!-- WEBSPIDER BEGIN_INDEX --></span>');
alert(html);
return html;
}
//===========================================================================================================================