1/** 2 * Created by Keiichiro on 14/09/10. 3 * puchidb V5 4 * 5 */ 6 7 8jQuery.fn.extend({ 9 local_file_uploader: function() { 10 $.each($(this), function(e, elm){ 11 var age_year_translator = new Local_file_uploader(elm); 12 }); 13 } 14}); 15 16function Local_file_uploader(target_area){ 17 var $target_area = $(target_area); 18 var action_url = $target_area.attr("action_url"); 19 this.$upload_btn = $target_area.find(".upload_btn"); 20 this.$delete_btn = $target_area.find(".delete_btn"); 21 this.$input_form = $target_area.find("#target_input"); 22 this.$display_area = $target_area.find(".display_area"); 23 this.preview_default = this.$display_area.html(); 24 25 var self = this; 26 // åæå¦ç 27 // ãã¿ã³ã®åãæ¿ã 28 if(this.$input_form.val() == ""){ 29 this.$upload_btn.show(); 30 this.$delete_btn.hide(); 31 } else { 32 this.$upload_btn.hide(); 33 this.$delete_btn.show(); 34 } 35 36 // ãã¬ãã¥ã¼ã¨ãªã¢ã®åæå 37 this.show_preview(self.$input_form.val()); 38 39 // ã¢ãããã¼ããã¿ã³ã®ã¯ãªãã¯ã¤ãã³ã 40 var original_upload_btn_text = this.$upload_btn.html(); 41 new Ajax_upload(this.$upload_btn,{ 42 //action: 'upload-test.php', // I disabled uploads in this example for security reasons 43 action: action_url, 44 name: 'userfile', 45 onSubmit : function(file, ext){ 46 // change button text, when user selects file 47 self.$upload_btn.text('Uploading'); 48 49 this.disable(); 50 51 interval = window.setInterval(function(){ 52 var text = self.$upload_btn.text(); 53 if (text.length < 13){ 54 self.$upload_btn.text(text + '.'); 55 } else { 56 self.$upload_btn.html('UpLoading...'); 57 } 58 }, 2000); 59 }, 60 onComplete: function(file, response){ 61 self.$upload_btn.text('Upload'); 62 63 window.clearInterval(interval); 64 65 this.enable(); 66 67 self.$input_form.val(response); 68 self.show_preview(response); 69 self.$upload_btn.html(original_upload_btn_text); 70 71 self.switch_mode(); 72 } 73 }); 74 75 // åé¤ãã¿ã³ã®ã¯ãªãã¯ã¤ãã³ã 76 this.$delete_btn.click(function(){ 77 self.$input_form.val(""); 78 79 self.show_preview(""); 80 self.switch_mode(); 81 }); 82 83} 84 85Local_file_uploader.prototype.switch_mode = function(){ 86 if(this.$upload_btn.is(':visible')){ 87 this.$upload_btn.hide(); 88 this.$delete_btn.show(); 89 90 } else { 91 this.$upload_btn.show(); 92 this.$delete_btn.hide(); 93 } 94 95} 96 97Local_file_uploader.prototype.show_preview = function(response){ 98 var display_contents = this.preview_default.split("$val").join(response); 99 this.$display_area.html(display_contents); 100 101}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.