Files

1 line
73 KiB
JavaScript

Crowdin = window.Crowdin ? Crowdin : { phrases: null, htmlPhrases: [], entryPoint: "http://crowdin.net/", jiptCDN: "http://jipt.crowdin.net/", editor: { currentTranslation: null, currentTranslations: [], currentElement: null, showTranslations: false, marker: "border", skipApproved: false, files: false, customPlaceholders: [], mergeDuplicates: true, currentPhraseId: null, traversePage: true }, suggestions: { tm: [], google: [], microsoft: [] }, language: { code: null, id: 0 }, source_language: { code: null }, project: { id: 0, identifier: null, name: null }, user: { is_leader: false, is_logged_in: true }, previewTranslations: false, _preloadCallbacks: [], is_first_run: false, matchType: { any: 0, text: 1, textRegExp: 2, html: 3, htmlRegExp: 4, htmlOuter: 5, title: 6 }, placeholders: [{ template: "((?:%%|%(?:[0-9]+\\$)?[+-]?(?:[ 0]|'.)?-?[0-9]*(?:\\.[0-9]+)?[bcdeufFosxX]))", replacement: "(.*)" }, { template: "(\\{0\\})", replacement: "(.*)" }, { template: "(\\{1\\})", replacement: "(.*)" }, { template: "(\\{2\\})", replacement: "(.*)" }, { template: "(\\{3\\})", replacement: "(.*)" }, { template: "(\\{4\\})", replacement: "(.*)" }, { template: "(\\{5\\})", replacement: "(.*)" }, { template: "(%1)", replacement: "(.*)" }, { template: "(%2)", replacement: "(.*)" }, { template: "(%3)", replacement: "(.*)" }, { template: "(%4)", replacement: "(.*)" }, { template: "(%5)", replacement: "(.*)" }, { template: "(%6)", replacement: "(.*)"}], init: function() { Crowdin.self = this; this.self_configure(); this.init_google_jsapi(); return this }, ready: function(a) { Crowdin._preloadCallbacks.push(a) }, get_instance: function() { return Crowdin.self }, start_translation: function() { if ($JIPT("#crowdin-translation-panel").length) { this.just_show_panel() } else { this.init_editor().init_translation_panel().init_help_dialog(); this.loader.create().hide() } }, self_configure: function() { if (this.check_first_run()) { this.is_first_run = true } else { this.is_first_run = false } if (!Crowdin.cookies.has("crowdin_language_code" + this.get_project_identifier()) || !Crowdin.cookies.has("crowdin_language_id" + this.get_project_identifier()) || !Crowdin.cookies.has("crowdin_project_id" + this.get_project_identifier()) || !Crowdin.cookies.has("crowdin_project_name" + this.get_project_identifier()) || !Crowdin.cookies.has("crowdin_source_language_code" + this.get_project_identifier())) { this.logout() } this.language.code = Crowdin.cookies.get("crowdin_language_code" + this.get_project_identifier()); this.language.id = Crowdin.cookies.get("crowdin_language_id" + this.get_project_identifier()); this.project.id = Crowdin.cookies.get("crowdin_project_id" + this.get_project_identifier()); this.project.name = Crowdin.cookies.get("crowdin_project_name" + this.get_project_identifier()); this.user.is_leader = Crowdin.cookies.get("crowdin_is_leader" + this.get_project_identifier()); if (Crowdin.cookies.has("crowdin_marker" + this.get_project_identifier())) { this.editor.marker = Crowdin.cookies.get("crowdin_marker" + this.get_project_identifier()) } if (Crowdin.cookies.has("crowdin_merge_duplicates" + this.get_project_identifier())) { this.editor.mergeDuplicates = (Crowdin.cookies.get("crowdin_merge_duplicates" + this.get_project_identifier()) == "true") } else { this.editor.mergeDuplicates = true } if (Crowdin.cookies.has("crowdin_show_translations" + this.get_project_identifier())) { this.editor.showTranslations = (Crowdin.cookies.get("crowdin_show_translations" + this.get_project_identifier()) == "true"); this.previewTranslations = this.editor.showTranslations } this.source_language.code = Crowdin.cookies.get("crowdin_source_language_code" + this.get_project_identifier()) }, check_first_run: function() { if (!Crowdin.cookies.pattern_has("crowdin_marker") && !Crowdin.cookies.pattern_has("crowdin_merge_duplicates") && !Crowdin.cookies.pattern_has("crowdin_show_translations")) { return true } else { return false } }, show_quick_start: function() { $JIPT("#crowdin-help-container").attr("src", this.jiptCDN + "help/quick-start.html"); $JIPT("#crowdin-help").dialog("open") }, set_element_marker: function(c, a) { if (this.previewTranslations) { return } c = $JIPT(c); var e = c.attr("class").split(/\s+/); var f = /^crowdin-jipt-/; for (var b = 0; b < e.length; b++) { var d = e[b]; if (d.match(f)) { c.removeClass(d) } } $JIPT(c).addClass(a + "-" + this.editor.marker) }, _get_editor_buttons: function() { var a = {}; if (this.editor.currentPhraseId) { a["Translate and Open Next"] = this._suggest_translation_and_open_next; a.Skip = this._proceed_to_next_phrase } if (this.editor.currentTranslations && this.editor.currentTranslations.length > 0) { a["Translate All"] = this._suggest_translation } else { a.Translate = this._suggest_translation } a.Cancel = function() { $JIPT("#crowdin-editor").dialog("close"); if (Crowdin.self.editor.currentElement != null) { } }; return a }, init_editor: function() { if ($JIPT("#crowdin-editor").length) { return this } $JIPT($JIPT("<div>").attr("id", "crowdin-editor").attr("title", "Crowdin Editor").css("display", "none").html(this.get_editor_markup())).appendTo("body"); $JIPT("#crowdin-editor").dialog({ autoOpen: false, height: "auto", zIndex: 16777260, width: 600, dialogClass: "cjipt", beforeClose: function() { $JIPT(".crowdin-active-element").removeClass("crowdin-active-element") }, buttons: this._get_editor_buttons() }); this.dialog_ui_help($JIPT("#crowdin-editor"), this.jiptCDN + "help/crowdin-editor.html"); $JIPT("#crowdin-show-hide-context").click(function() { $JIPT("#crowdin-context-header").slideToggle(); $JIPT(".crowdin-phrase-context").slideToggle() }); $JIPT("#crowdin-copy-source").click(function() { var a = Crowdin.self.editor.currentTranslation.html ? Crowdin.self.editor.currentTranslation.html : Crowdin.self.editor.currentTranslation.text; $JIPT(".crowdin-editor-translation").val(a).focus(); Crowdin.self.place_translation_preview(a) }); $JIPT("#crowdin-edit-context").click(function() { $JIPT("#crowdin-context-editor-current-context").html(Crowdin.self.editor.currentTranslation.context.replace(/(\r\n|\n\r|\r|\n)/g, "<br />")); $JIPT("#crowdin-context-editor").dialog("open"); Crowdin.self.fix_dialogs() }); $JIPT(".crowdin-editor-translation").keyup(function(a) { if ($JIPT(this).val().length == 0) { return } if (a.keyCode != 27) { Crowdin.self.place_translation_preview($JIPT(this).val()) } if ((a.ctrlKey) && ((a.keyCode == 10) || (a.keyCode == 13))) { if (Crowdin.self.editor.currentPhraseId) { Crowdin.self._suggest_translation_and_open_next() } else { Crowdin.self._suggest_translation() } } if ((a.altKey) && ((a.keyCode == 10) || (a.keyCode == 13))) { if (Crowdin.self.editor.currentPhraseId) { Crowdin.self._proceed_to_next_phrase() } } }); this.init_context_editor(); this.init_functions_proxy(); return this }, _suggest_translation_and_open_next: function() { if (Crowdin.self._suggest_translation()) { Crowdin.self._proceed_to_next_phrase() } }, _proceed_to_next_phrase: function() { if (Crowdin.self.editor.currentPhraseId && Crowdin.self.phrases[Crowdin.self.editor.currentPhraseId + 1]) { Crowdin.self.editor.currentPhraseId++; Crowdin.self.editor.currentTranslation = Crowdin.self.phrases[Crowdin.self.editor.currentPhraseId]; Crowdin.self.editor.currentTranslations = []; Crowdin.self.editor.currentElement = null; Crowdin.self.editor.currentPhraseId = Crowdin.self.editor.currentPhraseId; Crowdin.self.show_editor() } else { Crowdin.self.loader.notify("You reached the end of file.") } }, _suggest_translation: function() { if (!Crowdin.self._validate_translation()) { return false } else { Crowdin.self._force_suggest_translation(); return true } }, trigger_suggestion_added: function() { if (this.editor.currentElement != null) { for (var a = this.editor.currentTranslation.elements.length; a--; ) { this.set_element_marker(this.editor.currentTranslation.elements[a], "crowdin-jipt-translated") } } var c = null; for (var b = this.phrases.length; b--; ) { if (this.phrases[b].id == this.editor.currentTranslation.id) { this.phrases[b].suggestions_count++; c = b; break } } $JIPT(".jipt-phrases-to-translate li a[rel=" + c + "]").removeClass("crowdin-untranslated-item").addClass("crowdin-translated-item") }, trigger_suggestion_approved: function() { if (this.editor.currentElement != null) { for (var a = this.editor.currentTranslation.elements.length; a--; ) { this.set_element_marker(this.editor.currentTranslation.elements[a], "crowdin-jipt-approved") } } var c = null; for (var b = this.phrases.length; b--; ) { if (this.phrases[b].id == this.editor.currentTranslation.id) { this.phrases[b].approved = true; c = b; break } } $JIPT(".jipt-phrases-to-translate li a[rel=" + c + "]").removeClass("crowdin-translated-item").addClass("crowdin-approved-item") }, _force_suggest_translation: function() { $JIPT("#crowdin-editor").dialog("close"); this.trigger_suggestion_added(); if (this.editor.currentTranslations.length) { for (var a = 0; a < this.editor.currentTranslations.length; a++) { this.suggest(this.editor.currentTranslations[a].translation, $JIPT(".crowdin-editor-translation").val()) } } else { this.suggest(this.editor.currentTranslation, $JIPT(".crowdin-editor-translation").val()) } }, _validate_translation: function() { var a = $JIPT(".crowdin-editor-translation").val(); if (!a.length) { this.loader.notify("Translation can not be empty string"); $JIPT(".crowdin-editor-translation").focus(); return false } var p = this.editor.currentTranslation.text.match(/^\s*/g)[0].length; var b = a.match(/^\s*/g)[0].length; var c = this.editor.currentTranslation.text.match(/\s*$/g)[0].length; var d = a.match(/\s*$/g)[0].length; if (p != b && p == 0) { this.validation_message_with_action("Original text doesn't have any leading spaces, but your suggestion begins with " + b + " spaces"); return false } if (c != d && c == 0) { this.validation_message_with_action("Original text doesn't have any trailing spaces, but your suggestion ends with " + d + " spaces"); return false } if (p != b && b == 0) { this.validation_message_with_action("Original text begins with " + p + " leading spaces, but your suggestion haven't at all"); return false } if (c != d && d == 0) { this.validation_message_with_action("Original text ends with " + c + " trailing spaces, but your suggestion haven't at all"); return false } if (p != b && c != d) { this.validation_message_with_action("The original text has " + p + " leading spaces and " + c + " trailing spaces, your suggestion has " + b + " leading spaces and " + d + " trailing"); return false } if (p != b) { this.validation_message_with_action("The original text has " + p + " leading spaces, your suggestion has " + b); return false } if (c != d) { this.validation_message_with_action("The original text has " + c + " trailing spaces, your suggestion has " + d); return false } var l = this.editor.currentTranslation.text.match(/[\.\!\?\:]+\s*$/g); var h = a.match(/[\.\!\?\:]+\s*$/g); if (!this.is_eq(l, h) && l == null) { this.validation_message_with_action("The original text does not end with: <b>" + h.join(", ") + "</b>"); return false } if (!this.is_eq(l, h) && h == null) { this.validation_message_with_action('Probably you forgot the ending: "<b>' + l.join(", ") + '</b>"'); return false } if (!this.is_eq(l, h) && l != null && h != null) { this.validation_message_with_action('The original text ends with "<b>' + l.join(", ") + '</b>", but your suggestion ends with "<b>' + h.join(", ") + '</b>"'); return false } var n = []; var i = []; var m = []; var g, e, q = null, o = null, f = null; for (g = 0; g < this.placeholders.length; g++) { q = new RegExp(this.placeholders[g].template, "g"); o = this.editor.currentTranslation.text.match(q); f = a.match(q); if (o && o.length) { for (e = 0; e < o.length; e++) { i.push(o[e]) } } if (f && f.length) { for (e = 0; e < f.length; e++) { m.push(f[e]) } } } for (g = 0; g < this.editor.customPlaceholders.length; g++) { q = new RegExp(this.editor.customPlaceholders[g], "g"); o = this.editor.currentTranslation.text.match(q); f = a.match(q); if (o && o.length) { for (e = 0; e < o.length; e++) { i.push(o[e]) } } if (f && f.length) { for (e = 0; e < f.length; e++) { m.push(f[e]) } } } for (e = 0; e < i.length; e++) { if (m.indexOf(i[e]) == -1) { n.push(i[e]) } } if (n.length > 0) { this.validation_message_with_action("You translated or forgot some variables that should have been left as they were: <b>" + n.join(", ") + "</b>"); return false } return true }, validation_message_with_action: function(a) { this.loader.update(a + '&nbsp;<a href="#" class="crowdin-ignore-notification" onclick="Crowdin.self._force_suggest_translation();">Continue anyway!</a>') }, init_functions_proxy: function() { var b = window.alert; window.alert = function() { if (arguments[0]) { Crowdin.self.process_abstract_text(arguments[0]) } return b.apply(this, arguments) }; var a = window.confirm; window.confirm = function() { if (arguments[0]) { Crowdin.self.process_abstract_text(arguments[0]) } return a.apply(this, arguments) } }, process_abstract_text: function(b) { if (!b.length || !this.phrases) { return false } for (var a = this.phrases.length; a--; ) { if (this.fuzzy_trim(b) == this.phrases[a].textCleared) { this.editor.currentTranslation = this.phrases[a]; this.editor.currentTranslations = []; this.editor.currentElement = null; this.editor.currentPhraseId = null; this.show_editor(); return true } if (this.phrases[a].regexp) { if (b.match(this.phrases[a].regexp)) { this.editor.currentTranslation = this.phrases[a]; this.editor.currentTranslations = []; this.editor.currentElement = null; this.editor.currentPhraseId = null; this.show_editor(); return true } } } return false }, init_context_editor: function() { if ($JIPT("#crowdin-context-editor").length) { return } $JIPT($JIPT("<div>").attr("id", "crowdin-context-editor").attr("title", "Context Editor").css("display", "none").html(this.get_context_editor_markup())).appendTo("body"); $JIPT("#crowdin-context-editor").dialog({ autoOpen: false, height: "auto", width: 500, zIndex: 16777270, dialogClass: "cjipt", resizable: false, modal: true, buttons: this.get_context_editor_buttons() }); $JIPT("#crowdin-context-editor-current-context").hover(function() { $JIPT(this).css("background-color", "#fffed4") }, function() { $JIPT(this).css("background-color", "#fff") }); $JIPT("#crowdin-context-editor-current-context").click(function() { $JIPT("#crowdin-context-editor-context").val(Crowdin.self.editor.currentTranslation.context).focus() }) }, init_help_dialog: function() { if ($JIPT("#crowdin-help").length) { return this } $JIPT($JIPT("<div>").attr("id", "crowdin-help").attr("title", "Crowdin Help").css("display", "none").html('<iframe id="crowdin-help-container"></iframe>')).appendTo("body"); $JIPT("#crowdin-help").dialog({ autoOpen: false, height: 500, width: 700, zIndex: 16777271, dialogClass: "cjipt", resizable: true, modal: true }); return this }, get_context_editor_buttons: function() { var a = {}; a["Update context"] = function() { var c = $JIPT("#crowdin-context-editor-context").val(); Crowdin.self.editor.currentTranslation.context = c; var b = "<b>File:&nbsp;</b>" + Crowdin.self.editor.currentTranslation.file + "<br /><b>Context:</b><pre>" + c + "</pre>"; $JIPT(".crowdin-phrase-context").html(b); $JIPT.ajax({ url: Crowdin.self.entryPoint + "jipt/update_context?callback=?", dataType: "json", data: { id: Crowdin.self.editor.currentTranslation.id, project: Crowdin.self.get_project_identifier(), context: c }, success: function(d) { if (!d.success) { alert(d.msg) } else { $JIPT("#crowdin-context-editor").dialog("close"); Crowdin.self.loader.notify("Context has been updated...") } } }) }; a.Cancel = function() { $JIPT("#crowdin-context-editor").dialog("close") }; return a }, get_match_type_text: function(a) { switch (a) { default: case this.matchType.text: case this.matchType.textRegExp: case this.matchType.html: case this.matchType.htmlRegExp: case this.matchType.htmlOuter: return "Text on page"; case this.matchType.title: return "Element title" } }, init_translation_panel: function() { if (!$JIPT("#crowdin-translation-panel").length) { $JIPT($JIPT("<div>").attr("id", "crowdin-translation-panel").attr("title", "Crowdin JIPT").css("display", "none").html(this.get_translation_panel_markup())).prependTo("body"); $JIPT("#crowdin-translation-panel").dialog({ autoOpen: false, height: "auto", zIndex: 16777260, dialogClass: "cjipt", width: 500, height: 380, position: ["right", "bottom"] }); this.dialog_ui_minimization($JIPT("#crowdin-translation-panel")); this.dialog_ui_help($JIPT("#crowdin-translation-panel"), this.jiptCDN + "help/translations-panel.html"); this.bind_auto_search() } else { this.just_show_panel() } if (!this.user.is_logged_in) { this.init_login_panel() } else { this.init_translation_panel_phrases(); this.configure_translation_panel() } return this }, configure_translation_panel: function() { $JIPT("#jipt-options #jipt-show-actual-translations").get(0).checked = this.editor.showTranslations; $JIPT("#jipt-options #jipt-group-matches").get(0).checked = this.editor.mergeDuplicates; $JIPT("#jipt-options #jipt-marker").val(this.editor.marker); if (!this.editor.traversePage) { $JIPT("#jipt-options .inline-table").hide(); $JIPT("#jipt-preview-translations").hide(); $JIPT("#jipt-marker").parents("tr").remove() } }, init_translation_panel_phrases: function() { $JIPT(".crowdin-translation-panel-container").tabs(); $JIPT.ajax({ url: this.entryPoint + "jipt/project_languages?callback=?", dataType: "json", data: { project: this.get_project_identifier() }, success: function(c) { if (!Crowdin.self.check_auth(c)) { return } for (var a = 0; a < c.length; a++) { var b = $JIPT("<option>").attr("value", c[a].code).attr("text", c[a].name); if (c[a].code == Crowdin.self.language.code) { b.attr("selected", "selected") } b.appendTo("#jipt-languages") } $JIPT("#jipt-languages").val(Crowdin.self.language.code); Crowdin.self.reload_phrases() } }); $JIPT("#jipt-crowdin-project-page").click(function() { window.open(Crowdin.self.entryPoint + "project/" + Crowdin.self.project.name) }); $JIPT("#jipt-options #jipt-languages").change(function(a) { Crowdin.self.set_target_language($JIPT(a.target).val()); Crowdin.self.drop_element_translation_relations(document.body); Crowdin.self.reload_phrases() }); $JIPT("#jipt-options #jipt-marker").change(function(a) { Crowdin.self.set_marker($JIPT(a.target).val()); Crowdin.self.drop_element_translation_relations(document.body); Crowdin.self.reload_phrases() }); $JIPT("#jipt-options #jipt-group-matches").change(function(a) { var b = $JIPT("#jipt-options #jipt-group-matches").get(0).checked; Crowdin.self.set_merge_duplicates(b) }); $JIPT("#jipt-options #jipt-show-actual-translations").change(function(b) { var a = $JIPT("#jipt-options #jipt-show-actual-translations").get(0).checked; Crowdin.self.set_show_translations(a); Crowdin.self.previewTranslations = Crowdin.self.editor.showTranslations; if (a) { Crowdin.self.drop_element_translation_relations(document.body); Crowdin.self.reload_phrases() } else { window.location.reload() } }); $JIPT("#jipt-preview-translations").click(function() { Crowdin.self.preview_translations(); return false }); $JIPT("#jipt-logout").click(function() { Crowdin.self.logout() }); $JIPT(".jipt-phrases-to-translate li a").live("click", function(a) { Crowdin.self.editor.currentTranslation = Crowdin.self.phrases[$JIPT(this).attr("rel")]; Crowdin.self.editor.currentTranslations = []; Crowdin.self.editor.currentElement = null; Crowdin.self.editor.currentPhraseId = $JIPT(this).attr("rel"); Crowdin.self.show_editor(); a.stopPropagation(); return false }); autoSearchStartTimeout = null; $JIPT(".jipt-search-phrase").keyup(function() { clearTimeout(autoSearchStartTimeout); autoSearchStartTimeout = setTimeout('Crowdin.self.rebuild_panel_phrases($JIPT(".jipt-search-phrase").val());', 1000) }); $JIPT("#crowdin-translation-panel").dialog("option", "title", "Translating " + this.project.name) }, init_login_panel: function(a) { $JIPT.ajax({ url: this.entryPoint + "jipt/project_languages?callback=?", dataType: "json", data: { project: this.get_project_identifier() }, success: function(e) { if (e.jipt_error && e.code == 2) { return false } var b = null; if (Crowdin.cookies.has("crowdin_language_code" + Crowdin.self.get_project_identifier())) { b = Crowdin.cookies.get("crowdin_language_code" + Crowdin.self.get_project_identifier()) } else { b = e[0].code } for (var c = 0; c < e.length; c++) { var d = $JIPT("<option>").attr("value", e[c].code).attr("text", e[c].name); if (e[c].code == b) { d.attr("selected", "selected"); Crowdin.self.set_target_language(b) } d.appendTo("#crowdin-login-language-field") } } }); $JIPT("#crowdin-login-error-message").html(a); $JIPT("#crowdin-login-language-field").change(function(b) { Crowdin.self.set_target_language($JIPT(b.target).val()) }); $JIPT("#crowdin-login-field, #crowdin-password-field").keydown(function(b) { if (b.keyCode == 13) { Crowdin.self.login($JIPT("#crowdin-login-field").val(), $JIPT("#crowdin-password-field").val(), function(c) { if (c) { $JIPT("#crowdin-translation-panel").html(Crowdin.self.get_translation_panel_markup()); Crowdin.self.init_translation_panel().just_show_panel() } }); return false } }); $JIPT("#crowdin-jipt-join").click(function() { Crowdin.self.init_signup_panel(); return false }); $JIPT("#crowdin-jipt-login").click(function() { Crowdin.self.login($JIPT("#crowdin-login-field").val(), $JIPT("#crowdin-password-field").val(), function(b) { if (b) { $JIPT("#crowdin-translation-panel").html(Crowdin.self.get_translation_panel_markup()); Crowdin.self.init_translation_panel().just_show_panel() } }); return false }); $JIPT("#crowdin-translation-panel").dialog("option", "title", "Crowdin JIPT"); return this }, init_signup_panel: function() { $JIPT("#crowdin-translation-panel").html(this.get_signup_panel_markup()); $JIPT("#crowdin-jipt-back-to-login").click(function() { $JIPT("#crowdin-translation-panel").html(Crowdin.self.get_login_panel_markup()); Crowdin.self.init_login_panel(); return false }); $JIPT("#crowdin-jipt-signup-submit").click(function() { $JIPT.ajax({ url: Crowdin.self.entryPoint + "jipt/join?" + $JIPT("#crowdin-signup-form").serialize() + "&project=" + Crowdin.self.get_project_identifier() + "&callback=?", dataType: "json", success: function(a) { if (a.success) { $JIPT("#crowdin-translation-panel").html(Crowdin.self.get_login_panel_markup()); Crowdin.self.init_login_panel("Now you have translators account. Please select language and login to start translations") } else { $JIPT("#crowdin-join-error-message").html(a.msg); $JIPT("#crowdin-login-field").focus() } } }) }) }, login_success: function(a) { if (!this.check_auth(a)) { return } if (a.success) { this.user.is_logged_in = true; this.set_target_language(this.language.code); this.set_source_language(a.source_language); this.set_target_language_id(a.target_language_id); this.set_project_id(a.project_id); this.set_project_name(a.project_name); this.set_is_leader(a.is_leader) } else { this.user.is_logged_in = false; $JIPT("#crowdin-login-error-message").html(a.msg); $JIPT("#crowdin-login-field").focus() } }, init_google_jsapi: function() { if (!("google" in window)) { return } google.load("language", "1", { callback: function() { google.language.fixTranslation = function(c) { var b = crowdin.translation.data.text.match(/(\s*%[SsdnN]|\s*%\d|%[a-zA-Z]{1}[0-9]{1})/g); var a = 0; c = c.replace(/\&quot\;/g, '"'); c = c.replace(/&#[0-9]+;/, function(d) { return String.fromCharCode(parseInt(d.replace(/[&#]+/, ""))) }); return c.replace(/(%\s[SDN]|\s%\d|%[A-Z]{1}\s[0-9]{1})/g, function(e) { var d = e; if (b && b[a]) { d = b[a] } a++; return d }) } } }) }, bind_auto_search: function() { $JIPT("body").mouseup(function(a) { if (!$JIPT(a.target).parents("#crowdin-editor").length && !$JIPT(a.target).parents("#crowdin-translation-panel").length) { var b = false; if (window.getSelection) { b = window.getSelection() + "" } else { if (document.getSelection) { b = document.getSelection() + "" } else { if (document.selection) { b = document.selection.createRange().text + "" } } } if (b !== false && b.length > 2) { $JIPT(".jipt-search-phrase").val(b); Crowdin.self.rebuild_panel_phrases(b) } } }) }, reload_phrases: function() { this.loader.update("Initializing..."); this.overlay.create(); this.clear_markers($JIPT("body")); var b = { language_code: this.language.code, project: this.get_project_identifier() }; if (this.editor.files.length) { for (var a = 0; a < this.editor.files.length; a++) { b["file[" + a + "]"] = this.editor.files[a] } } if (this.editor.skipApproved) { b.skip_approved = true } $JIPT.ajax({ url: this.entryPoint + "jipt/phrases?callback=?", dataType: "json", data: b, success: function(c) { if (!Crowdin.self.check_auth(c)) { Crowdin.self.loader.hide(); Crowdin.self.overlay.destroy(); $JIPT("#crowdin-translation-panel").html(Crowdin.self.get_login_panel_markup()); Crowdin.self.init_login_panel().just_show_panel(); return } Crowdin.self.phrases = Crowdin.self.prepare_phrases_list(c); if (Crowdin.self.editor.traversePage) { Crowdin.self.proceed_phrases_with_html(document.body); Crowdin.self.each_element(document.body, Crowdin.self.phrases) } Crowdin.self.rebuild_panel_phrases(); Crowdin.self.overlay.destroy(); $JIPT("#crowdin-translation-panel").dialog("open"); if (Crowdin.self.is_first_run) { Crowdin.self.is_first_run = false; Crowdin.self.show_quick_start() } if (Crowdin.cookies.get("crowdin_is_tp_min" + Crowdin.self.get_project_identifier()) == "true") { $JIPT("#crowdin-translation-panel").parents(".cjipt").get(0).jipt_minimize() } document.addEventListener("DOMNodeInserted", function(e) { var d = e.target; if (d.nodeType == 3) { d = d.parentNode } if (d.matches) { return false } if ($JIPT(d).parents(".crowdin-tooltip").length || $JIPT(d).parents("#crowdin-load-indicator").length || $JIPT(d).parents(".cjipt").length) { return } if (Crowdin.self.editor.traversePage) { Crowdin.self.proceed_phrases_with_html(d); Crowdin.self.each_element(d, Crowdin.self.phrases) } }, false); document.addEventListener("DOMCharacterDataModified", function(e) { var d = e.target.parentElement; if ($JIPT(d).parents(".cjipt").length || $JIPT(d).parents('[id^="crowdin"]').length || (d.id && d.id.indexOf("crowdin") > -1) || (d.className && d.className.indexOf("crowdin") > -1)) { return } Crowdin.self.proceed_phrases_with_html(d); Crowdin.self.each_element(d, Crowdin.self.phrases) }, false) } }) }, proceed_phrases_with_html: function(d) { if (d.className && d.className.indexOf("cjipt") > 0 || d.className == "crowdin-translation-selection" || d.className == "crowdin-translation-badge" || d.className == "crowdin-tooltip") { return } if (d.nodeType != 1) { return } switch (d.nodeName.toLowerCase()) { case "script": case "head": return; break; case "body": break; break; default: var c, b, a; if (d.canonizedElementContent) { a = d.canonizedElementContent } else { a = this.canonize_html(d.innerHTML); d.canonizedElementContent = a } if (!a.length || a.length > 2000) { break } if (!$JIPT.browser.mozilla) { if (d.canonizedOuterElementContent) { b = d.canonizedOuterElementContent } else { b = this.canonize_html(d.outerHTML); d.canonizedOuterElementContent = b } } else { b = false } for (c = this.htmlPhrases.length; c--; ) { if (this.htmlPhrases[c].regexp) { if (a.match(this.htmlPhrases[c].regexp)) { this.handle_element(d, this.htmlPhrases[c].translation, this.matchType.htmlRegExp); continue } } if (a == this.htmlPhrases[c].canonized) { this.handle_element(d, this.htmlPhrases[c].translation, this.matchType.html) } if (b) { if (b == this.htmlPhrases[c].canonized) { this.handle_element(d, this.htmlPhrases[c].translation, this.matchType.htmlOuter) } } } break } if (d.hasChildNodes()) { for (c = d.childNodes.length; c--; ) { this.proceed_phrases_with_html(d.childNodes[c]) } } }, rebuild_panel_phrases: function(e) { $JIPT(".jipt-phrases-to-translate li").remove(); var d = 0; for (var c = 0; c < this.phrases.length; c++) { var a = this.phrases[c]; if (e && e.length > 3) { if (a.text.toLowerCase().indexOf(e.toLowerCase()) == -1) { continue } } else { if (c > 100) { $JIPT(".jipt-phrases-to-translate").append($JIPT("<li>").addClass("crowdin-comment-in-phrases").append("Only 100 phrases shown. " + this.phrases.length + " total")); break } } var b = $JIPT("<a>").attr("href", "#").attr("rel", c).html(a.text); this.get_translation_context_hint(a, b); if (a.suggestions_count > 0) { if (a.approved) { b.addClass("crowdin-approved-item") } else { b.addClass("crowdin-translated-item") } } else { b.addClass("crowdin-untranslated-item") } $JIPT(".jipt-phrases-to-translate").append($JIPT("<li>").append(b)); d++ } if (d == 0) { $JIPT(".jipt-phrases-to-translate").append($JIPT("<li>").addClass("crowdin-phrases-stub").html("Nothing's found")) } $JIPT(".jipt-phrases-to-translate").find("[title]").tooltip(); this.loader.hide() }, place_translation_preview: function(b) { if (this.editor.currentElement != null) { if (this.editor.currentTranslation.elements.length > 1) { for (var a = this.editor.currentTranslation.elements.length; a--; ) { this.force_translation_preview(this.editor.currentTranslation.elements[a], b, this.editor.currentTranslation) } } else { this.force_translation_preview(this.editor.currentElement, b, this.editor.currentTranslation) } } }, get_first_text_child: function(c) { var a = false; for (var b = 0; b < c.childNodes.length; b++) { if (c.childNodes[b].nodeType == 3) { if (a == false) { a = c.childNodes[b] } else { this.replace_text_node_with_span(c.childNodes[b]) } } } return a }, replace_text_node_with_span: function(c) { if (this.fuzzy_trim(c.nodeValue).length < 2) { return } var b = c.parentNode; var a = document.createElement("span"); a.className = "crowdin-jipt-innerspan-reset"; a.innerHTML = c.nodeValue; b.insertBefore(a, c); b.removeChild(c) }, fill_translation_placeholders: function(f, a, b) { if (a.textRegexp) { var i = f; var h = b.match(a.textRegexp); if (!h) { return f } var c, g = null; for (var e = 0; e < this.placeholders.length; e++) { c = new RegExp(this.placeholders[e].template, "g"); g = i.match(c); if (g) { i = i.replace(c, "--crowdin-jipt-replacements--") } } if (this.editor.customPlaceholders && this.editor.customPlaceholders.length) { for (e = 0; e < this.editor.customPlaceholders.length; e++) { c = new RegExp(this.editor.customPlaceholders, "g"); g = i.match(c); if (g) { i = i.replace(c, "--crowdin-jipt-replacements--") } } } var d = 1; while (i.indexOf("--crowdin-jipt-replacements--") > -1) { if (h[d]) { i = i.replace("--crowdin-jipt-replacements--", h[d]) } else { break } d++ } i = i.replace(/--crowdin-jipt-replacements--/g, "-extra placeholder-"); return i } else { return f } }, force_translation_preview: function(b, d, e) { switch (b.lastMatchType) { case this.matchType.title: d = this.fill_translation_placeholders(d, e, this.fuzzy_trim(b.originalTitle)); b.title = d; break; case this.matchType.html: case this.matchType.htmlRegExp: d = this.fill_translation_placeholders(d, e, this.canonize_html(b.originalInnerHTML)); $JIPT(b).html(d); break; case this.matchType.htmlOuter: d = this.fill_translation_placeholders(d, e, this.canonize_html(b.originalOuterHTML)); var c = $JIPT(d); $JIPT(b).replaceWith(c); this.handle_element(c, this.editor.currentTranslation, b.lastMatchType); break; case this.matchType.textRegExp: case this.matchType.text: default: var a = this.get_first_text_child(b); if (a != false) { d = this.fill_translation_placeholders(d, e, this.fuzzy_trim(b.originalFirstNodeValue)); a.nodeValue = d } else { if (b.nodeName == "INPUT") { d = this.fill_translation_placeholders(d, e, this.fuzzy_trim(b.originalInputValue)); $JIPT(b).val(d) } if (b.nodeName == "IMG") { d = this.fill_translation_placeholders(d, e, this.fuzzy_trim(b.originalAlt)); b.alt = d } } break } }, each_element: function(b, c) { var a = []; this.build_elements_queue(a, b, c); if (a.length) { this.loader.show(); this.process_elements_queue(a, c) } }, build_elements_queue: function(a, d, e) { if (d.className && d.className.indexOf("cjipt") > 0 || d.className == "crowdin-translation-selection" || d.className == "crowdin-translation-badge" || d.className == "crowdin-tooltip") { return } if (d.nodeName == "HEAD" || d.nodeName == "SCRIPT" || d.nodeType == 4 || d.nodeType == 8) { return } if (d.nodeName == "IMG" && d.alt && d.alt.length) { if (!d.originalAlt) { d.originalAlt = d.alt } a.push({ handler: this.match_element_text, text: d.alt, element: d }) } if (d.title && d.title.length) { if (!d.originalTitle) { d.originalTitle = d.title } a.push({ handler: this.match_element_title, text: d.title, element: d }) } if (d.nodeName == "INPUT") { if (!d.originalInputValue) { d.originalInputValue = d.value } a.push({ handler: this.match_element_text, text: d.value, element: d }); return } if (d.hasChildNodes()) { var c = this.get_first_text_child(d); if (c != false) { if (c.nodeValue.length) { if (!d.originalFirstNodeValue) { d.originalFirstNodeValue = c.nodeValue } a.push({ handler: this.match_element_text, text: c.nodeValue, element: d }) } } for (var b = 0; b < d.childNodes.length; b++) { this.build_elements_queue(a, d.childNodes[b], e) } } }, process_elements_queue: function(b, c) { var a = 0; var d; var e = function() { d = Math.round((a * 100) / b.length); if (d % 5 == 1) { Crowdin.self.loader.update("Progress: " + d + "%") } if (a == b.length) { Crowdin.self.loader.hide(); return } for (var f = 0; f < c.length; f++) { b[a].handler.call(Crowdin.self, b[a].text, b[a].element, c[f]) } a++; setTimeout(e, 0) }; e(b) }, prepare_phrases_list: function(d) { this.htmlPhrases = []; var a = false; var c = false; for (var b = 0; b < d.length; b++) { d[b].textCleared = this.fuzzy_trim(d[b].text); d[b].fuzzyTrimmed = this.fuzzy_trimmed(d[b].text); if (d[b].html) { c = this.canonize_html(d[b].html); try { a = this.phrase_to_regexp(c) } catch (f) { a = false } this.htmlPhrases.push({ translation: d[b], canonized: c, regexp: a }) } try { d[b].textRegexp = this.phrase_to_regexp(d[b].textCleared); this.htmlPhrases.push({ translation: d[b], canonized: d[b].textCleared, regexp: d[b].textRegexp }) } catch (f) { d[b].textRegexp = false } } return d }, canonize_html: function(a) { var b = { nbsp: 160, copy: 169, iexcl: 161, cent: 162, pound: 163, euro: 8364, curren: 164, yen: 165, brvbar: 166, not: 172, shy: 173, reg: 174, deg: 176, plusmn: 177, sup2: 178, sup3: 179, macr: 175, acute: 180, micro: 181, sect: 167, uml: 168, ordf: 170, para: 182, laquo: 171, middot: 183, cedil: 184, sup1: 185, ordm: 186, raquo: 187, iquest: 191, Agrave: 192, Aacute: 193, Acirc: 194, Atilde: 195, Auml: 196, Aring: 197, AElig: 198, Ccedil: 199, Ecirc: 202, Euml: 203, Egrave: 200, Eacute: 201, frac14: 188, frac12: 189, frac34: 190, Igrave: 204, Iacute: 205, Icirc: 206, Iuml: 207, ETH: 208, Ntilde: 209, Ograve: 210, Oacute: 211, Ocirc: 212, Otilde: 213, Ouml: 214, times: 215, Uuml: 220, Oslash: 216, Ugrave: 217, Uacute: 218, Ucirc: 219, Yacute: 221, THORN: 222, szlig: 223, agrave: 224, aacute: 225, acirc: 226, atilde: 227, auml: 228, aring: 229, aelig: 230, ccedil: 231, egrave: 232, eacute: 233, ecirc: 234, euml: 235, igrave: 236, iacute: 237, icirc: 238, eth: 240, ocirc: 244, otilde: 245, ntilde: 241, ograve: 242, oacute: 243, iuml: 239, ouml: 246, divide: 247, oslash: 248, ugrave: 249, uacute: 250, ucirc: 251, uuml: 252, yacute: 253, thorn: 254, yuml: 255, quot: 34, amp: 38, lt: 60, gt: 62, Scaron: 352, scaron: 353, Yuml: 376, circ: 710, tilde: 732, zwnj: 8204, zwj: 8205, ensp: 8194, emsp: 8195, thinsp: 8201, lrm: 8206, rlm: 8207, dagger: 8224, Dagger: 8225, ndash: 8211, mdash: 8212, lsquo: 8216, rsquo: 8217, sbquo: 8218, ldquo: 8220, rdquo: 8221, bdquo: 8222, permil: 8240, OElig: 338, oelig: 339, lsaquo: 8249, rsaquo: 8250 }; var c = a.replace(/<\s*br\s*\/?>/g, "").replace(/<\s*hr\s*\/?>/g, "").replace(/\\t/g, "").replace(/\\n/g, "").replace(/\n/g, "").replace(/\t/g, "").replace(/^\n+/m, "").replace(/ {2,}/g, " ").replace(/&([^;]+);/g, function(e, f) { var d; if (f.substr(0, 1) == "#") { if (f.substr(1, 1) == "x") { d = parseInt(f.substr(2), 16) } else { d = parseInt(f.substr(1), 10) } } else { d = b[f] } return (d === NaN || d === undefined) ? "&" + f + ";" : String.fromCharCode(d) }); return this.fuzzy_trim(c) }, phrase_to_regexp: function(l) { var b = l.replace(/([\?()\[\]\|\.\+]+)/g, "\\$1"); var c = 0; var m = 0; if (this.editor.customPlaceholders && this.editor.customPlaceholders.length) { var g, n = null; for (var f = this.editor.customPlaceholders.length; f--; ) { g = new RegExp(this.editor.customPlaceholders[f], "g"); n = b.match(g); if (n) { b = b.replace(g, "(.*)"); c += n.length; m += this.editor.customPlaceholders[f].length } } } var a, h = null; for (var e = 0; e < this.placeholders.length; e++) { a = new RegExp(this.placeholders[e].template, "g"); h = b.match(a); if (h) { b = b.replace(a, this.placeholders[e].replacement); c += h.length; for (var d = h.length; d--; ) { m += h[d].length } } } if (c == 0 || (c * m) > (b.length - 3)) { throw "Phrase do not contain placeholders" } b = "^" + b + "$"; return new RegExp(b) }, match_element_text: function(e, c, f) { if (!f.textCleared.length || !e.length || f.html) { return false } if (!c.docFuzzyPhrase) { c.docFuzzyPhrase = this.fuzzy_trim(e); c.docTrimmedCharacters = this.fuzzy_trimmed(e) } if (!c.docFuzzyPhrase.length) { return false } var a = f.fuzzyTrimmed; if (a.l.length > c.docTrimmedCharacters.l.length) { return false } if (a.r.length > c.docTrimmedCharacters.r.length) { return false } if (f.textRegexp) { var b = f.textRegexp; var d = c.docFuzzyPhrase; if (d.match(b)) { this.handle_element(c, f, this.matchType.textRegExp) } } else { this.exect_match(c, f) } }, exect_match: function(a, c) { var b = a.docFuzzyPhrase; if (b == c.textCleared) { this.handle_element(a, c, this.matchType.text) } }, match_element_title: function(d, c, e) { if (!e.textCleared.length || !d.length || e.html) { return false } if (!c.docFuzzyTitle) { c.docFuzzyTitle = this.fuzzy_trim(d) } if (!c.docFuzzyTitle.length) { return false } var b = c.docFuzzyTitle; if (e.textRegexp) { var a = e.textRegexp; if (b.match(a)) { this.handle_element(c, e, this.matchType.title) } } else { if (b == e.textCleared) { this.handle_element(c, e, this.matchType.title) } } }, handle_element: function(b, d, c) { if (!b.matches) { b.matches = [] } if (!b.titleMatches) { b.titleMatches = [] } if (!b.originalContent) { b.originalInnerHTML = b.innerHTML } if (!d.elements) { d.elements = [] } for (var a = b.matches.length; a--; ) { if (b.matches[a].translation.id == d.id) { return } } if (c == this.matchType.title) { b.titleMatches.push({ translation: d, matchType: c }) } else { b.matches.push({ translation: d, matchType: c }) } d.elements.push(b); b.lastMatchType = c; if (!this.previewTranslations) { if (d.suggestions_count > 0) { if (d.approved) { $JIPT(b).addClass("crowdin-jipt-approved-" + this.editor.marker) } else { $JIPT(b).addClass("crowdin-jipt-translated-" + this.editor.marker) } } else { $JIPT(b).addClass("crowdin-jipt-untranslated-" + this.editor.marker) } if (b.matches.length > 1) { $JIPT(b).addClass("crowdin-jipt-has-many-" + this.editor.marker) } } else { if (d.suggestions_count > 0) { this.force_translation_preview(b, d.html ? this.unhtmlspecialchars(d.translation) : d.translation, d) } } $JIPT(b).mouseenter(function() { Crowdin.self.show_translation_badge(b) }) }, drop_element_translation_relations: function(c) { for (var a = this.phrases.length; a--; ) { this.phrases[a].elements = [] } c.matches = null; c.titleMatches = null; if (c.hasChildNodes()) { for (var b = 0; b < c.childNodes.length; b++) { this.drop_element_translation_relations(c.childNodes[b]) } } }, get_element_position: function(a) { var d = 0; var b = 0; var c = a; if (c.offsetParent) { do { d += c.offsetLeft; b += c.offsetTop } while (c = c.offsetParent) } c = a; do { if (c.nodeName == "BODY") { break } if (c.scrollTop > 0) { b -= c.scrollTop } if (c.scrollLeft > 0) { b -= c.scrollLeft } } while (c = c.parentNode); return { left: d, top: b} }, get_translation_context_hint: function(c, b) { var a = "<b>File:</b> " + c.file + "\r\n<b>Translation:</b> " + (c.translation.length > 0 ? c.translation : "-") + "\r\n<b>Is Approved:</b> " + (c.approved ? "Yes" : "No") + "\r\n<b>Context:</b> \r\n" + c.context; if (b) { $JIPT(b).attr("title", a) } else { return a } }, show_translation_badge: function(d) { this.hide_translation_badge(); var e = this.get_element_position(d); var b = d.titleMatches.length, f = d.matches.length; if (d.nodeName == "OPTION") { e.left -= 16 } if (f) { var c = $JIPT("<img>").attr("src", this.jiptCDN + "/images/translate.png").attr("title", "Translate text").css("position", "absolute").css("top", e.top + "px").css("left", e.left + "px").css("z-index", 16777271).addClass("crowdin-translation-badge").click(function(g) { if (d.matches.length == 1) { Crowdin.self.editor.currentTranslation = d.matches[0].translation; Crowdin.self.editor.currentTranslations = []; Crowdin.self.editor.currentElement = d; Crowdin.self.editor.currentElement.lastMatchType = d.matches[0].matchType; Crowdin.self.editor.currentPhraseId = null; Crowdin.self.show_editor() } else { Crowdin.self.show_translation_select(d, c, Crowdin.self.matchType.any) } g.stopPropagation(); return false }); if (d.nodeName == "IMG") { c.attr("src", this.jiptCDN + "/images/image.png").attr("title", "Translate image ALT attribute") } $JIPT("body").append(c) } if (b) { var a = $JIPT("<img>").attr("src", this.jiptCDN + "/images/title.png").attr("title", "Translate element title").css("position", "absolute").css("top", e.top + "px").css("left", (e.left + (f > 0 ? 18 : 0)) + "px").css("z-index", 16777271).addClass("crowdin-translation-badge").click(function(g) { if (d.titleMatches.length == 1) { Crowdin.self.editor.currentTranslation = d.titleMatches[0].translation; Crowdin.self.editor.currentTranslations = []; Crowdin.self.editor.currentElement = d; Crowdin.self.editor.currentElement.lastMatchType = Crowdin.self.matchType.title; Crowdin.self.editor.currentPhraseId = null; Crowdin.self.show_editor() } else { Crowdin.self.show_translation_select(d, a, Crowdin.self.matchType.title) } g.stopPropagation(); return false }); $JIPT("body").append(a) } a.mouseout(function() { Crowdin.self.hide_translation_badge() }) }, show_translation_select: function(f, k, j) { var b = this.get_element_position(k.get(0)); var h = []; var c = []; switch (j) { case this.matchType.any: h = f.matches; break; case this.matchType.title: h = f.titleMatches; break } c = h; if (this.editor.mergeDuplicates) { h = this.group_similar_phrases(h) } var l = $JIPT("<ul>").addClass("crowdin-translation-selection").css("top", (b.top + 16) + "px").css("left", b.left + "px").hide(); $JIPT("<li>").html("Current text may reffer to one of following source phrases").addClass("crowdin-translation-selection-header").appendTo(l); var a; var d = true; var g = h[0].translation.text; for (var e = 0; e < h.length; e++) { a = $JIPT("<a>").attr("href", "#").html(h[e].translation.text); if (this.editor.mergeDuplicates && h[e].grouped && h[e].groupMatches.length > 1) { a.attr("title", "This is a group of " + h[e].groupMatches.length + " similar strings."); if (h[e].allElementsApproved) { a.addClass("crowdin-translations-group-approved"); a.attr("title", a.attr("title") + " All Elements are approved.") } else { if (h[e].allElementsTranslated) { a.addClass("crowdin-translations-group-translated"); a.attr("title", a.attr("title") + " All elements are translated.") } else { a.addClass("crowdin-translations-group") } } this.events_for_translation_variants_group(f, a, h[e].groupMatches) } else { a.attr("title", this.get_translation_context_hint(h[e].translation)); if (h[e].translation.suggestions_count > 0) { if (h[e].translation.approved) { a.addClass("crowdin-approved-item") } else { a.addClass("crowdin-translated-item") } } else { a.addClass("crowdin-untranslated-item") } this.events_for_translation_variant(f, a, h[e].translation, h[e].matchType) } $JIPT("<li>").append(a).appendTo(l); if (h[e].translation.text != g) { d = false } else { g = h[e].translation.text } } if (d) { if (this.editor.mergeDuplicates) { this.translate_all_similar_texts(f, c); return false } $JIPT("<li>").html('<a href="#" class="crowdin-jipt-translate-all-action" title="Suggest translation for all phrases (be careful)">Translate duplicates</a>').click(function(i) { Crowdin.self.translate_all_similar_texts(f, c); i.stopPropagation(); return false }).appendTo(l) } l.show(); $JIPT("body").append(l); l.find("[title]").tooltip(); l.slideDown("fast"); l.mouseleave(function() { Crowdin.self.hide_translation_picker() }) }, group_similar_phrases: function(c) { var a = [], b = false; continue_grouping: for (var e = 0, f = c.length; e < f; e++) { for (var d = e + 1; d < f; d++) { if (c[e].translation.text == c[d].translation.text) { continue continue_grouping } } b = c[e]; b.grouped = true; b.groupMatches = []; b.allElementsTranslated = true; b.allElementsApproved = true; a.push(b) } for (e = c.length; e--; ) { for (d = a.length; d--; ) { if (a[d].translation.text == c[e].translation.text) { a[d].groupMatches.push(c[e]); break } } } for (e = a.length; e--; ) { for (d = a[e].groupMatches.length; d--; ) { if (!a[e].groupMatches[d].translation.approved) { a[e].allElementsApproved = false } if (!a[e].groupMatches[d].translation.translation) { a[e].allElementsTranslated = false } } } return a }, events_for_translation_variant: function(b, a, d, c) { a.click(function(f) { b.lastMatchType = c; Crowdin.self.editor.currentTranslation = d; Crowdin.self.editor.currentTranslations = []; Crowdin.self.editor.currentElement = b; Crowdin.self.editor.currentPhraseId = null; Crowdin.self.show_editor(); f.stopPropagation(); return false }) }, events_for_translation_variants_group: function(b, a, c) { a.click(function(d) { Crowdin.self.translate_all_similar_texts(b, c); d.stopPropagation(); return false }) }, translate_all_similar_texts: function(b, a) { Crowdin.self.editor.currentTranslation = a[0].translation; Crowdin.self.editor.currentTranslations = a; Crowdin.self.editor.currentElement = b; Crowdin.self.editor.currentPhraseId = null; Crowdin.self.show_editor(); return false }, hightlight_active_elements: function(b) { $JIPT(".crowdin-active-element").removeClass("crowdin-active-element"); if (!b || !b.length) { return } for (var a = b.length; a--; ) { $JIPT(b[a]).addClass("crowdin-active-element") } }, show_editor: function() { if (!this.user.is_logged_in) { alert("Login first to be able to submit translations"); this.start_translation(); return } this.hightlight_active_elements(this.editor.currentTranslation.elements); $JIPT("#crowdin-editor").dialog("option", "buttons", this._get_editor_buttons()); $JIPT("#crowdin-editor-matches-count, #crowdin-editor-duplicates-count").hide(); if (this.editor.currentTranslation.elements && this.editor.currentTranslation.elements.length > 1) { $JIPT("#crowdin-editor-matches-count").show().html(this.editor.currentTranslation.elements.length + " same texts on this page") } if (this.editor.currentTranslations && this.editor.currentTranslations.length > 1) { $JIPT("#crowdin-editor-duplicates-count").show().html(this.editor.currentTranslations.length + " duplicates of this phrase") } if (!this.editor.currentTranslations.length) { $JIPT(".crowdin-original-phrase").html(this.editor.currentTranslation.text).attr("title", this.get_translation_context_hint(this.editor.currentTranslation)); $JIPT("#crowdin-show-hide-context").show(); $JIPT(".crowdin-phrase-context").html("<b>File:&nbsp;</b>" + this.editor.currentTranslation.file + "<br /><b>Context:</b><pre>" + this.editor.currentTranslation.context + "</pre>"); $JIPT(".crowdin-original-phrase").tooltip(); $JIPT(".crowdin-editor-translation").val(this.unhtmlspecialchars(this.editor.currentTranslation.translation)).focus() } else { $JIPT(".crowdin-original-phrase").html("").removeAttr("title"); var b = null, a = null, e = true, c = this.editor.currentTranslations[0].translation.translation; for (var d = 0; d < this.editor.currentTranslations.length; d++) { if (c != this.editor.currentTranslations[d].translation.translation) { e = false } else { c = this.editor.currentTranslations[d].translation.translation } a = this.editor.currentTranslations[d].translation; b = $JIPT("<a>").attr("href", "#").attr("rel", d).html(""); this._bind_translation_variant_click(b, a); if (a.suggestions_count > 0) { if (a.approved) { b.addClass("crowdin-approved-item") } else { b.addClass("crowdin-translated-item") } } else { b.addClass("crowdin-untranslated-item") } $JIPT(".crowdin-original-phrase").append($JIPT("<div></div>").addClass("crowdin-jipt-multiple-translations").attr("title", this.get_translation_context_hint(a)).append(b).append($JIPT("<span></span>").html(this.htmlspecialchars(a.html ? a.html : a.text)))) } $JIPT("#crowdin-show-hide-context, #crowdin-context-header, .crowdin-phrase-context").hide(); $JIPT(".crowdin-original-phrase").find("[title]").tooltip(); if (e) { $JIPT(".crowdin-editor-translation").val(this.unhtmlspecialchars(c)).focus() } else { $JIPT(".crowdin-editor-translation").val("").focus() } } if (this.user.is_leader) { $JIPT("#crowdin-edit-context").show() } else { $JIPT("#crowdin-edit-context").hide() } this.get_suggestions(this.editor.currentTranslation); $JIPT("#crowdin-editor").dialog("open"); this.fix_dialogs() }, _bind_translation_variant_click: function(a, b) { a.click(function() { Crowdin.self.editor.currentTranslation = b; Crowdin.self.editor.currentTranslations = []; Crowdin.self.show_editor(); return false }) }, hide_translation_badge: function() { $JIPT(".crowdin-translation-badge").remove() }, hide_translation_picker: function() { $JIPT(".crowdin-translation-selection").remove() }, suggest: function(b, a) { $JIPT.ajax({ url: this.entryPoint + "jipt/suggest?callback=?", dataType: "json", data: { id: b.id, text: a, plural_num: -1, language_code: this.language.code, project: this.get_project_identifier() }, success: function(c) { if (!Crowdin.self.check_auth(c)) { return } if (c.error) { alert(c.message) } else { Crowdin.self.loader.notify("Translation has been saved...") } } }) }, get_suggestion_actions: function(a) { var b = $JIPT("<div>").addClass("crowdin-suggestion-actions"); b.append('Rating: <span style="padding-right: 5px;" id="jipt-suggestion-rating-' + a.id + '">' + a.rating + "</span>"); if (a.approve_able) { b.append($JIPT("<button>").text("Approve").click(function() { Crowdin.self.approve_suggestion(a); return false })) } if (a.delete_able) { b.append($JIPT("<button>").text("Delete").click(function() { if (window.confirm("Are you sure you want to delete this suggestion?")) { Crowdin.self.delete_suggestion(a) } return false })) } if (a.vote_able) { b.append($JIPT("<button>").text('Vote "+"').click(function() { Crowdin.self.vote_suggestion(a, "plus"); return false })); b.append($JIPT("<button>").text('Vote "-"').click(function() { Crowdin.self.vote_suggestion(a, "minus"); return false })) } return b }, approve_suggestion: function(a) { $JIPT.ajax({ url: this.entryPoint + "jipt/approve?callback=?", dataType: "json", data: { id: a.id, language_code: this.language.code, project: this.get_project_identifier() }, success: function(b) { if (!Crowdin.self.check_auth(b)) { return } if (!b.success) { alert(b.msg) } else { $JIPT("#crowdin-editor").dialog("close"); Crowdin.self.loader.notify("Suggestion has been approved..."); Crowdin.self.trigger_suggestion_approved() } } }) }, delete_suggestion: function(a) { $JIPT.ajax({ url: this.entryPoint + "jipt/delete?callback=?", dataType: "json", data: { id: a.id, language_code: this.language.code, project: this.get_project_identifier() }, success: function(b) { if (!Crowdin.self.check_auth(b)) { return } if (!b.success) { alert(b.msg) } else { Crowdin.self.get_suggestions(Crowdin.self.editor.currentTranslation) } } }) }, vote_suggestion: function(a, b) { $JIPT.ajax({ url: this.entryPoint + "jipt/vote?callback=?", dataType: "json", data: { id: a.id, language_code: this.language.code, project: this.get_project_identifier(), mark: b }, success: function(c) { if (!Crowdin.self.check_auth(c)) { return } if (!c.success) { alert(c.msg) } else { $JIPT("#jipt-suggestion-rating-" + a.id).text(c.rating) } } }) }, bind_suggestion_item_click: function(b, a) { b.click(function() { $JIPT(".crowdin-editor-translation").val(Crowdin.self.unhtmlspecialchars(a.text)).focus(); Crowdin.self.place_translation_preview(a.text); return false }) }, get_suggestions: function(b) { if (!this.user.is_logged_in) { return } this.suggestions.google = []; this.suggestions.tm = []; this.suggestions.microsoft = []; $JIPT(".crowdin-user-suggestions").children("li").remove(); if (this.editor.currentTranslations.length) { $JIPT(".crowdin-user-suggestions").append($JIPT("<li>").addClass("crowdin-suggestions-message").html("User suggestions not available when multiple phrases selected")) } else { $JIPT(".crowdin-user-suggestions").append($JIPT("<li>").addClass("crowdin-suggestions-message").html("Loading...")); $JIPT.ajax({ url: this.entryPoint + "jipt/suggestions?callback=?", dataType: "json", data: { id: b.id, language_code: this.language.code, plural_num: -1, project: this.get_project_identifier() }, success: function(e) { if (!Crowdin.self.check_auth(e)) { return } $JIPT(".crowdin-user-suggestions").children("li").remove(); var c = null; for (var d = 0; d < e.length; d++) { c = $JIPT("<a>").attr("href", "#").html(Crowdin.self.htmlspecialchars(e[d].text)); Crowdin.self.bind_suggestion_item_click(c, e[d]); $JIPT(".crowdin-user-suggestions").append($JIPT("<li>").addClass("crowdin-single-user-suggestion").append(c).append(Crowdin.self.get_suggestion_actions(e[d]))) } if (e.length == 0) { $JIPT(".crowdin-user-suggestions").append($JIPT("<li>").addClass("crowdin-suggestions-message").html("No any translations yet")) } } }) } $JIPT(".crowdin-tm-mt-suggestions").children("li").remove(); $JIPT(".crowdin-tm-mt-suggestions").append($JIPT("<li>").html("Loading...")); $JIPT.ajax({ url: this.entryPoint + "tm_suggestions?callback=?", dataType: "json", data: { source_language: this.source_language.code, target_language: this.language.code, target_language_id: this.language.id, text: b.text, translation_id: b.id, project_id: this.project.id }, success: function(c) { if (!Crowdin.self.check_auth(c)) { return } c = c.data.data; if (!c) { Crowdin.self.suggestions.tm = [] } else { Crowdin.self.suggestions.tm = c } Crowdin.self.render_suggestions() } }); try { google.language.translate(b.html ? b.html : b.text, Crowdin.self.source_language.code, Crowdin.self.language.code, function(c) { Crowdin.self.suggestions.google.translation = c.translation; Crowdin.self.render_suggestions() }) } catch (a) { } try { Microsoft.Translator.Translate(b.text, Crowdin.self.source_language.code, Crowdin.self.language.code, function(c) { Crowdin.self.suggestions.microsoft.translation = c; Crowdin.self.render_suggestions() }) } catch (a) { } }, render_suggestions: function() { $JIPT(".crowdin-tm-mt-suggestions").children("li").remove(); var a = null; for (var b = 0; b < this.suggestions.tm.length; b++) { a = $JIPT("<li>").addClass("crowdin-crowdin-suggestion").append($JIPT("<a>").attr("href", "#").html(this.suggestions.tm[b].translation)); this.bind_user_suggestion_click(a, this.suggestions.tm[b].translation); $JIPT(".crowdin-tm-mt-suggestions").append(a) } if (this.suggestions.google.translation) { $JIPT(".crowdin-tm-mt-suggestions").append($JIPT("<li>").addClass("crowdin-google-suggestion").append($JIPT("<a>").attr("href", "#").html(this.htmlspecialchars(this.suggestions.google.translation))).click(function() { $JIPT(".crowdin-editor-translation").val(Crowdin.self.unhtmlspecialchars(Crowdin.self.suggestions.google.translation)).focus(); Crowdin.self.place_translation_preview(Crowdin.self.suggestions.google.translation); return false })) } if (this.suggestions.microsoft.translation) { $JIPT(".crowdin-tm-mt-suggestions").append($JIPT("<li>").addClass("crowdin-microsoft-suggestion").append($JIPT("<a>").attr("href", "#").html(this.suggestions.microsoft.translation)).click(function() { $JIPT(".crowdin-editor-translation").val(Crowdin.self.unhtmlspecialchars(Crowdin.self.suggestions.microsoft.translation)).focus(); Crowdin.self.place_translation_preview(Crowdin.self.suggestions.microsoft.translation); return false })) } }, bind_user_suggestion_click: function(b, a) { b.click(function() { $JIPT(".crowdin-editor-translation").val(a).focus(); Crowdin.self.place_translation_preview(a); return false }) }, get_editor_markup: function() { return '<div class="crowdin-editor-container"><div class="crowdin-editor-hint"><table style="width: 100%;"><tr><td style="text-align: left;">Source Text<span id="crowdin-editor-matches-count"></span><span id="crowdin-editor-duplicates-count"></span></td><td class="crowdin-editor-actions"><button id="crowdin-copy-source" type="button" class="ui-state-default ui-button" style="padding: 3px 5px;">Copy Source</button><button id="crowdin-show-hide-context" type="button" class="ui-state-default ui-button ui-button-text" style="padding: 3px 5px;">Show/Hide Context</button></td></tr></table></div><div class="crowdin-original-phrase"></div><div class="crowdin-context"></div><div class="crowdin-editor-hint">Enter translation below</div><textarea class="crowdin-editor-translation"></textarea><div id="crowdin-context-header" class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" style="margin-top: 5px; cursor: pointer; display: none;"><span style="float: right;"><button type="button" class="ui-state-default ui-button" style="padding: 3px 5px;" id="crowdin-edit-context">Edit</button></span><span class="ui-dialog-title" style="clear: left;">Context</span></div><div class="crowdin-phrase-context" style="display: none;"></div><div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" style="margin-top: 5px; cursor: pointer;"><span class="ui-dialog-title">Users Suggestions</span></div><div class="crowdin-suggestions"><ul class="crowdin-user-suggestions"><li>Loading...</li></ul></div><div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" style="margin-top: 10px; cursor: pointer;"><span class="ui-dialog-title" id="ui-dialog-title-crowdin-editor">TM & MT Suggestions</span></div><div class="crowdin-suggestions"><ul class="crowdin-tm-mt-suggestions"><li>Loading...</li></ul></div></div>' }, get_context_editor_markup: function() { return '<form><label for="crowdin-context-editor-context">Type your comment for current phrase in the field below</label><textarea name="context" id="crowdin-context-editor-context" class="text ui-widget-content ui-corner-all"></textarea><label>Current context</label><dd id="crowdin-context-editor-current-context" title="Click to use it"></dd><div style="margin: 15px 0pt 10px 5px; color: #555;"><p><b>Note: </b>Your comment will be visible for translators into other languages</p></div></form>' }, get_signup_panel_markup: function() { return '<div class="crowdin-login-panel"><form id="crowdin-signup-form"><table><tr><td colspan="2" style="text-align: center;"><a href="' + this.entryPoint + '" target="_blank" title="Collaborative Translation Tool"><img src="' + this.entryPoint + 'images/logo.png" alt="Crowdin - Collaborative Localization Tool"></a></td></tr><tr><td><label for="crowdin-login-field">Login: <span class="crowdin-jipt-required">&nbsp;*</span></label></td><td><input type="text" value="" id="crowdin-login-field" name="login"></td></tr><tr><td><label for="crowdin-login-field">Email: <span class="crowdin-jipt-required">&nbsp;*</span></label></td><td><input type="text" value="" id="crowdin-login-field" name="email"></td></tr><tr><td><label for="crowdin-password-field">Password: <span class="crowdin-jipt-required">&nbsp;*</span></label></td><td><input type="password" value="" id="crowdin-password-field" name="password"></td></tr><tr><td><label for="crowdin-password-confirm-field">Confirm Password: <span class="crowdin-jipt-required">&nbsp;*</span></label></td><td><input type="password" value="" id="crowdin-password-confirm-field" name="confirm-password"></td></tr><tr><td id="crowdin-join-error-message" colspan="2"></td></tr><tr><td colspan="2" style="text-align: center;"><a href="#" id="crowdin-jipt-back-to-login">Back to login</a>&nbsp;&nbsp;&nbsp;<input type="button" value="Sign Up" id="crowdin-jipt-signup-submit" /></td></tr></table></form></div>' }, set_project_identifier: function(a) { this.project.identifier = a }, set_target_language: function(a) { this.language.code = a; Crowdin.cookies.set("crowdin_language_code" + this.get_project_identifier(), a) }, set_marker: function(a) { this.editor.marker = a; Crowdin.cookies.set("crowdin_marker" + this.get_project_identifier(), a) }, set_target_language_id: function(a) { this.language.id = a; Crowdin.cookies.set("crowdin_language_id" + this.get_project_identifier(), a) }, set_project_id: function(a) { this.project.id = a; Crowdin.cookies.set("crowdin_project_id" + this.get_project_identifier(), a) }, mark_translatable_phrases: function(a) { this.editor.traversePage = a }, set_project_name: function(a) { this.project.name = a; Crowdin.cookies.set("crowdin_project_name" + this.get_project_identifier(), a) }, set_is_leader: function(a) { this.user.is_leader = a; Crowdin.cookies.set("crowdin_is_leader" + this.get_project_identifier(), a) }, set_translations_panel_state: function(a) { Crowdin.cookies.set("crowdin_is_tp_min" + this.get_project_identifier(), a) }, set_source_language: function(a) { this.source_language.code = a; Crowdin.cookies.set("crowdin_source_language_code" + this.get_project_identifier(), a) }, set_show_translations: function(a) { this.editor.showTranslations = a; Crowdin.cookies.set("crowdin_show_translations" + this.get_project_identifier(), a) }, set_files: function(a) { this.editor.files = a }, set_skip_approved: function(a) { this.editor.skipApproved = a }, set_custom_placeholders: function(a) { this.editor.customPlaceholders = a }, set_merge_duplicates: function(a) { this.editor.mergeDuplicates = a; Crowdin.cookies.set("crowdin_merge_duplicates" + this.get_project_identifier(), a) }, login: function(a, b, c) { $JIPT.ajax({ url: this.entryPoint + "jipt/login?callback=?", dataType: "json", data: { login: a, password: b, language_code: this.language.code, project: this.get_project_identifier() }, success: function(d) { Crowdin.self.login_success(d); if (c) { c(d.success) } } }) }, logout: function() { $JIPT.ajax({ url: this.entryPoint + "jipt/logout?callback=?", dataType: "json", data: { project: this.get_project_identifier() }, success: function(a) { Crowdin.self.user.is_logged_in = false; $JIPT("#crowdin-translation-panel").html(Crowdin.self.get_translation_panel_markup()); Crowdin.self.init_login_panel(); $JIPT("#crowdin-editor").dialog("close") } }) }, preview_translations: function() { this.overlay.create(); this.previewTranslations = true; this.drop_element_translation_relations(document.body); this.proceed_phrases_with_html(document.body); this.each_element(document.body, this.phrases); this.clear_markers($JIPT("body")); $JIPT("#crowdin-editor").dialog("close"); this.overlay.destroy() }, clear_markers: function(a) { a.find(".crowdin-jipt-approved-border").removeClass("crowdin-jipt-approved-border"); a.find(".crowdin-jipt-translated-border").removeClass("crowdin-jipt-translated-border"); a.find(".crowdin-jipt-untranslated-border").removeClass("crowdin-jipt-untranslated-border"); a.find(".crowdin-jipt-has-many-border").removeClass("crowdin-jipt-has-many-border"); a.find(".crowdin-jipt-approved-bg").removeClass("crowdin-jipt-approved-bg"); a.find(".crowdin-jipt-translated-bg").removeClass("crowdin-jipt-translated-bg"); a.find(".crowdin-jipt-untranslated-bg").removeClass("crowdin-jipt-untranslated-bg"); a.find(".crowdin-jipt-has-many-bg").removeClass("crowdin-jipt-has-many-bg"); a.find(".crowdin-jipt-approved-underline").removeClass("crowdin-jipt-approved-underline"); a.find(".crowdin-jipt-translated-underline").removeClass("crowdin-jipt-translated-underline"); a.find(".crowdin-jipt-untranslated-underline").removeClass("crowdin-jipt-untranslated-underline"); a.find(".crowdin-jipt-has-many-underline").removeClass("crowdin-jipt-has-many-underline"); a.find(".crowdin-jipt-approved-none").removeClass("crowdin-jipt-approved-none"); a.find(".crowdin-jipt-translated-none").removeClass("crowdin-jipt-translated-none"); a.find(".crowdin-jipt-untranslated-none").removeClass("crowdin-jipt-untranslated-none"); a.find(".crowdin-jipt-has-many-none").removeClass("crowdin-jipt-has-many-none") }, get_login_panel_markup: function() { return '<div class="crowdin-login-panel"><form><table><tr><td colspan="2" style="text-align: center;"><a href="' + this.entryPoint + '" target="_blank" title="Collaborative Translation Tool"><img src="' + this.entryPoint + 'images/logo.png" alt="Crowdin - Collaborative Localization Tool"></a></td></tr><tr><td><label for="crowdin-login-field">Login: </label></td><td><input type="text" value="" id="crowdin-login-field" name="login"></td></tr><tr><td><label for="crowdin-password-field">Password: </label></td><td><input type="password" value="" id="crowdin-password-field" name="password"></td></tr><tr><td><label for="crowdin-login-language-field">Language: </label></td><td><select id="crowdin-login-language-field"></select></td></tr><tr><td colspan="2" style="text-align: center;"><input type="button" value="Come on in" id="crowdin-jipt-login" /></td></tr><tr><td id="crowdin-login-error-message" colspan="2"></td></tr><tr><td colspan="2" style="text-align: center;"><a target="_blank" href="' + this.entryPoint + 'user/lostpassword">Forgot password</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td colspan="2" style="text-align: center;"><span>Do not have profile?</span><input type="button" value="Sign Up As Translator" id="crowdin-jipt-join" /></td></tr></table></form></div>' }, get_translation_panel_markup: function() { if (!this.user.is_logged_in) { return this.get_login_panel_markup() } else { return '<div class="crowdin-translation-panel-container"><ul class="jipt-tabs"><li><a href="#jipt-translations">Translations</a></li><li><a href="#jipt-options">Options</a></li></ul><div id="jipt-translations"><input type="text" class="jipt-search-phrase" placeholder="Type to start search" /><div class="jipt-phrases-container"><ul class="jipt-phrases-to-translate"><li class="crowdin-phrases-stub">Loading...</li></ul></div></div><div id="jipt-options"><table class="crowdin-jipt-options-table"><tr><td><label for="jipt-languages">Target Language:&nbsp;</label></td><td><select id="jipt-languages"></select></td></tr><tr><td><label for="jipt-marker">Translations Marker:&nbsp;</label></td><td><select id="jipt-marker"><option value="border">Border</option><option value="underline">Underline</option><option value="bg">Background</option><option value="none">None</option></select></td></tr><tr><td colspan="2"></td></tr><tr><td colspan="2"><table class="inline-table"><tr><td><input type="checkbox" id="jipt-show-actual-translations"></td><td><label for="jipt-show-actual-translations">Show Actual Translations</label></td></tr></table></td></tr><tr><td colspan="2"><table class="inline-table"><tr><td><input type="checkbox" id="jipt-group-matches" checked></td><td><label for="jipt-group-matches">Group Similar Phrases</label></td></tr></table></td></tr><tr><td colspan="2"><input type="button" value="Preview Translations" id="jipt-preview-translations">&nbsp;&nbsp;&nbsp;<input type="button" value="Open Crowdin Project" id="jipt-crowdin-project-page"></td></tr><tr><td colspan="2" style="padding-top: 20px;"><input type="button" value="Logout" id="jipt-logout"></td></tr></table></div></div>' } }, get_project_identifier: function() { if (this.project.identifier != null) { return this.project.identifier } else { return document.domain } }, check_auth: function(a) { if (a.jipt_error) { $JIPT("#crowdin-editor").dialog("close"); $JIPT("#crowdin-translation-panel").dialog("close"); alert(a.message); this.user.is_logged_in = false; return false } if (a.auth_error) { this.user.is_logged_in = false; $JIPT("#crowdin-translation-panel").html(this.get_translation_panel_markup()); this.init_login_panel(); return false } else { return true } }, fix_dialogs: function() { this.clear_markers($JIPT("#crowdin-editor").parents(".ui-dialog")); $JIPT("#crowdin-editor").parents(".ui-dialog").css("height", "auto"); $JIPT("#crowdin-editor").css("height", "auto"); $JIPT("#crowdin-context-editor").parents(".ui-dialog").css("height", "auto") }, fuzzy_trim: function(a) { return a.replace(/^[\s:.()*-]+|[\s:.()*-]+$/g, "").replace(/\\t/g, "").replace(/\\n/g, "").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"') }, fuzzy_trimmed: function(c) { c = c.replace(/^[\s]+|[\s]+$/g, ""); var b = c.match(/^([:.()*-]+)/g); var a = c.match(/([:.()*-]+)$/g); return { l: b ? b[0] : "", r: a ? a[0] : ""} }, htmlspecialchars: function(a) { return a.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;") }, unhtmlspecialchars: function(a) { return a.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"') }, just_show_panel: function() { $JIPT("#crowdin-translation-panel").dialog("open") }, is_eq: function(c, b) { if (c == b) { return true } else { if (c == null || b == null) { return false } else { if (c.length != b.length) { return false } } } for (var a = 0; a < c.length; a++) { if (c[a] != b[a]) { return false } } return true }, load_external_resource: function(b, a) { if (a == "js") { var c = document.createElement("script"); c.setAttribute("type", "text/javascript"); c.setAttribute("src", b) } else { if (a == "css") { var c = document.createElement("link"); c.setAttribute("rel", "stylesheet"); c.setAttribute("type", "text/css"); c.setAttribute("href", b) } } if (typeof c != "undefined") { document.getElementsByTagName("head")[0].appendChild(c) } return c }, loader: { create: function() { var a = $JIPT("<div></div>").appendTo(document.body).attr("id", "crowdin-load-indicator"); return a }, hide: function() { $JIPT("#crowdin-load-indicator").hide(); return this }, fadeOut: function() { $JIPT("#crowdin-load-indicator").fadeOut(); return this }, show: function() { $JIPT("#crowdin-load-indicator").show(); return this }, update: function(a) { $JIPT("#crowdin-load-indicator").html(a).show(); Crowdin.self.loader.center(); return this }, notify: function(a) { Crowdin.self.loader.update(a); setTimeout(function() { Crowdin.self.loader.fadeOut() }, 2000); return this }, center: function() { var a = $JIPT("#crowdin-load-indicator"); a.css("left", ($JIPT(window).width() - a.width()) / 2 + $JIPT(window).scrollLeft() + "px"); return this } }, overlay: { create: function() { var a = $JIPT("<div></div>").appendTo(document.body).addClass("ui-widget-overlay").css({ width: $JIPT.ui.dialog.overlay.width(), height: $JIPT.ui.dialog.overlay.height(), zIndex: 16777271 }); return a }, destroy: function() { $JIPT(".ui-widget-overlay").remove() } }, cookies: { set: function(a, b) { var c = new Date((new Date()).getTime() + (365 * 1000 * 60 * 60 * 24)); document.cookie = a + "=" + escape(b) + ";expires=" + c.toGMTString() + ";path=/" }, get: function(a) { var e = document.cookie.split(";"); var c = ""; var f = ""; var d = ""; for (var b = 0; b < e.length; b++) { c = e[b].split("="); f = c[0].replace(/^\s+|\s+$/g, ""); if (f == a) { if (c.length > 1) { d = unescape(c[1].replace(/^\s+|\s+$/g, "")) } return d } c = null; f = "" } return null }, has: function(a) { return Crowdin.cookies.get(a) }, pattern_has: function(a) { var c = document.cookie.split(";"); var d = ""; for (var b = 0; b < c.length; b++) { d = c[b].split("=")[0].replace(/^\s+|\s+$/g, ""); if (d.indexOf(a)) { return true } } return false } }, dialog_ui_help: function(e, b) { var a = e.parents(".cjipt"); var d = a.find(".ui-dialog-titlebar:first"); var c = $JIPT("<span></span>").addClass("ui-icon").addClass("ui-icon-help"); var f = $JIPT('<a href="#" class="ui-dialog-titlebar-button ui-dialog-titlebar-button-help"></a>').append(c); f.click(function(g) { $JIPT("#crowdin-help-container").attr("src", b); $JIPT("#crowdin-help").dialog("open"); g.stopPropagation(); return false }); d.append(f) }, dialog_ui_minimization: function(e) { var a = e.parents(".cjipt"); var d = a.find(".ui-dialog-titlebar"); var c = $JIPT("<span></span>").addClass("ui-icon").addClass("ui-icon-minusthick").data("state", true); var b = $JIPT('<a href="#" id="dialog-maximize" class="ui-dialog-titlebar-button ui-dialog-titlebar-button-minimize"></a>').append(c); a.get(0).jipt_minimize = function() { c.removeClass("ui-icon-minusthick").addClass("ui-icon-newwin").data("height", a.height()).data("width", a.width()).data("position", a.position()).data("state", false); e.hide(); $JIPT(e).dialog("option", "resizable", false); $JIPT(e).dialog("option", "draggable", false); a.height("auto").width(250); a.css({ position: "fixed", top: "auto", left: "auto", bottom: 0, right: 0 }) }; var f = function(g) { if (c.data("state")) { a.get(0).jipt_minimize(); Crowdin.self.set_translations_panel_state(true) } else { c.removeClass("ui-icon-minusthick").addClass("ui-icon-minusthick").data("state", true); $JIPT(e).dialog("option", "resizable", true); $JIPT(e).dialog("option", "draggable", true); a.height(c.data("height")).width(c.data("width")).position(c.data("position")); e.show(); Crowdin.self.set_translations_panel_state(false) } g.stopPropagation(); return false }; b.click(f); d.dblclick(f); d.append(b) } }; if (!("$JIPT" in window)) { Crowdin.load_external_resource(Crowdin.jiptCDN + "jipt.css", "css"); Crowdin.load_external_resource(Crowdin.jiptCDN + "lib/jquery-ui/jquery-ui.css", "css"); Crowdin.load_external_resource("http://www.google.com/jsapi", "js"); Crowdin.load_external_resource("http://api.microsofttranslator.com/v1/Ajax.svc/Embed?appId=5jsjk2lJyATpvoTvhmrzFt2WCkcFHsWH", "js"); Crowdin.load_external_resource(Crowdin.jiptCDN + "lib/jquery.js", "js").onload = function() { Crowdin.load_external_resource(Crowdin.jiptCDN + "lib/jquery-ui/jquery-ui.js", "js").onload = function() { window.$JIPT = $.noConflict(true); var a = Crowdin.init(); if ($JIPT("script[jipt=api]").length) { $JIPT(document).ready(function() { for (var b = 0; b < Crowdin._preloadCallbacks.length; b++) { Crowdin._preloadCallbacks[b](a) } }) } else { if ($JIPT("script[jipt=bml]").length) { a.start_translation() } else { if ($JIPT.isReady) { a.start_translation() } else { $JIPT(document).ready(function() { a.start_translation() }) } } } } } };