Closet For Anki [Official support]

thanks for the reply. Maybe the problem is with the android version.

For non-visible cards, read comment 66… we have discussed the issue before.

1 Like

Thanks for pointing it out.

In my case, since the same cards are showing up in Android10 but not in Android8 I simply assumed that the problem was OS related, and there is no parameter or code that I can change about that.

Anyway, I’m already used to use Ankidroid with my phone (And10), not with my tablet (And8), and, since I have 0 knowledge in programming, I’m not sure if the time neccesary to investigate this issue is worth for me

(I know, I’ll finish messing around with that when I have some free time, haha)

I’m quite excited to work on Closet again, especially now that 2.15.2 is out. I’ve prepared a special notetype ages ago, which is supposed to be an easy way to get started with Closet. I’ve held it back, because I still wanted to wait for Ankidroid support. As soon as I have some free time, I will get this stone rolling!

4 Likes

Is there any way that we can make image occlusion ‘h’ type as the default one while doing image occlusions in command note types …
Thanks for your valuable time,
@hengiesel @kleinerpirat

You can do it in the setup:

    closet.browser.recipes.rect({
        tagname: 'rect',
        defaultBehavior: closet.flashcard.behaviors.Hide,
    }),

Same goes for the other definitions like clozes.

Extra tip

You can set up your template in a way that you can toggle the visibility of the rectangles by clicking on the image. Put this into your back template:

<script>
   function toggleOcclusions() {
      if (this.hasAttribute("occluded")) {
         for (rect of document.querySelectorAll(".closet-rect")) {
            rect.style.display = "none"
            this.removeAttribute("occluded")
         }
      }
      else {
         for (rect of document.querySelectorAll(".closet-rect")) {
            rect.style.display = "block"
            this.setAttribute("occluded", "")
         }
      }
   }
   
   setTimeout(() => {
      if ((img = document.querySelector(".closet-occlusion-container")) != null) {
         img.setAttribute("occluded", "")
         img.addEventListener("click", toggleOcclusions)
      }
   }, 0)
</script>

This way you have the best of both worlds: no distractions because you set up the rects to hide by default, but if you want to see the full image, you now have the ability to show it.

Image Occlusion not showing on AnkiMobile

Today I tested on an old iPad whether the Closet features work on AnkiMobile too, and everything seems to work except image occlusions.

Could this be a CSS issue? It’s not the script from the post above, just checked.

This code works fine , thanks

Not working

I made three occlusions boxes in an image
observations :
1)first card - front side ok, backside = all boxes are revealed

  1. second and third card will ask for the box, backside will show the box revealed… with all other boxes closed…

  2. no boxes opened when clicked in any of the cards…

Where i copied the code: tools> manage cards>> commands note types>>cards>> back template –

Any idea where i need to work upon?

PS : the toggle option in commad note types was not functioning from the begining itself

Hm, it works on my test note type. The function has to execute after Closet, so perhaps it would even suffice to put it at the bottom of the back template. You could also try increasing the timeout from 0 to 500 and see if that changes anything.

Since this is just a little hack that is not part of Closet itself, I won’t provide any further support on that.

ok, thank you… i will try these tips then

hi all

now noticed a new issue
its regarding the close

when i use multiple close options in a single card, only the first card is functioning properly
Card type = basic
eg

colour of leaf =[[ch1:: green]]
colour of sky=[[ch2:: blue]]

colour of road= [[ch3:: black]]

then only card 1 gets operated properly

so i renamed the card as “card” from “card 1” >>> then no cards are functioning
when i change the card name to card 2 , second code { colour of sky=[[ch2:: blue]] } will function

so basically , under simple card types, i am not able to make multiples closes

can somebody suggest some ideas to rectify it

thanks for valuable help

below is the code of card for front side

{{Front}}

