index.html 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  6. <title>短链生成 Long To Short</title>
  7. <link rel="stylesheet" href="/static/css/style.css" />
  8. </head>
  9. <body>
  10. <div class="content">
  11. <h2>Long To Short</h2>
  12. <h3>-= 短链接生成 =-</h3>
  13. <div class="generate">
  14. <div class="get clear">
  15. <input class="long_link" type="text" placeholder="(~o ̄3 ̄)~~快把链接放进来嘛" />
  16. <div class="btn">快! ~ 点我!</div>
  17. </div>
  18. <div class="result">
  19. <div class="tag">失败</div>
  20. <div class="short">(*゚Д゚*) 链接~链接~我要吃链接~~~</div>
  21. </div>
  22. </div>
  23. </div>
  24. <script src="/static/js/common.js"></script>
  25. <script src="/static/js/jquery.min.js"></script>
  26. <script>
  27. $(function(){
  28. $('.get .btn').click(function(){
  29. $('.tag').hide();
  30. $('.short').text('─=≡Σ(((つ•̀ω•́)つ 加速获取短链接中...');
  31. if($('.long_link').val() && $('.long_link').val().match(/^http(s)?:\/\/(\w+|\.|\/)+/g)){
  32. var link = 'http://api.l2s.ch/getlink?key=e5e945ff9502096636bc1e903cea3325&url=' + b64EncodeUnicode($('.long_link').val());
  33. // var link = 'http://127.0.0.1:3231/getlink?key=e5e945ff9502096636bc1e903cea3325&url=' + b64EncodeUnicode($('.long_link').val());
  34. $.ajax({
  35. url:link,
  36. dataType:'json',
  37. success:function(result){
  38. if(result.success==1){
  39. $('.tag').text('成功').removeClass('fail').show();
  40. $('.short').text(result.short);
  41. }else{
  42. $('.tag').text('失败').addClass('fail').show();
  43. $('.short').text('(o´゚□゚`o) ~啊~咧!好像获取失败了呢~ ERROR:'+result.msg);
  44. }
  45. },
  46. error:function(){
  47. $('.tag').text('失败').addClass('fail').show();
  48. $('.short').text('(o´゚□゚`o) ~啊~咧!好像获取失败了呢~');
  49. }
  50. })
  51. }else{
  52. $('.tag').text('失败').addClass('fail').show();
  53. $('.short').text('(〃>皿<) 根本就不是一个正常的链接啊~~魂~淡!~');
  54. }
  55. });
  56. });
  57. </script>
  58. </body>
  59. </html>