PageSourceSearch

https://igotoworld.com/frontend/webcontent/js/translation.js

js igotoworld.com collected 2026-09-24 19:35:14 UTC 5,363 bytes, 168 lines download raw bytes

1var Translation = (function()
2{
3    var currentLangId;
4    var objectId;
5    var objectType; /** if we need to vote for different types of objects */
6    var isVoted = false;
7
8    var init = function (langId, oId, oType) {
9        currentLangId = langId;
10        objectId = oId;
11        objectType = oType || 'article';
12
13        checkUserVote();
14        subscribeEvents();
15    };
16
17    var subscribeEvents = function(){
18        // popup to vote for auto translation
19        $(".descriptionAutoTranslateTitle").off().hover(
20            function () {
21                $('.voteTranslationPopUp').show();
22            },
23            function () {
24                $('.voteTranslationPopUp').hide();
25            }
26        );
27        $(".voteTranslationPopUp").off().hover(
28            function () {
29                $('.voteTranslationPopUp').show();
30            },
31            function () {
32                $('.voteTranslationPopUp').hide();
33            }
34        );
35
36
37        // popup for original
38        $(".originalTitle").off().on({
39            mouseenter: function(e) {
40                $('.originalPopUp').show();
41            },
42            mouseleave: function(e) {
43                $('.originalPopUp').hide();
44            }
45        });
46        $(".originalPopUp").off().on({
47            mouseenter: function(e) {
48                $('.originalPopUp').show();
49            },
50            mouseleave: function(e) {
51                $('.originalPopUp').hide();
52            }
53        });
54
55        $(".translateVoteItem").off().hover(
56            function () {
57                if(!isVoted){
58                    $('.translateVoteItem').removeClass('translateVoteItemSelected');
59                    $(this).addClass('translateVoteItemSelected');
60                }
61            },
62            function () {
63                if(!isVoted){
64                    $(this).removeClass('translateVoteItemSelected');
65                }
66            }
67        );
68    };
69
70    /**
71     * Ajax load translation by lang id
72     * @param langId
73     * @returns {boolean}
74     */
75    var getOriginalByLangId = function(langId){
76        var params = {
77            objectType:	objectType,
78            objectId:	objectId,
79            langId:	    langId,
80            method:		'getOriginalByLangId',
81            controller:	'TranslateController'
82        };
83        $.ajax({
84            type: 'POST',
85            dataType: 'json',
86            url: '',
87            data: params
88        })
89        .done(function(response) {
90            if(response){
91                var originalPopupSource = $('.originalPopupSource').html();
92                $('#autotranslate-box-title').html(originalPopupSource);
93                $('#autotranslate-box').removeClass('descriptionAutoTranslate');
94
95                $("#article-title").html(response.title);
96                $("#article-infoblock").html(response.introHtml);
97
98                var image = '';
99                if(response.image !== ""){
100                    image = '<div class="newsImageHolder"><img src="'+response.image+'" alt="'+response.title+'" /></div>';
101                }
102
103                var content = image + '<div id="html-content">'+response.html+'</div>';
104
105                $("#autotranslate-box").html(content);
106
107                $("#originalLangIcon").attr('src', response.langImage);
108
109                /** reinit events */
110                subscribeEvents();
111            }
112        })
113        .fail(function(jqXHR, textStatus, errorThrown) {
114            alert(jqXHR + '   |   ' + textStatus + '   |   ' + errorThrown);
115        });
116
117        return false;
118    };
119
120    /**
121     * Check if current user vote of this object translation
122     */
123    var checkUserVote = function(){
124        var voteItemId = $.cookie('translate_vote_'+objectType+'_'+objectId+'_'+currentLangId);
125        if (voteItemId){
126            $('#translateVoteItem'+voteItemId).addClass('translateVoteItemSelected');
127            $(".translateVoteItem").off('mouseenter mouseleave');
128            isVoted = true;
129        }
130    };
131
132    var vote = function(obj, voteItem){
133        if (!isVoted){
134            var params = {
135                vote:	    voteItem,
136                objectType:	objectType,
137                objectId:	objectId,
138                method:		'translationVote',
139                controller:	'TranslateController'
140            };
141            $.ajax({
142                type: 'POST',
143                dataType: 'json',
144                url: '',
145                data: params
146
147            })
148            .done(function(response) {
149                    if(response){
150                        isVoted = true;
151                        $(obj).addClass('translateVoteItemSelected');
152                        $(".translateVoteItem").off('mouseenter mouseleave');
153                        $.cookie('translate_vote_'+objectType+'_'+objectId+'_'+currentLangId, voteItem, { expires: 365, path: '/' });
154                    }
155            })
156            .fail(function(jqXHR, textStatus, errorThrown) {
157                alert(jqXHR + '   |   ' + textStatus + '   |   ' + errorThrown);
158            });
159        }
160    };
161
162    return {
163        init: init,
164        vote: vote,
165        getOriginalByLangId: getOriginalByLangId
166    };
167
168})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.