src_js/iconolab-bundle/editor.html
changeset 320 81945eedc63f
equal deleted inserted replaced
319:bca3e4b1d0f1 320:81945eedc63f
       
     1 <!DOCTYPE html>
       
     2 <html lang="en">
       
     3   <head>
       
     4     <meta charset="utf-8">
       
     5     <title>Iconolab</title>
       
     6     <link rel="stylesheet" href="/static/iconolab/css/iconolab.css">
       
     7     <style>
       
     8     body {
       
     9         margin-top: 40px;
       
    10     }
       
    11     </style>
       
    12   </head>
       
    13   <body>
       
    14 
       
    15     <div class="container-fluid">
       
    16       <div class="row">
       
    17         <div class="col-md-9">
       
    18           <div id="wrapper">
       
    19             <image-annotator ref="annotator" image="img/main-image.jpg"></image-annotator>
       
    20           </div>
       
    21         </div>
       
    22         <div class="col-md-3">
       
    23           <div class="alert alert-success" style="display: none;">Annotation saved in LocalStorage!</div>
       
    24           <pre id="annotation"></pre>
       
    25         </div>
       
    26       </div>
       
    27     </div>
       
    28 
       
    29     <script src="/static/iconolab/js/vendor.js"></script>
       
    30     <script src="/static/iconolab/js/iconolab.js"></script>
       
    31     <script>
       
    32 
       
    33       function showAlert() {
       
    34         $('.alert-success').show();
       
    35         setTimeout(function() {
       
    36           $('.alert-success').hide();
       
    37         }, 3000);
       
    38       }
       
    39 
       
    40       var vm = new Vue({
       
    41         el: '#wrapper'
       
    42       });
       
    43 
       
    44       var data = localStorage.getItem('annotation');
       
    45       if (data) {
       
    46         var annotation = JSON.parse(data);
       
    47         vm.$refs.annotator.setAnnotation(annotation);
       
    48         $('#annotation').text(JSON.stringify(annotation, null, 2));
       
    49       }
       
    50 
       
    51       vm.$refs.annotator.$on('save', function(data) {
       
    52         console.log('Saving in localStorage', JSON.stringify(data));
       
    53         showAlert();
       
    54         localStorage.setItem('annotation', JSON.stringify(data));
       
    55       });
       
    56 
       
    57     </script>
       
    58   </body>
       
    59 </html>