/* コンポーネント内はthisでプロパティを取得したい場合はアロー関数を使わない dataはOK */ const joint_setting = { //共通コンポーネントを登録 components : { 'mhs-header' : httpVueLoader( 'https://moneystar.shop/header/mhs-header.vue.php' ) , 'mhs-footer' : httpVueLoader( 'https://moneystar.shop/footer/mhs-footer.vue.php' ) , 'mhs-modal' : httpVueLoader( 'https://moneystar.shop/mhs-modal.vue' ) , } , mounted : function() { }, created : function() { } , methods : { //クエリパラメータを取得する getParam : function( name , url ) { if(! url ) url = window.location.href; name = name.replace( /[\[\]]/g , "\\$&" ); var regex = new RegExp( "[?&]" + name + "(=([^&#]*)|&|#|$)" ) , results = regex.exec( url ); if(! results ) return null; if(! results[2] ) return ''; return decodeURIComponent( results[2].replace( /\+/g , " " ) ); }, //カテゴリスラッグからカテゴリリストを検索してカテゴリ名を取得する getCategoryBySlug: function( slug ) { if( slug == '' ) return; let category_name = null; const A_cat = []; this.categoryLists.forEach( function( obj , index ) { //含まれていたら配列に追加 if( slug == obj.value ) A_cat.push( obj.text ); }); if( A_cat.length ) category_name = A_cat.join( ' / ' ); return category_name; }, //エスケープした文字列を復元する convert_html : function( obj ) { //※オブジェクトの場合は参照コピーとなるため元データの上書きされる //blocksがなければ終了 if(! obj.hasOwnProperty( 'blocks' ) ) return obj; //スコープの関係で関数をコピー const return_html = this.return_html; Object.keys( obj.blocks ).forEach( function( key ) { //段落タイプであれば if( obj.blocks[ key ].type == 'paragraph' && obj.blocks[ key ].hasOwnProperty( 'data' ) && obj.blocks[ key ].data.hasOwnProperty( 'text' ) ) { //空であれば空文字に置き換え if( obj.blocks[ key ].data.text == '' || obj.blocks[ key ].data.text == ' ' ) { obj.blocks[ key ].data.text = ' '; } else { obj.blocks[ key ].data.text = obj.blocks[ key ].data.text.replace( /\[BR\]/g , "
" ); obj.blocks[ key ].data.text = obj.blocks[ key ].data.text.replace( /\[ENT\]/g , "
" ); obj.blocks[ key ].data.text = obj.blocks[ key ].data.text.replace( /<br>/g , "\n" ); //HTMLを復元する obj.blocks[ key ].data.text = return_html( obj.blocks[ key ].data.text ); } } //見出しタイプであれば else if( obj.blocks[ key ].type == 'header' && obj.blocks[ key ].hasOwnProperty( 'data' ) && obj.blocks[ key ].data.hasOwnProperty( 'text' ) ) { // obj.blocks[ key ].data.text = obj.blocks[ key ].data.text.replace( / /g , " " ); // obj.blocks[ key ].data.text = obj.blocks[ key ].data.text.replace( / /g , " " ); obj.blocks[ key ].data.text = obj.blocks[ key ].data.text.replace( /\[BR\]/g , "
" ); } //イメージタイプであれば else if( obj.blocks[ key ].type == 'image' && obj.blocks[ key ].hasOwnProperty( 'data' ) && obj.blocks[ key ].data.hasOwnProperty( 'caption' ) ) { obj.blocks[ key ].data.caption = obj.blocks[ key ].data.caption.replace( /\[BR\]/g , "
" ); } //引用タイプであれば else if( obj.blocks[ key ].type == 'quote' && obj.blocks[ key ].hasOwnProperty( 'data' ) && obj.blocks[ key ].data.hasOwnProperty( 'text' ) ) { obj.blocks[ key ].data.text = obj.blocks[ key ].data.text.replace( /\[BR\]/g , "
" ); obj.blocks[ key ].data.text = obj.blocks[ key ].data.text.replace( /\[ENT\]/g , "
" ); if( obj.blocks[ key ].data.hasOwnProperty( 'caption' ) ) { obj.blocks[ key ].data.caption = obj.blocks[ key ].data.caption.replace( /\[BR\]/g , "
" ); obj.blocks[ key ].data.caption = obj.blocks[ key ].data.caption.replace( /\[ENT\]/g , "
" ); } } //コードタイプであれば else if( obj.blocks[ key ].type == 'code' && obj.blocks[ key ].hasOwnProperty( 'data' ) && obj.blocks[ key ].data.hasOwnProperty( 'code' ) ) { //HTMLタグを元に戻す obj.blocks[ key ].data.code = obj.blocks[ key ].data.code.replace( /</g , '<' ); obj.blocks[ key ].data.code = obj.blocks[ key ].data.code.replace( />/g , '>' ); //二重引用符を元に戻す obj.blocks[ key ].data.code = obj.blocks[ key ].data.code.replace( /quot;/g , '"' ); obj.blocks[ key ].data.code = obj.blocks[ key ].data.code.replace( /\[ENT\]/g , "\n" ); obj.blocks[ key ].data.code = obj.blocks[ key ].data.code.replace( /\&/g , '&' ); } //区切り線タイプであれば else if( obj.blocks[ key ].type == 'divider' && obj.blocks[ key ].hasOwnProperty( 'data' ) && obj.blocks[ key ].data.hasOwnProperty( 'divider' ) ) { //HTMLタグを元に戻す obj.blocks[ key ].data.divider = obj.blocks[ key ].data.divider.replace( /</g , '<' ); obj.blocks[ key ].data.divider = obj.blocks[ key ].data.divider.replace( />/g , '>' ); //二重引用符を元に戻す obj.blocks[ key ].data.divider = obj.blocks[ key ].data.divider.replace( /quot;/g , '"' ); } }); return obj; } , //エスケープしたHTMLを復元する return_html : function( html ) { /* const str = '<a href="https://yahoo.co.jp/">リンク</a>'; const str2 = '<span style="background-image:https://yahoo.co.jp/">スパン</span>'; //aタグをエスケープするが、属性にURLらしきものが入っている場合はスルーする res = str.replace( /<(a\s?)(?!.*\/\/)(.*?)>/g , '<$1$2 target="_blank">' ); //spanタグをエスケープするが、属性にURLらしきものが入っている場合はスルーする res2 = str.replace( /<(span\s?)(?!.*\/\/)(.*?)>/g , '<$1$2>' ); */ //<a href="https://yahoo.co.jp/" style="background-image: https://yahoo.co.jp/;">スタイル付きリンク</a> //スタイル付きリンク //アンカーのスタイル属性とクラス属性を削除する html = html.replace( /<(a\s?.*?)(?:style|class)\s*?=\s*["'].*?["'](.*?)>/img , '<$1$2>' ); //' //アンカー html = html.replace( /<(a\s?)(?!.*style.*\/\/)(.*?)>/g , '<$1$2>' ); html = html.replace( /<\/a>/g , '' ); //エスケープしたアンカーを元に戻す html = html.replace( /\[a\]/g , '<a' ); html = html.replace( /\[\/a\]/g , '</a>' ); //斜体(属性にURLらしきものが入っていないこと) html = html.replace( /<(i\s?)(?!.*\/\/)(.*?)>/g , '<$1$2>' ); html = html.replace( /<\/i>/g , '' ); //太字(属性にURLらしきものが入っていないこと) html = html.replace( /<(b\s?)(?!.*\/\/)(.*?)>/g , '<$1$2>' ); html = html.replace( /<\/b>/g , '' ); //下線(属性にURLらしきものが入っていないこと) html = html.replace( /<(u\s?)(?!.*\/\/)(.*?)>/g , '<$1$2>' ); html = html.replace( /<\/u>/g , '' ); //span(属性にURLらしきものが入っていないこと) html = html.replace( /<(span\s?)(?!.*\/\/)(.*?)>/g , '<$1$2>' ); html = html.replace( /<\/span>/g , '' ); //文字色(属性にURLらしきものが入っていないこと) html = html.replace( /<(font\s?)(?!.*\/\/)(.*?)>/g , '<$1$2>' ); html = html.replace( /<\/font>/g , '' ); //mark(属性にURLらしきものが入っていないこと) html = html.replace( /<(mark\s?)(?!.*\/\/)(.*?)>/g , '<$1$2>' ); html = html.replace( /<\/mark>/g , '' ); return html; } , //本文を装飾する decorate_body : function( str ) { //鉤括弧を太字に str = str.replace( /\「(.*?)\」/g , '「$1」' ); //二重鉤括弧を太字に str = str.replace( /\『(.*?)\』/g , '『$1』' ); //角括弧を太字に str = str.replace( /\[(.*?)\]/g , '[$1]' ); //墨付括弧を太字に str = str.replace( /\【(.*?)\】/g , '【$1】' ); //リンクを太字に str = str.replace( //g , '' ); return str; } , //本文の文字列をカウントする count_body : function( obj ) { //オブジェクトをコピーしてから使う let obj_ = Object.assign( {} , JSON.parse( JSON.stringify( obj ) ) ); //エスケープした文字列を復元する obj_ = this.convert_html( obj_ ); let count = 0; Object.keys( obj_.blocks ).forEach( function( key ) { //段落タイプであれば if( obj_.blocks[ key ].type == 'paragraph' && obj_.blocks[ key ].hasOwnProperty( 'data' ) && obj_.blocks[ key ].data.hasOwnProperty( 'text' ) ) { //HTMLタグを除去する str = obj_.blocks[ key ].data.text.replace( /<("[^"]*"|'[^']*'|[^'">])*>/g , '' ); // を削除する str = str.replace( / /g , '' ); //文字数をカウントする count = count + str.length; } //見出しタイプであれば else if( obj_.blocks[ key ].type == 'header' && obj_.blocks[ key ].hasOwnProperty( 'data' ) && obj_.blocks[ key ].data.hasOwnProperty( 'text' ) ) { //HTMLタグを除去する str = obj_.blocks[ key ].data.text.replace( /<("[^"]*"|'[^']*'|[^'">])*>/g , '' ); // を削除する str = str.replace( / /g , '' ); //文字数をカウントする count = count + str.length; } //引用タイプであれば else if( obj_.blocks[ key ].type == 'quote' && obj_.blocks[ key ].hasOwnProperty( 'data' ) && obj_.blocks[ key ].data.hasOwnProperty( 'text' ) ) { //HTMLタグを除去する str = obj_.blocks[ key ].data.text.replace( /<("[^"]*"|'[^']*'|[^'">])*>/g , '' ); // を削除する str = str.replace( / /g , '' ); //文字数をカウントする count = count + str.length; if( obj_.blocks[ key ].data.hasOwnProperty( 'caption' ) ) { //HTMLタグを除去する str = obj_.blocks[ key ].data.caption.replace( /<("[^"]*"|'[^']*'|[^'">])*>/g , '' ); // を削除する str = str.replace( / /g , '' ); //文字数をカウントする count = count + str.length; } } //コードタイプであれば else if( obj_.blocks[ key ].type == 'code' && obj_.blocks[ key ].hasOwnProperty( 'data' ) && obj_.blocks[ key ].data.hasOwnProperty( 'code' ) ) { //HTMLタグを除去する str = obj_.blocks[ key ].data.code.replace( /<("[^"]*"|'[^']*'|[^'">])*>/g , '' ); // を削除する str = str.replace( / /g , '' ); //文字数をカウントする count = count + str.length; } }); return count; } , } , computed : { } , data : ()=> ({ ep_url : 'https://moneystar.shop/mhs-vaiden.php' , bs_url : 'https://moneystar.shop' , sign_in_url : 'https://moneystar.shop/sign_in/' , mypage_url : 'https://moneystar.shop/mypage/' , account_url : 'https://moneystar.shop/dashboard/?tab=2' , categoryLists : [ { text : 'FX' , value : 'fx' , icon : 'mdi-swap-horizontal' , color : 'light-blue darken-2' }, { text : '株式投資' , value : 'stock-investment' , icon : 'mdi-chart-line' , color : 'light-blue darken-2' }, { text : '資産運用' , value : 'asset-management' , icon : 'mdi-currency-usd' , color : 'light-blue darken-2' }, { text : '節約・節税' , value : 'savings' , icon : 'mdi-pig-variant-outline' , color : 'light-blue darken-2' }, { text : 'NFT・仮想通貨' , value : 'virtual-currency' , icon : 'mdi-database-sync-outline' , color : 'light-blue darken-2' }, { text : 'その他' , value : 'others' , icon : 'mdi-lightbulb-on-outline' , color : 'light-blue darken-2' }, ] , }), }