///############################################################ /// <summary> /// Renders the requested JavaScript file references. /// </summary> /// <remarks> /// NOTE: <c>cnCnRendererComplexSorter</c> is not yet implemented. /// </remarks> /// <param name="eJavaScriptFile">Enumeration representing the JavaScript/DHTML code to return.</param> /// <param name="oSettings">Cn.Web.Settings.Current instance representing the current enviroment.</param> /// <returns>String representing the required JavaScript file script block(s) for the referenced <paramref>eJavaScriptFile</paramref>.</returns> /// <exception cref="Cn.CnException">Thrown when the passed <paramref>eJavaScriptFile</paramref> is unreconized.</exception> /// <exception cref="Cn.CnException">Thrown when the passed <paramref>eJavaScriptFile</paramref> is <c>cnRenderAllJavaScript</c> and the referenced <paramref>oSettings.RenderedJavaScriptFiles</paramref> signanifies that some or all of the JavaScript file script blocks have been rendered previously.</exception> ///############################################################ /// <LastUpdated>March 3, 2010</LastUpdated> public static string GenerateFileReferences(enumJavaScriptFiles eJavaScriptFile, Settings.Current oSettings) { string sPath = Settings.Value(Settings.enumSettingValues.cnUIDirectory); string sCRLF = oSettings.CRLF; string sReturn; int iRenderedJavaScriptFiles = oSettings.GeneratedJavaScriptFileReferences; //#### If we are in .Debug mode, append g_cJavaScriptDebugDirectory onto the sPath if (oSettings.Debug) { sPath += g_cJavaScriptDebugDirectory; } //#### Else we are not in .Debug mode, so append g_cJavaScriptDirectory onto the sPath else { sPath += g_cJavaScriptDirectory; } //#### Pass the call off to .DoRender to generate the required JavaScript file references, Response.Write'ing out the returned value sReturn = DoGetScriptReferences(eJavaScriptFile, ref iRenderedJavaScriptFiles, oSettings.EndUserMessagesLanguageCode, sPath, sCRLF, oSettings.Debug); //#### Reset oSettings's .RenderedJavaScriptFiles to the local iRenderedJavaScriptFiles //#### NOTE: This is required because you cannot pass a property byref (as is required by the .DoGetScriptReferences call above) oSettings.GeneratedJavaScriptFileReferences = iRenderedJavaScriptFiles; //#### Return the above determined value to the caller return(sReturn); }
//########################################################################################## //# Private Static Functions //########################################################################################## ///############################################################ /// <summary> /// Returns the requested JavaScript file references. /// </summary> /// <remarks> /// NOTE: <c>cnCnRendererComplexSorter</c> is not yet implemented. /// </remarks> /// <param name="eJavaScriptFile">Enumeration representing the JavaScript/DHTML code to return.</param> /// <param name="iRenderedJavaScriptFiles">Reference to an integer representing a bitwise value indicating which JavaScript file references have been rendered previously.</param> /// <param name="sEndUserMessagesLanguageCode">String representing the end user's ISO639 2-letter language code.</param> /// <param name="sPath">String representing the path from the web oRootDir to the JavaScript oFiles.</param> /// <param name="sCRLF">String representing the line break character(s) to be included in the return value.</param> /// <returns>String representing the required JavaScript file script block(s) for the referenced <paramref>eJavaScriptFile</paramref>.</returns> /// <exception cref="Cn.CnException">Thrown when the passed <paramref>eJavaScriptFile</paramref> is unreconized.</exception> /// <exception cref="Cn.CnException">Thrown when the passed <paramref>eJavaScriptFile</paramref> is <c>cnRenderAllJavaScript</c> and the passed <paramref>iRenderedJavaScriptFiles</paramref> signanifies that some or all of the JavaScript file script blocks have been rendered previously.</exception> ///############################################################ /// <LastUpdated>March 3, 2010</LastUpdated> private static string DoGetScriptReferences(enumJavaScriptFiles eJavaScriptFile, ref int iRenderedJavaScriptFiles, string sEndUserMessagesLanguageCode, string sPath, string sCRLF, bool bDebug) { string sReturn = ""; //#### As long as the iRenderedJavaScriptFiles is not set to .cnDisableJavaScriptRendering and the passed eJavaScriptFile has not yet been rendered if (iRenderedJavaScriptFiles != (int)enumJavaScriptFiles.cnDisableJavaScriptRendering && (iRenderedJavaScriptFiles & (int)eJavaScriptFile) == 0) { //#### Determine the passed eJavaScriptFile and process accordingly switch (eJavaScriptFile) { //#### If this is a .cnCn eJavaScriptFile request, reset the sReturn value accordingly case enumJavaScriptFiles.cnCn: { sReturn = "<script type='text/javascript' src='" + sPath + "Cn/Cn.js'></script>" + sCRLF + "<script type='text/javascript' src='" + sPath + "Cn/Cn.js." + g_cServerSideScriptFileExtension + "'></script>" + sCRLF; break; } //#### If this is a .cnCnTools eJavaScriptFile request case enumJavaScriptFiles.cnCnTools: { //#### Recurse to collect the JavaScript for .cnCn and .cnYUIDOM (as they are required for this eJavaScriptFile) before appending the script tag //#### NOTE: Most of the .cnCn* calls below rely on the call below in order to collect their own copy of .cnCn //#### NOTE: Since .cnYUIDOM also requires .cnYUI, it is not included below (as the .cnYUIDOM call will pick it up) sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnCn, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnYUIDOM, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnYUIEvent, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "Cn/Data/Tools.js'></script>" + sCRLF + "<script type='text/javascript' src='" + sPath + "Cn/Web/Tools.js'></script>" + sCRLF; break; } //########## //########## //#### If this is a .cnCnInputs eJavaScriptFile request case enumJavaScriptFiles.cnCnInputs: { //#### Recurse to collect the JavaScript for .cnCn and .cnCnTools (as they are required for this eJavaScriptFile) before appending the script tag //#### NOTE: Since .cnCnSettings also requires .cnCn, it is not included below (as the .cnCnTools call will pick it up) sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnCnTools, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "Cn/Web/Inputs/Inputs.js'></script>" + sCRLF; break; } //#### If this is a .cnCnInputsValidation eJavaScriptFile request case enumJavaScriptFiles.cnCnInputsValidation: { //#### Recurse to collect the JavaScript for .cnCn, .cnCnTools, .cnCnInputs and .cnYUIDOM (as they are required for this eJavaScriptFile) before appending the script tag //#### NOTE: Since .cnCnSettings also requires .cnCn, it is not included below (as the .cnCnTools call will pick it up) //#### NOTE: Since .cnYUIDOM also requires .cnYUI, it is not included below (as the .cnYUIDOM call will pick it up) sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnCn, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnCnTools, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnCnInputs, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnYUIDOM, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "Cn/Web/Inputs/Validation.js'></script>" + sCRLF + "<script type='text/javascript' src='" + sPath + "Cn/Web/Inputs/Validation.js." + g_cServerSideScriptFileExtension + "?LanguageCode=" + sEndUserMessagesLanguageCode + "'></script>" + sCRLF; break; } //#### If this is a .cnCnInputsDateTime eJavaScriptFile request case enumJavaScriptFiles.cnCnInputsDateTime: { //#### Recurse to collect the JavaScript for .cnCn, .cnCnTools and .cnYUICalendar (as they are required for this eJavaScriptFile) before appending the script tag //#### NOTE: Since .cnCnSettings also requires .cnCn, it is not included below (as the .cnCnSettings call will pick it up) //#### NOTE: Since .cnYUICalendar also requires .cnYUI, it is not included below (as the .cnYUICalendar call will pick it up) //#### NOTE: SystemName and LanguageCode are passed in via the QueryString because they are used by the server-side script //#### NOTE: WeekOfYearCalculation is passed in via the QueryString because it is defined programaticially by the Developer at runtime sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnCn, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnCnTools, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnYUICalendar, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnYUIEvent, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "Cn/Dates/Tools.js'></script>" + sCRLF + "<script type='text/javascript' src='" + sPath + "Cn/Web/Inputs/DateTime.js'></script>" + sCRLF + "<script type='text/javascript' src='" + sPath + "Cn/Web/Inputs/DateTime.js." + g_cServerSideScriptFileExtension + "?LanguageCode=" + sEndUserMessagesLanguageCode + "'></script>" + sCRLF + "<script type='text/javascript' src='" + sPath + "Cn/Dates/Tools.js'></script>" + sCRLF; break; } //#### If this is a .cnCnInputsComboBox eJavaScriptFile request case enumJavaScriptFiles.cnCnInputsComboBox: { //#### Recurse to collect the JavaScript for .cnCn and .cnCnTools (as they are required for this eJavaScriptFile) before appending the script tag //#### NOTE: Since .cnCnSettings also requires .cnCn, it is not included below (as the .cnCnSettings call will pick it up) sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnCn, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnCnTools, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "Cn/Web/Inputs/ComboBox.js'></script>" + sCRLF; break; } //! neek //#### If this is a .cnCnInputsHTMLEditor eJavaScriptFile request case enumJavaScriptFiles.cnCnInputsHTMLEditor: { //#### Recurse to collect the JavaScript for .cnCn, .cnCnTools and .cnYUIRichTextEditor (as it is required for this eJavaScriptFile) before appending the script tag sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnCn, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnCnTools, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnYUIRichTextEditor, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "Cn/Web/Inputs/HTMLEditor.js'></script>" + sCRLF; break; } //! neek //#### If this is a .cnCnInputsMaxLength eJavaScriptFile request case enumJavaScriptFiles.cnCnInputsMaxLength: { //#### Recurse to collect the JavaScript for .cnCnTools, .cnCnInputs, .cnCnInputsValidation and .cnYUIEvent (as it is required for this eJavaScriptFile) before appending the script tag //#### NOTE: Since .cnCnTools also requires .cnCn, it is not included below (as the .cnCnTools call will pick it up) //#### NOTE: Since .cnYUIEvent also requires .cnYUI, it is not included below (as the .cnYUIEvent call will pick it up) sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnCnTools, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnCnInputs, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnCnInputsValidation, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnYUIEvent, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "Cn/Web/Inputs/MaxLength.js'></script>" + sCRLF; break; } //#### If this is a .cnCnInputsRadio eJavaScriptFile request case enumJavaScriptFiles.cnCnInputsRadio: { //#### Recurse to collect the JavaScript for .cnCnTools and .cnYUIEvent (as it is required for this eJavaScriptFile) before appending the script tag //#### NOTE: Since .cnCnTools also requires .cnCn, it is not included below (as the .cnCnTools call will pick it up) //#### NOTE: Since .cnYUIEvent also requires .cnYUI, it is not included below (as the .cnYUIEvent call will pick it up) sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnCnTools, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnYUIEvent, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "Cn/Web/Inputs/Radio.js'></script>" + sCRLF; break; } //########## //########## //#### If this is a .cnCnRendererForm eJavaScriptFile request case enumJavaScriptFiles.cnCnRendererForm: { //#### Recurse to collect the JavaScript for .cnCn, .cnCnInputs and .cnCnInputsValidation (as they are required for this eJavaScriptFile) before appending the script tag //#### NOTE: Since .cnCnSettings also requires .cnCn, it is not included below (as the .cnCnSettings call will pick it up) sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnCn, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnCnInputs, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnCnInputsValidation, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "Cn/Web/Renderer/Form.js'></script>" + sCRLF; break; } //#### If this is a .cnCnRendererComplexSorter eJavaScriptFile request case enumJavaScriptFiles.cnCnRendererComplexSorter: { //! sReturn += "<script type='text/javascript' src='" + sBaseDirectory + "Cn/Web/Renderer/ComplexSorter.js'></script>" + sCRLF; break; } //#### If this is a .cnCnRendererUserSelectedStack eJavaScriptFile request case enumJavaScriptFiles.cnCnRendererUserSelectedStack: { //#### Recurse to collect the JavaScript for .cnCn (as it is required for this eJavaScriptFile) before appending the script tag //#### NOTE: Since .cnCnSettings also requires .cnCn, it is not included below (as the .cnCnSettings call will pick it up) sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnCn, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "Cn/Web/Renderer/UserSelectedStack.js'></script>" ; break; } //########## //########## //#### If this is a .cnYUIRichTextEditor eJavaScriptFile request case enumJavaScriptFiles.cnYUIRichTextEditor: { sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnYUIEvent, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + DoGetScriptReferences(enumJavaScriptFiles.cnYUIDOM, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "yui/element.js'></script>" + sCRLF + "<script type='text/javascript' src='" + sPath + "yui/container.js'></script>" + sCRLF + "<script type='text/javascript' src='" + sPath + "yui/simpleeditor.js'></script>" + sCRLF + "<script type='text/javascript' src='" + sPath + "yui/menu.js'></script>" + sCRLF + "<script type='text/javascript' src='" + sPath + "yui/button.js'></script>" + sCRLF + "<script type='text/javascript' src='" + sPath + "yui/editor.js'></script>" + sCRLF + "<link rel='stylesheet' type='text/css' href='" + sPath + "yui/editor-core.css' />" ; break; } //########## //########## //#### If this is a .cnYUI eJavaScriptFile request, reset the sReturn value accordingly case enumJavaScriptFiles.cnYUI: { sReturn = "<script type='text/javascript' src='" + sPath + "yui/yahoo.js'></script>" + sCRLF; break; } //#### If this is a .cnYUICalendar eJavaScriptFile request case enumJavaScriptFiles.cnYUICalendar: { //#### Recurse to collect the JavaScript for .cnYUI and .cnYUIEvent (as they are required for this eJavaScriptFile) before appending the script tag //#### NOTE: Since .cnYUIEvent also requires .cnYUI, it is not included below (as the .cnYUIEvent call will pick it up) sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnYUIEvent, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "yui/calendar.js'></script>" + sCRLF + "<link rel='stylesheet' type='text/css' href='" + sPath + "yui/calendar.css' />" ; break; } //#### If this is a .cnYUIEvent eJavaScriptFile request case enumJavaScriptFiles.cnYUIEvent: { //#### Recurse to collect the JavaScript for .cnYUI (as it is required for this eJavaScriptFile) before appending the script tag sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnYUI, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "yui/event.js'></script>" + sCRLF; break; } //#### If this is a .cnYUIDOM eJavaScriptFile request case enumJavaScriptFiles.cnYUIDOM: { //#### Recurse to collect the JavaScript for .cnYUI (as it is required for this eJavaScriptFile) before appending the script tag sReturn = DoGetScriptReferences(enumJavaScriptFiles.cnYUI, ref iRenderedJavaScriptFiles, sEndUserMessagesLanguageCode, sPath, sCRLF, bDebug) + "<script type='text/javascript' src='" + sPath + "yui/dom.js'></script>" + sCRLF; break; } //########## //########## //#### If this is a .cnRenderAllJavaScript eJavaScriptFile request case enumJavaScriptFiles.cnRenderAllJavaScript: { //#### If no other JavaScript has been previously rendered if (iRenderedJavaScriptFiles == 0) { //#### Reset the value of the sPath to ensure that we are not looking at the /Debug path sPath = Settings.Value(Settings.enumSettingValues.cnUIDirectory) + g_cJavaScriptDirectory; //#### Set the sReturn value to the required all/ .js oFiles //#### NOTE: Since there is no Debug/ version of the all/ .js oFiles, the value of sPath is not utilized below //#### NOTE: SystemName and LanguageCode are passed in via the QueryString because they are used by the server-side script //! neek - debug hard coded!! // "<script type='text/javascript' src='" + sPath + "JS.aspx?Mode=Cn&Debug=" + bDebug + "&LanguageCode=" + sEndUserMessagesLanguageCode + "'></script>" + sCRLF + sReturn = "<script type='text/javascript' src='" + sPath + "JS.aspx?Mode=YUI&Debug=true'></script>" + sCRLF + "<script type='text/javascript' src='" + sPath + "JS.aspx?Mode=Cn&Debug=true&LanguageCode=" + sEndUserMessagesLanguageCode + "'></script>" + sCRLF + "<script type='text/javascript' src='" + sPath + "JS.aspx?Mode=CSS&Debug=true'></script>" ; //#### Set the .RenderedJavaScriptFiles to .cnDisableJavaScriptRendering (as no further JavaScript is to be rendered and .cnDisableJavaScriptRendering gives us this effect) iRenderedJavaScriptFiles = (int)enumJavaScriptFiles.cnDisableJavaScriptRendering; } //#### Else some JavaScript oFiles have been previously rendered, so raise the error else { Internationalization.RaiseDefaultError(g_cClassName + "JavaScript", Internationalization.enumInternationalizationValues.cnDeveloperMessages_Renderer_RenderedJavaScript, "", ""); } break; } //#### If this is a .cnDisableJavaScriptRendering eJavaScriptFile request case enumJavaScriptFiles.cnDisableJavaScriptRendering: { iRenderedJavaScriptFiles = (int)enumJavaScriptFiles.cnDisableJavaScriptRendering; break; } //#### Else the eJavaScriptFile was unreconized, so raise the error default: { Internationalization.RaiseDefaultError(g_cClassName + "JavaScript", Internationalization.enumInternationalizationValues.cnDeveloperMessages_General_UnknownValue, "eJavaScriptFile", Data.Tools.MakeString(eJavaScriptFile, "")); break; } } //#### If the .RenderedJavaScriptFiles is not set to .cnDisableJavaScriptRendering if (iRenderedJavaScriptFiles != (int)enumJavaScriptFiles.cnDisableJavaScriptRendering) { //#### Flip the eJavaScriptFile bit within the .RenderedJavaScriptFiles iRenderedJavaScriptFiles = (iRenderedJavaScriptFiles | (int)eJavaScriptFile); } } //#### Return the above determined sReturn value to the caller return(sReturn); }