jameskilton (owner)

Revisions

gist: 62081 Download_button fork
public
Public Clone URL: git://gist.github.com/62081.git
Embed All Files: show embed
JavaScript #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Turn this:
 
    $.post("/cameras/" + cameraId + "/wireless", {
        "_method": "delete"
      },
      function(response) {
 
        $.prompt(
          "<h3>Disconnecting from Wireless</h3>" +
          "<ul><li class=\"processing\">Sending Request to Camera</li></ul>", {
            buttons: { "Close": true }
          });
 
        var query = $("#userquery");
        var dialog = query.find("div.userquerymessage");
        query.find("div#userquerybuttons").hide();
 
        var currentStep = "request";
 
        function addNewStep(msg, itemClass) {
          var klass = itemClass || "processing";
          dialog.find("li.processing").removeClass("processing").addClass("success");
          dialog.find("ul").append("<li class=\"" + klass + "\">" + msg + "</li>");
        }
 
        function updateExistingStep(msg){
          dialog.find("li.processing").html(msg);
        }
 
        transaction(response.key, {
 
          update: function(data) {
            if(data.step != currentStep) {
              addNewStep(data.message);
              currentStep = data.step;
            } else {
              updateExistingStep(data.message);
            }
          },
 
          complete: function(data) {
            query.find("div#userquerybuttons").slideDown("slow");
          },
 
          success: function(data) {
            addNewStep(data.message, "success");
 
            $$.connectedTo = null;
 
            var view = $$.parentView.find(".current-network");
            view.slideUp("slow", function() {
              view.find(".ssid-list").html("");
            });
 
            $$.refreshView();
          },
 
          error: function(data) {
            var previousEntry = dialog.find("li.processing").removeClass("processing");
 
            if(data.type == "camera_failed") {
              previousEntry.addClass("success");
            } else {
              previousEntry.addClass("error");
            }
 
            dialog.find("ul").append("<li class=\"error\">" + data.message + "</li>");
          }
        });
      }, "json");
JavaScript #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Into this:
    this.__transactionPrompt({
      url: "/cameras/" + cameraId + "/wireless",
      method: "delete",
      url_args: {},
      prompt_text: "<h3>Disconnecting from Wireless</h3><ul><li class=\"processing\">Sending Request to Camera</li></ul>",
      
      onSuccess: function() {
        $$.connectedTo = null;
 
        var view = $$.parentView.find(".current-network");
        view.slideUp("slow", function() {
          view.find(".ssid-list").html("");
        });
 
        $$.refreshView();
      },
 
      onUpdate: function() {},
      onError: function() {},
      onComplete: function() {}
    });