The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Watch-Unwatch topics without changing the page

View previous topic View next topic Go down

Watch-Unwatch topics without changing the page

Post by Justice™ on June 2nd 2017, 9:02 pm

Hello Hello ,

I created a small code that makes watching and unwatching topics easier. No more page refresh or time wasting. It should work on any forum version, even if you have modified templates. Sounds interesting? If so, add this JS code with placement on topics:
Code:
$(function() {
    var lang = {
        stop_watch: "Stop watching this topic",
        start_watch: "Watch this topic for replies",
        error_watch: "There was an error while watching the topic",
        error_unwatch: "There was an error while un-watching the topic"
    };
    var l = $("[href*='watch=topic']"),
        d = 0;
    if (!(/t\d+/.test(window.location.pathname) && l.length != 0)) return false;
    l.click(function(e) {
        if (d == 1) return false;
        d = 1;
        l.css({
            "opacity": "0.7",
            "cursor": "not-allowed"
        });
        e.preventDefault();
        $.post(l.attr("href"), function(data) {}).error(function() {
            alert(/unwatch/.test(l.attr("href")) ? lang.error_watch : lang.error_unwatch);
        }).success(function() {
            l.text(/unwatch/.test(l.attr("href")) ? lang.start_watch : lang.stop_watch).attr("href", /unwatch/.test(l.attr("href")) ? l.attr("href").replace("unwatch", "watch") : l.attr("href").replace("watch", "unwatch"));
        }).always(function() {
            d = 0;
            l.css({
                "opacity": "1",
                "cursor": "pointer"
            });
        });
    });
});
You can modify the lang object if you want to modify or translate the texts. If the code is not working, please post your forum's address here so that I can go and see what's wrong. Enjoy!
avatar
Justice™
Forumember

Posts : 483
Reputation : 113
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by Ivan Ivanov on June 4th 2017, 11:13 am

Wolfuryo wrote:If the code is not working, please post your forum's address here so that I can go and see what's wrong.
http://chudofo.forum2x2.ru
avatar
Ivan Ivanov
New Member

Male Posts : 5
Reputation : 2
Language : Russian
Location : Russia

http://chudofo.forum2x2.ru/

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by Justice™ on June 4th 2017, 1:12 pm

@Ivan Ivanov wrote:
Wolfuryo wrote:If the code is not working, please post your forum's address here so that I can go and see what's wrong.
http://chudofo.forum2x2.ru
I made an account on your forum and it works for me. Are you sure you know what this cod e is supposed to do? Go to a topic, find the Watch topic for replies(Следить за ответами в теме in your language) button, click it and it should mark the topic as watched without you having to change the page.
avatar
Justice™
Forumember

Posts : 483
Reputation : 113
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by SarkZKalie on June 4th 2017, 7:41 pm

Keep doing good work, man! Very Happy
avatar
SarkZKalie
Forumember

Male Posts : 575
Reputation : 87
Language : English

http://rotavn.nstars.org/

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by Justice™ on June 4th 2017, 8:47 pm

@SarkZKalie, will do so lol
avatar
Justice™
Forumember

Posts : 483
Reputation : 113
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by BloodDrunk on June 4th 2017, 9:31 pm

Thanks Wolfy, this is nice addition. Smile
avatar
BloodDrunk
Forumember

Posts : 122
Reputation : 4
Language : English

http://www.nfssecrets.tk/

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by Justice™ on June 5th 2017, 5:24 am

Your welcomed, Bloody Smile
avatar
Justice™
Forumember

Posts : 483
Reputation : 113
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by Shek Crowley on June 9th 2017, 11:28 pm

You have a example, please?
avatar
Shek Crowley
Active Poster

Male Posts : 1382
Reputation : 38
Language : Portuguese and English
Location : Brazil

http://www.shiftactif.com/

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by Justice™ on June 10th 2017, 11:57 am

No, I don't. Install the code on your forum, go to a topic, press the Watch this topic button and you'll see how it works.
avatar
Justice™
Forumember

Posts : 483
Reputation : 113
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by SarkZKalie on June 11th 2017, 2:03 pm

Can you write a "Watch and Vote button" script without refresing the whole page? Very Happy Just my idea, a lite version maybe.
avatar
SarkZKalie
Forumember

Male Posts : 575
Reputation : 87
Language : English

http://rotavn.nstars.org/

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by Justice™ on June 11th 2017, 3:22 pm

@SarkZKalie,I'll note that down on my project list Smile
avatar
Justice™
Forumember

Posts : 483
Reputation : 113
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum