The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

A script for all closed topics

2 posters

Go down

Solved A script for all closed topics

Post by Mati September 29th 2015, 3:24 pm

I want a script to wright on all closed topics ex: "This topic is now closed to further replies."


Last edited by Mati on September 29th 2015, 5:34 pm; edited 1 time in total
Mati
Mati
Hyperactive

Posts : 2020
Reputation : 330
Language : HTML, CSS & JavaScript
Location : Forum Services

https://forumservice.forumotion.com/

Back to top Go down

Solved Re: A script for all closed topics

Post by Ange Tuteur September 29th 2015, 3:52 pm

Hi @Mati,

Try the following :
Go to Modules > JS codes management > Create a new script

Placement : In the topics
Code:
$(function() {
  var locked = 'http://i21.servimg.com/u/f21/16/89/96/68/locked10.png',
      message = 'This topic is now closed to further replies.',
      reply = $('.i_reply')[0],
      main = document.getElementById('main-content'),
      node;

  if (reply && reply.src == locked) {
    node = document.createElement('DIV');
    node.className = 'notice_locked';
    node.innerHTML = message;
    main && main.insertBefore(node, main.firstChild);
  }
});

There's various data at the top that you can modify :

locked : The URL of your locked image
message : The message you want to display

To style the notice you can use the .notice_locked classname.
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: A script for all closed topics

Post by Mati September 29th 2015, 5:12 pm

Works perfect but is it possible to have it above quick reply box.
Mati
Mati
Hyperactive

Posts : 2020
Reputation : 330
Language : HTML, CSS & JavaScript
Location : Forum Services

https://forumservice.forumotion.com/

Back to top Go down

Solved Re: A script for all closed topics

Post by Ange Tuteur September 29th 2015, 5:29 pm

Sure ! Smile

Replace the script with this :
Code:
$(function() {
  var locked = 'http://i21.servimg.com/u/f21/16/89/96/68/locked10.png',
      message = 'This topic is now closed to further replies.',
      reply = $('.i_reply')[0],
      main = document.getElementById('main-content'),
      quick = document.anchors.quickreply,
      node;

  if (reply && reply.src == locked) {
    node = document.createElement('DIV');
    node.className = 'notice_locked';
    node.innerHTML = message;
    if (main && quick) main.insertBefore(node, quick);
  }
});
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: A script for all closed topics

Post by Mati September 29th 2015, 5:36 pm

Thank you very much! Smile
Mati
Mati
Hyperactive

Posts : 2020
Reputation : 330
Language : HTML, CSS & JavaScript
Location : Forum Services

https://forumservice.forumotion.com/

Back to top Go down

Solved Re: A script for all closed topics

Post by Ange Tuteur September 29th 2015, 5:38 pm

You're welcome Smile

Topic archived

Have a good day. ^^
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top

- Similar topics

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