Watch-Unwatch topics without changing the page

Go down

Watch-Unwatch topics without changing the page Empty Watch-Unwatch topics without changing the page

Post by Guest 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
Guest
Guest


Back to top Go down

Watch-Unwatch topics without changing the page Empty 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
Ivan Ivanov
Ivan Ivanov
Forumember

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

http://chudofo.forum2x2.ru/

Back to top Go down

Watch-Unwatch topics without changing the page Empty Re: Watch-Unwatch topics without changing the page

Post by Guest 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
Guest
Guest


Back to top Go down

Watch-Unwatch topics without changing the page Empty 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


Watch-Unwatch topics without changing the page Sarkzk10
SarkZKalie
SarkZKalie
Support Moderator
Support Moderator

Male Posts : 1053
Reputation : 177
Language : English

https://www.rotavn.xyz/

Back to top Go down

Watch-Unwatch topics without changing the page Empty Re: Watch-Unwatch topics without changing the page

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

@SarkZKalie, will do so lol
avatar
Guest
Guest


Back to top Go down

Watch-Unwatch topics without changing the page Empty Re: Watch-Unwatch topics without changing the page

Post by Guest on June 5th 2017, 5:24 am

Your welcomed, Bloody Smile
avatar
Guest
Guest


Back to top Go down

Watch-Unwatch topics without changing the page Empty Re: Watch-Unwatch topics without changing the page

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

You have a example, please?
Shek
Shek
Active Poster

Male Posts : 1593
Reputation : 45
Language : pt_BR, EN
Location : Brazil

http://www.shiftactif.com/

Back to top Go down

Watch-Unwatch topics without changing the page Empty Re: Watch-Unwatch topics without changing the page

Post by Guest 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
Guest
Guest


Back to top Go down

Watch-Unwatch topics without changing the page Empty 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.


Watch-Unwatch topics without changing the page Sarkzk10
SarkZKalie
SarkZKalie
Support Moderator
Support Moderator

Male Posts : 1053
Reputation : 177
Language : English

https://www.rotavn.xyz/

Back to top Go down

Watch-Unwatch topics without changing the page Empty Re: Watch-Unwatch topics without changing the page

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

@SarkZKalie,I'll note that down on my project list Smile
avatar
Guest
Guest


Back to top Go down

Watch-Unwatch topics without changing the page Empty 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
RedCedar
RedCedar
New Member

Posts : 1
Reputation : 1
Language : English

http://alg2mail@gmail.com

Back to top Go down

Watch-Unwatch topics without changing the page Empty Re: Watch-Unwatch topics without changing the page

Post by Guest 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
Guest
Guest


Back to top Go down

Watch-Unwatch topics without changing the page Empty Re: Watch-Unwatch topics without changing the page

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

Keep up the good work man! Great code!
TheCrow
TheCrow
Energetic

Male Posts : 6096
Reputation : 699
Language : Greek, English
Location : Cyprus, Greece

https://www.inforumgr.com

Back to top Go down

Watch-Unwatch topics without changing the page Empty Re: Watch-Unwatch topics without changing the page

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

Perfect Job! Smile
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2425
Reputation : 115
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Back to top


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