예제 #1
0
    protected void cmdTestEq_Click(object sender, EventArgs e)
    {
        string result = string.Empty;
        Tracer tracer = new Tracer();

        JQuery jQuery = new JQuery("'li'");

        result += "测试方法 JQuery.Eq(string)<br />";

        tracer.Execute(jQuery, null, "Eq", FunctionType.Method, new Type[] { typeof(string) }, null, null, null,
                       new object[][] {
            new object[] { "-1" }
        },
                       false
                       );

        result += "jQuery.Code = " + jQuery.Html().Code + "<br />";

        ScriptHelper scriptHelper = new ScriptHelper();

        scriptHelper.Alert("'li eq(-1).innerHTML = ' + " + jQuery.Code);

        result += "scriptHelper.Code = " + scriptHelper.Code + "<br />";

        this.lblResult.Text = result;

        scriptHelper.Build(this, option: ScriptBuildOption.Startup);
    }
예제 #2
0
        public void ProcessGuess(JQuery stats, TextBox guessEntryField)
        {
            int guess;

            try {
                guess = int.Parse(guessEntryField.Value);
            } catch (FormatException) {
                var statusLabel = Query <JQuery>("#stats .status");
                statusLabel.Text("Your guess was not valid.");
                return;
            }


            ++_numberOfTries;

            if (guess == _randomNumber)
            {
                ReplaceWith(new CongratulationForm(_numberOfTries));
                return;
            }

            guessEntryField.Value = "";

            var statusText = "";

            if (guess < 1 || guess > 100)
            {
                statusText = "Your guess, " + guess + " was not between 1 and 100.";
            }
            else if (guess < _randomNumber)
            {
                if (guess >= LowerBound)
                {
                    LowerBound = guess + 1;
                }
                statusText = "Your guess, " + guess + " was too low.  Try again:";
            }
            else if (guess > _randomNumber)
            {
                statusText = "Your guess, " + guess + " was too high.  Try again:";
                if (guess <= UpperBound)
                {
                    UpperBound = guess - 1;
                }
            }

            stats.Html(RenderFragment("stats", statusText));
        }