function closetUserLogic(closet, preset, chooseMemory) { const elements = closet.template.anki.getQaChildNodes(); const memory = chooseMemory("closet__1"); const filterManager = closet.FilterManager.make(preset, memory.map);
        const output = [[elements, memory, filterManager]];

        /* here goes the setup - change it to fit your own needs */

        filterManager.install(
            closet.recipes.shuffle({ tagname: "mix" }),
            closet.recipes.order({ tagname: "ord" }),

            closet.flashcard.recipes.cloze.show({ tagname: "c" }),
            closet.flashcard.recipes.cloze.hide({ tagname: "ch" }),
            closet.flashcard.recipes.cloze.reveal({ tagname: "cr" }),

            closet.browser.recipes.rect.show({ tagname: "rect" }),
            closet.browser.recipes.rect.reveal({ tagname: "rectr" }),
            closet.browser.recipes.rect.hide({ tagname: "recth" }),

            closet.flashcard.recipes.multipleChoice({
                tagname: "mc",
                defaultBehavior: closet.flashcard.behaviors.Show,
            }),
            closet.flashcard.recipes.sort({
                tagname: "sort",
                defaultBehavior: closet.flashcard.behaviors.Show,
            }),

        );



        /** Click to reveal cloze */

        const removeObscure = function(event) {
          if (event.currentTarget.classList.contains('cl--obscure-clickable')) {
            event.currentTarget.classList.remove('cl--obscure')
            event.currentTarget.classList.remove('cl--obscure-hint')
            event.currentTarget.classList.remove('cl--obscure-fix')
          }
        }

        const wrappedClozeShow = closet.wrappers.aftermath(closet.flashcard.recipes.cloze.show, () => {
          document.querySelectorAll('.cl--obscure')
          .forEach(tag => {
            tag.addEventListener('click', removeObscure, {
              once: true,
            })
          })
        })

        const obscureAndClick = (t) => {
          return [`<span class="cl--obscure cl--obscure-hint cl--obscure-clickable">${t.values[0]}</span>`]
        }

        const obscureAndClickFix = (t) => {
          return [`<span class="cl--obscure cl--obscure-fix cl--obscure-clickable"><span>${t.values[0]}</span></span>`]
        }

        const frontStylizer = closet.Stylizer.make({
          processor: v => `<span style="color: cornflowerblue">${v}</span>`,
        })

        filterManager.install(
          wrappedClozeShow({
            tagname: 'c',
            frontEllipser: obscureAndClick,
            frontStylizer: frontStylizer,
          }),

          wrappedClozeShow({
            tagname: 'cx',
            frontEllipser: obscureAndClickFix,
            frontStylizer: frontStylizer,
          }),
        );
        return output;
    }

    var getAnkiPrefix = () =>
        globalThis.ankiPlatform === "desktop"
            ? ""
            : globalThis.AnkiDroidJS
            ? "https://appassets.androidplatform.net"
            : ".";

    var closetPromise = import(`${getAnkiPrefix()}/__closet-0.5.3.js`);
    closetPromise
        .then(
            ({ closet }) =>
                closet.template.anki.initialize(
                    closet,
                    closetUserLogic,
                    "{{Card}}",
                    "{{Tags}}",
                    "front",
                ),
            (error) => console.log("An error occured while loading Closet:", error),
        )
        .catch((error) =>
            console.log("An error occured while executing Closet:", error),
        );

    if (globalThis.onUpdateHook) {
        onUpdateHook.push(() => closetPromise);
    }
</script>

Update : problem solved . I used the 'command ’ note types… Please update if there is any otherway . Otherwise its functioning well and good

Hi, in my note I have [[ch1::…]] until [[ch10::…]]. This generates 10 cards. However only cards corresponding from ch1 to ch8 are working properly. From ch9 and above, the cloze did not show up in both front and back side (refer to attached screenshot).


. So the max number of cloze (ch1, ch2…) is 8? Is it possible to increase this max value?

The max value corresponds to the amount of card templates. You can increase it as much as you like by adding more card templates to your note type.

As far as I can see on your screenshots, 9 and 10 render as clozes too, don’t they? They’re just not active. Would you mind sharing the input of your {{Question}} field?

Hi, your website https://closetengine.com is not accessible by the moment.

Hi, @kleinerpirat

Above is my note. For 9 and 10, it does render as clozes, however it did not render correctly perhaps. The cloze is supposed to have “hint” and be orange in color (as my previous photo of 8). The back side also does not reveal the cloze also. Here is the screenshot of back side, not front side, of 9.

Thanks for the notification, the domain name had timed out. Should be back up within a day.

When did you create the card types? There was an Anki version, that inserted invisible Unicode isolation characters into the card name by accident.

1 Like

Thanks @hengiesel . That’s the problem. I renamed the card type and it works. Thank you so much.

1 Like

The installation tab on your website is empty. Is that a bug or intended?