How to use trustHTML method in Protractor

Best JavaScript code snippet using protractor

order.js

Source:order.js Github

copy

Full Screen

1/* tcy -start-*/2if (!window.F) window.F = {};3/* tcy -end-*/45var app = angular.module("orderApp", []);6app.filter("priceFormat", function() {7 //可以注入依赖8 return F._priceFormat;9});1011app.controller("orderCtrl", function($scope, $http, $filter, $sce) {12 $scope.msisdn = localStorage.getItem("msisdnFormat");1314 $scope.cancelStatus = "1";15 $scope.payStatus = "1";16 $scope.orderStatus = "1";1718 /*请求账单数据*/1920 var query = F._hrefUtils.parse().query || {};2122 //初始化账单请求参数23 $scope.reqPara = {24 status: query.status || "99999",25 page: query.page || "1",26 rows: "5"27 };2829 var status_json = {30 99999: 0,31 10004: 1,32 30000: 2,33 30001: 334 };3536 function orderOperate(status, payRate) {37 status = +status;38 if (payRate !== 1 && status === 10000) status = 54321;39 var result = [];40 switch (status) {41 case 10000: // 交易创建,等待买家付款42 result = [43 {44 name: "Quản lý đơn hàng",45 type: "detail",46 class: ""47 },48 {49 name: "Thanh toán",50 type: "pay",51 class: ""52 },53 {54 name: "Hủy",55 type: "cancel",56 class: ""57 }58 ];59 break;6061 case 30001: // 待评价62 result = [63 {64 name: "Quản lý đơn hàng",65 type: "detail",66 class: ""67 },68 {69 name: "Đánh giá",70 type: "review",71 class: ""72 }73 ];74 break;7576 case 54321: // 分期订单不支持取消77 result = [78 {79 name: "Quản lý đơn hàng",80 type: "detail",81 class: ""82 },83 {84 name: "Thanh toán",85 type: "pay",86 class: ""87 }88 ];89 break;9091 default:92 result = [93 {94 name: "Quản lý đơn hàng",95 type: "detail",96 class: ""97 }98 ];99 break;100 }101 return result;102 }103104 // $scope.orderOperate = orderOperate;105106 // : 0,107 // 2: 1,108 // 5: 2,109 // 6: 3,110111 $(".nav-item").removeClass("act");112 $(".nav-item")113 .eq(status_json[$scope.reqPara.status])114 .addClass("act");115116 //上一页117 $scope.lastPage = function() {118 if ($scope.reqPara.page > 1) {119 $scope.reqPara.page--;120 }121 F._setUrl("page", $scope.reqPara.page);122 };123124 //下一页125 $scope.nextPage = function() {126 if ($scope.reqPara.page < $scope.totalPage) {127 $scope.reqPara.page++;128 }129 F._setUrl("page", $scope.reqPara.page);130 };131132 $scope.confirm = function() {133 var page = $("#gotoPage").val();134 $scope.reqPara.page = page;135 };136137 //切换订单类型138 $scope.reqType = function(type) {139 // if (type != null) {140 // $scope.reqPara = {141 // status: type,142 // page: '1',143 // rows: '5'144 // }145 // } else {146 // $scope.reqPara = {147 // status: "",148 // page: '1',149 // rows: '5'150 // }151 // }152153 var status = "status";154 var page = "1";155 var rows = "5";156157 if (type != null) {158 status = type;159 }160161 $scope.reqPara = {162 status: status,163 page: page,164 rows: rows165 };166167 F._setUrl("page", "1");168169 $("#gotoPage").val("1");170 };171 $scope.$watch("iptpage", function(n, o) {172 if (n < 1) {173 $scope.iptpage = 1;174 } else if (n > $scope.totalPage) {175 $scope.iptpage = $scope.totalPage;176 }177 });178 $scope.$watch(179 "reqPara",180 function(n, o) {181 if (n.page > 0) {182 if (n.page <= $scope.totalPage && n.rows <= $scope.count) {183 } else {184 $scope.reqPara.page = o.page;185 $scope.reqPara.rows = o.rows;186 }187 } else {188 $scope.reqPara.page = 1;189 }190 orderDetailsAjax(n.status, n.page, n.rows);191 },192 true193 );194195 function orderDetailsAjax(status, page, rows) {196 if (!F._isLogin()) return false;197198 var loading = new F._loading();199 loading.show();200 var url = F._queryOrderList_td;201 var ajax = new ajaxClass($http, url, "POST");202203 var appid = localStorage.getItem("funId");204 var method = "fun.trade.queryList";205 var charset = "utf-8";206 var msisdn = localStorage.getItem("msisdn");207 var funId = localStorage.getItem("funId");208 $scope.funId = funId;209 $scope.msisdn = msisdn;210 var page = page;211 var rows = rows;212 var status = status;213 var Key = "tradeKey";214215 var md5SigntypeStrig = "appid=" + appid + "&method=" + method + "&charset=" + charset + Key;216 var signtype = hex_md5(md5SigntypeStrig);217218 var md5EncryptStrig = "funid=" + funId + "&page=" + page + "&rows=" + rows + "&status=" + status + Key;219 var encrypt = hex_md5(md5EncryptStrig);220221 ajax.data = $.param({222 appid: appid,223 method: method,224 charset: "utf-8",225 signtype: signtype,226 encrypt: encrypt,227 timestamp: "2017-9-21 09:51:41",228 version: "2.0",229 funid: funId,230 page: page,231 rows: rows,232 status: status233 });234235 ajax.headers = {236 "Content-Type": "application/x-www-form-urlencoded"237 };238239 ajax.successCallback = function(res) {240 loading.hide();241 function edit_for_status($scope, tradeStatus) {242 switch (tradeStatus) {243 case "10000":244 $scope.myHtml = "<span>" + F._tradeStatus(tradeStatus) + "</span>";245 $scope.trustHtml = $sce.trustAsHtml($scope.myHtml);246 $scope.orderList[i]["tradeStatusMsg"] = $scope.trustHtml;247248 $scope.orderList[i].operate = [249 {250 name: "Thông tin cụ thể về đơn hàng"251 },252 {253 name: "Thanh toán",254 type: "pay"255 },256 {257 name: "Hủy",258 type: "cancel"259 }260 ];261 break;262263 // case "10001":264 // $scope.myHtml = "<span>" + F._tradeStatus(tradeStatus) + "</span>";265 // $scope.trustHtml = $sce.trustAsHtml($scope.myHtml);266 // $scope.orderList[i]["tradeStatusMsg"] = $scope.trustHtml;267 // $scope.orderList[i].operate = [268 // {269 // name: "Thông tin cụ thể về đơn hàng"270 // }271 // ];272 // break;273274 case "10003": // 交易支付等待275 $scope.myHtml = "<span>" + F._tradeStatus(tradeStatus) + "</span>";276 $scope.trustHtml = $sce.trustAsHtml($scope.myHtml);277 $scope.orderList[i]["tradeStatusMsg"] = $scope.trustHtml;278 $scope.orderList[i].operate = [279 {280 name: "Thông tin cụ thể về đơn hàng"281 }282 ];283 break;284285 case "10003": // 待审核(新流程)286 $scope.myHtml = "<span>" + F._tradeStatus(tradeStatus) + "</span>";287 $scope.trustHtml = $sce.trustAsHtml($scope.myHtml);288 $scope.orderList[i]["tradeStatusMsg"] = $scope.trustHtml;289 $scope.orderList[i].operate = [290 {291 name: "Thông tin cụ thể về đơn hàng"292 }293 ];294 break;295296 case "20000":297 $scope.myHtml = "<span>" + F._tradeStatus(tradeStatus) + "</span>";298 $scope.trustHtml = $sce.trustAsHtml($scope.myHtml);299 $scope.orderList[i]["tradeStatusMsg"] = $scope.trustHtml;300 $scope.orderList[i].operate = [301 {302 name: "Thông tin cụ thể về đơn hàng"303 }304 ];305 break;306307 case "20001":308 $scope.myHtml = "<span>" + F._tradeStatus(tradeStatus) + "</span>";309 $scope.trustHtml = $sce.trustAsHtml($scope.myHtml);310 $scope.orderList[i]["tradeStatusMsg"] = $scope.trustHtml;311 $scope.orderList[i].operate = [312 {313 name: "Thông tin cụ thể về đơn hàng"314 }315 ];316 break;317318 case "20002":319 $scope.myHtml = "<span>" + F._tradeStatus(tradeStatus) + "</span>";320 $scope.trustHtml = $sce.trustAsHtml($scope.myHtml);321 $scope.orderList[i]["tradeStatusMsg"] = $scope.trustHtml;322 $scope.orderList[i].operate = [323 {324 name: "Thông tin cụ thể về đơn hàng"325 }326 ];327 break;328329 case "30000":330 $scope.myHtml = "<span>" + F._tradeStatus(tradeStatus) + "</span>";331 $scope.trustHtml = $sce.trustAsHtml($scope.myHtml);332 $scope.orderList[i]["tradeStatusMsg"] = $scope.trustHtml;333 $scope.waitList = [];334 $scope.waitList.push($scope.orderList[i]);335 $scope.orderList[i].operate = [336 {337 name: "Thông tin sản phẩm"338 }339 ];340 $("#shouhuoTip").css("display", "none");341 $("#shouhuoTbody").css("display", "block");342 break;343344 case "30001":345 $scope.myHtml = "<span>" + F._tradeStatus(tradeStatus) + "</span>";346 $scope.trustHtml = $sce.trustAsHtml($scope.myHtml);347 $scope.orderList[i]["tradeStatusMsg"] = $scope.trustHtml;348 $scope.orderList[i].operate = [349 {350 name: "Thông tin cụ thể về đơn hàng"351 },352 {353 name: "Đánh giá",354 type: "review"355 }356 ];357 break;358359 case "30002":360 $scope.myHtml = "<span>" + F._tradeStatus(tradeStatus) + "</span>";361 $scope.trustHtml = $sce.trustAsHtml($scope.myHtml);362 $scope.orderList[i]["tradeStatusMsg"] = $scope.trustHtml;363 $scope.orderList[i].operate = [364 {365 name: "Thông tin cụ thể về đơn hàng"366 }367 ];368 break;369370 case "40000":371 case "40001":372 case "40002":373 case "40003":374 case "40004":375 case "40005":376 $scope.myHtml = "<span>" + F._tradeStatus(tradeStatus) + "</span>";377 $scope.trustHtml = $sce.trustAsHtml($scope.myHtml);378 $scope.orderList[i]["tradeStatusMsg"] = $scope.trustHtml;379 $scope.orderList[i].operate = [380 {381 name: "Thông tin cụ thể về đơn hàng"382 }383 ];384 break;385386 default:387 $scope.myHtml = "<span>" + F._tradeStatus(tradeStatus) + "</span>";388 $scope.trustHtml = $sce.trustAsHtml($scope.myHtml);389 $scope.orderList[i]["tradeStatusMsg"] = $scope.trustHtml;390 break;391 }392 }393394 var resCode = res.status;395 if (resCode == 200) {396 $scope.orderList = res.data.details;397398 if ($scope.orderList.length == 0) {399 $(".changePage").css("display", "none");400 $(".no_list").css("display", "block");401 }402403 $scope.count = res.data.count;404405 $scope.totalPage = parseInt($scope.count / $scope.reqPara.rows);406407 /*tcy -start-*/408 if ($scope.count % $scope.reqPara.rows !== 0) {409 $scope.totalPage += 1;410 }411 /*tcy -end-*/412413 if ($scope.orderList) {414 // $scope.newOrderList = [];415 for (var j = 0; j < $scope.orderList.length; j++) {416 if (typeof $scope.orderList[j].goodsDetail != "undefined") {417 var item = $scope.orderList[j];418 item.orderOperate = orderOperate(item.tradeStatus, item.payRate);419 // $scope.newOrderList.push(item);420 // $scope.newOrderList[j] = $scope.orderList[j];421 // var goodsDetailObj = $scope.orderList[j].goodsDetail; //数组对象goodsDetail的JSON解析成对象422423 // var price = goodsDetailObj.price;424 // var creatData = goodsDetailObj.createTime;425426 // var imageUrl = goodsDetailObj.iconUrl;427428 // $scope.newOrderList[j]["imgUrl"] = imageUrl;429 // $scope.newOrderList[j]["price"] = price;430 // $scope.newOrderList[j]["creatData"] = creatData;431 }432 }433434 if (status == 0 || status == null || status == "99999") {435 if ($scope.orderList.length == 0) {436 $(".no_list").show();437 } else {438 $(".no_list").hide();439 $(".changePage").show();440 for (var i = 0; i < $scope.orderList.length; i++) {441 $scope.orderStatus = [];442 //$('.dpj').hide();443444 edit_for_status($scope, $scope.orderList[i].tradeStatus);445 }446 }447 } else if (status == "10001") {448 if ($scope.orderList.length == 0) {449 $(".no_list").show();450 } else {451 $(".no_list").hide();452 $(".changePage").show();453 for (var i = 0; i < $scope.orderList.length; i++) {454 $scope.orderStatus = [];455456 edit_for_status($scope, $scope.orderList[i].tradeStatus);457 }458 }459 } else {460 if ($scope.orderList.length == 0) {461 $(".no_list").show();462 } else {463 $(".no_list").hide();464 $(".changePage").show();465 for (var i = 0; i < $scope.orderList.length; i++) {466 $(".no_list").hide();467 $scope.orderStatus = [];468469 edit_for_status($scope, $scope.orderList[i].tradeStatus);470 }471 }472 }473 } else {474 $scope.orderList = "No orders!";475 }476 } else {477 $(".changePage").css("display", "none");478 }479 };480 ajax.failureCallback = function(res) {481 $(".changePage").css("display", "none");482 };483 ajax.requestData();484 }485486 $scope.getUserInfoDetails = function() {487 var url = F._userViewDetailInfo_uc;488 var ajax = new ajaxClass($http, url, "POST");489490 var appId = localStorage.getItem("funId");491 var method = "fun.uc.userviewdetail";492 var charset = "utf-8";493 var funid = localStorage.getItem("funId");494 var msisdn = localStorage.getItem("msisdn");495 var Key = "userKey";496497 var md5SigntypeStrig = "appId=" + appId + "&method=" + method + "&charset=" + charset + Key;498 var signType = hex_md5(md5SigntypeStrig);499500 var md5EncryptStrig = "funid=" + funid + "&msisdn=" + msisdn + Key;501 var encrypt = hex_md5(md5EncryptStrig);502503 ajax.data = $.param({504 appId: appId,505 method: method,506 charset: "utf-8",507 signType: signType,508 encrypt: encrypt,509 timestamp: "2017-09-06 11:30:50",510 version: "1.0",511 funid: funid,512 msisdn: msisdn513 });514515 ajax.headers = {516 "Content-Type": "application/x-www-form-urlencoded"517 };518 ajax.successCallback = function(res) {519 var resCode = res.data.code;520521 if (resCode == 10000) {522 /*tcy -start-*/523524 F.username = res.data.username;525 /*tcy -end-*/526527 $scope.centerUserInfo = res.data;528529 $scope.headimage = res.data.headimage;530 $(".img-phone").attr("src", $scope.headimage);531 } else {532 }533 };534 ajax.failureCallback = function(res) {};535 ajax.requestData();536 };537538 $scope.getUserInfoDetails();539540 $scope.product = function(typeId, brandId, sourceOrderType) {541 gotoDetails(typeId, brandId, sourceOrderType);542 };543544 function order_cancel(orderNo, tradeNo) {545 var loading = new F._loading();546 F._order_cancel(function(code) {547 if (!code) return false;548549 loading.show();550 F._orderCancel(551 {552 orderNo: orderNo,553 tradeNo: tradeNo,554 status: code555 },556 function(ret) {557 loading.hide();558 if (!ret) return false;559 if (ret.code !== 10000) return false;560561 window.location.reload();562 }563 );564 });565 }566567 $scope.order_func = function(type, orderNo, tradeNo, tradeStatus) {568 switch (type) {569 case "detail":570 case "pay":571 window.location.href = "./orderDetail.html?orderNo=" + orderNo + "&tradeNo=" + tradeNo;572 break;573574 case "review":575 window.location.href = "./evaluate.html?orderNo=" + orderNo + "&tradeNo=" + tradeNo;576 break;577578 case "cancel":579 order_cancel(orderNo, tradeNo);580 break;581582 default:583 window.location.href = "./orderDetail.html?orderNo=" + orderNo + "&tradeNo=" + tradeNo;584 break;585 }586 };587588 /* tcy 查看订单详情 -start- */589 $scope.openDetail = function(orderNo, tradeNo, typeId, brandId, tradeStatus, imgUrl, subject, key, type) {590 if (key > 0) {591 // 按钮592 switch (type) {593 case "cancel":594 order_cancel(orderNo, tradeNo);595 break;596597 case "pay":598 tradeStatus = tradeStatus + "";599 if (tradeStatus === "6") {600 // 评论601 window.location.href = "./evaluate.html?orderNo=" + orderNo + "&tradeNo=" + tradeNo + "&typeId=" + typeId + "&brandId=" + brandId + "&imgUrl=" + imgUrl + "&subject=" + subject + "&username=" + F.username;602 // window.open("./evaluate.html?orderNo=" + orderNo + "&tradeNo=" + tradeNo + "&typeId=" + typeId + "&brandId=" + brandId + "&imgUrl=" + imgUrl + "&subject=" + subject + "&username=" + F.username);603 } else {604 window.location.href = "./orderDetail.html?orderNo=" + orderNo + "&tradeNo=" + tradeNo + "&typeId=" + typeId + "&brandId=" + brandId;605 // window.open("./orderDetail.html?orderNo=" + orderNo + "&tradeNo=" + tradeNo+ "&typeId=" + typeId+ "&brandId=" + brandId);606 }607 break;608609 case "review":610 window.location.href = "./evaluate.html?orderNo=" + orderNo + "&tradeNo=" + tradeNo + "&typeId=" + typeId + "&brandId=" + brandId + "&imgUrl=" + imgUrl + "&subject=" + subject + "&username=" + F.username;611 break;612613 default:614 // TODO615 break;616 }617 } else {618 // 详情619 tradeStatus = tradeStatus + "";620 if (tradeStatus === "6") {621 // 评论622 window.location.href = "./evaluate.html?orderNo=" + orderNo + "&tradeNo=" + tradeNo + "&typeId=" + typeId + "&brandId=" + brandId + "&imgUrl=" + imgUrl + "&subject=" + subject + "&username=" + F.username;623 // window.open("./evaluate.html?orderNo=" + orderNo + "&tradeNo=" + tradeNo + "&typeId=" + typeId + "&brandId=" + brandId + "&imgUrl=" + imgUrl + "&subject=" + subject + "&username=" + F.username);624 } else {625 window.location.href = "./orderDetail.html?orderNo=" + orderNo + "&tradeNo=" + tradeNo + "&typeId=" + typeId + "&brandId=" + brandId;626 // window.open("./orderDetail.html?orderNo=" + orderNo + "&tradeNo=" + tradeNo+ "&typeId=" + typeId+ "&brandId=" + brandId);627 }628 }629 };630631 $scope.timeStrForm = F._timeStrForm;632 /* tcy 查看订单详情 -end- */633634 //点击商品页面跳转详情635 function gotoDetails(typeId, brandId, sourceOrderType) {636 637 if (brandId != null && brandId != "" && typeId != null && typeId != "") {638 // 0:普通订单;1:购物车订单 2 拼单 3 虚拟卡639 switch (sourceOrderType) {640 case 0:641 case 1:642 window.location.href = "./details.html?typeId=" + typeId + "&brandId=" + brandId;643 break;644 645 case 2:646 window.location.href = "./addOnItemdetails.html?brandId=" + brandId;647 break;648 default:649 break;650 }651 // if (sourceOrderType !== 0 && sourceOrderType !== 1) {652 // window.location.href = "./addOnItemdetails.html?brandId=" + brandId;653 // } else {654 // window.location.href = "./details.html?typeId=" + typeId + "&brandId=" + brandId;655 // }656 } else {657 window.location.href = "";658 }659 } ...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...270 } else {271 return $sce.trustAsHtml(lang);272 }273 }274 $scope.installProgress.messages.push(trustHTML("startInstall"));275 var installSteps = {276 _query: function(step, callback) {277 $http.post(config.BSU+"install", {278 step: step,279 data: $scope.$parent.configure,280 installing: true281 }).success(callback);282 },283 testDB: function() {284 installSteps._query("testDB", function(rs){285 if(rs.error) {286 $scope.installProgress.type = "danger";287 $scope.installProgress.messages.push(trustHTML("testDbConnectFailed"));288 $scope.installProgress.messages.push(trustHTML(rs.msg, false));289 return false;290 } else {291 $scope.installProgress.messages.push(trustHTML("testDbConnectSuccess"));292 installSteps.importData()293 }294 });295 },296 importData: function() {297 $scope.installProgress.messages.push(trustHTML("importingData"));298 installSteps._query("importDB", function(rs){299 if(rs.error) {300 var msg = "SQL:"+rs.msg.replace("\n", "");301 $scope.installProgress.type = "danger";302 $scope.installProgress.messages.push(trustHTML("importFailed"));303 $scope.installProgress.messages.push(trustHTML(msg, false));304 return false;305 } else {306 $scope.installProgress.messages.push(trustHTML("completeImport"));307 installSteps.importAdmin()308 }309 });310 },311 importAdmin: function() {312 $scope.installProgress.messages.push(trustHTML("configuringAdmin"));313 installSteps._query("init", function(rs){314 if(rs.error) {315 $scope.installProgress.type = "danger";316 $scope.installProgress.messages.push(trustHTML("configureAdminFailed"));317 return false;318 } else {319 $scope.installProgress.messages.push(trustHTML("completeConfigureAdmin"));320 installSteps.clearData()321 }322 });323 },324 clearData: function() {325 $scope.installProgress.messages.push(trustHTML("clearInstallData"));326 installSteps._query("clearData", function(rs){327 if(rs.error) {328 $scope.installProgress.type = "danger";329 $scope.installProgress.messages.push(trustHTML("clearInstallDataFailed"));330 return false;331 } else {332 $scope.installProgress.messages.push(trustHTML("installComplete"));333 }334 });335 }336 };337 installSteps.testDB();338 ones.caches.clear();339 //console.log(angular.toJson($scope.$parent.configure));340 }])341 ;...

Full Screen

Full Screen

swagger2-json-parser.js

Source:swagger2-json-parser.js Github

copy

Full Screen

1/*2 * Copyright 2017 StreamSets Inc.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16/*17 * Orange angular-swagger-ui - v0.2.318 *19 * (C) 2015 Orange, all right reserved20 * MIT Licensed21 */22angular23 .module('swaggerUi')24 .service('swagger2JsonParser', ['$q', '$sce', '$location', 'swaggerModel', function($q, $sce, $location, swaggerModel) {25 var swagger,26 trustedSources;27 function trustHtml(text) {28 var trusted = text;29 if (typeof text === 'string' && trustedSources) {30 trusted = $sce.trustAsHtml(text);31 }32 // else ngSanitize MUST be added to app33 return trusted;34 }35 /**36 * parses swagger description to ease HTML generation37 */38 function parseSwagger2Json(deferred, parseResult) {39 var operationId = 0,40 paramId = 0,41 map = {},42 form = {},43 resources = [],44 infos = swagger.info,45 openPath = $location.search().swagger,46 tag,47 i,48 res;49 // build URL params50 swagger.schemes = [swagger.schemes && swagger.schemes[0] ? swagger.schemes[0] : $location.protocol()];51 swagger.host = swagger.host || $location.host();52 // build main infos53 infos.scheme = swagger.schemes[0];54 infos.basePath = swagger.basePath;55 infos.host = swagger.host;56 infos.description = trustHtml(infos.description);57 // parse resources58 if (!swagger.tags) {59 resources.push({60 name: 'default',61 open: true62 });63 map['default'] = 0;64 } else {65 for (i = 0, l = swagger.tags.length; i < l; i++) {66 tag = swagger.tags[i];67 resources.push(tag);68 map[tag.name] = i;69 }70 }71 // parse operations72 for (var path in swagger.paths) {73 for (var httpMethod in swagger.paths[path]) {74 var operation = swagger.paths[path][httpMethod];75 //TODO manage 'deprecated' operations ?76 operation.id = operationId;77 operation.description = trustHtml(operation.description);78 operation.consumes = operation.consumes || swagger.consumes;79 operation.produces = operation.produces || swagger.produces;80 form[operationId] = {81 contentType: operation.consumes && operation.consumes.length === 1 ? operation.consumes[0] : 'application/json',82 responseType: 'application/json, text/plain, */*'83 };84 operation.httpMethod = httpMethod;85 operation.path = path;86 // parse operation's parameters87 for (var j = 0, params = operation.parameters || [], k = params.length; j < k; j++) {88 //TODO manage 'collectionFormat' (csv, multi etc.) ?89 //TODO manage constraints (pattern, min, max etc.) ?90 var param = params[j];91 if (param.$ref) {92 var parts = param.$ref.replace('#/', '').split('/');93 param = swagger[parts[0]][parts[1]];94 params[j] = param;95 }96 param.id = paramId;97 param.type = swaggerModel.getType(param);98 param.description = trustHtml(param.description);99 if (param.items && param.items.enum) {100 param.enum = param.items.enum;101 param.default = param.items.default;102 }103 param.subtype = param.enum ? 'enum' : param.type;104 // put param into form scope105 form[operationId][param.name] = param.default || '';106 if (param.schema) {107 param.schema.display = 1; // display schema108 param.schema.json = swaggerModel.generateSampleJson(swagger, param.schema);109 param.schema.model = $sce.trustAsHtml(swaggerModel.generateModel(swagger, param.schema));110 }111 if (param.in === 'body') {112 operation.consumes = operation.consumes || ['application/json'];113 }114 paramId++;115 }116 // parse operation's responses117 if (operation.responses) {118 for (var code in operation.responses) {119 //TODO manage headers ?120 var resp = operation.responses[code];121 resp.description = trustHtml(resp.description);122 if (resp.schema) {123 resp.schema.json = swaggerModel.generateSampleJson(swagger, resp.schema);124 if (resp.schema.type === 'object' || resp.schema.type === 'array' || resp.schema.$ref) {125 resp.display = 1; // display schema126 resp.schema.model = $sce.trustAsHtml(swaggerModel.generateModel(swagger, resp.schema));127 } else if (resp.schema.type === 'string') {128 delete resp.schema;129 }130 if (code === '200' || code === '201') {131 operation.responseClass = resp;132 operation.responseClass.display = 1;133 operation.responseClass.status = code;134 delete operation.responses[code];135 } else {136 operation.hasResponses = true;137 }138 } else {139 operation.hasResponses = true;140 }141 }142 }143 operation.tags = operation.tags || ['default'];144 // map operation to resource145 tag = operation.tags[0];146 if (typeof map[tag] === 'undefined') {147 map[tag] = resources.length;148 resources.push({149 name: tag150 });151 }152 res = resources[map[operation.tags[0]]];153 operation.open = openPath && openPath === operation.operationId || openPath === res.name + '*';154 res.operations = res.operations || [];155 res.operations.push(operation);156 if (operation.open) {157 res.open = true;158 }159 operationId++;160 }161 }162 // cleanup resources163 for (i = 0; i < resources.length; i++) {164 var operations = resources[i].operations;165 res = resources[i];166 res.open = res.open || openPath === res.name || openPath === res.name + '*';167 if (!operations || (operations && operations.length === 0)) {168 resources.splice(i, 1);169 }170 }171 // sort resources alphabeticaly172 resources.sort(function(a, b) {173 if (a.name > b.name) {174 return 1;175 } else if (a.name < b.name) {176 return -1;177 }178 return 0;179 });180 // clear cache181 swaggerModel.clearCache();182 parseResult.infos = infos;183 parseResult.resources = resources;184 parseResult.form = form;185 deferred.resolve(true);186 }187 /**188 * Module entry point189 */190 this.execute = function(parserType, contentType, data, isTrustedSources, parseResult) {191 var deferred = $q.defer();192 if (data.swagger === '2.0' && (parserType === 'json' || (parserType === 'auto' && contentType === 'application/json'))) {193 swagger = data;194 trustedSources = isTrustedSources;195 try {196 parseSwagger2Json(deferred, parseResult);197 } catch (e) {198 deferred.reject({199 code: 500,200 message: 'failed to parse swagger: ' + e.message201 });202 }203 } else {204 deferred.resolve(false);205 }206 return deferred.promise;207 };...

Full Screen

Full Screen

app-controller.js

Source:app-controller.js Github

copy

Full Screen

1angular.module('app').controller('AppController', function($rootScope, $scope, $state, utils, users, search) {2 $scope.utils = utils;3 $scope.users = users;4 $scope.currentState = $state.current;5 $scope.search = search;6 var docWidth = document.body.clientWidth;7 $rootScope.isPhone = docWidth <= 627;8 $rootScope.isTablet = docWidth <= 1024 && docWidth > 627;9 var ad1 = utils.getSetting('ad_slot_1'),10 ad2 = utils.getSetting('ad_slot_2'),11 ad3 = utils.getSetting('ad_slot_3'),12 ad4 = utils.getSetting('ad_slot_4'),13 ad5 = utils.getSetting('ad_slot_5');14 if (ad1) {15 $scope.ad1 = utils.trustHtml(ad1);16 }17 if (ad2) {18 $scope.ad2 = utils.trustHtml(ad2);19 }20 if (ad3) {21 $scope.ad3 = utils.trustHtml(ad3);22 }23 if (ad4) {24 $scope.ad4 = utils.trustHtml(ad4);25 }26 if (ad5) {27 $scope.ad5 = utils.trustHtml(ad5);28 }29 $scope.getCurrentStateName = function() {30 var name = utils.getCurrentStateName();31 if (name == 'phone-search') name = 'search';32 return utils.trans(name);33 };34 $scope.shouldPlayerControlsBeHidden = function() {35 return utils.stateIs(['admin', 'login', 'register']);36 };...

Full Screen

Full Screen

app.js

Source:app.js Github

copy

Full Screen

1(function(){2 'use strict';3 angular4 .module('myRetail', [5 'ngAnimate',6 'ui.router',7 'ui.bootstrap',8 'promos',9 'pdp'10 ])11 .config(routerConfig)12 .filter('trustHtml', trustHtml);13 routerConfig.$inject = ['$stateProvider', '$urlRouterProvider'];14 function routerConfig($stateProvider, $urlRouterProvider){15 $stateProvider16 .state('home', {17 url: "/home",18 views: {19 mainView: {templateUrl: "src/app/home/home.html"}20 }21 });22 $urlRouterProvider.otherwise('/home');23 }24 trustHtml.$inject = ['$sce'];25 function trustHtml($sce){26 return function(text){27 console.log('trusting')28 return $sce.trustAsHtml(text);29 };30 }...

Full Screen

Full Screen

trusthtml.js

Source:trusthtml.js Github

copy

Full Screen

1'use strict';2describe('Filter: trustHtml', function () {3 // load the filter's module4 beforeEach(module('webappApp'));5 // initialize a new instance of the filter before each test6 var trustHtml;7 beforeEach(inject(function ($filter) {8 trustHtml = $filter('trustHtml');9 }));10 it('should return the input prefixed with "trustHtml filter:"', function () {11 var text = 'angularjs';12 expect(trustHtml(text)).toBe('trustHtml filter: ' + text);13 });...

Full Screen

Full Screen

trustHtml.filter.js

Source:trustHtml.filter.js Github

copy

Full Screen

1/**2 * Created by anurag.mundada on 6/29/16.3 */4(function() {5 "use strict";6 angular7 .module('app')8 .filter('trustHtml', trustHtml);9 trustHtml.$inject = ['$sce'];10 function trustHtml($sce) {11 return function (text) {12 return $sce.trustAsHtml(text);13 };14 }...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import trustHtml from './filter-trustHtml/index';2export {3 trustHtml4};5export default function(ngModule) {6 ngModule.filter('trustHtml', trustHtml);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var trustHTML = function(html){2 return browser.executeScript('return arguments[0].innerHTML', html.getWebElement());3};4var trustHTML = function(html){5 return browser.executeScript('return arguments[0].innerHTML', html.getWebElement());6};7var trustHTML = function(html){8 return browser.executeScript('return arguments[0].innerHTML', html.getWebElement());9};10var trustHTML = function(html){11 return browser.executeScript('return arguments[0].innerHTML', html.getWebElement());12};13var trustHTML = function(html){14 return browser.executeScript('return arguments[0].innerHTML', html.getWebElement());15};16var trustHTML = function(html){17 return browser.executeScript('return arguments[0].innerHTML', html.getWebElement());18};19var trustHTML = function(html){20 return browser.executeScript('return arguments[0].innerHTML', html.getWebElement());21};22var trustHTML = function(html){23 return browser.executeScript('return arguments[0].innerHTML', html.getWebElement());24};25var trustHTML = function(html){26 return browser.executeScript('return arguments[0].innerHTML', html.getWebElement());27};

Full Screen

Using AI Code Generation

copy

Full Screen

1var trustHTML = function (html) {2 return browser.executeScript("return arguments[0].innerHTML", html);3};4var trustHTML = function (html) {5 return browser.executeScript("return arguments[0].innerHTML", html);6};7var trustHTML = function (html) {8 return browser.executeScript("return arguments[0].innerHTML", html);9};10var trustHTML = function (html) {11 return browser.executeScript("return arguments[0].innerHTML", html);12};13var trustHTML = function (html) {14 return browser.executeScript("return arguments[0].innerHTML", html);15};16var trustHTML = function (html) {17 return browser.executeScript("return arguments[0].innerHTML", html);18};19var trustHTML = function (html) {20 return browser.executeScript("return arguments[0].innerHTML", html);21};22var trustHTML = function (html) {23 return browser.executeScript("return arguments[0].innerHTML", html);24};25var trustHTML = function (html) {26 return browser.executeScript("return arguments[0].innerHTML", html);27};28var trustHTML = function (html) {29 return browser.executeScript("return arguments[0].innerHTML", html);30};31var trustHTML = function (html) {32 return browser.executeScript("return arguments[0].innerHTML", html);33};34var trustHTML = function (html) {35 return browser.executeScript("return arguments[0].innerHTML", html);36};37var trustHTML = function (html) {38 return browser.executeScript("return arguments[0].innerHTML", html);39};40var trustHTML = function (html) {41 return browser.executeScript("return arguments[0].innerHTML", html);42};

Full Screen

Using AI Code Generation

copy

Full Screen

1var EC = protractor.ExpectedConditions;2browser.wait(EC.presenceOf(element(by.id('id'))), 5000);3browser.wait(EC.presenceOf(element(by.id('id'))), 5000).then(function() {4 browser.executeScript(function() {5 return document.getElementById('id').innerHTML;6 }).then(function(html) {7 browser.executeScript(function(html) {8 document.getElementById('id').innerHTML = html;9 }, html);10 });11});12browser.executeScript(function() {13 return angular.element(document.getElementById('id')).scope().$sce.trustAsHtml(html);14}).then(function(html) {15 browser.executeScript(function(html) {16 angular.element(document.getElementById('id')).scope().$sce.trustAsHtml(html);17 }, html);18});19browser.executeScript(function() {20 return angular.element(document.getElementById('id')).scope().$sce.trustAsHtml(html);21}).then(function(html) {22 browser.executeScript(function(html) {23 angular.element(document.getElementById('id')).scope().$sce.trustAsHtml(html);24 }, html);25});26browser.executeScript(function() {27 return angular.element(document.getElementById('id')).scope().$sce.trustAsHtml(html);28}).then(function(html) {29 browser.executeScript(function(html) {30 angular.element(document.getElementById('id')).scope().$sce.trustAsHtml(html);31 }, html);32});33browser.executeScript(function() {34 return angular.element(document.getElementById('id')).scope().$sce.trustAsHtml(html);35}).then(function(html) {36 browser.executeScript(function(html) {37 angular.element(document.getElementById('id')).scope().$sce.trustAsHtml(html);38 }, html);39});40browser.executeScript(function() {41 return angular.element(document.getElementById('id')).scope().$sce.trustAsHtml(html);42}).then(function(html) {43 browser.executeScript(function(html) {44 angular.element(document.getElementById('id')).scope().$sce.trustAsHtml(html);45 }, html);46});47browser.executeScript(function() {48 return angular.element(document.getElementById('id')).scope().$sce.trustAsHtml(html);49}).then(function(html) {50 browser.executeScript(function(html

Full Screen

Using AI Code Generation

copy

Full Screen

1var EC = protractor.ExpectedConditions;2browser.wait(EC.presenceOf(element(by.id('someId'))), 10000);3browser.wait(EC.visibilityOf(element(by.id('someId'))), 10000);4var EC = protractor.ExpectedConditions;5browser.wait(EC.presenceOf(element(by.id('someId'))), 10000);6browser.wait(EC.visibilityOf(element(by.id('someId'))), 10000);7var EC = protractor.ExpectedConditions;8browser.wait(EC.presenceOf(element(by.id('someId'))), 10000);9browser.wait(EC.visibilityOf(element(by.id('someId'))), 10000);10var EC = protractor.ExpectedConditions;11browser.wait(EC.presenceOf(element(by.id('someId'))), 10000);12browser.wait(EC.visibilityOf(element(by.id('someId'))), 10000);13var EC = protractor.ExpectedConditions;14browser.wait(EC.presenceOf(element(by.id('someId'))), 10000);15browser.wait(EC.visibilityOf(element(by.id('someId'))), 10000);16var EC = protractor.ExpectedConditions;17browser.wait(EC.presenceOf(element(by.id('someId'))), 10000);18browser.wait(EC.visibilityOf(element(by.id('someId'))), 10000);19var EC = protractor.ExpectedConditions;20browser.wait(EC.presenceOf(element(by.id('someId'))), 10000);21browser.wait(EC.visibilityOf(element(by.id('someId'))), 10000);22var EC = protractor.ExpectedConditions;23browser.wait(EC.presenceOf(element(by.id('someId'))), 10000);24browser.wait(EC.visibilityOf(element(by.id('someId'))), 10000);25var EC = protractor.ExpectedConditions;26browser.wait(EC.presenceOf(element(by.id('someId'))), 10000);27browser.wait(EC.visibilityOf(element(by.id('someId'))), 10000);

Full Screen

Using AI Code Generation

copy

Full Screen

1var trustHTML = require('trust-html');2var html = '<h1>Protractor</h1>';3trustHTML(html);4var trustHTML = require('trust-html');5var html = '<h1>Protractor</h1>';6trustHTML(html);7var trustHTML = require('trust-html');8var html = '<h1>Protractor</h1>';9trustHTML(html);10var trustHTML = require('trust-html');11var html = '<h1>Protractor</h1>';12trustHTML(html);13var trustHTML = require('trust-html');14var html = '<h1>Protractor</h1>';15trustHTML(html);16var trustHTML = require('trust-html');17var html = '<h1>Protractor</h1>';18trustHTML(html);19var trustHTML = require('trust-html');20var html = '<h1>Protractor</h1>';21trustHTML(html);22var trustHTML = require('trust-html');23var html = '<h1>Protractor</h1>';24trustHTML(html);25var trustHTML = require('trust-html');26var html = '<h1>Protractor</h1>';27trustHTML(html);28var trustHTML = require('trust-html');29var html = '<h1>Protractor</h1>';30trustHTML(html);31var trustHTML = require('trust-html');32var html = '<h1>Protractor</h1>';33trustHTML(html);34var trustHTML = require('trust-html');35var html = '<h1>Protractor</h1>';36trustHTML(html);

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test suite', function() {2 it('should test', function() {3 element(by.css('div')).getInnerHtml().then(function(html) {4 expect(html).toEqual(trustAsHtml('<div><p>hello</p></div>'));5 });6 });7});8describe('Test suite', function() {9 it('should test', function() {10 element(by.css('div')).getInnerHtml().then(function(html) {11 expect(html).toEqual(trustAsHtml('<div><p>hello</p></div>'));12 });13 });14});

Full Screen

Selenium Protractor Tutorial

Protractor is developed by Google Developers to test Angular and AngularJS code. Today, it is used to test non-Angular applications as well. It performs a real-world user-like test against your application in a real browser. It comes under an end-to-end testing framework. As of now, Selenium Protractor has proved to be a popular framework for end-to-end automation for AngularJS.

Let’s talk about what it does:

  • Protractor, built on WebDriver JS (Selenium), offers Angular-specific locator strategies.
  • It helps to construct automated tests for applications other than Angular JS and is not just intended to test AngularJS applications.
  • Page object design pattern is supported by Protractor Selenium, which improves in producing clear and legible code. Automation testers need to write clean code.
  • Frameworks like Jasmine, Cucumber, and others are fully integrated with Protractor.

Chapters:

Protractor is a JavaScript framework, end-to-end test automation framework for Angular and AngularJS applications.

Protractor Selenium provides new locator methods that actually make it easier to find elements in the DOM.

Two files are required to execute Protractor Selenium tests for end-to-end automation: Specs & Config. Go through the link above to understand in a better way.

To carry out extensive, automated cross browser testing, you can't imagine installing thousands of the available browsers on your own workstation. The only way to increase browser usage is through remote execution on the cloud. To execute your automation test scripts across a variety of platforms and browser versions, LambdaTest offers more than 3000 browsers.

We recommend Selenium for end-to-end automation for AngularJS because both are maintained and owned by Google, and they build JavaScript test automation framework to handle AngularJS components in a way that better matches how developers use it.

For scripting, selenium locators are essential since if they're off, your automation scripts won't run. Therefore, in any testing framework, these Selenium locators are the foundation of your Selenium test automation efforts.

To make sure that your Selenium automation tests function as intended, debugging can be an effective option. Check the blog to know more.

Get familiar with global variables that are majorly used in locating the DOM elements with examples for better understanding of these Selenium locators in protractor.

If you are not familiar with writing Selenium test automation on Protractor, here is a blog for you to get you understand in depth.

Selenium tests are asynchronous and there are various reasons for a timeout to occur in a Protractor test. Find out how to handle timeouts in this Protractor tutorial.

In this Protractor tutorial, learn how to handle frames or iframes in Selenium with Protractor for automated browser testing.

Handle alerts and popups in Protractor more efficiently. It can be confusing. Here's a simple guide to understand how to handle alerts and popups in Selenium.

Run Protractor 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