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 29/9/2015, 15:24

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


Last edited by Mati on 29/9/2015, 17:34; edited 1 time in total
Mati
Mati
Active Poster

Posts : 1932
Reputation : 333
Language : HTML, CSS & JavaScript
Location : Forum Services

https://fm-focus.forumotion.com/

Back to top Go down

Solved Re: A script for all closed topics

Post by Ange Tuteur 29/9/2015, 15:52

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 : 13207
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 29/9/2015, 17:12

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

Posts : 1932
Reputation : 333
Language : HTML, CSS & JavaScript
Location : Forum Services

https://fm-focus.forumotion.com/

Back to top Go down

Solved Re: A script for all closed topics

Post by Ange Tuteur 29/9/2015, 17:29

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 : 13207
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 29/9/2015, 17:36

Thank you very much! Smile
Mati
Mati
Active Poster

Posts : 1932
Reputation : 333
Language : HTML, CSS & JavaScript
Location : Forum Services

https://fm-focus.forumotion.com/

Back to top Go down

Solved Re: A script for all closed topics

Post by Ange Tuteur 29/9/2015, 17:38

You're welcome Smile

Topic archived

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

Male Posts : 13207
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