1 /*jslint 2 browser: true, 3 nomen: false, 4 debug: true, 5 forin: true, 6 sub: true, 7 plusplus: true, 8 undef: true, 9 white: false, 10 onevar: false 11 */ 12 var sc, jQuery; 13 14 /** 15 * @constructor 16 */ 17 function SpazPhotoMailer(opts) { 18 19 this.apis = this.getAPIs(); 20 21 } 22 23 SpazPhotoMailer.prototype.getAPILabels = function() { 24 var labels = []; 25 for ( var key in this.getAPIs() ) { 26 labels.push(key); 27 } 28 return labels; 29 }; 30 31 SpazPhotoMailer.prototype.getAPIs = function() { 32 33 var thisSPM = this; 34 35 var apis = { 36 "yfrog": { 37 "email_tpl" :"{{username}}.??????@yfrog.com", 38 "message_in" :"subject", 39 "email_info_url":"http://yfrog.com/froggy.php", 40 'help_text' :"Log-in to yfrog.com with your Twitter username and password, and click 'my yfrog.' Your customized posting email will be listed on the right.", 41 'getToAddress': function(opts) { 42 var username = opts.username; 43 return thisSPM.apis['yfrog'].email_tpl.replace('{{username}}', username); 44 } 45 }, 46 47 "posterous": { 48 "email_tpl" :"post@posterous.com", 49 "message_in" :"subject", 50 "email_info_url":"http://posterous.com/autopost", 51 'help_text' :"Post instantly to your Posterous blog. Setup autopost to post back to Twitter! Login for more information and controls.", 52 'getToAddress': function(opts) { 53 return thisSPM.apis['posterous'].email_tpl; 54 } 55 }, 56 57 "pikchur": { 58 "email_tpl" :"{{username}}.???@pikchur.com", 59 "message_in" :"subject", 60 "email_info_url":"http://pikchur.com/dashboard/profile", 61 'help_text' :"Log-in to pikchur with your Twitter username and password, and click 'Profile.' Your customized posting email will be listed", 62 'getToAddress': function(opts) { 63 var username = opts.username; 64 return thisSPM.apis['pikchur'].email_tpl.replace('{{username}}', username); 65 } 66 }, 67 68 69 "twitgoo": { 70 "email_tpl" :"m@twitgoo.com", 71 "message_in" :"subject", 72 "email_info_url":"http://twitgoo.com/-settings/mobile", 73 'help_text' :"Log-in to twitgoo.com and click 'Settings.' Add the email address from which you'll be sending messages.", 74 'getToAddress': function(opts) { 75 return thisSPM.apis['twitgoo'].email_tpl; 76 } 77 }, 78 79 "twitpic": { 80 "email_tpl" :"{{username}}.####@twitpic.com", 81 "message_in" :"subject", 82 "email_info_url":"http://twitpic.com/settings.do", 83 'help_text' :"Log-in to twitpic.com, and click 'Settings.' Your custom email address will be listed.", 84 'getToAddress': function(opts) { 85 var username = opts.username; 86 return thisSPM.apis['twitpic'].email_tpl.replace('{{username}}', username); 87 } 88 }, 89 90 "tweetphoto": { 91 "email_tpl" :"{{username}}.####@tweetphoto.com", 92 "message_in" :"subject", 93 "email_info_url":"http://www.tweetphoto.com/mysettings.php", 94 'help_text' :"Log-in to tweetphoto.com and click 'My Settings.' Your custom email address will be listed.", 95 'getToAddress': function(opts) { 96 var username = opts.username; 97 return thisSPM.apis['tweetphoto'].email_tpl.replace('{{username}}', username); 98 }, 99 'retrievePostingAddress': function(username, password, success, failure) { 100 101 function getTweetPhotoProfile(username, password) { 102 103 var url = "http://tweetphotoapi.com/api/tpapi.svc/json/users/"+username; 104 var TPAPI_header = 'TPAPI: '+username+","+password; 105 106 jQuery.ajax({ 107 'dataType':'text', 108 109 'success':function(data, textStatus) { 110 var profile = sc.helpers.deJSON(data); 111 112 }, 113 114 'error':function(xhr, testStatus, errorThrown) { 115 failure(xhr, testStatus, errorThrown); 116 }, 117 118 'beforeSend':function(xhr){ 119 xhr.setRequestHeader("TPAPI", username+","+password); 120 }, 121 122 'url':url 123 124 125 }); 126 127 } 128 129 function getTweetPhoto(username, password, settings_url) { 130 131 var TPAPI_header = 'TPAPI: '+username+","+password; 132 133 jQuery.ajax({ 134 'dataType':'text', 135 136 'success':function(data, textStatus) { 137 var settings = sc.helpers.deJSON(data); 138 success(settings.Email); 139 }, 140 141 'error':function(xhr, testStatus, errorThrown) { 142 failure(xhr, testStatus, errorThrown); 143 }, 144 145 'beforeSend':function(xhr){ 146 xhr.setRequestHeader("TPAPI", username+","+password); 147 }, 148 149 'url':settings_url 150 151 }); 152 153 } 154 155 156 157 } 158 } 159 }; 160 161 return apis; 162 163 }; 164 165 SpazPhotoMailer.prototype.setAPI = function(apilabel) { 166 this.api = this.apis[apilabel]; 167 }; 168 169 SpazPhotoMailer.prototype.send = function(api, photo_url, message) { 170 171 }; 172