Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to provide add-on script to append to reload code #340

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

OnkarRuikar
Copy link

The PR adds an option to provide extra script to further customize the client script (that is appended at the end of served HTML page).

For example, to view logs we want to scroll to bottom every time the page reloads. Following JavaScript can be appended to the reload script:

// FILE: reload-addon.js
// scroll to bottom on load
window.addEventListener('load', () => {
  window.setTimeout(()=>window.scrollTo(0, document.body.scrollHeight), 50);
});

To tell reload server about the extra script to append use option -a:

reload -d "/sensor/logs/" -a "/home/user/bin/reload-addon.js"

This will make reload server provide following reload.js:

// default reload.js code
...
})()


// Add-on code
// FILE: reload-addon.js
// scroll to bottom on load
window.addEventListener('load', () => {
  window.setTimeout(()=>window.scrollTo(0, document.body.scrollHeight), 50);
});

Using this, depending on the application requirements, custom features (like floating menus, highlighting, scrolling etc) can be added to the served pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant