summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards/project/network_topology/templates/network_topology/_post_massage.html
blob: 053894e3f0049f715c487d8e10ee321689caa124 (plain)
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
<script type="text/javascript">
(function(){
  $(window).on('message',function(e){
    var message = JSON.parse(e.originalEvent.data);
    var id = message.id;
    $('button[id*="' + id + '"]').click();
  });

  $('.messages .alert').each(function(){
    var $this = $(this);
    var message = {};
    message.action = "alert";
    message.iframe_id = $(window.frameElement).attr('id');
    message.type =
      ($this.hasClass('alert-info')) ?    'info' :
      ($this.hasClass('alert-warning')) ? 'warning' :
      ($this.hasClass('alert-success')) ? 'success' :
      ($this.hasClass('alert-danger')) ?   'error' :
      null;
    message.message = $this.children('p')
      .html()
      .replace(/<strong>(.*?)<\/strong>/g,'');
    var target = (parent.postMessage ? parent : (parent.document.postMessage ? parent.document : undefined));
    target.postMessage(JSON.stringify(message, null, 2), '*');
  });
})();
</script>