Created
November 24, 2016 04:18
-
-
Save lucasbrigida/76533a0a44f7d528a7c3c958e0c0f043 to your computer and use it in GitHub Desktop.
This file contains 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
(function($){ | |
/*CUSTOM PHONE TAG */ | |
$(function(){ | |
var tag = 'phone'; | |
var tagSelector = '.profile div:contains("'+tag+'")'; | |
var tagValue = jQuery(tagSelector).first().text(); | |
//if (!tagValue) return; | |
var tagPrettyValue = tagValue.replace('['+tag+'=\"', '').replace('\"]', ''); | |
var tagRawValue = tagPrettyValue.replace('(', '').replace(')', '').replace(' ', '').replace('-', ''); | |
var tagRegexp = /^\(?[1-9]{2}\)?\s?\d{4,5}(\-|\s)?\d{4}$/gm; | |
var tagTemplate = '<a href="tel:'+tagRawValue+'">'+tagPrettyValue+'</a>'; | |
if (tagRegexp.test(tagRawValue) === true) jQuery(tagSelector).first().html(tagTemplate); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment