[mapguide-users] Automatic custom javascript loading in AjaxViewer

Bruno Scott bscott at geomapgis.com
Wed Jan 14 06:15:45 EST 2009


I propose a new enhencement to the AjaxViewer, the ability to the ajaxviewer
to automatically include javascript files at load time

In mainframe.aspx
        ...
        //Scans the customjs directory for custom client javascript files
        String clientJSInclude = "";
        String strExt = "*.js";
        String strPath = Request.PhysicalApplicationPath + "..\\customjs";
        try
        {
          String[] files = Directory.GetFiles(strPath, strExt,
SearchOption.TopDirectoryOnly);
          foreach(String file in files)
          {
            clientJSInclude += "\n<script language=\"javascript\"
src=\"../customjs/" + System.IO.Path.GetFileName(file) + "\"></script>";
          }
        }
        catch(Exception e){}
        
        //load the HTML template and format it
        //
        String template = MgLocalizer.Localize(LoadTemplate(Request,
"../viewerfiles/mainframe.templ"), locale, GetClientOS(Request));
        String[] args = {
                    webLayout.GetTitle(),
                    clientJSInclude,
                    ...

In mainframe.templ
Just add un new %s after the existing <script ...>


The advantages of this new features

  1) no need to have aspx,php (post enabled) files in any frames
  2) it much more easy to add specific user function ( UI based ) without
having the huge task pane displayed
  3) possible to create <div> on the fly to create sexy ExtJS type UI
  4) very easy to use mapguide "Invoke Script" command, it just the matter
of typing the javascript function.
  5) very easy for developpers to maintain, just copy the js files in the
www\customjs directory

Of course i can create a ticket for this, and Diff Patches for php and
DotNet

Bruno Scott


-- 
View this message in context: http://n2.nabble.com/Automatic-custom-javascript-loading-in-AjaxViewer-tp2156302p2156302.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list