Author: tchemit Date: 2008-05-19 18:26:13 +0000 (Mon, 19 May 2008) New Revision: 58 Modified: trunk/lutinrss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js Log: add only once the rssinclude script when adding rss Modified: trunk/lutinrss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js =================================================================== --- trunk/lutinrss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js 2008-05-19 07:08:25 UTC (rev 57) +++ trunk/lutinrss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js 2008-05-19 18:26:13 UTC (rev 58) @@ -20,7 +20,7 @@ // Translate the dialog box texts. oEditor.FCKLanguageManager.TranslatePage(document); - // chargement de la comba avec les feeds configures + // chargement de la combo avec les feeds configures LoadCombo(); // Load the selected element information (if any). @@ -94,10 +94,11 @@ if ( !oRss ) { oRss = FCK.InsertElement( 'DIV' ) ; - //TODO Il faut detecter si le script est deja present, - // car ajouter n script va provoquer n chargements... - oScript = FCK.InsertElement('SCRIPT'); - SetAttribute( oScript, 'src', FCKConfig.RssScriptURL); + if (!detectScript()) { + // add script to editor only once + oScript = FCK.InsertElement('SCRIPT'); + SetAttribute( oScript, 'src', FCKConfig.RssScriptURL); + } } updateRss( oRss ); @@ -106,6 +107,14 @@ } /** + * Detection de la presence ou non du script rssinclude dans l'edition + */ +function detectScript() { + var scripts = FCK.GetXHTML(); + return (scripts.indexOf("src=\""+FCKConfig.RssScriptURL+"\"")!=-1); +} + +/** * Mise a jour d'un div avec les informations trouvees dans l'interface */ function updateRss(e){