28
2012
04

jQuery实现声音上传功能

    <script type="text/javascript">
        KE.show({
            id: 'pb-text-textarea',
            imageUploadJson: '/kindeditor/plugins/upload_json.ashx',
            fileManagerJson: '/kindeditor/plugins/file_manager_json.ashx',
            allowFileManager: true,
            width: "100%", //编辑器的宽度为70% 
            height: "353px", //编辑器的高度为100px   
            filterMode: false, //不会过滤HTML代码 
            resizeMode: 0 //2或1或0,2时可以拖动改变宽度和高度,1时只能改变高度,0时不能拖动。
        });

        //歌曲搜索、试听
        $(document).ready(function () {
            $("#searchclick").click(function () {
                var musicname = document.getElementById("pb-text-title").value;
                var musicname2 = document.getElementById("pb-text-title2").value;
                var searchbtn = document.getElementById("searchclick");
                var pbflashdiv = document.getElementById("deletediv");
                if (musicname != "") {
                    if (!pbflashdiv.hasChildNodes()) {
                        var creat = document.createElement("application/x-shockwave-flash"); //创建播放器元素
                        creat.innerHTML = "<embed wmode='transparent' id='musicflash' name='' style='width: 405px; height: 100px; margin: 0 auto;padding: 0px;' name='musicflash' type='application/x-shockwave-flash' src='http://" + "box.baidu.com/widget/flash/mbsong.swf?name=" + musicname + "&artist=" + musicname2 + "&extra='></embed>";
                        $("#deletediv").append(creat); //将播放器元素添加到DIV中。
                    }
                    else {
                        $("#deletediv").children().remove();
                        var creat = document.createElement("application/x-shockwave-flash");
                        creat.innerHTML = "<embed wmode='transparent' id='musicflash' style='width: 405px; height: 100px; margin: 0 auto;padding: 0px;' name='musicflash' type='application/x-shockwave-flash' src='http://" + "box.baidu.com/widget/flash/mbsong.swf?name=" + musicname + "&artist=" + musicname2 + "&extra='></embed>";
                        $("#deletediv").append(creat);
                    }
                }
                else if (musicname == "" || musicname2 == "") {
                    alert("为了准确快速搜索,请正确输入:歌曲或歌手名");
                }
             
            });

        });

        $(document).ready(function () {
            $("#post-tag-input").focusin(function () {
                if ($(this).val() == "为您的音乐添加一个标签吧!") {
                    $(this).val("");
                }              
            }).focusout(function () {
                if ($(this).val() == "") {
                    $(this).val("为您的音乐添加一个标签吧!");
                }            
            });
        });
 
        function check() {
            var cookie_info = '<%=user_Mes%>';
            var musicurl = "http://box.baidu.com/widget/flash/mbsong.swf?name=" + $("#pb-text-title").val();
            if (cookie_info != "") {
                user = cookie_info.split(',');
                var userid = user[0];
            }

            if ($("#pb-text-title").val() != "" && $("#pb-text-title2").val() != "") {
                $.ajax({
                    type: "POST",
                    url: "/ashx/Dd_music.ashx",
                    data: "UserID=" + userid + "&Music_Address=" + musicurl + "&artist=" + $("#pb-text-title2").val() + "&Music_Description=" + $("#pb-text-textarea").val() + "&Music_Tag=" + $("#post-tag-input").val() + "&Music_Originld=" + userid,
                    success: function () {
                        window.location.href = "/Default.aspx";
                    }
                })
            }
            else if ($("#pb-text-title").val() == "") {
                alert("为了准确搜索您想要的歌曲,建议正确填写歌曲名!!");
            }
            else if ($("#pb-text-title2").val() == "") {
                alert("为了准确搜索您想要的歌曲,建议正确填写歌手名!!");
            }
            else if ($("#post-tag-input").val() == "为您的音乐添加一个标签吧!") {
                $("#post-tag-input").val("");
            }
            
           
           
           
           
            //            if (document.getElementById("pb-text-title").value.replace(/(^\s*)|(\s*$)/g, "") == "") {
            //                alert("请选择一首歌~~~");
            //                return false;
            //            }

            //    + "&artist=" + $("#pb-text-title2").val() + "&extra="

            //            if (document.getElementById("post-tag-input").value.replace(/(^\s*)|(\s*$)/g, "") == "") {
            //                alert("给音乐添加个标签吧~");
            //                return false;
            //            }

        }

    </script>
    <script type="text/javascript">
        $(function () {
            var cookie_info ='<%=user_Mes%>';
            if (cookie_info != "") {
                user = cookie_info.split(',');
                blogname.innerHTML = user[1];
            }
        });
    </script>

« 上一篇下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。