PageRenderTime 49ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/application/views/template_upload.php

https://bitbucket.org/inflex13/inkedgirls
PHP | 237 lines | 188 code | 37 blank | 12 comment | 24 complexity | 6c01a5d5eca1f57e56daf7c0f8a02c05 MD5 | raw file
  1. <!DOCTYPE html>
  2. <html lang="en-US">
  3. <head>
  4. <title><?php echo $this->template->title->default($this->config->item('title')); ?></title>
  5. <meta charset="utf-8">
  6. <meta name="description" content="<?php echo $this->template->description; ?>">
  7. <meta name="author" content="">
  8. <?php echo $this->template->meta; ?>
  9. <link rel="shortcut icon" href="<?php echo base_url('/style/images/favicon.png'); ?>"/>
  10. <link rel="stylesheet" type="text/css" href="<?php echo base_url('/style/style.css'); ?>" media="all" />
  11. <link rel="stylesheet" type="text/css" href="<?php echo base_url('/style/type/museo.css'); ?>" media="all" />
  12. <link rel="stylesheet" type="text/css" href="<?php echo base_url('/style/color/custom.css'); ?>" media="all" />
  13. <link rel="stylesheet" type="text/css" href="<?php echo base_url('/style/js/fancybox/jquery.fancybox.css?v=2.0.4'); ?>" media="all" />
  14. <?php echo $this->template->stylesheet; ?>
  15. <!--[if IE 7]>
  16. <link rel="stylesheet" type="text/css" href="<?php echo base_url('/style/css/ie7.css'); ?>" media="all" />
  17. <![endif]-->
  18. <!--[if IE 8]>
  19. <link rel="stylesheet" type="text/css" href="<?php echo base_url('/style/css/ie8.css'); ?>" media="all" />
  20. <![endif]-->
  21. <!--[if IE 9]>
  22. <link rel="stylesheet" type="text/css" href="<?php echo base_url('/style/css/ie9.css'); ?>" media="all" />
  23. <![endif]-->
  24. </head>
  25. <body>
  26. <!-- Begin Wrapper -->
  27. <div style="position:relative;margin: 0px auto;width: 1000px;">
  28. <!-- Logo -->
  29. <a style="float: left;" href="<?php echo base_url(); ?>">
  30. <img height="70" src="<?php echo base_url('/style/images/ig-logo2.png'); ?>" alt="" />
  31. </a>
  32. <!-- Facebook -->
  33. <?php echo $this->template->facebook; ?>
  34. <div style="clear: both"></div>
  35. <div id="wrapper" style="margin: 0px auto;">
  36. <!-- Begin Menu -->
  37. <div id="menu" class="menu">
  38. <?php echo $this->template->menu; ?>
  39. <br style="clear: left" />
  40. </div>
  41. <!-- End Menu -->
  42. <div id="container">
  43. <div id="full-width">
  44. <!-- Top Girls -->
  45. <?php echo $this->template->top_girls; ?>
  46. <!-- Begin Content -->
  47. <?php echo $this->template->content; ?>
  48. <!-- End Content -->
  49. </div>
  50. </div>
  51. <div class="clear"></div>
  52. <!-- Begin Footer -->
  53. <?php echo $this->template->footer; ?>
  54. <!-- End Footer -->
  55. </div>
  56. <!-- End Container -->
  57. </div>
  58. <!-- End Wrapper -->
  59. <!-- Global JS -->
  60. <?php echo $this->template->footer_javascript; ?>
  61. <!-- Page Specific JS -->
  62. <?php echo $this->template->javascript; ?>
  63. <script>
  64. /*
  65. * Required features:
  66. * addEventListener (Google Chrome 1+, FF 1+, IE 9+, Opera 7+, Safari 1+)
  67. * FileReader (Google Chrome 7+, FF 3.6+, IE 10+)
  68. * FormData (Google Chrome 7+, FF 4+, Safari 5+)
  69. */
  70. $(document).ready(function(){
  71. if(("addEventListener" in window) && ("FileReader" in window) && ("FormData" in window))
  72. {
  73. var formdata = new FormData();
  74. var totalfiles = 1;
  75. var file_info = new Array();
  76. $("#upload-link").live('click', function(e){
  77. e.preventDefault();
  78. if($("#upload").length != 0){
  79. //clear previous data
  80. $('#list').html('');
  81. formdata = new FormData();
  82. totalfiles = 0;
  83. file_info = new Array();
  84. $('#confirm').remove();
  85. $('#clear').remove();
  86. //emulate upload click
  87. $("#upload").click();
  88. }
  89. return false;
  90. });
  91. $("#upload").live('change', function(){
  92. var inputfield = $(this);
  93. var img, reader, file;
  94. file = this.files;
  95. file = file[0];
  96. var file_size = file.size;
  97. var file_name = file.name;
  98. console.log(file_size);
  99. if(file.type.match(/image.jpeg/))
  100. {
  101. file_info[totalfiles] = {'name':file_name, 'size':file_size};
  102. if(window.FileReader)
  103. {
  104. reader = new FileReader();
  105. reader.onloadend = function(e) {
  106. createImage(e.target.result);
  107. };
  108. reader.readAsDataURL(file);
  109. }
  110. if(formdata)
  111. {
  112. formdata.append("fb_uid", $('input[name=fb_uid]').attr('value'));
  113. //formdata.append("image_id", $('input[name=image_id]').attr('value'));
  114. //formdata.append("categorie_id", $('input[name=categorie_id]').attr('value'));
  115. //formdata.append("image_name", $('input[name=nom_fichier]').attr('value'));
  116. formdata.append("images", file);
  117. }
  118. }
  119. if($('#confirm').length == 0)
  120. {
  121. $(inputfield).parent().append("<input type='button' value='Upload' id='confirm' />");
  122. }
  123. if($('#clear').length == 0)
  124. {
  125. $(inputfield).parent().append("<input type='button' value='Clear' id='clear' />");
  126. }
  127. });
  128. $('#clear').live('click', function(){
  129. $('#list').html('');
  130. formdata = new FormData();
  131. totalfiles = 0;
  132. file_info = new Array();
  133. $('#confirm').remove();
  134. $('#clear').remove();
  135. });
  136. function createImage(source) {
  137. var the_size = (Math.round( (file_info[totalfiles].size * 100) / (1024 * 1024) ) / 100);
  138. $('#list').append('<div><img class="thumbnail" src='+source+' /><h2>'+file_info[totalfiles].name+'</h2></div>');
  139. totalfiles++;
  140. }
  141. function progressBar(percentage) {
  142. $('#progress_bar').addClass('loading');
  143. if($('#progress_bar').css('display') == 'none')
  144. {
  145. $('#progress_bar').slideDown('fast', function(){
  146. $('.percent').attr('data-percentage', percentage + "%");
  147. $('.percent').css({'width': (((percentage * $('#progress_bar').outerWidth()) / 100) - 2) + 'px', 'display':'block'});
  148. });
  149. }
  150. else
  151. {
  152. $('.percent').attr('data-percentage', percentage + "%");
  153. $('.percent').css({'width': (((percentage * $('#progress_bar').outerWidth()) / 100) - 2) + 'px', 'display':'block'});
  154. if(percentage == 100)
  155. {
  156. setTimeout(function(){
  157. $('#progress_bar').slideUp('slow', function(){
  158. $('.percent').css({'display':'none', 'width':'0px'});
  159. $('#progress_bar').removeClass('loading');
  160. });
  161. }, 1000);
  162. }
  163. }
  164. }
  165. $('#confirm').live('click', function(){
  166. console.log('Confirm clicked');
  167. var xhr = new XMLHttpRequest();
  168. function progressListener (e) {
  169. if (e.lengthComputable) {
  170. var percentage = Math.round((e.loaded * 100) / e.total);
  171. progressBar(percentage);
  172. }
  173. };
  174. function finishUpload (e) {
  175. progressBar(100);
  176. };
  177. xhr.upload.addEventListener("progress", progressListener, false);
  178. xhr.upload.addEventListener("load", finishUpload, false);
  179. xhr.open("POST", "framework/controllers/upload.php");
  180. xhr.onreadystatechange = function(){
  181. console.info("readyState: ", this.readyState);
  182. if (this.readyState == 4) {
  183. if ((this.status >= 200 && this.status < 300) || this.status == 304) {
  184. if (this.responseText != "") {
  185. $('#return').show();
  186. $('#list').empty();
  187. $('#confirm').remove();
  188. $('#clear').remove();
  189. //html(this.responseText);
  190. }
  191. }
  192. }
  193. };
  194. xhr.send(formdata);
  195. });
  196. }
  197. });
  198. </script>
  199. </body>
  200. </html>