「MediaWiki:Common.js」の版間の差分

提供:作業療法大百科事典OtWiki
編集の要約なし
編集の要約なし
 
(同じ利用者による、間の26版が非表示)
1行目: 1行目:
/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */
/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */


<script type="text/javascript">
window.addEventListener('load', function() {


document.addEventListener('DOMContentLoaded', function() {
const share_url = location.href;
    // 現在のページのURLを取得
const share_hostpath = location.host + location.pathname;
    var currentPageUrl = window.location.href;
const share_title = document.title;
   
const share_url_forx = share_url.replace(/%/g, "%25");
    // Pocketボタンを取得
    var pocketButton = document.querySelector('#footer-places-snsbuttonPocket a');


    // Pocketのシェア用URLを設定
const share_facebook = document.getElementById("js-share-facebook");
    var pocketShareUrl = 'https://getpocket.com/save?url=' + encodeURIComponent(currentPageUrl);
share_facebook.setAttribute("href", "https://www.facebook.com/share.php?u=" + share_url );


    // href属性にURLを設定
const share_twitter = document.getElementById("js-share-twitter");
    pocketButton.href = pocketShareUrl;
share_twitter.setAttribute("href","https://twitter.com/share?url=" + share_url_forx +"&text=" + share_title );


// Facebookボタンを取得
const share_line = document.getElementById("js-share-line");
    var facebookButton = document.querySelector('#footer-places-snsbuttonFacebook a');
share_line.setAttribute("href","https://social-plugins.line.me/lineit/share?url=" + share_url );


    // Facebookのシェア用URLを設定
const share_hatena = document.getElementById("js-share-hatena");
    var facebookShareUrl = 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(currentPageUrl);
share_hatena.setAttribute("href","https://b.hatena.ne.jp/entry/s/" + share_hostpath );


    // href属性にURLを設定
const share_inuser_pocket = document.getElementById("js-share-pocketurl");
    facebookButton.href = facebookShareUrl;
share_inuser_pocket.setAttribute("href","https://getpocket.com/edit?url=" + share_url );


// Twitterボタンを取得
const page_top_buttonnew = document.getElementById("pagetopbuttonnew");
    var twitterButton = document.querySelector('#footer-places-snsbuttonX a');
page_top_buttonnew.setAttribute("href","#" );


    // Twitterのシェア用URLを設定
})
    var twitterShareUrl = 'https://twitter.com/intent/tweet?url=' + encodeURIComponent(currentPageUrl) + '&text=' + encodeURIComponent(document.title);
 
    // href属性にURLを設定
    twitterButton.href = twitterShareUrl;
 
});
 
</ script>

2024年6月13日 (木) 07:04時点における最新版

/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */

window.addEventListener('load', function() {

const share_url = location.href;
const share_hostpath = location.host + location.pathname;
const share_title = document.title;
const share_url_forx = share_url.replace(/%/g, "%25");

const share_facebook = document.getElementById("js-share-facebook");
share_facebook.setAttribute("href", "https://www.facebook.com/share.php?u=" + share_url );

const share_twitter = document.getElementById("js-share-twitter");
share_twitter.setAttribute("href","https://twitter.com/share?url=" + share_url_forx +"&text=" + share_title );

const share_line = document.getElementById("js-share-line");
share_line.setAttribute("href","https://social-plugins.line.me/lineit/share?url=" + share_url );

const share_hatena = document.getElementById("js-share-hatena");
share_hatena.setAttribute("href","https://b.hatena.ne.jp/entry/s/" + share_hostpath );

const share_inuser_pocket = document.getElementById("js-share-pocketurl");
share_inuser_pocket.setAttribute("href","https://getpocket.com/edit?url=" + share_url );

const page_top_buttonnew = document.getElementById("pagetopbuttonnew");
page_top_buttonnew.setAttribute("href","#" );

})