@@ -137,20 +137,32 @@ export const downLoad_notebook = (state) => {
137137 * @param {Array } array of package CDNs to load
138138 * @param {* } callback
139139 */
140- export const load_package = ( array , callback ) => {
140+ // eslint-disable-next-line consistent-return
141+ const load_package = async ( array , callback ) => {
141142 try {
142- // document.getElementById("cell-running").style.display = "block";
143+ document . getElementById ( "play" ) . style . display = "none" ;
144+ document . getElementById ( "activity-loader" ) . style . display = "block" ;
143145 const loader = function ( src , handler ) {
144146 const script = document . createElement ( "script" ) ;
145- console . log ( src ) ;
146147 script . type = "text/javascript" ;
147148 script . src = src ;
148- const a = "https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest" ;
149- console . log ( a ) ;
150149 script . onload = script . onreadystatechange = function ( ) {
151150 script . onreadystatechange = script . onload = null ;
151+ document . getElementById ( "play" ) . style . display = "block" ;
152+ document . getElementById ( "activity-loader" ) . style . display = "none" ;
153+ document . getElementById ( "cell-output" ) . innerHTML =
154+ "Package sucessfully loaded" ;
155+ document . getElementById ( "cell-output" ) . style . color = "white" ;
152156 handler ( ) ;
153157 } ;
158+ script . onerror = function ( error ) {
159+ document . getElementById ( "play" ) . style . display = "block" ;
160+ document . getElementById ( "activity-loader" ) . style . display = "none" ;
161+ document . getElementById (
162+ "cell-output"
163+ ) . innerHTML = `Failed to load package ${ error . path [ 0 ] . src } . Check internet connection or package url` ;
164+ document . getElementById ( "cell-output" ) . style . color = "red" ;
165+ } ;
154166 script . async = true ;
155167 document . body . appendChild ( script ) ;
156168 eval ( script ) ;
@@ -162,8 +174,8 @@ export const load_package = (array, callback) => {
162174 // eslint-disable-next-line no-unused-expressions
163175 callback && callback ( ) ;
164176 }
165- // document.getElementById("cell-running").style.display = "none";
166177 } ) ( ) ;
178+ return "done" ;
167179 } catch ( error ) {
168180 console . log ( error ) ;
169181 }
0 commit comments