javascript web3.js library error - web3

Im trying to make web3.js library working, however still getting errors. The one I can't deal with is
var require=(
function(){
function t(e,n,r){......}
( // the line 21
{........},{},["Web3"] // Web3 in question
)("Web3")
}
);
line 21: TypeError: Web3 is not a function.
Any suggestion ?

Add web3 in the js
<script src="./web3/dist/web3.min.js"></script>

You need to import web3. See 'Installation' here: https://github.com/ChainSafe/web3.js

Related

Angular 6 - Ng-fullcalendar issue

The following is my runtime enviroment:
Angular CLI version 6.
ng-fullcalendar version 1.6.2.
fullcalendar vesion 3.6.1
HTML code:
<div *ngIf="calendarOptions">
<ng-fullcalendar
#ucCalendar
[options]="calendarOptions"
(select)="select($event.detail)"
(eventClick)="eventClick($event.detail)"
(eventDrop)="updateEvent($event.detail)"
(eventResize)="updateEvent($event.detail)"
[(eventsModel)]="events"
(viewRender)="loadEvents($event.detail)"
></ng-fullcalendar>
</div>
Component code:
this.events = resp.data.items.map(item => ({
start: moment(item.startTime).toDate(),
end: moment(item.toTime).toDate(),
item
}));
When I try to load events, it shows this error:
core.js:1673 ERROR TypeError: Cannot read property 'footprint' of undefined
at HTMLDivElement.<anonymous> (fullcalendar.js:5773)
at Function.each (jquery.js:381)
at jQuery.fn.init.each (jquery.js:203)
at constructor.renderFgSegEls (fullcalendar.js:5768)
at constructor.renderFgRanges (fullcalendar.js:5668)
at constructor.render (fullcalendar.js:5652)
at members.constructor.executeEventRender (fullcalendar.js:6559)
at constructor.executeEventRender (fullcalendar.js:17772)
at Object.func (fullcalendar.js:8294)
at constructor.runTask (fullcalendar.js:2667)
This might not be the solution but it is a workaround. I had the same error as yours but I'm running FullCalendar v3.10.1.
The issue might not be in your code but in the jQuery version you are running. FullCalendar broke when I went from jQuery v3.2.1 to v3.5.1.
I reverted back to jQuery v3.4.1 and it's working again.
For those that for whatever reason need jQuery#^3.5.0, you can use similar method described in the jQuery issue describing 3.5 incompatible with FullCalendar 3. The code fixing this problem can be found at the top of this jsfiddle:
var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi;
jQuery.htmlPrefilter = function( html ) {
return html.replace( rxhtmlTag, "<$1></$2>" );
};
But please be aware that this functionality was removed from jQuery as a security fix and by using this, you're exposing yourself to that attack vector again.

Processing error after upgrade to Version 6.0

