-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaffinity-calc.php
26 lines (24 loc) · 1.19 KB
/
affinity-calc.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
<?php
function cpu_affinity_calculator($atts) {
$atts = array_change_key_case((array)$atts, CASE_LOWER);
$rows = shortcode_atts(array('rows' => '8',), $atts)["rows"];
$scriptver = '09092021001'; // cache buster
$dir = str_replace($_SERVER['DOCUMENT_ROOT'], "", __DIR__);
wp_enqueue_script('affinity-calc',"$dir/affinity-calc.js",'',$scriptver);
$ret = "<table class=\"table table-striped\">";
for($cur_row=0;$cur_row<$rows;$cur_row++) {
$ret .= "<tr>";
for($cur_col=0;$cur_col<(64/$rows);$cur_col++) {
$cpu = ($cur_col*$rows)+$cur_row;
$ret .= sprintf("<td><input type=\"checkbox\" id=\"cpu%d\" name=\"cpu%d\" onclick=\"AffinityCalc.cpuCheck_event()\" class=\"cpu-checkbox\"> <label for=\"cpu%d\">CPU %d</label></td>", $cpu, $cpu, $cpu, $cpu);
}
$ret .= "</tr>";
}
$ret .= "</table>"
. "<input type=\"button\" value=\"invert\" id=\"btnInvert\" onclick=\"AffinityCalc.invert_event()\">"
. "<input type=\"button\" value=\"clear\" id=\"btnClear\" onclick=\"AffinityCalc.clear_event()\">"
. "<br />"
. "<label for=\"mask-hex\">CPU Affinity Bitmask (hex):</label> <input type=\"text\" size=\"26\" id=\"mask-hex\" name=\"mask-hex\" onchange=\"AffinityCalc.cpuMask_event()\">";
return $ret;
}
?>