Added minimizer to JSON Formatter
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
xml: {type: String, required: true}
|
xml: {type: String, required: true},
|
||||||
|
isMinimizer: {type: Boolean}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(["update:result"])
|
const emit = defineEmits(["update:result"])
|
||||||
@@ -18,11 +19,14 @@ function prepareRequest():Request {
|
|||||||
body: prepareRequestBody(),
|
body: prepareRequestBody(),
|
||||||
method: "POST"
|
method: "POST"
|
||||||
});
|
});
|
||||||
return request
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareURL(): string {
|
function prepareURL(): string {
|
||||||
return document.location.protocol + "//" + document.location.hostname + "/java/json/formatting";
|
var mode = "formatting";
|
||||||
|
if (props.isMinimizer)
|
||||||
|
mode = "minimize";
|
||||||
|
return document.location.protocol + "//" + document.location.hostname + "/java/json/" + mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareRequestBody():string {
|
function prepareRequestBody():string {
|
||||||
@@ -44,7 +48,7 @@ function sendProcessedData(data: JSON) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<button class="tool-button" @click="process()">Format</button>
|
<button class="tool-button" @click="process()">{{ props.isMinimizer ? "Minimize" : "Format"}}</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ function clear() {
|
|||||||
<div class="space-x-2">
|
<div class="space-x-2">
|
||||||
<InsertTemplateComponent pretty-name="JSON" @update:defaultData="(data: string) => setTextFieldValue(data)"></InsertTemplateComponent>
|
<InsertTemplateComponent pretty-name="JSON" @update:defaultData="(data: string) => setTextFieldValue(data)"></InsertTemplateComponent>
|
||||||
<button class="tool-button" @click="clear()">Clear</button>
|
<button class="tool-button" @click="clear()">Clear</button>
|
||||||
|
<JsonButtonFormatterComponent isMinimizer :xml="json" @update:result="(data: any) => format(data)"></JsonButtonFormatterComponent>
|
||||||
<JsonButtonFormatterComponent :xml="json" @update:result="(data: any) => format(data)"></JsonButtonFormatterComponent>
|
<JsonButtonFormatterComponent :xml="json" @update:result="(data: any) => format(data)"></JsonButtonFormatterComponent>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user