Bunny's Code Burrow

this is a JS world


  • Home

  • About

  • Archives

  • Tags

  • Search

time of novisilder

Posted on 2017-04-24

time of novisilder

go to the path
plugins/widget.nivoslider/scripts/jquery.nivo.slider.js
change the pause time
the default pause time is 5000
then we could change to 2000,which test it till work fine.

asp.net mvc

Posted on 2017-04-24

asp.net mvc

when learning asp.net mvc 4 according to
http://www.asp.net/mvc/overview/older-versions/getting-started-with-aspnet-mvc4/adding-a-model

but after creating the model, there is a problem which seems to be connected with sql connection.
the key to address this problem is download and install the localDB again.

intall react native

Posted on 2017-04-23

intall react native

basically follow the instruction of https://facebook.github.io/react-native/docs/getting-started.html#content
注意事项如下
http://reactnative.cn/docs/0.31/getting-started.html#content 中文参考
若是Android +windows

  1. 管理员权限打开cmd!!!!
  2. 在cmd下安装好nodejs和Python之后
    cd 到node下 再运行 npm
  3. Android studio的目的是打开模拟器,一定要打开模拟器,开机到开机画面
    react-native init AwesomeProject
    是在某路径下建立 react native 文件夹,可以自定义路径
  4. 注意:Android studio严格按照http://reactnative.cn/docs/0.31/getting-started.html#content 进行配置
  5. 在Android studio 中打开 AVD MANAGER,保证模拟器开机到开机画面即可

reactnative navigation

Posted on 2017-04-23

reactnative navigation

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */
import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableHighlight,
  Navigator,
} from 'react-native';


class NavButton extends React.Component {
  render() {
    return (
      <TouchableHighlight
        style={styles.button}
        underlayColor="#B5B5B5"
        onPress={this.props.onPress}>
        <Text style={styles.buttonText}>{this.props.text}</Text>
      </TouchableHighlight>
    );
  }
}
class NavMenu extends React.Component {
  render() {
    return (
      <View style={styles.scene}>
        <Text style={styles.messageText}>{this.props.message}</Text>
        <NavButton
          onPress={() => {
            this.props.navigator.push({
              message: '向右拖拽关闭页面',
              sceneConfig: Navigator.SceneConfigs.FloatFromRight,
            });
          }}
          text="从右边向左切入页面(带有透明度变化)"
        />
        <NavButton
          onPress={() => {
            this.props.navigator.push({
              message: '向下拖拽关闭页面',
              sceneConfig: Navigator.SceneConfigs.FloatFromBottom,
            });
          }}
          text="从下往上切入页面(带有透明度变化)"
        />
        <NavButton
          onPress={() => {
            this.props.navigator.pop();
          }}
          text="页面弹出(回退一页)"
        />
        <NavButton
          onPress={() => {
            this.props.navigator.popToTop();
          }}
          text="页面弹出(回退到最后一页)"
        />
      </View>
    );
  }
}
class NavigatorDemo extends Component {
  render() {
    return (
      <Navigator
        style={styles.container}
        initialRoute={{ message: '初始页面', }}
        renderScene={ (route, navigator) => <NavMenu
            message={route.message}
            navigator={navigator}
          />}
         configureScene={(route) => {
          if (route.sceneConfig) {
            return route.sceneConfig;
          }
          return Navigator.SceneConfigs.FloatFromBottom;
        }}
      />
    );
  }
}
const styles = StyleSheet.create({
   container: {
    flex: 1,
   },
   messageText: {
    fontSize: 17,
    fontWeight: '500',
    padding: 15,
    marginTop: 50,
    marginLeft: 15,
  },
  button: {
    backgroundColor: 'white',
    padding: 15,
    borderBottomWidth: StyleSheet.hairlineWidth,
    borderBottomColor: '#CDCDCD',
  },
});

AppRegistry.registerComponent('PT', () => NavigatorDemo);

react native login

Posted on 2017-04-23

react native login view

import React, { Component } from 'react';
import { AppRegistry,StyleSheet,Image, TextInput, Text,ScrollView,TouchableOpacity,View} from 'react-native';
class CoolApp extends React.Component {
  render() {
    return (
      <ScrollView
        contentContainerStyle={{flex:1}}
        keyboardDismissMode='on-drag'
        keyboardShouldPersistTaps={false}
        >
        <View style={styles.container}>
          <Image
            source={{uri: 'http://oss-hz.qianmi.com/qianmicom/u/cms/qmwww/201511/03102524l6ur.png'}}
            style={styles.logo}/>
          <TextInput 
            ref={(username) => this.username = username}
            onFocus={()=>this.username.focus()}
            style={styles.input}
            placeholder='username'/>
          <TextInput 
            ref={(password) => this.password = password}
            onFocus={() => this.password.focus()}
            style={styles.input}
            placeholder='password' 
            password={true}/>

          <TouchableOpacity style={styles.btn}
            onPress={() => console.log('press me')}>
            <Text style={styles.text}>login</Text>
          </TouchableOpacity>
        </View>
      </ScrollView>
    );
  }
}

var styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingLeft: 10,
    paddingRight: 10,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F4FCFF',
  },
  logo:{
    width:160,
    height:160,
    marginTop: 100
  },
  input: {
   height: 40,
   width:200,
   marginTop: 10, //间隔
   borderWidth: 1, 
   borderRadius: 5, //圆角
   borderColor: 'lightblue'
  },
  text:{
    fontWeight: 'bold',
    fontSize: 14,
    color: '#FFF'
  },
   btn:{
     alignSelf: 'stretch',
     alignItems: 'center',
     justifyContent: 'center',
     backgroundColor: '#3333FF',
     height: 40,
     borderRadius: 5,
     marginTop: 10
   }
});
AppRegistry.registerComponent('AwesomeProject', () => CoolApp);

massively import product special

Posted on 2017-04-23

massively import product special

# ~*~ coding:utf-8 ~*~
#csv是一个读取csv文件的lib
import csv
#itertools生成组合和排列的lib
import itertools
#pyodbc是连接ms sql server的lib
import pyodbc
import pymysql
#cnxn是数据库连接  更改数据库连接方式,账号密码
cursor = cnxn.cursor()



#主方法
def process():
    #读取csv,转换成list 更改文件存储位置
    reader = list(csv.reader(open("D:\\ski\\attribute\\attribute-nz-mn.csv")))
    header = reader[0]
    #遍历数据,并处理, tips:跳过第一行
    for i in reader[1:]:
        sku = i[0]
        product_id = getIdFromSku(sku)
        if product_id == 0:
            print ("error sku %s" % sku)
            continue
        optionname = i[1]
        test(optionname)

        optionid = getoptionIdFromoption(optionname)
        option_id=int(optionid)
        if exist(product_id,option_id):
            pass
        else:
            insert(product_id,option_id)


def exist(product_id,option_id):
    sql = "select * from dbo.Product_SpecificationAttribute_Mapping where ProductId = %d and SpecificationAttributeOptionId = %d" % (product_id,option_id)
    cursor.execute(sql)
    rows = cursor.fetchall()
    if len(rows)==0:
        return False
    else:
        print (rows)


def getoptionIdFromoption(optionname):
    sql="SELECT Id FROM dbo.SpecificationAttributeOption where SpecificationAttributeId= %d and Name='%s'" % (7,optionname)
    cursor.execute(sql)
    row = cursor.fetchall()
    if row:
        return row[0][0]
    else:
        return 0
    print (sql)

def insert(product_id,option_id):
    sql = "insert into dbo.Product_SpecificationAttribute_Mapping (ProductId,SpecificationAttributeOptionId,DisplayOrder,AllowFiltering,ShowOnProductPage) values(%d,%d,%d,%d,%d)" % (product_id,option_id,0,0,1)
    print (sql)
    cursor.execute(sql)
    cnxn.commit()

def getIdFromSku(a):
    sql = "select Id from dbo.Product where Sku='%s' and deleted=0" % a
    cursor.execute(sql)
    row = cursor.fetchall()
    if row:
        return row[0][0]
    else:
        return 0
def test(optionname):
    if find(optionname)==0:
        sql="insert into dbo.SpecificationAttributeOption (Name,SpecificationAttributeId,DisplayOrder) values('%s','7',0)" % optionname
        print (sql)
        cursor.execute(sql)
        cnxn.commit()

def find(optionname):
    sql="select Name FROM dbo.SpecificationAttributeOption where SpecificationAttributeId='7' and Name='%s'" % optionname   
    cursor.execute(sql) 
    row = cursor.fetchall()
    if row:
        return row[0][0]
    else:
        return 0

if __name__ == "__main__":
    process()

postfirst page choose

Posted on 2017-04-23

first page choose

import React, { Component } from 'react';
import { AppRegistry,ScrollView,View,Text,Image,TouchableOpacity,StyleSheet} from 'react-native';
class PT extends React.Component {
  render() {
    return (
      <ScrollView
        contentContainerStyle={{flex:1}}
        keyboardDismissMode='on-drag'
        keyboardShouldPersistTaps={false}
      >
       <View style={styles.container}>
          <View style={styles.Top}>
           <Text style={styles.WelcomeText}>Welcome to Virtual PT</Text>
          </View>
       </View>
       <View style={styles.maincontain}>
         <Image
              source={{uri: 'http://oss-hz.qianmi.com/qianmicom/u/cms/qmwww/201511/03102524l6ur.png'}}
              style={styles.logo}/>

            <View style={styles.choose}>
              <TouchableOpacity style={styles.btn}
              onPress={()=> console.log('press me')}>
              <Text style={styles.text}>Register</Text>
              </TouchableOpacity>
              <TouchableOpacity style={styles.btn}
              onPress={() => console.log('press me')}>
              <Text style={styles.text}> Login</Text>
              </TouchableOpacity>
            </View>
        </View>
      </ScrollView>
   );
  }
}
var styles = StyleSheet.create({
  container:{
    flex: 1,
    backgroundColor: '#F4FCFF',
  },
  Top:{
    height:50,
    alignItems: 'center',
    backgroundColor:'#f5f2f0',
    justifyContent: 'center',
  },
  WelcomeText:{
    fontWeight: 'bold',
    fontSize: 18,
    color: '#d7499a', 
    borderWidth: 2,
    borderBottomColor:'#b8a6b0',
  },
  maincontain:
  {
    flex: 10,
    paddingLeft: 10,
    paddingRight: 10,
    backgroundColor: '#F4FCFF',
    justifyContent: 'center',
    alignItems: 'center',
  },
   logo:{
    width:160,
    height:160,
  },
  choose:{
    flexDirection:'row'
  },
  btn:{
     alignSelf: 'stretch',
     alignItems: 'center',
     justifyContent: 'center',
     backgroundColor: '#80b8e4',
     height: 40,
     borderRadius: 5,
     width:100,
     marginTop: 100,
     marginLeft:20,
  },
  text:{
    fontWeight: 'bold',
    fontSize: 14,
    color: '#FFF'
  },
});
AppRegistry.registerComponent('PT', () => PT);

postreact native jump to target page

Posted on 2017-04-23

postreact native jump to target page

import React, { Component } from 'react';
import { AppRegistry,ScrollView,View,Text,Image,Navigator,TouchableOpacity,StyleSheet} from 'react-native';

var _navigator;
var ShopView = require('./shop.android.js');

// class PT extends React.Component {
var PT = React.createClass({
    getInitialState: function(){
    return {};
  },

  configureScenceAndroid: function(){
    return Navigator.SceneConfigs.FadeAndroid;
  },

 renderSceneAndroid: function(route, navigator){
_navigator = navigator;
if(route.id === 'main'){
  return (
    // <View>

    //   <TouchableOpacity onPress={() => _navigator.push({title:'instructwelcome',id:'instructwelcome'})} style={ styles.button }>
    //     <Text>I am instructor</Text>
    //   </TouchableOpacity>

    // </View>
     <ScrollView 
    contentContainerStyle={{flex:1}}
    keyboardDismissMode='on-drag'
    keyboardShouldPersistTaps={false}
  >

   <View style={styles.container}>
      <View style={styles.Top}>
       <Text style={styles.WelcomeText}>Welcome to Virtual PT</Text>
      </View>
   </View>
   <View style={styles.maincontain}>
     <Image
          source={{uri: 'http://oss-hz.qianmi.com/qianmicom/u/cms/qmwww/201511/03102524l6ur.png'}}
          style={styles.logo}/>

        <View style={styles.choose}>
          <TouchableOpacity style={styles.btn}
          onPress={() => _navigator.push({title:'shop',id:'shop'})}>
          <Text style={styles.text}>Register</Text>
          </TouchableOpacity>
          <TouchableOpacity style={styles.btn}
          onPress={() => console.log('press me')}>
          <Text style={styles.text}> Login</Text>
          </TouchableOpacity>
        </View>
    </View>
  </ScrollView>
   );
}

if(route.id === 'shop'){
  return (
    <ShopView navigator={navigator} route={route} />
   );
}



  },

 render: function(){
    var renderScene = this.renderSceneAndroid;
    var configureScence = this.configureScenceAndroid;
    return (
      <Navigator
        debugOverlay={false}
        initialRoute={{ title: 'Main', id:'main'}}
        configureScence={{ configureScence }}
        renderScene={renderScene}/>
   );
  }

});
var styles = StyleSheet.create({
  container:{
    flex: 1,
    backgroundColor: '#F4FCFF',
  },
  Top:{
    height:50,
    alignItems: 'center',
    backgroundColor:'#f5f2f0',
    justifyContent: 'center',
  },
  WelcomeText:{
    fontWeight: 'bold',
    fontSize: 18,
    color: '#d7499a', 
    borderWidth: 2,
    borderBottomColor:'#b8a6b0',
  },
  maincontain:
  {
    flex: 10,
    paddingLeft: 10,
    paddingRight: 10,
    backgroundColor: '#F4FCFF',
    justifyContent: 'center',
    alignItems: 'center',
  },
   logo:{
    width:160,
    height:160,
  },
  choose:{
    flexDirection:'row'
  },
  btn:{
     alignSelf: 'stretch',
     alignItems: 'center',
     justifyContent: 'center',
     backgroundColor: '#80b8e4',
     height: 40,
     borderRadius: 5,
     width:100,
     marginTop: 100,
     marginLeft:20,
  },
  text:{
    fontWeight: 'bold',
    fontSize: 14,
    color: '#FFF'
  },
});

module.exports = PT

some problems of react native

Posted on 2017-04-23

some problems of react native

at the end of the code

mode.exports= InstructwelcomView

记得用大写区分
react native升级之后

import React ,{Componet} from 'react';
import{ View} from 'react-native'

需要分开写

postnopcommerce image hover scale

Posted on 2017-04-23

nopcommerce image hover scale

.product-grid .product-item .picture:hover img {
  margin-left: auto;
  margin-right: auto; 
  transition: all 0.2s;
  -webkit-transition: all 0.2s;
  transform: scale(1.2);
  -webkit-transform: scale(1.2);
 }
1…13141516
Jenny Zeng

Jenny Zeng

Loving code ,especially javascript, React Native

155 posts
37 tags
GitHub Linkedin
© 2020 Jenny Zeng
Powered by Hexo
Theme - NexT.Pisces