-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_view.php
More file actions
122 lines (99 loc) · 2.54 KB
/
Copy pathadmin_view.php
File metadata and controls
122 lines (99 loc) · 2.54 KB
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
95
96
97
98
99
100
101
102
103
<div>Yeni sayfa oluşturup [area-calc] tag'ını sayfaya yapıştırın.</div>
<div ng-app="myApp" ng-controller="myCtrl as vm">
<form>
<table class="form-table-sample" border=1>
<tr>
<th></th>
<th>Window Type(Colour)</th>
<th>Price</th>
<th></th>
</tr>
<tr ng-repeat="option in vm.settings">
<th scope="row">
<label for="area_calc-one">{{$index}}</label>
</th>
<td>
<input type="text" ng-model="option.name">
</td>
<td>
<input type="number" ng-model="option.price">
</td>
<td>
<button ng-click="vm.del($index)">Delete</button>
</td>
</tr>
<tr>
<td colspan=4><button ng-click="vm.add()">Click me</button></td>
</tr>
</table>
<table class="form-table-sample" border=1>
<tr>
<th>Minimum Width (cm)</th>
<td><input type="number" ng-model="vm.minimum.width"></td>
</tr>
<tr>
<th>Minimum Height (cm)</th>
<td><input type="number" ng-model="vm.minimum.height"></td>
</tr>
</table>
</form>
<form method="POST" action="options.php">
<?php
settings_fields('area_calc');
do_settings_sections('area_calc');
?>
<input type="hidden" name="area_calc-one" value='{{vm.settings|json}}'>
<input type="hidden" name="area_calc-two" value='{{vm.minimum|json}}'>
<?php submit_button(); ?>
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.6/angular.min.js"></script>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http)
{
var vm = this;
var check = function(minimum)
{
if(!(minimum !== null && typeof minimum === 'object'))
{
minimum = {"height":1,"width":1};
}
if(minimum.height == '' || minimum.height < 1 || typeof minimum.height != 'number')
{
minimum.height = 1;
}
if(minimum.width == '' || minimum.width < 1 || typeof minimum.width != 'number')
{
minimum.width = 1;
}
return minimum;
}
var revise = function(x)
{
if(!Array.isArray(x))
{
return [{"name":'Sample',"price":10}];
}
var i,l=x.length,a=[];
for (i = 0; i < l; i++) {
if (x[i]['name']!='' && x[i]['name']!=null && x[i]['price']!='' && x[i]['price']!=null && typeof x[i]['price'] == 'number' && parseInt(x[i]['price'])>0)
{
x[i]['price'] = parseInt(x[i]['price']);
a.push(x[i]);
}
}
return a;
};
vm.settings = revise(<?php echo get_option('area_calc-one');?>);
vm.minimum = check(<?php echo get_option('area_calc-two');?>);
vm.add = function()
{
vm.settings.push({"name":null,"price":null});
}
vm.del = function(item)
{
vm.settings.splice(item, 1);
}
});
</script>