Last active
June 17, 2017 14:19
-
-
Save yumetodo/15b51e1ebd8b86cd533e6c5087009ab2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (typeof YAHOO == "undefined" || !YAHOO) { | |
var YAHOO = {}; | |
} | |
(function() { | |
function BottomSheetAndroid(e, t) { | |
var i = this, | |
n = str2Dom(TMPL.BS_AND); | |
i.bottomSheet = n, i.relatedLinks = n.querySelector("#yjDirectSLinkRelated"), i.directLinkInput = n.querySelector("#yjDirectSLinkIpt"), i.linker = e, i.logger = t, i.eventDetacher = [], i.setup() | |
} | |
function BottomSheetIPhone(e, t) { | |
var i = this, | |
n = str2Dom(TMPL.BS_INPUT), | |
r = str2Dom(TMPL.BS_IPN); | |
i.topInputBox = n, i.bottomSheet = r, i.relatedLinks = r.querySelector("#yjDirectSLinkRelated"), i.directLinkInput = r.querySelector("#yjDirectSLinkIpt"), i.topInputBoxInput = n.querySelector("#yjDirectSLinkIpt2"), i.linker = e, i.query = "", i.linkQuery = "", i.index = -1, i.adjustTopInputBoxPos = function() { | |
i.topInputBox.style.top = window.scrollY + "px" | |
}, i.logger = t, i.eventDetacher = [], i.setup() | |
} | |
function BottomSheetPC(e, t) { | |
var i = this, | |
n = str2Dom(TMPL.BS_PC); | |
i.bottomSheet = n, i.linker = e, i.query = "", i.index = -1, i._xposition = 0, i._yposition = 0, i.logger = t, i.eventDetacher = [], i.setup() | |
} | |
function Linker(e, t, i, n) { | |
var r = this, | |
o = e.HighlightSearchWords, | |
a = isPC() ? 10 : 5; | |
r.linkClass = "yjDirectSLinkHl", void 0 !== t && "" !== t && "underline" !== t && (r.linkClass = "yjDirectSLinkHl_" + t), r.linkCount = i.linkCount || a, r.fr = o.ServiceSpecific.Fr + (i.bucketID ? "_" + i.bucketID : "") + (i.addFR ? "_" + i.addFR : ""), r.direct = o.Result, r.slink = o.ServiceSpecific.SearchLink, r.showBottomsheet = n | |
} | |
function Logger(e, t) { | |
var i = this; | |
i.beaconer = YAHOO.i13n.Beaconer({ | |
beacon_server: CONST.URL_BEACON, | |
keys: e, | |
link_data: t, | |
spaceid: e.spaceid, | |
https: !0 | |
}) | |
} | |
function LoggerWrapper(e) { | |
var t = this; | |
t.pageParams = e | |
} | |
function loadResources(e, t) { | |
for (var i, n, r = document.head || document.getElementsByTagName("head")[0], o = 0, a = !0, s = function(i) { | |
o += 1, i && "error" === i.type && (a = !1), e.length <= o && t(a) | |
}, c = (isIE(), function() { | |
s() | |
}), d = 0; d < e.length; d += 1) i = e[d], ("css" === i.type || "js" === i.type) && ("js" === i.type ? (n = document.createElement("script"), n.setAttribute("src", i.src)) : (n = document.createElement("link"), n.setAttribute("type", "text/css"), n.setAttribute("rel", "stylesheet"), n.setAttribute("href", i.src)), isIE() < 10 ? setTimeout(c, 300) : !isPC() && (isIOS() < 6 || isAndroid()) && "css" === i.type ? setTimeout(s(), 300) : n.onload = n.onerror = s, r.appendChild(n)) | |
} | |
function isAndroid() { | |
var e, t, i = navigator.userAgent; | |
return /Android/i.test(i) ? (e = i.match(/Android (\d+)\.(\d+)\.?(\d+)?/), t = e[1] + "." + e[2], e[3] && (t += "." + e[3]), parseFloat(t)) : 0 | |
} | |
function isIOS() { | |
var e, t, i = navigator.userAgent; | |
return /iP(hone|od touch|ad);/i.test(i) ? (e = i.match(/OS (\d+)_(\d+)_?(\d+)?/), t = e[1] + "." + e[2], e[3] && (t += "." + e[3]), parseFloat(t)) : 0 | |
} | |
function isIE() { | |
var e = navigator.userAgent, | |
t = e.match(/MSIE ([^;]*)|Trident.*; rv:([0-9.]+)/), | |
i = !0; | |
return t ? parseFloat((t[1] || t[2]).replace(new RegExp("\\.", "g"), function() { | |
var e = i ? "." : ""; | |
return i = !1, e | |
})) : 0 | |
} | |
function isPC() { | |
return isAndroid() || isIOS() ? 0 : 1 | |
} | |
function isSSH() { | |
var e = 0; | |
return "https:" === document.location.protocol && (e = 1), e | |
} | |
function str2Dom(e) { | |
var t = document.createElement("div"); | |
return t.innerHTML = e, t.firstChild | |
} | |
function range(e, t) { | |
var i, n = []; | |
for (i = e; t >= i; i++) n.push(i); | |
return i | |
} | |
function jsonpRequest(e, t) { | |
var i = document.createElement("script"); | |
YAHOO.JP.srch.dlink.cb = t, i.setAttribute("async", !0), i.setAttribute("src", e.replace("{{callback}}", "YAHOO.JP.srch.dlink.cb")), isIE() < 10 ? (document.head || document.getElementsByTagName("head")[0]).appendChild(i) : document.head.appendChild(i) | |
} | |
function checkUA() { | |
var e = "", | |
t = navigator.userAgent; | |
return /jp\.co\.yahoo\.android\.yjtop/.test(t) && (e = "yjapp_and"), /YJApp-ANDROID jp\.co\.yahoo\.android\.ybrowser/.test(t) && (e = "ybr"), e | |
} | |
function checkAppDomain() { | |
var e = "", | |
t = window.location.href; | |
return /^https?:\/\/matome\.naver\.jp\/m\/odai/.test(t) ? e = "nvm" : /^https?:\/\/beauty\.yahoo\.co\.jp\/([^\/]+)\/articles/.test(t) ? e = "bty" : /^https?:\/\/blogs\.yahoo\.co\.jp/.test(t) ? e = "blg" : /^https?:\/\/ameblo\.jp\/([^\/]+)\/entry-\d+/.test(t) && (e = "amb"), e | |
} | |
function init() { | |
var e = isSSH() ? CONST.IMG_CENTER_SSH : CONST.IMG_CENTER, | |
t = isPC() ? CONST.CSS_PATH_PC : CONST.CSS_PATH, | |
i = CONST.ULT_JS_PATH, | |
n = isSSH() ? CONST.API_PATH_SSH : CONST.API_PATH; | |
t = e + t, i = e + i; | |
var r = YAHOO.JP.srch.dlink.PARAMS, | |
o = Math.floor(10 * Math.random()); | |
("nws" === r.serviceCode || "cbr" === r.serviceCode || "net" === r.serviceCode) && 1 === o && (n = CONST.API_PATH_SSH), loadResources([{ | |
type: "css", | |
src: t | |
}, { | |
type: "js", | |
src: i | |
}], function(e) { | |
if (e) { | |
var t = YAHOO.JP.srch.dlink.PARAMS, | |
i = n.replace("{{appid}}", t.appID || t.eappID).replace("{{service}}", t.serviceCode).replace("{{article_id}}", t.articleID); | |
if (5 !== t.linkCount && (i = i + "&count=" + t.linkCount), "amb" === t.serviceCode) { | |
var r = window.location.protocol + "//" + window.location.host + window.location.pathname; | |
i = i + "&href=" + encodeURIComponent(r) | |
} | |
jsonpRequest(i, applyLink) | |
} | |
}) | |
} | |
function applyLink(e) { | |
var t, i, n = { | |
nws: ".articleDefault .pgraphWrap .text,.articleDefault > .text,.articleDefault", | |
cbr: "#detail .detailQuestion .mainSentence .mainText,#detail .detailBa .mainSentence .mainText", | |
net: ".cpDraft > p,.cpDraft > .rest-article > p", | |
nvm: ".MdMTM02Body > .MdMTM03Item > .mdMTM03Inner > p.mdMTM03Ttl,.MdMTM02Body > .MdMTM03Item > .mdMTM03Inner > p.mdMTM03Txt,.MdMTM02Body > .MdMTM03Item > .mdMTM03Inner > .mdMTM03Row > p.mdMTM03TwitterPost,.MdMTM02Body > .MdMTM03Item > .mdMTM03Inner > p.mdMTM03Comment", | |
bty: ".detail-article > #arcl > p,.detail-article > #arcl > .rest-article > p", | |
blg: "#atcl > .richTextArea,#atcl > .richTextArea font,#atcl > .richTextArea div,#atcl > .richTextArea span,#atcl > .richTextArea b", | |
amb: "#app div._2M0-mQO6,#app div._2M0-mQO6 div,#app div._2M0-mQO6 span" | |
}, | |
r = { | |
cbr: ".mdPstdQstn .clrfx .usrQstn .ptsQes p,.mdPstdBA .clrfx .usrQstn .ptsQes p" | |
}, | |
o = YAHOO.JP.srch.dlink.PARAMS, | |
a = new LoggerWrapper({ | |
rpdprop: "entrypoint", | |
service: o.serviceCode, | |
spaceid: o.spaceID, | |
vtestid: o.bucketID, | |
article: o.articleID | |
}), | |
s = isAndroid(), | |
c = isIOS(), | |
d = isPC(), | |
l = d ? r : n, | |
h = document.querySelectorAll(l[o.serviceCode]), | |
p = "undefined" != typeof o.bottomSheet ? o.bottomSheet : !0, | |
u = window.navigator.userAgent; | |
p && (s && 4 > s || c && 5 > c) && (p = !1); | |
var m = new Linker(e, o.highlightStyle, o, p); | |
if (t = m.makeDirectLink(h), !t || t.length <= 0) { | |
if (CONST.ALERT) { | |
var g; | |
g = "リンクを作成できなかった", alert(g) | |
} | |
} else if (p && s >= 5 && 6 > s && u.indexOf("Nexus 5") >= 0 && u.indexOf("jp.co.yahoo.android.ybrowser") >= 0 && (p = !1), a.setupLinkLogger(t.length), a.sendLinkViewLog(), a.attachLinkClickLog(t, !p), p) i = d ? new BottomSheetPC(m, a, o.linkCount) : new BottomSheetIPhone(m, a, o.linkCount), t.forEach(function(e, t) { | |
e.addEventListener("click", function(n) { | |
var r = n.target, | |
o = r.getAttribute("title"), | |
a = { | |
x: n.clientX, | |
y: n.clientY | |
}; | |
YAHOO.JP.srch.dlink.istap = !0, i.returnIndex() !== t ? (d && (i.hide(), i.setPosition(e, a)), i.setIndex(t), i.show(o)) : (i.setIndex(-1), i.hide()), n.preventDefault() | |
}, !1) | |
}), d && document.body.addEventListener("click", function(e) { | |
var t = e.target.className; | |
"yjDirectSLinkHl" !== t && (i.setIndex(-1), i.hide()) | |
}, !1), YAHOO.JP.srch.dlink.close = function() { | |
i.setIndex(-1), i.hide() | |
}; | |
else if ("nws" === o.serviceCode) { | |
var f = document.getElementById("pgraphCap"); | |
f.innerHTML = "※記事本文中のリンクはYahoo!検索が提供する機能であり、記事提供社とは関係ありません", f.className = "articleDefaultCap" | |
} | |
} | |
var CONST = { | |
IMG_CENTER: "http://i.yimg.jp/", | |
IMG_CENTER_SSH: "https://s.yimg.jp/", | |
CSS_PATH: "/images/search/slink/direct/sp/1.0.0/css/direct_content_sp.css", | |
CSS_PATH_PC: "/images/search/slink/direct/pc/1.0.0/css/direct_content_pc.css", | |
ULT_JS_PATH: "/images/rapid/1.5.0/ult.js", | |
MAIN_JS_PATH: "/images/search/slink/direct/sp/1.0.0/js/directlink.min.js", | |
API_PATH: "http://entrypoint.search.yahooapis.jp/v1/link/highlight_words?&appid={{appid}}&.src={{service}}&article_id={{article_id}}&callback={{callback}}", | |
API_PATH_SSH: "https://slink-search.yahooapis.jp/v1/link/highlight_words?&appid={{appid}}&.src={{service}}&article_id={{article_id}}&callback={{callback}}", | |
BEACON_SERVER: "ybx.yahoo.co.jp", | |
CLASS_CLOSE: "animationClose", | |
CLASS_OPEN: "animationOpen", | |
ALERT: !1 | |
}, | |
TMPL = { | |
BS_AND: ['<div id="yjDirectSLink" class="animationOpen">', '<div id="yjDirectSLinkHd">', "<p>Yahoo! JAPAN</p>", '<a href="javascript:void(0)" id="yjDirectSLinkExpand" class="yjDirectSLinkExp">閉じる</a>', "</div>", '<div id="yjDirectSLinkSearchBox">', '<form id="yjDirectSLinkFrm" action="" method="get">', '<div id="yjDirectSLinkWrap">', '<input type="search" name="" value="" id="yjDirectSLinkIpt" autocomplete="off" autocorrect="off" autocapitalize="off" placeholder="キーワードを入力">', '<div id="yjDirectSLinkClearBtn"><span> </span></div>', "</div>", '<input type="submit" id="yjDirectSLinkSbmtBtn" value="検索">', "</form>", "</div>", '<div class="yjDirectSLinkSm">', '<p id="yjDirectSLinkRelated"></p>', "</div>", '<div class="yjDirectLinkMsg">', "<p>※本文中リンクはヤフー提供の機能で、記事提供社とは関係ありません</p>", "</div>", "</div>"].join(""), | |
BS_IPN: ['<div id="yjDirectSLink" class="animationOpen">', '<div id="yjDirectSLinkHd">', "<p>Yahoo! JAPAN</p>", '<a href="javascript:void(0)" id="yjDirectSLinkExpand" class="yjDirectSLinkExp">閉じる</a>', "</div>", '<div id="yjDirectSLinkSearchBox">', '<form id="yjDirectSLinkFrm" action="" method="get">', '<div id="yjDirectSLinkWrap">', '<div id="yjDirectSLinkIpt"></div>', '<div id="yjDirectSLinkClearBtn"><span> </span></div>', "</div>", '<input type="submit" id="yjDirectSLinkSbmtBtn" value="検索">', "</form>", "</div>", '<div class="yjDirectSLinkSm">', '<p id="yjDirectSLinkRelated"></p>', "</div>", '<div class="yjDirectLinkMsg">', "<p>※本文中リンクはヤフー提供の機能で、記事提供社とは関係ありません</p>", "</div>", "</div>"].join(""), | |
BS_INPUT: ['<div id="yjDirectSLink2" style="display: block; top: 0px;">', '<div id="yjDirectSLinkSearchBox2">', '<form id="yjDirectSLinkFrm2" action="" method="get">', '<div id="yjDirectSLinkWrap2">', '<input type="search" name="" value="" id="yjDirectSLinkIpt2" autocomplete="off" autocorrect="off" autocapitalize="off" placeholder="キーワードを入力" autofocus>', "</div>", '<input type="submit" id="yjDirectSLinkSbmtBtn2" value="検索">', "</form>", "</div>", "</div>"].join(""), | |
BS_PC: ['<div id="yjDirectSLink" style="display: block">', '<a href="javascript:void(0);" target="_blank">Yahoo!検索</a>', "</div>"].join("") | |
}; | |
BottomSheetAndroid.prototype = { | |
setup: function() { | |
var e = this, | |
t = e.logger, | |
i = e.bottomSheet, | |
n = e.directLinkInput, | |
r = i.querySelector("#yjDirectSLinkExpand"), | |
o = i.querySelector("#yjDirectSLinkSbmtBtn"), | |
a = i.querySelector("#yjDirectSLinkClearBtn"); | |
i.addEventListener("touchmove", function(e) { | |
e.preventDefault() | |
}, !1), r.addEventListener("click", function(t) { | |
t.preventDefault(), e.hide() | |
}, !1), o.addEventListener("click", function(i) { | |
i.preventDefault(), e.hide(), t.loggerBtms.sendClickLog(t.linkParamsBtms[0].links[1].params, e.linker.getLinkUrl(e.directLinkInput.value)) | |
}), a.addEventListener("click", function() { | |
n.value = "" | |
}), t.setupBottomSheetLogger(), t.attachBottomSheetLogs(r) | |
}, | |
hide: function() { | |
var e = this, | |
t = e.bottomSheet; | |
YAHOO.JP.srch.uho && YAHOO.JP.srch.uho.show instanceof Function && YAHOO.JP.srch.uho.show(), t.className = CONST.CLASS_CLOSE, setTimeout(function() { | |
-1 !== t.className.indexOf(CONST.CLASS_CLOSE) && e.detach() | |
}, 500) | |
}, | |
detach: function() { | |
var e = this, | |
t = e.bottomSheet, | |
i = t.parentNode; | |
i && i.removeChild(t) | |
}, | |
show: function(e) { | |
var t, i, n = this, | |
r = n.logger, | |
o = n.linker.getRelated(e), | |
a = n.bottomSheet, | |
s = n.relatedLinks, | |
c = [], | |
d = function() { | |
n.hide() | |
}; | |
if (n.directLinkInput.value = e, s.innerHTML = "", o.length > 0) { | |
for (s.style.display = "block", i = 0; i < o.length && 3 > i; i++) t = n.createRelatedLink(o[i], e), s.appendChild(t), c.push(t), t.addEventListener("click", d, !1); | |
r.setupRelatedLogger(i), r.sendRelatedViewLog(), r.attachLogsRelated(c) | |
} else s.style.display = "none"; | |
r.sendBtmsViewLog(), a.className = CONST.CLASS_OPEN, a.style.bottom = "", document.body.appendChild(a), YAHOO.JP.srch.uho && YAHOO.JP.srch.uho.hide instanceof Function && YAHOO.JP.srch.uho.hide() | |
}, | |
createRelatedLink: function(e, t) { | |
var i = document.createElement("a"); | |
return i.className = "yjDirectLinkTag", i.innerHTML = e.replace(t, "<em>" + t + "</em>"), i.href = this.linker.getLinkUrl(e), i | |
} | |
}, BottomSheetIPhone.prototype = { | |
setup: function() { | |
var e = this, | |
t = e.logger, | |
i = e.bottomSheet, | |
n = i.querySelector("#yjDirectSLinkExpand"), | |
r = i.querySelector("#yjDirectSLinkSbmtBtn"), | |
o = i.querySelector("#yjDirectSLinkClearBtn"); | |
i.addEventListener("touchmove", function(e) { | |
e.preventDefault() | |
}, !1), n.addEventListener("click", function(t) { | |
t.preventDefault(), e.hide() | |
}, !1), r.addEventListener("click", function(i) { | |
i.preventDefault(), e.hide(); | |
var n = ""; | |
e.query !== e.linkQuery && (n = "_re"), t.loggerBtms.sendClickLog(t.linkParamsBtms[0].links[1].params, e.linker.getLinkUrl(e.query, n)) | |
}), o.addEventListener("click", function() { | |
e.setQuery("") | |
}), e.setupTopInputBox(t), t.setupBottomSheetLogger(), t.attachBottomSheetLogs(n) | |
}, | |
setupTopInputBox: function(e) { | |
var t = this, | |
i = t.topInputBox, | |
n = i.querySelector("#yjDirectSLinkSbmtBtn2"), | |
r = t.topInputBoxInput, | |
o = t.directLinkInput, | |
a = document.body, | |
s = !1, | |
c = function() { | |
s || (t.setQuery(r.value), a.contains(i) && a.removeChild(i), t.bottomSheet.className = "", t.attach(), window.removeEventListener("scroll", t.adjustTopInputBoxPos)) | |
}, | |
d = function(n) { | |
n.preventDefault(), a.removeChild(i); | |
var o = ""; | |
r.value !== t.linkQuery && (o = "_re"), s = !0, e.loggerBtms.sendClickLog(e.linkParamsBtms[0].links[1].params, t.linker.getLinkUrl(r.value, o)) | |
}; | |
o.addEventListener("click", function(e) { | |
e.preventDefault(), t.detach(), t.adjustTopInputBoxPos(), a.appendChild(i), s = !1, window.removeEventListener("scroll", t.adjustTopInputBoxPos), window.addEventListener("scroll", t.adjustTopInputBoxPos), r.focus(), setTimeout(function() { | |
t.adjustTopInputBoxPos() | |
}, 500) | |
}), i.addEventListener("touchstart", function(e) { | |
e.target === i && (e.preventDefault(), r.blur(), c()) | |
}), n.addEventListener("touchstart", d), n.addEventListener("click", d), r.addEventListener("blur", function() { | |
setTimeout(c, 500) | |
}) | |
}, | |
hide: function() { | |
var e = this, | |
t = e.bottomSheet; | |
YAHOO.JP.srch.uho && YAHOO.JP.srch.uho.show instanceof Function && YAHOO.JP.srch.uho.show(), t.className = CONST.CLASS_CLOSE, e.index = -1, setTimeout(function() { | |
-1 !== t.className.indexOf(CONST.CLASS_CLOSE) && e.detach() | |
}, 500) | |
}, | |
detach: function() { | |
var e = this, | |
t = e.bottomSheet, | |
i = t.parentNode; | |
i && i.removeChild(t) | |
}, | |
attach: function() { | |
document.body.appendChild(this.bottomSheet) | |
}, | |
show: function(e) { | |
var t, i, n = this, | |
r = n.logger, | |
o = n.linker.getRelated(e), | |
a = n.bottomSheet, | |
s = n.relatedLinks, | |
c = [], | |
d = function() { | |
n.hide() | |
}; | |
if (n.setQuery(e), n.linkQuery = e, s.innerHTML = "", o.length > 0) { | |
for (s.style.display = "block", i = 0; i < o.length && 3 > i; i++) t = n.createRelatedLink(o[i], e), s.appendChild(t), c.push(t), t.addEventListener("click", d, !1); | |
r.setupRelatedLogger(i), r.sendRelatedViewLog(), r.attachLogsRelated(c) | |
} else s.style.display = "none"; | |
r.sendBtmsViewLog(), YAHOO.JP.srch.uho && YAHOO.JP.srch.uho.hide instanceof Function && YAHOO.JP.srch.uho.hide(), YAHOO.JP.idpf && YAHOO.JP.idpf.loginPromo && YAHOO.JP.idpf.loginPromo.hide instanceof Function && YAHOO.JP.idpf.loginPromo.hide(), a.className = CONST.CLASS_OPEN, a.style.bottom = "", n.attach(), (void 0 === YAHOO.JP.srch.nhighlight.istap || void 0 !== YAHOO.JP.srch.nhighlight.istap && YAHOO.JP.srch.nhighlight.istap !== !0) && (YAHOO.JP.srch.dlink.istap = !1) | |
}, | |
setQuery: function(e) { | |
var t = this; | |
t.query = e, t.directLinkInput.innerHTML = e, t.topInputBoxInput.value = e | |
}, | |
createRelatedLink: function(e, t) { | |
var i = document.createElement("a"); | |
return i.className = "yjDirectLinkTag", i.innerHTML = e.replace(t, "<em>" + t + "</em>"), i.href = this.linker.getLinkUrl(e), i | |
}, | |
returnIndex: function() { | |
return this.index | |
}, | |
setIndex: function(e) { | |
this.index = e | |
} | |
}, BottomSheetPC.prototype = { | |
setup: function() { | |
var e = this, | |
t = e.logger, | |
i = e.bottomSheet; | |
i.addEventListener("click", function(i) { | |
i.preventDefault(), e.hide(), t.loggerBtms.sendClickLog(t.linkParamsBtms[0].links[0].params, e.linker.getLinkUrl(e.query)) | |
}), t.setupBottomSheetLoggerPC() | |
}, | |
attach: function() { | |
document.body.appendChild(this.bottomSheet) | |
}, | |
detach: function() { | |
var e = this, | |
t = e.bottomSheet, | |
i = t.parentNode; | |
i && i.removeChild(t) | |
}, | |
hide: function() { | |
var e = this; | |
e.detach() | |
}, | |
show: function(e) { | |
var t, i = this, | |
n = i.bottomSheet, | |
r = i.logger; | |
i.setQuery(e), r.sendBtmsViewLog(), t = n.getElementsByTagName("a"), t[0].href = this.linker.getLinkUrl(e), n.style.left = i._xposition + "px", n.style.top = i._yposition + "px", i.attach() | |
}, | |
setPosition: function(e, t) { | |
var i, n, r, o, a, s = this, | |
c = { | |
width: 130, | |
height: 48 | |
}, | |
d = e.getBoundingClientRect(), | |
l = e.getClientRects(), | |
h = window.pageYOffset + $(window).height(), | |
p = "undefined" != typeof e.closest, | |
u = !1; | |
if (l.length > 1) | |
for (a = 0; a < l.length; a++) | |
if (t.y < l[a].bottom) { | |
d = l[a]; | |
break | |
} | |
isIE() ? (i = e.parentElement, void 0 !== i && (u = !0)) : p && (i = e.closest("div"), void 0 !== i && (u = !0)), n = u ? window.pageXOffset + i.getBoundingClientRect().right : window.pageXOffset + d.right, r = d.right + window.pageXOffset - 20, r + c.width > n && (r = n - c.width), o = d.bottom + window.pageYOffset + 3, o + c.height > h && (o = d.top + window.pageYOffset - c.height), s._xposition = r, s._yposition = o | |
}, | |
setQuery: function(e) { | |
var t = this; | |
t.query = e | |
}, | |
returnIndex: function() { | |
return this.index | |
}, | |
setIndex: function(e) { | |
this.index = e | |
} | |
}, Linker.prototype = { | |
SEARCHURL_TEMPLATE: "http://search.yahoo.co.jp/search?p={{QUERY}}&ei=UTF-8&rkf=1&slfr=1&fr={{FR_TAG}}", | |
SEARCHURL_TEMPLATE_SSH: "https://search.yahoo.co.jp/search?p={{QUERY}}&ei=UTF-8&rkf=1&slfr=1&fr={{FR_TAG}}", | |
makeVariations: function(e) { | |
var t = [e]; | |
return t.push(e.replace(/[A-Za-z0-9!?()\.]/g, function(e) { | |
return String.fromCharCode(e.charCodeAt(0) + 65248) | |
})), t.push(e.replace(/[A-Za-z0-9!?().]/g, function(e) { | |
return String.fromCharCode(e.charCodeAt(0) - 65248) | |
})), t | |
}, | |
getRelated: function(e) { | |
var t, i = this.slink, | |
n = []; | |
for (t = 0; t < i.length; t += 1) i[t].Label !== e && -1 !== i[t].Label.indexOf(e) && n.push(i[t].Label); | |
return n | |
}, | |
getLinkUrl: function(e, t) { | |
void 0 === t && (t = ""); | |
var i = isSSH() ? this.SEARCHURL_TEMPLATE_SSH : this.SEARCHURL_TEMPLATE; | |
return i.replace("{{QUERY}}", encodeURIComponent(e)).replace("{{FR_TAG}}", this.fr + t) | |
}, | |
getLinkableData: function() { | |
var e, t, i, n, r, o = this, | |
a = o.direct, | |
s = []; | |
for (i = 0; i < a.length && !(s.length >= o.linkCount); i++) { | |
for (t = a[i], e = !1, r = a[i].Original, n = 0; n < s.length; n++) | |
if (-1 !== s[n].Original.indexOf(r)) { | |
e = !0; | |
break | |
} | |
e || s.push(t) | |
} | |
return s | |
}, | |
makeDirectLink: function(e) { | |
var t, i, n, r = this, | |
o = r.getLinkableData(), | |
a = []; | |
if (CONST.ALERT) { | |
var s; | |
s = "リンク化可能文字列数:" + o.length, alert(s) | |
} | |
for (o = o.sort(function(e, t) { | |
return t.length - e.length | |
}), t = 0; t < o.length; t++) i = o[t], n = r.replaceToLink(e, r.makeVariations(i.Original), i.Label), n && a.push(n); | |
return a | |
}, | |
createLink: function(e, t) { | |
var i = this, | |
n = document.createElement("span"), | |
r = isSSH() ? i.SEARCHURL_TEMPLATE_SSH : i.SEARCHURL_TEMPLATE; | |
return n.className = i.linkClass, n.href = r.replace("{{QUERY}}", encodeURIComponent(t)).replace("{{FR_TAG}}", i.fr), n.innerHTML = e, n.setAttribute("title", t), i.showBottomsheet && n.setAttribute("data-nofollow", "on"), n | |
}, | |
replaceToLink: function(e, t, i) { | |
var n, r, o, a, s, c, d, l, h = this, | |
p = []; | |
for (d = 0; d < e.length; d++) | |
for (o = e[d].childNodes, l = 0; l < o.length; l++) o[l].nodeType === Node.TEXT_NODE && p.push(o[l]); | |
var u = p.length - 1; | |
for (d = u; d >= 0; d--) | |
if (s = p[d], n = h.getMatchPosition(s.nodeValue, t)) return r = h.createLink(n[1], i), a = s.splitText(n[0] + n[1].length), c = s.splitText(n[0]), c.parentNode.removeChild(c), a.parentNode.insertBefore(r, a), r | |
}, | |
getMatchPosition: function(e, t) { | |
var i, n = t.map(function(t) { | |
for (var i = e.length;;) { | |
if (i = e.lastIndexOf(t, i - 1), -1 === i) break; | |
var n = /^[a-zA-Z0-9a-zA-Z0-9]/.test(t), | |
r = /[a-zA-Z0-9a-zA-Z0-9]$/.test(t), | |
o = /[a-zA-Z0-9a-zA-Z0-9][ \t ]*$/.test(e.substr(0, i)), | |
a = /^[ \t ]*[a-zA-Z0-9a-zA-Z0-9]/.test(e.substr(i + t.length)); | |
if (!(n && o || r && a)) break | |
} | |
return [i, t] | |
}); | |
for (i = 0; i < n.length; i++) | |
if (-1 !== n[i][0]) return n[i] | |
} | |
}, Logger.prototype = { | |
sendViewLog: function() { | |
this.beaconer.doViewBeacon(0) | |
}, | |
attachClickLog: function(e, t, i) { | |
void 0 === t && (t = {}), e.getAttribute("target") ? this.attachClickLogForTargetBlank(e, t) : this.attachClickLogRegular(e, t, i) | |
}, | |
sendClickLog: function(e, t) { | |
var i = new Image; | |
t && (i.onload = i.onerror = i.onabort = function() { | |
location.href = t | |
}), i.src = this.beaconer.getClickBeacon(e) | |
}, | |
attachClickLogRegular: function(e, t, i) { | |
void 0 === t && (t = {}), e.addEventListener("click", function(e) { | |
return function(n) { | |
n.preventDefault(), e.sendClickLog(t, i) | |
} | |
}(this)) | |
}, | |
attachClickLogForTargetBlank: function(e, t) { | |
void 0 === t && (t = {}), e.addEventListener("click", function(e) { | |
return function() { | |
e.beaconer.doClickBeacon(t) | |
} | |
}(this)) | |
} | |
}, LoggerWrapper.prototype = { | |
setupLinkLogger: function(e) { | |
var t; | |
this.linkParamsMain = [{ | |
mod: { | |
name: "dslink" | |
}, | |
links: function() { | |
var i = []; | |
for (t = 1; e >= t; ++t) i.push({ | |
params: { | |
sec: "dslink", | |
slk: "main", | |
pos: t.toString() | |
} | |
}); | |
return i | |
}() | |
}], this.loggerMain = new Logger(this.pageParams, this.linkParamsMain) | |
}, | |
setupBottomSheetLogger: function() { | |
this.linkParamsBtms = [{ | |
mod: { | |
name: "btms" | |
}, | |
links: function() { | |
var e = []; | |
return e.push({ | |
params: { | |
sec: "btms", | |
slk: "close" | |
} | |
}), e.push({ | |
params: { | |
sec: "btms", | |
slk: "search", | |
pos: "sbtn" | |
} | |
}), e | |
}() | |
}], this.loggerBtms = new Logger(this.pageParams, this.linkParamsBtms) | |
}, | |
setupBottomSheetLoggerPC: function() { | |
this.linkParamsBtms = [{ | |
mod: { | |
name: "float" | |
}, | |
links: function() { | |
var e = []; | |
return e.push({ | |
params: { | |
sec: "float", | |
slk: "search" | |
} | |
}), e | |
}() | |
}], this.loggerBtms = new Logger(this.pageParams, this.linkParamsBtms) | |
}, | |
setupRelatedLogger: function(e) { | |
var t; | |
this.linkParamsRelated = [{ | |
mod: { | |
name: "btms" | |
}, | |
links: function() { | |
var i = []; | |
for (t = 1; e >= t; ++t) i.push({ | |
params: { | |
sec: "btms", | |
slk: "search", | |
pos: "rel", | |
dpos: t.toString() | |
} | |
}); | |
return i | |
}() | |
}], this.loggerRelated = new Logger(this.pageParams, this.linkParamsRelated) | |
}, | |
attachBottomSheetLogs: function(e, t) { | |
this.loggerBtms.attachClickLog(e, this.linkParamsBtms[0].links[0].params) | |
}, | |
attachLinkClickLog: function(e, t) { | |
var i, n; | |
for (n = 0; n < e.length; ++n) i = e[n], this.loggerMain.attachClickLog(i, this.linkParamsMain[0].links[n].params, t ? i.href : void 0) | |
}, | |
attachLogsRelated: function(e) { | |
var t, i, n; | |
for (t = e.length, i = 0; t > i; ++i) n = e[i], this.loggerRelated.attachClickLog(n, this.linkParamsRelated[0].links[i].params, n.href) | |
}, | |
sendViewLog: function() { | |
this.sendLinkViewLog(), this.sendBtmsViewLog() | |
}, | |
sendLinkViewLog: function() { | |
this.loggerMain.sendViewLog() | |
}, | |
sendBtmsViewLog: function() { | |
this.loggerBtms.sendViewLog() | |
}, | |
sendRelatedViewLog: function() { | |
this.loggerRelated.sendViewLog() | |
} | |
}, YAHOO = YAHOO || {}, YAHOO.JP = YAHOO.JP || {}, YAHOO.JP.srch = YAHOO.JP.srch || {}, YAHOO.JP.srch.dlink = YAHOO.JP.srch.dlink || {}, YAHOO.JP.srch.nhighlight = YAHOO.JP.srch.nhighlight || {}, YAHOO.JP.srch.dlink.onLoad = function(e) { | |
if (YAHOO.JP.srch.dlink.PARAMS = {}, e({ | |
setParams: function(e) { | |
var t = checkUA(), | |
i = checkAppDomain(); | |
if ("" === t || "" === i || e.addFR === t) YAHOO.JP.srch.dlink.PARAMS = e; | |
else if (CONST.ALERT) { | |
var n; | |
n = "アプリUAでアクセスしたがローダーから呼ばれてない", alert(n) | |
} | |
} | |
}), YAHOO.JP.srch.dlink.PARAMS.serviceCode || YAHOO.JP.srch.dlink.PARAMS.articleID) YAHOO.JP.srch.dlink.PARAMS.launchAfterDocLoad ? document.addEventListener("DOMContentLoaded", init, !1) : init(); | |
else if (CONST.ALERT) { | |
var t; | |
t = "serviceCode, articleIDが不足", alert(t) | |
} | |
}; | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(typeof YAHOO=="undefined"||!YAHOO){var YAHOO = {};} | |
(function(){ | |
function BottomSheetAndroid(e,t){var i=this,n=str2Dom(TMPL.BS_AND);i.bottomSheet=n,i.relatedLinks=n.querySelector("#yjDirectSLinkRelated"),i.directLinkInput=n.querySelector("#yjDirectSLinkIpt"),i.linker=e,i.logger=t,i.eventDetacher=[],i.setup()}function BottomSheetIPhone(e,t){var i=this,n=str2Dom(TMPL.BS_INPUT),r=str2Dom(TMPL.BS_IPN);i.topInputBox=n,i.bottomSheet=r,i.relatedLinks=r.querySelector("#yjDirectSLinkRelated"),i.directLinkInput=r.querySelector("#yjDirectSLinkIpt"),i.topInputBoxInput=n.querySelector("#yjDirectSLinkIpt2"),i.linker=e,i.query="",i.linkQuery="",i.index=-1,i.adjustTopInputBoxPos=function(){i.topInputBox.style.top=window.scrollY+"px"},i.logger=t,i.eventDetacher=[],i.setup()}function BottomSheetPC(e,t){var i=this,n=str2Dom(TMPL.BS_PC);i.bottomSheet=n,i.linker=e,i.query="",i.index=-1,i._xposition=0,i._yposition=0,i.logger=t,i.eventDetacher=[],i.setup()}function Linker(e,t,i,n){var r=this,o=e.HighlightSearchWords,a=isPC()?10:5;r.linkClass="yjDirectSLinkHl",void 0!==t&&""!==t&&"underline"!==t&&(r.linkClass="yjDirectSLinkHl_"+t),r.linkCount=i.linkCount||a,r.fr=o.ServiceSpecific.Fr+(i.bucketID?"_"+i.bucketID:"")+(i.addFR?"_"+i.addFR:""),r.direct=o.Result,r.slink=o.ServiceSpecific.SearchLink,r.showBottomsheet=n}function Logger(e,t){var i=this;i.beaconer=YAHOO.i13n.Beaconer({beacon_server:CONST.URL_BEACON,keys:e,link_data:t,spaceid:e.spaceid,https:!0})}function LoggerWrapper(e){var t=this;t.pageParams=e}function loadResources(e,t){for(var i,n,r=document.head||document.getElementsByTagName("head")[0],o=0,a=!0,s=function(i){o+=1,i&&"error"===i.type&&(a=!1),e.length<=o&&t(a)},c=(isIE(),function(){s()}),d=0;d<e.length;d+=1)i=e[d],("css"===i.type||"js"===i.type)&&("js"===i.type?(n=document.createElement("script"),n.setAttribute("src",i.src)):(n=document.createElement("link"),n.setAttribute("type","text/css"),n.setAttribute("rel","stylesheet"),n.setAttribute("href",i.src)),isIE()<10?setTimeout(c,300):!isPC()&&(isIOS()<6||isAndroid())&&"css"===i.type?setTimeout(s(),300):n.onload=n.onerror=s,r.appendChild(n))}function isAndroid(){var e,t,i=navigator.userAgent;return/Android/i.test(i)?(e=i.match(/Android (\d+)\.(\d+)\.?(\d+)?/),t=e[1]+"."+e[2],e[3]&&(t+="."+e[3]),parseFloat(t)):0}function isIOS(){var e,t,i=navigator.userAgent;return/iP(hone|od touch|ad);/i.test(i)?(e=i.match(/OS (\d+)_(\d+)_?(\d+)?/),t=e[1]+"."+e[2],e[3]&&(t+="."+e[3]),parseFloat(t)):0}function isIE(){var e=navigator.userAgent,t=e.match(/MSIE ([^;]*)|Trident.*; rv:([0-9.]+)/),i=!0;return t?parseFloat((t[1]||t[2]).replace(new RegExp("\\.","g"),function(){var e=i?".":"";return i=!1,e})):0}function isPC(){return isAndroid()||isIOS()?0:1}function isSSH(){var e=0;return"https:"===document.location.protocol&&(e=1),e}function str2Dom(e){var t=document.createElement("div");return t.innerHTML=e,t.firstChild}function range(e,t){var i,n=[];for(i=e;t>=i;i++)n.push(i);return i}function jsonpRequest(e,t){var i=document.createElement("script");YAHOO.JP.srch.dlink.cb=t,i.setAttribute("async",!0),i.setAttribute("src",e.replace("{{callback}}","YAHOO.JP.srch.dlink.cb")),isIE()<10?(document.head||document.getElementsByTagName("head")[0]).appendChild(i):document.head.appendChild(i)}function checkUA(){var e="",t=navigator.userAgent;return/jp\.co\.yahoo\.android\.yjtop/.test(t)&&(e="yjapp_and"),/YJApp-ANDROID jp\.co\.yahoo\.android\.ybrowser/.test(t)&&(e="ybr"),e}function checkAppDomain(){var e="",t=window.location.href;return/^https?:\/\/matome\.naver\.jp\/m\/odai/.test(t)?e="nvm":/^https?:\/\/beauty\.yahoo\.co\.jp\/([^\/]+)\/articles/.test(t)?e="bty":/^https?:\/\/blogs\.yahoo\.co\.jp/.test(t)?e="blg":/^https?:\/\/ameblo\.jp\/([^\/]+)\/entry-\d+/.test(t)&&(e="amb"),e}function init(){var e=isSSH()?CONST.IMG_CENTER_SSH:CONST.IMG_CENTER,t=isPC()?CONST.CSS_PATH_PC:CONST.CSS_PATH,i=CONST.ULT_JS_PATH,n=isSSH()?CONST.API_PATH_SSH:CONST.API_PATH;t=e+t,i=e+i;var r=YAHOO.JP.srch.dlink.PARAMS,o=Math.floor(10*Math.random());("nws"===r.serviceCode||"cbr"===r.serviceCode||"net"===r.serviceCode)&&1===o&&(n=CONST.API_PATH_SSH),loadResources([{type:"css",src:t},{type:"js",src:i}],function(e){if(e){var t=YAHOO.JP.srch.dlink.PARAMS,i=n.replace("{{appid}}",t.appID||t.eappID).replace("{{service}}",t.serviceCode).replace("{{article_id}}",t.articleID);if(5!==t.linkCount&&(i=i+"&count="+t.linkCount),"amb"===t.serviceCode){var r=window.location.protocol+"//"+window.location.host+window.location.pathname;i=i+"&href="+encodeURIComponent(r)}jsonpRequest(i,applyLink)}})}function applyLink(e){var t,i,n={nws:".articleDefault .pgraphWrap .text,.articleDefault > .text,.articleDefault",cbr:"#detail .detailQuestion .mainSentence .mainText,#detail .detailBa .mainSentence .mainText",net:".cpDraft > p,.cpDraft > .rest-article > p",nvm:".MdMTM02Body > .MdMTM03Item > .mdMTM03Inner > p.mdMTM03Ttl,.MdMTM02Body > .MdMTM03Item > .mdMTM03Inner > p.mdMTM03Txt,.MdMTM02Body > .MdMTM03Item > .mdMTM03Inner > .mdMTM03Row > p.mdMTM03TwitterPost,.MdMTM02Body > .MdMTM03Item > .mdMTM03Inner > p.mdMTM03Comment",bty:".detail-article > #arcl > p,.detail-article > #arcl > .rest-article > p",blg:"#atcl > .richTextArea,#atcl > .richTextArea font,#atcl > .richTextArea div,#atcl > .richTextArea span,#atcl > .richTextArea b",amb:"#app div._2M0-mQO6,#app div._2M0-mQO6 div,#app div._2M0-mQO6 span"},r={cbr:".mdPstdQstn .clrfx .usrQstn .ptsQes p,.mdPstdBA .clrfx .usrQstn .ptsQes p"},o=YAHOO.JP.srch.dlink.PARAMS,a=new LoggerWrapper({rpdprop:"entrypoint",service:o.serviceCode,spaceid:o.spaceID,vtestid:o.bucketID,article:o.articleID}),s=isAndroid(),c=isIOS(),d=isPC(),l=d?r:n,h=document.querySelectorAll(l[o.serviceCode]),p="undefined"!=typeof o.bottomSheet?o.bottomSheet:!0,u=window.navigator.userAgent;p&&(s&&4>s||c&&5>c)&&(p=!1);var m=new Linker(e,o.highlightStyle,o,p);if(t=m.makeDirectLink(h),!t||t.length<=0){if(CONST.ALERT){var g;g="リンクを作成できなかった",alert(g)}}else if(p&&s>=5&&6>s&&u.indexOf("Nexus 5")>=0&&u.indexOf("jp.co.yahoo.android.ybrowser")>=0&&(p=!1),a.setupLinkLogger(t.length),a.sendLinkViewLog(),a.attachLinkClickLog(t,!p),p)i=d?new BottomSheetPC(m,a,o.linkCount):new BottomSheetIPhone(m,a,o.linkCount),t.forEach(function(e,t){e.addEventListener("click",function(n){var r=n.target,o=r.getAttribute("title"),a={x:n.clientX,y:n.clientY};YAHOO.JP.srch.dlink.istap=!0,i.returnIndex()!==t?(d&&(i.hide(),i.setPosition(e,a)),i.setIndex(t),i.show(o)):(i.setIndex(-1),i.hide()),n.preventDefault()},!1)}),d&&document.body.addEventListener("click",function(e){var t=e.target.className;"yjDirectSLinkHl"!==t&&(i.setIndex(-1),i.hide())},!1),YAHOO.JP.srch.dlink.close=function(){i.setIndex(-1),i.hide()};else if("nws"===o.serviceCode){var f=document.getElementById("pgraphCap");f.innerHTML="※記事本文中のリンクはYahoo!検索が提供する機能であり、記事提供社とは関係ありません",f.className="articleDefaultCap"}}var CONST={IMG_CENTER:"http://i.yimg.jp/",IMG_CENTER_SSH:"https://s.yimg.jp/",CSS_PATH:"/images/search/slink/direct/sp/1.0.0/css/direct_content_sp.css",CSS_PATH_PC:"/images/search/slink/direct/pc/1.0.0/css/direct_content_pc.css",ULT_JS_PATH:"/images/rapid/1.5.0/ult.js",MAIN_JS_PATH:"/images/search/slink/direct/sp/1.0.0/js/directlink.min.js",API_PATH:"http://entrypoint.search.yahooapis.jp/v1/link/highlight_words?&appid={{appid}}&.src={{service}}&article_id={{article_id}}&callback={{callback}}",API_PATH_SSH:"https://slink-search.yahooapis.jp/v1/link/highlight_words?&appid={{appid}}&.src={{service}}&article_id={{article_id}}&callback={{callback}}",BEACON_SERVER:"ybx.yahoo.co.jp",CLASS_CLOSE:"animationClose",CLASS_OPEN:"animationOpen",ALERT:!1},TMPL={BS_AND:['<div id="yjDirectSLink" class="animationOpen">','<div id="yjDirectSLinkHd">',"<p>Yahoo! JAPAN</p>",'<a href="javascript:void(0)" id="yjDirectSLinkExpand" class="yjDirectSLinkExp">閉じる</a>',"</div>",'<div id="yjDirectSLinkSearchBox">','<form id="yjDirectSLinkFrm" action="" method="get">','<div id="yjDirectSLinkWrap">','<input type="search" name="" value="" id="yjDirectSLinkIpt" autocomplete="off" autocorrect="off" autocapitalize="off" placeholder="キーワードを入力">','<div id="yjDirectSLinkClearBtn"><span> </span></div>',"</div>",'<input type="submit" id="yjDirectSLinkSbmtBtn" value="検索">',"</form>","</div>",'<div class="yjDirectSLinkSm">','<p id="yjDirectSLinkRelated"></p>',"</div>",'<div class="yjDirectLinkMsg">',"<p>※本文中リンクはヤフー提供の機能で、記事提供社とは関係ありません</p>","</div>","</div>"].join(""),BS_IPN:['<div id="yjDirectSLink" class="animationOpen">','<div id="yjDirectSLinkHd">',"<p>Yahoo! JAPAN</p>",'<a href="javascript:void(0)" id="yjDirectSLinkExpand" class="yjDirectSLinkExp">閉じる</a>',"</div>",'<div id="yjDirectSLinkSearchBox">','<form id="yjDirectSLinkFrm" action="" method="get">','<div id="yjDirectSLinkWrap">','<div id="yjDirectSLinkIpt"></div>','<div id="yjDirectSLinkClearBtn"><span> </span></div>',"</div>",'<input type="submit" id="yjDirectSLinkSbmtBtn" value="検索">',"</form>","</div>",'<div class="yjDirectSLinkSm">','<p id="yjDirectSLinkRelated"></p>',"</div>",'<div class="yjDirectLinkMsg">',"<p>※本文中リンクはヤフー提供の機能で、記事提供社とは関係ありません</p>","</div>","</div>"].join(""),BS_INPUT:['<div id="yjDirectSLink2" style="display: block; top: 0px;">','<div id="yjDirectSLinkSearchBox2">','<form id="yjDirectSLinkFrm2" action="" method="get">','<div id="yjDirectSLinkWrap2">','<input type="search" name="" value="" id="yjDirectSLinkIpt2" autocomplete="off" autocorrect="off" autocapitalize="off" placeholder="キーワードを入力" autofocus>',"</div>",'<input type="submit" id="yjDirectSLinkSbmtBtn2" value="検索">',"</form>","</div>","</div>"].join(""),BS_PC:['<div id="yjDirectSLink" style="display: block">','<a href="javascript:void(0);" target="_blank">Yahoo!検索</a>',"</div>"].join("")};BottomSheetAndroid.prototype={setup:function(){var e=this,t=e.logger,i=e.bottomSheet,n=e.directLinkInput,r=i.querySelector("#yjDirectSLinkExpand"),o=i.querySelector("#yjDirectSLinkSbmtBtn"),a=i.querySelector("#yjDirectSLinkClearBtn");i.addEventListener("touchmove",function(e){e.preventDefault()},!1),r.addEventListener("click",function(t){t.preventDefault(),e.hide()},!1),o.addEventListener("click",function(i){i.preventDefault(),e.hide(),t.loggerBtms.sendClickLog(t.linkParamsBtms[0].links[1].params,e.linker.getLinkUrl(e.directLinkInput.value))}),a.addEventListener("click",function(){n.value=""}),t.setupBottomSheetLogger(),t.attachBottomSheetLogs(r)},hide:function(){var e=this,t=e.bottomSheet;YAHOO.JP.srch.uho&&YAHOO.JP.srch.uho.show instanceof Function&&YAHOO.JP.srch.uho.show(),t.className=CONST.CLASS_CLOSE,setTimeout(function(){-1!==t.className.indexOf(CONST.CLASS_CLOSE)&&e.detach()},500)},detach:function(){var e=this,t=e.bottomSheet,i=t.parentNode;i&&i.removeChild(t)},show:function(e){var t,i,n=this,r=n.logger,o=n.linker.getRelated(e),a=n.bottomSheet,s=n.relatedLinks,c=[],d=function(){n.hide()};if(n.directLinkInput.value=e,s.innerHTML="",o.length>0){for(s.style.display="block",i=0;i<o.length&&3>i;i++)t=n.createRelatedLink(o[i],e),s.appendChild(t),c.push(t),t.addEventListener("click",d,!1);r.setupRelatedLogger(i),r.sendRelatedViewLog(),r.attachLogsRelated(c)}else s.style.display="none";r.sendBtmsViewLog(),a.className=CONST.CLASS_OPEN,a.style.bottom="",document.body.appendChild(a),YAHOO.JP.srch.uho&&YAHOO.JP.srch.uho.hide instanceof Function&&YAHOO.JP.srch.uho.hide()},createRelatedLink:function(e,t){var i=document.createElement("a");return i.className="yjDirectLinkTag",i.innerHTML=e.replace(t,"<em>"+t+"</em>"),i.href=this.linker.getLinkUrl(e),i}},BottomSheetIPhone.prototype={setup:function(){var e=this,t=e.logger,i=e.bottomSheet,n=i.querySelector("#yjDirectSLinkExpand"),r=i.querySelector("#yjDirectSLinkSbmtBtn"),o=i.querySelector("#yjDirectSLinkClearBtn");i.addEventListener("touchmove",function(e){e.preventDefault()},!1),n.addEventListener("click",function(t){t.preventDefault(),e.hide()},!1),r.addEventListener("click",function(i){i.preventDefault(),e.hide();var n="";e.query!==e.linkQuery&&(n="_re"),t.loggerBtms.sendClickLog(t.linkParamsBtms[0].links[1].params,e.linker.getLinkUrl(e.query,n))}),o.addEventListener("click",function(){e.setQuery("")}),e.setupTopInputBox(t),t.setupBottomSheetLogger(),t.attachBottomSheetLogs(n)},setupTopInputBox:function(e){var t=this,i=t.topInputBox,n=i.querySelector("#yjDirectSLinkSbmtBtn2"),r=t.topInputBoxInput,o=t.directLinkInput,a=document.body,s=!1,c=function(){s||(t.setQuery(r.value),a.contains(i)&&a.removeChild(i),t.bottomSheet.className="",t.attach(),window.removeEventListener("scroll",t.adjustTopInputBoxPos))},d=function(n){n.preventDefault(),a.removeChild(i);var o="";r.value!==t.linkQuery&&(o="_re"),s=!0,e.loggerBtms.sendClickLog(e.linkParamsBtms[0].links[1].params,t.linker.getLinkUrl(r.value,o))};o.addEventListener("click",function(e){e.preventDefault(),t.detach(),t.adjustTopInputBoxPos(),a.appendChild(i),s=!1,window.removeEventListener("scroll",t.adjustTopInputBoxPos),window.addEventListener("scroll",t.adjustTopInputBoxPos),r.focus(),setTimeout(function(){t.adjustTopInputBoxPos()},500)}),i.addEventListener("touchstart",function(e){e.target===i&&(e.preventDefault(),r.blur(),c())}),n.addEventListener("touchstart",d),n.addEventListener("click",d),r.addEventListener("blur",function(){setTimeout(c,500)})},hide:function(){var e=this,t=e.bottomSheet;YAHOO.JP.srch.uho&&YAHOO.JP.srch.uho.show instanceof Function&&YAHOO.JP.srch.uho.show(),t.className=CONST.CLASS_CLOSE,e.index=-1,setTimeout(function(){-1!==t.className.indexOf(CONST.CLASS_CLOSE)&&e.detach()},500)},detach:function(){var e=this,t=e.bottomSheet,i=t.parentNode;i&&i.removeChild(t)},attach:function(){document.body.appendChild(this.bottomSheet)},show:function(e){var t,i,n=this,r=n.logger,o=n.linker.getRelated(e),a=n.bottomSheet,s=n.relatedLinks,c=[],d=function(){n.hide()};if(n.setQuery(e),n.linkQuery=e,s.innerHTML="",o.length>0){for(s.style.display="block",i=0;i<o.length&&3>i;i++)t=n.createRelatedLink(o[i],e),s.appendChild(t),c.push(t),t.addEventListener("click",d,!1);r.setupRelatedLogger(i),r.sendRelatedViewLog(),r.attachLogsRelated(c)}else s.style.display="none";r.sendBtmsViewLog(),YAHOO.JP.srch.uho&&YAHOO.JP.srch.uho.hide instanceof Function&&YAHOO.JP.srch.uho.hide(),YAHOO.JP.idpf&&YAHOO.JP.idpf.loginPromo&&YAHOO.JP.idpf.loginPromo.hide instanceof Function&&YAHOO.JP.idpf.loginPromo.hide(),a.className=CONST.CLASS_OPEN,a.style.bottom="",n.attach(),(void 0===YAHOO.JP.srch.nhighlight.istap||void 0!==YAHOO.JP.srch.nhighlight.istap&&YAHOO.JP.srch.nhighlight.istap!==!0)&&(YAHOO.JP.srch.dlink.istap=!1)},setQuery:function(e){var t=this;t.query=e,t.directLinkInput.innerHTML=e,t.topInputBoxInput.value=e},createRelatedLink:function(e,t){var i=document.createElement("a");return i.className="yjDirectLinkTag",i.innerHTML=e.replace(t,"<em>"+t+"</em>"),i.href=this.linker.getLinkUrl(e),i},returnIndex:function(){return this.index},setIndex:function(e){this.index=e}},BottomSheetPC.prototype={setup:function(){var e=this,t=e.logger,i=e.bottomSheet;i.addEventListener("click",function(i){i.preventDefault(),e.hide(),t.loggerBtms.sendClickLog(t.linkParamsBtms[0].links[0].params,e.linker.getLinkUrl(e.query))}),t.setupBottomSheetLoggerPC()},attach:function(){document.body.appendChild(this.bottomSheet)},detach:function(){var e=this,t=e.bottomSheet,i=t.parentNode;i&&i.removeChild(t)},hide:function(){var e=this;e.detach()},show:function(e){var t,i=this,n=i.bottomSheet,r=i.logger;i.setQuery(e),r.sendBtmsViewLog(),t=n.getElementsByTagName("a"),t[0].href=this.linker.getLinkUrl(e),n.style.left=i._xposition+"px",n.style.top=i._yposition+"px",i.attach()},setPosition:function(e,t){var i,n,r,o,a,s=this,c={width:130,height:48},d=e.getBoundingClientRect(),l=e.getClientRects(),h=window.pageYOffset+$(window).height(),p="undefined"!=typeof e.closest,u=!1;if(l.length>1)for(a=0;a<l.length;a++)if(t.y<l[a].bottom){d=l[a];break}isIE()?(i=e.parentElement,void 0!==i&&(u=!0)):p&&(i=e.closest("div"),void 0!==i&&(u=!0)),n=u?window.pageXOffset+i.getBoundingClientRect().right:window.pageXOffset+d.right,r=d.right+window.pageXOffset-20,r+c.width>n&&(r=n-c.width),o=d.bottom+window.pageYOffset+3,o+c.height>h&&(o=d.top+window.pageYOffset-c.height),s._xposition=r,s._yposition=o},setQuery:function(e){var t=this;t.query=e},returnIndex:function(){return this.index},setIndex:function(e){this.index=e}},Linker.prototype={SEARCHURL_TEMPLATE:"http://search.yahoo.co.jp/search?p={{QUERY}}&ei=UTF-8&rkf=1&slfr=1&fr={{FR_TAG}}",SEARCHURL_TEMPLATE_SSH:"https://search.yahoo.co.jp/search?p={{QUERY}}&ei=UTF-8&rkf=1&slfr=1&fr={{FR_TAG}}",makeVariations:function(e){var t=[e];return t.push(e.replace(/[A-Za-z0-9!?()\.]/g,function(e){return String.fromCharCode(e.charCodeAt(0)+65248)})),t.push(e.replace(/[A-Za-z0-9!?().]/g,function(e){return String.fromCharCode(e.charCodeAt(0)-65248)})),t},getRelated:function(e){var t,i=this.slink,n=[];for(t=0;t<i.length;t+=1)i[t].Label!==e&&-1!==i[t].Label.indexOf(e)&&n.push(i[t].Label);return n},getLinkUrl:function(e,t){void 0===t&&(t="");var i=isSSH()?this.SEARCHURL_TEMPLATE_SSH:this.SEARCHURL_TEMPLATE;return i.replace("{{QUERY}}",encodeURIComponent(e)).replace("{{FR_TAG}}",this.fr+t)},getLinkableData:function(){var e,t,i,n,r,o=this,a=o.direct,s=[];for(i=0;i<a.length&&!(s.length>=o.linkCount);i++){for(t=a[i],e=!1,r=a[i].Original,n=0;n<s.length;n++)if(-1!==s[n].Original.indexOf(r)){e=!0;break}e||s.push(t)}return s},makeDirectLink:function(e){var t,i,n,r=this,o=r.getLinkableData(),a=[];if(CONST.ALERT){var s;s="リンク化可能文字列数:"+o.length,alert(s)}for(o=o.sort(function(e,t){return t.length-e.length}),t=0;t<o.length;t++)i=o[t],n=r.replaceToLink(e,r.makeVariations(i.Original),i.Label),n&&a.push(n);return a},createLink:function(e,t){var i=this,n=document.createElement("span"),r=isSSH()?i.SEARCHURL_TEMPLATE_SSH:i.SEARCHURL_TEMPLATE;return n.className=i.linkClass,n.href=r.replace("{{QUERY}}",encodeURIComponent(t)).replace("{{FR_TAG}}",i.fr),n.innerHTML=e,n.setAttribute("title",t),i.showBottomsheet&&n.setAttribute("data-nofollow","on"),n},replaceToLink:function(e,t,i){var n,r,o,a,s,c,d,l,h=this,p=[];for(d=0;d<e.length;d++)for(o=e[d].childNodes,l=0;l<o.length;l++)o[l].nodeType===Node.TEXT_NODE&&p.push(o[l]);var u=p.length-1;for(d=u;d>=0;d--)if(s=p[d],n=h.getMatchPosition(s.nodeValue,t))return r=h.createLink(n[1],i),a=s.splitText(n[0]+n[1].length),c=s.splitText(n[0]),c.parentNode.removeChild(c),a.parentNode.insertBefore(r,a),r},getMatchPosition:function(e,t){var i,n=t.map(function(t){for(var i=e.length;;){if(i=e.lastIndexOf(t,i-1),-1===i)break;var n=/^[a-zA-Z0-9a-zA-Z0-9]/.test(t),r=/[a-zA-Z0-9a-zA-Z0-9]$/.test(t),o=/[a-zA-Z0-9a-zA-Z0-9][ \t ]*$/.test(e.substr(0,i)),a=/^[ \t ]*[a-zA-Z0-9a-zA-Z0-9]/.test(e.substr(i+t.length));if(!(n&&o||r&&a))break}return[i,t]});for(i=0;i<n.length;i++)if(-1!==n[i][0])return n[i]}},Logger.prototype={sendViewLog:function(){this.beaconer.doViewBeacon(0)},attachClickLog:function(e,t,i){void 0===t&&(t={}),e.getAttribute("target")?this.attachClickLogForTargetBlank(e,t):this.attachClickLogRegular(e,t,i)},sendClickLog:function(e,t){var i=new Image;t&&(i.onload=i.onerror=i.onabort=function(){location.href=t}),i.src=this.beaconer.getClickBeacon(e)},attachClickLogRegular:function(e,t,i){void 0===t&&(t={}),e.addEventListener("click",function(e){return function(n){n.preventDefault(),e.sendClickLog(t,i)}}(this))},attachClickLogForTargetBlank:function(e,t){void 0===t&&(t={}),e.addEventListener("click",function(e){return function(){e.beaconer.doClickBeacon(t)}}(this))}},LoggerWrapper.prototype={setupLinkLogger:function(e){var t;this.linkParamsMain=[{mod:{name:"dslink"},links:function(){var i=[];for(t=1;e>=t;++t)i.push({params:{sec:"dslink",slk:"main",pos:t.toString()}});return i}()}],this.loggerMain=new Logger(this.pageParams,this.linkParamsMain)},setupBottomSheetLogger:function(){this.linkParamsBtms=[{mod:{name:"btms"},links:function(){var e=[];return e.push({params:{sec:"btms",slk:"close"}}),e.push({params:{sec:"btms",slk:"search",pos:"sbtn"}}),e}()}],this.loggerBtms=new Logger(this.pageParams,this.linkParamsBtms)},setupBottomSheetLoggerPC:function(){this.linkParamsBtms=[{mod:{name:"float"},links:function(){var e=[];return e.push({params:{sec:"float",slk:"search"}}),e}()}],this.loggerBtms=new Logger(this.pageParams,this.linkParamsBtms)},setupRelatedLogger:function(e){var t;this.linkParamsRelated=[{mod:{name:"btms"},links:function(){var i=[];for(t=1;e>=t;++t)i.push({params:{sec:"btms",slk:"search",pos:"rel",dpos:t.toString()}});return i}()}],this.loggerRelated=new Logger(this.pageParams,this.linkParamsRelated)},attachBottomSheetLogs:function(e,t){this.loggerBtms.attachClickLog(e,this.linkParamsBtms[0].links[0].params)},attachLinkClickLog:function(e,t){var i,n;for(n=0;n<e.length;++n)i=e[n],this.loggerMain.attachClickLog(i,this.linkParamsMain[0].links[n].params,t?i.href:void 0)},attachLogsRelated:function(e){var t,i,n;for(t=e.length,i=0;t>i;++i)n=e[i],this.loggerRelated.attachClickLog(n,this.linkParamsRelated[0].links[i].params,n.href)},sendViewLog:function(){this.sendLinkViewLog(),this.sendBtmsViewLog()},sendLinkViewLog:function(){this.loggerMain.sendViewLog()},sendBtmsViewLog:function(){this.loggerBtms.sendViewLog()},sendRelatedViewLog:function(){this.loggerRelated.sendViewLog()}},YAHOO=YAHOO||{},YAHOO.JP=YAHOO.JP||{},YAHOO.JP.srch=YAHOO.JP.srch||{},YAHOO.JP.srch.dlink=YAHOO.JP.srch.dlink||{},YAHOO.JP.srch.nhighlight=YAHOO.JP.srch.nhighlight||{},YAHOO.JP.srch.dlink.onLoad=function(e){if(YAHOO.JP.srch.dlink.PARAMS={},e({setParams:function(e){var t=checkUA(),i=checkAppDomain();if(""===t||""===i||e.addFR===t)YAHOO.JP.srch.dlink.PARAMS=e;else if(CONST.ALERT){var n;n="アプリUAでアクセスしたがローダーから呼ばれてない",alert(n)}}}),YAHOO.JP.srch.dlink.PARAMS.serviceCode||YAHOO.JP.srch.dlink.PARAMS.articleID)YAHOO.JP.srch.dlink.PARAMS.launchAfterDocLoad?document.addEventListener("DOMContentLoaded",init,!1):init();else if(CONST.ALERT){var t;t="serviceCode, articleIDが不足",alert(t)}}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
beautified with http://jsbeautifier.org/