You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(204) |
Dec
(147) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(52) |
Feb
(33) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31357/magicajax/Core Modified Files: AjaxCallHelper.cs MagicAjax NET 2.0.csproj MagicAjax.csproj MagicAjaxModule.cs StoredPageInfo.cs Util.cs Added Files: MagicAjaxContext.cs PageFilter.cs Log Message: Major changes to enable MagicAjax for concurrent users. Added: MagicAjaxContext class (containing properties like 'IsAjaxCall') Added: PageFilter.cs (just moved the PageFilter class from MagicAjaxModule.cs) Index: MagicAjax NET 2.0.csproj =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjax NET 2.0.csproj,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MagicAjax NET 2.0.csproj 20 Nov 2005 15:21:31 -0000 1.7 --- MagicAjax NET 2.0.csproj 23 Nov 2005 15:12:48 -0000 1.8 *************** *** 118,121 **** --- 118,122 ---- <SubType>Code</SubType> </Compile> + <Compile Include="MagicAjaxContext.cs" /> <Compile Include="MagicAjaxException.cs"> <SubType>Code</SubType> *************** *** 124,127 **** --- 125,129 ---- <SubType>Code</SubType> </Compile> + <Compile Include="PageFilter.cs" /> <Compile Include="StoredPageInfo.cs"> <SubType>Code</SubType> Index: Util.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/Util.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Util.cs 21 Nov 2005 12:18:36 -0000 1.5 --- Util.cs 23 Nov 2005 15:12:48 -0000 1.6 *************** *** 19,23 **** static public string GetFingerprint(string input) { ! MagicAjax.Configuration.OutputCompareMode compareMode = MagicAjaxModule.Instance.Configuration.PageStore.CompareMode; switch (compareMode) { --- 19,23 ---- static public string GetFingerprint(string input) { ! MagicAjax.Configuration.OutputCompareMode compareMode = MagicAjaxContext.Configuration.PageStore.CompareMode; switch (compareMode) { Index: MagicAjax.csproj =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjax.csproj,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MagicAjax.csproj 20 Nov 2005 15:21:32 -0000 1.4 --- MagicAjax.csproj 23 Nov 2005 15:12:48 -0000 1.5 *************** *** 105,108 **** --- 105,113 ---- /> <File + RelPath = "MagicAjaxContext.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "MagicAjaxException.cs" SubType = "Code" *************** *** 115,118 **** --- 120,128 ---- /> <File + RelPath = "PageFilter.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "StoredPageInfo.cs" SubType = "Code" --- NEW FILE: MagicAjaxContext.cs --- using System; using System.Collections.Generic; using System.Text; using System.Web; using System.Web.UI; using System.Configuration; using MagicAjax.Configuration; namespace MagicAjax { /// <summary> /// MagicAjaxContext contains all information about the MagicAjax configuration and current request /// </summary> public class MagicAjaxContext { #region Private properties private bool _isAjaxCall = false; private bool _completedAjaxCall = false; private bool _exceptionThrown = false; private bool _isBrowserSupported = false; private StoredPageInfo _storedPageInfo = null; #endregion #region Public properties /// <summary> /// Returns true if request was made from the browser's XmlHttpRequest object /// </summary> public bool IsAjaxCall { get { return _isAjaxCall; } set { _isAjaxCall = value; } } /// <summary> /// True of ajax call was completed /// </summary> public bool CompletedAjaxCall { get { return _completedAjaxCall; } set { _completedAjaxCall = value; } } /// <summary> /// Has an exception been thrown during this callback /// </summary> public bool ExceptionThrown { get { return _exceptionThrown; } set { _exceptionThrown = value; } } /// <summary> /// Returns if this browser is supported by MagicAjax. /// For now (version 0.2) only IE and FireFox are supported. /// </summary> public bool IsBrowserSupported { get { return _isBrowserSupported; } set { _isBrowserSupported = value; } } /// <summary> /// Information about current (stored) page. Only used for Session/Cache store mode. /// </summary> public StoredPageInfo StoredPageInfo { get { return _storedPageInfo; } set { _storedPageInfo = value; } } /// <summary> /// Returns the AjaxCall type, suitable for a switch block. /// </summary> public AjaxCallType AjaxCallType { get { if (IsAjaxCallTimer) return AjaxCallType.Timer; else if (IsAjaxCall) return AjaxCallType.Control; else return AjaxCallType.None; } } /// <summary> /// Determines whether the page is stored or recreated at each AjaxCall. /// </summary> public bool IsPageNoStoreMode { get { return MagicAjaxContext.Configuration.PageStore.Mode == MagicAjax.Configuration.PageStoreMode.NoStore; } } /// <summary> /// Gets the argument string the was sent by the client. /// </summary> public string AjaxCallArgument { get { if (IsAjaxCall) return HttpContext.Current.Request.Form["__EVENTARGUMENT"]; else return null; } } /// <summary> /// Determines whether the AjaxCall occured by the AjaxCallTimer. /// </summary> /// <remarks> /// See the remarks of the SetAjaxCallTimerInterval method. /// </remarks> public bool IsAjaxCallTimer { get { return (HttpContext.Current.Request.Form["__EVENTTARGET"] == "__AJAX_AJAXCALLTIMER"); } } /// <summary> /// Determines if the page is being processed for an AjaxCall. It's more accurate /// than IsAjaxCall because it returns false if the page is being processed /// for Server.Transfer. /// </summary> /// <remarks> /// When the page is being processed for Server.Transfer, the Page's /// IsPostBack property will be false. If this is the case IsAjaxCallForPage /// will return false. /// </remarks> public bool IsAjaxCallForPage(Page page) { return (IsAjaxCall && ((IsPageNoStoreMode && page.IsPostBack) || (!IsPageNoStoreMode && StoredPageInfo.Page == page))); } #endregion #region Public Ctor public MagicAjaxContext() { //store initial settings on first call (per request) if (HttpContext.Current != null) { HttpBrowserCapabilities caps = HttpContext.Current.Request.Browser; if (caps.Browser != null && caps.EcmaScriptVersion.Major >= 1 && caps.W3CDomVersion.Major >= 1) { switch (caps.Browser.ToLower()) { case "ie": _isBrowserSupported = caps.MajorVersion > 5 || (caps.MajorVersion == 5 && caps.MinorVersion >= 5); break; case "gecko": _isBrowserSupported = caps.Type.ToLower().StartsWith("firefox") && caps.MajorVersion >= 1; break; case "firefox": _isBrowserSupported = caps.MajorVersion >= 1; break; //TODO: add support for Opera, Netscape and Safari } } } } #endregion #region Public Static properties public static MagicAjaxContext Current { get { MagicAjaxContext magicAjaxContext = null; if (HttpContext.Current != null) { // get the portal context for the current HTTP request if (HttpContext.Current.Items.Contains("__MAGICAJAXCONTEXT")) { magicAjaxContext = (MagicAjaxContext)HttpContext.Current.Items["__MAGICAJAXCONTEXT"]; } else { // create a new context and add it to the items collection for later retrieval magicAjaxContext = new MagicAjaxContext(); HttpContext.Current.Items.Add("__MAGICAJAXCONTEXT", magicAjaxContext); } } return magicAjaxContext; } } private static MagicAjaxConfiguration _configuration = null; public static MagicAjaxConfiguration Configuration { get { if (_configuration == null) { // Note: there is no need to cache this as singleton, .NET framework does this automatically (only a single instance is created) _configuration = (MagicAjaxConfiguration)ConfigurationSettings.GetConfig("magicAjax"); if (_configuration == null) { _configuration = new MagicAjaxConfiguration(null); } } return _configuration; } } #endregion } } Index: StoredPageInfo.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/StoredPageInfo.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StoredPageInfo.cs 14 Nov 2005 18:50:43 -0000 1.2 --- StoredPageInfo.cs 23 Nov 2005 15:12:48 -0000 1.3 *************** *** 11,15 **** private Page _page; private int _ajaxCallsCount; ! private DateTime _lastAccess; public Page Page --- 11,15 ---- private Page _page; private int _ajaxCallsCount; ! private DateTime _lastAccess; public Page Page Index: AjaxCallHelper.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/AjaxCallHelper.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AjaxCallHelper.cs 20 Nov 2005 08:47:29 -0000 1.7 --- AjaxCallHelper.cs 23 Nov 2005 15:12:48 -0000 1.8 *************** *** 56,137 **** private AjaxCallHelper() { } ! private static ArrayList _sbWritingLevels; ! private static int _writingLevel; ! ! private static void MergeNextWritingLevelRecursive (int writingLevel) ! { ! int nextLevel = writingLevel + 1; ! if (_sbWritingLevels.Count == nextLevel) ! return; ! ! MergeNextWritingLevelRecursive (nextLevel); ! (_sbWritingLevels[writingLevel] as StringBuilder).Append((_sbWritingLevels[nextLevel] as StringBuilder).ToString()); ! _sbWritingLevels.RemoveAt (nextLevel); ! } ! #endregion ! ! #region Static Properties ! /// <summary> ! /// Returns the AjaxCall type, suitable for a switch block. ! /// </summary> ! public static AjaxCallType AjaxCallType { get { ! if ( IsAjaxCallTimer ) ! return AjaxCallType.Timer; ! else if ( IsAjaxCall ) ! return AjaxCallType.Control; else ! return AjaxCallType.None; } } ! ! /// <summary> ! /// Determines whether an AjaxCall was invoked on the server by the client. ! /// </summary> ! public static bool IsAjaxCall { get { ! return ( HttpContext.Current != null && MagicAjaxModule.Instance.IsAjaxCall ); } ! } ! ! /// <summary> ! /// Determines whether the page is stored or recreated at each AjaxCall. ! /// </summary> ! public static bool IsPageNoStoreMode ! { ! get { return ( HttpContext.Current != null && MagicAjaxModule.Instance.Configuration.PageStore.Mode == Configuration.PageStoreMode.NoStore ); } ! } ! ! /// <summary> ! /// Gets the argument string the was sent by the client. ! /// </summary> ! public static string AjaxCallArgument ! { ! get { ! if ( IsAjaxCall ) ! return MagicAjaxModule.Instance.Form["__EVENTARGUMENT"]; else ! return null; } } ! /// <summary> ! /// Determines whether the AjaxCall occured by the AjaxCallTimer. ! /// </summary> ! /// <remarks> ! /// See the remarks of the SetAjaxCallTimerInterval method. ! /// </remarks> ! public static bool IsAjaxCallTimer { ! get ! { ! return ( MagicAjaxModule.Instance.Form["__EVENTTARGET"] == "__AJAX_AJAXCALLTIMER" ); ! } } /// <summary> --- 56,117 ---- private AjaxCallHelper() { } ! private static ArrayList _sbWritingLevels { get { ! if (HttpContext.Current.Items.Contains("_sbWritingLevels")) ! { ! return (ArrayList)(HttpContext.Current.Items["_sbWritingLevels"]); ! } ! return null; ! } ! set ! { ! if (!HttpContext.Current.Items.Contains("_sbWritingLevels")) ! { ! HttpContext.Current.Items.Add("_sbWritingLevels", value); ! } else ! { ! HttpContext.Current.Items["_sbWritingLevels"] = value; ! } } } ! private static int _writingLevel { get { ! if (HttpContext.Current.Items.Contains("_writingLevel")) ! { ! return (int)(HttpContext.Current.Items["_writingLevel"]); ! } ! return 0; } ! set { ! if (!HttpContext.Current.Items.Contains("_writingLevel")) ! { ! HttpContext.Current.Items.Add("_writingLevel", value); ! } else ! { ! HttpContext.Current.Items["_writingLevel"] = value; ! } } } ! private static void MergeNextWritingLevelRecursive(int writingLevel) { ! int nextLevel = writingLevel + 1; ! if (_sbWritingLevels.Count == nextLevel) ! return; ! ! MergeNextWritingLevelRecursive (nextLevel); ! (_sbWritingLevels[writingLevel] as StringBuilder).Append((_sbWritingLevels[nextLevel] as StringBuilder).ToString()); ! _sbWritingLevels.RemoveAt (nextLevel); } + #endregion + + #region Static Methods /// <summary> *************** *** 144,190 **** } - /// <summary> - /// Included for convenience. - /// </summary> - public static HttpContext Context - { - get - { - return System.Web.HttpContext.Current; - } - } - - /// <summary> - /// Included for convenience. - /// </summary> - public static HttpResponse Response - { - get - { - HttpResponse hr = System.Web.HttpContext.Current.Response; - if (hr == null) - throw new MagicAjaxException("AjaxCallHelper could not access current HttpResponse object"); - - return hr; - } - } - - /// <summary> - /// Included for convenience. - /// </summary> - public static HttpRequest Request - { - get - { - HttpRequest hr = System.Web.HttpContext.Current.Request; - if (hr == null) - throw new MagicAjaxException("AjaxCallHelper could not access current HttpRequest object"); - - return hr; - } - } - #endregion - - #region Static Methods /// <summary> /// Increases the script writing level. --- 124,127 ---- *************** *** 240,259 **** /// <summary> - /// Determines if the page is being processed for an AjaxCall. It's more accurate - /// than IsAjaxCall because it returns false if the page is being processed - /// for Server.Transfer. - /// </summary> - /// <remarks> - /// When the page is being processed for Server.Transfer, the Page's - /// IsPostBack property will be false. If this is the case IsAjaxCallForPage - /// will return false. - /// </remarks> - public static bool IsAjaxCallForPage (Page page) - { - return (AjaxCallHelper.IsAjaxCall && - ( (IsPageNoStoreMode && page.IsPostBack) || (!IsPageNoStoreMode && MagicAjaxModule.Instance.CurrentPageInfo.Page == page) ) ); - } - - /// <summary> /// Obtains a reference to a client-side script function that causes, when invoked, /// the control to raise an AjaxCall event to the server. This method also passes --- 177,180 ---- *************** *** 333,337 **** if (milliSeconds > 0) { ! if ( IsAjaxCall ) Write (String.Format("AJAXCbo.SetIntervalForAjaxCall({0});", milliSeconds)); else --- 254,258 ---- if (milliSeconds > 0) { ! if (MagicAjaxContext.Current.IsAjaxCall) Write (String.Format("AJAXCbo.SetIntervalForAjaxCall({0});", milliSeconds)); else *************** *** 344,348 **** else { ! if ( IsAjaxCall ) Write ("AJAXCbo.ClearIntervalForAjaxCall();"); else --- 265,269 ---- else { ! if (MagicAjaxContext.Current.IsAjaxCall) Write ("AJAXCbo.ClearIntervalForAjaxCall();"); else *************** *** 516,520 **** internal static void Init() { ! HttpResponse hr = AjaxCallHelper.Response; hr.StatusCode = 200; hr.StatusDescription = "OK"; --- 437,441 ---- internal static void Init() { ! HttpResponse hr = HttpContext.Current.Response; hr.StatusCode = 200; hr.StatusDescription = "OK"; *************** *** 539,549 **** WriteEndSignature(); ! HttpResponse hr = AjaxCallHelper.Response; hr.Clear(); MergeNextWritingLevelRecursive (0); hr.Write ((_sbWritingLevels[0] as StringBuilder).ToString()); ! ! MagicAjaxModule.Instance.CompletedAjaxCall = true; hr.Flush(); --- 460,470 ---- WriteEndSignature(); ! HttpResponse hr = HttpContext.Current.Response; hr.Clear(); MergeNextWritingLevelRecursive (0); hr.Write ((_sbWritingLevels[0] as StringBuilder).ToString()); ! ! MagicAjaxContext.Current.CompletedAjaxCall = true; hr.Flush(); --- NEW FILE: PageFilter.cs --- using System; using System.IO; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; using System.Web; namespace MagicAjax { /// <summary> /// Used to store and retrieve the html rendering of the page during an AjaxCall /// </summary> internal class PageFilter : Stream { private Stream _responseStream; private Stream _memStream; public PageFilter(Stream _responseStream) { this._responseStream = _responseStream; this._memStream = new MemoryStream(); } public string GetViewStateFieldValue() { //TODO: use regular expression (much faster) #if NET_2_0 string search = "<input type=\"hidden\" name=\"__VIEWSTATE\" id=\"__VIEWSTATE\" value=\""; #else string search = "<input type=\"hidden\" name=\"__VIEWSTATE\" value=\""; #endif string html = GetHtmlPage(); int si = html.IndexOf(search); if (si == -1) return null; si += search.Length; int ei = html.IndexOf('\"', si); if (ei == -1) return null; return html.Substring(si, ei - si); } #if NET_2_0 /// <summary> /// Look for javascript generated for draggable webparts (IE only), and returns these javascripts. /// </summary> public string GetWebPartManagerScriptValue(string formID) { string html = GetHtmlPage(); // Look for webpartmanager object creation script string searchWPManager = "<script type=\"text\\/javascript\">\\r\\n\\r\\n__wpm = new WebPartManager\\(\\);\\r\\n(?<WPManagerScript>.*?)<\\/script>"; Regex regExWPManager = new Regex(searchWPManager, RegexOptions.Singleline | RegexOptions.Compiled); Match match = regExWPManager.Match(html); // If no webpartmanager script exists in html -> exit if (!match.Success) return null; // Stringbuilder to hold the output script StringBuilder wpmScript = new StringBuilder(); // First look for hidden drag element (if not exists : add this to page) string searchDragElm = "<div id=\"(?<DragElmId>.+?___Drag)\" style=\"display:none.+?><\\/div>"; Regex regExDragElm = new Regex(searchDragElm, RegexOptions.Multiline | RegexOptions.Compiled); Match matchDragElm = regExDragElm.Match(html); if (matchDragElm.Success) { //add this element to the html page, if it didn't exist string elmID = matchDragElm.Groups["DragElmId"].Value; wpmScript.AppendLine(string.Format("if (document.getElementById('{0}') == null)", elmID)); wpmScript.AppendLine(string.Format(" AJAXCbo.AddElementScript('{0}','span','__DragHolder',{1},'null');", formID, AjaxCallHelper.EncodeString(matchDragElm.Value))); } // Now append the WebpartManager script wpmScript.AppendLine(match.Groups["WPManagerScript"].Value); // Now append the webpart menu scripts string searchWPMenus = "<script type=\"text\\/javascript\">\\r\\n(?<MenuScript>var menuWebPart_.*?)<\\/script>"; Regex regExMenuScripts = new Regex(searchWPMenus, RegexOptions.Singleline | RegexOptions.Compiled); MatchCollection matches = regExMenuScripts.Matches(html); //ei for (int i = 0; i < matches.Count; i++) { wpmScript.AppendLine(matches[i].Groups["MenuScript"].Value); } return wpmScript.ToString(); } #endif private string _htmlPage; public string GetHtmlPage() { if (_htmlPage == null) { byte[] buffer = new byte[_memStream.Length]; _memStream.Position = 0; _memStream.Read(buffer, 0, (int)_memStream.Length); _htmlPage = HttpContext.Current.Response.ContentEncoding.GetString(buffer); } return _htmlPage; } #region Stream overrides public override bool CanRead { get { return true; } } public override bool CanSeek { get { return true; } } public override bool CanWrite { get { return true; } } public override void Close() { _responseStream.Close(); } public override void Flush() { _responseStream.Flush(); } public override long Length { get { return _responseStream.Length; } } public override long Position { get { return _responseStream.Position; } set { _responseStream.Position = value; } } public override long Seek(long offset, SeekOrigin origin) { return _responseStream.Seek(offset, origin); } public override void SetLength(long length) { _responseStream.SetLength(length); } public override int Read(byte[] buffer, int offset, int count) { return _responseStream.Read(buffer, offset, count); } public override void Write(byte[] buffer, int offset, int count) { if (MagicAjaxContext.Current.IsAjaxCall) { _memStream.Write(buffer, offset, count); if (MagicAjaxContext.Current.CompletedAjaxCall) _responseStream.Write(buffer, offset, count); } else { _responseStream.Write(buffer, offset, count); } } #endregion } } Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** MagicAjaxModule.cs 22 Nov 2005 10:37:50 -0000 1.25 --- MagicAjaxModule.cs 23 Nov 2005 15:12:48 -0000 1.26 *************** *** 54,114 **** public class MagicAjaxModule: IHttpModule { - #region Static Properties - private static MagicAjaxModule _instance = null; - - public static MagicAjaxModule Instance - { - get - { - if (_instance == null) [...1121 lines suppressed...] - - public override void Write(byte[] buffer, int offset, int count) - { - if ( AjaxCallHelper.IsAjaxCall ) - { - _memStream.Write (buffer, offset, count); - - if ( MagicAjaxModule.Instance.CompletedAjaxCall ) - _responseStream.Write (buffer, offset, count); - } - else - { - _responseStream.Write (buffer, offset, count); - } - } - #endregion - } } } --- 856,859 ---- |
From: Dion O. <dol...@us...> - 2005-11-23 15:12:57
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31357/magicajax/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Major changes to enable MagicAjax for concurrent users. Added: MagicAjaxContext class (containing properties like 'IsAjaxCall') Added: PageFilter.cs (just moved the PageFilter class from MagicAjaxModule.cs) Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** AjaxPanel.cs 22 Nov 2005 00:59:22 -0000 1.20 --- AjaxPanel.cs 23 Nov 2005 15:12:48 -0000 1.21 *************** *** 873,877 **** string[] namevalue = namevaluepair.Split('#'); ! if (MagicAjaxModule.Instance.Configuration.PageStore.CompareMode == MagicAjax.Configuration.OutputCompareMode.FullHtml) { controlHtmlFingerprints.Add(string.Format("{0}_{1}", panelClientID, namevalue[0]), UnicodeEncoding.Default.GetString(Convert.FromBase64String(namevalue[1]))); --- 873,877 ---- string[] namevalue = namevaluepair.Split('#'); ! if (MagicAjaxContext.Configuration.PageStore.CompareMode == MagicAjax.Configuration.OutputCompareMode.FullHtml) { controlHtmlFingerprints.Add(string.Format("{0}_{1}", panelClientID, namevalue[0]), UnicodeEncoding.Default.GetString(Convert.FromBase64String(namevalue[1]))); *************** *** 933,937 **** string keyWithoutNamingcontainer = key.Substring(panelClientID.Length + 1); ! if (MagicAjaxModule.Instance.Configuration.PageStore.CompareMode == MagicAjax.Configuration.OutputCompareMode.FullHtml) { sbuilder.AppendFormat("{0}#{1}", keyWithoutNamingcontainer, Convert.ToBase64String(UnicodeEncoding.Default.GetBytes((string)_controlHtmlFingerprints[key]))); --- 933,937 ---- string keyWithoutNamingcontainer = key.Substring(panelClientID.Length + 1); ! if (MagicAjaxContext.Configuration.PageStore.CompareMode == MagicAjax.Configuration.OutputCompareMode.FullHtml) { sbuilder.AppendFormat("{0}#{1}", keyWithoutNamingcontainer, Convert.ToBase64String(UnicodeEncoding.Default.GetBytes((string)_controlHtmlFingerprints[key]))); *************** *** 946,950 **** string panelKey = GetControlFingerprintsField(panelClientID); ! if ( AjaxCallHelper.IsAjaxCallForPage(_owner.Page) ) { //if ajax callback, generate javascript to set panelfingerprints's hidden field value --- 946,950 ---- string panelKey = GetControlFingerprintsField(panelClientID); ! if ( MagicAjaxContext.Current.IsAjaxCallForPage(_owner.Page) ) { //if ajax callback, generate javascript to set panelfingerprints's hidden field value |
From: Dion O. <dol...@us...> - 2005-11-23 15:12:56
|
Update of /cvsroot/magicajax/magicajax/Core/UI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31357/magicajax/Core/UI Modified Files: AjaxControl.cs AjaxPage.cs AjaxUserControl.cs Log Message: Major changes to enable MagicAjax for concurrent users. Added: MagicAjaxContext class (containing properties like 'IsAjaxCall') Added: PageFilter.cs (just moved the PageFilter class from MagicAjaxModule.cs) Index: AjaxUserControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/AjaxUserControl.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AjaxUserControl.cs 20 Nov 2005 08:47:29 -0000 1.6 --- AjaxUserControl.cs 23 Nov 2005 15:12:48 -0000 1.7 *************** *** 73,77 **** public bool IsAjaxCall { ! get { return AjaxCallHelper.IsAjaxCallForPage(this.Page); } } --- 73,77 ---- public bool IsAjaxCall { ! get { return MagicAjaxContext.Current.IsAjaxCallForPage(this.Page); } } Index: AjaxPage.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/AjaxPage.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AjaxPage.cs 20 Nov 2005 08:47:29 -0000 1.6 --- AjaxPage.cs 23 Nov 2005 15:12:48 -0000 1.7 *************** *** 73,77 **** public bool IsAjaxCall { ! get { return AjaxCallHelper.IsAjaxCallForPage(this); } } --- 73,77 ---- public bool IsAjaxCall { ! get { return HttpContext.Current != null && MagicAjaxContext.Current.IsAjaxCallForPage(this); } } Index: AjaxControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/AjaxControl.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AjaxControl.cs 22 Nov 2005 15:14:20 -0000 1.7 --- AjaxControl.cs 23 Nov 2005 15:12:48 -0000 1.8 *************** *** 62,66 **** public bool IsPageNoStoreMode { ! get { return AjaxCallHelper.IsPageNoStoreMode; } } --- 62,66 ---- public bool IsPageNoStoreMode { ! get { return HttpContext.Current != null && MagicAjaxContext.Current.IsPageNoStoreMode; } } *************** *** 71,75 **** public bool IsAjaxCall { ! get { return ( HttpContext.Current != null && this.Page != null && AjaxCallHelper.IsAjaxCallForPage(this.Page) ); } } --- 71,75 ---- public bool IsAjaxCall { ! get { return (HttpContext.Current != null && this.Page != null && MagicAjaxContext.Current.IsAjaxCallForPage(this.Page)); } } *************** *** 84,92 **** { // Register 'AjaxCallObject.js' script ! MagicAjaxModule.Instance.EnableAjaxOnPage(this.Page); #if NET_2_0 // add WebPartManager script (AddWebPartClientFunctions will check if this page is a WebPartPage) ! MagicAjaxModule.Instance.AddWebPartClientFunctions(this.Page); #endif --- 84,92 ---- { // Register 'AjaxCallObject.js' script ! MagicAjaxModule.EnableAjaxOnPage(this.Page); #if NET_2_0 // add WebPartManager script (AddWebPartClientFunctions will check if this page is a WebPartPage) ! MagicAjaxModule.AddWebPartClientFunctions(this.Page); #endif |
From: Argiris K. <be...@us...> - 2005-11-23 09:05:15
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32035/Core/script Modified Files: AjaxCallObject.js Log Message: Multiple trace windows if multiple AjaxCalls are 'loading'. All trace windows closes before postback/form submit. Index: AjaxCallObject.js =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/script/AjaxCallObject.js,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** AjaxCallObject.js 22 Nov 2005 21:34:20 -0000 1.20 --- AjaxCallObject.js 23 Nov 2005 09:05:06 -0000 1.21 *************** *** 8,12 **** __PreviousOnPageBeforeUnload = null; __PreviousOnPageUnload = null; ! __TraceWindow = null; function AjaxCallObject() --- 8,12 ---- __PreviousOnPageBeforeUnload = null; __PreviousOnPageUnload = null; ! __TraceWindows = new Array(); function AjaxCallObject() *************** *** 96,99 **** --- 96,100 ---- AjaxCallObject.prototype.OnFormSubmit = function() { + AJAXCbo.ClearTracingWindows(); document.forms[0][__PageStateCacheName].value = ""; *************** *** 129,132 **** --- 130,134 ---- AjaxCallObject.prototype.DoPostBack = function(eventTarget, eventArgument) { + AJAXCbo.ClearTracingWindows(); document.forms[0][__PageStateCacheName].value = ""; *************** *** 430,436 **** AjaxCallObject.prototype.CreateTracingWindow = function() { ! if (__TraceWindow == null || __TraceWindow.closed) ! __TraceWindow = window.open("","_blank","location=no,resizable=yes,scrollbars=yes"); ! this.TraceWindow = __TraceWindow; } --- 432,450 ---- AjaxCallObject.prototype.CreateTracingWindow = function() { ! this.TraceWindow = window.open("","_blank","location=no,resizable=yes,scrollbars=yes"); ! __TraceWindows.push(this.TraceWindow); ! } ! ! AjaxCallObject.prototype.ClearTracingWindows = function() ! { ! for (var i=0; i < __TraceWindows.length; i++) ! { ! if (__TraceWindows[i].closed || __TraceWindows[i].TraceFinished) ! { ! __TraceWindows[i].close(); ! __TraceWindows.splice(i, 1); ! i--; ! } ! } } *************** *** 461,464 **** --- 475,479 ---- this.WriteTrace("<b>------------------------------</b><br>"); this.TraceWindow.document.close(); + this.TraceWindow.TraceFinished = true; } |
From: Dion O. <dol...@us...> - 2005-11-22 21:34:30
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7281/magicajax/Core/script Modified Files: AjaxCallObject.js Log Message: client traces are now written in available trace-window. Index: AjaxCallObject.js =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/script/AjaxCallObject.js,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** AjaxCallObject.js 22 Nov 2005 10:58:32 -0000 1.19 --- AjaxCallObject.js 22 Nov 2005 21:34:20 -0000 1.20 *************** *** 8,11 **** --- 8,12 ---- __PreviousOnPageBeforeUnload = null; __PreviousOnPageUnload = null; + __TraceWindow = null; function AjaxCallObject() *************** *** 429,433 **** AjaxCallObject.prototype.CreateTracingWindow = function() { ! this.TraceWindow = window.open("","_blank","location=no,resizable=yes,scrollbars=yes"); } --- 430,436 ---- AjaxCallObject.prototype.CreateTracingWindow = function() { ! if (__TraceWindow == null || __TraceWindow.closed) ! __TraceWindow = window.open("","_blank","location=no,resizable=yes,scrollbars=yes"); ! this.TraceWindow = __TraceWindow; } |
From: Argiris K. <be...@us...> - 2005-11-22 15:14:30
|
Update of /cvsroot/magicajax/magicajax/Core/UI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6481/Core/UI Modified Files: AjaxControl.cs Log Message: Made AjaxControl abstract so that it won't appear as a control that can be added to the toolbox. Index: AjaxControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/AjaxControl.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AjaxControl.cs 20 Nov 2005 08:47:29 -0000 1.6 --- AjaxControl.cs 22 Nov 2005 15:14:20 -0000 1.7 *************** *** 31,35 **** /// The base control for controls to get notified for AjaxCall events from the client. /// </summary> ! public class AjaxControl : System.Web.UI.WebControls.WebControl, IAjaxCallEventHandler { /// <summary> --- 31,35 ---- /// The base control for controls to get notified for AjaxCall events from the client. /// </summary> ! public abstract class AjaxControl : System.Web.UI.WebControls.WebControl, IAjaxCallEventHandler { /// <summary> |
From: Argiris K. <be...@us...> - 2005-11-22 10:58:40
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1548/Core/script Modified Files: AjaxCallObject.js Log Message: Re-enabled page state store for IE. Index: AjaxCallObject.js =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/script/AjaxCallObject.js,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** AjaxCallObject.js 22 Nov 2005 00:59:23 -0000 1.18 --- AjaxCallObject.js 22 Nov 2005 10:58:32 -0000 1.19 *************** *** 95,98 **** --- 95,100 ---- AjaxCallObject.prototype.OnFormSubmit = function() { + document.forms[0][__PageStateCacheName].value = ""; + var target; if ("activeElement" in document) *************** *** 126,129 **** --- 128,133 ---- AjaxCallObject.prototype.DoPostBack = function(eventTarget, eventArgument) { + document.forms[0][__PageStateCacheName].value = ""; + var target; var elemUniqueID = eventTarget.split("$").join(":"); *************** *** 173,177 **** AjaxCallObject.prototype.OnPageBeforeUnload = function() ! { if (document.forms[0][__PageStateCacheName] != null) document.forms[0][__PageStateCacheName].value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); --- 177,182 ---- AjaxCallObject.prototype.OnPageBeforeUnload = function() ! { ! // Will be null if an Error page is displayed. if (document.forms[0][__PageStateCacheName] != null) document.forms[0][__PageStateCacheName].value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); |
From: Dion O. <dol...@us...> - 2005-11-22 10:38:05
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29854/magicajax/Core Modified Files: MagicAjaxModule.cs Log Message: Checking of browsercaps (in IsMagicAjaxSupportedBrowser) is now only checked once per request (by storing result in Context.Items). This increases performance. Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** MagicAjaxModule.cs 21 Nov 2005 21:40:14 -0000 1.24 --- MagicAjaxModule.cs 22 Nov 2005 10:37:50 -0000 1.25 *************** *** 144,164 **** if (HttpContext.Current != null) { ! HttpBrowserCapabilities caps = HttpContext.Current.Request.Browser; ! ! if (caps.Browser != null && caps.EcmaScriptVersion.Major >=1 && caps.W3CDomVersion.Major >= 1) { ! switch (caps.Browser.ToLower()) { ! case "ie": ! isSupported = caps.MajorVersion >5 || (caps.MajorVersion == 5 && caps.MinorVersion >= 5); ! break; ! case "gecko": ! isSupported = caps.Type.ToLower().StartsWith("firefox") && caps.MajorVersion >= 1; ! break; ! case "firefox": ! isSupported = caps.MajorVersion >= 1; ! break; ! //TODO: add support for Opera, Netscape and Safari } } } --- 144,173 ---- if (HttpContext.Current != null) { ! // See if supported-check is done before in this request ! if (HttpContext.Current.Items.Contains("__IsMagicAjaxSupportedBrowser")) { ! isSupported = (bool)HttpContext.Current.Items["__IsMagicAjaxSupportedBrowser"]; ! } ! else ! { ! HttpBrowserCapabilities caps = HttpContext.Current.Request.Browser; ! ! if (caps.Browser != null && caps.EcmaScriptVersion.Major >= 1 && caps.W3CDomVersion.Major >= 1) { ! switch (caps.Browser.ToLower()) ! { ! case "ie": ! isSupported = caps.MajorVersion > 5 || (caps.MajorVersion == 5 && caps.MinorVersion >= 5); ! break; ! case "gecko": ! isSupported = caps.Type.ToLower().StartsWith("firefox") && caps.MajorVersion >= 1; ! break; ! case "firefox": ! isSupported = caps.MajorVersion >= 1; ! break; ! //TODO: add support for Opera, Netscape and Safari ! } } + HttpContext.Current.Items.Add("__IsMagicAjaxSupportedBrowser", isSupported); } } |
From: Argiris K. <be...@us...> - 2005-11-22 00:59:30
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10664/Core/script Modified Files: AjaxCallObject.js Log Message: More testing revealed that an AjaxPanel that is invisible and not contained inside another AjaxPanel, cannot be made visible during AjaxCall correctly. To spare developers the confusion, an exception is thrown when this situation occurs. Index: AjaxCallObject.js =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/script/AjaxCallObject.js,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** AjaxCallObject.js 21 Nov 2005 21:40:14 -0000 1.17 --- AjaxCallObject.js 22 Nov 2005 00:59:23 -0000 1.18 *************** *** 174,183 **** AjaxCallObject.prototype.OnPageBeforeUnload = function() { ! if (navigator.appName != "Microsoft Internet Explorer") ! { ! // Save the html of the form, so that it can be restored for the browser's "Back Button" ! // Note: Firefox only document.forms[0][__PageStateCacheName].value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); ! } if (__PreviousOnPageBeforeUnload != null) return __PreviousOnPageBeforeUnload(); --- 174,180 ---- AjaxCallObject.prototype.OnPageBeforeUnload = function() { ! if (document.forms[0][__PageStateCacheName] != null) document.forms[0][__PageStateCacheName].value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); ! if (__PreviousOnPageBeforeUnload != null) return __PreviousOnPageBeforeUnload(); *************** *** 357,360 **** --- 354,360 ---- AjaxCallObject.prototype.OnAbort = function() { + this.WriteTrace("<b>!!! AjaxCall was aborted !!!</b>"); + this.TraceWindow.document.close(); + if (waitElement) waitElement.style.visibility = 'hidden'; *************** *** 363,366 **** --- 363,369 ---- AjaxCallObject.prototype.OnError = function(status, statusText, responseText) { + this.WriteTrace("<b>!!! Server reported an Error !!!</b>"); + this.TraceWindow.document.close(); + if (waitElement) waitElement.style.visibility = 'hidden'; |
From: Argiris K. <be...@us...> - 2005-11-22 00:59:30
|
Update of /cvsroot/magicajax/magicajax/Core/UI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10664/Core/UI Modified Files: RenderedByScriptControl.cs Log Message: More testing revealed that an AjaxPanel that is invisible and not contained inside another AjaxPanel, cannot be made visible during AjaxCall correctly. To spare developers the confusion, an exception is thrown when this situation occurs. Index: RenderedByScriptControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/RenderedByScriptControl.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** RenderedByScriptControl.cs 21 Nov 2005 12:18:37 -0000 1.10 --- RenderedByScriptControl.cs 22 Nov 2005 00:59:22 -0000 1.11 *************** *** 267,278 **** { // Put the control's tag on page ! ! base.RenderBeginTag (strwriter); ! _currentTagHtml = sb.ToString(); ! base.RenderEndTag (strwriter); ! string html = sb.ToString(); ! ! Control con = FindNextVisibleSibling(); ! AjaxCallHelper.WriteAddElementScript (Parent.ClientID, "Span", String.Empty, html, (con == null) ? null : con.ClientID); } else --- 267,271 ---- { // Put the control's tag on page ! PutTagOnPageForAjaxCall(); } else *************** *** 301,304 **** --- 294,311 ---- /// <summary> + /// Called when the control gets visible during AjaxCall and is not already + /// rendered on page. + /// </summary> + /// <remarks> + /// RenderedByScriptControl's method throws an exception because it doesn't know + /// where to put the tag. An inheriting control should override this method + /// to provide the appropriate functionality. + /// </remarks> + protected virtual void PutTagOnPageForAjaxCall() + { + throw new MagicAjaxException(String.Format("RenderByScript control '{0}' cannot get visible during an AjaxCall.", this.ClientID)); + } + + /// <summary> /// Gets the top control that has its Visible property set to false. /// </summary> |
From: Argiris K. <be...@us...> - 2005-11-22 00:59:30
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10664/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: More testing revealed that an AjaxPanel that is invisible and not contained inside another AjaxPanel, cannot be made visible during AjaxCall correctly. To spare developers the confusion, an exception is thrown when this situation occurs. Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** AjaxPanel.cs 20 Nov 2005 20:04:24 -0000 1.19 --- AjaxPanel.cs 22 Nov 2005 00:59:22 -0000 1.20 *************** *** 395,398 **** --- 395,419 ---- } + #region override PutTagOnPageForAjaxCall + /// <summary> + /// If this AjaxPanel is inside another AjaxPanel it puts its empty tag on page + /// using "clientID$rbs" ID, otherwise it throws an exception. + /// </summary> + protected override void PutTagOnPageForAjaxCall() + { + if ( ! IsChildOfAjaxPanel(this) ) + throw new MagicAjaxException(String.Format("AjaxPanel '{0}' cannot get visible during an AjaxCall. It must be inside an AjaxPanel that is visible for the initial page request.", this.ClientID)); + + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + HtmlTextWriter strwriter = new HtmlTextWriter(new System.IO.StringWriter(sb)); + + this.RenderBeginTag (strwriter); + this.RenderEndTag (strwriter); + string html = sb.ToString(); + + AjaxCallHelper.WriteSetHtmlOfElementScript (html, this.ClientID + "$rbs"); + } + #endregion + #region RenderByScript /// <summary> *************** *** 588,592 **** { RenderedByScriptControl con = (RenderedByScriptControl) sender; ! e.Writer.Write ("<span id=\"{0}$rbs\" name=\"__ajax_rbs\"><{1} id=\"{0}\"></{1}></span>", con.ClientID, con.GetTagName()); e.AbortRendering = true; } --- 609,613 ---- { RenderedByScriptControl con = (RenderedByScriptControl) sender; ! e.Writer.Write ("<span id=\"{0}$rbs\" name=\"__ajax_rbs\"></span>", con.ClientID); e.AbortRendering = true; } *************** *** 746,749 **** --- 767,788 ---- #endregion + #region IsChildOfAjaxPanel + /// <summary> + /// Returns true if the given control is contained inside an AjaxPanel + /// </summary> + /// <param name="control"></param> + /// <returns></returns> + private bool IsChildOfAjaxPanel (Control control) + { + if ( control.Parent == null || control.Parent == control.Page ) + return false; + + if ( control.Parent is AjaxPanel ) + return true; + else + return IsChildOfAjaxPanel(control.Parent); + } + #endregion + #region FindUniqueID /// <summary> *************** *** 950,960 **** Write ("<span id=\"{0}$rbs\" name=\"__ajax_rbs\">", con.ClientID); onlyFullRender = true; - litewriter.Write ("<{0} id=\"{1}\">", con.GetTagName(), con.ClientID); } public void IScriptWriter_RenderEnd(object sender, System.EventArgs e) { - RenderedByScriptControl con = (RenderedByScriptControl) sender; - litewriter.Write ("</{0}>", con.GetTagName()); onlyFullRender = false; Write ("</span>"); --- 989,996 ---- |
From: Dion O. <dol...@us...> - 2005-11-21 21:40:21
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20146/magicajax/Core Modified Files: MagicAjaxModule.cs Log Message: - fix for older version of FireFox - __PAGE_STATE_CACHE only filled for Firefox Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** MagicAjaxModule.cs 21 Nov 2005 16:32:42 -0000 1.23 --- MagicAjaxModule.cs 21 Nov 2005 21:40:14 -0000 1.24 *************** *** 178,181 **** --- 178,186 ---- if (page == null || AjaxCallHelper.IsAjaxCallForPage(page)) return; + // Enable AJAX only MagicAjax-supported browsers. + // Other browsers will get a plain postback page. + if (!IsMagicAjaxSupportedBrowser()) + return; + string STARTUP_SCRIPT_FORMAT = @" <script language='javascript'> *************** *** 188,196 **** if (!page.IsClientScriptBlockRegistered( "AJAXCALL_FOR_MAGICAJAX" )) { - // Enable AJAX only MagicAjax-supported browsers. - // Other browsers will get a plain postback page. - if (!IsMagicAjaxSupportedBrowser()) - return; - // Provides the location of the script file. string location = _config.ScriptPath; --- 193,196 ---- |
From: Dion O. <dol...@us...> - 2005-11-21 21:40:21
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20146/magicajax/Core/script Modified Files: AjaxCallObject.js Log Message: - fix for older version of FireFox - __PAGE_STATE_CACHE only filled for Firefox Index: AjaxCallObject.js =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/script/AjaxCallObject.js,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** AjaxCallObject.js 21 Nov 2005 18:58:23 -0000 1.16 --- AjaxCallObject.js 21 Nov 2005 21:40:14 -0000 1.17 *************** *** 86,91 **** window.onbeforeunload = this.OnPageBeforeUnload; } ! ! if ( bPageIsStored && bUnloadStoredPage ) { __PreviousOnPageUnload = window.onunload; --- 86,90 ---- window.onbeforeunload = this.OnPageBeforeUnload; } ! else { __PreviousOnPageUnload = window.onunload; *************** *** 96,101 **** AjaxCallObject.prototype.OnFormSubmit = function() { - document.forms[0][__PageStateCacheName].value = ""; - var target; if ("activeElement" in document) --- 95,98 ---- *************** *** 107,111 **** { // Firefox ! target = arguments[0].explicitOriginalTarget; } --- 104,108 ---- { // Firefox ! target = arguments[0] ? arguments[0].explicitOriginalTarget : null; } *************** *** 129,134 **** AjaxCallObject.prototype.DoPostBack = function(eventTarget, eventArgument) { - document.forms[0][__PageStateCacheName].value = ""; - var target; var elemUniqueID = eventTarget.split("$").join(":"); --- 126,129 ---- *************** *** 178,186 **** AjaxCallObject.prototype.OnPageBeforeUnload = function() ! { ! // Save the html of the form, so that it can be restored for the ! // browser's "Back Button" ! document.forms[0][__PageStateCacheName].value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); ! if (__PreviousOnPageBeforeUnload != null) return __PreviousOnPageBeforeUnload(); --- 173,183 ---- AjaxCallObject.prototype.OnPageBeforeUnload = function() ! { ! if (navigator.appName != "Microsoft Internet Explorer") ! { ! // Save the html of the form, so that it can be restored for the browser's "Back Button" ! // Note: Firefox only ! document.forms[0][__PageStateCacheName].value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); ! } if (__PreviousOnPageBeforeUnload != null) return __PreviousOnPageBeforeUnload(); *************** *** 305,310 **** { // Synchronous ! // Use a timeout so that the screen refreshes before getting stack waiting ! // the AjaxCall. window.setTimeout( function() --- 302,306 ---- { // Synchronous ! // Use a timeout so that the screen refreshes before getting stack waiting the AjaxCall. window.setTimeout( function() *************** *** 318,323 **** else oThis.OnError(oThis.XmlHttp.status, oThis.XmlHttp.statusText, oThis.XmlHttp.responseText); ! }, ! 1); } } --- 314,318 ---- else oThis.OnError(oThis.XmlHttp.status, oThis.XmlHttp.statusText, oThis.XmlHttp.responseText); ! }, 1); } } *************** *** 565,570 **** // wait element CreateWaitElement(); ! window.attachEvent("onscroll", MoveWaitElement); ! window.attachEvent("onresize", MoveWaitElement); var waitElement; function MoveWaitElement() --- 560,573 ---- // wait element CreateWaitElement(); ! if (window.addEventListener) ! { ! window.addEventListener('onscroll', MoveWaitElement, false); ! window.addEventListener('onresize', MoveWaitElement, false); ! } ! else if (window.attachEvent) ! { ! window.attachEvent('onscroll', MoveWaitElement); ! window.attachEvent('onresize', MoveWaitElement); ! } var waitElement; function MoveWaitElement() *************** *** 575,580 **** var width = document.body.clientWidth; waitElement.style.top = document.body.scrollTop; ! waitElement.style.left = width + document.body.offsetLeft - ! waitElement.offsetWidth; } function CreateWaitElement() --- 578,582 ---- var width = document.body.clientWidth; waitElement.style.top = document.body.scrollTop; ! waitElement.style.left = width + document.body.offsetLeft - waitElement.offsetWidth; } function CreateWaitElement() |
From: Argiris K. <be...@us...> - 2005-11-21 18:58:31
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9180/Core/script Modified Files: AjaxCallObject.js Log Message: __PAGE_STATE_CACHE is cleared at every postback/form submit. Index: AjaxCallObject.js =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/script/AjaxCallObject.js,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** AjaxCallObject.js 21 Nov 2005 16:32:42 -0000 1.15 --- AjaxCallObject.js 21 Nov 2005 18:58:23 -0000 1.16 *************** *** 96,99 **** --- 96,101 ---- AjaxCallObject.prototype.OnFormSubmit = function() { + document.forms[0][__PageStateCacheName].value = ""; + var target; if ("activeElement" in document) *************** *** 127,130 **** --- 129,134 ---- AjaxCallObject.prototype.DoPostBack = function(eventTarget, eventArgument) { + document.forms[0][__PageStateCacheName].value = ""; + var target; var elemUniqueID = eventTarget.split("$").join(":"); |
From: Argiris K. <be...@us...> - 2005-11-21 16:32:52
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31823/Core/script Modified Files: AjaxCallObject.js Log Message: Minor modification for Page state cache and IsMagicAjaxSupportedBrowser. Index: AjaxCallObject.js =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/script/AjaxCallObject.js,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** AjaxCallObject.js 21 Nov 2005 15:20:12 -0000 1.14 --- AjaxCallObject.js 21 Nov 2005 16:32:42 -0000 1.15 *************** *** 1,5 **** __AJAXCboList = new Array(); __bPageIsStored = false; ! __PageStateCache = null; __bTracing = false; __PreviousOnFormSubmit = null; --- 1,5 ---- __AJAXCboList = new Array(); __bPageIsStored = false; ! __PageStateCacheName = null; __bTracing = false; __PreviousOnFormSubmit = null; *************** *** 61,65 **** } ! AjaxCallObject.prototype.HookAjaxCall = function(bPageIsStored, bUnloadStoredPage, pageStateCache, bTracing) { __PreviousOnFormSubmit = document.forms[0].onsubmit; --- 61,65 ---- } ! AjaxCallObject.prototype.HookAjaxCall = function(bPageIsStored, bUnloadStoredPage, pageStateCacheName, bTracing) { __PreviousOnFormSubmit = document.forms[0].onsubmit; *************** *** 73,80 **** __bPageIsStored = bPageIsStored; ! __PageStateCache = pageStateCache; __bTracing = bTracing; ! __PageStateCache.setAttribute("ExcludeFromPost", "true"); if ( !bPageIsStored || !bUnloadStoredPage ) --- 73,80 ---- __bPageIsStored = bPageIsStored; ! __PageStateCacheName = pageStateCacheName; __bTracing = bTracing; ! document.forms[0][__PageStateCacheName].setAttribute("ExcludeFromPost", "true"); if ( !bPageIsStored || !bUnloadStoredPage ) *************** *** 162,170 **** { // Restore the html of form ! var html = __PageStateCache.value; if (html != "") { document.forms[0].innerHTML = decodeURIComponent(html.substr(5)); ! __PageStateCache.value = ""; } --- 162,170 ---- { // Restore the html of form ! var html = document.forms[0][__PageStateCacheName].value; if (html != "") { document.forms[0].innerHTML = decodeURIComponent(html.substr(5)); ! document.forms[0][__PageStateCacheName].value = ""; } *************** *** 177,181 **** // Save the html of the form, so that it can be restored for the // browser's "Back Button" ! __PageStateCache.value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); if (__PreviousOnPageBeforeUnload != null) --- 177,181 ---- // Save the html of the form, so that it can be restored for the // browser's "Back Button" ! document.forms[0][__PageStateCacheName].value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); if (__PreviousOnPageBeforeUnload != null) *************** *** 428,431 **** --- 428,435 ---- { this.WriteTrace("<b>Ajax Call invoked at " + new Date().toLocaleTimeString() + "<br>"); + if (__bPageIsStored) + this.WriteTrace("Page Store Mode: Stored (Session or Cache)<br>"); + else + this.WriteTrace("Page Store Mode: NoStore<br>"); this.WriteTrace("Form Data sent to server (" + data.length + " characters):<br>"); this.WriteTrace("------------------------------</b><br>"); |
From: Argiris K. <be...@us...> - 2005-11-21 16:32:50
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31823/Core Modified Files: MagicAjaxModule.cs Log Message: Minor modification for Page state cache and IsMagicAjaxSupportedBrowser. Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** MagicAjaxModule.cs 21 Nov 2005 13:39:48 -0000 1.22 --- MagicAjaxModule.cs 21 Nov 2005 16:32:42 -0000 1.23 *************** *** 148,156 **** if (caps.Browser != null && caps.EcmaScriptVersion.Major >=1 && caps.W3CDomVersion.Major >= 1) { ! switch (caps.Browser.ToLowerInvariant()) { case "ie": isSupported = caps.MajorVersion >5 || (caps.MajorVersion == 5 && caps.MinorVersion >= 5); break; case "firefox": isSupported = caps.MajorVersion >= 1; --- 148,159 ---- if (caps.Browser != null && caps.EcmaScriptVersion.Major >=1 && caps.W3CDomVersion.Major >= 1) { ! switch (caps.Browser.ToLower()) { case "ie": isSupported = caps.MajorVersion >5 || (caps.MajorVersion == 5 && caps.MinorVersion >= 5); break; + case "gecko": + isSupported = caps.Type.ToLower().StartsWith("firefox") && caps.MajorVersion >= 1; + break; case "firefox": isSupported = caps.MajorVersion >= 1; *************** *** 175,183 **** if (page == null || AjaxCallHelper.IsAjaxCallForPage(page)) return; - // Enable AJAX only MagicAjax-supported browsers. - // Other browsers will get a plain postback page. - if (!IsMagicAjaxSupportedBrowser()) - return; - string STARTUP_SCRIPT_FORMAT = @" <script language='javascript'> --- 178,181 ---- *************** *** 190,193 **** --- 188,196 ---- if (!page.IsClientScriptBlockRegistered( "AJAXCALL_FOR_MAGICAJAX" )) { + // Enable AJAX only MagicAjax-supported browsers. + // Other browsers will get a plain postback page. + if (!IsMagicAjaxSupportedBrowser()) + return; + // Provides the location of the script file. string location = _config.ScriptPath; *************** *** 245,249 **** bool unloadStoredPage = _config.PageStore.UnloadStoredPage; ! page.RegisterStartupScript( "AJAXCALL_HOOK", String.Format(STARTUP_SCRIPT_FORMAT, location, "AjaxCallObject.js", pageIsStored.ToString().ToLower(), unloadStoredPage.ToString().ToLower(), String.Format("document.forms[0][\"{0}\"]", pageStateCacheName), _config.Tracing.ToString().ToLower())); } } --- 248,252 ---- bool unloadStoredPage = _config.PageStore.UnloadStoredPage; ! page.RegisterStartupScript( "AJAXCALL_HOOK", String.Format(STARTUP_SCRIPT_FORMAT, location, "AjaxCallObject.js", pageIsStored.ToString().ToLower(), unloadStoredPage.ToString().ToLower(), AjaxCallHelper.EncodeString(pageStateCacheName), _config.Tracing.ToString().ToLower())); } } |
From: Dion O. <dol...@us...> - 2005-11-21 15:20:20
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15113/magicajax/Core/script Modified Files: AjaxCallObject.js Log Message: reverted back changes Index: AjaxCallObject.js =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/script/AjaxCallObject.js,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AjaxCallObject.js 21 Nov 2005 15:11:04 -0000 1.13 --- AjaxCallObject.js 21 Nov 2005 15:20:12 -0000 1.14 *************** *** 1,5 **** __AJAXCboList = new Array(); __bPageIsStored = false; - __bUnloadStoredPage = false; __PageStateCache = null; __bTracing = false; --- 1,4 ---- *************** *** 7,10 **** --- 6,10 ---- __PreviousPostBack = null; __PreviousOnPageLoad = null; + __PreviousOnPageBeforeUnload = null; __PreviousOnPageUnload = null; *************** *** 73,77 **** __bPageIsStored = bPageIsStored; - __bUnloadStoredPage = bUnloadStoredPage; __PageStateCache = pageStateCache; __bTracing = bTracing; --- 73,76 ---- *************** *** 83,90 **** __PreviousOnPageLoad = window.onload; window.onload = this.OnPageLoad; } ! __PreviousOnPageUnload = window.onunload; ! window.onunload = this.OnPageUnload; } --- 82,95 ---- __PreviousOnPageLoad = window.onload; window.onload = this.OnPageLoad; + + __PreviousOnPageBeforeUnload = window.onbeforeunload; + window.onbeforeunload = this.OnPageBeforeUnload; } ! if ( bPageIsStored && bUnloadStoredPage ) ! { ! __PreviousOnPageUnload = window.onunload; ! window.onunload = this.OnPageUnload; ! } } *************** *** 160,164 **** if (html != "") { - //alert('about to restore state'); document.forms[0].innerHTML = decodeURIComponent(html.substr(5)); __PageStateCache.value = ""; --- 165,168 ---- *************** *** 169,206 **** } AjaxCallObject.prototype.OnPageUnload = function() { ! if ( !__bPageIsStored || !__bUnloadStoredPage ) ! { ! // Save the html of the form, so that it can be restored for the ! // browser's "Back Button" ! __PageStateCache.value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); ! //alert('just saved state'); ! } ! else ! { ! if (document.forms[0]["__AJAX_PAGEKEY"] == null) ! return; ! var thePage = document.forms[0].action; ! var index = thePage.indexOf("?"); ! if (index != -1) ! thePage = thePage.substring(0, index); ! thePage = thePage + "?__AJAX_PAGEUNLOAD=" + encodeURIComponent(document.forms[0]["__AJAX_PAGEKEY"].value); ! var oThis = AJAXCbo; ! __AJAXCboList.push(oThis); ! AJAXCbo = new AjaxCallObject(); ! if( oThis.XmlHttp ) ! { ! oThis.XmlHttp.open('GET', thePage, true); ! oThis.XmlHttp.onreadystatechange = function(){ }; ! oThis.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); ! oThis.XmlHttp.send(null); ! } } ! if (__PreviousOnPageUnload != null) return __PreviousOnPageUnload(); --- 173,210 ---- } + AjaxCallObject.prototype.OnPageBeforeUnload = function() + { + // Save the html of the form, so that it can be restored for the + // browser's "Back Button" + __PageStateCache.value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); + + if (__PreviousOnPageBeforeUnload != null) + return __PreviousOnPageBeforeUnload(); + } + AjaxCallObject.prototype.OnPageUnload = function() { ! if (document.forms[0]["__AJAX_PAGEKEY"] == null) ! return; ! var thePage = document.forms[0].action; ! var index = thePage.indexOf("?"); ! if (index != -1) ! thePage = thePage.substring(0, index); ! thePage = thePage + "?__AJAX_PAGEUNLOAD=" + encodeURIComponent(document.forms[0]["__AJAX_PAGEKEY"].value); ! var oThis = AJAXCbo; ! __AJAXCboList.push(oThis); ! AJAXCbo = new AjaxCallObject(); ! if( oThis.XmlHttp ) ! { ! oThis.XmlHttp.open('GET', thePage, true); ! oThis.XmlHttp.onreadystatechange = function(){ }; ! oThis.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); ! oThis.XmlHttp.send(null); } ! if (__PreviousOnPageUnload != null) return __PreviousOnPageUnload(); |
From: Dion O. <dol...@us...> - 2005-11-21 15:11:13
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13141/magicajax/Core/script Modified Files: AjaxCallObject.js Log Message: storing of PageStateCache is now done during 'window.onunload' instead of 'window.onbeforeunload'. So now ajax linkbuttons (href) won't call window.onbeforeunload anymore. Index: AjaxCallObject.js =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/script/AjaxCallObject.js,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** AjaxCallObject.js 21 Nov 2005 12:18:37 -0000 1.12 --- AjaxCallObject.js 21 Nov 2005 15:11:04 -0000 1.13 *************** *** 1,4 **** --- 1,5 ---- __AJAXCboList = new Array(); __bPageIsStored = false; + __bUnloadStoredPage = false; __PageStateCache = null; __bTracing = false; *************** *** 6,10 **** __PreviousPostBack = null; __PreviousOnPageLoad = null; - __PreviousOnPageBeforeUnload = null; __PreviousOnPageUnload = null; --- 7,10 ---- *************** *** 73,76 **** --- 73,77 ---- __bPageIsStored = bPageIsStored; + __bUnloadStoredPage = bUnloadStoredPage; __PageStateCache = pageStateCache; __bTracing = bTracing; *************** *** 82,95 **** __PreviousOnPageLoad = window.onload; window.onload = this.OnPageLoad; - - __PreviousOnPageBeforeUnload = window.onbeforeunload; - window.onbeforeunload = this.OnPageBeforeUnload; } ! if ( bPageIsStored && bUnloadStoredPage ) ! { ! __PreviousOnPageUnload = window.onunload; ! window.onunload = this.OnPageUnload; ! } } --- 83,90 ---- __PreviousOnPageLoad = window.onload; window.onload = this.OnPageLoad; } ! __PreviousOnPageUnload = window.onunload; ! window.onunload = this.OnPageUnload; } *************** *** 165,168 **** --- 160,164 ---- if (html != "") { + //alert('about to restore state'); document.forms[0].innerHTML = decodeURIComponent(html.substr(5)); __PageStateCache.value = ""; *************** *** 173,210 **** } - AjaxCallObject.prototype.OnPageBeforeUnload = function() - { - // Save the html of the form, so that it can be restored for the - // browser's "Back Button" - __PageStateCache.value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); - - if (__PreviousOnPageBeforeUnload != null) - return __PreviousOnPageBeforeUnload(); - } - AjaxCallObject.prototype.OnPageUnload = function() { ! if (document.forms[0]["__AJAX_PAGEKEY"] == null) ! return; ! var thePage = document.forms[0].action; ! var index = thePage.indexOf("?"); ! if (index != -1) ! thePage = thePage.substring(0, index); ! thePage = thePage + "?__AJAX_PAGEUNLOAD=" + encodeURIComponent(document.forms[0]["__AJAX_PAGEKEY"].value); ! var oThis = AJAXCbo; ! __AJAXCboList.push(oThis); ! AJAXCbo = new AjaxCallObject(); ! if( oThis.XmlHttp ) ! { ! oThis.XmlHttp.open('GET', thePage, true); ! oThis.XmlHttp.onreadystatechange = function(){ }; ! oThis.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); ! oThis.XmlHttp.send(null); } ! if (__PreviousOnPageUnload != null) return __PreviousOnPageUnload(); --- 169,206 ---- } AjaxCallObject.prototype.OnPageUnload = function() { ! if ( !__bPageIsStored || !__bUnloadStoredPage ) ! { ! // Save the html of the form, so that it can be restored for the ! // browser's "Back Button" ! __PageStateCache.value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); ! //alert('just saved state'); ! } ! else ! { ! if (document.forms[0]["__AJAX_PAGEKEY"] == null) ! return; ! var thePage = document.forms[0].action; ! var index = thePage.indexOf("?"); ! if (index != -1) ! thePage = thePage.substring(0, index); ! thePage = thePage + "?__AJAX_PAGEUNLOAD=" + encodeURIComponent(document.forms[0]["__AJAX_PAGEKEY"].value); ! var oThis = AJAXCbo; ! __AJAXCboList.push(oThis); ! AJAXCbo = new AjaxCallObject(); ! if( oThis.XmlHttp ) ! { ! oThis.XmlHttp.open('GET', thePage, true); ! oThis.XmlHttp.onreadystatechange = function(){ }; ! oThis.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); ! oThis.XmlHttp.send(null); ! } } ! if (__PreviousOnPageUnload != null) return __PreviousOnPageUnload(); |
From: Dion O. <dol...@us...> - 2005-11-21 13:39:57
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23710/magicajax/Core Modified Files: MagicAjaxModule.cs Log Message: Replaced 'document.all' with 'document.forms[0]'. (because document.all is only supported by IE and the newest Firefox browsers; if we want to support netscape and Safari in the future, we'll have less trouble ;) Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** MagicAjaxModule.cs 21 Nov 2005 13:28:50 -0000 1.21 --- MagicAjaxModule.cs 21 Nov 2005 13:39:48 -0000 1.22 *************** *** 245,249 **** bool unloadStoredPage = _config.PageStore.UnloadStoredPage; ! page.RegisterStartupScript( "AJAXCALL_HOOK", String.Format(STARTUP_SCRIPT_FORMAT, location, "AjaxCallObject.js", pageIsStored.ToString().ToLower(), unloadStoredPage.ToString().ToLower(), String.Format("document.all[\"{0}\"]", pageStateCacheName), _config.Tracing.ToString().ToLower())); } } --- 245,249 ---- bool unloadStoredPage = _config.PageStore.UnloadStoredPage; ! page.RegisterStartupScript( "AJAXCALL_HOOK", String.Format(STARTUP_SCRIPT_FORMAT, location, "AjaxCallObject.js", pageIsStored.ToString().ToLower(), unloadStoredPage.ToString().ToLower(), String.Format("document.forms[0][\"{0}\"]", pageStateCacheName), _config.Tracing.ToString().ToLower())); } } |
From: Dion O. <dol...@us...> - 2005-11-21 13:29:08
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20732/magicajax/Core Modified Files: MagicAjaxModule.cs Log Message: I've added the method IsMagicAjaxSupportedBrowser() in MagicAjaxModule.cs that return 'true' if MagicAjax supports it Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** MagicAjaxModule.cs 21 Nov 2005 12:18:36 -0000 1.20 --- MagicAjaxModule.cs 21 Nov 2005 13:28:50 -0000 1.21 *************** *** 135,138 **** --- 135,167 ---- /// <summary> + /// Returns if this browser is supported by MagicAjax. + /// For now (version 0.2) only IE and FireFox are supported. + /// </summary> + /// <returns></returns> + public bool IsMagicAjaxSupportedBrowser() + { + bool isSupported = false; + if (HttpContext.Current != null) + { + HttpBrowserCapabilities caps = HttpContext.Current.Request.Browser; + + if (caps.Browser != null && caps.EcmaScriptVersion.Major >=1 && caps.W3CDomVersion.Major >= 1) + { + switch (caps.Browser.ToLowerInvariant()) + { + case "ie": + isSupported = caps.MajorVersion >5 || (caps.MajorVersion == 5 && caps.MinorVersion >= 5); + break; + case "firefox": + isSupported = caps.MajorVersion >= 1; + break; + //TODO: add support for Opera, Netscape and Safari + } + } + } + return isSupported; + } + + /// <summary> /// Enables AJAX on a Page. /// </summary> *************** *** 146,153 **** if (page == null || AjaxCallHelper.IsAjaxCallForPage(page)) return; ! // Enable AJAX only for IE and Firefox, to be on the safe side. // Other browsers will get a plain postback page. ! if (page.Request.Browser.Type != "IE6" ! && page.Request.Browser.Type != "Firefox") return; --- 175,181 ---- if (page == null || AjaxCallHelper.IsAjaxCallForPage(page)) return; ! // Enable AJAX only MagicAjax-supported browsers. // Other browsers will get a plain postback page. ! if (!IsMagicAjaxSupportedBrowser()) return; |
From: Argiris K. <be...@us...> - 2005-11-21 12:18:45
|
Update of /cvsroot/magicajax/magicajax/Core/UI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2251/Core/UI Modified Files: RenderedByScriptControl.cs Log Message: Replaced RBS_Control_Stores with a single field storing the form's html. Added 'tracing' configuration option, used to monitor the traffic of AjaxCalls. Added a check that does not enable MagicAjax for browsers other than IE and Firefox. Index: RenderedByScriptControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/RenderedByScriptControl.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RenderedByScriptControl.cs 20 Nov 2005 08:47:29 -0000 1.9 --- RenderedByScriptControl.cs 21 Nov 2005 12:18:37 -0000 1.10 *************** *** 188,232 **** } - protected override void OnLoad(EventArgs e) - { - base.OnLoad (e); - - if (!IsChildOfRenderedByScriptControl(this)) - { - string hiddenStore; - - if ( IsPageNoStoreMode ) - { - // Firefox, when performing a refresh, loads the page but keeps any INPUT - // field values. Thus, the html of a RenderedByScriptControl is restored - // as if the page was loaded because of the browser's "Back Button". - // We cannot avoid this because Firefox also keeps any changes that occured - // to ViewState, so we need the controls to keep their changes. - hiddenStore = this.ClientID + "$RBS_Store"; - } - else - { - // At storing modes we don't mess with the ViewState field, so use - // a different name for the hidden field at each page request so that - // it can be reset for Firefox's "Refresh". - hiddenStore = this.ClientID + "$RBS_Store" + DateTime.Now.Ticks; - } - - Page.RegisterHiddenField(hiddenStore, null); - Page.RegisterArrayDeclaration("RBS_ControlIDs", String.Format("\"{0}$RBS_Holder\"", this.ClientID)); - Page.RegisterArrayDeclaration("RBS_Controls_Store", String.Format("document.all[\"{0}\"]", hiddenStore)); - } - } - - protected bool IsChildOfRenderedByScriptControl(Control control) - { - if (control.Parent == null || control.Parent == control.Page) - return false; - else if (control.Parent is RenderedByScriptControl) - return true; - else - return IsChildOfRenderedByScriptControl(control.Parent); - } - /// <summary> /// Normal rendering. --- 188,191 ---- *************** *** 247,256 **** if ( !IsAjaxCall || (writer.InnerWriter is IScriptRenderingDisabler && (writer.InnerWriter as IScriptRenderingDisabler).DisableScriptRendering) ) { - // Put the html of this control inside a SPAN tag so that it can - // be saved and restored when the page is loaded from the Browser's cache, - // i.e. when the back button is pressed. - writer.Write("<span id='{0}$RBS_Holder'>", this.ClientID); base.Render (writer); - writer.Write("</span>"); _isHtmlRendered = true; --- 206,210 ---- *************** *** 312,316 **** if ( ! IsRenderedOnPage ) { ! // Put the control's tag on page, inside a RBS_Holder span. base.RenderBeginTag (strwriter); --- 266,270 ---- if ( ! IsRenderedOnPage ) { ! // Put the control's tag on page base.RenderBeginTag (strwriter); *************** *** 320,324 **** Control con = FindNextVisibleSibling(); ! AjaxCallHelper.WriteAddElementScript (Parent.ClientID, "Span", this.ClientID + "$RBS_Holder", html, (con == null) ? null : con.ClientID); } else --- 274,278 ---- Control con = FindNextVisibleSibling(); ! AjaxCallHelper.WriteAddElementScript (Parent.ClientID, "Span", String.Empty, html, (con == null) ? null : con.ClientID); } else |
From: Argiris K. <be...@us...> - 2005-11-21 12:18:45
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2251/Core Modified Files: MagicAjaxModule.cs Util.cs Web.config Log Message: Replaced RBS_Control_Stores with a single field storing the form's html. Added 'tracing' configuration option, used to monitor the traffic of AjaxCalls. Added a check that does not enable MagicAjax for browsers other than IE and Firefox. Index: Web.config =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/Web.config,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Web.config 20 Nov 2005 20:04:24 -0000 1.4 --- Web.config 21 Nov 2005 12:18:36 -0000 1.5 *************** *** 11,14 **** --- 11,17 ---- If omitted, the embedded "AjaxCallObject.js" file is used (default). example: <magicAjax ajaxCallScriptPath="~/script" /> + tracing - "true" : When an AjaxCall is invoked a popup window displays the data that were sent + to the server and the data that the client received. Used to monitor the traffic of AjaxCalls. + "false" : tracing is disabled (Default). pageStore/mode - "NoStore" : Doesn't store the page object, it is recreated for each AjaxCall "Session" : Saves the page object in session, works only for "InProc" SessionState *************** *** 27,34 **** limit is reached. Default is false pageStore/outputCompareMode - "HashCode" : Use String.GetHashCode() to find changed Html output ! "MD5" : Use MD5 hashing to find changed Html output (slower, but practically no collisions) "FullHtml" : Use the complete Html output to find changes (for debugging purposes only) Default is "HashCode" --> ! <magicAjax> <pageStore mode="NoStore" --- 30,38 ---- limit is reached. Default is false pageStore/outputCompareMode - "HashCode" : Use String.GetHashCode() to find changed Html output ! "MD5" : Use MD5 hashing to find changed Html output (slower and larger in size, but practically no collisions) "FullHtml" : Use the complete Html output to find changes (for debugging purposes only) Default is "HashCode" --> ! <magicAjax ! tracing="false"> <pageStore mode="NoStore" Index: Util.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/Util.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Util.cs 20 Nov 2005 20:04:24 -0000 1.4 --- Util.cs 21 Nov 2005 12:18:36 -0000 1.5 *************** *** 24,39 **** case MagicAjax.Configuration.OutputCompareMode.FullHtml: return input; - break; case MagicAjax.Configuration.OutputCompareMode.HashCode: return input.GetHashCode().ToString("X2"); - break; case MagicAjax.Configuration.OutputCompareMode.MD5: byte[] inputBytes = UnicodeEncoding.Default.GetBytes(input); byte[] hashedBytes = new MD5CryptoServiceProvider().ComputeHash(inputBytes); return Convert.ToBase64String(hashedBytes); - break; default: return input; - break; } } --- 24,35 ---- Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** MagicAjaxModule.cs 20 Nov 2005 20:04:24 -0000 1.19 --- MagicAjaxModule.cs 21 Nov 2005 12:18:36 -0000 1.20 *************** *** 146,149 **** --- 146,155 ---- if (page == null || AjaxCallHelper.IsAjaxCallForPage(page)) return; + // Enable AJAX only for IE and Firefox, to be on the safe side. + // Other browsers will get a plain postback page. + if (page.Request.Browser.Type != "IE6" + && page.Request.Browser.Type != "Firefox") + return; + string STARTUP_SCRIPT_FORMAT = @" <script language='javascript'> *************** *** 151,155 **** alert(""Unable to find script library '{0}/{1}'. Copy the file to the required location, or change the 'ajaxCallScriptPath' setting at magicAjax section of web.config.""); else ! AJAXCbo.HookAjaxCall({2},{3}); </script>"; --- 157,161 ---- alert(""Unable to find script library '{0}/{1}'. Copy the file to the required location, or change the 'ajaxCallScriptPath' setting at magicAjax section of web.config.""); else ! AJAXCbo.HookAjaxCall({2},{3},{4},{5}); </script>"; *************** *** 179,184 **** bool pageIsStored = (_config.PageStore.Mode != PageStoreMode.NoStore); ! bool unloadStoredPage = _config.PageStore.UnloadStoredPage; ! page.RegisterStartupScript( "AJAXCALL_HOOK", String.Format(STARTUP_SCRIPT_FORMAT, location, "AjaxCallObject.js", pageIsStored.ToString().ToLower(), unloadStoredPage.ToString().ToLower())); if ( pageIsStored ) --- 185,189 ---- bool pageIsStored = (_config.PageStore.Mode != PageStoreMode.NoStore); ! string pageStateCacheName; if ( pageIsStored ) *************** *** 193,197 **** --- 198,221 ---- page.RegisterHiddenField (PageKeyFieldName, key); } + + // At storing modes we don't mess with the ViewState field, so use + // a different name for the hidden field at each page request so that + // it can be reset for Firefox's "Refresh". + pageStateCacheName = "__PAGE_STATE_CACHE" + DateTime.Now.Ticks; + } + else + { + // Firefox, when performing a refresh, loads the page but keeps any changed INPUT + // field values. Thus, the html of __PAGE_STATE_CACHE is restored + // as if the page was loaded because of the browser's "Back Button". + // We cannot avoid this because Firefox also keeps any changes that occured + // to ViewState, so we need the controls to keep their changes. + pageStateCacheName = "__PAGE_STATE_CACHE"; } + + page.RegisterHiddenField(pageStateCacheName, String.Empty); + + bool unloadStoredPage = _config.PageStore.UnloadStoredPage; + page.RegisterStartupScript( "AJAXCALL_HOOK", String.Format(STARTUP_SCRIPT_FORMAT, location, "AjaxCallObject.js", pageIsStored.ToString().ToLower(), unloadStoredPage.ToString().ToLower(), String.Format("document.all[\"{0}\"]", pageStateCacheName), _config.Tracing.ToString().ToLower())); } } *************** *** 409,416 **** { case PageStoreMode.Session: ! return String.Format("__AJAX_{0}_{1}", page.Request.FilePath, page.GetTypeHashCode()); case PageStoreMode.Cache: ! return String.Format("__AJAX_{0}_{1}_{2}", _context.Session.SessionID, page.Request.FilePath, page.GetTypeHashCode()); default: --- 433,440 ---- { case PageStoreMode.Session: ! return String.Format("__AJAX_{0}_{1}", page.Request.FilePath, page.GetTypeHashCode().ToString("X2")); case PageStoreMode.Cache: ! return String.Format("__AJAX_{0}_{1}_{2}", _context.Session.SessionID, page.Request.FilePath, page.GetTypeHashCode().ToString("X2")); default: |
From: Argiris K. <be...@us...> - 2005-11-21 12:18:45
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2251/Core/script Modified Files: AjaxCallObject.js Log Message: Replaced RBS_Control_Stores with a single field storing the form's html. Added 'tracing' configuration option, used to monitor the traffic of AjaxCalls. Added a check that does not enable MagicAjax for browsers other than IE and Firefox. Index: AjaxCallObject.js =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/script/AjaxCallObject.js,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** AjaxCallObject.js 20 Nov 2005 08:47:30 -0000 1.11 --- AjaxCallObject.js 21 Nov 2005 12:18:37 -0000 1.12 *************** *** 1,4 **** --- 1,6 ---- __AJAXCboList = new Array(); __bPageIsStored = false; + __PageStateCache = null; + __bTracing = false; __PreviousOnFormSubmit = null; __PreviousPostBack = null; *************** *** 59,63 **** } ! AjaxCallObject.prototype.HookAjaxCall = function(bPageIsStored, bUnloadStoredPage) { __PreviousOnFormSubmit = document.forms[0].onsubmit; --- 61,65 ---- } ! AjaxCallObject.prototype.HookAjaxCall = function(bPageIsStored, bUnloadStoredPage, pageStateCache, bTracing) { __PreviousOnFormSubmit = document.forms[0].onsubmit; *************** *** 71,80 **** __bPageIsStored = bPageIsStored; ! if (typeof(RBS_ControlIDs) != "undefined") ! { ! for (var i=0; i < RBS_ControlIDs.length; i++) ! RBS_Controls_Store[i].setAttribute("ExcludeFromPost", "true"); ! } if ( !bPageIsStored || !bUnloadStoredPage ) --- 73,80 ---- __bPageIsStored = bPageIsStored; + __PageStateCache = pageStateCache; + __bTracing = bTracing; ! __PageStateCache.setAttribute("ExcludeFromPost", "true"); if ( !bPageIsStored || !bUnloadStoredPage ) *************** *** 161,178 **** AjaxCallObject.prototype.OnPageLoad = function() { ! // Restore the html of RenderedByScript controls ! if (typeof(RBS_ControlIDs) != "undefined") { ! for (var i=0; i < RBS_ControlIDs.length; i++) ! { ! var elem = document.all[RBS_ControlIDs[i]]; ! var html = RBS_Controls_Store[i].value; ! if (html != "" && elem != null) ! { ! elem.innerHTML = decodeURIComponent(html.substring(5, html.length)); ! RBS_Controls_Store[i].value = ""; ! } ! } } if (__PreviousOnPageLoad != null) return __PreviousOnPageLoad(); --- 161,172 ---- AjaxCallObject.prototype.OnPageLoad = function() { ! // Restore the html of form ! var html = __PageStateCache.value; ! if (html != "") { ! document.forms[0].innerHTML = decodeURIComponent(html.substr(5)); ! __PageStateCache.value = ""; } + if (__PreviousOnPageLoad != null) return __PreviousOnPageLoad(); *************** *** 181,195 **** AjaxCallObject.prototype.OnPageBeforeUnload = function() { ! // Save the html of RenderedByScript controls, so that it can be restored for the // browser's "Back Button" ! if (typeof(RBS_ControlIDs) != "undefined") ! { ! for (var i=0; i < RBS_ControlIDs.length; i++) ! { ! var elem = document.all[RBS_ControlIDs[i]]; ! if (elem != null) ! RBS_Controls_Store[i].value = "HTML:" + encodeURIComponent(elem.innerHTML); ! } ! } if (__PreviousOnPageBeforeUnload != null) return __PreviousOnPageBeforeUnload(); --- 175,182 ---- AjaxCallObject.prototype.OnPageBeforeUnload = function() { ! // Save the html of the form, so that it can be restored for the // browser's "Back Button" ! __PageStateCache.value = "HTML:" + encodeURIComponent(document.forms[0].innerHTML); ! if (__PreviousOnPageBeforeUnload != null) return __PreviousOnPageBeforeUnload(); *************** *** 280,286 **** } ! if (theData.substring(theData.length-1, theData.length) == "&") ! theData = theData.substring(0, theData.length-1); ! if( this.XmlHttp ) { --- 267,273 ---- } ! if (theData.substr(theData.length-1) == "&") ! theData = theData.substr(0, theData.length-1); ! if( this.XmlHttp ) { *************** *** 294,297 **** --- 281,290 ---- __AJAXCboList.push(oThis); AJAXCbo = new AjaxCallObject(); + + if (__bTracing) + { + this.CreateTracingWindow(); + this.TraceSentData(theData); + } if( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 ) *************** *** 345,353 **** AjaxCallObject.prototype.OnComplete = function(responseText, responseXml) { ! //alert(responseText); // Checking if the data were fully loaded, without being aborted var flag = "'AJAX_LOADING_OK';\r\n"; ! if (responseText.substring(responseText.length - flag.length, responseText.length) != flag) return false; --- 338,349 ---- AjaxCallObject.prototype.OnComplete = function(responseText, responseXml) { ! if (__bTracing) ! { ! this.TraceReceivedData(responseText); ! } // Checking if the data were fully loaded, without being aborted var flag = "'AJAX_LOADING_OK';\r\n"; ! if (responseText.substr(responseText.length - flag.length) != flag) return false; *************** *** 407,410 **** --- 403,408 ---- } + AjaxCallObject.prototype.TraceWindow = null; + AjaxCallObject.prototype.ClockID = 0; *************** *** 422,425 **** --- 420,457 ---- } + AjaxCallObject.prototype.CreateTracingWindow = function() + { + this.TraceWindow = window.open("","_blank","location=no,resizable=yes,scrollbars=yes"); + } + + AjaxCallObject.prototype.TraceSentData = function(data) + { + this.WriteTrace("<b>Ajax Call invoked at " + new Date().toLocaleTimeString() + "<br>"); + this.WriteTrace("Form Data sent to server (" + data.length + " characters):<br>"); + this.WriteTrace("------------------------------</b><br>"); + + var fields = data.split("&"); + for (var i=0; i < fields.length; i++) + this.WriteTrace(decodeURIComponent(fields[i].split("<").join("<")) + "<br>"); + + this.WriteTrace("<b>------------------------------</b><br>"); + this.WriteTrace("Waiting response from server.....<br>"); + } + + AjaxCallObject.prototype.TraceReceivedData = function(data) + { + this.WriteTrace("<b>Server responsed at " + new Date().toLocaleTimeString() + "<br>"); + this.WriteTrace("Javascript code received from server (" + data.length + " characters):<br>"); + this.WriteTrace("------------------------------</b><br>"); + this.WriteTrace(data.split("<").join("<").split("\r\n").join("<br>")); + this.WriteTrace("<b>------------------------------</b><br>"); + this.TraceWindow.document.close(); + } + + AjaxCallObject.prototype.WriteTrace = function(text) + { + this.TraceWindow.document.write(text); + } + AjaxCallObject.prototype.SetAttributesOfControl = function(clientID, attributes) { *************** *** 439,443 **** { var place = document.getElementById(parentID); ! var child = document.getElementById(elementID); if (place != null && child == null) { --- 471,475 ---- { var place = document.getElementById(parentID); ! var child = (elementID != "") ? document.getElementById(elementID) : null; if (place != null && child == null) { *************** *** 446,451 **** var before = (beforeElemID != null) ? document.getElementById(beforeElemID) : null; place.insertBefore(child, before); } ! this.SetHtmlOfElementScript (html, elementID); } --- 478,485 ---- var before = (beforeElemID != null) ? document.getElementById(beforeElemID) : null; place.insertBefore(child, before); + child.innerHTML = html; } ! else ! this.SetHtmlOfElementScript (html, elementID); } |
From: Argiris K. <be...@us...> - 2005-11-21 12:18:44
|
Update of /cvsroot/magicajax/magicajax/Core/Configuration In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2251/Core/Configuration Modified Files: MagicAjaxConfiguration.cs Log Message: Replaced RBS_Control_Stores with a single field storing the form's html. Added 'tracing' configuration option, used to monitor the traffic of AjaxCalls. Added a check that does not enable MagicAjax for browsers other than IE and Firefox. Index: MagicAjaxConfiguration.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/Configuration/MagicAjaxConfiguration.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MagicAjaxConfiguration.cs 20 Nov 2005 20:04:23 -0000 1.4 --- MagicAjaxConfiguration.cs 21 Nov 2005 12:18:36 -0000 1.5 *************** *** 76,79 **** --- 76,80 ---- { private string _scriptPath; + private bool _tracing; private PageStore _pageStore; *************** *** 83,86 **** --- 84,92 ---- } + public bool Tracing + { + get { return _tracing; } + } + public PageStore PageStore { *************** *** 92,95 **** --- 98,102 ---- // Default values _scriptPath = null; // Null implicates that the embedded javascripts will be used (default) + _tracing = false; PageStoreMode mode = PageStoreMode.NoStore; bool unloadStoredPage = false; *************** *** 108,111 **** --- 115,131 ---- } + attrib = (XmlAttribute)xml.Attributes.GetNamedItem("tracing"); + if (attrib != null) + { + try + { + _tracing = bool.Parse(attrib.Value); + } + catch + { + throw new ConfigurationException("MagicAjax configuration: tracing must be boolean."); + } + } + XmlNode pageStore = xml["pageStore"]; attrib = (XmlAttribute)pageStore.Attributes.GetNamedItem("mode"); |
From: Dion O. <dol...@us...> - 2005-11-20 20:04:33
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24881/magicajax/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Fingerprints are now configurable (default HashCode, MD5 or FullHtml). Now used for all modes (so not only NoStore). Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** AjaxPanel.cs 20 Nov 2005 13:46:28 -0000 1.18 --- AjaxPanel.cs 20 Nov 2005 20:04:24 -0000 1.19 *************** *** 28,31 **** --- 28,32 ---- using System.Web.UI.HtmlControls; using System.Globalization; + using System.Text; namespace MagicAjax.UI.Controls *************** *** 82,87 **** private ArrayList _addedControls = new ArrayList(); private ArrayList _removedControls = new ArrayList(); ! private Hashtable _controlHtmls = new Hashtable(); ! private Hashtable _controlHtmlHashes = new Hashtable(); private ControlCollectionState _controlState; --- 83,87 ---- private ArrayList _addedControls = new ArrayList(); private ArrayList _removedControls = new ArrayList(); ! private Hashtable _controlHtmlFingerprints = new Hashtable(); private ControlCollectionState _controlState; *************** *** 183,190 **** ExtendedRenderControl (control, litewriter); ! if (IsPageNoStoreMode) ! _controlHtmlHashes[control] = Util.GetBase64MD5Sum(sb.ToString()); ! else ! _controlHtmls[control] = sb.ToString(); sb.Length = 0; --- 183,187 ---- ExtendedRenderControl (control, litewriter); ! _controlHtmlFingerprints[control] = Util.GetFingerprint(sb.ToString()); sb.Length = 0; *************** *** 203,208 **** _addedControls.Clear(); _removedControls.Clear(); ! _controlHtmls.Clear(); ! _controlHtmlHashes.Clear(); } #endregion --- 200,204 ---- _addedControls.Clear(); _removedControls.Clear(); ! _controlHtmlFingerprints.Clear(); } #endregion *************** *** 326,333 **** writer.Write (sbFull.ToString()); ! if (IsPageNoStoreMode) ! _controlHtmlHashes[con] = Util.GetBase64MD5Sum(sb.ToString()); ! else ! _controlHtmls[con] = sb.ToString(); sbFull.Length = 0; --- 322,326 ---- writer.Write (sbFull.ToString()); ! _controlHtmlFingerprints[con] = Util.GetFingerprint(sb.ToString()); sbFull.Length = 0; *************** *** 348,352 **** { //note:only for NoStore mode ! _controlState.SetControlIDs(_controlHtmlHashes); _controlState.Save (this.ClientID, this.Page); } --- 341,345 ---- { //note:only for NoStore mode ! _controlState.SetControlIDs(_controlHtmlFingerprints); _controlState.Save (this.ClientID, this.Page); } *************** *** 363,373 **** // Find new and previous controls _addedControls.Clear(); ! _controlHtmlHashes.Clear(); foreach (Control con in this.Controls) { ! if ( _controlState.ControlIDHtmls.ContainsKey(con.ClientID) ) { ! _controlHtmlHashes[con] = _controlState.ControlIDHtmls[con.ClientID]; } else --- 356,366 ---- // Find new and previous controls _addedControls.Clear(); ! _controlHtmlFingerprints.Clear(); foreach (Control con in this.Controls) { ! if (_controlState.ControlHtmlFingerprints.ContainsKey(con.ClientID)) { ! _controlHtmlFingerprints[con] = _controlState.ControlHtmlFingerprints[con.ClientID]; } else *************** *** 379,383 **** // Find removed controls _removedControls.Clear(); ! foreach (string clientID in _controlState.ControlIDHtmls.Keys) { int i; --- 372,376 ---- // Find removed controls _removedControls.Clear(); ! foreach (string clientID in _controlState.ControlHtmlFingerprints.Keys) { int i; *************** *** 444,453 **** fullwriter.WriteEndTag ("span"); ! ! if (IsPageNoStoreMode) ! _controlHtmlHashes[con] = Util.GetBase64MD5Sum(sb.ToString()); ! else ! _controlHtmls[con] = sb.ToString(); ! sb.Length = 0; } --- 437,441 ---- fullwriter.WriteEndTag ("span"); ! _controlHtmlFingerprints[con] = Util.GetFingerprint(sb.ToString()); sb.Length = 0; } *************** *** 463,471 **** foreach (Control con in _removedControls) { ! if (IsPageNoStoreMode) ! _controlHtmlHashes.Remove(con); ! else ! _controlHtmls.Remove(con); ! AjaxCallHelper.WriteRemoveElementScript (ClientID, GetAjaxElemID(ClientID + "_" + con.ClientID)); } --- 451,455 ---- foreach (Control con in _removedControls) { ! _controlHtmlFingerprints.Remove(con); AjaxCallHelper.WriteRemoveElementScript (ClientID, GetAjaxElemID(ClientID + "_" + con.ClientID)); } *************** *** 486,493 **** AjaxCallHelper.WriteAddElementScript (ClientID, "span", GetAjaxElemID(con), html, GetNextExistingElement(i)); ! if (IsPageNoStoreMode) ! _controlHtmlHashes[con] = Util.GetBase64MD5Sum(sb.ToString()); ! else ! _controlHtmls[con] = sb.ToString(); } else --- 470,474 ---- AjaxCallHelper.WriteAddElementScript (ClientID, "span", GetAjaxElemID(con), html, GetNextExistingElement(i)); ! _controlHtmlFingerprints[con] = Util.GetFingerprint(sb.ToString()); } else *************** *** 505,528 **** html = sb.ToString(); ! if (IsPageNoStoreMode) ! { ! string htmlHashCode = Util.GetBase64MD5Sum(html); ! ! // If it's html rendering sha1 hash is the same, ignore it. ! if (htmlHashCode != (string)_controlHtmlHashes[con]) ! { ! ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); ! _controlHtmlHashes[con] = htmlHashCode; ! } ! } ! else { ! // If it's html rendering is the same, ignore it. ! if (html != (string)_controlHtmls[con]) ! { ! ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); ! _controlHtmls[con] = html; ! } } --- 486,496 ---- html = sb.ToString(); + string htmlFingerprint = Util.GetFingerprint(html); ! // If it's html rendering fingerprint is the same, ignore it. ! if (htmlFingerprint != (string)_controlHtmlFingerprints[con]) { ! ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); ! _controlHtmlFingerprints[con] = htmlFingerprint; } *************** *** 770,774 **** Control con = Controls[i]; ! if (!_addedControls.Contains(con) && ((IsPageNoStoreMode && _controlHtmlHashes[con] != null) || (!IsPageNoStoreMode && _controlHtmls[con] != null))) return GetAjaxElemID(con); } --- 738,742 ---- Control con = Controls[i]; ! if (!_addedControls.Contains(con) && _controlHtmlFingerprints[con] != null) return GetAjaxElemID(con); } *************** *** 824,828 **** private class ControlCollectionState { ! private SortedList _controlIDHtmlHashes; private Control _owner; --- 792,796 ---- private class ControlCollectionState { ! private SortedList _controlHtmlFingerprints; private Control _owner; *************** *** 833,847 **** { _owner = owner; ! _controlIDHtmlHashes = new SortedList(); } /// <summary> ! /// Constructs a new ControlCollectionState with a list of controlIDHtmlHashes /// </summary> ! /// <param name="controlIDHtmlHashes"></param> ! public ControlCollectionState(SortedList controlIDHtmlHashes, Control owner) { _owner = owner; ! _controlIDHtmlHashes = controlIDHtmlHashes; } --- 801,815 ---- { _owner = owner; ! _controlHtmlFingerprints = new SortedList(); } /// <summary> ! /// Constructs a new ControlCollectionState with a list of controlHtmlFingerprints /// </summary> ! /// <param name="controlHtmlFingerprints"></param> ! public ControlCollectionState(SortedList controlHtmlFingerprints, Control owner) { _owner = owner; ! _controlHtmlFingerprints = controlHtmlFingerprints; } *************** *** 854,873 **** { string panelKey = GetControlFingerprintsField(panelClientID); ! string panelControlStates = HttpContext.Current.Request.Form[panelKey]; ! if (panelControlStates != null) { ! SortedList controlIDHtmlHashes = new SortedList(); ! if (panelControlStates != String.Empty) { ! string[] namevaluepairs = panelControlStates.Split(';'); for (int i = 0; i < namevaluepairs.Length; i++) { string namevaluepair = namevaluepairs[i]; string[] namevalue = namevaluepair.Split('#'); ! controlIDHtmlHashes.Add(string.Format("{0}_{1}", panelClientID, namevalue[0]), namevalue[1]); } } ! return new ControlCollectionState(controlIDHtmlHashes, owner); } else --- 822,849 ---- { string panelKey = GetControlFingerprintsField(panelClientID); ! string panelControlFingerprints = HttpContext.Current.Request.Form[panelKey]; ! if (panelControlFingerprints != null) { ! SortedList controlHtmlFingerprints = new SortedList(); ! if (panelControlFingerprints != String.Empty) { ! string[] namevaluepairs = panelControlFingerprints.Split(';'); for (int i = 0; i < namevaluepairs.Length; i++) { string namevaluepair = namevaluepairs[i]; string[] namevalue = namevaluepair.Split('#'); ! ! if (MagicAjaxModule.Instance.Configuration.PageStore.CompareMode == MagicAjax.Configuration.OutputCompareMode.FullHtml) ! { ! controlHtmlFingerprints.Add(string.Format("{0}_{1}", panelClientID, namevalue[0]), UnicodeEncoding.Default.GetString(Convert.FromBase64String(namevalue[1]))); ! } ! else ! { ! controlHtmlFingerprints.Add(string.Format("{0}_{1}", panelClientID, namevalue[0]), namevalue[1]); ! } } } ! return new ControlCollectionState(controlHtmlFingerprints, owner); } else *************** *** 887,905 **** } ! public System.Collections.SortedList ControlIDHtmls { ! get { return _controlIDHtmlHashes; } } ! public void SetControlIDs (Hashtable controlHtmlHashes) { ! _controlIDHtmlHashes.Clear(); ! foreach (Control con in controlHtmlHashes.Keys) ! _controlIDHtmlHashes.Add(con.ClientID, (string)controlHtmlHashes[con]); } /// <summary> ! /// Saves the ControlState hashes. ! /// When in AjaxCall mode, creates SetFieldScript to set hidden field when last ControlState hashes were changed. /// </summary> /// <param name="panelClientID"></param> --- 863,881 ---- } ! public System.Collections.SortedList ControlHtmlFingerprints { ! get { return _controlHtmlFingerprints; } } ! public void SetControlIDs(Hashtable controlHtmlFingerprints) { ! _controlHtmlFingerprints.Clear(); ! foreach (Control con in controlHtmlFingerprints.Keys) ! _controlHtmlFingerprints.Add(con.ClientID, (string)controlHtmlFingerprints[con]); } /// <summary> ! /// Saves the ControlState fingerprints. ! /// When in AjaxCall mode, creates SetFieldScript to set hidden field when last Control fingerprints were changed. /// </summary> /// <param name="panelClientID"></param> *************** *** 909,915 **** System.Text.StringBuilder sbuilder = new System.Text.StringBuilder(); ! foreach (string key in _controlIDHtmlHashes.Keys) { ! if (_controlIDHtmlHashes.IndexOfKey(key) > 0) { sbuilder.Append(';'); --- 885,891 ---- System.Text.StringBuilder sbuilder = new System.Text.StringBuilder(); ! foreach (string key in _controlHtmlFingerprints.Keys) { ! if (_controlHtmlFingerprints.IndexOfKey(key) > 0) { sbuilder.Append(';'); *************** *** 918,933 **** string keyWithoutNamingcontainer = key.Substring(panelClientID.Length + 1); ! sbuilder.AppendFormat("{0}#{1}", keyWithoutNamingcontainer, _controlIDHtmlHashes[key]); } ! string serializedPanelStateHashes = sbuilder.ToString(); string panelKey = GetControlFingerprintsField(panelClientID); if ( AjaxCallHelper.IsAjaxCallForPage(_owner.Page) ) { ! //if ajax callback, generate javascript to set panelstate's hidden field value ! if (HttpContext.Current.Request.Form[panelKey] != serializedPanelStateHashes) { ! AjaxCallHelper.WriteSetFieldScript(panelKey, serializedPanelStateHashes); } } --- 894,916 ---- string keyWithoutNamingcontainer = key.Substring(panelClientID.Length + 1); ! if (MagicAjaxModule.Instance.Configuration.PageStore.CompareMode == MagicAjax.Configuration.OutputCompareMode.FullHtml) ! { ! sbuilder.AppendFormat("{0}#{1}", keyWithoutNamingcontainer, Convert.ToBase64String(UnicodeEncoding.Default.GetBytes((string)_controlHtmlFingerprints[key]))); ! } ! else ! { ! sbuilder.AppendFormat("{0}#{1}", keyWithoutNamingcontainer, _controlHtmlFingerprints[key]); ! } } ! string serializedPanelFingerprints = sbuilder.ToString(); string panelKey = GetControlFingerprintsField(panelClientID); if ( AjaxCallHelper.IsAjaxCallForPage(_owner.Page) ) { ! //if ajax callback, generate javascript to set panelfingerprints's hidden field value ! if (HttpContext.Current.Request.Form[panelKey] != serializedPanelFingerprints) { ! AjaxCallHelper.WriteSetFieldScript(panelKey, serializedPanelFingerprints); } } *************** *** 936,940 **** // The hidden field is already registered at OnLoad event. // Set its value by javascript. ! page.RegisterStartupScript(panelKey + "VALUESET", String.Format("<script type='text/javascript'>AJAXCbo.SetFieldIfEmptyScript(\"{0}\",{1});</script>", panelKey, AjaxCallHelper.EncodeString(serializedPanelStateHashes))); } --- 919,923 ---- // The hidden field is already registered at OnLoad event. // Set its value by javascript. ! page.RegisterStartupScript(panelKey + "VALUESET", String.Format("<script type='text/javascript'>AJAXCbo.SetFieldIfEmptyScript(\"{0}\",{1});</script>", panelKey, AjaxCallHelper.EncodeString(serializedPanelFingerprints))); } |