Can not read property 'position' undefined, get Coordinates - CustomTile - Openseadragon - coordinates

I am trying to get the coordinates with below code : If i am clicking on the canvas to grab the X and Y position : showing me console error : Uncaught TypeError: Cannot read property 'position' of undefined
screenshot : http://screencast.com/t/0LHAae5AicRz
viewer.addHandler('canvas-click', function (target, info) {
var viewportPoint = viewer.viewport.pointFromPixel(info.position);
var imagePoint = viewer.viewport.viewportToImageCoordinates(viewportPoint.x, viewportPoint.y);
console.log(imagePoint.x, imagePoint.y);
});

The info parameter is probably not what you think it is.
Do console.log(info) to see what the variable is in the console.
Perhaps the variable you are looking for is another parameter.
Also log all the arguments that get passed to the function. Write this inside the function:
console.log(arguments)
This way you will be able to inspect the variables and find the data you need.

This way, I can remove the canvas-click related - position of undefined error : Take a look at here for the answer : https://github.com/openseadragon/openseadragon/issues/318
For the //! OpenSeadragon 1.1.1, please updated the code as per below.
viewer.addHandler('canvas-click', function (event)
{
console.log(event);
var viewportPoint = viewer.viewport.pointFromPixel(event.position);
var imagePoint = viewer.viewport.viewportToImageCoordinates(viewportPoint.x, viewportPoint.y);
console.log(imagePoint.x, imagePoint.y);
});

Related

Protractor- ElementFinder returning unexpected values

I am writing a protractor test case to compare the name(s) of the displayed data is same as the searched name.
Even though my test case works fine, I am not able to understand what is happening. Because when i expect the name to compare, it compares as expected, but when i print the elementFinder's(rowData)(i have attached the output screen shot here) value in console.log, it show a huge list of some values which i am not able to understand?
PS: I am a newbie to protractor`
This is the testCase:
it('should show proper data for given last name', function () {
var searchValue='manning';
searchBox.sendKeys(searchValue);
search.click();
element.all(by.binding('row.loanNumber')).count().then(function(value) {
var loanCount = value;
for (var i = 0; i < loanCount; i++) {
var rowData = element.all(by.binding('row.borrowerName')).get(i).getText();
expect(rowData).toMatch(searchValue.toUpperCase());
console.log(rowData,'*****',searchValue.toUpperCase());
}
});
});`
And give me valuable suggestions about my style of code
rowData is a promise (not a value), so when you console.log it, you get the promise object
Protractor patches Jasmine to automatically resolve promises within the expect(), so that's how it knows to resolve the value and compare to the expected result.
If you want to console.log the value, you need to resolve the promise with .then() to get the value.
rowData.then(function(rowDataText) {
console.log(rowDataText);
)}
This is pretty much everyone's first question when they start using protractor. You will want to learn how promises work if you want a good understanding of how to manipulate them.

CKEDITOR - Set Caret to end

I'm working a lot with positioning within CKEDITOR.
But i still can't figure out why the following code
sometimes doesn't work?
var range = new CKEDITOR.dom.range(editor.document);
range.moveToElementEditablePosition(element, setToEnd);
editor.getSelection().selectRanges([range]);
I think that it has something to do with the element input that i'm giving.
But i'm not sure.
Does anybody know what are the requirements for the moveToElementEditbalePosition to work?
The last time that i checked my input was a SPAN Element.
http://docs.ckeditor.com/#!/api/CKEDITOR.dom.range-method-moveToElementEditablePosition
Or is there a more secure(cross-browser) solution?
==== edit ====
I found an error, And it's coming from the new CKEDITOR.dom.range
TypeError: b is undefined
This means that editor.document is empty, but when i look in the editor.document it's filled?
When i'm trying to set the range a second time after the error also it shows the following error: uncaught exception: DOMException: INVALID_STATE_ERR
Try this HTML:
<p><span id="test">Text</span></p>
And this JS:
var e = CKEDITOR.instances.editor1;
var span = e.document.getById( 'test' );
var range = e.createRange();
range.moveToElementEditablePosition( span, 1 );
range.select();
e.insertText( 'FOO' );
range.moveToElementEditablePosition( span );
range.select();
e.insertText( 'BAR' );
The result seems to be correct:
<p><span>BARTextFOO</span></p>
Do you have any other cases?

FB.api() object type as a variable

I have written the code below:
function processLWO(lwo,type)
{
FB.api('me/'+lwo,
'post',
{shoe :'<%=sItemURL%>',object :'<%=sItemURL%>'},
function (response)
{
//code
}
);
}
My problem is with the following line of code:
//Code that works - Code A
shoe :'<%=sItemURL%>',object :'<%=sItemURL%>'
//Code I want to use - Code B
type.toString():'<%=sItemURL%>'
Code A works but I want to implement Code B because it is more flexible however Code B returns a Javascript error stating the original function that lead to this function is undefined. I understand type.toString() should be a Facebook object (for example, shoe or object) but if type.toString() is processed and returns a value then it would be evaluated as a valid object type.
Any suggestions how to solve this? Code A is just so lazy/stupid....
var params = {};
params[type] = <%=sItemURL%>'
FB.api('/me/' + lwo, 'POST', params, ...

Cannot call method 'instance' of undefined

When using the following code;
var pvChart = new pv.Panel();
pvChart.width(200);
pvChart.height(200);
var pvBar = pvChart.add(pv.Bar);
pvBar.data([1,2,3]);
console.log(pvBar.fillStyle());
I get the error;
Cannot call method 'instance' of
undefined
It refers to the pvBar.fillStyle(). Using this I want to retrieve the bars fillStyle for later use. Can anyone tell me the reason of this error and how to solve this?
SOLVED
it was because I was requesting the fillStyle before the bar has been drawn..
Correct code;
var pvChart = new pv.Panel();
pvChart.width(200);
pvChart.height(200);
var pvBar = pvChart.add(pv.Bar);
pvBar.data([1,2,3]);
pvChart.render();
console.log(pvBar.fillStyle());

AMFPHP overiding default function arguments?

I've got this odd problem.
If I make a call on that function through amfphp service browser and give it a valid ID and leave the $num_images field blank amfphp will actually pass a blank string as the argument.
// if i call this function width just an ID
function getWorkers($id, $num_images = 100) {
...
// num_images will be set as ''
}
I can easily override using a check:
function getWorkers($id, $num_images = 100) {
if($num_images=='') $num_images = 100;
...
// num_images will now be really set as 100
}
Anyone experiencing the same with amfphp?
That's odd, I never got that from AMFPHP. If you don't have the latest version try updating your installation of AMFPHP. Also make sure Flash doesn't somehow pass an empty variable as the second variable.
(Copied from the comment.)