How to use serializedArgs method in storybook-root

Best JavaScript code snippet using storybook-root

rpc.js

Source:rpc.js Github

copy

Full Screen

1// Universal Subtitles, universalsubtitles.org2//3// Copyright (C) 2010 Participatory Culture Foundation4//5// This program is free software: you can redistribute it and/or modify6// it under the terms of the GNU Affero General Public License as7// published by the Free Software Foundation, either version 3 of the8// License, or (at your option) any later version.9//10// This program is distributed in the hope that it will be useful,11// but WITHOUT ANY WARRANTY; without even the implied warranty of12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13// GNU Affero General Public License for more details.14//15// You should have received a copy of the GNU Affero General Public License16// along with this program. If not, see17// http://www.gnu.org/licenses/agpl-3.0.html.18goog.provide('mirosubs.Rpc');19mirosubs.Rpc.logger_ =20 goog.debug.Logger.getLogger('mirosubs.Rpc');21mirosubs.Rpc.baseURL = function() {22 return [mirosubs.siteURL(), 23 '/widget/',24 mirosubs.IS_NULL ? 'null_' : '',25 'rpc/'].join('');26};27mirosubs.Rpc.callCrossDomain_ = function(methodName, serializedArgs, opt_callback) {28 var p = goog.json.parse;29 goog.net.CrossDomainRpc.30 send([mirosubs.Rpc.baseURL(), 'xd/', methodName].join(''),31 function(event) {32 var responseText = event["target"]["responseText"];33 mirosubs.Rpc.logResponse_(methodName, responseText);34 if (opt_callback)35 opt_callback(p(responseText));36 }, "POST", serializedArgs);37};38mirosubs.Rpc.callXhr_ = function(methodName, serializedArgs, opt_callback) {39 goog.net.XhrIo.send(40 [mirosubs.Rpc.baseURL(), 'xhr/', methodName].join(''),41 function(event) {42 mirosubs.Rpc.logResponse_(43 methodName, 44 event.target.getResponseText());45 if (opt_callback)46 opt_callback(event.target.getResponseJson());47 },48 "POST", mirosubs.Rpc.encodeKeyValuePairs_(serializedArgs));49};50mirosubs.Rpc.encodeKeyValuePairs_ = function(serializedArgs) {51 var queryData = new goog.Uri.QueryData();52 for (var param in serializedArgs)53 queryData.set(param, serializedArgs[param]);54 return queryData.toString();55};56mirosubs.Rpc.callWithJsonp_ = function(methodName, serializedArgs, opt_callback) {57 var jsonp = new goog.net.Jsonp(58 [mirosubs.Rpc.baseURL(), 'jsonp/', methodName].join(''));59 jsonp.send(serializedArgs,60 function(result) {61 if (mirosubs.DEBUG)62 mirosubs.Rpc.logResponse_(63 methodName, goog.json.serialize(result));64 if (opt_callback)65 opt_callback(result);66 });67};68mirosubs.Rpc.logCall_ = function(methodName, args, channel) {69 if (mirosubs.DEBUG)70 mirosubs.Rpc.logger_.info(71 ['calling ', methodName, ' with ', channel,72 ': ', goog.json.serialize(args)].join(''));73};74mirosubs.Rpc.logResponse_ = function(methodName, response) {75 if (mirosubs.DEBUG)76 mirosubs.Rpc.logger_.info(77 [methodName, ' response: ', response].join(''));78};79mirosubs.Rpc.call = function(methodName, args, opt_callback) {80 var s = goog.json.serialize;81 var serializedArgs = {};82 var arg;83 var totalSize = 0;84 for (var param in args) {85 arg = s(args[param]);86 serializedArgs[param] = arg;87 totalSize += arg.length;88 }89 var callType = ''90 if (mirosubs.isEmbeddedInDifferentDomain()) {91 if (totalSize < 2000) {92 callType = 'jsonp';93 mirosubs.Rpc.callWithJsonp_(94 methodName, serializedArgs, opt_callback);95 }96 else {97 callType = 'xd-rpc';98 mirosubs.Rpc.callCrossDomain_(99 methodName, serializedArgs, opt_callback);100 }101 } else {102 callType = 'xhr';103 mirosubs.Rpc.callXhr_(104 methodName, serializedArgs, opt_callback);105 }106 mirosubs.Rpc.logCall_(methodName, args, callType);...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful