How to import external Javascript file
my home.js file is getting very large, about 1500 lines of code. It contains many functions that are called within the same file, for example:
////////////////////////////////////////////////////////////////////////////////////////////
//\\ ** PULSANTE MOSTRA PARTI DI RICAMBIO ** //\\
// questa funzione rende trasparente tutto il modello e suddivide con un codice colori le classifiche ricambi
// lancia inoltre l'apertura di un pannello laterale
$scope.showSpareParts=function(button, parameter){
console.log("funziona")
if(button == "spareParts"){
if(parameter == "pressed"){ // => pulsante premuto
$scope.app.view.Home.wdg['gridLayout-12']['visible'] = true;
//tml3dRenderer.setProperties($scope.app.cad.ModelID , {hidden : true});
//tml3dRenderer.setProperties ($scope.app.cad.ModelID,{phantom:true, opacity:0.5})
tml3dRenderer.setProperties ($scope.app.cad.ModelID, {opacity: 0.20}); // => rende trasparente TUTTO il modello, comprese le parti di ricambio
//tml3dRenderer.GetObject($scope.app.cad.ModelID).GetWidget().ApplyOccludeOpacity(0.0,0.1);
for(i=0; i<$scope.app.cad.listaRicambi.length; i++){
//tml3dRenderer.setProperties($scope.app.cad.listaRicambi[i].idPath, {hidden : false});
tml3dRenderer.setProperties($scope.app.cad.listaRicambi[i].idPath, {opacity : 1}); // => serve per togliere la trasparenza
if($scope.app.cad.listaRicambi[i].CLASSIFICA_RICAMBI == '01'){ // MECCANICI => NERO
console.log("case 01")
tml3dRenderer.setColor($scope.app.cad.listaRicambi[i].idPath, "rgba(0,0,0,255)");
}else if($scope.app.cad.listaRicambi[i].CLASSIFICA_RICAMBI == '02'){ // PNEUMATICI => ARANCIONE
console.log("case 02")
tml3dRenderer.setColor($scope.app.cad.listaRicambi[i].idPath, "rgba(255,165,0,255)");
}else if($scope.app.cad.listaRicambi[i].CLASSIFICA_RICAMBI == '03'){ // ELETTRICI/ELETTRONICI => VERDE
console.log("case 03")
tml3dRenderer.setColor($scope.app.cad.listaRicambi[i].idPath, "rgba(60,179,113,255)");
}else if($scope.app.cad.listaRicambi[i].CLASSIFICA_RICAMBI == '04'){ // MATERIALI DI CONSUMO => VIOLA
console.log("case 04")
tml3dRenderer.setColor($scope.app.cad.listaRicambi[i].idPath, "rgba(106,90,205,255)");
}else if($scope.app.cad.listaRicambi[i].CLASSIFICA_RICAMBI == '05'){ // CRITICI => ROSSO
console.log("case 05")
tml3dRenderer.setColor($scope.app.cad.listaRicambi[i].idPath, "rgba(255,0,0,255)");
}else if($scope.app.cad.listaRicambi[i].CLASSIFICA_RICAMBI == null){
$scope.app.cad.blue($scope.app.cad.listaRicambi[i].idPath)
console.log("campo null")
}
}
}else if(parameter == "unpressed"){
console.log("entro nell'if 2")
$scope.app.view.Home.wdg['gridLayout-12']['visible'] = false; //nasconde il pannello laterale
tml3dRenderer.setProperties($scope.app.cad.ModelID ,{opacity : 1});
//devo aggiungere l'opzione per togliere il colore ai ricambi, una sorta di reset
}
//$scope.app.view.Home.wdg['buttonUnhide']['visible'] = false; //nascondo pulsante per reimpostare tutti i componenti
//$scope.app.view.Home.wdg['buttonUndo']['visible'] = false; //nasconde pulsante per l'undo
//$scope.app.cad.idToUnhide=[]; //toglie tutti gli id da nascondere
}else if(button == "buttonHideModel"){
$scope.hideModelNOSpare();
//gestione dei pulsanti, il primo if controlla che il parametro button sia corretto
}
}
My idea is to create an additional function.js file where save all this function and save the file into a folder on my pc, which one could be accessed by all my experience. In this way all my project will become much smart.
I try the procedure posted here: https://community.ptc.com/t5/Vuforia-Studio/Include-Java-Script-Dokuments/m-p/616826 but when I try to call for example $scope.showSpareParts the console tell me that this is not a function.
p.s. for the moment I put function.js into "app/...Upload/function.js".
Anyone could help me?

