@@ -26,7 +26,7 @@ var GUI = {
2626 highlight_puredirect : false ,
2727 allow_intermediate_adjustment : true ,
2828 activate_path_style : function ( s , b ) {
29- var sty = DAGitty . stylesheets . default . style
29+ var sty = Models4PT . stylesheets . default . style
3030 if ( b ) {
3131 if ( sty [ s + "path_inactive" ] ) {
3232 sty [ s + "path" ] = sty [ s + "path_inactive" ] ;
@@ -38,10 +38,10 @@ var GUI = {
3838 delete sty [ s + "path" ] ;
3939 displayHide ( "legend_" + s ) ;
4040 }
41- DAGittyControl && DAGittyControl . redraw ( ) ;
41+ Models4PTControl && Models4PTControl . redraw ( ) ;
4242 } ,
4343 activate_node_style : function ( s , b ) {
44- var sty = DAGitty . stylesheets . default . style
44+ var sty = Models4PT . stylesheets . default . style
4545 if ( b ) {
4646 if ( sty [ s + "node_inactive" ] ) {
4747 sty [ s + "node" ] = sty [ s + "node_inactive" ] ;
@@ -67,15 +67,15 @@ var GUI = {
6767 this . activate_node_style ( n , b ) ;
6868 } , this ) ;
6969 b ? displayShow ( "legend_ancestors" ) : displayHide ( "legend_ancestors" ) ;
70- DAGittyControl && DAGittyControl . redraw ( ) ;
70+ Models4PTControl && Models4PTControl . redraw ( ) ;
7171 } ,
7272 set_view_mode : function ( vm ) {
7373 let vmel = document . getElementById ( "dagview_" + vm )
7474 vmel . checked ||= true
75- DAGittyControl && DAGittyControl . setViewMode ( vm ) ;
75+ Models4PTControl && Models4PTControl . setViewMode ( vm ) ;
7676 } ,
7777 set_bias_mode : function ( bm ) {
78- DAGittyControl && DAGittyControl . setBiasMode ( bm ) ;
78+ Models4PTControl && Models4PTControl . setBiasMode ( bm ) ;
7979 } ,
8080 refresh_variable_status : function ( ) {
8181 var vid = document . getElementById ( "variable_id" ) . value
@@ -89,14 +89,14 @@ var GUI = {
8989 set_variable_status : function ( n , stat ) {
9090 var vid = document . getElementById ( "variable_id" ) . value
9191 if ( stat ) {
92- DAGittyControl && DAGittyControl . setVertexProperty ( vid , n )
92+ Models4PTControl && Models4PTControl . setVertexProperty ( vid , n )
9393 } else {
94- DAGittyControl && DAGittyControl . unsetVertexProperty ( vid , n )
94+ Models4PTControl && Models4PTControl . unsetVertexProperty ( vid , n )
9595 }
9696 } ,
9797 set_style : function ( s ) {
98- DAGitty . stylesheets . default = DAGitty . stylesheets [ s ]
99- var sty = DAGitty . stylesheets . default . style
98+ Models4PT . stylesheets . default = Models4PT . stylesheets [ s ]
99+ var sty = Models4PT . stylesheets . default . style
100100 document . getElementById ( "highlight_ancestral" ) . checked = typeof ( sty [ "confoundernode_inactive" ] ) === "undefined" ;
101101 document . getElementById ( "highlight_ancestral" ) . checked ? displayShow ( "legend_ancestors" ) : displayHide ( "legend_ancestors" ) ;
102102
@@ -111,7 +111,7 @@ var GUI = {
111111 "outcome" , "rnode" , "adjustednode" ] , function ( n ) {
112112 document . getElementById ( "li" + n ) . src = "images/legend/" + s + "/" + n + ".png"
113113 } , this ) ;
114- DAGittyControl . setStyle ( s )
114+ Models4PTControl . setStyle ( s )
115115 }
116116} ;
117117
@@ -183,7 +183,7 @@ function nl2br (str, is_xhtml) {
183183}
184184
185185function msg ( t ) {
186- DAGittyControl . getView ( ) . openAlertDialog ( t ) ;
186+ Models4PTControl . getView ( ) . openAlertDialog ( t ) ;
187187}
188188
189189function how ( t ) {
@@ -608,7 +608,7 @@ function displayImplicationInfo( full ){
608608}
609609
610610function exportTikzCode ( ) {
611- DAGittyControl . getView ( ) . openHTMLDialog (
611+ Models4PTControl . getView ( ) . openHTMLDialog (
612612 "<textarea style=\"width:80%\" rows=\"10\">" +
613613 "% This code uses the tikz package\n" +
614614 "\\begin{tikzpicture}\n" +
@@ -653,7 +653,7 @@ function loadDAGFromTextData(){
653653 var layouter = new GraphLayouter . Spring ( Model . dag ) ;
654654 layouter . layout ( ) ;
655655 }
656- DAGittyControl . setGraph ( Model . dag ) ;
656+ Models4PTControl . setGraph ( Model . dag ) ;
657657 displayHide ( "model_refresh" ) ;
658658 document . getElementById ( "adj_matrix" ) . style . backgroundColor = "#fff" ;
659659}
@@ -662,7 +662,7 @@ function generateSpringLayout(){
662662 var layouter = new GraphLayouter . Spring ( Model . dag ) ;
663663 _ . each ( Model . dag . edges , function ( e ) { delete e [ "layout_pos_x" ] ; delete e [ "layout_pos_y" ] } )
664664 layouter . layout ( ) ;
665- DAGittyControl . setGraph ( Model . dag ) ; // trigges to refresh the rendering
665+ Models4PTControl . setGraph ( Model . dag ) ; // trigges to refresh the rendering
666666} ;
667667
668668function loadExample ( nr ) {
@@ -684,7 +684,7 @@ function newModel2(ename){
684684 if ( ename === null ) { return false ; }
685685 ename = ( "" + ename ) . trim ( )
686686 if ( ename == "" ) { return false ; }
687- DAGittyControl . getView ( ) . openPromptDialog (
687+ Models4PTControl . getView ( ) . openPromptDialog (
688688 "Please enter name of outcome variable" , "" , function ( s ) {
689689 newModel3 ( ename , s ) } )
690690 return true ;
@@ -695,7 +695,7 @@ function newModel3(ename,oname){
695695 if ( oname == "" || ename == oname ) { return false ; }
696696 document . getElementById ( "adj_matrix" ) . value = ename + " E @0,0\n" + oname + " O @1,1\n\n" + ename + " " + oname
697697 loadDAGFromTextData ( )
698- DAGittyControl . getView ( ) . closeDialog ( )
698+ Models4PTControl . getView ( ) . closeDialog ( )
699699}
700700
701701function supportsSVG ( ) {
@@ -799,9 +799,9 @@ function hostName(){
799799function networkFailMsg ( ) {
800800 msg (
801801 "A network error occurred when trying to perform this function. " +
802- "If you are using a downloaded DAGitty version, this is likely " +
802+ "If you are using a downloaded Models4PT version, this is likely " +
803803 "due to Browser security settings. Try again using the online " +
804- "version of DAGitty ." )
804+ "version of Models4PT ." )
805805}
806806
807807function getModelIdFromURL ( url ) {
@@ -820,31 +820,7 @@ function saveOnlineForm(){
820820 }
821821}
822822
823- /*
824- The original loadOnline function fetched a model from dagitty.net using an API call.
825- This version has been commented out as we are transitioning to using localStorage
826- for saving and loading models. When we implement a backend in the future, we may revisit
827- or adapt this function to integrate with our own backend.
828-
829- async function loadOnline( url ){
830- var graphid = getModelIdFromURL( url )
831- try{
832- const response = await fetch( "https://dagitty.net/db/id/"+graphid )
833- if( response.ok ){
834- const modelsyntax = await response.json()
835- DAGittyControl.getView().closeDialog()
836- document.getElementById("adj_matrix").value = modelsyntax.g
837- Model.uniqid = modelsyntax.g.id
838- loadDAGFromTextData()
839- } else {
840- networkFailMsg(); return
841- }
842- } catch( err ){
843- networkFailMsg();
844- console.log( err );
845- return
846- }
847- } */
823+
848824
849825// New localStorage-based version
850826async function loadOnline ( url ) {
@@ -861,7 +837,7 @@ async function loadOnline(url) {
861837 const modelsyntax = JSON . parse ( modelData ) ;
862838
863839 // Update the UI and render the DAG
864- DAGittyControl . getView ( ) . closeDialog ( ) ;
840+ Models4PTControl . getView ( ) . closeDialog ( ) ;
865841 document . getElementById ( "adj_matrix" ) . value = modelsyntax . g ;
866842 Model . uniqid = graphid ; // Optional: track the graph ID
867843 loadDAGFromTextData ( ) ; // Render the graph
@@ -874,7 +850,7 @@ async function loadOnline(url) {
874850// Updated loadOnlineForm function for localStorage:
875851// This version prompts the user for a Graph ID instead of a URL and loads the model from localStorage.
876852function loadOnlineForm ( ) {
877- DAGittyControl . getView ( ) . openPromptDialog (
853+ Models4PTControl . getView ( ) . openPromptDialog (
878854 "Enter the Graph ID" ,
879855 "exampleGraph123" , // Example placeholder
880856 function ( graphID ) {
@@ -888,16 +864,7 @@ function loadOnlineForm() {
888864}
889865
890866
891- /*
892- The original loadOnlineForm function opened a prompt dialog for the user to enter a URL.
893- This functionality relied on models stored remotely on dagitty.net.
894- As we transition to localStorage, this version has been replaced with one that prompts for a Graph ID instead of a URL.
895867
896- Original code:
897- function loadOnlineForm(){
898- DAGittyControl.getView().openPromptDialog(
899- "Enter the URL","dagitty.net/mOWOV4V",loadOnline)
900- } */
901868
902869 // ----------------------------
903870// Save and Load Functionality
0 commit comments