Skip to content

Commit

Permalink
Cleaning up unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
heliostatic committed Jan 4, 2021
1 parent bb8232a commit 123c298
Showing 1 changed file with 6 additions and 87 deletions.
93 changes: 6 additions & 87 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,29 @@
import { App, Modal, Notice, Plugin, PluginSettingTab, Setting, addIcon} from 'obsidian';
import { App, Plugin, PluginSettingTab, Setting, addIcon} from 'obsidian';
import { brotliDecompressSync } from 'zlib';

interface MyPluginSettings {
mySetting: string;
interface TaskHiderSettings {
hide: boolean;
}

const DEFAULT_SETTINGS: MyPluginSettings = {
mySetting: 'default',
const DEFAULT_SETTINGS: TaskHiderSettings = {
hide: false
}

export default class MyPlugin extends Plugin {
settings: MyPluginSettings;
export default class TaskHiderPlugin extends Plugin {
settings: TaskHiderSettings;

async onload() {
console.log('loading plugin');

await this.loadSettings();



addIcon('tasks', taskShowIcon);
this.addRibbonIcon('tasks', 'Task Hider', () => {
document.body.toggleClass('hide-completed-tasks', this.settings.hide);
this.settings.hide = !this.settings.hide;
// this.addStatusBarItem().setText(this.settings.hide ? 'Showing Completed Tasks' : 'Hiding Completed Tasks');
this.saveSettings()
});

this.addStatusBarItem().setText('Hiding Completed Tasks');

this.addCommand({
id: 'open-sample-modal',
name: 'Open Sample Modal',
// callback: () => {
// console.log('Simple Callback');
// },
checkCallback: (checking: boolean) => {
let leaf = this.app.workspace.activeLeaf;
if (leaf) {
if (!checking) {
new SampleModal(this.app).open();
}
return true;
}
return false;
}
});

this.addSettingTab(new SampleSettingTab(this.app, this));

this.registerCodeMirror((cm: CodeMirror.Editor) => {
console.log('codemirror', cm);
});

this.registerDomEvent(document, 'click', (evt: MouseEvent) => {
console.log('click', evt);
});

this.registerInterval(window.setInterval(() => console.log('setInterval'), 5 * 60 * 1000));
}

onunload() {
Expand All @@ -73,50 +38,4 @@ export default class MyPlugin extends Plugin {
await this.saveData(this.settings);
}
}

class SampleModal extends Modal {
constructor(app: App) {
super(app);
}

onOpen() {
let {contentEl} = this;
contentEl.setText('Woah!');
}

onClose() {
let {contentEl} = this;
contentEl.empty();
}
}

class SampleSettingTab extends PluginSettingTab {
plugin: MyPlugin;

constructor(app: App, plugin: MyPlugin) {
super(app, plugin);
this.plugin = plugin;
}

display(): void {
let {containerEl} = this;

containerEl.empty();

containerEl.createEl('h2', {text: 'Settings for my awesome plugin.'});

new Setting(containerEl)
.setName('Setting #1')
.setDesc('It\'s a secret')
.addText(text => text
.setPlaceholder('Enter your secret')
.setValue('')
.onChange(async (value) => {
console.log('Secret: ' + value);
this.plugin.settings.mySetting = value;
await this.plugin.saveSettings();
}));
}
}

const taskShowIcon = `<svg aria-hidden="true" focusable="false" data-prefix="fal" data-icon="tasks" class="svg-inline--fa fa-tasks fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M145.35 207a8 8 0 0 0-11.35 0l-71 71-39-39a8 8 0 0 0-11.31 0L1.35 250.34a8 8 0 0 0 0 11.32l56 56a8 8 0 0 0 11.31 0l88-88a8 8 0 0 0 0-11.32zM62.93 384c-17.67 0-32.4 14.33-32.4 32s14.73 32 32.4 32a32 32 0 0 0 0-64zm82.42-337A8 8 0 0 0 134 47l-71 71-39-39a8 8 0 0 0-11.31 0L1.35 90.34a8 8 0 0 0 0 11.32l56 56a8 8 0 0 0 11.31 0l88-88a8 8 0 0 0 0-11.32zM503 400H199a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h304a8 8 0 0 0 8-8v-16a8 8 0 0 0-8-8zm0-320H199a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h304a8 8 0 0 0 8-8V88a8 8 0 0 0-8-8zm0 160H199a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h304a8 8 0 0 0 8-8v-16a8 8 0 0 0-8-8z"></path></svg>`

0 comments on commit 123c298

Please sign in to comment.