var upload1_count = 0; var upload2_count = 0; var upload1, upload2; window.onload = function() { upload1 = new SWFUpload({ // Backend Settings upload_url: "/service/upload", post_params: param.image, // File Upload Settings file_size_limit : "2048", // 2MB file_types : "*.jpg;*.gif;*.png", file_types_description : "Image Files", file_upload_limit : "5", file_queue_limit : "5", // Event Handler Settings (all my handlers are in the Handler.js file) file_dialog_start_handler : fileDialogStart, file_queued_handler : fileQueued, file_queue_error_handler : fileQueueError, file_dialog_complete_handler : fileDialogComplete, upload_start_handler : uploadStart, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess, upload_complete_handler : uploadComplete, // Button Settings button_image_url : "/static/img/uploadbtn.gif", button_placeholder_id : "spanButtonPlaceholder1", button_width: 82, button_height: 38, // Flash Settings flash_url : "/static/lib/swfupload/swfupload.swf", custom_settings : { progressTarget : "fsUploadProgress1", cancelButtonId : "btnCancel1" }, // Debug Settings debug: false }); upload2 = new SWFUpload({ // Backend Settings upload_url: "/service/upload", post_params: param.voice, // File Upload Settings file_size_limit : "20480", // 20mb file_types : "*.mp3", file_types_description : "MP3 Files", file_upload_limit : "1", file_queue_limit : "1", // Event Handler Settings (all my handlers are in the Handler.js file) file_dialog_start_handler : fileDialogStart, file_queued_handler : fileQueued, file_queue_error_handler : fileQueueError, file_dialog_complete_handler : fileDialogComplete, upload_start_handler : uploadStart, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess, upload_complete_handler : uploadComplete, // Button Settings button_image_url : "/static/img/uploadbtn.gif", button_placeholder_id : "spanButtonPlaceholder2", button_width: 82, button_height: 38, // Flash Settings flash_url : "/static/lib/swfupload/swfupload.swf", custom_settings : { progressTarget : "fsUploadProgress2", cancelButtonId : "btnCancel2" }, // Debug Settings debug: false }); } var mp3player = { loaded : function(){ // Local copy of jQuery selectors, for performance. var my_jPlayer = $("#jquery_jplayer"), my_trackName = $("#jp_container .track-name"), my_playState = $("#jp_container .play-state"), my_extraPlayInfo = $("#jp_container .extra-play-info"); // Some options var opt_play_first = false, // If true, will attempt to auto-play the default track on page loads. No effect on mobile devices, like iOS. opt_auto_play = false, // If true, when a track is selected, it will auto-play. opt_text_playing = "Now playing", // Text when playing opt_text_selected = "Track selected"; // Text when not playing // Change the time format $.jPlayer.timeFormat.padMin = false; $.jPlayer.timeFormat.padSec = false; $.jPlayer.timeFormat.sepMin = " min "; $.jPlayer.timeFormat.sepSec = " sec"; // Initialize the play state text my_playState.text(opt_text_selected); // Instance jPlayer my_jPlayer.jPlayer({ ready: function () { }, timeupdate: function(event) { my_extraPlayInfo.text(parseInt(event.jPlayer.status.currentPercentAbsolute, 10) + "%"); }, play: function(event) { }, pause: function(event) { }, ended: function(event) { }, swfPath: "/static/lib/jplayer", cssSelectorAncestor: "#jp_container", supplied: "mp3", solution:"flash,html" }); // Create click handlers for the different tracks $(".jp-play").click(function(e) { my_jPlayer.jPlayer("setMedia", { mp3: $(this).attr('rel'), errorAlerts : true, warningAlerts : false }); my_jPlayer.jPlayer("play"); $('#player_status').show(); $(this).blur(); return false; }); $('.jp-stop').click(function(e){ $('#player_status').hide(); }); $('.voice_del').click(function(e) { $(this).deleteatt({ 'id':$(this).attr('rel'), 'url':'/service/delatt', 'content':'是否删除'+$(this).next('h4').html(), 'item_prefix':'thumbItems_', 'callback': function(){ upload2.setStats({successful_uploads:0}); upload2.setFileUploadLimit(1); my_jPlayer.jPlayer( "stop" ); } }); }); }, makeHtml : function(data){ html = '
' +' ' +'

'+data.realname+'

' +'
' +'
' +' ' +' ' +' ' +' ' +' ' +'
' +' ' +'' +'
' +'
'; return html; } } var thumbfunc = { binddelbtn : function(id){ this.dom = $('#thumbItems_'+id).children('.media-body').children('.thumb_del'); this.dom.bind('click',function(e) { $(this).deleteatt({ 'id':$(this).attr('rel'), 'url':'/service/delatt', 'content':'是否删除'+$(this).next('h4').html(), 'item_prefix':'thumbItems_', 'callback': thumbfunc.queueset() }); }); }, loaded : function(){ $('#thumbs').children('div').each(function(index, element) { this.delbtn = $(this).children('.media-body').children('.thumb_del'); $(this).hover( function(){ $(this).addClass('hovered'); }, function(){ $(this).removeClass('hovered'); } ) this.delbtn.bind('click',function(e) { $(this).deleteatt({ 'id':$(this).attr('rel'), 'url':'/service/delatt', 'content':'是否删除'+$(this).next('h4').html(), 'item_prefix':'thumbItems_', 'callback': thumbfunc.queueset() }); }); }); }, queueset : function(){ this.chilrenslen = $('#thumbs').children('div').length; upload1.setStats({successful_uploads:this.chilrenslen}); upload1.setFileUploadLimit(5- this.chilrenslen); upload1.setFileQueueLimit(5- this.chilrenslen); }, filetype : function(mime){ this.patrn=/image/; if (this.patrn.test(mime)) { return "image"; } this.patrn=/audio/ if(this.patrn.test(mime)) { return "audio"; } return null; }, makeHtml : function(data){ this.imgsrc = typeof(data.file_url) == 'undefined' ? data.fileurl:data.file_url; this.imgsrc = typeof(data.thumb[400]) == 'undefined' ? this.imgsrc : data.thumb[400].url; this.imgsrc = typeof(data.thumb[200]) == 'undefined' ? this.imgsrc : data.thumb[200].url; html = '
' +'' +'' +'' +'
' +'' +'

'+data.realname+'

' +'' +'' +'
' +'
'; return html; } }; function voicesubmited(data){ if (typeof(data)=='object') { if(typeof(data.error)!='undefined') { $("#alert-info").attr('class','alert alert-danger'); $("#alert-info").html(data.error); return false; } if(typeof(data.success)!='undefined') { $("#alert-info").attr('class','alert alert-success'); if(typeof(_this.source) != 'undefined' && _this.source == 'edit'){ $("#alert-info").html("编辑成功!(页面将自动跳转,如果没有跳转请点击这里)"); }else{ $("#alert-info").html("投稿成功!通过评审后会自动发布(页面将自动跳转,如果没有跳转请点击这里)"); } setTimeout("window.location.href ='/member'",3000); return false; } } else{ $("#alert-info").attr('class','alert alert-danger'); $("#alert-info").html('服务器掉链子了,通知管理员揍它'); return false; } } $(document).ready(function(e) { $('#tags').tagsInput({width:'auto'});//taginput $('#submit_btn').click(function(e) {//submit editor.sync(); $.ajax({ 'type':"POST", 'url':"/voice/submit", 'data':$("#voice_submit").serialize(), 'success':voicesubmited, 'timeout': 30000, 'error': function(){ $("#alert-info").attr('class','alert alert-danger'); $("#alert-info").html("出现错误,请稍后重试"); $('#submit-loading').hide(); return false; }, 'beforeSend': function(){ $("#submit_btn").addClass('disabled'); $("#submit_btn").attr('disabled','disabled'); $('#submit-loading').show(); }, complete: function(){ $("#submit_btn").removeClass('disabled'); $("#submit_btn").removeAttr('disabled'); $('#submit-loading').hide(); } }); }); });