<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>abcjs basic demo</title><script src="abcjs_basic_latest-min.js" type="text/javascript"></script></head><body><h1>abcjs basic demo page</h1><div id="notation"></div><script type="text/javascript">var chorus = '%%staffwidth 500\nX: 1\nT: Chorus\nV: T1 clef=treble name="Soprano"\nV: T2 clef=treble name="Alto"\nV: B1 clef=bass name="Tenor"\nV: B2 clef=bass name="Bass"\nL:1/8\nK:G\nP:First Part\n[V: T1]"C"ed"Am"ed "F"cd"G7"gf |\n[V: T2]GGAA- A2BB |\n[V: B1]C3D- DF,3 |\n[V: B2]C,2A,,2 F,,2G,,2 |';</script><div><script type="text/javascript">ABCJS.renderAbc('notation', chorus);</script></div></body></html>
%%staffwidth 500 ABCJS.renderAbc(this.pNode, this.tid);this.parentDomNode = parent; var width = parent.clientWidth*2/3; this.computeAttributes(); this.execute(); this.pNode = this.document.createElement("div"); parent.insertBefore(this.pNode,nextSibling); if (this.source) { this.tid = $tw.wiki.getTiddlerText(this.source) ABCJS.renderAbc(this.pNode, "%%staffwidth "+width+"\n"+this.tid);
to make it reactive to the resize there's this event:
object.addEventListener("resize", myScript);
\*/(function(){/*jslint node: true, browser: true *//*global $tw: false */"use strict";var Widget = require("$:/core/modules/widgets/widget.js").widget;var ABCWidget = function(parseTreeNode,options) {this.initialise(parseTreeNode,options);};// vpl variablesvar widgetParent;var widgetNextSib;/*Inherit from the base widget class*/ABCWidget.prototype = new Widget();/*Render this widget into the DOM*/ABCWidget.prototype.render = function(parent,nextSibling) {// vplwidgetParent = parent;widgetNextSib = nextSibling;
this.parentDomNode = parent;var width = parent.clientWidth*2/3;this.computeAttributes();this.execute();this.pNode = this.document.createElement("div");parent.insertBefore(this.pNode,nextSibling);if (this.source) {this.tid = $tw.wiki.getTiddlerText(this.source)ABCJS.renderAbc(this.pNode, "%%staffwidth "+width+"\n"+this.tid);}
this.domNodes.push(this.pNode);};/*Compute the internal state of the widget*/ABCWidget.prototype.execute = function() {this.source = this.getAttribute("source");};/*Refresh the widget by ensuring our attributes are up to date*/ABCWidget.prototype.refresh = function(changedTiddlers) {var changedAttributes = this.computeAttributes();if(changedAttributes["source"]||changedTiddlers[this.source]) {this.refreshSelf();return true;}return false;};exports["abc"] = ABCWidget;var myScript = function() {this.parentDomNode = widgetParent;
var width = parent.clientWidth*2/3;this.computeAttributes();this.execute();this.pNode = this.document.createElement("div");
parent.insertBefore(this.pNode,widgetNextSib);
if (this.source) {this.tid = $tw.wiki.getTiddlerText(this.source)
ABCJS.renderAbc(this.pNode, this.tid);}this.domNodes.push(this.pNode);};ABCWidget.prototype.addEventListener("resize", myScript);})();
ABCWidget.prototype.addEventListener("resize", this.refreshSelf());