Last active
December 19, 2015 02:39
-
-
Save vviro/5884632 to your computer and use it in GitHub Desktop.
JavaScript code for embedding the Peachnote Score Viewer on a website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script> | |
(function () { | |
var pnsv = document.createElement('script'); pnsv.type = 'text/javascript'; pnsv.async = true; | |
pnsv.src = 'http://pchnote.appspot.com/scoreviewer/scoreviewer.nocache.js'; | |
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(pnsv); | |
})(); | |
var _pnq = _pnq || []; | |
_pnq.push(['rootElement', 'PeachnoteViewerContainerId']); | |
_pnq.push(['loadScore', 'IMSLP00001']); | |
</script> | |
</head> | |
<body> | |
<div id='PeachnoteViewerContainerId'></div> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScript code necessary for embedding the Peachnote Score Viewer on a website | |
(function() { | |
var pnsv = document.createElement('script'); pnsv.type = 'text/javascript'; pnsv.async = true; | |
pnsv.src = 'http://pchnote.appspot.com/scoreviewer/scoreviewer.nocache.js'; | |
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(pnsv); | |
})(); | |
// object for communication with the viewer. | |
// following commands can be issued after the viewer is loaded: | |
// loadScore, loadPage, filterAnnotations, copyrightDisclaimerAcknowledged. | |
// this makes it possible to control and script the viewer from the outside. | |
var _pnq = _pnq || []; | |
// the id of the html element to attach the viewer to. | |
// there must be a <div id='PeachnoteViewerContainerId'></div> | |
// somewhere in your page. | |
_pnq.push(['rootElement', 'PeachnoteViewerContainerId']); | |
// the id of the score to load. | |
_pnq.push(['loadScore', 'IMSLP56321']); | |
// Optional parameters with reasonable defaults you might want to change | |
// page of the score to scroll to (default is 1). | |
_pnq.push(['loadPage', 2]); | |
// viewer widget width in pixels (default is 500). | |
_pnq.push(['widgetWidth', 650]); | |
// viewer widget height in pixels (default is 500). | |
_pnq.push(['widgetHeight', 900]); | |
// the entity on the copyright dialog (default is your site's domain). | |
_pnq.push(['copyrightDisclaimerEntity', | |
'YourWebsite/Organisation']); | |
// Optional parameters you might want to use | |
// select the localization that will override user default locale. | |
// possible values are currently 'en', 'fr', 'de', 'it' and 'ru' | |
_pnq.push(['language', 'en']); | |
// do not show the copyright dialog to the first-time users. | |
_pnq.push(['copyrightDisclaimerAcknowledged']); | |
// disable the search field. | |
_pnq.push(['disableScoreSearch']); | |
// disable all annotation-related functionality. | |
_pnq.push(['disableAnnotations']); | |
// annotations may be viewed, but not entered or deleted. | |
_pnq.push(['readonly']); | |
// automatically set the user name (useful when your visitors have accounts). | |
_pnq.push(['username', 'jsbach']); | |
// define annotation filters, so that only certain annotations are displayed. | |
_pnq.push(['filterAnnotations', | |
{ 'authors':'vviro,anonymous', // by certain users (e.g. you) | |
'types':'general,media', // of certain types | |
'domains':'imslp.org', // entered on certain domains (e.g. your site) | |
'tags':'tag 0'}]); // having certain tags | |
// remove all measure highlightings | |
_pnq.push(['clearMeasureHighlightings']); | |
// highlight a certain measure on a certain page | |
_pnq.push(['highlightMeasure', number, page); | |
// highlight a measure on a certain page at a certain poin in time (between 0 and 1) | |
// if exclusive is set to true, remove highlightings on other measures | |
_pnq.push(['highlightMeasureAtNormalizedTime', time, page, exclusive); | |
// callback for getting the information about a click inside the Viewer score. | |
// top and left are values between 0 and 1 representing the relative position of the click in the page coordinates | |
// where (0, 0) is the top left and (1, 1) the bottom right corner. | |
_pnq.push(['addPageClickHandler', function (sid, page, top, left, clickType) { | |
}); | |
// callback that is fired when a score is done loading in the Viewer | |
_pnq.push(['addScoreLoadedHandler', function (scoreId) { | |
}]); | |
// define a callback for getting information about a measure which has been clicked on | |
// (for scores with geometric information available) | |
_pnq.push(['addMeasureClickHandler', | |
function (scoreId, page, measureNumber, totalMeasures) { | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment