text
stringlengths
7
3.69M
// write your code below! console.log("Hello World!") console.log("This lesson isnt working")
import React from 'react'; import { render } from 'react-dom'; import { Provider } from 'react-redux'; import { store } from './_helpers/store.js'; //import { store } from './store.js'; import { App } from './App.jsx'; import MomentUtils from "material-ui-pickers/utils/moment-utils"; import moment from "moment/moment"; import 'moment/locale/zh-cn'; import MuiPickersUtilsProvider from 'material-ui-pickers/utils/MuiPickersUtilsProvider'; import ReactDOM from "react-dom"; //import {Hello} from './Hello.jsx'; // setup fake backend //import { configureFakeBackend } from './_helpers'; //configureFakeBackend(); ReactDOM.render( <MuiPickersUtilsProvider utils={MomentUtils} moment={moment} > <Provider store={store}> <App /> </Provider> </MuiPickersUtilsProvider>, document.getElementById('root') ); // import RaisedButtons from 'components/RaisedButton/RaisedButton.jsx'; // render( // <RaisedButtons/>, // document.getElementById('root') // );
import React from 'react'; import AutoComplete from 'material-ui/AutoComplete'; const dataSourceConfig = { text: 'textKey', value: 'valueKey', product:'product' }; export default class AutoCompleteExampleSimple extends React.Component { constructor(props) { super(props); this.handleSelect= this.handleSelect.bind(this); this.state = { dataSource: [], }; } get= function(url) { // Return a new promise. return new Promise(function(resolve, reject) { // Do the usual XHR stuff var req = new XMLHttpRequest(); req.open('GET', url); req.onload = function() { // This is called even on 404 etc // so check the status if (req.status == 200) { // Resolve the promise with the response text resolve(JSON.parse(req.response)); } else { // Otherwise reject with the status text // which will hopefully be a meaningful error reject(Error(req.statusText)); } }; // Handle network errors req.onerror = function() { reject(Error("Network Error")); }; // Make the request req.send(); }); } Typeahead(a,passstate) { debugger; var that = this; var datalist =[]; var search = a; passstate.get('http://localhost:8000/autocomplete/'+search).then(function(response) { console.log("Success!", response); for(var i=0;i<response.length; i++) { var input = {}; input.textKey =response[i].name; input.valueKey = response[i].value; input.product = response[i]; datalist.push(input); } passstate.setState({dataSource:datalist}); }, function(error) { console.error("Failed!", error); }); } handleUpdateInput = (value) => { this.Typeahead(value,this); this.setState({ searchText: value }) /* this.setState({ dataSource: [ value, value + value, value + value + value, ], }); */ }; handleSelect (t) { this.setState( { searchText: t }) } render() { var floatinglabel =this.props.floatinglabel != ""?this.props.floatinglabel :"Enter place name"; return ( <div> <AutoComplete floatingLabelText={floatinglabel} floatingLabelFixed={true} hintText="Type anything" dataSource={this.state.dataSource} dataSourceConfig={dataSourceConfig} onUpdateInput={this.handleUpdateInput} searchText={this.state.searchText} onNewRequest={this.handleSelect.bind(this)}/> </div> ); } }
if(!Array.prototype.map) { Array.prototype.map = function(callback, thisArg) { if (this == null) { throw new TypeError('this is null or not defined'); } if(!Array.isArray(this)) { throw new TypeError(`${this} is not array`); } if (typeof callback !== 'function') { throw new TypeError(`${callback} is not a function`); } const arr2 =[]; for (let i = 0; i < this.length; i++) { arr2.push(callback(this[i])); } return arr2; } } let arr = [1,2,3,4]; let arr2 = arr.map( function(a) { return a * a } ) console.log(arr2);
import React from 'react'; import styled from 'styled-components'; import {FaQuoteLeft} from 'react-icons/fa'; import {FaQuoteRight} from 'react-icons/fa'; import AboutPage from '../../components/AboutUs/About'; import maria from '../../assets/aboutUsimg/maria.png'; import nick from '../../assets/aboutUsimg/nick.png'; import andrea from '../../assets/aboutUsimg/andrea.png'; import aboutpage from '../../assets/bgimg/aboutpage.png' const BgContainer = styled.div ` background: url(${aboutpage}); background-repeat: no-repeat; height: 100vh; background-size: 80vw 100vh; ` const Container = styled.div ` @media (max-width: 770px) { @media (max-width: 377px) { } ` const Header = styled.h1 ` width: 23vw; margin-top: 3vw; padding: 1.8vw; margin-left: 40vw; text-align: center; color: whitesmoke; font-family: 'Montserrat', Sans serif; font-size: 3.5rem; @media (max-width: 770px) { width: 30vw; height: 0; margin-left: 35.5vw; font-size: 3rem; @media (max-width: 377px) { width: 35vw; height: 0; padding: 0; margin-top: 100px; font-size:2rem; } ` const Box = styled.div ` display: flex; margin-left: -12vw; @media (max-width: 770px) { margin-left: -9vw; margin-top: 20vw; @media (max-width: 377px) { } ` const Paragraph = styled.p ` width: 60vw; height: 38vh; margin-left: 20vw; margin-top: 20vw; border: 1px solid black; background-color: grey; border-radius: 5px 20px 5px; padding: 3vw; font-family: 'Montserrat', Sans serif; font-size: 1rem; font-weight: 700; color: whitesmoke; @media(max-width: 770px) { margin-left: 18vw; margin-top: 50vw; @media(max-width: 377px) { } ` function AboutUsUi () { return( <BgContainer> <Container> <Header>About Us.</Header> <Box> <div> <AboutPage pic= {maria} summ= "-'I always loved nature and green. Along with my passion for coding, we were able to create this platform with everyone!' " /> </div> <div> <AboutPage pic= {nick} summ= "-'I always loved nature and green. Along with my passion for coding, we were able to create this platform with everyone!' " /> </div> <div> <AboutPage pic= {andrea} summ= "-'I always loved nature and green. Along with my passion for coding, we were able to create this platform with everyone!' " /> </div> </Box> <Paragraph> <FaQuoteLeft/> Welcome to Plantpedia, your number one source for plant caring and guidelines. We 're dedicated to providing you the very best of tips and advice, with an emphasis on plant caring. As students in Digital Career Institute , we had this awesome idea to make a platform for other plant lovers, like ourselves and at the same time enjoy coding. We hope you enjoy our products as much as we enjoy offering them to you.If you have any questions or comments, please don 't hesitate to contact us. <FaQuoteRight/> <br/> <br/> Sincerely, <br/><br/> Plantpedia Team </Paragraph> </Container> </BgContainer> ); } export default AboutUsUi;
var card = { vehicle: { name: 'vehicle', label: '车辆', table: 'dat_vehicle_dync', // 动态 push 数据 keyIndex: 0, // table中key值在 field 中的位置 fields: { names: ['card_id', 'card_type_id', 'number', 'x', 'y', 'rec_time', 'down_time', 'up_time', 'enter_area_time', 'map_id', 'area_id', 'dept_id', 'work_time', 'state'], // 字段 types: ['NUMBER', 'NUMBER', 'STRING', 'NUMBER', 'NUMBER', 'DATETIME', 'DATETIME', 'DATETIME', 'DATETIME', 'NUMBER', 'NUMBER', 'NUMBER', 'STRING', 'NUMBER'], // 字段类型 labels: ['卡号', '卡类型', '车牌号', 'X坐标', 'Y坐标', '接收时间', '下井时间', '升井时间', '进入区域时间', '地图', '区域', '部门', '工作时长', '状态'] } }, staff: { name: 'staff', label: '人员', table: 'dat_staff_dync', // 动态 push 数据 keyIndex: 0, // table中key值在 field 中的位置 fields: { names: ['card_id', 'card_type_id', 'number', 'x', 'y', 'rec_time', 'down_time', 'up_time', 'enter_area_time', 'map_id', 'area_id', 'dept_id', 'work_time', 'state'], // 字段 types: ['NUMBER', 'NUMBER', 'STRING', 'NUMBER', 'NUMBER', 'DATETIME', 'DATETIME', 'DATETIME', 'DATETIME', 'NUMBER', 'NUMBER', 'NUMBER', 'STRING', 'NUMBER'], // 字段类型 labels: ['卡号', '卡类型', '身份证', 'X坐标', 'Y坐标', '接收时间', '下井时间', '升井时间', '进入区域时间', '地图', '区域', '部门', '工作时长', '状态'] } }, adhoc: { name: 'adhoc', label: '自组网', table: 'dat_adhoc_dync', // 动态 push 数据 keyIndex: 0, // table中key值在 field 中的位置 fields: { names: ['card_id', 'card_type_id', 'number', 'x', 'y', 'rec_time', 'down_time', 'up_time', 'enter_area_time', 'map_id', 'area_id', 'dept_id', 'work_time', 'state'], // 字段 types: ['NUMBER', 'NUMBER', 'STRING', 'NUMBER', 'NUMBER', 'DATETIME', 'DATETIME', 'DATETIME', 'DATETIME', 'NUMBER', 'NUMBER', 'NUMBER', 'STRING', 'NUMBER'], // 字段类型 labels: ['卡号', '卡类型', '设备号', 'X坐标', 'Y坐标', '接收时间', '下井时间', '升井时间', '进入区域时间', '地图', '区域', '部门', '工作时长', '状态'] } } } module.exports = card
import styled from 'styled-components' export const Field = styled.div` margin-bottom: ${(props) => props.theme.spacings.small}; ${(props) => !props.checkbox ? `* { width: 100%; }` : ''} `
export default { '.root': { boxSizing: 'border-box' } };
var _pdt_view_time_data = {}; /*----------------左侧-----------------------------*/ var StyAttr = function() { } var StyEvent = function(id) { StyDefEvent(id); } var StyDefAttr = function(id, data) { var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); if ($module_div.attr("data-module-style") != data.style) { $module_div.attr("data-module-style", data.style) $module_div.empty(); var module_style_html = $(_module_style_map[data.style].styHtml).prop("innerHTML"); $module_div.append(module_style_html); } $.each(data, function(n, value) { var $html = $('div[data-module-id=' + id + ']'); if ($html.find('[data-module-str=' + n + ']').length != 0) { $html.find('[data-module-str=' + n + ']').text(value); } if ($html.find('[data-module-img=' + n + ']').length != 0) { $html.find('[data-module-img=' + n + ']').attr("src", value); } if ($html.find('[data-module-view=' + n + ']').length != 0) { if (value) { $html.find('[data-module-view=' + n + ']').show(); } else { $html.find('[data-module-view=' + n + ']').hide(); } } }); } var ScrollBottom = function() { $('.tvm-shop-module-panel').parent().scrollTop($('.tvm-shop-module-panel')[0].scrollHeight); } var StyDefEvent = function(id) { var $html = $('div[data-module-id=' + id + ']'); // 选中模块 $html.unbind("click"); $html.click(function() { $("#tvm-shop-phone-panel div.tvm-shop-phone:first").find("div.tvm-shop-new-module-place") .animate({ height : "0px" }, function() { $(this).remove(); }); $html.find('.tvm-shop-module-panel').find("div.tvm-shop-newModuleBorder").removeClass( "tvm-shop-newModuleBorder"); $html.removeClass("tvm-shop-newModuleBorder") var module_id = $(this).attr("data-module-id"); var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var $set_div = $("div.tvm-shop-setting"); var set_module_first_flg = $set_div.find("div:first").hasClass("tvm-shop-setModule"); $set_div.prepend($set_div.find("div.tvm-shop-setModule:first")); $("#tvm-shop-phone-panel div.tvm-shop-phone:first").removeAttr("data-add"); // 点击最后一个模块,将滚动条至最底部 if ($html.index() == $(this).closest(".tvm-shop-module-panel").children().length - 1) { ScrollBottom(); } $("#saveBtn").show(); if (module_id == $set_div.find("div.tvm-shop-setModule").attr("data-set-module-id") && set_module_first_flg) { return true; } else { var data_temp = GetModuleDateById(page_id, module_id); if (data_temp == null) { return true;// TODO } _module_style_map[data_temp.type].setFillAttr(data_temp); _module_style_map[data_temp.type].setBindEvent(module_id); } $html.parent().find(".tvm-shop-module-border").remove(); $html.find(".tvm-shop-module-mask").after('<div class="tvm-shop-module-border"></div>'); }); // 删除模块 $html.find("div.tvm-shop-module-mask-close").unbind("click"); $html.find("div.tvm-shop-module-mask-close").click(function(event) { event.stopPropagation(); var module_id = $(this).parent().parent().attr("data-module-id"); $("#tvm-shop-delete-tips").attr("delete-tip-type",1); $("#tvm-shop-delete-tips").attr("delete-tip-id",module_id); $("#tvm-shop-delete-tips").show(); }); // 添加跳转页面链接TODO $html.find("div.tvm-shop-module-mask-addLink").unbind("click"); $html.find("div.tvm-shop-module-mask-addLink").click(function() { }); // 复制模块 $html.find("div.tvm-shop-module-mask-copy").unbind("click"); $html.find("div.tvm-shop-module-mask-copy").click(function(event) { event.stopPropagation(); var module_id = $(this).parent().parent().attr("data-module-id"); var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var copy_data = {}; var module_data = GetModuleDateById(page_id, module_id); jQuery.extend(true, copy_data, module_data); var copy_data_id = CreateGUID(); copy_data.id = copy_data_id; var page_data = GetPageDateById(page_id); page_data.module.push(copy_data); // 删除商品 图片 优惠券 if (copy_data.type == "pdt_view") { $.each(copy_data.data.pdt, function(n, value) { value.pdt_data = []; }); } if (copy_data.type == "pdt_mod") { copy_data.data.pdt = []; } if (copy_data.type == "goods_overflowx_mod") { copy_data.data.pdt = []; } if (copy_data.type == "banner_mod") { copy_data.data.banners = []; } if (copy_data.type == "category_mod") { copy_data.data.banners = []; } if (copy_data.type == "fenlan_mod") { copy_data.data.fenlan = []; } if (copy_data.type == "coupon_mod") { copy_data.data.coupon = []; } if (copy_data.type == "findshop_mod") { $.each(copy_data.data.findshop, function(n, value) { value.shop = []; }); } if (copy_data.type == "seckill_mod") { copy_data.data.pdt = []; } AddModel(copy_data, page_id, -1); var num = GetModuleNum(page_id, module_id); MoveModule(copy_data_id, num + 1); }); $html.find("div.tvm-shop-module-mask-upInsert").unbind("click"); $html.find("div.tvm-shop-module-mask-upInsert").click( function(event) { event.stopPropagation(); var $newModule = $('<div class="tvm-shop-new-module-place">' + '<div>' + '<div class="new-module-icon"></div>' + '<div>新模块将插入此处</div>' + '</div>' + '</div>'); $("#tvm-shop-phone-panel div.tvm-shop-phone:first").find( "div.tvm-shop-new-module-place").remove(); $(this).parent().parent().before($newModule.animate({ height : "66px" })); // $(this).parent().parent().before($newModule); $(".tvm-shop-phone-addbtn").click(); }); // 上移模块 $html.find("div.tvm-shop-module-mask-upBtn").unbind("click"); $html.find("div.tvm-shop-module-mask-upBtn").click(function(event) { event.stopPropagation(); var module_id = $(this).parent().parent().attr("data-module-id"); var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var num = GetModuleNum(page_id, module_id); MoveModule(module_id, num - 1); }); // 下移模块 $html.find("div.tvm-shop-module-mask-downBtn").unbind("click"); $html.find("div.tvm-shop-module-mask-downBtn").click(function(event) { event.stopPropagation(); var module_id = $(this).parent().parent().attr("data-module-id"); var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var num = GetModuleNum(page_id, module_id); MoveModule(module_id, num + 1); }); // 下边距控制 var page_id_temp = $html.parents("div.tvm-shop-phone").attr("data-page-id"); SetModuleBorder($html, page_id_temp, id); $html.find("div.tvm-shop-module-mask-setDownMargin").unbind("click"); $html.find("div.tvm-shop-module-mask-setDownMargin").click( function(event) { event.stopPropagation(); var module_id = $(this).parent().parent().attr("data-module-id"); var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr( "data-page-id"); var module_data = GetModuleDateById(page_id, module_id); module_data.data.bottom_boder_flg = module_data.data.bottom_boder_flg ? false : true; var page_data = GetPageDateById(page_id); page_data.update_time = GetTimestamp(); SetModuleBorder($html, page_id, module_id); // 最后一个模块 滚动条 到底部 var $page_html = $("#tvm-shop-phone-panel").find( 'div[data-page-id=' + page_id + ']'); if ($html.next().length == 0) { setTimeout(function() { $page_html.find('.tvm-shop-module > div > div').scrollTop( $page_html.find('.tvm-shop-module > div > div')[0].scrollHeight); }); } }); } var StyShopSignOneEvent = function(id) { StyDefEvent(id); } var StyPdtViewEvent = function(id) { StyDefEvent(id); } var StyPdtModEvent = function(id) { StyDefEvent(id); } var StyGoodOverFlowEvent = function(id) { StyDefEvent(id); } var StyBannerModEvent = function(id) { StyDefEvent(id); } var StyCateModEvent = function(id) { StyDefEvent(id); } var StyCouponEvent = function(id) { StyDefEvent(id); } var StyFenLanEvent = function(id) { StyDefEvent(id); } var StyFindShopEvent = function(id) { StyDefEvent(id); } var StySeckillEvent = function(id) { StyDefEvent(id); } var StyBrandOneEvent = function(id) { StyDefEvent(id); } var StyBrandTwoEvent = function(id) { StyDefEvent(id); } var StyActivityOneEvent = function(id) { StyDefEvent(id); } var StyActivityTwoEvent = function(id) { StyDefEvent(id); } var StyActivityThreeEvent = function(id) { StyDefEvent(id); } // 商品分类展示 var StyPdtViewOneAttr = function(id, data) { var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); if ($module_div.attr("data-module-style") != data.style) { $module_div.attr("data-module-style", data.style) $module_div.empty(); var module_style_html = $(_module_style_map[data.style].styHtml).prop("innerHTML"); $module_div.append(module_style_html); } var $cate_name_div = $module_div.find('[data-module-pdt="pdt_cate_name"]'); var $first_pdt_div = $module_div.find('[data-module-pdt="pdt_data"]'); $cate_name_div.empty(); $first_pdt_div.empty(); if (data.shop_cart_flg) { $module_div.attr("data-cart-show", 1); } else { $module_div.attr("data-cart-show", 0); } $.each(data.pdt, function(n, value) { var pdt_data_temp = GetPdtFromDict(value.pdt_data); var $cate_name_html = $('<div class="condition_5"></div>'); $cate_name_html.text(value.pdt_cate_name); if (n == 0) { $cate_name_html.addClass("on"); var view = Number(value.pdt_view); if (view < value.pdt_data.length) { $module_div.find(".show-more-goods").show(); } else { $module_div.find(".show-more-goods").hide(); } $.each(pdt_data_temp, function(i, obj) { if (i < view) { var $pdt_html = $('<div class="goods-items">' + '<div class="goods-img">' + '<img src="" />' + '<div class="shelves-flag"></div>' + '</div>' + '<div class="goods-name"><div></div></div>' + '<div class="update-goods-info">' + '<div class="update-goods-price"></div>' + '</div>' + '</div>'); $pdt_html.find(".shelves-flag").attr("flag", "hidden"); if (obj.expired) { $pdt_html.find(".shelves-flag").attr("flag", "over"); } if (obj.off) { $pdt_html.find(".shelves-flag").attr("flag", "off"); } $pdt_html.find("img").attr("src", obj.product_image); $pdt_html.find(".goods-name > div").text(obj.product_name); var $balance_html = $('<div class="update-goods-available-balance"></div>'); var $old_price_html = $('<del class="update-goods-oriprice"></del>'); var $shop_name_html = $('<div class="update-goods-relative-shop-name"></div>'); if (obj.max_balance > 0) { $balance_html.attr("data-type", "2"); $balance_html.text(PaddingZero(obj.max_balance)); $pdt_html.find(".update-goods-info").append($balance_html); } else if (obj.back_cash > 0) { $balance_html.attr("data-type", "1"); $balance_html.text(PaddingZero(obj.back_cash)); $pdt_html.find(".update-goods-info").append($balance_html); } if (typeof (obj.prices_id) != "undefined" && obj.prices_id != null && obj.prices && obj.prices_id in obj.prices) { var data_temp = GetRuleCompute(obj.unit_price, obj.prices[obj.prices_id]); $pdt_html.find(".update-goods-price").text(PaddingZero(data_temp.price)); $old_price_html.text(PaddingZero(obj.unit_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else if (obj.direct_price) { $pdt_html.find(".update-goods-price").text(PaddingZero(obj.unit_price)); $old_price_html.text(PaddingZero(obj.direct_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else { $pdt_html.find(".update-goods-price").text(PaddingZero(obj.unit_price)); } if (obj.shop_alias) { $shop_name_html.text(obj.shop_alias); $pdt_html.find(".update-goods-info").append($shop_name_html); } if (!data.org_price_flg) { $pdt_html.find(".update-goods-oriprice").remove(); } $first_pdt_div.append($pdt_html); } }); } $cate_name_div.append($cate_name_html); }); } var StyPdtViewTwoAttr = function(id, data) { var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); if ($module_div.attr("data-module-style") != data.style) { $module_div.attr("data-module-style", data.style) $module_div.empty(); var module_style_html = $(_module_style_map[data.style].styHtml).prop("innerHTML"); $module_div.append(module_style_html); } var $cate_name_div = $module_div.find('[data-module-pdt="pdt_cate_name"]'); var $first_pdt_div = $module_div.find('[data-module-pdt="pdt_data"]'); $cate_name_div.empty(); $first_pdt_div.empty(); if (data.shop_cart_flg) { $module_div.attr("data-cart-show", 1); } else { $module_div.attr("data-cart-show", 0); } $ .each( data.pdt, function(n, value) { var pdt_data_temp = GetPdtFromDict(value.pdt_data); var $cate_name_html = $('<div class="condition_5"></div>'); $cate_name_html.text(value.pdt_cate_name); if (n == 0) { $cate_name_html.addClass("on"); var view = Number(value.pdt_view); if (view < value.pdt_data.length) { $module_div.find(".show-more-goods").show(); } else { $module_div.find(".show-more-goods").hide(); } $ .each( pdt_data_temp, function(i, obj) { if (i < view) { var $pdt_html = $('<div class="goods-notwo-items">' + '<div class="goods-notwo-image"><img src=""/><div class="shelves-flag"></div></div>' + '<div class="goods-notwo-info">' + '<div class="goods-notwo-name"></div>' + '<div class="update-goods-info">' + '<div class="update-goods-price"></div>' + '</div>' + '</div>' + '</div>'); $pdt_html.find(".shelves-flag").attr("flag", "hidden"); if (obj.expired) { $pdt_html.find(".shelves-flag").attr( "flag", "over"); } if (obj.off) { $pdt_html.find(".shelves-flag").attr( "flag", "off"); } $pdt_html.find("img").attr("src", obj.product_image); $pdt_html.find(".goods-notwo-name").text( obj.product_name); var $balance_html = $('<div class="update-goods-available-balance"></div>'); var $old_price_html = $('<del class="update-goods-oriprice"></del>'); var $shop_name_html = $('<div class="update-goods-relative-shop-name"></div>'); if (obj.max_balance > 0) { $balance_html.attr("data-type", "2"); $balance_html .text(PaddingZero(obj.max_balance)); $pdt_html.find(".update-goods-info") .append($balance_html); } else if (obj.back_cash > 0) { $balance_html.attr("data-type", "1"); $balance_html .text(PaddingZero(obj.back_cash)); $pdt_html.find(".update-goods-info") .append($balance_html); } if (typeof (obj.prices_id) != "undefined" && obj.prices_id != null && obj.prices && obj.prices_id in obj.prices) { var data_temp = GetRuleCompute( obj.unit_price, obj.prices[obj.prices_id]); $pdt_html.find(".update-goods-price").text( PaddingZero(data_temp.price)); $old_price_html .text(PaddingZero(obj.unit_price)); $pdt_html.find(".update-goods-info") .append($old_price_html); } else if (obj.direct_price) { $pdt_html.find(".update-goods-price").text( PaddingZero(obj.unit_price)); $old_price_html .text(PaddingZero(obj.direct_price)); $pdt_html.find(".update-goods-info") .append($old_price_html); } else { $pdt_html.find(".update-goods-price").text( PaddingZero(obj.unit_price)); } if (obj.shop_alias) { $shop_name_html.text(obj.shop_alias); $pdt_html.find(".update-goods-info") .append($shop_name_html); } if (!data.org_price_flg) { $pdt_html.find(".update-goods-oriprice") .remove(); } $first_pdt_div.append($pdt_html); } }); } $cate_name_div.append($cate_name_html); }); } var StyPdtViewThreeAttr = function(id, data) { var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); if ($module_div.attr("data-module-style") != data.style) { $module_div.attr("data-module-style", data.style) $module_div.empty(); var module_style_html = $(_module_style_map[data.style].styHtml).prop("innerHTML"); $module_div.append(module_style_html); } var $cate_name_div = $module_div.find('[data-module-pdt="pdt_cate_name"]'); var $first_pdt_div = $module_div.find('[data-module-pdt="pdt_data"]'); $cate_name_div.empty(); $first_pdt_div.empty(); if (data.shop_cart_flg) { $module_div.attr("data-cart-show", 1); } else { $module_div.attr("data-cart-show", 0); } $ .each( data.pdt, function(n, value) { var pdt_data_temp = GetPdtFromDict(value.pdt_data); var $cate_name_html = $('<div class="condition_5"></div>'); $cate_name_html.text(value.pdt_cate_name); if (n == 0) { $cate_name_html.addClass("on"); var view = Number(value.pdt_view); if (view < value.pdt_data.length) { $module_div.find(".show-more-goods").show(); } else { $module_div.find(".show-more-goods").hide(); } $ .each( pdt_data_temp, function(i, obj) { if (i < view) { var $pdt_html = $('<div class="goods-nothree-items">' + '<div class="goods-nothree-image"><img src=""/><div class="shelves-flag"></div></div>' + '<div class="goods-nothree-name">商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称</div>' + '<div class="update-goods-info">' + '<div class="update-goods-price"></div>' + '</div>' + '</div>'); $pdt_html.find(".shelves-flag").attr("flag", "hidden"); if (obj.expired) { $pdt_html.find(".shelves-flag").attr( "flag", "over"); } if (obj.off) { $pdt_html.find(".shelves-flag").attr( "flag", "off"); } $pdt_html.find("img").attr("src", obj.product_image); $pdt_html.find(".goods-nothree-name").text( obj.product_name); var $balance_html = $('<div class="update-goods-available-balance"></div>'); var $old_price_html = $('<del class="update-goods-oriprice"></del>'); var $shop_name_html = $('<div class="update-goods-relative-shop-name"></div>'); if (obj.max_balance > 0) { $balance_html.attr("data-type", "2"); $balance_html .text(PaddingZero(obj.max_balance)); $pdt_html.find(".update-goods-info") .append($balance_html); } else if (obj.back_cash > 0) { $balance_html.attr("data-type", "1"); $balance_html .text(PaddingZero(obj.back_cash)); $pdt_html.find(".update-goods-info") .append($balance_html); } if (typeof (obj.prices_id) != "undefined" && obj.prices_id != null && obj.prices && obj.prices_id in obj.prices) { var data_temp = GetRuleCompute( obj.unit_price, obj.prices[obj.prices_id]); $pdt_html.find(".update-goods-price").text( PaddingZero(data_temp.price)); $old_price_html .text(PaddingZero(obj.unit_price)); $pdt_html.find(".update-goods-info") .append($old_price_html); } else if (obj.direct_price) { $pdt_html.find(".update-goods-price").text( PaddingZero(obj.unit_price)); $old_price_html .text(PaddingZero(obj.direct_price)); $pdt_html.find(".update-goods-info") .append($old_price_html); } else { $pdt_html.find(".update-goods-price").text( PaddingZero(obj.unit_price)); } if (obj.shop_alias) { $shop_name_html.text(obj.shop_alias); $pdt_html.find(".update-goods-info") .append($shop_name_html); } if (!data.org_price_flg) { $pdt_html.find(".update-goods-oriprice") .remove(); } $first_pdt_div.append($pdt_html); } }); } $cate_name_div.append($cate_name_html); }); } var StyPdtModOneAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); var $pdt_div = $module_div.find('div[data-module-pdt="pdt_data"]') var pdt_data_temp = GetPdtFromDict(data.pdt); var view = Number(data.pdt_view); if (data.shop_cart_flg) { $module_div.attr("data-cart-show", 1); } else { $module_div.attr("data-cart-show", 0); } $pdt_div.empty(); $.each(pdt_data_temp, function(i, obj) { if (i < view) { var $pdt_html = $('<div class="goods-items">' + '<div class="goods-img">' + '<img src="" />' + '<div class="shelves-flag"></div>' + '</div>' + '<div class="goods-name"><div></div></div>' + '<div class="update-goods-info">' + '<div class="update-goods-price"></div>' + '</div>' + '</div>'); $pdt_html.find(".shelves-flag").attr("flag", "hidden"); if (obj.expired) { $pdt_html.find(".shelves-flag").attr("flag", "over"); } if (obj.off) { $pdt_html.find(".shelves-flag").attr("flag", "off"); } $pdt_html.find("img").attr("src", obj.product_image); $pdt_html.find(".goods-name > div").text(obj.product_name); var $balance_html = $('<div class="update-goods-available-balance"></div>'); var $old_price_html = $('<del class="update-goods-oriprice"></del>'); var $shop_name_html = $('<div class="update-goods-relative-shop-name"></div>'); if (obj.max_balance > 0) { $balance_html.attr("data-type", "2"); $balance_html.text(PaddingZero(obj.max_balance)); $pdt_html.find(".update-goods-info").append($balance_html); } else if (obj.back_cash > 0) { $balance_html.attr("data-type", "1"); $balance_html.text(PaddingZero(obj.back_cash)); $pdt_html.find(".update-goods-info").append($balance_html); } if (typeof (obj.prices_id) != "undefined" && obj.prices_id != null && obj.prices && obj.prices_id in obj.prices) { var data_temp = GetRuleCompute(obj.unit_price, obj.prices[obj.prices_id]); $pdt_html.find(".update-goods-price").text(PaddingZero(data_temp.price)); $old_price_html.text(PaddingZero(obj.unit_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else if (obj.direct_price) { $pdt_html.find(".update-goods-price").text(PaddingZero(obj.unit_price)); $old_price_html.text(PaddingZero(obj.direct_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else { $pdt_html.find(".update-goods-price").text(PaddingZero(obj.unit_price)); } if (obj.shop_alias) { $shop_name_html.text(obj.shop_alias); $pdt_html.find(".update-goods-info").append($shop_name_html); } if (!data.org_price_flg) { $pdt_html.find(".update-goods-oriprice").remove(); } $pdt_div.append($pdt_html); } }); if (view < data.pdt.length) { $module_div.find(".show-more-goods").show(); } else { $module_div.find(".show-more-goods").hide(); } if ($module_div.find('[data-module-str="mod_name"]').text() == "") { $module_div.find('[data-module-str="mod_name"]').hide(); } else { $module_div.find('[data-module-str="mod_name"]').show(); } } var StyPdtModTwoAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); var $pdt_div = $module_div.find('div[data-module-pdt="pdt_data"]') var pdt_data_temp = GetPdtFromDict(data.pdt); var view = Number(data.pdt_view); if (data.shop_cart_flg) { $module_div.attr("data-cart-show", 1); } else { $module_div.attr("data-cart-show", 0); } $pdt_div.empty(); $ .each( pdt_data_temp, function(i, obj) { if (i < view) { var $pdt_html = $('<div class="goods-notwo-items">' + '<div class="goods-notwo-image"><img src=""/><div class="shelves-flag"></div></div>' + '<div class="goods-notwo-info">' + '<div class="goods-notwo-name"></div>' + '<div class="update-goods-info">' + '<div class="update-goods-price"></div>' + '</div>' + '</div>'); $pdt_html.find(".shelves-flag").attr("flag", "hidden"); if (obj.expired) { $pdt_html.find(".shelves-flag").attr("flag", "over"); } if (obj.off) { $pdt_html.find(".shelves-flag").attr("flag", "off"); } $pdt_html.find("img").attr("src", obj.product_image); $pdt_html.find(".goods-notwo-name").text(obj.product_name); var $balance_html = $('<div class="update-goods-available-balance"></div>'); var $old_price_html = $('<del class="update-goods-oriprice"></del>'); var $shop_name_html = $('<div class="update-goods-relative-shop-name"></div>'); if (obj.max_balance > 0) { $balance_html.attr("data-type", "2"); $balance_html.text(PaddingZero(obj.max_balance)); $pdt_html.find(".update-goods-info").append($balance_html); } else if (obj.back_cash > 0) { $balance_html.attr("data-type", "1"); $balance_html.text(PaddingZero(obj.back_cash)); $pdt_html.find(".update-goods-info").append($balance_html); } if (typeof (obj.prices_id) != "undefined" && obj.prices_id != null && obj.prices && obj.prices_id in obj.prices) { var data_temp = GetRuleCompute(obj.unit_price, obj.prices[obj.prices_id]); $pdt_html.find(".update-goods-price").text( PaddingZero(data_temp.price)); $old_price_html.text(PaddingZero(obj.unit_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else if (obj.direct_price) { $pdt_html.find(".update-goods-price").text( PaddingZero(obj.unit_price)); $old_price_html.text(PaddingZero(obj.direct_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else { $pdt_html.find(".update-goods-price").text( PaddingZero(obj.unit_price)); } if (obj.shop_alias) { $shop_name_html.text(obj.shop_alias); $pdt_html.find(".update-goods-info").append($shop_name_html); } if (!data.org_price_flg) { $pdt_html.find(".update-goods-oriprice").remove(); } $pdt_div.append($pdt_html); } }); if (view < data.pdt.length) { $module_div.find(".show-more-goods").show(); } else { $module_div.find(".show-more-goods").hide(); } if ($module_div.find('[data-module-str="mod_name"]').text() == "") { $module_div.find('[data-module-str="mod_name"]').hide(); } else { $module_div.find('[data-module-str="mod_name"]').show(); } } var StyPdtModThreeAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); var $pdt_div = $module_div.find('div[data-module-pdt="pdt_data"]') var pdt_data_temp = GetPdtFromDict(data.pdt); var view = Number(data.pdt_view); if (data.shop_cart_flg) { $module_div.attr("data-cart-show", 1); } else { $module_div.attr("data-cart-show", 0); } $pdt_div.empty(); $ .each( pdt_data_temp, function(i, obj) { if (i < view) { var $pdt_html = $('<div class="goods-nothree-items">' + '<div class="goods-nothree-image"><img src=""/><div class="shelves-flag"></div></div>' + '<div class="goods-nothree-name">商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称</div>' + '<div class="update-goods-info">' + '<div class="update-goods-price"></div>' + '</div>' + '</div>'); $pdt_html.find(".shelves-flag").attr("flag", "hidden"); if (obj.expired) { $pdt_html.find(".shelves-flag").attr("flag", "over"); } if (obj.off) { $pdt_html.find(".shelves-flag").attr("flag", "off"); } $pdt_html.find("img").attr("src", obj.product_image); $pdt_html.find(".goods-nothree-name").text(obj.product_name); var $balance_html = $('<div class="update-goods-available-balance"></div>'); var $old_price_html = $('<del class="update-goods-oriprice"></del>'); var $shop_name_html = $('<div class="update-goods-relative-shop-name"></div>'); if (obj.max_balance > 0) { $balance_html.attr("data-type", "2"); $balance_html.text(PaddingZero(obj.max_balance)); $pdt_html.find(".update-goods-info").append($balance_html); } else if (obj.back_cash > 0) { $balance_html.attr("data-type", "1"); $balance_html.text(PaddingZero(obj.back_cash)); $pdt_html.find(".update-goods-info").append($balance_html); } if (typeof (obj.prices_id) != "undefined" && obj.prices_id != null && obj.prices && obj.prices_id in obj.prices) { var data_temp = GetRuleCompute(obj.unit_price, obj.prices[obj.prices_id]); $pdt_html.find(".update-goods-price").text( PaddingZero(data_temp.price)); $old_price_html.text(PaddingZero(obj.unit_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else if (obj.direct_price) { $pdt_html.find(".update-goods-price").text( PaddingZero(obj.unit_price)); $old_price_html.text(PaddingZero(obj.direct_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else { $pdt_html.find(".update-goods-price").text( PaddingZero(obj.unit_price)); } if (obj.shop_alias) { $shop_name_html.text(obj.shop_alias); $pdt_html.find(".update-goods-info").append($shop_name_html); } if (!data.org_price_flg) { $pdt_html.find(".update-goods-oriprice").remove(); } $pdt_div.append($pdt_html); } }); if (view < data.pdt.length) { $module_div.find(".show-more-goods").show(); } else { $module_div.find(".show-more-goods").hide(); } if ($module_div.find('[data-module-str="mod_name"]').text() == "") { $module_div.find('[data-module-str="mod_name"]').hide(); } else { $module_div.find('[data-module-str="mod_name"]').show(); } } var StyBannerModOneAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); $module_div.find(".tvm-shop-banner-image-list").empty(); $.each(data.banners, function(n, value) { var $html_temp = $('<div class="tvm-shop-banner-image">' + '<img src=""/>' + '</div>'); $html_temp.find("img").attr("src", value.url); $html_temp.css("height", data.height + "px"); $module_div.find(".tvm-shop-banner-image-list").append($html_temp); }); } var StyBannerModTwoAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); $module_div.find(".swiper-wrapper").empty(); $.each(data.banners, function(n, value) { var $html_temp = $('<div class="swiper-slide tvm-shop-banner-image"><img src=""/></div>'); $html_temp.find("img").attr("src", value.url); $module_div.find(".swiper-wrapper").append($html_temp); }); $module_div.find(".swiper-container").css("height", data.height + "px"); } var StyCateModOneAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); $module_div.find(".category-list").empty(); $.each(data.banners, function(n, value) { var $html_temp = $('<div class="category-items">' + '<img src=""/>' + '</div>'); $html_temp.find("img").attr("src", value.url); $module_div.find(".category-list").append($html_temp); }); if ($module_div.find('[data-module-str="name"]').text() == "") { $module_div.find('[data-module-str="name"]').hide(); } else { $module_div.find('[data-module-str="name"]').show(); } } var StyCouponAttr = function(id, data) { var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); $module_div.find(".coupon-items").remove(); $.each(data.coupon, function(n, value) { var $cop_html = $('<div class="coupon-items">' + '<div class="coupon-bgimage">' + '<div class="coupon-name one-row-show"></div>' + '<div class="coupon-limit one-row-show"></div>' + '</div>' + '<div class="coupon-bgcolor"></div>' + '</div>'); /* * if(value.type == "baoyou"){ $cop_html.find(".coupon-name").text("包邮") }else if(value.type == * "cash_coupon"){ $cop_html.find(".coupon-name").text("现金") }else if(value.type == * "discount_coupon"){ $cop_html.find(".coupon-name").text("折扣") } if(coupon.type == * "cash_coupon"){ if(coupon.type_extend_value == 0){ title = "减" + coupon.amount; }else{ * title = "满" + coupon.type_extend_value + "减" + coupon.amount; } }else if(coupon.type == * "discount_coupon"){ if(coupon.type_extend_value == 0){ title = coupon.amount + "折"; * }else{ title = "满" + coupon.type_extend_value + " " + coupon.amount+"折"; } } */ var title_one = ""; var title_two = "无门槛"; if (value.type == "cash_coupon") { title_one = "¥" + value.amount; } else if (value.type == "discount_coupon") { title_one = value.amount * 1 + "折"; } if (value.type_extend_value != 0) { title_two = "满" + value.type_extend_value; } $cop_html.find(".coupon-name").text(title_one); $cop_html.find(".coupon-limit").text(title_two); $cop_html.find(".coupon-bgcolor").css("background-color", data.color); $cop_html.find(".coupon-name").css("color", data.color); $cop_html.find(".coupon-limit").css("color", data.color); $module_div.find(".coupons-list").append($cop_html); }); } var StyGoodOverFlowAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); var $pdt_div = $module_div.find('div[data-module-pdt="pdt_data"]') var pdt_data_temp = GetPdtFromDict(data.pdt); var view = Number(data.pdt_view); $pdt_div.empty(); $ .each( pdt_data_temp, function(i, obj) { if (i < view) { var $pdt_html = $('<div class="goods-overflowx-items">' + // '<div class="goods-relative-shop-name"></div>'+ '<div class="goods-overflowx-image">' + '<img src=""/>' + '<div class="shelves-flag"></div>' + '</div>' + '<div class="goods-overflowx-price-xianjia">¥<span><span class="goods-xianjia-temp"></span></span></div>' + '<div class="goods-overflowx-price-yuanjia"><del>¥<span class="goods-yuanjia-temp"></span></del></div>' + '</div>'); $pdt_html.find(".shelves-flag").attr("flag", "hidden"); if (obj.expired) { $pdt_html.find(".shelves-flag").attr("flag", "over"); } if (obj.off) { $pdt_html.find(".shelves-flag").attr("flag", "off"); } $pdt_html.find("img").attr("src", obj.product_image); $pdt_html.find(".goods-relative-shop-name").text(obj.shop_alias); if (typeof (obj.prices_id) != "undefined" && obj.prices_id != null && obj.prices && obj.prices_id in obj.prices) { var data_temp = GetRuleCompute(obj.unit_price, obj.prices[obj.prices_id]); $pdt_html.find(".goods-xianjia-temp").text( PaddingZero(data_temp.price)); $pdt_html.find(".goods-yuanjia-temp").text( PaddingZero(obj.unit_price)); $pdt_html.find(".goods-overflowx-price-yuanjia del").show(); } else if (obj.direct_price) { $pdt_html.find(".goods-xianjia-temp").text( PaddingZero(obj.unit_price)); $pdt_html.find(".goods-yuanjia-temp").text( PaddingZero(obj.direct_price)); $pdt_html.find(".goods-overflowx-price-yuanjia del").show(); } else { $pdt_html.find(".goods-xianjia-temp").text( PaddingZero(obj.unit_price)); $pdt_html.find(".goods-overflowx-price-yuanjia del").hide(); } if (!data.org_price_flg) { $pdt_html.find(".goods-overflowx-price-yuanjia del").hide(); } $pdt_div.append($pdt_html); } }); if (view < data.pdt.length) { $module_div.find(".goods-overflowx-more").show(); } else { $module_div.find(".goods-overflowx-more").hide(); } if ($module_div.find('[data-module-str="first_name"]').text() == "") { $module_div.find('[data-module-str="first_name"]').hide(); } else { $module_div.find('[data-module-str="first_name"]').show(); } if ($module_div.find('[data-module-str="second_name"]').text() == "") { $module_div.find('[data-module-str="second_name"]').hide(); } else { $module_div.find('[data-module-str="second_name"]').show(); } } var StyFenLanOneAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); if (data.name == "") { $module_div.find(".goods-fenlan-title").hide(); } else { $module_div.find(".goods-fenlan-title").show(); $module_div.find(".goods-fenlan-title").text(data.name); } $module_div.find(".goods-fenlan-list").empty(); $.each(data.fenlan, function(n, value) { var $html_temp = $(''); if (n == 0) { $html_temp = $('<div class="goods-fenlan-items-first">' + '<div class="goods-titles">' + '<div class="goods-title-a one-row-show"></div>' + '<div class="goods-title-b one-row-show"></div>' + '</div>' + '<div class="goods-fenlan-image-first">' + '<img src=""/>' + '</div>' + '</div>'); } else { $html_temp = $('<div class="goods-fenlan-items">' + '<div class="goods-fenlan-image">' + '<img src=""/>' + '</div>' + '<div class="goods-titles">' + '<div class="goods-title-a one-row-show"></div>' + '<div class="goods-title-b one-row-show"></div>' + '</div>' + '</div>'); } $html_temp.find("img").attr("src", value.url); $html_temp.find(".goods-title-a").text(value.big_title); $html_temp.find(".goods-title-b").text(value.small_title); $module_div.find(".goods-fenlan-list").append($html_temp); }); } var StyFenLanTwoAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); if (data.name == "") { $module_div.find(".goods-fenlan-title").hide(); } else { $module_div.find(".goods-fenlan-title").show(); $module_div.find(".goods-fenlan-title").text(data.name); } $module_div.find(".goods-fenlan-list").empty(); $.each(data.fenlan, function(n, value) { var $html_temp = $('<div class="goods-fenlan-two-items">' + '<div class="goods-fenlan-image">' + '<img src=""/>' + '</div>' + '<div class="goods-titles">' + '<div class="goods-title-a one-row-show"></div>' + '<div class="goods-title-b one-row-show"></div>' + '</div>' + '</div>'); $html_temp.find("img").attr("src", value.url); $html_temp.find(".goods-title-a").text(value.big_title); $html_temp.find(".goods-title-b").text(value.small_title); $module_div.find(".goods-fenlan-list").append($html_temp); }); } var StyFindShopAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); if (data.name == "") { $module_div.find(".findshop-module-title").hide(); } else { $module_div.find(".findshop-module-title").show(); $module_div.find(".findshop-module-title").text(data.name); } $module_div.find(".findshop-list").empty(); $.each(data.findshop, function(n, value) { var $html_temp = $('<div class="findshop-items">' + '<div class="findshop-module-image">' + '<img src=""/>' + '</div>' + '<div class="findshop-name one-row-show">店铺的名字</div>' + '</div>'); $html_temp.find("img").attr("src", value.url); $html_temp.find(".findshop-name").text(value.title); $module_div.find(".findshop-list").append($html_temp); }); } var StySeckillAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); if (data.title == "") { $module_div.find(".secondskill-subtitle").hide(); } else { $module_div.find(".secondskill-subtitle").show(); $module_div.find(".secondskill-subtitle").text(data.title); } var pdt_data_temp = GetPdtFromDict(data.pdt); $module_div.find("span.secondskill-type") .text(TimeToChinese(data.seckill_begin_time, 1) + "开始"); if (data.seckill_date != "" && data.seckill_begin_time != "" && data.seckill_end_time != "") { var nowDate = new Date(); var beginDate = new Date(data.seckill_date.replace(/-/gm, '/') + " " + data.seckill_begin_time); var endDate = new Date(data.seckill_date.replace(/-/gm, '/') + " " + data.seckill_end_time); $module_div.find("span.secondskill-time").empty(); if (nowDate < beginDate) { $module_div.find("span.secondskill-type").show(); $module_div.find("span.secondskill-time").text("即将开始"); } else if (nowDate > endDate) { $module_div.find("span.secondskill-type").hide(); $module_div.find("span.secondskill-time").text("已经结束"); } else { var time_temp = Math.floor((endDate.getTime() - nowDate.getTime()) / 1000); var hour_temp = Math.floor(time_temp / 3600); time_temp = time_temp - hour_temp * 3600; var minute_temp = Math.floor(time_temp / 60); time_temp = time_temp - minute_temp * 60; var sec_temp = time_temp; var html_temp = '<span class="sk-hour"></span>:<span class="sk-min"></span>:<span class="sk-sec"></span>'; $module_div.find("span.secondskill-time").append(html_temp); if (hour_temp < 10) { hour_temp = "0" + hour_temp; } if (minute_temp < 10) { minute_temp = "0" + minute_temp; } if (sec_temp < 10) { sec_temp = "0" + sec_temp; } $module_div.find(".sk-hour").text(hour_temp); $module_div.find(".sk-min").text(minute_temp); $module_div.find(".sk-sec").text(sec_temp); $module_div.find("span.secondskill-type").show(); $module_div.find("span.secondskill-type").text("距离结束"); } } var view = Number(data.pdt_view); $module_div.find(".secondskill-goods-list").empty(); $ .each( pdt_data_temp, function(n, value) { if (n < view) { var $html_temp = $('<div class="secondskill-goods-items">' + // '<div class="goods-relative-shop-name"></div>'+ '<div class="secondskill-goods-image">' + '<img src=""/>' + '<div class="shelves-flag"></div>' + '</div>' + '<div class="secondskill-goods-presentprice">¥<span class="xianjia-temp">123</span></div>' + '<div class="secondskill-goods-originalprice"><del>¥<span class="yuanjia-temp">345</span></del></div>' + '</div>'); $html_temp.find(".shelves-flag").attr("flag", "hidden"); if (value.expired) { $html_temp.find(".shelves-flag").attr("flag", "over"); } if (value.off) { $html_temp.find(".shelves-flag").attr("flag", "off"); } $html_temp.find("img").attr("src", value.product_image); $html_temp.find(".goods-relative-shop-name").text(value.shop_alias); if (typeof (value.prices_id) != "undefined" && value.prices_id != null && value.prices && value.prices_id in value.prices) { var data_temp = GetRuleCompute(value.unit_price, value.prices[value.prices_id]); $html_temp.find(".xianjia-temp").text(PaddingZero(data_temp.price)); $html_temp.find(".yuanjia-temp") .text(PaddingZero(value.unit_price)); $html_temp.find(".secondskill-goods-originalprice del").show(); } else if (value.direct_price) { $html_temp.find(".xianjia-temp") .text(PaddingZero(value.unit_price)); $html_temp.find(".yuanjia-temp").text( PaddingZero(value.direct_price)); $html_temp.find(".secondskill-goods-originalprice del").show(); } else { $html_temp.find(".xianjia-temp") .text(PaddingZero(value.unit_price)); $html_temp.find(".secondskill-goods-originalprice del").hide(); } $module_div.find(".secondskill-goods-list").append($html_temp); } }); if (view < data.pdt.length) { $module_div.find(".secondskill-more").show(); } else { $module_div.find(".secondskill-more").hide(); } } var StyBrandOneAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); $module_div.find(".brand-module-images").empty(); var view = Number(data.brands_view); $module_div.find(".brand-module-images").attr("data-count", view); $.each(data.brands, function(n, value) { if (n < view) { var $html_temp = $('<div class="brand-module-image-items">' + '<img src=""/>' + '</div>'); $html_temp.find("img").attr("src", value.url); $module_div.find(".brand-module-images").append($html_temp); } }); if (data.brands.length > view) { $module_div.find(".brand-show-more").show(); } else { $module_div.find(".brand-show-more").hide(); } if (data.brand_imgs != "") { $module_div.find(".brand-module-title img").attr("src", data.brand_imgs); $module_div.find(".brand-module-title").show(); } else { $module_div.find(".brand-module-title").hide(); } } var StyBrandTwoAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); $module_div.find(".brand-module-images").empty(); var view = Number(data.brands_view); $module_div.find(".brand-module-images").attr("data-count", view); $.each(data.brands, function(n, value) { if (n < view) { var $html_temp = $('<div class="brand-module-image-items">' + '<img src=""/>' + '</div>'); $html_temp.find("img").attr("src", value.url); $module_div.find(".brand-module-images").append($html_temp); } }); if (data.brand_imgs != "") { $module_div.find(".brand-module-title img").attr("src", data.brand_imgs); $module_div.find(".brand-module-title").show(); } else { $module_div.find(".brand-module-title").hide(); } } var StyActivityOneAttr = function(id, data) { } var StyActivityTwoAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); $module_div.find(".two-title-first-span").text(data.first_name); $module_div.find(".two-title-last-span").text(data.second_name); } var StyActivityThreeAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); $module_div.find(".activity-type-one-title-first").text(data.first_name); $module_div.find(".activity-type-one-title-second").text(data.second_name); $module_div.find(".activity-type-one-goods-items-parent").empty(); if (_final_data.act_dict[data.act_type_id]) { var act_temp = _final_data.act_dict[data.act_type_id].data; if (act_temp.end_time != "" && act_temp.start_time != "") { var nowDate = new Date(); var beginDate = new Date(act_temp.start_time.replace(/-/gm, '/')); var endDate = new Date(act_temp.end_time.replace(/-/gm, '/')); $module_div.find(".activity-type-one-over-time span").show(); if (beginDate.getTime() < nowDate.getTime()) { $module_div.find(".activity-type-one-over-time span:eq(0)").text("距本场开始"); var time_temp = Math.floor((nowDate.getTime() - beginDate.getTime()) / 1000); var hour_temp = Math.floor(time_temp / 3600); time_temp = time_temp - hour_temp * 3600; var minute_temp = Math.floor(time_temp / 60); time_temp = time_temp - minute_temp * 60; var sec_temp = time_temp; if (hour_temp < 10) { hour_temp = "0" + hour_temp; } if (minute_temp < 10) { minute_temp = "0" + minute_temp; } if (sec_temp < 10) { sec_temp = "0" + sec_temp; } if (hour_temp > 24) { $module_div.find(".activity-type-one-over-time .day").text( parseInt(hour_temp / 24) + "天"); hour_temp = hour_temp - parseInt(hour_temp / 24) * 24; } else { $module_div.find(".activity-type-one-over-time .day").text(""); } $module_div.find(".activity-type-one-over-time .hour").text(hour_temp); $module_div.find(".activity-type-one-over-time .mins").text(minute_temp); $module_div.find(".activity-type-one-over-time .secs").text(sec_temp); } else if (endDate.getTime() < nowDate.getTime()) { $module_div.find(".activity-type-one-over-time span").hide(); $module_div.find(".activity-type-one-over-time span:eq(0)").text("已经结束"); } else if (nowDate.getTime() < endDate.getTime()) { $module_div.find(".activity-type-one-over-time span:eq(0)").text("距本场结束"); var time_temp = Math.floor((endDate.getTime() - nowDate.getTime()) / 1000); var hour_temp = Math.floor(time_temp / 3600); time_temp = time_temp - hour_temp * 3600; var minute_temp = Math.floor(time_temp / 60); time_temp = time_temp - minute_temp * 60; var sec_temp = time_temp; if (hour_temp < 10) { hour_temp = "0" + hour_temp; } if (minute_temp < 10) { minute_temp = "0" + minute_temp; } if (sec_temp < 10) { sec_temp = "0" + sec_temp; } if (hour_temp > 24) { $module_div.find(".activity-type-one-over-time .day").text( parseInt(hour_temp / 24) + "天"); hour_temp = hour_temp - parseInt(hour_temp / 24) * 24; } else { $module_div.find(".activity-type-one-over-time .day").text(""); } $module_div.find(".activity-type-one-over-time .hour").text(hour_temp); $module_div.find(".activity-type-one-over-time .mins").text(minute_temp); $module_div.find(".activity-type-one-over-time .secs").text(sec_temp); } } if (_final_data.act_pdt_sort && _final_data.act_pdt_sort[data.group_pdt]) { var view = Number(data.group_view); $module_div.find(".activity-type-one-show-more").hide(); if (view < _final_data.act_pdt_sort[data.group_pdt].data.sort.length) { $module_div.find(".activity-type-one-show-more").show(); } $.each(_final_data.act_pdt_sort[data.group_pdt].data.sort, function(n, group_id) { if (act_temp.groups && act_temp.groups[group_id]) { var group = act_temp.groups[group_id]; if (_final_data.product_dict[group.product_id]) { var pdt_temp = _final_data.product_dict[group.product_id].data; if (n < view) { var $html_temp = $('<div class="activity-type-one-goods-items">' + '<div class="activity-type-one-goods-image">' + '<img/>' + '</div>' + '<div class="activity-type-one-goods-name">' + '<span>[团购]</span>' + '<span></span>' + '</div>' + '<div class="activity-type-one-goods-price">' + '¥<span></span>' + '</div>' + '<div class="activity-type-one-goods-oriprice">' + '<del><span>¥</span></del>' + '<span></span>' + '</div>' + '</div>'); $html_temp.find("img").attr("src", pdt_temp.product_image); $html_temp.find(".activity-type-one-goods-name span:eq(1)").text( pdt_temp.product_name); $html_temp.find(".activity-type-one-goods-price span").text( PaddingZero(group.group_price)); $html_temp.find(".activity-type-one-goods-oriprice span:eq(0)").text( PaddingZero(pdt_temp.unit_price)); $html_temp.find(".activity-type-one-goods-oriprice span:eq(1)").hide(); $module_div.find(".activity-type-one-goods-items-parent").append( $html_temp); } } } }); } } } var StyCateComModOneAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); var $pdt_div = $module_div.find('.category-commodity-type-one-goods-list'); $module_div.find(".category-commodity-type-one-image img").attr("src", data.banners.url); var pdt_data_temp = GetPdtFromDict(data.pdt); $pdt_div.empty(); $.each(pdt_data_temp, function(i, obj) { var $pdt_html = $('<div class="category-commodity-type-one-goods-items">' + '<div class="category-commodity-type-one-goods-image">' + '<img src=""/>' + '<div class="shelves-flag"></div>' + '</div>' + '<div class="category-commodity-type-one-goods-name"><div></div></div>' + '<div class="update-goods-info">' + '<div class="update-goods-price"></div>' + '</div>' + '</div>'); $pdt_html.find(".shelves-flag").attr("flag", "hidden"); if (obj.expired) { $pdt_html.find(".shelves-flag").attr("flag", "over"); } if (obj.off) { $pdt_html.find(".shelves-flag").attr("flag", "off"); } $pdt_html.find("img").attr("src", obj.product_image); $pdt_html.find(".category-commodity-type-one-goods-name > div").text(obj.product_name); var $balance_html = $('<div class="update-goods-available-balance"></div>'); var $old_price_html = $('<del class="update-goods-oriprice goods-nothree-yuanjia"></del>'); var $shop_name_html = $('<div class="update-goods-relative-shop-name"></div>'); if (obj.max_balance > 0) { $balance_html.attr("data-type", "2"); $balance_html.text(PaddingZero(obj.max_balance)); $pdt_html.find(".update-goods-info").append($balance_html); } else if (obj.back_cash > 0) { $balance_html.attr("data-type", "1"); $balance_html.text(PaddingZero(obj.back_cash)); $pdt_html.find(".update-goods-info").append($balance_html); } if (typeof (obj.prices_id) != "undefined" && obj.prices_id != null && obj.prices && obj.prices_id in obj.prices) { var data_temp = GetRuleCompute(obj.unit_price, obj.prices[obj.prices_id]); $pdt_html.find(".update-goods-price").text(PaddingZero(data_temp.price)); $old_price_html.text(PaddingZero(obj.unit_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else if (obj.direct_price) { $pdt_html.find(".update-goods-price").text(PaddingZero(obj.unit_price)); $old_price_html.text(PaddingZero(obj.direct_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else { $pdt_html.find(".update-goods-price").text(PaddingZero(obj.unit_price)); } if (obj.shop_alias) { $shop_name_html.text(obj.shop_alias); $pdt_html.find(".update-goods-info").append($shop_name_html); } // if(!data.org_price_flg){ // $pdt_html.find(".update-goods-oriprice").remove(); // } $pdt_div.append($pdt_html); }); } var StyCateComModTwoAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); var $pdt_div = $module_div.find('.category-commodity-type-two-goods-list'); $module_div.find(".category-commodity-type-two-image img").attr("src", data.banners.url); var pdt_data_temp = GetPdtFromDict(data.pdt); $pdt_div.empty(); $.each(pdt_data_temp, function(i, obj) { var $pdt_html = $('<div class="category-commodity-type-two-goods-items">' + '<div class="category-commodity-type-two-goods-image">' + '<img src=""/>' + '<div class="shelves-flag"></div>' + '</div>' + '<div class="category-commodity-type-two-goods-name"><div></div></div>' + '<div class="update-goods-info">' + '<div class="update-goods-price"></div>' + '</div>' + '</div>'); $pdt_html.find(".shelves-flag").attr("flag", "hidden"); if (obj.expired) { $pdt_html.find(".shelves-flag").attr("flag", "over"); } if (obj.off) { $pdt_html.find(".shelves-flag").attr("flag", "off"); } $pdt_html.find("img").attr("src", obj.product_image); $pdt_html.find(".category-commodity-type-two-goods-name > div").text(obj.product_name); var $balance_html = $('<div class="update-goods-available-balance"></div>'); var $old_price_html = $('<del class="update-goods-oriprice goods-nothree-yuanjia"></del>'); var $shop_name_html = $('<div class="update-goods-relative-shop-name"></div>'); if (obj.max_balance > 0) { $balance_html.attr("data-type", "2"); $balance_html.text(PaddingZero(obj.max_balance)); $pdt_html.find(".update-goods-info").append($balance_html); } else if (obj.back_cash > 0) { $balance_html.attr("data-type", "1"); $balance_html.text(PaddingZero(obj.back_cash)); $pdt_html.find(".update-goods-info").append($balance_html); } if (typeof (obj.prices_id) != "undefined" && obj.prices_id != null && obj.prices && obj.prices_id in obj.prices) { var data_temp = GetRuleCompute(obj.unit_price, obj.prices[obj.prices_id]); $pdt_html.find(".update-goods-price").text(PaddingZero(data_temp.price)); $old_price_html.text(PaddingZero(obj.unit_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else if (obj.direct_price) { $pdt_html.find(".update-goods-price").text(PaddingZero(obj.unit_price)); $old_price_html.text(PaddingZero(obj.direct_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else { $pdt_html.find(".update-goods-price").text(PaddingZero(obj.unit_price)); } if (obj.shop_alias) { $shop_name_html.text(obj.shop_alias); $pdt_html.find(".update-goods-info").append($shop_name_html); } // if(!data.org_price_flg){ // $pdt_html.find(".update-goods-oriprice").remove(); // } $pdt_div.append($pdt_html); }); } var StyCateComModThreeAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); var $pdt_div = $module_div.find('.category-commodity-type-three-goods-list'); $module_div.find(".category-commodity-type-three-image img").attr("src", data.banners.url); var pdt_data_temp = GetPdtFromDict(data.pdt); $pdt_div.empty(); $.each(pdt_data_temp, function(i, obj) { var $pdt_html = $('<div class="category-commodity-type-three-goods-items">' + '<div class="category-commodity-type-three-goods-image">' + '<img src=""/>' + '<div class="shelves-flag"></div>' + '</div>' + '<div class="category-commodity-type-three-goods-info">' + '<div class="category-commodity-type-three-goods-name"><div></div></div>' + '<div class="update-goods-info">' + '<div class="update-goods-price"></div>' + '</div>' + '</div>' + '</div>'); $pdt_html.find(".shelves-flag").attr("flag", "hidden"); if (obj.expired) { $pdt_html.find(".shelves-flag").attr("flag", "over"); } if (obj.off) { $pdt_html.find(".shelves-flag").attr("flag", "off"); } $pdt_html.find("img").attr("src", obj.product_image); $pdt_html.find(".category-commodity-type-three-goods-name > div").text(obj.product_name); var $balance_html = $('<div class="update-goods-available-balance"></div>'); var $old_price_html = $('<del class="update-goods-oriprice goods-nothree-yuanjia"></del>'); var $shop_name_html = $('<div class="update-goods-relative-shop-name"></div>'); if (obj.max_balance > 0) { $balance_html.attr("data-type", "2"); $balance_html.text(PaddingZero(obj.max_balance)); $pdt_html.find(".update-goods-info").append($balance_html); } else if (obj.back_cash > 0) { $balance_html.attr("data-type", "1"); $balance_html.text(PaddingZero(obj.back_cash)); $pdt_html.find(".update-goods-info").append($balance_html); } if (typeof (obj.prices_id) != "undefined" && obj.prices_id != null && obj.prices && obj.prices_id in obj.prices) { var data_temp = GetRuleCompute(obj.unit_price, obj.prices[obj.prices_id]); $pdt_html.find(".update-goods-price").text(PaddingZero(data_temp.price)); $old_price_html.text(PaddingZero(obj.unit_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else if (obj.direct_price) { $pdt_html.find(".update-goods-price").text(PaddingZero(obj.unit_price)); $old_price_html.text(PaddingZero(obj.direct_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else { $pdt_html.find(".update-goods-price").text(PaddingZero(obj.unit_price)); } if (obj.shop_alias) { $shop_name_html.text(obj.shop_alias); $pdt_html.find(".update-goods-info").append($shop_name_html); } // if(!data.org_price_flg){ // $pdt_html.find(".update-goods-oriprice").remove(); // } $pdt_div.append($pdt_html); }); } var StyCateComModFourAttr = function(id, data) { StyDefAttr(id, data); var $module_div = $("#tvm-shop-phone-panel").find('[data-module-id=' + id + ']'); var $pdt_div = $module_div.find('.category-commodity-type-four-goods-list'); $module_div.find(".category-commodity-type-four-image img").attr("src", data.banners.url); var pdt_data_temp = GetPdtFromDict(data.pdt); $pdt_div.empty(); $.each(pdt_data_temp, function(i, obj) { var $pdt_html = $('<div class="category-commodity-type-four-goods-items">' + '<div class="category-commodity-type-four-goods-image">' + '<img src=""/>' + '<div class="shelves-flag"></div>' + '</div>' + '<div class="category-commodity-type-four-goods-info">' + '<div class="category-commodity-type-four-goods-name"><div></div></div>' + '<div class="update-goods-info">' + '<div class="update-goods-price"></div>' + '</div>' + '</div>' + '</div>'); $pdt_html.find(".shelves-flag").attr("flag", "hidden"); if (obj.expired) { $pdt_html.find(".shelves-flag").attr("flag", "over"); } if (obj.off) { $pdt_html.find(".shelves-flag").attr("flag", "off"); } $pdt_html.find("img").attr("src", obj.product_image); $pdt_html.find(".category-commodity-type-four-goods-name > div").text(obj.product_name); var $balance_html = $('<div class="update-goods-available-balance"></div>'); var $old_price_html = $('<del class="update-goods-oriprice goods-nothree-yuanjia"></del>'); var $shop_name_html = $('<div class="update-goods-relative-shop-name"></div>'); if (obj.max_balance > 0) { $balance_html.attr("data-type", "2"); $balance_html.text(PaddingZero(obj.max_balance)); $pdt_html.find(".update-goods-info").append($balance_html); } else if (obj.back_cash > 0) { $balance_html.attr("data-type", "1"); $balance_html.text(PaddingZero(obj.back_cash)); $pdt_html.find(".update-goods-info").append($balance_html); } if (typeof (obj.prices_id) != "undefined" && obj.prices_id != null && obj.prices && obj.prices_id in obj.prices) { var data_temp = GetRuleCompute(obj.unit_price, obj.prices[obj.prices_id]); $pdt_html.find(".update-goods-price").text(PaddingZero(data_temp.price)); $old_price_html.text(PaddingZero(obj.unit_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else if (obj.direct_price) { $pdt_html.find(".update-goods-price").text(PaddingZero(obj.unit_price)); $old_price_html.text(PaddingZero(obj.direct_price)); $pdt_html.find(".update-goods-info").append($old_price_html); } else { $pdt_html.find(".update-goods-price").text(PaddingZero(obj.unit_price)); } if (obj.shop_alias) { $shop_name_html.text(obj.shop_alias); $pdt_html.find(".update-goods-info").append($shop_name_html); } // if(!data.org_price_flg){ // $pdt_html.find(".update-goods-oriprice").remove(); // } $pdt_div.append($pdt_html); }); } /*----------------右侧-----------------------------*/ var SetAttr = function(module) { SetDefFillAttr(module); } var SetEvent = function() { } var GetData = function() { } var SetBannerModEvent = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".banner-link-edit").hide(); $set_div.find(".banner-show-images-previous").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.append($module_style_div.find("div:first")); }); $set_div.find(".banner-show-images-next").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.prepend($module_style_div.find("div:last")); }); $set_div.find(".banner-link-edit").find(".banner-bannerlink-pages-select").click(function() { if ($set_div.find(".banner-bannerlink-pages-select").attr("contenteditable") == "false") { if ($(this).parent().find(".banner-bannerlink-pages").is(":hidden")) { $(this).parent().find(".banner-bannerlink-pages").show(); } else { $(this).parent().find(".banner-bannerlink-pages").hide(); } } }); $set_div.find(".banner-imageheight-select").change(function() { $set_div.find('.banner-img-height').text(Number($(this).val()) * 2); }); $set_div.find(".banner-bannerlink-pages .add-page-items").click( function() { // 添加新页面 if (isNaN(Number(_final_data.page_count))) { _final_data.page_count = 0; } _final_data.page_count = Number(_final_data.page_count) + 1; var page_name_temp = "页面" + ConvertToChinese(_final_data.page_count); var page_id_temp = CreateGUID(); AddPage(page_id_temp, page_name_temp, 2, 1); // 增加选项 var $link_div = $set_div.find(".banner-bannerlink-pages"); var $link_html = $('<div class="bannerlink-items"></div>'); var name = page_name_temp; $link_html.text(name); $link_html.attr("data-module-link-id", page_id_temp); $link_html.unbind("click"); $link_html.click(function() { SelctBannerLink($(this)); }); $link_div.prepend($link_html); $link_div.find('[data-module-link-id=' + page_id_temp + ']').click(); // 设置信息 var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr( "data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr( "data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data.data); module_data.data = temp; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.style = $html.find('[data-set-module-style="style"]').find( "div:first").attr("data-set-module-style"); module_data.data.height = $html.find('.banner-imageheight-select').val(); var error = ""; error = TextBannerMod(module_data.data); if (error == "") { module_final_data.data = module_data.data; $("#saveBtn").click(); SelectPage(page_id_temp); $("#saveBtn").hide(); } else { alert(error); } }); $set_div.find('.addimages-value-items').click( function() { var img_size_str = "建议尺寸:750*" + Number($set_div.find(".banner-imageheight-select").val()) * 2 + "(px) 图片大小:不超过500k 格式:jpg/gif/png"; $("#upload_img_dialog").find(".new_img_warn").text(img_size_str); _img_max = 4 - $set_div.find(".images-value-items").length; _img_dialog_data = []; _img_select_callback = function(imgs) { $.each(imgs, function(n, value) { var img_data = { url : value.url, type : 1, link : "index" } AddBanner(img_data); }); } GetOldImgServerRequest(); $("#upload_img_dialog").show("drop"); }); $set_div.find(".banner-bannerlink-pages .enter-link") .click( function() { if ($set_div.find(".banner-bannerlink-pages-select") .attr("contenteditable") == "true") { $set_div.find(".banner-bannerlink-pages-select").focus(); } else { var num = Number($set_div.find(".images-value-items.on").attr( "data-module-banner-num")); if (_pdt_view_time_data.data.banners[num - 1].type == 1) { $set_div.find(".banner-bannerlink-pages-select").text(""); } $set_div.find(".banner-bannerlink-pages-select").attr( "contenteditable", "true"); $set_div.find(".banner-bannerlink-pages-select").focus(); } $set_div.find(".banner-bannerlink-pages").hide(); }); $set_div.find(".banner-link-edit").find(".banner-bannerlink-pages-select").keypress( function(e) { if (e.which == 13) { // 回车事件 $(this).blur(); } }); $set_div.find(".banner-link-edit").find(".pages-select-icon").click(function(e) { e.stopPropagation(); if ($(this).parent().find(".banner-bannerlink-pages").is(":hidden")) { $(this).parent().find(".banner-bannerlink-pages").show(); } else { $(this).parent().find(".banner-bannerlink-pages").hide(); } }); $set_div.find(".banner-link-edit").find(".banner-bannerlink-pages-select") .blur( function() { if ($set_div.find(".banner-bannerlink-pages-select") .attr("contenteditable") == "true") { $set_div.find(".banner-bannerlink-pages").hide(); var num = Number($set_div.find(".images-value-items.on").attr( "data-module-banner-num")); _pdt_view_time_data.data.banners[num - 1].type = 0; _pdt_view_time_data.data.banners[num - 1].link = $.trim($set_div.find( ".banner-bannerlink-pages-select").text()); $set_div.find(".banner-bannerlink-pages-select").text( _pdt_view_time_data.data.banners[num - 1].link); $set_div.find(".banner-bannerlink-pages-select").attr( "contenteditable", "false"); } }) var SetBannerLink = function() { var $link_div = $set_div.find(".banner-bannerlink-pages"); $link_div.find(".bannerlink-items").remove(); $.each($(".tvm-shop-btns").find(".tvm-shop-btns-items"), function(n, value) { var $link_html = $('<div class="bannerlink-items"></div>'); var name = $(value).find(".page-name").text(); $link_html.text(name); $link_html.attr("data-module-link-id", $(value).attr("data-page-id")); $link_html.unbind("click"); $link_html.click(function() { SelctBannerLink($(this)); }); $link_div.append($link_html); }); $set_div.find('.writelink').remove(); } SetBannerLink(); $set_div.find(".images-value-items:first").click(); } var SetBrandModEvent = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".brand-link-edit").hide(); $set_div.find(".brand-value div.delete-btn").click(function(e) { e.stopPropagation(); $set_div.find(".brand-value img").attr("src", ""); }); $set_div.find(".brand-category-show-number input").blur(function() { _pdt_view_time_data.data.brands_view = $.trim($(this).val()); }); $set_div.find('.brand-value').click(function() { $current_img = [$(this).find("img")]; var img_size_str = "建议尺寸:750*70(像素) 图片大小:不超过500k 格式:jpg/gif/png"; $("#upload_img_dialog").find(".new_img_warn").text(img_size_str); _img_max = 1; _img_dialog_data = []; _img_select_callback = function(imgs) { $.each($current_img, function(n, value) { if (imgs.length > n) { value.attr("src", imgs[n].url); } }); } GetOldImgServerRequest(); $("#upload_img_dialog").show("drop"); }); $set_div.find(".brand-show-images-previous").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.append($module_style_div.find("div:first")); }); $set_div.find(".brand-show-images-next").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.prepend($module_style_div.find("div:last")); }); $set_div.find(".brand-link-edit").find(".banner-bannerlink-pages-select").click(function() { if ($set_div.find(".banner-bannerlink-pages-select").attr("contenteditable") == "false") { if ($(this).parent().find(".banner-bannerlink-pages").is(":hidden")) { $(this).parent().find(".banner-bannerlink-pages").show(); } else { $(this).parent().find(".banner-bannerlink-pages").hide(); } } }); $set_div.find(".banner-imageheight-select").change(function() { $set_div.find('.banner-img-height').text(Number($(this).val()) * 2); }); $set_div.find(".banner-bannerlink-pages .add-page-items").click( function() { // 添加新页面 if (isNaN(Number(_final_data.page_count))) { _final_data.page_count = 0; } _final_data.page_count = Number(_final_data.page_count) + 1; var page_name_temp = "页面" + ConvertToChinese(_final_data.page_count); var page_id_temp = CreateGUID(); AddPage(page_id_temp, page_name_temp, 2, 1); // 增加选项 var $link_div = $set_div.find(".banner-bannerlink-pages"); var $link_html = $('<div class="bannerlink-items"></div>'); var name = page_name_temp; $link_html.text(name); $link_html.attr("data-module-link-id", page_id_temp); $link_html.unbind("click"); $link_html.click(function() { SelctBrandLink($(this)); }); $link_div.prepend($link_html); $link_div.find('[data-module-link-id=' + page_id_temp + ']').click(); // 设置信息 var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr( "data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr( "data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data.data); module_data.data = temp; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.style = $html.find('[data-set-module-style="style"]').find("div:first").attr( "data-set-module-style"); module_data.data.brand_imgs = $html.find('.brand-value img').attr("src"); var error = ""; error = TextBrandMod(module_data.data); if (error == "") { module_final_data.data = module_data.data; $("#saveBtn").click(); SelectPage(page_id_temp); $("#saveBtn").hide(); } else { alert(error); } }); $set_div .find('.addimages-first-btn') .click( function() { var img_size_str = "建议宽度:1行1个(不大于750px),1行2个(不大于375px),1行3个(不大于250px),1行4个(不大于187px) 图片大小:均不超过500k 格式:jpg/gif/png"; $("#upload_img_dialog").find(".new_img_warn").text(img_size_str); _img_max = 999999 - $set_div.find(".brand-addimages-value-items").length; _img_dialog_data = []; _img_select_callback = function(imgs) { $.each(imgs, function(n, value) { var img_data = { url : value.url, type : 1, link : "index" } AddBrand(img_data); }); } GetOldImgServerRequest(); $("#upload_img_dialog").show("drop"); }); $set_div.find(".banner-bannerlink-pages .enter-link") .click( function() { if ($set_div.find(".banner-bannerlink-pages-select") .attr("contenteditable") == "true") { $set_div.find(".banner-bannerlink-pages-select").focus(); } else { var num = Number($set_div.find(".brand-addimages-value-items.on").attr( "data-module-banner-num")); if (_pdt_view_time_data.data.brands[num - 1].type == 1) { $set_div.find(".banner-bannerlink-pages-select").text(""); } $set_div.find(".banner-bannerlink-pages-select").attr( "contenteditable", "true"); $set_div.find(".banner-bannerlink-pages-select").focus(); } $set_div.find(".banner-bannerlink-pages").hide(); }); $set_div.find(".brand-link-edit").find(".banner-bannerlink-pages-select").keypress(function(e) { if (e.which == 13) { // 回车事件 $(this).blur(); } }); $set_div.find(".brand-link-edit").find(".pages-select-icon").click(function(e) { e.stopPropagation(); if ($(this).parent().find(".banner-bannerlink-pages").is(":hidden")) { $(this).parent().find(".banner-bannerlink-pages").show(); } else { $(this).parent().find(".banner-bannerlink-pages").hide(); } }); $set_div.find(".brand-link-edit").find(".banner-bannerlink-pages-select") .blur( function() { if ($set_div.find(".banner-bannerlink-pages-select") .attr("contenteditable") == "true") { $set_div.find(".banner-bannerlink-pages").hide(); var num = Number($set_div.find(".brand-addimages-value-items.on").attr( "data-module-banner-num")); _pdt_view_time_data.data.brands[num - 1].type = 0; _pdt_view_time_data.data.brands[num - 1].link = $.trim($set_div.find( ".banner-bannerlink-pages-select").text()); $set_div.find(".banner-bannerlink-pages-select").text( _pdt_view_time_data.data.brands[num - 1].link); $set_div.find(".banner-bannerlink-pages-select").attr( "contenteditable", "false"); } }) var SetBannerLink = function() { var $link_div = $set_div.find(".banner-bannerlink-pages"); $link_div.find(".bannerlink-items").remove(); $.each($(".tvm-shop-btns").find(".tvm-shop-btns-items"), function(n, value) { var $link_html = $('<div class="bannerlink-items"></div>'); var name = $(value).find(".page-name").text(); $link_html.text(name); $link_html.attr("data-module-link-id", $(value).attr("data-page-id")); $link_html.unbind("click"); $link_html.click(function() { SelctBrandLink($(this)); }); $link_div.append($link_html); }); $set_div.find('.writelink').remove(); } SetBannerLink(); $set_div.find(".brand-addimages-value-items:first").click(); } var SetFenLanEvent = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".fenlan-edit").hide(); $set_div.find(".banner-show-images-previous").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.append($module_style_div.find("div:first")); }); $set_div.find(".banner-show-images-next").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.prepend($module_style_div.find("div:last")); }); $set_div.find(".fenlan-edit").find(".banner-bannerlink-pages-select").click(function() { if ($set_div.find(".banner-bannerlink-pages-select").attr("contenteditable") == "false") { if ($(this).parent().find(".banner-bannerlink-pages").is(":hidden")) { $(this).parent().find(".banner-bannerlink-pages").show(); } else { $(this).parent().find(".banner-bannerlink-pages").hide(); } } }); $set_div.find('.addimages-value-items').click(function() { var img_size_str = "建议尺寸:160*160(px) 图片大小:不超过500k 格式:jpg/gif/png"; $("#upload_img_dialog").find(".new_img_warn").text(img_size_str); _img_max = 8 - $set_div.find(".images-value-items").length; _img_dialog_data = []; _img_select_callback = function(imgs) { $.each(imgs, function(n, value) { var img_data = { url : value.url, type : 1, link : "index", big_title : "", small_title : "" } AddFenlan(img_data); }); } GetOldImgServerRequest(); $("#upload_img_dialog").show("drop"); }); $set_div.find(".fenlan-edit .enter-link") .click( function() { if ($set_div.find(".banner-bannerlink-pages-select") .attr("contenteditable") == "true") { $set_div.find(".banner-bannerlink-pages-select").focus(); } else { var num = Number($set_div.find(".images-value-items.on").attr( "data-module-banner-num")); if (_pdt_view_time_data.data.fenlan[num - 1].type == 1) { $set_div.find(".banner-bannerlink-pages-select").text(""); } $set_div.find(".banner-bannerlink-pages-select").attr( "contenteditable", "true"); $set_div.find(".banner-bannerlink-pages-select").focus(); } $set_div.find(".banner-bannerlink-pages").hide(); }); $set_div.find(".fenlan-edit").find(".banner-bannerlink-pages-select").keypress(function(e) { if (e.which == 13) { // 回车事件 $(this).blur(); } }); $set_div.find(".fenlan-edit").find(".pages-select-icon").click(function(e) { e.stopPropagation(); if ($(this).parent().find(".banner-bannerlink-pages").is(":hidden")) { $(this).parent().find(".banner-bannerlink-pages").show(); } else { $(this).parent().find(".banner-bannerlink-pages").hide(); } }); $set_div.find(".fenlan-edit").find(".banner-bannerlink-pages-select") .blur( function() { if ($set_div.find(".banner-bannerlink-pages-select") .attr("contenteditable") == "true") { $set_div.find(".banner-bannerlink-pages").hide(); var num = Number($set_div.find(".images-value-items.on").attr( "data-module-banner-num")); _pdt_view_time_data.data.fenlan[num - 1].type = 0; _pdt_view_time_data.data.fenlan[num - 1].link = $.trim($set_div.find( ".banner-bannerlink-pages-select").text()); $set_div.find(".banner-bannerlink-pages-select").text( _pdt_view_time_data.data.fenlan[num - 1].link); $set_div.find(".banner-bannerlink-pages-select").attr( "contenteditable", "false"); } }) $set_div.find(".fenlan-edit").find(".big-title").blur(function() { var num = Number($set_div.find(".images-value-items.on").attr("data-module-banner-num")); _pdt_view_time_data.data.fenlan[num - 1].big_title = $(this).val(); }) $set_div.find(".fenlan-edit").find(".small-title").blur(function() { var num = Number($set_div.find(".images-value-items.on").attr("data-module-banner-num")); _pdt_view_time_data.data.fenlan[num - 1].small_title = $(this).val(); }) $set_div.find(".banner-bannerlink-pages .add-page-items").click( function() { // 添加新页面 if (isNaN(Number(_final_data.page_count))) { _final_data.page_count = 0; } _final_data.page_count = Number(_final_data.page_count) + 1; var page_name_temp = "页面" + ConvertToChinese(_final_data.page_count); var page_id_temp = CreateGUID(); AddPage(page_id_temp, page_name_temp, 2, 1); // 增加选项 var $link_div = $set_div.find(".banner-bannerlink-pages"); var $link_html = $('<div class="bannerlink-items"></div>'); var name = page_name_temp; $link_html.text(name); $link_html.attr("data-module-link-id", page_id_temp); $link_html.unbind("click"); $link_html.click(function() { SelctFenLanLink($(this)); }); $link_div.prepend($link_html); $link_div.find('[data-module-link-id=' + page_id_temp + ']').click(); // 设置信息 var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr( "data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr( "data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data.data); module_data.data = temp; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.style = $html.find('[data-set-module-style="style"]').find( "div:first").attr("data-set-module-style"); module_data.data.name = $html.find('[data-set-module-input="name"]').val(); var error = ""; error = TextFenlan(module_data.data); if (error == "") { module_final_data.data = module_data.data; $("#saveBtn").click(); $("#saveBtn").hide(); SelectPage(page_id_temp); } else { alert(error); } }); var SetBannerLink = function() { var $link_div = $set_div.find(".banner-bannerlink-pages"); $link_div.find(".bannerlink-items").remove(); $.each($(".tvm-shop-btns").find(".tvm-shop-btns-items"), function(n, value) { var $link_html = $('<div class="bannerlink-items"></div>'); var name = $(value).find(".page-name").text(); $link_html.text(name); $link_html.attr("data-module-link-id", $(value).attr("data-page-id")); $link_html.unbind("click"); $link_html.click(function() { SelctFenLanLink($(this)); }); $link_div.append($link_html); }); $set_div.find('.writelink').remove(); } SetBannerLink(); $set_div.find(".images-value-items:first").click(); } var SetFindShopEvent = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".findshop-edit").hide(); $set_div.find('.addimages-value-items').click(function() { var img_size_str = "建议尺寸:320*210(px) 图片大小:不超过500k 格式:jpg/gif/png"; $("#upload_img_dialog").find(".new_img_warn").text(img_size_str); _img_max = 6 - $set_div.find(".images-value-items").length; _img_dialog_data = []; _img_select_callback = function(imgs) { $.each(imgs, function(n, value) { var img_data = { url : value.url, title : "", shop : [] } AddFindShop(img_data); }); } GetOldImgServerRequest(); $("#upload_img_dialog").show("drop"); }); $set_div.find(".findshop-edit").find(".findshop-category-title").blur(function() { var num = Number($set_div.find(".images-value-items.on").attr("data-module-banner-num")); _pdt_view_time_data.data.findshop[num - 1].title = $(this).val(); }) $set_div.find(".findshop-edit").find(".shops-add-items:first").click(function() { var num = Number($set_div.find(".images-value-items.on").attr("data-module-banner-num")); _shop_dialog_data = []; jQuery.extend(true, _shop_dialog_data, _pdt_view_time_data.data.findshop[num - 1].shop); InitShopDialog(); _shop_dialog_callback = SetShopData; $("#tvm-shop-select-shops-window").show(); }); $set_div.find(".images-value-items:first").click(); } var SetCateModEvent = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".banner-link-edit").hide(); $set_div.find(".banner-link-edit").find(".banner-bannerlink-pages-select").click(function() { if ($set_div.find(".banner-bannerlink-pages-select").attr("contenteditable") == "false") { if ($(this).parent().find(".banner-bannerlink-pages").is(":hidden")) { $(this).parent().find(".banner-bannerlink-pages").show(); } else { $(this).parent().find(".banner-bannerlink-pages").hide(); } } }); $set_div.find('.addimages-value-items').click(function() { $current_img = [$(this)]; var img_size_str = "建议尺寸:250*270(px) 图片大小:不超过500k 格式:jpg/gif/png"; $("#upload_img_dialog").find(".new_img_warn").text(img_size_str); _img_max = 6 - $set_div.find(".images-value-items").length; _img_dialog_data = []; _img_select_callback = function(imgs) { $.each(imgs, function(n, value) { var img_data = { url : value.url, type : 1, link : "index" } AddCate(img_data); }); } GetOldImgServerRequest(); $("#upload_img_dialog").show("drop"); }); $set_div.find(".banner-bannerlink-pages .enter-link") .click( function() { if ($set_div.find(".banner-bannerlink-pages-select") .attr("contenteditable") == "true") { $set_div.find(".banner-bannerlink-pages-select").focus(); } else { var num = Number($set_div.find(".images-value-items.on").attr( "data-module-banner-num")); if (_pdt_view_time_data.data.banners[num - 1].type == 1) { $set_div.find(".banner-bannerlink-pages-select").text(""); } $set_div.find(".banner-bannerlink-pages-select").attr( "contenteditable", "true"); $set_div.find(".banner-bannerlink-pages-select").focus(); } $set_div.find(".banner-bannerlink-pages").hide(); }); $set_div.find(".banner-link-edit").find(".banner-bannerlink-pages-select").keypress( function(e) { if (e.which == 13) { // 回车事件 $(this).blur(); } }); $set_div.find(".banner-link-edit").find(".pages-select-icon").click(function(e) { e.stopPropagation(); if ($(this).parent().find(".banner-bannerlink-pages").is(":hidden")) { $(this).parent().find(".banner-bannerlink-pages").show(); } else { $(this).parent().find(".banner-bannerlink-pages").hide(); } }); $set_div.find(".banner-link-edit").find(".banner-bannerlink-pages-select") .blur( function() { if ($set_div.find(".banner-bannerlink-pages-select") .attr("contenteditable") == "true") { $set_div.find(".banner-bannerlink-pages").hide(); var num = Number($set_div.find(".images-value-items.on").attr( "data-module-banner-num")); _pdt_view_time_data.data.banners[num - 1].type = 0; _pdt_view_time_data.data.banners[num - 1].link = $.trim($set_div.find( ".banner-bannerlink-pages-select").text()); $set_div.find(".banner-bannerlink-pages-select").text( _pdt_view_time_data.data.banners[num - 1].link); $set_div.find(".banner-bannerlink-pages-select").attr( "contenteditable", "false"); } }) $set_div.find(".banner-bannerlink-pages .add-page-items").click(function() { // 添加新页面 if (isNaN(Number(_final_data.page_count))) { _final_data.page_count = 0; } _final_data.page_count = Number(_final_data.page_count) + 1; var page_name_temp = "页面" + ConvertToChinese(_final_data.page_count); var page_id_temp = CreateGUID(); AddPage(page_id_temp, page_name_temp, 2, 1); // 增加选项 var $link_div = $set_div.find(".banner-bannerlink-pages"); var $link_html = $('<div class="bannerlink-items"></div>'); var name = page_name_temp; $link_html.text(name); $link_html.attr("data-module-link-id", page_id_temp); $link_html.unbind("click"); $link_html.click(function() { SelctBannerLink($(this)); }); $link_div.prepend($link_html); $link_div.find('[data-module-link-id=' + page_id_temp + ']').click(); // 设置信息 var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data.data); module_data.data = temp; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.name = $.trim($html.find('[data-set-module-input="name"]').val()); var error = ""; error = TextCateMod(module_data.data); if (error == "") { module_final_data.data = module_data.data; $("#saveBtn").click(); SelectPage(page_id_temp); $("#saveBtn").hide(); } else { alert(error); } }); var SetBannerLink = function() { var $link_div = $set_div.find(".banner-bannerlink-pages"); $link_div.find(".bannerlink-items").remove(); $.each($(".tvm-shop-btns").find(".tvm-shop-btns-items"), function(n, value) { var $link_html = $('<div class="bannerlink-items"></div>'); var name = $(value).find(".page-name").text(); $link_html.text(name); $link_html.attr("data-module-link-id", $(value).attr("data-page-id")); $link_html.unbind("click"); $link_html.click(function() { SelctBannerLink($(this)); }); $link_div.append($link_html); }); $set_div.find('.writelink').remove(); } SetBannerLink(); $set_div.find(".images-value-items:first").click(); } var SetCouponEvent = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find('[data-set-module-color="color"]').find(".color-items").click(function() { $(this).parent().find(".color-items").removeClass("on"); $(this).addClass("on"); }); var $coupon_div = $set_div.find(".coupons-items-addcoupons-value"); $coupon_div.find(".tvm-shop-btns-addcoupon").click(function() { jQuery.extend(true, _cop_dialog_data, _pdt_view_time_data.data.coupon); InitCouponDialog(); _cop_dialog_callback = SetCouponsData; $("#tvm-shop-coupons-window").show(); }); var SetCouponsData = function() { var $set_coupon_div = $set_div.find(".coupons-items-addcoupons-value"); $set_coupon_div.find(".coupon-value-items").remove(); _pdt_view_time_data.data.coupon = []; $.each(_cop_dialog_data, function(n, value) { var $cop_html = $('<div class="coupon-value-items one-row-show">' + '<span class="coupon-type"></span>' + '<span class="coupon-title"></span>' + '<div class="coupon-items-delete-btn">&times;</div>' + '</div>'); /* * if(value.type == "baoyou"){ $cop_html.find(".coupon-type").text("包邮") }else * if(value.type == "cash_coupon"){ $cop_html.find(".coupon-type").text("现金") }else * if(value.type == "discount_coupon"){ $cop_html.find(".coupon-type").text("折扣") } */ $cop_html.find(".coupon-type").text(value.title); $cop_html.find(".coupon-title").text(GetCouponTitle(value)); $cop_html.attr("data-dialog-cop-id", value.id); $cop_html.attr("data-dialog-cop-amount", value.amount); $cop_html.attr("data-dialog-pdt-extend", value.type_extend_value); $cop_html.attr("data-dialog-type", value.type); $cop_html.find(".coupon-items-delete-btn").click(function() { var id_temp = $(this).parent().attr("data-dialog-cop-id"); var cops = []; $.each(_pdt_view_time_data.data.coupon, function(i, cop) { if (cop.id != id_temp) { cops.push(cop); } }); _pdt_view_time_data.data.coupon = cops; $(this).parent().remove(); }); $set_coupon_div.find(".tvm-shop-btns-addcoupon").before($cop_html); _pdt_view_time_data.data.coupon.push(value); }); } } var SetActivityModEvent = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); GetActSelectOptData(); $set_div.find(".goods-show-images-previous").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.append($module_style_div.find("div:first")); }); $set_div.find(".goods-show-images-next").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.prepend($module_style_div.find("div:last")); }); $set_div.find(".activity-value-select").click(function() { if ($set_div.find(".activity-select-options").is(":hidden")) { $set_div.find(".activity-select-options").show(); } else { $set_div.find(".activity-select-options").hide(); } }); $set_div .find(".activity-goods-price em") .click( function() { if ($(this).hasClass("on")) { $(this).removeClass("on"); _pdt_view_time_data.data.group_sort = 0; } else { $(this).addClass("on"); $set_div.find(".activity-goods-profits em").removeClass("on"); _pdt_view_time_data.data.group_sort = 1; var pdt_array_temp = {}; for ( var i = 0; i < $set_div .find(".activity-goods-order .goods-order-items").length; i++) { var $value = $set_div .find(".activity-goods-order .goods-order-items:eq(" + i + ")"); var value_price = FloatAdd($value.find( ".goods-order-price-number span").text(), 0); var data_index = $value.attr("data-index"); for ( var j = i + 1; j < $set_div .find(".activity-goods-order .goods-order-items").length; j++) { var $obj = $set_div .find(".activity-goods-order .goods-order-items:eq(" + j + ")"); var obj_price = FloatAdd($obj.find( ".goods-order-price-number span").text(), 0); if (value_price < obj_price) { value_price = obj_price; data_index = $obj.attr("data-index"); } } $set_div.find( ".activity-goods-order .goods-order-items:eq(" + i + ")") .before( $set_div.find(".activity-goods-order [data-index=" + data_index + "]")); } } }); $set_div.find(".activity-goods-profits em").click(function() { if ($(this).hasClass("on")) { $(this).removeClass("on"); _pdt_view_time_data.data.group_sort = 0; } else { $(this).addClass("on"); $set_div.find(".activity-goods-price em").removeClass("on"); _pdt_view_time_data.data.group_sort = 2; } }); } var SetCateComModEvent = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".category-commodity-image-link-options").hide(); $set_div.find(".category-commodity-show-images-previous").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.append($module_style_div.find("div:first")); }); $set_div.find(".category-commodity-show-images-next").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.prepend($module_style_div.find("div:last")); }); $set_div.find(".category-commodity-image-link-txt") .click( function() { if ($set_div.find(".category-commodity-image-link-txt").attr( "contenteditable") == "false") { if ($(this).parent().find(".category-commodity-image-link-options").is( ":hidden")) { $(this).parent().find(".category-commodity-image-link-options") .show(); } else { $(this).parent().find(".category-commodity-image-link-options") .hide(); } } }); $set_div.find(".category-commodity-image-link-options .add-page-items").click( function() { // 添加新页面 if (isNaN(Number(_final_data.page_count))) { _final_data.page_count = 0; } _final_data.page_count = Number(_final_data.page_count) + 1; var page_name_temp = "页面" + ConvertToChinese(_final_data.page_count); var page_id_temp = CreateGUID(); AddPage(page_id_temp, page_name_temp, 2, 1); // 增加选项 var $link_div = $set_div.find(".category-commodity-image-link-options"); var $link_html = $('<div class="cate-com-link-items"></div>'); var name = page_name_temp; $link_html.text(name); $link_html.attr("data-module-link-id", page_id_temp); $link_html.unbind("click"); $link_html.click(function() { $set_div.find(".category-commodity-image-link-txt").text($(this).text()); $set_div.find(".category-commodity-image-link-options").hide(); _pdt_view_time_data.data.banners.type = 1; _pdt_view_time_data.data.banners.link = $(this).attr("data-module-link-id"); $set_div.find(".category-commodity-image-link-txt").attr("contenteditable", "false"); }); $link_div.prepend($link_html); $link_div.find('[data-module-link-id=' + page_id_temp + ']').click(); // 设置信息 var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr( "data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr( "data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data.data); module_data.data = temp; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.style = $html.find('[data-set-module-style="style"]').find( "div:first").attr("data-set-module-style"); var error = ""; error = TextCateComMod(module_data.data); if (error == "") { module_final_data.data = module_data.data; $("#saveBtn").click(); SelectPage(page_id_temp); $("#saveBtn").hide(); } else { alert(error); } }); $set_div.find('.category-commodity-value').find('.category-commodity-add-goods-btn').click( function() { _pdt_select_max = 2; jQuery.extend(true, _pdt_dialog_data, _pdt_view_time_data.data.pdt); InitPdtDialog(); _pdt_dialog_callback = SetCateComPdtData; $("#tvm-shop-select-goods-window").show(); }); $set_div.find('.addimages-first-btn').click(function() { var img_size_str = "建议尺寸:300*404(px) 图片大小:不超过500k 格式:jpg/gif/png"; $("#upload_img_dialog").find(".new_img_warn").text(img_size_str); _img_max = 1; _img_dialog_data = []; _img_select_callback = function(imgs) { $.each(imgs, function(n, value) { $set_div.find('.addimages-first-btn').find("img").attr("src", value.url); _pdt_view_time_data.data.banners.url = value.url; }); } GetOldImgServerRequest(); $("#upload_img_dialog").show("drop"); }); $set_div.find(".category-commodity-image-link-options .enter-link").click(function() { if ($set_div.find(".category-commodity-image-link-txt").attr("contenteditable") == "true") { $set_div.find(".category-commodity-image-link-txt").focus(); } else { if (_pdt_view_time_data.data.banners.type == 1) { $set_div.find(".category-commodity-image-link-txt").text(""); } $set_div.find(".category-commodity-image-link-txt").attr("contenteditable", "true"); $set_div.find(".category-commodity-image-link-txt").focus(); } $set_div.find(".category-commodity-image-link-options").hide(); }); $set_div.find(".category-commodity-image-link-txt").keypress(function(e) { if (e.which == 13) { // 回车事件 $(this).blur(); } }); $set_div.find(".category-commodity-image-link-txt-icon").click(function(e) { e.stopPropagation(); if ($(this).parent().find(".category-commodity-image-link-options").is(":hidden")) { $(this).parent().find(".category-commodity-image-link-options").show(); } else { $(this).parent().find(".category-commodity-image-link-options").hide(); } }); $set_div.find(".category-commodity-image-link").find(".category-commodity-image-link-txt") .blur( function() { if ($set_div.find(".category-commodity-image-link-txt").attr( "contenteditable") == "true") { $set_div.find(".category-commodity-image-link-options").hide(); var num = Number($set_div.find(".images-value-items.on").attr( "data-module-banner-num")); _pdt_view_time_data.data.banners.type = 0; _pdt_view_time_data.data.banners.link = $.trim($set_div.find( ".category-commodity-image-link-txt").text()); $set_div.find(".category-commodity-image-link-txt").text( _pdt_view_time_data.data.banners.link); $set_div.find(".category-commodity-image-link-txt").attr( "contenteditable", "false"); } }); var SetCateComLink = function() { var $link_div = $set_div.find(".category-commodity-image-link-options"); $link_div.find(".cate-com-link-items").remove(); $.each($(".tvm-shop-btns").find(".tvm-shop-btns-items"), function(n, value) { var $link_html = $('<div class="cate-com-link-items"></div>'); var name = $(value).find(".page-name").text(); $link_html.text(name); $link_html.attr("data-module-link-id", $(value).attr("data-page-id")); $link_html.unbind("click"); $link_html.click(function() { $set_div.find(".category-commodity-image-link-txt").text($(this).text()); $set_div.find(".category-commodity-image-link-options").hide(); _pdt_view_time_data.data.banners.type = 1; _pdt_view_time_data.data.banners.link = $(this).attr("data-module-link-id"); $set_div.find(".category-commodity-image-link-txt") .attr("contenteditable", "false"); }); $link_div.append($link_html); }); $set_div.find('.writelink').remove(); } SetCateComLink(); $set_div.find(".images-value-items:first").click(); var SetCateComPdtData = function() { var $set_good_div = $set_div.find(".category-commodity-value"); $set_good_div.find(".category-commodity-goods-items").remove(); $ .each( _pdt_dialog_data, function(n, value) { var $good_html = $('<div class="category-commodity-goods-items">' + '<img src="">' + '<div class="goods-add-items-saletype">原价</div>' + '<div class="goods-add-items-origprice">¥<span></span></div>' + '<div class="edit-goods"><span>选择<br/>价格<br/>体系</span><div class="delete-btn"></div></div>' + '</div>'); $good_html.find("img").attr("src", value.product_image); $good_html.attr("data-cate-pdt-id", value.product_id); if (typeof (value.prices_id) != "undefined" && value.prices_id != null && value.prices && value.prices_id in value.prices) { var data_temp = GetRuleCompute(value.unit_price, value.prices[value.prices_id]); $good_html.find(".goods-add-items-saletype").text( value.prices[value.prices_id].price_title || value.prices[value.prices_id].title); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(data_temp.price)); } else { $good_html.find(".goods-add-items-saletype").text("原价"); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(value.unit_price)); } $good_html.find(".delete-btn").click(function() { var pdt_id = $(this).parent().parent().attr("data-cate-pdt-id"); var temp = []; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id != pdt_id) { temp.push(value); } }); _pdt_view_time_data.data.pdt = temp; $(this).parent().parent().remove(); }); $good_html.click(function() { var pdt_id = $(this).attr("data-cate-pdt-id"); var pdt_temp = {}; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id == pdt_id) { pdt_temp = value; } }); var prices_id = null; if (typeof (pdt_temp.prices_id) != "undefined") { prices_id = pdt_temp.prices_id; } if (typeof (pdt_temp.prices) != "undefined") { showPrices($set_good_div.parent(), pdt_temp.prices, prices_id, value.unit_price, function(obj) { if (obj != null) { var data_temp = GetRuleCompute( value.unit_price, obj); $good_html.find(".goods-add-items-saletype") .text(obj.price_title || obj.title); $good_html.find( ".goods-add-items-origprice span") .text(PaddingZero(data_temp.price)); pdt_temp.prices_id = obj.id; } else { $good_html.find(".goods-add-items-saletype") .text("原价"); $good_html.find( ".goods-add-items-origprice span") .text(PaddingZero(value.unit_price)); pdt_temp.prices_id = null; } }); } }); $set_good_div.append($good_html); }); if (_pdt_dialog_data.length == 0) { _pdt_view_time_data.data.pdt = []; } else { var temp_data = []; $.each(_pdt_dialog_data, function(n, value) { temp_data.push(value); }); _pdt_view_time_data.data.pdt = temp_data; } } } var SetBannerModAttr = function(module) { SetDefFillAttr(module); var temp = {}; _pdt_view_time_data = {}; jQuery.extend(true, _pdt_view_time_data, module); jQuery.extend(true, temp, _pdt_view_time_data); var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".images-value-items").remove(); $set_div.find('.banner-imageheight-select').val(module.data.height); $set_div.find('.banner-img-height').text(Number(module.data.height) * 2); _pdt_view_time_data.data.banners = []; $.each(temp.data.banners, function(n, value) { AddBanner(value); }); } var SetBrandModAttr = function(module) { SetDefFillAttr(module); var temp = {}; _pdt_view_time_data = {}; jQuery.extend(true, _pdt_view_time_data, module); jQuery.extend(true, temp, _pdt_view_time_data); var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".brand-addimages-value-items").remove(); _pdt_view_time_data.data.brands = []; $.each(temp.data.brands, function(n, value) { AddBrand(value); }); $set_div.find(".brand-value img").attr("src", _pdt_view_time_data.data.brand_imgs); $set_div.find(".brand-category-show-number input").val(_pdt_view_time_data.data.brands_view); } var SetFindShopAttr = function(module) { SetDefFillAttr(module); var temp = {}; _pdt_view_time_data = {}; jQuery.extend(true, _pdt_view_time_data, module); jQuery.extend(true, temp, _pdt_view_time_data); var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".images-value-items").remove(); _pdt_view_time_data.data.findshop = []; $.each(temp.data.findshop, function(n, value) { AddFindShop(value); }); } var SetFenLanAttr = function(module) { SetDefFillAttr(module); var temp = {}; _pdt_view_time_data = {}; jQuery.extend(true, _pdt_view_time_data, module); jQuery.extend(true, temp, _pdt_view_time_data); var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".images-value-items").remove(); _pdt_view_time_data.data.fenlan = []; $.each(temp.data.fenlan, function(n, value) { AddFenlan(value); }); } var SetCateModAttr = function(module) { SetDefFillAttr(module); var temp = {}; _pdt_view_time_data = {}; jQuery.extend(true, _pdt_view_time_data, module); jQuery.extend(true, temp, _pdt_view_time_data); var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".images-value-items").remove(); _pdt_view_time_data.data.banners = []; $.each(temp.data.banners, function(n, value) { AddCate(value); }); } var SetCouponAttr = function(module) { SetDefFillAttr(module); _pdt_view_time_data = {}; jQuery.extend(true, _pdt_view_time_data, module); var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var $coupon_div = $set_div.find(".coupons-items-addcoupons-value"); $coupon_div.remove(".coupon-value-items"); $.each(_pdt_view_time_data.data.coupon, function(n, value) { var $cop_html = $('<div class="coupon-value-items one-row-show">' + '<span class="coupon-type"></span>' + '<span class="coupon-title"></span>' + '<div class="coupon-items-delete-btn">&times;</div>' + '</div>'); /* * if(value.type == "baoyou"){ $cop_html.find(".coupon-type").text("包邮") }else if(value.type == * "cash_coupon"){ $cop_html.find(".coupon-type").text("现金") }else if(value.type == * "discount_coupon"){ $cop_html.find(".coupon-type").text("折扣") } */ $cop_html.find(".coupon-type").text(value.title); $cop_html.find(".coupon-title").text(GetCouponTitle(value)); $cop_html.attr("data-dialog-cop-id", value.id); $cop_html.attr("data-dialog-cop-amount", value.amount); $cop_html.attr("data-dialog-pdt-extend", value.type_extend_value); $cop_html.attr("data-dialog-type", value.type); $cop_html.find(".coupon-items-delete-btn").click(function() { var id_temp = $(this).parent().attr("data-dialog-cop-id"); var cops = []; $.each(_pdt_view_time_data.data.coupon, function(i, cop) { if (cop.id != id_temp) { cops.push(cop); } }); _pdt_view_time_data.data.coupon = cops; $(this).parent().remove(); }); $coupon_div.find(".tvm-shop-btns-addcoupon").before($cop_html); }); } var SetActivityModAttr = function(module) { SetDefFillAttr(module); _pdt_view_time_data = {}; jQuery.extend(true, _pdt_view_time_data, module); var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); if (_pdt_view_time_data.data.group_sort == 1) { $set_div.find(".activity-goods-price em").addClass("on"); $set_div.find(".activity-goods-profits em").removeClass("on"); } else if (_pdt_view_time_data.data.group_sort == 2) { $set_div.find(".activity-goods-price em").removeClass("on"); $set_div.find(".activity-goods-profits em").addClass("on"); } else if (_pdt_view_time_data.data.group_sort == 0) { $set_div.find(".activity-goods-price em").removeClass("on"); $set_div.find(".activity-goods-profits em").removeClass("on"); } $set_div.find('div[data-act-div="pdt-view-num"]').hide(); $set_div.find('div[data-act-div="pdt-view-sort"]').hide(); $set_div.find('div[data-act-div="pdt-view-list"]').hide(); if (_pdt_view_time_data.data.act_type == 2) { $set_div.find(".activity-select-div").text("限时购"); $set_div.find(".activity-value").find("[data-act-type='flash']").show(); $set_div.find(".activity-value").find("[data-act-type='group']").hide(); $set_div.find('div[data-act-div="pdt-third"]').hide(); $set_div.find('.activity-type-parent').show(); } else if (_pdt_view_time_data.data.act_type == 3) { $set_div.find(".activity-value").find("[data-act-type='flash']").hide(); $set_div.find(".activity-value").find("[data-act-type='group']").show(); $set_div.find('.activity-type-parent').show(); $set_div.find('div[data-act-div="pdt-view-num"]').show(); $set_div.find('div[data-act-div="pdt-view-sort"]').show(); $set_div.find('div[data-act-div="pdt-view-list"]').show(); $set_div.find('div[data-act-div="pdt-third"]').hide(); if (typeof (_final_data.act_dict[_pdt_view_time_data.data.act_type_id]) != "undefined") { var act_temp = _final_data.act_dict[_pdt_view_time_data.data.act_type_id].data; $set_div.find(".activity-select-div").text(act_temp.name); _pdt_view_time_data.data.act_type_id = act_temp; var act_pdt_temp = []; act_pdt_temp = GetActPdtFromDict(_pdt_view_time_data.data.group_pdt); SetActGroupPdtData(act_pdt_temp); _pdt_view_time_data.data.group_pdt = act_pdt_temp; } } else if (_pdt_view_time_data.data.act_type == 4) { $set_div.find(".activity-select-div").text("限量抢购"); $set_div.find(".activity-value").find(".activity-limit").show(); $set_div.find(".activity-value").find("[data-act-type='group']").hide(); $set_div.find(".activity-value").find("[data-act-type='flash']").hide(); $set_div.find('div[data-act-div="pdt-view-num"]').show(); $set_div.find('div[data-act-div="pdt-view-sort"]').hide(); $set_div.find('div[data-act-div="pdt-view-list"]').hide(); $set_div.find('div[data-act-div="pdt-first"]').hide(); $set_div.find('div[data-act-div="pdt-second"]').hide(); $set_div.find('div[data-act-div="pdt-third"]').show(); $set_div.find('.activity-type-parent').show(); } else { $set_div.find('.activity-type-parent').hide(); } } var SetCateComModAttr = function(module) { SetDefFillAttr(module); _pdt_view_time_data = {}; jQuery.extend(true, _pdt_view_time_data, module); var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var pdts_temp = GetPdtFromDict(module.data.pdt); _pdt_view_time_data.data.pdt = pdts_temp; var $set_good_div = $html.find(".category-commodity-value"); $set_good_div.find(".category-commodity-goods-items").remove(); $ .each( pdts_temp, function(n, value) { var $good_html = $('<div class="category-commodity-goods-items">' + '<img src="">' + '<div class="goods-add-items-saletype">原价</div>' + '<div class="goods-add-items-origprice">¥<span></span></div>' + '<div class="edit-goods"><span>选择<br/>价格<br/>体系</span><div class="delete-btn"></div></div>' + '</div>'); $good_html.find("img").attr("src", value.product_image); $good_html.attr("data-cate-pdt-id", value.product_id); $good_html.attr("data-cate-num", n); if (typeof (value.prices_id) != "undefined" && value.prices_id != null && value.prices && value.prices_id in value.prices) { var data_temp = GetRuleCompute(value.unit_price, value.prices[value.prices_id]); $good_html.find(".goods-add-items-saletype").text( value.prices[value.prices_id].price_title || value.prices[value.prices_id].title); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(data_temp.price)); } else { $good_html.find(".goods-add-items-saletype").text("原价"); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(value.unit_price)); } $good_html.find(".delete-btn").click(function() { var pdt_id = $(this).parent().parent().attr("data-cate-pdt-id"); var temp = []; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id != pdt_id) { temp.push(value); } }); _pdt_view_time_data.data.pdt = temp; $(this).parent().parent().remove(); }); $good_html.click(function() { var pdt_id = $(this).attr("data-cate-pdt-id"); var pdt_temp = {}; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id == pdt_id) { pdt_temp = value; } }); var prices_id = null; if (typeof (pdt_temp.prices_id) != "undefined") { prices_id = pdt_temp.prices_id; } if (typeof (pdt_temp.prices) != "undefined") { showPrices($set_good_div.parent(), pdt_temp.prices, prices_id, value.unit_price, function(obj) { if (obj != null) { var data_temp = GetRuleCompute(value.unit_price, obj); $good_html.find(".goods-add-items-saletype").text( obj.price_title || obj.title); $good_html.find(".goods-add-items-origprice span") .text(PaddingZero(data_temp.price)); pdt_temp.prices_id = obj.id; } else { $good_html.find(".goods-add-items-saletype").text( "原价"); $good_html.find(".goods-add-items-origprice span") .text(PaddingZero(value.unit_price)); pdt_temp.prices_id = null; } }); } }); $set_good_div.append($good_html); }); $html.find(".category-commodity-addimages-value").find("img").attr("src", _pdt_view_time_data.data.banners.url); if (_pdt_view_time_data.data.banners.type == 0) { $html.find(".category-commodity-image-link-txt").attr("contenteditable", "false"); $html.find(".category-commodity-image-link-txt").focus(); $html.find(".category-commodity-image-link-txt") .text(_pdt_view_time_data.data.banners.link); } else { $html.find(".category-commodity-image-link-txt").attr("contenteditable", "false"); var id_temp = _pdt_view_time_data.data.banners.link; var name = $(".tvm-shop-btns-addnewbtns").find( '.tvm-shop-btns-items[data-page-id=' + id_temp + ']'); name = name.find("div").text(); $html.find(".category-commodity-image-link-txt").text(name); } } /*---------------banner-----------------------------*/ var AddBanner = function(img_data) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var $addbtn_div = $set_div.find(".addimages-value-items"); var num = $addbtn_div.parent().find(".images-value-items").length + 1; var img_name = ConvertToChinese(num); if (num == 4) { $addbtn_div.hide(); } var $img_html = $('<div class="images-value-items">' + '<img src="" />' + '<div class="addimages-name one-row-show">' + img_name + '</div>' + '<div class="delete-btn"></div>' + '</div>'); $img_html.find("img").attr("src", img_data.url); $img_html.attr("data-module-banner-num", num); $img_html.find(".delete-btn").click(function() { DelBanner($(this)); }); $img_html.click(function() { SelectBanner($(this)); }); $addbtn_div.before($img_html); _pdt_view_time_data.data.banners.push(img_data); if ($set_div.find(".banner-link-edit").is(":hidden")) { $addbtn_div.parent().find(".images-value-items:first").click(); } } var AddBrand = function(img_data) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var $brands_div = $set_div.find(".brand-addimages-value"); var num = $brands_div.find(".brand-addimages-value-items").length + 1; var img_name = ConvertToChinese(num); // if(num == 4){ // $addbtn_div.hide(); // } var $img_html = $('<div class="brand-addimages-value-items">' + '<img src="" />' + '<div class="addimages-name one-row-show">' + img_name + '</div>' + '<div class="delete-btn"></div>' + '</div>'); $img_html.find("img").attr("src", img_data.url); $img_html.attr("data-module-banner-num", num); $img_html.find(".delete-btn").click(function() { DelBrand($(this)); }); $img_html.click(function() { SelectBrand($(this)); }); $brands_div.append($img_html); _pdt_view_time_data.data.brands.push(img_data); if ($set_div.find(".brand-link-edit").is(":hidden")) { $brands_div.find(".brand-addimages-value-items:first").click(); } } var AddCate = function(img_data) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var $addbtn_div = $set_div.find(".addimages-value-items"); var num = $addbtn_div.parent().find(".images-value-items").length + 1; var img_name = ConvertToChinese(num); if (num == 6) { $addbtn_div.hide(); } var $img_html = $('<div class="images-value-items category-image">' + '<img src="" />' + '<div class="addimages-name one-row-show">' + img_name + '</div>' + '<div class="delete-btn"></div>' + '</div>'); $img_html.find("img").attr("src", img_data.url); $img_html.attr("data-module-banner-num", num); $img_html.find(".delete-btn").click(function() { DelBanner($(this)); }); $img_html.click(function() { SelectBanner($(this)); }); $addbtn_div.before($img_html); _pdt_view_time_data.data.banners.push(img_data); if ($set_div.find(".banner-link-edit").is(":hidden")) { $addbtn_div.parent().find(".images-value-items:first").click(); } } var AddFenlan = function(img_data) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var $addbtn_div = $set_div.find(".addimages-value-items"); var num = $addbtn_div.parent().find(".images-value-items").length + 1; var img_name = ConvertToChinese(num); if (num == 8) { $addbtn_div.hide(); } var $img_html = $('<div class="images-value-items fenlan-image">' + '<img src="" />' + '<div class="addimages-name one-row-show">' + img_name + '</div>' + '<div class="delete-btn"></div>' + '</div>'); $img_html.find("img").attr("src", img_data.url); $img_html.attr("data-module-banner-num", num); $img_html.find(".delete-btn").click(function() { DelFenlan($(this)); }); $img_html.click(function() { SelectFenlan($(this)); }); $addbtn_div.before($img_html); _pdt_view_time_data.data.fenlan.push(img_data); if ($set_div.find(".fenlan-edit").is(":hidden")) { $addbtn_div.parent().find(".images-value-items:first").click(); } } var AddFindShop = function(img_data) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var $addbtn_div = $set_div.find(".addimages-value-items"); var num = $addbtn_div.parent().find(".images-value-items").length + 1; var img_name = ConvertToChinese(num); if (num == 6) { $addbtn_div.hide(); } var $img_html = $('<div class="images-value-items findshop-image">' + '<img src="" />' + '<div class="addimages-name one-row-show">' + img_name + '</div>' + '<div class="delete-btn"></div>' + '</div>'); $img_html.find("img").attr("src", img_data.url); $img_html.attr("data-module-banner-num", num); $img_html.find(".delete-btn").click(function() { DelFindShop($(this)); }); $img_html.click(function() { SelectFindShop($(this)); }); $addbtn_div.before($img_html); _pdt_view_time_data.data.findshop.push(img_data); if ($set_div.find(".findshop-edit").is(":hidden")) { $addbtn_div.parent().find(".images-value-items:first").click(); } } var SelectFenlan = function($el) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $el.parent().find(".images-value-items").removeClass("on"); $el.addClass("on"); $set_div.find(".fenlan-edit").show(); var num = Number($el.attr("data-module-banner-num")); $set_div.find(".banner-img-name").text($el.find(".addimages-name").text()); $set_div.find(".fenlan-edit").find("input.small-title").val( _pdt_view_time_data.data.fenlan[num - 1].small_title); $set_div.find(".fenlan-edit").find("input.big-title").val( _pdt_view_time_data.data.fenlan[num - 1].big_title); if (_pdt_view_time_data.data.fenlan[num - 1].type == 0) { $set_div.find(".banner-bannerlink-pages-select").attr("contenteditable", "false"); $set_div.find(".banner-bannerlink-pages-select").focus(); $set_div.find(".banner-bannerlink-pages-select").text( _pdt_view_time_data.data.fenlan[num - 1].link); } else { $set_div.find(".banner-bannerlink-pages-select").attr("contenteditable", "false"); var id_temp = _pdt_view_time_data.data.fenlan[num - 1].link; var name = $set_div.find(".banner-bannerlink-pages").find( '[data-module-link-id=' + id_temp + ']').text(); $set_div.find(".banner-bannerlink-pages-select").text(name); } } var SelectBanner = function($el) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $el.parent().find(".images-value-items").removeClass("on"); $el.addClass("on"); $set_div.find(".banner-link-edit").show(); var num = Number($el.attr("data-module-banner-num")); $set_div.find(".banner-img-name").text($el.find(".addimages-name").text()); if (_pdt_view_time_data.data.banners[num - 1].type == 0) { $set_div.find(".banner-bannerlink-pages-select").attr("contenteditable", "false"); $set_div.find(".banner-bannerlink-pages-select").focus(); $set_div.find(".banner-bannerlink-pages-select").text( _pdt_view_time_data.data.banners[num - 1].link); } else { $set_div.find(".banner-bannerlink-pages-select").attr("contenteditable", "false"); var id_temp = _pdt_view_time_data.data.banners[num - 1].link; var name = $set_div.find(".banner-bannerlink-pages").find( '[data-module-link-id=' + id_temp + ']').text(); $set_div.find(".banner-bannerlink-pages-select").text(name); } } var SelectBrand = function($el) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $el.parent().find(".brand-addimages-value-items").removeClass("on"); $el.addClass("on"); $set_div.find(".brand-link-edit").show(); var num = Number($el.attr("data-module-banner-num")); $set_div.find(".banner-img-name").text($el.find(".addimages-name").text()); if (_pdt_view_time_data.data.brands[num - 1].type == 0) { $set_div.find(".banner-bannerlink-pages-select").attr("contenteditable", "false"); $set_div.find(".banner-bannerlink-pages-select").focus(); $set_div.find(".banner-bannerlink-pages-select").text( _pdt_view_time_data.data.brands[num - 1].link); } else { $set_div.find(".banner-bannerlink-pages-select").attr("contenteditable", "false"); var id_temp = _pdt_view_time_data.data.brands[num - 1].link; var name = $set_div.find(".banner-bannerlink-pages").find( '[data-module-link-id=' + id_temp + ']').text(); $set_div.find(".banner-bannerlink-pages-select").text(name); } } var SelectFindShop = function($el) { if (!$el.hasClass("on")) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $el.parent().find(".images-value-items").removeClass("on"); $el.addClass("on"); var num = Number($el.attr("data-module-banner-num")); $set_div.find(".findshop-edit").find(".findshop-category-title").val( _pdt_view_time_data.data.findshop[num - 1].title); // 显示店铺 var copy_data = {}; jQuery.extend(true, copy_data, _pdt_view_time_data.data.findshop[num - 1]); _shop_dialog_data = copy_data.shop; SetShopData(); $set_div.find(".findshop-edit").show(); $set_div.find(".findshop-img-name").text( $set_div.find(".images-value-items.on").find(".addimages-name").text() + "的"); } } var SetShopData = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var $set_shop_div = $set_div.find(".goods-overflowx-add-value"); $set_shop_div.find(".shops-view-items").remove(); $.each(_shop_dialog_data, function(n, value) { var $shop_html = $('<div class="shops-view-items shops-add-items">' + '<div class="findshop-shop-image">' + '<img src="" />' + '</div>' + '<div class="findshop-shop-name one-row-show">店铺名字</div>' + '<div class="edit-goods">' + '<div class="delete-btn"></div>' + '</div>' + '</div>'); if (value.logo) { $shop_html.find("img").attr("src", value.logo); } else { $shop_html.find(".findshop-shop-image").append( '<div class="shoplist-shop-logo-default"></div>'); $shop_html.find("img").remove(); } $shop_html.attr("data-cate-shop-id", value.id); $shop_html.find(".findshop-shop-name").text(value.name); $shop_html.find(".delete-btn").click( function() { var num = Number($set_div.find(".images-value-items.on").attr( "data-module-banner-num")); var shop_id = $(this).parent().parent().attr("data-cate-shop-id"); var temp = []; $.each(_pdt_view_time_data.data.findshop[num - 1].shop, function(n, value) { if (value.id != shop_id) { temp.push(value); } }); _pdt_view_time_data.data.findshop[num - 1].shop = temp; $(this).parent().parent().remove(); }); $set_shop_div.append($shop_html); }); var num = Number($set_div.find(".images-value-items.on").attr("data-module-banner-num")); if (_shop_dialog_data.length == 0) { _pdt_view_time_data.data.findshop[num - 1].shop = []; } else { var temp_data = []; $.each(_shop_dialog_data, function(n, value) { temp_data.push(value); }); _pdt_view_time_data.data.findshop[num - 1].shop = temp_data; } } var SelctBannerLink = function($el) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".banner-bannerlink-pages-select").text($el.text()); $set_div.find(".banner-bannerlink-pages").hide();; var num = Number($set_div.find(".images-value-items.on").attr("data-module-banner-num")); _pdt_view_time_data.data.banners[num - 1].type = 1; _pdt_view_time_data.data.banners[num - 1].link = $el.attr("data-module-link-id"); $set_div.find(".banner-bannerlink-pages-select").attr("contenteditable", "false"); } var SelctBrandLink = function($el) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".banner-bannerlink-pages-select").text($el.text()); $set_div.find(".banner-bannerlink-pages").hide();; var num = Number($set_div.find(".brand-addimages-value-items.on") .attr("data-module-banner-num")); _pdt_view_time_data.data.brands[num - 1].type = 1; _pdt_view_time_data.data.brands[num - 1].link = $el.attr("data-module-link-id"); $set_div.find(".banner-bannerlink-pages-select").attr("contenteditable", "false"); } var SelctFenLanLink = function($el) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".banner-bannerlink-pages-select").text($el.text()); $set_div.find(".banner-bannerlink-pages").hide(); var num = Number($set_div.find(".images-value-items.on").attr("data-module-banner-num")); _pdt_view_time_data.data.fenlan[num - 1].type = 1; _pdt_view_time_data.data.fenlan[num - 1].link = $el.attr("data-module-link-id"); $set_div.find(".banner-bannerlink-pages-select").attr("contenteditable", "false"); } var DelBanner = function($el) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var num = Number($el.parent().attr("data-module-banner-num")); var banners_temp = []; $.each(_pdt_view_time_data.data.banners, function(n, value) { if (n != num - 1) { banners_temp.push(value); } }); _pdt_view_time_data.data.banners = banners_temp; var hide_flg = false; if ($el.parent().hasClass("on")) { hide_flg = true; } $el.parent().remove(); $.each($set_div.find(".images-value-items"), function(n, value) { $(value).find(".addimages-name").text(ConvertToChinese(n + 1)); $(value).attr("data-module-banner-num", n + 1); }); var $addbtn_div = $set_div.find(".addimages-value-items"); $addbtn_div.show(); if (hide_flg) { $set_div.find(".banner-link-edit").hide(); } else { $set_div.find(".banner-img-name").text( $set_div.find(".images-value-items.on").find(".addimages-name").text()); } } var DelBrand = function($el) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var num = Number($el.parent().attr("data-module-banner-num")); var brands_temp = []; $.each(_pdt_view_time_data.data.brands, function(n, value) { if (n != num - 1) { brands_temp.push(value); } }); _pdt_view_time_data.data.brands = brands_temp; var hide_flg = false; if ($el.parent().hasClass("on")) { hide_flg = true; } $el.parent().remove(); $.each($set_div.find(".brand-addimages-value-items"), function(n, value) { $(value).find(".addimages-name").text(ConvertToChinese(n + 1)); $(value).attr("data-module-banner-num", n + 1); }); if (hide_flg) { $set_div.find(".brand-link-edit").hide(); } else { $set_div.find(".banner-img-name").text( $set_div.find(".brand-addimages-value-items.on").find(".addimages-name").text()); } } var DelFenlan = function($el) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var num = Number($el.parent().attr("data-module-banner-num")); var fenlan_temp = []; $.each(_pdt_view_time_data.data.fenlan, function(n, value) { if (n != num - 1) { fenlan_temp.push(value); } }); _pdt_view_time_data.data.fenlan = fenlan_temp; var hide_flg = false; if ($el.parent().hasClass("on")) { hide_flg = true; } $el.parent().remove(); $.each($set_div.find(".images-value-items"), function(n, value) { $(value).find(".addimages-name").text(ConvertToChinese(n + 1)); $(value).attr("data-module-banner-num", n + 1); }); var $addbtn_div = $set_div.find(".addimages-value-items"); $addbtn_div.show(); if (hide_flg) { $set_div.find(".fenlan-edit").hide(); } else { $set_div.find(".banner-img-name").text( $set_div.find(".images-value-items.on").find(".addimages-name").text()); } } var DelFindShop = function($el) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var num = Number($el.parent().attr("data-module-banner-num")); var findshop_temp = []; $.each(_pdt_view_time_data.data.findshop, function(n, value) { if (n != num - 1) { findshop_temp.push(value); } }); _pdt_view_time_data.data.findshop = findshop_temp; var hide_flg = false; if ($el.parent().hasClass("on")) { hide_flg = true; } $el.parent().remove(); $.each($set_div.find(".images-value-items"), function(n, value) { $(value).find(".addimages-name").text(ConvertToChinese(n + 1)); $(value).attr("data-module-banner-num", n + 1); }); var $addbtn_div = $set_div.find(".addimages-value-items"); $addbtn_div.show(); if (hide_flg) { $set_div.find(".findshop-edit").hide(); } else { $set_div.find(".findshop-img-name").text( $set_div.find(".images-value-items.on").find(".addimages-name").text() + "的"); } } /* end------------banner--------------------------- */ /*---------------coupon----------------------------*/ var GetCouponTitle = function(coupon) { var title = ""; if (coupon.type == "baoyou") { if (coupon.type_extend_value == 0) { title = "全场包邮"; } else { title = "满" + coupon.type_extend_value + "包邮"; } } else if (coupon.type == "cash_coupon") { if (coupon.type_extend_value == 0) { title = "减" + coupon.amount; } else { title = "满" + coupon.type_extend_value + "减" + coupon.amount; } } else if (coupon.type == "discount_coupon") { if (coupon.type_extend_value == 0) { title = coupon.amount + "折"; } else { title = "满" + coupon.type_extend_value + " " + coupon.amount + "折"; } } return title; } /* end------------coupon---------------------------- */ var SetPdtModAttr = function(module) { SetDefFillAttr(module); _pdt_view_time_data = {}; jQuery.extend(true, _pdt_view_time_data, module); var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var pdts_temp = GetPdtFromDict(module.data.pdt); _pdt_view_time_data.data.pdt = pdts_temp; var $set_good_div = $html.find(".goods-add-value"); $set_good_div.find(".goods-view-items").remove(); $set_good_div.find(".tvm-shop-setModule-goods-items input").val(module.data.pdt_view); $ .each( pdts_temp, function(n, value) { var $good_html = $('<div class="goods-add-items goods-view-items">' + '<img src="">' + '<div class="goods-add-items-saletype">原价</div>' + '<div class="goods-add-items-origprice">¥<span>200</span></div>' + '<div class="edit-goods"><span>选择<br/>价格<br/>体系</span><div class="delete-btn"></div></div>' + '</div>'); $good_html.find("img").attr("src", value.product_image); $good_html.attr("data-cate-pdt-id", value.product_id); $good_html.attr("data-cate-num", n); if (typeof (value.prices_id) != "undefined" && value.prices_id != null && value.prices && value.prices_id in value.prices) { var data_temp = GetRuleCompute(value.unit_price, value.prices[value.prices_id]); $good_html.find(".goods-add-items-saletype").text( value.prices[value.prices_id].price_title || value.prices[value.prices_id].title); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(data_temp.price)); } else { $good_html.find(".goods-add-items-saletype").text("原价"); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(value.unit_price)); } $good_html.find(".delete-btn").click(function() { var pdt_id = $(this).parent().parent().attr("data-cate-pdt-id"); var temp = []; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id != pdt_id) { temp.push(value); } }); _pdt_view_time_data.data.pdt = temp; $(this).parent().parent().remove(); }); $good_html.click(function() { var pdt_id = $(this).attr("data-cate-pdt-id"); var pdt_temp = {}; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id == pdt_id) { pdt_temp = value; } }); var prices_id = null; if (typeof (pdt_temp.prices_id) != "undefined") { prices_id = pdt_temp.prices_id; } if (typeof (pdt_temp.prices) != "undefined") { showPrices($set_good_div.parent(), pdt_temp.prices, prices_id, value.unit_price, function(obj) { if (obj != null) { var data_temp = GetRuleCompute(value.unit_price, obj); $good_html.find(".goods-add-items-saletype").text( obj.price_title || obj.title); $good_html.find(".goods-add-items-origprice span") .text(PaddingZero(data_temp.price)); pdt_temp.prices_id = obj.id; } else { $good_html.find(".goods-add-items-saletype").text( "原价"); $good_html.find(".goods-add-items-origprice span") .text(PaddingZero(value.unit_price)); pdt_temp.prices_id = null; } }); } }); $set_good_div.append($good_html); }); } var SetSeckillAttr = function(module) { SetDefFillAttr(module); _pdt_view_time_data = {}; jQuery.extend(true, _pdt_view_time_data, module); var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var pdts_temp = GetPdtFromDict(module.data.pdt); _pdt_view_time_data.data.pdt = pdts_temp; var $set_good_div = $html.find(".goods-overflowx-add-value"); $set_good_div.find(".goods-view-items").remove(); $html.find(".secondskill-goods-show-number input").val(module.data.pdt_view); $html.find("input.secondskill-date-txt").val(DateToChinese(module.data.seckill_date)); $html.find("input.times-start").val(TimeToChinese(module.data.seckill_begin_time, 0)); $html.find("input.times-end").val(TimeToChinese(module.data.seckill_end_time, 0)); $ .each( pdts_temp, function(n, value) { var $good_html = $('<div class="goods-add-items goods-view-items">' + '<img src="">' + '<div class="goods-add-items-saletype">原价</div>' + '<div class="goods-add-items-origprice">¥<span>200</span></div>' + '<div class="edit-goods"><span>选择<br/>价格<br/>体系</span><div class="delete-btn"></div></div>' + '</div>'); $good_html.find("img").attr("src", value.product_image); $good_html.attr("data-cate-pdt-id", value.product_id); $good_html.attr("data-cate-num", n); if (typeof (value.prices_id) != "undefined" && value.prices_id != null && value.prices && value.prices_id in value.prices) { var data_temp = GetRuleCompute(value.unit_price, value.prices[value.prices_id]); $good_html.find(".goods-add-items-saletype").text( value.prices[value.prices_id].price_title || value.prices[value.prices_id].title); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(data_temp.price)); } else { $good_html.find(".goods-add-items-saletype").text("原价"); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(value.unit_price)); } $good_html.find(".delete-btn").click(function() { var pdt_id = $(this).parent().parent().attr("data-cate-pdt-id"); var temp = []; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id != pdt_id) { temp.push(value); } }); _pdt_view_time_data.data.pdt = temp; $(this).parent().parent().remove(); }); $good_html.click(function() { var pdt_id = $(this).attr("data-cate-pdt-id"); var pdt_temp = {}; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id == pdt_id) { pdt_temp = value; } }); var prices_id = null; if (typeof (pdt_temp.prices_id) != "undefined") { prices_id = pdt_temp.prices_id; } if (typeof (pdt_temp.prices) != "undefined") { showPrices($set_good_div.parent(), pdt_temp.prices, prices_id, value.unit_price, function(obj) { if (obj != null) { var data_temp = GetRuleCompute(value.unit_price, obj); $good_html.find(".goods-add-items-saletype").text( obj.price_title || obj.title); $good_html.find(".goods-add-items-origprice span") .text(PaddingZero(data_temp.price)); pdt_temp.prices_id = obj.id; } else { $good_html.find(".goods-add-items-saletype").text( "原价"); $good_html.find(".goods-add-items-origprice span") .text(PaddingZero(value.unit_price)); pdt_temp.prices_id = null; } }); } }); $set_good_div.append($good_html); }); } var SetGoodOverFlowAttr = function(module) { SetDefFillAttr(module); _pdt_view_time_data = {}; jQuery.extend(true, _pdt_view_time_data, module); var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var pdts_temp = GetPdtFromDict(module.data.pdt); _pdt_view_time_data.data.pdt = pdts_temp; var $set_good_div = $html.find(".goods-overflowx-add-value"); $set_good_div.find(".goods-view-items").remove(); $set_good_div.find(".tvm-shop-setModule-goods-items input").val(module.data.pdt_view); $ .each( pdts_temp, function(n, value) { var $good_html = $('<div class="goods-add-items goods-view-items">' + '<img src="">' + '<div class="goods-add-items-saletype">原价</div>' + '<div class="goods-add-items-origprice">¥<span>200</span></div>' + '<div class="edit-goods"><span>选择<br/>价格<br/>体系</span><div class="delete-btn"></div></div>' + '</div>'); $good_html.find("img").attr("src", value.product_image); $good_html.attr("data-cate-pdt-id", value.product_id); $good_html.attr("data-cate-num", n); if (typeof (value.prices_id) != "undefined" && value.prices_id != null && value.prices && value.prices_id in value.prices) { var data_temp = GetRuleCompute(value.unit_price, value.prices[value.prices_id]); $good_html.find(".goods-add-items-saletype").text( value.prices[value.prices_id].price_title || value.prices[value.prices_id].title); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(data_temp.price)); } else { $good_html.find(".goods-add-items-saletype").text("原价"); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(value.unit_price)); } $good_html.find(".delete-btn").click(function() { var pdt_id = $(this).parent().parent().attr("data-cate-pdt-id"); var temp = []; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id != pdt_id) { temp.push(value); } }); _pdt_view_time_data.data.pdt = temp; $(this).parent().parent().remove(); }); $good_html.click(function() { var pdt_id = $(this).attr("data-cate-pdt-id"); var pdt_temp = {}; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id == pdt_id) { pdt_temp = value; } }); var prices_id = null; if (typeof (pdt_temp.prices_id) != "undefined") { prices_id = pdt_temp.prices_id; } if (typeof (pdt_temp.prices) != "undefined") { showPrices($set_good_div.parent(), pdt_temp.prices, prices_id, value.unit_price, function(obj) { if (obj != null) { var data_temp = GetRuleCompute(value.unit_price, obj); $good_html.find(".goods-add-items-saletype").text( obj.price_title || obj.title); $good_html.find(".goods-add-items-origprice span") .text(PaddingZero(data_temp.price)); pdt_temp.prices_id = obj.id; } else { $good_html.find(".goods-add-items-saletype").text( "原价"); $good_html.find(".goods-add-items-origprice span") .text(PaddingZero(value.unit_price)); pdt_temp.prices_id = null; } }); } }); $set_good_div.append($good_html); }); } var SetPdtModEvent = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".goods-show-images-previous").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.append($module_style_div.find("div:first")); }); $set_div.find(".goods-show-images-next").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.prepend($module_style_div.find("div:last")); }); $set_div.find('[data-set-module-check="shop_cart_flg"]').click(function() { if ($(this).hasClass("all-icon-checked")) { $(this).removeClass("all-icon-checked"); } else { $(this).addClass("all-icon-checked"); } }); $set_div.find('[data-set-module-check="org_price_flg"]').click(function() { if ($(this).hasClass("all-icon-checked")) { $(this).removeClass("all-icon-checked"); } else { $(this).addClass("all-icon-checked"); } }); $set_div.find(".goods-add-value div.goods-add-items:first").click(function() { jQuery.extend(true, _pdt_dialog_data, _pdt_view_time_data.data.pdt); InitPdtDialog(); _pdt_dialog_callback = SetPdtData; $("#tvm-shop-select-goods-window").show(); }); $set_div.find(".goods-show-number input").blur(function() { _pdt_view_time_data.data.pdt_view = $.trim($(this).val()); }); var SetPdtData = function() { var $set_good_div = $set_div.find(".goods-add-value"); $set_good_div.find(".goods-view-items").remove(); $ .each( _pdt_dialog_data, function(n, value) { var $good_html = $('<div class="goods-add-items goods-view-items">' + '<img src="">' + '<div class="goods-add-items-saletype">原价</div>' + '<div class="goods-add-items-origprice">¥<span></span></div>' + '<div class="edit-goods"><span>选择<br/>价格<br/>体系</span><div class="delete-btn"></div></div>' + '</div>'); $good_html.find("img").attr("src", value.product_image); $good_html.attr("data-cate-pdt-id", value.product_id); if (typeof (value.prices_id) != "undefined" && value.prices_id != null && value.prices && value.prices_id in value.prices) { var data_temp = GetRuleCompute(value.unit_price, value.prices[value.prices_id]); $good_html.find(".goods-add-items-saletype").text( value.prices[value.prices_id].price_title || value.prices[value.prices_id].title); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(data_temp.price)); } else { $good_html.find(".goods-add-items-saletype").text("原价"); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(value.unit_price)); } $good_html.find(".delete-btn").click(function() { var pdt_id = $(this).parent().parent().attr("data-cate-pdt-id"); var temp = []; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id != pdt_id) { temp.push(value); } }); _pdt_view_time_data.data.pdt = temp; $(this).parent().parent().remove(); }); $good_html.click(function() { var pdt_id = $(this).attr("data-cate-pdt-id"); var pdt_temp = {}; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id == pdt_id) { pdt_temp = value; } }); var prices_id = null; if (typeof (pdt_temp.prices_id) != "undefined") { prices_id = pdt_temp.prices_id; } if (typeof (pdt_temp.prices) != "undefined") { showPrices($set_good_div.parent(), pdt_temp.prices, prices_id, value.unit_price, function(obj) { if (obj != null) { var data_temp = GetRuleCompute( value.unit_price, obj); $good_html.find(".goods-add-items-saletype") .text(obj.price_title || obj.title); $good_html.find( ".goods-add-items-origprice span") .text(PaddingZero(data_temp.price)); pdt_temp.prices_id = obj.id; } else { $good_html.find(".goods-add-items-saletype") .text("原价"); $good_html.find( ".goods-add-items-origprice span") .text(PaddingZero(value.unit_price)); pdt_temp.prices_id = null; } }); } }); $set_good_div.append($good_html); }); if (_pdt_dialog_data.length == 0) { _pdt_view_time_data.data.pdt = []; } else { var temp_data = []; $.each(_pdt_dialog_data, function(n, value) { temp_data.push(value); }); _pdt_view_time_data.data.pdt = temp_data; } } } var SetSeckillEvent = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".goods-overflowx-add-value div.goods-add-items:first").click(function() { jQuery.extend(true, _pdt_dialog_data, _pdt_view_time_data.data.pdt); InitPdtDialog(); _pdt_dialog_callback = SetPdtData; $("#tvm-shop-select-goods-window").show(); }); $set_div.find(".secondskill-goods-show-number input").blur(function() { _pdt_view_time_data.data.pdt_view = $.trim($(this).val()); }); $set_div.find(".times-start").timepicker({ showSecond : true, timeFormat : 'hh:mm:ss', stepHour : 1, stepMinute : 1, stepSecond : 1, onSelect : function(selectedDate) { var date_temp = ChineseToTime(selectedDate); _pdt_view_time_data.data.seckill_begin_time = date_temp; } }); $set_div.find(".times-end").timepicker({ showSecond : true, timeFormat : 'hh:mm:ss', stepHour : 1, stepMinute : 1, stepSecond : 1, startTime : new Date(), onSelect : function(selectedDate) { var date_temp = ChineseToTime(selectedDate); _pdt_view_time_data.data.seckill_end_time = date_temp; } }); $set_div.find(".secondskill-date-txt").datepicker({ /* 区域化周名为中文 */ dayNamesMin : ["日", "一", "二", "三", "四", "五", "六"], /* 每周从周一开始 */ firstDay : 1, /* 区域化月名为中文习惯 */ monthNames : ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"], /* 月份显示在年后面 */ showMonthAfterYear : true, /* 年份后缀字符 */ yearSuffix : "年", /* 格式化中文日期(因为月份中已经包含“月”字,所以这里省略) */ dateFormat : "yy-mm-dd", onSelect : function(selectedDate) { var date_temp = ChineseToDate(selectedDate); _pdt_view_time_data.data.seckill_date = date_temp; } }); var SetPdtData = function() { var $set_good_div = $set_div.find(".goods-overflowx-add-value"); $set_good_div.find(".goods-view-items").remove(); $ .each( _pdt_dialog_data, function(n, value) { var $good_html = $('<div class="goods-add-items goods-view-items">' + '<img src="">' + '<div class="goods-add-items-saletype">原价</div>' + '<div class="goods-add-items-origprice">¥<span></span></div>' + '<div class="edit-goods"><span>选择<br/>价格<br/>体系</span><div class="delete-btn"></div></div>' + '</div>'); $good_html.find("img").attr("src", value.product_image); $good_html.attr("data-cate-pdt-id", value.product_id); if (typeof (value.prices_id) != "undefined" && value.prices_id != null && value.prices && value.prices_id in value.prices) { var data_temp = GetRuleCompute(value.unit_price, value.prices[value.prices_id]); $good_html.find(".goods-add-items-saletype").text( value.prices[value.prices_id].price_title || value.prices[value.prices_id].title); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(data_temp.price)); } else { $good_html.find(".goods-add-items-saletype").text("原价"); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(value.unit_price)); } $good_html.find(".delete-btn").click(function() { var pdt_id = $(this).parent().parent().attr("data-cate-pdt-id"); var temp = []; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id != pdt_id) { temp.push(value); } }); _pdt_view_time_data.data.pdt = temp; $(this).parent().parent().remove(); }); $good_html.click(function() { var pdt_id = $(this).attr("data-cate-pdt-id"); var pdt_temp = {}; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id == pdt_id) { pdt_temp = value; } }); var prices_id = null; if (typeof (pdt_temp.prices_id) != "undefined") { prices_id = pdt_temp.prices_id; } if (typeof (pdt_temp.prices) != "undefined") { showPrices($set_good_div.parent(), pdt_temp.prices, prices_id, value.unit_price, function(obj) { if (obj != null) { var data_temp = GetRuleCompute( value.unit_price, obj); $good_html.find(".goods-add-items-saletype") .text(obj.price_title || obj.title); $good_html.find( ".goods-add-items-origprice span") .text(PaddingZero(data_temp.price)); pdt_temp.prices_id = obj.id; } else { $good_html.find(".goods-add-items-saletype") .text("原价"); $good_html.find( ".goods-add-items-origprice span") .text(PaddingZero(value.unit_price)); pdt_temp.prices_id = null; } }); } }); $set_good_div.append($good_html); }); if (_pdt_dialog_data.length == 0) { _pdt_view_time_data.data.pdt = []; } else { var temp_data = []; $.each(_pdt_dialog_data, function(n, value) { temp_data.push(value); }); _pdt_view_time_data.data.pdt = temp_data; } } } var SetGoodOverFlowEvent = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".goods-overflowx-add-value div.goods-add-items:first").click(function() { jQuery.extend(true, _pdt_dialog_data, _pdt_view_time_data.data.pdt); InitPdtDialog(); _pdt_dialog_callback = SetPdtData; $("#tvm-shop-select-goods-window").show(); }); $set_div.find(".goods-show-number input").blur(function() { _pdt_view_time_data.data.pdt_view = $.trim($(this).val()); }); $set_div.find('[data-set-module-check="org_price_flg"]').click(function() { if ($(this).hasClass("all-icon-checked")) { $(this).removeClass("all-icon-checked"); } else { $(this).addClass("all-icon-checked"); } }); var SetPdtData = function() { var $set_good_div = $set_div.find(".goods-overflowx-add-value"); $set_good_div.find(".goods-view-items").remove(); $ .each( _pdt_dialog_data, function(n, value) { var $good_html = $('<div class="goods-add-items goods-view-items">' + '<img src="">' + '<div class="goods-add-items-saletype">原价</div>' + '<div class="goods-add-items-origprice">¥<span></span></div>' + '<div class="edit-goods"><span>选择<br/>价格<br/>体系</span><div class="delete-btn"></div></div>' + '</div>'); $good_html.find("img").attr("src", value.product_image); $good_html.attr("data-cate-pdt-id", value.product_id); if (typeof (value.prices_id) != "undefined" && value.prices_id != null && value.prices && value.prices_id in value.prices) { var data_temp = GetRuleCompute(value.unit_price, value.prices[value.prices_id]); $good_html.find(".goods-add-items-saletype").text( value.prices[value.prices_id].price_title || value.prices[value.prices_id].title); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(data_temp.price)); } else { $good_html.find(".goods-add-items-saletype").text("原价"); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(value.unit_price)); } $good_html.find(".delete-btn").click(function() { var pdt_id = $(this).parent().parent().attr("data-cate-pdt-id"); var temp = []; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id != pdt_id) { temp.push(value); } }); _pdt_view_time_data.data.pdt = temp; $(this).parent().parent().remove(); }); $good_html.click(function() { var pdt_id = $(this).attr("data-cate-pdt-id"); var pdt_temp = {}; $.each(_pdt_view_time_data.data.pdt, function(n, value) { if (value.product_id == pdt_id) { pdt_temp = value; } }); var prices_id = null; if (typeof (pdt_temp.prices_id) != "undefined") { prices_id = pdt_temp.prices_id; } if (typeof (pdt_temp.prices) != "undefined") { showPrices($set_good_div.parent(), pdt_temp.prices, prices_id, value.unit_price, function(obj) { if (obj != null) { var data_temp = GetRuleCompute( value.unit_price, obj); $good_html.find(".goods-add-items-saletype") .text(obj.price_title || obj.title); $good_html.find( ".goods-add-items-origprice span") .text(PaddingZero(data_temp.price)); pdt_temp.prices_id = obj.id; } else { $good_html.find(".goods-add-items-saletype") .text("原价"); $good_html.find( ".goods-add-items-origprice span") .text(PaddingZero(value.unit_price)); pdt_temp.prices_id = null; } }); } }); $set_good_div.append($good_html); }); if (_pdt_dialog_data.length == 0) { _pdt_view_time_data.data.pdt = []; } else { var temp_data = []; $.each(_pdt_dialog_data, function(n, value) { temp_data.push(value); }); _pdt_view_time_data.data.pdt = temp_data; } } } var SetDefFillAttr = function(module) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.empty(); $set_div.attr("data-set-module-id", module.id); var $set_module_html = $(_module_style_map[module.type].setHtml); $set_module_html.attr("data-set-module-id", module.data.id); $set_div.append($set_module_html); $.each(module.data, function(n, value) { var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule"); if ($html.find('[data-set-module-input=' + n + ']').length != 0) { $html.find('[data-set-module-input=' + n + ']').val(value); } if ($html.find('[data-set-module-textarea=' + n + ']').length != 0) { $html.find('[data-set-module-textarea=' + n + ']').text(value); } if ($html.find('[data-set-module-img=' + n + ']').length != 0) { $html.find('[data-set-module-img=' + n + ']').attr("src", value); } if ($html.find('[data-set-module-check=' + n + ']').length != 0) { if (value) { $html.find('[data-set-module-check=' + n + ']') .addClass("all-icon-checked"); } else { $html.find('[data-set-module-check=' + n + ']').removeClass( "all-icon-checked"); } } if ($html.find('[data-set-module-style=' + n + ']').length != 0) { var module_style_div = $html.find('[data-set-module-style=' + n + ']'); var index_temp = module_style_div.find('[data-set-module-style=' + value + ']') .index(); module_style_div.append(module_style_div.find('div:lt(' + index_temp + ')')); } if ($html.find('[data-set-module-color=' + n + ']').length != 0) { var module_color_div = $html.find('[data-set-module-color=' + n + ']'); module_color_div.find(".color-items").removeClass("on"); module_color_div.find('[data-set-module-color=' + value + ']').addClass("on"); } }); } var SetShopSignOneAttr = function(data) { SetDefFillAttr(data); } var SetShopSignEvent = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find('[data-set-module-check="wcat_flg"]').click(function() { if ($(this).hasClass("all-icon-checked")) { $(this).removeClass("all-icon-checked"); } else { $(this).addClass("all-icon-checked"); } }); $set_div.find('[data-set-module-check="goods_flg"]').click(function() { if ($(this).hasClass("all-icon-checked")) { $(this).removeClass("all-icon-checked"); } else { $(this).addClass("all-icon-checked"); } }); $set_div.find(".shopdesc-css-images-previous").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.append($module_style_div.find("div:first")); }); $set_div.find(".shopdesc-css-images-next").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.prepend($module_style_div.find("div:last")); }); $set_div.find(".add-shop-imgs .add-shop-imgs-deleteIcon").click(function(e) { e.stopPropagation(); $(this).prev().attr("src", ""); }); $set_div.find('.add-shop-imgs').click(function() { $current_img = [$(this).find("img")]; var img_size_str = "建议尺寸:750*236(像素) 图片大小:不超过500k 格式:jpg/gif/png"; $("#upload_img_dialog").find(".new_img_warn").text(img_size_str); _img_max = 1; _img_dialog_data = []; _img_select_callback = function(imgs) { $.each($current_img, function(n, value) { if (imgs.length > n) { value.attr("src", imgs[n].url); } }); } GetOldImgServerRequest(); $("#upload_img_dialog").show("drop"); }); $set_div.find('[data-set-module-img="shop_ico"]').click(function() { $current_img = [$(this)]; var img_size_str = "建议尺寸:108*108(像素) 图片大小:不超过500k 格式:jpg/gif/png"; $("#upload_img_dialog").find(".new_img_warn").text(img_size_str); _img_max = 1; _img_dialog_data = []; _img_select_callback = function(imgs) { $.each($current_img, function(n, value) { if (imgs.length > n) { value.attr("src", imgs[n].url); } }); } GetOldImgServerRequest(); $("#upload_img_dialog").show("drop"); }); } // 商品分类设置填充 var SetPdtViewAttr = function(module) { SetDefFillAttr(module); _pdt_view_time_data = {}; jQuery.extend(true, _pdt_view_time_data, module); var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var $cate_div = $html.find('[data-set-module-cate="cate"]'); $cate_div.empty(); var add_cate_html = '<div class="goods-category-value-items one-row-show">' + '<div class="add-goods-category-btn"></div>添加' + '</div>'; $ .each( module.data.pdt, function(n, value) { var $cate_html = $('<div class="goods-category-edit">' + '<div class="goods-category-txt" contenteditable="true"></div>' + '<div class="delete-page-btn" title="删除标签"></div>' + '</div>'); $cate_html.attr("data-module-cate-num", $html.find(".goods-category-edit").length); $cate_html.find('.goods-category-txt').text(value.pdt_cate_name); var pdts_temp = GetPdtFromDict(value.pdt_data); _pdt_view_time_data.data.pdt[n].pdt_data = pdts_temp; if (n == 0) { $cate_html.addClass("on"); $cate_html.find('div.delete-page-btn').remove(); var $set_good_div = $html.find(".goods-add-value"); $set_good_div.find(".goods-view-items").remove(); $html.find(".tvm-shop-setModule-goods-items input").val(value.pdt_view); $ .each( pdts_temp, function(i, obj) { var $good_html = $('<div class="goods-add-items goods-view-items">' + '<img src="">' + '<div class="goods-add-items-saletype">原价</div>' + '<div class="goods-add-items-origprice">¥<span></span></div>' + '<div class="edit-goods"><span>选择<br/>价格<br/>体系</span><div class="delete-btn"></div></div>' + '</div>'); $good_html.find("img").attr("src", obj.product_image); $good_html.attr("data-cate-pdt-id", obj.product_id); $good_html.attr("data-cate-num", i); if (typeof (obj.prices_id) != "undefined" && obj.prices_id != null && obj.prices && obj.prices_id in obj.prices) { var data_temp = GetRuleCompute(obj.unit_price, obj.prices[obj.prices_id]); $good_html .find(".goods-add-items-saletype") .text( obj.prices[obj.prices_id].price_title || obj.prices[obj.prices_id].title); $good_html.find( ".goods-add-items-origprice span") .text(PaddingZero(data_temp.price)); } else { $good_html.find(".goods-add-items-saletype") .text("原价"); $good_html.find( ".goods-add-items-origprice span") .text(PaddingZero(obj.unit_price)); } $good_html.find(".delete-btn").click( function() { var pdt_id = $(this).parent().parent() .attr("data-cate-pdt-id"); var pdt_num = Number($cate_div.find( ".goods-category-edit.on") .attr("data-module-cate-num")); PdtViewGoodsRemove(pdt_num, pdt_id); $(this).parent().parent().remove(); }); $good_html .click(function() { var pdt_id = $(this).attr( "data-cate-pdt-id"); var pdt_temp = {}; var num = Number($html .find( '[data-set-module-cate="cate"]') .find(".on").attr( "data-module-cate-num")); $ .each( _pdt_view_time_data.data.pdt[num].pdt_data, function(n, value) { if (value.product_id == pdt_id) { pdt_temp = value; } }); var prices_id = null; if (typeof (pdt_temp.prices_id) != "undefined") { prices_id = pdt_temp.prices_id; } if (typeof (pdt_temp.prices) != "undefined") { showPrices( $set_good_div.parent(), pdt_temp.prices, prices_id, obj.unit_price, function(obj_temp) { if (obj_temp != null) { var data_temp = GetRuleCompute( obj.unit_price, obj_temp); $good_html .find( ".goods-add-items-saletype") .text( obj_temp.price_title || obj_temp.title); $good_html .find( ".goods-add-items-origprice span") .text( PaddingZero(data_temp.price)); pdt_temp.prices_id = obj_temp.id; } else { $good_html .find( ".goods-add-items-saletype") .text("原价"); $good_html .find( ".goods-add-items-origprice span") .text( PaddingZero(obj.unit_price)); pdt_temp.prices_id = null; } }); } }); $set_good_div.append($good_html); }); } $cate_html.find(".goods-category-txt").keypress(function(e) { if (e.which == 13) { // 回车事件 return false; } }); $cate_html.find(".goods-category-txt").blur( function() { var $html = $("div.tvm-shop-setting").find( "div.tvm-shop-setModule:first"); var num = Number($html.find('[data-set-module-cate="cate"]') .find(".on").attr("data-module-cate-num")); if ($(this).text().replace(/(^s*)|(s*$)/g, "").length == 0) { $(this).text( _pdt_view_time_data.data.pdt[num].pdt_cate_name); } else { _pdt_view_time_data.data.pdt[num].pdt_cate_name = $(this) .text(); } }); $cate_div.append($cate_html); }); if (module.data.pdt.length < 5) { $cate_div.append(add_cate_html); } $cate_div.append('<div class="cle"></div>'); } // 商品分类设置事件 var SetPdtViewEvent = function() { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); $set_div.find(".goods-show-images-previous").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.append($module_style_div.find("div:first")); }); $set_div.find(".goods-show-images-next").click(function() { var $module_style_div = $set_div.find('[data-set-module-style="style"]') $module_style_div.prepend($module_style_div.find("div:last")); }); $set_div.find('[data-set-module-check="shop_cart_flg"]').click(function() { if ($(this).hasClass("all-icon-checked")) { $(this).removeClass("all-icon-checked"); } else { $(this).addClass("all-icon-checked"); } }); $set_div.find('[data-set-module-check="org_price_flg"]').click(function() { if ($(this).hasClass("all-icon-checked")) { $(this).removeClass("all-icon-checked"); } else { $(this).addClass("all-icon-checked"); } }); $set_div.find(".add-goods-category-btn").parent().click( function() { if ($set_div.find(".goods-category-edit").length < 5) { var $cate_html = $('<div class="goods-category-edit">' + '<div class="goods-category-txt" contenteditable="true"></div>' + '<div class="delete-page-btn" title="删除标签"></div>' + '</div>'); var new_pdt_cate = { pdt_cate_name : "分类", pdt_data : [], pdt_view : "1" }; $cate_html.attr("data-module-cate-num", $set_div.find(".goods-category-edit").length); $cate_html.find(".goods-category-txt").text(new_pdt_cate.pdt_cate_name); $cate_html.find(".goods-category-txt").keyup(function() { if (event.keyCode == 13) { // 回车事件 $(this).text($(this).text().replace(/[\r\n]/g, "")); $(this).blur(); } }); $cate_html.find(".goods-category-txt").blur( function() { var $html = $("div.tvm-shop-setting").find( "div.tvm-shop-setModule:first"); var num = Number($html.find('[data-set-module-cate="cate"]').find( ".on").attr("data-module-cate-num")); if ($(this).text().replace(/(^s*)|(s*$)/g, "").length == 0) { $(this).text(_pdt_view_time_data.data.pdt[num].pdt_cate_name); } else { _pdt_view_time_data.data.pdt[num].pdt_cate_name = $(this) .text(); } }); $(this).before($cate_html); _pdt_view_time_data.data.pdt.push(new_pdt_cate); } if ($set_div.find(".goods-category-edit").length == 5) { $(this).hide(); } $set_div.find(".delete-page-btn").unbind("click"); $set_div.find(".delete-page-btn").click(function() { PdtViewDeleteCate($(this)); }); $set_div.find(".goods-category-txt").parent().unbind("click"); $set_div.find(".goods-category-txt").parent().click(function() { PdtViewSelectCate($(this)); }); }); $set_div.find(".delete-page-btn").unbind("click"); $set_div.find(".delete-page-btn").click(function() { PdtViewDeleteCate($(this)); }); $set_div.find(".goods-category-txt").parent().unbind("click"); $set_div.find(".goods-category-txt").parent().click(function() { PdtViewSelectCate($(this)); }); $set_div.find(".goods-add-value div.goods-add-items:first").click( function() { var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var num = Number($html.find('[data-set-module-cate="cate"]').find(".on").attr( "data-module-cate-num")); jQuery.extend(true, _pdt_dialog_data, _pdt_view_time_data.data.pdt[num].pdt_data); InitPdtDialog(); _pdt_dialog_callback = SetPdtData; $("#tvm-shop-select-goods-window").show(); }); $set_div.find(".goods-show-number input").blur( function() { var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var num = Number($html.find('[data-set-module-cate="cate"]').find(".on").attr( "data-module-cate-num")); _pdt_view_time_data.data.pdt[num].pdt_view = $.trim($(this).val()); }); var SetPdtData = function() { var $set_good_div = $set_div.find(".goods-add-value"); $set_good_div.find(".goods-view-items").remove(); $ .each( _pdt_dialog_data, function(n, value) { var $good_html = $('<div class="goods-add-items goods-view-items">' + '<img src="">' + '<div class="goods-add-items-saletype">原价</div>' + '<div class="goods-add-items-origprice">¥<span></span></div>' + '<div class="edit-goods"><span>选择<br/>价格<br/>体系</span><div class="delete-btn"></div></div>' + '</div>'); $good_html.find("img").attr("src", value.product_image); $good_html.attr("data-cate-pdt-id", value.product_id); if (typeof (value.prices_id) != "undefined" && value.prices_id != null && value.prices && value.prices_id in value.prices) { var data_temp = GetRuleCompute(value.unit_price, value.prices[value.prices_id]); $good_html.find(".goods-add-items-saletype").text( value.prices[value.prices_id].price_title || value.prices[value.prices_id].title); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(data_temp.price)); } else { $good_html.find(".goods-add-items-saletype").text("原价"); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(value.unit_price)); } $good_html.attr("data-cate-num", n); $good_html.find(".delete-btn").click( function() { var pdt_id = $(this).parent().parent().attr( "data-cate-pdt-id"); var $cate_div = $set_div .find('[data-set-module-cate="cate"]'); var pdt_num = Number($cate_div.find( ".goods-category-edit.on").attr( "data-module-cate-num")); PdtViewGoodsRemove(pdt_num, pdt_id); $(this).parent().parent().remove(); }); $good_html.click(function() { var pdt_id = $(this).attr("data-cate-pdt-id"); var pdt_temp = {}; var num = Number($html.find('[data-set-module-cate="cate"]').find( ".on").attr("data-module-cate-num")); $.each(_pdt_view_time_data.data.pdt[num].pdt_data, function(n, value) { if (value.product_id == pdt_id) { pdt_temp = value; } }); var prices_id = null; if (typeof (pdt_temp.prices_id) != "undefined") { prices_id = pdt_temp.prices_id; } if (typeof (pdt_temp.prices) != "undefined") { showPrices($set_good_div.parent(), pdt_temp.prices, prices_id, value.unit_price, function(obj) { if (obj != null) { var data_temp = GetRuleCompute( value.unit_price, obj); $good_html.find(".goods-add-items-saletype") .text(obj.price_title || obj.title); $good_html.find( ".goods-add-items-origprice span") .text(PaddingZero(data_temp.price)); pdt_temp.prices_id = obj.id; } else { $good_html.find(".goods-add-items-saletype") .text("原价"); $good_html.find( ".goods-add-items-origprice span") .text(PaddingZero(value.unit_price)); pdt_temp.prices_id = null; } }); } }); $set_good_div.append($good_html); }); var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var num = Number($html.find('[data-set-module-cate="cate"]').find(".on").attr( "data-module-cate-num")); if (_pdt_dialog_data.length == 0) { _pdt_view_time_data.data.pdt[num].pdt_data = []; } else { var temp_data = []; $.each(_pdt_dialog_data, function(n, value) { temp_data.push(value); }); _pdt_view_time_data.data.pdt[num].pdt_data = temp_data; } } var PdtViewDeleteCate = function($obj) { $set_div.find(".tvm-shop-price-list-parent").remove(); var num = Number($obj.parent().attr("data-module-cate-num")); if ($obj.parent().hasClass("on")) { $set_div.find('.goods-category-edit:eq(0)').click(); } $set_div.find('.goods-category-edit:eq(' + num + ')').remove(); var module_temp = _pdt_view_time_data; var new_module_data_pdt = []; $.each(module_temp.data.pdt, function(n, value) { if (n != num) { new_module_data_pdt.push(value); } }); module_temp.data.pdt = new_module_data_pdt; $set_div.find(".add-goods-category-btn").parent().show(); $.each($set_div.find('[data-set-module-cate="cate"]').find(".goods-category-edit"), function(n, value) { $(value).attr("data-module-cate-num", n); }); } var PdtViewSelectCate = function($obj) { $set_div.find(".tvm-shop-price-list-parent").remove(); if (!$obj.hasClass("on")) { $obj.parent().find(".goods-category-edit").removeClass("on"); $obj.addClass("on"); // 显示商品 var $set_good_div = $set_div.find(".goods-add-value"); $set_good_div.find(".goods-view-items").remove(); var num = Number($obj.attr("data-module-cate-num")); $set_div.find(".goods-show-number input").val( _pdt_view_time_data.data.pdt[num].pdt_view); $ .each( _pdt_view_time_data.data.pdt[num].pdt_data, function(n, value) { var $good_html = $('<div class="goods-add-items goods-view-items">' + '<img src="">' + '<div class="goods-add-items-saletype">原价</div>' + '<div class="goods-add-items-origprice">¥<span>200</span></div>' + '<div class="edit-goods"><span>选择<br/>价格<br/>体系</span><div class="delete-btn"></div></div>' + '</div>'); $good_html.find("img").attr("src", value.product_image); $good_html.attr("data-cate-pdt-id", value.product_id); $good_html.attr("data-cate-num", num); if (typeof (value.prices_id) != "undefined" && value.prices_id != null && value.prices && value.prices_id in value.prices) { var data_temp = GetRuleCompute(value.unit_price, value.prices[value.prices_id]); $good_html.find(".goods-add-items-saletype").text( value.prices[value.prices_id].price_title || value.prices[value.prices_id].title); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(data_temp.price)); } else { $good_html.find(".goods-add-items-saletype").text("原价"); $good_html.find(".goods-add-items-origprice span").text( PaddingZero(value.unit_price)); } $good_html.find(".delete-btn").click( function() { var pdt_id = $(this).parent().parent().attr( "data-cate-pdt-id"); var pdt_num = Number($(this).parent().parent().attr( "data-cate-num")); PdtViewGoodsRemove(pdt_num, pdt_id); $(this).parent().parent().remove(); }); $good_html .click(function() { var pdt_id = $(this).attr("data-cate-pdt-id"); var pdt_temp = {}; var num = Number($set_div.find( '[data-set-module-cate="cate"]').find(".on") .attr("data-module-cate-num")); $.each(_pdt_view_time_data.data.pdt[num].pdt_data, function(n, value) { if (value.product_id == pdt_id) { pdt_temp = value; } }); var prices_id = null; if (typeof (pdt_temp.prices_id) != "undefined") { prices_id = pdt_temp.prices_id; } if (typeof (pdt_temp.prices) != "undefined") { showPrices( $set_good_div.parent(), pdt_temp.prices, prices_id, value.unit_price, function(obj_temp) { if (obj_temp != null) { var data_temp = GetRuleCompute( value.unit_price, obj_temp); $good_html .find( ".goods-add-items-saletype") .text( obj_temp.price_title || obj_temp.title); $good_html .find( ".goods-add-items-origprice span") .text( PaddingZero(data_temp.price)); pdt_temp.prices_id = obj_temp.id; } else { $good_html .find( ".goods-add-items-saletype") .text("原价"); $good_html .find( ".goods-add-items-origprice span") .text( PaddingZero(value.unit_price)); pdt_temp.prices_id = null; } }); } }); $set_good_div.append($good_html); }); $set_div.find("#goods-add-txt").text($obj.text()); } } } var PdtViewGoodsRemove = function(n, id) { var temp = []; $.each(_pdt_view_time_data.data.pdt[n].pdt_data, function(n, value) { if (value.product_id != id) { temp.push(value); } }); _pdt_view_time_data.data.pdt[n].pdt_data = temp; } /*----------------获取数据-----------------------------*/ var GetDefDate = function() { var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {} jQuery.extend(true, module_data, module_final_data); $.each(module_data.data, function(n, value) { var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); if ($html.find('[data-set-module-input=' + n + ']').length != 0) { value = $.trim($html.find('[data-set-module-input=' + n + ']').val()); } if ($html.find('[data-set-module-textarea=' + n + ']').length != 0) { value = $.trim($html.find('[data-set-module-textarea=' + n + ']').val()); } if ($html.find('[data-set-module-img=' + n + ']').length != 0) { value = $html.find('[data-set-module-img=' + n + ']').attr("src"); } if ($html.find('[data-set-module-check=' + n + ']').length != 0) { if ($html.find('[data-set-module-check=' + n + ']').hasClass("all-icon-checked")) { value = true; } else { value = false; } } if ($html.find('[data-set-module-style=' + n + ']').length != 0) { if (module_data.type == "shop_sign") { value = $html.find('[data-set-module-style=' + n + ']').find("div:first").attr( "data-set-module-style"); } } module_data.data[n] = value; }); var error = ""; if (module_data.type == "shop_sign") { error = TextShopSign(module_data.data); } if (error == "") { module_final_data.data = module_data.data; showSettingTips(); } else { alert(error); } } var GetShopSignDate = function() { GetDefDate(); var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); module_final_data.data.shop_name = $.trim($("#store_name_input").val()); } var GetPdtViewDate = function() { var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data); module_data.data = temp.data; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); if ($html.find('[data-set-module-check="shop_cart_flg"]').hasClass("all-icon-checked")) { module_data.data.shop_cart_flg = true; } else { module_data.data.shop_cart_flg = false; } if ($html.find('[data-set-module-check="org_price_flg"]').hasClass("all-icon-checked")) { module_data.data.org_price_flg = true; } else { module_data.data.org_price_flg = false; } module_data.data.style = $html.find('[data-set-module-style="style"]').find("div:first").attr( "data-set-module-style"); $.each($html.find(".goods-category-edit"), function(n, value) { module_data.data.pdt[n].pdt_cate_name = $.trim($(this).find(".goods-category-txt").text()); }); var error = ""; error = TextPdtView(module_data.data); if (error == "") { // 字典处理 $.each(module_final_data.data.pdt, function(n, value) { DelPdtDict(value.pdt_data); }); $.each(module_data.data.pdt, function(n, value) { var pdts_array = AddPdtDict(value.pdt_data); value.pdt_data = pdts_array; }); module_final_data.data = module_data.data; showSettingTips(); } else { alert(error); } } var GetPdtModDate = function() { var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data); module_data.data = temp.data; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); if ($html.find('[data-set-module-check="shop_cart_flg"]').hasClass("all-icon-checked")) { module_data.data.shop_cart_flg = true; } else { module_data.data.shop_cart_flg = false; } if ($html.find('[data-set-module-check="org_price_flg"]').hasClass("all-icon-checked")) { module_data.data.org_price_flg = true; } else { module_data.data.org_price_flg = false; } module_data.data.style = $html.find('[data-set-module-style="style"]').find("div:first").attr( "data-set-module-style"); module_data.data.mod_name = $.trim($html.find('[data-set-module-input="mod_name"]').val()); var error = ""; error = TextPdtMod(module_data.data); if (error == "") { // 字典处理 DelPdtDict(module_final_data.data.pdt); var pdts_array = AddPdtDict(module_data.data.pdt); module_data.data.pdt = pdts_array; module_final_data.data = module_data.data; showSettingTips(); } else { alert(error); } } var GetGoodOverFlowData = function() { var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data); module_data.data = temp.data; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.first_name = $.trim($html.find('[data-set-module-input="first_name"]').val()); module_data.data.second_name = $ .trim($html.find('[data-set-module-input="second_name"]').val()); if ($html.find('[data-set-module-check="org_price_flg"]').hasClass("all-icon-checked")) { module_data.data.org_price_flg = true; } else { module_data.data.org_price_flg = false; } var error = ""; error = TextGoodOverFlow(module_data.data); if (error == "") { // 字典处理 DelPdtDict(module_final_data.data.pdt); var pdts_array = AddPdtDict(module_data.data.pdt); module_data.data.pdt = pdts_array; module_final_data.data = module_data.data; showSettingTips(); } else { alert(error); } } var GetBannerModData = function() { var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data.data); module_data.data = temp; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.style = $html.find('[data-set-module-style="style"]').find("div:first").attr( "data-set-module-style"); module_data.data.height = $html.find('.banner-imageheight-select').val(); var error = ""; error = TextBannerMod(module_data.data); if (error == "") { module_final_data.data = module_data.data; showSettingTips(); } else { alert(error); } } var GetBrandModData = function() { var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data.data); module_data.data = temp; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.style = $html.find('[data-set-module-style="style"]').find("div:first").attr( "data-set-module-style"); module_data.data.brand_imgs = $html.find('.brand-value img').attr("src"); var error = ""; error = TextBrandMod(module_data.data); if (error == "") { module_final_data.data = module_data.data; showSettingTips(); } else { alert(error); } } var GetSeckillData = function() { var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data.data); module_data.data = temp; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.title = $html.find('.secondskill-sub-title').val(); var error = ""; error = TextSeckill(module_data.data); if (error == "") { //字典处理 DelPdtDict(module_final_data.data.pdt); var pdts_array = AddPdtDict(module_data.data.pdt); module_data.data.pdt = pdts_array; module_final_data.data = module_data.data; showSettingTips(); } else { alert(error); } } var GetFindShopData = function() { var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data.data); module_data.data = temp; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.name = $html.find('[data-set-module-input="name"]').val(); var error = ""; error = TextFindShop(module_data.data); if (error == "") { module_final_data.data = module_data.data; showSettingTips(); } else { alert(error); } } var GetFenLanData = function() { var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data.data); module_data.data = temp; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.style = $html.find('[data-set-module-style="style"]').find("div:first").attr( "data-set-module-style"); module_data.data.name = $html.find('[data-set-module-input="name"]').val(); var error = ""; error = TextFenlan(module_data.data); if (error == "") { module_final_data.data = module_data.data; showSettingTips(); } else { alert(error); } } var GetCateModData = function() { var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data.data); module_data.data = temp; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.name = $.trim($html.find('[data-set-module-input="name"]').val()); var error = ""; error = TextCateMod(module_data.data); if (error == "") { module_final_data.data = module_data.data; showSettingTips(); } else { alert(error); } } var GetCouponData = function() { var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = []; jQuery.extend(true, temp, _pdt_view_time_data.data.coupon); module_data.data.coupon = temp; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.color = $html.find('[data-set-module-color="color"]').find(".on").attr( "data-set-module-color"); var error = ""; error = TextCoupon(module_data.data); if (error == "") { module_final_data.data = module_data.data; showSettingTips(); } else { alert(error); } } var GetActivityModData = function() { var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data); module_data.data = temp.data; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.first_name = $html.find("input[data-set-module-input='first_name']").val(); module_data.data.second_name = $html.find("input[data-set-module-input='second_name']").val(); module_data.data.third_name = $html.find("input[data-set-module-input='third_name']").val(); module_data.data.group_view = $html.find("input[data-set-module-input='group_view']").val(); if (module_data.data.act_type == 1) { module_data.data.style = "activity_mod_one"; } else if (module_data.data.act_type == 2) { module_data.data.style = "activity_mod_two"; } else if (module_data.data.act_type == 3) { module_data.data.style = "activity_mod_three"; } else if (module_data.data.act_type == 4) { module_data.data.style = $html.find('[data-set-module-style="style"]').find("div:first") .attr("data-set-module-style"); } var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var pdts_temp = []; $.each($set_div.find(".activity-goods-order").find(".goods-order-items"), function(n, value) { var index_temp = $(value).attr("data-index"); pdts_temp.push(module_data.data.group_pdt[index_temp]); }); module_data.data.group_pdt = pdts_temp; var error = ""; error = TextActivityMod(module_data.data); if (error == "") { //字典处理 if (module_data.data.act_type == 3) { DelActPdtDict(module_final_data.data.group_pdt); var sort_id = AddActPdtDict(module_data.data.group_pdt, module_data.data.act_type_id.id); DelActDict(module_final_data.data.act_type_id); var act_type_id_temp = AddActDict(module_data.data.act_type_id, module_data.data.group_pdt); module_data.data.group_pdt = sort_id; module_data.data.act_type_id = act_type_id_temp; } module_final_data.data = module_data.data; showSettingTips(); } else { alert(error); } } var GetCateComModData = function() { var page_id = $("#tvm-shop-phone-panel div.tvm-shop-phone:first").attr("data-page-id"); var module_id = $(".tvm-shop-setting div.tvm-shop-setModule").attr("data-set-module-id"); var module_final_data = GetModuleDateById(page_id, module_id); var module_data = {}; jQuery.extend(true, module_data, module_final_data); var temp = {}; jQuery.extend(true, temp, _pdt_view_time_data); module_data.data = temp.data; var $html = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); module_data.data.style = $html.find('[data-set-module-style="style"]').find("div:first").attr( "data-set-module-style"); var error = ""; error = TextCateComMod(module_data.data); if (error == "") { //字典处理 DelPdtDict(module_final_data.data.pdt); var pdts_array = AddPdtDict(module_data.data.pdt); module_data.data.pdt = pdts_array; module_final_data.data = module_data.data; showSettingTips(); } else { alert(error); } } var TextCateComMod = function(module) { var error = ""; if (module.pdt.length == 0) { error = '请添加商品'; } if (module.banners.url == "") { error = '请添加图片'; } return error; } var TextActivityMod = function(module) { var error = ""; if (module.act_type == 3) { var reg = new RegExp("^[0-9]*[1-9][0-9]*$"); if (!reg.test(module.group_view)) { error = '请输入大于0的数字,显示商品数量'; } if (module.group_pdt.length == 0) { error = '该活动没有商品'; } } else if (module.act_type == 4) { var reg = new RegExp("^[0-9]*[1-9][0-9]*$"); if (!reg.test(module.group_view)) { error = '请输入大于0的数字,显示商品数量'; } if (module.third_name.replace(/(^s*)|(s*$)/g, "").length == 0) { error = "请输入非空字符,模块标题"; } } return error; } var TextShopSign = function(module) { var error = ""; if (module.shop_del.replace(/(^s*)|(s*$)/g, "").length == 0) { error = "请输入非空字符,店铺介绍"; } if (module.shop_ico.replace(/(^s*)|(s*$)/g, "").length == 0) { error = "请上传店铺头像"; } if (module.shop_imgs.replace(/(^s*)|(s*$)/g, "").length == 0) { if (module.style == "shop_sign_one" || module.style == "shop_sign_two") { error = "请上传店招图片"; } } if (module.wcat_flg) { if (module.wcat_num.replace(/(^s*)|(s*$)/g, "").length == 0) { error = "请输入非空字符,微信号"; } } if (module.goods_flg) { var reg = new RegExp("^[0-9]*[1-9][0-9]*$"); if (!reg.test(module.goods_cate)) { error = "请输入大于0的数字,商品类数量"; } } return error; } var TextSeckill = function(module) { var error = ""; var reg = new RegExp("^[0-9]*[1-9][0-9]*$"); if (!reg.test(module.pdt_view)) { error = '请输入大于0的数字,"' + module.pdt_view + '"中显示商品数量'; } if (module.pdt.length == 0) { error = '请选择商品'; } if (module.title.replace(/(^s*)|(s*$)/g, "").length == 0) { error = "请输入非空字符,副标题"; } if (module.seckill_begin_time.length == 0) { error = "请选择秒杀开始时间"; } else if (module.seckill_end_time.length == 0) { error = "请选择秒杀结束时间"; } else { var begin_time = new Date("2000/01/01 " + module.seckill_begin_time); var end_time = new Date("2000/01/01 " + module.seckill_end_time); if (end_time <= begin_time) { error = "请修改秒杀结束时间,必须大于秒杀开始时间"; } } if (module.seckill_date.length == 0) { error = "请选择秒杀日期"; } return error; } var TextPdtView = function(module) { var error = ""; $.each(module.pdt, function(n, obj) { var reg = new RegExp("^[0-9]*[1-9][0-9]*$"); if (!reg.test(obj.pdt_view)) { error = '请输入大于0的数字,"' + obj.pdt_cate_name + '"中显示商品数量'; } if (obj.pdt_data.length == 0) { error = '请选择"' + obj.pdt_cate_name + '"中商品'; } }); return error; } var TextPdtMod = function(module) { var error = ""; var reg = new RegExp("^[0-9]*[1-9][0-9]*$"); if (!reg.test(module.pdt_view)) { error = '请输入大于0的数字,显示商品数量'; } if (module.pdt.length == 0) { error = '请选择商品'; } return error; } var TextGoodOverFlow = function(module) { var error = ""; var reg = new RegExp("^[0-9]*[1-9][0-9]*$"); if (!reg.test(module.pdt_view)) { error = '请输入大于0的数字,"' + module.pdt_view + '"中显示商品数量'; } if (module.pdt.length == 0) { error = '请选择商品'; } return error; } var TextBannerMod = function(module) { var error = ""; if (module.banners.length == 0) { error = '请选择至少一张图片'; } return error; } var TextBrandMod = function(module) { var error = ""; var reg = new RegExp("^[0-9]*[1-9][0-9]*$"); if (!reg.test(module.brands_view)) { error = '请输入大于0的数字,中显示数量'; } if (module.brands.length == 0) { error = '请选择图片'; } return error; } var TextFenlan = function(module) { var error = ""; if (module.fenlan.length == 0) { error = '请选择至少一张图片'; } else { $.each(module.fenlan, function(n, value) { if (value.big_title.replace(/(^s*)|(s*$)/g, "").length == 0) { error = "请输入非空字符,图片" + ConvertToChinese(n + 1) + "中大标题"; return false; } }); } return error; } var TextFindShop = function(module) { var error = ""; if (module.findshop.length == 0) { error = '请选择至少一张图片'; } else { $.each(module.findshop, function(n, value) { if (value.title.replace(/(^s*)|(s*$)/g, "").length == 0) { error = "请输入非空字符,图片" + ConvertToChinese(n + 1) + "中分类名称"; return false; } if (value.shop.length == 0) { error = "请选择至少一个店铺,图片" + ConvertToChinese(n + 1) + "中店铺"; return false; } }); } return error; } var TextCateMod = function(module) { var error = ""; if (module.banners.length == 0) { error = '请选择至少一张图片'; } return error; } var TextCoupon = function(module) { var error = ""; if (module.coupon.length == 0) { error = '请选择至少一张优惠券'; } return error; } var AddPdtDict = function(pdts) { var pdts_array = []; if (typeof (pdts) != "undefined") { $.each(pdts, function(n, pdt) { var pdt_temp = { pdt_id : pdt.product_id, prices_id : null } if (typeof (pdt.prices_id) != "undefined") { pdt_temp.prices_id = pdt.prices_id; } pdts_array.push(pdt_temp); if (typeof (_final_data.product_dict[pdt.product_id]) == "undefined") { var temp = { count : 1, data : pdt }; _final_data.product_dict[pdt.product_id] = temp; } else { var num = Number(_final_data.product_dict[pdt.product_id].count); num++; _final_data.product_dict[pdt.product_id].count = num; var temp = {}; jQuery.extend(true, temp, pdt); _final_data.product_dict[pdt.product_id].data = temp; } }); } return pdts_array; } var AddActDict = function(act, pdts) { if (typeof (act) != "undefined") { if (typeof (_final_data.act_dict) == "undefined") { _final_data.act_dict = { temp : "" }; } if (typeof (_final_data.act_dict[act.id]) == "undefined") { var temp = { count : 1, data : act }; _final_data.act_dict[act.id] = temp; var groups_temp = { temp : "" }; $.each(pdts, function(n, pdt) { groups_temp[pdt.groupBuy_id] = pdt; groups_temp[pdt.groupBuy_id].product_id = pdt.product.product_id; groups_temp[pdt.groupBuy_id].product = null; }); _final_data.act_dict[act.id].data.groups = groups_temp; } else { var num = Number(_final_data.act_dict[act.id].count); num++; _final_data.act_dict[act.id].count = num; var temp = {}; jQuery.extend(true, temp, act); _final_data.act_dict[act.id].data = temp; var groups_temp = { temp : "" }; $.each(pdts, function(n, pdt) { groups_temp[pdt.groupBuy_id] = pdt; groups_temp[pdt.groupBuy_id].product_id = pdt.product.product_id; groups_temp[pdt.groupBuy_id].product = null; }); _final_data.act_dict[act.id].data.groups = groups_temp; } } return act.id; } var AddActPdtDict = function(pdts, id) { var sort_id = CreateGUID(); if (typeof (_final_data.act_pdt_sort) == "undefined") { _final_data.act_pdt_sort = { temp : "" }; } if (typeof (pdts) != "undefined") { var temp = { count : 1, data : { act_id : id, sort_id : sort_id, sort : [] } }; var pdts_array = []; $.each(pdts, function(n, pdt) { temp.data.sort.push(pdt.groupBuy_id); pdts_array.push(pdt.product); }); AddPdtDict(pdts_array); _final_data.act_pdt_sort[sort_id] = temp; } return sort_id; } var DelPdtDict = function(pdts) { if (typeof (pdts) != "undefined") { $.each(pdts, function(n, pdt) { if (typeof (_final_data.product_dict[pdt.pdt_id]) != "undefined") { var num = Number(_final_data.product_dict[pdt.pdt_id].count); num--; _final_data.product_dict[pdt.pdt_id].count = num; } }); } } var DelActDict = function(act) { if (typeof (act) != "undefined") { if (typeof (_final_data.act_dict) == "undefined") { _final_data.act_dict = { temp : "" }; } if (typeof (_final_data.act_dict[act]) != "undefined") { var num = Number(_final_data.act_dict[act].count); num--; _final_data.act_dict[act].count = num; } } } var DelActPdtDict = function(sort_id) { if (typeof (_final_data.act_pdt_sort) == "undefined") { _final_data.act_pdt_sort = { temp : "" }; } if (typeof (_final_data.act_pdt_sort[sort_id]) != "undefined") { var act_id = _final_data.act_pdt_sort[sort_id].act_id; var pdts_array = []; if (typeof (_final_data.act_dict[act_id]) != "undefined") { $.each(_final_data.act_dict[act_id].data.groups, function(n, group) { var param = { pdt_id : group.product_id } pdts_array.push(param); }); } DelPdtDict(pdts_array); _final_data.act_pdt_sort[sort_id].count = 0; } } var GetPdtFromDict = function(pdts) { var pdts_array = []; if (typeof (pdts) != "undefined") { $.each(pdts, function(n, obj) { if (typeof (_final_data.product_dict[obj.pdt_id]) != "undefined") { var temp = {}; jQuery.extend(true, temp, _final_data.product_dict[obj.pdt_id].data); temp.prices_id = obj.prices_id; pdts_array.push(temp); } }); } return pdts_array; } var GetActPdtFromDict = function(pdt_id) { var pdts_array = []; if (typeof (_final_data.act_pdt_sort[pdt_id]) != "undefined" && typeof (_final_data.act_dict[_final_data.act_pdt_sort[pdt_id].data.act_id] != "undefined")) { var act_temp = _final_data.act_dict[_final_data.act_pdt_sort[pdt_id].data.act_id].data; $ .each( _final_data.act_pdt_sort[pdt_id].data.sort, function(n, obj) { if (typeof (act_temp.groups[obj]) != "undefined" && typeof (_final_data.product_dict[act_temp.groups[obj].product_id]) != "undefined") { var temp_group = {}; jQuery.extend(true, temp_group, act_temp.groups[obj]); var temp_pdt = {}; jQuery .extend( true, temp_pdt, _final_data.product_dict[act_temp.groups[obj].product_id].data); temp_group.product = temp_pdt; pdts_array.push(temp_group); } }); } return pdts_array; } var ClearPdtDict = function() { var dict_pdt_temp = { temp : "" }; $.each(_final_data.product_dict, function(n, pdt) { if (pdt.count > 0) { dict_pdt_temp[pdt.data.product_id] = pdt; } }); _final_data.product_dict = dict_pdt_temp; if (typeof (_final_data.act_pdt_sort) != "undefined") { var dict_act_pdt_temp = { temp : "" }; $.each(_final_data.act_pdt_sort, function(n, pdt) { if (pdt.count > 0) { dict_act_pdt_temp[pdt.data.sort_id] = pdt; } }); _final_data.act_pdt_sort = dict_act_pdt_temp; } if (typeof (_final_data.act_dict) != "undefined") { var dict_act_temp = { temp : "" }; $.each(_final_data.act_dict, function(n, act) { if (act.count > 0) { dict_act_temp[act.data.id] = act; } }); _final_data.act_dict = dict_act_temp; } } var DateToChinese = function(str) { /*var result = ""; if(str != ""){ var data = str.split("-"); result = data[0] + "年" + data[1] + "月" + data[2] + "日"; }*/ return str; } var ChineseToDate = function(str) { //var result = str.substring(0,str.length-1).replace(/[^\d]/g,'-'); return str; } var TimeToChinese = function(str, flg) { return str; /* var result = ""; if(str != ""){ var data = str.split(":"); if(flg == 0){ result = data[0] + "时" + data[1] + "分" + data[2] + "秒"; } if(flg == 1){ result = data[0] + "时"; if(data[1] != "00"){ result = result + data[1] + "分"; } if(data[2] != "00"){ result = result + data[2] + "秒"; } } } return result;*/ } var ChineseToTime = function(str) { //var result = str.substring(0,str.length-1).replace(/[^\d]/g,':'); return str; } var GetRuleCompute = function(price, obj) { var data_temp = { name : "", price : 0 } var name_temp = ""; var price_temp = price; if (obj.type == "1") { name_temp = FloatAdd(obj.number, 0) * 10 + "折"; price_temp = FloatMulKeepDecimal(price_temp, obj.number); } else { name_temp = "减" + obj.number; price_temp = FloatSub(price_temp, obj.number); } if (price_temp < 0) { price_temp = 0; } data_temp.name = name_temp; data_temp.price = price_temp; return data_temp; } var MoveModule = function(module_id, n) { var $module_panel_divs = $(".tvm-shop-module-panel > div"); var $page_div = $("#tvm-shop-phone-panel div.tvm-shop-phone:first"); var page_id = $page_div.attr("data-page-id"); var page_data = GetPageDateById(page_id); var module_data_temp = {}; var modules_data_temp = []; var flg = true; if(page_id == "index" && n==0){ flg = false; }else{ if(!(page_data.module.length > n && n >= 0)){ flg = false; } } if (page_data != null && flg && $module_panel_divs.length > 0) { if ($module_panel_divs.length > 0) { $module_panel_divs.each(function() { if ($(this).hasClass("tvm-shop-new-module-place")) { $page_div.find('.tvm-shop-module-panel').find("div.tvm-shop-newModuleBorder") .removeClass("tvm-shop-newModuleBorder"); $page_div.find('.tvm-shop-module-panel div:first').before( $page_div.find('[data-module-id=' + module_id + ']').addClass( "tvm-shop-newModuleBorder")).fadeIn(1000); $(".tvm-shop-new-module-place").remove(); } else { $page_div.find('.tvm-shop-module-panel div:first').before( $page_div.find('[data-module-id=' + module_id + ']')); } }); } else { $page_div.find('.tvm-shop-module-panel div:first').before( $page_div.find('[data-module-id=' + module_id + ']')); } $.each(page_data.module, function(i, value) { if (value.id == module_id) { module_data_temp = value; } else { if (modules_data_temp.length == n) { modules_data_temp.push({}); } modules_data_temp.push(value); } if (modules_data_temp.length == n) { $page_div.find('[data-module-id=' + value.id + ']').after( $page_div.find('[data-module-id=' + module_id + ']')); } }); modules_data_temp[n] = module_data_temp; page_data.module = modules_data_temp; page_data.update_time = GetTimestamp(); } } var SetModuleBorder = function($html, page_id, module_id) { var module_data = GetModuleDateById(page_id, module_id); if (typeof (module_data.data.bottom_boder_flg) == "undefined") { module_data.data.bottom_boder_flg = false; } if (module_data.data.bottom_boder_flg) { $html.addClass("tvm-module-margin-bottom"); } else { $html.removeClass("tvm-module-margin-bottom"); } } var GetActSelectOptData = function() { $("#tvm-shop-loading").show(); $.ajax({ url : "Mall/MallActivities", data : JSON.stringify({}), async : true, type : 'post', dataType : 'json', timeout : 10000, success : function(data) { if (AjaxStatus(data)) { return true; } SetActSelectOptData(data.data.group_buy); }, error : function(XMLHttpRequest, textStatus, errorThrown) { AjaxErrorMSG(XMLHttpRequest, textStatus, errorThrown); }, complete : function(XHR, TS) { $("#tvm-shop-loading").hide(); } }); } var SetActSelectOptData = function(groups) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var $options_left = $set_div.find(".activity-select-options-left"); var $options_right = $set_div.find(".activity-select-options-right"); $options_right.find("div[data-act-type='group']").remove(); $.each(groups, function(n, value) { $group_html = $('<div class="activity-select-options-right-items one-row-show"></div>'); $group_html.attr("data-index", n); $group_html.attr("data-act-type", "group"); $group_html.attr("data-act-id", value.id); $group_html.text(value.name); $group_html.hide(); $options_right.append($group_html); }); $options_left.find(".one-row-show").click(function() { if (!$(this).hasClass("on")) { $options_left.find(".one-row-show").removeClass("on"); $(this).addClass("on"); $options_right.find("div").hide(); $options_right.find('div[data-act-type=' + $(this).attr("data-act-type") + ']').show(); } }); $options_right.find(".one-row-show").click(function() { if (!$(this).hasClass("on")) { $options_right.find(".one-row-show").removeClass("on"); $(this).addClass("on"); $set_div.find(".activity-select-div").text($(this).text()); $set_div.find(".activity-select-options").hide(); if ($(this).attr("data-act-type") == "group") { var param = { id : $(this).attr("data-act-id") }; GetActGroupPdtData(param); $set_div.find(".activity-value").find("[data-act-type='flash']").hide(); $set_div.find(".activity-value").find("[data-act-type='group']").show(); $set_div.find(".activity-value .activity-limit").hide(); $set_div.find('div[data-act-div="pdt-view-num"]').show(); $set_div.find('div[data-act-div="pdt-view-sort"]').show(); $set_div.find('div[data-act-div="pdt-view-list"]').show(); $set_div.find('.activity-type-parent').show(); $set_div.find('div[data-act-div="pdt-first"]').show(); $set_div.find('div[data-act-div="pdt-second"]').show(); $set_div.find('div[data-act-div="pdt-third"]').hide(); _pdt_view_time_data.data.act_type = 3; _pdt_view_time_data.data.act_type_id = groups[$(this).attr("data-index")]; } else if ($(this).attr("data-act-type") == "flash") { $set_div.find(".activity-value .activity-limit").hide(); $set_div.find(".activity-value").find("[data-act-type='flash']").show(); $set_div.find(".activity-value").find("[data-act-type='group']").hide(); $set_div.find('div[data-act-div="pdt-view-num"]').hide(); $set_div.find('div[data-act-div="pdt-view-sort"]').hide(); $set_div.find('div[data-act-div="pdt-view-list"]').hide(); $set_div.find('.activity-type-parent').show(); $set_div.find('div[data-act-div="pdt-first"]').show(); $set_div.find('div[data-act-div="pdt-second"]').show(); $set_div.find('div[data-act-div="pdt-third"]').hide(); _pdt_view_time_data.data.act_type = 2; _pdt_view_time_data.data.act_type_id = $(this).attr("data-act-id"); } else if ($(this).attr("data-act-type") == "limit") { $set_div.find(".activity-value .activity-limit").show(); $set_div.find(".activity-value").find(".activity-limit").show(); $set_div.find(".activity-value").find("[data-act-type='group']").hide(); $set_div.find(".activity-value").find("[data-act-type='flash']").hide(); $set_div.find('div[data-act-div="pdt-view-num"]').show(); $set_div.find('div[data-act-div="pdt-view-sort"]').hide(); $set_div.find('div[data-act-div="pdt-view-list"]').hide(); $set_div.find('div[data-act-div="pdt-first"]').hide(); $set_div.find('div[data-act-div="pdt-second"]').hide(); $set_div.find('div[data-act-div="pdt-third"]').show(); $set_div.find('.activity-type-parent').show(); _pdt_view_time_data.data.act_type = 4; _pdt_view_time_data.data.act_type_id = $(this).attr("data-act-id"); } } }); } var GetActGroupPdtData = function(param) { $("#tvm-shop-loading").show(); $.ajax({ url : "Goods/ProductsOfGroupBuy", data : JSON.stringify(param), async : true, type : 'post', dataType : 'json', timeout : 10000, success : function(data) { if (AjaxStatus(data)) { return true; } SetActGroupPdtData(data.data); }, error : function(XMLHttpRequest, textStatus, errorThrown) { AjaxErrorMSG(XMLHttpRequest, textStatus, errorThrown); }, complete : function(XHR, TS) { $("#tvm-shop-loading").hide(); } }); } var SetActGroupPdtData = function(pdts) { var $set_div = $("div.tvm-shop-setting").find("div.tvm-shop-setModule:first"); var $goods_order = $set_div.find(".activity-goods-order"); _pdt_view_time_data.data.group_pdt = pdts; $goods_order.empty(); $.each(pdts, function(n, value) { var $goood_html = $('<div class="goods-order-items">' + '<div class="goods-order-image"><img src=""></div>' + '<div class="goods-order-price-type one-row-show"></div>' + '<div class="goods-order-price-number one-row-show">¥<span></span></div>' + '</div>'); $goood_html.attr("data-index", n); $goood_html.find("img").attr("src", value.product.product_image); $goood_html.find(".goods-order-price-number span").text( PaddingZero(value.product.unit_price)); $goood_html.find(".goods-order-price-type").text(value.product.product_name); $goods_order.append($goood_html); }); $set_div.find(".activity-goods-order").sortable().bind('sortupdate', function() { if ($set_div.find(".activity-goods-price em").hasClass("on")) { $set_div.find(".activity-goods-price em").removeClass("on"); _pdt_view_time_data.data.group_sort = 0; } }); }
const chalk = require('chalk'); module.exports = function() { console.log( chalk.yellow( ` 1) This is, essentially, a string concatenation problem 2) If you're having trouble accessing data from the input person object, lookup "js object dot notation" 3) To access objects within objects, just use object dot notation one layer deeper (i.e. - objectName.innerObjectName.propertyIWant) 4) Make sure that the final value is stated on the same line after the "return" keyword ` ) ); process.exit(); };
import React from "react"; import Layout from "../components/layout" import SEO from "../components/seo" import PageLayout from "../components/pageLayout/pageLayout" import { osporivanieKadastrovojSistemu } from "../contants" const SporKadastr = () => ( <Layout> <SEO title="Оспаривание кадастровой стоимости"/> <PageLayout page={osporivanieKadastrovojSistemu}/> </Layout> ) export default SporKadastr
import React from 'react' class Timer extends React.Component { render () { return ( <div> <h2>00:{this.props.time}</h2> </div> ) } } export default Timer
// @flow import * as React from 'react'; import { connect } from 'react-redux'; import { type Dispatch } from 'redux'; import { Platform } from 'react-primitives'; import { select } from '../../store'; import { MessengerContext } from '../../MessengerContext'; import { dispatchSocketMessage } from '../../ConnectionManager/Connection'; import { createSubToConversation, cancelSubToConversation, requestMessagesBatch, } from '../../ConnectionManager/messages'; import { loading } from '../../store/actions'; import { MessageList } from './MessageList'; import type { MessageBatchRequest } from '../../types'; type Props = { activeConversationId: *, loadingMessages: boolean, onMessagePress(message: *): mixed, }; type CP = { conversationDetail: *, viewer: *, subscribeToUpdates(): mixed, unsubscribeFromUpdates(): mixed, requestMessages(MessageBatchRequest): mixed, }; type State = {}; class Renderer extends React.Component<Props & CP, State> { componentDidMount() { this.props.subscribeToUpdates(); } componentDidUpdate(prevProps: Props) { if (Platform.OS === 'web') { return; } if (prevProps.activeConversationId !== this.props.activeConversationId) { this.props.subscribeToUpdates(); } } // ak niekto zmaze tuto cas, ruky a nohy dolamem!! componentWillReceiveProps(nextProps: Props) { if (Platform.OS === 'web') { return; } if ( nextProps.activeConversationId !== this.props.activeConversationId && this.props.connected ) { this.props.unsubscribeFromUpdates(); } } componentWillUnmount() { if (this.props.connected) { this.props.unsubscribeFromUpdates(); } } onRequestPreviousMessages = () => { if (this.props.loadingMessages) { return; } const detail = this.props.conversationDetail; this.props.requestMessages({ conversation_id: detail.conversation_id, cursor: detail.messages[detail.messages.length - 1].id, limit: detail.limit, }); }; render() { if (this.props.activeConversationId === undefined) { return null; } return ( <MessengerContext.Consumer> {context => { const { Loader } = context.components; return this.props.conversationDetail && this.props.viewer ? ( <MessageList conversation={this.props.conversationDetail} viewer={this.props.viewer} onRequestPreviousMessages={this.onRequestPreviousMessages} onMessagePress={this.props.onMessagePress} busy={this.props.loadingMessages} /> ) : ( <Loader /> ); }} </MessengerContext.Consumer> ); } } const mapState = (state, props) => ({ loadingMessages: select.loading(state, 'get_messages'), conversationDetail: select.conversationDetail(state, { conversation_id: props.activeConversationId, }), viewer: select.viewer(state), connected: select.connected(state), }); const mapDispatch = (dispatch: Dispatch<*>, props) => ({ subscribeToUpdates: () => props.activeConversationId ? dispatchSocketMessage(createSubToConversation(props.activeConversationId)) : null, unsubscribeFromUpdates: () => props.activeConversationId ? dispatchSocketMessage(cancelSubToConversation(props.activeConversationId)) : null, requestMessages: request => { dispatch(loading({ get_messages: true })); dispatchSocketMessage(requestMessagesBatch(request)); }, }); export const ConversationDetail = connect( mapState, mapDispatch, )(Renderer);
import React, { useEffect, useRef, useMemo, useState } from "react"; import * as d3 from 'd3'; import { getColorByCompanyCategory } from '../../utility_functions/ColorFunctions.js'; import classes from './MegaBallsView_v2.module.scss'; import data from '../../data/companies_details.json'; import { keyBy } from 'lodash'; // import styles from '../../globalStyle.module.scss'; const fontSizeOfCompanyDetail = 30 / 2; // /2 because scale for balls and tooltip increased by 2 in y and x axis const maxZoomScale = 8; const minZoomScale = 0.5; const companies = keyBy(data, 'name'); const MegaBalls = ({ height = window.innerHeight, width = window.innerWidth, margin = { left: 0, right: 0, top: 0, bottom: 0 }, year = 2010, data = [], }) => { const [tooltipName, setTooltipName] = useState(""); const [tooltipEmployees, setTooltipEmployees] = useState(""); const [tooltipRevenue, setTooltipRevenue] = useState(""); const [tooltipPosition, setTooltipPosition] = useState({ x: 0, y: 0 }); const [tooltipFounded, setTooltipFounded] = useState(""); const [tooltipFounders, setTooltipFounders] = useState(""); const [tooltipInfo, setTooltipInfo] = useState(""); const [tooltipWebsite, setTooltipWebsite] = useState(""); const [foundedIn, setFoundedIn] = useState(""); const [foundedBy, setFoundedBy] = useState(""); const anchor = useRef(); const didMount = useRef(false); const simulation = useRef(null); const zoom = useRef(null); function onCursorMove(e) { setTooltipPosition({ x: e.nativeEvent.offsetX + 5, y: e.nativeEvent.offsetY + 5 }) } useEffect(() => { setupContainersOnMount(); resetZoom(); drawBalls(); didMount.current = true; //----- FUNCTION DEFINITIONS ------------------------------------------------------// function setupContainersOnMount() { if (!didMount.current) { setupSimulation(); const anchorNode = d3.select(anchor.current) .attr("preserveAspectRatio", "xMinYMin meet") .attr("viewBox", "0 0" + (width) + " " + (height)) .attr("overflow", 'visible') .classed("svg-content", true) let canvas = anchorNode.append('g').classed("canvas", true); //glow definitions let defs = anchorNode.append("defs"); let filter = defs.append("filter") .attr("id", "glow") .attr("x", "-5000%") .attr("y", "-5000%") .attr("width", "10000%") .attr("height", "10000%"); filter.append("feGaussianBlur") .attr("stdDeviation", "8.0") .attr("result", "coloredBlur"); let feMerge = filter.append("feMerge"); feMerge.append("feMergeNode") .attr("in", "coloredBlur"); feMerge.append("feMergeNode") .attr("in", "SourceGraphic"); zoom.current = d3.zoom(); zoom.current.scaleExtent([1, maxZoomScale]); canvas.append('g').classed('balls', true).attr("transform", "translate(" + width / 2 + "," + height / 2 + ") scale(2,2)"); canvas.append('g').classed('tooltip', true).attr("transform", "translate(" + width / 2 + "," + height / 2 + ") scale(2,2)") // .append('text') // .attr('class', 'companyTooltip') // .attr("font-weight", 450) // .attr('x', 0) // .attr('y', 0) // .attr('text-anchor', 'middle') // .style('font', "Open Sans") // .attr("font-size", fontSizeOfCompanyDetail) // .attr("cursor", "none") // .attr("pointer-events", "none") // .attr("opacity", 0) // .append('tspan'); // setup zoom functionality zoom.current = d3.zoom(); zoom.current.scaleExtent([minZoomScale, maxZoomScale]); anchorNode.call(zoom.current.on("zoom", function () { anchorNode.select(".canvas").attr("transform", d3.event.transform); const fontSize = d3.event.transform.k >= 1 ? fontSizeOfCompanyDetail / d3.event.transform.k : fontSizeOfCompanyDetail; d3.select('.companyTooltip').attr("font-size", (fontSize) + "px"); })); } } function resetZoom() { zoom.current = d3.zoom(); zoom.current.scaleExtent([0.5, maxZoomScale]); d3.select(anchor.current).selectAll(".canvas").transition().duration(1000).attr("transform", d3.zoomIdentity); d3.select(anchor.current).call(zoom.current.transform, d3.zoomIdentity); } function setupSimulation() { simulation.current = d3.forceSimulation() .force("forceX", d3.forceX().strength(-0.04).x(0)) .force("forceY", d3.forceY().strength(-0.04).y(0)) .force("charge", d3.forceManyBody().strength(-1)) .force('collision', d3.forceCollide().radius((d) => { return d.size; })) .force("charge", d3.forceManyBody().strength(-2)) .velocityDecay(0.83) //.force("collide", d3.forceCollide().strength(1).radius((d) => { return d.size }) //.iterations(10)); } function drawBalls() { var balls = d3.select('.balls').selectAll('circle').data(data.nodes, (d) => { return d.key }); balls.on('mouseover', function (d) { d3.selectAll('.companyTooltip') .text(function () { return d.name + ": " + (d.employees === null ? '0' : d.employees) + " employee(s) & " + d.revenue + 'SEK revenue in ' + year; }); }) .attr("opacity", 0.9); balls.transition() .duration(500) .attr("r", (d) => d.size); // d3.select(anchor.current).append('circle').attr('cx', width / 2).attr('cy', height / 2).attr('r', 100); // var formatter = new Intl.NumberFormat('se', { // style: 'currency', // currency: 'SEK', // }); var enter = balls.enter() .append("circle") .attr("id", (d) => d.key) .attr("class", (d) => "_" + d.id) .attr("fill", function (d) { return getColorByCompanyCategory(d.id) }) .attr("opacity", 0.9) .on('mouseenter', function (d, e) { var self = d3.select(this); const x = self.attr('cx'); const y = self.attr('cy'); setTooltipName(d.name); setTooltipEmployees(d.employees); setTooltipRevenue(new Intl.NumberFormat('en-US').format(d.revenue)); setTooltipPosition({ x: e.clientX, y: e.clientY }); if (d && Object.keys(companies).includes(d.name)) { setFoundedIn("Founded in: "); setFoundedBy("Founders: "); setTooltipFounded(companies[d.name].founded); setTooltipFounders(companies[d.name].founders); setTooltipInfo(companies[d.name].info); setTooltipWebsite(companies[d.name].website); } else { setFoundedIn("") setFoundedBy("") setTooltipFounded("") setTooltipFounders("") setTooltipInfo("") setTooltipWebsite("") } /* d3.select('.tooltip') .append('rect') .attr('class', 'companybox') .attr('width', '100') .attr('height', '100') .attr("x", (x + width / 2)) .attr("y", y + height / 2) .style('fill', 'white') */ //.text(() => { return d.name + ": " + (d.employees === null ? '0' : d.employees) + " employee(s) & " + d3.format(",")(d.revenue) + ' SEK revenue in ' + year }) //.transition() //.delay(20) //.attr("opacity", 1).select("tspan") //.attr("font-weight", 300) //.text(" but this is not."); }) .on('mouseout', function (d) { d3.select('.companybox').remove() setTooltipName("") //.attr("opacity", 0) //.text(""); }) .attr('fill-opacity', 1.0) .attr("stroke", d => d.error ? "red" : "black") .style("stroke-width", '1px') .attr("vector-effect", "non-scaling-stroke") .attr("stroke-opacity", 0.2) .style("filter", function (d) { //TODO: GLOW if (Object.keys(companies).includes(d.name)) { return "url(#glow)"; } return ""; }) .transition(d3.easeLinear) .duration(700) .attr("r", (d) => d.size); balls.exit().transition(d3.easeLinear) .duration(700) .attr("r", 0).remove(); var enterAndUpdateBalls = balls.merge(enter); simulation.current.nodes(data.nodes) .on("tick", (d) => { enterAndUpdateBalls .attr("cx", function (d) { return d.x }) .attr("cy", function (d) { return d.y }); }); simulation.current.alpha(1).restart(); } return () => { simulation.current.stop(); } }, [year, width, height, data.nodes]); // useEffect return <div onMouseMove={onCursorMove}> <div className={classes.tooltipBox} style={{ display: tooltipName ? 'block' : 'none', left: `${tooltipPosition.x}px`, top: `${tooltipPosition.y}px` }}> <div className={classes.tooltipName}>{tooltipName}</div> <div className={classes.tooltipEmployees}><b>Number of employees:</b> {tooltipEmployees}</div> <div className={classes.tooltipRevenue}><b>Revenue:</b> {tooltipRevenue} kSEK</div> <div className={classes.tooltipFounded}><b>{foundedIn}</b> {tooltipFounded}</div> <div className={classes.tooltipFounders}><b>{foundedBy}</b>{tooltipFounders}</div> <div className={classes.tooltipInfo}>{tooltipInfo}</div> <a href={tooltipWebsite} className={classes.tooltipWebsite}>{tooltipWebsite}</a> </div> <svg overflow='visible' height={height} width={width} ref={anchor} /> </div> }; export default MegaBalls; //old code: // const nodes = data.nodes.map((node) => { // let copyNode; // if (node.key === 3812) { // const copyNode = node; // copyNode.x = width / 15; // copyNode.y = 0; // return node; // } // if (node.key === 26110) { // const copyNode = node; // copyNode.x = 0; // copyNode.y = -height / 15; // return node; // } // if (node.key === 72190) { // const copyNode = node; // copyNode.x = -width / 15; // copyNode.y = 0; // return node; // } // copyNode = node; // return copyNode; // });
import React, { useEffect, useState } from "react"; import { InputAdornment, Paper, makeStyles, Fab, TableBody, TableRow, TableCell, Toolbar, } from "@material-ui/core"; import useTable from "../../components/useTable"; import SearchIcon from "@material-ui/icons/Search"; import AddIcon from "@material-ui/icons/Add"; import EditOutlinedIcon from "@material-ui/icons/EditOutlined"; import DeleteIcon from "@material-ui/icons/Delete"; import ClinicService from "../../services/clinic.service"; import PageHeader from "../../components/PageHeader/PageHeader"; import { ReactComponent as ClinicIcon } from "../../assets/svg_icons/clinic.svg"; import Controls from "../../components/controls/Controls"; import ClinicForm from "./ClinicForm"; const useStyles = makeStyles((theme) => ({ pageContent: { margin: theme.spacing(5), padding: theme.spacing(3), }, searchInput: { width: "75%", }, addButton: { position: "absolute", right: "10px", }, })); const columnCells = [ { id: "clinicName", label: "Clinic Name" }, { id: "clinicCity", label: "City" }, { id: " clinicNPI", label: "NPI", disableSorting: true }, { id: "clinicPhone", label: "Main Phone", disableSorting: true }, { id: "actions", label: "Actions", disableSorting: true }, ]; export default function ClinicTable() { const classes = useStyles(); const [loadData, setLoadData] = useState(true); const [recordForEdit, setRecordForEdit] = useState(null); const [records, setRecords] = useState([]); // Initialize with a default filter of all records, bypasses initial load error const [filterFn, setFilterFn] = useState({ fn: (items) => { return items; }, }); const [openPopup, setOpenPopup] = useState(false); const [notify, setNotify] = useState({ isOpen: false, message: "", type: "", }); const [confirmDialog, setConfirmDialog] = useState({ isOpen: false, title: "", subTitle: "", }); // const dispatch = useDispatch(); useEffect(() => { getClinics(); }, [loadData]); async function getClinics(e) { try { const response = await ClinicService.getAllClinics(); setRecords(response.data); setLoadData(false); } catch (e) { console.log("API call unsuccessful", e); } } const { TblContainer, TblHead, TblPagination, recordsAfterPagingAndSorting } = useTable(records, columnCells, filterFn); const handleSearch = (e) => { let target = e.target; // state can't store functions, so we are storing an object with the function internally defined. setFilterFn({ fn: (items) => { // target.value is the search box contents if (target.value === "") return items; else return items.filter( (x) => x.clinicName.toLowerCase().includes(target.value.toLowerCase()) || x.clinicCity.toLowerCase().includes(target.value.toLowerCase()) || x.clinicNPI.toLowerCase().includes(target.value.toLowerCase()) ); }, }); }; const addOrEdit = (clinic, resetForm) => { console.log("Clinic id: ", clinic.clinicId); if (clinic.clinicId === 0) { ClinicService.addClinic(clinic); setLoadData(true); // Request reload of data } else { ClinicService.updateClinic(clinic); setLoadData(true); // Request reload of data } resetForm(); setRecordForEdit(null); setOpenPopup(false); // Close Popup modal setNotify({ isOpen: true, message: "Submitted Successfully", type: "success", }); }; const openInPopup = (item) => { setRecordForEdit(item); setOpenPopup(true); }; const onDelete = (id) => { setConfirmDialog({ ...confirmDialog, isOpen: false, }); ClinicService.deleteClinic(id); setLoadData(true); setNotify({ isOpen: true, message: "Record deleted", type: "error", }); }; return ( <React.Fragment> <PageHeader title="Clinics" subtitle="List of available clinics" icon={<ClinicIcon />} isSvg={true} /> <Paper className={classes.pageContent}> <Toolbar> <Controls.Input label="Search Clincs, Cities, and NPI's" fullWidth={false} className={classes.searchInput} InputProps={{ startAdornment: ( <InputAdornment position="start"> <SearchIcon /> </InputAdornment> ), }} onChange={handleSearch} /> <Fab className={classes.addButton} color="secondary" aria-label="add" size="small" onClick={() => { setOpenPopup(true); setRecordForEdit(null); }} > <AddIcon /> </Fab> </Toolbar> <TblContainer> <TblHead /> <TableBody> {recordsAfterPagingAndSorting().map((item) => ( <TableRow key={item.clinicId}> <TableCell>{item.clinicName}</TableCell> <TableCell>{item.clinicCity}</TableCell> <TableCell>{item.clinicNPI}</TableCell> <TableCell>{item.clinicPhone}</TableCell> <TableCell> <Controls.ActionButton color="primary" onClick={() => openInPopup(item)} > <EditOutlinedIcon fontSize="small" /> </Controls.ActionButton> <Controls.ActionButton color="secondary" onClick={() => { setConfirmDialog({ isOpen: true, title: "Are you sure you want to delete this clinic?", subTitle: "You can't undo this action.", onConfirm: () => { onDelete(item.clinicId); }, }); }} > <DeleteIcon fontSize="small" /> </Controls.ActionButton> </TableCell> </TableRow> ))} </TableBody> </TblContainer> <TblPagination /> </Paper> <Controls.Popup openPopup={openPopup} setOpenPopup={setOpenPopup} title="Clinic Form" > <ClinicForm recordForEdit={recordForEdit} addOrEdit={addOrEdit} /> </Controls.Popup> <Controls.Notification notify={notify} setNotify={setNotify} /> <Controls.ConfirmDialog confirmDialog={confirmDialog} setConfirmDialog={setConfirmDialog} /> </React.Fragment> ); }
define( [ "ember" ], function( Ember ) { return Ember.Object.extend({ /** @type {ChildProcess} spawn */ spawn : null, stream : null, quality: null, started: undefined, nameBinding : "stream.channel.name", displayNameBinding: "stream.channel.display_name", statusBinding : "stream.channel.status", /** @type {(TwitchUserSubscription|boolean)} _subscribed */ _subscribed : false, subscribed : Ember.computed.bool( "_subscribed" ), /** @type {(TwitchUserFollowsChannel|boolean)} _following */ _following : null, following : Ember.computed.bool( "_following" ), following_loading: Ember.computed.equal( "_following", null ), following_lock : false, init: function() { this.started = new Date(); }, kill: function() { if ( this.spawn ) { this.spawn.kill( "SIGTERM" ); } }, qualityObserver: function() { // The LivestreamerController knows that it has to spawn a new child process this.kill(); }.observes( "quality" ) }).reopenClass({ toString: function() { return "Livestreamer"; } }); });
const test = require('../../test'); module.exports = function(argv) { let options = { fnName: 'isEuroFormat', esVersion: 5, allowHigherOrderFns: false }; let test1 = { input: 'isEuroFormat("X04135981862")', expected: true }; let test2 = { input: 'isEuroFormat("x04135981862")', expected: false }; let test3 = { input: 'isEuroFormat("504135981862")', expected: false }; let test4 = { input: 'isEuroFormat("X041359818626")', expected: false }; let test5 = { input: 'isEuroFormat("X0413598186")', expected: false }; let test6 = { input: 'isEuroFormat("XX4135981862")', expected: false }; test(argv, [test1, test2, test3, test4, test5, test6], options); };
import React from 'react' import Layout from '../components/Layout'; import './../style/global.css' import { withStyles } from '@material-ui/core/styles' import "react-responsive-carousel/lib/styles/carousel.min.css"; import { Carousel } from 'react-responsive-carousel'; import RecipeReviewCard from '../components/card'; class Home extends React.Component{ constructor(props, context) { super(props, context); this.state = { metas:{} }; } newOptions() { this.setState({ nav: true // Show next and prev buttons }); } render(){ return( <div> <Layout title="Home" description="A next js starter pack with seo and react material-ui" > <div className="hero"> <Carousel> <div> <img src="http://react-responsive-carousel.js.org/assets/4.jpeg" /> <p className="legend">Legend 1</p> </div> <div> <img src="http://react-responsive-carousel.js.org/assets/4.jpeg" /> {/* <p className="legend">Legend 2</p> */} </div> <div> <img src="http://react-responsive-carousel.js.org/assets/4.jpeg" /> {/* <p className="legend">Legend 3</p> */} </div> </Carousel> <div style={{margin:10,flexDirection:'row'}}> <RecipeReviewCard image="https://material-ui.com/static/images/cards/paella.jpg"/> <RecipeReviewCard image="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSU-1KVqGBBPiFsPUDYeNa97R0gjpPBm5LzvXj-Ka7l_2Y3IY4d"/> </div> </div> <style jsx global>{` `}</style> </Layout> </div> ) } } const styles = theme => ({ container: { display: 'flex', flexWrap: 'wrap' }, title: { fontSize: 14 } }) export default withStyles(styles)(Home);
import axios from 'axios' const token = localStorage.getItem("token"); export const login = (email, password) => { const data = { email, password, }; return axios({ method: "POST", url: "https://kas-e.herokuapp.com/api/v1/user/login", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, data: JSON.stringify(data), }); }; export const register = ( email, password, confirmPassword, fullName, gender, age ) => { const data = { email, password, confirmPassword, fullName, gender, age, }; return axios({ method: "POST", url: "https://kas-e.herokuapp.com/api/v1/user/register", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, data: JSON.stringify(data), }); }; export const profile = () => { return axios({ method: "GET", url: "https://kas-e.herokuapp.com/api/v1/profile", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, }); }; export const getSafe = async () => { const url = `https://kas-e.herokuapp.com/api/v1/safe`; try { const response = await fetch(url, { method: "GET", headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}`, }, }); return response.json(); } catch (error) { throw error; } }; export const createSafe = (safeName, amount) => { const url = `https://kas-e.herokuapp.com/api/v1/safe/create` const data = { safeName, amount, }; try { const response = fetch(url, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}`, }, body: JSON.stringify(data), }); return response; } catch (error) { throw error; } }; export const updateSafe = (safeName, amount) => { const url = `https://kas-e.herokuapp.com/api/v1/safe`; const data = { safeName, amount, }; try { const response = fetch(url, { method: "PUT", headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}`, }, body: JSON.stringify(data), }); return response; } catch (error) { throw error; } }; export const deleteSafeId = (id) => { const data = { id, } return axios({ method: "DELETE", url: `https://kas-e.herokuapp.com/api/v1/safe/${id}`, headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, data: JSON.stringify(data), }); }; export const getTransaction = () => { return axios({ method: "GET", url: "https://kas-e.herokuapp.com/api/v1/transaction", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, }); }; export const getTransactionDaily = (date) => { return axios({ method: "GET", url: `https://kas-e.herokuapp.com/api/v1/transaction/daily?date=${date}`, headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, }); }; export const getTransactionMonthly = (date) => { return axios({ method: "GET", url: `https://kas-e.herokuapp.com/api/v1/transaction/monthly?date=${date}`, headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, }); }; export const addTransaction = ( category_id, detailExpense, expense, safe_id ) => { const data = { category_id, detailExpense, expense, safe_id, }; return axios({ method: "POST", url: "https://kas-e.herokuapp.com/api/v1/transaction", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, data: JSON.stringify(data), }); }; export const deleteTransaction = (id_transaction) => { return axios({ method: 'DELETE', url: `https://kas-e.herokuapp.com/api/v1/transaction/${id_transaction}`, headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, }) } export const getCategory = () => { return axios({ method: "GET", url: "https://kas-e.herokuapp.com/api/v1/limit", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, }); }; export const getProfile = (token) => { return axios({ method: "GET", url: "https://kas-e.herokuapp.com/api/v1/profile", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, }); }; export const addIncome = (safe_id, expense) => { const data = { safe_id, expense: parseInt(expense), }; return axios({ method: "POST", url: "https://kas-e.herokuapp.com/api/v1/transaction/addincome", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, data, }); }; // export const getReportDaily = () => { // return axios({ // method: "GET", // url: "https://kas-e.herokuapp.com/api/v1/report/daily", // headers: { // Authorization: `Bearer ${token}`, // "Content-Type": "application/json", // }, // }); // }; export const editCategoryLimit = (category_id, limit) => { const data = { category_id, limit, }; return axios({ method: "PUT", url: "https://kas-e.herokuapp.com/api/v1/limit", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, data: JSON.stringify(data), }); }; export const limitFirst = (params) => { return axios({ method: "POST", url: "https://kas-e.herokuapp.com/api/v1/limit", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, data: JSON.stringify(params), }); }; export const getReportDaily = (date) => { return axios({ method: "GET", url: `https://kas-e.herokuapp.com/api/v1/report/daily?date=${date}`, headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, }); }; export const getReportMonthly = (date) => { return axios({ method: "GET", url: `https://kas-e.herokuapp.com/api/v1/report/monthly?date=${date}`, headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, }); };
const {Sequelize}=require('sequelize'); const db=new Sequelize('sinfit','root','',{ host:'localhost', dialect:'mysql', port:'3306', define:{ timestamps:false } }); module.exports=db;
// leave off @2x/@3x const images = { // labor labor_01: require('./images/labor/labor_01.jpg'), labor_02: require('./images/labor/labor_02.jpg'), labor_03: require('./images/labor/labor_03.jpg'), labor_04: require('./images/labor/labor_04.jpg'), labor_05: require('./images/labor/labor_05.jpg'), // person ap_beka: require('./images/persons/ap_beka.jpg'), ap_brinkmann: require('./images/persons/ap_brinkmann.jpg'), ap_gerve: require('./images/persons/ap_gerve.jpg'), ap_homburg: require('./images/persons/ap_homburg.jpg'), ap_kirjanov: require('./images/persons/ap_kirjanov.jpg'), ap_koch: require('./images/persons/ap_koch.jpg'), ap_kodde: require('./images/persons/ap_kodde.jpg'), ap_mai: require('./images/persons/ap_mai.jpg'), ap_naermann: require('./images/persons/ap_naermann.jpg'), ap_schoepper: require('./images/persons/ap_schoepper.jpg'), ap_tuepker: require('./images/persons/ap_tuepker.jpg'), ap_wenning: require('./images/persons/ap_wenning.jpg'), }; export default images
import RNFirebase from 'react-native-firebase' import express from 'express' const firebase = RNFirebase.initializeApp({ // config options });
class BoardController { constructor() { console.log("loaded board"); } }
export const API_BASE_URL = 'http://localhost/space/public/api';
import React from 'react'; import {Route, IndexRoute} from 'react-router'; import App from './components/App'; import Home from './components/Home'; import SignupPage from './components/signup/SignupPage'; import LoginPage from './components/signup/LoginPage'; import ProductByCate from './components/product/ProductByCate'; import ProductDetail from './components/product/ProductDetail'; import CartContainer from './components/shopping_cart/CartContainer'; import ThankYou from './components/shopping_cart/ThankYou'; export default ( <Route path="/" component={App} > <IndexRoute component={Home}/> <Route path="signup" component={SignupPage} /> <Route path="login" component={LoginPage} /> <Route path="productbycate/:id" component={ProductByCate} /> <Route path="productdetail/:id" component={ProductDetail} /> <Route path="shoppingcart" component={CartContainer} /> <Route path="thankyou" component={ThankYou}/> </Route> )
'use strict'; (() => { const optimist = require('optimist'); const colors = require('colors'); const Toichi = require(__dirname + '/Toichi'); const argv = optimist .boolean('h') .alias('h', 'help') .default('h', false) .describe('h', 'show this help.') .string('o') .alias('o', 'out') .describe('o', 'output file name.') .string('i') .alias('i', 'interval') .describe('i', 'gif animation interval.') .string('c') .alias('c', 'column') .default('c', '1') .describe('c', 'sprite columns') .argv; if (argv.h) { optimist.showHelp(); return; } const toichi = new Toichi({ files: argv._, dest: argv.out, column: isNaN(argv.column) ? 1 : argv.column, interval: argv.interval }); toichi.on('error', (err) => { console.error(err); }); toichi.on('file', (file) => { console.log( '[file]'.green, `(${file.index + 1} / ${file.all})`, `${file.path} -> ${file.dest}` ); }); toichi.on('end', (result) => { console.log( '[done]'.green, `${result.outputFile} (${result.count} files)` ); }); toichi.start(); })();
import React, {useState} from 'react' import Products from './Products' import Total from './Total'; import ProductForm from './ProductForm' function ProductList() { const [product, setProduct]=useState([ {id:1,name:"Andrpod",price:150}, {id:2,name:"Apple",price:170}, {id:3,name:"Nokia",price:65}, ]); const addproduct = (productObj)=>{ setProduct([...product, productObj]); } const [total, setTotal] = useState(0); const calculateTotal = (price)=>{ setTotal(total+parseInt(price)); }; const parentFunction = (x)=>{ alert("You Presed "+x); }; return ( <div> <ProductForm index={product.length} onAddProduct={addproduct}/> {product.map((p)=>( <Products key={p.id} name={p.name} price={p.price} parentFun={parentFunction} onCalculateTotal={calculateTotal}/> ))} <hr/> {/* <Products name="Apple" price={170} parentFun={parentFunction} onCalculateTotal={calculateTotal}/> <hr/> <Products name="Nokia" price={65} parentFun={parentFunction} onCalculateTotal={calculateTotal}/> */} <Total totalCash={total}/> </div> ) } export default ProductList
var express = require('express') var mongoose = require('mongoose'); var MongoStore = require('connect-mongo')(express); var app = express.createServer(); require('./app/config/initialize.js')(app, express); require('./app/config/routes.js')(app); db.connection.on('open', function () { app.listen(3000); });
/* 공백으로 구분하여 두 숫자가 주어집니다. 두번째 숫자로 첫번째 숫자를 나누었을 때 그 몫과 나머지를 공백으로 구분하여 출력하세요. */ const n = prompt('두 수를 입력하세요.').split(' '); const ans = Math.floor(parseInt(n[0],10) / parseInt(n[1],10)); const remain = parseInt(n[0],10) % parseInt(n[1],10); console.log(`${ans} ${remain}`); /* const n = prompt('수를 입력하세요.').split(' '); const result = Math.floor(parseInt(n[0], 10) / parseInt(n[1], 10)); const left = parseInt(n[0], 10) % parseInt(n[1], 10); console.log(result, left); */
import React, { Component } from 'react'; import './App.css'; import Clock from './Clock'; class App extends Component { constructor(props) { super(props); this.state= { deadLine: "June 3, 2018", }; } render() { return ( <div className="tc helvetica App"> <div className= "f1 "> Countdown to {this.state.deadLine} </div> <br/> <Clock deadLine={this.state.deadLine}/> </div> ); } } export default App;
//Creational Patterns: Constructor Pattern, added prototype, as module var repo = require('./taskRepository') var Task = function (data) { this.name = data.name; this.completed = data.completed; }; Task.prototype.complete = function () { console.log('Task completed: ' + this.name); this.completed = true; }; Task.prototype.save = function () { console.log('Saving task: ' + this.name); repo.set(this); }; module.exports = Task;
const CHANGE_TYPE = { UP: "UP", DOWN: "DOWN", }; const ERROR_TYPE = { NOT_FOUND: "NOT_FOUND", NOT_POSSIBLE: "NOT_POSSIBLE", INVALID_INPUT: "INVALID_INPUT", }; let numbers = [4, 6, 10, 23, 0, 24, 30, 2]; // Your code here... const numbersContainer = document.getElementById("numbers-container") function print(numb) { numbersContainer.innerHTML = "" numb.forEach(number => { let item = document.createElement("span") item.innerText = String(number) numbersContainer.appendChild(item) }) } print(numbers) const itemInput = document.getElementById("item-input") const countInput = document.getElementById("count-input") const typeContainer = document.getElementsByName('type') const errorContainer = document.getElementById("error-container") const submitBtn = document.getElementById("submit-btn") // itemInput.addEventListener("input", (e) => console.log(e)) Array.prototype.move = function(from, to) { this.splice(to, 0, this.splice(from, 1)[0]); }; submitBtn.addEventListener("click", () => { const item = itemInput.value const count = countInput.value const direction = typeContainer[0].checked ? "UP" : "DOWN" const error = handleError(item, count, direction) console.log(error) if (error) { switch (error) { case ERROR_TYPE.INVALID_INPUT: errorContainer.innerHTML = `<p id="error">${ERROR_TYPE.INVALID_INPUT}</p>` return case ERROR_TYPE.NOT_FOUND: errorContainer.innerHTML = `<p id="error">${ERROR_TYPE.NOT_FOUND}</p>` return case ERROR_TYPE.NOT_POSSIBLE: errorContainer.innerHTML = `<p id="error">${ERROR_TYPE.NOT_POSSIBLE}</p>` return } } else { errorContainer.innerHTML = "" } const itemInt = parseInt(item); const countInt = parseInt(count) const index = numbers.indexOf(itemInt) let newArr = [] if (direction === "UP") { numbers.move(index, index + countInt) } else { numbers.move(index, index - countInt) } print(numbers) }) function handleError(item, count, direction) { if (item.length === 0 || count.length === 0) { return ERROR_TYPE.INVALID_INPUT } if (numbers.indexOf(parseInt(item)) === -1) return ERROR_TYPE.NOT_FOUND if (direction === "DOWN" && numbers.indexOf(parseInt(item)) - parseInt(count) < 0) { return ERROR_TYPE.NOT_POSSIBLE } if (direction === "UP" && numbers.indexOf(parseInt(item)) + parseInt(count) > (numbers.length - 1)) { return ERROR_TYPE.NOT_POSSIBLE } return false }
'use strict'; const productInfo = require('../controllers/productInfo'); const productList = require("../controllers/productList"); let productInfoRoute={ method:'GET', path: '/product/{spuNo?}', config:{ // If an error occurs when parsing a cookie don't error, just log it. state:{ failAction : 'log', } }, handler:function (request,h) { // 用productDetail中的实现来赋值 D145290A1EE5FD6951F12E36F726B497 return productInfo({spuNo:request.params.spuNo,userId:'D145290A1EE5FD6951F12E36F726B497'}); } }; let productListRoute ={ method:'GET', path: '/productList/{category?}', config:{ // If an error occurs when parsing a cookie don't error, just log it. state:{ failAction : 'log', } }, handler:function (request,h) { // 用productCtl中的实现来赋值 D145290A1EE5FD6951F12E36F726B497 return productList({category:request.params.category}); } }; module.exports=[productInfoRoute,productListRoute];
angular.module('monitoring') .controller('CliCtrl', ['$scope', '$state', 'SettingsService', 'ConfigurationService', function($scope, $state, SettingsService, ConfigurationService){ $scope.clis = []; $scope.devices = {}; ConfigurationService.getClis().then(function(response){ angular.forEach(response.result, function(item) { $scope.clis.push(item); }); }); $scope.addClick = function() { $scope.clis.push({metrics: []}); } $scope.addMetric = function(index) { var metricId = 0; angular.forEach($scope.clis[index].metrics, function(item) { if (metricId < item['metric-id']) { metricId = item['metric-id']; } }); $scope.clis[index].metrics.push({ 'metric-id': ++metricId, command : "", regexp : "" }); } $scope.deleteMetric = function(parent, index) { $scope.clis[parent].metrics.splice(index, 1); } $scope.save = function(index) { ConfigurationService.saveCli($scope.clis[index]); } SettingsService.getDevices().then(function(response){ angular.forEach(response.result, function(item) { $scope.devices[item.id] = item.name; }); }); }]);
var questions = { show_result: function() { $("#aswr-score-num").html(this.round_score); $("#total-score-num").html(this.user_score + this.round_score); $("#qstn").hide(); $("#aswr-rslt").css("display", "flex").fadeIn(900); }, show_question: function() { var $this = this; if($this.qstn_id >= $this.questions.length) { $this.show_result(); return; } var question = $this.questions[$this.qstn_id]; var qstn_content = ($this.qstn_id+1).toString() + ". " + question.question_text; var qstn_score = question.score + "分"; var count_down = question.count_down; var options_html = ""; for(var j=0;j<question.options.length;j++) { var option = question.options[j]; options_html += '<div class="border border-grey rounded-pill opt-content" option-id="' + option.option_id + '"onclick="questions.submit_answer(event)">' + option.label + ". " + option.option_text + '</div>\n'; } $("#qstn-clock").html(count_down); $("#qstn-content").html(qstn_content); $("#qstn-score").html(qstn_score); $("#options").html(options_html); $("#qstn-opts").show(); $this.qstn_id += 1; count_down = 10; $this.intv = setInterval(function() { if(count_down == -1) { var msg = "时间到"; $("#qstn-modal-body").html(msg); $("#qstn-modal").modal("show"); clearInterval($this.intv); setTimeout(function() { $("#qstn-modal").modal("hide"); }, 1000); setTimeout(function() { $this.show_question(); }, 1200); return; } $("#qstn-clock").html(count_down); count_down = count_down - 1; }, 1000); }, prepare_countdown: function(num) { var $this = this; var ret = setInterval(function() { if(num == 0) { clearInterval(ret); $this.show_question(); return; } $("#prepare").html(num); $("#prepare").fadeIn(900, function(){ $("#prepare").hide(); }); num = num - 1; }, 1000); }, get_questions: function() { var $this = this; $.ajax({ type: "GET", url: "/get_random_questions/", }).done(function(data) { if(data.success) { $this.questions = data.result.questions; $this.user_score = data.result.user_score; } else { var msg = "服务器开小差了"; $("#qstn-modal-body").html(msg); $("#qstn-modal").modal("show"); } }); }, init: function() { this.get_questions(); this.prepare_countdown(3); this.round_score = 0; this.qstn_id = 0; }, highlight_correct: function(select_opt, correct_opt) { var target = $('div[option-id="' + select_opt +'"]'); target.removeClass("border-warning text-warning").addClass("border-success bg-success text-white") }, highlight_wrong: function(select_opt, correct_opt) { var target = $('div[option-id="' + select_opt +'"]'); target.removeClass("border-warning text-warning").addClass("border-danger bg-danger text-white") }, update_score: function() { var score = parseInt($("#qstn-score").html()); this.round_score += score; $("#score-num").html(this.round_score); }, submit_answer: function(event) { var $this = this; var target = $(event.target); target.removeClass("border-grey").addClass("border-warning text-warning"); var option_id = target.attr("option-id"); $.ajax({ type: "POST", url: "/answer/submit/", data: {"option_id": option_id} }).done(function(data) { if(data.success) { var is_correct = data.result.is_correct; var correct_option = data.result.correct_option; if(is_correct) { $this.highlight_correct(option_id, correct_option); $this.update_score(); } else { $this.highlight_wrong(option_id, correct_option); } clearInterval($this.intv); setTimeout(function() { $this.show_question(); }, 200); } else { var msg = "服务器开小差了"; $("#aswrrslt-modal-body").html(msg); $("#aswrrslt-modal").modal("show"); } }); } }
export const RULE_LOADED = "RULE_LOADED"; export const RULES_LOADED = "RULES_LOADED"; export function rulesLoaded(data) { return { type: RULES_LOADED, payload: data, }; } export function ruleLoaded(data) { return { type: RULE_LOADED, payload: data, }; } // This is a thunk: a function that returns a function (with dispatch as an argument) export function loadRules() { return function (dispatch) { return fetch("/rest/rules") .then((res) => res.json()) .then((data) => { dispatch(rulesLoaded(data)); }); }; } export function loadRule(id) { return function (dispatch) { return fetch(`/rest/rules/${id}`) .then((res) => res.json()) .then((data) => { dispatch(ruleLoaded(data)); }); }; }
let selectedContact = { selectedContact: { name: null, number: null } }; export default selectedContact ;
import React from 'react' import Hero from 'components/Hero'; export default function ListOfHeros ({ heros }) { return <div className='ListOfHeros'> { heros.map(hero => <Hero url={hero.url} />) } </div> }
//用于所有页面的JS复用 $(function(){ //购彩中心的下拉菜单 $(".nav_title").hover(function(){ $(".buy_center").stop(true, true).delay(300).slideDown(50); //为了防止鼠标不经意划过区域就下拉 所以延时300毫秒下拉 },function(){ //如果反复移入移出 之前延时的下拉还没进行就开始新的下拉 那就用stop阻止掉之前的下拉动画 $(".buy_center").stop(true, true).delay(100).slideUp(50); }); //点击登录 弹登录界面 居中 遮罩锁屏 $('#dailog_login').click(function(){ $('#header_login').css('display', 'block'); center($('#header_login')); $(window).on('scroll resize', function(){ center($('#header_login')); }); screenMark(); }); //点击登录的X 隐藏登录界面 取消遮罩锁屏 $('#header_login .close').click(function(){ $('#header_login').css('display', 'none'); $('#mark').remove(); }); }); //所有页面共用函数部分 /** * 所有竞彩投注页面付款弹窗的动态生成 * json 用于动态生成.content ul下面的li * dataStr 传输给后台的json格式字符串 * .dialog的CSS都在base.css中复用 */ function MoneyDialog(json, dataStr){ //动态生成.dialog div var liStr = ''; var bStop = false; for(var attr in json){ liStr += '<li>' + attr + ':' + json[attr] + '</li>'; } $('body').append(''+ '<div class="dialog">'+ '<div class="the_title">立即付款</div>'+ '<div class="content">'+ '<ul>'+ liStr + '</ul>'+ '</div>'+ '<div class="bottom">'+ '<form action="/lottery/bet.htm" method="post">'+ '<input class="data_submit" type="submit" value="付款" />'+ '<input class="return" type="button" value="返回修改" />'+ '<input class="data" type="hidden" name="data" value="" />'+ '</form>'+ '</div>'+ '</div>'+ '') //.dialog居中 锁屏遮罩 center($('.dialog')); $(window).on('scroll resize', function(){ center($('.dialog')); }); screenMark(); //将name="data"的表单input value设置为dataStr 如果点击了付款 服务器post接收这个value $('.dialog .data').val(dataStr); //点击返回修改 移除.dialog 去掉锁屏遮罩 $('.dialog .return').click(function(){ $('.dialog').remove(); $('#mark').remove(); }); //付款的submit重复点击无效 $('.dialog form').submit(function(){ if(bStop){ return; } bStop = true; }); } function center(obj){ var nLeft = ($(window).width() - obj.width())/2 + $(window).scrollLeft(); var nTop = ($(window).height() - obj.height())/2 + $(window).scrollTop(); obj.css({"left":nLeft, "top":nTop}); } function screenMark(){ var bodyWidth = $('body').width(); var bodyHeight = $('body').height(); $('body').append('<div id="mark"></div>'); $('#mark').css({ "position": "fixed", "left": 0, "top": 0, "width": bodyWidth, "height": bodyHeight, "background": "#ccc", "opacity": 0.3, "zIndex": "9998" }); } /** * 所有页面的倒计时函数 * nDateEnd 离截止投注时间还有多少毫秒 * oDay 在页面生成距离截止投注时间天数的DOM对象 * oHour 在页面生成距离截止投注时间小时数的DOM对象 * oMin 在页面生成距离截止投注时间分钟数的DOM对象 * oSec 在页面生成距离截止投注时间秒数的DOM对象 * fn 传入的函数 在这个函数内部写ajax请求 以及回调这个函数 */ function showCountDown(nDateEnd, oDay, oHour, oMin, oSec, fn){ var Ftime = null; //每次刷新进入页面的时候 最好清下定时器 var nNow = nDateEnd/1000; //离截止投注时间还有多少秒 upDateTime(); Ftime = setInterval(upDateTime, 1000); //开启循环 一秒钟更新一次时间 function upDateTime(){ // console.time('程序耗时'); //此段程序平均耗时1ms左右 var nRemain = nNow; var nDay = parseInt(nRemain/86400); //将相差的秒数,算成多少天 小时 分钟 秒 nRemain %= 86400; var nHour = parseInt(nRemain/3600); nRemain %= 3600; var nMin = parseInt(nRemain/60); nRemain %= 60; var nSec = parseInt(nRemain); if( nDay == 0 && nHour == 0 && nMin == 0 && nSec <= 0 ){ clearInterval(Ftime); fn(); } if(oDay != null){ //如果对象为null 就不输出到html页面 oDay.html(nDay); } if(oHour != null){ oHour.html(setDigit(nHour,2)); } if(oMin != null){ oMin.html( setDigit(nMin,2)); } if(oSec != null){ oSec.html(setDigit(nSec,2)); } nNow--; //每秒nNow减1 // console.timeEnd('程序耗时'); } function setDigit(num,n){ var str = '' + num ; //num可能是数字也可能是字符串 所以统一用""+变成了字符串 便于后面的str = '0' + str while(str.length<n){ //n就是要用0把num补成几位 例如num是1位 要补成00X 那就是1<3的while 也就是whilie循环两次 str = '0' + str; //往前面填零 } return str; } } /** * 重写系统函数alert * css在base.css下 */ // function alert(info){ // $('body').append(''+ // '<div class="alert">'+ // '<div class="the_title">提示<span>×<span></div>'+ // '<div class="content">'+ info +'</div>'+ // '<div class="bottom">'+ // '<input class="alert_yes" type="button" value="确定" />'+ // '</div>'+ // '</div>'+ // ''); // $('.alert span, .alert input').click(function(){ // $('.alert').remove(); // }); // center($('.alert')); // }
//array mapping const a = [2, 4, 6, 8]; const result = a.map(x => x * 2); console.log(result);
import React from 'react'; import Main from '../components/layout/Main'; import AddEntryForm from '../containers/AddEntryForm'; const UpdateEntry = (props) => ( <div className="addEntryContent"> <Main {...props}> <AddEntryForm {...props} type="update" /> </Main> </div> ); export default UpdateEntry;
import React from "react" import styles from "./index.module.css"; export default () => <div className={styles.container}>Hello world!</div>
/* ================================================ * * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * ================================================ */ "use strict"; const fs = require('fs'); const http = require('http'); const uuidv4 = require('uuid/v4'); const request = require('request-promise-native'); const constants = require('./constants.js'); // const docStore = require('./docStore_api.js'); const errorLibrary = require('./error_library.js'); const driverName = "SODA-REST" module.exports.initialize = initialize module.exports.setDatabaseName = setDatabaseName module.exports.getSupportedFeatures = getSupportedFeatures module.exports.getDBDriverName = getDBDriverName module.exports.processError = processError module.exports.getDocumentContent = getDocumentContent module.exports.getCollection = getCollection module.exports.queryByExample = queryByExample module.exports.postDocument = postDocument module.exports.bulkInsert = bulkInsert module.exports.putDocument = putDocument module.exports.deleteDocument = deleteDocument module.exports.createIndex = createIndex module.exports.createIndexes = createIndexes module.exports.collectionExists = collectionExists module.exports.createCollection = createCollection module.exports.collectionNotFound = collectionNotFound module.exports.dropCollection = dropCollection let applicationName let connectionProperties = {} let collectionMetadata = {} let documentStoreURL = ""; let sodaPath = ""; let docStore = undefined const supportedFeatures = {} function writeLogEntry(module,comment) { const message = ( comment === undefined) ? module : `${module}: ${comment}` console.log(`${new Date().toISOString()}: ${driverName}.${message}`); } function getDBDriverName() { return driverName } function getConnectionProperties() { return connectionProperties; } function getCollectionMetadata(collectionName) { let metadata = collectionMetadata[collectionName]; if (metadata != null) { metadata = Object.assign({},metadata); delete(metadata.indexes); } return metadata } function setSodaPath(ordsRoot, schemaName, sodaRoot) { sodaPath = `${ordsRoot}/${schemaName.toLowerCase()}/${sodaRoot}`; } function setDatabaseName(databaseName) { setSodaPath(connectionProperties.ordsRoot,databaseName,connectionProperties.sodaRoot); } function getSodaPath() { return sodaPath; } function getCollectionLink(collectionName) { return `${getSodaPath()}/${collectionName}`; } function getDocumentLink(collectionName,key) { return `${getCollectionLink(collectionName)}/${key}`; } function setHeaders(contentType, etag) { var headers = {}; if (contentType === undefined) { contentType = 'application/json'; } if (contentType !== null) { headers['Content-Type'] = contentType; } if (etag !== undefined) { headers["If-Match"] = etag; } return headers; } function getLimitAndFields(queryProperties, limit, fields, includeTotal) { if (fields === undefined) { fields = 'all'; } queryProperties.fields = fields; if (limit !== undefined) { queryProperties.limit = limit; } if (includeTotal) { queryProperties.totalResults = true; } return queryProperties; } function processError(invokerId, logRequest, e) { const moduleId = `processError()`; // writeLogEntry(moduleId,JSON.stringify(e)); if ((e.statusCode) && (e.error) && (typeof e.error === "string")) { try { e.error = JSON.parse(e.error); } catch (e) {} } const details = { driver : driverName , module : invokerId , elapsedTime : e.elapsedTime ? e.elapsedTime : new Date().getTime() - logRequest.startTime , request : logRequest.logEntry ? logRequest.logEntry.request : null , stack : logRequest.logEntry.stack ? logRequest.logEntry.stack : null , underlyingCause : errorLibrary.makeSerializable(e) , status : docStore.interpretHTTPStatusCode(e.statusCode) } return new errorLibrary.GenericException(`${driverName}: Unexpected exception encountered`,details) } async function sendRequest(invokerId, sessionState, options, logContainer) { const moduleId = `${invokerId}.sendRequest("${options.method}","${options.uri}")`; // writeLogEntry(moduleId); options.resolveWithFullResponse = true options.simple = true if (getConnectionProperties().useProxy) { options.proxy = `http://${getConnectionProperties().proxy.hostname}:${getConnectionProperties().proxy.port}` } logContainer.logRequest = docStore.createLogRequest(moduleId, sessionState, options) let startTime = null try { startTime = new Date().getTime() const rawResponse = await request(options).auth(getConnectionProperties().username, getConnectionProperties().password, true); // mwriteLogEntry(moduleId,`Success : HTTP statusCode = ${rawResponse.statusCode} Elapsed time: ${rawResponse.elapsedTime}`); // writeLogEntry(moduleId,`Response:\n"${JSON.stringify(rawResponse.toJSON()," ",2)}`) // elapsedTime is lost for PUT and POST when calling toJSON() const response = rawResponse.toJSON() response.elapsedTime = rawResponse.elapsedTime return response } catch (e) { const endTime = new Date().getTime(); if (e.elapsedTime === undefined) { e.elapsedTime = endTime - startTime } if (typeof e.toJSON === 'function') { const elapsedTime = e.elapsedTime e = e.toJSON() e.elapsedTime = elapsedTime } // writeLogEntry(moduleId,`Exception:\n"${JSON.stringify(e," ",2)}`); throw processError(moduleId,logContainer.logRequest,e); } } async function processQuery(sessionState, options, limit) { const moduleId = `processQuery()` const logContainer = {} const startTime = new Date().getTime() const results = await sendRequest(moduleId, sessionState, options, logContainer); if (sessionState.sqlTrace) { sessionState.qbeRewrite = results.body.sqlStatement } if ((limit !== 'unlimited') && (limit === 0)) { results.body.items = [] results.body.count = 0 } else { if ((limit === 'unlimited') || (results.body.count < limit)) { let batchCount = 1; while (results.body.hasMore) { batchCount++ if (limit !== 'unlimited') { options.qs.limit = limit - results.body.count } options.qs.offset = results.body.count const moreResults = await sendRequest(moduleId, sessionState, options, logContainer); if (sessionState.sqlTrace) { sessionState.qbeRewrite = moreResults.body.sqlStatement } results.body.items = results.body.items.concat(moreResults.body.items); results.body.count = results.body.items.length results.body.hasMore = moreResults.body.hasMore if (results.body.count === limit) { break; } } logContainer.logRequest.endTime = new Date().getTime() logContainer.logRequest.startTime = startTime results.elapsedTime = logContainer.logRequest.endTime - logContainer.logRequest.startTime logContainer.logRequest.batchCount = batchCount } } return docStore.processResultsHTTP(moduleId, results, logContainer.logRequest); } async function getSupportedFeatures() { /* ** Test for $CONTAINS support */ const moduleId = `getSupportedFeatures()` if (Object.keys(supportedFeatures).length > 0) { return supportedFeatures } var collectionName = 'TMP_' + uuidv4(); try { const sodaResponse = await createCollection(constants.DB_LOGGING_DISABLED, collectionName); var indexDef = { name : "TEST_IDX" , unique : true , fields : [{ path : "id" , datatype : "number" , order : "asc" }] } supportedFeatures.nullOnEmptySupported = true; try { await createIndex(constants.DB_LOGGING_DISABLED, collectionName, indexDef.name, indexDef); } catch (sodaError) { if (sodaError.status === constants.BAD_REQUEST) { var sodaException = sodaError.details.underlyingCause.error; if (sodaException['o:errorCode'] === 'SQL-00907') { supportedFeatures.nullOnEmptySupported = false; } else { throw sodaError; } } else { throw sodaError; } } var qbe = {id : {"$contains" : 'XXX'}} supportedFeatures.$containsSupported = true; try { await queryByExample(constants.DB_LOGGING_DISABLED, collectionName, qbe) } catch (sodaError) { if (sodaError.status === constants.BAD_REQUEST) { var sodaException = sodaError.details.underlyingCause.error; if (sodaException.title === 'The field name $contains is not a recognized operator.') { supportedFeatures.$containsSupported = false; } else { throw sodaError; } } else { throw sodaError; } } var qbe = { geoCoding : { $near : { $geometry : { type : "Point", coordinates : [-122.12469369777311,37.895215209615884] }, $distance : 5, $unit : "mile" } } } supportedFeatures.$nearSupported = true; try { await queryByExample(constants.DB_LOGGING_DISABLED, collectionName, qbe) } catch (sodaError) { if (sodaError.status === constants.BAD_REQUEST) { var sodaException = sodaError.details.underlyingCause.error; // writeLogEntry(moduleId,'Error: ' + JSON.stringify(sodaException)); // if (sodaException['o:errorCode'] === 'SODA-02002') { if (sodaException.title === 'The field name $near is not a recognized operator.') { supportedFeatures.$nearSupported = false; } else { throw sodaError; } } else { throw sodaError; } } /* ** Create Text Index with language specification (12.2 Format with langauge and dataguide) ** ** ToDo : Can we use alternative index metadata if we encounter "DRG-10700: preference does not exist: CTXSYS.JSONREST_ENGLISH_LEXER" ** */ var indexDef = { name : "FULLTEXT_INDEX" , dataguide : "on" , language : "english" } supportedFeatures.textIndexSupported = true; try { await createIndex(constants.DB_LOGGING_DISABLED, collectionName, indexDef.name, indexDef) } catch (sodaError) { console.log(sodaError) if ((sodaError.status === constants.FATAL_ERRROR)) { var sodaException = sodaError.details.underlyingCause.error; if (sodaException['o:errorCode'] === 'SQL-29855') { supportedFeatures.textIndexSupported = false; } else { throw sodaError; } } else { throw sodaError; } } await dropCollection(constants.DB_LOGGING_DISABLED, collectionName); writeLogEntry(moduleId,`$contains operator supported: ${supportedFeatures.$containsSupported}`); writeLogEntry(moduleId,`$near operatator supported: ${supportedFeatures.$nearSupported}`); writeLogEntry(moduleId,`Text Index supported: ${supportedFeatures.textIndexSupported}`); writeLogEntry(moduleId,`"NULL ON EMPTY" supported: ${supportedFeatures.nullOnEmptySupported}`); return supportedFeatures } catch(err) { writeLogEntry(moduleId,`Exception encountered at:\n${err.stack ? err.stack : err}`); throw err; }; } async function initialize(appName, ds) { const moduleId = `initialize()` if (Object.keys(connectionProperties).length === 0) { try { if ((appName === undefined) || (appName === null)) { throw new Error (`${moduleId}: Application name is NULL or undefined.`) } if ((ds === undefined) || (ds === null)) { throw new Error (`${moduleId}: Document Store object is NULL or undefined.`) } applicationName = appName docStore = ds; const connectionDetails = fs.readFileSync(`${__dirname}/${applicationName}.connectionProperties.soda.json`); connectionProperties = JSON.parse(connectionDetails); const collectionDetails = fs.readFileSync(`${__dirname}/${applicationName}.collectionMetadata.soda.json`); collectionMetadata = JSON.parse(collectionDetails); documentStoreURL = `${connectionProperties.protocol}://${connectionProperties.hostname}` if (connectionProperties.port !== null) { documentStoreURL = `${documentStoreURL}:${connectionProperties.port}` } setSodaPath(connectionProperties.ordsRoot,connectionProperties.schemaName,connectionProperties.sodaRoot); writeLogEntry(moduleId,`Document Store URL = "${documentStoreURL}".`); await getSupportedFeatures() } catch (e) { const details = { module : moduleId , applicationName : applicationName , underlyingCause : errorLibrary.makeSerializable(e) } throw new errorLibrary.GenericException(`${driverName}: Driver Intialization Failure`,details) } } } async function getDocumentContent(sessionState, collectionName, key, binary, etag) { const moduleId = `getDocumentContent("${collectionName}","${key}")`; const options = { method : 'GET' , baseUrl : documentStoreURL , uri : getDocumentLink(collectionName,key) , headers : setHeaders(null, etag) , time : true }; if (binary) { options.encoding = null; } const logContainer = {} const results = await sendRequest(moduleId, sessionState, options, logContainer); return docStore.processResultsHTTP(moduleId, results, logContainer.logRequest); } async function getCollection(sessionState, collectionName, limit, fields, includeTotal) { const moduleId = `getCollection("${collectionName}")`; let sodaLimit = limit if ((limit !== undefined) && (limit === 0)) { sodaLimit = 1 } const options = { method : 'GET' , baseUrl : documentStoreURL , uri : getCollectionLink(collectionName) , qs : getLimitAndFields({}, sodaLimit, fields, includeTotal) , headers : setHeaders() , time : true , json : true }; return processQuery(sessionState,options,limit) } async function queryByExample(sessionState, collectionName, qbe, limit, fields, includeTotal) { const moduleId = `queryByExample("${collectionName}","${JSON.stringify(qbe)}")`; // writeLogEntry(moduleId); const options = { method : 'POST' , baseUrl : documentStoreURL , uri : getCollectionLink(collectionName) , qs : getLimitAndFields({action : "query"}, limit, fields, includeTotal) , json : qbe , time : true }; if (sessionState.sqlTrace) { options.qs["sqlStatement"] = true } return processQuery(sessionState,options,limit) } async function postDocument(sessionState, collectionName, document, contentType) { const moduleId = `postDocument("${collectionName}","${contentType}")`; const options = { method : 'POST' , baseUrl : documentStoreURL , uri : getCollectionLink(collectionName) , headers : setHeaders(contentType , undefined) , time : true }; if (contentType === 'application/json') { options.json = document } else { options.body = document } const logContainer = {} const results = await sendRequest(moduleId, sessionState, options, logContainer); // Appears BODY is a string when the payload was not JSON return docStore.processResultsHTTP(moduleId, results, logContainer.logRequest); } async function bulkInsert(sessionState, collectionName, documents) { const moduleId = `bulkInsert("${collectionName}")`; const options = { method : 'POST' , baseUrl : documentStoreURL , uri : getCollectionLink(collectionName) , qs : {action : 'insert'} , json : documents , time : true }; const logContainer = {} const results = await sendRequest(moduleId, sessionState, options, logContainer); return docStore.processResultsHTTP(moduleId, results, logContainer.logRequest); } async function putDocument(sessionState, collectionName, key, document, contentType, etag) { const moduleId = `putDocument("${collectionName}","${key}","${contentType}")`; const options = { method : 'PUT' , baseUrl : documentStoreURL , uri : getDocumentLink(collectionName,key) , headers : setHeaders(contentType , etag) , time : true }; if (contentType === 'application/json') { options.json = document } else { options.body = document } const logContainer = {} const results = await sendRequest(moduleId, sessionState, options, logContainer); const updateResponse = { id : key , etag : results.headers.etag , lastModified : results.headers["last-modified"] , location : results.headers.location } results.body = docStore.formatSingleInsert(updateResponse) return docStore.processResultsHTTP(moduleId, results, logContainer.logRequest); } async function deleteDocument(sessionState, collectionName, key, etag) { const moduleId = `deleteDocument("${collectionName}","{key}")`; writeLogEntry(moduleId) const options = { method : 'DELETE' , baseUrl : documentStoreURL , uri : getDocumentLink(collectionName,key) , headers : setHeaders(undefined, etag) , time : true }; const logContainer = {} const results = await sendRequest(moduleId, sessionState, options, logContainer); return docStore.processResultsHTTP(moduleId, results, logContainer.logRequest); } async function createIndex(sessionState, collectionName, indexName, indexMetadata) { const moduleId = `createIndex("${collectionName}","${indexName}")`; // Skip Spatial Indexes in environments where spatial operations on Geo-JSON are not supported if ((indexMetadata.spatial) && !supportedFeatures.$nearSupported) { writeLogEntry(moduleId,'Skipped creation of unsupported spatial index') return constants.HTTP_RESPONSE_SUCCESS } // Skip Text Indexes in environments where text index syntax is not supported if ((indexMetadata.language) && !supportedFeatures.textIndexSupported) { writeLogEntry(moduleId,'Skipped creation of unsupported text index' || indexMetadata.name); return constants.HTTP_RESPONSE_SUCCESS } // Remove the Singleton Key from the index definition if we are in a Pre 12.2 database if ((!supportedFeatures.nullOnEmptySupported) && (indexMetadata.fields !== undefined) && (!indexMetadata.scalarRequired)) { indexMetadata.scalarRequired = true; } const options = { method : 'POST' , baseUrl : documentStoreURL , uri : getCollectionLink(collectionName) , qs : {action : 'index'} , json : indexMetadata , time : true }; const logContainer = {} const results = await sendRequest(moduleId, sessionState, options, logContainer); return docStore.processResultsHTTP(moduleId, results, logContainer.logRequest); } function getIndexMetadata(collectionName) { const metadata = collectionMetadata[collectionName]; if ((metadata != null) && (metadata.hasOwnProperty('indexes'))) { const indexes = metadata.indexes.slice(0) // Remove disabled Indexes for (let i=0; i < indexes.length; /* i is only incremented when not splicing */ ) { if ((indexes[i].hasOwnProperty('disabled')) && (indexes[i].disabled === true)) { indexes.splice(i,1); } else { delete(indexes[i].disabled); i++; } } return indexes; } return [] } async function createIndexes(sessionState, collectionName) { const moduleId = 'createIndexes("' + collectionName + '")'; const indexes = getIndexMetadata(collectionName); const createIndexOperations = indexes.map(function(indexMetadata) { return docStore.createIndex(sessionState,collectionName,indexMetadata.name,indexMetadata) }) const logRequest = docStore.createLogRequest(moduleId, sessionState, indexes) logRequest.startTime = new Date().getTime(); const createIndexResults = await Promise.all(createIndexOperations) logRequest.endTime = new Date().getTime() const results = Object.assign({},constants.HTTP_RESPONSE_SUCCESS) results.elapsedTime = logRequest.endTime - logRequest.startTime results.json = createIndexResults return docStore.processResultsHTTP(moduleId, results, logRequest); } function collectionExists(e) { return true; } async function createCollection(sessionState, collectionName) { const moduleId = `createCollection("${collectionName}")`; const options = { method : 'PUT' , baseUrl : documentStoreURL , uri : getCollectionLink(collectionName) , json : getCollectionMetadata(collectionName) , time : true }; const logContainer = {} const results = await sendRequest(moduleId, sessionState, options, logContainer); return docStore.processResultsHTTP(moduleId, results, logContainer.logRequest); } function collectionNotFound(e) { if ((e.status) && (e.status === constants.NOT_FOUND)) { if ((e.details) && (e.details.underlyingCause)) { const sodaError = e.details.underlyingCause if ((sodaError.statusCode) && (sodaError.statusCode === 404) && (sodaError.error) && (sodaError.error['o:errorCode'] === 'REST-02000')) { return true; } } } return false; } async function dropCollection(sessionState, collectionName) { const moduleId = `dropCollection("${collectionName}")`; const options = { method : 'DELETE' , baseUrl : documentStoreURL , uri : getCollectionLink(collectionName) , time : true }; const logContainer = {} try { const results = await sendRequest(moduleId, sessionState, options, logContainer); return docStore.processResultsHTTP(moduleId, results, logContainer.logRequest); } catch (e) { if (collectionNotFound(e)) { writeLogEntry(moduleId,`NOT-FOUND: ${e.status}. Returning success.`) const results = Object.assign({},constants.HTTP_RESPONSE_SUCCESS) results.elapsedTime = e.elapsedTime return docStore.processResultsHTTP(moduleId, results, logContainer.logRequest); } throw processError(moduleId,logContainer.logRequest,e); } }
const BACKEND_URL = "http://localhost:3005" const showProps = (component) => { console.log(`${component.constructor.name} component props`, component.props) } const capitalize = (word) =>{ return word[0].toUpperCase()+word.slice(1) } export { BACKEND_URL, showProps, capitalize } // export default "no"
var cvs = document.getElementById("canvas") ; var ctx = cvs.getContext("2d"); // load images var bird = new Image(); var bg = new Image(); var fg = new Image(); var pipeNorth = new Image(); var pipeSouth = new Image(); bird.src = "images/squirt.png"; bg.src = "images/bg.png"; fg.src = "images/fg.png"; pipeNorth.src = "images/pipeNorth.png" ; pipeSouth.src = "images/pipeSouth.png" ; //audio var fly= new Audio(); var point= new Audio(); var die= new Audio(); fly.src= "sound/fly.wav"; point.src= "sound/point.wav"; die.src= "sound/die.mp3"; // some variables var gap = 100; var constant = pipeNorth.height + gap ; var bx = 10; var by = 150; var gravity = 2 ; var score =0 ; window.onkeydown = function(e){ if(e.keyCode == 32 && e.target == document.body){ e.preventDefault(); } }; // Function to stop scrolling page when spacebar is pressed document.addEventListener('keydown',moveUp); cvs.addEventListener('touchstart',function(e){ e.preventDefault(); by -= 35; fly.play(); }); function moveUp(){ by -= 35; fly.play(); } //pipe coordinates var pipe = []; pipe[0] = { x:cvs.width , y:-50} // draw images function draw() { ctx.drawImage(bg,0,0) ; for(var i=0; i<pipe.length; i++) { ctx.drawImage(pipeNorth,pipe[i].x,pipe[i].y) ; ctx.drawImage(pipeSouth,pipe[i].x, pipe[i].y + pipeNorth.height + gap) ; pipe[i].x-- ; if(pipe[i].x == 125) //generating random pipes { pipe.push({ x:cvs.width, y:Math.floor(Math.random()*pipeNorth.height)-pipeNorth.height }); } if(pipe[i].x == 5 ) { score++; point.play(); } //score increase //detecting collicsion if((bx + bird.width>=pipe[i].x && bx <=pipe[i].x + pipeNorth.width) && (by<=pipe[i].y + pipeNorth.height || by+bird.height>= pipe[i].y+ pipeNorth.height + gap) ){ die.play(); if(score<=2) alert("Lol! You Suck at this"); else if(score<=6) alert("Not Bad!"); else if(score<=11) alert("Great Job!"); else if(score>11) alert("Insane!"); location.reload(true); //reload the page } } ctx.drawImage( fg , 0 ,cvs.height - fg.height ) ; ctx.drawImage(bird,bx,by) ; by += gravity ; ctx.fillStyle="#fff"; ctx.font = "20px times new roman"; ctx.fillText("Score :" + score,cvs.width - 100, cvs.height - 10); requestAnimationFrame(draw); } draw();
import React from 'react' import { injectGlobal } from 'styled-components' injectGlobal` @font-face { font-family: 'iconi_mia'; src: url("/src/fonts/iconi_mia.eot"); src: url("/src/fonts/iconi_mia.eot?#iefix") format('embedded-opentype'), url("/src/fonts/iconi_mia.woff") format('woff'), url("/src/fonts/iconi_mia.ttf") format('truetype'), url("/src/fonts/iconi_mia.svg") format('svg'); font-weight: normal; font-style: normal; } @font-face { font-family: "Mia Light"; src: url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Light.eot"); src: url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Light.eot?#iefix") format('embedded-opentype'), url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Light.woff") format('woff'), url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Light.ttf") format('truetype'), url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Light.svg") format('svg'); font-weight: normal; font-style: normal; } @font-face { font-family: "Mia Regular"; src: url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Regular.eot"); src: url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Regular.eot?#iefix") format('embedded-opentype'), url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Regular.woff") format('woff'), url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Regular.ttf") format('truetype'), url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Regular.svg") format('svg'); font-weight: normal; font-style: normal; } @font-face { font-family: "Mia Bold"; src: url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Bold.eot"); src: url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Bold.eot?#iefix") format('embedded-opentype'), url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Bold.woff") format('woff'), url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Bold.ttf") format('truetype'), url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Bold.svg") format('svg'); font-weight: normal; font-style: normal; } @font-face { font-family: "Mia Black"; src: url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Black.eot"); src: url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Black.eot?#iefix") format('embedded-opentype'), url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Black.woff") format('woff'), url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Black.ttf") format('truetype'), url("https://mia-grotesk.s3.amazonaws.com/MiaGrotesk-Black.svg") format('svg'); font-weight: normal; font-style: normal; } html { box-sizing: border-box; -webkit-font-smoothing: antialiased; } *, *:before, *:after { box-sizing: inherit; } h1, h2, h3, h4, h5, h6, p, ul, ol, dl, blockquote, figure, table { margin: 0 0 1rem 0; } ul, ol { padding-left: 1.5rem; } ol li{ padding-left: .25rem; } li { margin: 0 0 0.25rem 0; } html, body { height: 100%; } html { position: relative; min-height: 100%; } body { color: #231f20; font-family: "Helvetica Neue", Helvetica, san-serif; background: #fff; /* Flexbox in use for sticky footer */ display: flex; flex-direction: column; margin: 0; } img { /* width: 100%; */ height: auto; max-width: 100%; } a img { transition: all .4s ease-in-out } a img:hover { opacity: 0.8; } `
import SingletonAxios from "../utils/SingletonAxios"; import ConstantType from "../constant/ConstantType"; import Client from "../client"; export default { baseUrl() { return Client.getInstance().origin + '/' + Client.getInstance().companyId + "/platform" // return Client.getInstance().origin + "/platform" }, /** * 创建群 * @param {string} groupName 群名称 * @param {Array<string>} imIds 群成员imUid集合 * @param {number} type 群类型 */ createGroup(groupName, imIds, type) { return SingletonAxios.getInstance()({ url: this.baseUrl() + "/hermes/group/createGroup", method: "post", data: { os: ConstantType.ClientType.WEB, token: Client.getInstance().token, formData: { groupName: groupName, imIds: imIds, type: type, settings: "" } } }); }, /** * 创建官方群 * @param {string} orgId 组织节点Id * @param {string} groupName 群名称 * @param {number} groupType 群类型 * @param {boolean} filiale 是否包含分公司 * @param {boolean} prodepart 是否包含项目部 * @param {boolean} parttime 是否包含兼职人员 */ createOfficialGroup(orgId, groupName, groupType, filiale, prodepart, parttime) { return SingletonAxios.getInstance()({ url: this.baseUrl() + "/hermes/group/createOfficialGroup", method: "post", data: { os: ConstantType.ClientType.WEB, token: Client.getInstance().token, formData: { orgId: orgId, groupName: groupName, groupType: groupType, settings: { filiale: filiale ? filiale : false, prodepart: prodepart ? prodepart : false, parttime: parttime ? parttime : false } } } }); }, /** * 解散群 * @param {string} groupId 群Id */ dissolveGroup(groupId) { return SingletonAxios.getInstance()({ url: this.baseUrl() + "/hermes/group/dissolveGroup", method: "post", data: { os: ConstantType.ClientType.WEB, token: Client.getInstance().token, formData: { groupId: groupId } } }); }, /** * 群内批量拉人 * @param {string} groupId * @param {Array<string>} imIds */ joinUsersGroup(groupId, imIds) { return SingletonAxios.getInstance()({ url: this.baseUrl() + "/hermes/group/joinUsersGroup", method: "post", data: { os: ConstantType.ClientType.WEB, token: Client.getInstance().token, formData: { groupId: groupId, imIds: imIds } } }); }, /** * 群内批量移除人员 * @param {string} groupId * @param {string} imIds */ removeUsersGroup(groupId, imIds) { return SingletonAxios.getInstance()({ url: this.baseUrl() + "/hermes/group/removeUsersGroup", method: "post", data: { os: ConstantType.ClientType.WEB, token: Client.getInstance().token, formData: { groupId: groupId, imIds: imIds } } }); }, /** * 退群 * @param {string} groupId */ exitGroup(groupId) { return SingletonAxios.getInstance()({ url: this.baseUrl() + "/hermes/group/exitGroup", method: "post", data: { os: ConstantType.ClientType.WEB, token: Client.getInstance().token, formData: { groupId: groupId } } }); }, /** * 修改群名 * @param {string} groupId * @param {string} groupName */ editGroupName(groupId, groupName) { return SingletonAxios.getInstance()({ url: this.baseUrl() + "/hermes/group/editGroupName", method: "post", data: { os: ConstantType.ClientType.WEB, token: Client.getInstance().token, formData: { groupId: groupId, groupName: groupName } } }); }, /** * 获取群信息 * @param {string} groupId */ findGroup(groupId) { return SingletonAxios.getInstance()({ url: this.baseUrl() + "/hermes/group/findGroup", method: "post", data: { os: ConstantType.ClientType.WEB, token: Client.getInstance().token, formData: { groupId: groupId } } }); } }
gulp = require('gulp') coffee = require('gulp-coffee') gulp.task('default', ['coffee:libs']); gulp.task('coffee:libs', function (){ gulp.src('./mylib/**/**.coffee') .pipe(coffee()) .pipe(gulp.dest('./node_modules/my')); });
$(document).ready(function() { $('.display-options img:eq(0)').click(function() { $('.note').css('width','25%'); $('.note').css('float','left'); $('.note').css('margin','1em 0 1em 3.3em'); $('.note').css('height','20em'); }); $('.display-options img:eq(1)').click(function() { $('.note').css('width','50%'); $('.note').css('float','none'); $('.note').css('margin','0 auto'); $('.note').css('margin-top','2em'); $('.note').css('height','24em'); }); $('.create_note .content').click(function() { $('.create_note').css("border", "1px solid #4D90FE"); $(this).css("padding-top", "2em"); $('.create_note .title').show(); }); $('.page-wrap').on('keydown click', function() { console.log("keydown pressed"); var elementClass = $(':focus').closest('section').attr('class'); console.log('this is the closest class' + elementClass); if (elementClass !== undefined) { elementClass.toString(); if (elementClass == 'create_note') console.log('we are in create note'); } else { console.log($('.create_note form')); var note = { title: $('.create_note form').find('.title').val().toString(), content: $('.create_note form').find('.content').val().toString(), color: 'none', }; console.log(note); createNote(note); console.log('we are not in create note'); } }); $('.create_note form').submit(function() { var note = { title: $( this ).find('.title').val().toString(), content: $( this ).find('.content').val().toString(), color: 'none', }; createNote(note); return false; }); // $('.notes').delegate('.note form', 'submit', function() { // console.log('updating note....'); // return false; // }); $('.notes-wrapper .notes').delegate('.note', 'mouseenter', function() { $(this).find('.options').show({duration:200}); $(this).closest('.note').css('border-left-color','#4D90FE'); $(this).closest('.note').css('border-left-width','.15em'); }); $('.notes-wrapper .notes').delegate('.note', 'mouseleave', function() { $(this).find('.options').hide(); $(this).closest('.note').css('border-left-width','0em'); }); $('.notes').delegate('.note .options .trash', 'click', function() { console.log('trash clicked'); deleteNote($( this ).closest('.note').data('resource'), $( this ).closest('.note')); }); $('.notes').delegate('.note .options .btn-update', 'click', function() { console.log('update clicked'); var note = { title: $( this ).closest('.note').find('.title').val().toString(), content: $( this ).closest('.note').find('.content').val().toString(), color: $( this ).closest('.note').css('border-top-color').toString(), }; updateNote($( this ).closest('.note').data('resource'), note); return false; }); $('.notes').delegate('#brush', 'click', function() { $( this ).next().simplecolorpicker(); }); $('.notes').delegate('.options .simplecolorpicker span', 'click', function() { var color = $(this).css('background-color'); color = hexc(color); $( this ).closest('.note').css('border-top-color', color); $( this ).parent().prev().simplecolorpicker('destroy'); $('.colorpicker').css('display','none'); }); function createNote(note) { console.log("in create note"); console.log("title:" + $('.create_note form').find('.title').val()); if ($('.create_note form').find('.title').val() != "" || $('.create_note form').find('.content').val() != "") $.ajax({ url: '/api/v1/notes/', type: 'post', data: JSON.stringify(note), contentType: 'application/json', async: false, beforeSend: function(xhr, settings) { if (!csrfSafeMethod(settings.type) && sameOrigin(settings.url)) { // Send the token to same-origin, relative URLs only. // Send the token only if the method warrants CSRF protection // Using the CSRFToken value acquired earlier xhr.setRequestHeader("X-CSRFToken", csrftoken); } }, success: function (data, textStatus, jqXHR) { $("#noteTemplate").tmpl(data).appendTo(".notes-wrapper .notes"); clearCreateNote(); } }); $('.create_note').css("border", "none"); // $('.create_note .title').hide(); // $('.create_note .content').css("padding-top", "0em"); } function updateNote (resourceURL, note) { $.ajax({ url: resourceURL, type: 'PUT', data: JSON.stringify(note), contentType: 'application/json', async: false, beforeSend: function(xhr, settings) { if (!csrfSafeMethod(settings.type) && sameOrigin(settings.url)) { // Send the token to same-origin, relative URLs only. // Send the token only if the method warrants CSRF protection // Using the CSRFToken value acquired earlier xhr.setRequestHeader("X-CSRFToken", csrftoken); } }, success: function (data, textStatus, jqXHR) { console.log(data); } }); } function deleteNote (resource, note_form) { $.ajax({ url: resource, type: 'DELETE', beforeSend: function(xhr, settings) { if (!csrfSafeMethod(settings.type) && sameOrigin(settings.url)) { // Send the token to same-origin, relative URLs only. // Send the token only if the method warrants CSRF protection // Using the CSRFToken value acquired earlier xhr.setRequestHeader("X-CSRFToken", csrftoken); } }, success: function (data) { console.log('note deleted'); note_form.hide('slow', function() { note_form.remove(); }); } }); } function clearCreateNote() { $('.create_note .title').val(''); $('.create_note .content').val(''); } // $('.create_note').on('keydown', function(e) { // var now = $(this).attr('class'); // var keyCode = e.keyCode || e.which; // if (keyCode == 9) { // console.log('keycode = 9'); // var input = $(this).find(':focus'); // isInCreateNote(now); // // if (input.length > 0) // // console.log('We are in the create note'); // } // }); // $('.create_note input').focusout(function(e) { // console.log('focusout'); // console.log(e.target); // // console.log($(this).closest('section').attr('class')); // // if ($(this).closest('section').attr('class') == 'create_note') // // console.log('we are in create_note'); // // else console.log('we are not in create_note'); // //isInCreateNote(); // }); // $('.create_note input').live('focusout', function() { // console.log($('.create_note').find(':active').length); // }); function isInCreateNote(now) { if (now !== undefined) { console.log(now + "i'm increatenote function"); } else { if ($('.create_note').find(':active').length > 0 || $('.create_note').find(':active').length > 0) console.log('we in the create note'); else { console.log('OUTSIDE'); } } // if ($('.create_note').find(':active').length > 0 || $('.create_note').find(':focus').length > 0) // console.log('we are in the create note'); // else { // console.log('OUTSIDE'); // console.log($('.create_note input').find(':focus')); // } // if (element) { // console.log(element.length); // if (element.length > 0) { // console.log('We are in the create note'); // } // } // else { // if ( $('.create_note .title input').is(':active') || $('.create_note .content input').is(':active') ) { // console.log('something is focused'); // } // else{ // // $('.create_note form').submit(); // // $('.create_note .title').hide(); // // $('.create_note .content').css("padding-top", "0em"); // console.log('OUTSIDE!!!'); // } // } // console.log($('.create_note .title input').is(':focus')); } function hexc(colorval) { var parts = colorval.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); delete(parts[0]); for (var i = 1; i <= 3; ++i) { parts[i] = parseInt(parts[i]).toString(16); if (parts[i].length == 1) parts[i] = '0' + parts[i]; } color = '#' + parts.join(''); return color; } // using jQuery function getCookie(name) { var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } var csrftoken = getCookie('csrftoken'); function csrfSafeMethod(method) { // these HTTP methods do not require CSRF protection return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); } function sameOrigin(url) { // test that a given url is a same-origin URL // url could be relative or scheme relative or absolute var host = document.location.host; // host + port var protocol = document.location.protocol; var sr_origin = '//' + host; var origin = protocol + sr_origin; // Allow absolute or scheme relative URLs to same origin return (url == origin || url.slice(0, origin.length + 1) == origin + '/') || (url == sr_origin || url.slice(0, sr_origin.length + 1) == sr_origin + '/') || // or any other URL that isn't scheme relative or absolute i.e relative. !(/^(\/\/|http:|https:).*/.test(url)); } });
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; import _extends from "@babel/runtime/helpers/esm/extends"; var _excluded = ["allDay", "children", "className", "contentTemplate", "contentTemplateProps", "endDate", "groupIndex", "groups", "index", "isFirstGroupCell", "isLastGroupCell", "startDate", "text", "timeCellTemplate"]; import { createVNode, createComponentVNode, normalizeProps } from "inferno"; import { BaseInfernoComponent } from "@devextreme/vdom"; import { CellBase as Cell, CellBaseProps } from "../cell"; export var viewFunction = viewModel => createComponentVNode(2, Cell, { "isFirstGroupCell": viewModel.props.isFirstGroupCell, "isLastGroupCell": viewModel.props.isLastGroupCell, "contentTemplate": viewModel.props.timeCellTemplate, "contentTemplateProps": viewModel.timeCellTemplateProps, "className": "dx-scheduler-time-panel-cell dx-scheduler-cell-sizes-vertical ".concat(viewModel.props.className), children: createVNode(1, "div", null, viewModel.props.text, 0) }); export var TimePanelCellProps = _extends({}, CellBaseProps); var getTemplate = TemplateProp => TemplateProp && (TemplateProp.defaultProps ? props => normalizeProps(createComponentVNode(2, TemplateProp, _extends({}, props))) : TemplateProp); export class TimePanelCell extends BaseInfernoComponent { constructor(props) { super(props); this.state = {}; } get timeCellTemplateProps() { var { groupIndex, groups, index, startDate, text } = this.props; return { data: { date: startDate, groups, groupIndex, text }, index }; } get restAttributes() { var _this$props = this.props, restProps = _objectWithoutPropertiesLoose(_this$props, _excluded); return restProps; } render() { var props = this.props; return viewFunction({ props: _extends({}, props, { timeCellTemplate: getTemplate(props.timeCellTemplate), contentTemplate: getTemplate(props.contentTemplate) }), timeCellTemplateProps: this.timeCellTemplateProps, restAttributes: this.restAttributes }); } } TimePanelCell.defaultProps = _extends({}, TimePanelCellProps);
var inputItem = document.getElementById('todo-add-new') var list = document.getElementById('todo-items') var error = document.getElementById('error') getValuesFromLockalStorage() function getValuesFromLockalStorage() { let storageData = localStorage.getItem('list') storageData = JSON.parse(storageData) if (storageData) { for (const key in storageData) { addToDo(key, storageData[key]) } } } function validate(e) { e.preventDefault() if (inputItem.value) { addToDo(), hideError() } else { showError() } } function removeItem(e) { var id = e.target.id var clickedBtn = e.target var dataId = clickedBtn.getAttribute('data-id') console.log(id, dataId) var liElement = document.getElementById('todo-item-id_' + dataId) list.removeChild(liElement) removeValueFromLocalStorage(dataId) } function hideError() { error.innerHTML = '' } function addToDo(storageId, storageValue) { var item = document.createElement('li') var id = 'todo-item-id_' var generatedId = storageId || generateId() var value = storageValue || inputItem.value var checkBoxEl = createCheckboxEl(generatedId) var label = createLabelEl(value) var removeBtn = createRemoveBtnEl(generatedId) item.appendChild(checkBoxEl) item.appendChild(label) item.appendChild(removeBtn) item.setAttribute('class', 'todo-item') item.setAttribute('id', id + generatedId) list.appendChild(item) setValueToLocalStorage(value, generatedId) inputItem.value = '' } function setValueToLocalStorage(value, generatedId) { let storageData = localStorage.getItem('list') console.log(storageData, typeof storageData) if (storageData) { storageData = JSON.parse(storageData) storageData[generatedId] = value } else { storageData = { [generatedId]: value } } localStorage.setItem('list', JSON.stringify(storageData)) } function removeValueFromLocalStorage(generatedId) { let storageData = localStorage.getItem('list') storageData = JSON.parse(storageData) if (storageData) { delete storageData[generatedId] localStorage.setItem('list', JSON.stringify(storageData)) } } function removeValuseFromLocalStorage() { localStorage.removeItem('list') } function createCheckboxEl(generatedId) { var input = document.createElement('input') var idCheckbox = 'idCheckbox_' input.setAttribute('type', 'checkbox') input.setAttribute('id', idCheckbox + generatedId) input.addEventListener('change', event => onCheckboxChange(event, generatedId), false) return input } function onCheckboxChange(event, generatedId) { let item = document.getElementById('todo-item-id_' + generatedId) if (event.target.checked == true) { item.setAttribute('class', 'todo-item completed') } else { item.setAttribute('class', 'todo-item') } console.log(item, event.target.id, event.target.checked, generatedId, 'todo-item-id_' + generatedId) } function createRemoveBtnEl(generatedId) { var button = document.createElement('button') var btnId = 'btnId_' var i = document.createElement('i') var span = document.createElement('span') button.setAttribute('class', 'btn btn--icon') button.setAttribute('type', 'button') button.onclick = removeItem button.setAttribute('id', btnId + generatedId) button.setAttribute('data-id', generatedId) i.setAttribute('id', btnId + generatedId) i.setAttribute('data-id', generatedId) i.setAttribute('class', 'icon icon--remove') button.appendChild(i) span.setAttribute('class', 'todo__remove') span.appendChild(button) return span } function createLabelEl(value) { var label = document.createElement('label') var span = document.createElement('span') span.setAttribute('class', 'labelSpan') span.innerHTML = value label.appendChild(span) return label } function showError() { error.innerHTML = 'Some value must be inputed !!!' } var generateId = function () { var charSet = 'abcdefghijklmnopqrstuvwxyz0123456789' var charSetSize = charSet.length var charCount = 8 var id = '' for (var i = 1; i <= charCount; i++) { var randPos = Math.floor(Math.random() * charSetSize) id += charSet[randPos] } return id } function clearTodos() { var list = document.getElementById('todo-items') while (list.firstChild) { list.removeChild(list.firstChild) } removeValuseFromLocalStorage() } document.getElementById('btn-submit').addEventListener('click', validate, false) document.getElementById('clear-todos').addEventListener('click', clearTodos, false)
/** * Created by george.vlada on 20.04.2016. */ (function(window, $) { "use strict"; function PhotonJqGrid(parameters) { var $this = this; var customCallbacks = { 'mergeGridComplete': 'gridComplete', 'mergeLoadComplete': 'loadComplete', 'mergeOnPaging': 'onPaging' }; var defaultParams = { //For options details check here: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options table: '#grid-table', pager: '#grid-pager', loadtext: '<div class="loader-dots dark"><div class="sk-bounce1"></div><div class="sk-bounce2"></div><div class="sk-bounce3"></div></div>', datatype: 'jsonstring', mtype: 'POST', sortable: true, viewrecords: true, multiSort: true, rowNum: 100, rowList: [1, 2, 5, 10, 20, 75, 100], multiselect: false, multiboxonly: true, styleUI : 'fontAwesome', shrinkToFit: true, autoResizing: { compact: true }, autowidth: true, width: 'auto', height: '100%', stickyButtons: false, mergeOnPaging: true, useAutocompleteRow: false, onPaging: function() { var jqGridOverlay = _getJqGridOverlay(); jqGridOverlay.addClass('custom-overlay'); }, beforeRequest: function () { var jqGridOverlay = _getJqGridOverlay(); //Make overlay background active jqGridOverlay.addClass('custom-overlay'); }, mergeLoadComplete: true, loadComplete: function () { var jqGridOverlay = _getJqGridOverlay(); var tableIdSelector = gridOpts.table; var tableId = tableIdSelector.slice(1); var records = $(tableIdSelector).jqGrid('getGridParam', 'records'); var $jqgridContainer = $('#' + $(tableIdSelector).attr('aria-labelledby')); _updateRecords($jqgridContainer, records); _displayNoRecordsMessage(tableId, records); jqGridOverlay.removeClass('custom-overlay'); _formatDefaultButtons(tableId); }, mergeGridComplete: true, gridComplete: function() { var tableIdSelector = gridOpts.table; var tableId = tableIdSelector.slice(1); var jqGridOverlay = _getJqGridOverlay(); jqGridOverlay.removeClass('custom-overlay'); if (gridOpts.stickyButtons && !gridOpts.stickyButtonsInitialized) { _initStickyOnJqGrid(gridOpts); gridOpts.stickyButtonsInitialized = true; } else if (gridOpts.stickyButtons) { $(document.body).trigger("sticky_kit:recalc"); } var $jqgridContainer = $('#' + $(tableIdSelector).attr('aria-labelledby')); var records = jQuery(tableIdSelector).jqGrid('getGridParam', 'records'); if(!$jqgridContainer.find('.ui-pg-selbox-container').length){ _createContainerForPgSelbox($jqgridContainer,records); _movePgSelbox($jqgridContainer); } _displayNoRecordsMessage(tableId, records); jqGridOverlay.removeClass('custom-overlay'); }, caption: null, useCustomColumnChooser: false, columnChooserOptions: {} }; var gridOpts = $.extend({}, defaultParams, parameters || {}); gridOpts.caption = null; gridOpts.altRows = null; function _formatDefaultButtons(tableId){ var $table = $('#' + tableId); var $buttons = $table.find('.ui-inline-edit, .ui-inline-del, .ui-inline-save, .ui-inline-cancel'); var noBorderClass = (gridOpts.styleUI == 'fontAwesomeNoBorder') ? ' btn-no-border' : ''; $.each($buttons, function (index, value) { $this = $(this); if (!$this.parent().hasClass('btn-group')) { $this.parent().addClass('btn-group').css({ 'margin': '0' }); } $(this).addClass('btn btn-default btn-sm' + noBorderClass); }); $table.off('jqGridInlineAfterRestoreRow', onJqGridInlineAfterRestoreRow) .on('jqGridInlineAfterRestoreRow', onJqGridInlineAfterRestoreRow); $table.on('jqGridInlineAfterSaveRow',onJqGridInlineAfterSaveRow) .on('jqGridInlineAfterSaveRow',onJqGridInlineAfterSaveRow); function onJqGridInlineAfterSaveRow (event, rowId){ $table.find('tr').removeClass('success'); setTimeout(function(){ $table.find('tr#' + rowId).addClass('success'); },0) } function onJqGridInlineAfterRestoreRow(events,rowId){ var $buttons = $table.find('tr#' + rowId).find('.ui-inline-edit, .ui-inline-del, .ui-inline-save, .ui-inline-cancel'); var noBorderClass = (gridOpts.styleUI == 'fontAwesomeNoBorder') ? ' btn-no-border' : ''; $.each($buttons, function (index, value) { $this = $(this); if (!$this.parent().hasClass('btn-group')) { $this.parent().addClass('btn-group').css({ 'margin': '0' }); } $(this).addClass('btn btn-default btn-sm' + noBorderClass); }); } } function _initStickyOnJqGrid(gridOpts){ var tableId = '#gbox_'+ gridOpts.table.slice(1); var $tableHead = $(tableId + ' .ui-jqgrid-hdiv'); var $tableBody = $(tableId + ' .ui-jqgrid-bdiv'); _addClassForStickElements(tableId); initPhotonStick(tableId); $(window).on("sticky_kit:stick", function() { $tableHead.scrollLeft($tableBody.scrollLeft()); }).on("sticky_kit:unstick", function() { $tableHead.scrollLeft($tableBody.scrollLeft()); }) } function _addClassForStickElements(tableId){ $(tableId +' .ui-jqgrid-hdiv').addClass('stick'); } function _getJqGridOverlay() { var table = gridOpts.table; return $("#lui_" + table.substr(1)); } for(var mergeCallbackOption in customCallbacks) { if(_hasCustomCallback(mergeCallbackOption, customCallbacks[mergeCallbackOption])) { _mergeCustomCallback(customCallbacks[mergeCallbackOption]); } } function _initCustomColumnChooser() { $.jgrid.extend({ columnChooser: function() { var defaultOptions = { selectAllCheckboxLabel: 'Select all', saveBtnLabel: 'Apply', cancelBtnLabel: 'Cancel', actionButton: '' }; var opts = $.extend(defaultOptions, gridOpts.columnChooserOptions); var self = this; var dropId = self[0].id + '_drop_jsc'; var drop; var $body = $('body'); var $button = $(opts.actionButton); _initDrop($button); _initColumnChooserEvents(); function _initColumnChooserEvents() { $body.on('input', '#' + dropId + ' .jsc-search', function() { var searchString = $(this).val().toLowerCase(); var results = 0; $('#' + dropId + ' .dd-jsc-checkbox-all-columns .checkbox .jsc-col-name').each(function (i) { var $this = $(this); var colName = $this.html(); if (colName.toLowerCase().indexOf(searchString) === -1) { $this.parents('.checkbox').parent().addClass('hide'); } else { $this.parents('.checkbox').parent().removeClass('hide'); results++; } }); if (!results) { $('#' + dropId + ' .dd-jsc-checkbox.dd-jsc-one-item').addClass('no-border-bottom'); $('#' + dropId + ' .dd-jsc-checkbox-all-columns').addClass('hide'); } else { $('#' + dropId + ' .dd-jsc-checkbox.dd-jsc-one-item').removeClass('no-border-bottom'); $('#' + dropId + ' .dd-jsc-checkbox-all-columns').removeClass('hide'); } $('#' + dropId + ' .dd-jsc-checkbox-all-columns li').removeClass('no-border-top'); $('#' + dropId + ' .dd-jsc-checkbox-all-columns').find('li:not(.hide)').eq(0).addClass('no-border-top'); }); $body.on('click', '#' + dropId + ' .jsc-checkbox-all', function() { if (this.checked) { $('#' + dropId + ' .jsc-search').val(''); $('#' + dropId + ' .dd-jsc-checkbox-all-columns li').removeClass('hide'); $('#' + dropId + ' .jsc-checkbox').prop('checked', true); $('#' + dropId + ' .btn-jsc-save-btn').prop('disabled', false); $('#' + dropId + ' .dd-jsc-checkbox.dd-jsc-one-item').removeClass('no-border-bottom'); $('#' + dropId + ' .dd-jsc-checkbox-all-columns').removeClass('hide'); } else { $('#' + dropId + ' .jsc-checkbox').prop('checked', false); $('#' + dropId + ' .btn-jsc-save-btn').prop('disabled', true); } }); $body.on('click', '#' + dropId + ' .jsc-checkbox', function() { if (!this.checked) { $('#' + dropId + ' .jsc-checkbox-all').prop('checked', false); } else { $('#' + dropId + ' .jsc-checkbox-all').prop('checked', _isSelectAll()); } if ($('#' + dropId + ' .jsc-checkbox:checked').length > 0) { $('#' + dropId + ' .btn-jsc-save-btn').prop('disabled', false); } else { $('#' + dropId + ' .btn-jsc-save-btn').prop('disabled', true); } }); $body.off('click', '#' + dropId + ' .btn-jsc-save-btn'); $body.off('click', '#' + dropId + ' .btn-jsc-cancel-btn'); $body.on('click', '#' + dropId + ' .btn-jsc-cancel-btn', function() { $('#' + dropId + ' .btn-jsc-save-btn').prop('disabled', false); }); $body.on('click', '#' + dropId + ' .btn-jsc-save-btn', function() { var colModel = self.jqGrid('getGridParam', 'colModel'); $('#' + dropId + ' .dd-jsc-checkbox-all-columns .jsc-checkbox').each(function (i) { if (this.checked) { self.jqGrid('showCol', colModel[this.value].name); } else { self.jqGrid('hideCol', colModel[this.value].name); } }); photonResizeGrid(); drop.close(); }); $body.on('click', '#' + dropId + ' .btn-jsc-cancel-btn', function() { var colModel = self.jqGrid('getGridParam', 'colModel'); $.each(colModel, function (i) { $('#' + dropId + ' .jsc-checkbox[value="' + i + '"]').prop('checked', !this.hidden); }); $('#' + dropId + ' .jsc-checkbox-all').prop('checked', _isSelectAll()); drop.close(); }); } function _initDrop($button) { drop = new Drop({ target: $button[0], classes: 'drop-actions', content: '<div id="' + dropId + '">' + '<ul class="dropdown-menu dropdown-default dd-jqgrid-select-columns dd-jsc-one-item">' + '<li>' + '<input type="text" class="form-control jsc-search" placeholder="Search">' + '</li>' + '</ul>' + '<ul class="dropdown-menu dropdown-default dd-jqgrid-select-columns dd-jsc-checkbox dd-jsc-one-item">' + '<li>' + '<div class="checkbox"><label><input type="checkbox" class="form-checkbox-control jsc-checkbox-all" value="" checked=""> (' + opts.selectAllCheckboxLabel +')</label></div>' + '</li>' + '</ul>' + '<ul class="dropdown-menu dropdown-default dd-jqgrid-select-columns dd-jsc-checkbox dd-jsc-checkbox-all-columns">' + _getColumnsCheckboxes() + '</ul>' + '<ul class="dropdown-menu dropdown-default dd-jqgrid-select-columns dd-jsc-buttons">' + '<li>' + '<button type="button" class="btn btn-default btn-jsc-cancel-btn">' + opts.cancelBtnLabel + '</button> ' + '<button type="button" class="btn btn-primary btn-jsc-save-btn pull-right">' + opts.saveBtnLabel + '</button>' + '</li>' + '</ul>' + '</div>', position: 'bottom right', openOn: 'click', constrainToWindow: true, constrainToScrollParent: false, tetherOptions: { offset: '-5px 0' } }); } function _isSelectAll() { return ($('#' + dropId + ' .jsc-checkbox:checked').length == $('#' + dropId + ' .jsc-checkbox').length); } function _getColumnsCheckboxes() { var columnsCheckboxes = ''; var colModel = self.jqGrid('getGridParam', 'colModel'); var colNames = self.jqGrid('getGridParam', 'colNames'); $.each(colModel, function(i) { if (colModel[i].name !== 'cb') { var checkedStatus = this.hidden? '' : 'checked="checked"'; columnsCheckboxes += '<li>' + '<div class="checkbox">' + '<label>' + '<input type="checkbox" class="form-checkbox-control jsc-checkbox" value="' + i + '"' + checkedStatus + '> ' + '<span class="jsc-col-name">' + colNames[i] + '</span>' + '</label>' + '</div>' + '</li>'; } }); return columnsCheckboxes; } } }); } function _movePgSelbox($jqgridContainer){ $.each( $jqgridContainer.find('.ui-pg-selbox'), function() { var $selbox = $(this); $selbox.appendTo($selbox.closest('.ui-pager-control').find('.ui-pg-selbox-container span').eq(0)) }); } function _createContainerForPgSelbox($jqgridContainer, records) { $jqgridContainer.find('.ui-pager-control').append( '<div class="ui-pg-selbox-container">' + photonTranslations.listing[photonPageLang].view + '<span></span>' + photonTranslations.listing[photonPageLang].of + ' <span class="no-items">' + records + '</span> ' + photonTranslations.listing[photonPageLang].items + '</div>' ); } function _updateRecords($jqgridContainer, records){ $jqgridContainer.find('.ui-pager-control .no-items').html(records); } function _displayNoRecordsMessage(tableId, records) { //Display no records message. var noRecordsMessage = photonTranslations.listing[photonPageLang].noResults; var emptyMessage = $( '<div class="custom-jqgrid-messages-'+ tableId +' custom-jqgrid-no-records-'+ tableId +' alert alert-info">' + '<i class="fa fa-info-circle"></i> ' + noRecordsMessage + '</div>' ); if (records == 0) { $('.custom-jqgrid-messages-' + tableId).remove(); $('#' + tableId).parent().append(emptyMessage); $('#gbox_'+ tableId +' .ui-jqgrid-pager').addClass('hide'); } else { $('#gbox_'+ tableId +' .ui-jqgrid-pager').removeClass('hide'); $('#'+ tableId ).removeClass('hide'); $('.custom-jqgrid-messages-' + tableId).remove(); } } this.init = function () { $.extend($.jgrid,{ styleUI : { jQueryUI : { common : { disabled: "ui-state-disabled", highlight : "ui-state-highlight", hover : "ui-state-hover", cornerall: "ui-corner-all", cornertop: "ui-corner-top", cornerbottom : "ui-corner-bottom", hidden : "ui-helper-hidden", icon_base : "ui-icon", overlay : "ui-widget-overlay", active : "ui-state-active", error : "ui-state-error", button : "ui-state-default ui-corner-all", content : "ui-widget-content" }, base : { entrieBox : "ui-widget ui-widget-content ui-corner-all", // entrie div incl everthing viewBox : "", // view diw headerTable : "", headerBox : "ui-state-default", rowTable : "", rowBox : "ui-widget-content", stripedTable : "ui-jqgrid-table-striped", footerTable : "", footerBox : "ui-widget-content", headerDiv : "ui-state-default", gridtitleBox : "ui-widget-header ui-corner-top ui-helper-clearfix", customtoolbarBox : "ui-state-default", //overlayBox: "ui-widget-overlay", loadingBox : "ui-state-default ui-state-active", rownumBox : "ui-state-default", scrollBox : "ui-widget-content", multiBox : "", pagerBox : "ui-state-default ui-corner-bottom", pagerTable : "", toppagerBox : "ui-state-default", pgInput : "ui-corner-all", pgSelectBox : "ui-widget-content ui-corner-all", pgButtonBox : "ui-corner-all", icon_first : "ui-icon-seek-first", icon_prev : "ui-icon-seek-prev", icon_next: "ui-icon-seek-next", icon_end: "ui-icon-seek-end", icon_asc : "ui-icon-triangle-1-n", icon_desc : "ui-icon-triangle-1-s", icon_caption_open : "ui-icon-circle-triangle-n", icon_caption_close : "ui-icon-circle-triangle-s" }, modal : { modal : "ui-widget ui-widget-content ui-corner-all ui-dialog", header : "ui-widget-header ui-corner-all ui-helper-clearfix", content :"ui-widget-content", resizable : "ui-resizable-handle ui-resizable-se", icon_close : "ui-icon-closethick", icon_resizable : "ui-icon-gripsmall-diagonal-se" }, celledit : { inputClass : "ui-widget-content ui-corner-all" }, inlinedit : { inputClass : "ui-widget-content ui-corner-all", icon_edit_nav : "ui-icon-pencil", icon_add_nav : "ui-icon-plus", icon_save_nav : "ui-icon-disk", icon_cancel_nav : "ui-icon-cancel" }, formedit : { inputClass : "ui-widget-content ui-corner-all", icon_prev : "ui-icon-triangle-1-w", icon_next : "ui-icon-triangle-1-e", icon_save : "ui-icon-disk", icon_close : "ui-icon-close", icon_del : "ui-icon-scissors", icon_cancel : "ui-icon-cancel" }, navigator : { icon_edit_nav : "ui-icon-pencil", icon_add_nav : "ui-icon-plus", icon_del_nav : "ui-icon-trash", icon_search_nav : "ui-icon-search", icon_refresh_nav : "ui-icon-refresh", icon_view_nav : "ui-icon-document", icon_newbutton_nav : "ui-icon-newwin" }, grouping : { icon_plus : 'ui-icon-circlesmall-plus', icon_minus : 'ui-icon-circlesmall-minus' }, filter : { table_widget : 'ui-widget ui-widget-content', srSelect : 'ui-widget-content ui-corner-all', srInput : 'ui-widget-content ui-corner-all', menu_widget : 'ui-widget ui-widget-content ui-corner-all', icon_search : 'ui-icon-search', icon_reset : 'ui-icon-arrowreturnthick-1-w', icon_query :'ui-icon-comment' }, subgrid : { icon_plus : 'ui-icon-plus', icon_minus : 'ui-icon-minus', icon_open : 'ui-icon-carat-1-sw' }, treegrid : { icon_plus : 'ui-icon-triangle-1-', icon_minus : 'ui-icon-triangle-1-s', icon_leaf : 'ui-icon-radio-off' }, fmatter : { icon_edit : "ui-icon-pencil", icon_add : "ui-icon-plus", icon_save : "ui-icon-disk", icon_cancel : "ui-icon-cancel", icon_del : "ui-icon-trash" }, colmenu : { menu_widget : 'ui-widget ui-widget-content ui-corner-all', input_checkbox : "ui-widget ui-widget-content", filter_select: "ui-widget-content ui-corner-all", filter_input : "ui-widget-content ui-corner-all", icon_menu : "ui-icon-comment", icon_sort_asc : "ui-icon-arrow-1-n", icon_sort_desc : "ui-icon-arrow-1-s", icon_columns : "ui-icon-extlink", icon_filter : "ui-icon-calculator", icon_group : "ui-icon-grip-solid-horizontal", icon_freeze : "ui-icon-grip-solid-vertical", icon_move: "ui-icon-arrow-4" } }, Bootstrap : { common : { disabled: "ui-disabled", highlight : "success", hover : "active", cornerall: "", cornertop: "", cornerbottom : "", hidden : "", icon_base : "glyphicon", overlay: "ui-overlay", active : "active", error : "bg-danger", button : "btn btn-default", content : "" }, base : { entrieBox : "", viewBox : "table-responsive", headerTable : "table table-bordered", headerBox : "", rowTable : "table table-bordered", rowBox : "", stripedTable : "table-striped", footerTable : "table table-bordered", footerBox : "", headerDiv : "", gridtitleBox : "", customtoolbarBox : "", //overlayBox: "ui-overlay", loadingBox : "row", rownumBox : "active", scrollBox : "", multiBox : "checkbox", pagerBox : "", pagerTable : "table", toppagerBox : "", pgInput : "form-control", pgSelectBox : "form-control", pgButtonBox : "", icon_first : "glyphicon-step-backward", icon_prev : "glyphicon-backward", icon_next: "glyphicon-forward", icon_end: "glyphicon-step-forward", icon_asc : "glyphicon-triangle-top", icon_desc : "glyphicon-triangle-bottom", icon_caption_open : "glyphicon-circle-arrow-up", icon_caption_close : "glyphicon-circle-arrow-down" }, modal : { modal : "modal-content", header : "modal-header", title : "modal-title", content :"modal-body", resizable : "ui-resizable-handle ui-resizable-se", icon_close : "glyphicon-remove-circle", icon_resizable : "glyphicon-import" }, celledit : { inputClass : 'form-control' }, inlinedit : { inputClass : 'form-control', icon_edit_nav : "glyphicon-edit", icon_add_nav : "glyphicon-plus", icon_save_nav : "glyphicon-save", icon_cancel_nav : "glyphicon-remove-circle" }, formedit : { inputClass : "form-control", icon_prev : "glyphicon-step-backward", icon_next : "glyphicon-step-forward", icon_save : "glyphicon-save", icon_close : "glyphicon-remove-circle", icon_del : "glyphicon-trash", icon_cancel : "glyphicon-remove-circle" }, navigator : { icon_edit_nav : "glyphicon-edit", icon_add_nav : "glyphicon-plus", icon_del_nav : "glyphicon-trash", icon_search_nav : "glyphicon-search", icon_refresh_nav : "glyphicon-refresh", icon_view_nav : "glyphicon-info-sign", icon_newbutton_nav : "glyphicon-new-window" }, grouping : { icon_plus : 'glyphicon-triangle-right', icon_minus : 'glyphicon-triangle-bottom' }, filter : { table_widget : 'table table-condensed', srSelect : 'form-control', srInput : 'form-control', menu_widget : '', icon_search : 'glyphicon-search', icon_reset : 'glyphicon-refresh', icon_query :'glyphicon-comment' }, subgrid : { icon_plus : 'glyphicon-triangle-right', icon_minus : 'glyphicon-triangle-bottom', icon_open : 'glyphicon-indent-left' }, treegrid : { icon_plus : 'glyphicon-triangle-right', icon_minus : 'glyphicon-triangle-bottom', icon_leaf : 'glyphicon-unchecked' }, fmatter : { icon_edit : "glyphicon-edit", icon_add : "glyphicon-plus", icon_save : "glyphicon-save", icon_cancel : "glyphicon-remove-circle", icon_del : "glyphicon-trash" }, colmenu : { menu_widget : '', input_checkbox : "", filter_select: "form-control", filter_input : "form-control", icon_menu : "glyphicon-menu-hamburger", icon_sort_asc : "glyphicon-sort-by-alphabet", icon_sort_desc : "glyphicon-sort-by-alphabet-alt", icon_columns : "glyphicon-list-alt", icon_filter : "glyphicon-filter", icon_group : "glyphicon-align-left", icon_freeze : "glyphicon-object-align-horizontal", icon_move: "glyphicon-move" } }, fontAwesome : { common : { disabled: "ui-disabled", highlight : "highlight", hover : "active", cornerall: "2px", cornertop: "2px", cornerbottom : "2px", hidden : "sr-only", icon_base : "fa", overlay: "ui-overlay", active : "active", error : "bg-danger", button : "btn btn-default", content : "" }, base : { entrieBox : "", viewBox : "table-responsive", headerTable : "table table-bordered", headerBox : "", rowTable : "table table-bordered", rowBox : "", footerTable : "table table-bordered", footerBox : "", headerDiv : "", gridtitleBox : "", customtoolbarBox : "", //overlayBox: "ui-overlay", loadingBox : "row", rownumBox : "active", scrollBox : "", multiBox : "checkbox", pagerBox : "ui-pager-box", pagerTable : "table", toppagerBox : "", pgInput : "form-control", pgSelectBox : "form-control", pgButtonBox : "btn btn-default", icon_first : "fa-angle-double-left", icon_prev : "fa-angle-left", icon_next: "fa-angle-right", icon_end: "fa-angle-double-right", icon_asc : "fa-caret-up", icon_desc : "fa-caret-down", icon_caption_open : "fa-chevron-up", icon_caption_close : "fa-chevron-down" }, modal : { modal : "modal-content", header : "modal-header", title : "modal-title", content :"modal-body", resizable : "", icon_close : "fa-remove", icon_resizable : "" }, celledit : { inputClass : 'form-control' }, inlinedit : { inputClass : 'form-control', icon_edit_nav : "fa-pencil", icon_add_nav : "fa-plus", icon_save_nav : "fa-check-circle", icon_cancel_nav : "fa-remove" }, formedit : { inputClass : "form-control", icon_prev : "fa-step-backward", icon_next : "fa-step-forward", icon_save : "fa-check-circle", icon_close : "fa-remove", icon_del : "fa-trash", icon_cancel : "fa-remove" }, navigator : { icon_edit_nav : "fa-pencil", icon_add_nav : "fa-plus", icon_del_nav : "fa-trash", icon_search_nav : "fa-search", icon_refresh_nav : "fa-refresh", icon_view_nav : "fa-eye", icon_newbutton_nav : "fa-external-link-square" }, grouping : { icon_plus : 'fa-expand', icon_minus : 'fa-compress' }, filter : { table_widget : 'table table-condensed', srSelect : 'form-control', srInput : 'form-control', menu_widget : '', icon_search : 'fa-search', icon_reset : 'fa-refresh', icon_query :'fa-comment' }, subgrid : { icon_plus : 'fa-caret-right', icon_minus : 'fa-caret-down', icon_leaf : 'fa-circle-o' }, treegrid : { icon_plus : 'fa-caret-right', icon_minus : 'fa-caret-down', icon_leaf : 'fa-circle-o' }, fmatter : { icon_edit : "fa-pencil", icon_add : "fa-plus", icon_save : "fa-check-circle", icon_cancel : "fa-remove", icon_del : "fa-trash" } }, fontAwesomeNoBorder : { common : { disabled: "ui-disabled", highlight : "highlight", hover : "active", cornerall: "2px", cornertop: "2px", cornerbottom : "2px", hidden : "sr-only", icon_base : "fa", overlay: "ui-overlay", active : "active", error : "bg-danger", button : "btn btn-default", content : "" }, base : { entrieBox : "table-no-border", viewBox : "table-responsive", headerTable : "table table-bordered", headerBox : "bb", rowTable : "table table-bordered", rowBox : "cc", footerTable : "table table-bordered", footerBox : "dd", headerDiv : "ff", gridtitleBox : "gg", customtoolbarBox : "hh", //overlayBox: "ui-overlay", loadingBox : "row ii", rownumBox : "active", scrollBox : "jj", multiBox : "checkbox", pagerBox : "ui-pager-box", pagerTable : "table", toppagerBox : "", pgInput : "form-control", pgSelectBox : "form-control", pgButtonBox : "btn btn-default", icon_first : "fa-angle-double-left", icon_prev : "fa-angle-left", icon_next: "fa-angle-right", icon_end: "fa-angle-double-right", icon_asc : "fa-caret-up", icon_desc : "fa-caret-down", icon_caption_open : "fa-chevron-up", icon_caption_close : "fa-chevron-down" }, modal : { modal : "modal-content", header : "modal-header", title : "modal-title", content :"modal-body", resizable : "", icon_close : "fa-remove", icon_resizable : "" }, celledit : { inputClass : 'form-control' }, inlinedit : { inputClass : 'form-control', icon_edit_nav : "fa-pencil", icon_add_nav : "fa-plus", icon_save_nav : "fa-check-circle", icon_cancel_nav : "fa-remove" }, formedit : { inputClass : "form-control", icon_prev : "fa-step-backward", icon_next : "fa-step-forward", icon_save : "fa-check-circle", icon_close : "fa-remove", icon_del : "fa-trash", icon_cancel : "fa-remove" }, navigator : { icon_edit_nav : "fa-pencil", icon_add_nav : "fa-plus", icon_del_nav : "fa-trash", icon_search_nav : "fa-search", icon_refresh_nav : "fa-refresh", icon_view_nav : "fa-eye", icon_newbutton_nav : "fa-external-link-square" }, grouping : { icon_plus : 'fa-expand', icon_minus : 'fa-compress' }, filter : { table_widget : 'table table-condensed', srSelect : 'form-control', srInput : 'form-control', menu_widget : '', icon_search : 'fa-search', icon_reset : 'fa-refresh', icon_query :'fa-comment' }, subgrid : { icon_plus : 'fa-caret-right', icon_minus : 'fa-caret-down', icon_leaf : 'fa-circle-o' }, treegrid : { icon_plus : 'fa-caret-right', icon_minus : 'fa-caret-down', icon_leaf : 'fa-circle-o' }, fmatter : { icon_edit : "fa-pencil", icon_add : "fa-plus", icon_save : "fa-check-circle", icon_cancel : "fa-remove", icon_del : "fa-trash" } } } }); $this.grid = $(gridOpts.table).jqGrid(gridOpts); var jqGridOverlay = _getJqGridOverlay(); //The overlay class should be added if data is added through ajax if(gridOpts.datatype && gridOpts.datatype !== 'jsonstring') { jqGridOverlay.removeClass('ui-overlay').addClass('custom-overlay'); } if(gridOpts.useCustomColumnChooser) { _initCustomColumnChooser(); } if(gridOpts.useAutocompleteRow) { $($this.grid).parents('.ui-jqgrid-bdiv:first').addClass('reset-overflow'); $($this.grid).parents('.ui-jqgrid-view:first').removeClass('table-responsive'); } }; function _mergeCustomCallback(callback) { var defaultCallback = defaultParams[callback]; var customCallback = parameters[callback]; gridOpts[callback] = function () { defaultCallback(); customCallback(gridOpts.table); } } function _hasCustomCallback(mergeCallbackOption, callback) { return gridOpts[mergeCallbackOption] && typeof (parameters) !== 'undefined' && typeof(parameters[callback]) !== 'undefined'; } } function photonAddGridError(message, gridId){ if(gridId == undefined || gridId == ''){ gridId = 'grid-table'; } var customMessage = $( '<div class="custom-jqgrid-messages-'+ gridId +' custom-errors-'+ gridId +' alert alert-danger no-margin">' + '<i class="fa fa-exclamation-circle"></i>' + message + '</div>' ); $('.custom-jqgrid-messages-' + gridId).remove(); $('#' + gridId).parent().prepend(customMessage); $('#' + gridId).addClass('hide'); $('#gbox_'+ gridId +' .ui-jqgrid-pager').addClass('hide'); } function photonResizeGrid() { if ($('.ui-jqgrid table').length <= 0) { return false; } var resize = function (index, grid) { var width = $(grid).first().parent().width(); $(grid).find('table').setGridWidth(width); }; setTimeout(function () { $('.ui-jqgrid').each(function(index, value) { resize(index, value); }); }, 0); return true; } //---- Events ---- var $window = $(window); //Resize grid $window.on('resize', function () { photonResizeGrid(); }); //Resize after show collapse panel $window.on("show.bs.collapse", function(){ $window.trigger('resize'); }); //Resize after closing or opening menu $('#toggle-sidebar-size-btn').on('click', function () { $window.trigger('resize'); }); //---- Public access to functions ---- window.PhotonJqGrid = PhotonJqGrid; window.photonAddGridError = photonAddGridError; window.photonResizeGrid = photonResizeGrid; }(window, jQuery));
import ContentBox from '@/components/Layout/content_box'; import MoreHorizIcon from '@/icons/Common/more_horiz.svg'; import Button from '@/components/Button'; import Link from 'next/link'; import { isEmpty } from 'underscore'; import { useRouter } from 'next/router'; const Box = ({ title, subtitle, contentLink, isBigTitle, children, contentLinkText, dropdownItems, }) => { const router = useRouter(); return ( <ContentBox> <div className='flex flex-col w-full'> <div className='flex justify-between md:items-center py-6'> <div className='ml-6'> <h3 className={`${isBigTitle ? 'text-xl mb-1' : 'text-sm'} font-semibold`}>{title}</h3> <p className='text-sm text-black-900 opacity-80 md:max-w-[75%]'> {subtitle}{' '} {!isEmpty(contentLink) && ( <span className='text-link-blue'> <Link href={contentLink}>{contentLinkText || 'Read more'}</Link> </span> )} </p> </div> <div className='mr-6'> <div className='dropdown dropdown-end'> <label tabIndex={0} className='border border-grey-200 rounded-lg btn btn-sm btn-square btn-outline hover:bg-transparent m-1' > <MoreHorizIcon /> </label> {dropdownItems && ( <ul tabIndex={0} className='dropdown-content menu p-2 shadow bg-base-100 rounded-box w-52' > {dropdownItems.map((item, index) => { if (item.type === 'path') { return ( <li> <a onClick={() => router.push(item.link)}>{item.label}</a> </li> ); } if (item.type === 'event') { return ( <li> <a onClick={item.event}>{item.label}</a> </li> ); } })} </ul> )} </div> </div> </div> <hr className='bg-skeleton h-[0.5px] w-full mb-6' /> <>{children}</> </div> </ContentBox> ); }; export default Box;
/** * Created by Administrator on 2017/3/15. */ import React, { Component } from 'react'; import { StyleSheet, Text, View, Image, } from 'react-native'; export default class SwitchComponent extends Component{ constructor(props){ super(props); } setNativeProps(nativeProps) { this._root.setNativeProps(nativeProps); } render(){ var props = this.props; var icon; if (props.icon==1){ icon = require('../images/alipay_icon.png'); }else if (props.icon ==2){ icon = require('../images/weipay_icon.png'); } var select; if (props.flag ===true){ select =require('../images/paySelect_icon@2x.png'); }else { select =require('../images/payUnSelect_icon@2x.png'); } return( <View ref={component => this._root = component}> <View style={styles.selectContainer}> <Image style={styles.divideSpace} source={select}/> <Image style={styles.divideSpace} source={icon}/> <Text style={styles.divideSpace}>{props.account}</Text> </View> <View style={styles.greyLine}></View> </View> ) } } var styles = StyleSheet.create({ selectContainer: { flexDirection:'row', alignItems:'center', padding:10, }, greyBg:{ height:40, backgroundColor:'#F7F7F7', paddingLeft:15, justifyContent:'center' }, titleText:{ fontSize:15, color:'#2AC1BC' }, contentText:{ fontSize:18, padding:15 }, greyLine:{ height:2, backgroundColor:'#D8DADC', marginLeft:20, marginRight:20 }, divideSpace:{ marginLeft:15 } });
import angular from 'angular'; /** * @desc User info component */ class UserInfoCtrl { constructor ($state, usersService, baseModalService) { 'ngInject'; Object.assign(this, { $state, usersService, baseModalService }); this.user = angular.copy(usersService.user); this.isDisabled = !this.create; if (this.create) { this.user = angular.copy(usersService.emptyUser); } } cancel () { if (this.create) { this.$state.go('^'); } else if (this.userForm.$dirty) { this.baseModalService.confirmationModal({ title: 'Edit', content: 'Do you really want to leave without saving?' }).result.then(() => { this.user = angular.copy(this.userData); this.isDisabled = true; }); } else { this.isDisabled = true; } } createUser () { if (this.userForm.$invalid) { return; } this.usersService.createUser(this.user) .then(() => { this.$state.go('^'); }); } updateUser () { this.usersService.updateUser(this.user.id, this.user) .then(() => { this.$state.go('^'); }); } removeUser () { this.baseModalService.confirmationModal({ title: 'Remove', content: 'Do you really want to remove user?' }).result.then(() => { this.usersService.removeUser(this.user.id) .then(() => { this.$state.go('^'); }); }); } } export default UserInfoCtrl;
import React from "react" import { Link } from "gatsby" import { NavContainer } from "./Nav.style" import PropTypes from "prop-types" function Nav({ items = [] }) { return ( <NavContainer> <ul> {items.map(item => ( <li key={item.name}> <Link activeClassName="active" to={item.dir}> {item.name} </Link> </li> ))} </ul> </NavContainer> ) } Nav.propTypes = {} export default Nav
(function() { angular.module('bienestarysalud.services', []) .service('DatosAbiertosService', ['$q','$filter','DatosAbiertosFactory', function($q, $filter, datosAbiertosFactory) { var normalize = $filter('normalize'); this.getDiscapacitadosResult = function() { var deferred = $q.defer(); datosAbiertosFactory.getDiscapacitadosResult("") .then(function(data) { deferred.resolve(data); }) return deferred.promise; } this.getActividadesResult = function(month) { var deferred = $q.defer(); datosAbiertosFactory.getActividadesResult("") .then(function(data) { //console.log(data) /*var results = data.filter(function (actividad) { //console.log(actividad[2]) return actividad[2] === month; });*/ //console.log(results) deferred.resolve(data); }) return deferred.promise; } this.getSaludResult = function() { var deferred = $q.defer(); datosAbiertosFactory.getSaludResult("") .then(function(data) { deferred.resolve(data); }) return deferred.promise; } this.getVeterinariaResult = function() { var deferred = $q.defer(); datosAbiertosFactory.getVeterinariaResult("") .then(function(data) { deferred.resolve(data); }) return deferred.promise; } this.getTallerResult = function() { var deferred = $q.defer(); datosAbiertosFactory.getTallerResult("") .then(function(data) { deferred.resolve(data); }) return deferred.promise; } this.getRestauranteResult = function() { var deferred = $q.defer(); datosAbiertosFactory.getRestauranteResult("") .then(function(data) { deferred.resolve(data); }) return deferred.promise; } /*var cartId = new Object(); this.getCartId = function(){ return cartId; }; this.cartId = function(value){ cartId = value; }; this.getCart = function(){ return CompanyFactory.getCart(this.getCartId()).then(function(data){return data}); };*/ }]); })()
import Vue from "vue"; import Vuex from "vuex"; import allEvents from "./modules/allEvents"; import singleEvent from "./modules/singleEvent"; Vue.use(Vuex); export default () => new Vuex.Store({ modules: { allEvents, singleEvent } });
import { ROUTER_DID_CHANGE } from 'redux-router/lib/constants' export default function loaderMiddleware({ dispatch, getState }) { return next => action => { if (action.type === ROUTER_DID_CHANGE) { setTimeout(() => { const { workspace = {} } = getState() // Actions.hideLoader() if (workspace.mobileMenu) { dispatch({ type: '@@bypass/workspace/CLOSE_MOBILE_MENU' }) } }, 200) } return next(action) } }
// 生成一个随机数,看是不是去 function go() { let p= new Promise((resolve,reject)=>{ setTimeout(function () { if(Math.random()-0.5>0){ resolve('去'); }else{ reject('不去'); } },1000); }); return p; } go().then((data)=>{ console.log(data); },(data)=>{ console.log(data); });
import teamPool from './teamPool.js' import Group from './classes/Group.js'; import { sortTeams } from './utils/aux.js'; import { playRound } from './utils/aux.js'; import { nthPlaces } from './utils/auxRoundOf16.js'; import { sortAndSlice } from './utils/auxRoundOf16.js'; import { inSameGroup } from './utils/auxRoundOf16.js'; import { splitSecondPlaces } from './utils/auxRoundOf16.js'; import { avoidSameGroup } from './utils/auxRoundOf16.js'; //Distribución aleatoria de los 24 equipos en 6 grupos de 4 equipos cada uno const randomTeams = teamPool.sort(() => { return 0.5 - Math.random() }); const teamsA = randomTeams.slice(0, 4); const teamsB = randomTeams.slice(4, 8); const teamsC = randomTeams.slice(8, 12); const teamsD = randomTeams.slice(12, 16); const teamsE = randomTeams.slice(16, 20); const teamsF = randomTeams.slice(20, 24); console.log(`Groups and teams ============`); //Creación de los 6 grupos y de un array de grupos 'groups' function createGroups() { const groups = []; const groupA = new Group('A', teamsA); groups.push(groupA); const groupB = new Group('B', teamsB); groups.push(groupB); const groupC = new Group('C', teamsC); groups.push(groupC); const groupD = new Group('D', teamsD); groups.push(groupD); const groupE = new Group('E', teamsE); groups.push(groupE); const groupF = new Group('F', teamsF); groups.push(groupF); return groups; } const groups = createGroups(); function showTournamentSchedule(groups) { for (let group of groups) { group.setupSchedule(); group.showGroupSchedule(); } } //Mostrar los grupos y sus calendarios: jornadas y partidos grupo por grupo showTournamentSchedule(groups); console.log(`\n\n================================ ======THE EUROCUP STARTS!======\n================================\n`); //Mostrar el resultado de cada jornada grupo por grupo //Tras acabar la jornada de cada grupo, mostrar la tabla de clasificación actualizada for (let i = 0; i < 3; i++) { console.log(`\n=== Matchday ${i + 1}===\n`); for (let group of groups) { console.log(`\nGroup ${group.name}\n`); console.log(group.playMatchDay(i, 0), '\n'); console.log(group.playMatchDay(i, 1), '\n'); group.showMatchDayResults(); } } //Primeros de grupo let firstPlaces = nthPlaces(groups, 0); firstPlaces.reverse(); //Terceros de grupo const thirdPlaces = nthPlaces(groups, 2); //Escoger los 4 mejores terceros de grupo const bestThirdPlaces = sortAndSlice(groups, thirdPlaces, sortTeams); //Segundos de grupo const secondPlaces = nthPlaces(groups, 1); //Segundos de grupo sin tercero clasificado const secondPlacesFromNoBestThirdPlaceGroup = splitSecondPlaces('fromNoBestThirdPlaceGroup', secondPlaces, bestThirdPlaces, inSameGroup); //Resto de segundos de grupo const restOfSecondPlaces = splitSecondPlaces('rest', secondPlaces, bestThirdPlaces, inSameGroup); //Comienza la fase de playoffs console.log('\n==========ROUND OF SIXTEEN==========\n'); //Clasificados para los octavos de final firstPlaces.forEach(team => { console.log(team.name); }) secondPlaces.forEach(team => { console.log(team.name); }) bestThirdPlaces.forEach(team => { console.log(team.name); }) const setRoundOf16 = function (firstPlaces, secondPlacesFromNoBestThirdPlaceGroup, bestThirdPlaces, restOfSecondPlaces) { const roundOf16 = []; //Emparejamientos de octavos en dos subgrupos de ocho: //(1) Primeros vs. mejores terceros //(2) Primeros y segundos de grupos sin terceros clasificados vs. resto de segundos //(1) Primeros vs. mejores terceros const first4Locals = firstPlaces.slice(0, 4); let first4Visitors = bestThirdPlaces; //Evitar los cruces con equipos del mismo grupo (reordena first4Visitors si es necesario) first4Visitors = avoidSameGroup(first4Locals, first4Visitors); for (let i = 0; i < first4Locals.length; i++) { roundOf16.push({ local: `${first4Locals[i].name}`, visitor: `${first4Visitors[i].name}` }); } //(2) Primeros y segundos de grupos sin terceros clasificados vs. resto de segundos const last4Locals = firstPlaces.slice(4).concat(secondPlacesFromNoBestThirdPlaceGroup); let last4Visitors = restOfSecondPlaces; //Evitar los cruces con equipos del mismo grupo (reordena last4Visitors si es necesario) last4Visitors = avoidSameGroup(last4Locals, last4Visitors); for (let i = 0; i < last4Locals.length; i++) { roundOf16.push({ local: `${last4Locals[i].name}`, visitor: `${last4Visitors[i].name}` }); } return roundOf16; } const roundOf16 = setRoundOf16(firstPlaces, secondPlacesFromNoBestThirdPlaceGroup, bestThirdPlaces, restOfSecondPlaces); //Jugar los partidos de octavos de final const roundOf16Winners = playRound(roundOf16, 'Q'); console.log('\n==========QUARTER-FINALS==========\n'); //Emparejamientos de cuartos de final const setQuarterFinals = function(roundOf16Winners){ const quarterFinals = []; quarterFinals.push({local:`${roundOf16Winners[0]}`, visitor: `${roundOf16Winners[7]}`}); quarterFinals.push({local:`${roundOf16Winners[1]}`, visitor: `${roundOf16Winners[6]}`}); quarterFinals.push({local:`${roundOf16Winners[2]}`, visitor: `${roundOf16Winners[5]}`}); quarterFinals.push({local:`${roundOf16Winners[3]}`, visitor: `${roundOf16Winners[4]}`}); return quarterFinals; } const quarterFinals = setQuarterFinals(roundOf16Winners); //Jugar los cuartos de final const quarterFinalsWinners = playRound(quarterFinals,'QF'); console.log('\n==========SEMIFINALS==========\n'); //Emparejamientos de las semifinales const setSemiFinals = function(quarterFinalsWinners){ const semiFinals = []; semiFinals.push({local:`${quarterFinalsWinners[0]}`, visitor: `${quarterFinalsWinners[2]}`}); semiFinals.push({local:`${quarterFinalsWinners[1]}`, visitor: `${quarterFinalsWinners[3]}`}); return semiFinals; } const semiFinals = setSemiFinals(quarterFinalsWinners); //Jugar las semifinales const semiFinalsWinners = playRound(semiFinals,'SF'); console.log('\n==========THIRD AND FOURTH PLACE==========\n'); //Preparar el partido por el tercer y cuarto lugar let semiFinalsLosers=[]; quarterFinalsWinners.forEach((team)=>{ if (!semiFinalsWinners.includes(team)){ semiFinalsLosers.push(team); } }) semiFinalsLosers = [{local: semiFinalsLosers[0], visitor: semiFinalsLosers[1]}]; //Jugar el partido por el tercer lugar const thirdPlaceWinner = playRound(semiFinalsLosers, 'T'); console.log('\n===================FINAL===================\n'); //Preparar la final const finalists = [{local: semiFinalsWinners[0], visitor: semiFinalsWinners[1]}]; //Jugar la final const champion = playRound(finalists, 'F'); console.log(`\n===========================================\n`); //El ganador de la final es el campeón de la Euro Copa console.log(`${champion} is the new Euro Cup Champion!`); console.log(`\n===========================================\n`);
import React, { Component } from 'react'; import Item from './Item' class List extends Component { render() { return ( <ol> <Item text="learn javascript" price={100} /> <Item text="learn React" /> <Item text="make money" /> <Item text="make money" > wwwwww</Item> </ol> ); } } export default List;
import { app, server } from '../app' import models from '../db/models' const https = require('http') var portApp = normalizePort(process.env.NODE_PORT_APP || '3003') app.set('port', portApp) var httpServer = https.createServer(app) server.installSubscriptionHandlers(httpServer) models.sequelize.sync({force: false}).then(function() { httpServer.listen(portApp) httpServer.on('error', onError); httpServer.on('listening', onListening); }); function normalizePort(val) { let port = parseInt(val, 10) if (isNaN(port)) { return val } if (port >= 0) { return port } return false } function onError(error) { if (error.syscall !== 'listen') { throw error; } let bind = typeof portApp === 'string' ? 'Pipe ' + portApp : 'Port ' + portApp switch (error.code) { case 'EACCES': console.error(bind + ' requires elevated privileges') process.exit(1) case 'EADDRINUSE': console.error(bind + ' is already in use') process.exit(1) default: throw error; } } function onListening() { console.log(`🚀 Server ready at http://0.0.0.0:${portApp}${server.graphqlPath}`) console.log(`🚀 Subscriptions ready at ws://0.0.0.0:${portApp}${server.subscriptionsPath}`) }
'use strict'; describe('Service: inventario', function () { // load the service's module beforeEach(module('nextbook20App')); // instantiate service var inventario; beforeEach(inject(function (_inventario_) { inventario = _inventario_; })); it('should do something', function () { expect(!!inventario).toBe(true); }); });
import React from 'react'; import * as _ from 'lodash'; import * as $ from 'jquery'; import {Link} from 'react-router-dom'; import moment from 'moment'; import {Prompt} from 'react-router-dom'; import TimerComponent from '../../helper/timer'; import {getMockExamByIdPublic,startExamAttempt,finishExamAttempt} from '../../../services/mock-exam'; import {startTestAttempt} from '../../../services/exam-test'; import QuestionPanelComponent from '../question-panel/component'; import TogglerComp from './toggler-comp'; export default class ExamStartHome extends React.Component{ state={ isError:false, message:'Please wait while we are loading exam details...', exam:'', activeTest:'', examStarted:true, attemptedQuestions:{}, testStarted:{}, examFinished:false, examAttempt:{}, testAttempts:{}, questionPanelStates:{}, examStartHome:'', isTimeout:false, isExamExpired:false, } componentDidMount=()=>{ getMockExamByIdPublic(this.props.examId) .then(examData =>{ let startTime = moment(examData.mockExam.startDateTime?examData.mockExam.startDateTime: new Date()); let durationLeft = moment.duration(moment(startTime).add(examData.mockExam.durationMinutes,'m').diff(moment())); console.log('durationLeft ',durationLeft); if(durationLeft.hours() < 0 || durationLeft.minutes() < 0 || durationLeft.seconds() < 0){ this.onExamExpired(); return; } startExamAttempt(this.props.examId) .then(attemptData =>{ this.setState({isError:false,examStartHome:this.props.match.url, message:'',examFinished:false,examAttempt:attemptData.examAttempt,exam:examData.mockExam}); }) .catch(error =>{ console.error('Error while starting the exam ',error); this.setState({isError:true, message:error.message}); }); }) .catch(error =>{ console.error('Error while loading the exam ',error); this.setState({isError:true, message:error.message}); }); } componentWillUnmount =()=>{ if(!this.state.examFinished || !this.state.exam){ return; } } onOptionSelect = (questionPanelState)=>{ let testAttempts = this.state.testAttempts; let activeTestAttempt = testAttempts[this.state.activeTest.id]; activeTestAttempt['attemptAnswers']=questionPanelState['attemptedQuestions']; let questionPanelStates = this.state.questionPanelStates; questionPanelStates[this.state.activeTest.id] = questionPanelState; this.setState({ testAttempts:testAttempts ,questionPanelStates:questionPanelStates } ); } onTestStart = (testId)=>{ startTestAttempt(testId) .then( attemptData =>{ let testAttempts = this.state.testAttempts || {}; testAttempts[testId] = attemptData.testAttempt; this.setState({testAttempts:testAttempts}); }) .catch(error =>{ console.error('Error >',error); this.setState({isError:true, message:'Test could not start'}); }); } onExamExpired = ()=>{ this.setState({isError:true, isExamExpired:true, message:'This exam has been expired!'}); } onTimeout = ()=>{ this.onExamFinish(true); this.setState({isError:true, isTimeout:true, message:'Your time is over!'}); } onExamFinish =(timeout)=>{ if(!timeout){ let done = window.confirm('Are you sure to submit the exam?'); if(!done ){ return; } } let examTestAttempts = []; _.forEach(this.state.exam.tests , t =>{ if(this.state.testAttempts[t.id]){ let testAttempt = this.state.testAttempts[t.id]; let attemptAnswers = testAttempt['attemptAnswers']; let attemptAnswersList = []; let questionsList = attemptAnswers?Object.keys(attemptAnswers):[]; _.forEach(questionsList, questionId =>{ attemptAnswersList.push({questionId:questionId,selectedAns:attemptAnswers[questionId]}); }); testAttempt['attemptAnswers'] = attemptAnswersList; examTestAttempts.push(this.state.testAttempts[t.id]); } }); finishExamAttempt(this.state.exam.id,this.state.examAttempt,examTestAttempts) .then(attemptData =>{ this.props.history.push({ pathname:`${this.props.match.url}/finish/`+this.state.exam.id, state:{ examAttempt:attemptData.examAttempt, testAttempts:attemptData.testAttempts, exam:this.state.exam }}); }) .catch(error =>{ console.log('Error while submitting the exam.'); this.setState({isError:true,message:'Error while submitting the exam!'}); }); } onTestClick = (testId)=>{ let tests = this.state.exam.tests || []; let activeTest = {}; if(Array.isArray(tests)){ activeTest = _.find(tests, t => Number(t.id) === Number(testId)); } this.setState({activeTest:activeTest}); } render(){ if(this.state.isExamExpired || this.state.isTimeout){ return <div className="container"> <div className="row"> <div className="mx-auto"><span className="text-style">{this.state.message}</span></div> </div> </div>; } let tests = this.state.exam.tests; let subjectsHtml =''; if(tests && Array.isArray(tests)){ subjectsHtml = tests.map((test,index)=>{ let subjectName = test.name?test.name.split('-')[1]:test.name; return <div key={index} className={"exam-test-col"+(Number(this.state.activeTest.id) === Number(test.id)?' active ':'')}> <button type="button" onClick={()=>this.onTestClick(test.id)} className="exam-test-name-btn" > <span className="text-style">{subjectName} </span></button> </div>; }); }else{ return <div className="container"> <div className="row"> <div className="mx-auto"><span className="text-style">{this.state.message}</span></div> </div> </div>; } return <div className="container-fluid exam-start-home-container"> <Prompt when={this.state.examStarted} message={ (location) =>{ return (location.pathname && location.pathname.indexOf('/finish')>0)?true:"Are you sure to leave the exam?"; } } /> <div className=" row heading-row "> <div className="mx-auto"><span className="text-style">{this.state.exam.name}</span></div> </div> <div className="row justify-content-center"> <div className="text-center"> {this.state.message? <div className={"alert "+ (this.state.isError?' alert-danger':'alert-success') }> {this.state.message} </div>:''} </div> </div> <div className="row"> <TogglerComp exam={this.state.exam}/> </div> <div className="row timmer-row"> <div className="timer-col"> <TimerComponent startTime={this.state.exam.startDateTime} onExamExpired={this.onExamExpired} onExamTimeout = {this.onTimeout} hour={0} minutes={this.state.exam.durationMinutes ?this.state.exam.durationMinutes:0} seconds={0} /> </div> </div> <div className="row justify-content-end mr-2"> <button className="btn btn-primary" onClick={this.onExamFinish} ><span className="text-style">Finish Exam</span></button> </div> <div className="row test-name-row"> {subjectsHtml} </div> {this.state.testAttempts && this.state.testAttempts[this.state.activeTest.id]? <div className="row test-panel-container"> <div className="container-fluid"> <div className="row"> <QuestionPanelComponent attemptedQuestions={this.state.attemptedQuestions[this.state.activeTest.id] || {}} testId={this.state.activeTest.id} questions={this.state.activeTest.questions} onOptionSelect={this.onOptionSelect} questionPanelState={this.state.questionPanelStates[this.state.activeTest.id]} /> </div> </div> </div>: <div className={"row mt-2" + (this.state.activeTest.id?'':' d-none')}> <div className="mx-auto"> <button className="btn btn-primary" onClick={()=>this.onTestStart(this.state.activeTest.id)} > Start {this.state.activeTest.name?this.state.activeTest.name.split('-')[1]:this.state.activeTest.name} Test </button> </div> </div> } </div>; } }
import veact from 'veact' import { state } from '../../controllers' import { type, mediumMargin, purpleRegular, teamNameToID } from '../lib' import { assign, sortBy, filter } from 'lodash' const view = veact() const { div, h2, ul, li, a } = view.els() view.styles({ h2: assign( type('avantgarde', 'smallHeadline'), { marginTop: 30, marginBottom: 4 } ), ul: type('garamond', 'body'), br: { height: mediumMargin }, li: { cursor: 'pointer' } }) const extraLinks = [{ name: 'Who is New?', href: '/who-is-new' }, { name: 'Did you know?', href: '/did-you-know' }] view.render(() => { const highlights = state.get('highlightTeams') const standouts = state.get('standoutSubTeams') const floors = state.get('floors') const team = filter(sortBy([...standouts, ...state.get('teams')]), team => !highlights.teams.includes(team)) return div( h2('.h2', 'Locations'), ul('.ul', sortBy(state.get('cities')).map(city => li('.li', a({ href: `/location/${city}`, style: { color: city === state.get('curFilter') ? purpleRegular : '' } }, city))), div(highlights ? div( h2('.h2', highlights.name), ul('.ul', sortBy(highlights.teams).map(team => a({ href: `/team/${teamNameToID(team)}` }, li('.li', { style: { color: team === teamNameToID(state.get('team')) ? purpleRegular : '' } }, team) ))), ) : ''), h2('.h2', 'Teams'), ul('.ul', team.map(team => a({ href: `/team/${teamNameToID(team)}` }, li('.li', { style: { color: team === teamNameToID(state.get('team')) ? purpleRegular : '' } }, team) ))), // Temporarily disabled, see slack // h2('.h2', 'Floor Plans'), // ul('.ul', floors.map(floor => // a({ href: `/seating/${teamNameToID(floor)}` }, // li('.li', { // style: { // color: floor === teamNameToID(state.get('team')) ? purpleRegular : '' // } // }, floor) // ))), h2('.h2', 'Links'), ul('.ul', extraLinks.map(link => a({ href: link.href }, li('.li', link.name) ))))) }) export default view()
var models = require('.'); var assert = require('assert'); var faker = require('faker'); describe('User Model', () => { describe('Schema', () => { var user; before(done => { models.User.create({name: faker.name.findName()}) .then(u => {user = u}) .then(done, done) }) it('should have a name field', () => { assert.ok('name' in user) assert.equal(typeof user.name, 'string') }) }) })
import React from 'react' import {Link} from 'react-router-dom' import { motion } from 'framer-motion' function HomePage() { const container = { hidden: { opacity: 0 }, show: { opacity: 1, transition: { staggerChildren: 0.1 } } } const item = { hidden: { opacity: 0, y: -100 }, show: { opacity: 1, y: 0, transition: { duration: 0.5 } } } return( <section> <div className="container"> <motion.div variants={container} initial="hidden" animate="show" exit="hidden" className="row"> <motion.div variants={item} className="col-4 demo"> <Link to='/movie'> <img className="demo_img" src={require('../img/movie_demo.jpg')} alt="Movie demo"/> <strong>Movie</strong> </Link> </motion.div> <motion.div variants={item} className="col-4 demo"> <Link to='/project_management'> <img className="demo_img" src={require('../img/project_management_demo.jpg')} alt="Project Management demo"/> <strong>Project Management</strong> </Link> </motion.div> </motion.div> </div> </section> ); } export default HomePage
import { connect } from 'react-redux'; import { signOut } from '../../actions/authActions'; import Logout from '../../components/Auth/Logout'; export default connect( null, { signOut } )(Logout);
// import { useInView } from 'react-intersection-observer'; import Slider from "react-slick"; // import Button from "components/website/button/Button"; import TitleStyle1 from "components/website/pages/about-us/section-banner/title-banner/TitleStyle1"; import TitleStyleVi from "components/website/pages/about-us/section-banner/title-banner/TitleStyleVi"; import asset from "plugins/assets/asset"; // import ItemsScaleEffect from "components/website/pages/about-us/section-banner/item-banner/ItemsEffect.js"; import ItemsSmallEffect1 from "components/website/pages/about-us/section-banner/item-banner/ItemsSmallEffect"; import ItemBanner from "components/website/pages/about-us/section-banner/item-banner/ItemBanner.js"; import useWindowSize from "components/website/hooks/useWindowsSize"; import { useNextResponsive } from "plugins/next-reponsive"; import { MainContent } from "components/website/contexts/MainContent"; import { useEffect, useRef, useState, useContext } from "react"; import { useRouter } from "next/router"; export default function BannerOurProduct() { const settings = { dots: true, infinite: false, speed: 500, slidesToShow: 1, slidesToScroll: 1, adaptiveHeight: true, }; const Language = { en: { name: "en", title: ["Your health","Is our","Specialty"], description: "Lipovitan is a brand of Taisho Pharmaceutical company - one of the largest pharmaceutical corporations in Japan. Taisho has also expanded its business and has subsidiaries in 12 other countries around the world.", }, vi: { name: "vi", title: ["Sức khỏe của bạn","là SỨ MỆNH", "của chúng tôi"], description: "Lipovitan là thương hiệu của công ty Taisho Pharmaceutical - một trong những tập đoàn dược phẩm lớn nhất Nhật Bản. Taisho cũng đã mở rộng hoạt động kinh doanh và có các công ty con tại 12 quốc gia khác trên thế giới." } } const valueLanguageContext = useContext(MainContent); const [dataBannerOurProduct, setDataBannerOurProduct] = useState(); const route = useRouter() const getLink = (link = "https://www.taisho.co.jp/global") => { if(window){ window.open(link,'_blank'); } // route.push(link) }; // detect screen size const [responsiveMaxScreen, setResponsiveMaxScreen] = useState(false); const windowSize = useWindowSize(); let responsive = useNextResponsive(); const LayoutDesktop = asset("/images/slide-banner-about-us-1-size-m.jpg"); const LayoutMobile = asset("/images/mb/aboutus/banner.png"); const [layout, setLayout] = useState(LayoutDesktop); let description = (description) => ( <> <div className="desOurProduct"> <p> {description} </p> </div> <style jsx>{` .desOurProduct { max-width: 500px; margin: 0; p { padding: 20px 0; font-size: 22px; line-height: 1.8; color: #fff; padding-bottom: 30px; } } @media screen and (max-width: 768px) { .desOurProduct { p { font-size: 2vmax; } } } `}</style> </> ); const itemsDescription = (language) => { let component; switch (language) { case "vi": component = description(Language.vi.description) break; default: component = description(Language.en.description) break; } return component; } useEffect(() => { if (valueLanguageContext.languageCurrent) { setDataBannerOurProduct(Language[`${valueLanguageContext.languageCurrent}`]) } }, []) useEffect(() => { if (valueLanguageContext.languageCurrent) { setDataBannerOurProduct(Language[`${valueLanguageContext.languageCurrent}`]) } }, [valueLanguageContext.languageCurrent]); //check responsive useEffect(() => { if (windowSize.width > 600) { setResponsiveMaxScreen(true); } else { setResponsiveMaxScreen(false); } }, [windowSize]); useEffect(() => { switch (responsive.device) { case "mobile": setLayout(LayoutMobile); break; default: setLayout(LayoutDesktop); break; } }, [JSON.stringify(responsive)]); return ( <section className="sectionBanner"> <div className={"slideBanner " + valueLanguageContext.languageCurrent}> <div> <Slider {...settings}> <ItemBanner urlImage={layout}> { dataBannerOurProduct ? ( dataBannerOurProduct.name === "vi" ? ( <TitleStyleVi textLine1={dataBannerOurProduct.title[0]} textLine2={dataBannerOurProduct.title[1]} textLine3={dataBannerOurProduct.title[2]} description={description(dataBannerOurProduct.description)} cbFunctionBtn={getLink} /> ) : ( <TitleStyle1 textLine1={dataBannerOurProduct.title[0]} textLine2={dataBannerOurProduct.title[1]} textLine3={dataBannerOurProduct.title[2]} description={description(dataBannerOurProduct.description)} cbFunctionBtn={getLink} /> ) ) : <></> } {responsiveMaxScreen === true ? ( <ItemsSmallEffect1 srcImage={asset("/images/item-about-us-banner-house.png")} timeShow={0.4} width={64} top={25} right={"0"} animation={false} ></ItemsSmallEffect1> ) : ( "" )} </ItemBanner> </Slider> </div> </div> <style jsx>{` .sectionBanner{ z-index: 2; } .slideBanner{ z-index: 2; } `}</style> </section> ); }
var CommonUIDrawManager = new function(){ var bNumFont = null, rNumFont = null, yNumFont = null, wNumFont = null;; var lNumFont = null, l2NumFont = null; var slash = null, colon = null, max = null, lv = null, percent = null; var bar_id, bar_key, bar_stone_red, bar_stone_blue, bar_stone_black, bar_coin, bar_gem; this.renderMoney = function(g) { if (bNumFont != null) { this.renderToken(g); g.drawImage(bar_stone_red, 492, 12); g.drawImage(bar_stone_blue, 638, 12); g.drawImage(bar_stone_black, 782, 12); g.drawImage(bar_coin, 926, 12); g.drawImage(bar_gem, 1097, 13); g.setFont(FONT_20); g.setColor(COLOR_WHITE); HTextRender.oriRender(g, itemMgr.getRedStoneAmount(), 585, 43, HTextRender.CENTER); HTextRender.oriRender(g, itemMgr.getBlueStoneAmount(), 730, 43, HTextRender.CENTER); HTextRender.oriRender(g, itemMgr.getBlackStoneAmount(), 874, 43, HTextRender.CENTER); HTextRender.oriRender(g, itemMgr.getGoldAmountForRender(), 1029, 43, HTextRender.CENTER); HTextRender.oriRender(g, itemMgr.getGemAmountForRender(), 1201, 43, HTextRender.CENTER); } }; this.renderMain = function(g) { if (bNumFont != null) { this.renderInfo(g); this.renderToken(g); g.drawImage(bar_stone_red, 492, 12); g.drawImage(bar_stone_blue, 638, 12); g.drawImage(bar_stone_black, 782, 12); g.drawImage(bar_coin, 926, 12); g.drawImage(bar_gem, 1097, 13); g.setFont(FONT_20); g.setColor(COLOR_WHITE); HTextRender.oriRender(g, itemMgr.getRedStoneAmount(), 585, 43, HTextRender.CENTER); HTextRender.oriRender(g, itemMgr.getBlueStoneAmount(), 730, 43, HTextRender.CENTER); HTextRender.oriRender(g, itemMgr.getBlackStoneAmount(), 874, 43, HTextRender.CENTER); HTextRender.oriRender(g, itemMgr.getGoldAmountForRender(), 1029, 43, HTextRender.CENTER); HTextRender.oriRender(g, itemMgr.getGemAmountForRender(), 1201, 43, HTextRender.CENTER); } }; var gameMoney = 0; this.setGameMoney = function() { gameMoney = 0; }; this.increaseGameMoney = function(_gold) { gameMoney += _gold; }; this.decreaseGameMoney = function(_gold) { gameMoney -= _gold; }; this.getGameMoneyGold = function() { return gameMoney; }; this.renderMoneyForGame = function(g) { rNumFont.render(g, gameMoney, 910, 18, 16, HTextRender.CENTER); }; this.checkPrice = function(code, price) { if (code == "GEM") return gameGem - price; else if (code == "GOLD") return gameMoney - price; else return 0; }; this.renderToken = function(g) { var amount = tokenMgr.getAmount(); g.drawImage(bar_key, 349, 11); g.setFont(FONT_20); g.setColor(COLOR_WHITE); HTextRender.oriRender(g, tokenMgr.getAmount(), 440, 43, HTextRender.CENTER); if (amount < 10) { if (tokenMgr.getRemainSecStr() < 10) { HTextRender.oriRender(g, tokenMgr.getRemainMinStr() + ":0" + tokenMgr.getRemainSecStr(), 440, 75, HTextRender.CENTER); } else { HTextRender.oriRender(g, tokenMgr.getRemainMinStr() + ":" + tokenMgr.getRemainSecStr(), 440, 75, HTextRender.CENTER); } } }; this.renderStone = function(g) { bNumFont.render(g, itemMgr.getGoldAmountForRender(), 74, 37, 11, HTextRender.LEFT); bNumFont.render(g, itemMgr.getGemAmountForRender(), 199, 37, 11, HTextRender.LEFT); }; this.renderInfo = function(g) { g.drawImage(bar_id, 24, 14); g.setFont(FONT_20); g.setColor(COLOR_WHITE); HTextRender.oriRender(g, MyInfo.getUserName(), 114, 43, HTextRender.CENTER); }; this.setResource = function(onload) { bNumFont = PlayResManager.getMoneyMap().get("bNumFont"); rNumFont = PlayResManager.getMoneyMap().get("rNumFont"); yNumFont = PlayResManager.getMoneyMap().get("yNumFont"); lNumFont = PlayResManager.getMoneyMap().get("lNumFont"); l2NumFont = PlayResManager.getMoneyMap().get("l2NumFont"); wNumFont = PlayResManager.getMoneyMap().get("wNumFont"); lv = PlayResManager.getMoneyMap().get("lv"); percent = PlayResManager.getMoneyMap().get("percent"); bar_id = PlayResManager.getMoneyMap().get("bar_id"); bar_key = PlayResManager.getMoneyMap().get("bar_key"); bar_stone_red = PlayResManager.getMoneyMap().get("bar_stone_red"); bar_stone_blue = PlayResManager.getMoneyMap().get("bar_stone_blue"); bar_stone_black = PlayResManager.getMoneyMap().get("bar_stone_black"); bar_coin = PlayResManager.getMoneyMap().get("bar_coin"); bar_gem = PlayResManager.getMoneyMap().get("bar_gem"); onload(); }; this.removeResource = function() { if(bNumFont!=null) bNumFont.dispose(); if(rNumFont!=null) rNumFont.dispose(); if(yNumFont!=null) yNumFont.dispose(); if(lNumFont!=null) lNumFont.dispose(); if(l2NumFont!=null) l2NumFont.dispose(); bNumFont = null; rNumFont = null; yNumFont = null; lNumFont = null; l2NumFont = null; wNumFont = null; slash = null; colon = null; max = null; lv = null; percent = null; bar_id = null; bar_key = null; bar_stone_red = null; bar_stone_blue = null; bar_stone_black = null; bar_coin = null; bar_gem = null; }; this.destroy = function() { this.removeResource(); }; }; var uiDrawMgr = CommonUIDrawManager;
let myfunction= function checkCollegeName(clgname){ var collegeList=['biher','lps','shs']; for (let index = 0; index < 3; index++) { if(clgname==collegeList[index]){ return true; } } return false; } exports.checkClg=myfunction;
/** * Current Date/Time Location Widget */ import React, { Component } from 'react'; // intl messages import IntlMessages from 'Util/IntlMessages'; // rct card box import { RctCardContent } from 'Components/RctCard'; function checkTime(i) { if (i < 10) { i = "0" + i }; // add zero in front of numbers < 10 return i; } class CurrentTimeLocation extends Component { state = { currentTime: { hours: '', minutes: '', seconds: '' } } componentWillMount() { let self = this; this.timer = setInterval(() => { self.startTime(); }, 500); } componentWillUnmount() { clearInterval(this.timer); } startTime() { let today = new Date(); let h = today.getHours(); let m = today.getMinutes(); let s = today.getSeconds(); m = checkTime(m); s = checkTime(s); let time = { hours: h, minutes: m, seconds: s } this.setState({ currentTime: time }); } render() { const { hours, minutes, seconds } = this.state.currentTime; return ( <div className="current-widget bg-info"> <RctCardContent> <div className="d-flex justify-content-between"> <div className="align-items-start"> <h3 className="mb-10"><IntlMessages id="widgets.currentTime" /></h3> <h2 className="mb-0">{`${hours} : ${minutes} : ${seconds}`}</h2> </div> <div className="align-items-end"> <i className="zmdi zmdi-time"></i> </div> </div> </RctCardContent> </div> ); } } export default CurrentTimeLocation;
const dateFormat = require('dateformat'); function format(object) { const tmp = object; if (tmp.from) { tmp.from = dateFormat(tmp.from, 'yyyy-mm-dd HH:MM:ss'); } if (tmp.to) { tmp.to = dateFormat(tmp.to, 'yyyy-mm-dd HH:MM:ss'); } if (tmp.date) { tmp.date = dateFormat(tmp.date, 'yyyy-mm-dd HH:MM:ss'); } if (tmp.exp_year) { tmp.exp_year = dateFormat(tmp.exp_year, 'yyyy-mm-dd HH:MM:ss'); } if (tmp.change_date) { tmp.change_date = dateFormat(tmp.change_date, 'yyyy-mm-dd HH:MM:ss'); } if (tmp.start_date) { tmp.start_date = dateFormat(tmp.start_date, 'yyyy-mm-dd HH:MM:ss'); } return tmp; } function formatArr(arr) { return arr.map(item => format(item)); } module.exports = { format, formatArr, };
import React, { Component } from 'react' import PropTypes from 'prop-types' class Item extends Component { render() { return( <li>{this.props.item}</li> ) } } Item.propTypes = { item: PropTypes.string } export default Item
import React from 'react' import reactDOM from 'react-dom' import Wrapper from './js/index' import { AppContainer } from 'react-hot-loader' const render = (App) => { reactDOM.render( <AppContainer> <App /> </AppContainer>, document.getElementById('app') ) } render(Wrapper) if(module.hot){ module.hot.accept('./js/index', () => { render(Wrapper) }) }
function ymdChart(){ var chartdata =[]; $.ajax({ url : "salesData", async : false, data : {'yearSales':yearSales,'monthSales':monthSales,'daySales':daySales}, success : function(result) { for(i=0; i<result.length; i++) { chartdata.push(result[i].yearSales, result[i].monthSales,result[i].daySales =="undefined"? 0 : result[i].daySales); } } }); var ctx = document.getElementById("ymdChart").getContext('2d'); var myChart = new Chart(ctx, { type : 'bar', data: { labels : ["년","월","일"], datasets: [{ label: ' 연 매출', data : chartdata, backgroundColor : [ 'rgba(255, 159, 64, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(255, 206, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(255, 159, 64, 0.2)' ], borderColor : [ 'rgba(255,99,132,1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)' ], borderWidth : 1 } ] }, options : { scales : { yAxes : [ { ticks : { beginAtZero : true } } ] } } }); yearSales =''; monthSales =''; daySales =''; };
import axios from 'axios' import {Message} from 'element-ui' import store from '@/store' import {getToken} from '@/utils/auth' // create an axios instance const service = axios.create({ baseURL: "http://127.0.0.1:8080", // 服务器地址 // withCredentials: true, // send cookies when cross-domain requests timeout: 5000 // request timeout }) // request interceptor service.interceptors.request.use( config => { // 发送请求前做一些处理 if (store.getters.token) { //每次请求都需要携带Token config.headers['Authentication-Token'] = getToken() } return config }, error => { // do something with request error console.log(error) // for debug return Promise.reject(error) } ) // response interceptor service.interceptors.response.use( /** * If you want to get http information such as headers or status * Please return response => response */ /** * Determine the request status by custom code * Here is just an example * You can also judge the status by HTTP Status Code */ response => { const res = response.data console.log(res) //统一在这里出错时输出原因 if(res.code !== 200) { Message({ message: res.message || 'Error', type: 'error', duration: 5 * 1000 }) //这个会向上抛出错误,不然上面以为执行成功 return Promise.reject(new Error(res.message || 'Error')) } return res; }, error => { console.log('err' + error) // for debug Message({ message: error.message, type: 'error', duration: 5 * 1000 }) return Promise.reject(error) } ) export default service
import React from 'react'; import { connect } from 'react-redux'; import requiresLogin from './requires-login'; import './dashboard.css'; import { Link } from 'react-router-dom'; export class Dashboard extends React.Component { render() { return ( <div className="dashboard-layout"> <div className="background-image" /> {/* top part of dashboard */} <div className="dashboard-top"> {/* top bar of dashboard */} <div className="dashboard-background"> <div className="dashboard-banner"> <div className="welcome-message-prompt"> <div className="left-banner">👋 Welcome {this.props.name}!</div> </div> </div> </div> {/* End of top bar of dashboard */} <div className="dashboard-main"> <div className="dashboard-box"> <div className="title"> <h1> 📗 SQL Beginner </h1> </div> <h3 className="level">10 questions | Lifetime Score: 75%</h3> <div className="about-cards"> SQL Learning Labs is a platform made to test your knowledge of SQL Bash commands, and to help you accelerate your learning. </div> <Link to="/frontofcard"> <button className="hero-button">📚 SQL Basics</button> {/* <button>SQL Basics</button> */} </Link> </div> <div className="dashboard-box"> <div className="title"> <h1> 🔖 SQL Intermediate </h1> </div> <h3 className="level">Coming Soon</h3> <div className="about-cards"> SQL Learning Labs is a platform made to test your knowledge of SQL Bash commands, and to help you accelerate your learning. </div> </div> </div> </div> </div> ); } } const mapStateToProps = state => { const { currentUser } = state.authReducer; return { username: state.authReducer.currentUser.username, name: `${currentUser.firstName} ${currentUser.lastName}` }; }; export default requiresLogin()(connect(mapStateToProps)(Dashboard)); { /* <p>Questions or feedback? We'd love to hear from you:{' '} <a href="mailto:sqllearninglabs@gmail.com?Subject=SQL%20is%20Awesome" target="_top" > Email Us! </a> </p> */ }
import React, { Component } from 'react' export default class Features extends Component { render() { return ( <div> <section className="awesome-feature-area bg-white section_padding_0_50 clearfix" id="features"> <div className="container"> <div className="row"> <div className="col-12"> {/* Heading Text */} <div className="section-heading text-center"> <h2>Awesome Features</h2> <div className="line-shape" /> </div> </div> </div> <div className="row"> {/* Single Feature Start */} <div className="col-12 col-sm-6 col-lg-4"> <div className="single-feature"> <i className="ti-user" aria-hidden="true" /> <h5>Awesome Experience</h5> <p>Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </div> </div> {/* Single Feature Start */} <div className="col-12 col-sm-6 col-lg-4"> <div className="single-feature"> <i className="ti-pulse" aria-hidden="true" /> <h5>Fast and Simple</h5> <p>Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </div> </div> {/* Single Feature Start */} <div className="col-12 col-sm-6 col-lg-4"> <div className="single-feature"> <i className="ti-dashboard" aria-hidden="true" /> <h5>Clean Code</h5> <p>Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </div> </div> {/* Single Feature Start */} <div className="col-12 col-sm-6 col-lg-4"> <div className="single-feature"> <i className="ti-palette" aria-hidden="true" /> <h5>Perfect Design</h5> <p>Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </div> </div> {/* Single Feature Start */} <div className="col-12 col-sm-6 col-lg-4"> <div className="single-feature"> <i className="ti-crown" aria-hidden="true" /> <h5>Best Industry Leader</h5> <p>Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </div> </div> {/* Single Feature Start */} <div className="col-12 col-sm-6 col-lg-4"> <div className="single-feature"> <i className="ti-headphone" aria-hidden="true" /> <h5>24/7 Online Support</h5> <p>Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </div> </div> </div> </div> </section> {/* ***** Awesome Features End ***** */} </div> ) } }
const readline = require('readline').createInterface({ input: process.stdin, output: process.stdout }); readline.question('Input = ', input => { let panjangArr = input.charAt(0) let rotasi = input.charAt(2) let arr = []; //input array for(let i = 0; i < panjangArr; i++){ arr.push(i + 1); } //melakukan rotasi for(let i = 1; i <= rotasi; i++){ //mengambil value awal array let firstValue = arr[0]; //lalukan penambahan pada array arr.push(firstValue); //melakukan penghapusan value awal array arr.shift(); } //print hasil console.log(arr.join(' ')) readline.close(); });
'use strict'; var app = require('../..'); import request from 'supertest'; var newFeeds; describe('Feeds API:', function() { describe('GET /api/feeds', function() { var feedss; beforeEach(function(done) { request(app) .get('/api/feeds') .expect(200) .expect('Content-Type', /json/) .end((err, res) => { if (err) { return done(err); } feedss = res.body; done(); }); }); it('should respond with JSON array', function() { feedss.should.be.instanceOf(Array); }); }); describe('POST /api/feeds', function() { beforeEach(function(done) { request(app) .post('/api/feeds') .send({ name: 'New Feeds', info: 'This is the brand new feeds!!!' }) .expect(201) .expect('Content-Type', /json/) .end((err, res) => { if (err) { return done(err); } newFeeds = res.body; done(); }); }); it('should respond with the newly created feeds', function() { newFeeds.name.should.equal('New Feeds'); newFeeds.info.should.equal('This is the brand new feeds!!!'); }); }); describe('GET /api/feeds/:id', function() { var feeds; beforeEach(function(done) { request(app) .get('/api/feeds/' + newFeeds._id) .expect(200) .expect('Content-Type', /json/) .end((err, res) => { if (err) { return done(err); } feeds = res.body; done(); }); }); afterEach(function() { feeds = {}; }); it('should respond with the requested feeds', function() { feeds.name.should.equal('New Feeds'); feeds.info.should.equal('This is the brand new feeds!!!'); }); }); describe('PUT /api/feeds/:id', function() { var updatedFeeds; beforeEach(function(done) { request(app) .put('/api/feeds/' + newFeeds._id) .send({ name: 'Updated Feeds', info: 'This is the updated feeds!!!' }) .expect(200) .expect('Content-Type', /json/) .end(function(err, res) { if (err) { return done(err); } updatedFeeds = res.body; done(); }); }); afterEach(function() { updatedFeeds = {}; }); it('should respond with the updated feeds', function() { updatedFeeds.name.should.equal('Updated Feeds'); updatedFeeds.info.should.equal('This is the updated feeds!!!'); }); }); describe('DELETE /api/feeds/:id', function() { it('should respond with 204 on successful removal', function(done) { request(app) .delete('/api/feeds/' + newFeeds._id) .expect(204) .end((err, res) => { if (err) { return done(err); } done(); }); }); it('should respond with 404 when feeds does not exist', function(done) { request(app) .delete('/api/feeds/' + newFeeds._id) .expect(404) .end((err, res) => { if (err) { return done(err); } done(); }); }); }); });
customrs = JSON.parse(localStorage.getItem('customrs')) || [] CustomrId=500300200 //Customr Data Form document.querySelector("#showForm").addEventListener('click', function(e){ e.target.textContent == "Add New Customr"? e.target.textContent="Hide Form": e.target.textContent="Add New Customr"; document.querySelector('#addCustomrForm').classList.toggle('d-none') }) //Customr Data Entry document.querySelector("#addCustomrData").addEventListener('submit',function(e){ e.preventDefault() data = e.target.elements customrs.length>0? CustomrId=customrs[customrs.length-1].id+1 : CustomrId customr ={ id:CustomrId } for(i=0; i<data.length-1;i++){ customr[data[i].name] = data[i].value } customrs.push(customr) localStorage.setItem('customrs', JSON.stringify(customrs)) e.target.reset() document.querySelector('#customrDisplayTable').classList.remove('d-none') displayCustomrs() }) //Creat Element Function const addElement = function(type,contant){ ele = document.createElement(type) ele.innerHTML = contant return(ele) } //Customr Display const displayCustomrs = function(){ document.querySelector('#customrDisplayTable table tbody').textContent="" customrs.forEach( (customer, i) => { const tr = document.createElement('tr') const td1 = addElement('td', customer.id) const td2 = addElement('td', customer.CustomrName) const td3 = addElement('td', customer.CustomrBalance) const td4 = addElement('button', 'DELETE Customer') const td5 = addElement('button', 'Withdraw Balance') const td6 = addElement('button', 'Add Balance') tr.appendChild(td1) tr.appendChild(td2) tr.appendChild(td3) tr.appendChild(td4) tr.appendChild(td5) tr.appendChild(td6) document.querySelector('#customrDisplayTable table tbody').appendChild(tr) delCustomer(td4,i) withdrawBalance(td5,i) addBalance(td6,i) }); } //Delete Customers Function delCustomer = function(btn, i){ btn.addEventListener('click', function(e){ customrs.splice(i,1) localStorage.setItem('customrs', JSON.stringify(customrs)) customrs.length == 0 ? document.querySelector('#customrDisplayTable').classList.add('d-none'): displayCustomrs() }) } //withdraw balance of Customers Function withdrawBalance = function(btn, i){ btn.addEventListener('click', function(e){ val = parseFloat(prompt('enter value')) customrs[i].CustomrBalance>val? customrs[i].CustomrBalance = customrs[i].CustomrBalance - val : alert("Rejected withdraw") localStorage.setItem('customrs', JSON.stringify(customrs)) displayCustomrs() }) } //Add balance of Customers Function addBalance = function(btn, i){ btn.addEventListener('click', function(e){ val = parseFloat(prompt('enter value')) customrs[i].CustomrBalance = customrs[i].CustomrBalance + val localStorage.setItem('customrs', JSON.stringify(customrs)) displayCustomrs() }) } //Search by customers ID function document.querySelector("#customrSearchTable").addEventListener('keyup', function(e){ const SearchVal= e.target.value table = document.getElementById("customersTable"); tr = table.getElementsByTagName("tr"); for (i = 0; i < tr.length; i++) { td = tr[i].getElementsByTagName("td")[0]; if (td) { txtValue = td.textContent ; if (txtValue.includes(SearchVal) > 0) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } }) customrs.length == 0 ? document.querySelector('#customrDisplayTable').classList.add('d-none'): displayCustomrs()
const {Calendar,Sem} = require('../models/index'); const getCalendar=async(roles)=>{ if(!roles.includes("Admin")) throw new Error("Only Admin roles can make this request") const calendar=await Calendar.findAll(); return calendar;`` } const modifyDatetype=async(roles,dateOpts)=>{ if(!roles.includes("Admin")) throw new Error("Only Admin roles can make this request") const cal=await Calendar.findOne({where: {date: dateOpts.date}}); if (!cal){ await Calendar.create({ ...dateOpts }) }else{ cal.type=dateOpts.type; await cal.save(); } const calendar=await Calendar.findAll(); return calendar; } const deleteDateType=async(roles,date)=>{ if(!roles.includes("Admin")) throw new Error("Only Admin roles can make this request") const cal = await Calendar.findOne({where: {date: date}}); await cal.destroy(); const days = await Calendar.findAll(); return days } module.exports={ getCalendar, modifyDatetype, deleteDateType }
export const SET_PAPERBOY_HEAD = 'SET_PAPERBOY_HEAD'; export const ADD_PAPERBOY_ROWS = 'ADD_PAPERBOY_ROWS'; export const OPEN_MODAL_MODIFY_DRAFT = 'OPEN_MODAL_MODIFY_DRAFT'; export const CLOSE_MODAL_MODIFY_DRAFT = 'CLOSE_MODAL_MODIFY_DRAFT'; export const REQ_CREATE_DRAFT = 'REQ_CREATE_DRAFT'; export const TRUNCATE_PAPERBOY_ROWS = 'TRUNCATE_PAPERBOY_ROWS';
const { authenticate } = require('@feathersjs/authentication/lib').hooks const linkTo = require('../../hooks/linkTo') const unlinkFrom = require('../../hooks/unlinkFrom') const { disallow } = require('feathers-hooks-common/lib') const restrictToOwner = require('../../hooks/restrictToOwner') const injectUserId = require('../../hooks/injectUserId') const restrictToCustomer = () => restrictToOwner('customer', 'cartId') const cartLinks = [ { targetService: 'users', targetKey: 'customer.cartId', sourceIdKey: 'userId', isArray: false } ] const createNewCart = () => async context => { context.data.isPlaced = false context.data.cartProducts = [] return context } module.exports = { before: { all: [authenticate('jwt')], find: [], get: [restrictToCustomer()], create: [ // put back disallow injectUserId(), createNewCart() ], update: [], patch: [restrictToCustomer()], remove: [disallow('external'), injectUserId(), unlinkFrom(cartLinks)] }, after: { all: [], find: [], get: [], create: [linkTo(cartLinks)], update: [], patch: [], remove: [] }, error: { all: [], find: [], get: [], create: [], update: [], patch: [], remove: [] } }
"use strict"; require('promise.prototype.finally').shim(); const promisify = require("es6-promisify"), config = require("config"), _ = require('lodash'), winston = require('winston'), commonUtils = require('../common/utils'), encryption = require('../common/encryption'), readDuration = commonUtils.readDuration, error = require('../common/error'), SqsBase = require('./sqs-base'), humanInterval = require('human-interval'), moment = require('moment'); const DEFAULT_AWS_EXT_CONFIG = { sqs: { defaults: { poll: { interval: 20, // seconds error: { maxWait: 600, //seconds minWait: 10 //seconds } }, message: { error: { minVisibility: 60, // seconds maxVisibility : 1800, //seconds maxRetries: 10, exponentBase: 2 } }, } } }; /** * SQS Queue consumer that handles * - message parsing (JSON) * - validation * - Retries and Polling * - API Methods to get status and control consumer */ class SqsConsumer extends SqsBase { constructor(options, handler, defaultAwsExtConfig) { super(options, _.merge({}, DEFAULT_AWS_EXT_CONFIG, defaultAwsExtConfig)); this._errorCnt = 0; this._running = false; this._lastPollDate = null; this._jobRetrier = new commonUtils.Retrier(this.conf.poll.error.minWait, this.conf.poll.error.maxWait); this._messageRetrier = new commonUtils.Retrier(this.conf.message.error.minVisibility, this.conf.message.error.maxVisibility, this.conf.message.error.maxRetries, this.conf.message.error.exponentBase); this._enabled = this.conf.consumer.enabled; this._scheduler = this.conf.consumer.scheduler; this._nextScheduledStartDate = moment(this._scheduler.start, 'hh:mm:ss'); // Either handler can be overridden or injected // If passed in , we will inject it if(handler) { this.handle = handler; } } status() { return _.merge(super.status(), { enabled: this._enabled, running: this._running, lastPollDate: this._lastPollDate }); } get running() { return this._running; } get enabled() { return this._enabled; } getScheduler() { return { isScheduled: this._scheduler.scheduled, nextStartDate: this._nextScheduledStartDate, duration: humanInterval(this._scheduler.duration) }; } isConsuming() { if(!this._scheduler.scheduled) return true; return this._getVisibilityTimeout() === 0; } start(waitTillStopped) { if(!this._enabled) { return Promise.resolve(); } if(this._running) { return Promise.resolve(); } this._running = true; return this._init() .then(()=>{ this.emit('running'); let pollPromise = this._poll(); if(waitTillStopped) { return pollPromise; } }) .catch(err => { winston.error(`SqsConsumer::${this.name}:: An error occurred during initialization.`, err); this._running = false; this.emit('stopped'); throw err; }); } stop() { winston.info(`SqsConsumer::${this.name}:: Stopping consumer`); if(this._running) { this._running = false; return new Promise(resolve => { this.once('stopped', () => { this._queueUrl = null; return resolve(); }); }); } return Promise.resolve(); } /** * Handles message. This method should be extended and overridden for application specific message handling. * @param {Object} msgBody - Message body * @param {Object} message - Original SQS message * @return {Promise.<*>} */ handle(msgBody, message) { return Promise.reject(new error.NonRetryableError('Not Implemented')); } /** * Handler for handling errors during message processing * @param {Error} err - Error to be handled * @param {Object} message - Original SQS message * @param {Object} msgBody - Parsed message bofy if available * @return {Promise.<TResult>|*} */ handleError(err, message, msgBody) { this.emit('failed', message, msgBody, err); if(err && (err instanceof SyntaxError || err instanceof error.ValidationError || err instanceof error.NonRetryableError)) { //No Retries on syntax error or ValidationError (Delete the message from queue for these errors) //In perfect world this should never happen, but even it does, we do not intend to retry these errors. winston.warn(`SqsConsumer::${this.name}:: Invalid message: ${message.MessageId}`, err); if(!this._queueUrl) { return Promise.resolve(true); } return this._sqs.deleteMessage({ QueueUrl: this._queueUrl, ReceiptHandle: message.ReceiptHandle }).promise() .then(() => { winston.info(`SqsConsumer::${this.name}:: Deleted message: ${message.MessageId}`); return true; }); } //Only throw errors if we've retried more than the maxRetry count if (message.Attributes.ApproximateReceiveCount >= this.conf.message.error.maxRetries) { winston.error(`SqsConsumer::${this.name}:: An error occurred processing message: ${message.MessageId}`, err); } throw err; } _handle(message) { winston.info(`SqsConsumer::${this.name}:: Processing message: ${message.MessageId}`); let msgBody = null; return Promise.resolve(message.Body) .then(messageBody => { msgBody = JSON.parse(messageBody); return msgBody; }) .then(messageBody => this._decryptMessage(messageBody, message)) .then(messageBody => { msgBody = messageBody; return this.validateMessage(msgBody); }) .then(() => this.handle(msgBody, message)) .then(()=> this._sqs.deleteMessage({ QueueUrl: this._queueUrl, ReceiptHandle: message.ReceiptHandle }).promise()) .then(data => { this.emit('processed', message, msgBody); if(data) { winston.info(`SqsConsumer::${this.name}:: Deleted message: ${message.MessageId}`); } return true; }) .catch(err => { return this.handleError(err, message, msgBody); }) .catch(() => { // Final Catch all (should not raise further exceptions) if(message && this._queueUrl) { return this._sqs.changeMessageVisibility({ QueueUrl: this._queueUrl, ReceiptHandle: message.ReceiptHandle, VisibilityTimeout: this._messageRetrier.nextTryInterval(message.Attributes.ApproximateReceiveCount || 1) }).promise() .then(() => false) .catch((err) => { winston.error(`SqsConsumer::${this.name}:: Failed to change message visibility`, err); return false; }); } return false; }); } _checkPoll() { if(!this._enabled) { winston.info(`SqsConsumer::${this.name}:: Consumer not enabled. Stopping poll.`); this.stop(); return false; } if(!this._running) { winston.info(`SqsConsumer::${this.name}:: Stop polling for queue`, {queueUrl: this._queueUrl}); return false; } if(!this._queueUrl) { winston.error(`SqsConsumer::${this.name}:: Queue not initialized. Stopping poll`); this.stop(); return false; } return true; } _poll() { if(!this._checkPoll()) { this.emit('stopped'); return Promise.resolve(); } winston.debug(`SqsConsumer::${this.name}:: Polling queue using long poll`, {queueUrl: this._queueUrl}); this._lastPollDate = new Date(); return this._sqs.receiveMessage({ MaxNumberOfMessages: this.conf.concurrency, WaitTimeSeconds: this.conf.poll.interval, QueueUrl: this._queueUrl, AttributeNames: ['ApproximateReceiveCount'] }).promise() .then(data => this._scheduledConsuming(data)) .then(data => { if(!data || !data.Messages || !data.Messages.length) { return Promise.resolve(true); } return Promise.all(data.Messages.map(message => this._handle(message))) .then(results=> results.reduce((previous, current) => previous !== false && current !== false)); }).catch(err => { winston.error(`SqsConsumer::${this.name}:: Unknown error occurred during poll`, err); throw err; }).then( (success) => this._waitAndPoll(!success), (err) => this._waitAndPoll(true)); } _waitAndPoll(shouldWait) { if(!shouldWait) { //Clear error count as we are not waiting. this._errorCnt = 0; return this._poll(); } this._errorCnt++; let waitPeriod = this._jobRetrier.nextTryInterval(this._errorCnt); winston.info(`SqsConsumer::${this.name}::Waiting for ${waitPeriod} seconds prior to starting next poll`); return commonUtils.wait(waitPeriod * 1000) .finally(() => this._poll()); } _scheduledConsuming(data) { if(!data || !data.Messages || !data.Messages.length || !this._scheduler || !this._scheduler.scheduled) { return Promise.resolve(data); } let timeout = this._getVisibilityTimeout(); if(timeout) { let messageIds = _.map(data.Messages, _.property('MessageId')); winston.info(`SqsConsumer::${this.name}:: Delaying messages by ${timeout} seconds: ` + `${JSON.stringify(messageIds)}`); return Promise.all(data.Messages.map(message => { this._sqs.changeMessageVisibility({ QueueUrl: this._queueUrl, ReceiptHandle: message.ReceiptHandle, VisibilityTimeout: timeout }).promise(); })) .then(() => ({})); } return Promise.resolve(data); } /** * Will decrypt the message body * @param {object} messageBody The SQS message body * @return {object} The decrypted message body. If there was no encrypted data, returns messageBody. */ _decryptMessage(messageBody, message) { // If the message has encrypted properties... if(messageBody.encrypted) { return this._decrypt(messageBody.encrypted) // decrypt it... .then(decryptedData => { delete messageBody.encrypted; return _.merge({}, messageBody, decryptedData); // and merge it into the message body }) .catch(err => { if (err instanceof TypeError || err.name === 'InvalidCiphertextException') { throw new error.NonRetryableError( `Failed to decrypt the payload for message: ${message.MessageId}. Reason:${err}`, err); } throw err; }); } // Return the original message body if there was nothing to decrypt return Promise.resolve(messageBody); } /** * Returns a SQS queue message visibility timeout based on the schedule's next start date-time * @return {Number} timeout A sqs queue message visibility timeout in seconds */ _getVisibilityTimeout() { let now = moment().milliseconds(0), start = moment(this._scheduler.start, 'hh:mm:ss'), end = moment(start).add(humanInterval(this._scheduler.duration), 'ms'), timeoutDuration = readDuration(this._scheduler.maxVisibilityTimeout); this._nextScheduledStartDate = moment(start); // A timeout of zero means we don't want to wait to process the messages later. We're in the processing window. if(now.isBetween(start, end)) return 0; // Calculate the time until the next scheduled start if(now.isAfter(end)) this._nextScheduledStartDate.add(1, 'days'); let nextStartDiff = this._nextScheduledStartDate.diff(now, 'seconds', true), timeout = Math.min(nextStartDiff, timeoutDuration.asSeconds()); return timeout; } } module.exports = SqsConsumer;
'use strict' module.exports = function OptionsValidator (params) { if (!validateParams(params)) { throw new Error('-- OptionsValidator: required options missing') } if (!(this instanceof OptionsValidator)) { return new OptionsValidator(params) } const requiredOptions = params.required this.getRequiredOptions = function () { return requiredOptions } this.validate = function (parameters) { const errors = [] requiredOptions.forEach(function (requiredOptionName) { if (typeof parameters[requiredOptionName] === 'undefined') { errors.push(requiredOptionName) } }) return errors } function validateParams (params) { if (!params) { return false } return typeof params.required !== 'undefined' && params.required instanceof Array } }
import React from 'react'; import './FilterButton.scss' import { FilterContext } from './FilterContext'; class FilterPerimeterButton extends React.Component { onClick(filter) { this.context.setPerimeter(filter); } render() { const filter = this.props.filter; const active = this.context.perimeter === filter; const name = this.props.name; return ( <span className={'button' + (active ? ' is-active-filter' : '')} onClick={() => this.onClick(filter)}> {name} </span> ) } } FilterPerimeterButton.contextType = FilterContext; export default FilterPerimeterButton;
var searchData= [ ['scena_88',['Scena',['../class_scena.html',1,'Scena'],['../class_scena.html#a8f9fe11b4cfef890123a2acc94672e17',1,'Scena::Scena()']]], ['scena_2ecpp_89',['scena.cpp',['../scena_8cpp.html',1,'']]], ['size_2ehh_90',['size.hh',['../size_8hh.html',1,'']]], ['skalax_91',['SkalaX',['../class_pz_g_1_1_lacze_do_g_n_u_plota.html#a4b1eb252fd785a5aeff938e7b2dce2b1',1,'PzG::LaczeDoGNUPlota']]], ['skalaz_92',['SkalaZ',['../class_pz_g_1_1_lacze_do_g_n_u_plota.html#a44f922ccbc508d6cd7809c669238dae3',1,'PzG::LaczeDoGNUPlota']]], ['solid_93',['Solid',['../class_solid.html',1,'']]], ['solid_2ecpp_94',['Solid.cpp',['../_solid_8cpp.html',1,'']]], ['srodek_5fbryly_95',['srodek_bryly',['../class_solid.html#a670f611d4e6e6444b0b05d5a495ffe16',1,'Solid']]] ];
import { Upload, Icon, Modal,message } from 'antd'; import {onGetImageUrl} from '@/utils/FunctionSet'; import _ from 'lodash' function getBase64(file) { return new Promise((resolve, reject) => { const reader = new FileReader(); reader.readAsDataURL(file); reader.onload = () => resolve(reader.result); reader.onerror = error => reject(error); }); } //主表图片格式的上传 export default class ImageUpload extends React.Component { state = { previewVisible: false, previewImage: '', fileList: this.props.field.FIELD_VALUE, }; UNSAFE_componentWillReceiveProps = (newProps) => { const { fileList } = this.state if (!newProps.field.FIELD_VALUE) { this.setState({ fileList: [] }) } else { this.setState({ fileList: newProps.field.FIELD_VALUE }) } } handleCancel = () => this.setState({ previewVisible: false }); handlePreview = async file => { if (!file.url && !file.preview) { file.preview = await getBase64(file.originFileObj); } let url = onGetImageUrl(file) this.setState({ // previewImage: file.url || file.preview, previewImage: url, previewVisible: true, }); }; beforeUpload=(file)=> { const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png' || file.type === 'image/png' || file.type === 'image/icon' || file.type === 'image/svg+xml'; if (!isJpgOrPng) { message.error('只能上传图片格式文件!'); } const isLt10M = file.size / 1024 / 1024 < 10; if (!isLt10M) { message.error('上传的图片大小必须小于10M!'); } return isJpgOrPng && isLt10M; } handleChange = ({ fileList, file }) => { let url = onGetImageUrl(file) fileList = fileList.slice(-1); //限制只保留一张图片 // fileList[0].response.data.url = fileList[0].response.data ? = url : this.props.handleImageChange(fileList) this.props.dispatch({ type: 'tableTemplate/save', payload: { fileList, fileKey: this.props.field.FIELD_NAME } }) this.setState({ fileList, previewImage: url, }); } onRemove=(file)=>{ console.log('删除',file) } render() { const { previewVisible } = this.state; const previewImage = _.get(this.state,'previewImage') // const fileList = this.props.field.FIELD_VALUE const { fileList } = this.state const { apiUrl: _apiUrl } = window.config; const origin = localStorage.getItem('origin') || ''; const apiUrl = process.env.NODE_ENV === 'development' ? _apiUrl : origin; const uploadButton = ( <div> <Icon type="plus" /> <div className="ant-upload-text">选择图片</div> </div> ); return ( <div className="clearfix" style={{ cursor: this.props.disabled ? 'not-allowed' : '' }}> <Upload action={apiUrl + '/rs/uploadImage'} listType="picture-card" beforeUpload={this.beforeUpload} disabled={this.props.disabled} fileList={fileList} showUploadList={{ showPreviewIcon: this.props.disabled ? true : true, showRemoveIcon: this.props.disabled ? false : true }} headers={{ sessionId: localStorage.getItem('sessionId') || '' }} onPreview={this.handlePreview} onChange={this.handleChange} onRemove={this.onRemove} > {this.props.disabled ? '' : uploadButton} </Upload> <Modal visible={previewVisible} footer={null} onCancel={this.handleCancel}> <img alt={previewImage} style={{ width: '100%' }} src={previewImage} /> </Modal> </div> ); } }
// var toLowerCase = function(s) { // return s.toLowerCase(); // }; //the purpose of the problem was actually to use ASCII var toLowerCase = function(s) { let arr = s.split("").map(letter => letter.charCodeAt(0)); //console.log(arr.map(letter => letter.charCodeAt(0))); console.log(arr) let result = [] for(let i=0; i<arr.length; i++){ if(arr[i]>=65 && arr[i]<=90){ result.push(arr[i]+32) } else { result.push(arr[i]) } } //console.log(result.map(letter=> String.fromCharCode(letter))) return result.map(letter=> String.fromCharCode(letter)).join("") };
import {AUTHENTICATED, UNAUTHENTICATED, AUTH_ERROR, REQUIRES_AUTHENTICATION} from "../actions/action-types"; import appState from './app-state'; export default function (state = appState.auth, action) { switch(action.type) { case AUTHENTICATED: return { ...state, authenticated: true, userId: action.data.userId, error: null}; case UNAUTHENTICATED: return { ...state, authenticated: false, userId: null, error: null}; case REQUIRES_AUTHENTICATION: return { ...state, authenticated: false, userId: null, error: 'You must be logged in to access this page.'}; case AUTH_ERROR: return { ...state, error: action.data}; default: return state; } }
/** * Populate DB with sample data on server start * to disable, edit config/environment/index.js, and set `seedDB: false` */ 'use strict'; var Gebruiker = require('../api/gebruiker/gebruiker.model') , Inschrijving = require('../api/inschrijving/inschrijving.model') , Activiteit = require('../api/activiteit/activiteit.model') , Comment = require('../api/comment/comment.model') , NieuwsItem = require('../api/nieuwsitem/nieuwsitem.model') , Kamp = require('../api/kamp/kamp.model') , Contact = require('../api/contact/contact.model') , Categorie = require('../api/categorie/categorie.model'); Gebruiker.find({}).remove(function () { Gebruiker.create({ provider: 'local', naam: 'Doe', voornaam: 'John', email: 'test@test.com', wachtwoord: 'test' }, { provider: 'local', role: 'ROLE_ADMIN', naam: 'Admin', voornaam: 'John', name: 'Admin', email: 'admin@admin.com', wachtwoord: 'admin' }, { provider: 'local', name: 'Roy Hollanders', naam: 'Hollanders', voornaam: 'Roy', email: 'roy_9852@hotmail.com', wachtwoord: 'Test123' }, { provider: 'local', naam: 'Doe', voornaam: 'Jane', role: 'ROLE_MONITOR', email: 'monitor@joetz.com', wachtwoord: 'monitor1' } , function () { console.log('finished populating users'); // Ah async populateCategories(); populateKampen(); populateNieuws(); populateComments(); populateActiviteiten(); populateInschrijvingen(); populateContacts(); } ); }); function populateNieuws() { NieuwsItem.find({}).remove(function () { Gebruiker.findOne({email: "admin@admin.com"}, function (err, gebruiker) { NieuwsItem.create( { title: "Joetz organiseert flashmob in het teken van de Internationale week van de Vrede", text: "Joetz organiseert op woensdag 24 september een flashmob op het Muntplein in Brussel. Tientallen vrijwilligers zullen verkleed als knuffeldier een groepsknuffel organiseren. Met deze ludieke actie willen we de aandacht vestigen op verdraagzaamheid en vrede. <br/>" + "We staan aan het begin van een nieuw werkjaar waarin zoals steeds vrede en verdraagzaamheid twee essentiële pijlers zijn in de werking van Joetz. Vooral tijdens de Internationale Week van de Vrede willen we deze topics extra benadrukken. Inclusie, verdraagzaamheid en aandacht voor minderheden zijn thema’s die al in meerdere Joetz-campagnes aan bod zijn gekomen. Aan de hand van reizen en infomomenten, proberen we om verdraagzaamheid en solidariteit zoveel mogelijk te promoten." + "Er zijn echter veel kinderen in andere delen van de wereld die op dagelijkse basis geconfronteerd worden met geweld en oorlog. Om duidelijk te maken dat er ook aan hen gedacht wordt, organiseert Joetz de actie ‘Knuffel voor een Truffel’. Op 24 september zullen tientallen monitoren en vrijwilligers van Joetz verkleed als knuffeldieren naar het Muntplein in Brussel stappen waar ze onderweg gratis knuffels uitdelen aan voorbijgangers. Ze krijgen in ruil voor de knuffel een lekkere truffel. Met deze ludieke actie wil Joetz duidelijk maken dat verdraagzaamheid en vrede twee kerneigenschappen zijn van een gezonde maatschappij waarin jongeren en kinderen zich kunnen ontplooien." + "Waarom dan precies knuffelen?" + "willen met deze actie benadrukken dat het voor kinderen en jongeren heel gezond is om dagelijks iemand te knuffelen. Uit wetenschappelijk onderzoek is zelfs gebleken dat kin¬deren die tijdens de eerste zes jaar niet genoeg werden geknuffeld, lichamelijke of geestelijke achter-stand kunnen oplopen. Knuffelen heeft een positieve invloed op het immuunsysteem, vermindert stress, helpt tegen slapeloos¬heid en blijkt te helpen tegen depressie�?, legt Sofie De Bisschop van Joetz vzw uit.", createdBy: gebruiker, createdOn: new Date(2014, 9, 22) }, { title: "SMOOR", text: "Een educatief theaterproject over roken. " + "SMOOR is een leuk stukje theater waar jongeren zonder autoritair gemoraliseer en zonder overdreven bangmakerij duidelijk gemaakt worden dat een sigaret weigeren stoer is. Met veel humor, fijne intriges en blitse dialogen wordt SMOOR een aantrekkelijk project in het kader van tabakspreventie. Met de educatieve werkmap en de nieuwe affichecampagne kan je in de klas verder werken rond het thema. De affiche kan je gratis via email aanvragen.", createdBy: gebruiker, createdOn: new Date(2014, 9, 19) }, { title: "Red Je Rug!", text: "Het nieuwe schooljaar is begonnen: tijd om elke dag te sjouwen met een zware boekentas." + "Overladen tassen vormen thans regelmatig een last voor de rug van kinderen en jongeren. Om te vermijden dat kinderen en jongeren op jonge leeftijd al rugpijn ontwikkelen, is het belangrijk om hier aandacht voor te hebben." + "Daarom lanceert JOETZ naast de bestaande \"Red je Rug\" affiche voor jongeren, een nieuwe affichecampagne \"Red Je Rug\" voor kinderen van de lagere school. 10 \"Red je Rug\" - tips met bijhorende leuke cartoons zetten leerlingen aan om hun boekentas niet nodeloos vol te proppen.", createdBy: gebruiker, createdOn: new Date(2014, 9, 11) }, { title: "Eén op tien kinderen gaat nooit naar toilet op school. Dat moet veranderen.", text: "Uit recent betrouwbaar onderzoek is gebleken dat 1 op 10 kinderen nooit naar het toilet gaat op school. Het toilet is voor veel kinderen een vieze, donkere en koude plaats die ze liefst zo veel mogelijk vermijden. JOETZ vzw wil daar verandering in brengen en van de toiletten een hippe plek maken waar kinderen kunnen ontspannen en eventjes tot rust komen." + "Antistresscampagne" + "Daarom trekt JOETZ vzw, partner van de Socialistische Mutualiteiten, op vrijdag 5 september naar Basisschool Het Schrijvertje in Mol ter promotie van www.stresskip.be een antistresscampagne voor lagere schoolkinderen. JOETZ vzw zal de kale toiletten van deze basisschool omtoveren tot een plekje waar het aangenaam vertoeven is en waar kinderen even tot rust kunnen komen en de stress loslaten.", createdBy: gebruiker, createdOn: new Date(2014, 9, 5) }, { title: "Professor Slurp leert de JOETZ-deelnemers wat etiquette is", text: "De zomer is begonnen en dit betekent meteen ook de start van de zomerkampen en speelpleinwerkingen. Ook JOETZ ontvangt deze zomer ruim 3.500 kinderen op de JOETZ-vakanties en speelpleinwerkingen. Maar dit jaar gaat er wel een hele speciale gast mee met JOETZ: Professor Slurp! Deze gekke handpop is overgewaaid uit Nederland en is een uniek concept om kinderen op een speelse manier iets te leren over etiquette. Slurp komt oorspronkelijk uit Burpieland en weet zich totaal niet te gedragen. De jongste JOETZ-deelnemers gaan de onaangepaste en ondeugende Professor Slurp deze zomer leren hoe hij zich beter kan gedragen. Ze helpen hem in verschillende situaties waardoor zij ongemerkt bijleren over etiquette.", createdBy: gebruiker, createdOn: new Date(2014, 7, 25) }, function () { console.log("populated nieuwsitems"); } ) }); }); } function populateActiviteiten() { Activiteit.find({}).remove(function () { Gebruiker.findOne({email: "monitor@joetz.com"}, function (err, gebruiker) { Comment.find({}, function (err, comments) { var _gebruiker = gebruiker; var _comments = comments; Activiteit.create( { beschrijving: "Monitor vorming te Spa, voor alle monitors!", contact: _gebruiker, eindDatum: new Date(2014, 12, 16), locatie: "Spa", naam: "Monitor vorming", startDatum: new Date(2014, 12, 15), comments: _comments, createdOn: new Date(2014, 9, 5), inschrijvingen: _gebruiker, prijs: 100 }, { beschrijving: "Algemene info sessie voor alle monitors!", contact: _gebruiker, eindDatum: new Date(2014, 12, 16), locatie: "Kortrijk", naam: "Algemene info sessie", startDatum: new Date(2014, 12, 15), comments: _comments, createdOn: new Date(2014, 9, 5), inschrijvingen: _gebruiker, prijs: 100 } , function () { console.log('populated activiteiten') } ) }) }); }) } function populateComments() { Comment.find({}).remove(function () { Gebruiker.findOne({email: "Monitor@Joetz.com"}, function (err, gebruiker) { var _gebruiker = gebruiker; Comment.create( { text: "Lekker slapen!", createdOn: new Date(2014, 9, 5), createdBy: _gebruiker }, { text: "Snoezen!", createdOn: new Date(2014, 9, 6), createdBy: _gebruiker } , function () { console.log('populated comments') } ) }); }) } function populateKampen() { Kamp.find({}).remove(function () { /*Kamp.create( //DATUM ATTENTION: ISODAte --> maand begint vanaf 0! { naam: "Kerstvakantie aan zee", beschrijving: 'Flikkerende lichtjes en glinsterende slingers, een besneeuwd strand en vooral veel vrienden en plezier. Onze JOETZ monitoren zijn er weer helemaal klaar voor om met jou de laatste dagen van het jaar op een onvergetelijke manier te beleven. We voorzien een fantastisch avontuur in een besneeuwd winterlandschap. Ons monitorenteam ontwikkelende een supergezellig programma waar plezier en sfeer centraal staan. Neem dus je warmste muts en sjaal mee om samen met ons van deze prachtige vakantie te genieten! Wie weet krijgen we de kerstman op bezoek ... .!', contact: "???", startDatum: new Date(2014, 11, 26, 0, 0, 0), eindDatum: new Date(2014, 11, 31, 0, 0, 0), doelgroepen: [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], promoAfbeelding: "zomer/kroatie.jpg", afbeeldingen:["hotel1.jpg","hotel2.jpg","hotel3.jpg"], //Extra Info locatie: "Barkentijn te Nieuwpoort", prijs: 192, korting: 0, formule: "Volpension", inbegrepen:["Heen- en terugreis per luxe autocar"," Verblijf in volpension", "Drank bij de maaltijden", "Dagelijks vieruurtje", "Begeleiding door ervaren, gebrevetteerde monitoren","Gevarieerd spelprogramma incl. aangeboden activiteiten","Ongevallenverzekering"], //Vervoer vervoer: "Bus" }, { naam: "Ski en fun", beschrijving: 'Begrijp je er geen jota van? Geen nood, in elk niveaugroepje skiet een monitor van JOETZ mee. Die helpt je over de taalbarrière en de Oostenrijkse skimonitor leert je vlekkeloos langs elk pisteobstakel laveren. De lunchpauzes nemen we in het hotel dat vlakbij de skipiste ligt. Praktisch toch!? De JOETZ-monitors garanderen leuke après-ski en avondactiviteiten.', contact: "???", startDatum: new Date(2014, 11, 19, 0, 0, 0), eindDatum: new Date(2014, 11, 27, 0, 0, 0), doelgroepen: [10, 11, 12, 13, 14], locatie: "Jeugdhotel Oberau te Maria Alm(Oostenrijk)", prijs: 785, vervoer: "Bus", korting: 0, promoAfbeelding: "winter/oostenrijk.jpg" }, { naam: "Skiën in Maria Alm", startDatum: new Date(2014, 1, 13, 0, 0, 0), beschrijving: 'Wij vertrekken naar Oostenrijk voor een week ski- en snowboardfun. Lange pistes, leuk gezelschap en hopelijk wat zon. Wat wil je nog meer? Oostenrijkse skimonitoren leren je vlekkeloos langs elk pisteobstakel laveren. De lunchpauzes nemen we in het hotel dat vlak bij de piste ligt: lekker en makkelijk! De JOETZ monitoren skiën een hele dag mee en garanderen geweldige après-ski en avondactiviteiten.', contact: "???", eindDatum: new Date(2015, 1, 21, 0, 0, 0), doelgroepen: [11, 12, 13, 14, 15, 16, 17, 18], locatie: "Jugendgästehaus Oberau te Maria Alm(Oostenrijk)", prijs: 640, vervoer: "Bus", korting: 0, promoAfbeelding: "winter/oostenrijk.jpg" }, { naam: "Austria? Check!", startDatum: new Date(2015, 6, 3, 0, 0, 0), beschrijving: 'Beleef de fun van onze verschillende JOETZ-activiteiten: de berg op in de gondellift, de berg af via de rodelbaan, een duik in het zwemparadijs of aan de waterval, bezoekjes aan grot en burcht, super animaties en nog zoveel meer. De pracht van de Oostenrijkse bergen, de alpenweiden en de kloven krijg je er gratis en voor niks bovenop!', contact: "???", eindDatum: new Date(2015, 6, 12, 0, 0, 0), doelgroepen: [12, 13, 14, 15, 16], locatie: "Jugendgästehaus Oberau te Maria Alm(Oostenrijk)", prijs: 382, vervoer: "Bus", korting: 0, promoAfbeelding: "winter/oostenrijk.jpg" }, { naam: "Actie, fun en avontuur - Trophy", startDatum: new Date(2015, 6, 3, 0, 0, 0), beschrijving: 'Raften, klimmen of hoogteparcours, mountainbiken, oriëntatielopen, avonturentocht … rekening houdend met de (weers)omstandigheden beoefen je verschillende buitensporten. De climax van de vakantie is de Trophy-wedstrijd waarin je alleen of in team je grenzen verlegt.', contact: "???", eindDatum: new Date(2015, 6, 12, 0, 0, 0), doelgroepen: [13, 14, 15, 16], locatie: "Jugendgästehaus Oberau te Maria Alm(Oostenrijk)", prijs: 448, vervoer: "Bus", korting: 0, promoAfbeelding: "winter/oostenrijk.jpg" }, { naam: "Krk binnenstebuiten!", startDatum: new Date(2015, 6, 17, 0, 0, 0), beschrijving: 'Laat onze JOETZ-animatoren je meenemen op ontdekking van het eiland Krk. Oude stadjes, leuke uitstapjes en activiteiten, een heerlijke BBQ op het einde van de dag en natuurlijk een azuurblauwe zee onder de Kroatische zon. Je verveelt je geen minuut… We verblijven in Hostel Krk, in het bovenste gedeelte van het historische, ommuurde stadje Krk.', contact: "???", eindDatum: new Date(2015, 6, 28, 0, 0, 0), doelgroepen: [13, 14, 15], locatie: "Hostel Krk te Krk(Kroatië)", prijs: 535, vervoer: "Bus", korting: 0, promoAfbeelding: "zomer/kroatie.jpg" }, { naam: "Krk, here we come!", beschrijving: 'Kom mee en ontdek het ‘gouden eiland’ Krk. Hostel Krk, onze uitvalsbasis voor 10 dagen ligt in het bovenste gedeelte van het historische, ommuurde stadje Krk. Maak je klaar voor een heerlijk zonnige vakantie, neem een duik in de azuurblauwe zee, lanterfant door oude kleine straatjes, laat de BBQ je smaken, geniet van leuke uitstapjes en activiteiten en laat je verrassen door ons top-animatieteam!', contact: "???", startDatum: new Date(2015, 6, 28, 0, 0, 0), eindDatum: new Date(2015, 7, 6, 0, 0, 0), doelgroepen: [15, 16, 17, 18], locatie: "Hostel Krk te Krk(Kroatië)", prijs: 535, vervoer: "Bus", korting: 0, promoAfbeelding: "zomer/kroatie.jpg" }, { naam: "Sun & Fun Spanje", beschrijving: 'Zon, zee, strand en … actie. Is stilzitten niet jouw ding? Onze dagen onder de zon worden gevuld met geweldige activiteiten als watertrekking, laser-shooting, vlottentocht, een bootcruise, een dag in een waterpretpark, een uitstapje naar Barcelona en nog zoveel meer. Om dan van de leuke avondactiviteiten en een heuse poolparty nog maar te zwijgen.', contact: "???", startDatum: new Date(2015, 6, 6, 0, 0, 0), eindDatum: new Date(2015, 6, 28, 0, 0, 0), doelgroepen: [12, 13, 14, 15], locatie: "tentenkamp aan het strand te Empuriabrava, Spanje", prijs: 585, vervoer: "Bus", korting: 0, promoAfbeelding: "zomer/spanje.jpg" }, { naam: "Balaton-pret", startDatum: new Date(2015, 7, 16, 0, 0, 0), beschrijving: 'Een plons hier en een duik daar: het Balatonmeer leent zich met zijn prachtige omgeving en zijn aangename temperaturen voor tonnen waterpret. Natuurlijk staat er nog veel meer op het programma: wat dacht je van een bezoekje aan het prachtige Boedapest? Of een fietstocht om de omgeving te verkennen? Wat we ook doen, de JOETZ-animatoren maken er een geweldig verblijf van!', contact: "???", eindDatum: new Date(2015, 7, 27, 0, 0, 0), doelgroepen: [13, 14, 15], locatie: "Balaton Hostel bij het Balatonmeer(Hongarije)", prijs: 475, vervoer: "Bus", korting: 0, promoAfbeelding: "zomer/hongarije.jpg" }, { naam: "Balaton-fun", beschrijving: 'We verblijven in het dorpje Révfülöp, aan de noordelijke kust van het Ballatonmeer. We zullen tijdens onze vakantie niet alleen lekker badderen in deze ‘Hongaarse zee’, om en rond zijn nog ontelbare leuke activiteiten. Wat dacht je van een bezoekje aan het prachtige Boedapest? Of een fietstocht om de omgeving te verkennen? Wat we ook doen, de JOETZ-animatoren maken er een geweldig verblijf van!', contact: "???", startDatum: new Date(2015, 7, 17, 0, 0, 0), eindDatum: new Date(2015, 7, 28, 0, 0, 0), doelgroepen: [16, 17, 18], locatie: "Balaton Hostel bij het Balatonmeer(Hongarije)", prijs: 475, vervoer: "Bus", korting: 0, promoAfbeelding: "zomer/hongarije.jpg" }, function () { console.log('populated kampen') } ) */ Kamp.create( { naam: "Krokusvakantie aan zee", beschrijving: 'Verveling krijgt geen kans tijdens de krokusvakantie want op maandag 3 maart 2014 trekken we er met z’n allen op uit! We logeren in het vakantiecentrum ‘De Barkentijn’ te Nieuwpoort. Vijf dagen lang spelen we de leukste spelletjes, voor klein en groot. Samen met je vakantievriendjes beleef je het ene avontuur na het andere. Plezier gegarandeerd!', contact: "???", periodes: [ { startDatum: new Date(2014, 3, 3, 0, 0, 0), eindDatum: new Date(2014, 3, 7, 0, 0, 0) } ], vakantie: "krokusvakantie", doelgroepen: [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], promoAfbeelding: "krokus/krokusvakantie_aan_zee.jpg", afbeeldingen:[], //Extra Info locatie: "De Barkentijn, Nieuwpoort", prijs: 165, korting: 0, formule: "Volpension", inbegrepen:[ "Heenreis per autocar", "Verblijf in volpension, drank bij de maaltijden", "Dagelijks vieruurtje", "Begeleiding door ervarenm gebrevetteerde monitoren", "Volledig animatiepakket incl. spelmateriaal", "Ongevallenverzekering" ], //Vervoer vervoer: { "heen": "Busvervoer", "terug": "eigen vervoer" } }, { naam: "Joetz aan zee - Lange periode", beschrijving: 'Heb je zin om 12 dagen lang met vrienden te spelen onder een aangenaam lentezonnetje? Wij hebben alvast een superleuk monitorenteam en een tof vakantieverblijf voor je klaarstaan! Aarzel niet en kom de paassfeer opsnuiven in De Barkentijn!', contact: "???", periodes: [ { startDatum: new Date(2014, 4, 7, 0, 0, 0), eindDatum: new Date(2014, 4, 18, 0, 0, 0) } ], vakantie: "paasvakantie", doelgroepen: [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], promoAfbeelding: "pasen/joetz_aan_zee_lange_periode.jpg", afbeeldingen:[], //Extra Info locatie: "De Barkentijn, Nieuwpoort", prijs: 324, korting: 0, formule: "Volpension", inbegrepen:[ "Heenreis-en terugreis per autocar", "Verblijf in volpension, drank bij de maaltijden", "Dagelijks vieruurtje", "Begeleiding door ervarenm gebrevetteerde monitoren", "Volledig animatiepakket incl. spelmateriaal", "Ongevallenverzekering" ], //Vervoer vervoer: { "heen": "Busvervoer of eigen vervoer", "terug": "Busvervoer of eigen vervoer" } }, { naam: "Joetz aan zee - Korte periode", beschrijving: 'Ooit al een paashaas op een go-cart gezien? Of paaseieren gezocht in de duinen of op het strand? Waag je kans en kom naar De Barkentijn om 5 dagen te genieten van leuke spelletjes en lekker eten. Breng gerust ook wat vrienden mee, want iedereen is van harte welkom!', contact: "???", periodes: [ { startDatum: new Date(2014, 4, 7, 0, 0, 0), eindDatum: new Date(2014, 4, 11, 0, 0, 0) }, { startDatum: new Date(2014, 4, 14, 0, 0, 0), eindDatum: new Date(2014, 4, 18, 0, 0, 0) } ], vakantie: "paasvakantie", doelgroepen: [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], promoAfbeelding: "pasen/joetz_aan_zee_korte_periode.jpg", afbeeldingen:[], //Extra Info locatie: "De Barkentijn, Nieuwpoort", prijs: 165, korting: 0, formule: "Volpension", inbegrepen:[ "Heenreis-en terugreis per autocar", "Verblijf in volpension, drank bij de maaltijden", "Dagelijks vieruurtje", "Begeleiding door ervarenm gebrevetteerde monitoren", "Volledig animatiepakket incl. spelmateriaal", "Ongevallenverzekering" ], //Vervoer vervoer: { "heen": "Busvervoer of eigen vervoer", "terug": "Busvervoer of eigen vervoer" } }, { naam: "Joetz aan zee - danskamp", beschrijving: 'Kan je ook niet blijven stilstaan als je muziek hoort? Muziek, maestro, please want bij JOETZ vliegen we er in! Onze professionele dansleraren leren je de leukste dansjes aan en zorgen voor de nodige afwisseling met toffe spelletjes. Danservaring is niet vereist, zolang je er maar zin in hebt!', contact: "???", periodes: [ { startDatum: new Date(2014, 4, 7, 0, 0, 0), eindDatum: new Date(2014, 4, 11, 0, 0, 0) } ], vakantie: "paasvakantie", doelgroepen: [6, 7, 8, 9, 10, 11, 12, 13, 14], promoAfbeelding: "pasen/joetz_aan_zee_danskamp.jpg", afbeeldingen:[], //Extra Info locatie: "De Barkentijn, Nieuwpoort", prijs: 185, korting: 0, formule: "Volpension", inbegrepen:[ "Heenreis-en terugreis per autocar", "Verblijf in volpension, drank bij de maaltijden", "Dagelijks vieruurtje", "Begeleiding door ervarenm gebrevetteerde monitoren", "Volledig animatiepakket incl. spelmateriaal", "Ongevallenverzekering" ], //Vervoer vervoer: { "heen": "Busvervoer of eigen vervoer", "terug": "Busvervoer of eigen vervoer" } }, { naam: "Joetz aan zee - Welkom in het circus", beschrijving: 'Gaat jouw kind de eerste keer op kamp? Dan is deze kleutervakantie zeker iets voor hem haar. Op deze superleuke themavakantie worden onze allerkleinsten volledig ondergedompeld in een wereld van dolle pret! Onze monitoren zorgen alvast voor een leuk programma waar je kind nog lang over zal napraten. Aarzel niet langer en schrijf je kind vlug in voor zijn/haar eerste kleutervakantie!', contact: "???", periodes: [ { startDatum: new Date(2014, 4, 7, 0, 0, 0), eindDatum: new Date(2014, 4, 11, 0, 0, 0) } ], vakantie: "paasvakantie", doelgroepen: [4, 5, 6], promoAfbeelding: "pasen/joetz_aan_zee_circus.jpg", afbeeldingen:[], //Extra Info locatie: "De Barkentijn, Nieuwpoort", prijs: 185, korting: 0, formule: "Volpension", inbegrepen:[ "Heenreis-en terugreis per autocar", "Verblijf in volpension, drank bij de maaltijden", "Dagelijks vieruurtje", "Begeleiding door ervarenm gebrevetteerde monitoren", "Volledig animatiepakket incl. spelmateriaal", "Ongevallenverzekering" ], //Vervoer vervoer: { "heen": "Busvervoer of eigen vervoer", "terug": "Busvervoer of eigen vervoer" } }, { naam: "Joetz aan zee - Lange periode", beschrijving: 'Recept voor een fantastische zomervakantie: toffe monitoren, leuke vrienden, een prachtig vakantiecentrum en véél fun en ambiance! De monitoren zorgen voor een afwisselend programma (strand- en duinspelen, daguitstappen, themaspelen, fuif …) maar willen jou er natuurlijk ook bij. Wacht niet te lang en plan je vakantie naar zee met JOETZ!', contact: "???", periodes: [ { startDatum: new Date(2014, 7, 5, 0, 0, 0), eindDatum: new Date(2014, 7, 19, 0, 0, 0) }, { startDatum: new Date(2014, 7, 19, 0, 0, 0), eindDatum: new Date(2014, 8, 2, 0, 0, 0) }, { startDatum: new Date(2014, 8, 2, 0, 0, 0), eindDatum: new Date(2014, 8, 16, 0, 0, 0) }, { startDatum: new Date(2014, 8, 16, 0, 0, 0), eindDatum: new Date(2014, 8, 30, 0, 0, 0) } ], vakantie: "zomervakantie", doelgroepen: [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], promoAfbeelding: "zomer/joetz_aan_zee_lange_periode.jpg", afbeeldingen:[], //Extra Info locatie: "De Barkentijn, Nieuwpoort", prijs: 400, korting: 0, formule: "Volpension", inbegrepen:[ "Heenreis-en terugreis per autocar", "Verblijf in volpension, drank bij de maaltijden", "Dagelijks vieruurtje", "Begeleiding door ervarenm gebrevetteerde monitoren", "Volledig animatiepakket incl. spelmateriaal", "Ongevallenverzekering" ], //Vervoer vervoer: { "heen": "Busvervoer of eigen vervoer", "terug": "Busvervoer of eigen vervoer" } }, { naam: "Joetz aan zee - Korte periode", beschrijving: 'Zomervakantie aan zee: zes dagen vol spel en amusement maken van jouw verblijf een leuke vakantie. Een themanamiddag afgewisseld met leuke spelen en een ritje op de go-cart zorgen voor een korte maar krachtige vakantie. Wij zijn er helemaal klaar voor en kijken alvast uit naar jouw komst!', contact: "???", periodes: [ { startDatum: new Date(2014, 7, 7, 0, 0, 0), eindDatum: new Date(2014, 7, 12, 0, 0, 0) }, { startDatum: new Date(2014, 7, 14, 0, 0, 0), eindDatum: new Date(2014, 7, 19, 0, 0, 0) }, { startDatum: new Date(2014, 7, 21, 0, 0, 0), eindDatum: new Date(2014, 7, 26, 0, 0, 0) }, { startDatum: new Date(2014, 7, 28, 0, 0, 0), eindDatum: new Date(2014, 8, 2, 0, 0, 0) }, { startDatum: new Date(2014, 8, 4, 0, 0, 0), eindDatum: new Date(2014, 8, 9, 0, 0, 0) }, { startDatum: new Date(2014, 8, 11, 0, 0, 0), eindDatum: new Date(2014, 8, 16, 0, 0, 0) }, { startDatum: new Date(2014, 8, 18, 0, 0, 0), eindDatum: new Date(2014, 8, 23, 0, 0, 0) }, { startDatum: new Date(2014, 8, 25, 0, 0, 0), eindDatum: new Date(2014, 8, 30, 0, 0, 0) } ], vakantie: "zomervakantie", doelgroepen: [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], promoAfbeelding: "zomer/joetz_aan_zee_korte_periode.jpg", afbeeldingen:[], //Extra Info locatie: "De Barkentijn, Nieuwpoort", prijs: 192, korting: 0, formule: "Volpension", inbegrepen:[ "Heenreis-en terugreis per autocar", "Verblijf in volpension, drank bij de maaltijden", "Dagelijks vieruurtje", "Begeleiding door ervarenm gebrevetteerde monitoren", "Volledig animatiepakket incl. spelmateriaal", "Ongevallenverzekering" ], //Vervoer vervoer: { "heen": "Busvervoer of eigen vervoer", "terug": "Busvervoer of eigen vervoer" } }, { naam: "Joetz aan zee - Danskamp", beschrijving: 'Kan je ook niet blijven stilstaan als je muziek hoort? Muziek, maestro, please want bij JOETZ vliegen we er in! Onze professionele dansleraren leren je de leukste dansjes aan en zorgen voor de nodige afwisseling met toffe spelletjes. Danservaring is niet vereist, zolang je er maar zin in hebt!', contact: "???", periodes: [ { startDatum: new Date(2014, 7, 28, 0, 0, 0), eindDatum: new Date(2014, 8, 2, 0, 0, 0) }, { startDatum: new Date(2014, 8, 25, 0, 0, 0), eindDatum: new Date(2014, 8, 30, 0, 0, 0) } ], vakantie: "zomervakantie", doelgroepen: [4, 5, 6], promoAfbeelding: "zomer/joetz_aan_zee_danskamp.jpg", afbeeldingen:[], //Extra Info locatie: "De Barkentijn, Nieuwpoort", prijs: 207, korting: 0, formule: "Volpension", inbegrepen:[ "Heenreis-en terugreis per autocar", "Verblijf in volpension, drank bij de maaltijden", "Dagelijks vieruurtje", "Begeleiding door ervarenm gebrevetteerde monitoren", "Volledig animatiepakket incl. spelmateriaal", "Ongevallenverzekering" ], //Vervoer vervoer: { "heen": "Busvervoer of eigen vervoer", "terug": "Busvervoer of eigen vervoer" } }, function(err) { if(err) console.log(err); console.log("Populated vakanties!"); } ) } ); } function populateInschrijvingen() { Inschrijving.find({}).remove(function () { Gebruiker.findOne({email: "test@test.com"}, function (err, gebruiker) { Kamp.findOne({naam: "Krokusvakantie aan zee"}, function (err, kamp) { var _gebruiker = gebruiker; var _kamp = kamp; Inschrijving.create( { lidMutualiteit: false, persoonTenLaste: { aansluitingsNummer: "1234565789", codeGerechtigde: "1234" }, tweedeOuder: { aansluitingsNummer: "541562156" }, contactPersoon: gebruiker, betalendeOuder: { rijksregisterNummer: "165485162198", voornaam: "Bob", naam: "BobSon", straat: "straat", huisnummer: "1", bus: "2", gemeente: "testegem", postcode: "4567", telefoonNummer: "123456" }, rijksregisterNummer: "1232456", voornaam: "test", naam: "testson", geboorteDatum: new Date(2005, 5, 25), adresDeelnemer: { straat: "straat", huisnummer: "1", bus: "2", gemeente: "testegem", postcode: "4567" }, noodPersonen: [ { voornaam: "nood", naam: "noodson", telefoonNummer: "123456789" } ], extraInformatie: "bla", toevoeging: "Test", gebruiker: _gebruiker, kamp: _kamp } , function () { console.log('populated inschrijvingen') } ) }) }); }) } function populateContacts() { Contact.find({}).remove(function () { Gebruiker.findOne({email: "test@test.com"}, function (err, gebruiker) { var _gebruiker = gebruiker; Contact.create({ sendBy: _gebruiker, sendDate: new Date(2014, 11, 22), onderwerp: "Aanvraag voor meer kampen", bericht: "Zou het mogelijk zijn om enventueel meer kampen toe te voegen aan uw selectie van kampen" } , function () { console.log('populated contact') }); }); }); } function populateCategories() { Categorie.find({}).remove(function () { Categorie.create({ naam: "Waterpret" }, { naam: "Avontuur" }, { naam: "Sport" }, { naam: "Exploratie" }, function () { console.log('populated categorie') }); }); }
const express = require('express'); const router = express.Router(); const { Url } = require('../models/url'); const { validateID } = require('../middlewares/utilities'); router.get('/tags', (req,res) => { let names = req.query.names.split(','); Url.find({tags: {$in: names}}).then((url) =>{ if (url){ res.send(url) } else { res.send({ notice: 'Url not found' }); } }).catch((err) => { res.send(err); }); }); router.get('/', (req, res) => { Url.find().then((urls) => { res.send(urls); }).catch((err) => { res.send(err); }) }) router.get('/:id', validateID, (req, res) => { let id = req.params.id; Url.findById(id).then((url) => { if (url){ res.send(url) } else { res.send({ notice: 'Url not found' }); } }).catch((err) => { res.send(err); }); }); router.get('/tags/:name', (req,res) => { let name = req.params.name; Url.find( {tags: name }).then((url) =>{ if (url){ res.send(url) } else { res.send({ notice: 'Url not found' }); } }).catch((err) => { res.send(err); }); }); router.post('/', (req,res) => { let body = req.body; let url = new Url(body); url.save().then((url) => { res.send({ url, notice: 'Successfully created the url' }); }).catch((err) => { res.send(err); }) }) router.delete('/:id', validateID, (req,res) => { let id = req.params.id; Url.findByIdAndRemove(id).then((url) => { if(url) { res.send(url) } else { res.send({ notice: 'Url not found' }); } }).catch((err) => { res.send(err); }); }); router.put('/id:', validateID, (req,res) => { let id = req.params.id; let body = req.body; Url.findOneAndUpdate({_id: id}, { $set: body }, { new: true, runValidators: true}).then((url) => { if(!url) { res.send({ notice: 'Url not found' }); } res.send({ url, notice: 'Successfully updated the url' }); }).catch((err) => { res.send(err); }) }); module.exports = { urlsController: router, }
import RestfulDomainModel from '../../base/RestfulDomainModel' class Model extends RestfulDomainModel { } export default new Model([ { id: { name: 'ID' } }, { short_id: { name: '抖音号' } }, { avatar_thumb: { name: '头像' } }, { nickname: { name: '昵称' } }, { follower_count: { name: '粉丝数' } }, { live_commerce: { name: '是否商家' } }, { wechat: { name: '微信' } }, { signature: { name: '签名' } }, { mtime: { name: '更新时间' } }, { ctime: { name: '创建时间' } } ], '/clouddata_douyin/user')
import React, { Fragment, Component } from 'react'; import Task from './Task'; import AddTask from './buttons/AddTask'; var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; class KnightTable extends Component { constructor(props) { super(props); this.displayTasks = this.displayTasks.bind(this); this.getFormattedDate = this.getFormattedDate.bind(this); this.displayStatus = this.displayStatus.bind(this); } getFormattedDate(date) { var dateArr = date.toLocaleDateString().split("/"); var mon = months[Number(dateArr[0]) - 1]; var day = dateArr[1]; var year = dateArr[2]; return "" + mon + " " + day + ", " + year; } displayTasks() { // Sort the tasks by due date var tasks = this.props.brother.tasks; return tasks.map((task, i) => { var dueDate = new Date(Number(task.dueDate)); var originalDueDate = new Date(Number(task.originalDueDate)); return ( <Task key={i} index={i + 1} id={this.props.brother.id} description={task.description} dueDate={this.getFormattedDate(dueDate)} originalDueDate={this.getFormattedDate(originalDueDate)} notes={task.notes} partners={task.partners} /> ); }); } displayStatus(status) { if (status === "active") { return ( <span className="active"> {status} </span> ); } else { return ( <span className="inactive"> {status} </span> ); } } // Conditionally render so if there are no tasks for a bro we say something else render() { if (this.props.brother.tasks.length === 0) { return ( <div className="knight-table"> <div className="knight-name"> Sir {this.props.brother.sirName} has no tasks 🙂 </div> <div className="knight-email"> {this.props.brother.email} | {this.displayStatus(this.props.brother.status)} </div> </div> ); } else { return ( <div className="knight-table"> <div className="knight-name"> Sir {this.props.brother.sirName} </div> <div className="knight-email"> {this.props.brother.email} | {this.displayStatus(this.props.brother.status)} </div> <table className="table table-striped table-borderless"> <thead> <tr> <th scope="col">#</th> <th scope="col">Task</th> <th scope="col">Due</th> <th scope="col">Notes</th> </tr> </thead> <tbody> {this.displayTasks()} </tbody> </table> <AddTask sirName={this.props.brother.sirName}/> </div> ); } } } export default KnightTable;
import { sessionService } from "redux-react-session"; import * as sessionApi from "../api/SessionApi"; import Toast from "../components/commonUI/Toast"; import Cookies from "universal-cookie"; export const login = (user, history) => { return () => { return sessionApi .login(user) .then(response => { var res = response.data; if (res.Code && res.Code === 200) { Toast.success("Đăng nhập thành công", "Thành công", { onOpen: ({ cls }) => { history.push("/"); } }); var token = { token: res.Data.Token }; sessionService.saveSession(token); var user = res.Data.Profile; sessionService.saveUser(user); const cookies = new Cookies(); var date = new Date(); let days = 4; date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); cookies.set("token", res.Data.Token, { path: "/", domain: ".truyenda.tk", expires: date }); } else { if (res.Code < 300) Toast.error("Tài khoản đăng nhập không đúng", "Error " + res.Code); else Toast.error(res.MsgEror); } }) .catch(err => { Toast.error("Có lỗi trong quá trình kết nối"); }); }; }; export const logout = history => { return () => { // return sessionApi // .logout() // .then(() => { // sessionService.deleteSession(); // sessionService.deleteUser(); // history.push("/"); // }) // .catch(err => { // throw err; // }); }; };
var requirejs = require('requirejs'); var Backbone = require('backbone'); var _ = require('lodash'); var dashboards = require('../../../tests/stagecraft_stub/dashboards'); var controller = require('../../../app/server/controllers/simple-dashboard-list'); var View = require('../../../app/server/views/simple-dashboard-list'); var ServicesView = require('../../../app/server/views/services'); var StagecraftApiClient = requirejs('stagecraft_api_client'); var PageConfig = requirejs('page_config'); describe('Simple dashboard list controller', function () { var fake_app = {'app': {'get': function(key){ return { 'port':'8989', 'stagecraftUrl':'the url', 'assetPath': '/spotlight/' }[key]; }} }; var req = _.extend({ get: function(key) { return { 'Request-Id':'Xb35Gt', 'GOVUK-Request-Id': '1231234123' }[key]; }, originalUrl: '', query: { filter: '' } }, fake_app); var res = { send: jasmine.createSpy(), set: jasmine.createSpy(), status: jasmine.createSpy() }; var client_instance; beforeEach(function () { spyOn(PageConfig, 'commonConfig').andReturn({ config: 'setting' }); spyOn(Backbone.Model.prototype, 'initialize'); spyOn(Backbone.Collection.prototype, 'initialize'); spyOn(View.prototype, 'initialize'); spyOn(ServicesView.prototype, 'render').andCallFake(function () { this.html = 'html string'; }); spyOn(StagecraftApiClient.prototype, 'fetch').andCallFake(function () {}); }); afterEach(function() { this.removeAllSpies(); }); it('creates a model containing config and page settings', function () { client_instance = controller('web-traffic', req, res); client_instance.trigger('sync'); expect(Backbone.Model.prototype.initialize).toHaveBeenCalledWith(jasmine.objectContaining({ config: 'setting', 'page-type': 'services' })); }); it('passes query params filter to model if defined', function () { var queryReq = _.cloneDeep(req); queryReq.query.filter = 'foo'; client_instance = controller('web-traffic', queryReq, res); client_instance.trigger('sync'); expect(Backbone.Model.prototype.initialize).toHaveBeenCalledWith(jasmine.objectContaining({ filter: 'foo'})); }); it('creates a collection', function () { client_instance = controller('web-traffic', req, res); client_instance.set({ 'status': 200, 'items': _.cloneDeep(dashboards.items) }); client_instance.trigger('sync'); expect(Backbone.Collection.prototype.initialize).toHaveBeenCalledWith(jasmine.any(Array)); }); it('creates a view', function () { client_instance = controller('web-traffic', req, res); client_instance.set({ 'status': 200, 'items': _.cloneDeep(dashboards.items) }); client_instance.trigger('sync'); expect(View.prototype.initialize).toHaveBeenCalledWith({ model: jasmine.any(Backbone.Model), collection: jasmine.any(Backbone.Collection) }); }); it('renders the services view', function () { client_instance = controller('web-traffic', req, res); client_instance.set({ 'status': 200, 'items': _.cloneDeep(dashboards.items) }); client_instance.trigger('sync'); expect(ServicesView.prototype.render).toHaveBeenCalled(); }); it('sends the services view html', function () { client_instance = controller('web-traffic', req, res); client_instance.set({ 'status': 200, 'items': _.cloneDeep(dashboards.items) }); client_instance.trigger('sync'); expect(res.send).toHaveBeenCalledWith('html string'); }); it('has an explicit caching policy', function () { client_instance = controller('web-traffic', req, res); client_instance.set({ 'status': 200, 'items': _.cloneDeep(dashboards.items) }); client_instance.trigger('sync'); expect(res.set).toHaveBeenCalledWith('Cache-Control', 'public, max-age=7200'); }); });
import reactLogo from "./react_logo.png"; import tailwindLogo from "./tailwindcss_logo.svg"; function App() { return ( <div className="w-full h-screen text-3xl font-bold text-white"> <div className="w-full h-5/6 flex"> <div className="w-1/2 h-full flex flex-col justify-center items-center bg-blue-500"> <img src={reactLogo} alt="react-logo" className="w-20" /> <h1>Create-React-App</h1> </div> <div className="w-1/2 h-full flex flex-col justify-center items-center bg-green-400"> <img src={tailwindLogo} alt="tailwind-logo" className="w-20" /> <h1>Tailwind CSS</h1> </div> </div> <footer className="w-full h-1/6 bg-white text-black flex items-center justify-center"> <h1> Clone the template from {} <a href="https://github.com/nimalansivakumar/create-react-app-tailwindcss" className="underline font-thin" target="_blank" rel="noreferrer" > create-react-app-tailwindcss </a> </h1> </footer> </div> ); } export default App;