Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Added option to edit the zettel format like in obsidian #78

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/clip.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const create = async (testing=false) => {
dateFormat: "YYYY-MM-DD",
datetimeFormat: "YYYY-MM-DD HH:mm:ss",
timeFormat: "HH:mm:ss",
zettelFormat: "YYYYMMDDmmss",
}

async function getFromStorage(key) {
Expand All @@ -35,7 +36,7 @@ export const create = async (testing=false) => {
let day = moment().format("DD")
let month = moment().format("MM")
let year = moment().format("YYYY")
let zettel = moment().format("YYYYMMDDHHmmss")
let zettel = moment().format(clippingOptions.zettelFormat)

let selection = '';
let link = '';
Expand Down
7 changes: 6 additions & 1 deletion src/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ <h2 class="subtitle">An unoffical clipper</h2>
<label for="time_format">Time format</label>
<input id="time_format" name="time_format" type="text" placeholder="HH:mm:ss">
</div>

<div class="form-group">
<label for="zettel_format">Zettel format</label>
<input id="zettel_format" name="zettel_format" type="text" placeholder="YYYYMMDDHHmmss">
</div>

<div id="status"></div>

Expand All @@ -82,4 +87,4 @@ <h2 class="subtitle">An unoffical clipper</h2>

<a target="_blank" rel="noopener" class="by-jplattel" href="https://jplattel.nl/"><img src="https://jplattel.nl/img/joostplattel_small_cropped.png" /><p>by jplattel</p></a>
</body>
</html>
</html>
7 changes: 6 additions & 1 deletion src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function saveOptions() {
var datetimeFormat = document.getElementById('datetime_format').value;
var dateFormat = document.getElementById('date_format').value;
var timeFormat = document.getElementById('time_format').value;
var zettelFormat = document.getElementById('zettel_format').value;

chrome.storage.sync.set({
obsidianVaultName: obsidianVaultName,
Expand All @@ -19,6 +20,8 @@ function saveOptions() {
datetimeFormat: datetimeFormat,
dateFormat: dateFormat,
timeFormat: timeFormat,
zettelFormat: zettelFormat,

}, function() {
// Update status to let user know options were saved.
var status = document.getElementById('status');
Expand All @@ -43,6 +46,7 @@ Clipped from [{title}]({url}) at {date}.`,
datetimeFormat: "YYYY-MM-DD HH:mm:ss",
dateFormat: "YYYY-MM-DD",
timeFormat: "HH:mm:ss",
zettelFormat: "YYYYMMDDHHmmss",
}, function(options) {
document.getElementById('obsidian_vault_name').value = options.obsidianVaultName;
document.getElementById('obsidian_note_name').value = options.obsidianNoteName;
Expand All @@ -52,6 +56,7 @@ Clipped from [{title}]({url}) at {date}.`,
document.getElementById('datetime_format').value = options.datetimeFormat;
document.getElementById('date_format').value = options.dateFormat;
document.getElementById('time_format').value = options.timeFormat;
document.getElementById('zettel_format').value = options.zettelFormat;
});
}

Expand All @@ -72,4 +77,4 @@ async function testClipping() {
document.addEventListener('DOMContentLoaded', restoreOptions);
document.getElementById('save').addEventListener('click', saveOptions);
document.getElementById('reset').addEventListener('click', resetFormat);
document.getElementById('test').addEventListener('click', testClipping);
document.getElementById('test').addEventListener('click', testClipping);