Commit 759301b2 authored by 神楽坂玲奈's avatar 神楽坂玲奈

easypignate

parent 12cc9ad8
......@@ -354,7 +354,16 @@ class CardsController extends Spine.Controller
$('#search_cards_' + (if $('.operate_area').hasClass('text') then 'text' else 'graphic') + '_template')
search: (name)->
Card.fetch_by_name name, (cards)=>
category_count = {}
for category in Card.categories
category_count[category] = 0
for card in cards
category_count[(category for category in card.card_type when category in Card.categories).pop()]++
$("#search_cards_spells_count").html category_count.Spell
$("#search_cards_traps_count").html category_count.Trap
$("#search_cards_monsters_count").html category_count.Monster
@html @template().tmpl cards
@el.easyPaginate(step: 7, delay: 30)
decks = new DecksController(el: $("#deck"))
......
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
(function() {
var Card, CardUsage, CardsController, Deck, DecksController, cards, decks, locale,
var Card, CardUsage, CardsController, Deck, DecksController, cards, decks, locale, _ref, _ref1, _ref2, _ref3, _ref4,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
......@@ -9,11 +9,11 @@
locale = 'zh';
Card = (function(_super) {
__extends(Card, _super);
function Card() {
return Card.__super__.constructor.apply(this, arguments);
_ref = Card.__super__.constructor.apply(this, arguments);
return _ref;
}
Card.types = ['Warrior', 'Spellcaster', 'Fairy', 'Fiend', 'Zombie', 'Machine', 'Aqua', 'Pyro', 'Rock', 'Winged_Beast', 'Plant', 'Insect', 'Thunder', 'Dragon', 'Beast', 'Beast-Warrior', 'Dinosaur', 'Fish', 'Sea_Serpent', 'Reptile', 'Psychic', 'Divine-Beast', 'Creator_God'];
......@@ -46,8 +46,10 @@
Card.load = function(cards, langs) {
var card, card_type, i, lang;
return this.refresh((function() {
var _i, _j, _len, _len1, _results;
_results = [];
for (_i = 0, _len = langs.length; _i < _len; _i++) {
lang = langs[_i];
......@@ -74,6 +76,7 @@
card_type: card_type,
type: lang.race ? (i = 0, (function() {
var _results1;
_results1 = [];
while (!(lang.race >> i & 1)) {
_results1.push(i++);
......@@ -82,6 +85,7 @@
})(), this.types[i]) : void 0,
attribute: lang.attribute ? (i = 0, (function() {
var _results1;
_results1 = [];
while (!(lang.attribute >> i & 1)) {
_results1.push(i++);
......@@ -100,20 +104,23 @@
Card.fetch_by_name = function(name, callback) {
var _this = this;
return $.getJSON("" + this.locale_url + "?q=" + (JSON.stringify({
name: {
$regex: name.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1'),
$options: 'i'
}
})), function(langs) {
var cards_id, lang, result, _i, _len;
var cards_id, e, lang, result, _i, _len;
result = [];
cards_id = [];
for (_i = 0, _len = langs.length; _i < _len; _i++) {
lang = langs[_i];
try {
result.push(Card.find(lang._id));
} catch (e) {
} catch (_error) {
e = _error;
cards_id.push(lang._id);
}
}
......@@ -124,6 +131,7 @@
}
})), function(cards) {
var card, _j, _len1;
_this.load(cards, langs);
for (_j = 0, _len1 = cards.length; _j < _len1; _j++) {
card = cards[_j];
......@@ -140,8 +148,10 @@
Card.fetch_by_id = function(cards_id, callback, before, after) {
var card_id,
_this = this;
cards_id = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = cards_id.length; _i < _len; _i++) {
card_id = cards_id[_i];
......@@ -180,11 +190,11 @@
})(Spine.Model);
CardUsage = (function(_super) {
__extends(CardUsage, _super);
function CardUsage() {
return CardUsage.__super__.constructor.apply(this, arguments);
_ref1 = CardUsage.__super__.constructor.apply(this, arguments);
return _ref1;
}
CardUsage.configure('CardUsage', 'count', 'side');
......@@ -198,11 +208,11 @@
})(Spine.Model);
Deck = (function(_super) {
__extends(Deck, _super);
function Deck() {
return Deck.__super__.constructor.apply(this, arguments);
_ref2 = Deck.__super__.constructor.apply(this, arguments);
return _ref2;
}
Deck.configure('Deck', 'name');
......@@ -212,11 +222,12 @@
Deck.key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789*-=";
Deck.prototype.encode = function() {
var c, card_usage, i, result, _i, _j, _len, _ref;
var c, card_usage, i, result, _i, _j, _len, _ref3;
result = '';
_ref = this.card_usages().all();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
card_usage = _ref[_i];
_ref3 = this.card_usages().all();
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
card_usage = _ref3[_i];
c = card_usage.side << 29 | card_usage.count << 27 | card_usage.card_id;
for (i = _j = 4; _j >= 0; i = --_j) {
result += Deck.key.charAt((c >> i * 6) & 0x3F);
......@@ -226,7 +237,8 @@
};
Deck.prototype.sort = function() {
var card, card_type, card_usage, category, _i, _j, _len, _len1, _ref, _ref1, _results;
var card, card_type, card_usage, category, _i, _j, _len, _len1, _ref3, _ref4, _results;
this._main = [];
this._side = [];
this._extra = [];
......@@ -234,25 +246,26 @@
this._side_count = 0;
this._extra_count = 0;
this._category_count = {};
_ref = Card.categories;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
category = _ref[_i];
_ref3 = Card.categories;
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
category = _ref3[_i];
this._category_count[category] = 0;
}
_ref1 = this.card_usages().all();
_ref4 = this.card_usages().all();
_results = [];
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
card_usage = _ref1[_j];
for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) {
card_usage = _ref4[_j];
card = card_usage.card();
if (card_usage.side) {
this._side.push(card_usage);
_results.push(this._side_count += card_usage.count);
} else if (((function() {
var _k, _len2, _ref2, _results1;
_ref2 = card.card_type;
var _k, _len2, _ref5, _results1;
_ref5 = card.card_type;
_results1 = [];
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
card_type = _ref2[_k];
for (_k = 0, _len2 = _ref5.length; _k < _len2; _k++) {
card_type = _ref5[_k];
if (__indexOf.call(Card.card_types_extra, card_type) >= 0) {
_results1.push(card_type);
}
......@@ -265,11 +278,12 @@
this._main.push(card_usage);
this._main_count += card_usage.count;
_results.push(this._category_count[((function() {
var _k, _len2, _ref2, _results1;
_ref2 = card.card_type;
var _k, _len2, _ref5, _results1;
_ref5 = card.card_type;
_results1 = [];
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
category = _ref2[_k];
for (_k = 0, _len2 = _ref5.length; _k < _len2; _k++) {
category = _ref5[_k];
if (__indexOf.call(Card.categories, category) >= 0) {
_results1.push(category);
}
......@@ -282,28 +296,28 @@
};
Deck.prototype.main = function() {
if (!(this._main != null)) {
if (this._main == null) {
this.sort();
}
return this._main;
};
Deck.prototype.side = function() {
if (!(this._side != null)) {
if (this._side == null) {
this.sort();
}
return this._side;
};
Deck.prototype.extra = function() {
if (!(this._extra != null)) {
if (this._extra == null) {
this.sort();
}
return this._extra;
};
Deck.prototype.main_count = function() {
if (!(this._main_count != null)) {
if (this._main_count == null) {
this.sort();
}
return this._main_count;
......@@ -324,24 +338,25 @@
};
Deck.prototype.category_count = function() {
if (!(this._category_count != null)) {
if (this._category_count == null) {
this.sort();
}
return this._category_count;
};
Deck.decode = function(str, name) {
var card_id, card_usages, char, count, decoded, i, result, side, _i, _j, _len, _ref, _ref1;
var card_id, card_usages, char, count, decoded, i, result, side, _i, _j, _len, _ref3, _ref4;
result = new Deck({
name: name
});
result.save();
card_usages = [];
for (i = _i = 0, _ref = str.length; _i < _ref; i = _i += 5) {
for (i = _i = 0, _ref3 = str.length; _i < _ref3; i = _i += 5) {
decoded = 0;
_ref1 = str.substr(i, 5);
for (_j = 0, _len = _ref1.length; _j < _len; _j++) {
char = _ref1[_j];
_ref4 = str.substr(i, 5);
for (_j = 0, _len = _ref4.length; _j < _len; _j++) {
char = _ref4[_j];
decoded = (decoded << 6) + this.key.indexOf(char);
}
side = decoded >> 29;
......@@ -360,6 +375,7 @@
Deck.load = function(str, name) {
var card_id, card_usages, count, last_id, line, lines, result, side, _i, _len;
result = new Deck({
name: name
});
......@@ -438,7 +454,8 @@
};
Deck.prototype.add = function(card_usage) {
var c, count, _i, _len, _ref;
var c, count, _i, _len, _ref3;
if (!card_usage.card_id) {
card_usage = this.card_usages().findByAttribute('card_id', card.id) || new CardUsage({
card_id: card_usage.id,
......@@ -448,9 +465,9 @@
});
}
count = 0;
_ref = this.card_usages().findAllByAttribute('card_id', card_usage.card_id);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
c = _ref[_i];
_ref3 = this.card_usages().findAllByAttribute('card_id', card_usage.card_id);
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
c = _ref3[_i];
count += c.count;
}
if (count < 3) {
......@@ -479,14 +496,12 @@
})(Spine.Model);
DecksController = (function(_super) {
__extends(DecksController, _super);
function DecksController() {
this.render = __bind(this.render, this);
this.refresh = __bind(this.refresh, this);
return DecksController.__super__.constructor.apply(this, arguments);
this.refresh = __bind(this.refresh, this); _ref3 = DecksController.__super__.constructor.apply(this, arguments);
return _ref3;
}
DecksController.prototype.events = {
......@@ -508,12 +523,14 @@
DecksController.prototype.refresh = function() {
var card_usage,
_this = this;
return Card.fetch_by_id((function() {
var _i, _len, _ref, _results;
_ref = this.deck().card_usages().all();
var _i, _len, _ref4, _results;
_ref4 = this.deck().card_usages().all();
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
card_usage = _ref[_i];
for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
card_usage = _ref4[_i];
_results.push(card_usage.card_id);
}
return _results;
......@@ -527,6 +544,7 @@
DecksController.prototype.render = function() {
var card_width, deck_width, extra_margin, main_margin, side_margin;
this.html($('#deck_template').tmpl({
main: this.deck().main(),
side: this.deck().side(),
......@@ -539,25 +557,25 @@
this.set_history();
this.set_download();
/*
$( ".deck_part" ).sortable(
connectWith: ".deck_part"
stop: =>
card_usages = []
last_item = null
for el in $('.card_usage')
card_id = $(el).tmplItem().data.card_id
side = $(el).parent().hasClass('side')
if last_item
if last_item.card_id == card_id and last_item.side == side
last_item.count++
else
card_usages.push last_item
last_item = {card_id: card_id, side: side, count: 1}
else
last_item = {card_id: card_id, side: side, count: 1}
card_usages.push last_item
@deck().card_usages card_usages, clear: true
).disableSelection();
$( ".deck_part" ).sortable(
connectWith: ".deck_part"
stop: =>
card_usages = []
last_item = null
for el in $('.card_usage')
card_id = $(el).tmplItem().data.card_id
side = $(el).parent().hasClass('side')
if last_item
if last_item.card_id == card_id and last_item.side == side
last_item.count++
else
card_usages.push last_item
last_item = {card_id: card_id, side: side, count: 1}
else
last_item = {card_id: card_id, side: side, count: 1}
card_usages.push last_item
@deck().card_usages card_usages, clear: true
).disableSelection();
*/
if ($('.operate_area').hasClass('text')) {
......@@ -602,16 +620,20 @@
DecksController.prototype.upload = function(files) {
var file, reader;
file = files[0];
reader = new FileReader();
if (file) {
$('#deck_load').attr('disabled', true);
}
reader.onload = function(ev) {
var error;
$('#deck_load').attr('disabled', false);
try {
return decks.deck(Deck.load(ev.target.result, file.name.split('.')[0]));
} catch (error) {
} catch (_error) {
error = _error;
return alert(error);
}
};
......@@ -619,9 +641,12 @@
};
DecksController.prototype.load_from_url = function(url) {
var error;
try {
return decks.deck(Deck.decode($.url(url).param('cards'), $.url().param('name')));
} catch (error) {
} catch (_error) {
error = _error;
return alert(error);
}
};
......@@ -634,18 +659,21 @@
DecksController.prototype.set_download = function() {
var card_usage, i;
if ($.browser.chrome) {
$('#deck_url_ydk').attr('download', this.deck().name + '.ydk');
$('#deck_url_ydk').attr('href', 'data:application/x-ygopro-deck,' + encodeURI(["#generated by mycard/web"].concat((function() {
var _i, _len, _ref, _results;
_ref = this.deck().main();
var _i, _len, _ref4, _results;
_ref4 = this.deck().main();
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
card_usage = _ref[_i];
for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
card_usage = _ref4[_i];
_results.push(((function() {
var _j, _ref1, _results1;
var _j, _ref5, _results1;
_results1 = [];
for (i = _j = 0, _ref1 = card_usage.count; 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {
for (i = _j = 0, _ref5 = card_usage.count; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; i = 0 <= _ref5 ? ++_j : --_j) {
_results1.push(card_usage.card_id);
}
return _results1;
......@@ -653,15 +681,17 @@
}
return _results;
}).call(this), (function() {
var _i, _len, _ref, _results;
_ref = this.deck().extra();
var _i, _len, _ref4, _results;
_ref4 = this.deck().extra();
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
card_usage = _ref[_i];
for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
card_usage = _ref4[_i];
_results.push(((function() {
var _j, _ref1, _results1;
var _j, _ref5, _results1;
_results1 = [];
for (i = _j = 0, _ref1 = card_usage.count; 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {
for (i = _j = 0, _ref5 = card_usage.count; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; i = 0 <= _ref5 ? ++_j : --_j) {
_results1.push(card_usage.card_id);
}
return _results1;
......@@ -669,15 +699,17 @@
}
return _results;
}).call(this), ["!side"], (function() {
var _i, _len, _ref, _results;
_ref = this.deck().side();
var _i, _len, _ref4, _results;
_ref4 = this.deck().side();
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
card_usage = _ref[_i];
for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
card_usage = _ref4[_i];
_results.push(((function() {
var _j, _ref1, _results1;
var _j, _ref5, _results1;
_results1 = [];
for (i = _j = 0, _ref1 = card_usage.count; 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {
for (i = _j = 0, _ref5 = card_usage.count; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; i = 0 <= _ref5 ? ++_j : --_j) {
_results1.push(card_usage.card_id);
}
return _results1;
......@@ -694,6 +726,7 @@
DecksController.prototype.tab_control = function() {
$(".bottom_area div").click(function() {
var $dangqian;
$(this).addClass("bottom_button_active").removeClass("bottom_button");
$(this).siblings().addClass("bottom_button").removeClass("bottom_button_active");
$dangqian = $(".card_frame .frame_element").eq($(".bottom_area div").index(this));
......@@ -710,6 +743,7 @@
DecksController.prototype.show = function(e) {
var active_page_index, card;
card = $(e.target).tmplItem().data;
if (card.card_id) {
card = card.card();
......@@ -737,11 +771,11 @@
})(Spine.Controller);
CardsController = (function(_super) {
__extends(CardsController, _super);
function CardsController() {
return CardsController.__super__.constructor.apply(this, arguments);
_ref4 = CardsController.__super__.constructor.apply(this, arguments);
return _ref4;
}
CardsController.prototype.events = {
......@@ -769,8 +803,40 @@
CardsController.prototype.search = function(name) {
var _this = this;
return Card.fetch_by_name(name, function(cards) {
return _this.html(_this.template().tmpl(cards));
var card, category, category_count, _i, _j, _len, _len1, _ref5;
category_count = {};
_ref5 = Card.categories;
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
category = _ref5[_i];
category_count[category] = 0;
}
for (_j = 0, _len1 = cards.length; _j < _len1; _j++) {
card = cards[_j];
category_count[((function() {
var _k, _len2, _ref6, _results;
_ref6 = card.card_type;
_results = [];
for (_k = 0, _len2 = _ref6.length; _k < _len2; _k++) {
category = _ref6[_k];
if (__indexOf.call(Card.categories, category) >= 0) {
_results.push(category);
}
}
return _results;
})()).pop()]++;
}
$("#search_cards_spells_count").html(category_count.Spell);
$("#search_cards_traps_count").html(category_count.Trap);
$("#search_cards_monsters_count").html(category_count.Monster);
_this.html(_this.template().tmpl(cards));
return _this.el.easyPaginate({
step: 7,
delay: 30
});
});
};
......@@ -795,7 +861,6 @@
$("#deck_share_dialog").dialog({
modal: true,
autoOpen: false,
width: 600,
open: function() {
$("#deck_url").val(decks.deck().url());
$("#deck_url")[0].select();
......@@ -844,7 +909,7 @@
$("#drop_upload_dialog").dialog('close');
return decks.upload(event.dataTransfer.files);
});
$(".swith").click(function() {
$(".rename_ope").click(function() {
$(".text,.graphic").toggleClass("graphic text");
return decks.render();
});
......
......@@ -104,17 +104,15 @@ body{margin:0;padding:0;background:#eee;}
label{float:left;}
}
}
.page{
max-width:518px;height:60px;padding:20px 15px 0 0;text-align:right;
#pagination {
max-width:518px;height:60px;padding:20px 15px 0 0;text-align:right;float:right;
a{margin:0 4px;}
}
.page_home{background:url('/assets/images/decks/page_arrows.gif') -26px 0 no-repeat;width:23px;height:17px;display:block;float:left;}
.page_pre{background:url('/assets/images/decks/page_arrows.gif') -1px 0 no-repeat;width:13px;height:17px;display:block;float:left;}
.page_next{background:url('/assets/images/decks/page_arrows.gif') -13px 0 no-repeat;width:13px;height:17px;display:block;float:left;}
.page_last{background:url('/assets/images/decks/page_arrows.gif') -47px 0 no-repeat;width:23px;height:17px;display:block;float:left;}
.page_num{
display:block;float:left;height:17px;line-height:17px;width:16px;font-size:14px;color:#999;text-decoration:none;text-align:center;
&:hover{text-decoration:underline;}
li{
display:block;float:left;height:17px;line-height:17px;width:16px;font-size:14px;color:#999;text-decoration:none;text-align:center;
&:hover{text-decoration:underline;}
}
.next{background:url('/assets/images/decks/page_arrows.gif') -13px 0 no-repeat;width:13px;height:17px;display:block;float:left;font-size: 0px;}
.prev{background:url('/assets/images/decks/page_arrows.gif') -1px 0 no-repeat;width:13px;height:17px;display:block;float:left;font-size: 0px;}
}
.card_group{
height:565px;//width:150px;
......@@ -237,7 +235,7 @@ body{margin:0;padding:0;background:#eee;}
}
span{font-size:12px;}
}
.page{
#pagination{
padding:20px 5px 0 0;
a{margin:0 2px;}
}
......
......@@ -442,22 +442,13 @@
<!-- 修改 -->
<div class="floatleft search_results">
<span style="color:#3366CC;font-weight:bold;">结果数</span>
魔法:<span style="color:#FFAD6E;">XXX</span>
陷阱:<span style="color:#FFAD6E;">XXX</span>
怪兽:<span style="color:#FFAD6E;">XXX</span>
魔法:<span id="search_cards_spells_count" style="color:#FFAD6E;">-</span>
陷阱:<span id="search_cards_traps_count" style="color:#FFAD6E;">-</span>
怪兽:<span id="search_cards_monsters_count" style="color:#FFAD6E;">-</span>
</div>
</div>
<div class="floatleft main_area" id="search_cards"></div>
<div class="floatright page">
<a class="page_home" href=""></a>
<a class="page_pre" href=""></a>
<a class="page_num" href="">9</a>
<a class="page_num" href="">10</a>
<a class="page_num" href="">11</a>
<a class="page_next" href=""></a>
<a class="page_last" href=""></a>
</div>
<!--{"archetypes":"","card_type":"\u6548\u679c\u602a\u517d","id":2067,"lore":"\u8fd9\u5f20\u5361\u653b\u51fb\u7684\u573a\u5408\uff0c\u5bf9\u65b9\u76f4\u5230\u4f24\u5bb3\u6b65\u9aa4\u7ed3\u675f\u65f6\u4e0d\u80fd\u53d1\u52a8\u9b54\u6cd5\u00b7\u9677\u9631\u5361\u3002\u7528\u4ee5\u4e0b\u7684\u602a\u517d\u4e3a\u796d\u54c1\u4f5c\u796d\u54c1\u53ec\u5524\u7684\u573a\u5408\uff0c\u8fd9\u5f20\u5361\u5f97\u5230\u5404\u81ea\u7684\u6548\u679c\u3002\u25cf\u7eff\u9f7f\u8f6e\uff1a\u8fd9\u5f20\u5361\u653b\u51fb\u5b88\u5907\u8868\u793a\u602a\u517d\u65f6\uff0c\u82e5\u8fd9\u5f20\u5361\u7684\u653b\u51fb\u529b\u8d85\u8fc7\u5b88\u5907\u8868\u793a\u602a\u517d\u7684\u5b88\u5907\u529b\uff0c\u7ed9\u4e88\u5bf9\u65b9\u57fa\u672c\u5206\u90a3\u4e2a\u6570\u503c\u7684\u6218\u6597\u4f24\u5bb3\u3002\u25cf\u7ea2\u9f7f\u8f6e\uff1a\u7ed9\u4e88\u5bf9\u65b9\u73a9\u5bb6\u6218\u6597\u4f24\u5bb3\u65f6\uff0c\u7ed9\u4e88\u5bf9\u65b9\u57fa\u672c\u5206400\u5206\u4f24\u5bb3\u3002\u25cf\u9ec4\u9f7f\u8f6e\uff1a\u6218\u6597\u7834\u574f\u5bf9\u65b9\u602a\u517d\u7684\u573a\u5408\uff0c\u7ed9\u4e88\u5bf9\u65b9\u57fa\u672c\u5206600\u5206\u4f24\u5bb3\u3002","mediums":"OCG\tTCG","monster_atk":3000,"monster_attribute":"\u5730","monster_def":2000,"monster_level":8,"monster_type":null,"name":"\u53e4\u4ee3\u7684\u673a\u68b0\u5de8\u9f99","number":50933533,"stats":"21,26,37","status":3,"tokens":0,"type":"\u673a\u68b0"} -->
</div>
......@@ -533,6 +524,7 @@
<script src="/vendor/javascripts/jquery.i18n.properties-min-1.0.9.js"></script>
<script src="/vendor/javascripts/jquery-ui-1.9.1.custom.min.js"></script>
<script src="/vendor/javascripts/jquery.base64.min.js"></script>
<script src="/vendor/javascripts/easypaginate.js"></script>
<script src="/vendor/javascripts/hScrollPane.js"></script>
<script src="/vendor/javascripts/jscroll.js"></script>
<script src="/vendor/javascripts/json2.js"></script>
......
/*
* Easy Paginate 1.0 - jQuery plugin
* written by Alen Grakalic
* http://cssglobe.com/
*
* Copyright (c) 2011 Alen Grakalic (http://cssglobe.com)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* Built for jQuery library
* http://jquery.com
*
*/
(function($) {
$.fn.easyPaginate = function(options){
var defaults = {
step: 4,
delay: 100,
numeric: true,
nextprev: true,
auto:false,
loop:false,
pause:4000,
clickstop:true,
controls: 'pagination',
current: 'current',
randomstart: false
};
var options = $.extend(defaults, options);
var step = options.step;
var lower, upper;
var children = $(this).children();
var count = children.length;
var obj, next, prev;
var pages = Math.floor(count/step);
var page = (options.randomstart) ? Math.floor(Math.random()*pages)+1 : 1;
var timeout;
var clicked = false;
function show(){
clearTimeout(timeout);
lower = ((page-1) * step);
upper = lower+step;
$(children).each(function(i){
var child = $(this);
child.hide();
if(i>=lower && i<upper){ setTimeout(function(){ child.fadeIn('fast') }, ( i-( Math.floor(i/step) * step) )*options.delay ); }
if(options.nextprev){
if(upper >= count) { next.fadeOut('fast'); } else { next.fadeIn('fast'); };
if(lower >= 1) { prev.fadeIn('fast'); } else { prev.fadeOut('fast'); };
};
});
$('li','#'+ options.controls).removeClass(options.current);
$('li[data-index="'+page+'"]','#'+ options.controls).addClass(options.current);
if(options.auto){
if(options.clickstop && clicked){}else{ timeout = setTimeout(auto,options.pause); };
};
};
function auto(){
if(options.loop) if(upper >= count){ page=0; show(); }
if(upper < count){ page++; show(); }
};
this.each(function(){
obj = this;
if(count>step){
if((count/step) > pages) pages++;
var ol = $('<ol id="'+ options.controls +'"></ol>').insertAfter(obj);
if(options.nextprev){
prev = $('<li class="prev">Previous</li>')
.hide()
.appendTo(ol)
.click(function(){
clicked = true;
page--;
show();
});
};
if(options.numeric){
for(var i=1;i<=pages;i++){
$('<li data-index="'+ i +'">'+ i +'</li>')
.appendTo(ol)
.click(function(){
clicked = true;
page = $(this).attr('data-index');
show();
});
};
};
if(options.nextprev){
next = $('<li class="next">Next</li>')
.hide()
.appendTo(ol)
.click(function(){
clicked = true;
page++;
show();
});
};
show();
};
});
};
})(jQuery);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment