示例#1
0
        /// <summary>
        /// Popup for the calendar page showing potential and accepted offers by date.
        /// </summary>
        /// <param name="ev"></param>
        public static void Calendar(jQueryEvent ev)
        {
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#calendarCard");
            dialog.Children().First().Html("Loading...");

            JsonObject parameters = new JsonObject("page", 0);

            jQuery.Post("/services/Calendar?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                Utility.ProcessResponse((Dictionary)data);
            }
            );

            // BUGBUG: currently the sizes are hard-coded and too big - need to fix this.
            dialog.Dialog(
                new JsonObject(
                    "width", jQuery.Window.GetWidth() - 120,
                    "height", jQuery.Window.GetHeight() - 40,
                    "modal", true,
                    "closeOnEscape", true,
                    "title", "Calendar",
                    "position", "top"
                )
            );
        }
示例#2
0
        private void SaveDetails(jQueryEvent e)
        {
            this.EditButton.Hide(EffectDuration.Fast);
            this.Obj.Attribute("disabled", "disabled").AddClass("ui-state-disabled");

            // Find the objects with the .edit class that are descendants of objects with .keyvaluerow class
            // These are the editable key/value pairs
            jQueryObject edits = this.Obj.Find(".keyvaluerow .edit");

            string ntrp = edits.Find(".ntrp").GetValue();
            string court = edits.Find(".placesAutoValue").GetValue();
            string playPreference = edits.Find(".preference").GetValue();
            string style = edits.Find(".style").GetValue();
            string email = ((CheckBoxElement)edits.Find(".email").GetElement(0)).Checked ? "true" : "false";

            JsonObject parameters = new JsonObject
            (
                "ntrp", ntrp,
                "preference", playPreference,
                "courtData", court,
                "style", style,
                "emailOffers", email
            );

            // Post the user data to the service
            jQuery.Post("/services/PostTennisUserDetails" + "?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                Utility.ProcessResponse((Dictionary)data);
            });
        }
示例#3
0
        private void CancelOffer(jQueryEvent e)
        {
            this.Obj.Attribute("disabled", "disabled").AddClass("ui-state-disabled");
            jQueryObject button = jQuery.FromElement(e.CurrentTarget);

            JsonObject parameters = new JsonObject("offerId", button.GetAttribute("data-offerId"));

            jQuery.Post("/services/CancelOffer?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                Utility.ProcessResponse((Dictionary)data);
            }
            );
        }
示例#4
0
        public static void PostCancel(jQueryUIObject dialog, string offerId)
        {
            JsonObject parameters = new JsonObject("offerId", offerId);

            dialog.Attribute("disabled", "disabled").AddClass("ui-state-disabled");

            jQuery.Post("/services/CancelOffer?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                dialog.Dialog("destroy");
                Utility.ProcessResponse((Dictionary)data);
            }
            );
        }
示例#5
0
        /// <summary>
        /// Posts the service request with the requested page 
        /// Uses the filter with which it was initialized
        /// </summary>
        /// <param name="page"></param>
        protected void PostBack(int page)
        {
            // Use jquery to set the object as disabled in the DOM before initiating the post
            this.Obj.Attribute("disabled", "disabled").AddClass("ui-state-disabled");

            // Construct the parameters
            JsonObject parameters = new JsonObject("page", page, "filter", this.Filter);

            // Do the post - response will be handled by the generic response handler
            jQuery.Post("/services/" + this.ServiceName + "?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                Utility.ProcessResponse((Dictionary)data);
            }
            );
        }
示例#6
0
        public static void DoCreateMatch(jQueryObject obj, string datetime, object ids, string courtData, string comments, object opponentId, Callback callback)
        {
            JsonObject parameters = new JsonObject("date", datetime, "locations", ids, "courtData", courtData, "comments", comments, "opponentId", opponentId);

            obj.Attribute("disabled", "disabled").AddClass("ui-state-disabled");
            jQuery.Post("/services/CreateOffer?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                obj.Attribute("disabled", "").RemoveClass("ui-state-disabled");
                Utility.ProcessResponse((Dictionary)data);

                if (null != callback)
                {
                    callback();
                }
            }
            );
        }
示例#7
0
        private void SendMessage(jQueryEvent e)
        {
            jQueryObject button = jQuery.FromElement(e.CurrentTarget);
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#playerDetailsCard");

            string text = jQuery.Select("#playerDetailsCard .comments").GetValue();
            string id = dialog.GetAttribute("data-id");

            Script.Literal("debugger");

            dialog.Attribute("disabled", "disabled").AddClass("ui-state-disabled");
            JsonObject parameters = new JsonObject("userId", id, "comments", text);
            jQuery.Post("/services/SendMessage?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                dialog.Attribute("disabled", "").RemoveClass("ui-state-disabled");
                dialog.Dialog("close");
                Utility.ProcessResponse((Dictionary)data);
            }
            );
        }
示例#8
0
        /// <summary>
        /// Static method that gets called when a user is selected from the grid (the wiring is hard-coded in PlayerGrid itself for now)
        /// </summary>
        /// <param name="e"></param>
        public static void SelectUser(jQueryEvent e)
        {
            // Get the button that was selected - id should be the FacebookId of the selected user
            jQueryObject button = jQuery.FromElement(e.CurrentTarget);
            string selectedUserId = button.GetAttribute("data-fbId");

            // Get the offer id from the dialg attribute
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#playerGridCard");
            string offerId = dialog.GetAttribute("data-offerId");

            // Script.Alert("offerId: " + offerId + " uid: " + selectedUserId);

            // Post the confirmation - now that we have the offer id and the selected user
            JsonObject parameters = new JsonObject("offerId", offerId, "uid", selectedUserId);

            dialog.Attribute("disabled", "disabled").AddClass("ui-state-disabled");
            jQuery.Post("/services/ConfirmOfferFromPage?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                dialog.Dialog("close");
                Utility.ProcessResponse((Dictionary)data);
            }
            );
        }
示例#9
0
        /// <summary>
        /// Shows the dialog to select users from the player grid
        /// </summary>
        /// <param name="e"></param>
        private void SelectUserDialog(jQueryEvent e)
        {
            jQueryObject button = jQuery.FromElement(e.CurrentTarget);

            // Get the offer id from the button's attribute
            string offerId = button.GetAttribute("data-offerId");

            // Find the user selection dialog and communicate the offer id to the dialog so it can be posted on the dialog's select user event
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#playerGridCard");
            dialog.Children().First().Html("Loading...");
            dialog.Attribute("data-offerId", offerId);

            // Post the request to get the users who have accepted this offer
            JsonObject parameters = new JsonObject("page", 0, "offerId", offerId);
            jQuery.Post("/services/AcceptPlayerGrid?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                Utility.ProcessResponse((Dictionary)data);
            }
            );

            // Display the dialog in modal fashion
            dialog.Dialog(
                new JsonObject(
                    "width", jQuery.Window.GetWidth() - 120,
                    "height", jQuery.Window.GetHeight() - 40,
                    "modal", true,
                    "title", "Select Your Opponent",
                    "closeOnEscape", true,
                    "position", "top"
                )
            );
        }
示例#10
0
 public static XmlHttpRequest GetJsonP(JsonObject obj)
 {
     return null;
 }
示例#11
0
        private void MoreClick(jQueryEvent e)
        {
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#playerGridCard");
            dialog.Children().First().Html("Loading...");

            JsonObject parameters = new JsonObject("page", 0);

            jQuery.Post("/services/PlayerGrid?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                Utility.ProcessResponse((Dictionary)data);
            }
            );

            dialog.Dialog(
                new JsonObject(
                    "width", jQuery.Window.GetWidth() - 40,
                    "height", jQuery.Window.GetHeight() - 20,
                    "modal", true,
                    "title", "Similar Players",
                    "closeOnEscape", true,
                    "position", "top"
                )
            );
        }
示例#12
0
        private static void CreateMatch(string id)
        {
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#challengeDialog");

            string date = dialog.Find(".datepicker").GetValue();
            string time = dialog.Find(".time").GetValue();
            string ampm = dialog.Find(".ampm").GetValue();
            string comments = dialog.Find(".comments").GetValue();
            string courtData = dialog.Find(".placesAutoValue").GetValue();

            string datetime = date + " " + time + ampm;

            ArrayList ids = new ArrayList();
            dialog.Find(".cities input").Each((ElementIterationCallback)delegate(int index, Element element)
            {
                ids.Add(((CheckBoxElement)element).Value);
            });

            JsonObject parameters = new JsonObject("date", datetime, "locations", ids, "comments", comments, "opponentId", 0);
            QuickMatch.DoCreateMatch(dialog, datetime, ids, courtData, comments, id, (Callback)delegate() { dialog.Dialog("close"); });
        }
示例#13
0
        public static void PostResults(jQueryUIObject dialog, string offerId)
        {
            string comments = jQuery.Select("#scoreComments").GetValue();

            string score = "";

            for (int i = 0; i < 5; ++i)
            {
                string requestValue = jQuery.Select("#request" + i).GetValue();
                string acceptValue = jQuery.Select("#accept" + i).GetValue();

                if (string.IsNullOrEmpty(requestValue) || string.IsNullOrEmpty(acceptValue))
                {
                    break;
                }

                if (score.Length > 0)
                {
                    score = score + ", ";
                }

                score = score + requestValue + "-" + acceptValue;
            }

            JsonObject parameters = new JsonObject("offerId", offerId, "comments", comments, "scores", score);

            dialog.Attribute("disabled", "disabled").AddClass("ui-state-disabled");
            jQuery.Post("/services/PostScore?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                dialog.Dialog("destroy");
                Utility.ProcessResponse((Dictionary)data);
            }
            );
        }