How to use addScriptTag method in Puppeteer

Best JavaScript code snippet using puppeteer

BattleRoom.js

Source:BattleRoom.js Github

copy

Full Screen

...1125 var optionKey;1126 var user;1127 var userName;11281129 //this.scriptManager.addScriptTag(key, val);1130 this.extraScriptTags[key.toLowerCase()] = (''+val).toLowerCase();11311132 if( this.gotGame && key.toLowerCase().match( /game\/modoptions\// ) )1133 {1134 optionKey = key.toLowerCase().replace( 'game/modoptions/', '' );1135 this.modOptions.updateModOption({key: optionKey, value: val} );1136 }1137 if( this.gotMap && key.toLowerCase().match( /game\/mapoptions\// ) )1138 {1139 if( this.battleMap.modOptions )1140 {1141 optionKey = key.toLowerCase().replace( 'game/mapoptions/', '' );1142 this.battleMap.modOptions.updateModOption({key: optionKey, value: val} );1143 }1144 else1145 {1146 /*1147 uncommon scenario: map changes, setting map and gotmap, modoptions are loading,1148 but before they are finished loading, lobby calls SETSCRIPTTAGS game/mapoptions and arrive here1149 where this.battleMap.modOptions is null.1150 1151 Can try setting this.gotmap only after this.battleMap.modOptions is loaded, but it is not exact.1152 Can try setting other variable after modoption is loaded, but it would be no different than current if block1153 */1154 }1155 }1156 1157 userName = key.match('game/players/(.*)/skill')1158 if( userName !== null )1159 {1160 userName = userName[1];1161 1162 user = this.getPlayerNameByLowerCase(userName)1163 if( user !== null )1164 {1165 user.skill = val;1166 }1167 }1168 1169 if( key.toLowerCase() === 'game/hosttype' && val === 'SPADS' )1170 {1171 this.spads = true;1172 }1173 },1174 1175 getPlayerNameByLowerCase: function(userName)1176 {1177 var user;1178 var curUserName;1179 1180 user = this.players[userName]1181 if( user )1182 {1183 return user;1184 }1185 for( curUserName in this.players )1186 {1187 if( curUserName.toLowerCase() === userName )1188 {1189 return this.players[curUserName]1190 }1191 }1192 return null;1193 },11941195 generateScript: function()1196 {1197 var scriptManager, startRect, x1, y1, x2, y2, name, aiNum,1198 teams, teamLeader, alliances, alliance,1199 numUsers, numPlayers, allianceNum, alliance,1200 teamNum, team, scriptCountry1201 ;1202 1203 if( this.scriptMissionScript !== null && typeof this.scriptMissionScript !== 'undefined' && this.scriptMissionScript !== '' )1204 {1205 return this.scriptMissionScript;1206 }1207 1208 1209 teams = {};1210 alliances = {};1211 numUsers = 0;1212 numPlayers = 0;12131214 scriptManager = new ScriptManager({});12151216 scriptManager.addScriptTag( "game/HostIP", this.hosting ? '127.0.0.1' : this.ip );1217 scriptManager.addScriptTag( "game/HostPort", this.hostPort );1218 scriptManager.addScriptTag( "game/IsHost", this.hosting ? '1' : '0' );1219 scriptManager.addScriptTag( "game/MyPlayerName", this.nick );1220 if( this.scriptPassword !== '')1221 {1222 scriptManager.addScriptTag( "game/MyPasswd", this.scriptPassword );1223 }1224 if( !this.hosting )1225 {1226 return scriptManager.getScript();1227 }1228 1229 scriptManager.addScriptTag( "game/GameType", this.game );1230 scriptManager.addScriptTag( "game/MapName", this.map );1231 scriptManager.addScriptTag( "game/SourcePort", this.sourcePort );1232 scriptManager.addScriptTag( "game/modhash", this.gameHash );1233 scriptManager.addScriptTag( "game/maphash", this.mapHash );1234 1235 scriptManager.addScriptTag( "game/nohelperais", 0 ); //fixme1236 //scriptManager.addScriptTag( "game/onlylocal", this.local ? 1 : 0 );1237 scriptManager.addScriptTag( "game/startPosType", 2 ); //fixme1238 1239 1240 12411242 for( key in this.extraScriptTags )1243 {1244 val = this.extraScriptTags[key]1245 scriptManager.addScriptTag(key, val);1246 }1247 1248 for( name in this.players )1249 {1250 numUsers += 1;1251 user = this.players[name];1252 scriptCountry = user.country === 'unknown' ? '' : user.country;1253 if( name in this.bots )1254 {1255 aiNum = this.bots[name]1256 scriptManager.addScriptTag( 'game/AI' + aiNum + '/Team', user.teamNumber );1257 scriptManager.addScriptTag( 'game/AI' + aiNum + '/ShortName', user.ai_dll );1258 scriptManager.addScriptTag( 'game/AI' + aiNum + '/Name', user.name );1259 //scriptManager.addScriptTag( 'AI' + aiNum + '/Version', '' );1260 scriptManager.addScriptTag( 'game/AI' + aiNum + '/IsFromDemo', 0 );1261 scriptManager.addScriptTag( 'game/AI' + aiNum + '/Spectator', user.isSpectator ? 1 : 0 );1262 scriptManager.addScriptTag( 'game/AI' + aiNum + '/host', this.players[user.owner].playerNum );1263 scriptManager.addScriptTag( 'game/AI' + aiNum + '/CountryCode', scriptCountry );1264 1265 teamLeader = this.players[user.owner].playerNum;1266 }1267 else1268 {1269 numPlayers += 1;1270 1271 if( !user.isSpectator )1272 {1273 scriptManager.addScriptTag( 'game/PLAYER' + user.playerNum + '/Team', user.teamNumber );1274 }1275 scriptManager.addScriptTag( 'game/PLAYER' + user.playerNum + '/Name', user.name );1276 scriptManager.addScriptTag( 'game/PLAYER' + user.playerNum + '/Spectator', user.isSpectator ? 1 : 0 );1277 scriptManager.addScriptTag( 'game/PLAYER' + user.playerNum + '/Rank', user.rank );1278 scriptManager.addScriptTag( 'game/PLAYER' + user.playerNum + '/CountryCode', scriptCountry );1279 scriptManager.addScriptTag( 'game/PLAYER' + user.playerNum + '/isfromdemo', 0 );1280 //lobbyID? lobbyrank?1281 if( user.scriptPassword !== '' )1282 {1283 scriptManager.addScriptTag( 'game/PLAYER' + user.playerNum + '/Password', user.scriptPassword );1284 }1285 1286 teamLeader = user.playerNum;1287 }1288 teams[user.teamNumber] = {1289 allyTeam: user.allyNumber,1290 teamleader: teamLeader,1291 side: user.side,1292 color: (user.r/256) + ' ' + (user.g/256) + ' ' + (user.b/256)1293 }1294 alliances[user.allyNumber] = {1295 1296 }1297 }1298 scriptManager.addScriptTag( "game/numPlayers", numPlayers ); //fixme1299 scriptManager.addScriptTag( "game/numUsers", numUsers ); //fixme1300 1301 for( teamNum in teams )1302 {1303 team = teams[teamNum]1304 scriptManager.addScriptTag( 'game/TEAM' + teamNum + '/allyTeam', team.allyTeam );1305 scriptManager.addScriptTag( 'game/TEAM' + teamNum + '/teamleader', team.teamleader );1306 scriptManager.addScriptTag( 'game/TEAM' + teamNum + '/side', this.factions[ team.side ] );1307 scriptManager.addScriptTag( 'game/TEAM' + teamNum + '/rgbcolor', team.color );1308 scriptManager.addScriptTag( 'game/TEAM' + teamNum + '/handicap', '' );1309 }1310 1311 1312 for( allianceNum in alliances )1313 {1314 alliance = alliances[allianceNum];1315 scriptManager.addScriptTag( 'game/ALLYTEAM' + allianceNum + '/NumAllies', 0 );1316 if( allianceNum in this.startRects )1317 {1318 startRect = this.startRects[allianceNum];1319 x1 = startRect[0];1320 y1 = startRect[1];1321 x2 = startRect[2];1322 y2 = startRect[3];1323 scriptManager.addScriptTag( 'game/ALLYTEAM' + allianceNum + '/StartRectLeft', x1/200 );1324 scriptManager.addScriptTag( 'game/ALLYTEAM' + allianceNum + '/StartRectTop', y1/200 );1325 scriptManager.addScriptTag( 'game/ALLYTEAM' + allianceNum + '/StartRectRight', x2/200 );1326 scriptManager.addScriptTag( 'game/ALLYTEAM' + allianceNum + '/StartRectBottom', y2/200 );1327 }1328 }1329 1330 //console.log( scriptManager.getScript() );1331 return scriptManager.getScript();13321333 }, //generateScript13341335 getEmptyTeam: function(userName)1336 {1337 var user, teams, emptyTeam, name, team, name;1338 teams = {};1339 for( name in this.players )1340 { ...

Full Screen

Full Screen

MadCapLiveHelpUtilities.js

Source:MadCapLiveHelpUtilities.js Github

copy

Full Screen

1/// <reference path="MadCapUtilities.js" />2// {{MadCap}} //////////////////////////////////////////////////////////////////3// Copyright: MadCap Software, Inc - www.madcapsoftware.com ////////////////////4////////////////////////////////////////////////////////////////////////////////5// <version>4.2.0.0</version>6////////////////////////////////////////////////////////////////////////////////7var gEmptyIcon = null;8var gHalfFullIcon = null;9var gFullIcon = null;10var gIconWidth = 16;11var gTopicRatingIconsInit = false;12function TopicRatingIconsInit()13{14 if ( gTopicRatingIconsInit )15 {16 return;17 }18 19 //20 21 var value = CMCFlareStylesheet.LookupValue( "ToolbarItem", "TopicRatings", "EmptyIcon", null );22 if ( value == null )23 {24 gEmptyIcon = MCGlobals.RootFolder + MCGlobals.SkinTemplateFolder + "Images/Rating0.gif";25 gIconWidth = 16;26 }27 else28 {29 value = FMCStripCssUrl( value );30 value = decodeURIComponent( value );31 value = escape( value );32 gEmptyIcon = FMCGetSkinFolderAbsolute() + value;33 }34 value = CMCFlareStylesheet.LookupValue( "ToolbarItem", "TopicRatings", "HalfFullIcon", null );35 if ( value == null )36 {37 gHalfFullIcon = MCGlobals.RootFolder + MCGlobals.SkinTemplateFolder + "Images/RatingGold50.gif";38 }39 else40 {41 value = FMCStripCssUrl( value );42 value = decodeURIComponent( value );43 value = escape( value );44 gHalfFullIcon = FMCGetSkinFolderAbsolute() + value;45 }46 value = CMCFlareStylesheet.LookupValue( "ToolbarItem", "TopicRatings", "FullIcon", null );47 if ( value == null )48 {49 gFullIcon = MCGlobals.RootFolder + MCGlobals.SkinTemplateFolder + "Images/RatingGold100.gif";50 }51 else52 {53 value = FMCStripCssUrl( value );54 value = decodeURIComponent( value );55 value = escape( value );56 gFullIcon = FMCGetSkinFolderAbsolute() + value;57 }58 59 //60 61 gTopicRatingIconsInit = true;62}63function FMCRatingIconsCalculateRating( e, iconContainer )64{65 if ( !e ) { e = window.event; }66 var x = FMCGetMouseXRelativeTo( window, e, iconContainer );67 var imgNodes = iconContainer.getElementsByTagName( "img" );68 var numImgNodes = imgNodes.length;69 var iconWidth = gIconWidth;70 var numIcons = Math.ceil( x / iconWidth );71 var rating = numIcons * 100 / numImgNodes;72 73 return rating;74}75function FMCRatingIconsOnmousemove( e, iconContainer )76{77 TopicRatingIconsInit();78 79 //80 81 if ( !e ) { e = window.event; }82 var rating = FMCRatingIconsCalculateRating( e, iconContainer );83 84 FMCDrawRatingIcons( rating, iconContainer );85}86function FMCClearRatingIcons( rating, iconContainer )87{88 FMCDrawRatingIcons( rating, iconContainer );89}90function FMCDrawRatingIcons( rating, iconContainer )91{92 TopicRatingIconsInit();93 94 //95 var imgNodes = iconContainer.getElementsByTagName( "img" );96 var numImgNodes = imgNodes.length;97 var numIcons = Math.ceil( rating * numImgNodes / 100 );98 for ( var i = 0; i < numImgNodes; i++ )99 {100 var node = imgNodes[i];101 102 if ( i <= numIcons - 1 )103 {104 node.src = gFullIcon;105 }106 else107 {108 node.src = gEmptyIcon;109 }110 }111}112//113// Class CMCLiveHelpServiceClient114//115var gLiveHelpServerUrl = null; // Set by compiler116gLiveHelpServerUrl = FMCGetFeedbackServerUrl( gLiveHelpServerUrl );117function FMCGetFeedbackServerUrl( serverUrl )118{119 if ( serverUrl == null )120 {121 return null;122 }123 124 var url = serverUrl;125 var pos = url.indexOf( ":" );126 var urlProtocol = url.substring( 0, pos + 1 );127 var docProtocol = document.location.protocol;128 129 if ( window.name != "bridge" )130 {131 if ( urlProtocol.Equals( "https:", false ) && docProtocol.Equals( "http:", false ) )132 {133 url = url.substring( pos + 1 );134 url = "http:" + url;135 }136 }137 138 if ( url.Contains( "madcapsoftware.com", false ) )139 {140 url = url + "LiveHelp/Service.LiveHelp/LiveHelpService.asmx/";141 }142 else143 {144 url = url + "Service.FeedbackExplorer/FeedbackJsonService.asmx/";145 }146 147 return url;148}149var gServiceClient = new function()150{151 // Private member variables and functions152 153 var mCallbackMap = new CMCDictionary();154 155 var mLiveHelpScriptIndex = 0;156 var mLiveHelpService = gLiveHelpServerUrl;157 var mGetAverageRatingOnCompleteFunc = null;158 var mGetAverageRatingOnCompleteArgs = null;159 var mGetRecentCommentsOnCompleteFunc = null;160 var mGetRecentCommentsOnCompleteArgs = null;161 var mGetAnonymousEnabledOnCompleteFunc = null;162 var mGetAnonymousEnabledOnCompleteArgs = null;163 var mStartActivateUserOnCompleteFunc = null;164 var mStartActivateUserOnCompleteArgs = null;165 var mCheckUserStatusOnCompleteFunc = null;166 var mCheckUserStatusOnCompleteArgs = null;167 var mGetSynonymsFileOnCompleteFunc = null;168 var mGetSynonymsFileOnCompleteArgs = null;169 170 var mVersion = -1;171 172 function AddScriptTag( webMethodName, onCompleteFunc, nameValuePairs )173 {174 var script = document.createElement( "script" );175 var head = document.getElementsByTagName( "head" )[0];176 var scriptID = "MCLiveHelpScript_" + mLiveHelpScriptIndex++;177 var src = mLiveHelpService + webMethodName + "?";178 179 src += "OnComplete=" + onCompleteFunc + "&ScriptID=" + scriptID + "&UniqueID=" + (new Date()).getTime();180 181 if ( nameValuePairs != null )182 {183 for ( var i = 0, length = nameValuePairs.length; i < length; i++ )184 {185 var pair = nameValuePairs[i];186 var name = pair[0];187 var value = encodeURIComponent( pair[1] );188 189 src += ("&" + name + "=" + value);190 }191 }192 if ( document.body.currentStyle != null )193 {194 var ieUrlLimit = 2083;195 196 if ( src.length > ieUrlLimit )197 {198 var diff = src.length - ieUrlLimit;199 var data = { ExceedAmount: diff };200 var ex = new CMCFeedbackException( -1, "URL limit exceeded.", data );201 202 throw ex;203 }204 }205 206 var qsLimit = 2048;207 var qsPos = src.indexOf( "?" )208 var qsChars = src.substring( qsPos + 1 ).length;209 210 if ( qsChars > qsLimit )211 {212 var diff = qsChars - qsLimit;213 var data = { ExceedAmount: diff };214 var ex = new CMCFeedbackException( -1, "Query string limit exceeded.", data );215 216 throw ex;217 }218 script.id = scriptID;219 script.setAttribute( "type", "text/javascript" );220 script.setAttribute( "src", src );221 head.appendChild( script );222 223 return scriptID;224 }225 // Public member functions226 this.RemoveScriptTag = function( scriptID )227 {228 function RemoveScriptTag2()229 {230 var script = document.getElementById( scriptID );231 script.parentNode.removeChild( script );232 }233 234 // IE bug: Need this setTimeout() or else IE will crash. This happens when removing the <script> tag after re-navigating to the same page.235 236 window.setTimeout( RemoveScriptTag2, 10 );237 }238 239 this.LogTopic = function( topicID )240 {241 AddScriptTag( "LogTopic", "gServiceClient.LogTopicOnComplete", [ [ "TopicID", topicID] ] );242 }243 244 this.LogTopicOnComplete = function( scriptID )245 {246 this.RemoveScriptTag( scriptID );247 }248 249 this.LogTopic2 = function( topicID, cshID, onCompleteFunc, onCompleteArgs, thisObj )250 {251 this.LogTopic2OnComplete = function( scriptID )252 {253 if ( onCompleteFunc != null )254 {255 if ( thisObj != null )256 {257 onCompleteFunc.call( thisObj, onCompleteArgs );258 }259 else260 {261 onCompleteFunc( onCompleteArgs );262 }263 }264 265 //266 267 this.RemoveScriptTag( scriptID );268 269 this.LogTopic2OnComplete = null;270 }271 AddScriptTag( "LogTopic2", "gServiceClient.LogTopic2OnComplete", [ [ "TopicID", topicID],272 [ "CSHID", cshID ] ] );273 }274 275 this.LogSearch = function( projectID, userGuid, resultCount, language, query )276 {277 AddScriptTag( "LogSearch", "gServiceClient.LogSearchOnComplete", [ [ "ProjectID", projectID],278 [ "UserGuid", userGuid],279 [ "ResultCount", resultCount],280 [ "Language", language],281 [ "Query", query] ] );282 }283 284 this.LogSearchOnComplete = function( scriptID )285 {286 this.RemoveScriptTag( scriptID );287 }288 289 this.AddComment = function( topicID, userGuid, userName, subject, comment, parentCommentID )290 {291 AddScriptTag( "AddComment", "gServiceClient.AddCommentOnComplete", [ [ "TopicID", topicID],292 [ "UserGuid", userGuid],293 [ "Username", userName],294 [ "Subject", subject],295 [ "Comment", comment],296 [ "ParentCommentID", parentCommentID ] ] );297 }298 299 this.AddCommentOnComplete = function( scriptID )300 {301 this.RemoveScriptTag( scriptID );302 }303 304 this.GetAverageRating = function( topicID, onCompleteFunc, onCompleteArgs )305 {306 mGetAverageRatingOnCompleteFunc = onCompleteFunc;307 mGetAverageRatingOnCompleteArgs = onCompleteArgs;308 AddScriptTag( "GetAverageRating", "gServiceClient.GetAverageRatingOnComplete", [ [ "TopicID", topicID] ] );309 }310 this.GetAverageRatingOnComplete = function( scriptID, averageRating, ratingCount )311 {312 if ( mGetAverageRatingOnCompleteFunc != null )313 {314 mGetAverageRatingOnCompleteFunc( averageRating, ratingCount, mGetAverageRatingOnCompleteArgs );315 mGetAverageRatingOnCompleteFunc = null;316 mGetAverageRatingOnCompleteArgs = null;317 }318 319 //320 321 this.RemoveScriptTag( scriptID );322 }323 324 this.SubmitRating = function( topicID, rating, comment )325 {326 AddScriptTag( "SubmitRating", "gServiceClient.SubmitRatingOnComplete", [ [ "TopicID", topicID],327 [ "Rating", rating],328 [ "Comment", comment] ] );329 }330 331 this.SubmitRatingOnComplete = function( scriptID )332 {333 this.RemoveScriptTag( scriptID );334 }335 336 this.GetTopicComments = function( topicID, userGuid, userName, onCompleteFunc, onCompleteArgs )337 {338 var scriptID = AddScriptTag( "GetTopicComments", "gServiceClient.GetTopicCommentsOnComplete", [ [ "TopicID", topicID],339 [ "UserGuid", userGuid],340 [ "Username", userName] ] );341 var callbackData = { OnCompleteFunc: onCompleteFunc, OnCompleteArgs: onCompleteArgs };342 343 mCallbackMap.Add( scriptID, callbackData );344 }345 346 this.GetTopicCommentsOnComplete = function( scriptID, commentsXml )347 {348 var callbackData = mCallbackMap.GetItem( scriptID );349 var callbackFunc = callbackData.OnCompleteFunc;350 var callbackArgs = callbackData.OnCompleteArgs;351 352 if ( callbackFunc != null )353 {354 callbackFunc( commentsXml, callbackArgs );355 356 mCallbackMap.Remove( scriptID );357 }358 359 //360 361 this.RemoveScriptTag( scriptID );362 }363 364 this.GetRecentComments = function( projectID, userGuid, userName, oldestComment, onCompleteFunc, onCompleteArgs )365 {366 mGetRecentCommentsOnCompleteFunc = onCompleteFunc;367 mGetRecentCommentsOnCompleteArgs = onCompleteArgs;368 369 AddScriptTag( "GetRecentComments", "gServiceClient.GetRecentCommentsOnComplete", [ [ "ProjectID", projectID],370 [ "UserGuid", userGuid],371 [ "Username", userName],372 [ "Oldest", oldestComment] ] );373 }374 this.GetRecentCommentsOnComplete = function( scriptID, commentsXml )375 {376 if ( mGetRecentCommentsOnCompleteFunc != null )377 {378 mGetRecentCommentsOnCompleteFunc( commentsXml, mGetRecentCommentsOnCompleteArgs );379 mGetRecentCommentsOnCompleteFunc = null;380 mGetRecentCommentsOnCompleteArgs = null;381 }382 383 //384 385 this.RemoveScriptTag( scriptID );386 }387 388 this.GetAnonymousEnabled = function( projectID, onCompleteFunc, onCompleteArgs )389 {390 mGetAnonymousEnabledOnCompleteFunc = onCompleteFunc;391 mGetAnonymousEnabledOnCompleteArgs = onCompleteArgs;392 393 var src = mLiveHelpService + "GetAnonymousEnabled?ProjectID=" + encodeURIComponent( projectID );394 395 AddScriptTag( "GetAnonymousEnabled", "gServiceClient.GetAnonymousEnabledOnComplete", [ [ "ProjectID", projectID] ] );396 }397 this.GetAnonymousEnabledOnComplete = function( scriptID, enabled )398 {399 if ( mGetAnonymousEnabledOnCompleteFunc != null )400 {401 mGetAnonymousEnabledOnCompleteFunc( enabled, mGetAnonymousEnabledOnCompleteArgs );402 mGetAnonymousEnabledOnCompleteFunc = null;403 mGetAnonymousEnabledOnCompleteArgs = null;404 }405 406 //407 408 this.RemoveScriptTag( scriptID );409 }410 411 this.StartActivateUser = function( xmlDoc, onCompleteFunc, onCompleteArgs )412 {413 mStartActivateUserOnCompleteFunc = onCompleteFunc;414 mStartActivateUserOnCompleteArgs = onCompleteArgs;415 var usernameNode = FMCGetChildNodeByAttribute( xmlDoc.documentElement, "Name", "Username" );416 var username = FMCGetAttribute( usernameNode, "Value" );417 var emailAddressNode = FMCGetChildNodeByAttribute( xmlDoc.documentElement, "Name", "EmailAddress" );418 var emailAddress = FMCGetAttribute( emailAddressNode, "Value" );419 var firstNameNode = FMCGetChildNodeByAttribute( xmlDoc.documentElement, "Name", "FirstName" );420 var firstName = FMCGetAttribute( firstNameNode, "Value" );421 var lastNameNode = FMCGetChildNodeByAttribute( xmlDoc.documentElement, "Name", "LastName" );422 var lastName = FMCGetAttribute( lastNameNode, "Value" );423 var countryNode = FMCGetChildNodeByAttribute( xmlDoc.documentElement, "Name", "Country" );424 var country = FMCGetAttribute( countryNode, "Value" );425 var postalCodeNode = FMCGetChildNodeByAttribute( xmlDoc.documentElement, "Name", "PostalCode" );426 var postalCode = FMCGetAttribute( postalCodeNode, "Value" );427 var genderNode = FMCGetChildNodeByAttribute( xmlDoc.documentElement, "Name", "Gender" );428 var gender = FMCGetAttribute( genderNode, "Value" );429 var uiLanguageOrder = "";430 431 AddScriptTag( "StartActivateUser", "gServiceClient.StartActivateUserOnComplete", [ [ "Username", username],432 [ "EmailAddress", emailAddress],433 [ "FirstName", firstName],434 [ "LastName", lastName],435 [ "Country", country],436 [ "Zip", postalCode],437 [ "Gender", gender],438 [ "UILanguageOrder", uiLanguageOrder] ] );439 }440 this.StartActivateUserOnComplete = function( scriptID, pendingGuid )441 {442 if ( mStartActivateUserOnCompleteFunc != null )443 {444 mStartActivateUserOnCompleteFunc( pendingGuid, mStartActivateUserOnCompleteArgs );445 mStartActivateUserOnCompleteFunc = null;446 mStartActivateUserOnCompleteArgs = null;447 }448 449 //450 451 this.RemoveScriptTag( scriptID );452 }453 454 this.StartActivateUser2 = function( xmlDoc, onCompleteFunc, onCompleteArgs, thisObj )455 {456 var xml = CMCXmlParser.GetOuterXml( xmlDoc );457 458 this.StartActivateUser2OnComplete = function( scriptID, pendingGuid )459 {460 if ( onCompleteFunc != null )461 {462 if ( thisObj != null )463 {464 onCompleteFunc.call( thisObj, pendingGuid, onCompleteArgs );465 }466 else467 {468 onCompleteFunc( pendingGuid, onCompleteArgs );469 }470 }471 472 //473 474 this.RemoveScriptTag( scriptID );475 476 this.StartActivateUser2OnComplete = null;477 }478 AddScriptTag( "StartActivateUser2", "gServiceClient.StartActivateUser2OnComplete", [ [ "Xml", xml] ] );479 }480 481 this.UpdateUserProfile = function( guid, xmlDoc, onCompleteFunc, onCompleteArgs, thisObj )482 {483 var xml = CMCXmlParser.GetOuterXml( xmlDoc );484 485 this.UpdateUserProfileOnComplete = function( scriptID, pendingGuid )486 {487 if ( onCompleteFunc != null )488 {489 if ( thisObj != null )490 {491 onCompleteFunc.call( thisObj, pendingGuid, onCompleteArgs );492 }493 else494 {495 onCompleteFunc( pendingGuid, onCompleteArgs );496 }497 }498 499 //500 501 this.RemoveScriptTag( scriptID );502 503 this.UpdateUserProfileOnComplete = null;504 }505 AddScriptTag( "UpdateUserProfile", "gServiceClient.UpdateUserProfileOnComplete", [ [ "Guid", guid],506 [ "Xml", xml] ] );507 }508 509 this.CheckUserStatus = function( pendingGuid, onCompleteFunc, onCompleteArgs )510 {511 mCheckUserStatusOnCompleteFunc = onCompleteFunc;512 mCheckUserStatusOnCompleteArgs = onCompleteArgs;513 AddScriptTag( "CheckUserStatus", "gServiceClient.CheckUserStatusOnComplete", [ [ "PendingGuid", pendingGuid] ] );514 }515 this.CheckUserStatusOnComplete = function( scriptID, status )516 {517 if ( mCheckUserStatusOnCompleteFunc != null )518 {519 var func = mCheckUserStatusOnCompleteFunc;520 var args = mCheckUserStatusOnCompleteArgs;521 mCheckUserStatusOnCompleteFunc = null;522 mCheckUserStatusOnCompleteArgs = null;523 524 func( status, args );525 }526 527 //528 529 this.RemoveScriptTag( scriptID );530 }531 532 this.GetSynonymsFile = function( projectID, updatedSince, onCompleteFunc, onCompleteArgs )533 {534 mGetSynonymsFileOnCompleteFunc = onCompleteFunc;535 mGetSynonymsFileOnCompleteArgs = onCompleteArgs;536 AddScriptTag( "GetSynonymsFile", "gServiceClient.GetSynonymsFileOnComplete", [ [ "ProjectID", projectID],537 [ "UpdatedSince", updatedSince] ] );538 }539 this.GetSynonymsFileOnComplete = function( scriptID, synonymsXml )540 {541 if ( mGetSynonymsFileOnCompleteFunc != null )542 {543 mGetSynonymsFileOnCompleteFunc( synonymsXml, mGetSynonymsFileOnCompleteArgs );544 mGetSynonymsFileOnCompleteFunc = null;545 mGetSynonymsFileOnCompleteArgs = null;546 }547 548 //549 550 this.RemoveScriptTag( scriptID );551 }552 553 this.GetVersion = function( onCompleteFunc, onCompleteArgs, thisObj )554 {555 this.GetVersionOnComplete = function( scriptID, version )556 {557 if ( version == null )558 {559 mVersion = 1;560 }561 else562 {563 mVersion = version;564 }565 566 if ( onCompleteFunc != null )567 {568 if ( thisObj != null )569 {570 onCompleteFunc.call( thisObj, mVersion, onCompleteArgs );571 }572 else573 {574 onCompleteFunc( mVersion, onCompleteArgs );575 }576 }577 578 //579 580 if ( scriptID != null )581 {582 this.RemoveScriptTag( scriptID );583 }584 585 this.GetVersionOnComplete = null;586 }587 588 if ( mVersion == -1 )589 {590 AddScriptTag( "GetVersion", "gServiceClient.GetVersionOnComplete" );591 }592 else593 {594 this.GetVersionOnComplete( null, mVersion );595 }596 }597}598//599// End class CMCLiveHelpServiceClient600//601//602// Class CMCFeedbackException603//604function CMCFeedbackException( number, message, data )605{606 CMCException.call( this, number, message );607 // Public properties608 this.Data = data;609}610CMCFeedbackException.prototype = new CMCException();611CMCFeedbackException.prototype.constructor = CMCFeedbackException;612CMCFeedbackException.prototype.base = CMCException.prototype;613//614// End class CMCFeedbackException...

Full Screen

Full Screen

loadHub.js

Source:loadHub.js Github

copy

Full Screen

...38 var script_src_prefix = "";39 for (var i=0; i<dirDepth; i++) {40 script_src_prefix += "../";41 }42 function addScriptTag(src) {43 document.write("<scr"+"ipt type='text/javascript' src='"+script_src_prefix+src+"'></scr"+"ipt>");44 }45 if (config === "src") {46 addScriptTag("src/OpenAjax-mashup.js");47 addScriptTag("src/containers/iframe/iframe.js");48 addScriptTag("src/containers/iframe/crypto.js");49 addScriptTag("src/containers/inline/inline.js");50 addScriptTag("src/containers/iframe/json2.js");51 addScriptTag("src/containers/iframe/rpc/rpc-dependencies.js");52 addScriptTag("src/containers/iframe/rpc/fe.transport.js");53 addScriptTag("src/containers/iframe/rpc/ifpc.transport.js");54 addScriptTag("src/containers/iframe/rpc/nix.transport.js");55 addScriptTag("src/containers/iframe/rpc/rmr.transport.js");56 addScriptTag("src/containers/iframe/rpc/wpm.transport.js");57 addScriptTag("src/containers/iframe/rpc/rpc.js");58 } else if (config === "release_all") {59 addScriptTag("release/all/OpenAjaxManagedHub-all.js");60 } else if (config === "release_all_separate_rpc") {61 addScriptTag("release/all_separate_rpc/OpenAjaxManagedHub-all-oaa.js");62 addScriptTag("release/all_separate_rpc/OpenAjaxManagedHub-rpc.js");63 } else if (config === "release_core") {64 addScriptTag("release/core/OpenAjaxManagedHub-core.js");65 addScriptTag("release/core/OpenAjaxManagedHub-iframe.js");66 } else if (config === "release_core_separate_rpc") {67 addScriptTag("release/core_separate_rpc/OpenAjaxManagedHub-core.js");68 addScriptTag("release/core_separate_rpc/OpenAjaxManagedHub-iframe-oaa.js");69 addScriptTag("release/core_separate_rpc/OpenAjaxManagedHub-rpc.js");70 } else if (config === "release_unmanagedhub") {71 addScriptTag("release/unmanagedhub/OpenAjaxUnmanagedHub.js");72 } else {73 throw new Error("loadHub: Invalid or missing value for URL param 'config' (URI=" + window.location.href + ")");74 }...

Full Screen

Full Screen

commonScriptsAndStyles.js

Source:commonScriptsAndStyles.js Github

copy

Full Screen

2 <!-- ADD COMMON CSS FILES HERE -->3 addCss("../css/bootstrap.min.css");4 addCss("../css/style.css");5 <!-- ADD COMMON JAVASCRIPT FILES HERE -->6 addScriptTag("../js/thirdParty/bootstrap.js");7 addScriptTag("../js/util/constants.js");8 addScriptTag("../config/env.js");9 addScriptTag("../js/util/endpoints.js");10 addScriptTag("../js/util/application.js");11 addScriptTag("../js/thirdParty/handlebars.min.js");12 addScriptTag("../js/thirdParty/blockUI.js");13 addScriptTag("../js/util/handleBarHelper.js");14})();15function addCss(cssPath) {16 const link = document.createElement("link");17 link.href = cssPath;18 link.rel = "stylesheet";19 $("head").append(link);20}21function addScriptTag(scriptPath) {22 const script = document.createElement("script");23 script.src = scriptPath;24 $("head").append(script);...

Full Screen

Full Screen

app_loader.js

Source:app_loader.js Github

copy

Full Screen

1// Copyright 2014 The Chromium Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4// Adds a Javascript source tag to the document.5function addScriptTag(src) {6 document.write(7 '<script type="text/javascript" src="eme_player_js/' + src +8 '"></script>');9}10// Load all the dependencies for the app.11addScriptTag('globals.js');12addScriptTag('utils.js');13addScriptTag('test_config.js');14addScriptTag('fps_observer.js');15addScriptTag('media_source_utils.js');16addScriptTag('player_utils.js');17addScriptTag('clearkey_player.js');18addScriptTag('widevine_player.js');19addScriptTag('unit_test_player.js');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.addScriptTag({path: 'jquery.js'});6 await page.evaluate(() => {7 return $('body').append('Hello, world!');8 });9 await browser.close();10})();11console.log('jQuery is loaded');

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.evaluate(() => {6 return $('div').length;7 });8 await browser.close();9})();10The addScriptTag() method has the following signature:11page.addScriptTag(options)12const puppeteer = require('puppeteer');13(async () => {14 const browser = await puppeteer.launch();15 const page = await browser.newPage();16 await page.evaluate(() => {17 return $('div').length;18 });19 await browser.close();20})();21The addScriptTag() method is used to add a script tag to the page. The script

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const path = require('path');3(async () => {4 const browser = await puppeteer.launch();5 const page = await browser.newPage();6 await page.addScriptTag({7 path: path.join(__dirname, 'jquery.js'),8 });9 await page.screenshot({ path: 'google.png' });10 await browser.close();11})();12console.log('jQuery version:', $().jquery);13page.waitForFunction(pageFunction[, options[, ...args]])

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 Puppeteer 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