1// åå空éãã¿ã¼ã³ TYD_GDS_COMMON 2 3var TYD_GDC_COMMON = TYD_GDC_COMMON || {}; 4 5(function(ns, $) { 6 'use strict'; 7 8 // ------------------------------------------------------------ 9 // å ±é颿° 10 // ------------------------------------------------------------ 11 12 // æ£è¦è¡¨ç¾ã®ã¨ã¹ã±ã¼ã 13 function regExpEscape (str) { 14 return str.replace(/[-\/\\^$*+?.()|\[\]{}]/g, '\\$&'); 15 }; 16 // ããã«ã¯ã©ã¼ãã¼ã·ã§ã³ã®ã¨ã¹ã±ã¼ã 17 function dqEscape (str) { 18 return str.replace(/"/g, '\$&'); 19 } 20 21 // Query Stringã®ãã©ã¡ã¼ã¿ãåå¾ãã 22 function getParam(name, url) { 23 if (!url) url = window.location.href; 24 name = name.replace(/[\[\]]/g, "\\$&"); 25 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), 26 results = regex.exec(url); 27 if (!results) return null; 28 if (!results[2]) return ''; 29 return decodeURIComponent(results[2].replace(/\+/g, " ")); 30 } 31 32 // date: æ¥ä»ãªãã¸ã§ã¯ã 33 // format: æ¸å¼ãã©ã¼ããã 34 function formatDate (date, format) { 35 format = format.replace(/yyyy/g, date.getFullYear()); 36 format = format.replace(/MM/g, ('0' + (date.getMonth() + 1)).slice(-2)); 37 format = format.replace(/dd/g, ('0' + date.getDate()).slice(-2)); 38 format = format.replace(/HH/g, ('0' + date.getHours()).slice(-2)); 39 format = format.replace(/mm/g, ('0' + date.getMinutes()).slice(-2)); 40 format = format.replace(/ss/g, ('0' + date.getSeconds()).slice(-2)); 41 format = format.replace(/SSS/g, ('00' + date.getMilliseconds()).slice(-3)); 42 return format; 43 }; 44 45 function getLang() { 46 var lang = window.location.href.match(/_([^/]*)\.html/)[1]; 47 return lang; 48 } 49 50 function formatSize (size, decimal) { 51 //function formatSize (size, decimal = 2) { // IEç¨ã«æ¹ä¿® 52 //const { target, unit } = getTarget(size); 53 const tmp = getTarget(size); 54 const target = tmp.target; 55 const unit = tmp.unit; 56 const d = Math.pow(10, decimal); 57 58 const newSize = target !== null ? Math.floor((size / target) * d) / d : size; 59 60 return newSize + unit; 61 } 62 63 function getTarget (size) { 64 const kb = 1024 65 const mb = Math.pow(kb, 2) 66 const gb = Math.pow(kb, 3) 67 const tb = Math.pow(kb, 4) 68 69 if (size >= tb) return { target: tb, unit: 'TB' } 70 if (size >= gb) return { target: gb, unit: 'GB' } 71 if (size >= mb) return { target: mb, unit: 'MB' } 72 if (size >= kb) return { target: kb, unit: 'KB' } 73 74 return { target: null, unit: 'byte' } 75 } 76 77 function getFileName() { 78 return window.location.href.match(".+/(.+?)([\?#;].*)?$")[1]; 79 } 80 81 // ------------------------------------------------------------ 82 // åå空é TYD_CHROME_OS ã®å¤æ°ã»é¢æ°ãï¼å¤é¨ããå©ç¨ããªããï¼ 83 // ------------------------------------------------------------ 84 85 ns.regExpEscape = function (str) { 86 return regExpEscape(str); 87 }; 88 89 ns.dqEscape = function (str) { 90 return dqEscape(str); 91 }; 92 93 ns.getParam = function (name, url) { 94 return getParam(name, url); 95 }; 96 97 ns.formatDate = function (date, format) { 98 return formatDate(date, format); 99 }; 100 101 ns.formatSize = function (size, decimal) { 102 //ns.formatSize = function (size, decimal = 2) { // IEç¨ã«æ¹ä¿® 103 return formatSize(size, decimal); 104 } 105 106 ns.getLang = function () { 107 return getLang(); 108 } 109 110 ns.getFileName = function () { 111 return getFileName(); 112 } 113 ns.regionId; 114 115 $(document).on('change', '#select-lang', function(){ 116 var lang = $(this).val(); 117 var url = 'index_' + lang + '.html' + '?r=' + ns.regionId; 118 console.log(url); 119 location.href = url; 120 return true; 121 }); 122 123})(TYD_GDC_COMMON, jQuery);
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.