diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js index 29845697e..960fce5f7 100644 --- a/www/common/sframe-app-framework.js +++ b/www/common/sframe-app-framework.js @@ -84,6 +84,7 @@ define([ }); }); + var textContentGetter; var titleRecommender = function () { return false; }; var contentGetter = function () { return UNINITIALIZED; }; var normalize0 = function (x) { return x; }; @@ -284,6 +285,10 @@ define([ if (!readOnly) { onLocal(); } evOnReady.fire(newPad); + if (AppConfig.textAnalyzer && textContentGetter) { + AppConfig.textAnalyzer(textContentGetter); + } + UI.removeLoadingScreen(emitResize); var privateDat = cpNfInner.metadataMgr.getPrivateData(); @@ -567,6 +572,10 @@ define([ // in the pad when requested by the framework. setContentGetter: function (cg) { contentGetter = cg; }, + // Set a text content supplier, this is a function which will give a text + // representation of the pad content if a text analyzer is configured + setTextContentGetter: function (tcg) { textContentGetter = tcg; }, + // Inform the framework that the content of the pad has been changed locally. localChange: onLocal, diff --git a/www/pad/inner.js b/www/pad/inner.js index 6945f6d45..22ec21e40 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -402,6 +402,17 @@ define([ } }); + framework.setTextContentGetter(function () { + var innerCopy = inner.cloneNode(true); + displayMediaTags(framework, innerCopy, mediaTagMap); + innerCopy.normalize(); + $(innerCopy).find('*').each(function (i, el) { + $(el).append(' '); + }); + var str = $(innerCopy).text(); + str = str.replace(/\s\s+/g, ' '); + return str; + }); framework.setContentGetter(function () { displayMediaTags(framework, inner, mediaTagMap); inner.normalize();