there are some Javascript scripts that I try to import into my project, but most of them always get the error> Uncaught ReferenceError, what am I doing wrong when importing these scripts? below an example of the functional html code :
Code: Select all
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="https://cdn.metroui.org.ua/v4/css/metro-all.min.css">
</head>
<body>
<h1 class="text-center">Metro 4</h1>
<h3 class="text-center">The Components Library</h3>
<div data-role="cube"></div>
<script src="https://cdn.metroui.org.ua/v4/js/metro.min.js"></script>
</body>
</html>
at metro.js: 5450
screenshot : https://prnt.sc/100xl1l
below the SB code that I'm using :
Code: Select all
ExamineDesktops()
Global deskwidth.i = DesktopWidth(0)
Global deskheight.i = DesktopHeight(0)
Declare ButtonClick(index)
Procedure AppendHead(content.s)
Debug "head"
!$("head").append(v_content);
EndProcedure
Procedure AppendBody(content.s)
!$("body").append(v_content);
EndProcedure
Procedure AppendContent(component.i,content.s, Position = #PB_Ignore)
GID = GadgetID(component)
If Position <> #PB_Ignore
! $(".card:eq(" + v_position + ")").prepend(v_content);
Else
! $(v_gid.div).append(v_content);
EndIf
EndProcedure
Procedure OnResize()
ExamineDesktops()
deskwidth = DesktopWidth(0)
deskheight = DesktopHeight(0)
Debug "Resized W : " + Str(deskwidth)
Debug "Resized H : " + Str(deskheight)
ResizeWindow(0,#PB_Ignore,#PB_Ignore,deskwidth,deskheight)
ResizeGadget(0,#PB_Ignore,#PB_Ignore,deskwidth,deskheight)
EndProcedure
Procedure Main(URL$, Success)
Debug "Script URL: " + URL$
Debug "Loading status: " + Success
OpenWindow(0, 0, 0, 600, 600, "",#PB_Window_Background)
ScrollAreaGadget(0, 0, 0, deskwidth, deskheight,600,600) : CloseGadgetList()
AppendContent(0," <h1 class='text-center'>Metro 4</h1>"+
" <h3 class='text-center'>The Components Library</h3>"+
" <div Data-role='cube'></div> ")
EndProcedure
Procedure ButtonClick(indice)
Debug "ButtonClick(" + indice + ")"
EndProcedure
Procedure init(URL$, Success)
Debug "Script URL: " + URL$
Debug "Loading status: " + Success
; ! $("<link rel='stylesheet' type='text/css'>").attr("href", "https://cdn.metroui.org.ua/v4/css/metro-all.min.css").appendTo("head");
; ! require(["https://cdn.metroui.org.ua/v4/js/metro.min.js"], function() {
; Main()
; ! });
LoadScript("https://cdn.metroui.org.ua/v4/js/metro.min.js",@Main(),#PB_Script_JavaScript)
EndProcedure
BindEvent(#PB_Event_SizeDesktop,@OnResize())
AppendHead("<meta http-equiv='cache-control' content='max-age=0' />' />"+
"<meta http-equiv='pragma' content='no-cache' />"+
"<meta http-equiv='cache-control' content='no-store' />"+
"<meta http-equiv='expires' content='Tue, 01 Jan 1980 1:00:00 GMT' />' />"+
"<meta http-equiv='expires' content='-1' />")
AppendHead("<meta http-equiv='Content-Security-Policy' content='upgrade-insecure-requests'>")
AppendHead("<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'>")
;! $("<link rel='stylesheet' href='https://cdn.metroui.org.ua/v4/css/metro-all.min.css' />").appendTo("head");
LoadScript("https://cdn.metroui.org.ua/v4/css/metro-all.min.css", @init(), #PB_Script_CSS)