With the following function I am trying to load the model into the earlier initialized viewer.
viewer.loadModel("https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6aW1wbGVuaWFfaW1kL1JhaV8wNC4zZHM/manifest/urn%3Aadsk.viewing%3Afs.file%3AdXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6aW1wbGVuaWFfaW1kL1JhaV8wNC4zZHM%2Foutput%2FRai_04.3ds.svf")
Unfortuneately I get the following error for the function:
viewer3D.js:74844 Error while processing SVF: {"url":"https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6aW1wbGVuaWFfaW1kL1JhaV8wNC4zZHM/manifest/urn%253Aadsk.viewing%253Afs.file%253AdXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6aW1wbGVuaWFfaW1kL1JhaV8wNC4zZHM%252Foutput%252FRai_04.3ds.svf?domain=http%3A%2F%2Flocalhost%3A3002","httpStatus":400,"httpStatusText":"Bad Request","data":{"url":"https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6aW1wbGVuaWFfaW1kL1JhaV8wNC4zZHM/manifest/urn%253Aadsk.viewing%253Afs.file%253AdXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6aW1wbGVuaWFfaW1kL1JhaV8wNC4zZHM%252Foutput%252FRai_04.3ds.svf?domain=http%3A%2F%2Flocalhost%3A3002"}}
This is the way I initialize my viewer:
function onInitialized() { //console.log("viewer inizialized");
var config = Autodesk.Viewing.createViewerConfig();
config.extensions.push('Autodesk.Viewing.ZoomWindow');
config.startOnInitialize = true;
config.theme = 'light-theme';
viewerApp = new Autodesk.Viewing.ViewingApplication('main-viewer');
viewerApp.registerViewer(viewerApp.k3D,Autodesk.Viewing.Private.GuiViewer3D ,config);
viewer = viewerApp.getViewer(config);
viewer.start();
If I use the version 4.1 of the viewer, the model can be loaded this way. Changing to 6.0 the above described error appears.
I would really appreaciate a hint to a solution of my problem!
Thanks a lot in advance!
Cheers,
Felix
With v6 and onwards, call wrapper method Viewer3D.load insteadof .loadModel so that the resource requests made to Forge endpoints can be formed properly:
viewer.load('https://developer.api.autodesk.com/derivativeservice/v2/derivatives/urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMvd2Fycmlvci4zZHM/output/warrior.3ds.svf');
or simply:
viewer.start(svfUrl)
Code sample: https://jsfiddle.net/dukedhx/9qncbuLt

Loading Aurelia breaks Google API

I have created a reproduction of this bug here (ugly use of Aurelia but to prove the point): https://jberggren.github.io/GoogleAureliaBugReproduce/
If I load Google API and try to list my files in Google Drive my code derived from Googles quickstart works fine. If I use the same code after loading Aurelia I get a script error from gapi stating
Uncaught Error: arrayForEach was called with a non array value
at Object._.Sa (cb=gapi.loaded_0:382)
at Object._.eb (cb=gapi.loaded_0:402)
at MF (cb=gapi.loaded_0:723)
at Object.HF (cb=gapi.loaded_0:722)
at Object.list (cb=gapi.loaded_0:40)
at listFiles (index.js:86)
...
When debugging it seems to be some sort of array check (Chroms says 'native code') that failes after Aurelia is loaded. In my search for an answer I found two other people with the same problem but no solution (Aurelia gitter question, SO Question). Don't know if to report this to the Aurelia team, Google or where the actual problem lays.
Help me SO, you are my only hope.
This is not a perfect solution but works.
aurelia-binding
https://github.com/aurelia/binding/blob/master/src/array-observation.js
Aurelia overrides Array.prototype.* for some reasons.
gapi (especially spreadsheets)
Gapi lib checks to make sure that is it native code or not.
// example
const r = /\[native code\]/
r.test(Array.prototype.push)
conclusion
So, we have to monkey patching.
gapi.load('client:auth2', async () => {
await gapi.client.init({
clientId: CLIENT_ID,
discoveryDocs: ['https://sheets.googleapis.com/$discovery/rest?version=v4'],
scope: 'https://www.googleapis.com/auth/spreadsheets',
});
// monkey patch
const originTest = RegExp.prototype.test;
RegExp.prototype.test = function test(v) {
if (typeof v === 'function' && v.toString().includes('__array_observer__.addChangeRecord')) {
return true;
}
return originTest.apply(this, arguments);
};
});

Programmatically loading a ES6 module with Traceur in web page

I have been using Traceur to develop some projects in ES6. In my HTML page, I include local Traceur sources:
<script src="traceur.js"></script>
<script src="bootstrap.js"></script>
and if I have a module in the HTML afterwards like:
<script type="module" src="foo.js"></script>
Then Traceur loads in that module, compiles it and everything works great.
I now want to programmatically add an ES6 module to the page from within another ES6 module (reasons are somewhat complicated). Here was my first attempt:
var module = document.createElement('script');
module.setAttribute('type', 'module');
module.textContent = `
console.log('Inside the module now!');
`;
document.body.appendChild(module);
Unfortunately this doesn't work as Traceur does not monitor the page for every script tag added, I guess.
How can I get Traceur to compile and execute the script? I guess I need to invoke something on either 'traceur' or '$traceurRuntime' but I haven't found a good online source of documentation for that.
You can load other modules using ES6 import statements or TraceurLoader API for dynamic dependencies.
Example from Traceur Documentation
function getLoader() {
var LoaderHooks = traceur.runtime.LoaderHooks;
var loaderHooks = new LoaderHooks(new traceur.util.ErrorReporter(), './');
return new traceur.runtime.TraceurLoader(loaderHooks);
}
getLoader().import('../src/traceur.js',
function(mod) {
console.log('DONE');
},
function(error) {
console.error(error);
}
);
Also, System.js loader seems to be supported as well
window.System = new traceur.runtime.BrowserTraceurLoader();
System.import('./Greeter.js');
Dynamic module loading is a (not-yet-standardized) feature of System:
System.import('./repl-module.js').catch(function(ex) {
console.error('Internal Error ', ex.stack || ex);
});
To make this work you need to npm test then include BrowserSystem
<script src="../bin/BrowserSystem.js"></script>
You might also like to look into https://github.com/systemjs/systemjs as it has great support for browser loading.
BTW the System object may eventually be standardize (perhaps under a different name) in the WHATWG: http://whatwg.github.io/loader/#system-loader-instance

Uncaught TypeError: this.EventDispatcher_initialize is not a function createjs error

i am following a famous book "beginning html5 game development with createjs.pdf " Apress Publication .
Anyhow when i run the codes i get error in my browser console : i updated my createjs hosted lib to latest version
gs skinner github i found p.initialize =function is deprecated .
i am not a good programmer. is there any way so that i can fix the error and run the codes of this book. thanks
Uncaught TypeError: this.EventDispatcher_initialize is not a function
AssetManager.js:34 Uncaught TypeError:
here i pasted few lines for 34 to last of function
p.initialize = function () {
this.EventDispatcher_initialize();
this.loadManifest = [
{id:this.EXPLOSION, src:this.assetsPath + 'explosion.mp3'},
{id:this.SOUNDTRACK, src:this.assetsPath + 'dreamRaid1.mp3'},
{id:this.GAME_SPRITES_DATA, src:this.assetsPath + 'all.json'},
{id:this.GAME_SPRITES, src:this.assetsPath + 'all.png'}
];
}
Can you show more of your code? The this.EventDispatcher_initialize is used with early inheritance approaches, as well as with the newer extend/promote approach.
If you are using the old approach, there should be a line above this one that says:
p.EventDispatcher_initialize = p.initialize;
This stores the superclass (EventDispatcher) method on the current class prototype first, so you can call it to apply the default functionality. You should also see something like this at the top, which sets up the inheritance:
function MyClass() {
this.initialize();
}
var p = MyClass.prototype = new createjs.EventDispatcher();
If you are missing any of these steps, your code will not work.