有用的JS-福田

有用的JS-福田

作者:LAMP小白  点击:1819  发布日期:2012-11-06 18:32:00  返回列表

有很多有用的东西 以后可以方便的查询 放这里备份份

//垃圾IE
 var notIE = 0;
  if (navigator.appName.indexOf("Netscape") !== -1){
    $('#openWinDivDiv').attr( { style :  'position:absolute;left:10%;top:1350px;width:630px;height:516px;display:none;z-index:1988;' } );
    $('#picChoose').attr( { style : 'display:none;' } );
    $('#setup1, #setup2, #setup3, #setup4').attr( { value:'TRNSPQRENET ' } );
    $('#openWinDiv').attr( { style: 'position:absolute;left:10%;top:1350px;width:630px;height:516px;display:none;z-index:1988;'} );
    notIE = 1;
  }
    var checkFollow = 1;
    var child_pic;
    var child_contents;
    var child_follow;
    var child_modeVal;
    var friendsGup = 2;
    var user_ids = 0;
    var allowNext = 1;
    var allowSub = 1;
    var points = 3;
    //换一组
    $('#changeFriends').click(function(){
        //friendsGup = friendsGup + 1;
        if(allowNext == 1){
            allowNext = 0;
            $.post('{$smarty.const.STATIC_URL}?anu=sub/more_friends', { friendsGup:friendsGup } , function(data){
                if(data.err == '1'){
                    alert('没有返回UID');
                    allowNext = 1;
                    return false;
                } else if(data.err == '2'){
                  alert('接口返回好友数据为空,复位仍为空,请检查调用次数是否过于频繁');
                    allowNext = 1;
                    return false;
                } else {
                    $('#scrollbar1').empty().html(data.html);
                    friendsGup = friendsGup +1;
                    allowNext = 1;
                    return false;
                }
            }, 'json');
        } else {
            alert('请不要连续点击');
        }
    })
    //关注按钮
    $('#mioRadio').click(function(){
        var nowStatus = $(this).attr('class');
        if(nowStatus == 'click-on'){
            $(this).removeClass('click-on').addClass('click');
            checkFollow = 0;
        } else {
            $(this).removeClass('click').addClass('click-on');
            checkFollow = 1;
        }
        return false;
    });
    function add_follow(){
        $.post('{$smarty.const.STATIC_URL}?anu=sub/followed', { } , function(data){
            return false;
        });
    }
    //sub form
    $('#weibo_sub').click(function(){
        //判断加关注
        child_follow = returnFollow();
        if(checkFollow == 1 || child_follow == 1){
            add_follow();
        }
        $('#openWinBack').attr( { style : 'display:none;background: none repeat scroll 0 0 #000000;height: 100%;left: 0;filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity: 0.5; opacity: 0.5;position: fixed;top: 0;width: 100%;z-index: 1987;' } );
        $('#waits').attr( { style: 'z-index:1988;position:absolute;width:200px;height:30px;color:#DDDDDD;font-size:26px;left: 260px;top: 200px;font-weight: bold;'} );
        $('#waits').html('发布中...');
        var vals = $('#content').val();
        var content = $('#content').val();
        var nums = 0;
        var i = 0;
        var re = /@/;
        //检测是否关注了福田
        //检测是否@了3个人
        while(vals.indexOf('@') mio_gt;= 0){
            vals = vals.replace(re, '1');
            ++nums;
        }
        if( nums mio_lt; 4 || content == ''){
            alert('请@3名好友!'); return false;
        }
        //显示一个等待浮层
        $('#openWinBack').show();
        $('#waits').show();
        var weibo_img_url = get_weibo_img();
        if(weibo_img_url == '' || weibo_img_url == null){
            alert('图片上传失败');
            return false;
        }
        var weibo_id = 0;
        content = content+' ';
        $.post('{$smarty.const.STATIC_URL}?anu=sub/save', { content:content, weibo_img:weibo_img_url }, function(data){
            if(data.id == '0'){
                alert(data.err);
                return false;
            } else {
                weibo_id = data.id;
                if(weibo_id == 0 || weibo_id == null || weibo_id == ''){
                    alert('微博发布失败');
                    return false;
                }
                var data = new Array(user_is_auth, user_is_follow, user_user_id, user_avatar, weibo_id);
                var name = new Array('is_auth', 'is_follow', 'user_id', 'user_name', 'weibo_id');
                var info = mio2Json(data, name);
                thisMovie('flashJsa').publish(info);
                $.post('{$smarty.const.STATIC_URL}?anu=sub/bak_id', { wid : weibo_id , follow:checkFollow}, function(){
                   // SUDA.uaTrack("ebusiness_apps", "2731341697:1571148725:other1_{urlencode('发布')}::::share");
                   $('#openWinDivF').attr( { src:'http://all.vic.sina.com.cn/201210foton/?anu=sub/more' } );
                    //显示浮层
                    $('#openWinDivDiv').hide();
                    $('#openWinBack,#openWinDiv').fadeIn('1000');
                    return false;
                });
            }
        }, 'json');
    })
    function changeWait(){
        var htmls = $('#waits').html();
        if(points == 3){
            points = 1;
        }
        var txt = '';
        for(var i = 0; i mio_lt; points; i++ ){
            txt = txt+'.';
        }
        txt = '发布中'+txt;
        $('#waits').html(txt);
    }
    //at friends
    $('.atFriends').live('click', function(){
        var user_name = $(this).children('.user_name').html();
        var vals = $('#content').val();
        var temp = vals;
        if(vals == ''){
            vals = '@'+user_name;
        } else {
            var rr = vals.indexOf(user_name);
            if(rr mio_gt;= 0){
                alert('不能重复@一个人哦~');
                return false;
            } else {
                vals = vals+' @'+user_name;
            }
        }
        var nums = 0;
        var re = /@/;
        //检测是否@了3个人
        while(temp.indexOf('@') mio_gt;= 0){
            temp = temp.replace(re, '1');
            ++nums;
        }
        if( nums mio_gt; 3){
            alert('亲~@三人就可以了~');
            return false;
        }
        $('#content').html(vals);
        $('#content').val(vals);
        $(this).addClass('select');
    });
    function closeWin(){
        closeOpenWin();
        $('#openWinDivDiv').hide();
        ifrOn = '0';
        return false;
    }
mio_lt;/scriptmio_gt;
mio_lt;scriptmio_gt;
//CSS JS
$(function(){
  $('#marquee1').kxbdSuperMarquee({
    isAuto:true,
    distance:215,
    time:6,
    btnGo:{ left:'#goL',right:'#goR' },
    direction:'left'
  });
    $("#scrollbar1").jScrollPane({
      scrollbarWidth:22
    });
    $("#scrollbar2").jScrollPane({
      topCapHeight: 42,
      bottomCapHeight: 10 ,
      scrollbarWidth:22
    });
        $('#atab-0').click(function(){
        $('#atab-con4').show(function(){
          $("#scrollbar2").jScrollPane({
          topCapHeight: 42,
          bottomCapHeight: 40,
          scrollbarWidth:22
        }); });
      })
     $('#atab-4').click(function(){
        $('#atab-con5').show(function(){
          $("#scrollbar3").jScrollPane({
          topCapHeight: 42,
          bottomCapHeight: 40,
          scrollbarWidth:22
        }); });
      })
      })
  function nTabs(tabObj,obj){
    var tabList = document.getElementById(tabObj).getElementsByTagName("span");
    for(i=0; i mio_lt;tabList.length; i++)
    {
      if (tabList[i].id == obj.id)
      {
        document.getElementById(tabObj+'-'+i).className ="active";
        document.getElementById(tabObj+'-con'+i).style.display = "block";
      }else{
        document.getElementById(tabObj+'-'+i).className = "normal";
        document.getElementById(tabObj+'-con'+i).style.display = "none";
      }
    }
  }
  //js start
  var choosePicNum = 0;
  var choosePicTitle = '';
  var orderType = 0;
  var ifrOn = '0';
  var authHref = '{$smarty.const.STATIC_URL}?anu=auth/';
  var weibo_img = '';
  var flash_user_name = '{$user_info.user_name}';
  var flash_user_id = '{$user_info.id}';
  var flash_is_follow = '{$user_info.is_followed}';
  var flash_auth = false;
  var mioPageNums = 0;
  var atab_con1 = 0;
  var atab_con5 = 0;
  var picChooseArr = '';
  var parentIsFollowed = 0;
  $.post('{AnUrl("rand_image")}', { } , function(data){
    $('#choose_list_my').empty().html(data.my);
    $('#choose_list_live').empty().html(data.live);
  },'json');
  function returnFollow()
  {
    return parentIsFollowed;
  }
  $('#atab-0,#atab-4').addClass('normal');
  $('#atab-con1').show();
  $('#atab-con4').hide();
  $('#atab-con5').hide();
  $('#atab-0').click(function(){
    if(atab_con1 == 1){
      $('#atab-con1').show();
      $('#atab-con4').hide();
      $('#atab-con5').hide();
      $('#atab-4, #atab-1, #atab-2, #atab-3, #atab-0').removeClass('active').addClass('normal');
      atab_con1 = 0;
    } else {
      $('#atab-con1').hide();
      $('#atab-con4').show();
      $('#atab-con5').hide();
      $('#atab-0').removeClass('normal').addClass('active');
      $('#atab-4, #atab-1, #atab-2, #atab-3').removeClass('active').addClass('normal');
      atab_con1 = 1;
    }
    return false;
  });
  $('#atac-con4-close').click(function(){
    $('#atab-con1').show();
      $('#atab-con4').hide();
      $('#atab-con5').hide();
      $('#atab-4, #atab-1, #atab-2, #atab-3, #atab-0').removeClass('active').addClass('normal');
      return false;
  })
  $('#atab-con5-close').click(function(){
    $('#atab-con1').show();
    $('#atab-con5').hide();
    $('#atab-con4').hide();
    $('#atab-0, #atab-4, #atab-1, #atab-2, #atab-3').removeClass('active').addClass('normal');
    return false;
  })
  $('#atab-4').click(function(){
    if(atab_con5 == 1){
      $('#atab-con1').show();
      $('#atab-con5').hide();
      $('#atab-con4').hide();
      $('#atab-0').removeClass('active').addClass('normal');
      $('#atab-4, #atab-1, #atab-2, #atab-3').removeClass('active').addClass('normal');
      atab_con5 = 0;
    } else {
      $('#atab-con1').hide();
      $('#atab-con4').hide();
      $('#atab-con5').show();
      $('#atab-4').removeClass('normal').addClass('active');
      $('#atab-0, #atab-1, #atab-2, #atab-3').removeClass('active').addClass('normal');
      atab_con5 = 1;
    }
    return false;
  });
  //arr to json
  function mio2Json(arr, nameArr){
      var i,jsonstr;
      jsonstr="[{ldelim}";
      for(i=0;imio_lt;arr.length;i++){
          jsonstr += """ + nameArr[i] + """+ ":" + """ + arr[i] + "",";
      }
      jsonstr = jsonstr.substring(0,jsonstr.lastIndexOf(','));
      jsonstr += "{rdelim}]";
      return jsonstr;
  }
  $('#choose_change').click(function(){
    $.post('{AnUrl("rand_image")}', { } , function(data){
      $('#choose_list_my').empty().html(data.my);
      $('#choose_list_live').empty().html(data.live);
    },'json');
    return false;
  });
  $('.picChoose').live('click',function(){
    $('.picChoose').removeClass('select');
    $(this).addClass('select');
    choosePicNum = $(this).children('a').children('img').attr('src');
    choosePicTitle = $(this).children('a').children('p').html();
    return false;
  });
  $('#choose-concel, #choose-concel2').click(function(){
    picChooseClose();
    if(notIE == 0)
    document.getElementById('appPart2').scrollIntoView();
    return false;
  })
  $('#choose-ok').click(function(e,data){
    picChooseSend();
    if(notIE == 0)
    document.getElementById('appPart2').scrollIntoView();
    return false;
  })
  function gotoFlash(){
    if(notIE == 0)
    document.getElementById('appPart2').scrollIntoView();
    return false;
  }
  function picChooseSend(){
    if(choosePicTitle == '' || choosePicNum == ''){
      alert('请选择图片!');
      return false;
    }
    //得到位置
    picChooseArray[picChoosePart] = choosePicTitle;
    var i;
    for(i = 1;i mio_lt; 6; i++){
      if(picChooseArray[i] == choosePicTitle mio_amp;mio_amp; picChoosePart !== i){
        alert('不能重复选择');
        return false;
      }
    }
    var data = new Array(choosePicTitle, choosePicNum);
    var name = new Array('title','url')
    var info = mio2Json(data, name);
    thisMovie('flashJsa').selectOk(info);
    picChooseClose();
    return false;
  }
  var picChooseArray = new Array();
  picChooseArray[1] = '';
  picChooseArray[2] = '';
  picChooseArray[3] = '';
  picChooseArray[4] = '';
  picChooseArray[5] = '';
  var picChoosePart = 0;
  var isAuthEd = 0;
  var user_is_auth = 0;
  var user_is_follow = 0;
  var user_user_id = 0;
  var user_avatar = 0;
  function picChooseShow(part){
    picChoosePart = part;
    if(isAuthEd == 1){
      $('#picChoose').show();
      if(notIE == 0)
      document.getElementById('appPart0').scrollIntoView();
      return false;
    }
    $.post('http://all.vic.sina.com.cn/201210foton/index.php?anu=index/get_user_info', { } , function(data){
      if(data.status == 'succ'){
        user_is_auth = '1';
        user_is_follow = data.follow;
        user_user_id = data.id;
        user_avatar = data.avatar;
        var dataa = new Array('1', data.follow, data.id, data.name, data.avatar, '0');
        var name = new Array('is_auth', 'is_follow', 'user_id', 'user_name', 'avatar', 'weibo_id');
        var info = mio2Json(dataa, name);
        thisMovie('flashJsa').sendInfo(info);
        isAuthEd = 1;
        $('#picChoose').fadeIn('500');
        if(notIE == 0)
        document.getElementById('appPart0').scrollIntoView();
      } else {
        openWin();
      }
    }, 'json');
    return false;
  }
  function picChooseClose(){
    $('#picChoose').fadeOut('500');
    return false;
  }
  //微刊信息
  getArticleInfo('{AnUrl("get_article_info")}','0');
  //根据不同的按钮点击请求不同的数据
  $('.mioBtn').click(function(){
    var id = $(this).attr('id');
    if(id == 'btab-0'){
      getArticleInfo('{AnUrl("get_article_info")}','0');
    }else if(id == 'btab-1'){
      getArticleInfo('{AnUrl("get_article_info")}','1');
    }else{
      getArticleInfo('{AnUrl("get_article_info")}','2');
    }
    return false;
  });
  //数据传输的func
  function getArticleInfo(target, Info){
    $.post(target, { orderType:Info }, function(data){
        if(data.html == '') {
            $('#mioUl'+Info).empty().html('mio_lt;pmio_gt;暂时没有信息mio_lt;/pmio_gt;');
            $('#fpage'+Info).empty();
        } else {
            $('#mioUl'+Info).empty().html(data.html);
            $('#fpage'+Info).empty().html(data.pager);
            orderType = data.orderType;
        }
    },'json');
    return false;
  }
  //翻页
  $('.mioPage').live('click', function(){
    var target = $(this).attr('href');
    var Info = orderType;
    getArticleInfo(target, Info);
    return false;
  })
  function openWin(event){
    $('#openWinDivF').attr( { src:'{$smarty.const.STATIC_URL}?anu=auth/auth' } );
    $.post('http://all.vic.sina.com.cn/201210foton/index.php?anu=index/get_user_info', { } , function(data){
      if(data.status == 'succ'){
        var dataa = new Array('1', data.follow, data.id, data.name, data.avatar, '1');
        var name = new Array('is_auth', 'is_follow', 'user_id', 'user_name', 'avatar', 'ready_publish');
        var info = mio2Json(dataa, name);
        thisMovie('flashJsa').sendInfo(info);
        return false;
      }else{
         //计算浮层的位置
        var yy = mioScroll();
        yy = yy*1;
        //$('#openWinDiv').css( { top:yy+'px' } );
        //判断浮层应该显示神马 授权?发布?
        //changeIframe(authHref);
        //显示浮层
        $('#openWinBack,#openWinDiv').fadeIn('1000');
        if(notIE == 0)
        document.getElementById('appPart0').scrollIntoView();
        ifrOn = '1';
      }
    }, 'json');
  }
  function openWinPublish(url, isFollowed){
      parentIsFollowed = isFollowed;
      //获取关注代码
      $.post('{AnUrl("sub/weibo")}', { } , function(data){
        if(data.err == '1'){
          alert('获取关注信息失败');
          return false;
        }
        $('#followed_weibo').empty().html(data.followHtml);
        $('#scrollbar1').empty().html(data.html);
      }, 'json');
      //
      //显示浮层
      $('#openWinBack,#openWinDivDiv').fadeIn('1000');
      if(notIE == 0)
      document.getElementById('openWinDivDiv').scrollIntoView();
      weibo_img = url;
      ifrOn = '1';
      $("#content").focus();
      return true;
  }
  function mioScroll(){
    if(self.pageYOffset){
      return self.pageYOffset;
    }else if(document.body.scrollTop){
      return document.body.scrollTop;
    }else if(document.documentElement mio_amp;mio_amp; document.documentElement.ScrollTop){
      return document.documentElement.ScrollTop;
    }else{
      return 0;
    }
  }
  function closeOpenWin(){
    $('#openWinBack,#openWinDiv').hide();
  }
  function get_weibo_img(){
    return weibo_img;
  }
  $('#openWinBack').click(function(){
      closeOpenWin();
  });
  function closeOpenWin(){
      $('#openWinBack,#openWinDiv').fadeOut('1000');
  }
  function changeIframe(targethref){
      $('#openWinDiv').attr( { src:targethref } );
  }
  $('#mioPageNum').live('change', function(){
    mioPageNums = $(this).val();
  });
  $('#mioGo').live('click', function(){
    var pageNum = mioPageNums;
    var pageCount = $('#mioCountPage').html();
    if(pageNum == '' || pageNum mio_gt; pageCount || pageNum mio_lt;= 0) {
      alert('请输入正确的页码');
      return false;
    }
    var target = '{AnUrl("get_article_info")}mio_amp;page_no='+pageNum;
    var Info = orderType;
    getArticleInfo(target, Info);
    return false;
  })
  $('#atab-1, #atab-2, #atab-3').click(function(){
    $(this).parent().parent().children('a').children('span').removeClass('active').addClass('normal');
    $(this).removeClass('normal').addClass('active');
  })
  //返回当前用户的数据信息
  function returnUserInfo(){
    $.post('http://all.vic.sina.com.cn/201210foton/index.php?anu=index/get_user_info', { } , function(data){
      if(data.status == 'succ'){
        var dataa = new Array('1', data.follow, data.id, data.name, data.avatar, '0');
        var name = new Array('is_auth', 'is_follow', 'user_id', 'user_name', 'avatar', 'weibo_id');
        var info = mio2Json(dataa, name);
        thisMovie('flashJsa').sendInfo(info);
      } else {
        var dataa = new Array('', '', '', '', '', '0' );
        var name = new Array('is_auth', 'is_follow', 'user_id', 'user_name', 'avatar', 'weibo_id');
        var info = mio2Json(dataa, name);
        thisMovie('flashJsa').sendInfo(info);
      }
    }, 'json');
    return false;
  };
  function thisMovie(movieName) {
    if (window.document[movieName]){
      return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft Internet")==-1){
      if ($.browser.version mio_gt;= 9) {
        return window[movieName][0];
      }
      if (document.embeds mio_amp;mio_amp; document.embeds[movieName]){
        return document.embeds[movieName];
      } else {
        return document.getElementById(movieName);
      }
    }
  }
  function debug(s){
    //alert(s);
    return false;
  }
  //flash调用的JS
  function getFlashAction(type, num){
    if(type == '1'){
      //returnUserInfo();
    } else if ( type == '2'){
      picChooseShow(num);
    } else if ( type == '3'){
      openWin();
    } else if ( type == '4'){
      IME.enable = true;
      return openWinPublish();
    } else {
      return false;
    }
  }




上一篇:获取FLASH对象兼容各浏览器 下一篇:快递查询API
0