Implementing PDF.js Viewer example - javascript

I am running into an issue trying to implement the PDF.js viewer demo found here, but I keep running into an issue that certain properties are not being set. Checking the console there are two errors that I get:
First error:
app.js:883 Uncaught (in promise) TypeError: Cannot read property 'setPagesCount' of null
at Object.load (app.js:883)
at app.js:666
Second error:
app.js:870 Uncaught (in promise) TypeError: Cannot read property 'then' of undefined
at app.js:870
I have tried resolving this issue by diving through the code myself, and comparing it to the example with no luck. I have also looked around online trying to figure out why this may be happening and have still come up empty handed. It seems to me that this.toolbar is not being set with anything in the first error, but I cannot figure out why this may be.
Through looking around online, I believe I am setting this up properly, but am not 100% positive. Here is my setup:
<script type="text/javascript">
$(document).ready(function () {
var pdfDoc = '#pdf';
// Open the default file after the document is ready. Otherwise, PDFViewerApplication probably won't exist.
PDFViewerApplication.open(pdfDoc);
});
</script>
Has anyone ever experienced this before and would be able to help? If not, does anyone know where I can start to look?
An additional note is that I have moved the files outside of their original build and web directories. I thought that I changed the configuration paths in viewer.js to accommodate this, but perhaps I missed one?

It appears that my issue was do to me not adding the link resource for locale.properties in my HTML. Turns out the first error I was getting was more of a red herring, and was able to solve this issue by focusing on the second error.
I added this:
<link rel="resource" type="application/l10n" href="[your path to]/locale/locale.properties">
Where all the HTML for the viewer is located and it loaded right up.

Related

OrbitControls.js - Cannot read property 'prototype' of undefined

I am starting a project in Three.js and I have correctly imported the library OrbitControls.js, but when I open the console to test it, I see the following error:
Cannot read property 'prototype' of undefined
And it is related to the following line code inside OrbitConstrols.js:
THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );
I found similar examples that research a solution for this problem, like this one, but it is made for Typescript.
Do you know a possible way to solve this issue? Or it is simply a bug of the library and even if I get an error, the object will be properly rendered?
I don't know how you are adding this in your HTML but the order matters when adding OrbitControls as it needs certain things from Three.js.
It should be
<script src="../build/three.min.js"></script>
<script src="js/controls/OrbitControls.js"></script>
The examples are the best way to figure out what is wrong - threejs.org/examples/misc_controls_orbit.html

Wikitude SDK project derived from samples doesn't work

I've been modifying the sample projects Wikitude SDK provides, and I'm facing a problem: it seems like this code never works:
this.tracker = new AR.Tracker("/assets/magazine.wtc", {
onLoaded: this.worldLoaded
});
That is, the world never loads, so the function "worldLoaded" is never called.
I have no idea why the world doesn't load as the file is the original provided in the samples and it used to work.
The difference seems to be trivial, I only added a new member to the World variable that would define some additional parameteres.
The error I get is
Uncaught TypeError: Cannot read property 'apply' of undefined
ade.js:1AR.i.__executeFunctionByName ade.js:1AR.i.callAsync ade.js:1l
Any idea how to tackle this?
It seems as if you have the ADE activated, which is not necessary on a mobile device. In your HTML, please delete the line (your path to ade.js might differ slightly). This will make the error go away.
In addition, my suggestion is to also add an onError event to the tracker. In this case, you'll be notified when the tracker cannot be loaded (wrong location specified, invalid file etc), and you can react accordingly.

Uncaught TypeError without ability to find the reason

