Automatic counter

That’s great. @spamless. Triggering it wit the spacebar is a cool idea. Well done for finding the code, and even more so for making it work! :wink: :+1:
BTW, @elusien is on vacation now (on a nice cruise :heart_eyes:) so if he doesn’t reply, that’s why.

PS would it be possible for you to post the complete code of the counter, including the JavaScript? I’m unsure where to add your extra code into the original… You could post it as a .txt file maybe. Thanks!

1 Like

Sure, I can make it available temporarily. This link shares it through the end of October 2022. Password is “4shotcut”.

I do some hobby coding myself and I know that, while this works, it’s embarrassing to present an inefficient algorithm that adds a near-duplicate function just to change the event input method. But I don’t know enough yet about HTML/CSS coding to fix what I see as deficiencies in the direction of elegance. So I see this as a patchwork solution until the “master” returns. :slight_smile:

Btw, I’m on vacation for a week as of tomorrow myself.

2 Likes

Thank you, @spamless, I downloaded the code. It works fine. No problem with the code for me - I’m not good at understanding JavaScript. Yet. I’m trying to learn all the time … The main thing is - it works! Have a good vacation.

Indeed, @elusien is awesome!

1 Like

This is great!
I’m a little surprised though @spamless. You make it look almost effortless to do 67 push-ups, but you get tired pressing a mouse button 100 times? :blush:

By the way, I think your new codes may need one other small improvement: Limiting the counter to one increment for each pressing of the space bar.
If you leave your finger on the space bar a fraction of a second too long, the counter will go up 2 steps instead of just one.

There is probably a fix for that. Let’s activate the Elusien Signal so he can check this when he’s back from his vacations. :smiley:

2 Likes

:rofl: :rofl:

1 Like

Aw, shucks. Well, but on push-up day this week, which was Tuesday, I did three sets of 72! Sixty-seven is so … last week! :wink: Actually, I’ve been working on the new video for hours instead of packing for my flight tomorrow. I’ll upload it to my YouTube channel in a bit. I’m trying out a new effect, too.

I’ll look forward to his master hand on that. This also happened to me with the mouse clicks, by the way. Sometimes I’d get a double-click and ruin the take. A solution would be good.

Loved that Batsignal!

2 Likes

No need to activate the signal - I’ve located his ship. It’s the blue one :wink:


Seriously. It’s this actual ship:

…and this is the route. Nice!

2 Likes

Awesome!

You seem well informed mister B… I mean mister JonRay. :face_with_monocle:
Any affiliation with the MI6? :man_detective:

Photoshop_sObq4qx7Rj

2 Likes

LOL! :rofl: :rofl:

No, it was easy. Elementary, dear Watson… :grin: @elusien gave his itinerary … Valetta, Taranto, Corfu… so a quick Google search revealed all …https://www.pocruises.com/find-a-cruise/A220B/A220B.
Then I typed the ship name, Azura, into a cruise tracking site. Ta- DA!

1 Like

PS that Sean Connery flute mockup is awesome! Did you do that, @musicalbox? If so, Bravo!

2 Likes

Well, excellent detective work. No one is ever safe lol :smile:

Yep! Just a bit of Photoshop magic and a little help from Google where I found these two photos:

Photoshop_gUz6e74W4g

2 Likes

Excellent Photoshop work @musicalbox. I couldn’t see the join! The guy on the left is Emmanuel Pahud. Swiss flutist. World-renowned and well known in flute playing circles, but his name is probably not too well known by the general public I would imagine.

Who’s the guy on the right? :smile: :rofl:

1 Like

Guess what? I’m back from my trip, which was excellent but I’m now self-isolating because of a mild bout (so far) of COVID.

Yes, there is a fix for that. Just put this one line of code as the first statement in the fuction:

if (e.repeat) { return; } // Don't update the counter if the key is being repeated.

1 Like

I’ll try that, thank you!

Glad you enjoyed your cruise. But I’m sorry you contracted the virus. Hope you get better soon.

1 Like

Thanks! I’m back from traveling and will try that now. I’m sorry to hear you got covid! We just got off the plane after an 11-hour ride, so I’ll relax in another 2-3 days, I guess.

Hi @elusien, good to see you back. Delighted you had a good trip but a shame you have caught Covid. Get well soon. As you can see from a few posts above, I was able to track your ship. Amazing that I could do that, but not great for your privacy… :upside_down_face: Looking back I hope it was OK to track you like that …
Anyway looking at your destinations no wonder you had a good time…

2 Likes

I figured out how to make my edits to @Elusien’s code better conform to my wish for a modicum of polish. The behavior is the same, but my function adding the spacebar alternative now doesn’t embarrass me so much. :slight_smile: Elusien’s fix stopping the repeating spacebar key is incorporated.

The function area now looks like this:

    function refactored(c, e) {
        if (e.repeat) { return; } // Don't update the counter if the key is being repeated.
        if (c == "click" || (c == "key" && e.keyCode == 32)) {
        // add your code here.
			span.textContent = (++count).toString().padStart(ndigits, '0');
            if (count === 1) { span_style.display = 'inline'; }
            if (beep_on_click) { beep_sound.play();}
            e.preventDefault();
            }
		};

     main.onclick = function(e){ refactored("click", e);};

     document.onkeydown = function(e){ refactored("key", e);};

I’ve removed (I think) the expiration on my shared link. The password remains “4shotcut”.
Here’s the updated link that shouldn’t expire.

1 Like

Two points to note: the keyCode property is deprecated. This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. You should use the key property instead.

Also, you don’t need to supply the “c” parameter as the type of event is stored in the event object itself as the property type. Hence the code:

function increment_count(e) {
	if (e.repeat) { return; } // Don't update the counter if the key is being repeated.
	if (e.type == "click" || (e.type == "keydown" && e.key == " ")) {
	// add your code here.
		span.textContent = (++count).toString().padStart(ndigits, '0');
		if (count === 1) { span_style.display = 'inline'; }
		if (beep_on_click) { beep_sound.play();}
		e.preventDefault();
	}
}
["click", "keydown"].forEach(function(e){ window.addEventListener(e, increment_count); });
1 Like

Oh, but that is awesome. Thank you very much! Also great to know about the deprecation of the keyCode property and the parameter statement.

I’ve replaced the function code in my shared document with this emendation from you, of course. (Link and password remain as posted in my reply above of Oct 16, '22.)