div.seatcharts-div id containerr 怎么修改

jquery-seat-charts 使用-自定义座位号 及 重新加载数据
jquery-seat-charts 使用-自定义座位号 及 重新加载数据
[摘要:一.自界说坐位号(即从新减载数据源)
1.自界说数据
var data1 = [['aa1','aa2','aa3','aa4','aa5','aa6'],['bb1&#]
一.自定义座位号(即重新加载数据源)
1.自定义数据
var data1 = [['aa1','aa2','aa3','aa4','aa5','aa6'],['bb1','bb2','bb3','bb4','bb5','bb6'],['cc1','cc2','cc3','cc4','cc5','cc6']];
2.html传输数据
naming: {//设置行列等信息
top: false, //不显示顶部横坐标(行)
// rows: ['3', '2', '1'],
// columns: ['A', 'B', 'C', 'G', 'D', 'F'],
getLabel: function(character, row, column) { //返回房间信息
getData:function(dataList){
console.log(dataList)
return dataL
data:data1
3.源码修改 大概400行左右,修改lable
seats[id] = new seat({
: naming.data[row][column] ,
: overrideLabel ? overrideLabel : naming.getLabel(character, naming.rows[row], naming.columns[column]),
character : character
4.源码修改,25行左右 加入data参数
settings = {
animate : false, //requires jQuery UI
: function(character, row, column) {
return row + '_' +
getLabel : function (character, row, column) {
二.重新刷新数据&
修改源码 在开始的位置
if (this.data('seatCharts')) {
// console.log(this.data('seatCharts'))
// return this.data('seatCharts');
// console.log(setup)
// console.log(setup.legend.items)
// console.log(this.data('seatCharts'))
var ary = setup.legend.
ary.splice(0,ary.length);
this.empty();
&!DOCTYPE html PUBLIC &-//W3C//DTD XHTML 1.0 Transitional//EN& &http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&&
&html xmlns=&http://www.w3.org/1999/xhtml&&
&meta http-equiv=&Content-Type& content=&text/ charset=utf-8& /&
&title&test&/title&
&link rel=&stylesheet& type=&text/css& href=&css/roomchartcommon.css& /&
&script type=&text/javascript& src=&js/jquery-1.11.2.js&&&/script&
&script type=&text/javascript& src=&js/jquery.seat-charts.js&&&/script&
&script type=&text/javascript&&
var price = 100; //房间价
var $cart = $('#rooms_selected'), //房间区
$rooms_num = $('#rooms_num'), //房间数
$total_price = $('#rooms_price'); //总金额
$roomNo = $('#roomNo');//房间号
$roomMsg = $('#roomMsg');//房间信息
var data1 = [['aa1','aa2','aa3','aa4','aa5','aa6'],['bb1','bb2','bb3','bb4','bb5','bb6'],
['cc1','cc2','cc3','cc4','cc5','cc6']];
var data2 = [['dd1','dd2','dd3','dd4','dd5','dd6'],['ee1','ee2','ee3','ee4','ee5','ee6'],
['ff1','ff2','ff3','ff4','ff5','ff6']];
$(document).ready(function() {
initchart(data1);
function initchart(dataList){
sc = $('#room_area').seatCharts({
map: [//房间结构图 f 代表已入住;e 代表未入住; 下划线 &_& 代表过道
'ffffff',
'eeeeee',
'ffeeee'
seats: {//设置已入住和未入住相关属性
price: 125,
classes: 'first-class',
category: '已入住'
price: 70,
classes: 'economy-class',
category: '未入住'
naming: {//设置行列等信息
top: false, //不显示顶部横坐标(行)
// rows: ['3', '2', '1'],
// columns: ['A', 'B', 'C', 'G', 'D', 'F'],
getLabel: function(character, row, column) { //返回房间信息
getData:function(dataList){
console.log(dataList)
return dataL
data:dataList
legend: {//定义图例
node: $('#roomlegend'),
['f', 'available', '未入住'],
['e', 'available', '将到期'],
['f', 'unavailable', '已入住']
click: function() {
if (this.status() == 'available') { //若为可选状态,添加响应事件
var roomNoText = $('&li&' + this.settings.label + '号&/li&')
.attr('id', 'cart-item-' + this.settings.id)
.data('seatId', this.settings.id).text();
$roomNo.text(roomNoText);
var roomMsgHtml = '&span&没有入住信息&/span&&br&&input type=&button& class=&roominbtn& value=&入住&/&';
$roomMsg.html(roomMsgHtml);
return 'selected';
$('&li&' + (this.settings.row + 1) + this.settings.label + '号&/li&')
.attr('id', 'cart-item-' + this.settings.id)
.data('seatId', this.settings.id)
.appendTo($cart);
$rooms_num.text(sc.find('selected').length + 1); //统计选票数量
$total_price.text(getTotalPrice(sc) + price);//计算票价总金额
return 'selected';
} else if (this.status() == 'selected') { //若为选中状态
$rooms_num.text(sc.find('selected').length - 1);//更新票数量
$total_price.text(getTotalPrice(sc) - price);//更新票价总金额
$('#cart-item-' + this.settings.id).remove();//删除已预订座位
return 'available';
} else if (this.status() == 'unavailable') { //若为损坏状态
var roomNoText = $('&li&' + this.settings.label + '号&/li&')
.attr('id', 'cart-item-' + this.settings.id)
.data('seatId', this.settings.id).text();
console.log(roomNoText);
$roomNo.text(roomNoText);
var roomMsgText = &张三、李四、王五、马六&;
$roomMsg.text(roomMsgText);
return 'unavailable';
return this.style();
//设置已售出的座位
sc.get(['3_03', '2_05']).status('unavailable');
function refresh(){
// console.log(sc);
// sc.dataReload(data2)
initchart(data2)
&button style=&float:width:150height:30& onclick=&refresh()&&刷新图表&/button&
&div class=&roomcontent&&
&div id=&room_area&&
&div id=&roomlegend& class='of'&&/div&
&div id=&roomdetail&&
&h3&房间详细信息&/h3&
&div id=&roomNo&&
&div id=&roomMsg&&
* jQuery-Seat-Charts v1.1.0
(function($) {
$.fn.seatCharts = function (setup) {
//if there's seatCharts object associated with the current element, return it
if (this.data('seatCharts')) {
// console.log(this.data('seatCharts'))
// return this.data('seatCharts');
// console.log(setup)
// console.log(setup.legend.items)
// console.log(this.data('seatCharts'))
var ary = setup.legend.
ary.splice(0,ary.length);
this.empty();
settings = {
animate : false, //requires jQuery UI
: function(character, row, column) {
return row + '_' +
getLabel : function (character, row, column) {
legend : {
: function() {
if (this.status() == 'available') {
return 'selected';
} else if (this.status() == 'selected') {
return 'available';
return this.style();
: function() {
if (this.status() == 'available') {
return 'focused';
return this.style();
: function() {
return this.status();
//seat will be basically a seat object which we'll when generating the map
seat = (function(seatCharts, seatChartsSettings) {
return function (setup) {
fn.settings = $.extend({
status : 'available', //available, unavailable, selected
: 'available',
//make sure there's an empty hash if user doesn't pass anything
: seatChartsSettings.seats[setup.character] || {}
//anything goes here?
}, setup);
fn.settings.$node = $('&div&&/div&');
fn.settings.$node
: fn.settings.id,
: 'checkbox',
'aria-checked' : false,
: -1 //manual focus
.text(fn.settings.label)
.addClass(['seatCharts-seat', 'seatCharts-cell', 'available'].concat(
//let's merge custom user defined classes with standard JSC ones
fn.settings.classes,
typeof seatChartsSettings.seats[fn.settings.character] == &undefined& ?
[] : seatChartsSettings.seats[fn.settings.character].classes
).join(' '));
//basically a wrapper function
fn.data = function() {
return fn.settings.
fn.char = function() {
return fn.settings.
fn.node = function() {
return fn.settings.$
* Can either set or return status depending on arguments.
* If there's no argument, it will return the current style.
* If you pass an argument, it will update seat's style
fn.style = function() {
return arguments.length == 1 ?
(function(newStyle) {
var oldStyle = fn.settings.
//if nothing changes, do nothing
if (newStyle == oldStyle) {
//focused is a special style which is not associated with status
fn.settings.status = newStyle != 'focused' ? newStyle : fn.settings.
fn.settings.$node
.attr('aria-checked', newStyle == 'selected');
//if user wants to animate status changes, let him do this
seatChartsSettings.animate ?
fn.settings.$node.switchClass(oldStyle, newStyle, 200) :
fn.settings.$node.removeClass(oldStyle).addClass(newStyle);
return fn.settings.style = newS
})(arguments[0]) : fn.settings.
//either set or retrieve
fn.status = function() {
return fn.settings.status = arguments.length == 1 ?
fn.style(arguments[0]) : fn.settings.
//using immediate function to convienietly get shortcut variables
(function(seatSettings, character, seat) {
//attach event handlers
$.each(['click', 'focus', 'blur'], function(index, callback) {
//we want to be able to call the functions for each seat object
fn[callback] = function() {
if (callback == 'focus') {
//if there's already a focused element, we have to remove focus from it first
if (seatCharts.attr('aria-activedescendant') !== undefined) {
seats[seatCharts.attr('aria-activedescendant')].blur();
seatCharts.attr('aria-activedescendant', seat.settings.id);
seat.node().focus();
* User can pass his own callback function, so we have to first check if it exists
* and if not, use our default callback.
* Each callback function is executed in the current seat context.
return fn.style(typeof seatSettings[character][callback] === 'function' ?
seatSettings[character][callback].apply(seat) : seatChartsSettings[callback].apply(seat));
//the below will become seatSettings, character, seat thanks to the immediate function
})(seatChartsSettings.seats, fn.settings.character, fn);
//the first three mouse events are simple
.on('click',
.on('mouseenter', fn.focus)
.on('mouseleave', fn.blur)
//keydown requires quite a lot of logic, because we have to know where to move the focus
.on('keydown',
(function(seat, $seat) {
return function (e) {
//everything depends on the pressed key
switch (e.which) {
//spacebar will just trigger the same event mouse click does
e.preventDefault();
seat.click();
//UP & DOWN
e.preventDefault();
* This is a recursive, immediate function which searches for the first &focusable& row.
* We're using immediate function because we want a convenient access to some DOM elements
* We're using recursion because sometimes we may hit an empty space rather than a seat.
$newSeat = (function findAvailable($rows, $seats, $currentRow) {
//let's determine which row should we move to
if (!$rows.index($currentRow) && e.which == 38) {
//if this is the first row and user has pressed up arrow, move to the last row
$newRow = $rows.last();
} else if ($rows.index($currentRow) == $rows.length-1 && e.which == 40) {
//if this is the last row and user has pressed down arrow, move to the first row
$newRow = $rows.first();
//using eq to get an element at the desired index position
$newRow = $rows.eq(
//if up arrow, then decrement the index, if down increment it
$rows.index($currentRow) + (e.which == 38 ? (-1) : (+1))
//now that we know the row, let's get the seat using the current column position
$newSeat = $newRow.find('.seatCharts-seat,.seatCharts-space').eq($seats.index($seat));
//if the seat we found is a space, keep looking further
return $newSeat.hasClass('seatCharts-space') ?
findAvailable($rows, $seats, $newRow) : $newS
//get a reference to the parent container and then select all rows but the header
.parents('.seatCharts-container')
.find('.seatCharts-row:not(.seatCharts-header)'),
//get a reference to the parent row and then find all seat cells (both seats & spaces)
.parents('.seatCharts-row:first')
.find('.seatCharts-seat,.seatCharts-space'),
//get a reference to the current row
$seat.parents('.seatCharts-row:not(.seatCharts-header)')
//we couldn't determine the new seat, so we better give up
if (!$newSeat.length) {
//remove focus from the old seat and put it on the new one
seat.blur();
seats[$newSeat.attr('id')].focus();
$newSeat.focus();
//update our &aria& reference with the new seat id
seatCharts.attr('aria-activedescendant', $newSeat.attr('id'));
//LEFT & RIGHT
e.preventDefault();
* The logic here is slightly different from the one for up/down arrows.
* User will be able to browse the whole map using just left/right arrow, because
* it will move to the next row when we reach the right/left-most seat.
$newSeat = (function($seats) {
if (!$seats.index($seat) && e.which == 37) {
//user has pressed left arrow and we're currently on the left-most seat
return $seats.last();
} else if ($seats.index($seat) == $seats.length -1 && e.which == 39) {
//user has pressed right arrow and we're currently on the right-most seat
return $seats.first();
//simply move one seat left or right depending on the key
return $seats.eq($seats.index($seat) + (e.which == 37 ? (-1) : (+1)));
.parents('.seatCharts-container:first')
.find('.seatCharts-seat:not(.seatCharts-space)'));
if (!$newSeat.length) {
//handle focus
seat.blur();
seats[$newSeat.attr('id')].focus();
$newSeat.focus();
//update our &aria& reference with the new seat id
seatCharts.attr('aria-activedescendant', $newSeat.attr('id'));
})(fn, fn.node()));
//.appendTo(seatCharts.find('.' + row));
})(fn, settings);
fn.addClass('seatCharts-container');
//true -& deep copy!
$.extend(true, settings, setup);
//Generate default row ids unless user passed his own
settings.naming.rows = settings.naming.rows || (function(length) {
var rows = [];
for (var i = 1; i &= i++) {
rows.push(i);
})(settings.map.length);
//Generate default column ids unless user passed his own
settings.naming.columns = settings.naming.columns || (function(length) {
var columns = [];
for (var i = 1; i &= i++) {
columns.push(&0&+i);
})(settings.map[0].split('').length);
if (settings.naming.top) {
var $headerRow = $('&div&&/div&')
.addClass('seatCharts-row seatCharts-header');
if (settings.naming.left) {
$headerRow.append($('&div&&/div&').addClass('seatCharts-cell'));
$.each(settings.naming.columns, function(index, value) {
$headerRow.append(
$('&div&&/div&')
.addClass('seatCharts-cell')
.text(value)
fn.append($headerRow);
//do this for each map row
$.each(settings.map, function(row, characters) {
var $row = $('&div&&/div&').addClass('seatCharts-row');
if (settings.naming.left) {
$row.append(
$('&div&&/div&')
.addClass('seatCharts-cell seatCharts-space')
.text(settings.naming.rows[row])
* Do this for each seat (letter)
* Now users will be able to pass custom ID and label which overwrite the one that seat would be assigned by getId and
* getLabel
* New format is like this:
* a[ID,label]a[ID]aaaaa
* So you can overwrite the ID or label (or both) even for just one seat.
* Basically ID should be first, so if you want to overwrite just label write it as follows:
* a[,LABEL]
* Allowed characters in IDs areL 0-9, a-z, A-Z, _
* Allowed characters in labels are: 0-9, a-z, A-Z, _, ' ' (space)
$.each(characters.match(/[a-z_]{1}(\[[0-9a-z_]{0,}(,[0-9a-z_ ]+)?\])?/gi), function (column, characterParams) {
var matches
= characterParams.match(/([a-z_]{1})(\[([0-9a-z_ ,]+)\])?/i),
//no matter if user specifies [] params, the character should be in the second element
= matches[1],
//check if user has passed some additional params to override id or label
= typeof matches[3] !== 'undefined' ? matches[3].split(',') : [],
//id param should be first
overrideId
= params.length ? params[0] : null,
//label param should be second
overrideLabel
= params.length === 2 ? params[1] :
$row.append(character != '_' ?
//if the character is not an underscore (empty space)
(function(naming) {
//console.log(naming);
//so users don't have to specify empty objects
// console.log(naming);
// console.log(&character&+naming.getLabel(character, naming.rows[row], naming.columns[column]));
// console.log(&row&+row);
// console.log(column);
// console.log(naming.data)
settings.seats[character] = character in settings.seats ? settings.seats[character] : {};
var id = overrideId ? overrideId : naming.getId(character, naming.rows[row], naming.columns[column]);
seats[id] = new seat({
: naming.data[row][column] ,
: overrideLabel ? overrideLabel : naming.getLabel(character, naming.rows[row], naming.columns[column]),
character : character
seatIds.push(id);
return seats[id].node();
})(settings.naming) :
//this is just an empty space (_)
$('&div&&/div&').addClass('seatCharts-cell seatCharts-space')
fn.append($row);
//if there're any legend items to be rendered
settings.legend.items.length ? (function(legend) {
//either use user-defined container or create our own and insert it right after the seat chart div
var $container = (legend.node || $('&div&&/div').insertAfter(fn))
.addClass('seatCharts-legend');
var $ul = $('&ul&&/ul&')
.addClass('seatCharts-legendList')
.appendTo($container);
$.each(legend.items, function(index, item) {
$ul.append(
$('&li&&/li&')
.addClass('seatCharts-legendItem')
$('&div&&/div&')
//merge user defined classes with our standard ones
.addClass(['seatCharts-seat', 'seatCharts-cell', item[1]].concat(
settings.classes,
typeof settings.seats[item[0]] == &undefined& ? [] : settings.seats[item[0]].classes).join(' ')
$('&span&&/span&')
.addClass('seatCharts-legendDescription')
.text(item[2])
})(settings.legend) :
tabIndex : 0
//when container's focused, move focus to the first seat
fn.focus(function() {
if (fn.attr('aria-activedescendant')) {
seats[fn.attr('aria-activedescendant')].blur();
fn.find('.seatCharts-seat:not(.seatCharts-space):first').focus();
seats[seatIds[0]].focus();
//public methods of seatCharts
fn.data('seatCharts', {
seatIds : seatIds,
//set for one, set for many, get for one
status: function() {
return arguments.length == 1 ? fn.seats[arguments[0]].status() : (function(seatsIds, newStatus) {
return typeof seatsIds == 'string' ? fn.seats[seatsIds].status(newStatus) : (function() {
$.each(seatsIds, function(index, seatId) {
fn.seats[seatId].status(newStatus);
})(arguments[0], arguments[1]);
: function(callback) {
for (var seatId in fn.seats) {
if (false === callback.call(fn.seats[seatId], seatId)) {
return seatId;//return last checked
: function() {
//basically create a CSS query to get all seats by their DOM ids
return $('#' + fn.seatIds.join(',#'));
: function(query) {//D, a.available, unavailable
var seatSet = fn.set();
//user searches just for a particual character
return query.length == 1 ? (function(character) {
fn.each(function() {
if (this.char() == character) {
seatSet.push(this.settings.id, this);
return seatS
})(query) : (function() {
//user runs a more sophisticated query, so let's see if there's a dot
return query.indexOf('.') & -1 ? (function() {
//there's a dot which separates character and the status
var parts = query.split('.');
fn.each(function(seatId) {
if (this.char() == parts[0] && this.status() == parts[1]) {
seatSet.push(this.settings.id, this);
return seatS
})() : (function() {
fn.each(function() {
if (this.status() == query) {
seatSet.push(this.settings.id, this);
return seatS
: function set() {//inherits some methods
: function() {
var args = arguments,
//if there's just one seat in the set and user didn't pass any params, return current status
return this.length == 1 && args.length == 0 ? this.seats[0].status() : (function() {
//otherwise call status function for each of the seats in the set
$.each(that.seats, function() {
this.status.apply(this, args);
: function() {
return fn.node.call(this);
: function() {
return fn.each.call(this, arguments[0]);
: function() {
return fn.get.call(this, arguments[0]);
: function() {
return fn.find.call(this, arguments[0]);
: function() {
return set.call(fn);
: function(id, seat) {
this.seats.push(seat);
this.seatIds.push(id);
//get one object or a set of objects
: function(seatsIds) {
return typeof seatsIds == 'string' ?
fn.seats[seatsIds] : (function() {
var seatSet = fn.set();
$.each(seatsIds, function(index, seatId) {
if (typeof fn.seats[seatId] === 'object') {
seatSet.push(seatId, fn.seats[seatId]);
return seatS
dataReload : function(data){
// console.log(this)
// console.log(data);
return fn.data('seatCharts');
})(jQuery);
感谢关注 Ithao123Jquery频道,是专门为互联网人打造的学习交流平台,全面满足互联网人工作与学习需求,更多互联网资讯尽在 IThao123!
Hadoop是一个由Apache基金会所开发的分布式系统基础架构。
用户可以在不了解分布式底层细节的情况下,开发分布式程序。充分利用集群的威力进行高速运算和存储。
Hadoop实现了一个分布式文件系统(Hadoop Distributed File System),简称HDFS。HDFS有高容错性的特点,并且设计用来部署在低廉的(low-cost)硬件上;而且它提供高吞吐量(high throughput)来访问应用程序的数据,适合那些有着超大数据集(large data set)的应用程序。HDFS放宽了(relax)POSIX的要求,可以以流的形式访问(streaming access)文件系统中的数据。
Hadoop的框架最核心的设计就是:HDFS和MapReduce。HDFS为海量的数据提供了存储,则MapReduce为海量的数据提供了计算。
产品设计是互联网产品经理的核心能力,一个好的产品经理一定在产品设计方面有扎实的功底,本专题将从互联网产品设计的几个方面谈谈产品设计
随着国内互联网的发展,产品经理岗位需求大幅增加,在国内,从事产品工作的大部分岗位为产品经理,其实现实中,很多从事产品工作的岗位是不能称为产品经理,主要原因是对产品经理的职责不明确,那产品经理的职责有哪些,本专题将详细介绍产品经理的主要职责
Swift是Apple在WWDC2014所发布的一门编程语言,用来撰写OS X和iOS应用程序[1]。在设计Swift时.就有意和Objective-C共存,Objective-C是Apple操作系统在导入Swift前使用的编程语言
Swift是供iOS和OS X应用编程的新编程语言,基于C和Objective-C,而却没有C的一些兼容约束。Swift采用了安全的编程模式和添加现代的功能来使得编程更加简单、灵活和有趣。界面则基于广受人民群众爱戴的Cocoa和Cocoa Touch框架,展示了软件开发的新方向。
IThao123周刊}

我要回帖

更多关于 div not .container 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信