Skip to content

Commit

Permalink
adding in click statisticsusage through my bitly plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
addyosmani committed Apr 25, 2011
1 parent 56f56f4 commit 6fe710c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
5 changes: 5 additions & 0 deletions css/application.css
Expand Up @@ -156,4 +156,9 @@ body {


#tasks .count span { #tasks .count span {
font-weight: bold; font-weight: bold;
}

.bitly-summary span{
clear:both;
display:block;
} }
18 changes: 15 additions & 3 deletions index.html
Expand Up @@ -124,8 +124,12 @@
}, },


viewclicks: function(){ viewclicks: function(){
this.navigate("/ui", 'dashboard/' + this.el.index()); this.navigate("/ui", 'clicks/' + this.el.index());
//then follow render var elements = $("#clicksTemplate").tmpl(this.item);
this.el.html(elements);
this.el.bitlyDFD({utility:'clicks', shortUrl:this.item.name}); //test
this.refreshElements();
return this;
}, },


edit: function(){ edit: function(){
Expand Down Expand Up @@ -224,7 +228,7 @@


<span>${name}</span> <span>${name}</span>
<span class="original">${original}</span> <span class="original">${original}</span>
<a class="clicks">Clicks data</a> <a class="clicks">Click Statistics</a>
<a class="destroy"></a> <a class="destroy"></a>
</div> </div>


Expand All @@ -233,6 +237,14 @@
</div> </div>
</div> </div>
</script> </script>

<script type="text/x-jquery-tmpl" id="clicksTemplate">
<div class="clicksView">
<h2>Click Statistics</h2>
<span><strong>Short URL: </strong> ${name}</span>
<div class="clicksInfo"></div>
</div>
</script>






Expand Down
17 changes: 2 additions & 15 deletions js/jquery.bitlydfd.0.1.js
Expand Up @@ -50,12 +50,9 @@ $.fn.bitlyDFD = function( options ) {


case 'clicks': case 'clicks':
return collection.each(function() { return collection.each(function() {
//refactor or remove.
$(this).append("<div class='bitly-summary'>" + $(this).append("<div class='bitly-summary'>" +
"<span>Global Clicks (this URL):" + result.data["clicks"][0].global_clicks + "</span>" + "<span><strong>User Clicks (all URLs): </strong>" + result.data["clicks"][1].user_clicks + "</span>" +
"<span>User Clicks (this URL):" + result.data["clicks"][0].user_clicks + "</span>" + "<span><strong>Global Clicks (Aggregated): </strong>" + result.data["clicks"][1].global_clicks + "</span>" +
"<span>Global Clicks (all URLs):" + result.data["clicks"][1].global_clicks + "</span>" +
"<span>User Clicks (all URLs):" + result.data["clicks"][1].user_clicks + "</span>" +
"</div>"); "</div>");
}); });
break; break;
Expand All @@ -69,13 +66,3 @@ $.fn.bitlyDFD = function( options ) {
); );
}; };



/*Usage*/
/*
function test( longUrl , shortUrl ){
console.log(longUrl);
////Task.create({name: result.results[defaults.longUrl].shortUrl, original:opts.longUrl});
}
//$('#short').bitlyDFD({utility:'shorten', longUrl:'http://google.com', callback:test});
//$('#short').bitlyDFD({utility:'clicks', shortUrl:'http://bit.ly/eUGBef'});
*/

0 comments on commit 6fe710c

Please sign in to comment.