Cc imitates the method of converting long URL to short address of sina Weibo

From , 5 Years ago, written in C#, viewed 163 times.
URL https://pastebin.vip/view/ab2ce2a4
  1.  
  2. function CheckInput() {  
  3.     var $txtLength = $("#inp_text").val().length;  
  4.     if ($txtLength > 10) {  
  5.         var url = $("#inp_text").val();  
  6.         var xx = url.match(RegExp("((news|telnet|nttp|file|http|ftp|https)://){1}(([-A-Za-z0-9]+(\\.[-A-Za-z0-9]+)*(\\.[-A-Za-z]{2,5}))|([0-9]{1,3}(\\.[0-9]{1,3}){3}))(:[0-9]*)?(/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*)*", "gi") || []);  
  7.         if (xx != null) {  
  8.             for (var i = 0; i < xx.length; i++) {  
  9.                 var $txtLength = $("#inp_text").val().length;  
  10.                 $txtLength = $txtLength - xx[i].length + 11;  
  11.             }  
  12.         }  
  13.     }  
  14.     if ($txtLength < 141) {  
  15.         $("#div_txtlength").html("还能输入<span>" + (140 - $txtLength) + "</span>个字");  
  16.     }  
  17.     else {  
  18.         $("#div_txtlength").html("超出<span>" + ($txtLength - 140) + "</span>个字");  
  19.     }  
  20.  
  21. }  
  22.  
  23. function InsertText() {  
  24.     if ($("#inp_text").val().Trim().length == 0) {  
  25.         art.dialog({  
  26.             title: '错误',  
  27.             icon: 'error',  
  28.             content: '请输入内容',  
  29.             width: "150px",  
  30.             height: "80px",  
  31.             lock: true  
  32.         });  
  33.         return;  
  34.     }  
  35.     //长url转换成短url  
  36.     var url = $("#inp_text").val();  
  37.     var xx = url.match(RegExp("((news|telnet|nttp|file|http|ftp|https)://){1}(([-A-Za-z0-9]+(\\.[-A-Za-z0-9]+)*(\\.[-A-Za-z]{2,5}))|([0-9]{1,3}(\\.[0-9]{1,3}){3}))(:[0-9]*)?(/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*)*", "gi") || []);  
  38.     var $txtLength = $("#inp_text").val().length;  
  39.     if (xx != null) {  
  40.         for (var i = 0; i < xx.length; i++) {  
  41.             $txtLength = $txtLength - xx[i].length + 11;  
  42.         }  
  43.     }  
  44.     if ($txtLength < 141) {  
  45.         $("#div_txtlength").html("还能输入<span>" + (140 - $txtLength) + "</span>个字");  
  46.     }  
  47.     else {  
  48.         $("#div_txtlength").html("超出<span>" + ($txtLength - 140) + "</span>个字");  
  49.     }  
  50.     if ($txtLength > 140) {  
  51.         art.dialog({  
  52.             title: '错误',  
  53.             icon: 'error',  
  54.             content: '字数超出限制',  
  55.             width: "150px",  
  56.             height: "80px",  
  57.             lock: true  
  58.         });  
  59.         return false;  
  60.     }  
  61.     $.ajax({  
  62.         type: "POST",  
  63.         url: "../MiniBlog/Handler.ashx",  
  64.         data: { "txt": $("#inp_text").val() },  
  65.         datatype: "html",  
  66.         beforeSend: function () { $("#div_txtlength").html("正在提交。。。"); },  
  67.         success: function (data) {  
  68.             if (data.length > 1) {  
  69.                 window.location.reload();  
  70.             }  
  71.             else {  
  72.                 art.dialog({  
  73.                     title: '错误',  
  74.                     icon: 'error',  
  75.                     content: '发布失败,请复制内容后刷新当前页面。',  
  76.                     width: "150px",  
  77.                     height: "80px",  
  78.                     lock: true  
  79.                 });  
  80.             }  
  81.         },  
  82.         complete: function (XMLHttpRequest, textStatus) {  
  83.             //                    alert(XMLHttpRequest.responseText);  
  84.             //                    alert(textStatus);  
  85.         },  
  86.         error: function () {  
  87.         }  
  88.     });  
  89. }  
  90.  
  91.  
  92. //csharp/6655

Reply to "Cc imitates the method of converting long URL to short address of sina Weibo"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website