Skip to content

Commit

Permalink
Format code with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
cbe committed Oct 31, 2023
1 parent 38351bc commit 5f1fe2b
Show file tree
Hide file tree
Showing 12 changed files with 1,239 additions and 1,111 deletions.
2 changes: 1 addition & 1 deletion internal/view/assets/css/archive.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/view/assets/css/style.css

Large diffs are not rendered by default.

43 changes: 20 additions & 23 deletions internal/view/assets/js/component/bookmark.js
Expand Up @@ -62,9 +62,9 @@ export default {
tags: {
type: Array,
default() {
return []
}
}
return [];
},
},
},
computed: {
mainURL() {
Expand All @@ -79,34 +79,31 @@ export default {
ebookURL() {
if (this.hasEbook) {
return new URL(`bookmark/${this.id}/ebook`, document.baseURI);
} else {
return null;
}
} else {
return null;
}
},
hostnameURL() {
var url = new URL(this.url);
return url.hostname.replace(/^www\./, "");
},
thumbnailVisible() {
return this.imageURL !== "" &&
!this.HideThumbnail;
return this.imageURL !== "" && !this.HideThumbnail;
},
excerptVisible() {
return this.excerpt !== "" &&
!this.thumbnailVisible &&
!this.HideExcerpt;
return this.excerpt !== "" && !this.thumbnailVisible && !this.HideExcerpt;
},
thumbnailStyleURL() {
return {
backgroundImage: `url("${this.imageURL}")`
}
backgroundImage: `url("${this.imageURL}")`,
};
},
eventItem() {
return {
id: this.id,
index: this.index,
}
}
};
},
},
methods: {
tagClicked(name, event) {
Expand All @@ -125,12 +122,12 @@ export default {
this.$emit("update", this.eventItem);
},
downloadebook() {
const id = this.id;
const ebook_url = new URL(`bookmark/${id}/ebook`, document.baseURI);
const downloadLink = document.createElement("a");
downloadLink.href = ebook_url.toString();
downloadLink.download = `${this.title}.epub`;
downloadLink.click();
const id = this.id;
const ebook_url = new URL(`bookmark/${id}/ebook`, document.baseURI);
const downloadLink = document.createElement("a");
downloadLink.href = ebook_url.toString();
downloadLink.download = `${this.title}.epub`;
downloadLink.click();
},
}
}
},
};
117 changes: 64 additions & 53 deletions internal/view/assets/js/component/dialog.js
Expand Up @@ -66,96 +66,107 @@ export default {
visible: Boolean,
content: {
type: String,
default: ''
default: "",
},
fields: {
type: Array,
default() {
return []
}
return [];
},
},
showLabel: {
type: Boolean,
default: false
default: false,
},
mainText: {
type: String,
default: 'OK'
default: "OK",
},
secondText: String,
mainClick: {
type: Function,
default() { this.visible = false; }
default() {
this.visible = false;
},
},
secondClick: {
type: Function,
default() { this.visible = false; }
default() {
this.visible = false;
},
},
escPressed: {
type: Function,
default() { this.visible = false; }
}
default() {
this.visible = false;
},
},
},
data() {
return {
formFields: []
formFields: [],
};
},
computed: {
btnTabIndex() {
return this.fields.length + 1;
}
},
},
watch: {
fields: {
immediate: true,
handler() {
this.formFields = this.fields.map(field => {
if (typeof field === 'string') return {
name: field,
label: field,
value: '',
type: 'text',
dictionary: [],
separator: ' ',
suggestion: undefined
}

if (typeof field === 'object') return {
name: field.name || '',
label: field.label || '',
value: field.value || '',
type: field.type || 'text',
dictionary: field.dictionary instanceof Array ? field.dictionary : [],
separator: field.separator || ' ',
suggestion: undefined
}
this.formFields = this.fields.map((field) => {
if (typeof field === "string")
return {
name: field,
label: field,
value: "",
type: "text",
dictionary: [],
separator: " ",
suggestion: undefined,
};

if (typeof field === "object")
return {
name: field.name || "",
label: field.label || "",
value: field.value || "",
type: field.type || "text",
dictionary:
field.dictionary instanceof Array ? field.dictionary : [],
separator: field.separator || " ",
suggestion: undefined,
};
});
}
},
},
'fields.length'() {
"fields.length"() {
this.focus();
},
visible: {
immediate: true,
handler() { this.focus() }
}
handler() {
this.focus();
},
},
},
methods: {
fieldType(f) {
var type = f.type || 'text';
if (type !== 'text' && type !== 'password') return 'text';
var type = f.type || "text";
if (type !== "text" && type !== "password") return "text";
else return type;
},
handleMainClick() {
var data = {};
this.formFields.forEach(field => {
this.formFields.forEach((field) => {
var value = field.value;
if (field.type === 'number') value = parseInt(value, 10) || 0;
else if (field.type === 'float') value = parseFloat(value) || 0.0;
else if (field.type === 'check') value = Boolean(value);
if (field.type === "number") value = parseInt(value, 10) || 0;
else if (field.type === "float") value = parseFloat(value) || 0.0;
else if (field.type === "check") value = Boolean(value);
data[field.name] = value;
})
});

this.mainClick(data);
},
Expand All @@ -178,9 +189,9 @@ export default {
lastWord = words[words.length - 1].toLowerCase(),
suggestion;

if (lastWord !== '') {
suggestion = dictionary.find(word => {
return word.toLowerCase().startsWith(lastWord)
if (lastWord !== "") {
suggestion = dictionary.find((word) => {
return word.toLowerCase().startsWith(lastWord);
});
}

Expand All @@ -192,11 +203,11 @@ export default {
// Display suggestion
this.$nextTick(() => {
var input = this.$refs.input[index],
suggestionNode = this.$refs['suggestion-' + index][0],
suggestionNode = this.$refs["suggestion-" + index][0],
inputRect = input.getBoundingClientRect();

suggestionNode.style.top = (inputRect.bottom - 1) + 'px';
suggestionNode.style.left = inputRect.left + 'px';
suggestionNode.style.top = inputRect.bottom - 1 + "px";
suggestionNode.style.left = inputRect.left + "px";
});
},
handleInputEnter(index) {
Expand All @@ -223,7 +234,7 @@ export default {
if (!this.visible) return;

var fields = this.$refs.input,
otherInput = this.$el.querySelectorAll('input'),
otherInput = this.$el.querySelectorAll("input"),
button = this.$refs.mainButton;

if (fields && fields.length > 0) {
Expand All @@ -235,7 +246,7 @@ export default {
} else if (button) {
button.focus();
}
})
}
}
}
});
},
},
};
8 changes: 4 additions & 4 deletions internal/view/assets/js/component/pagination.js
Expand Up @@ -23,7 +23,7 @@ var template = `
<i class="fas fa-fw fa-angle-double-right"></i>
</a>
</template>
</div>`
</div>`;

export default {
template: template,
Expand All @@ -39,6 +39,6 @@ export default {
else if (page <= 1) page = 1;

this.$emit("change", page);
}
}
}
},
},
};

0 comments on commit 5f1fe2b

Please sign in to comment.