Toubsen: OpenPinboard

Beitrag lesen

<script type="text/javascript">
<!--
  // define variables
  var pages      = <?php echo (int)$pages ?>;
  var pp         = <?php echo (int)$pp ?>;
  var style      = <?php echo (int)$style ?>;
  var mypress = 0, divPosX = 0, divPosY = 0, diffx = 0, diffy = 0, layer = "lay1", count = 1, logindialog = 0, admin = false, smileys = 0, adminaction = "";
  var xhttp;
  var mouseX = 0, mouseY = 0;
  // language
<?php echo arrayphp2js($language,"language") ?>

document.onmousemove = checkPosition;

function putsmiley(code) {
    target = document.getElementsByName("message")[0];
    target.value += " "+code;
    target.focus();
  }
  function checkPosition(e) {
    if (document.all) {
      mouseX = event.clientX + document.body.scrollLeft;
      mouseY = event.clientY + document.body.scrollTop;
    }
    else {
      mouseX = e.pageX;
      mouseY = e.pageY;
    }
  }
  function press(lay) {
    if (adminaction!="") return false;
    layer=lay;
    mypress=1;
    diffx = mouseX- divPosX;
    diffy = mouseY- divPosY;
  }
  function unpress(lay) {
    if (adminaction!="") return false;
    layer = lay;
    mypress = 0;
    x = mouseX-diffx;
    y = mouseY-diffy;
    x = document.getElementById(layer).style.left;
    y = document.getElementById(layer).style.top;

// make an xhttp-request to save the position
    if (!xhttp) return xhttperror();
    xhttp.open("GET","index.php?action=move&x="+x+"&y="+y+"&id="+lay, true);
    xhttp.send("");
  }
  function checkMouse(Element) {
    divPosX = Element.offsetLeft;
    divPosY = Element.offsetTop;
    if(mypress==1) {
      document.getElementById(layer).style.left = mouseX-diffx;
      document.getElementById(layer).style.top = mouseY-diffy;
    }
    return true;
  }
  function opendialog() {
    document.getElementById("lay_entry").style.left = mouseX;
    document.getElementById("lay_entry").style.top = mouseY;
    document.getElementById("lay_entry").style.visibility = "visible";
    document.getElementById("lay_entry").style.display = "inline";
    document.haupt.x.value = mouseX;
    document.haupt.y.value = mouseY;
  }
  function closedialog() {
    document.getElementById('lay_entry').style.visibility = "hidden";
    document.getElementById('lay_entry').style.display = "none";
    document.haupt.message.value = language["label_message"];
    document.haupt.op_title.value = language["label_subject"];
    document.haupt.op_username.value = language["label_name"];
    document.getElementById("rest").innerHTML = "120";
    // force smileys hidden
    target = document.getElementById("smileybox").style;
    target.visibility = "hidden";
    target.display = "inline";
    smiley = 0;
  }
  function smileytoogle() {
    target = document.getElementById("smileybox").style;
    if (smiley==0) {
      target.visibility = "visible";
      target.display = "inline";
      target.left = (mouseX+15)+"px";
      target.top = (mouseY+15)+"px";
      smiley = 1;
    }
    else if(smiley==1) {
      target.visibility = "hidden";
      target.display = "none";
      smiley = 0;
    }
  }
  function rest() {
    var allow = 200;
    chars = document.haupt.message.value.length;
    if(chars>allow) {
      document.haupt.message.value = document.haupt.message.value.substring(0,allow);
      restchars = 0;
    }
    else {
      restchars = allow-chars;
    }
    document.getElementById("rest").innerHTML = restchars;
  }
  function bbc(aTag, eTag) {
    var input = document.forms["haupt"].elements["message"];
    input.focus();
    if(typeof document.selection != "undefined") {
      var range = document.selection.createRange();
      var insText = range.text;
      range.text = aTag + insText + eTag;
      range = document.selection.createRange();
      if (insText.length == 0) {
        range.move('character', -eTag.length);
      }
      else {
        range.moveStart('character', aTag.length + insText.length + eTag.length);
      }
      range.select();
    }
    else if(typeof input.selectionStart != "undefined") {
      var start = input.selectionStart;
      var end = input.selectionEnd;
      var insText = input.value.substring(start, end);
      input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
      var pos;
      if (insText.length == 0) {
        pos = start + aTag.length;
      }
      else {
        pos = start + aTag.length + insText.length + eTag.length;
      }
      input.selectionStart = pos;
      input.selectionEnd = pos;
    }
    else {
      var pos;
      var re = new RegExp('[1]{0,3}$');
      if (!re.test(pos)) pos = input.value.length;
      var insText = prompt(language["please_enter_the_text"]);
      input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
    }
  }

function xhttpinit() {
    if (window.ActiveXObject) {
      try {
        // Internet Explorer 6.x
        xhttp  = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch(e) {
        //  Internet Explorer 5.x
        try {
          xhttp  = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e) {
          xhttp = false;
        }
      }
    }
    else if (window.XMLHttpRequest) {
      // Für Mozilla, Opera und Safari
      try {
        xhttp = new XMLHttpRequest();
      }
      catch (e) {
        xhttp = false;
      }
    }
  }

function makeentry() {
    op_username = encodeURIComponent(document.haupt.op_username.value);
    op_title = encodeURIComponent(document.haupt.op_title.value);
    message = encodeURIComponent(document.haupt.message.value);
    x = encodeURIComponent(document.haupt.x.value);
    y = encodeURIComponent(document.haupt.y.value);

// send XHTTP-Request to save the entry
    if (!xhttp) return xhttperror();
    xhttp.open("POST","index.php?action=make_entry",false);
    xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xhttp.send("op_username="+op_username+"&op_title="+op_title+"&message="+message+"&x="+x+"&y="+y);

if (xhttp.readyState==4 && xhttp.status==200 && xhttp.responseXML!=0) {
      xml = xhttp.responseXML.getElementsByTagName("makeentry")[0];
      errno = parseInt(xml.getElementsByTagName("error")[0].getAttribute("no"));
      if (errno==3) msgbox("r",language["you_entered_no_text"]);
    }

closedialog();
    getpage(0);
  }
  function getpage(page) {
    if (!xhttp) return xhttperror();
    xhttp.open("GET","index.php?action=getpage&page="+page, true);
    xhttp.onreadystatechange = getpage_callback;
    xhttp.send("");
  }
  function getpage_callback() {
    if (xhttp.readyState==4 && xhttp.status==200) {
      target = document.getElementById("entries");
      target.innerHTML = "";
      var list = xhttp.responseXML.getElementsByTagName("entries")[0];
      if (list) {
        // pager
        pages = list.getAttribute("pages");
        cpage = list.getAttribute("cpage");

if (pages==0) pager = " <b>1</b>";
        else {
          pager = "<b>"+language["page"]+":</b>";
          for (a=1; a<=pages; a++) {
            if (a!=cpage) pager += " <a href="javascript:getpage("+a+")">"+a+"</a>";
            else pager += " <b>"+a+"</b>";
          }
        }
        document.getElementById("pager").innerHTML = pager;

...


  1. 0-9 ↩︎