MISP/app/View/Events/add.ctp

107 lines
3.5 KiB
Plaintext
Raw Normal View History

<div class="events form">
<?php echo $this->Form->create('', array('type' => 'file'));?>
<fieldset>
2013-06-01 11:05:15 +02:00
<legend>Add Event</legend>
<?php
echo $this->Form->input('date', array(
'type' => 'text',
'class' => 'datepicker'
));
$initialDistribution = 3;
if (Configure::read('MISP.default_event_distribution') != null) {
$initialDistribution = Configure::read('MISP.default_event_distribution');
}
2013-06-01 11:05:15 +02:00
if ('true' == Configure::read('CyDefSIG.sync')) {
echo $this->Form->input('distribution', array(
2013-06-10 20:34:05 +02:00
'options' => array($distributionLevels),
2013-06-01 11:05:15 +02:00
'label' => 'Distribution',
'selected' => $initialDistribution,
2013-06-01 11:05:15 +02:00
));
}
echo $this->Form->input('risk', array(
'div' => 'input clear'
));
echo $this->Form->input('analysis', array(
'options' => array($analysisLevels),
));
echo $this->Form->input('info', array(
'div' => 'clear',
'class' => 'input-xxlarge'
));
echo $this->Form->input('Event.submittedgfi', array(
'label' => '<b>GFI sandbox</b>',
'type' => 'file',
'div' => 'clear'
));
?>
</fieldset>
2013-06-01 11:05:15 +02:00
<?php
echo $this->Form->button('Add', array('class' => 'btn btn-primary'));
echo $this->Form->end();
?>
</div>
<?php
echo $this->element('side_menu', array('menuList' => 'event-collection', 'menuItem' => 'add'));
?>
<script type="text/javascript">
//
//Generate tooltip information
//
2013-06-10 23:56:35 +02:00
var formInfoValues = {
'EventDistribution' : new Array(),
'EventRisk' : new Array(),
'EventAnalysis' : new Array()
};
<?php
foreach ($distributionDescriptions as $type => $def) {
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
2013-06-10 23:56:35 +02:00
echo "formInfoValues['EventDistribution']['" . addslashes($type) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
}
foreach ($riskDescriptions as $type => $def) {
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
2013-06-10 23:56:35 +02:00
echo "formInfoValues['EventRisk']['" . addslashes($type) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
}
foreach ($analysisDescriptions as $type => $def) {
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
2013-06-10 23:56:35 +02:00
echo "formInfoValues['EventAnalysis']['" . addslashes($type) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
}
?>
2013-06-06 16:36:28 +02:00
$(document).ready(function() {
$("#EventAnalysis, #EventRisk, #EventDistribution").on('mouseleave', function(e) {
$('#'+e.currentTarget.id).popover('destroy');
});
$("#EventAnalysis, #EventRisk, #EventDistribution").on('mouseover', function(e) {
var $e = $(e.target);
if ($e.is('option')) {
$('#'+e.currentTarget.id).popover('destroy');
$('#'+e.currentTarget.id).popover({
trigger: 'focus',
2013-06-06 16:36:28 +02:00
placement: 'right',
2013-06-10 23:56:35 +02:00
content: formInfoValues[e.currentTarget.id][$e.val()],
2013-06-06 16:36:28 +02:00
}).popover('show');
2013-06-10 23:56:35 +02:00
}
2013-06-06 16:36:28 +02:00
});
// workaround for browsers like IE and Chrome that do now have an onmouseover on the 'options' of a select.
// disadvangate is that user needs to click on the item to see the tooltip.
// no solutions exist, except to generate the select completely using html.
$("#EventAnalysis, #EventRisk, #EventDistribution").on('change', function(e) {
var $e = $(e.target);
$('#'+e.currentTarget.id).popover('destroy');
$('#'+e.currentTarget.id).popover({
trigger: 'focus',
placement: 'right',
2013-06-10 23:56:35 +02:00
content: formInfoValues[e.currentTarget.id][$e.val()],
}).popover('show');
});
2013-06-06 16:36:28 +02:00
});
</script>
<?php echo $this->Js->writeBuffer();