How to import Js libraries into SL playground? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

How to import Js libraries into SL playground?

Hello guys, Iā€™m currently working with Js and Iā€™d like to import a library into SL playground. How can I do it?

30th Jun 2019, 6:34 PM
Gintonic
Gintonic - avatar
17 Respostas
30th Jun 2019, 8:53 PM
dĻlĻ…Ń•ĻlĻ…Ń•
dĻlĻ…Ń•ĻlĻ…Ń• - avatar
+ 6
I don't know what libraries you have in mind, but maybe you can use CDN and link them in your project. https://cdnjs.com/
30th Jun 2019, 8:44 PM
dĻlĻ…Ń•ĻlĻ…Ń•
dĻlĻ…Ń•ĻlĻ…Ń• - avatar
+ 6
Of course, like any other script link. āœŒļø
30th Jun 2019, 11:46 PM
dĻlĻ…Ń•ĻlĻ…Ń•
dĻlĻ…Ń•ĻlĻ…Ń• - avatar
+ 5
Great, it's looking amazing. Window.onload is not written correctly. Put this instead of the first line: window.onload= function() { When I uncomment the seventh line it works fine for me. šŸ™ŒšŸ™Œ
3rd Jul 2019, 2:15 PM
dĻlĻ…Ń•ĻlĻ…Ń•
dĻlĻ…Ń•ĻlĻ…Ń• - avatar
+ 4
You obviously have one extra closing braces in line 10, read the error report. However, it seems that won't solve the issue. One more file is missing, you'll need to read the official documents and also this thread on github : https://github.com/dwa012/html5-qrcode/issues/36 https://code.sololearn.com/WZbCZ756EC7Z/?ref=app
1st Jul 2019, 12:47 PM
dĻlĻ…Ń•ĻlĻ…Ń•
dĻlĻ…Ń•ĻlĻ…Ń• - avatar
+ 3
Alright. I don't know what else to tell, except to try their official example maybe that will work for you : https://davidshimjs.github.io/qrcodejs/
1st Jul 2019, 4:08 PM
dĻlĻ…Ń•ĻlĻ…Ń•
dĻlĻ…Ń•ĻlĻ…Ń• - avatar
+ 2
Yes, that should be added too to your project. That's why you see that error. I see a qr code ? It shows every time. Maybe you should try this code outside sololearn.
1st Jul 2019, 3:40 PM
dĻlĻ…Ń•ĻlĻ…Ń•
dĻlĻ…Ń•ĻlĻ…Ń• - avatar
+ 2
dĻlĻ…Ń•ĻlĻ…Ń• are you able to see different profiles by changing the ā€œprofile numberā€ input? For example: your profile number is 2251477. Thus, once you put it into the first input the qrcode should lead to your profile page because itā€™s sololearn.com/profile/2251477 EDIT: iā€™ve added .toString() method in the 7th line so that the number typed in the input turns into a string. But still doesnā€™t work out properly. There must be an error in the 78th line EDIT2: solved!
4th Jul 2019, 7:44 PM
Gintonic
Gintonic - avatar
+ 1
hi dĻlĻ…Ń•ĻlĻ…Ń• , thanks for answering. I need to use the qrcode.js library and implement it into the HTML code
30th Jun 2019, 8:46 PM
Gintonic
Gintonic - avatar
+ 1
So i just need to type in the HTML <script type=ā€œtext/javascriptā€ src=ā€œhttps://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.jsā€></script> Right?
30th Jun 2019, 8:57 PM
Gintonic
Gintonic - avatar
1st Jul 2019, 6:35 AM
Gintonic
Gintonic - avatar
+ 1
https://code.sololearn.com/WO8yZOtCk7Lr/?ref=app Canā€™t find out why it says ā€œSyntax Errorā€ šŸ¤”
1st Jul 2019, 9:06 AM
Gintonic
Gintonic - avatar
+ 1
Thanks for your patience, i know itā€™s annoying... Almost finished my code, just miss the qrcode script implementation https://code.sololearn.com/Wpw8c3rVXKa9/?ref=app
1st Jul 2019, 4:14 PM
Gintonic
Gintonic - avatar
+ 1
Ok dĻlĻ…Ń•ĻlĻ…Ń• good news, found a way to display the qrcode through JQuery!!šŸ™Œ Now just have to solve the problem at line 64 of the Js file. That inp1 var is not recognised
3rd Jul 2019, 1:51 PM
Gintonic
Gintonic - avatar
0
The error is: ReferenceError: Can't find variable: QRCode at Line: 1 Got few questions. That one in the Js section is a library? Run your code but it shows nothing, just a white background
1st Jul 2019, 2:33 PM
Gintonic
Gintonic - avatar
0
Ok found that it doesnā€™t work on ios devices. Then i pasted the code on Codepen (pc) to see if it works and it doesnā€™t. You can check it here ā€”> https://codepen.io/Gintonicc/pen/EBEWev
1st Jul 2019, 3:59 PM
Gintonic
Gintonic - avatar
0
The problem is that the qrcode shows just the link https/sololearn.com/profile while it should display the https:/sololearn.com/profile/ + number of the profile (which you put in the first input). Thatā€™s like the inp1 var doesnā€™t work
3rd Jul 2019, 2:43 PM
Gintonic
Gintonic - avatar