Ver Mensaje Individual
  #2 (permalink)  
Antiguo 10/09/2011, 10:09
Avatar de JuJoGuAl
JuJoGuAl
 
Fecha de Ingreso: julio-2009
Ubicación: Venezuela
Mensajes: 754
Antigüedad: 15 años, 3 meses
Puntos: 19
Respuesta: No se ejecuta JavaScript si pego otro

Código Javascript:
Ver original
  1. if(oW.addEventListener){oW.addEventListener("keypress", kb_handler, true)}
  2.  else{d.body.attachEvent("onpaste",function(){setTimeout('cleanUp()',10)})}
  3.  addEvt(d,"mouseup", whereAmI); addEvt(d,"keyup", whereAmI); addEvt(d,"dblclick", doDbl);
  4.  taObject = o(idTa);
  5.  o("CONTAINER"+idTa).removeChild(o(idTa));
  6.  o("CONTAINER"+idTa).appendChild(taObject);
  7.  idTa=null;
  8. }
  9. function whizzywig(controls){
  10.  var i,ta=document.getElementsByTagName('TEXTAREA');
  11.  for (i=0;i<ta.length;i++){
  12.   if(!ta[i].id){ta[i].id=ta.name}
  13.   makeWhizzyWig(ta[i].id,controls);
  14.  }
  15. }
  16. function addEvt(o,e,f){if(wn.addEventListener){o.addEventListener(e, f, false)}else{o.attachEvent("on"+e,f)}}
  17. function doDbl(){if(papa.nodeName == 'IMG'){doImage()}else{if(papa.nodeName=='A'){doLink()}}}
  18. function makeButton(button){// assemble the button requested
  19.  var butHTML, ucBut=button.substring(0,1).toUpperCase();
  20.  ucBut += button.substring(1);
  21.  ucBut=t(ucBut.replace(/_/g,' '));
  22.  if(!document.frames && (button=="spellcheck")){return}
  23.  if(o(idTa).nodeName!="TEXTAREA" && button=="html"){return}
  24.  if(!buttonExt){buttonExt='.gif'}
  25.  if (buttonPath == "textbuttons"){butHTML='<button type=button onClick=makeSo("'+button+'")>'+ucBut+"</button>\n"}
  26.  else{butHTML='<button  title="'+ucBut+'" type=button onClick=makeSo("'+button+'")>'+(btn[button]!=undefined?'<div style="width:'+btn._w+'px;height:'+btn._h+'px;background-image:url('+btn._f+');background-position:-'+btn[button]+'px 0px"></div>':'<img src="'+buttonPath+button+buttonExt+'" alt="'+ucBut+'" onError="this.parentNode.innerHTML=this.alt">')+'</button>\n'}
  27.  w(butHTML)
  28. }
  29. function fGo(id){return '<div id="'+id+'_FORM'+idTa+'" unselectable="on" style="display:none" onkeypress="if(event.keyCode==13) {return false;}"><hr>'+"\n"}//new form
  30. function fNo(txt,go){//form do it/cancel buttons
  31.  return ' <input type="button" onclick="'+go+'" value="'+txt+'"> <input type="button" onclick="hideDialogs();" value='+t("Cancel")+"></div>\n";
  32. }
  33. function makeSelect(select){
  34.  var values,options,h,i;
  35.  if (select == 'formatblock'){
  36.  h="Heading";
  37.  values=["<p>", "<p>", "<h1>", "<h2>", "<h3>", "<h4>", "<h5>", "<h6>", "<address>",  "<pre>"];
  38.  options=[t("Choose style")+":", t("Paragraph"), t(h)+" 1 ", t(h)+" 2 ", t(h)+" 3 ", t(h)+" 4 ", t(h)+" 5 ", t(h)+" 6", t("Address"), t("Fixed width<pre>")];
  39.  }else if (select == 'fontname') {
  40.   values=["Arial, Helvetica, sans-serif", "Arial, Helvetica, sans-serif","'Arial Black', Helvetica, sans-serif", "'Comic Sans MS' fantasy", "Courier New, Courier, monospace", "Georgia, serif", "Impact,sans-serif","'Times New Roman', Times, serif", "'Trebuchet MS',sans-serif", "Verdana, Arial, Helvetica, sans-serif"];
  41.   options=[t("Font")+":", "Arial","Arial Black", "Comic", "Courier", "Georgia", "Impact","Times New Roman", "Trebuchet","Verdana"]
  42.  }else if(select == 'fontsize'){
  43.   values=["3", "1", "2", "3", "4", "5", "6", "7"];
  44.   options=[t("Font size")+":", "1 "+t("Small"), "2", "3", "4", "5", "6", "7 "+t("Big")]
  45.  }else{
  46.   values=vals[select];
  47.   options=opts[select]
  48.  }
  49.  w('<select id="'+select+idTa+'" onchange="doSelect(this.id);">'+"\n");
  50.  for (i=0;i<values.length;i++){w(' <option value="' + values[i] + '">' + options[i] + "</option>\n")}
  51.  w("</select>\n")
  52. }
  53. function tagButs(){
  54.  w('<input type="button" onclick=\'doTag("<h1>")\' value="H1" title="<H1>"><input type="button" onclick=\'doTag("<h2>")\' value="H2" title="<H2>"><input type="button" onclick=\'doTag("<h3>")\' value="H3" title="<H3>"><input type="button" onclick=\'doTag("<h4>")\' value="H4" title="<H4>"><input type="button" onclick=\'doTag("<p>")\' value="P" title="<P>"><input type="button" onclick=\'doTag("<strong>")\' value="S" title="<STRONG>" style="font-weight:bold"><input type="button" onclick=\'doTag("<em>")\' value="E" title="<EM>" style="font-style:italic;"><input type="button" onclick=\'doTag("<li>")\' value="&bull;&mdash;" title="<LI>"><input type="button" onclick=\'doTag("<a>")\' value="@" title="<A HREF= >"><input type="button" onclick=\'doTag("<img>")\' value="[&hearts;]" title="<IMG SRC= >"><input type="button" onclick=\'doTag("<br />")\' value="&larr;" title="<BR />">');
  55. }
  56. function xC(c,o){return oW.document.execCommand(c,false,o)}
  57. function makeSo(cm,op){
  58.  hideDialogs();
  59.  oW.focus();
  60.  if(dobut[cm]) {insHTML(dobut[cm]); return;}
  61.  if (/Firefox/.test(navigator.userAgent)) {xC("styleWithCSS",cm=="hilite")}
  62.  if(cm=="justify"){cm="full"}
  63.  if("leftrightcenterfull".indexOf(cm)!=-1){cm="justify"+cm}
  64.  else if(cm=="number"){cm="insertorderedlist"}
  65.  else if(cm=="bullet"){cm="insertunorderedlist"}
  66.  else if (cm=="rule"){cm="inserthorizontalrule"}
  67.  switch(cm){
  68.   case "color":o('cf_cmd'+idTa).value="forecolor"; if(textSel()){s('COLOR_FORM'+idTa)} break;
  69.   case "hilite":o('cf_cmd'+idTa).value=cm; if(textSel()){s('COLOR_FORM'+idTa)} break;
  70.   case "image":doImage(); break;
  71.   case "link":doLink(); break;
  72.   case "html":showHTML(); break;
  73.   case "table":doTable(); break;
  74.   case "delete_row":doRow('delete','0'); break;
  75.   case "add_row_above":doRow('add','0'); break;
  76.   case "add_row_below":doRow('add','1'); break;
  77.   case "delete_column":doCol('delete','0'); break;
  78.   case "add_column_before":doCol('add','0'); break;
  79.   case "add_column_after":doCol('add','1'); break;
  80.   case "table_in_cell":hideDialogs(); s('TABLE_FORM'+idTa); break;
  81.   case "clean":cleanUp(); break;
  82.   case "spellcheck":spellCheck(); break;
  83.   case "fullscreen":fullscreen(); break;
  84.   default:xC(cm,op); break;
  85.  }
  86.  oW.focus();
  87. }
  88. function doSelect(selectname) {  
  89.  var idx=o(selectname).selectedIndex;
  90.  var selected=o(selectname).options[idx].value;
  91.  o(selectname).selectedIndex=0;
  92.  selectname=selectname.replace(idTa,"");
  93.  if (" _formatblock_fontname_fontsize".indexOf('_'+selectname) > 0) {
  94.   var cmd=selectname;
  95.   oW.focus();
  96.   xC(cmd,selected);
  97.  } else {
  98.   insHTML(selected);
  99.  }  
  100.  oW.focus();
  101. }
  102. function vC(colour){
  103.  if(!colour){colour=o('cf_color'+idTa).value}
  104.  o('cPrvw'+idTa).style.backgroundColor=colour;
  105.  o('cf_color'+idTa).value=colour
  106. }
  107. function sC(color) {
  108.  hideDialogs();
  109.  var cmd=o('cf_cmd'+idTa).value;
  110.  if(!color){color=o('cf_color'+idTa).value}
  111.  if(rng){rng.select();}
  112.  if(cmd=="hilite"){try{xC("hilitecolor",color)}catch(e){xC("backcolor",color)}}
  113.  else{xC(cmd,color)}
  114.  oW.focus();
  115. }
  116. function doLink(){
  117.  if(textSel()){
  118.   if(papa.nodeName=='A'){o("lf_url"+idTa).value=papa.href}
  119.   s('LINK_FORM'+idTa)
  120.  }
  121. }
  122. function insertLink(url) {
  123.  if (rng){rng.select()}
  124.  var a,i,mk='http://whizzy.wig/mark',
  125.  URL=url ? url : o("lf_url"+idTa).value;
  126.  if (URL.replace(/ /g,"")===""){xC('Unlink',null)}else{
  127.   xC('CreateLink',mk);
  128.   a=oW.document.body.getElementsByTagName("A");
  129.   for (i=0;i<a.length;i++){
  130.    if (a[i].href==mk){a[i].href=URL; if(o("lf_new"+idTa).checked){a[i].target="_blank"}break}
  131.   }
  132.  }
  133.  hideDialogs();
  134. }
  135. function doImage(){
  136.  if (papa && papa.nodeName == 'IMG'){
  137.   o("if_url"+idTa).value=papa.src;
  138.   o("if_alt"+idTa).value=papa.alt;
  139.   var position = papa.style.cssFloat?papa.style.cssFloat:papa.style.styleFloat;
  140.   o("if_side"+idTa).selectedIndex=(position=="left")?1:(position=="right")?2:0;
  141.   o("if_border"+idTa).value=papa.style.border?papa.style.border:papa.border>0?papa.border:0;
  142.   o("if_margin"+idTa).value=papa.style.margin?papa.style.margin:papa.hspace>0?papa.hspace:0;
  143.  }
  144.  s('IMAGE_FORM'+idTa);
  145. }
  146. function insertImage(URL, side, border, margin, alt) {
  147.  hideDialogs();
  148.  if(!URL){URL=o("if_url"+idTa).value}
  149.  if (URL) {
  150.   if (!alt){alt=o("if_alt"+idTa).value ? o("if_alt"+idTa).value: URL.replace(/.*\/(.+)\..*/,"$1")}
  151.   img='<img alt="' + alt + '" src="' + URL +'" ';
  152.   if(!side){side=o("if_side"+idTa).value}
  153.   if((side=="left") || (side=="right")){align='float:'+side+';'}else{align=''}
  154.   if(!border){border=o("if_border"+idTa).value}
  155.   if(border.match(/^\d+$/)){border+='px solid'}
  156.   if(!margin){margin=o("if_margin"+idTa).value}
  157.   if(margin.match(/^\d+$/)){margin+='px'}
  158.   if(border || margin){img+=' style="border:'+border+';margin:'+margin+';'+align+ '"'}
  159.   img+='/>';
  160.   insHTML(img)
  161.  }
  162. }
  163. function doTable(){ //show table controls if in a table, else make table
  164.  if(trail && trail.indexOf('TABLE') > 0){s('TABLE_CONTROLS'+idTa)}
  165.   else{s('TABLE_FORM'+idTa)}
  166. }
  167. function doRow(toDo,below) {
  168.  var pa=papa,tRow,tCols,newRow,newCell;
  169.  while(pa.tagName != "TR"){pa=pa.parentNode}
  170.  tRow=pa.rowIndex;
  171.  tCols=pa.cells.length;
  172.  while(pa.tagName != "TABLE"){pa=pa.parentNode}
  173.  if(toDo=="delete"){pa.deleteRow(tRow)}
  174.  else{
  175.   newRow=pa.insertRow(tRow+parseInt(below,10));//1=below 0=above
  176.    for(i=0;i<tCols;i++){
  177.     newCell=newRow.insertCell(i);
  178.     newCell.innerHTML="#";
  179.    }
  180.  }
  181. }
  182. function doCol(toDo,after) {//insert or delete a column
  183.  var pa=papa,tCol,tRows,i,newCell;
  184.  while(pa.tagName != 'TD'){pa=pa.parentNode}
  185.  tCol=pa.cellIndex;
  186.  while(pa.tagName != "TABLE"){pa=pa.parentNode}
  187.  tRows=pa.rows.length;
  188.  for(i=0;i<tRows;i++){
  189.   if(toDo=="delete"){pa.rows[i].deleteCell(tCol)}
  190.   else{
  191.    newCell=pa.rows[i].insertCell(tCol+parseInt(after,10));//if after=0 then before
  192.    newCell.innerHTML="#";
  193.   }
  194.  }
  195. }
  196. function makeTable() {
  197.  hideDialogs();
  198.  var rows=o('tf_rows'+idTa).value, cols=o('tf_cols'+idTa).value, border=o('tf_border'+idTa).value, head=o('tf_head'+idTa).value, table,i,j;
  199.  if ((rows>0)&&(cols>0)){
  200.   table='<table border="'+border+'">';
  201.   for (i=1;i<=rows;i++){
  202.    table=table+"<tr>";
  203.    for (j=1;j<=cols;j++){
  204.     if (i==1){
  205.      if(head=="1"){table += "<th>Title"+j+"</th>"}//Title1 Title2 etc.
  206.      else{table+="<td>"+j+"</td>"}
  207.     }
  208.     else if(j==1){table+="<td>"+i+"</td>"}
  209.    else{table += "<td>#</td>"}
  210.    }
Continua…