How to use listItems method in Cypress

Best JavaScript code snippet using cypress

Todo.js

Source:Todo.js Github

copy

Full Screen

1import React, { Component } from "react";2import axios from "../../axios";3import TodoContainer from "../../components/TodoContainer/TodoContainer";4import { withRouter } from "react-router-dom";5import classes from "./Todo.module.css";6import { toast } from "react-toastify";7import _ from "lodash";8import Loader from "../../UI/Loader/Loader";9toast.configure({ autoClose: "2000" });10class Todo extends Component {11 state = {12 listItems: [],13 inputList: {14 search: {15 elementType: "input",16 elementConfig: {17 type: "text",18 placeholder: "SEARCH TODO...",19 },20 validation: {21 isValid: false,22 },23 value: "",24 },25 add: {26 elementType: "input",27 elementConfig: {28 type: "text",29 placeholder: "TODO TITLE...",30 },31 validation: {32 isvalid: false,33 },34 value: "",35 },36 filter: {37 elementType: "select",38 elementConfig: {39 option: [40 { value: "all", displayValue: "ALL" },41 { value: "complete", displayValue: "COMPLETE" },42 { value: "incomplete", displayValue: "INCOMPLETE" },43 ],44 },45 validation: {},46 value: "all",47 },48 errorMessage: null,49 showError: true,50 },51 loading: false,52 };53 fetchTodo = async () => {54 this.setState({ loading: true });55 const GET_TODOS = {56 query: `57 query getAllTodo{58 todo59 {60 getAllTodo {61 todos {62 id63 text64 description65 completed66 }67 }68 }69 }70 71 `,72 };73 try {74 const response = await axios.post("/graphql", GET_TODOS);75 this.setState({ loading: false });76 if (response.data.errors) {77 toast(response.data.errors[0].message, { type: "warning" });78 } else {79 const items = response.data.data.todo.getAllTodo.todos.map((item) => {80 return {81 ...item,82 delete: false,83 loading: false,84 display: true,85 detail: false,86 update: false,87 };88 });89 this.setState({ listItems: items });90 }91 } catch (err) {92 this.setState({ loading: false });93 toast(err.message, { type: "error" });94 }95 };96 componentDidMount() {97 this.fetchTodo();98 }99 componentDidUpdate(prevProps, prevState) {100 if (101 this.props.update &&102 !prevProps.update103 // (prevState.listItems.length !== 0 &&104 // prevState.listItems.length !== this.state.listItems.length)105 ) {106 this.fetchTodo();107 }108 }109 changeHandler = (event, type) => {110 const inputList = _.cloneDeep(this.state.inputList);111 inputList[type].value = event.target.value;112 this.setState({ inputList: inputList });113 };114 toggleDetailHandler = (id) => {115 const listItems = _.cloneDeep(this.state.listItems);116 const index = listItems.findIndex((item) => item.id === id);117 listItems[index].detail = !this.state.listItems[index].detail;118 this.setState({ listItems: listItems });119 };120 closeDetailHandler = (id) => {121 const listItems = _.cloneDeep(this.state.listItems);122 const index = listItems.findIndex((item) => item.id === id);123 listItems[index].detail = false;124 this.setState({ listItems: listItems });125 };126 updateShowHandler = (id) => {127 const listItems = _.cloneDeep(this.state.listItems);128 const index = listItems.findIndex((item) => item.id === id);129 listItems[index].update = true;130 this.setState({ listItems: listItems });131 };132 updateCloseHandler = (id) => {133 const listItems = _.cloneDeep(this.state.listItems);134 const index = listItems.findIndex((item) => item.id === id);135 listItems[index].update = false;136 this.setState({ listItems: listItems });137 };138 closeUpdateAndDetailHandler = (id) => {139 const listItems = _.cloneDeep(this.state.listItems);140 const index = listItems.findIndex((item) => item.id === id);141 listItems[index].update = false;142 listItems[index].detail = false;143 this.setState({ listItems: listItems });144 };145 updateTodoHandler = (todo) => {146 const listItems = _.cloneDeep(this.state.listItems);147 const index = listItems.findIndex((item) => item.id === todo.id);148 const updatedTodo = {149 ...listItems[index],150 text: todo.text,151 description: todo.description,152 };153 listItems[index] = updatedTodo;154 this.setState({ listItems: listItems });155 };156 //==========================================================157 //Bug in serach handler158 searchHandler = (event, type) => {159 const state = _.cloneDeep(this.state);160 const value = event.target.value;161 state.inputList[type].value = value;162 let searchList = null;163 const completeList = state.listItems.filter((item) => item.completed);164 const inCompleteList = state.listItems.filter((item) => !item.completed);165 const allList = [...state.listItems];166 if (this.state.inputList.filter.value === "complete") {167 searchList = [...completeList];168 } else if (this.state.inputList.filter.value === "incomplete") {169 searchList = inCompleteList;170 } else {171 searchList = allList;172 }173 searchList.forEach((item, index) => {174 if (175 item.text.indexOf(value.toLowerCase()) === -1 &&176 value.trim() !== ""177 ) {178 state.listItems[index].display = false;179 } else {180 state.listItems[index].display = true;181 }182 });183 if (this.state.inputList.filter.value === "complete") {184 state.listItems = [...searchList, ...inCompleteList];185 } else if (this.state.inputList.filter.value === "incomplete") {186 state.listItems = [...searchList, ...completeList];187 } else {188 state.listItems = [...allList];189 }190 this.setState(state);191 };192 ///=============================================================193 plusClickHandler = () => {194 const inputList = _.cloneDeep(this.state.inputList);195 const value = inputList.add.value;196 let isValid = true;197 inputList.errorMessage = null;198 inputList.showError = true;199 isValid = value.trim() !== "" && isValid;200 if (!isValid) {201 inputList.errorMessage = "Field cannot be empty";202 return this.setState({ inputList: inputList });203 }204 isValid = value.length <= 30 && isValid;205 if (!isValid) {206 inputList.errorMessage = "Length should be less than 30 character";207 return this.setState({ inputList: inputList });208 }209 this.props.set(["modalShow", "title"], [true, value]);210 this.setState({ inputList: inputList });211 };212 crossClickHandler = () => {213 const inputList = _.cloneDeep(this.state.inputList);214 inputList.showError = false;215 this.setState({ inputList: inputList });216 };217 toggleClick = async (event, id) => {218 const listItems = _.cloneDeep(this.state.listItems);219 const index = listItems.findIndex((item) => id === item.id);220 const bool = !listItems[index].completed;221 listItems[index].completed = bool;222 const UPDATE_TODO = {223 query: `224 mutation UPDATE_TODO($completed:Boolean,$id:Int){225 todo{226 toggleComplete(todoInput:{completed:$completed,id:$id})227 {228 message229 }230 }231 }`,232 variables: {233 completed: bool,234 id: id,235 },236 };237 try {238 const response = await axios.post("/graphql", UPDATE_TODO);239 if (response.data.errors) {240 toast(response.data.errors[0].message, { type: "warning" });241 } else {242 this.setState({ listItems: listItems }, () => {243 this.filterHandler(event, "filter");244 });245 }246 } catch (err) {247 toast(err.message, { type: "error" });248 }249 };250 deleteHandler = async (id) => {251 const loadingItems = this.state.listItems.filter(252 (item) => item.loading === true253 );254 if (loadingItems.length > 0) {255 return;256 }257 const index = this.state.listItems.findIndex((item) => item.id === id);258 let updateList = { ...this.state.listItems[index], loading: true };259 let updatedListItmes = [...this.state.listItems];260 updatedListItmes[index] = updateList;261 this.setState({ listItems: updatedListItmes });262 const DELETE_TODO = {263 query: `mutation DELETE_TODO($id:Int!){264 todo{265 deleteTodo(todoInput:{id:$id}){266 message267 }268 }269 }`,270 variables: {271 id: id,272 },273 };274 try {275 const response = await axios.post("graphql", DELETE_TODO);276 updateList = { ...this.state.listItems[index], loading: false };277 updatedListItmes = [...this.state.listItems];278 updatedListItmes[index] = updateList;279 this.setState({ listItems: updatedListItmes });280 if (response.data.errors) {281 toast(response.data.errors[0].message, { type: "warning" });282 } else {283 const state = _.cloneDeep(this.state);284 const filterItems = state.listItems.filter((item) => item.id !== id);285 this.setState({ listItems: filterItems }, () => {286 toast(response.data.data.todo.deleteTodo.message, {287 type: "success",288 });289 });290 }291 } catch (err) {292 updateList = { ...this.state.listItems[index], loading: false };293 updatedListItmes = [...this.state.listItems];294 updatedListItmes[index] = updateList;295 this.setState({ listItems: updatedListItmes });296 toast(err.message, { type: "error" });297 }298 };299 filterHandler = (event, type) => {300 const state = _.cloneDeep(this.state);301 let value = null;302 if (event.type === "change") {303 value = event.target.value;304 } else {305 value = state.inputList[type].value;306 }307 state.inputList[type].value = value;308 state.listItems.forEach((item, index) => {309 if (value === "complete" || value === "all") {310 if (!item.completed && value !== "all") {311 state.listItems[index].display = false;312 } else {313 state.listItems[index].display = true;314 }315 } else {316 if (item.completed) {317 state.listItems[index].display = false;318 } else {319 state.listItems[index].display = true;320 }321 }322 });323 this.setState(state);324 };325 render() {326 const iconClass = ["fas fa-list-alt", classes.Icon];327 let todoContainer = <Loader />;328 if (!this.state.loading) {329 todoContainer = (330 <TodoContainer331 changeHandler={this.changeHandler}332 inputList={this.state.inputList}333 listItems={this.state.listItems}334 plusClick={this.plusClickHandler}335 crossClick={this.crossClickHandler}336 toggleClick={this.toggleClick}337 deleteClick={this.deleteHandler}338 searchHandler={this.searchHandler}339 filterHandler={this.filterHandler}340 toggleDetail={this.toggleDetailHandler}341 closeDetail={this.closeDetailHandler}342 updateShow={this.updateShowHandler}343 updateClose={this.updateCloseHandler}344 closeUpdateAndDetail={this.closeUpdateAndDetailHandler}345 updateTodo={this.updateTodoHandler}346 />347 );348 }349 return (350 <div className={classes.Todo}>351 <h1 className={classes.Heading}>352 <i className={iconClass.join(" ")}></i>TODO LIST353 </h1>354 {todoContainer}355 </div>356 );357 }358}...

Full Screen

Full Screen

FooterOne.js

Source:FooterOne.js Github

copy

Full Screen

1import React from "react";2import { Link } from "~components";3import { Container, Row, Col } from "react-bootstrap";4import { useRouter } from "next/router";5// import { Images } from '~data'6import Footer from "./style";7import LogoWhite from "~image/logo/logo-black.png";8import styles from "./style.module.css";9export default function FooterOne() {10 const router = useRouter();11 return (12 <Footer>13 <Container>14 <Footer.Box pbXL="95px">15 <Row>16 <Col xs="12" className="col-lg-4 col-md-8 col-xs-10">17 <Footer.Widgets className="footer-widgets footer-widgets--l7">18 {/* Brand Logo*/}19 <Footer.Box mb="30px">20 <Link to="#">21 <img22 src={LogoWhite.src}23 alt="logo"24 style={{ width: "159px" }}25 />26 </Link>27 </Footer.Box>28 <Footer.Text mb="36px">29 The best medicines & biggest30 <br className="d-none d-xl-block" />31 brands within 30 minutes at your32 <br className="d-none d-xl-block" />33 home. Experience the power of34 <br className="d-none d-xl-block" />35 MedCartel today.36 </Footer.Text>37 </Footer.Widgets>38 </Col>39 <Col xs="12" className="col-xl-8">40 <Row>41 <Col xs="6" className="col-md-4 col-xs-6">42 <Footer.Widgets>43 <Footer.Title>Features</Footer.Title>44 <Footer.List>45 <Footer.ListItems>46 <Link to="">Account Management</Link>47 </Footer.ListItems>48 <Footer.ListItems>49 <Link to="/">Inventory Management</Link>50 </Footer.ListItems>51 <Footer.ListItems>52 <Link to="s">Built-in POS</Link>53 </Footer.ListItems>54 <Footer.ListItems>55 <Link to="">Staff Management</Link>56 </Footer.ListItems>57 <Footer.ListItems>58 <Link to="">Productivity Tools</Link>59 </Footer.ListItems>60 <Footer.ListItems>61 <Link to="">Unlimited Menus</Link>62 </Footer.ListItems>{" "}63 <Footer.ListItems>64 <Link to="">Tailored Apps</Link>65 </Footer.ListItems>{" "}66 <Footer.ListItems>67 <Link to="">Social Media Management</Link>68 </Footer.ListItems>{" "}69 <Footer.ListItems>70 <Link to="">Free Website</Link>71 </Footer.ListItems>{" "}72 <Footer.ListItems>73 <Link to="">Own Delivery App</Link>74 </Footer.ListItems>75 </Footer.List>76 </Footer.Widgets>77 </Col>78 <Col xs="6" className="col-md-4 col-xs-6">79 <Footer.Widgets>80 <Footer.Title>Learn More</Footer.Title>81 <Footer.List>82 <Footer.ListItems>83 <Link to="">Support</Link>84 </Footer.ListItems>85 <Footer.ListItems>86 <Link to="/">Billing & Subscription</Link>87 </Footer.ListItems>88 <Footer.ListItems>89 <Link to="s">Blog</Link>90 </Footer.ListItems>91 <Footer.ListItems>92 <Link to="">Tutorial Videos</Link>93 </Footer.ListItems>94 <Footer.ListItems>95 <Link to="">Ebooks</Link>96 </Footer.ListItems>97 <Footer.ListItems>98 <Link to="">Forum</Link>99 </Footer.ListItems>{" "}100 <Footer.ListItems>101 <Link to="">Community</Link>102 </Footer.ListItems>{" "}103 <Footer.ListItems>104 <Link to="">Hire an Expert</Link>105 </Footer.ListItems>{" "}106 <Footer.ListItems>107 <Link to="">Customers</Link>108 </Footer.ListItems>{" "}109 <Footer.ListItems>110 <Link to="">Restro X vs Others</Link>111 </Footer.ListItems>112 </Footer.List>113 </Footer.Widgets>114 </Col>115 <Col xs="12" className="col-md-4 col-xs-6">116 <Footer.Widgets>117 <Footer.Title>Company</Footer.Title>118 <Footer.List>119 <Footer.ListItems>120 <Link to="">About Us</Link>121 </Footer.ListItems>122 <Footer.ListItems>123 <Link to="/">Contact Us</Link>124 </Footer.ListItems>125 <Footer.ListItems>126 <div className={styles.link}>127 <div onClick={() => router.push("/innerpage/career")}>128 Careers129 </div>130 <div style={{ color: "red", marginLeft: "1em" }}>131 we're hiring.132 </div>133 </div>134 </Footer.ListItems>135 <Footer.ListItems>136 <Link to="">Press</Link>137 </Footer.ListItems>138 <Footer.ListItems>139 <Link to="">Apps</Link>140 </Footer.ListItems>141 <Footer.ListItems>142 <Link to="">Security</Link>143 </Footer.ListItems>{" "}144 <Footer.ListItems>145 <div className={styles.link}>146 <div onClick={() => router.push("/innerpage/terms")}>147 Tearms & Condition148 </div>149 </div>150 </Footer.ListItems>{" "}151 <Footer.ListItems>152 <div className={styles.link}>153 <div onClick={() => router.push("/innerpage/terms")}>154 Refund Poilcy155 </div>156 </div>157 </Footer.ListItems>{" "}158 <Footer.ListItems>159 <div className={styles.link}>160 <div onClick={() => router.push("/innerpage/terms")}>161 Privacy & Security Policy162 </div>163 </div>164 </Footer.ListItems>{" "}165 <Footer.ListItems>166 <div className={styles.link}>167 <div onClick={() => router.push("/innerpage/terms")}>168 Cookie Policy & Preferences169 </div>170 </div>171 </Footer.ListItems>172 <Footer.ListItems>173 <Link to="">Referral Programme</Link>174 </Footer.ListItems>{" "}175 <Footer.ListItems>176 <Link to="">Become an Affiliate</Link>177 </Footer.ListItems>178 </Footer.List>179 </Footer.Widgets>180 </Col>181 </Row>182 </Col>183 </Row>184 </Footer.Box>185 <Footer.Copyright>186 <Footer.CopyrightText>187 © 2021 RestroX by Blacktech. All Rights Reserved188 </Footer.CopyrightText>189 <Footer.SocialShare>190 <Footer.SocialShareItem>191 <a target="_blank" href="https://www.facebook.com">192 <i className="fab fa-facebook-square" />193 </a>194 </Footer.SocialShareItem>195 <Footer.SocialShareItem>196 <a target="_blank" href="https://twitter.com">197 <i className="fab fa-twitter" />198 </a>199 </Footer.SocialShareItem>200 <Footer.SocialShareItem>201 <a target="_blank" href="https://www.instagram.com">202 <i className="fab fa-instagram" />203 </a>204 </Footer.SocialShareItem>205 <Footer.SocialShareItem>206 <a target="_blank" href="https://www.linkedin.com">207 <i className="fab fa-linkedin" />208 </a>209 </Footer.SocialShareItem>210 </Footer.SocialShare>211 </Footer.Copyright>212 </Container>213 </Footer>214 );...

Full Screen

Full Screen

todolist-resolvers.js

Source:todolist-resolvers.js Github

copy

Full Screen

1const ObjectId = require('mongoose').Types.ObjectId;2const Todolist = require('../models/todolist-model');3// The underscore param, "_", is a wildcard that can represent any value;4// here it is a stand-in for the parent parameter, which can be read about in5// the Apollo Server documentation regarding resolvers6module.exports = {7 Query: {8 /** 9 @param {object} req - the request object containing a user id10 @returns {array} an array of todolist objects on success, and an empty array on failure11 **/12 getAllTodos: async (_, __, { req }) => {13 const _id = new ObjectId(req.userId);14 if(!_id) { return([])};15 const todolists = await Todolist.find({owner: _id});16 if(todolists) return (todolists);17 },18 /** 19 @param {object} args - a todolist id20 @returns {object} a todolist on success and an empty object on failure21 **/22 getTodoById: async (_, args) => {23 const { _id } = args;24 const objectId = new ObjectId(_id);25 const todolist = await Todolist.findOne({_id: objectId});26 if(todolist) return todolist;27 else return ({});28 },29 },30 Mutation: {31 /** 32 @param {object} args - a todolist id and an empty item object33 @returns {string} the objectID of the item or an error message34 **/35 addItem: async(_, args) => {36 const { _id, item , index } = args;37 const listId = new ObjectId(_id);38 const objectId = new ObjectId();39 const found = await Todolist.findOne({_id: listId});40 if(!found) return ('Todolist not found');41 if(item._id === '') item._id = objectId;42 let listItems = found.items;43 if(index < 0) listItems.push(item);44 else listItems.splice(index, 0, item);45 46 const updated = await Todolist.updateOne({_id: listId}, { items: listItems });47 if(updated) return (item._id);48 else return ('Could not add item');49 },50 /** 51 @param {object} args - an empty todolist object52 @returns {string} the objectID of the todolist or an error message53 **/54 addTodolist: async (_, args) => {55 const { todolist } = args;56 const objectId = new ObjectId();57 const { id, name, owner, items } = todolist;58 const newList = new Todolist({59 _id: objectId,60 id: id,61 name: name,62 owner: owner,63 items: items64 });65 const updated = await newList.save();66 if(updated) return objectId;67 else return ('Could not add todolist');68 },69 /** 70 @param {object} args - a todolist objectID and item objectID71 @returns {array} the updated item array on success or the initial 72 array on failure73 **/74 deleteItem: async (_, args) => {75 const { _id, itemId } = args;76 const listId = new ObjectId(_id);77 const found = await Todolist.findOne({_id: listId});78 let listItems = found.items;79 listItems = listItems.filter(item => item._id.toString() !== itemId);80 const updated = await Todolist.updateOne({_id: listId}, { items: listItems })81 if(updated) return (listItems);82 else return (found.items);83 },84 /** 85 @param {object} args - a todolist objectID 86 @returns {boolean} true on successful delete, false on failure87 **/88 deleteTodolist: async (_, args) => {89 const { _id } = args;90 const objectId = new ObjectId(_id);91 const deleted = await Todolist.deleteOne({_id: objectId});92 if(deleted) return true;93 else return false;94 },95 /** 96 @param {object} args - a todolist objectID, field, and the update value97 @returns {boolean} true on successful update, false on failure98 **/99 updateTodolistField: async (_, args) => {100 const { field, value, _id } = args;101 const objectId = new ObjectId(_id);102 const updated = await Todolist.updateOne({_id: objectId}, {[field]: value});103 if(updated) return value;104 else return "";105 },106 /** 107 @param {object} args - a todolist objectID, an item objectID, field, and108 update value. Flag is used to interpret the completed 109 field,as it uses a boolean instead of a string110 @returns {array} the updated item array on success, or the initial item array on failure111 **/112 updateItemField: async (_, args) => {113 const { _id, itemId, field, flag } = args;114 let { value } = args115 const listId = new ObjectId(_id);116 const found = await Todolist.findOne({_id: listId});117 let listItems = found.items;118 if(flag === 1) {119 if(value === 'complete') { value = true; }120 if(value === 'incomplete') { value = false; }121 }122 listItems.map(item => {123 if(item._id.toString() === itemId) { 124 125 item[field] = value;126 }127 });128 const updated = await Todolist.updateOne({_id: listId}, { items: listItems })129 if(updated) return (listItems);130 else return (found.items);131 },132 /**133 @param {object} args - contains list id, item to swap, and swap direction134 @returns {array} the reordered item array on success, or initial ordering on failure135 **/136 reorderItems: async (_, args) => {137 const { _id, itemId, direction } = args;138 const listId = new ObjectId(_id);139 const found = await Todolist.findOne({_id: listId});140 let listItems = found.items;141 const index = listItems.findIndex(item => item._id.toString() === itemId);142 // move selected item visually down the list143 if(direction === 1 && index < listItems.length - 1) {144 let next = listItems[index + 1];145 let current = listItems[index]146 listItems[index + 1] = current;147 listItems[index] = next;148 }149 // move selected item visually up the list150 else if(direction === -1 && index > 0) {151 let prev = listItems[index - 1];152 let current = listItems[index]153 listItems[index - 1] = current;154 listItems[index] = prev;155 }156 const updated = await Todolist.updateOne({_id: listId}, { items: listItems })157 if(updated) return (listItems);158 // return old ordering if reorder was unsuccessful159 listItems = found.items;160 return (found.items);161 },162 sortListBy: async (_, args,) =>{163 const {_id, sortByVar} = args;164 const listId = new ObjectId(_id);165 const found = await Todolist.findOne({_id: listId});166 let listItems = found.items;167 let firstItem = listItems[0];168 if(sortByVar === "description"){169 for(let i = 0; i < listItems.length - 1; i++){170 for(let j = 0; j < listItems.length - 1 - i; j++){171 if(listItems[j].description < listItems[j+1].description){172 let temp = listItems[j];173 listItems[j] = listItems[j+1];174 listItems[j+1] = temp;175 }176 }177 }178 }179 if(sortByVar === "due_date"){180 for(let i = 0; i < listItems.length - 1; i++){181 for(let j = 0; j < listItems.length - 1 - i; j++){182 if(listItems[j].due_date < listItems[j+1].due_date){183 let temp = listItems[j];184 listItems[j] = listItems[j+1];185 listItems[j+1] = temp;186 }187 }188 }189 }190 if(sortByVar === "completed"){191 for(let i = 0; i < listItems.length - 1; i++){192 for(let j = 0; j < listItems.length - 1 - i; j++){193 if(listItems[j].completed < listItems[j+1].completed){194 let temp = listItems[j];195 listItems[j] = listItems[j+1];196 listItems[j+1] = temp;197 }198 }199 }200 }201 if(sortByVar === "assigned_to"){202 for(let i = 0; i < listItems.length - 1; i++){203 for(let j = 0; j < listItems.length - 1 - i; j++){204 if(listItems[j].assigned_to < listItems[j+1].assigned_to){205 let temp = listItems[j];206 listItems[j] = listItems[j+1];207 listItems[j+1] = temp;208 }209 }210 }211 }212 if(firstItem === listItems[0]){213 if(sortByVar === "description"){214 for(let i = 0; i < listItems.length - 1; i++){215 for(let j = 0; j < listItems.length - 1 - i; j++){216 if(listItems[j].description > listItems[j+1].description){217 let temp = listItems[j];218 listItems[j] = listItems[j+1];219 listItems[j+1] = temp;220 }221 }222 }223 }224 if(sortByVar === "due_date"){225 for(let i = 0; i < listItems.length - 1; i++){226 for(let j = 0; j < listItems.length - 1 - i; j++){227 if(listItems[j].due_date > listItems[j+1].due_date){228 let temp = listItems[j];229 listItems[j] = listItems[j+1];230 listItems[j+1] = temp;231 }232 }233 }234 }235 236 if(sortByVar === "completed"){237 for(let i = 0; i < listItems.length - 1; i++){238 for(let j = 0; j < listItems.length - 1 - i; j++){239 if(listItems[j].completed > listItems[j+1].completed){240 let temp = listItems[j];241 listItems[j] = listItems[j+1];242 listItems[j+1] = temp;243 }244 }245 }246 }247 248 if(sortByVar === "assigned_to"){249 for(let i = 0; i < listItems.length - 1; i++){250 for(let j = 0; j < listItems.length - 1 - i; j++){251 if(listItems[j].assigned_to > listItems[j+1].assigned_to){252 let temp = listItems[j];253 listItems[j] = listItems[j+1];254 listItems[j+1] = temp;255 }256 }257 }258 }259 }260 const updated = await Todolist.updateOne({_id: listId}, { items: listItems })261 if(updated) return (listItems);262 listItems = found.items;263 return (found.items);264 },265 undoSortListBy: async (_, args,) =>{266 const {_id, _oldList} = args;267 const updated = await Todolist.updateOne({_id: _id}, { items: _oldList })268 if(updated) return (_oldList);269 } 270 }...

Full Screen

Full Screen

pagesmanager.js

Source:pagesmanager.js Github

copy

Full Screen

1var level=2;2var IDPage=0;3var Label="";4var Title="";5var Link="";6var Off=false;7var JoinPr=false;8Enter.onclick=function (Enter_onclick){9Submit();10}11AddPage.onclick=function (AddPage_onclick){12Submit();13}14EditPage.onclick=function (EditPage_onclick){15 Submit();16 if(ListItems.selectedIndex!=-1){17 Info();18 PageSelect.value=IDPage;19 }20}21AddItem.onclick = function (AddItem_onclick)22{23 Reset();24 level = 2;25 ResetMove();26 Label = prompt(msg101, "");27 Title = prompt(msg102, "");28 if (Label == null)29 {30 Label = ""31 }32 if (Title == null)33 {34 Title = ""35 }36 oOption = document.createElement("OPTION");37 oOption.text = Label;38 Position = ListItems.selectedIndex + 1;39 insertOption(ListItems,oOption,Position)40 ListItems.selectedIndex = Position;41 SetInfo();42 ListItemChange();43}44RemoveItem.onclick=function (RemoveItem_onclick)45{46 ResetMove();47 if(ListItems.selectedIndex!=-1)48 {49 Position=ListItems.selectedIndex; 50 Info();51 if(IDPage==0)52 {53 ListItems.remove(ListItems.selectedIndex);54 try55 {56 ListItems.selectedIndex=Position;57 ListItemChange();58 }59 catch(err)60 {61 } 62 }63 }64}65ObjLabel.onchange = function (Label_onclick)66{67 if (ListItems.selectedIndex != -1)68 {69 Info();70 Label = cln(ObjLabel.value);71 CurrentListItem().text = Label;72 SetInfo();73 }74}75ObjTitle.onchange = function (Title_onchange)76{77 if(ListItems.selectedIndex!=-1){78 Info();79 Title=cln(ObjTitle.value);80 SetInfo();81 }82}83ObjLink.onchange = function (Link_onchange)84 {85 if(ListItems.selectedIndex!=-1){86 Info();87 Link=cln(ObjLink.value);88 SetInfo();89 }90}91ListItems.onchange=function (ListItems_onchange){92 ListItemChange();93}94ListItems.ondblclick=function (ListItems_ondblclick){95 PreciseMove();96 ListItemChange();97}98HidePage.onclick=function (HidePage_onclick){99 Info();100 Off=HidePage.checked;101 SetInfo();102}103JoinPrevious.onclick=function (JoinPrevious_onclick){104 Info();105 JoinPr=JoinPrevious.checked;106 SetInfo();107}108function cln(text){109 text = text.replace("{", "(");110 text = text.replace("[", "(");111 text = text.replace("}", ")");112 text = text.replace("]", ")");113 return text;114}115function declevel(){116 Info();117 if(level>0){ level=level-1;118 SetInfo();119 }120}121function inclevel(){122 Info();123 if(level<3){ level=level+1;124 SetInfo();125 }126}127function moveup(){128 ResetMove();129 if(ListItems.selectedIndex>0){130 Position=ListItems.selectedIndex;131 oOption=ListItems[Position];132 ListItems.remove(Position);133 insertOption(ListItems, oOption, Position-1)134 ListItems.selectedIndex=Position-1;135 }136}137function movedown(){138 ResetMove();139 if(ListItems.selectedIndex!=-1 && ListItems.selectedIndex<ListItems.length-1){140 Position=ListItems.selectedIndex;141 oOption=ListItems[Position]; 142 ListItems.remove(Position);143 insertOption(ListItems, oOption, Position + 1)144 ListItems.selectedIndex = Position + 1;145 }146}147StaticPosition=-1;148function PreciseMove(){149 if(StaticPosition!=-1)150 {151 Position=ListItems.selectedIndex;152 oOption=ListItems[StaticPosition];153 ListItems.remove(StaticPosition);154 insertOption(ListItems,oOption,Position)155 ListItems.selectedIndex = Position;156 ResetMove();157 }else158 {159 StaticPosition=ListItems.selectedIndex;160 MessageAlert.firstChild.nodeValue = msg3017;161 }162}163function ResetMove(){164 if(StaticPosition!=-1){165 StaticPosition = -1;166 MessageAlert.firstChild.nodeValue = msg3016;167 }168}169function Reset() 170 {171 level=0;172 IDPage=0;173 Label="";174 Title="";175 Link="";176 Off=false;177 JoinPr=false;178 }179function Info() 180 {181 Reset();182 if(ListItems.selectedIndex!=-1)183 {184 Record=ListItems.value;185 while(Record.substr(level,1) == ".")186 {187 level = level + 1;188 }189 p1 = Record.indexOf("[")+1;190 p2=1;191 if(p1)192 {193 p2 = Record.indexOf("]",p1)+1;194 Field = Record.substr(p1, p2 - p1 - 1);195 if(Field.substr(0,1) == "#")196 {197 IDPage = parseInt(Field.substr(1));198 }199 p1 = Record.indexOf("[",p2-1)+1;200 if(p1)201 {202 p2 = Record.indexOf("]",p1)+1;203 Label = Record.substr(p1, p2 - p1 - 1);204 p1 = Record.indexOf("[",p2-1)+1;205 if(p1)206 {207 p2 = Record.indexOf("]",p1)+1;208 Title = Record.substr(p1, p2 - p1 - 1);209 p1 = Record.indexOf("[",p2-1)+1;210 if(p1)211 {212 p2 = Record.indexOf("]",p1)+1;213 Link = Record.substr(p1, p2 - p1 - 1);214 }215 }216 }217 }218 Off = Record.indexOf("{off}", p2-1)>-1;219 JoinPr = Record.indexOf("{join}", p2-1)>-1;220 }221 }222function SetInfo(){223 if(ListItems.selectedIndex!=-1){224 Record="...........".substr(0,level);225 if(IDPage == 0){226 Record = Record + "[]";227 }else{228 Record = Record + "[#" + IDPage + "]";229 }230 Record = Record + "[" + Label + "][" + Title + "]";231 if(Link != ""){ Record = Record + "[" + Link + "]";}232 if(Off){ Record = Record + "{off}";}233 if(JoinPr){ Record = Record + "{join}";}234 ListItem=CurrentListItem();235 ListItem.value = Record;236 SetVisualization(ListItem,level,Off,JoinPr);237 }else{238 EditPage.disabled=true;239 DisabletextModify();240 }241}242function SetVisualization(ListItem,level,Off,JoinPr){243 ListItem.text = ">>>>>>>>>>".substr(0, level) + removeIdent(ListItem.text);244 switch (level)245 {246 case 0:247 ListItem.style.color = "Red";248 ListItem.style.backgroundColor = "Yellow";249 break;250 case 1:251 ListItem.style.color = "Black";252 ListItem.style.backgroundColor = "Yellow";253 break;254 default:255 ListItem.style.color = "Black";256 ListItem.style.backgroundColor = "White";257 }258 if(Off){259 ListItem.style.color = "Gray";260 ListItem.style.backgroundColor = "White";261 }262 if(JoinPr){263 ListItem.style.color = "Blue";264 }265 }266function removeIdent(stringa) {267 while (stringa.substring(0, 1) == '>')268 { stringa = stringa.substring(1, stringa.length); }269 return stringa;270}271function trim(stringa){272 while (stringa.substring(0,1) == ' ')273 {stringa = stringa.substring(1, stringa.length);}274 while (stringa.substring(stringa.length-1, stringa.length) == ' ')275 {stringa = stringa.substring(0,stringa.length-1);}276 return stringa;277}278function CurrentListItem(){279 if(ListItems.selectedIndex!=-1){280 var SelectedId=ListItems[ListItems.selectedIndex];281 return SelectedId;282 }283}284function ListItemChange(){285 Info();286 HidePage.checked=Off;287 JoinPrevious.checked=JoinPr;288 if(IDPage){289 DisabletextModify();290 EditPage.disabled=false;291 EditPage.style.visibility = "";292 } else {293 ObjTitle.disabled=false;294 ObjLabel.disabled=false;295 ObjLink.disabled=false;296 ObjTitle.value=Title;297 ObjLabel.value=Label;298 ObjLink.value=Link;299 RemoveItem.disabled=false;300 RemoveItem.style.visibility = "";301 EditPage.disabled = true;302 EditPage.style.visibility = "hidden";303 }304}305function DisabletextModify(){306 ObjTitle.disabled=true;307 ObjLabel.disabled=true;308 ObjLink.disabled=true;309 ObjTitle.value="";310 ObjLabel.value="";311 ObjLink.value="";312 RemoveItem.disabled=true;313 RemoveItem.style.visibility = "hidden";314 }315function AbjustListVisualization(){316 for (n=1;n<=ListItems.length;n++) {317 ListItems.selectedIndex=n-1;318 Info();319 SetInfo();320 }321 ListItemChange();322}323function Submit(){324 text=""325 for (n=0;n<=ListItems.length-1;n++) {326 text = text + ListItems[n].value + '\r\n';327 }328 CodeMenu.value=text;329}330AbjustListVisualization();331function insertOption(list,option,position)332{333 try334 {335 var OptionPosition = list.options[position];336 list.add(option, OptionPosition);337 }338 catch (ex)339 {340 list.add(option, position);341 }...

Full Screen

Full Screen

personal_setting_menu.js

Source:personal_setting_menu.js Github

copy

Full Screen

1/**2 * Created by tony_vopo on 2016/9/7.3 */4var PersonalSettingMenuPage_Index = 0;5function PersonalSettingMenuPage(params,srcModule)6{7 var self = this;8 // constructor9 // Constructed end10 11 var width_List = 430;12 var height_list = 530;13 14 var width_table = width_List - 40;15 16 var font1 = uiCom.font.F18;17 var font2 = uiCom.font.F22;18 var font3 = uiCom.font.F35;19 20 var color1 = "grey";21 var color2 = "white";22 23 var listDlg;24 var listTable;25 26 var listItems;2728 this.dlgParam = [29 {uiType:UIFrame,id:"page_bk",l:0,t:0,w:1280,h:720,type:"hole"},30 //{uiType:UIFrame,id:"page_bk",l:0,t:0,w:1280,h:720,type:"img",imgNames:["setting/default_background"]},31 ];32 33 this.listParam = [34 {uiType:UIFrame,id:"list_bk",l:(1280 - width_List)/2,t:90,w:width_List,h:height_list,styleClass:"system_setting_bk"},35 {uiType:UILabel,w:width_List,h:50,ol:0,ot:2,dt:10,HAlign:"center",font:font3,value:Lp.getValue("Personal_Settings")},36 {uiType:UITable,id:"list_table",w:width_table,h:height_list*0.78,ol:(width_List-width_table)/2,ot:60,lineRectWidth:0,lineHWidth:0,lineVWidth:0,lineColor:"#505050", cols:1,rows:9,rowsOnePage:9,HAlign:"center",dl:0,color:color1,focusColor:color2,font:font2,37 skin:{38 normalBar:{type:"none"},39 focusBar:{type:"img",imgNames:["setting/subNav_selecteditemBg"],stretch:"HV",},40 }41 },42 {uiType:UIImg,w:36,h:22,ol:100,ot:height_list-40,src:"setting/ico_ok"},43 {uiType:UILabel,w:50,h:30,ol:100+40,ot:height_list-40+3,value:Lp.getValue("Ok"),font:font1},44 {uiType:UIImg,w:60,h:22,ol:100+40+50+50,ot:height_list-40,src:"setting/ico_back"},45 {uiType:UILabel,w:80,h:30,ol:100+40+50+50+62,ot:height_list-40+3,value:Lp.getValue("Up_Page"),font:font1}46 ];47 48 this.initData = function(){49 listItems = new Array();50 listItems[0] = new Array();51 listItems[0][0] = Lp.getValue("Parent_Child_Channel_Lock");52 listItems[0][1] = LockMenuPage;53 54 listItems[1] = new Array();55 listItems[1][0] = Lp.getValue("Personal_Authentication_Code");56 listItems[1][1] = PersonalPasswordPage;57 58 listItems[2] = new Array();59 listItems[2][0] = Lp.getValue("Language_And_Messaging_Settings");60 listItems[2][1] = LanguageInformationPage;616263 listItems[3] = new Array();64 listItems[3][0] = Lp.getValue("Screen_And_Sound_Settings");65 listItems[3][1] = ScreenSoundPage;6667 listItems[4] = new Array();68 listItems[4][0] = Lp.getValue("Subtitle_Setting");69 listItems[4][1] = SubtitleSettingPage;70 7172 73 /*listItems[5] = new Array();74 listItems[5][0] = Lp.getValue("Video_Function");75 listItems[5][1] = VideoFunctionPage;76 */77 listItems[5] = new Array();78 listItems[5][0] = Lp.getValue("Channel_Search");79 listItems[5][1] = ScanChannelPage;80 81 listItems[6] = new Array();82 listItems[6][0] = Lp.getValue("Network_Settings");83 listItems[6][1] = CMSettingMenuPage;84 85 listItems[7] = new Array();86 listItems[7][0] = Lp.getValue("System_Information");87 listItems[7][1] = SystemInformationPage;88 };899091 this.initData = function(){92 listItems = new Array();93 listItems[0] = new Array();94 listItems[0][0] = Lp.getValue("Parent_Child_Channel_Lock");95 listItems[0][1] = null;9697 listItems[1] = new Array();98 listItems[1][0] = Lp.getValue("Personal_Authentication_Code");99 listItems[1][1] = null;100101 listItems[2] = new Array();102 listItems[2][0] = Lp.getValue("Language_And_Messaging_Settings");103 listItems[2][1] = null;104105106 listItems[3] = new Array();107 listItems[3][0] = Lp.getValue("Screen_And_Sound_Settings");108 listItems[3][1] = null;109110 listItems[4] = new Array();111 listItems[4][0] = Lp.getValue("Subtitle_Setting");112 listItems[4][1] = null;113114115116 /*listItems[5] = new Array();117 listItems[5][0] = Lp.getValue("Video_Function");118 listItems[5][1] = VideoFunctionPage;119 */120 listItems[5] = new Array();121 listItems[5][0] = Lp.getValue("Channel_Search");122 listItems[5][1] = null;123124 listItems[6] = new Array();125 listItems[6][0] = Lp.getValue("Network_Settings");126 listItems[6][1] = null;127128 listItems[7] = new Array();129 listItems[7][0] = Lp.getValue("System_Information");130 listItems[7][1] = null;131 };132 this.initDataPage = function(){133 if(listItems[0][1] == null) {134 listItems[0][1] = LockMenuPage;135136137 listItems[1][1] = PersonalPasswordPage;138139140 listItems[2][1] = LanguageInformationPage;141142143 listItems[3][1] = ScreenSoundPage;144145146 listItems[4][1] = SubtitleSettingPage;147148149 /*150 listItems[5][1] = VideoFunctionPage;151 */152153 listItems[5][1] = ScanChannelPage;154155156 listItems[6][1] = CMSettingMenuPage;157158159 listItems[7][1] = SystemInformationPage;160 }161 };162 this.initView = function(){163 listDlg = UI.createGroup(self.listParam,"listDlg",self.win);164 listTable = listDlg.getChild("list_table");165 166 listTable.addItems(listItems);167 listTable.curIndex = PersonalSettingMenuPage_Index;168 listTable.setFocus(true);169 self.win.update();170 };171 172 this.open = function(){173 this.initData();174 this.defOpen();175 this.initView();176 };177178 this.close = function(){179 this.defClose();180 };181182 this.start = function(){183 setTimeout(function(){184185 var rect = {186 l:0,187 t:0,188 w:1280,189 h:720190 };191 var r = getVideoRect(rect,sysCom.config.Reslution);192 dtvCom.mp.mpSetVideoSize(r.l, r.t, r.w, r.h, false);193 }, 300);194 };195196 this.key_return = function(){197 var index = listTable.curIndex;198 console.log("key_return index == "+index);199 switch(index){200 case 0:201 case 3:202 case 5:203 case 6:204 //case 7:205 var passwd = sysCom.config.ParentalPin;206 var p = {207 win:self.win,208 rightPasswd:passwd,209 titleCont:Lp.getValue("Please_Input_Parent_Password"),210 rightDo:function(){211 var page = listItems[index][1];212 self.go(page);213 },214 backDo:function(){215 listTable.setFocus(true);216 }217 };218 var pd = new PasswdDialog(p);219 pd.show();220 221 break;222 case 1:223 var passwd = sysCom.config.PersonalAuthenticationPin;224 var p = {225 win:self.win,226 rightPasswd:passwd,227 titleCont:Lp.getValue("Please_Input_Persional_Password"),228 rightDo:function(){229 var page = listItems[index][1];230 self.go(page);231 },232 backDo:function(){233 listTable.setFocus(true);234 }235 };236 var pd = new PasswdDialog(p);237 pd.show();238 break;239 default:240 var page = listItems[index][1];241 self.go(page);242 break;243 }244 };245246 this.onkey = function(e)247 {248 var ret = false;249 switch(e.keyCode)250 {251 case UI.KEY.ENTER:252 PersonalSettingMenuPage_Index = listTable.curIndex;253 self.initDataPage();254 self.key_return();255 break;256 case UI.KEY.BACKSPACE:257 PersonalSettingMenuPage_Index = 0;258 appCom.goAppByName("tvportal",true);259 break;260261 case UI.KEY.FUNRED:262 /*console.log("FUNRED");263 utility.cnsCreateFile("/ch_flash_data/fctflag.txt",function(){264 Utility.reboot(false);265 });266 ret = true;*/267 break;268 }269 return ret;270 };271}272PersonalSettingMenuPage.prototype = UIModule.baseModule; ...

Full Screen

Full Screen

system_setting_menu.js

Source:system_setting_menu.js Github

copy

Full Screen

1/**2 * Created by tony_vopo on 2016/9/7.3 */4var firstGoSystemSettingPage = true;5var SystemSettingPage_index = 0;6function SystemSettingMenuPage(params,srcModule)7{8 var self = this;9 // constructor10 // Constructed end11 12 var width_List = 430;13 var height_list = 690;14 15 var width_table = width_List - 40;16 17 var font1 = uiCom.font.F22;18 var font2 = uiCom.font.F30;19 var font3 = uiCom.font.F35;20 21 var color1 = "grey";22 var color2 = "white";23 24 var listDlg;25 var listTable;26 27 var listItems;2829 this.dlgParam = [30 //{uiType:UIFrame,id:"page_bk",l:0,t:0,w:1280,h:720,type:"hole"},31 {uiType:UIFrame,id:"page_bk",l:0,t:0,w:1280,h:720,type:"none"},32 ];33 34 this.listParam = [35 {uiType:UIFrame,id:"list_bk",l:(1280 - width_List)/2,t:16,w:width_List,h:height_list,styleClass:"system_setting_bk",visibility:0},36 {uiType:UILabel,w:width_List,h:50,ol:0,ot:2,dt:10,HAlign:"center",font:font3,value:Lp.getValue("System_Setting")},37 {uiType:UITable,id:"list_table",w:width_table,h:height_list*0.83,ol:(width_List-width_table)/2,ot:58,lineRectWidth:0,lineHWidth:0,lineVWidth:0,lineColor:"#505050", cols:1,rows:13,rowsOnePage:13,HAlign:"center",dl:0,color:color1,focusColor:color2,38 skin:{39 normalBar:{type:"none"},40 focusBar:{type:"img",imgNames:["setting/subNav_selecteditemBg"],stretch:"HV",},41 }42 },43 {uiType:UIImg,w:36,h:22,ol:100,ot:height_list-40,src:"setting/ico_ok"},44 {uiType:UILabel,w:50,h:30,ol:100+40,ot:height_list-40+3,value:Lp.getValue("OK"),font:font1},45 {uiType:UIImg,w:60,h:22,ol:100+40+50+50,ot:height_list-40,src:"setting/ico_back"},46 {uiType:UILabel,w:80,h:30,ol:100+40+50+50+62,ot:height_list-40+3,value:Lp.getValue("UP_Page"),font:font1}47 ];48 49 var index = 0;50 this.initData = function(){51 listItems = new Array();52 listItems[index] = new Array();53 listItems[index][0] = Lp.getValue("System_Update");54 listItems[index++][1] = null;55 56 listItems[index] = new Array();57 listItems[index][0] = Lp.getValue("Search_Channel");58 listItems[index++][1] = null;59 60 listItems[index] = new Array();61 listItems[index][0] = Lp.getValue("Singal_Check");62 listItems[index++][1] = null;63 64 listItems[index] = new Array();65 listItems[index][0] = Lp.getValue("Network_Settings");66 listItems[index++][1] = null;67 68 listItems[index] = new Array();69 listItems[index][0] = Lp.getValue("CM_Information");70 listItems[index++][1] = null;71 72 listItems[index] = new Array();73 listItems[index][0] = Lp.getValue("CA_Information");74 listItems[index++][1] = null;75 76 listItems[index] = new Array();77 listItems[index][0] = Lp.getValue("Reset_STB");78 listItems[index++][1] = null;79 80 /*listItems[index] = new Array();81 listItems[index][0] = Lp.getValue("Authorization_Status");82 listItems[index++][1] = null;*/83 84 listItems[index] = new Array();85 listItems[index][0] = Lp.getValue("Work_Order_Return");86 listItems[index++][1] = null;87 88 listItems[index] = new Array();89 listItems[index][0] = Lp.getValue("DTV_Bidirectional_Module_Return");90 listItems[index++][1] = null;91 92 listItems[index] = new Array();93 listItems[index][0] = Lp.getValue("Action_Open_QR");94 listItems[index++][1] = null;95 96 /*listItems[index] = new Array();97 listItems[index][0] = Lp.getValue("BID_Setting");98 listItems[index++][1] = null;*/99 100 listItems[index] = new Array();101 listItems[index][0] = Lp.getValue("Format_Hard_Disk");102 listItems[index++][1] = null;103104 listItems[index] = new Array();105 listItems[index][0] = Lp.getValue("app_update");106 listItems[index++][1] = null;107108 listItems[index] = new Array();109 listItems[index][0] = Lp.getValue("Debug_Information");110 listItems[index++][1] = null;111 112 /*listItems[index] = new Array();113 listItems[index][0] = Lp.getValue("VBM_Switch");114 listItems[index++][1] = null;*/115 };116 this.initDataPage = function(){117 index = 0;118 if( listItems[0][1] == null) {119 listItems[index++][1] = SystemUpdateMenuPage;120121122 listItems[index++][1] = ScanChannelPage;123124125 listItems[index++][1] = SignalCheckPage;126127128 listItems[index++][1] = NetworkSettingMenuPage;129130131 listItems[index++][1] = CMInformationPage;132133 listItems[index++][1] = CAInformationMenuPage;134135136 listItems[index++][1] = RestoreFactorySettingPage;137138 /*139 listItems[index++][1] = ClusterMachineStatusPage;*/140141142 listItems[index++][1] = WorkOrderReturnPage;143144145 listItems[index++][1] = WorkOrderReturnPage;146147 listItems[index++][1] = AcitonOpenPage;148149 /*150 listItems[index++][1] = BidSettingPage;*/151152153 listItems[index++][1] = FormatHardDiskPage;154155 listItems[index++][1] = AppUpdatePage;156157158 listItems[index++][1] = DebugInformationPage;159 }160 /*161 listItems[index++][1] = VBMInformationPage;*/162 };163 this.initView = function(){164 listDlg = UI.createGroup(self.listParam,"listDlg",self.win);165 listTable = listDlg.getChild("list_table");166167 listTable.addItems(listItems);168 listTable.curIndex = SystemSettingPage_index;169 if(firstGoSystemSettingPage == true)170 {171 showPasswordDlg();172 firstGoSystemSettingPage = false;173 }174 else{175 this.initDataPage();176 listTable.setFocus(true);177 listDlg.visibility = 1;178 self.win.update();179 }180 };181 182 function rightDo(){183 listTable.setFocus(true);184 listDlg.visibility = 1;185 self.win.update();186 }187 function backDo(){188 appCom.goAppByName("tvportal",true);189 }190 191 function showPasswordDlg(){192 var p = 193 {194 win:self.win,195 titleCont:Lp.getValue("Please_Input_System_Password"),196 rightPasswd:sysCom.config.SystemSettingPin,197 rightDo:rightDo,198 backDo:backDo199 };200 var pd = new PasswdDialog(p);201 pd.show();202 }203 204 this.open = function(){205 this.initData();206 this.defOpen();207 this.initView();208 };209210 this.close = function(){211212213 this.defClose();214 };215216 this.start = function(){217 setTimeout(function(){218219 var rect = {220 l:0,221 t:0,222 w:1280,223 h:720224 };225 var r = getVideoRect(rect,sysCom.config.Reslution);226 dtvCom.mp.mpSetVideoSize(r.l, r.t, r.w, r.h, false);227 }, 300);228 };229230 this.key_return = function(){231 var index = listTable.curIndex;232 this.initDataPage();233 var page = listItems[index][1];234235 if(page!=""){236 this.go(page);237 }238 else{239 console.log("還沒實現"); 240 }241 }242243 this.onkey = function(e)244 {245 var ret = false;246 switch(e.keyCode)247 {248 case UI.KEY.ENTER:249 SystemSettingPage_index = listTable.curIndex;250 self.key_return();251 break;252 case UI.KEY.BACKSPACE:253 SystemSettingPage_index = 0;254 appCom.goAppByName("tvportal",true);255 break;256 }257 return ret;258 };259}260SystemSettingMenuPage.prototype = UIModule.baseModule; ...

Full Screen

Full Screen

checklist-factory.js

Source:checklist-factory.js Github

copy

Full Screen

1app.factory("CheckListFactory", function($q, $http, $rootScope, FIREBASE_CONFIG){2 let postChecklist = (listItems, id) => {3 return $q((resolve, reject) => {4 for(i=0;i<listItems.length;i++){5 let asf = listItems[i]["ASF / Marketing Plan / PID File"];6 let grid = listItems[i].Grid;7 let psd = listItems[i]["PSD - Copied to the Server"];8 let html = listItems[i].HTML;9 let images = listItems[i].Images;10 let text = listItems[i].Text;11 let cellId = listItems[i]["Cell Id"];12 let rownum = listItems[i]["Rownum not in joins"];13 let redirects = listItems[i]["No redirected links"];14 let detectTags = listItems[i]["Open Detect tags not included in source"];15 let placeholder = listItems[i]["If links were not provided, use: (placeholder image)"];16 let formAction = listItems[i]["Form action is formatted correctly for redirection"];17 let formVariable = listItems[i]["Form Variable hidden inputs are not hard coded"];18 let boxes = listItems[i]["No boxes or strange charcaters"];19 let spellCheck = listItems[i]["Spell check subject lines"];20 let report = listItems[i]["Report names correct per ASF"];21 let links = listItems[i]["All inks reported on, unless otherwise requested"];22 let postal = listItems[i]["Postal Address visible"];23 let naming = listItems[i]["Consistent Naming - reportnames, images, image folders"];24 let breaks = listItems[i]["No breaks in table structure"];25 let brokenImages = listItems[i]["No broken/missing images"];26 let spaces = listItems[i]["No spaces in image names"];27 let fonts = listItems[i]["No inconsistent/unusual fonts"];28 let securePayPal = listItems[i]["All links are secure - PayPal only"];29 let hostPayPAl = listItems[i]["Secure hosted link used - PayPal only"];30 let altTags = listItems[i]["Alt tags updated per ASF or content"];31 let imagesAbsolute = listItems[i]["images absolutely referenced"];32 let outlook2013 = listItems[i]["Outlook 2013 Rendering: Add style to 'td' cells under 20px in height --> Style='font-size:0; line-height:0';"];33 let title = listItems[i]["Update <title> of the build for hosted link"];34 let psdMatch = listItems[i]["make sure all content matches PSD: alignment, padding, font sizes, colors, etc"];35 let specialChar = listItems[i]["No special characters"];36 let textHTML = listItems[i]["Text is representative of HTML"];37 let mergeError = listItems[i]["No Merger errors"];38 let audiences = listItems[i]["Correct audiences receive correct creative"];39 let hostedLink = listItems[i]["Hosted link is functional"];40 let forwardFunc = listItems[i]["f2f is functional"];41 let forwardUnsub = listItems[i]["F2F and Unsub links removed on forwarded versions"];42 let unsub = listItems[i]["unsub resolves to proper landing page"];43 let workingRedirects = listItems[i]["redirects working"];44 let dynamic = listItems[i]["dynamic elements published as instructed"];45 let jiraTasks = listItems[i]["All requests in Jira task complete"];46 let oneUpLayout = listItems[i]["One-up layout matches build/spec"];47 let forms = listItems[i]["Forms are functional and redirected"];48 let litmus = listItems[i]["Send and verify rendering through Litmus"];49 let responsive = listItems[i]["Responsive version is checked"];50 $http.post(`${FIREBASE_CONFIG.databaseURL}/projects/${id}/checklist.json`, JSON.stringify({51 "Grid" : grid,52 "ASF" : asf,53 "PSD" : psd,54 "HTML" : html,55 "IMAGES" : images,56 "TEXT" : text,57 "CELLID" : cellId,58 "ROWNUM" : rownum,59 "REDIRECTS": redirects,60 "DETECTAGS" : detectTags,61 "PLACEHOLDER" : placeholder,62 "FORMACTION" : formAction,63 "FORMVARIABLE" : formVariable,64 "BOXES" : boxes,65 "SPELLCHECK" : spellCheck,66 "REPORT" : report,67 "LINKS" : links,68 "POSTAL" : postal,69 "NAMING" : naming,70 "BREAKS" : breaks,71 "BROKENIMAGES" : brokenImages,72 "SPACES" : spaces,73 "FONTS" : fonts,74 "SECUREPAYPAL" : securePayPal,75 "HOSTPAYPAL" : hostPayPAl,76 "ALTTAGS" : altTags,77 "IMAGEABSOLUTE" :imagesAbsolute,78 "OUTLOOK2013" : outlook2013,79 "TITLE" : title,80 "PSDMATCH" : psdMatch,81 "SPECIALCHAR" : specialChar,82 "TEXTHTML" : textHTML,83 "MERGEERROR" : mergeError,84 "AUDIENCES" : audiences,85 "HOSTEDLINK" : hostedLink,86 "FORWARDFUNC" : forwardFunc,87 "FORWARDUNSUB" : forwardUnsub,88 "UNSUB" : unsub,89 "WORKINGREDIRECTS" : workingRedirects,90 "DYNAMIC" : dynamic,91 "JIRATASKS" : jiraTasks,92 "ONEUPLAYOUT" : oneUpLayout,93 "FORMS" : forms,94 "LITMUS" : litmus,95 "RESPONSIVE" : responsive96 }))97 .then((result) => {98 console.log(result);99 resolve(result);100 }).catch((error) => {101 reject(error);102 });103 }104 });105 }106 let markTrue = (projectId) => {107 return $q((resolve, reject) => {108 $http.put(`${FIREBASE_CONFIG.databaseURL}/projects/${projectId}.json`, JSON.stringify({109 "checklist" : true110 }))111 .then((result) => {112 resolve(result.config.data);113 }).catch((error) => {114 reject(error);115 });116 });117 }118 let getCheckedData = (projId) => {119 let checklist = [];120 return $q((resolve, reject) => {121 $http.get(`${FIREBASE_CONFIG.databaseURL}/projects/${projId}/checklist.json`).then((result) => {122 let dataCollect = result.data;123 if(dataCollect !== null){124 Object.keys(dataCollect).forEach((key) => {125 // dataCollect[key].id = key;126 checklist.push(dataCollect[key]);127 });128 }129 console.log(checklist);130 resolve(checklist);131 }).catch((error) => {132 reject(error);133 });134 });135 }136 return { postChecklist:postChecklist, getCheckedData:getCheckedData }...

Full Screen

Full Screen

gilded_rose_spec.js

Source:gilded_rose_spec.js Github

copy

Full Screen

1const { Shop, Item } = require('../src/gilded_rose.js');2describe('GildedRose shop manager', () => {3 let listItems;4 beforeEach(() => {5 listItems = [];6 });7 it("Baisser de 1 la qualité et sellIn d'item normaux", () => {8 listItems.push(new Item('+5 Dexterity Vest', 10, 20));9 listItems.push(new Item('Mana Cake', 3, 6));10 const gildedRose = new Shop(listItems);11 const items = gildedRose.updateQuality();12 const expected = [13 { sellIn: 9, quality: 19 },14 { sellIn: 2, quality: 5 },15 ];16 expected.forEach((testCase, idx) => {17 expect(items[idx].quality).toBe(testCase.quality);18 expect(items[idx].sellIn).toBe(testCase.sellIn);19 });20 });21 it('Augmenter la qualité de 1 pour Aged Brie et Backstage pass', () => {22 listItems.push(new Item('Aged Brie', 20, 30));23 listItems.push(new Item('Backstage passes to a TAFKAL80ETC concert', 20, 30));24 const gildedRose = new Shop(listItems);25 const items = gildedRose.updateQuality();26 const expected = [27 { sellIn: 19, quality: 31 },28 { sellIn: 19, quality: 31 },29 ];30 expected.forEach((testCase, idx) => {31 expect(items[idx].quality).toBe(testCase.quality);32 expect(items[idx].sellIn).toBe(testCase.sellIn);33 });34 });35 it('Augmenter la qualité de 3 quand il reste 5 jours ou moins avant la deadline du brie ou de backstage', () => {36 listItems.push(new Item('Aged Brie', 5, 30));37 listItems.push(new Item('Backstage passes to a TAFKAL80ETC concert', 4, 30));38 const gildedRose = new Shop(listItems);39 const items = gildedRose.updateQuality();40 const expected = [41 { sellIn: 4, quality: 33 },42 { sellIn: 3, quality: 33 },43 ];44 expected.forEach((testCase, idx) => {45 expect(items[idx].quality).toBe(testCase.quality);46 expect(items[idx].sellIn).toBe(testCase.sellIn);47 });48 });49 it('Ne pas modifier la qualité de Sulfuras', () => {50 listItems.push(new Item('Sulfuras', 5, 80));51 const gildedRose = new Shop(listItems);52 const items = gildedRose.updateQuality();53 const expected = [54 { quality: 80 },55 ];56 expected.forEach((testCase, idx) => {57 expect(items[idx].quality).toBe(testCase.quality);58 });59 });60 it("Réduire deux fois plus rapidement la qualité des items Conjured", () => {61 listItems.push(new Item('Conjured cat', 10, 20));62 listItems.push(new Item('+5 Astrology Vest', 10, 20));63 const gildedRose = new Shop(listItems);64 const items = gildedRose.updateQuality();65 const expected = [66 { sellIn: 9, quality: 18 },67 { sellIn: 9, quality: 19 },68 ];69 expected.forEach((testCase, idx) => {70 expect(items[idx].quality).toBe(testCase.quality);71 expect(items[idx].sellIn).toBe(testCase.sellIn);72 });73 });74 it("Réduire deux fois plus rapidement la qualité des items une fois la dates de péremption dépassée", () => {75 listItems.push(new Item('+5 Astrology Vest', 10, 20));76 listItems.push(new Item('Top quality cake', -1, 20));77 const gildedRose = new Shop(listItems);78 const items = gildedRose.updateQuality();79 const expected = [80 { sellIn: 9, quality: 19 },81 { sellIn: -2, quality: 18 },82 ];83 expected.forEach((testCase, idx) => {84 expect(items[idx].quality).toBe(testCase.quality);85 expect(items[idx].sellIn).toBe(testCase.sellIn);86 });87 });88 it("La qualité ne peux pas passer sous 0", () => {89 listItems.push(new Item('+5 Astrology Vest', 10, 0));90 listItems.push(new Item('Top quality cake', -1, 0));91 const gildedRose = new Shop(listItems);92 const items = gildedRose.updateQuality();93 const expected = [94 { quality: 0 },95 { quality: 0 },96 ];97 expected.forEach((testCase, idx) => {98 expect(items[idx].quality).toBe(testCase.quality);99 });100 });101 it("La qualité des produits (hors Sulfuras) ne peux pas passer au-dessus de 50", () => {102 listItems.push(new Item('Sulfuras', 10, 80));103 listItems.push(new Item('Aged Brie', 5, 50));104 const gildedRose = new Shop(listItems);105 const items = gildedRose.updateQuality();106 const expected = [107 { quality: 80 },108 { quality: 50 },109 ];110 expected.forEach((testCase, idx) => {111 expect(items[idx].quality).toBe(testCase.quality);112 });113 });114 it("La qualité des pass Backstage tombe à 0 après le concert", () => {115 listItems.push(new Item('Backstage passes', 0, 20));116 const gildedRose = new Shop(listItems);117 const items = gildedRose.updateQuality();118 const expected = [119 { sellIn: -1, quality: 0 },120 ];121 expected.forEach((testCase, idx) => {122 expect(items[idx].quality).toBe(testCase.quality);123 });124 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Visits the Kitchen Sink', function() {3 cy.pause()4 cy.contains('type').click()5 cy.url().should('include', '/commands/actions')6 cy.get('.action-email')7 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Visits the Kitchen Sink', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 })6})7describe('My First Test', function() {8 it('Does not do much!', function() {9 cy.contains('type').click()10 cy.url().should('include', '/commands/actions')11 })12})13describe('My First Test', function() {14 it('Does not do much!', function() {15 cy.contains('type').click()16 cy.url().should('include', '/commands/actions')17 })18})19describe('My First Test', function() {20 it('Does not do much!', function() {21 cy.contains('type').click()22 cy.url().should('include', '/commands/actions')23 })24})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.pause()4 cy.contains('type').click()5 cy.url().should('include', '/commands/actions')6 cy.get('.action-email')7 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('fake@email')7 .should('have.value', 'fake@email')8 })9})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 })4 it('finds the content "type"', function() {5 cy.contains('type')6 })7 it('clicks the link "type"', function() {8 cy.contains('type').click()9 })10 it('clicks the link "type" and then clicks the link "type"', function() {11 cy.contains('type').click()12 cy.contains('type').click()13 })14 it('clicks the link "type" and then clicks the link "type"', function() {15 cy.contains('type').click()16 cy.contains('type').click()17 })18 it('clicks the link "type" and then clicks the link "type"', function() {19 cy.contains('type').click()20 cy.contains('type').click()21 })22 it('clicks the link "type" and then clicks the link "type"', function() {23 cy.contains('type').click()24 cy.contains('type').click()25 })26 it('clicks the link "type" and then clicks the link "type"', function() {27 cy.contains('type').click()28 cy.contains('type').click()29 })30 it('clicks the link "type" and then clicks the link "type"', function() {31 cy.contains('type').click()32 cy.contains('type').click()33 })34 it('clicks the link "type" and then clicks the link "type"', function() {35 cy.contains('type').click()36 cy.contains('type').click()37 })38 it('clicks the link "type" and then clicks the link "type"', function() {39 cy.contains('type').click()40 cy.contains('type').click()41 })

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('List items', () => {2 it('Should list items', () => {3 cy.get('.query-list')4 .contains('bananas')5 .should('have.class', 'third')6 })7})8describe('List items', () => {9 it('Should list items', () => {10 cy.get('.query-list')11 .contains('apples')12 .should('have.class', 'first')13 })14})15describe('List items', () => {16 it('Should list items', () => {17 cy.get('.query-list')18 .contains('oranges')19 .should('have.class', 'second')20 })21})22describe('List items', () => {23 it('Should list items', () => {24 cy.get('.query-list')25 .contains('grapes')26 .should('have.class', 'third')27 })28})29describe('List items', () => {30 it('Should list items', () => {31 cy.get('.query-list')32 .contains('bananas')33 .should('have.class', 'third')34 })35})36describe('List items', () => {37 it('Should list items', () => {38 cy.get('.query-list')39 .contains('apples')40 .should('have.class', 'first')41 })42})43describe('List items', () => {44 it('Should list items', () => {45 cy.get('.query-list')

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test the list items', () => {2 it('should return the list items', () => {3 cy.get('.todo-list li').should('have.length', 3)4 cy.get('.todo-list li').first().should('have.text', 'Pay electric bill')5 cy.get('.todo-list li').eq(1).should('have.text', 'Walk the dog')6 cy.get('.todo-list li').last().should('have.text', 'Read the newspaper')7 cy.get('.todo-list li').contains('Walk the dog').should('have.text', 'Walk the dog')8 })9})10describe('Test the list items', () => {11 it('should return the list items', () => {12 cy.get('.todo-list li').each(($el, index, $list) => {13 const text = $el.text()14 if (text.includes('Read')) {15 cy.wrap($el).click()16 }17 })18 })19})20describe('Test the list items', () => {21 it('should return the list items', () => {22 cy.get('.todo-list li').first().invoke('text').should('include', 'Pay electric bill')23 })24})25describe('Test the list items', () => {26 it('should return the list items', () => {27 cy.get('.todo-list li').first().then(($firstLi) => {28 cy.wrap($firstLi).should('have.class', 'todo')29 })30 })31})32describe('Test the list items', () => {33 it('should return the list items', () => {34 cy.get('.todo-list li').filter('.completed').should('have.length', 1)35 })36})

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

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