Advertisement
Guest User

index.php

a guest
Dec 30th, 2010
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.47 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3.  
  4. <head>
  5.         <script src="javascripts/jquery-1.4.2.min.js"></script>
  6.         <script src="javascripts/jquery.imgareaselect.js"></script>
  7.         <link rel="stylesheet" type="text/css" href="css/imgareaselect-default.css" />
  8. <body>
  9. <div id='preview'>
  10. <?
  11.        echo '<img height=297 width=216 id="prev_img" src="images/preview.png?salt=' . rand() . '" />'
  12. ?>
  13. </div>
  14. <input type='button' id='scan_preview' value='Предворительный просмотр'>
  15. <hr />
  16.  
  17. <form id="params">
  18.         <select name='mode'>
  19.                 <option value='auto'>auto(Color)</option>
  20.                 <option value='Halftone'>Halftone</option>
  21.                 <option value='Gray'>Gray</option>
  22.                 <option value='Lineart'>Lineart</option>
  23.                 <option value='Color'>Color</option>
  24.         </select>
  25.         <select name='resolution'>
  26.                 <option value='auto'>auto(300dpi)</option>
  27.                 <option value='50'>50</option>
  28.                 <option value='75'>75</option>
  29.                 <option value='100'>100</option>
  30.                 <option value='150'>150</option>
  31.                 <option value='200'>200</option>
  32.                 <option value='300'>300</option>
  33.                 <option value='450'>450</option>
  34.                 <option value='600'>600</option>
  35.         </select>
  36. </form>
  37. <input type='button' id='scan_image' value='Сканировать'>
  38. <div style="overflow:auto;height:400px" id='images'>
  39. <?
  40.        $dir = opendir("images/");
  41.        while($file = readdir($dir)) {
  42.                if($file != '.' && $file != '..' && $file != 'preview.png'){
  43.                        echo "<div id='$file' style='float:left'><img height=297 width=216 src='images/$file?salt=".rand()."' /><input  class='delete_button' type='button' value='Удалить'></div>";
  44.                 }
  45.         }
  46.         closedir($dir);
  47. ?>
  48. </div>
  49. <script>
  50. $(function(){
  51.         $('input.delete_button').click(function(){
  52.                 var div = $(this).parent();
  53.                 $.ajax({
  54.                         type:'POST',
  55.                         url:'/delete_image.php',
  56.                         data:{file_name : div.attr('id')},
  57.                         dataType:'json',
  58.                         success:function(data, textStatus, XMLHttpRequest){
  59.                                 if(data.success){
  60.                                         div.remove();
  61.                                 }
  62.                         }
  63.                 });
  64.         });
  65.         var image_select = $('#prev_img').imgAreaSelect({ x1: 0, y1: 0, x2: 216, y2: 297,instance: true });
  66.         $('#scan_preview').click(function(){
  67.                 $.ajax({
  68.                         type:'POST',
  69.                         url:'/scan_image.php',
  70.                         data:{
  71.                                 preview : 1
  72.                         },
  73.                         dataType:'json',
  74.                         success:function(data, textStatus, XMLHttpRequest){
  75.                                 if(data.success){
  76.                                         $('#prev_img').attr('src','images/preview.png?salt=' + Math.random());
  77.                                 }
  78.                         }
  79.                 });
  80.         });
  81.  
  82.         $('#scan_image').click(function(){
  83.                 var data = {};
  84.                 $('#params input,select').each(function(index,el) {
  85.                         data[el.name] = el.value;
  86.                 });
  87.                 data['l'] = image_select.getSelection().x1;
  88.                 data['t'] = image_select.getSelection().y1;
  89.                 data['x'] = image_select.getSelection().width;
  90.                 data['y'] = image_select.getSelection().height;
  91.                 $.ajax({
  92.                         type:'POST',
  93.                         url:'/scan_image.php',
  94.                         data:data,
  95.                         dataType:'json',
  96.                         success:function(data, textStatus, XMLHttpRequest){
  97.                                 if(data.success){
  98.                                         $('#images').append("<div id='" + data.file_name + "' style='float:left'><img height=297 width=216 src='images/" + data.file_name + "?salt=" +Math.random() + "' /><input  class='delete_button' type='button' value='Удалить'></div>");
  99.                                 }
  100.                         }
  101.                 });
  102.         });
  103. });
  104. </script>
  105. </body>
  106. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement