Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tml-js-browser

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tml-js-browser - npm Package Compare versions

Comparing version 0.4.31 to 0.4.34

Gruntfile.js

3

lib/api_adapters/ajax.js

@@ -88,3 +88,4 @@ /**

if (method.match(/^get$/i)) {
url = url + "?" + this.serialize(params || {});
var query = this.serialize(params || {});
if (query !== '') url = url + "?" + query;
data = null;

@@ -91,0 +92,0 @@ } else {

@@ -169,3 +169,4 @@ /**

if (key.match(/^tml_/))
this.cache.removeItem(key);
if (!key.match(/current_version/))
this.cache.removeItem(key);
}

@@ -172,0 +173,0 @@ if (callback) callback(null);

@@ -65,2 +65,17 @@ /**

includeLs: function(options) {
var node = document.createElement("div");
if (utils.isObject(options)) {
for(var propertyName in options) {
if (propertyName == 'type')
node.setAttribute("data-tml-language-selector", options[propertyName]);
else
node.setAttribute("data-tml-" + propertyName, options[propertyName]);
}
} else {
node.setAttribute("data-tml-language-selector", "sideflags");
}
document.body.appendChild(node);
},
includeAgent: function(app, options, callback) {

@@ -171,3 +186,4 @@ var agent_host = options.host || "https://tools.translationexchange.com/agent/stable/agent.min.js";

setCookie: helpers.setCookie,
includeLs: helpers.includeLs,
includeAgent: helpers.includeAgent
};

@@ -1,3 +0,2 @@

var inline = ["a", "span", "i", "b", "img", "strong", "s", "em", "u", "sub", "sup", "var", "code"];
var inline = ["a", "span", "i", "b", "img", "strong", "s", "em", "u", "sub", "sup", "var", "code", "kbd"];
var separators = ["br", "hr"];

@@ -4,0 +3,0 @@

@@ -110,3 +110,5 @@ /**

tml.startKeyListener();
tml.startSourceListener(options);
if (callback) {

@@ -155,2 +157,5 @@ callback();

startSourceListener: function (options) {
// TODO: Ian, we don't need this unless we use a fully automated mode
if (!options.translateBody) return;
var self = this;

@@ -207,3 +212,4 @@ var app = tml.getApplication();

adapter: "browser",
version: cache_version
version: cache_version,
version_check_interval: options.version_check_interval || 60 // browser will default to every 60 sec
}

@@ -219,3 +225,3 @@ }, options);

key: options.key,
token: options.token,
token: cookie.oauth ? cookie.oauth.token : null,
host: options.host || DEFAULT_HOST

@@ -245,2 +251,6 @@ });

if (options.language_selector) {
helpers.includeLs(options.language_selector);
}
helpers.includeAgent(tml.app, {

@@ -256,21 +266,9 @@ host: options.agent.host,

}, function () {
if (typeof(options.onLoad) == "function") {
options.onLoad(tml.app);
}
tml.emit('load');
if (callback) callback();
});
if (typeof(options.onLoad) == "function") {
options.onLoad(tml.app);
}
});
// if version is hardcoded - don't bother checking the version
if (options.fetch_version) {
setTimeout(function () {
tml.config.getCache().fetchVersion(function (current_version) {
tml.app.getApiClient().getReleaseVersion(function (new_version) {
if (current_version != new_version)
tml.config.getCache().clear();
});
});
}, 1000);
}
});

@@ -302,4 +300,6 @@ },

if (this.tokenizer) {
if (this.tokenizer && this.tokenizer.updateAllNodes) {
this.tokenizer.updateAllNodes();
} else {
window.location.reload();
}

@@ -306,0 +306,0 @@

@@ -8,2 +8,3 @@ var tml = require('tml-js');

var DomTokenizer = function(doc, context, options) {

@@ -47,4 +48,5 @@ this.doc = doc;

var tml, data, translation, text = "";
if(parent) {
tml = nodes.map(function(n){text+=n.innerText||n.nodeValue;return this.generateTmlTags(n);}.bind(this)).join("");
tml = nodes.map(function(n){text+=n.innerHTML || n.nodeValue;return this.generateTmlTags(n);}.bind(this)).join("");
data = this.tokens;

@@ -174,6 +176,8 @@ translation = this.translateTml(tml);

generateTmlTags: function(node) {
if(node.nodeType == 3) { return node.nodeValue; }
if(node.nodeType == 3) {
return this.escapeHtml(node.nodeValue);
}
if (!this.isTranslatable(node)) {
var tokenName = this.contextualize(this.adjustName(node), node.innerHTML);
var tokenName = this.contextualize(this.adjustName(node), node.outerHTML);
return "{" + tokenName + "}";

@@ -191,3 +195,3 @@ }

var child = node.childNodes[i];
buffer = buffer + ((child.nodeType == 3) ? child.nodeValue : this.generateTmlTags(child));
buffer = buffer + ((child.nodeType == 3) ? this.escapeHtml(child.nodeValue) : this.generateTmlTags(child));
}

@@ -381,2 +385,7 @@ var tokenContext = this.generateHtmlToken(node);

escapeHtml: function(str) {
var div = document.createElement('div');
div.appendChild(document.createTextNode(str));
return div.innerHTML;
},

@@ -383,0 +392,0 @@

{
"name": "tml-js-browser",
"description": "Translation plugin for browsers.",
"version": "0.4.31",
"version": "0.4.34",
"author": {

@@ -6,0 +6,0 @@ "name": "Michael Berkovich",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc