Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

handle user and free limited percentages

  • Loading branch information...
commit 254cb8345a367091fcb68b0684bfc012a47a8561 1 parent ea089ed
@ianloic ianloic authored
Showing with 33 additions and 4 deletions.
  1. +10 −0 hello.html
  2. +23 −4 hello.js
View
10 hello.html
@@ -31,6 +31,9 @@
height: 10px;
background-color: red;
}
+ #upsell div {
+ display: none;
+ }
</style>
</head>
<body>
@@ -70,5 +73,12 @@
<div></div>
<div></div>
</div>
+
+<div id="upsell">
+ <div id="subscriber">You are an Rdio subscriber. You're awesome.</div>
+ <div id="trial">You are an Rdio trial user, Subscribe now!</div>
+ <div id="free">You are an Rdio Free user with <span id="remaining"></span>% of your quota remaining, subscribe now!</div>
+ <div id="nobody">To hear full tracks subscribe to Rdio.</div>
+</div>
</body>
</html>
View
27 hello.js
@@ -53,16 +53,35 @@ $(document).ready(function() {
// the global callback object
var callback_object = {};
-callback_object.ready = function ready() {
+callback_object.ready = function ready(user) {
// Called once the API SWF has loaded and is ready to accept method calls.
// find the embed/object element
apiswf = $('#apiswf').get(0);
apiswf.rdio_startFrequencyAnalyzer({
- frequencies: '10-band',
- period: 100
- })
+ frequencies: '10-band',
+ period: 100
+ });
+
+ if (user == null) {
+ $('#nobody').show();
+ } else if (user.isSubscriber) {
+ $('#subscriber').show();
+ } else if (user.isTrial) {
+ $('#trial').show();
+ } else if (user.inFreeLimited) {
+ $('#remaining').text(user.freeLimitedRemaining);
+ $('#free').show();
+ } else {
+ $('#nobody').show();
+ }
+
+ console.log(user);
+}
+
+callback_object.freeLimitedRemainingChanged = function freeLimitedRemainingChanged(remaining) {
+ $('#remaining').text(remaining);
}
callback_object.playStateChanged = function playStateChanged(playState) {
Please sign in to comment.
Something went wrong with that request. Please try again.