Created
January 13, 2015 17:56
-
-
Save nhindman/20039ac70f8027879423 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <script type="application/javascript" src="/wp-content/uploads/2015/01/urx-bugfix-this2.js"></script> | |
| <script type="application/javascript"> | |
| function goToURX(result){ | |
| result.resolveDeeplinkWithWebFallback(function (){}); | |
| } | |
| $urx.setApiKey("Uy3q1L8GSPRO+apW20GaufFZNbJ4RQpD5OX9JNxIM3h6AwoKRAg3gU1tGww=|M+wZfGMnswkf+/Zah+9WBhymHb+z0kIJ"); | |
| function urxSearch(searchTerm) { | |
| $urx.search(searchTerm, function(response) { | |
| // SEARCH SUCCESS HANDLER | |
| var searchResult = response.results[0]; | |
| // The Search Result Content's Title | |
| console.log(searchResult.name); | |
| for(var i=0;i<response.results.length;i++){ | |
| var res = response.results[i]; | |
| console.log(res.name); | |
| var div = document.createElement('div'); | |
| div.res = res; | |
| div.onclick = function() { goToURX(res); }; | |
| div.innerHTML = res.name+'<br><img src="'+res.imageUrl+'"/><br>'; | |
| document.getElementById('searchResults').appendChild(div); | |
| } | |
| // The Search Result Content's image url | |
| console.log(searchResult.imageUrl); | |
| // The Search Result Content's longer text description | |
| console.log(searchResult.descriptionText); | |
| // The Search Result Content's call to action text (ie. "Buy Tickets") | |
| console.log(searchResult.callToActionText); | |
| // The Search Result Content's app name (if deeplink is available) | |
| console.log(searchResult.appName); | |
| }, function(req, errorMessage) { | |
| // SEARCH FAILURE HANDLER | |
| console.log(errorMessage); | |
| }); | |
| } | |
| $( document ).ready(function() { | |
| $('.urx-search-button').click(function(){ | |
| $('#searchResults').empty(); | |
| urxSearch($('#urx-search-value').val()); | |
| }); | |
| });</script> | |
| <div id="music-search-box">Use me on your mobile device to find music in your apps:<br><br> | |
| <input type="text" id="urx-search-value" name="urx-search-value" placeholder="Artist, album or song"><input class="urx-search-button" type="button" value="Search"> | |
| <div id="searchResults"></div></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment