1var DEFAULT_NOTIFY_TIME = 3*1000; 2var GMOCL_HAKARU_AI = GMOCL_HAKARU_AI || {}; 3//get width 4var browserWidth = $(window).width(); 5 6const checkWidth = function() { 7 if(browserWidth <= 767.79) { 8 $('button[data-target = "#navbar"]').on( 'click', function() { 9 setTimeout(function(){ 10 //get height 11 var navbar_ul_height = $('#navbar-nav-ul').outerHeight(true); 12 //edit css 13 $('.navbar-default .navbar-nav.sp-ftlogo').css('padding-top','calc(100vh - (60px + ' + navbar_ul_height + 'px + 20px + 20px))'); 14 }, 250); 15 }); 16 } 17}; 18 19$(function(){ 20 checkWidth(); 21 $(window).resize(checkWidth); 22 commonLink() 23}); 24 25 26// popover.js star 27/*$(function () { 28 $('[data-toggle="popover"]').popover({ 29 html:true, 30 trigger: 'manual'}); 31});*/ 32 33$('#li-popover').popover({ 34 html:true, 35 content: 'hogehoge', 36 trigger: 'manual' 37}); 38 39var popover_show = 0; 40 41$('#li-popover').click(function(evt){ 42 if(popover_show == 1){ 43 $('#li-popover').popover('hide'); 44 //console.log('ãã§ã«éãã¦ããããé表示ã«ãã¾ãã'); 45 }else{ 46 evt.stopPropagation(); 47 $(this).popover('show'); 48 popover_show = 1; 49 //console.log('#li-popoverã®ã¯ãªãã¯ã§è¡¨ç¤ºããã¾ãã'); 50 } 51}); 52 53$(document).on('click', '.popover', function(evt) { 54 evt.stopPropagation(); 55 //console.log('popovernå ã§ã®ã¯ãªãã¯ã¯ç¡å¹ã§ã'); 56}); 57 58$(document).on('click', 'html', function() { 59 $('#li-popover').popover('hide'); 60 popover_show = 0; 61 //console.log('ã¨ãªã¢å¤ã®ã¯ãªãã¯ã§é表示ã«ãã¾ãã'); 62}); 63 64 65 66 67// popover.js end 68 69$(function () { 70 $('[data-toggle="tooltip"]').tooltip(); 71 on_notify_msg(); 72}); 73 74function createErrorDialog(msg, delay) { 75 new PNotify({ 76 title: 'Oh No!', 77 text: msg, 78 type: 'error', 79 delay: delay || DEFAULT_NOTIFY_TIME, 80 }); 81} 82 83function createSuccessDialog(msg, delay) { 84 new PNotify({ 85 title: 'Success!', 86 text: msg, 87 type: 'success', 88 delay: delay || DEFAULT_NOTIFY_TIME, 89 }); 90} 91 92function notify_success_msg(ttl, text){ 93 if (text === undefined || text === null) 94 text = ''; 95 var opts = $create_pnotify_option(ttl, text); 96 opts.type = 'success'; 97 new PNotify(opts); 98} 99 100function notify_err_msg(ttl, text){ 101 if (text === undefined || text === null) 102 text = ''; 103 var opts = $create_pnotify_option(ttl, text); 104 opts.type = 'error'; 105 opts.delay = 1000*10; 106 new PNotify(opts); 107} 108 109function notify_warning_msg(ttl, text){ 110 var opts = $create_pnotify_option(ttl, text); 111 opts.type = 'notice'; 112 opts.delay = 1000*10; 113 new PNotify(opts); 114} 115 116function notify_info_msg(ttl, text){ 117 var opts = $create_pnotify_option(ttl, text); 118 opts.type = 'info'; 119 new PNotify(opts); 120} 121 122function notify_msg(type, ttl, text){ 123 if (text === undefined || text === null) text = ''; 124 const opts = $create_pnotify_option(ttl, text); 125 opts.type = type 126 new PNotify(opts); 127} 128 129function $create_pnotify_option(ttl, text){ 130 var stack_bar_top = {"dir1": "up", "dir2": "right", "spacing1": 0, "spacing2": 0}; 131 var opts = { 132 title: ttl, 133 addclass: "stack-bar-top", 134 styling: 'bootstrap3', 135 cornerclass: "", 136 width: "70%", 137 delay: 1000*5, 138 stack: stack_bar_top 139 }; 140 if (text) { 141 opts.text = text; 142 } 143 return opts; 144} 145 146// Show notify box and keep it 147function keep_warning_msg(ttl, text) { 148 var stack_bar_top = {"dir1": "down", "dir2": "right", "push": "top", "spacing1": 0, "spacing2": 0}; 149 var opts = { 150 type: 'notice', 151 title: ttl, 152 addclass: "stack-keep-warning", 153 styling: 'bootstrap3', 154 cornerclass: "", 155 hide: false, 156 stack: stack_bar_top, 157 width: "60%" 158 }; 159 if (text) { 160 opts.text = text; 161 } 162 new PNotify(opts); 163} 164 165function notify_error_to_page(ttl, msg, url){ 166 set_cookies('notify_msg', {type: 'error', title: ttl, msg: msg}); 167 location.href = url; 168} 169 170function notify_to_page(ttl, msg, url){ 171 // console.log(ttl, msg, url); 172 set_cookies('notify_msg', {type: 'success', title: ttl, msg: msg}); 173 location.href = url; 174} 175 176function on_notify_msg(){ 177 // console.log('no_notify_msg!!'); 178 const msg = get_cookies('notify_msg'); 179 if (msg !== null) { 180 notify_msg(msg.type, msg.title, msg.msg) 181 remove_cookies('notify_msg'); 182 } 183} 184 185function create_error_msg(msg){ 186 $create_msg('msg-area', msg, 'alert alert-danger'); 187} 188 189function create_error_msg2(msg){ 190 $create_msg2('msg-area', msg, 'alert alert-danger'); 191} 192 193function create_warning_msg(msg){ 194 $create_msg('msg-area', msg, 'alert alert-warning'); 195} 196 197function create_warning_msg2(msg){ 198 $create_msg2('msg-area', msg, 'alert alert-warning'); 199} 200 201function create_success_info(msg){ 202 $create_msg('msg-area', msg, 'alert alert-info'); 203} 204 205function create_success_msg(msg){ 206 $create_msg('msg-area', msg, 'alert alert-success'); 207} 208 209function $create_msg(id, msg, cl){ 210 $('#' + id).attr('class', cl); 211 $('#' + id).text(msg); 212 $('#' + id).show(); 213} 214 215function $create_msg2(id, msg, cl){ 216 $('#' + id).attr('class', cl); 217 $('#' + id).html(msg); 218 $('#' + id).show(); 219} 220 221function get_cookies(key) { 222 var val = Cookies.getJSON(key); 223 if (val) 224 return val; 225 226 return null; 227} 228 229function get_cookies_cb(key, callback) { 230 var val = Cookies.getJSON(key); 231 if (val) 232 callback(null, val); 233 callback('NG'); 234} 235 236function set_cookies(key, value, expires) { 237 const is_secure = !!location.protocol.match(/^https/i); 238 const options = { 239 expires: expires || 365, 240 secure: is_secure, 241 samesite: 'Lax', 242 path: '/' 243 }; 244 Cookies.set(key, value, options); 245} 246 247function remove_cookies(key) { 248 Cookies.remove(key); 249} 250 251function get(url, success_cb, error_cb) { 252 253 if (! success_cb) 254 success_cb = function(data, dataType) { 255 console.log('success'); 256 console.log('data', data); 257 console.log('dataType', dataType); 258 dialog(data); 259 }; 260 261 if (! error_cb) 262 error_cb = function(data, dataType) { 263 console.log('error'); 264 console.log('data', data); 265 console.log('dataType', dataType); 266 dialog(data); 267 }; 268 269 $.ajax({ 270 type: 'GET', 271 url: url, 272 async: true, 273 dataType: 'json', 274 contentType: 'application/json', 275 timeout: 300000, 276 success: success_cb, 277 error: error_cb 278 }); 279 280 function dialog(data) { 281 if (data.status == 200) 282 notify_success_msg('æåï¼', 'æåï¼'); 283 else 284 notify_err_msg('失æ', '失æ'); 285 286 } 287} 288 289function post(url, val, success_cb, arg_error_cb, auth_error=true) { 290 291 if (! success_cb) 292 success_cb = function(data, dataType) { 293 console.log('success'); 294 console.log('data', data); 295 console.log('dataType', dataType); 296 dialog(data); 297 }; 298 299 const default_error_cb = function(data, dataType) { 300 console.log('error'); 301 console.log('data', data); 302 console.log('dataType', dataType); 303 dialog(data); 304 }; 305 306 const error_cb = function(data, dataType) { 307 console.error('base_post:', data.status, dataType) 308 if (auth_error && data.status === 401) { 309 notify_err_msg(get_i18n().base.NG, get_i18n().auth.session_expired) 310 $('#loading-modal').modal('hide') 311 return 312 } 313 if (arg_error_cb) { 314 arg_error_cb(data, dataType) 315 } else { 316 default_error_cb(data, dataType) 317 } 318 } 319 320 $.ajax({ 321 type: 'POST', 322 headers: {'csrf-token': $('#token-a').data('token-a')}, 323 url: url, 324 async: true, 325 dataType: 'json', 326 contentType: 'application/json', 327 data: JSON.stringify(val), 328 timeout: 400000, 329 success: success_cb, 330 error: error_cb 331 }); 332 333 function dialog(data) { 334 if (data.status == 200) 335 notify_success_msg('æåï¼', 'æåï¼'); 336 else 337 notify_err_msg('失æ', '失æ'); 338 } 339} 340 341function __delete(url, success_cb, arg_error_cb) { 342 343 if (! success_cb) 344 success_cb = function(data, dataType) { 345 console.log('success'); 346 console.log('data', data); 347 console.log('dataType', dataType); 348 dialog(data); 349 }; 350 351 const default_error_cb = function(data, dataType) { 352 console.log('error'); 353 console.log('data', data); 354 console.log('dataType', dataType); 355 dialog(data); 356 }; 357 358 const error_cb = function(data, dataType) { 359 console.error('base_post:', data.status, dataType) 360 if (data.status === 401) { 361 notify_err_msg(get_i18n().base.NG, get_i18n().auth.session_expired) 362 $('#loading-modal').modal('hide') 363 return 364 } 365 if (arg_error_cb) { 366 arg_error_cb(data, dataType) 367 } else { 368 default_error_cb(data, dataType) 369 } 370 } 371 372 if (! error_cb) 373 error_cb = function(data, dataType) { 374 console.log('error'); 375 console.log('data', data); 376 console.log('dataType', dataType); 377 dialog(data); 378 }; 379 380 $.ajax({ 381 type: 'DELETE', 382 headers: {'csrf-token': $('#token-a').data('token-a')}, 383 url: url, 384 async: true, 385 success: success_cb, 386 error: error_cb 387 }); 388 389 function dialog(data) { 390 if (data.status == 200) { 391 const msg = get_i18n().base.OK; 392 notify_success_msg(msg, msg); 393 } else { 394 const msg = get_i18n().base.NG; 395 notify_err_msg(msg, msg); 396 } 397 } 398} 399 400function post_download(url, val, success_cb, _error_cb) { 401 402 if (_error_cb) { 403 error_cb = function(data, dataType) { 404 console.log('post_download:', data.status, dataType) 405 if (data.status === 401) { 406 notify_err_msg(get_i18n().base.NG, get_i18n().auth.session_expired) 407 $('#loading-modal').modal('hide') 408 $('#csv-loading-modal').modal('hide') 409 return 410 } 411 _error_cb(data, dataType) 412 } 413 } 414 415 $.ajax({ 416 type: 'POST', 417 headers: {'csrf-token': $('#token-a').data('token-a')}, 418 url: url, 419 dataType: 'binary', 420 responseType:'blob', 421 async: false, 422 contentType: 'application/json', 423 data: JSON.stringify(val), 424 timeout: 10 * 60 * 1000, // 10å 425 success: success_cb, 426 error: error_cb 427 }); 428 429} 430 431// form post æã«èªè¨¼ã®æ¤è¨¼ãè¡ã 432function verifyPostForm() { 433 const url = '/account/verify' 434 435 return new Promise((resolve, reject) => { 436 post(url, function(data){ 437 resolve(data.result) 438 }, function(data, dataType) { 439 console.log(data, dataType) 440 resolve({data, dataType}) 441 }) 442 }) 443} 444 445 446function to_page(url, millsec){ 447 setTimeout(function(){ 448 window.location.href = url; 449 }, millsec); 450} 451 452if (navigator.userAgent.match(/(iPhone|iPad|iPod|Android)/)) { 453 //tel for SP 454 $(function() { 455 $('#tel-num').each(function() { 456 var str = $(this).html(); 457 $(this).html($('<a>').attr('href', 'tel:' + $(this).text().replace(/-/g, '')).append(str + '</a>')); 458 }); 459 $('.input-checkbox').each(function(){ 460 $(this).addClass('no-hover-action'); 461 }); 462 }); 463}else { 464 $('.side-bar').each(function(){ 465 $(this).addClass('get-hover'); 466 }); 467} 468 469/** 470 * å ¥åãã©ã¼ã ã®å ¥åç¶æ ããã§ãã¯ãã 471 * 472 * @param {Array} requireFields 473 */ 474function is_make_disable_save_button(requireFields) { 475 const hakaru_common = new GMOCL_HAKARU_AI.common.modules(); 476 const locale = hakaru_common.get_locale_saved_server();
477 const is_kana_field = function (field_name) { 478 return field_name.match(/-kana$/) ? true : false; 479 } 480 481 for (let idx=0; idx < requireFields.length; idx++) { 482 let elem = $(requireFields[idx]); 483 if (elem.length === 0) { 484 continue; 485 } 486 487 let skip_kana = (locale != 'ja' && is_kana_field(elem.attr('id'))); 488 let node_name = elem[0].nodeName; 489 let checkbox = (elem[0].type === 'checkbox'); 490 491 if (checkbox && !elem[0].checked) { 492 return true; 493 } 494 if (node_name == 'INPUT' && !checkbox && !skip_kana) { 495 if (elem.val().length == 0) { 496 return true; 497 } 498 if (elem.nextAll('span.error-message').text().trim().length > 0) { 499 return true; 500 } 501 } 502 if (node_name == 'SELECT') { 503 if (elem.find('option:selected').val() == 0) { 504 return true; 505 } 506 } 507 } 508 return false; 509} 510 511function get_i18n() { 512 const locale = getLocale(); 513 return (GMOCL_HAKARU_AI.lang[locale]) ? GMOCL_HAKARU_AI.lang[locale] : GMOCL_HAKARU_AI.lang.en; 514} 515 516function getLocale() { 517 const hakaru_common = new GMOCL_HAKARU_AI.common.modules(); 518 return hakaru_common.get_locale_saved_server(); 519} 520 521function getUrlVars(){ 522 var vars = {}; 523 var param = location.search.substring(1).split('&'); 524 for(var i = 0; i < param.length; i++) { 525 var keySearch = param[i].search(/=/); 526 var key = ''; 527 if(keySearch != -1) key = param[i].slice(0, keySearch); 528 var val = param[i].slice(param[i].indexOf('=', 0) + 1); 529 if(key != '') vars[key] = decodeURI(val); 530 } 531 return vars; 532} 533 534function get_user_channel_type() { 535 return GMOCL_HAKARU_AI.channel_type || 1; 536} 537 538function getPrivacyPolicyUrlWithLocale(locale) { 539 locale = locale || window.navigator.language; 540 return (locale == 'ja') 541 ? 'https://gmogshd.com/privacy/' 542 : 'https://gmogshd.com/english/privacy/'; 543} 544 545/** 546 * 飿³é åãé£çµ 547 * Object.assign ãå©ç¨ã§ããªã IE å¯¾å¿ 548 */ 549function arrayMerge() { 550 if (arguments.length === 0) return false; 551 552 let i, len, key, result = {}; 553 for (i = 0, len = arguments.length;i < len; i++) { 554 if (typeof arguments[i] !== 'object') { 555 continue; 556 } 557 for (key in arguments[i]) { 558 result[key] = arguments[i][key]; 559 } 560 } 561 return result; 562}; 563 564function commonLink() { 565 $('button').each((_, btn) => { 566 const link = $(btn).data('link') 567 if (link) { 568 btn.addEventListener("click", () => {location.href=link}) 569 } 570 }) 571 572 $('input').each((_, input) => { 573 const isBack = $(input).data('back') 574 if (isBack) { 575 input.addEventListener("click", () => {history.back()}) 576 } 577 578 const link = $(input).data('link') 579 if (link) { 580 input.addEventListener("click", () => {location.href=link}) 581 } 582 }) 583} 584 585 586/** 587 * GMO Cloud hakaru common 588 */ 589GMOCL_HAKARU_AI.common = { 590 591 modules: (function () { 592 593 var __get_base_url = function () { 594 var port = ':' + location.port; 595 if (port == 80 || port == 443) { 596 port = ''; 597 } 598 return location.protocol + '//' + location.hostname + port; 599 } 600 601 var __call_api = function (uri, method, data) { 602 method = method || 'GET'; 603 data = data || {}; 604 url = __get_base_url() + uri; 605 606 return $.ajax({ 607 url: url, 608 headers: {'csrf-token': $('#token-a').data('token-a')}, 609 type: method, 610 dataType: 'json', 611 data: data 612 }); 613 } 614 615 var __get_user_time_zone = function () { 616 let uri = '/user/timezone'; 617 var def = $.Deferred(); 618 619 __call_api(uri) 620 .then(function (resjson) { 621 def.resolve(resjson.time_zone); 622 }).fail (function (xhr) { 623 def.reject(xhr.statusText); 624 }); 625 return def; 626 } 627 628 var __get_user_locale = function () { 629 let uri = '/user/locale'; 630 var def = $.Deferred(); 631 632 __call_api(uri) 633 .then(function (resjson) { 634 def.resolve(resjson.locale); 635 }).fail (function (xhr) { 636 def.reject(xhr.statusText); 637 }); 638 return def; 639 } 640 641 var __get_available_locale_list = function () { 642 const uri = '/user/locale/list' 643 var def = $.Deferred(); 644
645 __call_api(uri) 646 .then(function (resjson) { 647 const available_list = resjson.locale_list; 648 // console.log("available_list"+JSON.stringify(available_list)) 649 def.resolve(available_list); 650 }).fail (function (xhr) { 651 def.reject(xhr.statusText); 652 }); 653 return def; 654 } 655 656 /** 657 * Initialize locale/time-zone in client 658 */ 659 var __init_moment_locale = function() { 660 var def = $.Deferred(); 661 662 $.when(__get_user_time_zone(), __get_user_locale(), __get_available_locale_list()) 663 .then (function (current_tz, current_lc, lc_list) { 664 // console.log(current_tz, current_lc, lc_list) 665 let def2 = $.Deferred(); 666 667 if (current_lc) { 668 __set_locale_saved_server(current_lc); 669 } 670 671 if (current_tz && current_lc) { 672 return def2.resolve(current_tz, current_lc); 673 } 674 const browser_setting = __check_browser_locale(); 675 const update_tz = current_tz || browser_setting.time_zone; 676 let update_lc = current_lc || browser_setting.locale; 677 let is_available = false; 678 679 for (let idx = 0; idx < lc_list.length; idx++) { 680 if (lc_list[idx].locale == update_lc) { 681 is_available = true; 682 break; 683 } 684 } 685 686 if (!is_available) { 687 update_lc = 'en'; 688 } 689 690 // If it hasn't added locale/time-zone to the user session, 691 // set them by the browser's. 692 return __post_user_locale(update_lc, update_tz) 693 .then(function() { 694 return def2.resolve(update_tz, update_lc); 695 }).catch(function(err) { 696 return def2.reject(err); 697 }) 698 }).then(function (tz, lc) { 699 moment.tz.setDefault(tz); 700 moment.tz.zone(tz); 701 moment.locale(lc); 702 def.resolve(tz, lc); 703 }).fail(function (xhr) { 704 def.reject(xhr.statusText); 705 }); 706 707 return def; 708 } 709 710 var __post_user_locale = function (locale, time_zone) { 711 var data = {'locale': locale, 'time_zone': time_zone}; 712 // console.log("data: "+data) 713 __set_locale_saved_server(locale); 714 return __call_api('/user/locale/update', 'post', data); 715 } 716 717 var __check_browser_locale = function () { 718 const locale = 719 (window.navigator.languages && window.navigator.languages[0]) || 720 window.navigator.language || 721 window.navigator.userLanguage || 722 window.navigator.browserLanguage; 723 const time_zone = moment.tz.guess(true); 724 725 return {locale: locale, time_zone: time_zone}; 726 } 727 728 var __get_locale_saved_server = function () { 729 return GMOCL_HAKARU_AI.lang.locale_saved_server ; 730 } 731 732 var __set_locale_saved_server = function (locale) { 733 // console.log('__set_locale_saved_server: ' + locale) 734 if (locale && locale.toString().trim() != '') { 735 GMOCL_HAKARU_AI.lang.locale_saved_server = locale; 736 } 737 } 738 739 /** 740 * ã¦ã¼ã¶ã¼ãã±ã¼ã«ã«ãã£ã¦ããªã¬ãå ¥åãã£ã¼ã«ãã®è¡¨ç¤ºï¼é表示ãåãæ¿ãã 741 */ 742 var __toggle_kana_field = function () { 743 const locale = __get_locale_saved_server(); 744 745 $('input').each(function(index, element){ 746 let field_name = $(element).attr('id'); 747 if (field_name && field_name.match(/-kana$/)) { 748 let toggle_area = $(element).parent().parent(); 749 toggle_area = toggle_area.parent().hasClass('form-group') ? toggle_area.parent() : toggle_area 750 751 if (locale == 'ja') { 752 toggle_area.show(); 753 $(element).attr('required', true); 754 } else { 755 toggle_area.hide(); 756 $(element).removeAttr('required'); 757 } 758 } 759 }); 760 } 761 762 return { 763 call_api: __call_api, 764 get_user_time_zone: __get_user_time_zone, 765 get_user_locale: __get_user_locale, 766 init_moment_locale: __init_moment_locale, 767 check_browser_locale: __check_browser_locale, 768 get_locale_saved_server: __get_locale_saved_server, 769 set_locale_saved_server: __set_locale_saved_server, 770 toggle_kana_field: __toggle_kana_field 771 }; 772 }) // modules 773};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.