How to mark a card good/bad via JavaScript? - anki

Can you think of how to mark a card good/bad via Javascript, so it marks the current card and then displays the next one?
Ideally without any addons so it works on mobiles.
I am creating a custom quiz interface with multiple answer buttons.
Thank you!

Edit: Turns out it is already available in the AnkiDroid
https://github.com/ankidroid/Anki-Android/wiki/Advanced-formatting#designing-custom-cards-layout-for-buttons
showAnswer()
buttonAnswerEase1()
buttonAnswerEase2()
buttonAnswerEase3()
buttonAnswerEase4()
ankiMarkCard()
ankiToggleFlag()
AnkiDroidJS.ankiGetNewCardCount()
AnkiDroidJS.ankiGetLrnCardCount()
AnkiDroidJS.ankiGetRevCardCount()
AnkiDroidJS.ankiGetCardMark()
AnkiDroidJS.ankiGetCardFlag()
AnkiDroidJS.ankiGetETA()
In the next release they are planning to implement JS function to get the time for each button (to find out which one is "good" and if "easy" is available.

Related

Show upper-part of adaptive card

I have this very long "form" using adaptive card. Using CardFactory, the bot framework, based on my understanding, can render the card and my bot can display it for my user to fill in the necessary details.
The end of my form (in which I'll use instead of the word adaptive card), has a submit button for user to click whenever all fields are filled in. And while everything works the way I want it to be, its not really user friendly in a sense that what user sees after showing the form is the bottom part of it. User has to scroll for a bit to go up and see the first part of the form.
My question is: Is there anyway I could help user experience by showing the upper-part/top most part of the form? Is that possible in bot framework?
Like if the bot sends successive messages, does the framework allows to show the first messages first, before the last part. THANK YOU!
PS. I use NodeJS for my bot framework, read the documentation but can't find one that dwells deeply about adaptive cards.
Please see images below:
How do I make the first framework to show the first image before the end part which is in the second image.
Have you looked at the "ShowCard" action? It basically lets you collapse part of your card, and only open it when a user clicks on a button. That way you could possibly group your card into sections and show each one at a time. See here for more.
Another option in future is the new ToggleVisibility action in AdaptiveCards 1.2, but it's only if your client supports 1.2. (e.g. it's only available in Developer Preview for Teams right now (so very likely coming in future, but not available at the moment))

How can I debug the Modx "mxCalendar" extra?

I hope someone is here, who is familiar with the cms Modx.
I installed the extra "mxCalendar" and my button "Create New Calendar Item" is not working. I click on it and nothing happens.
Can you help me?
mxCalendar is not actively maintained anymore. Which MODX version are you using? mxCalendar does not work in MODX 2.3 and up, according to this list.
I suggest to use another calendar system like integrating Google Calendar or use regular resources and add some date/time tv's to work with dates. It really depends on how you want to use the calendar. Think about questions like:
Do I need (auto) recurring events?
Can an event occupy multiple days?
If both questions are anwsered with 'yes', than it could become technically very complex in my experience. The best way to go is embedding Google Calendar, or it's API.

How to invoke "next track" and "star current track" from my Spotify App?

I just started writing a little Spotify App and can't figure out how to invoke the two functions next/star from Javascript. I just need this simple functionality: From within my App (Javascript) call a method that skips the current track and plays the next one (if there is any) OR call a method that "stars" (is this really a verb?) the current song.
Is this API DOC the only resource for building my own App? Thanks in advance for any hints on this!
UPDATE: Just found out how to SKIP: sp.trackPlayer.skipToNextTrack();
Unfortunately, how to "star" a track remains unknown.
UPDATE 2: GOT IT! : models.library.starredPlaylist.add(models.player.track); – yep that makes sense.
The correct way to star a track is indeed the function you wrote:
models.library.starredPlaylist.add(models.player.track);
trackPlayer is not a supported object that shouldn't be accessed by developers since it's not versioned properly. This means that it may break in the future when we do updates to the platform bridge.
We recommend only using the documented classes on our developer website.
https://developer.spotify.com/technologies/apps/docs/beta/
The correct way to skip to the next track is to use:
models.player.next()

How to write text values in masked field?

i need some help related to masked field in web form. Syntax of phone field is (___)___-_____, if i execute this code in ruby shell
browser.text_field(:id => 'txtphone').set '7893457889'
... nothing has been added in the phone field.
then i find this solution in one blog, someone said first unmask this field using this code.
browser.text_field(:id,'txtphone').fire_event("unmask")
then write the above code again.
browser.text_field(:id => 'txtphone').set '7893457889'
but still nothing has happened. kindly help me out...am i doing right or still there is a mistake.
If you could provide some sample of the page HTML it will be easier to give you an answer more likely to work.
Given what you have provided us to work from, we have to go with the normal way that such masked input fields typically work and go from there. Usually pages with this kind of thing are calling a javascript function which is triggered by a specific event. Most often this is an event such as onchange but it may be something like keypress or any other even that happens when a normal user types or pasts text into the cell.
You likely need to experiment with using the '.fire_event' method to fire the proper javascript event, or if that fails entirely making a direct call to execute the proper script
When doing this do not confuse the name of a script such as 'applymask' or somesuch with the javascript event which causes that script to be invoked.
The answers to this question How to find out which JavaScript events fired? include some good information on how to use firebug or the chrome developer tools to figure out what events are being fired when you interact with an object on the browser screen.
Update: instead of responding here to indicate if this answer was of any use the OP reposted their question here Masked Text Box issue and by digging around on the vendor's demo site (since that time he actually had posted some of the HTML when we asked for it) I was able to find a solution using watir-webdriver that worked for him.

NSMutableAttributedString and Adding a Link to text

I have a NSMutableAttributedString, Now I want to add Link to some portion of the text. how can i add a link to the text so that when the user touches the text i can fire some actions. I'm working in iOS 4.2
Thanks in Advance.
Shinto
I did a library a few months back that dealt with that exact use case. However, I had to re-use it last week and found out that CMTextLabel isn't very user-friendly.
https://github.com/pothibo/CMFramework/tree/master/CMKit/RichText
You could have a look at it. If you decide to use it and refactor some of it to make it easier to use, send a push request and I'll merge it.

Resources