Originally posted by mudskipper
View Post
Thanks again for your input.


jQuery.get('http://mystatus.skype.com/mySkypeName.txt', function (data) {
alert(data);
});
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
//Customise these settings to suit:
var skypeName = 'yourSkypeName';
var unavailableImg = 'someURL';
var onlineImg = 'someURL';
var donotDisturbImg = 'someURL';
var imAwayImg = 'someURL';
// End of custom settings
jQuery.ajax = (function (_ajax) {
var protocol = location.protocol, hostname = location.hostname, exRegex = RegExp(protocol + '//' + hostname), YQL = 'http' + (/^https/.test(protocol) ? 's' : '') + '://query.yahooapis.com/v1/public/yql?callback=?', query = 'select * from html where url="{URL}" and xpath="*"';
function isExternal(url) {
return !exRegex.test(url) && /:\/\//.test(url);
}
return function (o) {
var url = o.url;
if (/get/i.test(o.type) && !/json/i.test(o.dataType) && isExternal(url)) {
// Manipulate options so that JSONP-x request is made to YQL
o.url = YQL;
o.dataType = 'json';
o.data = {
q: query.replace('{URL}', url + (o.data ? (/\?/.test(url) ? '&' : '?') + jQuery.param(o.data) : '')),
format: 'xml'
};
// Since it's a JSONP request
// complete === success
if (!o.success && o.complete) {
o.success = o.complete;
delete o.complete;
}
o.success = (function (_success) {
return function (data) {
if (_success) {
// Fake XHR callback.
_success.call(this, {
responseText: (data.results[0] || '')
// YQL screws with <script>s
// Get rid of them
.replace(/<script[^>]+?\/>|<script(.|\s)*?\/script>/gi, '')
}, 'success');
}
};
})(o.success);
}
return _ajax.apply(this, arguments);
};
})(jQuery.ajax);
var skypeStatusURL = 'http://mystatus.skype.com/' + skypeName + '.txt';
$(document).ready(function () {
jQuery.get(skypeStatusURL, function (data) {
var match, result = "", regex = /<p>(.*?)<\/p>/ig;
while (match = regex.exec(data.responseText)) {
result += match[1];
}
var imgURL = unavailableImg
var unavailableAction = 'alert("Sorry, I\'m unavailable")';
var callAction = 'window.open (\'skype:' + skypeName + '?call\',\'_self\',false)';
var buttonOnClick = unavailableAction;
//Add whatever custom actions you need against each 'case', e.g. absolute positioning of the button
switch (result) {
case 'Online':
imgURL = onlineImg;
buttonOnClick = callAction;
break;
case 'Away':
imgURL = imAwayImg;
buttonOnClick = callAction;
break;
case 'Do Not Disturb':
imgURL = donotDisturbImg;
buttonOnClick = unavailableAction;
break;
case 'Offline':
imgURL = unavailableImg;
buttonOnClick = unavailableAction;
break;
}
$("#skypeButtonImage").attr("src", imgURL);
$("#skypeButtonImage").attr("onclick", buttonOnClick);
});
});
</script>
<img id="skypeButtonImage" src="" style="border: none; cursor:pointer;" width="210" height="32" alt="My status" />


Comment