diff options
| author | s1n <[email protected]> | 2020-03-28 10:36:41 -0700 |
|---|---|---|
| committer | s1n <[email protected]> | 2020-03-28 10:36:41 -0700 |
| commit | 25b7d2aab61ae6421398d3abae5da6ffe590333d (patch) | |
| tree | 611985ec78bb2d94099c9fd5dd687f5c9cee6f3e /js/share.js | |
| parent | Initial commit (diff) | |
| download | crack.cf-backup-25b7d2aab61ae6421398d3abae5da6ffe590333d.tar.xz crack.cf-backup-25b7d2aab61ae6421398d3abae5da6ffe590333d.zip | |
Diffstat (limited to 'js/share.js')
| -rw-r--r-- | js/share.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/js/share.js b/js/share.js new file mode 100644 index 0000000..beb99f5 --- /dev/null +++ b/js/share.js @@ -0,0 +1,49 @@ +$(document).ready(function(){ + $('#tweet_body').focus(); + + $('#tweet_body').keypress(function(){ + setTimeout( function(){update_share()}, 50 ); // we're delaying, otherwise keypress() always triggers too fast before current key press actually inserts a letter?!! Go figure. + }); +}) + +function update_share() { + var text = encodeURIComponent( $('#tweet_body').val() ); + var url = encodeURIComponent( $('#copylink').val() ); + var tw = 'https://twitter.com/intent/tweet?status='+text; + var fb = 'https://www.facebook.com/share.php?u='+url ; + $('#share_tw').attr('href', tw); + $('#share_fb').attr('href', fb); + + var charcount = parseInt(280 - $('#tweet_body').val().length); + $('#charcount') + .toggleClass("negative", charcount < 0) + .text( charcount ); +} + +function share(dest) { + var url = $('#share_'+dest).attr('href'); + switch (dest) { + case 'fb': + //var url = $('#share_fb').attr('href'); + window.open( url, 'fb','toolbar=no,width=1000,height=550'); + break; + case 'tw': + //var url = $('#share_tw').attr('href'); + window.open(url, 'tw','toolbar=no,width=800,height=550'); + break; + } + return false; +} + +function init_clipboard() { + var clipboard = new Clipboard('#copylink', { + text: function (trigger) { + return $(trigger).val(); + } + }); + + clipboard.on('success', function () { + $('#copylink').select(); + html_pulse('#copybox h2, #copybox h3', 'Copied!'); + }); +};
\ No newline at end of file |