Skip to content

Commit

Permalink
update(feat): notice displays json
Browse files Browse the repository at this point in the history
  • Loading branch information
Rooyca committed May 16, 2024
1 parent ebef2d2 commit de2217e
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export default class QJSON extends Plugin {

async onload() {
const statusBarItemEl = this.addStatusBarItem();
var qjCount = document.querySelectorAll('.notHere').length;
let qjCount;
qjCount = document.querySelectorAll('.notHere').length;
statusBarItemEl.setText('QJSON: ' + qjCount);

this.registerMarkdownCodeBlockProcessor("qjson", async (source, el, ctx) => {
Expand All @@ -16,17 +17,19 @@ export default class QJSON extends Plugin {

const id = source.match(/#qj-id: (\d+)/)[1];

let desc;

if (!source.includes('#qj-id-ds')) {
var desc;
try {
desc = source.match(/#qj-id-desc: (.+)/)[1];
} catch (e) {
desc = "»»» Query JSON «««";
}
el.createEl('h3', {text: desc});
el.createEl('h4', {text: "ID: " + id});
try {
desc = source.match(/#qj-id-desc: (.+)/)[1];
} catch (e) {
desc = "»»» Query JSON «««";
}
el.createEl('h3', {text: desc});
el.createEl('h4', {text: "ID: " + id});
}


if (source.includes('#qj-file:')) {
const file = source.match(/#qj-file: (.+)/)[1];
const response = await this.app.vault.adapter.read(file);
Expand All @@ -36,7 +39,7 @@ export default class QJSON extends Plugin {
const json = JSON.parse(source);
el.createEl('pre', {text: JSON.stringify(json, null, 2), cls: 'QJSON-'+id+' notHere'});

var qjCount = document.querySelectorAll('.notHere').length;
qjCount = document.querySelectorAll('.notHere').length;
statusBarItemEl.setText('QJSON: ' + qjCount);
});

Expand Down

0 comments on commit de2217e

Please sign in to comment.