javascript.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. function $obj(id) {
  2. return document.getElementById(id);
  3. }
  4. function setButtonDisable(b,c){
  5. var d=$obj(b);
  6. if(d)if(!c&&arguments.length==2)window.setTimeout("setButtonDisable('"+b+"',false,0);",40);
  7. else{
  8. d.disabled=c;d=d.parentNode.parentNode;var e="";if(d.className.indexOf("minbtn-wrap")>-1)e="minbtn-disable";else if(d.className.indexOf("btn-wrap")>-1)e="btn-disable";
  9. if(e)c?addCssClass(d,e):removeCssClass(d,e)
  10. }
  11. }
  12. function noneblock(targetid){
  13. var ifview = document.getElementsByTagName("a");
  14. var target = document.getElementById(targetid);
  15. target.style.display = target.style.display == 'none' ? 'block' : 'block';
  16. }
  17. function CleanHtml(content)
  18. {
  19. content = content.replace(/<p>/gi,"\n\r");
  20. content = content.replace(/<br>/gi,"\n");
  21. content = content.replace(/&nbsp;/gi," ");
  22. content = content.replace(/(<(meta|iframe|frame|span|tbody|layer)[^>]*>|<\/(iframe|frame|meta|span|tbody|layer)>)/gi, "");
  23. content = content.replace(/<\\?\?xml[^>]*>/gi, "") ;
  24. content = content.replace(/o:/gi, "");
  25. content = content.replace(/ /gi, " ");
  26. return content;
  27. }
  28. function AvatarSubmit()
  29. {
  30. if(document.form1.mymps_member_logo.value=="")
  31. {
  32. document.form1.mymps_member_logo.focus();
  33. alert("请选择你要上传的文件!");
  34. return false;
  35. }
  36. }
  37. function CertifySubmit()
  38. {
  39. if(document.form1.certify_image.value=="")
  40. {
  41. document.form1.certify_image.focus();
  42. alert("请选择你要上传的文件!");
  43. return false;
  44. }
  45. }
  46. function AlbumSubmit(){
  47. if(document.form1.title.value=="")
  48. {
  49. document.form1.title.focus();
  50. alert("相片标题不能为空!");
  51. return false;
  52. } else if(document.form1.album_up.value==""){
  53. document.form1.album_up.focus();
  54. alert("请选择你要上传的文件!");
  55. return false;
  56. }
  57. }
  58. function SeePic(img,f){
  59. if ( f.value != "" ) { img.src = f.value; }
  60. }
  61. function CheckAll(form)
  62. {
  63. for (var i=0;i<form.elements.length-1;i++)
  64. {
  65. var e = form.elements[i];
  66. if( e.type == 'checkbox'){
  67. e.checked = ifcheck;
  68. }
  69. }
  70. ifcheck = ifcheck == false ? true : false;
  71. }
  72. function removeElement(obj){
  73. var text = $(obj).parent().text();
  74. text = text.substring(0,text.length-1);
  75. json = $("#currentClass").val();
  76. if(json){
  77. json = JSON.parse(json);
  78. }else{
  79. json={};
  80. }
  81. delete json[text];
  82. $("#currentClass").val( JSON.stringify(json) );
  83. $(obj).parent().remove();
  84. }
  85. function addClass(){
  86. var ele = $("#intName");
  87. var json = $("#currentClass").val();
  88. if(json){
  89. json = JSON.parse(json);
  90. }else{
  91. json={};
  92. }
  93. var input = ele.val();
  94. if(input){
  95. if(ele.parent().children().length>12){
  96. alert("最多只能添加12个分类");
  97. return false;
  98. }
  99. for(var i =0,allElement = ele.parent().children();i<allElement.length;i++){
  100. if(allElement[i].nodeName === "SPAN"){
  101. if(allElement[i].innerText==(input+"X")){
  102. alert("存在相同栏目名");
  103. return false;
  104. }
  105. }
  106. }
  107. var ele_span = $('<span class=mclass>'+input+'<span class=x title=删>X</span></span>');
  108. ele_span.insertBefore(ele);
  109. ele_span.find("span").click(function(){
  110. removeElement(this);
  111. });
  112. json[input]="";
  113. $("#currentClass").val( JSON.stringify(json) );
  114. }else{
  115. alert("请输入栏目名称");
  116. }
  117. }
  118. ifcheck = true;