Best JavaScript code snippet using playwright-internal
jqxangular.js
Source:jqxangular.js  
...1205                $scope.$digest();1206            }1207        }]);1208    }1209    function addDirective(name) {1210        var properties = {};1211        var linkFunction = function (scope, element, attrs, controllers, transclude) {1212            if ($(element).attr('data-jqx-ng-include')) {1213                $(element).removeAttr('data-jqx-ng-include');1214                var children = $(element.children()).detach();1215                element = addTemplate(element, true, attrs, name);1216                element.append(children);1217                $compile(element)(scope);1218                var toParentScope = true;1219                for (var obj in attrs) {1220                    if (obj.toString().indexOf('jqx') == -1) {1221                        continue;1222                    }1223                    if (scope[attrs[obj]] != undefined) {1224                        toParentScope = false;1225                    }1226                    if (attrs[obj].split(".").length > 1) {1227                        var subProperties = attrs[obj].split(".");1228                        for (var i = 0; i < subProperties.length; i++) {1229                            if (scope[subProperties[i]] != undefined) {1230                                toParentScope = false;1231                            }1232                        }1233                    }1234                }1235                if (toParentScope && attrs.jqxSettings) {1236                    if (!$parse(attrs.jqxSettings)(scope)) {1237                        toParentScope = false;1238                    }1239                }1240                if (toParentScope) {1241                    scope = scope.$parent;1242                }1243            }1244            if ($.jqx.AMD) {1245                var properties = {};1246                JQWIDGETS_LOADED_WIDGETS[name] = false;1247                properties.documentReady = false;1248                AMD(name, properties);1249            }1250            var visibility = element[0].style.visibility;1251            var display = element[0].style.display;1252            element[0].style.visibility = "hidden";1253            element[0].style.display = "none";1254            var parentScope = scope;1255            var stop = $interval(function () {1256                $interval.cancel(stop);1257                stop = undefined;1258                var createWidget = function () {1259                    var ngModel = controllers[0];1260                    element[0].style.visibility = visibility;1261                    element[0].style.display = display;1262                    var widget = createInstance(scope, element, attrs, name, parentScope);1263                    var lowerName = name.toLowerCase();1264                    var isInput = name.match(/(input|list|radio|checkbox|combobox|rating|slider|scrollbar|progress|range|editor|picker|range|gauge|textarea|calendar|switch|button)/ig);1265                    var args = { element: element[0], name: name, instance: $(element).data().jqxWidget, id: element[0].id, scope: scope };1266                    var raiseCreated = function () {1267                        scope.$emit(name + 'Created', args);1268                        if (attrs.jqxSettings && $parse(attrs.jqxSettings)(scope) && $parse(attrs.jqxSettings)(scope).created) {1269                            $timeout(function () {1270                                var created = $parse(attrs.jqxSettings)(scope).created;1271                                created(args);1272                            });1273                        }1274                        if (attrs.jqxCreated) {1275                            $timeout(function () {1276                                var created = $parse(attrs['jqxCreated'])(scope);1277                                created(args);1278                            });1279                        }1280                    }1281                    if (name === "jqxGrid" || name === "jqxDataTable") {1282                        var intervalCount = 0;1283                        var stopInterval = $interval(function () {1284                            if (!$(element).data().jqxWidget) {1285                                $interval.cancel(stopInterval);1286                                stopInterval = undefined;1287                            }1288                            else {1289                                if ($(element).data().jqxWidget.initializedcall || intervalCount == 25) {1290                                    $interval.cancel(stopInterval);1291                                    stopInterval = undefined;1292                                    raiseCreated();1293                                }1294                            }1295                            intervalCount++;1296                        }, 100);1297                    }1298                    else {1299                        raiseCreated();1300                    }1301                    $timeout(function update() {1302                        if (ngModel) {1303                            ngModel.$render = function () {1304                                var val = ngModel.$viewValue;1305                                if (val === undefined) {1306                                    val = ngModel.$modelValue;1307                                }1308                                if (name === "jqxRadioButton") {1309                                    if (scope.$eval($(element).attr('value')) == ngModel.$viewValue) {1310                                        $(element).val(true);1311                                    }1312                                    else if (scope.$eval($(element).attr('value')) == "true" && ngModel.$viewValue == true) {1313                                        $(element).val(true);1314                                    }1315                                    else {1316                                        $(element).val(false);1317                                    }1318                                    return;1319                                }1320                                else if (name === "jqxCheckBox") {1321                                    if (scope.$eval($(element).attr('ng-true-value')) == ngModel.$viewValue) {1322                                        $(element).val(true);1323                                    }1324                                    if (scope.$eval($(element).attr('ng-false-value')) == ngModel.$viewValue) {1325                                        $(element).val(false);1326                                    }1327                                    else {1328                                        $(element).val(ngModel.$viewValue);1329                                    }1330                                    return;1331                                }1332                                if (val != $(element).val()) {1333                                    $timeout(function () {1334                                        $(element).val(val);1335                                    });1336                                }1337                            };1338                            if (name === "jqxRadioButton") {1339                                if (scope.$eval($(element).attr('value')) == ngModel.$viewValue) {1340                                    $(element).val(true);1341                                }1342                                else if (scope.$eval($(element).attr('value')) == "true" && ngModel.$viewValue == true) {1343                                    $(element).val(true);1344                                }1345                                else {1346                                    $(element).val(false);1347                                }1348                            }1349                            else if (name === "jqxCheckBox") {1350                                if (scope.$eval($(element).attr('ng-true-value')) == ngModel.$viewValue) {1351                                    $(element).val(true);1352                                }1353                                if (scope.$eval($(element).attr('ng-false-value')) == ngModel.$viewValue) {1354                                    $(element).val(false);1355                                }1356                                else {1357                                    $(element).val(ngModel.$viewValue);1358                                }1359                            }1360                            else if (name === "jqxDropDownList" || name === "jqxComboBox" || name === "jqxListBox" || name === "jqxInput" || name === "jqxTextArea") {1361                                if (attrs.jqxNgModel != undefined) {1362                                    var instance = $(element).data().jqxWidget;1363                                    if (name != "jqxInput") {1364                                        if (instance.valueMember) {1365                                            instance.selectItem(ngModel.$viewValue[instance.valueMember]);1366                                        }1367                                        else if (instance.displayMember) {1368                                            instance.selectItem(ngModel.$viewValue[instance.displayMember]);1369                                        }1370                                        else {1371                                            $(element).val(ngModel.$viewValue);1372                                        }1373                                    }1374                                    else {1375                                        $(element).val(ngModel.$viewValue);1376                                    }1377                                }1378                                else {1379                                    $(element).val(ngModel.$viewValue);1380                                }1381                            }1382                            else if (name === "jqxDateTimeInput" || name === "jqxCalendar") {1383                                if (attrs.jqxNgModel != undefined) {1384                                    var instance = $(element).data().jqxWidget;1385                                    if (instance.selectionMode == "range") {1386                                        instance.setRange(ngModel.$viewValue);1387                                    }1388                                    else {1389                                        instance.setDate(ngModel.$viewValue);1390                                    }1391                                }1392                                else {1393                                    $(element).val(ngModel.$viewValue);1394                                }1395                            }1396                            else if (name == "jqxToggleButton") {1397                                var instance = $(element).data().jqxWidget;1398                                instance.toggled = true;1399                                instance.refresh();1400                            }1401                            else {1402                                $(element).val(ngModel.$viewValue);1403                            }1404                        1405                            if (isInput) {1406                                var eventList = 'keyup change';1407                                if (name == "jqxScrollBar")1408                                    eventList = "valueChanged";1409                                if (name == "jqxToggleButton") {1410                                    eventList = "keyup click";1411                                }1412                                if (name == "jqxInput") {1413                                    eventList = "keyup change select";1414                                }1415                                var promise;1416                                var host = widget.host;1417                                if (!host && widget.base) {1418                                    host = widget.base.host;1419                                }1420                                $(host).on(eventList, function (event) {1421                                    var args = event.args;1422                                    if (promise){1423                                        $timeout.cancel(promise);1424                                    }1425                                    promise = $timeout(function () {1426                                        if (name === "jqxRadioButton") {1427                                            if (args && args.type != "api") {1428                                                ngModel.$setViewValue(scope.$eval($(element).attr('value')));1429                                            }1430                                        }1431                                        else if (name === "jqxCheckBox") {1432                                            if ($(element).attr('ng-true-value') != undefined && args.checked) {1433                                                ngModel.$setViewValue($(element).attr('ng-true-value'));1434                                            }1435                                            else if ($(element).attr('ng-false-value') != undefined && !args.checked) {1436                                                ngModel.$setViewValue($(element).attr('ng-false-value'));1437                                            }1438                                            else {1439                                                ngModel.$setViewValue($(element).val());1440                                            }1441                                        }1442                                        else if (name === "jqxDropDownList" || name === "jqxComboBox" || name === "jqxListBox" || name === "jqxInput" || name === "jqxTextArea") {1443                                            var val = $(element).val();1444                                            if (attrs.jqxNgModel != undefined) {1445                                                var instance = $(element).data().jqxWidget;1446                                                if (instance.getSelectedItem) {1447                                                    val = instance.getSelectedItem();1448                                                    if (val.originalItem)1449                                                        val = val.originalItem;1450                                                }1451                                                if (name === "jqxInput"|| name === "jqxTextArea") {1452                                                    val = instance.selectedItem;1453                                                }1454                                                ngModel.$setViewValue(val);1455                                            }1456                                            else {1457                                                ngModel.$setViewValue(val);1458                                            }1459                                        }1460                                        else if (name === "jqxDateTimeInput" || name === "jqxCalendar") {1461                                            if (attrs.jqxNgModel != undefined) {1462                                                var instance = $(element).data().jqxWidget;1463                                                if (instance.selectionMode == "range") {1464                                                    ngModel.$setViewValue(instance.getRange());1465                                                }1466                                                else {1467                                                    ngModel.$setViewValue(instance.getDate());1468                                                }1469                                            }1470                                            else {1471                                                if ($.type(ngModel.$viewValue) === "date") {1472                                                    var instance = $(element).data().jqxWidget;1473                                                    if (instance.selectionMode == "range") {1474                                                        ngModel.$setViewValue(instance.getRange());1475                                                    }1476                                                    else {1477                                                        ngModel.$setViewValue(instance.getDate());1478                                                    }1479                                                }1480                                                else {1481                                                    ngModel.$setViewValue($(element).val());1482                                                }1483                                            }1484                                        }1485                                        else if (name == "jqxToggleButton") {1486                                            var instance = $(element).data().jqxWidget;1487                                            ngModel.$setViewValue(instance.toggled);1488                                        }1489                                        else {1490                                            ngModel.$setViewValue($(element).val());1491                                        }1492                                        scope.$emit(name + 'ModelChange', ngModel.$viewValue);1493                                    });1494                                });1495                            }                       1496                        }1497                    });1498                }1499                if (attrs.ngShow !== undefined && attrs.jqxCreate === undefined) {1500                    var unregister = scope.$watch(attrs["ngShow"], function (newObj, oldObj) {1501                        if (newObj) {1502                            createWidget();1503                            unregister();1504                        }1505                    });1506                    return;1507                }1508                var createWidgetsWhenReady = function () {1509                    if (attrs.jqxCreate != null || attrs.jqxCreate != null) {1510                        if (attrs.jqxCreate === true || (attrs.jqxCreate !== null && $.type(attrs.jqxCreate) == "object")) {1511                            createWidget();1512                        }1513                        else {1514                            var unregister = scope.$watch(attrs["jqxCreate"], function (newObj, oldObj) {1515                                if (typeof newObj == "number") {1516                                    $timeout(createWidget, newObj);1517                                    unregister();1518                                }1519                                else if (newObj) {1520                                    createWidget();1521                                    unregister();1522                                }1523                            });1524                        }1525                    }1526                    else {1527                        createWidget();1528                    }1529                }1530                if ($.jqx.AMD) {1531                    var raiseLoaded = function () {1532                        var allLoaded = true;1533                        for (var widgetName in JQWIDGETS_LOADED_WIDGETS) {1534                            if (!JQWIDGETS_LOADED_WIDGETS[widgetName]) {1535                                allLoaded = false;1536                                break;1537                            }1538                        }1539                        if (allLoaded) {1540                            if (!allScriptsLoaded) {1541                                scope.$emit('jQWidgetsScriptsLoaded');1542                                allScriptsLoaded = true;1543                            }1544                            for (var widgetName in JQWIDGETS_LOADED_WIDGETS) {1545                                $.each(JQWIDGETS_LOADED_WIDGETS[widgetName], function () {1546                                    this();1547                                });1548                                JQWIDGETS_LOADED_WIDGETS[widgetName] = new Array();1549                            }1550                        }1551                    }1552                    if (properties.documentReady) {1553                        var args = { element: element[0], name: name, scope: scope };1554                        scope.$emit(name + 'ScriptsLoaded', args);1555                        if (!JQWIDGETS_LOADED_WIDGETS[name]) {1556                            JQWIDGETS_LOADED_WIDGETS[name] = new Array();1557                        }1558                        JQWIDGETS_LOADED_WIDGETS[name].push(createWidgetsWhenReady);1559                        raiseLoaded();1560                    }1561                    else {1562                        properties.scriptsLoaded = function () {1563                            var args = { element: element[0], name: name, scope: scope };1564                            scope.$emit(name + 'ScriptsLoaded', args);1565                            if (!JQWIDGETS_LOADED_WIDGETS[name]) {1566                                JQWIDGETS_LOADED_WIDGETS[name] = new Array();1567                            }1568                            JQWIDGETS_LOADED_WIDGETS[name].push(createWidgetsWhenReady);1569                            raiseLoaded();1570                        };1571                    }1572                }1573                else {1574                    createWidgetsWhenReady();1575                }1576            });1577        }1578        module.directive(name,1579        ['$timeout', '$interval', '$parse', '$compile', '$log', function (timeout, interval, parse, compile, log) {1580            $timeout = timeout;1581            $interval = interval;1582            $parse = parse;1583            $compile = compile;1584            $log = log;1585            var properties = {};1586            var directiveScope;1587            return {1588                restrict: "ACE",1589                require: ["?ngModel"],1590                scope: false,1591                template: function (element, attrs) {1592                    addTemplate(element, false, attrs, name);1593                    directiveScope = this.scope;1594                },1595                controller: ['$scope', '$attrs', '$element', '$transclude', function ($scope, $attrs, $element, $transclude) {1596   1597                }],1598                compile: function ($element, $attrs, linker) {1599                    return {1600                        pre: function ($scope, $element, $attrs, $controllers, $transclude) {1601                        },1602                        post: function ($scope, $element, $attrs, $controllers, $transclude) {1603                            linkFunction($scope, $element, $attrs, $controllers, $transclude);1604                        }1605                    }1606                },1607                link: linkFunction1608            };1609        }]);1610    }1611    addDirective("jqxBulletChart");1612    addDirective("jqxButtonGroup");1613    addDirective("jqxButton");1614    addDirective("jqxBarGauge");1615    addDirective("jqxRepeatButton");1616    addDirective("jqxToggleButton");1617    addDirective("jqxLinkButton");1618    addDirective("jqxCalendar");1619    addDirective("jqxChart");1620    addDirective("jqxCheckBox");1621    addDirective("jqxComplexInput");1622    addDirective("jqxColorPicker");1623    addDirective("jqxComboBox");1624    addDirective("jqxDataTable");1625    addDirective("jqxDateTimeInput");1626    addDirective("jqxDocking");1627    addDirective("jqxDockPanel");1628    addDirective("jqxDragDrop");1629    addDirective("jqxDraw");1630    addDirective("jqxDropDownButton");1631    addDirective("jqxDropDownList");1632    addDirective("jqxEditor");1633    addDirective("jqxExpander");1634    addDirective("jqxFormattedInput");1635    addDirective("jqxFileUpload");1636    addDirective("jqxGauge");1637    addDirective("jqxLinearGauge");1638    addDirective("jqxGrid");1639    addDirective("jqxInput");1640    addDirective("jqxListBox");1641    addDirective("jqxListMenu");1642    addDirective("jqxMaskedInput");1643    addDirective("jqxMenu");1644    addDirective("jqxNavigationBar");1645    addDirective("jqxNavBar");1646    addDirective("jqxNotification");1647    addDirective("jqxNumberInput");1648    addDirective("jqxPanel");1649    addDirective("jqxPasswordInput");1650    addDirective("jqxProgressBar");1651    addDirective("jqxRadioButton");1652    addDirective("jqxRangeSelector");1653    addDirective("jqxRating");1654    addDirective("jqxRibbon");1655    addDirective("jqxScrollBar");1656    addDirective("jqxScrollView");1657    addDirective("jqxSlider");1658    addDirective("jqxSplitter");1659    addDirective("jqxSwitchButton");1660    addDirective("jqxTabs");1661    addDirective("jqxToolBar");1662    addDirective("jqxTooltip");1663    addDirective("jqxTouch");1664    addDirective("jqxTree");1665    addDirective("jqxTreeGrid");1666    addDirective("jqxTreeMap");1667    addDirective("jqxValidator");1668    addDirective("jqxWindow");1669    addDirective("jqxTagCloud");1670    addDirective("jqxPopover");1671    addDirective("jqxKanban");1672    addDirective("jqxKnob");1673    addDirective("jqxSortablePlugin");1674    addDirective("jqxScheduler");1675    addDirective("jqxTextArea");1676    addDirective("jqxLayout");1677    addDirective("jqxDockingLayout");1678    addDirective("jqxResponsivePanel");1679    addDirective("jqxLoader");1680    addDirective("jqxPivotGrid");...index.js
Source:index.js  
...13    const speechText = 'Welcome to banana bread baker. A step by step baking process. We are going to make a great loaf, I can just feel it. You navigate this app with your voice, at any time you can say Alexa next to continue or Alexa go back, to go back. You may also see all the steps at once by asking for them. Show me the steps!';14    if (supportsAPL(handlerInput)) {15      return handlerInput.responseBuilder16        .speak(speechText)17        .addDirective({18            type: 'Alexa.Presentation.APL.RenderDocument',19            document: require('./homepage.json'),20            token: 'homepage',21            datasources: {}22        })23        .addDirective({24            type : 'Alexa.Presentation.APL.ExecuteCommands',25            token: "homepage",26            commands: [27                {28                    type: "Parallel",29                    commands: [30                        {31                            type: "Idle",32                            delay: 6000033                        }],34                }35            ]36            37        })38        39        .getResponse();40    }41    else {42      return handlerInput.responseBuilder43        .speak("Sorry, this app is built for multimodal experience only. Try this app again on an amazon device with a screen")44        .reprompt(speechText)45        .withSimpleCard('Try this on an amazon device with a screen', speechText)46        .getResponse();47    }48  },49};50const NextIntentHandler = {51  canHandle(handlerInput) {52    console.log("ARUGMENTS" + JSON.stringify(handlerInput.requestEnvelope));53    54    return (handlerInput.requestEnvelope.request.type === 'IntentRequest'55      && handlerInput.requestEnvelope.request.intent.name === 'AMAZON.NextIntent')56      || (handlerInput.requestEnvelope.request.type === 'Alexa.Presentation.APL.UserEvent'57        && handlerInput.requestEnvelope.request.arguments.length > 058        && handlerInput.requestEnvelope.request.arguments[0] === 'videoEnded');59 },60  handle(handlerInput) {61      ++SELECTED;62      63      if (SELECTED == 0){64      return handlerInput.responseBuilder65        .speak('')66        .addDirective({67            type: 'Alexa.Presentation.APL.RenderDocument',68            document: require('./homepage.json'),69            datasources: {}70        })71        .getResponse();72      }73      if (SELECTED == 1){74      return handlerInput.responseBuilder75        .speak('')76        .addDirective({77            type: 'Alexa.Presentation.APL.RenderDocument',78            token: "VideoPlayerToken",79            document: require('./miseen.json'),80            datasources: {}81        })82        .getResponse();83      }84      if (SELECTED == 2){85      return handlerInput.responseBuilder86        .speak('')87        .addDirective({88            type: 'Alexa.Presentation.APL.RenderDocument',89            token: "VideoPlayerToken",90            document: require('./step1.json'),91            datasources: {}92        })93        .getResponse();94      }95      if (SELECTED == 3){96      return handlerInput.responseBuilder97        .speak('')98        .addDirective({99            type: 'Alexa.Presentation.APL.RenderDocument',100            token: "VideoPlayerToken",101            document: require('./step2.json'),102            datasources: {}103        })104        .getResponse();105      }106      if (SELECTED == 4){107      return handlerInput.responseBuilder108        .speak('')109        .addDirective({110            type: 'Alexa.Presentation.APL.RenderDocument',111            token:"VideoPlayerToken",112            document: require('./step3.json'),113            datasources: {}114        })115        .getResponse();116      }117      if (SELECTED == 5){118      return handlerInput.responseBuilder119        .speak('')120        .addDirective({121            type: 'Alexa.Presentation.APL.RenderDocument',122            token: "VideoPlayerToken",123            document: require('./step4.json'),124            datasources: {}125        })126        .getResponse();127      }128      if (SELECTED == 6){129      return handlerInput.responseBuilder130        .speak('')131        .addDirective({132            type: 'Alexa.Presentation.APL.RenderDocument',133            token: "VideoPlayerToken",134            document: require('./step5.json'),135            datasources: {}136        })137        .getResponse();138      }139      if (SELECTED == 7){140      return handlerInput.responseBuilder141        .speak('')142        .addDirective({143            type: 'Alexa.Presentation.APL.RenderDocument',144            token:"VideoPlayerToken",145            document: require('./step6.json'),146            datasources: {}147        })148        .getResponse();149      }150      if (SELECTED == 8){151      return handlerInput.responseBuilder152        .speak('')153        .addDirective({154            type: 'Alexa.Presentation.APL.RenderDocument',155            token: "VideoPlayerToken",156            document: require('./step7.json'),157            datasources: {}158        })159        .getResponse();160      }161      if (SELECTED == 9){162      return handlerInput.responseBuilder163        .speak('')164        .addDirective({165            type: 'Alexa.Presentation.APL.RenderDocument',166            token: "VideoPlayerToken",167            document: require('./step8.json'),168            datasources: {}169        })170        .getResponse();171      }172      if (SELECTED == 10){173      return handlerInput.responseBuilder174        .speak('')175        .addDirective({176            type: 'Alexa.Presentation.APL.RenderDocument',177            token: "VideoPlayerToken",178            document: require('./vo.json'),179            datasources: {}180        })181        .getResponse();182      }183      if (SELECTED == 11){184      return handlerInput.responseBuilder185        .speak('')186        .addDirective({187            type: 'Alexa.Presentation.APL.RenderDocument',188            token: "VideoPlayerToken",189            document: require('./step10.json'),190            datasources: {}191        })192        .getResponse();193      }194      if (SELECTED == 12){195      return handlerInput.responseBuilder196        .speak('')197        .addDirective({198            type: 'Alexa.Presentation.APL.RenderDocument',199            token: "VideoPlayerToken",200            document: require('./step11.json'),201            datasources: {}202        })203        .getResponse();204      }205      if (SELECTED == 13){206      return handlerInput.responseBuilder207        .speak('')208        .addDirective({209            type: 'Alexa.Presentation.APL.RenderDocument',210            token: "VideoPlayerToken",211            document: require('./step12.json'),212            datasources: {}213        })214        .getResponse();215      }216      if (SELECTED == 14){217      return handlerInput.responseBuilder218        .speak('')219        .addDirective({220            type: 'Alexa.Presentation.APL.RenderDocument',221            token: "VideoPlayerToken",222            document: require('./step13.json'),223            datasources: {}224        })225        .getResponse();226      }227      if (SELECTED == 15){228      return handlerInput.responseBuilder229        .speak('')230        .addDirective({231            type: 'Alexa.Presentation.APL.RenderDocument',232            token: "VideoPlayerToken",233            document: require('./step14.json'),234            datasources: {}235        })236        .getResponse();237      }238      if (SELECTED == 16){239      return handlerInput.responseBuilder240        .speak('Thanks for baking with us!')241        .addDirective({242            type: 'Alexa.Presentation.APL.RenderDocument',243            document: require('./step15.json'),244            token: 'endpage',245            datasources: {}246        })247        .addDirective({248            type : 'Alexa.Presentation.APL.ExecuteCommands',249            token: "endpage",250            commands: [251                {252                    type: "Parallel",253                    commands: [254                        {255                            type: "Idle",256                            delay: 60000257                        }],258                }259            ]260            261        })262        .getResponse();263      }264      else {265      SELECTED = 1;266      return handlerInput.responseBuilder267        .speak('You have reached the end of this app, I am redirecting you to the mise en place')268        .addDirective({269            type: 'Alexa.Presentation.APL.RenderDocument',270            token: "VideoPlayerToken",271            document: require('./miseen.json'),272            datasources: {}273        })274        .getResponse();275    }276  },277};278const PreviousIntentHandler = {279  canHandle(handlerInput) {280    return (handlerInput.requestEnvelope.request.type === 'IntentRequest'281      && handlerInput.requestEnvelope.request.intent.name === 'AMAZON.PreviousIntent');282 },283  handle(handlerInput) {284      --SELECTED;285      286      if (SELECTED == 0){287      return handlerInput.responseBuilder288        .speak('')289        .addDirective({290            type: 'Alexa.Presentation.APL.RenderDocument',291            document: require('./homepage.json'),292            datasources: {}293        })294        .getResponse();295      }296      if (SELECTED == 1){297      return handlerInput.responseBuilder298        .speak('')299        .addDirective({300            type: 'Alexa.Presentation.APL.RenderDocument',301            token: "VideoPlayerToken",302            document: require('./miseen.json'),303            datasources: {}304        })305        .getResponse();306      }307      if (SELECTED == 2){308      return handlerInput.responseBuilder309        .speak('')310        .addDirective({311            type: 'Alexa.Presentation.APL.RenderDocument',312            token: "VideoPlayerToken",313            document: require('./step1.json'),314            datasources: {}315        })316        .getResponse();317      }318      if (SELECTED == 3){319      return handlerInput.responseBuilder320        .speak('')321        .addDirective({322            type: 'Alexa.Presentation.APL.RenderDocument',323            token: "VideoPlayerToken",324            document: require('./step2.json'),325            datasources: {}326        })327        .getResponse();328      }329      if (SELECTED == 4){330      return handlerInput.responseBuilder331        .speak('')332        .addDirective({333            type: 'Alexa.Presentation.APL.RenderDocument',334            token:"VideoPlayerToken",335            document: require('./step3.json'),336            datasources: {}337        })338        .getResponse();339      }340      if (SELECTED == 5){341      return handlerInput.responseBuilder342        .speak('')343        .addDirective({344            type: 'Alexa.Presentation.APL.RenderDocument',345            token: "VideoPlayerToken",346            document: require('./step4.json'),347            datasources: {}348        })349        .getResponse();350      }351      if (SELECTED == 6){352      return handlerInput.responseBuilder353        .speak('')354        .addDirective({355            type: 'Alexa.Presentation.APL.RenderDocument',356            token: "VideoPlayerToken",357            document: require('./step5.json'),358            datasources: {}359        })360        .getResponse();361      }362      if (SELECTED == 7){363      return handlerInput.responseBuilder364        .speak('')365        .addDirective({366            type: 'Alexa.Presentation.APL.RenderDocument',367            token:"VideoPlayerToken",368            document: require('./step6.json'),369            datasources: {}370        })371        .getResponse();372      }373      if (SELECTED == 8){374      return handlerInput.responseBuilder375        .speak('')376        .addDirective({377            type: 'Alexa.Presentation.APL.RenderDocument',378            token: "VideoPlayerToken",379            document: require('./step7.json'),380            datasources: {}381        })382        .getResponse();383      }384      if (SELECTED == 9){385      return handlerInput.responseBuilder386        .speak('')387        .addDirective({388            type: 'Alexa.Presentation.APL.RenderDocument',389            token: "VideoPlayerToken",390            document: require('./step8.json'),391            datasources: {}392        })393        .getResponse();394      }395      if (SELECTED == 10){396      return handlerInput.responseBuilder397        .speak('')398        .addDirective({399            type: 'Alexa.Presentation.APL.RenderDocument',400            token: "VideoPlayerToken",401            document: require('./step9.json'),402            datasources: {}403        })404        .getResponse();405      }406      if (SELECTED == 11){407      return handlerInput.responseBuilder408        .speak('')409        .addDirective({410            type: 'Alexa.Presentation.APL.RenderDocument',411            token: "VideoPlayerToken",412            document: require('./step10.json'),413            datasources: {}414        })415        .getResponse();416      }417      if (SELECTED == 12){418      return handlerInput.responseBuilder419        .speak('')420        .addDirective({421            type: 'Alexa.Presentation.APL.RenderDocument',422            token: "VideoPlayerToken",423            document: require('./step11.json'),424            datasources: {}425        })426        .getResponse();427      }428      if (SELECTED == 13){429      return handlerInput.responseBuilder430        .speak('')431        .addDirective({432            type: 'Alexa.Presentation.APL.RenderDocument',433            token: "VideoPlayerToken",434            document: require('./step12.json'),435            datasources: {}436        })437        .getResponse();438      }439      if (SELECTED == 14){440      return handlerInput.responseBuilder441        .speak('')442        .addDirective({443            type: 'Alexa.Presentation.APL.RenderDocument',444            token: "VideoPlayerToken",445            document: require('./step13.json'),446            datasources: {}447        })448        .getResponse();449      }450      if (SELECTED == 15){451      return handlerInput.responseBuilder452        .speak('')453        .addDirective({454            type: 'Alexa.Presentation.APL.RenderDocument',455            token: "VideoPlayerToken",456            document: require('./step14.json'),457            datasources: {}458        })459        .getResponse();460      }461      if (SELECTED == 16){462      return handlerInput.responseBuilder463        .speak('Thanks for baking with us!')464        .addDirective({465            type: 'Alexa.Presentation.APL.RenderDocument',466            document: require('./step15.json'),467            datasources: {}468        })469        .getResponse();470      }471      else {472      SELECTED = 1;473      return handlerInput.responseBuilder474        .speak('You have reached the front of this app, I am redirecting you to the mise en place')475        .addDirective({476            type: 'Alexa.Presentation.APL.RenderDocument',477            token: "VideoPlayerToken",478            document: require('./miseen.json'),479            datasources: {}480        })481        .getResponse();482    }483  },484};485const indexhandler = {486  canHandle(handlerInput) {487    return (handlerInput.requestEnvelope.request.type === 'IntentRequest'488      && handlerInput.requestEnvelope.request.intent.name === 'DrinkIntent') 489      || (handlerInput.requestEnvelope.request.type === 'Alexa.Presentation.APL.UserEvent'490        && handlerInput.requestEnvelope.request.arguments.length > 0491        && handlerInput.requestEnvelope.request.arguments[0] != 'videoEnded'492        && handlerInput.requestEnvelope.request.arguments[0] != 'pass');493  },494  handle(handlerInput) {495    const request = handlerInput.requestEnvelope.request;496    if (request.type  === 'Alexa.Presentation.APL.UserEvent') {497      selectedIndex = parseInt(request.arguments[0]);498    }499    SELECTED = selectedIndex;500    501    if (SELECTED == 0){502      return handlerInput.responseBuilder503        .speak('')504        .addDirective({505            type: 'Alexa.Presentation.APL.RenderDocument',506            document: require('./homepage.json'),507            datasources: {}508        })509        .getResponse();510      }511      if (SELECTED == 1){512      return handlerInput.responseBuilder513        .speak('')514        .addDirective({515            type: 'Alexa.Presentation.APL.RenderDocument',516            token: "VideoPlayerToken",517            document: require('./miseen.json'),518            datasources: {}519        })520        .getResponse();521      }522      if (SELECTED == 2){523      return handlerInput.responseBuilder524        .speak('')525        .addDirective({526            type: 'Alexa.Presentation.APL.RenderDocument',527            token: "VideoPlayerToken",528            document: require('./step1.json'),529            datasources: {}530        })531        .getResponse();532      }533      if (SELECTED == 3){534      return handlerInput.responseBuilder535        .speak('')536        .addDirective({537            type: 'Alexa.Presentation.APL.RenderDocument',538            token: "VideoPlayerToken",539            document: require('./step2.json'),540            datasources: {}541        })542        .getResponse();543      }544      if (SELECTED == 4){545      return handlerInput.responseBuilder546        .speak('')547        .addDirective({548            type: 'Alexa.Presentation.APL.RenderDocument',549            token:"VideoPlayerToken",550            document: require('./step3.json'),551            datasources: {}552        })553        .getResponse();554      }555      if (SELECTED == 5){556      return handlerInput.responseBuilder557        .speak('')558        .addDirective({559            type: 'Alexa.Presentation.APL.RenderDocument',560            token: "VideoPlayerToken",561            document: require('./step4.json'),562            datasources: {}563        })564        .getResponse();565      }566      if (SELECTED == 6){567      return handlerInput.responseBuilder568        .speak('')569        .addDirective({570            type: 'Alexa.Presentation.APL.RenderDocument',571            token: "VideoPlayerToken",572            document: require('./step5.json'),573            datasources: {}574        })575        .getResponse();576      }577      if (SELECTED == 7){578      return handlerInput.responseBuilder579        .speak('')580        .addDirective({581            type: 'Alexa.Presentation.APL.RenderDocument',582            token:"VideoPlayerToken",583            document: require('./step6.json'),584            datasources: {}585        })586        .getResponse();587      }588      if (SELECTED == 8){589      return handlerInput.responseBuilder590        .speak('')591        .addDirective({592            type: 'Alexa.Presentation.APL.RenderDocument',593            token: "VideoPlayerToken",594            document: require('./step7.json'),595            datasources: {}596        })597        .getResponse();598      }599      if (SELECTED == 9){600      return handlerInput.responseBuilder601        .speak('')602        .addDirective({603            type: 'Alexa.Presentation.APL.RenderDocument',604            token: "VideoPlayerToken",605            document: require('./step8.json'),606            datasources: {}607        })608        .getResponse();609      }610      if (SELECTED == 10){611      return handlerInput.responseBuilder612        .speak('')613        .addDirective({614            type: 'Alexa.Presentation.APL.RenderDocument',615            token: "VideoPlayerToken",616            document: require('./step9.json'),617            datasources: {}618        })619        .getResponse();620      }621      if (SELECTED == 11){622      return handlerInput.responseBuilder623        .speak('')624        .addDirective({625            type: 'Alexa.Presentation.APL.RenderDocument',626            token: "VideoPlayerToken",627            document: require('./step10.json'),628            datasources: {}629        })630        .getResponse();631      }632      if (SELECTED == 12){633      return handlerInput.responseBuilder634        .speak('')635        .addDirective({636            type: 'Alexa.Presentation.APL.RenderDocument',637            token: "VideoPlayerToken",638            document: require('./step11.json'),639            datasources: {}640        })641        .getResponse();642      }643      if (SELECTED == 13){644      return handlerInput.responseBuilder645        .speak('')646        .addDirective({647            type: 'Alexa.Presentation.APL.RenderDocument',648            token: "VideoPlayerToken",649            document: require('./step12.json'),650            datasources: {}651        })652        .getResponse();653      }654      if (SELECTED == 14){655      return handlerInput.responseBuilder656        .speak('')657        .addDirective({658            type: 'Alexa.Presentation.APL.RenderDocument',659            token: "VideoPlayerToken",660            document: require('./step13.json'),661            datasources: {}662        })663        .getResponse();664      }665      if (SELECTED == 15){666      return handlerInput.responseBuilder667        .speak('')668        .addDirective({669            type: 'Alexa.Presentation.APL.RenderDocument',670            token: "VideoPlayerToken",671            document: require('./step14.json'),672            datasources: {}673        })674        .getResponse();675      }676      if (SELECTED == 16){677      return handlerInput.responseBuilder678        .speak('Thanks for baking with us!')679        .addDirective({680            type: 'Alexa.Presentation.APL.RenderDocument',681            document: require('./step15.json'),682            datasources: {}683        })684        .getResponse();685      }686      else {687      SELECTED = 1;688      return handlerInput.responseBuilder689        .speak('well this is awkward')690        .addDirective({691            type: 'Alexa.Presentation.APL.RenderDocument',692            token: "VideoPlayerToken",693            document: require('./miseen.json'),694            datasources: {}695        })696        .getResponse();697    }698  },699};700const miseenHandler = {701  canHandle(handlerInput) {702    return handlerInput.requestEnvelope.request.type === 'IntentRequest'703      && handlerInput.requestEnvelope.request.intent.name === 'miseen';704  },705  handle(handlerInput) {706      SELECTED = 1;707      708      if (SELECTED == 1){709      return handlerInput.responseBuilder710        .speak('')711        .addDirective({712            type: 'Alexa.Presentation.APL.RenderDocument',713            token:"VideoPlayerToken",714            document: require('./miseen.json'),715            datasources: {}716        })717        .getResponse();718      }719  },720};721const ShowthestepsHandler = {722  canHandle(handlerInput) {723    return handlerInput.requestEnvelope.request.type === 'IntentRequest'724      && handlerInput.requestEnvelope.request.intent.name === 'Showthesteps';725  },726  handle(handlerInput) {727      return handlerInput.responseBuilder728        .speak('This is a touchscreen list, you can scroll to see more steps and select any step to see the video')729        .addDirective({730            type: 'Alexa.Presentation.APL.RenderDocument',731            document: require('./steps.json'),732            token: 'steper',733            datasources: {}734        })735        .addDirective({736            type : 'Alexa.Presentation.APL.ExecuteCommands',737            token: "steper",738            commands: [739                {740                    type: "Parallel",741                    commands: [742                        {743                            type: "Idle",744                            delay: 60000745                        }],746                }747            ]748        })749        .getResponse();750  },751};752const voicerHandler = {753  canHandle(handlerInput) {754    return (handlerInput.requestEnvelope.request.type === 'Alexa.Presentation.APL.UserEvent'755        && handlerInput.requestEnvelope.request.arguments.length > 0756        && handlerInput.requestEnvelope.request.arguments[0] === 'pass');757  },758  handle(handlerInput) {759      SELECTED = 10;760      761      if (SELECTED == 10){762      return handlerInput.responseBuilder763        .speak('')764        .addDirective({765            type: 'Alexa.Presentation.APL.RenderDocument',766            token:"VideoPlayerToken",767            document: require('./step9.json'),768            datasources: {}769        })770        .getResponse();771      }772  },773};774const HomeIntentHandler = {775  canHandle(handlerInput) {776    return handlerInput.requestEnvelope.request.type === 'IntentRequest'777      && handlerInput.requestEnvelope.request.intent.name === 'AMAZON.NavigateHomeIntent';778  },779  handle(handlerInput) {780      SELECTED = 1;781      782      if (SELECTED == 1){783      return handlerInput.responseBuilder784        .speak('')785        .addDirective({786            type: 'Alexa.Presentation.APL.RenderDocument',787            document: require('./miseen.json'),788            datasources: {}789        })790        .getResponse();791      }792  },793};794const HelpIntentHandler = {795  canHandle(handlerInput) {796    return handlerInput.requestEnvelope.request.type === 'IntentRequest'797      && handlerInput.requestEnvelope.request.intent.name === 'AMAZON.HelpIntent';798  },799  handle(handlerInput) {800    const speechText = 'You can say next, go back, or home to navigate this app';801    return handlerInput.responseBuilder802      .speak(speechText)803      .reprompt(speechText)804      .getResponse();805  },806};807const ResumeAndPauseIntentHandler = {808  canHandle(handlerInput) {809    return handlerInput.requestEnvelope.request.type === 'IntentRequest'810      && (handlerInput.requestEnvelope.request.intent.name === 'AMAZON.ResumeIntent'811        || handlerInput.requestEnvelope.request.intent.name === 'AMAZON.PauseIntent');812  },813  handle(handlerInput) {814    CURR_STATE = !CURR_STATE;815    let playPause = CURR_STATE ? "play" : "pause";816      return handlerInput.responseBuilder817        .addDirective({818              type: "Alexa.Presentation.APL.ExecuteCommands",819              token: "VideoPlayerToken",820              commands: [821                {822                  type: "ControlMedia",823                  componentId: "myVideoPlayer",824                  command: playPause825                }826              ]827          })828        .getResponse();829    830  },831};...setupX.js
Source:setupX.js  
23456tp.addDirective("description", function(arr, params) {7  return typeof params.item.getDescription === "function" ? params.item.getDescription() : params.item.description;8});910tp.addDirective("attire", function(arr, params) {11  const l = params.item.getWearingVisible()12  return formatList(l, {article:INDEFINITE, lastJoiner:lang.list_and, nothing:"nothing", npc:true, noWorn:true, modified:arr[0] === 'mod', enhanced:true, noBrackets:true});13});1415tp.addDirective("posture", function(arr, params) {16  if (!params.item.posture) return ''17  return params.item.getPostureDescription()18})1920tp.addDirective("ifPosture", function(arr, params) {21  return params.item.posture && params.item.posture !== "standing" ? arr.join(":") : "";22});2324tp.addDirective("bpAdjective", function(arr, params) {25  let name = arr.shift()26  const obj = tp._findObject(name, params, arr)27  if (!obj) return errormsg("Failed to find object '" + name + "' in text processor 'bpAdjective' (" + params.tpOriginalString + ")")28  name = arr.shift()29  return obj.getBodyPartAdjective(name)30})3132tp.addDirective("restraint", function(arr, params) {33  if (!params.item.restraint) return ''34  return params.item.restraint.situation35})3637tp.addDirective("ifRestraint", function(arr, params) {38  return params.item.restraint ? arr[0] : arr[1]39})4041tp.addDirective("ifBare", function(arr, params) {42  const bodyPart = w[arr.shift()]43  return params.item.isBodyPartBare(bodyPart) ? arr[0] : arr[1]44})4546tp.addDirective("ifBP", function(arr, params) {47  let name = arr.shift()48  const obj = tp._findObject(name, params, arr)49  if (!obj) return errormsg("Failed to find object '" + name + "' in text processor 'ifBP' (" + params.tpOriginalString + ")")50  const bodyPart = w[arr.shift()]51  return obj.hasBodyPart(arr[0]) ? arr[1] : arr[2]52})5354tp.addDirective("covering", function(arr, params) {55  let name = arr.shift()56  const obj = tp._findObject(name, params, arr)57  const slot = arr[0]58  const subject = obj.getOuterWearable(slot)59  const options = {}60  if (arr[1] === 'the') options.article = DEFINITE61  if (arr[1] === 'a') options.article = INDEFINITE62  return arr[2] === 'true' ? sentenceCase(lang.getName(subject, options)) : lang.getName(subject, options)63})6465tp.addDirective("insult", function(arr, params) {66  let name = arr.shift()67  const obj = tp._findObject(name, params, arr)68  if (!obj) return errormsg("Failed to find object '" + name + "' in text processor 'ifBP' (" + params.tpOriginalString + ")")69  const target = tp._findObject(arr[0], params, arr)70  return obj.insult(target)71})727374// {arouse:chr:amt}75tp.addDirective("arouse", function(arr, params) {76  const chr = tp.findSubject(arr, params);77  if (!chr) return false;78  79  const amt = parseInt(arr[1])80  chr.arousal += amt81  return false;82});8384tp.addDirective("cock", function(arr, params) {85  const chr = tp.findSubject(arr, params);86  if (!chr) return false;87  if (chr.arousal < 30) return chr.getBodyPartAdjective('cock') + " willy";88  if (chr.arousal < 60) return chr.getBodyPartAdjective('cock') + " dick";89  if (chr.hasHugeCock)  return "huge, " + chr.getBodyPartAdjective('cock') + " cock";90  return chr.getBodyPartAdjective('cock') + " cock";91});9293tp.addDirective("tits", function(arr, params) {94  const chr = tp.findSubject(arr, params);95  if (!chr) return false;96  return chr.getBodyPartAdjective('tit') + " " + random.fromArray(chr.hasHugeBoobs ? erotica.bigTitsSynonyms : erotica.titsSynonyms);97});9899tp.addDirective("pussy", function(arr, params) {100  const chr = tp.findSubject(arr, params);101  if (!chr) return false;102  return chr.getBodyPartAdjective('pussy') + " pussy";103});104105tp.addDirective("ass", function(arr, params) {106  const chr = tp.findSubject(arr, params);107  if (!chr) return false;108  return chr.getBodyPartAdjective('ass') + " ass";109});110111112const erotica = {113  REFUSE:0,114  RELUCTANT:1,115  HAPPY:2,116};117118119
...app.js
Source:app.js  
...39    } catch (e) {40        console.log(JSON.stringify(e));41    }42}43addDirective("customSelect2", customSelect2);44addDirective("dateTimePicker", dateTimePicker);45addDirective("formatMoney", formatMoney);46addDirective("getWidth", getWidth);47addDirective("getHeight", getHeight);48addDirective("lazyLoad", lazyLoad);49addDirective("noInput", noInput);50addDirective("whenEnter", whenEnter);51addDirective("compile", compile);52addDirective("gridSort", gridSort);53addDirective("inputFormat", inputFormat);54addDirective("paginationStyle1", paginationStyle1);55addDirective("paginationStyle2", paginationStyle2);56//addDirective("exportData", exportData);57//addDirective("gridCheckBox", gridCheckBox);58//addDirective("gridCheckBoxVertical", gridCheckBoxVertical);59//addDirective("gridCheckBoxParent", gridCheckBoxParent);60//61//addDirective("gridCheckBoxProCat", gridCheckBoxProCat);62//addDirective("gridCheckBoxVerticalProCat", gridCheckBoxVerticalProCat);63//addDirective("gridCheckBoxParentProCat", gridCheckBoxParentProCat);64//65//#endregion Khai báo Directives66//#region Khai báo Filters67var addFilter = function (name, filter) {68    try {69        MyApp.filter(name, filter);70    } catch (e) {71        console.log(JSON.stringify(e));72    }73}74addFilter("dateFormat", dateFormat);75addFilter("trustHtml", trustHtml);76addFilter("ifEmpty", ifEmpty);77addFilter("toFixedDecimal", toFixedDecimal);...private.js
Source:private.js  
1Snakeskin.addDirective(2	'__&__',3	{4		group: 'ignore'5	},6	function () {7		this.startInlineDir();8		this.space = true;9	}10);11Snakeskin.addDirective(12	'__setFile__',13	{14	},15	function (command) {16		command = this.pasteDangerBlocks(command);17		var module = {18			exports: {},19			require: require,20			id: this.module.id + 1,21			filename: command,22			parent: this.module,23			children: [],24			loaded: true25		};26		this.module.children.push(module);27		this.module = module;28		this.info['file'] = command;29	}30);31Snakeskin.addDirective(32	'__endSetFile__',33	{34	},35	function () {36		this.module = this.module.parent;37		this.info['file'] = this.module.filename;38	}39);40Snakeskin.addDirective(41	'__setError__',42	{43	},44	function (command) {45		this.error(this.pasteDangerBlocks(command));46	}47);48Snakeskin.addDirective(49	'__end__',50	{51		alias: true52	},53	function () {54		Snakeskin.Directions['end'].apply(this, arguments);55	}56);57Snakeskin.addDirective(58	'__appendLine__',59	{60		group: 'ignore'61	},62	function (command) {63		if (!this.structure.parent) {64			return this.error(("directive \"cdata\" only be used only within a " + (groupsList['template'].join(', '))));65		}66		this.startInlineDir('cdata');67		this.isSimpleOutput();68		var val = parseInt(command, 10),69			line = this.info['line'];70		this.info['line'] += val;71		if (!this.proto) {72			for (var i = -1; ++i < val;) {73				this.lines[line + i] = '';74			}75		}76	}77);78Snakeskin.addDirective(79	'__setLine__',80	{81		group: 'ignore'82	},83	function (command) {84		this.startInlineDir();85		if (!this.freezeLine) {86			this.info['line'] = parseInt(command, 10);87		}88	}89);90Snakeskin.addDirective(91	'__freezeLine__',92	{93		group: 'ignore'94	},95	function (command) {96		this.startDir();97		if (!command && !this.freezeLine) {98			this.lines.pop();99			this.info['line']--;100		}101		if (!command || this.lines.length >= parseInt(command, 10)) {102			this.freezeLine++;103		}104	},105	function () {106		this.freezeLine--;107	}108);109Snakeskin.addDirective(110	'__cutLine__',111	{112		group: 'ignore'113	},114	function () {115		this.startInlineDir();116		if (!this.freezeLine) {117			this.lines.pop();118			this.info['line']--;119		}120	}121);122Snakeskin.addDirective(123	'__switchLine__',124	{125		group: 'ignore'126	},127	function (command) {128		var val = parseInt(command, 10);129		this.startDir(null, {130			line: this.info['line']131		});132		if (!this.freezeLine) {133			this.info['line'] = val;134		}135	},136	function () {137		if (!this.freezeLine) {138			this.info['line'] = this.structure.params.line;139		}140	}141);142Snakeskin.addDirective(143	'__protoWhile__',144	{145	},146	function (command) {147		this.startDir();148		if (this.isSimpleOutput()) {149			var i = this.prepareOutput('__I_PROTO__', true);150			protoCache[this.tplName][this.proto.name].i = i;151			this.save((("" + i) + (":while (" + (this.prepareOutput(command, true))) + ") {"));152		}153	},154	function () {155		if (this.isSimpleOutput()) {156			this.save('}');...private.es6
Source:private.es6  
1Snakeskin.addDirective(2	'__&__',3	{4		group: 'ignore'5	},6	function () {7		this.startInlineDir();8		this.space = true;9	}10);11Snakeskin.addDirective(12	'__setFile__',13	{14	},15	function (command) {16		command = this.pasteDangerBlocks(command);17		let module = {18			exports: {},19			require: require,20			id: this.module.id + 1,21			filename: command,22			parent: this.module,23			children: [],24			loaded: true25		};26		this.module.children.push(module);27		this.module = module;28		this.info['file'] = command;29	}30);31Snakeskin.addDirective(32	'__endSetFile__',33	{34	},35	function () {36		this.module = this.module.parent;37		this.info['file'] = this.module.filename;38	}39);40Snakeskin.addDirective(41	'__setError__',42	{43	},44	function (command) {45		this.error(this.pasteDangerBlocks(command));46	}47);48Snakeskin.addDirective(49	'__end__',50	{51		alias: true52	},53	function () {54		Snakeskin.Directions['end'].apply(this, arguments);55	}56);57Snakeskin.addDirective(58	'__appendLine__',59	{60		group: 'ignore'61	},62	function (command) {63		if (!this.structure.parent) {64			return this.error(`directive "cdata" only be used only within a ${groupsList['template'].join(', ')}`);65		}66		this.startInlineDir('cdata');67		this.isSimpleOutput();68		var val = parseInt(command, 10),69			line = this.info['line'];70		this.info['line'] += val;71		if (!this.proto) {72			for (let i = -1; ++i < val;) {73				this.lines[line + i] = '';74			}75		}76	}77);78Snakeskin.addDirective(79	'__setLine__',80	{81		group: 'ignore'82	},83	function (command) {84		this.startInlineDir();85		if (!this.freezeLine) {86			this.info['line'] = parseInt(command, 10);87		}88	}89);90Snakeskin.addDirective(91	'__freezeLine__',92	{93		group: 'ignore'94	},95	function (command) {96		this.startDir();97		if (!command && !this.freezeLine) {98			this.lines.pop();99			this.info['line']--;100		}101		if (!command || this.lines.length >= parseInt(command, 10)) {102			this.freezeLine++;103		}104	},105	function () {106		this.freezeLine--;107	}108);109Snakeskin.addDirective(110	'__cutLine__',111	{112		group: 'ignore'113	},114	function () {115		this.startInlineDir();116		if (!this.freezeLine) {117			this.lines.pop();118			this.info['line']--;119		}120	}121);122Snakeskin.addDirective(123	'__switchLine__',124	{125		group: 'ignore'126	},127	function (command) {128		var val = parseInt(command, 10);129		this.startDir(null, {130			line: this.info['line']131		});132		if (!this.freezeLine) {133			this.info['line'] = val;134		}135	},136	function () {137		if (!this.freezeLine) {138			this.info['line'] = this.structure.params.line;139		}140	}141);142Snakeskin.addDirective(143	'__protoWhile__',144	{145	},146	function (command) {147		this.startDir();148		if (this.isSimpleOutput()) {149			let i = this.prepareOutput('__I_PROTO__', true);150			protoCache[this.tplName][this.proto.name].i = i;151			this.save(`${i}:while (${this.prepareOutput(command, true)}) {`);152		}153	},154	function () {155		if (this.isSimpleOutput()) {156			this.save('}');...space.js
Source:space.js  
...6 * Released under the MIT license7 * https://github.com/SnakeskinTpl/Snakeskin/blob/master/LICENSE8 */9import Snakeskin from '../core';10Snakeskin.addDirective(11	'ignoreWhitespaces',12	{13		group: ['ignoreWhitespaces', 'space'],14		placement: 'template',15		shorthands: {'&': 'ignoreWhitespaces '}16	},17	function () {18		this.space = true;19		this.prevSpace = true;20	}21);22Snakeskin.addDirective(23	'ignoreAllWhitespaces',24	{25		block: true,26		group: ['ignoreAllWhitespaces', 'space'],27		placement: 'template',28		shorthands: {'&+': 'ignoreAllWhitespaces '}29	},30	function () {31		this.strongSpace.push(true);32	},33	function () {34		this.strongSpace.pop();35		this.sysSpace = Number(this.sysSpace);36	}37);38Snakeskin.addDirective(39	'unIgnoreAllWhitespaces',40	{41		block: true,42		group: ['unIgnoreAllWhitespaces', 'space'],43		placement: 'template',44		shorthands: {'&-': 'unIgnoreAllWhitespaces '}45	},46	function () {47		this.strongSpace.push(false);48	},49	function () {50		this.strongSpace.pop();51		this.sysSpace = Number(this.sysSpace);52	}53);54Snakeskin.addDirective(55	'sp',56	{57		group: ['sp', 'space'],58		shorthands: {'\\': 'sp '},59		text: true60	}61);62Snakeskin.addDirective(63	'__sp__',64	{65		group: 'ignore',66		text: true67	}68);69Snakeskin.addDirective(70	'__&+__',71	{72		group: 'ignore'73	},74	function () {75		if (this.tolerateWhitespaces) {76			return;77		}78		this.sysSpace = true;79	}80);81Snakeskin.addDirective(82	'__&-__',83	{84		group: 'ignore'85	},86	function () {87		if (this.tolerateWhitespaces) {88			return;89		}90		if (this.sysSpace === 1) {91			this.space = false;92		}93		this.sysSpace = false;94	}95);VectorableGraphics.js
Source:VectorableGraphics.js  
...3    constructor(){4        super();5        this.directives = [];6    }7    addDirective(prefix, values){8        this.directives.push(`${prefix} ${values.join(' ')}`);9    }10    clear(){11        12        this.directives = [];13        super.clear();14    }15    moveTo(x, y){16        this.addDirective('M', [x, y]);17        super.moveTo(x, y);18    }19    lineTo(x, y){20        this.addDirective('L', [x, y]);21        super.lineTo(x, y);22    }23    verticalLineTo(x, y){24        this.addDirective('V', [x]);25        super.lineTo(x, y);26    }27    horizontalLineTo(x, y){28        this.addDirective('H', [y]);29        super.lineTo(x, y);30    }31    smoothLineTo(x, y){32        this.addDirective('T', [x, y]);33        super.lineTo(x, y);34    }35    quadraticCurveTo(cx, cy, dx, dy){36        this.addDirective('Q', [cx, cy, dx, dy]);37        super.quadraticCurveTo(cx, cy, dx, dy);38    }39    smoothQuadraticCurveTo(cx, cy, dx, dy){40        this.addDirective('S', [cx, cy, dx, dy]);41        super.quadraticCurveTo(cx, cy, dx, dy);42    }43    bezierCurveTo(c1x, c1y, c2x, c2y, dx, dy){44        this.addDirective('C', [c1x, c1y, c2x, c2y, dx, dy]);45        super.bezierCurveTo(c1x, c1y, c2x, c2y, dx, dy);46    }47    endFill(){48        this.addDirective('Z', []);49        super.endFill();50    }51    vectorize(){52        return this.directives.join('');53    }...Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3  const browser = await chromium.launch();4  const context = await browser.newContext();5  const page = await context.newPage();6  const addDirective = (name, value) => {7    const directive = { name, value };8    page._delegate._client.send('Page.addScriptToEvaluateOnNewDocument', { source: `window['${name}'] = '${value}';`, worldName: 'main' });9    page._delegate._pageBindings.set(name, directive);10  };11  addDirective('test', 'test');12  await page.evaluate(() => {13    console.log(test);14  });15  await browser.close();16})();17const { chromium } = require('playwright');18(async () => {19  const browser = await chromium.launch();20  const context = await browser.newContext();21  const page = await context.newPage();22  page._delegate._client.send('Page.addScriptToEvaluateOnNewDocument', { source: `console.log('Hello World');`, worldName: 'main' });23  await browser.close();24})();Using AI Code Generation
1const { addDirective } = require('@playwright/test');2addDirective('myDirective', async (page, name, value) => {3  await page.evaluate((name, value) => {4    window[name] = value;5  }, name, value);6});7test.use({ myDirective: 'foo', 'bar' });8const { addStep } = require('@playwright/test');9addStep('myStep', async (page, name, value) => {10  await page.evaluate((name, value) => {11    window[name] = value;12  }, name, value);13});14test('my test', async ({ page }) => {15  await page.myStep('foo', 'bar');16});17const { addWorker } = require('@playwright/test');18addWorker('myWorker', async ({ page }, name, value) => {19  await page.evaluate((name, value) => {20    window[name] = value;21  }, name, value);22});23test('my test', async ({ myWorker }) => {24  await myWorker('foo', 'bar');25});Using AI Code Generation
1const playwright = require('playwright');2const { addDirective, addDirectiveToContext } = require('playwright/lib/server/injected/injectedScript');3(async () => {4  const browser = await playwright.chromium.launch();5  const context = await browser.newContext();6  addDirectiveToContext(context, 'test', 'test', (selector, name, arg) => {7    console.log(selector, name, arg);8  });9  const page = await context.newPage();10  await page.addDirective('test', 'test', 'test');11  await browser.close();12})();13const playwright = require('playwright');14const { addDirective, addDirectiveToContext } = require('playwright/lib/server/injected/injectedScript');15(async () => {16  const browser = await playwright.chromium.launch();17  const context = await browser.newContext();18  const page = await context.newPage();19  await page.addDirective('input.gLFyf.gsfi', 'test', 'test');20  await browser.close();21})();Using AI Code Generation
1const { addDirective } = require('@playwright/test');2addDirective('waitFor', async (element, timeout = 10000, message) => {3  await element.waitForElementState('visible', { timeout, message });4});5const { test, expect } = require('@playwright/test');6test('test', async ({ page }) => {7  await page.waitFor(page.locator('#features'));8  const features = page.locator('#features');9  const text = await features.textContent();10  expect(text).toBe('Playwright is a Node.js library to automate');11});Using AI Code Generation
1const { addDirective } = require('@playwright/test/lib/test');2addDirective('testDirective', async function (test, body) {3  await test.step('testDirective', async () => {4    await body();5  });6});7test('testDirective', async ({ page }) => {8  await page.testDirective(async () => {9    await page.click('text=Get started');10  });11});12  ✓ testDirective (1s)13### `addDirective(name, callback)`14[MIT](LICENSE)Using AI Code Generation
1const { addDirective } = require('@playwright/test');2addDirective('directiveName', (name) => {3});4const { addDirective } = require('@playwright/test');5addDirective('directiveName', (name) => {6});7test('test name', async ({ page }) => {8  await page.directiveName('value');9});10test('test name', async ({ page }) => {11  await page.directiveName('value');12});13const { test, expect } = require('@playwright/test');14const { addDirective } = require('@playwright/test');15addDirective('directiveName', (name) => {16});17const { test, expect } = require('@playwright/test');18const { addDirective } = require('@playwright/test');19addDirective('directiveName', (name) => {20});21test('test name', async ({ page }) => {22  await page.directiveName('value');23});24test('test name', async ({ page }) => {25  await page.directiveName('value');26});27const { test, expect } = require('@playwright/test');28const { addDirective } = require('@playwright/test');29addDirective('directiveName', (name) => {30});31const { test, expect } = require('@playwright/test');32const { addDirective } = require('@playwright/test');33addDirective('directiveName', (name) => {34});LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!
