demos\outlook\notes\notes.js
  1 var notes_viewer_table;
  2 var note_target_num=1;
  3 var notes_config;
  4 
  5 function onChange_notes_navigator() {
  6   if(notes_viewer_table==null) {
  7     notes_viewer_init(widget);
  8   }
  9 }
 10 
 11 /**
 12  *Initializes the notes table, populating it with data
 13  */
 14 function notes_init() {
 15   var v,data
 16   v=window.getViewer("content_stack").getViewer("notes");
 17   notes_viewer_table=v.getWidget();
 18   if(notes_viewer_table.getRowCount()==0) {
 19     data=widget.getURLText("gumbo.txt",null);
 20     if(data==null) {
 21       data="Test\nThis is a test note";
 22     }
 23     var title=sage.getLines(data,1);
 24     var s=sage.getLines(data,3);
 25     if(s==data) {
 26       s+="<end>";
 27     }
 28     notes_table_addRow("resource:pim.icon.notes",title,window.now(),"",data,s)
 29     data=widget.getURLText("knee.txt",null);
 30     if(data!=null) {
 31       title=sage.getLines(data,1);
 32       s=sage.getLines(data,3);
 33       if(s==data) {
 34         s+="<end>";
 35         
 36       }
 37       notes_table_addRow("resource:pim.icon.notes",title,window.now(),"",data,s)
 38     }
 39     data=widget.getURLText("dip.txt",null);
 40     if(data!=null) {
 41       title=sage.getLines(data,1);
 42       s=sage.getLines(data,3);
 43       if(s==data) {
 44         s+="<end>";
 45       }
 46       notes_table_addRow("resource:pim.icon.notes",title,window.now(),"",data,s)
 47     }
 48   }
 49 }
 50 
 51 /**
 52  *Creates and adds a new row to the notes table
 53  *A unique key identifying the note is stored with the row.
 54  *The key will be used as the target name for the window used to display
 55  *the note. This key allows us to find the window for a specific note, if
 56  *one is open.
 57  */
 58 function notes_table_addRow(icon,subject,created,categories,content,preview) {
 59   var row=notes_viewer_table.createRow(4,false);
 60   row.add(notes_viewer_table.createItem("","note_"+(note_target_num++),icon));
 61   row.add(notes_viewer_table.createItem(subject,content,null));
 62   row.add(notes_viewer_table.createItem(created));
 63   row.add(notes_viewer_table.createItem(categories));
 64   row.setValue(preview); //set the preview
 65   notes_viewer_table.add(row);
 66   
 67 }
 68 /**
 69  * This function is invoked when the user double-clicks on an item in the notes table
 70  * It grabs the url for the note from the linked data stored in the second column (index=1)
 71  * and populates the configuration object that will be used to create a viewer to show the url
 72  */
 73 function notes_table_onAction() {
 74   window.showWaitCursor();
 75   try {
 76     var target=widget.getSelectionDataAsString(0);
 77     var t=window.getTarget(target);
 78     if(t!=null) {
 79       t.activate();
 80       return;
 81     }
 82     var title=widget.getSelectionAsString(1);
 83     var text=widget.getSelectionDataAsString(1);
 84     var created=widget.getSelectionAsString(2);
 85     if(notes_config==null) {
 86       notes_create_config();
 87     }
 88     notes_config.dataURL.value=text;
 89     window.open(notes_config,'target='+target+',windowType=popup_orphan,translucency=.1,width=600,height=700,border=line,resizable=true,title="'+title+'",icon="resource:pim.icon.notes",bgcolor="#FFFFFF",status="Created on '+created+'"');
 90   }
 91   finally {
 92     window.hideWaitCursor();
 93   }
 94 }
 95 
 96 /**
 97  * This function create a configuration object that will be used (and reused)
 98  * to display a note in the popup window
 99  */
100 function notes_create_config() {
101   notes_config=window.createConfigurationObject("DocumentPane");
102   notes_config.setBorder(BORDER_NONE);
103   notes_config.bgColor.value=",#FFFFFF"; //light to dark gradient of the specified color
104   notes_config.dataURL.spot_setAttribute("inline","true");
105   notes_config.dataURL.spot_setAttribute("mimeType","text/plain");
106 }
107 
108