Warning: is_executable(): open_basedir restriction in effect. File(/bin/bash) is not within the allowed path(s): (/var/www/vhosts/megazine3.de/:/tmp/) in /var/www/vhosts/megazine3.de/megazine3.de/mw1.32.2/includes/shell/Command.php on line 312

Warning: is_executable(): open_basedir restriction in effect. File(/bin/bash) is not within the allowed path(s): (/var/www/vhosts/megazine3.de/:/tmp/) in /var/www/vhosts/megazine3.de/megazine3.de/mw1.32.2/includes/shell/Command.php on line 312

Warning: is_executable(): open_basedir restriction in effect. File(/bin/bash) is not within the allowed path(s): (/var/www/vhosts/megazine3.de/:/tmp/) in /var/www/vhosts/megazine3.de/megazine3.de/mw1.32.2/includes/shell/Command.php on line 312JavaScript - MegaZine3

The JavaScript plugin introduces a common interface for the engine and other plugins to communicate with JavaScript, should the engine run in a browser. It provides two interfaces, one for itself, so that other plugins can access it, and one other plugins can implement so they can add themselves to the list of JavaScript aware plugins. All registered plugins will be notified when the JavaScript plugin's setting "jsenabled" is set to true.

All plugins should use this way when offering JavaScript functionality, to allow a common behavior and centralized way of controlling the use of JavaScript.

The Javascript interface defined and made availalble with js/megazine.js only works if

the javascript plugin is activated (listed in the 'plugins' attribute), and

MegaZine3 runs on a server (a 'real' or a local one like XAMP). If you call a local file directly in a browser, the book might show up, but the Javascript API will not work!

Contents

Plugin interactions

The JavaScript plugin registers a protocol with the Links plugin, if loaded. The registered protocol is javascript: and can be used to run JavaScript code if the book is displayed using a browser. Example usage:

<elementurl="javascript:alert('test');"/>

Settings

== jsenabled =={{#if: Boolean |

Type: Boolean}}{{#if: |

Valid values: {{{valid}}}}}{{#if: true |

Default:true}}{{#if: |

Overrides:{{{overrides}}}}}{{#if: enablejs |

Aliases: enablejs}}{{#if: |

Version: {{{version}}}}}

This setting can be used to globally enable or disable JavaScript interaction of the book. As all plugins should use this plugin for registering and enabling JavaScript functionality, this will control the use of any JavaScript use at all, meaning if set to false it can be guaranteed (when using "nice" plugins) that there will indeed be no JavaScript interaction used.{{#if: |

First an HTML 'div' block with id 'header is inserted above the book, with one paragraph (id #pgnum) which will be updated when a page is turned.
The JS API is availbale after the book is initialized. When everything is ready, the API is available and the function defined as handler for onJSInit will be called.
Here the handler for onPageChange is defined, which will be called during a page turn.
That function provides the new and old page number as their 2 parameters. The first parameter (new page) is used to update the text in the #pgnum paragraph.
All available functions can be found in the js/megazine.js class.