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 : 517
Reputation : 119
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 : 517
Reputation : 119
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 : 581
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 : 517
Reputation : 119
Language : Romanian and English

http://board.realmsn.com

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 : 517
Reputation : 119
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 : 1422
Reputation : 40
Language : pt_BR, EN
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 : 517
Reputation : 119
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 : 581
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 : 517
Reputation : 119
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by RedCedar on October 7th 2017, 10:28 pm

Hi Justice

Problem on my forum is that topic page does not show new posts unless the page is manually refreshed.

Tried several free Auto-refresh browser extensions.
They key on URL and do not work for this purpose because URL changes with each new post as follows:
starts out with .../.../MyTopic then after receiving a reply it's changed to .../.../MyTopic/#nnn where nnn=number of posts on the topic.

I'm looking for a fix for this.

Regards
RedCedar
avatar
RedCedar
New Member

Posts : 1
Reputation : 1
Language : English

http://alg2mail@gmail.com

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by Justice™ on October 8th 2017, 5:21 pm

Hello,

Your post does not seem topic-related. If you want help with any problem, you should open a new topic.
avatar
Justice™
Forumember

Posts : 517
Reputation : 119
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by Luffy on October 8th 2017, 5:47 pm

Keep up the good work man! Great code!





avatar
Luffy
Manager
Manager

Male Posts : 4825
Reputation : 486
Language : Greek, English
Location : Greece

http://vibes.forumotion.com/

Back to top Go down

Re: Watch-Unwatch topics without changing the page

Post by Van-Helsing on October 9th 2017, 12:16 am

Perfect Job! Smile
avatar
Van-Helsing
Hyperactive

Male Posts : 2324
Reputation : 92
Language : English, Greek

http://helpgr.forumgreek.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