Toubsen: OpenPinboard

Beitrag lesen

...

// build messagebox
        var box = "";
        for (i=0; i<list.getElementsByTagName("item").length; i++) {
          item = list.getElementsByTagName("item")[i]
          id = item.getElementsByTagName("id")[0].innerHTML;
          from = item.getElementsByTagName("from")[0].innerHTML;
          title = item.getElementsByTagName("title")[0].innerHTML;
          text = item.getElementsByTagName("text")[0].innerHTML;
          x = item.getElementsByTagName("x")[0].innerHTML;
          y = item.getElementsByTagName("y")[0].innerHTML;
          time = item.getElementsByTagName("time")[0].innerHTML;

box += "<div id="lay"+id+"" class="note" style="left:"+x+"px; top:"+y+"px; z-index:"+(i+1)+"; max-width: 250px;" onmousedown="press('lay"+id+"')" onmouseup="unpress('lay"+id+"')" onMousemove="checkMouse(this)" onclick="admindo(this)">";
          box += "<table border="0" cellspacing="0" cellpadding="0">";
          box += "<tr>";
          box += "<td style="width: 20px; height: 20px; background-image: url(images/paper/style"+style+"/tl.gif)"></td>";
          box += "<td style="height: 20px; background-image: url(images/paper/style"+style+"/mt.gif)"></td>";
          box += "<td style="width: 20px; height: 20px; background-image: url(images/paper/style"+style+"/tr.gif)"></td>";
          box += "</tr>";
          box += "<tr>";
          box += "<td style="width: 20px; background-image: url(images/paper/style"+style+"/ml.gif)"></td>";
          box += "<td style="background-image: url(images/paper/style"+style+"/mm.gif)">";
          box += "<div style="font-weight: bold; font-size: smaller;">"+title+"</div>";
          box += "<div style="font-size: x-small">"+text+"</div><br />";
          box += "<div style="font-size: x-small;">"+from+" ("+time+")</div>";
          box += "</td>";
          box += "<td style="width: 20px; background-image: url(images/paper/style"+style+"/mr.gif)"></td>";
          box += "</tr>";
          box += "<tr>";
          box += "<td style="width: 20px; height: 20px; background-image: url(images/paper/style"+style+"/bl.gif)"></td>";
          box += "<td style="height: 20px; background-image: url(images/paper/style"+style+"/mb.gif)"></td>";
          box += "<td style="width: 20px; height: 20px; background-image: url(images/paper/style"+style+"/br.gif)"></td>";
          box += "</tr>";
          box += "</table>";
          box += "</div>";
        }
        target.innerHTML = box;
      }
    }
  }
  function tlogindialog() {
    if (logindialog==0) {
      document.getElementById("adminlogin").style.visibility = "visible";
      document.admin.password.focus();
      logindialog = 1;
    }
    else if (logindialog==1) {
      document.getElementById("adminlogin").style.visibility = "hidden";
      logindialog = 0;
    }
  }
  function adminlogin() {
    if (!xhttp) return xhttperror();
    password = document.admin.password.value;
    document.admin.password.value = "";
    document.admin.password.blur();
    tlogindialog();
    xhttp.open("POST","index.php?action=login", true);
    xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xhttp.onreadystatechange = adminlogin_callback;
    xhttp.send("password="+password);

return false // have to return FALSE that the form will not be send
  }
  function adminlogin_callback() {
    if (xhttp.readyState==4 && xhttp.status==200 && xhttp.responseXML!=0) {
      xml = xhttp.responseXML.getElementsByTagName("admin")[0];

errno = parseInt(xml.getElementsByTagName("error")[0].getAttribute("no"));
      if (errno==1) msgbox("r",language["wrong_password"]);
      else if (errno==0) {
        admin = true;
        msgbox("g",language["youre_admin_now"]);
        target = document.getElementById("adminlink");
        target.innerHTML = language["admin_logout"];
        target.setAttribute("href","javascript:adminlogout()");
        target2 = document.getElementById("admin").style;
        target2.display = "inline";
        target2.visibility = "visible";
      }
    }
  }
  function adminlogout() {
    target = document.getElementById("adminlink");
    target.innerHTML = language["admin_login"];
    target.setAttribute("href","javascript:tlogindialog()");
    target2 = document.getElementById("admin").style;
    target2.display = "none";
    target2.visibility = "hidden";
    admin = false;
    adminaction = "";
    msgbox("g",language["youre_logged_out"]);
  }
  function admint(action) {
    if (adminaction==action) {
      document.getElementById(adminaction).style.border = "0px solid #000000";
      action = "";
    }
    else if (action!="") {
      document.getElementById(action).style.border = "1px solid #000000";
    }
    adminaction = action;
  }
  function admindo(element) {
    id = element.getAttribute("id").substr(3);
    if (adminaction!="") {
      if (!xhttp) return xhttperror();
      usedaa = adminaction;
      if (admin==false) {
        msgbox("r",language["youre_not_admin"])
        return false;
      }
      if (adminaction=="del") {
        xhttp.open("POST","index.php?action=del", false);
        xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        xhttp.send("password="+password+"&id="+id);
        if (xhttp.readyState==4 && xhttp.status==200 && xhttp.responseXML!=0) {
          xml = xhttp.responseXML.getElementsByTagName("admin")[0];
          errno = parseInt(xml.getElementsByTagName("error")[0].getAttribute("no"));
          if (errno==1) msgbox("r",language["wrong_password"]);
          else if (errno==2) msgbox("r",language["mysql_error"]);
          else if (errno<0 || errno>2) msgbox("r",language["unknown_error"]);
        }
      }
      getpage(0);
    }
  }
  function admindo_callback() {

}
  function msgbox(mode,text) {
    if (mode=="r") {
      title = language["error"];
      img = "images/error.png";
    }
    else if (mode=="g") {
      title = language["information"];
      img= "images/ok.png";
    }
    else return false;

js = "document.getElementById('errors').innerHTML = ''";
    text = "<table border=0 class="warning" id="message" style="z-index: "+(pp+4)+";"><tr><td width=50 rowspan=2 style="text-align: center; vertical-align: middle;"><img src=""+img+"" alt=""+title+""></td><th width=250 style="text-align: center; vertical-align: middle;">"+title+"</th></tr><tr><td style="text-align: left; vertical-align: middle; font-size: small;">"+text+"</td></tr><tr><td style="text-align: center; vertical-align: middle;" colspan=2 width="100%"><input type="button" value="  OK  " onClick=""+js+""></td></tr></table>";
    document.getElementById("errors").innerHTML = text;
    return true;
  }
  function xhttperror() {
    msgbox("r",language["xhttp-error"]);
    return false;
  }
//-->
</script>