PageSourceSearch

https://sanyo-rec.co.jp/wp-content/themes/sitefactory-theme/js/jquery.autoKana.js?ver=6.6.10

js sanyo-rec.co.jp collected 2026-10-08 12:03:27 UTC 6,685 bytes, 198 lines download raw bytes

vendor: 5,578 bytes, lines 1-159
1// Copyright (c) 2013 Keith Perhac @ DelfiNet (http://delfi-net.com)
2//
3// Based on the AutoRuby library created by:
4// Copyright (c) 2005-2008 spinelz.org (http://script.spinelz.org/)
5//
6// Permission is hereby granted, free of charge, to any person obtaining
7// a copy of this software and associated documentation files (the
8// "Software"), to deal in the Software without restriction, including
9// without limitation the rights to use, copy, modify, merge, publish,
10// distribute, sublicense, and/or sell copies of the Software, and to
11// permit persons to whom the Software is furnished to do so, subject to
12// the following conditions:
13//
14// The above copyright notice and this permission notice shall be
15// included in all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25(function ($) {
26    $.fn.autoKana = function (element1, element2, passedOptions) {
27
28        var options = $.extend(
29            {
30                'katakana': false
31            }, passedOptions);
32
33        var kana_extraction_pattern = new RegExp('[^  ぁあ-んー]', 'g');
34        var kana_compacting_pattern = new RegExp('[ぁぃぅぇぉっゃゅょ]', 'g');
35        var elName,
36            elKana,
37            active = false,
38            timer = null,
39            flagConvert = true,
40            input,
41            values,
42            ignoreString,
43            baseKana;
44
45        elName = $(element1);
46        elKana = $(element2);
47        active = true;
48        _stateClear();
49
50        elName.blur(_eventBlur);
51        elName.focus(_eventFocus);
52        elName.keydown(_eventKeyDown);
53
54        function start() {
55            active = true;
56        };
57
58        function stop() {
59            active = false;
60        };
61
62        function toggle(event) {
63            var ev = event || window.event;
64            if (event) {
65                var el = Event.element(event);
66                if (el.checked) {
67                    active = true;
68                } else {
69                    active = false;
70                }
71            } else {
72                active = !active;
73            }
74        };
75
76        function _checkConvert(new_values) {
77            if (!flagConvert) {
78                if (Math.abs(values.length - new_values.length) > 1) {
79                    var tmp_values = new_values.join('').replace(kana_compacting_pattern, '').split('');
80                    if (Math.abs(values.length - tmp_values.length) > 1) {
81                        _stateConvert();
82                    }
83                } else {
84                    if (values.length == input.length && values.join('') != input) {
85                        if (input.match(kana_extraction_pattern)) {
86                            _stateConvert();
87                        }
88                    }
89                }
90            }
91        };
92
93        function _checkValue() {
94            var new_input, new_values;
95            new_input = elName.val()
96            if (new_input == '' && elKana.val() != '') {
97                _stateClear();
98                _setKana();
99            } else {
100                new_input = _removeString(new_input);
101                if (input == new_input) {
102                    return;
103                } else {
104                    input = new_input;
105                    if (!flagConvert) {
106                        new_values = new_input.replace(kana_extraction_pattern, '').split('');
107                        _checkConvert(new_values);
108                        _setKana(new_values);
109                    }
110                }
111            }
112        };
113
114        function _clearInterval() {
115            clearInterval(timer);
116        };
117
118        function _eventBlur(event) {
119            _clearInterval();
120        };
121        function _eventFocus(event) {
122            _stateInput();
123            _setInterval();
124        };
125        function _eventKeyDown(event) {
126            if (flagConvert) {
127                _stateInput();
128            }
129        };
130        function _isHiragana(chara) {
131            return ((chara >= 12353 && chara <= 12435) || chara == 12445 || chara == 12446);
132        };
133        function _removeString(new_input) {
134            if (new_input.indexOf(ignoreString) !== -1) {
135                return new_input.replace(ignoreString, '');
136            } else {
137                var i, ignoreArray, inputArray;
138                ignoreArray = ignoreString.split('');
139                inputArray = new_input.split('');
140                for (i = 0; i < ignoreArray.length; i++) {
141                    if (ignoreArray[i] == inputArray[i]) {
142                        inputArray[i] = '';
143                    }
144                }
145                return inputArray.join('');
146            }
147        };
148        function _setInterval() {
149            var self = this;
150            timer = setInterval(_checkValue, 30);
151        };
152        function _setKana(new_values) {
153            if (!flagConvert) {
154                if (new_values) {
155                    values = new_values;
156                }
157                if (active) {
158                    var _val = _toKatakana(baseKana + values.join(''));
159                    elKana.val(_val).change(
vendor: 1,107 bytes, lines 159-198
159);
160                }
161            }
162        };
163        function _stateClear() {
164            baseKana = '';
165            flagConvert = false;
166            ignoreString = '';
167            input = '';
168            values = [];
169        };
170        function _stateInput() {
171            baseKana = elKana.val();
172            flagConvert = false;
173            ignoreString = elName.val();
174        };
175        function _stateConvert() {
176            baseKana = baseKana + values.join('');
177            flagConvert = true;
178            values = [];
179        };
180        function _toKatakana(src) {
181            if (options.katakana) {
182                var c, i, str;
183                str = new String;
184                for (i = 0; i < src.length; i++) {
185                    c = src.charCodeAt(i);
186                    if (_isHiragana(c)) {
187                        str += String.fromCharCode(c + 96);
188                    } else {
189                        str += src.charAt(i);
190                    }
191                }
192                return str;
193            } else {
194                return src;
195            }
196        }
197    };
198})(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.