Every time I right-click anywhere in my Application, jQuery is going to throw an error at line 5095 saying:
Uncaught TypeError: undefined is not a function
To find the cause of this error I tried two ways without success:
1. Debug jQuery:
In the Dev-Tool's I debug jQuery at Line 5095. The Problem: When I move the cursor over the page, it will stop and break. I have NO possibility to get it to make a right click. Even if I press play in Chrome's Debug-Line which appears, it will instantly fire again, even if I won't move the cursor!
2. Searching the reason in my code:
Since this Error is thrown for a long time now I cannot tell where to search. I have multiple js-files. So I realized the error is being thrown when I release the mouse-button. So I searched ALL my code for ANY mouse(-up/down)-events without success (found several that wont fire if I set breakpoints)
Now I am out of ideas how to find the source of it. I thought debugging the line of jQuery where the error is thrown would give me access to the stack variables with possibly more information about its source. Any suggestions?
Please don't ask me to post code. Since I can't tell where the mistakes happen I might post thousands of lines of JavaScript. I need a logical way to find the Errorsource.
the error definitely isn't in jquery or jquery-ui files. it's most definitely in a plugin's code or your custom code.
think of where the error might be. just do a basic estimation. and put a console.log() before those lines and run it again. see if the error occurs before the console output. if it happens before, investigate the code that executes before this line and the javascript files that are included before this file. if it happens after do the opposite. You can narrow down by putting multiple console.log()s
you can look at events with
$._data(element, "events")
but you cant see where the bind is in your code
maybe someone knows

Uncaught ReferenceError: chrome_fix3 is not defined _cmp_execLogic._cmp_suclick

I am getting the following error. How can I resolve this?
Uncaught ReferenceError: chrome_fix3 is not defined
_cmp_execLogic._cmp_suclick
Good news - the error is nothing to do with your site.
Bad news - it's caused by an erroneous browser extension that's injecting invalid javascript into your pages. I have an ever increasing list of similarly caused errors that we can do nothing other than trap and ignore. At some point I intend to feed a message back to the user that something they have installed may cause problems on our sites, but ideally I'd like to tell them exactly what extension is causing the issue, which I don't know in all cases.
If anyone knows where the attempt to reference "chrome_fix3" actually comes from, please add to this post.
A similar error that we trap but is nothing to do with our code is:
Uncaught ReferenceError: conduitPage is not defined
I found the following pages helpful when investigating the error:
https://webmademovies.lighthouseapp.com/projects/65733/tickets/2895-crash-referenceerror-conduitpage-is-not-defined
http://www.youtube.com/user/conduityoursite#g/c/4B820DE13E03888D
Your code tries to refer to a variable or property that does not exist, in your case it's named chrome_fix3.
This probably came from a javascript libary that you are using, maybe jQuery or something.
I assume that the library is fine and it's caused by wrongfully calling some of it's functions.
The best way now is to install the Firebug plugin in Firefox (you could use Chrome, Opera or Internet Explorer's debugger but I like Firebug best)
Then add following code in your code where you think it's going wrong:
//add the following line only once:
var okCounter=0;
// add teh following line every couple of lines in your code:
console.log("still ok here:",okCounter++);
Open your page in Forefox and hit F12, the Firebug window should show up now. Reload the page and check out the console tab.
At some point you should notice there is no more output to the console where there should be; now you have found the part in your code where something goes wrong. If you post that part we might be able to help you out more.

Uncaught TypeError: Cannot read property '1' of undefined

trying to fiddle with an app, getting this error "Uncaught TypeError: Cannot read property '1' of undefined "in dev tools console. i'm pretty sure it's because of the json i'm pulling and the proxy i'm using are not talking to each other correctly. seriously n00b question, i truly don't understand what's going on in the document. i also see that there are ALOT of similar questions like this, so i'm guessing they're pretty localized and not great for the community. still important to me though...i'd like to learn what's going on in the code, not just fix the problem. you can check it out here: http://dev.bowdenweb.com/busfinder.html i did put it up on jsfiddle, but it wasn't rendering correctly. thanks for any and all advice!
loadBusesIntoMap seems to be the root of the problem. On Chrome developer tools, click on the arrow next to the error and track the stack. Just before running Google maps code the function that throws error is that one. It's very probable that somewhere you're sending an empty buses array. I'd start by checking if it's empty or has a length first...

Categories

Resources