Improve str length tool
This commit is contained in:
parent
02bc94d10c
commit
6bf9e60c60
@ -7,13 +7,18 @@
|
||||
<textarea id="data" v-model="toolData.data" style="height: 150px"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="data_delimiter">Delimiter</label>
|
||||
<input id="data_delimiter" v-model="toolData.dataDelimiter" placeholder="," type="text">
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label>Mode</label>
|
||||
|
||||
<div>
|
||||
<input id="count_mode_characters" value="characters" name="count_mode" v-model="toolData.countMode" type="radio"> <label for="count_mode_characters">characters</label><br>
|
||||
<input id="count_mode_words" value="words" name="count_mode" v-model="toolData.countMode" type="radio"> <label for="count_mode_words">words</label><br>
|
||||
<input id="count_mode_lines" value="lines" name="count_mode" v-model="toolData.countMode" type="radio"> <label for="count_mode_lines">lines</label>
|
||||
<input id="count_mode_characters" value="characters" name="count_mode" v-model="toolData.countMode" :disabled="toolData.dataDelimiter.length" type="radio"> <label for="count_mode_characters">characters</label><br>
|
||||
<input id="count_mode_words" value="words" name="count_mode" v-model="toolData.countMode" :disabled="toolData.dataDelimiter.length" type="radio"> <label for="count_mode_words">words</label><br>
|
||||
<input id="count_mode_lines" value="lines" name="count_mode" v-model="toolData.countMode" :disabled="toolData.dataDelimiter.length" type="radio"> <label for="count_mode_lines">lines</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -31,12 +36,16 @@ export default {
|
||||
return {
|
||||
toolData: {
|
||||
data: '',
|
||||
dataDelimiter: '',
|
||||
countMode: 'characters',
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
toolResult() {
|
||||
if (this.toolData.dataDelimiter.length) {
|
||||
return this.toolData.data.split(this.toolData.dataDelimiter).length;
|
||||
} else {
|
||||
switch (this.toolData.countMode) {
|
||||
case 'characters':
|
||||
return this.toolData.data.length;
|
||||
@ -45,6 +54,7 @@ export default {
|
||||
case 'lines':
|
||||
return this.toolData.data.split('\n').length;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user