Best JavaScript code snippet using appium-android-driver
admin.js
Source:admin.js
1// Copyright (c) 2015-present Xenia, Inc. All Rights Reserved.2// See LICENSE.txt for license information.3// @flow4import {AdminTypes} from 'action_types';5import {General} from 'constants';6import {Client4} from 'client';7import {logError} from './errors';8import {bindClientFunc, forceLogoutIfNecessary} from './helpers';9import {batchActions} from 'redux-batched-actions';10import type {ActionFunc} from 'types/actions';11import type {Job} from 'types/jobs';12import type {GroupSearchOpts} from 'types/groups';13export function getLogs(page: number = 0, perPage: number = General.LOGS_PAGE_SIZE_DEFAULT): ActionFunc {14 return bindClientFunc({15 clientFunc: Client4.getLogs,16 onRequest: AdminTypes.GET_LOGS_REQUEST,17 onSuccess: [AdminTypes.RECEIVED_LOGS, AdminTypes.GET_LOGS_SUCCESS],18 onFailure: AdminTypes.GET_LOGS_FAILURE,19 params: [20 page,21 perPage,22 ],23 });24}25export function getAudits(page: number = 0, perPage: number = General.PAGE_SIZE_DEFAULT): ActionFunc {26 return bindClientFunc({27 clientFunc: Client4.getAudits,28 onRequest: AdminTypes.GET_AUDITS_REQUEST,29 onSuccess: [AdminTypes.RECEIVED_AUDITS, AdminTypes.GET_AUDITS_SUCCESS],30 onFailure: AdminTypes.GET_AUDITS_FAILURE,31 params: [32 page,33 perPage,34 ],35 });36}37export function getConfig(): ActionFunc {38 return bindClientFunc({39 clientFunc: Client4.getConfig,40 onRequest: AdminTypes.GET_CONFIG_REQUEST,41 onSuccess: [AdminTypes.RECEIVED_CONFIG, AdminTypes.GET_CONFIG_SUCCESS],42 onFailure: AdminTypes.GET_CONFIG_FAILURE,43 });44}45export function updateConfig(config: Object): ActionFunc {46 return bindClientFunc({47 clientFunc: Client4.updateConfig,48 onRequest: AdminTypes.UPDATE_CONFIG_REQUEST,49 onSuccess: [AdminTypes.RECEIVED_CONFIG, AdminTypes.UPDATE_CONFIG_SUCCESS],50 onFailure: AdminTypes.UPDATE_CONFIG_FAILURE,51 params: [52 config,53 ],54 });55}56export function reloadConfig(): ActionFunc {57 return bindClientFunc({58 clientFunc: Client4.reloadConfig,59 onRequest: AdminTypes.RELOAD_CONFIG_REQUEST,60 onSuccess: AdminTypes.RELOAD_CONFIG_SUCCESS,61 onFailure: AdminTypes.RELOAD_CONFIG_FAILURE,62 });63}64export function getEnvironmentConfig(): ActionFunc {65 return bindClientFunc({66 clientFunc: Client4.getEnvironmentConfig,67 onRequest: AdminTypes.GET_ENVIRONMENT_CONFIG_REQUEST,68 onSuccess: [AdminTypes.RECEIVED_ENVIRONMENT_CONFIG, AdminTypes.GET_ENVIRONMENT_CONFIG_SUCCESS],69 onFailure: AdminTypes.GET_ENVIRONMENT_CONFIG_FAILURE,70 });71}72export function testEmail(config: Object): ActionFunc {73 return bindClientFunc({74 clientFunc: Client4.testEmail,75 onRequest: AdminTypes.TEST_EMAIL_REQUEST,76 onSuccess: AdminTypes.TEST_EMAIL_SUCCESS,77 onFailure: AdminTypes.TEST_EMAIL_FAILURE,78 params: [79 config,80 ],81 });82}83export function testS3Connection(config: Object): ActionFunc {84 return bindClientFunc({85 clientFunc: Client4.testS3Connection,86 onRequest: AdminTypes.TEST_S3_REQUEST,87 onSuccess: AdminTypes.TEST_S3_SUCCESS,88 onFailure: AdminTypes.TEST_S3_FAILURE,89 params: [90 config,91 ],92 });93}94export function invalidateCaches(): ActionFunc {95 return bindClientFunc({96 clientFunc: Client4.invalidateCaches,97 onRequest: AdminTypes.INVALIDATE_CACHES_REQUEST,98 onSuccess: AdminTypes.INVALIDATE_CACHES_SUCCESS,99 onFailure: AdminTypes.INVALIDATE_CACHES_FAILURE,100 });101}102export function recycleDatabase(): ActionFunc {103 return bindClientFunc({104 clientFunc: Client4.recycleDatabase,105 onRequest: AdminTypes.RECYCLE_DATABASE_REQUEST,106 onSuccess: AdminTypes.RECYCLE_DATABASE_SUCCESS,107 onFailure: AdminTypes.RECYCLE_DATABASE_FAILURE,108 });109}110export function createComplianceReport(job: Job): ActionFunc {111 return bindClientFunc({112 clientFunc: Client4.createComplianceReport,113 onRequest: AdminTypes.CREATE_COMPLIANCE_REQUEST,114 onSuccess: [AdminTypes.RECEIVED_COMPLIANCE_REPORT, AdminTypes.CREATE_COMPLIANCE_SUCCESS],115 onFailure: AdminTypes.CREATE_COMPLIANCE_FAILURE,116 params: [117 job,118 ],119 });120}121export function getComplianceReport(reportId: string): ActionFunc {122 return bindClientFunc({123 clientFunc: Client4.getComplianceReport,124 onRequest: AdminTypes.GET_COMPLIANCE_REQUEST,125 onSuccess: [AdminTypes.RECEIVED_COMPLIANCE_REPORT, AdminTypes.GET_COMPLIANCE_SUCCESS],126 onFailure: AdminTypes.GET_COMPLIANCE_FAILURE,127 params: [128 reportId,129 ],130 });131}132export function getComplianceReports(page: number = 0, perPage: number = General.PAGE_SIZE_DEFAULT): ActionFunc {133 return bindClientFunc({134 clientFunc: Client4.getComplianceReports,135 onRequest: AdminTypes.GET_COMPLIANCE_REQUEST,136 onSuccess: [AdminTypes.RECEIVED_COMPLIANCE_REPORTS, AdminTypes.GET_COMPLIANCE_SUCCESS],137 onFailure: AdminTypes.GET_COMPLIANCE_FAILURE,138 params: [139 page,140 perPage,141 ],142 });143}144export function uploadBrandImage(imageData: File): ActionFunc {145 return bindClientFunc({146 clientFunc: Client4.uploadBrandImage,147 onRequest: AdminTypes.UPLOAD_BRAND_IMAGE_REQUEST,148 onSuccess: AdminTypes.UPLOAD_BRAND_IMAGE_SUCCESS,149 onFailure: AdminTypes.UPLOAD_BRAND_IMAGE_FAILURE,150 params: [151 imageData,152 ],153 });154}155export function deleteBrandImage(): ActionFunc {156 return bindClientFunc({157 clientFunc: Client4.deleteBrandImage,158 onRequest: AdminTypes.DELETE_BRAND_IMAGE_REQUEST,159 onSuccess: AdminTypes.DELETE_BRAND_IMAGE_SUCCESS,160 onFailure: AdminTypes.DELETE_BRAND_IMAGE_FAILURE,161 });162}163export function getClusterStatus(): ActionFunc {164 return bindClientFunc({165 clientFunc: Client4.getClusterStatus,166 onRequest: AdminTypes.GET_CLUSTER_STATUS_REQUEST,167 onSuccess: [AdminTypes.RECEIVED_CLUSTER_STATUS, AdminTypes.GET_CLUSTER_STATUS_SUCCESS],168 onFailure: AdminTypes.GET_CLUSTER_STATUS_FAILURE,169 });170}171export function testLdap(): ActionFunc {172 return bindClientFunc({173 clientFunc: Client4.testLdap,174 onRequest: AdminTypes.TEST_LDAP_REQUEST,175 onSuccess: AdminTypes.TEST_LDAP_SUCCESS,176 onFailure: AdminTypes.TEST_LDAP_FAILURE,177 });178}179export function syncLdap(): ActionFunc {180 return bindClientFunc({181 clientFunc: Client4.syncLdap,182 onRequest: AdminTypes.SYNC_LDAP_REQUEST,183 onSuccess: AdminTypes.SYNC_LDAP_SUCCESS,184 onFailure: AdminTypes.SYNC_LDAP_FAILURE,185 });186}187export function getLdapGroups(page: number = 0, perPage: number = General.PAGE_SIZE_MAXIMUM, opts: GroupSearchOpts = {q: ''}): ActionFunc {188 return bindClientFunc({189 clientFunc: Client4.getLdapGroups,190 onRequest: AdminTypes.GET_LDAP_GROUPS_REQUEST,191 onSuccess: [AdminTypes.RECEIVED_LDAP_GROUPS, AdminTypes.GET_LDAP_GROUPS_SUCCESS],192 onFailure: AdminTypes.GET_LDAP_GROUPS_FAILURE,193 params: [194 page,195 perPage,196 opts,197 ],198 });199}200export function linkLdapGroup(key: string): ActionFunc {201 return async (dispatch, getState) => {202 dispatch({type: AdminTypes.LINK_LDAP_GROUP_REQUEST, data: key});203 let data;204 try {205 data = await Client4.linkLdapGroup(key);206 } catch (error) {207 forceLogoutIfNecessary(error, dispatch, getState);208 dispatch(batchActions([209 {type: AdminTypes.LINK_LDAP_GROUP_FAILURE, error, data: key},210 logError(error),211 ]));212 return {error};213 }214 dispatch(batchActions([215 {type: AdminTypes.LINK_LDAP_GROUP_SUCCESS, data: null},216 {217 type: AdminTypes.LINKED_LDAP_GROUP,218 data: {219 primary_key: key,220 name: data.display_name,221 xenia_group_id: data.id,222 has_syncables: false,223 },224 },225 ]));226 return {data: true};227 };228}229export function unlinkLdapGroup(key: string): ActionFunc {230 return async (dispatch, getState) => {231 dispatch({type: AdminTypes.UNLINK_LDAP_GROUP_REQUEST, data: key});232 try {233 await Client4.unlinkLdapGroup(key);234 } catch (error) {235 forceLogoutIfNecessary(error, dispatch, getState);236 dispatch(batchActions([237 {type: AdminTypes.UNLINK_LDAP_GROUP_FAILURE, error, data: key},238 logError(error),239 ]));240 return {error};241 }242 dispatch(batchActions([243 {type: AdminTypes.UNLINK_LDAP_GROUP_SUCCESS, data: null},244 {type: AdminTypes.UNLINKED_LDAP_GROUP, data: key},245 ]));246 return {data: true};247 };248}249export function getSamlCertificateStatus(): ActionFunc {250 return bindClientFunc({251 clientFunc: Client4.getSamlCertificateStatus,252 onRequest: AdminTypes.SAML_CERT_STATUS_REQUEST,253 onSuccess: [AdminTypes.RECEIVED_SAML_CERT_STATUS, AdminTypes.SAML_CERT_STATUS_SUCCESS],254 onFailure: AdminTypes.SAML_CERT_STATUS_FAILURE,255 });256}257export function uploadPublicSamlCertificate(fileData: File): ActionFunc {258 return bindClientFunc({259 clientFunc: Client4.uploadPublicSamlCertificate,260 onRequest: AdminTypes.UPLOAD_SAML_PUBLIC_REQUEST,261 onSuccess: AdminTypes.UPLOAD_SAML_PUBLIC_SUCCESS,262 onFailure: AdminTypes.UPLOAD_SAML_PUBLIC_FAILURE,263 params: [264 fileData,265 ],266 });267}268export function uploadPrivateSamlCertificate(fileData: File): ActionFunc {269 return bindClientFunc({270 clientFunc: Client4.uploadPrivateSamlCertificate,271 onRequest: AdminTypes.UPLOAD_SAML_PRIVATE_REQUEST,272 onSuccess: AdminTypes.UPLOAD_SAML_PRIVATE_SUCCESS,273 onFailure: AdminTypes.UPLOAD_SAML_PRIVATE_FAILURE,274 params: [275 fileData,276 ],277 });278}279export function uploadIdpSamlCertificate(fileData: File): ActionFunc {280 return bindClientFunc({281 clientFunc: Client4.uploadIdpSamlCertificate,282 onRequest: AdminTypes.UPLOAD_SAML_IDP_REQUEST,283 onSuccess: AdminTypes.UPLOAD_SAML_IDP_SUCCESS,284 onFailure: AdminTypes.UPLOAD_SAML_IDP_FAILURE,285 params: [286 fileData,287 ],288 });289}290export function removePublicSamlCertificate(): ActionFunc {291 return bindClientFunc({292 clientFunc: Client4.deletePublicSamlCertificate,293 onRequest: AdminTypes.DELETE_SAML_PUBLIC_REQUEST,294 onSuccess: AdminTypes.DELETE_SAML_PUBLIC_SUCCESS,295 onFailure: AdminTypes.DELETE_SAML_PUBLIC_FAILURE,296 });297}298export function removePrivateSamlCertificate(): ActionFunc {299 return bindClientFunc({300 clientFunc: Client4.deletePrivateSamlCertificate,301 onRequest: AdminTypes.DELETE_SAML_PRIVATE_REQUEST,302 onSuccess: AdminTypes.DELETE_SAML_PRIVATE_SUCCESS,303 onFailure: AdminTypes.DELETE_SAML_PRIVATE_FAILURE,304 });305}306export function removeIdpSamlCertificate(): ActionFunc {307 return bindClientFunc({308 clientFunc: Client4.deleteIdpSamlCertificate,309 onRequest: AdminTypes.DELETE_SAML_IDP_REQUEST,310 onSuccess: AdminTypes.DELETE_SAML_IDP_SUCCESS,311 onFailure: AdminTypes.DELETE_SAML_IDP_FAILURE,312 });313}314export function testElasticsearch(config: Object): ActionFunc {315 return bindClientFunc({316 clientFunc: Client4.testElasticsearch,317 onRequest: AdminTypes.TEST_ELASTICSEARCH_REQUEST,318 onSuccess: AdminTypes.TEST_ELASTICSEARCH_SUCCESS,319 onFailure: AdminTypes.TEST_ELASTICSEARCH_FAILURE,320 params: [321 config,322 ],323 });324}325export function purgeElasticsearchIndexes(): ActionFunc {326 return bindClientFunc({327 clientFunc: Client4.purgeElasticsearchIndexes,328 onRequest: AdminTypes.PURGE_ELASTICSEARCH_INDEXES_REQUEST,329 onSuccess: AdminTypes.PURGE_ELASTICSEARCH_INDEXES_SUCCESS,330 onFailure: AdminTypes.PURGE_ELASTICSEARCH_INDEXES_FAILURE,331 });332}333export function uploadLicense(fileData: File): ActionFunc {334 return bindClientFunc({335 clientFunc: Client4.uploadLicense,336 onRequest: AdminTypes.UPLOAD_LICENSE_REQUEST,337 onSuccess: AdminTypes.UPLOAD_LICENSE_SUCCESS,338 onFailure: AdminTypes.UPLOAD_LICENSE_FAILURE,339 params: [340 fileData,341 ],342 });343}344export function removeLicense(): ActionFunc {345 return bindClientFunc({346 clientFunc: Client4.removeLicense,347 onRequest: AdminTypes.REMOVE_LICENSE_REQUEST,348 onSuccess: AdminTypes.REMOVE_LICENSE_SUCCESS,349 onFailure: AdminTypes.REMOVE_LICENSE_FAILURE,350 });351}352export function getAnalytics(name: string, teamId: string = ''): ActionFunc {353 return async (dispatch, getState) => {354 dispatch({type: AdminTypes.GET_ANALYTICS_REQUEST, data: null}, getState);355 let data;356 try {357 data = await Client4.getAnalytics(name, teamId);358 } catch (error) {359 forceLogoutIfNecessary(error, dispatch, getState);360 dispatch(batchActions([361 {type: AdminTypes.GET_ANALYTICS_FAILURE, error},362 logError(error),363 ]), getState);364 return {error};365 }366 const actions = [{type: AdminTypes.GET_ANALYTICS_SUCCESS, data: null}];367 if (teamId === '') {368 actions.push({type: AdminTypes.RECEIVED_SYSTEM_ANALYTICS, data, name});369 } else {370 actions.push({type: AdminTypes.RECEIVED_TEAM_ANALYTICS, data, name, teamId});371 }372 dispatch(batchActions(actions), getState);373 return {data};374 };375}376export function getStandardAnalytics(teamId: string = ''): ActionFunc {377 return getAnalytics('standard', teamId);378}379export function getAdvancedAnalytics(teamId: string = ''): ActionFunc {380 return getAnalytics('extra_counts', teamId);381}382export function getPostsPerDayAnalytics(teamId: string = ''): ActionFunc {383 return getAnalytics('post_counts_day', teamId);384}385export function getUsersPerDayAnalytics(teamId: string = ''): ActionFunc {386 return getAnalytics('user_counts_with_posts_day', teamId);387}388export function uploadPlugin(fileData: File, force: boolean = false): ActionFunc {389 return async (dispatch, getState) => {390 dispatch({type: AdminTypes.UPLOAD_PLUGIN_REQUEST, data: null});391 let data;392 try {393 data = await Client4.uploadPlugin(fileData, force);394 } catch (error) {395 forceLogoutIfNecessary(error, dispatch, getState);396 dispatch(batchActions([397 {type: AdminTypes.UPLOAD_PLUGIN_FAILURE, error},398 logError(error),399 ]));400 return {error};401 }402 dispatch(batchActions([403 {type: AdminTypes.UPLOAD_PLUGIN_SUCCESS, data: null},404 ]));405 return {data};406 };407}408export function getPlugins(): ActionFunc {409 return bindClientFunc({410 clientFunc: Client4.getPlugins,411 onRequest: AdminTypes.GET_PLUGIN_REQUEST,412 onSuccess: [AdminTypes.GET_PLUGIN_SUCCESS, AdminTypes.RECEIVED_PLUGINS],413 onFailure: AdminTypes.GET_PLUGIN_FAILURE,414 });415}416export function getPluginStatuses(): ActionFunc {417 return bindClientFunc({418 clientFunc: Client4.getPluginStatuses,419 onRequest: AdminTypes.GET_PLUGIN_STATUSES_REQUEST,420 onSuccess: [AdminTypes.GET_PLUGIN_STATUSES_SUCCESS, AdminTypes.RECEIVED_PLUGIN_STATUSES],421 onFailure: AdminTypes.GET_PLUGIN_STATUSES_FAILURE,422 });423}424export function removePlugin(pluginId: string): ActionFunc {425 return async (dispatch, getState) => {426 dispatch({type: AdminTypes.REMOVE_PLUGIN_REQUEST, data: pluginId});427 try {428 await Client4.removePlugin(pluginId);429 } catch (error) {430 forceLogoutIfNecessary(error, dispatch, getState);431 dispatch(batchActions([432 {type: AdminTypes.REMOVE_PLUGIN_FAILURE, error, data: pluginId},433 logError(error),434 ]));435 return {error};436 }437 dispatch(batchActions([438 {type: AdminTypes.REMOVE_PLUGIN_SUCCESS, data: null},439 {type: AdminTypes.REMOVED_PLUGIN, data: pluginId},440 ]));441 return {data: true};442 };443}444export function enablePlugin(pluginId: string): ActionFunc {445 return async (dispatch, getState) => {446 dispatch({type: AdminTypes.ENABLE_PLUGIN_REQUEST, data: pluginId});447 try {448 await Client4.enablePlugin(pluginId);449 } catch (error) {450 forceLogoutIfNecessary(error, dispatch, getState);451 dispatch(batchActions([452 {type: AdminTypes.ENABLE_PLUGIN_FAILURE, error, data: pluginId},453 logError(error),454 ]));455 return {error};456 }457 dispatch(batchActions([458 {type: AdminTypes.ENABLE_PLUGIN_SUCCESS, data: null},459 {type: AdminTypes.ENABLED_PLUGIN, data: pluginId},460 ]));461 return {data: true};462 };463}464export function disablePlugin(pluginId: string): ActionFunc {465 return async (dispatch, getState) => {466 dispatch({type: AdminTypes.DISABLE_PLUGIN_REQUEST, data: pluginId});467 try {468 await Client4.disablePlugin(pluginId);469 } catch (error) {470 forceLogoutIfNecessary(error, dispatch, getState);471 dispatch(batchActions([472 {type: AdminTypes.DISABLE_PLUGIN_FAILURE, error, data: pluginId},473 logError(error),474 ]));475 return {error};476 }477 dispatch(batchActions([478 {type: AdminTypes.DISABLE_PLUGIN_SUCCESS, data: null},479 {type: AdminTypes.DISABLED_PLUGIN, data: pluginId},480 ]));481 return {data: true};482 };...
toolbar.js
Source:toolbar.js
1// used to identify pickers2var pickercounter=0;3/**4 * Create a toolbar5 *6 * @param string tbid ID of the element where to insert the toolbar7 * @param string edid ID of the editor textarea8 * @param array tb Associative array defining the buttons9 * @param bool allowblock Allow buttons creating multiline content10 * @author Andreas Gohr <andi@splitbrain.org>11 */12function initToolbar(tbid,edid,tb, allowblock){13 var $toolbar, $edit;14 if (typeof tbid == 'string') {15 $toolbar = jQuery('#' + tbid);16 } else {17 $toolbar = jQuery(tbid);18 }19 $edit = jQuery('#' + edid);20 if ($toolbar.length == 0 || $edit.length == 0 || $edit.attr('readOnly')) {21 return;22 }23 if (typeof allowblock === 'undefined') {24 allowblock = true;25 }26 //empty the toolbar area:27 $toolbar.html('');28 jQuery.each(tb, function (k, val) {29 if (!tb.hasOwnProperty(k) || (!allowblock && val.block === true)) {30 return;31 }32 var actionFunc, $btn;33 // create new button (jQuery object)34 $btn = jQuery(createToolButton(val.icon, val.title, val.key, val.id,35 val['class']));36 // type is a tb function -> assign it as onclick37 actionFunc = 'tb_'+val.type;38 if( jQuery.isFunction(window[actionFunc]) ){39 $btn.bind('click', bind(window[actionFunc],$btn,val,edid) );40 $toolbar.append($btn);41 return;42 }43 // type is a init function -> execute it44 actionFunc = 'addBtnAction'+val.type.charAt(0).toUpperCase()+val.type.substring(1);45 if( jQuery.isFunction(window[actionFunc]) ){46 var pickerid = window[actionFunc]($btn, val, edid);47 if(pickerid !== ''){48 $toolbar.append($btn);49 $btn.attr('aria-controls', pickerid);50 if (actionFunc === 'addBtnActionPicker') {51 $btn.attr('aria-haspopup', 'true');52 }53 }54 return;55 }56 alert('unknown toolbar type: '+val.type+' '+actionFunc);57 });58}59/**60 * Button action for format buttons61 *62 * @param DOMElement btn Button element to add the action to63 * @param array props Associative array of button properties64 * @param string edid ID of the editor textarea65 * @author Gabriel Birke <birke@d-scribe.de>66 * @author Andreas Gohr <andi@splitbrain.org>67 */68function tb_format(btn, props, edid) {69 var sample = props.sample || props.title;70 insertTags(edid,71 fixtxt(props.open),72 fixtxt(props.close),73 fixtxt(sample));74 pickerClose();75 return false;76}77/**78 * Button action for format buttons79 *80 * This works exactly as tb_format() except that, if multiple lines81 * are selected, each line will be formatted seperately82 *83 * @param DOMElement btn Button element to add the action to84 * @param array props Associative array of button properties85 * @param string edid ID of the editor textarea86 * @author Gabriel Birke <birke@d-scribe.de>87 * @author Andreas Gohr <andi@splitbrain.org>88 */89function tb_formatln(btn, props, edid) {90 var sample = props.sample || props.title,91 opts,92 selection = DWgetSelection(jQuery('#'+edid)[0]);93 sample = fixtxt(sample);94 props.open = fixtxt(props.open);95 props.close = fixtxt(props.close);96 // is something selected?97 if(selection.getLength()){98 sample = selection.getText();99 opts = {nosel: true};100 }else{101 opts = {102 startofs: props.open.length,103 endofs: props.close.length104 };105 }106 sample = sample.split("\n").join(props.close+"\n"+props.open);107 sample = props.open+sample+props.close;108 pasteText(selection,sample,opts);109 pickerClose();110 return false;111}112/**113 * Button action for insert buttons114 *115 * @param DOMElement btn Button element to add the action to116 * @param array props Associative array of button properties117 * @param string edid ID of the editor textarea118 * @author Gabriel Birke <birke@d-scribe.de>119 * @author Andreas Gohr <andi@splitbrain.org>120 */121function tb_insert(btn, props, edid) {122 insertAtCarret(edid,fixtxt(props.insert));123 pickerClose();124 return false;125}126/**127 * Button action for the media popup128 *129 * @param DOMElement btn Button element to add the action to130 * @param array props Associative array of button properties131 * @param string edid ID of the editor textarea132 * @author Andreas Gohr <andi@splitbrain.org>133 */134function tb_mediapopup(btn, props, edid) {135 window.open(136 DOKU_BASE+props.url+encodeURIComponent(NS)+'&edid='+encodeURIComponent(edid),137 props.name,138 props.options);139 return false;140}141/**142 * Button action for automatic headlines143 *144 * Insert a new headline based on the current section level145 *146 * @param DOMElement btn Button element to add the action to147 * @param array props Associative array of button properties148 * @param string edid ID of the editor textarea149 * @author Andreas Gohr <andi@splitbrain.org>150 */151function tb_autohead(btn, props, edid){152 var lvl = currentHeadlineLevel(edid),153 tags;154 // determine new level155 lvl += props.mod;156 if(lvl < 1) lvl = 1;157 if(lvl > 5) lvl = 5;158 tags = (new Array(8 - lvl)).join('=');159 insertTags(edid, tags+' ', ' '+tags+"\n", props.text);160 pickerClose();161 return false;162}163/**164 * Add button action for picker buttons and create picker element165 *166 * @param jQuery btn Button element to add the action to167 * @param array props Associative array of button properties168 * @param string edid ID of the editor textarea169 * @return boolean If button should be appended170 * @author Gabriel Birke <birke@d-scribe.de>171 */172function addBtnActionPicker($btn, props, edid) {173 var pickerid = 'picker'+(pickercounter++);174 var picker = createPicker(pickerid, props, edid);175 jQuery(picker).attr('aria-hidden', 'true');176 $btn.click(177 function(e) {178 pickerToggle(pickerid,$btn);179 e.preventDefault();180 return '';181 }182 );183 return pickerid;184}185/**186 * Add button action for the link wizard button187 *188 * @param DOMElement btn Button element to add the action to189 * @param array props Associative array of button properties190 * @param string edid ID of the editor textarea191 * @return boolean If button should be appended192 * @author Andreas Gohr <gohr@cosmocode.de>193 */194function addBtnActionLinkwiz($btn, props, edid) {195 dw_linkwiz.init(jQuery('#'+edid));196 jQuery($btn).click(function(e){197 dw_linkwiz.val = props;198 dw_linkwiz.toggle();199 e.preventDefault();200 return '';201 });202 return 'link__wiz';203}204/**205 * Show/Hide a previously created picker window206 *207 * @author Andreas Gohr <andi@splitbrain.org>208 */209function pickerToggle(pickerid,$btn){210 var $picker = jQuery('#' + pickerid),211 pos = $btn.offset();212 if ($picker.hasClass('a11y')) {213 $picker.removeClass('a11y').attr('aria-hidden', 'false');214 } else {215 $picker.addClass('a11y').attr('aria-hidden', 'true');216 }217 $picker.offset({left: pos.left+3, top: pos.top+$btn[0].offsetHeight+3});218}219/**220 * Close all open pickers221 *222 * @author Andreas Gohr <andi@splitbrain.org>223 */224function pickerClose(){225 jQuery('.picker').addClass('a11y');226}227/**228 * Replaces \n with linebreaks229 */230function fixtxt(str){231 return str.replace(/\\n/g,"\n");232}233jQuery(function () {234 initToolbar('tool__bar','wiki__text',toolbar);235 jQuery('#tool__bar').attr('role', 'toolbar');...
index.js
Source:index.js
1import React, { Component } from 'react';2import { connect } from 'react-redux'3import { CSSTransition } from 'react-transition-group'4import { actionFunc } from './store';5import { actionFunc as loginActionFunc } from '../../pages/login/store'6import {Link} from 'react-router-dom';7import {8 HeaderWrapper, Logo,9 Nav, NavItem,10 NavSearch, Addition,11 Button, SearchWrapper,12 SearchInfo, SearchInfoTitle,13 SearchInfoSwitch, SearchInfoItem,14 SearchInfoList15} from './style'16class Header extends Component {17 // å½æ°ç»ä»¶18 getListArea = () => {19 const { 20 focused, page, searchItemList,21 handleMouseEnter,handleMouseLeave,22 handleSearchChange,mouseIn,totalPage23 } = this.props;24 // è¿é使ç¨immutableçtoJSæ¹æ³ä¾æ§ä¼æ¥éï¼æ示toJS is not a function25 // const newList = searchItemList.toJS(); // æimmutableç±»åçæ°æ®åææ®éjs对象26 const newList = JSON.parse(JSON.stringify(searchItemList)); // 临æ¶è¢«è¿«ä½¿ç¨è¿ç§æ¹å¼27 const pageList = [];28 if(newList.length){29 for (let i = page * 5; i < (page + 1) * 5 ; i++) {30 pageList.push(31 <SearchInfoItem key={newList[i]}>{newList[i]}</SearchInfoItem>32 )33 }34 }35 if (focused || mouseIn) {36 return (37 <SearchInfo 38 onMouseEnter={handleMouseEnter}39 onMouseLeave={handleMouseLeave}40 >41 <SearchInfoTitle>42 çé¨æç´¢43 <SearchInfoSwitch44 onClick={()=>{handleSearchChange(page,totalPage,this.spinIcon)}}45 >46 <i ref={(icon)=>{this.spinIcon = icon}} className="iconfont spin"></i>47 æ¢ä¸æ¹48 </SearchInfoSwitch>49 </SearchInfoTitle>50 <SearchInfoList>51 {pageList}52 </SearchInfoList>53 </SearchInfo>54 )55 } else {56 return null57 }58 }59 render() {60 const { focused, handleInputFocus, handleInputBlur,searchItemList,login } = this.props61 return (62 <HeaderWrapper>63 <Link to='/'>64 <Logo></Logo>65 </Link>66 <Nav>67 <NavItem className="left active">é¦é¡µ</NavItem>68 <NavItem className="left">ä¸è½½App</NavItem>69 {70 login ? 71 <NavItem onClick={this.props.logout} className="right">éåº</NavItem> : 72 <Link to='/login'>73 <NavItem className="right">ç»é</NavItem>74 </Link>75 }76 <NavItem className="right">77 <i className="iconfont"></i>78 </NavItem>79 <SearchWrapper>80 <CSSTransition81 in={focused}82 timeout={200}83 classNames='slide'84 >85 <NavSearch86 className={focused ? 'focused' : ''}87 onFocus={()=>handleInputFocus(searchItemList)}88 onBlur={handleInputBlur}89 ></NavSearch>90 </CSSTransition>91 <i className={focused ? 'focused iconfont zoom' : 'iconfont zoom'}></i>92 {this.getListArea()}93 </SearchWrapper>94 <Addition>95 <Link to="/write">96 <Button className="writing"><i className="iconfont"></i>åæç« </Button>97 </Link>98 <Button className="reg">注å</Button>99 </Addition>100 </Nav>101 </HeaderWrapper>102 )103 }104}105const mapStateToProps = (state) => {106 return {107 focused: state.getIn(['header', 'focused']),108 mouseIn:state.getIn(['header','mouseIn']),109 searchItemList: state.getIn(['header', 'searchItemList']),110 page: state.getIn(['header', 'page']),111 totalPage: state.getIn(['header', 'totalPage']),112 login:state.getIn(['login','login'])113 }114}115const mapDispatchToProps = (dispatch) => {116 return {117 handleInputBlur() {118 dispatch(actionFunc.searchBlur())119 },120 handleInputFocus(list) {121 list.size === 0 && dispatch(actionFunc.getSearchItem())122 dispatch(actionFunc.searchFocus())123 },124 handleMouseEnter() {125 dispatch(actionFunc.mouseEnter())126 },127 handleMouseLeave() {128 dispatch(actionFunc.mouseLeave())129 },130 logout(){131 dispatch(loginActionFunc.logout())132 },133 handleSearchChange(page,totalPage,spin){134 let originAngle = spin.style.transform.replace(/[^0-9]/ig,'');135 spin.style.transform = `rotate(${originAngle+360}deg)`;136 if(page < totalPage){137 dispatch(actionFunc.searchChange(++page))138 }else{139 dispatch(actionFunc.searchChange(0))140 }141 }142 }143}...
CommonMiddleware.test.js
Source:CommonMiddleware.test.js
...20 global.__SERVER__ = false; // eslint-disable-line21 });22 it('Check FORM_ERROR case ', () => {23 const action = { type: AnalyticsActionTypes.FORM_ERROR, errorDetails: [{ errorDescription: 'Enter phone number' }] };24 actionFunc(action);25 });26 it('Check ANALYTICS_OPEN_MODAL case ', () => {27 const action = { type: AnalyticsActionTypes.ANALYTICS_OPEN_MODAL, name: 'store - modal' };28 actionFunc(action);29 });30 it('Check NAVIGATION_CLICK with reload case ', () => {31 const action = { type: AnalyticsActionTypes.NAVIGATION_CLICK, navClick: { linkName: 'coupons', isReload: false } };32 actionFunc(action);33 });34 it('Check NAVIGATION_CLICK without reload case ', () => {35 const action = { type: AnalyticsActionTypes.NAVIGATION_CLICK, navClick: { linkName: 'coupons', isReload: true } };36 actionFunc(action);37 });38 it('Check ANALYTICS_CHANGE_STORE case ', () => {39 const action = { type: AnalyticsActionTypes.ANALYTICS_CHANGE_STORE };40 actionFunc(action);41 });42 it('Check ANALYTICS_SELECT_STORE case ', () => {43 const action = { type: AnalyticsActionTypes.ANALYTICS_SELECT_STORE };44 actionFunc(action);45 });46 it('Check GET_STORE_BY_STORE_ID_SUCCESS case ', () => {47 const action = { type: OrderActionTypes.GET_STORE_BY_STORE_ID_SUCCESS };48 actionFunc(action);49 });50 it('Check GET_STORES_GET_REQUEST case ', () => {51 const action = { type: OrderActionTypes.GET_STORES_GET_REQUEST, payload: { address: 'dallas' } };52 actionFunc(action);53 });54 it('Check ANALYTICS_STORE_SEARCH case ', () => {55 const action = { type: AnalyticsActionTypes.ANALYTICS_STORE_SEARCH, payload: { address: '75024' } };56 actionFunc(action);57 });58 it('Check GET_STORES_GET_REQUEST without payload ', () => {59 const action = { type: OrderActionTypes.GET_STORES_GET_REQUEST, payload: {} };60 actionFunc(action);61 });62 it('Check with exception ', () => {63 const action = { type: AnalyticsActionTypes.FORM_ERROR };64 console.log(actionFunc(action));65 });66 it('Move items to list ', () => {67 const action = { type: MoveListActionTypes.MOVE_SITE_ITEMS_EVENT_ANALYTICS };68 console.log(actionFunc(action));69 });70 it('CREATE_SITE_LIST_CLICK_EVENT case ', () => {71 const action = { type: MoveListActionTypes.CREATE_SITE_LIST_CLICK_EVENT };72 console.log(actionFunc(action));73 });74 it('Add to list analytics ', () => {75 const action = { type: MoveListActionTypes.ADD_SITE_TO_LIST_EVENT, analyticsData: {} };76 console.log(actionFunc(action));77 });78 it('Add to list error analytics ', () => {79 const action = { type: MoveListActionTypes.ADD_SITE_TO_LIST_ERROR_EVENT, errorData: {} };80 console.log(actionFunc(action));81 });82 it('Create list error analytics ', () => {83 const action = { type: MoveListActionTypes.SITE_MOVETOLIST_ERROR_EVENT, errorData: {} };84 actionFunc(action);85 });86 it('Check ANALYTICS_VIDEO_LOADED case ', () => {87 const test = sinon.stub(Cookies, 'load', () => ('coupons'));88 const action = { type: AnalyticsActionTypes.ANALYTICS_VIDEO_LOADED, payload: { eventName: 'dallas', video: '', product: '' } };89 actionFunc(action);90 test.restore();91 });92 it('Check __SERVER__ as false ', () => {93 global.__SERVER__ = true; // eslint-disable-line94 const action = { type: AnalyticsActionTypes.FORM_ERROR };95 console.log(actionFunc(action));96 });97 after(() => {98 storeObj = undefined;99 nextfunc = undefined;100 nextObj = undefined;101 actionFunc = undefined;102 });...
CheckpointHolder.js
Source:CheckpointHolder.js
...69 addActionFunc(actionFunc){70 this.actionFuncs.push(actionFunc)71 //if func is added after completion, run72 if(this.completed){73 actionFunc()74 }75 }76 runActionFuncs(){77 for(const actionFunc of this.actionFuncs){78 actionFunc()79 }80 }...
message_window.js
Source:message_window.js
1function __message_window_actions_init(actionFunc, messageComponent,2 ajaxComponent, frequency, closeDelay) {3 var _startMessage = function() {4 var w = Object.isString(messageComponent) ? $Actions[messageComponent]5 : messageComponent;6 if (w.isVisible()) {7 w.refreshContentRef();8 } else {9 (Object.isString(ajaxComponent) ? $Actions[ajaxComponent] : ajaxComponent)();10 }11 if (closeDelay > 0) {12 (function() { w.close(); }).delay(closeDelay);13 }14 };15 16 actionFunc.startMessage = function() {17 if (frequency == 0) {18 _startMessage();19 } else {20 actionFunc.pe = new PeriodicalExecuter(function() {21 _startMessage();22 }, frequency);23 }24 };25 26 actionFunc.stopMessage = function() {27 if (actionFunc.pe) {28 actionFunc.pe.stop();29 actionFunc.pe = null;30 }31 };32 33 actionFunc.ajaxRequestCallback = function(json) {34 if (!json['showMessageNotification']) return;35 var w = Object.isString(messageComponent) ? $Actions[messageComponent]36 : messageComponent;37 var t = document.viewport.getHeight() - w.options.height - 20;38 var l = document.viewport.getWidth() - w.options.width - 20;39 w.setOptions({ theme: 'popup', top: t, left : l });40 w();41 };...
getit.task.js
Source:getit.task.js
...24 var pattern = registration[name]['pattern'],25 actionFunc = registration[name]['action']26 failFast = registration[name]['failFast'];27 if(pattern.test(href) && typeof actionFunc == 'function'){28 var success = actionFunc(api);29 if(failFast && !success){30 task.stop();31 }32 return;33 }34 }35 log('This page is not supported.');36 task.stop();37}38function register(name, pattern, action, failFast){39 if(typeof action == 'string'){40 var actionFunc = function(api){41 return api.click(action);42 };...
TypingDelay.js
Source:TypingDelay.js
...20 if (this.timeoutHandle != null) {21 clearTimeout(this.timeoutHandle);22 }23 this.timeoutHandle = setTimeout(function(callback) {24 actionFunc();25 }, this.delay);26 };27};...
Using AI Code Generation
1var wd = require('wd'),2 assert = require('assert'),3 serverConfig = {4 };5var desired = {6};7var driver = wd.promiseChainRemote(serverConfig);8 .init(desired)9 .then(function () {10 .click()11 .click()12 .click()13 .click();14 })15 .then(function () {16 .text()17 .then(function (text) {18 assert.equal(text, '4');19 });20 })21 .fin(function () {22 return driver.quit();23 })24 .done();25at io.appium.android.bootstrap.handler.Click.handler(Click.java:34)26at io.appium.android.bootstrap.handler.Click.handler(Click.java:29)27at io.appium.android.bootstrap.handler.Click.execute(Click.java:54)28at io.appium.android.bootstrap.AndroidCommandExecutor.execute(AndroidCommandExecutor.java:32)29at io.appium.android.bootstrap.SocketServer.runCommand(SocketServer.java:164)30at io.appium.android.bootstrap.SocketServer.handleClientData(SocketServer.java:147)31at io.appium.android.bootstrap.SocketServer.listenForever(SocketServer.java:106)32at io.appium.android.bootstrap.Bootstrap.main(Bootstrap.java:32)33at dalvik.system.NativeStart.main(Native Method)
Using AI Code Generation
1var wd = require('wd');2var assert = require('assert');3var desiredCaps = {4};5var driver = wd.promiseChainRemote('localhost', 4723);6driver.init(desiredCaps).then(function () {7 return driver.elementByClassName('android.widget.TextView').text();8}).then(function (text) {9 assert.equal(text, 'API Demos');10 return driver.elementByAndroidUIAutomator('new UiSelector().text("Preference")').click();11}).then(function () {12 return driver.elementByAndroidUIAutomator('new UiSelector().text("3. Preference dependencies")').click();13}).then(function () {14 return driver.elementByAndroidUIAutomator('new UiSelector().text("WiFi settings")').click();15}).then(function () {16 return driver.elementByAndroidUIAutomator('new UiSelector().text("WiFi")').click();17}).then(function () {18 return driver.elementByAndroidUIAutomator('new UiSelector().text("ON")').click();19}).then(function () {20 return driver.elementByAndroidUIAutomator('new UiSelector().text("ON")').click();21}).then(function () {22 return driver.elementByAndroidUIAutomator('new UiSelector().text("OFF")').click();23}).then(function () {24 return driver.elementByAndroidUIAutomator('new UiSelector().text("OFF")').click();25}).then(function () {26 return driver.elementByAndroidUIAutomator('new UiSelector().text("ON")').click();27}).then(function () {28 return driver.elementByAndroidUIAutomator('new UiSelector().text("OK")').click();29}).then(function () {30 return driver.elementByAndroidUIAutomator('new UiSelector().text("ON")').click();31}).then(function () {32 return driver.elementByAndroidUIAutomator('new UiSelector().text("OK")').click();33}).then(function () {34 return driver.elementByAndroidUIAutomator('new UiSelector().text("ON")').click
Using AI Code Generation
1var wd = require('wd');2var assert = require('assert');3var driver = wd.remote("localhost", 4723);4driver.init({platformName: "Android", deviceName: "Android Emulator", app: "path/to/my.apk"}, function() {5 driver.elementById("myId", function(err, el) {6 el.actionFunc("tap", function(err) {7 assert.ok(!err);8 });9 });10});11var wd = require('wd');12var assert = require('assert');13var driver = wd.remote("localhost", 4723);14driver.init({platformName: "Android", deviceName: "Android Emulator", app: "path/to/my.apk"}, function() {15 driver.elementById("myId", function(err, el) {16 el.actionFunc("tap", function(err) {17 assert.ok(!err);18 });19 });20});21var wd = require('wd');22var assert = require('assert');23var driver = wd.remote("localhost", 4723);24driver.init({platformName: "Android", deviceName: "Android Emulator", app: "path/to/my.apk"}, function() {25 driver.elementById("myId", function(err, el) {26 el.actionFunc("tap", function(err) {27 assert.ok(!err);28 });29 });30});31var wd = require('wd');32var assert = require('assert');33var driver = wd.remote("localhost", 4723);34driver.init({platformName: "Android", deviceName: "Android Emulator", app: "path/to/my.apk"}, function() {35 driver.elementById("myId", function(err, el) {36 el.actionFunc("tap", function(err) {37 assert.ok(!err);38 });39 });40});
Using AI Code Generation
1var driver = new AndroidDriver();2driver.actionFunc();3var AndroidDriver = function() {4 this.actionFunc = function() {5 console.log('actionFunc called');6 };7}8var AndroidDriver = function() {9 this.actionFunc = function() {10 console.log('actionFunc called');11 };12}13var driver = new AndroidDriver();14driver.actionFunc();15var AndroidDriver = require('appium').AndroidDriver;16var driver = new AndroidDriver();17driver.actionFunc();18var AndroidDriver = require('appium').AndroidDriver;19var driver = new AndroidDriver();20driver.actionFunc();21var AndroidDriver = require('appium').AndroidDriver;22var driver = new AndroidDriver();23driver.actionFunc();24var AndroidDriver = require('appium').AndroidDriver;25var driver = new AndroidDriver();26driver.actionFunc();27var AndroidDriver = require('appium').AndroidDriver;28var driver = new AndroidDriver();29driver.actionFunc();30var AndroidDriver = require('appium').AndroidDriver;31var driver = new AndroidDriver();32driver.actionFunc();33var AndroidDriver = require('appium').AndroidDriver;34var driver = new AndroidDriver();
Using AI Code Generation
1driver.actionFunc();2driver.actionFunc();3driver.android.actionFunc();4driver.ios.actionFunc();5driver.actionFunc();6at Context. (C:\Users\user\Documents\test\test.js:8:8)7at callFn (C:\Users\user\AppData\Roaming8at Test.Runnable.run (C:\Users\user\AppData\Roaming9at Runner.runTest (C:\Users\user\AppData\Roaming10at next (C:\Users\user\AppData\Roaming11at next (C:\Users\user\AppData\Roaming12at Immediate._onImmediate (C:\Users\user\AppData\Roaming
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!