タグに自動で色がつくようにしました。なお、同一のタグは同一の色がつくようになっています
タグのコンポーネントはこんな感じ
<template>
<b-badge pill v-bind:style="'background-color : #'+ string_to_utf8_hex_string(tag).substr(1,6) + ';'" class="mr-2" v-bind:to="to">{{tag}}</b-badge>
</template>
<script>
export default {
props:["tag","to"],
methods : {
string_to_utf8_hex_string : function(text){
var bytes1 = this.string_to_utf8_bytes(text);
var hex_str1 = this.bytes_to_hex_string(bytes1);
return hex_str1;
},
string_to_utf8_bytes : function(text){
var result = [];
if (text == null)
return result;
for (var i = 0; i < text.length; i++) {
var c = text.charCodeAt(i);
if (c <= 0x7f) {
result.push(c);
} else if (c <= 0x07ff) {
result.push(((c >> 6) & 0x1F) | 0xC0);
result.push((c & 0x3F) | 0x80);
} else {
result.push(((c >> 12) & 0x0F) | 0xE0);
result.push(((c >> 6) & 0x3F) | 0x80);
result.push((c & 0x3F) | 0x80);
}
}
return result;
},
bytes_to_hex_string : function(bytes){
var result = "";
for (var i = 0; i < bytes.length; i++) {
result += this.byte_to_hex(bytes[i]);
}
return result;
},
byte_to_hex : function(byte_num){
var digits = (byte_num).toString(16);
if (byte_num < 16) return '0' + digits;
return digits;
}
}
}
</script>
この後はワードクラウドとか作りたい
エンジニアが「社会人サークル」を始めるべきである7つの理由
2022年8月16日(火) 14時29分57秒 | 416 view埋め込み要素(iframe / embed)をいい加減対応させたい
2021年6月9日(水) 1時2分54秒 | 65 viewactions-js/push@masterでのデフォルトブランチがmasterからmainに変わっていてCIが動かなくなっていた
2021年8月30日(月) 8時49分10秒 | 63 viewhighlight.jsを入れた
2020年10月28日(水) 13時49分3秒 | 45 viewWebの変更をLINEに通知する仕組みを提供するサービスをココナラに出品しました
2020年10月25日(日) 2時50分32秒 | 27 view