Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SmartClient 6.0 - HTMLFlow failing to execute script blocks in content pages

    In SmartClient version 6.0 a bug exists whereby if content loaded by an HTMLFlow component contains multiple script blocks, in some cases the script blocks will fail to execute.

    This patch will resolve this issue for the 6.0 build and cause script blocks to execute correctly.

    Code:
    if (window.isc && isc.version.startsWith("6.0/")){ 
    isc.HTMLFlow.addClassMethods({
    getScript:function (_1, _2, _3, _4) {
    var _5 = _1;
    var _6, _7, _8, _9;
    while ((_6 = _1.match(/<!--/i)) != null) {
    _7 = _1.match(/-->/i);
    if (_7 == null || _7.index < _6.index) {
    this.logWarn("HTMLFlow content contains an opening comment tag \"<!--\"" + " with no closing tag \"-->\", or vice versa. We recommend you review this " + "HTML (original HTML follows):\n" + _5);
    if (_7) {
    _8 = _7.index;
    _9 = _8 + 3;
    } else {
    _8 = _6.index;
    _9 = _8 + 4;
    }
    } else {
    _8 = _6.index;
    _9 = _7.index + 3;
    }
    _1 = _1.slice(0, _8) + _1.slice(_9, _1.length);
    }
    var _10 = [];
    var _11 = [];
    var _12;
    while ((_12 = _1.match(/(<script([^>]*)?>)/i)) != null) {
    var _13 = _12[1];
    _1 = _1.slice(0, _12.index) + _1.slice(_12.index + _13.length, _1.length);
    var _14 = _1.match(/<\/script>/i), _15 = _1.match(/(<script([^>]*)?>)/i);
    if (_14 == null || _15 && _14.index > _15.index) {
    this.logWarn("HTMLFlow content contains an opening <script ...> tag " + "with no closing tag, or vice versa. Stripping out this tag:" + _13);
    continue;
    }
    var _16 = _1.slice(_12.index, _14.index);
    _1 = _1.slice(0, _12.index) + _1.slice(_14.index + 9, _1.length);
    var _17 = _13.match(/<script\s*(language|type)/i) == null ||
    _13.match(/<script\s*(language|type)\s*=["']?(javascript|ecmascript|jscript)["']?/i) != null;
    if (_17) {
    var _18;
    if (_18 = _13.match(/src=('|")?([^'"> ]*)/i)) {
    _11[_10.length] = _18[2];
    _10.add(null);
    } else {
    if (!isc.isA.String(_16) || isc.isAn.emptyString(_16)) {
        continue;
    }
    _10.add(_16);
    }
    } else {
    this.logWarn("html to be evaluated contains non-JS script tags - these will be" + " ignored.  Tag: " + _13);
    }
    }
    if (_11.length > 0 && !_4) {
    if (isc.RPCManager) {
    for (var i = 0; i < _11.length; i++) {
    if (_11[i] == null) {
        continue;
    }
    isc.RPCManager.sendRequest({actionURL:_11[i], serverOutputAsString:true, clientContext:{scriptIndex:i, scriptAccum:_10, srcTargets:_11, callback:_2, html:_3 ? _1 : _5}, callback:"isc.HTMLFlow.loadedRemoteScriptBlock(data, rpcResponse.clientContext)"});
    }
    return;
    } else {
    _10.removeEmpty();
    this.logWarn("html contains <script src=> blocks with the " + "following target URLs: " + _11 + " If you want " + "these to be dynamically loaded, please include the " + "DataBinding module or include the contents of " + "these files in inline <script> blocks.");
    }
    }
    var _20 = _10.join("\n");
    this.fireCallback(_2, "html,script", [_3 ? _1 : _5, _20]);
    }
    });
    
    } else if (window.isc) {
      isc.Log.logWarn("Patch for SmartClient 6.0 builds included in this application. " +
                "You are currently running SmartClient verion '"+ isc.version + 
                "'. This patch is not compatible with this build and will have no effect. " +
                "It should be removed from your application source.");
    
    }
Working...
X