Title of watched topics in notifications

Go down

Tutorial Title of watched topics in notifications

Post by Ange Tuteur on 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 " :


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


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>"))
  });
 
});





avatar
Ange Tuteur
Forumaster

Male Posts : 13215
Reputation : 2941
Language : EN, JA, FR
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Back to top


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