Javascript error in Internet Explorer - javascript

I have a problem with a js script running in Internet Explorer.
Basically the script runs fine in Firefox, but I need to embed it into the webbrowser control in a silverlight application, for which it has to run error free in the Internet Explorer engine.
Running it in the IE produces an "Expected object" error in the following line:
$f("player", "player.swf", {
How could this be rewritten to also work in IE?
Here is the complete script:
$f("player", "player.swf", {
key: '##18a1aaa6552d45a2cfe',
log: { level: 'debug', filter: 'org.flowplayer.cluster.*' },
clip: {
url: 'live3',
live: true,
provider: 'rtmp',
autoBuffer:true,
bufferLength:10,
scale:'fit',
connectionProvider: 'cluster',
onStart: function(clip){ }
},
canvas: {backgroundImage: 'url(staytuned.jpg)'},
onError:function(err){canvas: {backgroundImage: 'url(taytuned.jpg)'}},
contextMenu: [
'player 1.1',
{'About ...' : function() {
location.href = "url/?page=aboutus";}},
{'Contact ...' : function() {
location.href = "url/?page=contactus";}},
{'More Casts ...' : function() {
location.href = "url/?page=casts";}},
],
plugins: {
overlay: {
url: 'overlay.swf',
top: 0,
right: 0,
width: 854,
height:450,
zIndex:3
},
rtmp: {
url: 'rtmp.swf'
},
cluster: {
url: 'cluster.swf',
netConnectionUrl: 'url',
hosts: [
{host:'url'},
{host:'url'}
]
},
controls: {
autoHide: false,
url:'url',
zIndex:5
},
gatracker: {
url: "analytics.swf",
trackingMode: "Bridge",
bridgeObject: "pageTracker"
}
}
});
Thanks,
Andrej

First answer was incorrect. See comments for details.
Edit
The problem is likely that $f is not defined at the time you're trying to call it. Place alert(typeof $f); on the line immediately before the line causing the error. If it doesn't alert function, them I'm right.
Make sure you're including the script that contains the definition for $f before you try to call it.

Goto www.jslint.com. Paste this entire script into the top window and click the "jslint" button below it.
You'll find that onError is malformed:
onError:function(err){canvas: {backgroundImage: 'url(taytuned.jpg)'}},
it should read more like:
onError:function(err) {
var canvas = {backgroundImage: 'url(taytuned.jpg)'};
return canvas;
},
There's a similar issue a few lines below.
And I suspect that "taytuned.jpg" needs to be enclosed within quotes, but it's not my script.

Related

Protractor Cucumber Configuration file throwing undefined warning for my scenarios even though those are present

my Configuration file is not able to find the spec file even though it is present in the path that i provided in the cucumberOpts..i tried all the resolutions but none of them is worked.
Config File
const log4js = require('log4js');
var fs=require('fs');
global.screenshots = require('protractor-take-screenshots-on-demand');
global.browser2;
var propertiesReader=require('properties-reader');
var env=require("../../env.js");
const {Given, Then, When, Before} = require('cucumber');
exports.config = {
//seleniumAddress: 'http://localhost:4444/wd/hub',
directConnect:true,
framework: 'custom',
// path relative to the current config file
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome',
metadata: {
browser: {
name: 'chrome',
version: '79'
},
device: 'MacBook Pro 15',
platform: {
name: 'OSX',
version: '10.12.6'
},
disableLog:true,
durationInMS:true,
openReportInBrowser:true
}
},
ignoreUncaughtExceptions:false,
// Spec patterns are relative to this directory.
specs: [
'../../Test_modules/features/'
],
beforeLaunch:function(){
if (fs.existsSync('./logs/ExecutionLog.log')) {
fs.unlink('./logs/ExecutionLog.log')
}
log4js.configure({
appenders: {
out: { type: 'console' },
info:{ type: 'dateFile', filename: "../Reports/logs/info", "pattern":"-dd.log",alwaysIncludePattern:false},
"console" : {
"type": "console",
"category": "console"
},
"file" : {
"category": "test-file-appender",
"type": "file",
"filename": "../../Reports/logs/log_file.log",
"maxLogSize": 10240,
// "backups": 3,
// "pattern": "%d{dd/MM hh:mm} %-5p %m"
}
},
categories: {
"info" :{"appenders": ["console"], "level": "info"},
"default" :{"appenders": ["console", "file"], "level": "DEBUG"},
//"file" : {"appenders": ["file"], "level": "DEBUG"}
}
});
},
cucumberOpts: {
require:['../../Test_modules/utilities/timeOutConfig.js','../../Test_modules/stepDefinition/spec.js'],
tags: false,
profile: false,
format:'json:../../Reports/jsonResult/results.json',
'no-source': true
},
onPrepare: function () {
const logDefault = log4js.getLogger('default');
const logInfo=log4js.getLogger('info');
screenshots.browserNameJoiner = ' - '; //this is the default
//folder of screenshot
screenshots.screenShotDirectory = '../../Screenshots';
global.openNewBrowser=require('../../Test_modules/utilities/newBrowserinstance.js');
global.testData=require('../../TestData/testData.json');
browser.logger = log4js.getLogger('protractorLog4js');
global.firstBrowser=browser;
global.properties=propertiesReader('../../TestData/propertyConfig.properties');
browser.waitForAngularEnabled(false);
browser.manage().window().maximize();
global.facebook=require('../../Test_modules/pages/fbPageObjects.js');
global.utility=require('../../Test_modules/utilities/testFile.js');
},
plugins: [{
package: 'H:/workspace/Proc-UI/node_modules/protractor-multiple-cucumber-html-reporter-plugin',
options:{
// read the options part for more options
automaticallyGenerateReport: true,
removeExistingJsonReportFile: true,
reportPath:'../../Reports/HtmlReports',
reportName:"test.html"
},
customData: {
title: 'Run info',
data: [
{label: 'Project', value: 'Framework Setup'},
{label: 'Release', value: '1.2.3'},
{label: 'Cycle', value: 'Test Cycle'}
]
},
}]
};
Spec File
var utilityInit,page2;//browser2;
page1=new facebook(firstBrowser);
module.exports=function(){
this.Given(/^Open the browser and Load the URL$/,async function(){
await firstBrowser.get(properties.get("url1"));
browser.logger.info("Title of the window is :"+await browser.getTitle());
//screenshots.takesScreenshot("filename");
});
this.When(/^User entered the text in the search box$/,async function(){
firstBrowser.sleep(3000);
await page1.email().sendKeys(testData.Login.CM[0].Username);
browser.sleep(3000);
await page1.password().sendKeys(testData.Login.CM[0].Password);
});
this.Then(/^click on login button$/,async function(){
browser.sleep(3000);
await facebook.submit().click();
});
this.Then(/^User tried to open in new browser instance$/,async function(){
browser2=await openNewBrowser.newBrowserInit(firstBrowser);
utilityInit=new utility(browser2);
utilityInit.ignoreSync(properties.get("url2"));
browser2.manage().window().maximize();
console.log(await utilityInit.title()+" title");
browser2.sleep(5000);
});
this.When(/^User entered the text in the email field$/,async function(){
page2=new facebook(browser2);
console.log(await page2.title()+" browser2");
await page2.search().sendKeys("testing");
browser2.sleep(3000);
page1=new facebook(firstBrowser);
console.log(await page1.title()+" browser1");
await page1.email().sendKeys(testData.Login.CM[0].Username);
screenshots.takeScreenshot("newScreenshot");
firstBrowser.sleep(5000);
});
};
Execution log
1) Scenario: Title of your scenario # ..\features\test.feature:24
? Given Open the browser and Load the URL
Undefined. Implement with the following snippet:
Given('Open the browser and Load the URL', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
? Then User tried to open in new browser instance
Undefined. Implement with the following snippet:
Then('User tried to open in new browser instance', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
? And User entered the text in the email field
Undefined. Implement with the following snippet:
Then('User entered the text in the email field', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
√ After # ..\..\node_modules\protractor-cucumber-framework\lib\resultsCapturer.js:27
1 scenario (1 undefined)
3 steps (3 undefined)
0m00.004s
i tried by adding cucumber dependencies, updating from relative path to absolute path everything i did.. but none it is resolved.. previously it worked fine but in the process of updating it in to public framework file.. i updated the paths from absolute to relative path. that's it i lost my whole framework and it is continuesly saying undefined scenarios.
**For Just made me sure i ran the script by passing wrong spec file name in the cucumber opts and still it giving Undefined and that confirmed me that it is not even considering that spec file that i passed.
Simple installation makes my framework works
npm install cucumber#1.3.3 --save-dev

Alasql is undefined

I can't seem to get the Alasql to become defined, i have installed it via node and I'm fairly certain that it is installed proplery however whenever i load my front end. i'm not 100% sure where it's going wrong, any help would be greatly appreciated!
require is not defined at Scope.$scope.exportData
$scope.exportData = function () {
var mystyle = {
sheetid: 'Account sheet',
headers: true,
caption: {
title:'My Big Table',
},
style:'background:#00FF00',
column: {
style:'font-size:30px'
},
columns: [
{columnid:'Date'},
{columnid:'Description'},
{columnid:'Due'},
{columnid:'Charged £'},
{columnid:'Received £'},
{columnid:'Balanced £'},
{
columnid:'name',
title: 'Number of letters in name',
width: '300px',
cell: {
value: function(value){return value.length}
}
},
],
row: {
style: function(sheet,row,rowidx){
return 'background:'+(rowidx%2?'red':'yellow');
}
},
rows: {
},
cells: {
2:{
2:{
}
}
}
};
$scope.exportData = function () {
var alasql = require('alasql');
alasql('SELECT * INTO XLS("report.xls",?) FROM ?',[mystyle,records]);
};
1 - From their own angularjs readme:
Please include the file normally and not via requireJS. Please include alasql before requireJS to avoid issue of "Mismatched anonymous define() module". This issue is with requireJS.
2 - I had "alasql is undefined" when using grunt to build my project. So I had to include alasql in my jshint file under "globals" section:
{
.
.
.
"globals": {
"angular": false,
"confirm": false,
"console": false,
"alert": false,
"alasql": false
}
}
PS: I recommend you exporting to ".xlsx" instead of ".xls". Microsoft is now refusing to open those files.

How do I use hosted YUI with SSL?

I have downloaded YUI onto my local server and linked through to the yui-min.js. The code i use is:
<script src="//mysite.com/scripts/yui3-3.17.2/build/yui/yui-min.js"></script>
This works fine in a HTTP environment but doesn't work when I switch to HTTPS.
My only bit of yui code is as follows:
<script>
YUI({
classNamePrefix: 'pure'
}).use('gallery-sm-menu', function (Y) {
var horizontalMenu = new Y.Menu({
container : '#demo-horizontal-menu',
sourceNode : '#std-menu-items',
orientation : 'horizontal',
hideOnOutsideClick: false,
hideOnClick : false
});
horizontalMenu.render();
horizontalMenu.show();
});
</script>
I believe i need to use a combo handler to get this to work but i cannot understand the documentation on how this works. Can someone please help?
Thanks!
Matt
That is the complete code that works in https:
<script>
YUI({
classNamePrefix: 'pure',
modules: {
'gallery-sm-menu': {
fullpath: 'js/yui-gallery-master/build/gallery-sm-menu/gallery-sm-menu.js'
},
'gallery-sm-menu-base-min': {
fullpath: 'js/yui-gallery-master/build/gallery-sm-menu-base/gallery-sm-menu-base-min.js'
},
'gallery-sm-menu-templates-min': {
fullpath: 'js/yui-gallery-master/build/gallery-sm-menu-templates/gallery-sm-menu-templates-min.js'
},
'gallery-sm-menu-item-min': {
fullpath: 'js/yui-gallery-master/build/gallery-sm-menu-item/gallery-sm-menu-item-min.js'
}
}
}).use( 'gallery-sm-menu',
'gallery-sm-menu-base-min',
'gallery-sm-menu-templates-min',
'gallery-sm-menu-item-min', function (Y) {
var horizontalMenu = new Y.Menu({
container : '#demo-horizontal-menu',
sourceNode : '#std-menu-items',
orientation : 'horizontal',
hideOnOutsideClick: false,
hideOnClick : false
});
horizontalMenu.render();
horizontalMenu.show();
});
</script>
YUI CDN (yui.yahooapis.com) doesn't support HTTPS endpoint. Gallery modules such as gallery-sm-menu will loads from HTTP CDN as default. You need to define the module within YUI configuration object.
The example as follows. Please see also YUI Global Object.
YUI({
modules: {
gallery-sm-menu: {
fullpath: 'https://your-domain/your/path/to/module.js'
}
}
}).use("gallery-sm-menu", function (Y) {
// do something.
});

TypeError: e is undefined when trying to open a Magnific popup

Trying to open this popup but I get a jQuery error TypeError: e is undefined
$.magnificPopup.open(
{
items: {
src: '/the-page?' + $.param(params),
type: 'ajax'
},
ajax: {
settings: {
dataType: 'json'
},
cursor: 'mfp-ajax-cur',
tError: 'The content could not be loaded.'
},
callbacks: function (mfpResponse) {
console.log(mfpResponse);
mfpResponse.data = mfpResponse.html;
}
}
);
I can see in Firebug that the json response arrived correctly. The Loading... message is displayed but the mfpResponse is never console.logged. The html has a single div root with the example style from the site. I need the response as json as there are other data to use. This is Firefox 26, jQuery 1.10.2 and Magnific-Popup 0.9.9.
The callback definition was wrong and the json response data is in mfpResponse.xhr.responseJSON so the correct code is
callbacks: {
parseAjax: function (mfpResponse) {
console.log(mfpResponse);
mfpResponse.data = mfpResponse.xhr.responseJSON.html;
}
}

List not populating with a JsonP proxy

I want to have a Navigation view. I am trying to populate the list in Sencha Touch using a JsonP proxy.
Here's the sample code snippet of what I have tried till now :
var view = Ext.define('MyApp.view.NavigateView', {
extend: 'Ext.navigation.View',
xtype:'navigateview',
config : {
fullscreen:true,
styleHtmlContent:true,
scrollable:true,
items : [
{
title:'Navigation',
items : [
{
xtype:'list',
store: {
fields : ['title','author'],
proxy : {
type:'jsonp',
url:'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/SenchaBlog',
reader: {
type: 'json',
rootProperty: 'responseData.feed.entries'
}
},
autoLoad:true,
},
itemTpl:'<div class="contact">{title} <strong>{author}</strong></div>',
listeners : {
itemtap : function(){
Ext.Msg.alert('Called');
}
}
}
],
}
]
}
});
But the problem is, my list is not getting populated. No items are being shown up in the list.
Also, I am constantly getting this error on console.
XMLHttpRequest cannot load
http://api.tinyhippos.com/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=list.php%3F_dc%3D1334462633038%26page%3D1%26start%3D0%26limit%3D25.
Origin http://localhost is not allowed by Access-Control-Allow-Origin.
Anyone please guide ? Anything that I am missing here ?
i was facing the same error when using AJAX request in cross domain.
have a look here
you have to make sure that the server part is configured properly using jsonp
as a first step identify if your application will run correctly when you disable web security in your browser
locate your chrome installation directory
then type in your cmd: chrome --disable-web-security
Your Ext.navigation.View object is containing one Ext.Component object (xtype not defined so defaulted to 'component') that is containing your list. If you put your list directly as an item of your view, it'll be rendered:
var view = Ext.define('MyApp.view.NavigateView', {
extend: 'Ext.navigation.View',
xtype: 'navigateview',
config : {
fullscreen: true,
styleHtmlContent: true,
scrollable: true,
items : [{
title: 'Navigation',
xtype: 'list',
store: {
fields: ['title','author'],
proxy: {
type: 'jsonp',
url: 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/SenchaBlog',
reader: {
type: 'json',
rootProperty: 'responseData.feed.entries'
}
},
autoLoad:true
},
itemTpl: '<div class="contact">{title} <strong>{author}</strong></div>'
}]
}
});
Note1: Not sure why your code is not working.
Note2: The error your mentioned is not related to your code snippet

Categories

Resources