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

timekit-booking

Package Overview
Dependencies
Maintainers
2
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timekit-booking - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

test/prefillFromUrl.spec.js

3

package.json
{
"name": "timekit-booking",
"version": "2.1.0",
"version": "2.2.0",
"description": "Make a beautiful embeddable booking widget in minutes",

@@ -30,2 +30,3 @@ "main": "dist/booking.min.js",

"moment-timezone": "^0.5.13",
"querystringify": "^2.0.0",
"sprintf-js": "^1.0.3",

@@ -32,0 +33,0 @@ "timekit-sdk": "^1.16.0"

'use strict';
var defaultConfig = require('./defaults');
var qs = require('querystringify');

@@ -9,2 +10,3 @@ function InitConfig() {

var config = {};
var global = null;

@@ -36,2 +38,11 @@ // Setup defaults for the SDK

// Prefill customer fields based on URL query string
var applyPrefillFromUrlGetParams = function (suppliedConfig, urlParams) {
$.each(suppliedConfig.customer_fields, function (key) {
if (!urlParams['customer.' + key]) return
suppliedConfig.customer_fields[key].prefilled = urlParams['customer.' + key];
});
return suppliedConfig
}
// Setup config

@@ -48,6 +59,8 @@ var parseAndUpdate = function(suppliedConfig) {

// Check for required settings
if (!newConfig.app_key) {
throw 'A required config setting ("app_key") was missing';
}
if (!newConfig.app_key) throw 'A required config setting ("app_key") was missing';
// Prefill fields based on query string
var urlParams = getGlobal().location && getGlobal().location.search;
if (urlParams) newConfig = applyPrefillFromUrlGetParams(newConfig, qs.parse(urlParams));
// Set new config to instance config

@@ -68,2 +81,10 @@ update(newConfig);

var setGlobal = function(val) {
global = val
}
var getGlobal = function(val) {
return global
}
return {

@@ -74,3 +95,5 @@ parseAndUpdate: parseAndUpdate,

update: update,
retrieve: retrieve
retrieve: retrieve,
setGlobal: setGlobal,
getGlobal: getGlobal
}

@@ -77,0 +100,0 @@ }

@@ -21,3 +21,8 @@ 'use strict';

// Initilization method
var init = function(suppliedConfig) {
var init = function(suppliedConfig, global) {
// Allows mokcing the window object if passed
global = global || window;
config.setGlobal(global)
// Make sure that SDK is ready and debug flag is checked early

@@ -24,0 +29,0 @@ var localConfig = config.setDefaults(suppliedConfig || {});

@@ -6,3 +6,3 @@ 'use strict';

// Creates a new widget instance with supplied config, inits it and returns it
module.exports = function(config) {
module.exports = function(config, global) {

@@ -13,3 +13,3 @@ var newConfig = {};

var widget = new TimekitBooking();
widget.init(newConfig);
widget.init(newConfig, global);

@@ -16,0 +16,0 @@ return widget;

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

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 not supported yet

Sorry, the diff of this file is not supported yet

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