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 1.0.6 to 1.0.8

2

lib/api_adapters/ajax.js
/**
* Copyright (c) 2017 Translation Exchange, Inc.
* Copyright (c) 2018 Translation Exchange, Inc.
*

@@ -4,0 +4,0 @@ * _______ _ _ _ ______ _

/**
* Copyright (c) 2017 Translation Exchange, Inc.
* Copyright (c) 2018 Translation Exchange, Inc.
*

@@ -4,0 +4,0 @@ * _______ _ _ _ ______ _

/**
* Copyright (c) 2017 Translation Exchange, Inc.
* Copyright (c) 2018 Translation Exchange, Inc.
*

@@ -4,0 +4,0 @@ * _______ _ _ _ ______ _

/**
* Copyright (c) 2017 Translation Exchange, Inc.
* Copyright (c) 2018 Translation Exchange, Inc.
*

@@ -168,3 +168,69 @@ * _______ _ _ _ ______ _

/**ch
/**
* Returns query params from a URL
*
* @param url
*/
getQueryParams: function(url) {
var params = {};
var query = url.split('#')[0].split('?');
if (query.length === 1)
return params;
var vars = query[1].split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
return params;
},
/**
* Exports object as parameters
*
* @param obj
* @returns {*}
*/
toQueryParams: function (obj) {
if (typeof obj === 'undefined' || obj === null) return "";
if (typeof obj === 'string') return obj;
var qs = [];
for (var p in obj) {
qs.push(p + "=" + encodeURIComponent(obj[p]));
}
return qs.join("&");
},
/**
* Adjust iFrame urls with the locale
*
* @param app
*/
adjustIFrameUrls: function(app) {
if (!app || !app.current_locale)
return;
var iframes = document.getElementsByTagName("iframe");
if (iframes.length === 0)
return;
tml.logger.debug("Adjusting IFrame URLs locale to " + app.current_locale);
for (var i = 0; i < iframes.length; i++) {
var url = iframes[i].src;
var params = helpers.getQueryParams(url);
params.locale = app.current_locale;
var new_url = url.split('?')[0] + "?" + helpers.toQueryParams(params);
var hash = url.split('#');
if (hash.length > 1) new_url = new_url + "#" + hash[1];
iframes[i].src = new_url;
}
},
/**
* Returns path fragments

@@ -437,3 +503,4 @@ *

includeCss: helpers.includeCss,
includeAgent: helpers.includeAgent
includeAgent: helpers.includeAgent,
adjustIFrameUrls: helpers.adjustIFrameUrls
};
/**
* Copyright (c) 2017 Translation Exchange, Inc.
* Copyright (c) 2018 Translation Exchange, Inc.
*

@@ -4,0 +4,0 @@ * _______ _ _ _ ______ _

/**
* Copyright (c) 2017 Translation Exchange, Inc.
* Copyright (c) 2018 Translation Exchange, Inc.
*

@@ -100,3 +100,3 @@ * _______ _ _ _ ______ _

if (!options.current_source) {
options.current_source = function() {
options.current_source = function () {
return helpers.getDefaultSource(options);

@@ -163,3 +163,3 @@ };

options.fetch_version = (options.cache.adapter == 'browser' && !cache_version);
options.fetch_version = (options.cache.adapter === 'browser' && !cache_version);

@@ -213,2 +213,5 @@ tml.config.initCache(options.key);

if (options.skip_iframes !== true)
helpers.adjustIFrameUrls(tml.app);
helpers.includeCss(tml.app);

@@ -229,3 +232,3 @@

}, function () {
if (typeof(options.onLoad) == "function") {
if (typeof(options.onLoad) === "function") {
options.onLoad(tml.app);

@@ -362,7 +365,7 @@ }

*/
setSource: function(name, callback){
setSource: function (name, callback) {
var app = tml.getApplication();
var update = function () {
app.current_source = name;
if(callback) callback();
if (callback) callback();
};

@@ -369,0 +372,0 @@

/**
* Copyright (c) 2017 Translation Exchange, Inc.
* Copyright (c) 2018 Translation Exchange, Inc.
*

@@ -4,0 +4,0 @@ * _______ _ _ _ ______ _

{
"name": "tml-js-browser",
"description": "Translation plugin for browsers.",
"version": "1.0.6",
"version": "1.0.8",
"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