Spotify API 1.0.0: addToCollectionButton not working - spotify

Has anyone got the addToCollectionButton working?
var album = models.Album.fromURI('spotify:album:37uqAKt9dLsLob7yomDWY4');
var button = buttons.AddToCollectionButton.forItem(album);
document.getElementById('AddToCollectionButton').appendChild(button.node);
This adds a green button with plus sign, so far so good.
But when I click it, it doesn't do anything.
Anyone with the same problem?

The AddToCollection button is related to the Collection feature, presented in December last year. So at this point in time it's not the correct button for what you want to do.
If you want to add an album to a user's playlist, you could create a button that adds that album as a playlist to the user's library. The SubscribeButton can be used if you want a button that lets the user subscribe/follow a playlist (among other things).

Related

How to track clicks from the current tab to a new one?

I need some help.
I need to track clicks from the current tab to a new one when I click on any menu item, and then pull up the current user's cookies on a new tab. Now it pulls up the latest user from localStorage.
Can you direct me in the right direction? I try to understand the algorithm of actions.
I think I need to work with currentTabId in onBeforeSendHeaders. Am I right?
It's my code https://jsbin.com/cetezesami/edit?html,css,js,output
enter code here

Browser add on/extension to intercept data selection then simulate link click and data entry

Background: a third party web application with a requirement on the order page to explicitly guide staff when a certain category of product is ordered.
Normal process:
select product to add order line (click on product image)
New process:
select product to add order line (click on product image)
[add on] simulate click on edit order line
[add on] simulate clear of default additional information form fields
enter additional information and click save
Note that the two steps to be performed by the add-on could be performed by the user however when things get busy or new staff begin is often the case that the order gets processed with the default value.
Any pointers in the right direction would be appreciated.
A multi-browser solution is preferred but not essential.
I am an experienced developer, including web development, but have no experience in browser add on/extension development.
Thanks.
You can make an addon out of this very easily. You addEventListener to the gBrowser and if the event.target is the product element then preventDefault so the click doesnt go thru (you will have to do mousedown and mouseup prevent as well). Then rather get the id of the "edit order line" and do .click() if that doesnt work and you really need to simulate use MouseEvent:
MDN :: MouseEvent
MDN :: Initatite/Dispatch MouseEvent
To enter aditional information get the id of the fields, and set their value. Then get the "Save" button id and then do .submit() or .click()
i said do get id in this post but you can use querySelector and go by css selector
see this page here on how to interact with content in currently selected tab:
https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Tabbed_browser
basically just do gBrowser.contentDocument.getElementById

How can i get data from another document when i creat a new document on my XPage?

I've start to develop XPage 7 weeks ago, and i have a problem with "getting data".
On my first page i have a view with a lot of documents, and a button who redirect me on a new page, to create a new document. On my first page i can select a document and when i click on the button i put my id document selected on a sessionSCope.
Button script:
var viewPanel=getComponent("viewPanel1");
var docIDArray=viewPanel.getSelectedIds();
var docUID=database.getDocumentByID(docIDArray[0]).getUniversalID();
sessionScope.put("docUID", docUID);
context.redirectToPage("AjoutSuivi");
On my new XPage i want to get some data on my selected document so on clientLoad of the XPage i execute this script:
var docUID = sessionScope.get("docUID");
var doc:NotesDocument = database.getDocumentByUNID(docUID);
getComponent("contactname1").setValue(doc.getItemValueString("ContactName"));
On my database i have a field "ContactName" and on my XPage i have a field contactname1. I have try with "database.getDocumentByID(docUID)" and i'm sure that "database" is the good link of the database.
When i try it, there is nothing on the field contactname1 have u an idea why that's doesn't work ?
So much thank's if you can help me
Yann
PS: sorry for my bad english
Put your code into the event afterPageLoad and it should work (for the execution order of events take a look at XPage Cheat Sheet #1 - The Page Lifecycle).
Y4nn welcome to the XPages club. When you bind a control to a data source it is better to set the value in the data source than in the control. So you write:
document1.getDocument().replaceItemvalue(...)
(picking on a glass now, watch out for correct syntax)

Spotify: Linking tracks on page

How can I link different tracks present in a particular tab on spotify page, so that when clicked on spotify next/previous button the next/previous track is played. Presenlty it is not playing anything if clicked on next button, when it should be starting to play the next track present on the page
My script looks like this,
$.each(allTracks,function(index,track){
models.Track.fromURI(track, function(track) {
models.Album.fromURI(track.album.uri, function(album) {
var single_track = models.Track.fromURI(track.uri);
var single_track_playlist = new models.Playlist();
single_track_playlist.add(single_track);
var pl = new views.Player();
pl.context = single_track_playlist;
if(index==0) {
$("#firstTrack").append(pl.node);
}
.............
.............
Can anyone please guide me on how I should be going around doing this? Thank you in advance
In your case, the context of each Player view is a playlist with that single track. If you want to render your tracks as players, and have them synchronized so that the next track plays after the one before ends, you need to create a custom solution.
You can check this Grid Play Spotify App, that shows an example of how to achieve it. It basically creates custom Player views that respond to certain events triggered by the Player model and other Player views.

Newest tracks don't come up on top in embedded Spotify playlist?

When I embed a Spotify playlist, the oldest tracks come up on top. Is there any way to to make the newest tracks come up on top instead?
Well, the Play button (I assume that's what you're using) displays the playlist in the playlist's order - if the user manually drags tracks to the top, they'll be at the top.
The problem here is that by default, the Spotify clients add new tracks to the end of the playlist. Changing that would need a change in the Spotify clients, which obviously is beyond the scope of this problem.

Resources