この記事ã§ä¸»å¼µãã¦ããããã«ãåããã¨ã2度ããªãï¼Only and Only Onceãããã¯DRYï¼Don't Repeat Yourselfï¼ãã¨ç¡æ¡ä»¶ã§èãã¦ãã¾ãã¨ãéã«çç£æ§ã大ããä½ä¸ããã±ã¼ã¹ãããããããããã®è¨äºã®ãã¼ãã¯ä¸»ã«èªååã®è©±ã ããããã¯èªååã ãã§ãªããã½ããã¦ã§ã¢ã¢ã¸ã¥ã¼ã«ã®åå©ç¨ã«ã¤ãã¦ãåããã¨ãè¨ãããã½ããã¦ã§ã¢ããåå©ç¨å¯è½ãªå½¢ã§è¨è¨ãããããã©ã¬ãã«ãªã¢ã¼ããã¯ãã£ã«è¨è¨ããã³ã¹ãããããè¨è¨ãããã¨ã§å¾ãããã¡ãªãããä¸åãã¨ããã±ã¼ã¹ãªã©ããããã§ããã(ããã¯ãæè³å¹æã®åé¡ãªã®ã§ãæè³ããã¨ãæè³ãããã¯ç¦ç©ã¨ããã話ãããªãããã¼ã¿ã«ã¡ãªããã¨ãã¼ã¿ã«ã³ã¹ããè¨ç®ãã¦æè³ããã¨ãã話)ãã¨ãå°è¦æ¨¡ã®Webãµã¤ããããã£ã¨ä½ãå¿
è¦ãããã¨ããªã©ããã®å¾åãå¼·ããä½åãªå·¥æ°ãããã¦åå©ç¨å¯è½ã ã®ãã©ã¬ãã«ã ã®ã«è¨è¨ããã¨ããã§ããã¨ããèµ·ããç¶æ³ã®å¤åããã¯ããã«äºè¦ãããã©ã¬ãã«ã¢ã¼ããã¯ãã£ã®ç¯å²å
ã§èµ·ããã¨ã¯éããªãã®ã ããããå°ãã§ãé²ãããã«ãååãªç²¾åº¦ã§æªæ¥ãäºè¦ããããã®ãå
¥å¿µãªæ¤è¨ã«ã³ã¹ãã¨æéããããããããå ´åãæ³å®ããæè»ãªã¢ã¼ããã¯ãã£ã«è¨è¨ããã¨ãã¾ãã¾ããéçºã³ã¹ãã¯å¢å¤§ããå·¥æã¯é·ããªãããã¸ãã¹ã®æ©åæ§ã¯ä½ä¸ãããµã¼ãã¹å±éãé
ããªããããããäºè¦ãªãã¦ãã£ããã§ããããããã©ã¬ãã«ã¢ã¼ããã¯ãã£ãªã©æ¾æ£ãã¦ããã£ãã¨ä½ã£ã¦ãã¾ã£ãã»ããããã¼ã¿ã«ã³ã¹ãã¯å®ããæ©åçã§ãæè»æ§ã大ããã±ã¼ã¹ãªãã¦ãããããããããªã«ã大ããªå¤åãèµ·ãããããã®ã¨ãã¾ããæ¸ãç´ãã¦ãã¾ãã°ãããå°è¦æ¨¡ã®ãµã¤ãã®å ´åããã©ã¬ãã«ã¢ã¼ããã¯ãã£ãªã©ã«ãã ãããªããã°ãéçºã³ã¹ãã¯ããã£ã¨å°ãããªãã®ã ããããªã«ãããããããã®ã¯ããã©ã¬ãã«ã¢ã¼ããã¯ãã£ã¨ãã檻ã«çºæ³ãéãè¾¼ãããã¦ãç¡æèã®ãã¡ã«ããã®æ å
ã§ãããã¸ãã¹ãå±éã§ããªããªã£ã¦ãã¾ãã¨ãããã¨ã ãåå©ç¨å¯è½ãªæè»ãªãã¬ã¼ã ã¯ã¼ã¯ã¯ãç²¾ç¥ã®ç¢çãªã®ã ããã¡ãããDIã§ãEJBã§ããªãã§ã使ã£ã¦ããã©ã¬ãã«ã¢ã¼ããã¯ãã£ã«ããæ¹ãããã¼ã¿ã«ã³ã¹ãã¯å®ããªãå ´åã ã£ã¦ããããããã大è¦æ¨¡ãªã·ã¹ãã ãªãã¦ãããã¦ãããã ãã§ãããã®çºæ³ãã¿ã¼ã³ãã®ãã®ã«ã¹ã±ã¼ã©ããªãã£ã¼ãããã»ã©ãããããããªãã¨ãããã¨ã¯ããã£ã¨æèãããã¹ãã ã¨æããããã¯ãã¾ãã§ãä¸æ¥ã«ãããã1000ã¢ã¯ã»ã¹ãããªãä¸å°ä¼æ¥ã®Webãµã¼ãã®æ§æãè¨è¨ããã®ã«ãYahooã®ãµã¼ãã¼æ§æã®è¨è¨ã«ããã¦éè¦ãªæè¨ãçµé¨åããã®ã¾ã¾é©ç¨ãããããªãã®ãªã®ãããªããã¨æãã®ã ã
';
break;
case 'horizontal':
if(a.imgUrl){
imgCode = '
';
}
code = '
'+
'
';
code += imgCode;
if(a.label) code += ''+a.label+'';
code += '
';
break;
default:
error('ãããªviewç¥ãããã'+a.view);
}
return code;
}
function toImgUrl(super_kind){
var HFotoTbl = {
tw: '20180803102713',
fb: '20180803102707',
hb: '20180803102710',
line: '20180803102711',
pocket: '20180803102712',
feedly: '20180803102708',
hate_blo: '20180803102709',
note: '20180821103319'
};
var hf_id = HFotoTbl[super_kind];
if(!hf_id){
log('ãã®super kind:'+super_kind+'ã®ã¯ã¦ãªãã©ãIDãç»é²ããã¦ãªããã');
return null;
}
return hfid2url(hf_id);
}
var HFDayRE = /^\d{8}/;
function hfid2url(hf_id){
var sa = HFDayRE.exec(hf_id);
return 'https://cdn-ak.f.st-hatena.com/images/fotolife/f/fromdusktildawn/'+
sa[0] + '/' + hf_id + '.png';
}
function setButton(a){
var pos = isString( a.pos ) ? $(a.pos) : a.pos;
a.imgUrl = toImgUrl(a.superKind);
var html = makeButtonHtml(a);
var meth = a.insertMethod;
if(!meth) meth = 'after';
pos[meth](html);
$('#'+a.id).on('click',function(){
window.location.href = a.url;
});
}
function asurePrefix(a){
if(!a.prefix){
var random = Math.floor( Math.random() * 110000000000000 );
a.prefix = 'random-'+random+'-';
}
}
function setSocialBts(a, defs){
var title = getPageTitle(a.title);
var url = getPageUrl();
if(!a.insertMethod) a.insertMethod = 'after';
var b = $.extend(true, {}, a);
asurePrefix(b);
var i=0;
b.title = encodeURIComponent(title);
b.url = encodeURIComponent(url);
var pos = b.pos;
var id;
defs.forEach(function(def){
var c = $.extend(true, {}, b);
var kind = def[0];
c.label = def[1];
id = c.id = c.prefix + kind;
c.pos = pos;
c.kind = kind;
var superKind = SuperKindTbl[kind];
c.superKind = superKind ? superKind : kind;
var site = SITE_NAME;
if(site == 'fromd.hateblo.jp') site = 'www.furomuda.com';
switch(kind){
case 'tw':
c.url = 'http://twitter.com/share?url=' + c.url +
'&text='+c.title+encodeURIComponent(' @fromdusktildawn ')+
'&related=fromdusktildawn';
break;
case 'fb':
c.url = 'https://www.facebook.com/sharer/sharer.php?u='+c.url;
break;
case 'hb':
c.url = 'http://b.hatena.ne.jp/add?mode=confirm&url=' + c.url +
'&title='+c.title;
break;
case 'line':
c.url = 'https://social-plugins.line.me/lineit/share?url='+c.url;
break;
case 'pocket':
c.url = 'http://getpocket.com/edit?url='+c.url+
'&title='+c.title;
break;
case 'twFollow':
c.url = "https://twitter.com/intent/follow?screen_name=fromdusktildawn";
break;
case 'hbFollow':
c.url = "http://b.hatena.ne.jp/fromdusktildawn/";
break;
case 'fbPage':
c.url = 'https://www.facebook.com/furomuda/';
break;
case 'fbGroup':
c.url = "https://www.facebook.com/groups/426678561170457/";
break;
case 'hate_blo':
c.url = "https://blog.hatena.ne.jp/fromdusktildawn/"+ site + "/subscribe";
break;
case 'note':
c.url = 'https://note.mu/fromdusktildawn';
break;
case 'feedly':
c.url = 'https://feedly.com/i/subscription/feed/'+
encodeURIComponent('https://'+site+'/feed');
break;
default:
console.log('ãããªkindããããã:'+kind);
}
setButton(c);
if(c.insertMethod == 'after'){
pos = '#'+id;
}
});
return id;
}
function make2ColButtons(a, ldef, rdef){
var col_ids = make2ColFrame(a);
var lpos = '#'+col_ids.l;
var rpos = '#'+col_ids.r;
a.pos = lpos;
setSocialBts(a, ldef);
a.pos = rpos;
setSocialBts(a, rdef);
return col_ids.frame_id;
}
function make2ColFrame(a){
asurePrefix(a);
var LEFT_SUFFIX='-left-cell';
var RIGHT_SUFFIX='-right-cell';
var prefix = a.prefix;
var frame_id = prefix+'-frame';
var left_id = prefix+LEFT_SUFFIX;
var right_id = prefix+RIGHT_SUFFIX;
var frame = '
';
$(a.pos).after(frame);
return {l: left_id, r: right_id, frame: frame_id};
}
// PCä¾åã®ã³ã¼ãï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼
var archiveEntries = $(".archive-entry");
if(archiveEntries.length){
archiveEntries.each(function(){
var archiveEntry = $(this)
var entryTitleLink = archiveEntry.find(".entry-title-link");
var entryHref = entryTitleLink.attr("href")
var entryDescription = archiveEntry.find(".entry-description");
var bookmarkHtml = "
"
entryTitleLink.append(bookmarkHtml);
var readMoreHtml = "
ãã£ã¨èªã";
entryDescription.append(readMoreHtml);
var bookmarkCounter = archiveEntry.find(".bookmark-widget-counter");
bookmarkCounter.hide();
var starContainer = archiveEntry.find(".star-container");
var bigBookmarkCounter = archiveEntry.find(".big-bookmark-counter");
starContainer.insertAfter(bigBookmarkCounter);
function makeStarCountBig(){
var starCount = archiveEntry.find(".hatena-star-inner-count");
if(starCount.length){
starCount.css('font-size','140%');
} else {
setTimeout(makeStarCountBig,300);
}
}
makeStarCountBig();
});
// ãã©ãã¼ãã¦ããããã¿ã³ããµã¤ããã¼ã«è¨ç½®
var btPos = '.profile-description';
var startPos = 'my-buttons-pos';
$(btPos).after(
'
'
);
twPos = '#'+startPos;
var last_id = setSocialBts({pos: twPos}, [
['twFollow', 'ãã©ãã¼ãã'],
['note', 'ãã©ãã¼ãã'],
['hate_blo', 'èªè
ã«ãªã'],
['feedly', 'è³¼èªãã'],
['hbFollow', 'ãã©ãã¼ãã'],
['fbPage', 'facebookãã¼ã¸'],
['fbGroup', 'facebookã°ã«ã¼ã']
]);
var paddingBottomId = 'my-padding-bottom-id';
$('#'+ last_id).after(
'
'
);
var pos = $('#main-inner');
var img_url = hfid2url('20201008224538');
//var img_url = hfid2url('20201003093324');
//var img_url = "https://storage.googleapis.com/hateblog/img/prj/book/learning/learning_blog_top.png";
pos.before(
'
'
);
/*
var free_a_begin = '
';
var book_a_begin = '';
pos.before(
''+
''+
''+
free_a_begin+
''+
' | '+
''+
'ãµããã æ¬ã®ã¬ãããªï¼ç« åãç¡æã®Webè¨äºã¨ãã¦èªãã¾ãï¼
'+
free_a_begin+
'ç¡æçãèªãã«ã¯ãããã¯ãªãã¯'+
' | '+
'
'+
''+
''+
book_a_begin+
'æ¬ã§èªã¿ããæ¹ã¯ãããã¯ãªãã¯'+
' |
'+
'
'
);
*/
} else {
var title = $(".entry-header .entry-title a");
if(title) {
var titleHref = title.attr("href")
var bookmarkHtml = "
"
var entryTitle =title.parent();
entryTitle.append(bookmarkHtml);
entryTitle.css('font-size','150%');
function addHeadStar(){
var starCountCheck = $(".entry-footer .hatena-star-star-container .hatena-star-inner-count");
if(starCountCheck.length){
var starContainer = $(".entry-footer .hatena-star-star-container");
if(starContainer){
var starCount = starContainer.find(".hatena-star-inner-count");
starCount.css('font-size','24px');
var starClone = starContainer.clone(true,true);
var bigBookmarkCounter = title.parent().find(".big-bookmark-counter");
starClone.insertAfter(bigBookmarkCounter);
starCount = starClone.find(".hatena-star-inner-count");
starCount.on('click',function(){
alert('âãä»ãã人ã®ä¸è¦§ãè¦ãã«ã¯ããã®è¨äºã®ä¸é¨ã®âæ°ãã¯ãªãã¯ãã¦ãã ããã');
$("html,body").animate({scrollTop:$('.entry-footer .hatena-star-star-container').offset().top-100});
});
var bt = starClone.find(".hatena-star-add-button");
bt.on('click',function(){
alert('âãä»ããã«ã¯ããã®è¨äºã®ä¸é¨ã®ãâ+ããã¿ã³ãã¯ãªãã¯ãã¦ãã ããã');
$("html,body").animate({scrollTop:$('.entry-footer .hatena-star-star-container').offset().top-100});
});
} else{
setTimeout(addHeadStar,300);
}
} else {
setTimeout(addHeadStar,300);
}
}
addHeadStar();
procSpecialMarkers();
var param = {
pos: 'footer.entry-footer p.entry-footer-section',
title: title.text()
}
make2ColButtons(param,
[
['tw', 'ãã®è¨äºããã¤ã¼ããã'],
['hb', 'ãã®è¨äºãããã¯ãã¼ã¯ãã'],
['pocket', 'ãã®è¨äºãå¾ã§èªã']
],
[
['fb', 'ãã®è¨äºãã·ã§ã¢ãã'],
['line', 'ãã®è¨äºãLINEã§éã']
]
);
// ãã©ãã¼ãã¦ããããã¿ã³ãä¸é¨ã«è¨ç½®
param = {
pos: 'footer.entry-footer div.social-buttons'
};
var frame_id = make2ColButtons(param,
[
['twFollow', 'ãã©ãã¼ãã'],
['hate_blo', 'èªè
ã«ãªã'],
['hbFollow', 'ãã©ãã¼ãã'],
['fbGroup', 'facebookã°ã«ã¼ã']
],
[
['note', 'ãã©ãã¼ãã'],
['feedly', 'è³¼èªãã'],
['fbPage', 'facebookãã¼ã¸']
]
);
}
}
// è¨äºä¸è¦§ãã¼ã¸ã¨ãåä½è¡¨ç¤ºãã¼ã¸ã®ä¸¡æ¹ã«å
±éããã³ã¼ã ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼
var d = $('div.date a time');
d.css({
'color': '#aaa',
'font-weight': 'normal'
});
if(IS_ANNEX){
var link = $('h1#title a'); // ããã°ã¿ã¤ãã«ã®ãªã³ã¯
link.attr("href", 'https://www.furomuda.com/');
}
})