[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 01 Jul 2002 15:24:44 -0000


matthew		Mon Jul  1 11:24:44 2002 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
  Log:
  Added &browser_and_searcher_javascript, a utility function which returns
  javascript helpers to open the indexer (browser) and searcher windows.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.41 loncom/interface/loncommon.pm:1.42
--- loncom/interface/loncommon.pm:1.41	Tue Jun 25 13:09:38 2002
+++ loncom/interface/loncommon.pm	Mon Jul  1 11:24:44 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.41 2002/06/25 17:09:38 ng Exp $
+# $Id: loncommon.pm,v 1.42 2002/07/01 15:24:44 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -190,6 +190,92 @@
     
 }
 # ============================================================= END BEGIN BLOCK
+###############################################################
+##           HTML and Javascript Helper Functions            ##
+###############################################################
+
+=pod 
+
+=item browser_and_searcher_javascript 
+
+Returns scalar containing javascript to open a browser window
+or a searcher window.  Also creates 
+
+=over 4
+
+=item openbrowser(formname,elementname,only,omit) [javascript]
+
+inputs: formname, elementname, only, omit
+
+formname and elementname indicate the name of the html form and name of
+the element that the results of the browsing selection are to be placed in. 
+
+Specifying 'only' will restrict the browser to displaying only files
+with the given extension.  Can be a comma seperated list.
+
+Specifying 'omit' will restrict the browser to NOT displaying files
+with the given extension.  Can be a comma seperated list.
+
+=item opensearcher(formname, elementname) [javascript]
+
+Inputs: formname, elementname
+
+formname and elementname specify the name of the html form and the name
+of the element the selection from the search results will be placed in.
+
+=back
+
+=cut
+
+###############################################################
+sub browser_and_searcher_javascript {
+    return <<END;
+    var editbrowser;
+    function openbrowser(formname,elementname,only,omit) {
+        var url = '/res/?';
+        if (editbrowser == null) {
+            url += 'launch=1&';
+        }
+        url += 'catalogmode=interactive&';
+        url += 'mode=edit&';
+        url += 'form=' + formname + '&';
+        if (only != null) {
+            url += 'only=' + only + '&';
+        } 
+        if (omit != null) {
+            url += 'omit=' + omit + '&';
+        }
+        url += 'element=' + elementname + '';
+        var title = 'Browser';
+        var options = 'scrollbars=1,resizable=1,menubar=0';
+        options += ',width=700,height=600';
+        editbrowser = open(url,title,options,'1');
+        editbrowser.focus();
+    }
+    var editsearcher;
+    function opensearcher(formname,elementname) {
+        var url = '/adm/searchcat?';
+        if (editsearcher == null) {
+            url += 'launch=1&';
+        }
+        url += 'catalogmode=interactive&';
+        url += 'mode=edit&';
+        url += 'form=' + formname + '&';
+        url += 'element=' + elementname + '';
+        var title = 'Search';
+        var options = 'scrollbars=1,resizable=1,menubar=0';
+        options += ',width=700,height=600';
+        editsearcher = open(url,title,options,'1');
+        editsearcher.focus();
+    }
+END
+}
+
+
+
+###############################################################
+
+=pod
 
 =item linked_select_forms(...)