Registered: March 14, 2007 | Reputation: | Posts: 1,029 |
| Posted: | | | | The following little tool analyzes the participation of users in a given topic on this forum. You can save the code below to an HTML file, call it up in your browser, enter an Invelos topic number and get the number of posts in that topic for each participating user, sorted both by name and by count, along with percentage. Please note: Only tested with IE, don't know if it works with other browsers.On Windows XP and newer, you have to unblock the created HTML file to enable scripting.You must be logged into the Invelos forums, the script uses the currently active login.The script calls up all topic pages, so this may take a while.In order to get unbiased results, you have to remove any forum blocks.Some of you may remember this from a while ago. As was pointed out to me, the old script no longer produced correct results with the changed forum layout. That has been fixed. I decided to not resurrect the old thread, because it got somewhat derailed. File TopicPostsPerUser.html: Quote:
<HTML> <!-- *** Show topic post count per user *** Copyright (c) 2007-2009 Matthias Wolf, Germany AKA goodguy
History: 15-Apr-2009 - Updated for forum layout changes. 29-Sep-2007 - Created. --> <HEAD> <TITLE>Topic Post Count Per User</TITLE> <STYLE type="text/css"> </STYLE> <SCRIPT language=javascript>
var g_oXmlHttp; var g_nPageGet; var g_nPageDone; var g_aStats; var g_oByUser;
function errText(nErrNo, szErrDesc) { // Simple error text if (szErrDesc != null && szErrDesc != "") return szErrDesc; var n = nErrNo; if (n < 0) n = n + 0xFFFFFFFF + 1; return "Error " + nErrNo + " (0x" + n.toString(16) + ")"; }
function errHandler(e) { // Simple error handler alert(errText(e.number, e.description)); }
function pageGetNext() { // Get next topic page g_nPageGet++; try { idResult.innerText = "Querying page " + g_nPageGet + "..."; g_oXmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); g_oXmlHttp.onreadystatechange = xmlhttp_onreadystatechange; g_oXmlHttp.open("GET", lnkTopic.href + "&pageNum=" + g_nPageGet); g_oXmlHttp.send(); } catch (e) { errHandler(e) }; }
function pageAnalyze(szHtml) { // Analyzes page and returns true if there are more pages var re, m, o, sz; try { re = /<TD>\s*<A\s+HREF="\/UserProfile\.aspx\?Alias=(.*?)"/ig; while ((m = re.exec(szHtml)) != null) { sz = m[1]; o = g_oByUser[sz]; if (o == null) { o = { user: sz, count: 0 }; g_oByUser[sz] = o; g_aStats.push(o); } o.count++; } return (szHtml.search(/<IMG src="\/images\/next\.gif" border=0><\/A>/i) >= 0); } catch (e) { errHandler(e) }; return false; }
function sortByUser(o0, o1) { // Array sort callback return o0.user.localeCompare(o1.user); }
function sortByCount(o0, o1) { // Array sort callback var n = o1.count - o0.count; if (n != 0) return n; return o0.user.localeCompare(o1.user); }
function showResults() { // Create result tables var szTable; var aOut, aFn; var i, k, n; try { szTable = "<TABLE border=1><COLGROUP>" + "<COL><COL span=2 align=right></COLGROUP>" + "<TR><TH>User</TH><TH>Count</TH><TH>Percent</TH></TR>"; n = 0; for (i = 0; i < g_aStats.length; i++) n += g_aStats[i].count; aOut = new Array(); aFn = new Array(sortByCount, sortByUser); aOut.push("<TABLE border=0>" + "<TR><TH>By Count</TH><TH> </TH><TH>By User</TH></TR><TR>"); for (i = 0; i < aFn.length; i++) { g_aStats.sort(aFn[i]); if (i != 0) aOut.push("<TD> </TD>"); aOut.push("<TD>" + szTable); for (k = 0; k < g_aStats.length; k++) { o = g_aStats[k]; aOut.push("<TR><TD>" + o.user + "</TD><TD>" + o.count + "</TD><TD>" + Math.round(o.count * 100 / n) + " %</TD></TR>"); } aOut.push("</TABLE></TD>"); } aOut.push("</TR></TABLE>"); idResult.innerHTML = aOut.join("\n"); } catch (e) { errHandler(e) }; }
function xmlhttp_onreadystatechange() { // Fires on data retrieval try { if (g_oXmlHttp.readyState != 4) return; if (g_nPageGet == g_nPageDone) return; // Avoid multiple rs==4 g_nPageDone = g_nPageGet; if (g_oXmlHttp.status != 200) throw Error("HTTP Error " + g_oXmlHttp.status + " " + g_oXmlHttp.statusText); // Avoid recursion by putting next call outside event response if (pageAnalyze(g_oXmlHttp.responseText)) window.setTimeout(pageGetNext, 10); else window.setTimeout(showResults, 10); } catch (e) { errHandler(e) }; }
function frm1_onsubmit() { // Process form submit locally try { if (frm1.edtTopic.value == "") throw Error("Please enter a topic ID." + " See &topicID= in your browser's address bar."); lnkTopic.href = "http://www.invelos.com/Forums.aspx?" + "task=viewtopic&topicID=" + frm1.edtTopic.value; lnkTopic.innerText = lnkTopic.href; idResult.innerText = "Querying data..."; g_nPageGet = g_nPageDone = 0; g_aStats = new Array(); g_oByUser = {}; pageGetNext(); } catch (e) { errHandler(e) }; return false; }
</SCRIPT> </HEAD> <BODY> <B>Topic Post Count Per User</B><BR> Copyright (c) 2007-2009 Matthias Wolf, Germany AKA goodguy <HR> <FORM id=frm1 onsubmit="return frm1_onsubmit()"> Enter topic ID: <INPUT type=text id=edtTopic> <INPUT type=submit value="Start"> </FORM> Topic URL: <A id=lnkTopic href=""></A> <HR> <DIV id=idResult> </DIV> </BODY> </HTML>
| | | Matthias | | | Last edited: by goodguy |
|
Registered: March 15, 2007 | Reputation: | Posts: 5,459 |
| Posted: | | | | Thanks for the updated code, but I daresn't run it for fear of what the results will be! PS out of green arrows for today, you can have one tomorrow. | | | Last edited: by northbloke |
|
Registered: May 19, 2007 | Reputation: | Posts: 5,917 |
| Posted: | | | | I was wondering a week or so ago about the percentage of total posts a person has made. |
|
Registered: March 14, 2007 | Reputation: | Posts: 1,022 |
| Posted: | | | | Thanks Matthias, very interesting results it delivers | | | |
|
Registered: March 14, 2007 | Reputation: | Posts: 1,029 |
| Posted: | | | | Quoting Dr. Killpatient: Quote: I was wondering a week or so ago about the percentage of total posts a person has made. Well you can just add up the total number of posts on the index page (e.g. by copying the forum overview table into an Excel sheet). In your case it's almost 2% (3482 / 178386) now. | | | Matthias |
|
Registered: March 14, 2007 | Reputation: | Posts: 17,804 |
| Posted: | | | | Thanks for this nifty tool! | | | Thorsten |
|
Registered: March 14, 2007 | Reputation: | Posts: 1,022 |
| Posted: | | | | Quoting goodguy: Quote:
Well you can just add up the total number of posts on the index page (e.g. by copying the forum overview table into an Excel sheet). In your case it's almost 2% (3482 / 178386) now. I cannot seem to replicate this, I was wondering who the top 10 posters were overall? | | | |
|
Registered: March 14, 2007 | Reputation: | Posts: 1,029 |
| Posted: | | | | Quoting richierich: Quote: Quoting goodguy:
Quote:
Well you can just add up the total number of posts on the index page (e.g. by copying the forum overview table into an Excel sheet). In your case it's almost 2% (3482 / 178386) now. I cannot seem to replicate this, I was wondering who the top 10 posters were overall? No, it doesn't help you find the overall top posters, it just a quick way of adding up the total post count (which may not be entirely exact, if you don't have access to all forums). Then you can calculate the percentage for a given person, which is what Dr. Killpatient was asking. | | | Matthias | | | Last edited: by goodguy |
|