Skip to content

Instantly share code, notes, and snippets.

@mayoz
Created November 1, 2013 23:22
Show Gist options
  • Save mayoz/7273511 to your computer and use it in GitHub Desktop.
Save mayoz/7273511 to your computer and use it in GitHub Desktop.
/*!
* upperCase
* $(element).upperCase( [text] );
*
* mit license. sercan cakir. 2013.
*/
$(function () {
$.fn.upperCase = function() {
return this.each(function() {
var $self = $(this),
text = $self.text(),
temp = [];
for(var i = 0; i < text.length; i++) {
var char = text.charAt(i),
code = text.charCodeAt(i);
if (code == 105) temp.push('İ');
else if (code == 305) temp.push('I');
else if (code == 287) temp.push('Ğ');
else if (code == 252) temp.push('Ü');
else if (code == 351) temp.push('Ş');
else if (code == 246) temp.push('Ö');
else if (code == 231) temp.push('Ç');
else if (code >= 97 ) temp.push(char.toUpperCase());
else if (code <= 122) temp.push(char.toUpperCase());
else temp.push(char);
}
$self.text(temp.join(''));
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment