-
-
Save technoweenie/9345 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
// Beginning of a Ubiquty script for use with xtt | |
CmdUtils.CreateCommand({ | |
name: "xtt", | |
takes: {status: noun_arb_text}, | |
preview: function(previewBlock, statusText) { | |
var previewTemplate = "Updates your XTT status to: <br/>" + | |
"<b>${status}</b><br /><br />"; | |
var previewData = { | |
status: statusText.text | |
}; | |
var previewHTML = CmdUtils.renderTemplate(previewTemplate, | |
previewData); | |
previewBlock.innerHTML = previewHTML; | |
}, | |
execute: function(statusText) { | |
if(statusText.text.length < 1) { | |
displayMessage("XTT requires a status to be entered"); | |
return; | |
} | |
var updateUrl = "http://tt.entp.com/statuses.json"; | |
jQuery.ajaxSetup({ | |
'beforeSend': function(xhr) { | |
xhr.setRequestHeader("Accept", "application/json"); | |
xhr.setRequestHeader("Content-Type", "application/json" ); | |
} | |
}) | |
var statusData = '{"status": {"code_and_message": ' + statusText.text + '}}'; | |
jQuery.ajax({ | |
type: "POST", | |
url: updateUrl, | |
data: statusData, | |
dataType: "json", | |
error: function() { | |
displayMessage("XTT error - status not updated"); | |
}, | |
success: function() { | |
displayMessage("XTT status updated"); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment