1) If you post two or more articles consecutively things get a little messy. A page refresh usually straightens it out.
2) When you post a new comment it gets displayed below the post you're on. Not supposed to do that. But it goes into the db ok, so a page refresh will display it where it's supposed to be.
Hoping to fix these in the next couple days. Will have to rethink my way through a jumble of perl and AJAX javascript spaghetti routines.
2) When you post a new comment it gets displayed below the post you're on. Not supposed to do that. But it goes into the db ok, so a page refresh will display it where it's supposed to be.
Hoping to fix these in the next couple days. Will have to rethink my way through a jumble of perl and AJAX javascript spaghetti routines.
Looks like the posting comments bug is fixed. Woo hoo!
Bugs 1 and 2 above fixed. Next item: why is there no comment form on a newly inserted thread?
// process new post form
function ajaxProcessNewPost(){
function ajaxRequest(){
var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
for (var i=0; i
return new ActiveXObject(activexmodes[i])
}
catch(e){
//suppress error
}
}
}
else if (window.XMLHttpRequest) // if Mozilla, Safari etc
return new XMLHttpRequest()
else
return false
}
var mypostrequest=new ajaxRequest();
mypostrequest.onreadystatechange=function(){
var commenttextid='commenttext'+mypost;
var newcontent, divcontent;
if (mypostrequest.readyState==4){
if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
togglePostForm();
document.getElementById("edittableformposts").reset();
newcontent = document.createElement("div");
newcontent.innerHTML=mypostrequest.responseText;
divcontent = document.getElementById('postcontent');
divcontent.insertBefore(newcontent,divcontent.firstChild);
// old code document.getElementById('newpost').innerHTML=mypostrequest.responseText;
}
else{ alert("An error has occured making the request");
}
}
}
var mypost=encodeURIComponent(document.getElementById("mypost").value);
var mysite=encodeURIComponent(document.getElementById("mysite").value);
var postedby=encodeURIComponent(document.getElementById("postedby").value);
var poststamp=encodeURIComponent(document.getElementById("poststamp").value);
var page=encodeURIComponent(document.getElementById("page").value);
var pageuserid=encodeURIComponent(document.getElementById("pageuserid").value);
var postercomment=encodeURIComponent(document.getElementById("postercomment").value);
var title=encodeURIComponent(document.getElementById("title").value);
var source=encodeURIComponent(document.getElementById("source").value);
var sourcelink=encodeURIComponent(document.getElementById("sourcelink").value);
var author=encodeURIComponent(document.getElementById("author").value);
var datepublished=encodeURIComponent(document.getElementById("datepublished").value);
var embed=encodeURIComponent(document.getElementById("embed").value);
var text=encodeURIComponent(document.getElementById("text").value);
var parameters = "op=Post&op2=posts&noheader=1&mysite="+mysite+"&mypost="+mypost+"&post="+mypost+"&pageuserid="+pageuserid+"&page="+page+"&postedby="+postedby+"&poststamp="+poststamp+"&postercomment="+postercomment+"&title="+title+"&source="+source+"&sourcelink="+sourcelink+"&author="+author+"&datepublished="+datepublished+"&embed="+embed+"&text="+text;
mypostrequest.open("POST", "/cgi-bin/newpost.cgi", true);
mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
mypostrequest.send(parameters);
}
To fix bug number 1 listed at the top of the thread, had to replace the line (above) marked "// old code" (and a couple others) with the four lines just above it. Then I spent hours trying to debug it and it turned out the div named 'postcontent' had a class designation but not an id. Damn. Kept overlooking that and couldn't figure out why the code wasn't working. Finally spotted the omission, inserted the missing ID tag and presto! It works! (this is my first javascript project and it's pretty tricky coding - for me).
Seems perfectly obvious to me.
Not. ;-)
I think at least a couple of our testers are javascript enabled bit fiddlers. ;-)