Jump to content
Matt Mason

Code error since Christie release

Recommended Posts

Morning all.  We have just had the Christie release installed on our platform and a previously working HTML widget has stopped working with the error 'Malformed Javascript'. I have been told that FROG created this code for us originally.  The code basically pulls data from the dataviewer and displays it in a custom way.  After some investigation the error seems to be due to the line of code below. You get the error TypeError: Illegal module name "//dataviewer/models/form_model" in the console.

steal('//dataviewer/models/form_model.js').then(function()

Below is the full code and any help with this will be much appreciated.  Matt
 

<style>
    .greenshawTable {
        background:#FFFFFF;
        margin:20px;
        width:90%;
        font-size:12pt;
    }
    .greenshawTable th {
        background:#CCCCCC;
    }
</style>


<script>
 var movementTable = $("<table>", {
                        id: Frog.Utilities.generateSimpleId()
                      });
movementTable.addClass('table');
movementTable.addClass('greenshawTable');
movementTable.html(
   '<tr>'+
        '<th><b>Attn</b></th>'+
        '<th><b>Notice</b></th>'+
        '<th><b>Submitted by</b></th>'+
        '<th><b>Submitted time</b></th>'+
        '<th><b>Day of Week</b></th>'+
    '</tr>'
);
  

if (!Array.prototype.findIndex) {
    Array.prototype.findIndex = function(predicate) {
        if (this === null) {
            throw new TypeError('Array.prototype.findIndex called on null or undefined');
        }
        if (typeof predicate !== 'function') {
            throw new TypeError('predicate must be a function');
        }
        var list = Object(this);
        var length = list.length >>> 0;
        var thisArg = arguments[1];
        var value;

        for (var i = 0; i < length; i++) {
            value = list[i];
            if (predicate.call(thisArg, value, i, list)) {
                return i;
            }
        }
        return -1;
    };
}
steal('//dataviewer/models/form_model.js').then(function() {
    var formUuid = '6334FCA52003E978E8C4EFC54BD6C5044AAD2E4CDCCBB0AE';
    Dataviewer.Models.Form.findAll({
        content_uuid: formUuid,
        sort_dir: 'DESC',
        sort_field: 'date',
        limit:100
    }).done(function(responseDataModel) {
        //console.log(responseDataModel);
                responseDataModel.forEach(function(data, index) {
                var myArray = new Array('','','');
                for (var i=0;i<3;i++) {
                    myArray[i]=data.fields[i].responses[0].response;
                }
                    //console.log(trumpArray);
                movementTable.append("<tr>"+
                                    "<td>"+myArray[0]+"</td>"+
                                    "<td>"+myArray[1]+"</td>"+
                                    "<td>"+data.user.displayname+"</td>"+   
                                    "<td>"+
                                       moment.unix(data.responded_on).format("HH:ss DD/MM/YYYY")+
                                    "</td>"+                                       
                                     "<td>"+myArray[2]+"</td>"+
                                    "</tr>"
                    );
                });
        //});
    }).fail(function() {
        // these are not the results you are looking for.
    });
    
});
this.element.append(movementTable);    


</script>

 

Link to comment
Share on other sites

33 minutes ago, Matt Mason said:

Morning all.  We have just had the Christie release installed on our platform and a previously working HTML widget has stopped working with the error 'Malformed Javascript'. I have been told that FROG created this code for us originally.  The code basically pulls data from the dataviewer and displays it in a custom way.  After some investigation the error seems to be due to the line of code below. You get the error TypeError: Illegal module name "//dataviewer/models/form_model" in the console.


steal('//dataviewer/models/form_model.js').then(function()

Below is the full code and any help with this will be much appreciated.  Matt
 


<style>
    .greenshawTable {
        background:#FFFFFF;
        margin:20px;
        width:90%;
        font-size:12pt;
    }
    .greenshawTable th {
        background:#CCCCCC;
    }
</style>


<script>
 var movementTable = $("<table>", {
                        id: Frog.Utilities.generateSimpleId()
                      });
movementTable.addClass('table');
movementTable.addClass('greenshawTable');
movementTable.html(
   '<tr>'+
        '<th><b>Attn</b></th>'+
        '<th><b>Notice</b></th>'+
        '<th><b>Submitted by</b></th>'+
        '<th><b>Submitted time</b></th>'+
        '<th><b>Day of Week</b></th>'+
    '</tr>'
);
  

if (!Array.prototype.findIndex) {
    Array.prototype.findIndex = function(predicate) {
        if (this === null) {
            throw new TypeError('Array.prototype.findIndex called on null or undefined');
        }
        if (typeof predicate !== 'function') {
            throw new TypeError('predicate must be a function');
        }
        var list = Object(this);
        var length = list.length >>> 0;
        var thisArg = arguments[1];
        var value;

        for (var i = 0; i < length; i++) {
            value = list[i];
            if (predicate.call(thisArg, value, i, list)) {
                return i;
            }
        }
        return -1;
    };
}
steal('//dataviewer/models/form_model.js').then(function() {
    var formUuid = '6334FCA52003E978E8C4EFC54BD6C5044AAD2E4CDCCBB0AE';
    Dataviewer.Models.Form.findAll({
        content_uuid: formUuid,
        sort_dir: 'DESC',
        sort_field: 'date',
        limit:100
    }).done(function(responseDataModel) {
        //console.log(responseDataModel);
                responseDataModel.forEach(function(data, index) {
                var myArray = new Array('','','');
                for (var i=0;i<3;i++) {
                    myArray[i]=data.fields[i].responses[0].response;
                }
                    //console.log(trumpArray);
                movementTable.append("<tr>"+
                                    "<td>"+myArray[0]+"</td>"+
                                    "<td>"+myArray[1]+"</td>"+
                                    "<td>"+data.user.displayname+"</td>"+   
                                    "<td>"+
                                       moment.unix(data.responded_on).format("HH:ss DD/MM/YYYY")+
                                    "</td>"+                                       
                                     "<td>"+myArray[2]+"</td>"+
                                    "</tr>"
                    );
                });
        //});
    }).fail(function() {
        // these are not the results you are looking for.
    });
    
});
this.element.append(movementTable);    


</script>

 

Hi @Matt Mason,

In the Da vinci release, we updated the library that loads FrogOS (StealJS). Unfortunately, the new version of that library works slightly differently to the old one. Here is the change you need to make.

steal.import('dataviewer/dataviewer!frog-component').then(function() {
    var formUuid = '..';
    // the rest should be the same
});

As always, let us know how you get on and if you have any other questions don't hesitate to ask.

 

~ Chris

  • Thanks 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...