Skip to content

Commit

Permalink
fix replaceall bug in od and otmr
Browse files Browse the repository at this point in the history
  • Loading branch information
hauselin committed Apr 29, 2021
1 parent 3372263 commit 3c8cd0d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
Binary file modified Obsidian.alfredworkflow
Binary file not shown.
38 changes: 21 additions & 17 deletions Obsidian/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -860,14 +860,15 @@ var date_format_original = date_format;
// get today's day if requested
if (date_format.includes('dddd')) {
day_string = days[day]
date_format = date_format.replaceAll('dddd', 'zzzz')
date_format = date_format.replace('dddd', 'zzzz')
}
if (date_format.includes('ddd')) {
day_string_short = days_short[day]
date_format = date_format.replaceAll('ddd', 'zzz')
date_format = date_format.replace('ddd', 'zzz')
}
// TODO clean up code
// TODO clean up the two blocks of if statements
// don't replace letter e or E that appear before/after alphabets
if (date_format.includes('e')) {
for (var i = 0; i < date_format.length; i++) {
console.log(date_format.charAt(i));
Expand Down Expand Up @@ -1009,17 +1010,17 @@ if (m_char == 'mmm') {
// day of week if requested
if (date_format.includes('zzzz')) {
date_format = date_format.replaceAll('zzzz', day_string)
date_format = date_format.replace('zzzz', day_string)
}
if (date_format.includes('zzz')) {
date_format = date_format.replaceAll('zzz', day_string_short)
date_format = date_format.replace('zzz', day_string_short)
}
// e is day of week (0, 1, ... 7)
if (date_format_original.includes('e')) {
date_format = date_format.replaceAll('!!!', days_e[day].toString())
date_format = date_format.replace('!!!', days_e[day].toString())
}
if (date_format_original.includes('E')) {
date_format = date_format.replaceAll('@@@', days_E[day].toString())
date_format = date_format.replace('@@@', days_E[day].toString())
}
console.log('3. date_format: ' + date_format);
Expand Down Expand Up @@ -1195,11 +1196,11 @@ var date_format_original = date_format;
// get today's day if requested
if (date_format.includes('dddd')) {
day_string = days[day]
date_format = date_format.replaceAll('dddd', 'zzzz')
date_format = date_format.replace('dddd', 'zzzz')
}
if (date_format.includes('ddd')) {
day_string_short = days_short[day]
date_format = date_format.replaceAll('ddd', 'zzz')
date_format = date_format.replace('ddd', 'zzz')
}
// TODO clean up code
Expand All @@ -1221,15 +1222,15 @@ if (date_format.includes('e')) {
continue
} else {
console.log("replacing this e")
// date_format = date_format.replaceAll('e', '!!!')
// date_format = date_format.replace('e', '!!!')
date_format = date_format.substring(0, i) + '!!!' + date_format.substring(i + 1);
}
}
}
}
// if (date_format.includes('E')) {
// date_format = date_format.replaceAll('E', '@@@')
// date_format = date_format.replace('E', '@@@')
// }
if (date_format.includes('E')) {
for (var i = 0; i < date_format.length; i++) {
Expand All @@ -1249,7 +1250,7 @@ if (date_format.includes('E')) {
continue
} else {
console.log("replacing this E")
// date_format = date_format.replaceAll('e', '@@@')
// date_format = date_format.replace('e', '@@@')
date_format = date_format.substring(0, i) + '@@@' + date_format.substring(i + 1);
}
}
Expand Down Expand Up @@ -1344,17 +1345,17 @@ if (m_char == 'mmm') {
// day of week if requested
if (date_format.includes('zzzz')) {
date_format = date_format.replaceAll('zzzz', day_string)
date_format = date_format.replace('zzzz', day_string)
}
if (date_format.includes('zzz')) {
date_format = date_format.replaceAll('zzz', day_string_short)
date_format = date_format.replace('zzz', day_string_short)
}
// e is day of week (0, 1, ... 7)
if (date_format_original.includes('e')) {
date_format = date_format.replaceAll('!!!', days_e[day].toString())
date_format = date_format.replace('!!!', days_e[day].toString())
}
if (date_format_original.includes('E')) {
date_format = date_format.replaceAll('@@@', days_E[day].toString())
date_format = date_format.replace('@@@', days_E[day].toString())
}
console.log('3. date_format: ' + date_format);
Expand Down Expand Up @@ -4247,6 +4248,9 @@ RELEASE NOTES
Full documentation: https://github.com/hauselin/obsidian-alfred
v0.3.6
- Remove replaceAll in od and otmr to avoid bug in #25.
v0.3.5
- Fix od bug. #28 @lh00000000
Expand Down Expand Up @@ -4989,7 +4993,7 @@ If the Obsidian app isn't already opened, this workflow will always open the las
<string>dailyheader</string>
</array>
<key>version</key>
<string>0.3.5</string>
<string>0.3.6</string>
<key>webaddress</key>
<string>https://github.com/hauselin/obsidian-alfred</string>
</dict>
Expand Down

0 comments on commit 3c8cd0d

Please sign in to comment.