un javascript + mon bbcode = zob :o

un javascript + mon bbcode = zob :o - HTML/CSS - Programmation

Marsh Posté le 21-11-2006 à 20:37:28    

yo  :o  
Bon, je préviens, c'est assez "lourd" comme code, "voudra bien m'aider qui voudra"  :jap:  
 
Alors voilà:
je code un petit module de messagerie locale pour un projet avec un poto. j'ai pompé du js par-ci par-là (c'est un domaine ou j'excèle pas franchement [:dawa]), et pour l'insertion des tags, ça donne ça:

Code :
  1. <style>
  2. .smiley a{
  3. cursor: default;
  4. }
  5. .bbcode { border : 0px none #000000; margin: 0; vertical-align : bottom; }
  6. </style>
  7. <script type="text/javascript">
  8. function insereTag(Tag, fTag)
  9. ajtBBCode(Tag, fTag, "message" );
  10. }
  11. function insereTxt(txt)
  12. {
  13. ajtTexte(txt, "message" );
  14. function ajtTexte(txt,id)
  15. {
  16. var obj = document.getElementById(id), sel;
  17. obj.focus();
  18. if(document.selection && document.selection.createRange){
  19. sel = document.selection.createRange();
  20. if (sel.parentElement()==obj)//si sel est dans obj
  21. sel.text = sel.text+txt;
  22. }
  23. else if(String(typeof obj.selectionStart)!="undefined" ){
  24. sel = obj.selectionStart;
  25. obj.value = (obj.value).substring(0,sel) +
  26.           txt +
  27. (obj.value).substring(sel,obj.value.length);
  28. }
  29. else obj.value+=txt;
  30. obj.focus();
  31. }
  32. function ajtBBCode(Tag, fTag, id)
  33. {
  34. var obj = document.getElementById(id), sel;
  35. obj.focus();
  36. if (document.selection && document.selection.createRange){//if ie
  37.    sel = document.selection.createRange();
  38.    if (sel.parentElement()==obj)//si sel est dans obj
  39. sel.text = Tag+sel.text+fTag;
  40. }
  41. else if(String(typeof obj.selectionStart)!="undefined" ){
  42.    var longueur= parseInt(obj.textLength);
  43.    var selStart = obj.selectionStart;
  44.    var selEnd = obj.selectionEnd;
  45.    if (selEnd == 2 || selEnd == 1)selEnd = longueur;
  46.    obj.value = (obj.value).substring(0,selStart) +
  47.               Tag +
  48.     (obj.value).substring(selStart,selEnd) +
  49.                  fTag +
  50.   (obj.value).substring(selEnd,longueur);
  51. }
  52. else obj.value+=Tag+fTag;
  53. obj.focus();
  54. }
  55. </script>
  56.   <script language="Javascript" type="text/javascript">
  57.    // args : string moncontroletexte, int nbcar, string moncontroledecompte
  58.   // return : aucun
  59. // Affecte à certains évènements d'un textarea, le contrôle de la longueur de son contenu
  60.    function LimiterTextArea(nom_controletexte, nbcar, nom_controledecompte)
  61.    {
  62.       var moncontroletexte = document.getElementById(nom_controletexte);
  63.  
  64.        var moncontroledecompte = document.getElementById(nom_controledecompte);
  65.    
  66.       if (moncontroletexte && moncontroledecompte)
  67.        {
  68.    
  69.           moncontroletexte.onclick = function(){TextAreaEstRempli(moncontroletexte, nbcar, moncontroledecompte)};
  70.           moncontroletexte.onblur = function(){TextAreaEstRempli(moncontroletexte, nbcar, moncontroledecompte)};
  71.            moncontroletexte.onkeyup = function(){TextAreaEstRempli(moncontroletexte, nbcar, moncontroledecompte)};
  72.            moncontroletexte.onkeypress = function(){TextAreaEstRempli(moncontroletexte, nbcar, moncontroledecompte)};
  73.  
  74.           // *** Affichage du nombre de caractères restant
  75.            if(moncontroledecompte.type)
  76.                moncontroledecompte.value = NbCarRestant(moncontroletexte, nbcar);            // Pour un input de formulaire         
  77.            else
  78.               moncontroledecompte.innerHTML = NbCarRestant(moncontroletexte, nbcar);    // Pour un élément HTML     
  79.  
  80.        }
  81.    }
  82.    
  83.    // TextAreaEstRempli
  84.    // args : textarea moncontroletexte, int nbcar, element_HTML moncontroledecompte
  85.    // return : bool
  86.    // Renvoie vrai si le nombre de caractères maximum du textarea n'est pas atteint
  87.   function TextAreaEstRempli(moncontroletexte, nbcar, moncontroledecompte)
  88.    {
  89.       if (moncontroletexte)
  90.      {
  91.           if (moncontroletexte.value.length <= nbcar)
  92.           {
  93.              //alert("pas rempli" );
  94.                // mes actions ...
  95.    
  96.                // *** Affichage du nombre de caractères restant
  97.                if(moncontroledecompte.type)
  98.                    moncontroledecompte.value = NbCarRestant(moncontroletexte, nbcar);
  99.               else
  100.                  moncontroledecompte.innerHTML = NbCarRestant(moncontroletexte, nbcar);
  101.  
  102.               return true;
  103.          }
  104.           else
  105.          {
  106.               //alert("rempli" );
  107.              // mes actions ...
  108.  
  109.               // Affichage du nombre de caractères restant
  110.              moncontroletexte.value = moncontroletexte.value.substr(0, nbcar);
  111.  
  112.               // *** Affichage du nombre de caractères restant
  113.               if(moncontroledecompte.type)
  114.                   moncontroledecompte.value = NbCarRestant(moncontroletexte, nbcar);
  115.               else
  116.                   moncontroledecompte.innerHTML = NbCarRestant(moncontroletexte, nbcar);
  117.                
  118.             return false;
  119.           }
  120.       }
  121.   }
  122.  
  123.   // NbCarRestant
  124.   // args : textarea moncontroletexte, int nbcar
  125.    // return : int
  126.   // Renvoie le nombre de caractère à saisir
  127.    function NbCarRestant(moncontroletexte, nbcar)
  128.    {
  129.        if (moncontroletexte.value.length)
  130.            return new Number(nbcar - moncontroletexte.value.length);
  131.       else
  132.          return new Number(nbcar);
  133.   }
  134. </script>


 
ainsi, quand on clique sur le bouton de l'image italique, ça inscrit [i][/i] dans le textarea. \o/ pareil pour le bold, underline, etc.
 
Là où ça se complique, c'est que j'essaye d'incruster un js pour permettre à l'utilisateur de selectionner une couleur pour son texte. donc dès qu'il clique sur un couleur, il doit y avoir [c=#cdcdcd]texte[/c]. à priori, avec le code que j'ai trouvé et traficotté ça marche mais quand on selectionne la couleur, le textarea est tout effacé (donc on perd tout ce qui été ecrit).  :lol:  :lol:  
ça donne ça (un extrait):

Code :
  1. </td>
  2.        <td style="padding-bottom:0;">';?><br /><br />
  3.         <a href="javascript:insereTag('','')" onMouseOver= "if (document.images) document.b.src='./img/bold2.bmp';" onMouseOut= "if (document.images) document.b.src='./img/bold.bmp';" style="text-decoration:none;"><img src="./img/bold.bmp" class="bbcode" name="b" width="25" height="22" alt="gras" title="gras" /></a><a href="javascript:insereTag('','')" onMouseOver= "if (document.images) document.i.src='./img/italic2.bmp';" onMouseOut= "if (document.images) document.i.src='./img/italic.bmp';" style="text-decoration:none;"><img src="./img/italic.bmp" class="bbcode" name="i" width="24" height="22" alt="italique" title="italique" /></a><a href="javascript:insereTag('','')" onMouseOver= "if (document.images) document.u.src='./img/u2.bmp';" onMouseOut= "if (document.images) document.u.src='./img/u.bmp';" style="text-decoration:none;"><img src="./img/u.bmp" class="bbcode" name="u" width="23" height="22" alt="souligné" title="souligné" /></a>
  4.         <a href="javascript:insereTag('','')" onMouseOver= "if (document.images) document.g.src='./img/g2.bmp';" onMouseOut= "if (document.images) document.g.src='./img/g.bmp';" style="text-decoration:none;"><img src="./img/g.bmp" class="bbcode" name="g" width="25" height="22" alt="alignement gauche" title="alignement gauche" /></a><a href="javascript:insereTag('[c]','[/c]')" onMouseOver= "if (document.images) document.c.src='./img/c2.bmp';" onMouseOut= "if (document.images) document.c.src='./img/c.bmp';" style="text-decoration:none;"><img src="./img/c.bmp" class="bbcode" name="c" width="24" height="22" alt="[c]centré[/c]" title="[c]centré[/c]" /></a><a href="javascript:insereTag('[d]','[/d]')" onMouseOver= "if (document.images) document.d.src='./img/d2.bmp';" onMouseOut= "if (document.images) document.d.src='./img/d.bmp';" style="text-decoration:none;"><img src="./img/d.bmp" class="bbcode" name="d" width="26" height="22" alt="[d]alignement droit[/d]" title="[d]alignement droit[/d]" /
  5.         </a>
  6.         <a href="javascript:insereTag('','')" onMouseOver= "if (document.images) document.url.src='./img/url2.bmp';" onMouseOut= "if (document.images) document.url.src='./img/url.bmp';" style="text-decoration:none;"><img src="./img/url.bmp" class="bbcode" name="url" width="25" height="22" alt="insérer un lien" title="insérer un lien" /></a><a href="javascript:insereTag('[img]','[/img]')" onMouseOver= "if (document.images) document.img.src='./img/img2.bmp';" onMouseOut= "if (document.images) document.img.src='./img/img.bmp';" style="text-decoration:none;"><img src="./img/img.bmp" class="bbcode" name="img" width="23" height="22" alt="[img]insérer une image[/img]" title="[img]insérer une image[/img]" /></a>
  7.         <a href="javascript:insereTag('[aa]','[/aa]')" onMouseOver= "if (document.images) document.aa.src='./img/aa2.bmp';" onMouseOut= "if (document.images) document.aa.src='./img/aa.bmp';" style="text-decoration:none;"><img src="./img/aa.bmp" class="bbcode" name="aa" width="28" height="22" alt="[aa]txt[/aa]" title="[aa]txt[/aa]" /></a><a href="javascript:insereTag('[Aaa]','[/Aaa]')" onMouseOver= "if (document.images) document.Aaa.src='./img/Aaa2.bmp';" onMouseOut= "if (document.images) document.Aaa.src='./img/Aaa.bmp';" style="text-decoration:none;"><img src="./img/Aaa.bmp" class="bbcode" name="Aaa" width="26" height="22" alt="[Aaa]txt[/Aaa]" title="[Aaa]txt[/Aaa]" /></a>
  8.        <?php echo'</td>
  9.       </tr>
  10.              <tr>
  11.        <td align="right" valign="top" >Message : </td>
  12.        <td align="left" style="padding-top:0;"><textarea name="message" id="message" style="width:260px; height:120px;">';
  13. echo '</textarea><br />


 
et pour le script qui permet de selectionner une couleur de font, je dois faire ainsi:
 

Code :
  1. <HTML>
  2. <HEAD>
  3. <TITLE>JavaScript Toolbox - Color Picker Swatch Popup</TITLE>
  4. <SCRIPT LANGUAGE="Javascript" SRC="./ColorPicker2.js"></SCRIPT>
  5. <SCRIPT LANGUAGE="JavaScript">
  6. var cp = new ColorPicker('window'); // Popup window
  7. var cp2 = new ColorPicker(); // DIV style
  8. </SCRIPT>
  9. </HEAD>
  10. <FORM>
  11. Color: <INPUT TYPE="text" NAME="color2" SIZE="20" VALUE=""> <A HREF="#" onClick="cp2.select(document.forms[0].color2,'pick2');return false;" NAME="pick2" ID="pick2">Pick</A>
  12. </FORM>
  13. <SCRIPT LANGUAGE="JavaScript">cp.writeDiv()</SCRIPT>
  14. </BODY>
  15. </HTML>


 
avec le fichier inclus: ColorPicker2.js :

Code :
  1. // ===================================================================
  2. // Author: Matt Kruse <matt@mattkruse.com>
  3. // WWW: http://www.mattkruse.com/
  4. //
  5. // NOTICE: You may use this code for any purpose, commercial or
  6. // private, without any further permission from the author. You may
  7. // remove this notice from your final code if you wish, however it is
  8. // appreciated by the author if at least my web site address is kept.
  9. //
  10. // You may *NOT* re-distribute this code in any way except through its
  11. // use. That means, you can include it in your product, or your web
  12. // site, or any other form where the code is actually being used. You
  13. // may not put the plain javascript up on your site for download or
  14. // include it in your javascript libraries for download.  
  15. // If you wish to share this code with others, please just point them
  16. // to the URL instead.
  17. // Please DO NOT link directly to my .js files from your site. Copy
  18. // the files to your server and use them there. Thank you.
  19. // ===================================================================
  20. /* SOURCE FILE: AnchorPosition.js */
  21. function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false, use_css=false, use_layers=false;if(document.getElementById){use_gebi=true;}else if(document.all){use_css=true;}else if(document.layers){use_layers=true;}if(use_gebi && document.all){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_gebi){var o=document.getElementById(anchorname);x=AnchorPosition_getPageOffsetLeft(o);y=AnchorPosition_getPageOffsetTop(o);}else if(use_css){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_layers){var found=0;for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==anchorname){found=1;break;}}if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}x=document.anchors[i].x;y=document.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}coordinates.x=x;coordinates.y=y;return coordinates;}
  22. function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(document.getElementById){if(isNaN(window.screenX)){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}else if(document.all){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else if(document.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}coordinates.x=x;coordinates.y=y;return coordinates;}
  23. function AnchorPosition_getPageOffsetLeft(el){var ol=el.offsetLeft;while((el=el.offsetParent) != null){ol += el.offsetLeft;}return ol;}
  24. function AnchorPosition_getWindowOffsetLeft(el){return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;}
  25. function AnchorPosition_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent) != null){ot += el.offsetTop;}return ot;}
  26. function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;}
  27. /* SOURCE FILE: PopupWindow.js */
  28. function PopupWindow_getXYPosition(anchorname){var coordinates;if(this.type == "WINDOW" ){coordinates = getAnchorWindowPosition(anchorname);}else{coordinates = getAnchorPosition(anchorname);}this.x = coordinates.x;this.y = coordinates.y;}
  29. function PopupWindow_setSize(width,height){this.width = width;this.height = height;}
  30. function PopupWindow_populate(contents){this.contents = contents;this.populated = false;}
  31. function PopupWindow_setUrl(url){this.url = url;}
  32. function PopupWindow_setWindowProperties(props){this.windowProperties = props;}
  33. function PopupWindow_refresh(){if(this.divName != null){if(this.use_gebi){document.getElementById(this.divName).innerHTML = this.contents;}else if(this.use_css){document.all[this.divName].innerHTML = this.contents;}else if(this.use_layers){var d = document.layers[this.divName];d.document.open();d.document.writeln(this.contents);d.document.close();}}else{if(this.popupWindow != null && !this.popupWindow.closed){if(this.url!="" ){this.popupWindow.location.href=this.url;}else{this.popupWindow.document.open();this.popupWindow.document.writeln(this.contents);this.popupWindow.document.close();}this.popupWindow.focus();}}}
  34. function PopupWindow_showPopup(anchorname){this.getXYPosition(anchorname);this.x += this.offsetX;this.y += this.offsetY;if(!this.populated &&(this.contents != "" )){this.populated = true;this.refresh();}if(this.divName != null){if(this.use_gebi){document.getElementById(this.divName).style.left = this.x + "px";document.getElementById(this.divName).style.top = this.y;document.getElementById(this.divName).style.visibility = "visible";}else if(this.use_css){document.all[this.divName].style.left = this.x;document.all[this.divName].style.top = this.y;document.all[this.divName].style.visibility = "visible";}else if(this.use_layers){document.layers[this.divName].left = this.x;document.layers[this.divName].top = this.y;document.layers[this.divName].visibility = "visible";}}else{if(this.popupWindow == null || this.popupWindow.closed){if(this.x<0){this.x=0;}if(this.y<0){this.y=0;}if(screen && screen.availHeight){if((this.y + this.height) > screen.availHeight){this.y = screen.availHeight - this.height;}}if(screen && screen.availWidth){if((this.x + this.width) > screen.availWidth){this.x = screen.availWidth - this.width;}}var avoidAboutBlank = window.opera ||( document.layers && !navigator.mimeTypes['*']) || navigator.vendor == 'KDE' ||( document.childNodes && !document.all && !navigator.taintEnabled);this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"" );}this.refresh();}}
  35. function PopupWindow_hidePopup(){if(this.divName != null){if(this.use_gebi){document.getElementById(this.divName).style.visibility = "hidden";}else if(this.use_css){document.all[this.divName].style.visibility = "hidden";}else if(this.use_layers){document.layers[this.divName].visibility = "hidden";}}else{if(this.popupWindow && !this.popupWindow.closed){this.popupWindow.close();this.popupWindow = null;}}}
  36. function PopupWindow_isClicked(e){if(this.divName != null){if(this.use_layers){var clickX = e.pageX;var clickY = e.pageY;var t = document.layers[this.divName];if((clickX > t.left) &&(clickX < t.left+t.clip.width) &&(clickY > t.top) &&(clickY < t.top+t.clip.height)){return true;}else{return false;}}else if(document.all){var t = window.event.srcElement;while(t.parentElement != null){if(t.id==this.divName){return true;}t = t.parentElement;}return false;}else if(this.use_gebi && e){var t = e.originalTarget;while(t.parentNode != null){if(t.id==this.divName){return true;}t = t.parentNode;}return false;}return false;}return false;}
  37. function PopupWindow_hideIfNotClicked(e){if(this.autoHideEnabled && !this.isClicked(e)){this.hidePopup();}}
  38. function PopupWindow_autoHide(){this.autoHideEnabled = true;}
  39. function PopupWindow_hidePopupWindows(e){for(var i=0;i<popupWindowObjects.length;i++){if(popupWindowObjects[i] != null){var p = popupWindowObjects[i];p.hideIfNotClicked(e);}}}
  40. function PopupWindow_attachListener(){if(document.layers){document.captureEvents(Event.MOUSEUP);}window.popupWindowOldEventListener = document.onmouseup;if(window.popupWindowOldEventListener != null){document.onmouseup = new Function("window.popupWindowOldEventListener();PopupWindow_hidePopupWindows();" );}else{document.onmouseup = PopupWindow_hidePopupWindows;}}
  41. function PopupWindow(){if(!window.popupWindowIndex){window.popupWindowIndex = 0;}if(!window.popupWindowObjects){window.popupWindowObjects = new Array();}if(!window.listenerAttached){window.listenerAttached = true;PopupWindow_attachListener();}this.index = popupWindowIndex++;popupWindowObjects[this.index] = this;this.divName = null;this.popupWindow = null;this.width=0;this.height=0;this.populated = false;this.visible = false;this.autoHideEnabled = false;this.contents = "";this.url="";this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";if(arguments.length>0){this.type="DIV";this.divName = arguments[0];}else{this.type="WINDOW";}this.use_gebi = false;this.use_css = false;this.use_layers = false;if(document.getElementById){this.use_gebi = true;}else if(document.all){this.use_css = true;}else if(document.layers){this.use_layers = true;}else{this.type = "WINDOW";}this.offsetX = 0;this.offsetY = 0;this.getXYPosition = PopupWindow_getXYPosition;this.populate = PopupWindow_populate;this.setUrl = PopupWindow_setUrl;this.setWindowProperties = PopupWindow_setWindowProperties;this.refresh = PopupWindow_refresh;this.showPopup = PopupWindow_showPopup;this.hidePopup = PopupWindow_hidePopup;this.setSize = PopupWindow_setSize;this.isClicked = PopupWindow_isClicked;this.autoHide = PopupWindow_autoHide;this.hideIfNotClicked = PopupWindow_hideIfNotClicked;}
  42. /* SOURCE FILE: ColorPicker2.js */
  43. ColorPicker_targetInput = null;
  44. function ColorPicker_writeDiv(){document.writeln("<DIV ID=\"colorPickerDiv\" STYLE=\"position:absolute;visibility:hidden;\"> </DIV>" );}
  45. function ColorPicker_show(anchorname){this.showPopup(anchorname);}
  46. function ColorPicker_pickColor(color,obj){obj.hidePopup();pickColor(color);}
  47. function pickColor(color){if(ColorPicker_targetInput==null){alert("Target Input is null, which means you either didn't use the 'select' function or you have no defined your own 'pickColor' function to handle the picked color!" );return;}ColorPicker_targetInput.value = color;}
  48. function ColorPicker_select(inputobj,linkname){if(inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea" ){alert("colorpicker.select: Input object passed is not a valid form input object" );window.ColorPicker_targetInput=null;return;}window.ColorPicker_targetInput = inputobj;this.show(linkname);}
  49. function ColorPicker_highlightColor(c){var thedoc =(arguments.length>1)?arguments[1]:window.document;var d = thedoc.getElementById("colorPickerSelectedColor" );d.style.backgroundColor = c;d = thedoc.getElementById("colorPickerSelectedColorValue" );d.innerHTML = c;}
  50. function ColorPicker(){var windowMode = false;if(arguments.length==0){var divname = "colorPickerDiv";}else if(arguments[0] == "window" ){var divname = '';windowMode = true;}else{var divname = arguments[0];}if(divname != "" ){var cp = new PopupWindow(divname);}else{var cp = new PopupWindow();cp.setSize(225,250);}cp.currentValue = "#FFFFFF";cp.writeDiv = ColorPicker_writeDiv;cp.highlightColor = ColorPicker_highlightColor;cp.show = ColorPicker_show;cp.select = ColorPicker_select;var colors = new Array("#000000",
  51. "#993300","#333300","#003300","#003366","#000080","#333399","#333333",
  52. "#800000","#FF6600","#808000","#808080","#008080","#0000FF","#666699","#808080",
  53. "#FF0000","#FF9900","#99CC00","#339966","#33CCCC","#3366FF","#800080","#999999",
  54. "#FF00FF","#FFCC00","#FFFF00","#00FF00","#00FFFF","#00CCFF","#993366","#C0C0C0",
  55. "#FF99CC","#FFCC99","#FFFF99","#CCFFCC","#CCFFFF","#99CCFF","#CC99FF","#FFFFFF" );
  56. var total = colors.length;var width = 8;var cp_contents = "";var windowRef =(windowMode)?"window.opener.":"";if(windowMode){cp_contents += "<HTML><HEAD><TITLE>Select Color</TITLE></HEAD>";cp_contents += "<BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0><CENTER>";}cp_contents += "<table style='border: 1px dashed #bebebe;' cellspacing=1 cellpadding=0>";var use_highlight =(document.getElementById || document.all)?true:false;for(var i=0;i<total;i++){if((i % width) == 0){cp_contents += "<TR>";}if(use_highlight){var mo = 'onMouseOver="'+windowRef+'ColorPicker_highlightColor(\''+colors[i]+'\',window.document)"';}else{mo = "";}cp_contents += '<TD BGCOLOR="'+colors[i]+'"><FONT SIZE="-3"><A HREF="#" onClick="'+windowRef+'ColorPicker_pickColor(\'[c='+colors[i]+']texte[/c]\','+windowRef+'window.popupWindowObjects['+cp.index+']);return false;" '+mo+' STYLE="text-decoration:none;">&nbsp;&nbsp;&nbsp;</A></FONT></TD>';if( ((i+1)>=total) ||(((i+1) % width) == 0)){cp_contents += "</TR>";}}
  57. if(document.getElementById){var width1 = Math.floor(width/2);var width2 = width = width1;cp_contents += "<TR><TD COLSPAN='"+(width1-1)+"' BGCOLOR='#000000' ID='colorPickerSelectedColor'>&nbsp;</TD><TD COLSPAN='"+(width2+1)+"' ALIGN='CENTER' ID='colorPickerSelectedColorValue' style='font-family:Arial; font-size:9px; border-top:1px dashed #cdcdcd; border-left:1px dashed #cdcdcd;'>#000000</TD></TR>";}cp_contents += "</TABLE>";if(windowMode){cp_contents += "</CENTER></BODY></HTML>";}cp.populate(cp_contents+"\n" );cp.offsetY = 25;cp.autoHide();return cp;}


 
 
 
Voilà, en fait je cherche à adapter ce script de colorpicker avec le script de bbcode que j'ai déjà.  :(  
énorme merci à celui qui a le courage de bien vouloir s'interesser à mon cas.  :lol:


Message édité par pmusa le 21-11-2006 à 20:47:01

---------------
intralase surgery [:cerveau love]
Reply

Marsh Posté le 21-11-2006 à 20:37:28   

Reply

Marsh Posté le 21-11-2006 à 20:43:38    

pardon pour avoir niké les tabs. :o
c'est l'indentation telle quelle dans mon code source. :/


---------------
intralase surgery [:cerveau love]
Reply

Marsh Posté le 21-11-2006 à 21:41:08    

tl;dr [:petrus75]

Reply

Marsh Posté le 21-11-2006 à 21:46:19    

lapin comprite pancake sur la tête [:petrus75]


---------------
intralase surgery [:cerveau love]
Reply

Marsh Posté le 21-11-2006 à 21:48:56    

Ca veut dire "Too long - Didn't read" [:dawak]

Reply

Marsh Posté le 21-11-2006 à 22:00:55    

wow u rosque at zi internet. [:dawa]
 
 
ouais forcément, je sais bien.  :o tu y répondra quand tu sera bourré.


---------------
intralase surgery [:cerveau love]
Reply

Marsh Posté le 21-11-2006 à 22:34:07    

J'ai plus de bière [:zytrasnif]

Reply

Marsh Posté le 21-11-2006 à 23:09:09    

http://img329.imageshack.us/img329/3571/pmusaflorentgri2.gif


Message édité par pmusa le 21-11-2006 à 23:34:12

---------------
intralase surgery [:cerveau love]
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed