[SCEditor] BBcode Google URL Shortener

  Bài viết hay nhất1

BBcode Google URL Shortener cho SCEditor


Giới thiệu

Google URL Shortener sẽ giúp bạn rút gọn các liên kết dài, và theo dõi hoạt động của nó như số liên kết, trang web sử dụng. Trong forumotion, nó đặc biệt hữu dụng với các liên kết download, vì nếu bạn để dạng thông thường sẽ bị gắn liên kết adf.ly.
Ví dụ: [You must be registered and logged in to see this link.] (đây là liên kết từ mega.co.nz)

Plugin [You must be registered and logged in to see this link.], mình chỉ ứng dụng 2 api tạo liên kết rút gọn và lấy liên kết gốc. Để xem số liệu thống kê bạn làm theo cách sau:
Đăng nhập tài khoản google.
Lấy url_id của liên kết.
Ví dụ: [You must be registered and logged in to see this link.] thì url_idYuSMzW
Thay vào vị trí tương ứng: http://goo.gl/#analytics/goo.gl/url_id/all_time
Ví dụ: [You must be registered and logged in to see this link.]


Demo

[You must be registered and logged in to see this image.]
Tạo liên kết rút gọn

[You must be registered and logged in to see this image.]
Lấy liên kết gốc


Hướng dẫn

Tạo javascript mới

ACP >> Modules >> HTML & JAVASCRIPT >> Javascript codes management >> Create a new javascript
Placement : In all the pages
Javascript Code * :
Code:
/* BBcode Google URL Shortener - devs.forumvi.com */
$(function () {
   $(function () {
      if ($.sceditor) {
         $("body").append('<div id="sceditor-shortlink" style="display:none;" class="sceditor-dropdown sceditor-shortlink"><div><div unselectable="on"><label unselectable="on" for="shortlinkurl">URL</label><input id="shortlinkurl" class="url" placeholder="http://" value="" type="text" /></div><div unselectable="on"><input id="gooSubmit" value="insert" class="button" type="button" /></div></div></div>');
         var b = $("#shortlinkurl");
         $('<a class="sceditor-button sceditor-button-shortlink" title="Google URL Shortener"><div id="shortlink-icon" style="opacity:1;background-image:url(http://i.imgur.com/ZUOYMBj.png)">URL Shortener</div></a>').insertAfter(".sceditor-button-link").click(function () {
            $("#sceditor-shortlink").css({
               "margin-top": $(".sceditor-button-shortlink").outerHeight(),
               left: $(this).offset().left,
               top: $(this).offset().top
            }).toggle();
            if ($("#sceditor-shortlink").is(":visible")) {
               var a = $("#shortlink-icon");
               "undefined" == typeof $.GoogleURLShortener && (a.css("background-image", "url(http://i.imgur.com/m3NXDa6.gif)"), b.prop("disabled", !0).val("Đang kết nối..."), $.getScript("http://devs.forumvi.com/32907.js", function () {
                  a.css("background-image", "url(http://i.imgur.com/ZUOYMBj.png)");
                  b.prop("disabled", !1).focus().val("")
               }))
            }
         }).mouseover(function () {
            $(this).removeClass("disabled")
         });
         var c = $("#shortlink-icon"),
            d = function () {
               $("#sceditor-shortlink").hide();
               b.prop("disabled", !1).val("");
               c.css("background-image", "url(http://i.imgur.com/ZUOYMBj.png)")
            };
         b.keyup(function (a) {
            13 == a.keyCode && $("#gooSubmit").click()
         });
         $("#gooSubmit").click(function () {
            b.prop("disabled", !0);
            c.css("background-image", "url(http://i.imgur.com/m3NXDa6.gif)");
            $.GoogleURLShortener({
               url: $("#shortlinkurl").val(),
               success: function (a, b) {
                  $("#text_editor_textarea").sceditor("instance").insert(a);
                  d()
               },
               error: function (a, c) {
                  console.error(a, c);
                  alert("Có lỗi xảy ra! Vui lòng kiểm tra lại URL:\n" + b.val());
                  d()
               }
            })
         });
         $(".sceditor-button:not(.sceditor-button-shortlink)").click(function () {
            $("#sceditor-shortlink").is(":visible") && $("#sceditor-shortlink").hide()
         })
      }
   })
});


Nguồn

Zzbaivong (devs.forumvi.com)
  Bài viết hay nhất2
sao mình làm mà nhấp vào nó tắt luôn ko hiên lên nữa
  Bài viết hay nhất3
[You must be registered and logged in to see this link.]
tommy_phan wrote:sao mình làm mà nhấp vào nó tắt luôn ko hiên lên nữa
demo onl + acc test
  Bài viết hay nhất4
Demo: [You must be registered and logged in to see this link.]
Acc Test: ID: Test - Pass: psgclub
forum cũg bị như bạn tommy_phan @@
  Bài viết hay nhất5
Thay lại code javascript nhé!
  Bài viết hay nhất6
vẫn vậy ah admin
  Bài viết hay nhất7
[You must be registered and logged in to see this link.]
tommy_phan wrote:vẫn vậy ah admin
cái đó là ad hướng dẫn cho demo của người ta, demo của bác đâu + acc test của bác đâu - k up lên mà hỏi tại sao mãi @@
  Bài viết hay nhất8
Fantastic, working very well..!
  Bài viết hay nhất9
Mình nhập link nào nó cũng báo "Có lỗi xảy ra. Vui lòng kiểm tra lại URL là sao ạ...
  Bài viết hay nhất10
ko nên sài cái này. Dùng link lâu sau này truy cập vào ko đc nữa
  Bài viết hay nhất11
Vậy sài cái gì đc. Forum mình phải dùng nhiều link download lắm.
  Bài viết hay nhất12
còn nhiều cách khác nữa mà?
  Bài viết hay nhất13
đó là những cách nào
  Bài viết hay nhất14
You cannot reply to topics in this forum