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.

Title of watched topics in notifications

Go down

Tutorial Title of watched topics in notifications

Post by Ange Tuteur December 19th 2014, 6:49 am

Title of watched topics in notifications
For the notification of a watched topic, there is this phrase " Username wrote a message in a watched topic " :

Title of watched topics in notifications Captur82

This tutorial will allow you to modify that phrase, to put the title of the topic and simplify it :

Title of watched topics in notifications Captur83

The topic title is simplified to where :

  • a, b, c, d, ..., x, y, z, 0, 1, 2, ..., 7, 8, 9, _ and spaces are preserved
  • é, à, ï, ç, ... are replaced by their basic letter
  • - is replace by a space
  • others are ignored


Installation

Go to Administration Panel > Modules > JavaScript codes management. Make sure JavaScript codes management is enabled, and create a new script.

Title : Your choice
Placement : In all the pages
Code:
$(function(){
  var middle_text = " replied to ";
  var empty_title = "this topic";
  if(typeof(compileNotif)!="function")return;var d=compileNotif;Toolbar.compileNotif=compileNotif=function(b){var a=d(b);if(b.text.type==FA.Notification.NOTIF_TOPIC_WATCH){var c=a.match(/^(.*) wrote a message (<a href="\/t[0-9]+(p[0-9]+)?-([^#?"]*)[^"]+">)[^<]+<\/a>$/);c&&(b=c[1]+middle_text+c[2],a=c[4],a="topic"==a||/^[\s-]*$/.test(a)?empty_title:a.replace(/-/g," ").replace(/(^\s+|\s+$)/g,""),a=b+a+"</a>")}return a}
});

You can modify these texts :

  • " replied to " => text between the poster and topic link
  • "this topic" => text if there is no simplified topic title


Notifications Page (Optional)

Go to Administration Panel > Modules > JavaScript codes management.

Title : Your choice
Placement : In all the pages
Code:
location.pathname=="/profile" && location.search.indexOf("page_profil=notifications")!=-1 && $(function(){
 
  var middle_text = " replied to ";
  var empty_title = "this topic";
 
  $('.table1 td:first-child,td.gen:first-child,.ipbtable td:first-child,.tcr .postdetails').each(function(){
    var a = $(this).html();
    var c = a.match(/^(.*) wrote a message (<a href="\/t[0-9]+(p[0-9]+)?-([^#?"]*)[^"]+">)[^<]+<\/a>$/);
    c&&(b=c[1]+middle_text+c[2],a=c[4],a="topic"==a||/^[\s-]*$/.test(a)?empty_title:a.replace(/-/g," ").replace(/(^\s+|\s+$)/g,""),$(this).html(b+a+"</a>"))
  });
 
});





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