private void GotLinkText(TextPackage package){
			Document document=(Document)package.ExtraData;
			
			if(package.Errored){
				
				if(ErrorHandlers.PageNotFound!=null){
					ErrorHandlers.PageNotFound(new FileErrorInfo(package),document);
				}else{
					document.innerHTML="Error: "+package.Error;
				}
				
			}else{
				document.innerHTML=package.Text;
			}
		}
Exemple #2
0
        private void OnFormSent(HttpRequest request)
        {
            Element element = (Element)request.ExtraData;

            // Attempt to run ondone:
            object result = element.Run("ondone", request);

            if (result != null && result.GetType() == typeof(bool) && (((bool)result) == false))
            {
                // The ondone function returned false. Don't load into a target at all.
                return;
            }

            // Load the result into target now.
            Document document = ResolveTarget(element);

            if (document == null)
            {
                // Posting a form to an external target.

                Log.Add("Warning: Unity cannot post to external targets. The page will be loaded a second time.");

                // Open the URL outside of Unity:
                Application.OpenURL(request.Url);
            }
            else
            {
                if (request.Errored)
                {
                    if (ErrorHandlers.PageNotFound != null)
                    {
                        ErrorHandlers.PageNotFound(new HttpErrorInfo(request), document);
                    }
                    else
                    {
                        document.innerHTML = "Error: " + request.Error;
                    }
                }
                else
                {
                    document.innerHTML = request.Text;
                }
            }
        }
        /// <summary>Sets the document content with a status code.
        /// Displays error info if html is blank or ErrorHandlers.CatchAll is set.</summary>
        internal void GotDocumentContent(string html, int status, bool openClose)
        {
            if (status != 200 && (string.IsNullOrEmpty(html) || ErrorHandlers.CatchAll))
            {
                // Build an error message now:
                ErrorInfo error = new ErrorInfo();
                error.document   = this;
                error.Url        = location;
                error.Custom     = html;
                error.StatusCode = status;

                // Display:
                ErrorHandlers.Display(error);
            }
            else
            {
                if (openClose)
                {
                    // Full open/close cycle:
                    innerHTML = html;
                }
                else
                {
                    // Parse now:
                    HtmlLexer lexer = new HtmlLexer(html, this);
                    lexer.Parse();
                    close();
                }
            }

            if (resourcesLoading <= 0 && readyState != "complete")
            {
                // Fire onload now!
                ReadyStateChange(2);

                // Fire event:
                PowerUI.UIEvent de = new PowerUI.UIEvent("load");
                de.SetTrusted(true);
                dispatchEvent(de);
            }
        }