Author: tchemit Date: 2008-05-18 11:35:01 +0000 (Sun, 18 May 2008) New Revision: 43 Modified: trunk/lutinrss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js Log: utilisation variables de configuration 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-18 08:37:45 UTC (rev 42) +++ trunk/lutinrss/src/main/resources/fckeditor/editor/plugins/rssinclude/fck_rssinclude.js 2008-05-18 11:35:01 UTC (rev 43) @@ -1,35 +1,32 @@ -var dialog = window.parent ; -var oEditor = dialog.InnerDialogLoaded() ; -var FCK = oEditor.FCK ; -var FCKLang = oEditor.FCKLang ; -var FCKConfig = oEditor.FCKConfig ; -var FCKTools = oEditor.FCKTools ; +var dialog = window.parent; +var oEditor = dialog.InnerDialogLoaded(); +var FCK = oEditor.FCK; +var FCKLang = oEditor.FCKLang; +var FCKConfig = oEditor.FCKConfig; +var FCKTools = oEditor.FCKTools; -// L'url du service web permettant de recuperer les Feeds configures -var configSiteURL = '/srvwebsiteworkshop'; - // Set the language direction. -window.document.dir = oEditor.FCKLang.Dir ; +window.document.dir = oEditor.FCKLang.Dir; // Recuperation du feed selectionne -var oRss = dialog.Selection.GetSelectedElement() ; +var oRss = dialog.Selection.GetSelectedElement(); // Un peu de travail au chargement de la page window.onload = function() { - // Translate the dialog box texts. - oEditor.FCKLanguageManager.TranslatePage(document) ; + // Translate the dialog box texts. + oEditor.FCKLanguageManager.TranslatePage(document); - // chargement de la comba avec les feeds configures - LoadCombo(); + // chargement de la comba avec les feeds configures + LoadCombo(); - // Load the selected element information (if any). - LoadSelection() ; + // Load the selected element information (if any). + LoadSelection(); - // Activate the "OK" button. - window.parent.SetOkButton( true ) ; + // Activate the "OK" button. + window.parent.SetOkButton( true ); - SelectField( 'txtFeedName' ) ; + SelectField( 'txtFeedName' ); } /** @@ -37,45 +34,41 @@ * Cela n'est fait que si le serveur peut etre contacte */ function LoadCombo() { - var xhr = null; - if(window.XMLHttpRequest) // Firefox - xhr = new window.XMLHttpRequest(); - else if(window.ActiveXObject) // Internet Explorer - xhr = new window.ActiveXObject("Microsoft.XMLHTTP"); + var xhr = null; + if(window.XMLHttpRequest) // Firefox + xhr = new window.XMLHttpRequest(); + else if(window.ActiveXObject) // Internet Explorer + xhr = new window.ActiveXObject("Microsoft.XMLHTTP"); - if (xhr) { - var url = configSiteURL + "?action=doRss&rssAction=optionList&template=" + escape("<option id='%1' value='%1'>%2</option>"); - xhr.open("GET", url, false); - xhr.onreadystatechange = function() { - if(xhr.readyState == 4) { - if (xhr.status == 200) /* 200 : code HTTP pour OK */ - { - var div = document.getElementById("divFeedName"); - div.innerHTML = '<select style="WIDTH: 100%" id="txtFeedName" onblur="updatePreview();">' - + xhr.responseText - + '</input>'; - if (oRss) { - // on selectionne l'ancienne valeur - GetE('txtFeedName').value = GetAttribute( oRss, 'feedName', '' ); - } - } - } - } - xhr.send(null); - } + if (xhr) { + xhr.open("GET", FCKConfig.RssKnownFeedsURL, false); + xhr.onreadystatechange = function() { + if(xhr.readyState == 4 && xhr.status == 200) /* 200 : code HTTP pour OK */ + { + var content = '<select style="WIDTH: 100%" id="txtFeedName" onblur="updatePreview();">'+ + xhr.responseText + '</select>'; + document.getElementById("divFeedName").innerHTML = content; + if (oRss) { + // on selectionne l'ancienne valeur + GetE('txtFeedName').value = GetAttribute( oRss, 'feedName', '' ); + } + } + } + xhr.send(null); + } } /** * Chargement du feed que l'on re-edite */ function LoadSelection() { - if (! oRss) return; + if (! oRss) return; - GetE('txtFeedName').value = GetAttribute( oRss, 'feedName', '' ); - GetE('txtNbItem').value = GetAttribute( oRss, 'nbItem', '' ); - GetE('txtFeedRepr').value = GetAttribute( oRss, 'feedRepr', '' ); + GetE('txtFeedName').value = GetAttribute( oRss, 'feedName', '' ); + GetE('txtNbItem').value = GetAttribute( oRss, 'nbItem', '' ); + GetE('txtFeedRepr').value = GetAttribute( oRss, 'feedRepr', '' ); - updatePreview(); + updatePreview(); } /** @@ -83,40 +76,41 @@ */ function Ok() { - if ( GetE('txtFeedName').value.length == 0 ) - { - GetE('txtFeedName').focus() ; + if ( GetE('txtFeedName').value.length == 0 ) + { + GetE('txtFeedName').focus() ; - alert( oEditor.FCKLang.DlgRssincludeAlertFeedName ) ; - return false ; - } + alert( oEditor.FCKLang.DlgRssincludeAlertFeedName ) ; + return false ; + } - oEditor.FCKUndo.SaveUndoStep() ; - if ( !oRss ) - { - oRss = FCK.InsertElement( 'DIV' ) ; - oScript = FCK.InsertElement('SCRIPT'); - SetAttribute( oScript, 'src', 'http://rssinclude/lutinrss-1.0/rssinclude_1.js'); - } - updateRss( oRss ) ; + oEditor.FCKUndo.SaveUndoStep() ; + if ( !oRss ) + { + oRss = FCK.InsertElement( 'DIV' ) ; + oScript = FCK.InsertElement('SCRIPT'); + SetAttribute( oScript, 'src', FCKConfig.RssScriptURL); + } + updateRss( oRss ) ; - rssincludeUpdateDiv(oRss, false); - return true ; + rssincludeUpdateDiv(oRss, false); + return true ; } /** * Mise a jour d'un div avec les informations trouvees dans l'interface */ function updateRss(e){ - e.contentEditable = false ; + e.contentEditable = false ; - SetAttribute( e, 'class', 'rssinclude'); - SetAttribute( e, 'name', 'rssinclude'); - SetAttribute( e, 'feedName', GetE('txtFeedName').value ); - SetAttribute( e, 'nbItem', GetE('txtNbItem').value ); - SetAttribute( e, 'feedRepr', GetE('txtFeedRepr').value ); - e.innerHTML = 'RSS ' + GetE('txtFeedName').value; - e.style.backgroundColor = '#ffff00' ; + SetAttribute( e, 'class', 'rssinclude'); + SetAttribute( e, 'name', 'rssinclude'); + SetAttribute( e, 'feedName', GetE('txtFeedName').value ); + SetAttribute( e, 'nbItem', GetE('txtNbItem').value ); + SetAttribute( e, 'feedRepr', GetE('txtFeedRepr').value ); + SetAttribute( e, 'forceReload', 'true' ); + e.innerHTML = 'RSS ' + GetE('txtFeedName').value; + e.style.backgroundColor = '#ffff00' ; } // L'element servant a la preview @@ -127,18 +121,18 @@ */ function updatePreview(){ - if ( !ePreview ) { - ePreview = GetE('rssincludePreview') ; - } + if ( !ePreview ) { + ePreview = GetE('rssincludePreview') ; + } - if ( ! ePreview) { - return; - } + if ( ! ePreview) { + return; + } - if ( GetE('txtFeedName').value.length == 0 ) { - ePreview.innerHTML = 'Invalid RSS' ; - } else { - updateRss(ePreview); - rssincludeUpdateDiv(ePreview, true, true); - } + if ( GetE('txtFeedName').value.length == 0 ) { + ePreview.innerHTML = 'Invalid RSS' ; + } else { + updateRss(ePreview); + rssincludeUpdateDiv(ePreview, true); + } }