var games = []; search = function (keyword, partial) { $.getJSON("https://static-wordpress.akamaized.net/ubisoft.co.jp/wp-content/themes/ubisoft/json/games.json?ver=8", function (json) { title = ""; if (keyword == null) { keyword = ""; } if (keyword == "") { title = "全ての検索結果"; } else { title = keyword + "の検索結果"; $('.form-control .platform-select').val(''); } games = filteredFreewords(json, keyword); // attach if (partial) { attachPartial(games, title); } else { attach(games, title); } }); } list = function (platform, page, max, partial) { $.getJSON("https://static-wordpress.akamaized.net/ubisoft.co.jp/wp-content/themes/ubisoft/json/games.json?ver=8", function (json) { if (platform == null) { platform = '' } games = filteredPlatform(json, platform); title = platform + "の検索結果"; // attach if (partial) { attachPartial(games, title); } else { attach(games, title); } }); } generate = function (slug) { $.getJSON("https://static-wordpress.akamaized.net/ubisoft.co.jp/wp-content/themes/ubisoft/json/games.json?ver=8", function (json) { if (slug == null) { slug = ''; } games = (slug != '' ? filteredSlug(json, slug) : filteredFreewords(json, '')); title = slug; // attach attachInstant(games, title); }); } attachInstant = function (array, title) { var literal = ''; $(document).ready(function () { tmpstr = ""; for (var i = 0; i < array.length; i++) { title_link = array[i][0].link; for (var u = 0; u < array[i].length; u++) { if (array[i][u]['link_override'] != '') { title_link = array[i][u]['link_override']; } } // platform bind platform = '' + array[i][0].platform + ''; icons = '' + array[i][0].mnemonic + ''; if (array[i][0].slug == "pc") { if (array[i][0].link.match(/amazon/)) { platform = 'Amazon.co.jpで購入'; } else if (array[i][0].link.match(/konamistyle/)) { platform = 'KONAMI STYLEで購入'; } else if (array[i][0].link == 'Amazon') { platform = 'Amazon.co.jp'; } else if (array[i][0].link == 'KONAMI STYLE') { platform = 'KONAMI STYLE'; } else { platform = ''; } icons = '' + array[i][0].platform + ''; } for (var j = 1; j < array[i].length; j++) { if (array[i][j].slug == "pc") { if (array[i][j].link.match(/amazon/)) { platform += ' / ' + 'Amazon.co.jpで購入'; } else if (array[i][j].link.match(/konamistyle/)) { platform += ' / ' + 'KONAMI STYLEで購入'; } else if (array[i][j].link == 'Amazon') { platform += ' / ' + 'Amazon.co.jp'; } else if (array[i][j].link == 'KONAMI STYLE') { platform += ' / ' + 'KONAMI STYLE';; } else { platform += ' / ' + ''; } } else { platform += ' / ' + '' + array[i][j].platform + ''; icons = '' + array[i][j].mnemonic + '' + icons; } } var release = array[i][0].date.split("/"); if (release.length == 3) { var tmp2 = release[0] + "年" + release[1] + "月" + release[2] + "日発売"; var tmp = new Date(Date.parse(array[i][0].date)); var today = new Date(); if (today < tmp) { tmp2 += "予定"; } release = tmp2; } else { release = array[i][0].date; } if (array[i][0].slug == "pc") { tmpstr += '
' + icons + '' + '

' + array[i][0].title + '

' + platform + '

' + release + '

'; } else { tmpstr += '
' + icons + '' + '

' + array[i][0].title + '

' + platform + '

' + release + '

'; } if ((i != 0 && i % 3 == 2) || i == array.length - 1) { literal += "
" + tmpstr + "
"; tmpstr = ""; } } $('#archive-results .archive-item-group').empty(); $('#archive-results .archive-item-group').html(literal); }); }; attachPartial = function (array, title) { var literal = ''; $(document).ready(function () { tmpstr = ""; for (var i = 0; i < array.length; i++) { title_link = array[i][0].link; for (var u = 0; u < array[i].length; u++) { if (array[i][u]['link_override'] != '') { title_link = array[i][u]['link_override']; } } // platform bind platform = '' + array[i][0].platform + ''; icons = '' + array[i][0].mnemonic + ''; if (array[i][0].slug == "pc") { if (array[i][0].link.match(/amazon/)) { platform = 'Amazon.co.jpで購入'; } else if (array[i][0].link.match(/konamistyle/)) { platform = 'KONAMI STYLEで購入'; } else if (array[i][0].link == 'Amazon') { platform = 'Amazon.co.jp'; } else if (array[i][0].link == 'KONAMI STYLE') { platform = 'KONAMI STYLE'; } else { platform = ''; } icons = '' + array[i][0].platform + ''; } for (var j = 1; j < array[i].length; j++) { if (array[i][j].slug == "pc") { if (array[i][j].link.match(/amazon/)) { platform += ' / ' + 'Amazon.co.jpで購入'; } else if (array[i][j].link.match(/konamistyle/)) { platform += ' / ' + 'KONAMI STYLEで購入'; } else if (array[i][j].link == 'Amazon') { platform += ' / ' + 'Amazon.co.jp'; } else if (array[i][j].link == 'KONAMI STYLE') { platform += ' / ' + 'KONAMI STYLE';; } else { platform += ' / ' + ''; } } else { platform += ' / ' + '' + array[i][j].platform + ''; icons = '' + array[i][j].mnemonic + '' + icons; } } var release = array[i][0].date.split("/"); if (release.length == 3) { var tmp2 = release[0] + "年" + release[1] + "月" + release[2] + "日発売"; var tmp = new Date(Date.parse(array[i][0].date)); var today = new Date(); if (today < tmp) { tmp2 += "予定"; } release = tmp2; } else { release = array[i][0].date; } if (array[i][0].slug == "pc") { tmpstr += '
' + icons + '' + '

' + array[i][0].title + '

' + platform + '

' + release + '

'; } else { tmpstr += '
' + icons + '' + '

' + array[i][0].title + '

' + platform + '

' + release + '

'; } if ((i != 0 && i % 3 == 2) || i == array.length - 1) { literal += "
" + tmpstr + "
"; tmpstr = ""; } } $('#search-results .search-item-group').animate({ opacity: 0 }, 500, function () { $('#search-results .search-item-group').empty(); $('#search-results .search-item-group').html(literal); $('#search-results .search-item-group').animate({ opacity: 1 }); }); }); }; attach = function (array, title) { var literal = ''; $(document).ready(function () { if ($('body').hasClass('home')) { $('#content_wrap').animate({ opacity: 0 }, 500, function () { $('#search-results').remove(); $('.news-area, .banner-area').css({ display: 'none' }); $('.blog-area, .banner-area').css({ display: 'none' }); // block literal += "

" + title + "

"; literal += "

閉じる

"; tmpstr = ""; for (var i = 0; i < array.length; i++) { title_link = array[i][0].link; for (var u = 0; u < array[i].length; u++) { if (array[i][u]['link_override'] != '') { title_link = array[i][u]['link_override']; } } // platform bind platform = '' + array[i][0].platform + ''; icons = '' + array[i][0].mnemonic + ''; if (array[i][0].slug == "pc") { if (array[i][0].link.match(/amazon/)) { platform = 'Amazon.co.jpで購入'; } else if (array[i][0].link.match(/konamistyle/)) { platform = 'KONAMI STYLEで購入'; } else if (array[i][0].link == 'Amazon') { platform = 'Amazon.co.jp'; } else if (array[i][0].link == 'KONAMI STYLE') { platform = 'KONAMI STYLE'; } else { platform = ''; } icons = '' + array[i][0].platform + ''; } for (var j = 1; j < array[i].length; j++) { if (array[i][j].slug == "pc") { if (array[i][j].link.match(/amazon/)) { platform += ' / ' + 'Amazon.co.jpで購入'; } else if (array[i][j].link.match(/konamistyle/)) { platform += ' / ' + 'KONAMI STYLEで購入'; } else if (array[i][j].link == 'Amazon') { platform += ' / ' + 'Amazon.co.jp'; } else if (array[i][j].link == 'KONAMI STYLE') { platform += ' / ' + 'KONAMI STYLE';; } else { platform += ' / ' + ''; } } else { platform += ' / ' + '' + array[i][j].platform + ''; icons = '' + array[i][j].mnemonic + '' + icons; } } var release = array[i][0].date.split("/"); if (release.length == 3) { var tmp2 = release[0] + "年" + release[1] + "月" + release[2] + "日発売"; var tmp = new Date(Date.parse(array[i][0].date)); var today = new Date(); if (today < tmp) { tmp2 += "予定"; } release = tmp2; } else { release = array[i][0].date; } if (array[i][0].slug == "pc") { tmpstr += '
' + icons + '' + '

' + array[i][0].title + '

' + platform + '

' + release + '

'; } else { tmpstr += '
' + icons + '' + '

' + array[i][0].title + '

' + platform + '

' + release + '

'; } if ((i != 0 && i % 3 == 2) || i == array.length - 1) { literal += "
" + tmpstr + "
"; tmpstr = ""; } } // block $('
' + literal + '
').prependTo('#content_wrap'); $('#content_wrap').animate({ opacity: 1 }); $('#search-results .result-close').click(function (e) { $('#content_wrap').animate({ opacity: 0 }, 500, function () { $('#search-results').remove(); $('.news-area, .banner-area').css({ display: 'block' }); $('#content_wrap').animate({ opacity: 1 }); }); }); }); } else { $('#content_wrap').animate({ opacity: 0 }, 500, function () { $('#search-results').remove(); $('.content-area').css({ display: 'none' }); plats = [ ['platform/ps5', 'PlayStation®5'], ['platform/ps4', 'PlayStation®4'], ['platform/ps3', 'PlayStation®3'], ['platform/ps2', 'PlayStation®2'], ['platform/psvita', 'PlayStation®Vita'], ['platform/psp', 'PSP®'], ['platform/xboxseriesx', 'Xbox Series X'], ['platform/xboxone', 'Xbox One'], ['platform/xbox360', 'Xbox 360®'], ['platform/xbox', 'Xbox®'], ['platform/switch', 'Nintendo Switch™'], ['platform/wiiu', 'Wii U™'], ['platform/wii', 'Wii™'], ['platform/n3ds', 'Nintendo 3DS™'], ['platform/nds', 'Nintendo DS™'], ['platform/pc', 'PC'], ['platform/ios_android', 'iOS/Android']]; platsSelect = ''; for (i = 0; i < plats.length; i++) { platsSelect += ''; } literal += '
'; literal += "

" + title + "

"; literal += "

閉じる

"; literal += "
プラットフォーム:
" + "" + "" + "
"; literal += "
"; literal += '
'; $('#content_wrap').prepend(literal); $('#content_wrap').animate({ opacity: 1 }, 500, function () { // block for (var i = 0; i < array.length; i++) { var row; if (i % 3 == 0) { row = $("
"); $('.search-item-group').append(row); } title_link = array[i][0].link; for (var u = 0; u < array[i].length; u++) { if (array[i][u]['link_override'] != '') { title_link = array[i][u]['link_override']; } } // platform bind platform = '' + array[i][0].platform + ''; icons = '' + array[i][0].mnemonic + ''; if (array[i][0].slug == "pc") { if (array[i][0].link.match(/amazon/)) { platform = 'Amazon.co.jpで購入'; } else if (array[i][0].link.match(/konamistyle/)) { platform = 'KONAMI STYLEで購入'; } else if (array[i][0].link == 'Amazon') { platform = 'Amazon.co.jp'; } else if (array[i][0].link == 'KONAMI STYLE') { platform = 'KONAMI STYLE'; } else { platform = ''; } icons = '' + array[i][0].platform + ''; } for (var j = 1; j < array[i].length; j++) { if (array[i][j].slug == "pc") { if (array[i][j].link.match(/amazon/)) { platform += ' / ' + 'Amazon.co.jpで購入'; } else if (array[i][j].link.match(/konamistyle/)) { platform += ' / ' + 'KONAMI STYLEで購入'; } else if (array[i][j].link == 'Amazon') { platform += ' / ' + 'Amazon.co.jp'; } else if (array[i][j].link == 'KONAMI STYLE') { platform += ' / ' + 'KONAMI STYLE';; } else { platform += ' / ' + ''; } } else { platform += ' / ' + '' + array[i][j].platform + ''; icons = '' + array[i][j].mnemonic + '' + icons; } } var release = array[i][0].date.split("/"); if (release.length == 3) { var tmp2 = release[0] + "年" + release[1] + "月" + release[2] + "日発売"; var tmp = new Date(Date.parse(array[i][0].date)); var today = new Date(); if (today < tmp) { tmp2 += "予定"; } release = tmp2; } else { release = array[i][0].date; } var tmpstr = '
' + icons + '' + '

' + array[i][0].title + '

' + platform + '

' + release + '

'; if (array[i][0].slug == "pc") { tmpstr = '
' + icons + '' + '

' + array[i][0].title + '

' + platform + '

' + release + '

'; } var itemtag = $(tmpstr); itemtag.appendTo(row).css({ opacity: 0 }).animate({ opacity: 1 }, 500); } // block $('#search-results .result-close').click(function (e) { $('#content_wrap').animate({ opacity: 0 }, 500, function () { $('#search-results').remove(); $('.content-area').css({ display: 'block' }); $('#content_wrap').animate({ opacity: 1 }); }); }); $('#search-results .platform-select').change(function (e) { $('#titleInputInResult').val(""); $('#search-results .search-item-group').animate({ opacity: 0 }, 500, function () { txt = $(e.currentTarget).find('option:selected').text(); if (txt == "全て") { search(null, true); } else { list(txt, null, null, true); } }); }); $('#search-results #search-results-form').submit(function (e) { e.preventDefault(); $('#search-results .search-item-group').animate({ opacity: 0 }, 500, function () { search($('#titleInputInResult').val(), true); }); }); }); }); } }); } filteredFreewords = function (array, pattern) { pattern = pattern.replace(/ /g, " "); pattern = pattern.replace(/ +/g, " "); pattern = pattern.replace(/^\s+|\s+$/g, ""); //pattern = pattern.replace(/®/g, '®'); //pattern = pattern.replace(/™/g, '™'); var filtered = []; var patterns = pattern.split(' '); var regexps = []; regexps.push(new RegExp(patterns[0], 'gi')); if (patterns.length > 1) { for (var k = 1; k < patterns.length; k++) { regexps.push(new RegExp(patterns[k], 'gi')); } } var found; for (var i = 0; i < array.length; i++) { for (var k = 0; k < array[i].length; k++) { found = true; for (var j = 0; j < regexps.length; j++) { if (array[i][k].title.match(regexps[j]) && (array[i][k].title.match(regexps[j])).length > 0) { found *= true; } else if (array[i][k].platform.match(regexps[j]) && (array[i][k].platform.match(regexps[j])).length > 0) { found *= true; } else { found *= false; } } } if (found) { filtered.push(array[i]); } } filtered.sort(function (a, b) { var pattern = /(\d{4})\.(\d{2})\.(\d{2})/; var ad = new Date(a[0].date.replace(pattern, '$1-$2-$3')); var bd = new Date(b[0].date.replace(pattern, '$1-$2-$3')); if (ad.toString() === "Invalid Date") { return -1; } if (bd.toString() === "Invalid Date") { return 1; } if (ad < bd) return 1; if (ad > bd) return -1; return 0; }); return filtered; } filteredPlatform = function (array, pattern) { //pattern = pattern.replace(/®/g, '®'); //pattern = pattern.replace(/™/g, '™'); var filtered = []; for (var i = 0; i < array.length; i++) { for (var j = 0; j < array[i].length; j++) { if (array[i][j].platform == pattern) { var results = array[i]; var target = array[i][j]; results.splice(j, 1); results.splice(0, 0, target); filtered.push(results); if (array[i][0].platform == 'PC') { break; } } } } filtered.sort(function (a, b) { var pattern = /(\d{4})\.(\d{2})\.(\d{2})/; var ad = new Date(a[0].date.replace(pattern, '$1-$2-$3')); var bd = new Date(b[0].date.replace(pattern, '$1-$2-$3')); if (ad.toString() === "Invalid Date") { return -1; } if (bd.toString() === "Invalid Date") { return 1; } if (ad < bd) return 1; if (ad > bd) return -1; return 0; }); return filtered; } filteredSlug = function (array, pattern) { //pattern = pattern.replace(/®/g, '®'); //pattern = pattern.replace(/™/g, '™'); var filtered = []; for (var i = 0; i < array.length; i++) { for (var j = 0; j < array[i].length; j++) { if (array[i][j].slug == pattern) { var results = array[i]; var target = array[i][j]; results.splice(j, 1); results.splice(0, 0, target); filtered.push(results); if (array[i][0].slug == 'pc') { break; } } } } filtered.sort(function (a, b) { var pattern = /(\d{4})\.(\d{2})\.(\d{2})/; var ad = new Date(a[0].date.replace(pattern, '$1-$2-$3')); var bd = new Date(b[0].date.replace(pattern, '$1-$2-$3')); if (ad.toString() === "Invalid Date") { return -1; } if (bd.toString() === "Invalid Date") { return 1; } if (ad < bd) return 1; if (ad > bd) return -1; return 0; }); return filtered; } $(function () { $("#primary-menu .menu-item-object-platform").click(function (e) { e.preventDefault(); var target = $(e.currentTarget); if ($('#search-results').length > 0 && target.hasClass('selected')) { return; } $('#primary-menu li').removeClass('selected'); target.addClass('selected'); list(target.text(), null, null, false) }); $(".menu-item-object-custom").click(function (e) { var a = $(e.currentTarget).find("a"); if (a[0].href.indexOf('/product') != -1) { e.preventDefault(); if ($('#search-results').length > 0) { return; } search(null, false); } }); $("#primarynav-form").submit(function (e) { e.preventDefault(); search($('#titleInput').val().trim(), false); }); })