[3.2][BETA] Extra Javascript

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Scam Warning
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
Post Reply
User avatar
martti
Registered User
Posts: 739
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

[3.2][BETA] Extra Javascript

Post by martti » Tue May 29, 2018 7:21 pm

Extension Name: Extra Javascript
Author: martti
Extension Description: With this extension you can write extra Javascript files in the ACP. The HTTP header for browser cache is set to maximum, 1 year.
Extension Version: 0.1.0
Requirements: Extension Download: https://github.com/marttiphpbb/phpbb-ex ... master.zip The files are to be put in ext/marttiphpbb/extrajavascript
Github repository: https://github.com/marttiphpbb/phpbb-ex ... javascript
Languages: en
Templates: all
Screenshots:

ACP Files

Image

ACP Edit

Image

Result

Image
(The console is opened in the browser here)
Last edited by martti on Thu May 31, 2018 6:44 am, edited 1 time in total.

User avatar
martti
Registered User
Posts: 739
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] Extra Javascript

Post by martti » Wed May 30, 2018 7:48 am

In response to this request:

An approach with Javascript only, how to color text after a symbol (at the beginning of the line):

Create with this extension a Javascript file, set the script names to viewtopic,posting,search and drop in the editor in the ACP the following code:

Code: Select all

;(function($, window, document) {
  $('document').ready(function (){
    $('div.postbody div.content').each(function(){
	  var newLine = true;
      $(this).contents().each(function(){
        if ($(this).is('br')){
          newLine = true;
          return;
        }
        if ((this.nodeType === Node.TEXT_NODE) 
            && newLine
            && $(this).text().trim().charAt(0) === '>'){
          $(this).wrap('<span style="color:green;">');
        }
        newLine = false;
      });
    });
  });
})(jQuery, window, document);
ACP Editor:

Image

Result:

Image

Miri4ever
Registered User
Posts: 409
Joined: Sat Mar 07, 2015 11:18 am

Re: [3.2][BETA] Extra Javascript

Post by Miri4ever » Wed May 30, 2018 12:58 pm

Got it working and will do some more testing. Seems interesting. Got first some problems with no work, until I disabled my mouse java script then everything shows fine.

Is only JS allowed or with html code ? A lot of JS things found at the net having still small pieces of HTML Code before and after.
Homepage: Terra Oceanica

User avatar
martti
Registered User
Posts: 739
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] Extra Javascript

Post by martti » Wed May 30, 2018 1:05 pm

Miri4ever wrote:
Wed May 30, 2018 12:58 pm
Got it working and will do some more testing. Seems interesting. Got first some problems with no work, until I disabled my mouse java script then everything shows fine.

Is only JS allowed or with html code ? A lot of JS things found at the net having still small pieces of HTML Code before and after.
Mouse java script? What's that?

The files are loaded with the application/javascript type header so that's only for javascript.
An extension for html will follow. But that are not separate files, but code inserted in the phpBB template events locations.

Post Reply

Return to “Extensions in Development”