• Thống kê diễn đàn


[SCEditor] BBcode Google URL Shortener

View previous topic View next topic Go down

[SCEditor] BBcode Google URL Shortener Empty [SCEditor] BBcode Google URL Shortener

Post by Bui Minh Phong™ 28/5/2014, 9:03 pm

[You must be registered and logged in to see this link.]

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 GoogleURLShortener, 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.]

[SCEditor] BBcode Google URL Shortener U4m97mz
Tạo liên kết rút gọn

[SCEditor] BBcode Google URL Shortener S0dugkQ
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()
            })
        }
    })
});


Zzbaivong
Bui Minh Phong™
Bui Minh Phong™
Quản Trị Cấp Cao
Quản Trị Cấp Cao

Posts : 3260
Points : 371262
Thanked : 1927
Birthday : 1994-12-18
Status Hãy Lặng Yên Để Cảm Nhận Tình Yêu Xung Quanh Bạn :x
Giới tính : Male Rất dễ thương

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum