Created
February 11, 2009 15:53
-
-
Save jasonroelofs/62081 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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() {} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment