How to use serve method in Slash

Best Python code snippet using slash

pack.js

Source:pack.js Github

copy

Full Screen

1/**2 * Created by horo on 2016/10/21.3 */4$(function () {5 findAll(currentPage);6 findAllServe();7 $("#serveAdd").click(function () {8 $("#servePro").show(200);9 })10 nursifyClass();11})12var serveNamePull = "";13function findAllServe(currentPage) {14 var url = domainUrl + "/serve/services/findAll";15 var getData = {currentPage: currentPage, limit: limit};16 var html = "";17 getAjax(url, false, getData, function (data) {18 var num = data.aaData.length;19 for (var i = 0; i < num; i++) {20 html += '<a value="' + data.aaData[i].id + '" class="servename">' + data.aaData[i].serveName + '</a>';21 }22 html += '<input type="button" value="选择完成" class="btn" id="serversAdd">';23 $("#servePro").html(html);24 $(".servename").click(function () {25 if ($(this).hasClass("colorA")) {26 $(this).removeClass("colorA")27 serveNamePull = serveNamePull.replace('' + $(this).attr("value") + ',', '');28 } else {29 serveNamePull += '' + $(this).attr("value") + ',';30 $(this).addClass("colorA")31 }32 if (serveNamePull == "") {33 $("#serversAdd").css("pointer-events", "none").css("background-color", "#DDDDDD")34 } else {35 $("#serversAdd").css("pointer-events", "auto").css("background-color", "#FF4B01")36 }37 })38 $("#serversAdd").click(function () {39 $("#servePro").hide(200);40 })41 })42}43var pageList;44var pageNp = 1;45function findAll(currentPage) {46 var url = domainUrl + '/serve/service_pack/findAll';47 var getData = {currentPage: currentPage, limit: limit};48 var html = '<table id="aaa"><tbody> <tr> <th>名称</th> <th>折扣</th> <th>开始时间</th> <th>结束时间</th> <th>服务项</th> <th>注意事项</th><th>护理级别</th><th>服务简介</th> <th>操作</th></tr> </tbody>';49 var tile='';50 var num = '';51 var serveNum = '';52 var picture = '';53 getAjax(url, false, getData, function (data) {54 num = data.aaData.length;55 pageList = Math.ceil(data.iTotalRecords / limit);56 for (var i = 0; i < num; i++) {57 var serveList = '';58 for (var j = 0; j < serveNum; j++) {59 serveList += '' + data.aaData[i].servicesList[j].serveName + '、';60 }61 html += '<tr><td>' + data.aaData[i].serveName + '</td><td>' + data.aaData[i].servrRebate + '</td><td>' + data.aaData[i].serveStartDate.substring(0, 11) + '</td>' +62 '<td>' + data.aaData[i].serveEnddate.substring(0, 11) + '</td><td>' + serveList + '</td><td>' + data.aaData[i].serveCare + '</td>' +63 '<td>' + data.aaData[i].serveNurseify.nursifyName + '</td><td>' + data.aaData[i].serveBrief + '</td>' +64 '<td><i class="glyphicon glyphicon-pencil bianji" title="编辑" onclick="make(' + data.aaData[i].id + ')"></i>' +65 '<i class="glyphicon glyphicon-remove shanchu" title="删除" onclick="del(' + data.aaData[i].id + ')"></i></td></tr>';66 if (data.aaData[i].commentPicture.pictureAddress == null) {67 picture = '<img src=' + domainFile + '/assets/images/serve/pack.png onclick="uploadShow(' + data.aaData[i].id + ')"/>';68 } else {69 picture = '<img src="' + domainFile + '/assets/uploadimg/' + data.aaData[i].commentPicture.pictureAddress + '" onclick="uploadShow(' + data.aaData[i].id + ')" />';70 }71 tile += ' <div class="main-modules"><i class="glyphicon glyphicon-pencil bianji" title="编辑" style="margin-right: 30px;" onclick="make(' + data.aaData[i].id + ')"></i><i' +72 ' class="glyphicon glyphicon-remove shanchu" title="删除" onclick="del(' + data.aaData[i].id + ')"></i><ul> <li id="staff-mess1">' + picture + '</li>' +73 ' <li id="staff-mess2"> <ul> <li>名称</li> <li>折扣</li> <li>开始时间</li> <li>结束时间</li> <li>服务项</li> </ul>' +74 ' <ul class="staff-mess-right"> <li>' + data.aaData[i].serveName + '</li> <li>' + data.aaData[i].servrRebate + '</li> <li id="sdate-text" >' + data.aaData[i].serveStartDate.substring(0, 11) + '</li> ' +75 '<li id="edate-text" >' + data.aaData[i].serveEnddate.substring(0, 11) + '</li> <li>' + serveList + '</li> </ul> </li> <li id="staff-mess3"> <ul> <li>注意事项</li>' +76 ' <li>护理级别</li><li>服务简介</li> </ul> ' +77 '<ul class="staff-mess-right"> <li>' + data.aaData[i].serveCare + '</li><li>' + data.aaData[i].serveNurseify.nursifyName + '</li> <li>' + data.aaData[i].serveBrief + '</li>' +78 ' </ul> </li>' +79 ' </ul> </div>';80 }81 html+='</table>';82 if(findAllNum ==1){83 $(".main-module").html(html);84 }else{85 $(".main-module").html(tile);86 }87 if (pageNp == 1) {88 pageNp = 2;89 $(".tcdPageCode").createPage({90 pageCount: pageList,91 current: currentPage,92 backFn: function (p) {93 findAll(p)94 }95 });96 }97 tableTileShow(tile,html);98 })99}100function clearModal() {101 $("#update-btn").hide();102 $("#add-btn").show();103 $("#name").val(""); //服务名称104 $("#care").val(""); //注意事项105 $("#rebate").val(""); //折扣106 $("#brief").val(); //服务简介107}108function add() {109 var serveName = $("#name").val(); //服务名称110 var serveCare = $("#care").val(); //注意事项111 var serveRebate = $("#rebate").val(); //折扣112 var ServeStartDate = $("#sdate").val();//开始时间113 var ServeEnddate = $("#edate").val(); //结束时间114 var serveBrief = $("#brief").val(); //服务简介115 var url = domainUrl + '/serve/service_pack/add';116 var postData = {117 serveDetailed: 1,118 serveName: serveName,119 serveCare: serveCare,120 serveRebate: serveRebate,121 ServeStartdate: ServeStartDate,122 ServeEnddate: ServeEnddate,123 serveServes: serveNamePull,124 serveNurseify: 1,125 serveBrief: serveBrief,126 serveDetailed: ""127 };128 postAjax(url, false, postData, function (data) {129 alert("打包成功");130 findAll(currentPage);131 $('#myModal').modal("hide");132 })133}134function update() {135 var serveName = $("#name").val(); //服务名称136 var serveCare = $("#care").val(); //注意事项137 var serveRebate = $("#rebate").val(); //折扣138 var ServeStartDate = $("#sdate").val();//开始时间139 var ServeEnddate = $("#edate").val(); //结束时间140 var serveNurseify = $("#nurseify").val(); //护理级别141 var serveBrief = $("#brief").val(); //服务简介142 var url = domainUrl + '/serve/service_pack/update';143 var id = $("#xid").text();144 var postData = {145 id: id,146 serveDetailed: 1,147 serveName: serveName,148 serveCare: serveCare,149 serveRebate: serveRebate,150 ServeStartDate: ServeStartDate,151 ServeEnddate: ServeEnddate,152 serveServes: serveNamePull,153 serveNurseify: serveNurseify,154 serveBrief: serveBrief,155 serveDetailed: ""156 };157 postAjax(url, false, postData, function (data) {158 alert("修改成功");159 findAll(currentPage);160 $('#myModal').modal("hide");161 })162}163function del(id) {164 var url = domainUrl + '/serve/service_pack/del';165 var postData = {id: id};166 postAjax(url, false, postData, function (data) {167 alert("刪除成功");168 $("#shanchu-yes").show();169 $("#shanchu-no").hide();170 findAll(currentPage);171 })172}173function make(id) {174 $("#xid").text(id);175 findAllServe();176 $("#update-btn").show();177 $("#add-btn").hide();178 var url = domainUrl + '/serve/service_pack/findAll';179 var getData = {};180 var name, care, rebate, sdate, edate, nurseify, brief;181 getAjax(url, false, getData, function (data) {182 var num = data.aaData.length;183 for (var i = 0; i < num; i++) {184 if (id == data.aaData[i].id) {185 name = data.aaData[i].serveName;186 rebate = data.aaData[i].servrRebate;187 sdate = $("#sdate-text").text();188 edate = $("#edate-text").text();189 care = data.aaData[i].serveCare;190 nurseify = data.aaData[i].serveNurseify.nursifyLeave;191 brief = data.aaData[i].serveBrief;192 $("#name").val(name); //服务名称193 $("#care").val(care); //注意事项194 $("#rebate").val(rebate); //折扣195 $("#sdate").val(sdate);//开始时间196 $("#edate").val(edate); //结束时间197 $("#nurseify").val(nurseify); //护理级别198 $("#brief").val(brief); //服务简介199 }200 }201 $('#myModal').modal("show");202 })203}204function upload(id) {205 $("#box").hide();206 $("#aaaa").hide();207 var url = domainUrl + '/serve/service_pack_picture/adds';208 var postData = {209 servicePackId: id,210 pictureAddress: pathList,211 };212 postAjax(url, false, postData, function (data) {213 alert("上传成功");214 findAll(currentPage);215 })216}217//树218var nursifyClass;219function nursifyClass() {220 var url = domainUrl+"/serve/nurseify/findTreeAll";221 var getData = {currentPage: currentPage, limit: limit};222 var html = '<option value="请选择">请选择</option>'223 getAjax(url, false, getData, function (data) {224 var num = data.aaData[0].length;225 console.log(JSON.stringify(data))226 for (var i = 0; i < num; i++) {227 html += '<option value="' + data.aaData[0][i].id + '">' + data.aaData[0][i].nursifyName + '</option>';228 }229 $("#nurseify").html(html);230 var type = document.getElementById('nurseify');231 type.onchange = function () {232 var id = this.value;233 if (data.aaData[1] != undefined && id != "请选择") {234 for (var i = 0; i < data.aaData[1].length; i++) {235 if (data.aaData[1][i].nursifyTid != null) {236 $("#tr2").show();237 nursifyClass2(id);238 nursifyClass = null;239 } else {240 var selectIndex = document.getElementById("nurseify").selectedIndex;//获得是第几个被选中了241 var selectText = document.getElementById("nurseify").options[selectIndex].value //获得被选中的项目242 nursifyClass = selectText;243 $("#tr2").hide();244 }245 }246 } else {247 var selectIndex = document.getElementById("nurseify").selectedIndex;//获得是第几个被选中了248 var selectText = document.getElementById("nurseify").options[selectIndex].value //获得被选中的项目249 nursifyClass = selectText;250 $("#tr2").hide();251 }252 }253 })254}255function nursifyClass2(id) {256 var url = domainUrl+"/serve/nurseify/findTreeAll";257 var getData = {currentPage: currentPage, limit: limit};258 var html = '<option>请选择</option>'259 getAjax(url, false, getData, function (data) {260 var num = data.aaData[1].length;261 for (var i = 0; i < num; i++) {262 if (id == data.aaData[1][i].nursifyTid) {263 html += '<option value="' + data.aaData[1][i].id + '">' + data.aaData[1][i].nursifyName + '</option>';264 }265 }266 $("#nurseify2").html(html);267 var type = document.getElementById('nurseify2');268 type.onchange = function () {269 var selectIndex = document.getElementById("nurseify2").selectedIndex;//获得是第几个被选中了270 var selectText = document.getElementById("nurseify2").options[selectIndex].value //获得被选中的项目271 nursifyClass = selectText;272 }273 })...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1/**2 * index.js - 服务开通记录明细3 * @date: 2019-07-104 * @author: WY <yang.wang08@hand-china.com>5 * @version: 0.0.16 * @copyright: Copyright (c) 2018, Hand7 */8import React, { Component } from 'react';9import { connect } from 'dva';10import { Spin, Card, Row, Col, Button } from 'hzero-ui';11import { Bind } from 'lodash-decorators';12import classnames from 'classnames';13import { Header, Content } from 'components/Page';14import { DETAIL_CARD_CLASSNAME } from 'utils/constants';15import { filterNullValueObject, createPagination, getCurrentOrganizationId } from 'utils/utils';16import formatterCollections from 'utils/intl/formatterCollections';17import notification from 'utils/notification';18import intl from 'utils/intl';19import FilterForm from './FilterForm';20import List from './List';21/**22 * 服务开通记录明细23 * @extends {Component} - Detail24 * @reactProps {Object} [match={}] - react-router match路由信息25 * @reactProps {Object} [history={}]26 * @reactProps {Object} serveLog - 数据源27 * @reactProps {Boolean} queryDetailLoading - 申请头数据加载是否完成28 * @reactProps {Boolean} serveListLoading - 服务列表数据加载是否完成29 * @reactProps {Function} [dispatch=function(e) {return e;}] - redux dispatch方法30 * @return React.element31 */32const organizationId = getCurrentOrganizationId();33const promptCode = 'spfm.serveLog';34@connect(({ loading = {} }) => ({35 serveListLoading: loading.effects['serveLog/serveQueryList'],36 queryDetailLoading: loading.effects['serveLog/queryDetailLoading'],37}))38@formatterCollections({ code: ['spfm.serveLog'] })39export default class detail extends Component {40 constructor(props) {41 super(props);42 this.state = {43 selectedRows: [],44 rowDataSource: {},45 detailDataSource: [],46 detailPagination: {},47 };48 }49 componentDidMount() {50 this.serveDetail();51 this.serveQueryList();52 }53 /**54 * 服务开通记录明细-申请头55 * @param {object} params - 采购申请头ID56 */57 @Bind()58 serveDetail() {59 const {60 dispatch,61 match: { params = {} },62 } = this.props;63 dispatch({64 type: 'serveLog/serveDetail',65 payload: {66 ...params,67 },68 }).then(res => {69 if (res) {70 this.setState({71 rowDataSource: res,72 });73 }74 });75 }76 /**77 * serveQueryList - 服务开通记录明细-服务列表78 * @param {number} params - 采购申请行ID79 */80 @Bind()81 serveQueryList(page = {}) {82 const {83 dispatch,84 match: { params = {} },85 } = this.props;86 dispatch({87 type: 'serveLog/serveQueryList',88 payload: {89 ...params,90 page,91 },92 }).then(res => {93 if (res) {94 this.setState({95 detailDataSource: res.content,96 detailPagination: createPagination(res),97 });98 }99 });100 }101 /**102 * 删除选中的行103 */104 @Bind()105 delSeletedRows() {106 const rowKey = 'requestLineId';107 const { dispatch } = this.props;108 const { selectedRows } = this.state;109 const lineIds = selectedRows.map(item => item[rowKey]);110 dispatch({111 type: 'serveLog/serveDelete',112 payload: {113 crmTenant: organizationId,114 lineIds,115 },116 }).then(res => {117 if (res) {118 this.setState({119 selectedRows: [],120 });121 this.serveQueryList();122 }123 });124 }125 /**126 * 设置选中行127 * @param {Array} selectedRows128 */129 @Bind()130 rowSelectChange(_, selectedRows) {131 this.setState({132 selectedRows,133 });134 }135 /**136 * 保存137 */138 @Bind()139 save() {140 const { dispatch } = this.props;141 const { form } = this.formdatas.props;142 const { rowDataSource = {}, detailDataSource = [] } = this.state;143 form.validateFieldsAndScroll((err, values) => {144 if (!err) {145 const data = {146 requestHeader: {147 ...rowDataSource,148 ...values,149 },150 requestLineList: detailDataSource,151 client: 'HZERO',152 };153 dispatch({154 type: 'serveLog/serveSave',155 payload: filterNullValueObject(data),156 }).then(res => {157 if (res) {158 notification.success();159 this.serveDetail();160 this.serveQueryList();161 }162 });163 }164 });165 }166 /**167 * 提交168 */169 @Bind()170 submit() {171 const { history, dispatch } = this.props;172 const { form } = this.formdatas.props;173 const { rowDataSource = {}, detailDataSource = [] } = this.state;174 form.validateFieldsAndScroll((err, values) => {175 if (!err) {176 const data = {177 requestHeader: {178 ...rowDataSource,179 ...values,180 },181 requestLineList: detailDataSource,182 client: 'HZERO',183 };184 dispatch({185 type: 'serveLog/serveSubmit',186 payload: filterNullValueObject(data),187 }).then(res => {188 if (res) {189 notification.success();190 history.push('/spfm/amkt-servelog/list');191 }192 });193 }194 });195 }196 render() {197 const { serveListLoading = false, queryDetailLoading = false } = this.props;198 const {199 selectedRows = [],200 rowDataSource = {},201 detailDataSource = [],202 detailPagination = {},203 } = this.state;204 const selectedRowKeys = selectedRows.map(item => item.requestLineId);205 const fiterProps = {206 rowDataSource,207 formOnRef: node => {208 this.formdatas = node;209 },210 };211 const listProps = {212 selectedRowKeys,213 rowDataSource,214 serveListLoading,215 detailDataSource,216 detailPagination,217 fetchList: this.serveQueryList,218 onRowSelectChange: this.rowSelectChange,219 onDelSeletedRows: this.delSeletedRows,220 onHandlePageChange: this.serveQueryList,221 };222 return (223 <React.Fragment>224 <Header225 backPath="/spfm/amkt-servelog/list"226 title={intl.get(`${promptCode}.view.message.title`).d('服务开通记录')}227 >228 {rowDataSource.status === 'NEW' ? (229 <React.Fragment>230 <Button231 onClick={this.submit}232 disabled={detailDataSource.length === 0}233 type="primary"234 icon="check"235 >236 {intl.get('hzero.common.button.submit').d('提交')}237 </Button>238 <Button onClick={this.save} disabled={detailDataSource.length === 0} icon="save">239 {intl.get('hzero.common.button.save').d('保存')}240 </Button>241 </React.Fragment>242 ) : null}243 </Header>244 <Content>245 <Spin246 spinning={queryDetailLoading || serveListLoading}247 wrapperClassName={classnames('ued-detail-wrapper')}248 >249 <Row gutter={48}>250 <Col span={24}>251 <Card252 key="zuul-rate-limit-header"253 bordered={false}254 className={DETAIL_CARD_CLASSNAME}255 title={intl.get(`${promptCode}.view.message.baseInfo`).d('基本信息')}256 >257 <FilterForm {...fiterProps} />258 </Card>259 </Col>260 </Row>261 <Row gutter={48}>262 <Col span={24}>263 <Card264 key="zuul-rate-limit-header"265 bordered={false}266 className={DETAIL_CARD_CLASSNAME}267 title={intl.get(`${promptCode}.view.message.serveManage`).d('服务清单')}268 >269 <List {...listProps} />270 </Card>271 </Col>272 </Row>273 </Spin>274 </Content>275 </React.Fragment>276 );277 }...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

1'use strict';2$.fn.mytoggle = function () {3 var b = arguments;4 return this.each(function (i, el) {5 var a = function () {6 var c = 0;7 return function () {8 b[c++ % b.length].apply(el, arguments);9 };10 }();11 $(el).click(a);12 });13};14$(function () {15 $('.go_to').click(function () {16 var scroll_el = $(this).attr('href');17 if ($(scroll_el).length != 0) {18 $('html, body').animate({ scrollTop: $(scroll_el).offset().top }, 600);19 }20 return false;21 });22 $('.popup_btn').click(function (e) {23 e.preventDefault();24 $('.popupForm').arcticmodal();25 });26 $('.popup_btn_2').click(function (e) {27 e.preventDefault();28 $('.popupForm2').arcticmodal();29 });30 $('.popup_btn_3').click(function (e) {31 e.preventDefault();32 $('.popupForm3').arcticmodal();33 });34 $('.popup_btn_4').click(function (e) {35 e.preventDefault();36 $('.popupForm4').arcticmodal();37 });38 $('.popup_btn_5').click(function (e) {39 e.preventDefault();40 $('.popupForm5').arcticmodal();41 });42 $('.popup_btn_6').click(function (e) {43 e.preventDefault();44 $('.popupForm6').arcticmodal();45 });46 $('.popup_btn_7').click(function (e) {47 e.preventDefault();48 $('.popupForm7').arcticmodal();49 });50 $('.popup_btn_8').click(function (e) {51 e.preventDefault();52 $('.popupForm8').arcticmodal();53 });54 $('.sendFeedbackForm').click(function (e) {55 e.preventDefault();56 var status = true;57 var name = $(this).parent().find('.name').val();58 var phone = $(this).parent().find('.phone').val();59 var serve = $(this).parent().find('._serve').val();60 var serve_1 = $(this).parent().find('#serve_1').prop("checked");61 var serve_2 = $(this).parent().find('#serve_2').prop("checked");62 var serve_3 = $(this).parent().find('#serve_3').prop("checked");63 var serve_4 = $(this).parent().find('#serve_4').prop("checked");64 var serve_5 = $(this).parent().find('#serve_5').prop("checked");65 var serve_6 = $(this).parent().find('#serve_6').prop("checked");66 var serve_7 = $(this).parent().find('#serve_7').prop("checked");67 var serve_8 = $(this).parent().find('#serve_8').prop("checked");68 var serve_9 = $(this).parent().find('#serve_9').prop("checked");69 var serve_10 = $(this).parent().find('#serve_10').prop("checked");70 var serve_11 = $(this).parent().find('#serve_11').prop("checked");71 var serve_12 = $(this).parent().find('#serve_12').prop("checked");72 var serve_13 = $(this).parent().find('#serve_13').prop("checked");73 var serve_14 = $(this).parent().find('#serve_14').prop("checked");74 var serve_15 = $(this).parent().find('#serve_15').prop("checked");75 var serve_16 = $(this).parent().find('#serve_16').prop("checked");76 var serve_17 = $(this).parent().find('#serve_17').prop("checked");77 var serve_18 = $(this).parent().find('#serve_18').prop("checked");78 var serve_19 = $(this).parent().find('#serve_19').prop("checked");79 var serve_20 = $(this).parent().find('#serve_20').prop("checked");80 var serve_21 = $(this).parent().find('#serve_21').prop("checked");81 var serve_22 = $(this).parent().find('#serve_22').prop("checked");82 var serve_23 = $(this).parent().find('#serve_23').prop("checked");83 var serve_24 = $(this).parent().find('#serve_24').prop("checked");84 if (serve_1) {85 serve_1 = $('#serve_1').parent().find('label').html();86 } else { serve_1 = ""; }87 if (serve_2) {88 serve_2 = $('#serve_2').parent().find('label').html();89 } else { serve_2 = ""; }90 if (serve_3) {91 serve_3 = $('#serve_3').parent().find('label').html();92 } else { serve_3 = ""; }93 if (serve_4) {94 serve_4 = $('#serve_4').parent().find('label').html();95 } else { serve_4 = ""; }96 if (serve_5) {97 serve_5 = $('#serve_5').parent().find('label').html();98 } else { serve_5 = ""; }99 if (serve_6) {100 serve_6 = $('#serve_6').parent().find('label').html();101 } else { serve_6 = ""; }102 if (serve_7) {103 serve_7 = $('#serve_7').parent().find('label').html();104 } else { serve_7 = ""; }105 if (serve_8) {106 serve_8 = $('#serve_8').parent().find('label').html();107 } else { serve_8 = ""; }108 if (serve_9) {109 serve_9 = $('#serve_9').parent().find('label').html();110 } else { serve_9 = ""; }111 if (serve_10) {112 serve_10 = $('#serve_10').parent().find('label').html();113 } else { serve_10 = ""; }114 if (serve_11) {115 serve_11 = $('#serve_11').parent().find('label').html();116 } else { serve_11 = ""; }117 if (serve_12) {118 serve_12 = $('#serve_12').parent().find('label').html();119 } else { serve_12 = ""; }120 if (serve_13) {121 serve_13 = $('#serve_13').parent().find('label').html();122 } else { serve_13 = ""; }123 if (serve_14) {124 serve_14 = $('#serve_14').parent().find('label').html();125 } else { serve_14 = ""; }126 if (serve_15) {127 serve_15 = $('#serve_15').parent().find('label').html();128 } else { serve_15 = ""; }129 if (serve_16) {130 serve_16 = $('#serve_16').parent().find('label').html();131 } else { serve_16 = ""; }132 if (serve_17) {133 serve_17 = $('#serve_17').parent().find('label').html();134 } else { serve_17 = ""; }135 if (serve_18) {136 serve_18 = $('#serve_18').parent().find('label').html();137 } else { serve_18 = ""; }138 if (serve_19) {139 serve_19 = $('#serve_19').parent().find('label').html();140 } else { serve_19 = ""; }141 if (serve_20) {142 serve_20 = $('#serve_20').parent().find('label').html();143 } else { serve_20 = ""; }144 if (serve_21) {145 serve_21 = $('#serve_21').parent().find('label').html();146 } else { serve_21 = ""; }147 if (serve_22) {148 serve_22 = $('#serve_22').parent().find('label').html();149 } else { serve_22 = ""; }150 if (serve_23) {151 serve_23 = $('#serve_23').parent().find('label').html();152 } else { serve_23 = ""; }153 if (serve_24) {154 serve_24 = $('#serve_24').parent().find('label').html();155 } else { serve_24 = ""; }156 if (name == '') {157 $(this).parent().find('.name').css({ border: "1px solid red" });158 status = false;159 } else {160 $(this).parent().find('.name').css({ border: "1px solid #aaa" });161 }162 if (phone == '') {163 $(this).parent().find('.phone').css({ border: "1px solid red" });164 status = false;165 } else {166 $(this).parent().find('.phone').css({ border: "1px solid #aaa" });167 }168 if (status) {169 $.ajax({170 url: "/mail.php",171 type: "POST",172 data: {173 "name": name, "phone": phone, "serve_1": serve_1, "serve_2": serve_2,174 "serve_3": serve_3, "serve_4": serve_4,175 "serve_5": serve_5, "serve_6": serve_6,176 "serve_7": serve_7, "serve_8": serve_8,177 "serve_9": serve_9, "serve_10": serve_10,178 "serve_11": serve_11, "serve_12": serve_12,179 "serve_13": serve_13, "serve_14": serve_14,180 "serve_15": serve_15, "serve_16": serve_16,181 "serve_17": serve_17, "serve_18": serve_18,182 "serve_19": serve_19, "serve_20": serve_20,183 "serve_21": serve_21, "serve_22": serve_22,184 "serve_23": serve_23, "serve_24": serve_24,185 "serve": serve186 },187 success: function() {188 $('.feedbackForm')[0].reset();189 $('.feedbackForm2')[0].reset();190 $.arcticmodal('close');191 $('.successModal').arcticmodal();192 }193 });194 }195 });196 var slider = $('.slider');197 slider.owlCarousel({198 pagination: false,199 items: 1,200 loop: true,201 autoplay: true,202 autoplayTimeout: 10000,203 autoplaySpeed: 1000204 });205 $('.next-slide').click(function () {206 slider.trigger('next.owl.carousel');207 });208 $('.prev-slide').click(function () {209 slider.trigger('prev.owl.carousel');210 });211 $('.photo-grid').find('.item').click(function () {212 var src = $(this).find('.img').attr('data-slide');213 src--;214 $('.slider').trigger('to.owl.carousel', [src, 0]);215 $('.fullImgModal').arcticmodal();216 });217 $('.close').click(function () {218 $.arcticmodal('close');219 });220 $('.questions').find('.title-item').mytoggle(function () {221 $(this).parent().find('.hidden').slideDown();222 }, function () {223 $(this).parent().find('.hidden').slideUp();224 });...

Full Screen

Full Screen

json-serve.js

Source:json-serve.js Github

copy

Full Screen

1if (!String.prototype.format) {2 String.prototype.format = function() {3 var args = arguments;4 return this.replace(/{(\d+)}/g, function(match, number) {5 return typeof args[number] != 'undefined'6 ? args[number]7 : match8 ;9 });10 };11}12// json_serve namespace.13(function( json_serve, $ ) {14 json_serve.total_results = 0;15 json_serve.current_page = 0;16 json_serve.results = null;17 json_serve.form_selector = "form";18 json_serve.submit_selector = "#submit";19 json_serve.filter_selector = "#filter";20 json_serve.query_selector = "#query";21 json_serve.results_selector = "#results";22 json_serve.modal_selector = "#modal";23 json_serve.init = function () {24 json_serve.bind_events();25 json_serve.init_modal();26 json_serve.search();27 };28 json_serve.bind_events = function () {29 $(json_serve.submit_selector).click(json_serve.change_filter);30 $(json_serve.form_selector).submit(json_serve.form_submit);31 };32 json_serve.bind_events_paging = function () {33 $('#first').click(json_serve.first_page);34 $('#previous').click(json_serve.previous_page);35 $('#next').click(json_serve.next_page);36 $('#last').click(json_serve.last_page);37 $('.view').click(json_serve.view_result);38 };39 json_serve.init_modal = function () {40 $(json_serve.modal_selector).modal({41 keyboard: true,42 show: false43 });44 };45 json_serve.total_pages = function () {46 return parseInt(json_serve.total_results / 20);47 };48 json_serve.first_page = function () {49 json_serve.current_page = 0;50 json_serve.search();51 };52 json_serve.previous_page = function () {53 if (json_serve.current_page > 0) {54 json_serve.current_page--;55 }56 json_serve.search();57 };58 json_serve.next_page = function () {59 if (json_serve.current_page < json_serve.total_pages()) {60 json_serve.current_page++;61 }62 json_serve.search();63 };64 json_serve.last_page = function () {65 json_serve.current_page = json_serve.total_pages();66 json_serve.search();67 };68 json_serve.form_submit = function (e) {69 e.preventDefault();70 json_serve.submit();71 };72 json_serve.submit = function () {73 json_serve.current_page = 0;74 json_serve.search();75 };76 json_serve.search = function () {77 $(json_serve.results_selector).html("loading...");78 var skip = json_serve.current_page * 20;79 var filter = $(json_serve.filter_selector).val();80 var query = $(json_serve.query_selector).val();81 var url = "/search?skip={0}&filter={1}&query={2}".format(82 encodeURIComponent(skip),83 encodeURIComponent(filter),84 encodeURIComponent(query));85 var data = $.getJSON(86 url,87 json_serve.process_results).error(88 json_serve.search_error);89 };90 json_serve.search_error = function () {91 alert ("Error fetching data");92 };93 json_serve.process_results = function (data) {94 json_serve.total_results = parseInt(data[0].n);95 // Validate we have results to process.96 if (json_serve.total_results === 0) {97 $(json_serve.results_selector).html("No data found");98 return;99 }100 json_serve.results = data[1];101 var html = json_serve.build_pagination();102 html += json_serve.build_results();103 // Insert html into dom104 $(json_serve.results_selector).html(html);105 // Bind events106 json_serve.bind_events_paging();107 };108 json_serve.build_pagination = function () {109 var data = {110 page: json_serve.current_page + 1,111 total_pages: json_serve.total_pages() + 1,112 total_results: json_serve.total_results113 };114 var template = $('#paging_template').html();115 var html = Mustache.to_html(template, data);116 return html;117 };118 json_serve.build_results = function () {119 var rows = [];120 var row = {columns: []};121 $.each( json_serve.results, function( key, val ) {122 if ( key > 0 && key % 4 === 0 ) {123 rows.push( row );124 row = {columns: []};125 }126 row.columns.push( val );127 });128 if ( row.columns.length > 0 ) {129 rows.push( row );130 }131 // Build the results container html132 var data = {133 rows: rows134 };135 template = $('#results_template').html();136 var html = Mustache.to_html(template, data);137 return html;138 };139 json_serve.view_result = function () {140 var div = $(this).parent().parent().parent();141 $.each(json_serve.results, function (key, val) {142 if (val.id === div.attr('id')) {143 json_serve.build_modal(val);144 }145 });146 };147 json_serve.build_modal = function (val) {148 var title = val.title;149 $(json_serve.modal_selector + ' .modal-title').html(title);150 var rows = "";151 for (key in val) {152 if (val[key] === "") {153 continue;154 }155 var data = {156 key: key,157 raw: val[key],158 value: json_serve.fetch_value159 };160 template = $('#modal_row_template').html();161 rows += Mustache.to_html(template, data);162 }163 var data = {164 rows: rows165 };166 template = $('#modal_template').html();167 html = Mustache.to_html(template, data);168 $(json_serve.modal_selector + ' .modal-body').html(html);169 $(json_serve.modal_selector).modal('show');170 };171 json_serve.fetch_value = function () {172 var fetch = function (value) {173 if (json_serve.is_object(value)) {174 var html = "";175 for (prop in value) {176 if (json_serve.is_object(value[prop])) {177 html += fetch(value[prop]);178 } else {179 html += prop + ": " + json_serve.make_url(value[prop]) + ", ";180 }181 }182 return html.substring(0, html.length - 2) + " ";183 } else {184 return json_serve.make_url(value);185 }186 };187 return fetch(this.raw);188 };189 json_serve.is_object = function (value) {190 if (value !== null && typeof value === 'object') {191 return true;192 } else {193 return false;194 }195 };196 json_serve.make_url = function (str) {197 var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol198 '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name199 '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address200 '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path201 '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string202 '(\\#[-a-z\\d_]*)?$','i'); // fragment locator203 if(!pattern.test(str)) {204 return str;205 } else {206 return "<a href='{0}' target='_blank'>{1}</a>".format(str, "Link");207 }208 };...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

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