if (this.fluidbook.settings.tagcommander_id) {
this.initTagCommander();
}
+ if (this.fluidbook.settings.xiti) {
+ this.initPianoAnalytics();
+ }
},
initTagCommander: function () {
});
},
+
+ initPianoAnalytics: function () {
+ var $this = this;
+ $(this.fluidbook).on('fluidbook.hashchange', function (e, data) {
+ if (window.location.hash === this.lastTCHash) {
+ return;
+ }
+ this.lastTCHash = window.location.hash;
+ data.shift();
+ var hashes = [];
+ if (!$this.fluidbook.displayOnePage && data[0] === 'page') {
+ var p = parseInt(data[1]);
+ if (!isNaN(p)) {
+ var even, odd;
+ if (p % 2 === 0) {
+ even = p;
+ odd = p + 1;
+ } else {
+ odd = p;
+ even = p - 1;
+ }
+ if ($this.fluidbook.settings.piano_plan['page/' + even] !== undefined) {
+ data[1] = even;
+ hashes.push(data.join('/'));
+ }
+
+ if ($this.fluidbook.settings.piano_plan['page/' + odd] !== undefined) {
+ data[1] = odd;
+ hashes.push(data.join('/'));
+ }
+ }
+ } else {
+ hashes.push(data.join('/'));
+ }
+
+ $.each(hashes, function (k, hash) {
+ if ($this.fluidbook.settings.piano_plan[hash]) {
+ setTimeout(function () {
+ var pianoData = $this.fluidbook.settings.piano_plan[hash];
+ console.info('Piano Data', pianoData);
+ try {
+ pa.sendEvent('page.display', pianoData);
+ } catch (e) {
+ console.error(e);
+ }
+ }, 500 * k)
+ }
+ });
+ });
+ },
+
track: function (type, page, extra) {
if (!this.fluidbook.support.hasNetwork() || this.fluidbook.nointerface) {
return;