Forum Moderators: open
if (parent.border)
{
var clickCount = 0;
var clickSpacing = 4;
var clickCycle = 22;
document.onclick = function()
{
clickCount = ++clickCount % clickCycle // if 22, return to zero
if(clickCount &&!(clickCount % clickSpacing)) // if clickCount is non-zero multiple of clickSpacing
parent.border.location
= 'home/home-border-top-pissed-peasant-'
+ (clickCount/clickSpacing)
+ '.php';
}
}
The new script should support two parameters, person and the click cycle. There are different people to annoy and some have more material then others. However a nice constant is that a sound function is triggered every fourth click. Once the script reaches the clickCycle it loops/resets back to zero.
The tricky part for me is figuring out how to work with parameters to create dynamically generated calls to a different script that handles sound events. This script only needs to call events. Here is an example list...
soundManager.play('peasant1');
soundManager.play('peasant2');
soundManager.play('peasant3');
soundManager.play('peasant4');
soundManager.play('peasant5');
I can have my site use an HTTP query in the script element as my JavaScript files are compressed by PHP and thus I can simply have PHP set echo the person in the script dynamically. I'm really tired right now so this is what I have right now...
- John
function sitepersonality(person, clicks) {
var clickCount = 0;
var clickSpacing = 4;
var clickCycle = 22;
document.onclick = function()
{
clickCount = ++clickCount % clickCycle // if 22, return to zero
if(clickCount &&!(clickCount % clickSpacing)) // if clickCount is non-zero multiple of clickSpacing
{soundManager.play((person)(clickCount/clickSpacing));}
}
}
soundManager.play(person+(clickCount%clickSpacing));
Try that to see what you get...
function sitepersonality() {
var clickCount = 0;
var clickSpacing = 4;
var clickCycle = 22;
var person = peasant;
document.onclick = function()
{
clickCount = ++clickCount % clickCycle // if 22, return to zero
if(clickCount &&!(clickCount % clickSpacing)) // if clickCount is non-zero multiple of clickSpacing
{
soundManager.play('person+(clickCount%clickSpacing)');
}
}
}
Here is what the code looks like in a static test case...
<span onclick="soundManager.play('peasant1');">sound 1</span>
<br />
<span onclick="soundManager.play('peasant2');">sound 1</span>
- John
function sitepersonality() {
var clickCount = 0;
var clickSpacing = 4;
var clickCycle = 22;
var person = peasant;
document.onclick = function()
{
clickCount = ++clickCount % clickCycle // if 22, return to zero
if(clickCount &&!(clickCount % clickSpacing)) // if clickCount is non-zero multiple of clickSpacing
{
soundManager.play(person+(clickCount%clickSpacing));
}
}
}
- John
var clickCount = 0;
var clickSpacing = 4;
var clickCycle = 22;
window.onclick = clickPage;
function clickPage()
{
var person = 'peasant';
clickCount = ++clickCount % clickCycle // if 22, return to zero
if (clickCount &&!(clickCount % clickSpacing)) // if clickCount is non-zero multiple of clickSpacing
{
alert(person+clickCount/clickSpacing);
soundManager.play(person+clickCount/clickSpacing);}
}