-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.php
executable file
·85 lines (73 loc) · 2.77 KB
/
settings.php
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
<?php
only_admin_access();
$optionGroup = seven_get_option_group();
?>
<div class='module-live-edit-settings'>
<div class='setting-item' id='setting-item'>
<div class="form-group">
<div class='mw-ui-box-content mw-accordion-content'>
<h2><?php _e('General') ?></h2>
<div class='mw-ui-field-holder'>
<label class='control-label' for='apiKey'>
<?php _e('API Key') ?></label>
<input class='form-control mw_option_field'
id='apiKey'
maxlength='90'
name='apiKey'
option-group='<?= $optionGroup ?>'
type='text'
value='<?= seven_get_api_key() ?>'
/>
</div>
<hr>
<h2><?php _e('SMS') ?></h2>
<div class='mw-ui-field-holder'>
<label class='control-label' for='sms_from'>
<?php _e('From') ?></label>
<input class='form-control mw_option_field'
id='sms_from'
maxlength='16'
name='sms_from'
option-group='<?= $optionGroup ?>'
type='text'
value='<?= seven_get_sms_from() ?>'
/>
</div>
</div>
</div>
</div>
</div>
<script>
seven_settings = {
init: function (item) {
$(item.querySelectorAll('input[type="text"]')).on('keyup', function () {
mw.on.stopWriting(this, function () {
console.log('seven_settings:OnStopWriting');
seven_settings.save();
});
});
},
collect: function () {
var all = document.querySelectorAll('.setting-item');
var data = {};
for (var i = 0; i < all.length; i++)
data.apiKey = all[i].querySelector('input[name=apiKey]').value;
return data;
},
save: function () {
mw.$('#settingsfield').val(JSON.stringify(seven_settings.collect()))
.trigger('change');
}
};
$(document).ready(function () {
mw.options.form('.<?= $config['module_class'] ?>', function () {
mw.notification.success("<?php _ejs("All changes are saved") ?>.");
});
var all = document.querySelectorAll('.setting-item'), l = all.length, i = 0;
for (; i < l; i++) {
if (!!all[i].prepared) continue;
all[i].prepared = true;
seven_settings.init(all[i]);
}
});
</script>