Created
June 2, 2011 23:31
-
-
Save madhur/1005576 to your computer and use it in GitHub Desktop.
miner
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 SocialMiner() | |
{ | |
var verbose=true; | |
var profileArray=new Array(); | |
this.tabUrl; | |
var that=this; | |
this.getTabUrl=function(callback) | |
{ | |
chrome.tabs.getSelected(null, function(tab) | |
{ | |
callback.call(this,tab.url); | |
}); | |
} | |
this.setTabUrlValue=function(pageUrl) | |
{ | |
that.tabUrl=pageUrl; | |
console.log("22"+that.tabUrl); | |
} | |
this.getUrlType=function(pageUrl) | |
{ | |
this.logToConsole(pageUrl); | |
var fbRegex="(?:http:\/\/)?(?:www.)?facebook.com\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[?\w\-]*\/)?(?:profile.php\?id=(?=\d.*))?([\w\-]*)?"; | |
var soRegex="(?:http:\/\/)?(?:www.)?stackoverflow.com\/(?:(?:\w)*#!\/)?(?:users\/)?(?:[?\w\-]*\/)?(?:profile.php\?id=(?=\d.*))?([\w\-]*)?"; | |
var lnkdRegex="(?:http:\/\/)?(?:www.)?linkedin.com\/(?:(?:\w)*#!\/)?(?:in\/)?(?:[?\w\-]*\/)?(?:profile.php\?id=(?=\d.*))?([\w\-]*)?"; | |
if(pageUrl.matches(fbRegex)) | |
{ | |
this.logToConsole("Its FB Page"); | |
return "fb"; | |
} | |
else if(pageUrl.matches(soRegex)) | |
{ | |
this.logToConsole("Its SO Page"); | |
return "so"; | |
} | |
else if(pageUrl.matches(lnkdRegex)) | |
{ | |
this.logToConsole("Its LNKD Page"); | |
return "lnkd"; | |
} | |
} | |
this.GetSOProfiles=function(email) | |
{ | |
} | |
this.GetFBProfiles=function(email) | |
{ | |
} | |
this.GetLKPDProfiles=function(email) | |
{ | |
} | |
this.logToConsole=function logToConsole(text) | |
{ | |
if (verbose) | |
console.log(text); | |
} | |
} | |
// The above class is being called as | |
$(document).ready(function () { | |
$("#tabs" ).tabs(); | |
console.log("5"); | |
miner.getTabUrl(miner.setTabUrlValue); | |
console.log("6"); | |
miner.logToConsole("1"+miner.tabUrl); | |
console.log("7"); | |
} | |
// Output: | |
5 | |
6 | |
1 undefined | |
7 | |
22 http://url | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment