-
Notifications
You must be signed in to change notification settings - Fork 11
/
base.js
94 lines (76 loc) · 2.51 KB
/
base.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
91
92
93
94
// Export
module.exports = {
data() {
return {
form: new SparkForm({
id: 0,
error: 0,
collection_id: 0,
tool: '',
code: ''
})
};
},
mounted() {
// Dispatch
this.dispatchData();
},
methods: {
// udef
udef(value) {
return (value == undefined ? '' : value);
},
// udefHide
udefHide(form, value, tab = true) {
return (this.udef(form) != ''
? (tab ? ',\n '+value(form) : value(form))
: ''
);
},
// curlyList
curlyList(value, pretty = false) {
// Variables
var returnValue = '';
var tab = ' ';
var notSingle = false;
if(pretty) {
var singleMatch = this.udef(value).match(/,/g);
notSingle = singleMatch != null && singleMatch.length >= 1 && pretty;
}
// Value
returnValue += '{'+(notSingle ? '\n'+tab+tab : '');
returnValue += (!pretty ? this.udef(value) : this.udef(value).replace(/, /g, ',\n'+tab+tab));
returnValue += (notSingle ? '\n'+tab : '')+'}';
// Return
return returnValue;
},
// dispatchData
dispatchData() {
Bus.$emit('tool-data', this.$data);
},
// luaColor
luaColor(value, event) {
var colorTable = event.color.toRGB();
var colorValue = 'Color(%r, %g, %b, 255)';
$.each(['r', 'g', 'b'], function(index, value) {
colorValue = colorValue.replace('%'+value, colorTable[value]);
});
return colorValue;
},
// luaColorWatch
luaColorWatch(value) {
var colorPattern = 'Color\\(([0-9]{1,3}), ([0-9]{1,3}), ([0-9]{1,3}), 255\\)';
var colorMatches = value.match(new RegExp(colorPattern))
if(!colorMatches || colorMatches.length < 4) { return value; }
return 'rgb('+colorMatches[1]+', '+colorMatches[2]+', '+colorMatches[3]+')';
}
},
created() {
// Variables
var vm = this;
// tool-form
Bus.$on('tool-form', function(form) {
vm.form = form;
});
}
};