-\r
/* ***** BEGIN LICENSE BLOCK *****\r
* Copyright (c) 2008-2009 EADS DEFENCE AND SECURITY - All rights reserved.\r
* ximfmail is under the triple license MPL 1.1/GPL 2.0/LGPL 2.1.\r
- * \r
*\r
- * Redistribution and use, in source and binary forms, with or without modification, \r
+ *\r
+ * Redistribution and use, in source and binary forms, with or without modification,\r
* are permitted provided that the following conditons are met :\r
*\r
- * 1. Redistributions of source code must retain the above copyright notice, \r
- * 2. MPL 1.1/GPL 2.0/LGPL 2.1. license agreements must be attached \r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * 2. MPL 1.1/GPL 2.0/LGPL 2.1. license agreements must be attached\r
* in the redistribution of the source code.\r
- * 3. Neither the names of the copyright holders nor the names of any contributors \r
- * may be used to endorse or promote products derived from this software without specific \r
+ * 3. Neither the names of the copyright holders nor the names of any contributors\r
+ * may be used to endorse or promote products derived from this software without specific\r
* prior written permission from EADS Defence and Security.\r
- * \r
+ *\r
* Alternatively, the contents of this file may be used under the terms of\r
* either of the GNU General Public License Version 2 or later (the "GPL"),\r
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),\r
* and other provisions required by the GPL or the LGPL. If you do not delete\r
* the provisions above, a recipient may use your version of this file under\r
* the terms of any one of the MPL, the GPL or the LGPL.\r
- * \r
+ *\r
* REMINDER :\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND \r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \r
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \r
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \r
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \r
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING \r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\r
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\r
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- * \r
- * EADS Defence and Security - 1 Boulevard Jean Moulin - \r
- * ZAC de la Clef Saint Pierre - 78990 Elancourt - FRANCE (IDDN.FR.001.480012.002.S.P.2008.000.10000) \r
+ *\r
+ * EADS Defence and Security - 1 Boulevard Jean Moulin -\r
+ * ZAC de la Clef Saint Pierre - 78990 Elancourt - FRANCE (IDDN.FR.001.480012.002.S.P.2008.000.10000)\r
* ***** END LICENSE BLOCK ***** */\r
var gJSLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].createInstance(Components.interfaces.mozIJSSubScriptLoader);\r
var gConsole = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);\r
gJSLoader.loadSubScript("chrome://ximfmail/content/jquery.js");\r
gJSLoader.loadSubScript("chrome://ximfmail/content/ximfmail.js");\r
-\r
var gBoxOpener = null;\r
var gXimfMaxItems = null;\r
var gXimfMinItems = null;\r
var gXimfSeparator = null;\r
var gCurrentText = null;\r
-var gEditorElt = null; //textbox elment\r
+var gEditorElt = null;\r
var gTitleDlg = null;\r
var gDlgEditorXimf_maxItem_alert = "";\r
-\r
/*\r
window.arguments = [];\r
- args[0] id of textbox \r
+ args[0] id of textbox\r
args[1] text\r
- args[2] separator value \r
+ args[2] separator value\r
args[3] max items to write\r
args[4] min items to write\r
*/\r
-$(document).ready(function(){ \r
+$(document).ready(function(){\r
var gArgs = window.arguments;\r
- if(gArgs[0].length < 5){ \r
- ximfAlert("error nbargs = "+gArgs[0].length)\r
- return;} \r
- \r
+ if(gArgs[0].length < 5){\r
+ ximfAlert("error nbargs = "+gArgs[0].length);\r
+ return;\r
+ }\r
// load background datas\r
gBoxOpener = gArgs[0][0];\r
gCurrentText = gArgs[0][1];\r
gXimfSeparator = gArgs[0][2];\r
gXimfMaxItems = gArgs[0][3];\r
- gXimfMinItems = gArgs[0][4]; \r
+ gXimfMinItems = gArgs[0][4];\r
gTitleDlg = gArgs[0][5];\r
- //\r
- gEditorElt = document.getElementById("textbox-editor"); \r
- gConsole.logStringMessage("[ximfmail - dialogEditor ] \n id of textbox :" + gArgs[0][0] + "\n separator value: " + gArgs[0][2] + "\n max items to write: "+ gArgs[0][3] + "\n min items to write: " +gArgs[0][4]); \r
- \r
+ gEditorElt = document.getElementById("textbox-editor");\r
+ gConsole.logStringMessage("[ximfmail - dialogEditor ] \n id of textbox :" + gArgs[0][0] + "\n separator value: " + gArgs[0][2] + "\n max items to write: "+ gArgs[0][3] + "\n min items to write: " +gArgs[0][4]);\r
if(parseInt(gXimfMaxItems, 10) > 1){\r
- gDlgEditorXimf_maxItem_alert = gXimfMaxItems + " "+ getIlkProperties("ximfmail.dialog.editor.warning.nbrows"); \r
+ gDlgEditorXimf_maxItem_alert = gXimfMaxItems + " "+ getIlkProperties("ximfmail.dialog.editor.warning.nbrows");\r
$("#textbox-editor").attr("style","width:400px;height:100px");\r
- }else{ \r
+ }else{\r
gDlgEditorXimf_maxItem_alert = gXimfMaxItems + "1 "+ getIlkProperties("ximfmail.dialog.editor.warning.nbrows.one");\r
$("#textbox-editor").attr("maxrows","1");\r
}\r
RefreshEditor();\r
- \r
// event observer\r
- $("#textbox-editor").keypress(onCheck); \r
-}); \r
-\r
+ $("#textbox-editor").keypress(onCheck);\r
+});\r
/*\r
- * \r
+ *\r
*/\r
function doOK()\r
{\r
- if(!gEditorElt) return false;\r
- if(gXimfMinItems){\r
+ if (!gEditorElt) {\r
+ return false;\r
+ }\r
+ if(gXimfMinItems){\r
if( getWritedRowsCount() < parseInt(gXimfMinItems, 10)){\r
ximfAlert("not enough item");\r
}\r
}\r
- \r
var newvalue = "";\r
- if(!gXimfSeparator){ \r
- newvalue = gEditorElt.value; \r
- }else{ \r
+ if(!gXimfSeparator){\r
+ newvalue = gEditorElt.value;\r
+ }else{\r
var reg=new RegExp("\n", "g");\r
- //newvalue = gEditorElt.value.replace(reg , gXimfSeparator);\r
- var arrayValue = gEditorElt.value.split(reg); \r
+ var arrayValue = gEditorElt.value.split(reg);\r
var nbElements = arrayValue.length;\r
if(parseInt(gXimfMaxItems, 10)<arrayValue.length){\r
nbElements = parseInt(gXimfMaxItems, 10);\r
ximfAlert(gDlgEditorXimf_maxItem_alert);\r
- } \r
+ }\r
for(var i=0 ; i<nbElements ; ++i){\r
- if(arrayValue[i]!=""){\r
- if(i==0)\r
+ if(arrayValue[i] !== ""){\r
+ if (i === 0) {\r
newvalue = arrayValue[i];\r
- else\r
- newvalue += gXimfSeparator + arrayValue[i]; \r
- } \r
+ } else {\r
+ newvalue += gXimfSeparator + arrayValue[i];\r
+ }\r
+ }\r
}\r
}\r
- \r
- \r
- //remove last separator \r
- if(newvalue.lastIndexOf(gXimfSeparator)+1 == newvalue.length){\r
+ //remove last separator\r
+ if(newvalue.lastIndexOf(gXimfSeparator)+1 === newvalue.length){\r
newvalue = newvalue.substring(0,newvalue.lastIndexOf(gXimfSeparator));\r
- } \r
- \r
+ }\r
window.opener.document.getElementById(gBoxOpener).value = newvalue;\r
- window.opener.document.getElementById(gBoxOpener).setAttribute("ximfvalue", newvalue); \r
+ window.opener.document.getElementById(gBoxOpener).setAttribute("ximfvalue", newvalue);\r
window.opener.document.getElementById(gBoxOpener).setAttribute("tooltiptext", newvalue);\r
return true;\r
}\r
-\r
-\r
function doCancel()\r
{\r
return true;\r
}\r
-\r
-\r
/*\r
- * \r
+ *\r
*/\r
function onCheck(aEvent){\r
- if(!gEditorElt) return false;\r
- var key = aEvent.which; \r
+ if (!gEditorElt) {\r
+ return false;\r
+ }\r
+ var key = aEvent.which;\r
switch(key){\r
- case 13: // key=="\n" \r
- if( getWritedRowsCount() >= parseInt(gXimfMaxItems, 10)){\r
- ximfAlert(gDlgEditorXimf_maxItem_alert); \r
+ case 13: // key==="\n"\r
+ if ( getWritedRowsCount() >= parseInt(gXimfMaxItems, 10)) {\r
+ ximfAlert(gDlgEditorXimf_maxItem_alert);\r
var reg = new RegExp("\n", "g");\r
var artxt = gEditorElt.value.split(reg);\r
var newText = "";\r
for(var i=0 ; i < gXimfMaxItems; ++i){\r
if(i < artxt.length){\r
- if(gXimfMaxItems-1 == i){\r
+ if(gXimfMaxItems-1 === i){\r
newText += artxt[i];\r
}else{\r
newText += artxt[i] + "\n";\r
}\r
}\r
}\r
- gEditorElt.value = newText; \r
+ gEditorElt.value = newText;\r
}\r
case 8: // backspace\r
case 0: // delete\r
break;\r
default:\r
if( getWritedRowsCount() > parseInt(gXimfMaxItems, 10)){\r
- ximfAlert(gDlgEditorXimf_maxItem_alert); \r
+ ximfAlert(gDlgEditorXimf_maxItem_alert);\r
return false;\r
}\r
}\r
- /*\r
- // check for entries items\r
- if(key == 13){ // key=="\n" \r
- if( getWritedRowsCount() >= parseInt(gXimfMaxItems, 10)){\r
- alert(gDlgEditorXimf_maxItem_alert); \r
- var reg = new RegExp("\n", "g");\r
- var artxt = gEditorElt.value.split(reg);\r
- var newText = "";\r
- for(var i=0 ; i < gXimfMaxItems; ++i){\r
- if(i < artxt.length){\r
- if(gXimfMaxItems-1 == i){\r
- newText += artxt[i];\r
- }else{\r
- newText += artxt[i] + "\n";\r
- }\r
- }\r
- }\r
- gEditorElt.value = newText; \r
- }\r
- }\r
- else{\r
- if( getWritedRowsCount() > parseInt(gXimfMaxItems, 10)){\r
- alert(gDlgEditorXimf_maxItem_alert); \r
- return false;\r
- }\r
- }*/\r
return true;\r
}\r
-\r
function getWritedRowsCount(){\r
var nblines = 0;\r
var reg=new RegExp("\n", "g");\r
var nbvalue = gEditorElt.value.split(reg);\r
return nbvalue.length;\r
}\r
-/*\r
- * \r
- */\r
function RefreshEditor(){\r
- if(!gEditorElt) return;\r
-\r
+ if(!gEditorElt) {\r
+ return;\r
+ }\r
// title box\r
- $("#editorDialogHeader").attr("title",gTitleDlg); \r
+ $("#editorDialogHeader").attr("title",gTitleDlg);\r
$("#editorDialogHeader").attr("description",gDlgEditorXimf_maxItem_alert);\r
- \r
// text value\r
if(!gXimfSeparator){\r
gEditorElt.setAttribute("multiline","false");\r
- gEditorElt.value = gCurrentText; \r
+ gEditorElt.value = gCurrentText;\r
}else{\r
- try{ \r
+ try{\r
gEditorElt.setAttribute("multiline","true");\r
- if(gCurrentText){ \r
- var reg=new RegExp(gXimfSeparator, "g"); \r
- var multitxt = gCurrentText.replace(reg , "\n"); \r
- //gEditorElt.setAttribute("value",multitxt+"\n");\r
+ if(gCurrentText){\r
+ var reg=new RegExp(gXimfSeparator, "g");\r
+ var multitxt = gCurrentText.replace(reg , "\n");\r
gEditorElt.setAttribute("value",multitxt);\r
- } \r
+ }\r
}catch(e){\r
- gConsole.logStringMessage("[ximfmail - RefreshEditor ] \n " + e + "\nfile : " + Error().fileName+"\nline : "+ e.lineNumber); \r
- } \r
+ gConsole.logStringMessage("[ximfmail - RefreshEditor ] \n " + e + "\nfile : " + Error().fileName+"\nline : "+ e.lineNumber);\r
+ }\r
}\r
}
\ No newline at end of file