mornaistar
User
|
I have this table on a website:
http://img146.imageshack.us/img146/1541/saefsef...
I want this script to be able to calculate average clicks by each ref and put it on a new column , after the "clicks" column.
Also for users with average lower than 2 the row is red and above 7 green.
Anyone can help me on this?
I can give more information if anyone needs.
Thanks alot
|
|
|
Aquilax
Scriptwright
|
Ok I will help you: the average of one value is equal the the value self.
|
|
|
lucideer
Scriptwright
|
Right... I'm assuming you've worded your request wrongly and you want something different. Do you want the overall average of the rows, or is there some other information outside of the table that you need to take in.
Otherwise, I second what Aquilax said.
|
|
|
mornaistar
User
|
maybe I've made a bad explanation.
looking to the image you see this:
the day the user joined my downline, the day they made the last click and the amount of clicks they made during this time.
i need a script to calculate the days between the date they joined and the day they made the last click and after that calculate the average of clicks using Date in days / clicks.
sorry for my bad explanation but my english isn't that good :S
|
|
|
mornaistar
User
|
"average of clicks the users click per day"
|
|
|
mornaistar
User
|
http://img206.imageshack.us/img206/6154/afoiaed...
Here goes another image , this one is made by a software that does the calculation part exactly like i need, in this case , i want the "2.03" to show right near the clicks value in the website table.
like 114 clicks ( 2.03)
|
|
|
Mikado
Scriptwright
|
You know what? Looking at number of your referrals, I think you've spammed a lot of forums with your ref links. Now you're coming to one of such forums to ask for a tool that will help you insult people more effectively. What would you expect?
|
|
|
Aquilax
Scriptwright
|
Ah, I've forgot: asking to make a script from a picture is like asking to reach the moon with a paper sheet, you have to fold it to half only 46 times.
|
|
|
mornaistar
User
|
mikado what are you talking about?
-.- i didn't spammed my ref link , i've bought all my refs with my own money. stop talking about what you don't know.
but as i can see this community is a bit weird when it comes to say useful things.
a moderator or an admin can close this topic.
have a nice day
|
|
|
Aquilax
Scriptwright
|
Hey, how much do you know about users scripts? I think you have no idea but them! Look at the other requests, they post url and html code, you have posted a picture. If you want some help you need to give something more concrete.
|
|
|
lucideer
Scriptwright
|
@Mikado
While it's quite possible that mornaistar is a spammer, it's equally possible that he/she is not. The facts are - mornaistar has not spammed this forum. In actual fact, he hasn't even "spammed" his own profile on this forum
- as far as I can tell, what he's requesting would not assist spamming in any way - it would only help in reading results
Beyond that, please enlighten me as to any evidence as to mornaistars guilt?
@Aquilax:
how much do you know about users scripts?
Well... if he mornaistar knew more about UserScripts, he might not need to post in this (the script requests) forum. He might be able to do it himself. You can't assume people posting here will know how to "post url and html code" as you say. For some people an image is the best way they can communicate.
@mornaistar
You probably won't bother looking at this thread again, but if you do, would I be right in saying what you want to do is: - Divide column 6 (clicks) by number of days since column 3 (days)
- Put that number in column 8
|
|
|
mornaistar
User
|
@lucideer: thanks for the gentle reply, in fact i did not spammed the forum or any other forum in any way, all my refs were bought. I wouldn't go against the TOS in any website.
@Aquilax: i'm sorry if my request wasn't that clean. but i believe posting a url won't help because this website requires an account to be on that table. once again really sorry.
as it's really hard to explain what i want and i'm not sure if i can post the website html in a public way, would it be possible for you to add me on msn so i can explain it more precisely.
arcaiola [@] h o t m a i l DOT com
if you can't add for some reason , please post here something and i will ask admin if i can post here more about the table code itself.
thanks alot
|
|
|
mornaistar
User
|
@lucideer: i know i'm a bit confusing while explaining something sometimes
http://img156.imageshack.us/img156/6852/example...
does this new image help in any way?
i tryed to explain the 2 calculations that i need to get the output on that place.
thanks alot
|
|
|
Aquilax
Scriptwright
|
When you are on the page press ctrl-u or from the menu-->View-->Page Source.
When you have the source you can post it there or if you have an homepage you can put it there.
Without source code is impossible to write a script.
|
|
|
mornaistar
User
|
<table width="100%"><tr><td width="50"> </td><td><table width="100%"><tr><td>YOUR RENTED REFERRALS: 40<table width="100%"><tr><td width="16"> </td><td></td></tr><tr><td> </td><td>AutoPay is the simpliest way to pay for your referrals.
When AutoPay is Enabled, with the first click your referrals make daily, $0.009 will be deducted from your "Rental Balance" or from your "Main Balance". This will pay the referral for one more day and in a full month you'll save 10%.
If any referral doesn't click on a particular day, no amount will be deducted. This way you don't have to pay for them each 30 days.
Enable or disable it as you prefer. No late payments, no hassle.
AutoPay will only work for referrals with 20 or more days left until the next payment date.</td></tr></table></td><td><table><tr><td> </td><td> </td><td> </td><td> </td></tr></table> </td></tr></table></td></tr></table> <jj>0){dd('jo1',1);dd('jo0',0);var ts=d('suss').options[d('suss').selectedIndex].value;if(ts==1) tss=0.05; else if(ts==2) tss=0.30; else tss=0;var t2=(t1*tss);if(t2>0){t2=t2.toFixed(2);d('joq').style.display='';var out='Total amount to pay: $'+t2+'';if(t2>rf){out=''+out+' You do not have enough funds in your Rental Balance
<input>';dd('jop',0);d('job').disabled=true;}else{dd('jop',1);d('job').disabled=false;}d('joq').innerHTML=out;}else{dd('joq',0);dd('jop',0);d('job').disabled=true;}}else{dd('jo0',1);dd('jo1',0);dd('jop',0);d('job').disabled=true;}}function dd(o,O){d(o).style.display=(O==1)?'':'none';}function j0(){var ts=d('suss').options[d('suss').selectedIndex].value;if(ts>0){d('job').disabled=true;d('jon').innerHTML=' Processing... Please wait. ';document.jj.action=(ts==1)?'/?u=c&s=r_rec':'/?u=c&s=r_m1m';return true;}else{return false;}}function j2(){var x=d('jjsa').checked;for (a=0;a<jj><table><tr><td><table><tr><td> </td><td>Referral</td><td>Your referral since </td><td>Next Payment in</td><td>Last click</td><td>Clicks</td><td> <input /></td></tr><style>.l1,.l2{border-top:1px solid #aaaaaa;border-left:1px solid #bbbbbb;padding-left:3px;padding-right:3px;}.z{border-left:none;}.w{text-align:right;color:#666666;}.im{cursor:pointer;cursor:hand;}.l1{background-color:#ffffff;}.l2{background-color:#e7e7e7;}.i{color:#aaaaaa;font-style:italic;}.x{border-top:none;font-size:1px;height:1px;}</style></table><form></form><tr><td class="l1 z w">1</td><td class="l1">R3065690 <td class="l2">2008/08/18 at 22:34 </td><td class="l2">31 days, 1 hours, 59 minutes </td><td class="l2">Yesterday </td><td class="l2">18 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">3</td><td class="l1">R2670264 <td class="l2">2008/08/13 at 19:18 </td><td class="l2">33 days, 1 hours, 59 minutes </td><td class="l2">Today </td><td class="l2">32 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">5</td><td class="l1">R2626376 <td class="l2">2008/08/13 at 19:18 </td><td class="l2">32 days, 1 hours, 59 minutes </td><td class="l2">Yesterday </td><td class="l2">24 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">7</td><td class="l1">R2198026 <td class="l2">2008/08/13 at 19:18 </td><td class="l2">31 days, 1 hours, 59 minutes </td><td class="l2">Yesterday </td><td class="l2">28 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">9</td><td class="l1">R590580 <td class="l2">2008/08/13 at 19:18 </td><td class="l2">32 days, 1 hours, 59 minutes </td><td class="l2">Today </td><td class="l2">27 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">11</td><td class="l1">R1589718 <td class="l2">2008/08/02 at 21:56 </td><td class="l2">26 days, 20 hours, 6 minutes </td><td class="l2">Today </td><td class="l2">51 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">13</td><td class="l1">R2492752 <td class="l2">2008/07/31 at 13:25 </td><td class="l2">27 days, 20 hours, 6 minutes </td><td class="l2">Today </td><td class="l2">56 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">15</td><td class="l1">R2281216 <td class="l2">2008/07/31 at 13:25 </td><td class="l2">25 days, 20 hours, 6 minutes </td><td class="l2">Yesterday </td><td class="l2">51 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">17</td><td class="l1">R1046708 <td class="l2">2008/07/31 at 13:25 </td><td class="l2">29 days, 20 hours, 6 minutes </td><td class="l2">Today </td><td class="l2">55 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">19</td><td class="l1">R335220 <td class="l2">2008/07/31 at 13:25 </td><td class="l2">24 days, 20 hours, 6 minutes </td><td class="l2">Yesterday </td><td class="l2">46 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">21</td><td class="l1">R730256 <td class="l2">2008/07/21 at 14:59 </td><td class="l2">24 days, 5 hours, 40 minutes </td><td class="l2">Yesterday </td><td class="l2">74 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">23</td><td class="l1">R1363842 <td class="l2">2008/07/15 at 17:02 </td><td class="l2">25 days, 5 hours, 40 minutes </td><td class="l2">Today </td><td class="l2">86 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">25</td><td class="l1">R1321216 <td class="l2">2008/07/10 at 22:59 </td><td class="l2">26 days, 5 hours, 40 minutes </td><td class="l2">Today </td><td class="l2">93 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">27</td><td class="l1">R915500 <td class="l2">2008/07/10 at 22:59 </td><td class="l2">30 days, 5 hours, 40 minutes </td><td class="l2">Today </td><td class="l2">114 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">29</td><td class="l1">R186506 <td class="l2">2008/07/10 at 22:59 </td><td class="l2">25 days, 5 hours, 40 minutes </td><td class="l2">Yesterday </td><td class="l2">100 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">31</td><td class="l1">R1605100 <td class="l2">2008/06/27 at 03:44 </td><td class="l2">32 days, 10 hours, 25 minutes </td><td class="l2">2008/08/21 </td><td class="l2">109 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">33</td><td class="l1">R1218156 <td class="l2">2008/06/27 at 03:44 </td><td class="l2">41 days, 10 hours, 25 minutes </td><td class="l2">Yesterday </td><td class="l2">132 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">35</td><td class="l1">R959708 <td class="l2">2008/06/27 at 03:44 </td><td class="l2">44 days, 10 hours, 25 minutes </td><td class="l2">Yesterday </td><td class="l2">120 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">37</td><td class="l1">R507362 <td class="l2">2008/06/27 at 03:44 </td><td class="l2">38 days, 10 hours, 25 minutes </td><td class="l2">2008/08/21 </td><td class="l2">127 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><tr><td class="l1 z w">39</td><td class="l1">R24924 <td class="l2">2008/06/27 at 03:44 </td><td class="l2">36 days, 10 hours, 25 minutes </td><td class="l2">Yesterday </td><td class="l2">101 </td><td class="l2"> <input /></td></tr><tr><td class="l2 z x"></td></tr><41></table><table><tr><td> What do you want to do with the selected referrals?<select><option>--- Please select an option ---</option><option>I want to recycle them</option><option>I want to pay to keep them for 30 more days</option></select> <input /> </td></tr></table> Some usernames may be masked like R1245678 if the referral has selected not to show his/her username. By default, rented referrals have their usernames HIDDEN. <td> </td><tr></tr><td height="55"></td>
|
|
|
lucideer
Scriptwright
|
Well.... I've no way of testing any code here... so. If this doesn't work, you'll have to give debugging a go yourself.
(function(){
// get an array containing a reference to the 1st cell in each row
var rowRefs=document.evaluate('//td[contains(@class,"l1 z w")]',document,null,6,null);
// initialise an object call table that will contain the table
var table={'row':[{'cell':[]}]};
// loop over our "rowRefs" array
for(var i=0,ii=rowRefs.snapshotLength;i<ii;++i){
var j=1,table.row[i].cell[0]=rowRefs.snapshotItem(i); // set 1st cell in "table" obj to 1st cell
while(currCell=table.row[i].cell[0].nextSibling){ // traverse across the DOM of each row
if(currCell.nodeType==1){
table.row[i].cell[j]=currCell; //store each cell in our "table" obj
j++; // advance counter
}
}
}
// all the above code gets an object "table" containing ONLY cells of each row, no textNodes, etc.
for(var i=0,ii=table.row.length;i<ii;++i){ // loop over our "table" obj
var startdate=table.row[i].cell[2].textContent.substr(0,10); // third cell has date
var today=new Date(); // todays date
var diff=Date.parse(today)-Date.parse(startdate); //get the difference in seconds
diff=diff/86400000; // get the difference in days
var average=row.childNodes[5]; //sixth cell
var newCell=document.createElement('td');
newCell.appendChild(document.createTextNode(average));
table.row[i].appendChild.insertBefore(newCell,table.row[i].cell[5])
}
})();
|
|
|
mornaistar
User
|
thanks alot, i will go test it and give feedback =)
|
|
|
anonymous_user
User
|
I found this topic usefull as I "want" the same thing as described by mornaistar, I think he sums up the thing really well with the last image.
Add a column, titled average, with the value regarding today minus the day in the table and divide it by the number of clicks.
Thanks lucideer for your code, since the last time I coded something was about 10 years ago.
So, i did run the script and came with this error
table.row[i].cells[0]=rowRefs.snapshotItem(i); // table.row[i].cells is undefined
and...
var rowRefs=document.evaluate('//td[contains(@class,"l1 z w")]',document,null,6,null); // there are more classes than l1 z w, they are four in total
/*
class="l1 z x"
class="l1 z w"
class="l2 z x"
class="l2 z w"
*/
So if anyone could help, I will also post progress as I study and read info about coding scripts.
Thanks
|
|
|
anonymous_user
User
|
Ok, I'm stuck.
I cannot fix the error I described in the last post and I also don't know how to include all the 4 class when using document.evaluate, i'm not good at regexp.
Could someone help? Please.
|
|
|
gollum
Scriptwright
|
Without a link it's hard to test, but maybe you could make the @class lookup more general
//td[contains(@class,"l1 z")] | //td[contains(@class,"l2 z")]
or
//td[contains(@class,"z x")] | //td[contains(@class,"z w")]
table.row[i].cells is undefined I think the plural .cells should be .cell
|
|
|
lucideer
Scriptwright
|
As gollum says it really is like clutching in the dark without a link to test. That code I wrote above is completely untested on anything so even though I've now corrected the .cell .cells typo (thanks gollum), there could be more problems with it.
@georgie
I know there's more classes than that one but we only want to get at certain cells. The idea is simply to get a reference to one of them ("l1 z w") and work forward from that with DOM traversal (.nexSibling). Sorry I should really have explained the method more clearly. I'll actually go up now and comment the script a little better.
P.S. document.evaluate uses xpath expressions, not regexp. They're very very simple to figure out, I'm also clueless when it comes to regexp.
|
|
|
anonymous_user
User
|
I've just read your answers and going to test out the changes.
About you being able to test it for yourself, as this is a https page with login, is it enough if I save a static html version of one page and put it on my webserver so you can test it?
I'll check this topic later, after work.
Thanks for your time.
|