-
Notifications
You must be signed in to change notification settings - Fork 4
/
jquery.replaceInput.js
90 lines (73 loc) · 4.17 KB
/
jquery.replaceInput.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
jQuery.fn.input = function(spanMatch, checkCase, bound) {
if (bound === undefined) {
bound = true;
}
bound = bound ? '\\b' : '';
checkCase = checkCase ? '' : 'i';
function innerInput(node, pat) {
var skip = 0;
if (node.nodeType == 3) {
var re = new RegExp(bound + pat + bound, checkCase);
var pos = node.data.search(re);
if (pos >= 0) {
var span = document.createElement('span');
span.innerHTML = spanMatch[pat];
var middlebit = node.splitText(pos);
middlebit.splitText(pat.length);
middlebit.parentNode.replaceChild(span, middlebit);
skip = 1;
}
} else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
for (var i = 0; i < node.childNodes.length; ++i) {
i += innerInput(node.childNodes[i], pat);
}
}
return skip;
}
return this.each(function() {
for (var pat in spanMatch) {
innerInput(this, pat);
}
});
};
var viewInput = {
"punch" : "<span class='button'>P</span>",
"pp" : "<span style='white-space:nowrap;'><span class='button'>P</span><span class='button flow'>P</span></span>",
"ppp" : "<span style='white-space:nowrap;'><span class='button'>P</span><span class='button flow'>P</span><span class='button flow'>P</span></span>",
"kick" : "<span class='button'>K</span>",
"kk" : "<span style='white-space:nowrap;'><span class='button'>K</span><span class='button flow'>K</span></span>",
"kkk" : "<span style='white-space:nowrap;'><span class='button'>K</span><span class='button flow'>K</span><span class='button flow'>K</span></span>",
"lp" : "<span class='button'>LP</span>",
"mp" : "<span class='button'>MP</span>",
"hp" : "<span class='button'>HP</span>",
"lk" : "<span class='button'>LK</span>",
"mk" : "<span class='button'>MK</span>",
"hk" : "<span class='button'>HK</span>",
"slash" : "<span class='button'>S</span>",
"hs" : "<span class='button'>HS</span>",
"dust" : "<span class='button'>D</span>",
"fp" : "<span class='button'>FP</span>",
"bp" : "<span class='button'>BP</span>",
"fk" : "<span class='button'>FK</span>",
"bk" : "<span class='button'>BK</span>",
"up" : "<img class='rotate8' src='/raviolist/img/arrow_a.png' />",
"upforward" : "<img class='rotate9' src='/raviolist/img/arrow_a.png' />",
"forward" : "<img class='rotate6' src='/raviolist/img/arrow_a.png' />",
"downforward" : "<img class='rotate3' src='/raviolist/img/arrow_a.png' />",
"down" : "<img class='rotate2' src='/raviolist/img/arrow_a.png' />",
"downback" : "<img class='rotate1' src='/raviolist/img/arrow_a.png' />",
"back" : "<img class='rotate4' src='/raviolist/img/arrow_a.png' />",
"upback" : "<img class='rotate7' src='/raviolist/img/arrow_a.png' />",
"chdown" : "<img class='rotate2' src='/raviolist/img/arrow_b.png' />",
"chdownback" : "<img class='rotate1' src='/raviolist/img/arrow_b.png' />",
"chback" : "<img class='rotate4' src='/raviolist/img/arrow_b.png' />",
"dpf" : "<span style='white-space:nowrap;'><img class='rotate6' src='/raviolist/img/arrow_a.png' /><img class='flow rotate2' src='/raviolist/img/arrow_a.png' /><img class='flow rotate3' src='/raviolist/img/arrow_a.png' /></span>",
"dpb" : "<span style='white-space:nowrap;'><img class='rotate4' src='/raviolist/img/arrow_a.png' /><img class='flow rotate2' src='/raviolist/img/arrow_a.png' /><img class='flow rotate1' src='/raviolist/img/arrow_a.png' /></span>",
"qcf" : "<img class='rotate1' src='/raviolist/img/qcf.png' />",
"qcb" : "<img class='rotate3' src='/raviolist/img/qcb.png' />",
"hcf" : "<img class='rotate1' src='/raviolist/img/hcf.png' />",
"hcb" : "<img class='rotate3' src='/raviolist/img/hcb.png' />",
"360" : "<img class='rotate4' src='/raviolist/img/360.png' />",
"cwing" : "<img class='rotate2' src='/raviolist/img/hcf.png' />",
};
$('.move_input').input(viewInput);