Jump to content

User:Zocky/wysawyg.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <pre><nowiki>

// hook
addOnloadHook(wysawygInit);

//init
function wysawygInit()
{
  if ($('wpTextbox1'))
  {
    $('content').innerHTML+=
      '<i'+'frame width="90%" height="400" id="rtshed" name="rtshed"></i'+'frame>';
   rtshed.document.open();
   rtshed.document.write(' <html><head>'
    + '<l'+'ink type="text/css" rel="stylesheet" href="/w/index.php?title=User:Zocky/wysawyg.css&action=raw&type=text/css"/>'
    + '<s'+'cript type="text/javascript" src="/w/index.php?title=User:Zocky/wysawygEd.js&action=raw&type=text/javascript"/>'
    + '<s'+'cript type="text/javascript"/>RTSH.language = "javascript";</'+'script>'
    + '</head><body><pre id="ffedt"><pre id="ieedt">'
    + $('wpTextbox1').value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
    + '</pre></pre></body></html>');
    rtshed.document.close();
//    rtshed.contentWindow.CodePress.initialize();
  };
} 

// cross-browser event functions

function eventAddListener (element,event,handler) 
{ 
  if (element.addEventListener) 
    element.addEventListener(event,handler,false) 
  else
    element.attachEvent('on'+event,handler);
} 

function eventRemoveListener (element, event, handler)
{
  if (element.removeEventListener)
    element.removeEventListener(event,handler,false) 
  else
    element.detachEvent('on'+event,handler);
}

function eventStop(event)
{
 if (event.preventDefault) 
 {  
   event.preventDefault();
   event.stopPropagation();
 } 
 else 
 {
   event.returnValue = false;
   event.cancelBubble = true;
 }
}

function eventTarget(event)
{
 return event.target || event.srcElement;
}

function eventKeyCode(event)
{
   return event.preventDefault ? event.which : event.keyCode ;
}

function $(id)
{
  return document.getElementById(id);
}