Commit e3ba9477 authored by 神楽坂玲奈's avatar 神楽坂玲奈

fix

parent 72e2aa46
...@@ -160,7 +160,7 @@ class Deck extends Spine.Model ...@@ -160,7 +160,7 @@ class Deck extends Spine.Model
if !line or line.charAt(0) == '#' if !line or line.charAt(0) == '#'
continue continue
else if line.substr(0, 5) == '!side' else if line.substr(0, 5) == '!side'
card_usages.push {card_id: last_id, side: side, count: count} if last_id card_usages.push {id: "#{result.cid}_#{side}_#{last_id}", card_id: last_id, side: side, count: count} if last_id
side = true side = true
last_id = null last_id = null
else else
...@@ -290,7 +290,12 @@ class DecksController extends Spine.Controller ...@@ -290,7 +290,12 @@ class DecksController extends Spine.Controller
load_from_url: (url)-> load_from_url: (url)->
try try
decks.deck Deck.decode $.url(url).param('cards'), $.url().param('name') #there is a bug in old version deck editor.
cards_param = $.url(url).param('cards')
if cards_param.indexOf('*') >= 0
cards_param = cards_param.replace /[\*\-]/g, (char)-> {'*':'-', '-':'_'}[char]
decks.deck Deck.decode cards_param, $.url().param('name')
catch error catch error
alert error alert error
...@@ -368,20 +373,14 @@ class CardsController extends Spine.Controller ...@@ -368,20 +373,14 @@ class CardsController extends Spine.Controller
decks = new DecksController(el: $("#deck")) decks = new DecksController(el: $("#deck"))
cards = new CardsController(el: $("#search_cards")) cards = new CardsController(el: $("#search_cards"))
#there is a bug in old version deck editor. decks.load_from_url()
competition_convert = {'*':'-', '-':'_'}
if document.location.href.indexOf('*') >= 0
location.href = document.location.href.replace /[\*\-]/g, (char)-> competition_convert[char]
$(document).ready ->
decks.load_from_url()
$('#search').submit -> $('#search').submit ->
cards.search $('.search_input').val() cards.search $('.search_input').val()
return false return false
#dialog #dialog
$("#deck_share_dialog").dialog $("#deck_share_dialog").dialog
modal: true modal: true
autoOpen: $.url().attr('fragment') == 'share' autoOpen: $.url().attr('fragment') == 'share'
width: 600 width: 600
...@@ -390,18 +389,18 @@ $(document).ready -> ...@@ -390,18 +389,18 @@ $(document).ready ->
$("#deck_url")[0].select() $("#deck_url")[0].select()
$("#deck_url_qrcode").attr 'src', 'https://chart.googleapis.com/chart?chs=171x171&cht=qr&chld=|0&chl=' + encodeURIComponent(decks.deck().url()) $("#deck_url_qrcode").attr 'src', 'https://chart.googleapis.com/chart?chs=171x171&cht=qr&chld=|0&chl=' + encodeURIComponent(decks.deck().url())
$("#drop_upload_dialog").dialog $("#drop_upload_dialog").dialog
dialogClass: 'drop_upload' dialogClass: 'drop_upload'
draggable: false draggable: false
resizable: false resizable: false
modal: true modal: true
autoOpen: false autoOpen: false
#share #share
$('#deck_share').click -> $('#deck_share').click ->
$("#deck_share_dialog").dialog('open') $("#deck_share_dialog").dialog('open')
$('#deck_url_shorten').click -> $('#deck_url_shorten').click ->
$('#deck_url_shorten').attr "disabled", true $('#deck_url_shorten').attr "disabled", true
$.ajax $.ajax
url: 'https://www.googleapis.com/urlshortener/v1/url' url: 'https://www.googleapis.com/urlshortener/v1/url'
...@@ -413,32 +412,32 @@ $(document).ready -> ...@@ -413,32 +412,32 @@ $(document).ready ->
$("#deck_url")[0].select() $("#deck_url")[0].select()
$('#deck_url_shorten').attr "disabled", false $('#deck_url_shorten').attr "disabled", false
#upload #upload
$('#deck_load').change -> $('#deck_load').change ->
decks.upload(@files) decks.upload(@files)
$(window).bind 'popstate', (ev)-> $(window).bind 'popstate', (ev)->
if ev.state if ev.state
deck.refresh ev.state, false deck.refresh ev.state, false
$('.main_div').bind 'dragover', (ev)-> $('.main_div').bind 'dragover', (ev)->
ev.preventDefault(); ev.preventDefault();
#$("#drop_upload_dialog").dialog('open') #$("#drop_upload_dialog").dialog('open')
$('.main_div').bind 'drop', (ev)-> $('.main_div').bind 'drop', (ev)->
ev.preventDefault(); ev.preventDefault();
$("#drop_upload_dialog").dialog('close') $("#drop_upload_dialog").dialog('close')
decks.upload event.dataTransfer.files decks.upload event.dataTransfer.files
$(".switch").click -> $(".switch").click ->
$(".text,.graphic").toggleClass("graphic text") $(".text,.graphic").toggleClass("graphic text")
decks.render() decks.render()
$.i18n.properties $.i18n.properties
name: 'card' name: 'card'
path: '/locales/' path: '/locales/'
mode: 'map' mode: 'map'
cache: true cache: true
addthis.init() addthis.init()
\ No newline at end of file \ No newline at end of file
// Generated by CoffeeScript 1.6.2 // Generated by CoffeeScript 1.6.2
(function() { (function() {
var Card, CardUsage, CardsController, Deck, DecksController, cards, competition_convert, decks, locale, _ref, _ref1, _ref2, _ref3, _ref4, var Card, CardUsage, CardsController, Deck, DecksController, cards, decks, locale, _ref, _ref1, _ref2, _ref3, _ref4,
__hasProp = {}.hasOwnProperty, __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; }, __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; }, __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; },
...@@ -392,6 +392,7 @@ ...@@ -392,6 +392,7 @@
} else if (line.substr(0, 5) === '!side') { } else if (line.substr(0, 5) === '!side') {
if (last_id) { if (last_id) {
card_usages.push({ card_usages.push({
id: "" + result.cid + "_" + side + "_" + last_id,
card_id: last_id, card_id: last_id,
side: side, side: side,
count: count count: count
...@@ -641,10 +642,19 @@ ...@@ -641,10 +642,19 @@
}; };
DecksController.prototype.load_from_url = function(url) { DecksController.prototype.load_from_url = function(url) {
var error; var cards_param, error;
try { try {
return decks.deck(Deck.decode($.url(url).param('cards'), $.url().param('name'))); cards_param = $.url(url).param('cards');
if (cards_param.indexOf('*') >= 0) {
cards_param = cards_param.replace(/[\*\-]/g, function(char) {
return {
'*': '-',
'-': '_'
}[char];
});
}
return decks.deck(Deck.decode(cards_param, $.url().param('name')));
} catch (_error) { } catch (_error) {
error = _error; error = _error;
return alert(error); return alert(error);
...@@ -852,23 +862,13 @@ ...@@ -852,23 +862,13 @@
el: $("#search_cards") el: $("#search_cards")
}); });
competition_convert = {
'*': '-',
'-': '_'
};
if (document.location.href.indexOf('*') >= 0) {
location.href = document.location.href.replace(/[\*\-]/g, function(char) {
return competition_convert[char];
});
}
$(document).ready(function() {
decks.load_from_url(); decks.load_from_url();
$('#search').submit(function() { $('#search').submit(function() {
cards.search($('.search_input').val()); cards.search($('.search_input').val());
return false; return false;
}); });
$("#deck_share_dialog").dialog({ $("#deck_share_dialog").dialog({
modal: true, modal: true,
autoOpen: $.url().attr('fragment') === 'share', autoOpen: $.url().attr('fragment') === 'share',
...@@ -879,6 +879,7 @@ ...@@ -879,6 +879,7 @@
return $("#deck_url_qrcode").attr('src', 'https://chart.googleapis.com/chart?chs=171x171&cht=qr&chld=|0&chl=' + encodeURIComponent(decks.deck().url())); return $("#deck_url_qrcode").attr('src', 'https://chart.googleapis.com/chart?chs=171x171&cht=qr&chld=|0&chl=' + encodeURIComponent(decks.deck().url()));
} }
}); });
$("#drop_upload_dialog").dialog({ $("#drop_upload_dialog").dialog({
dialogClass: 'drop_upload', dialogClass: 'drop_upload',
draggable: false, draggable: false,
...@@ -886,9 +887,11 @@ ...@@ -886,9 +887,11 @@
modal: true, modal: true,
autoOpen: false autoOpen: false
}); });
$('#deck_share').click(function() { $('#deck_share').click(function() {
return $("#deck_share_dialog").dialog('open'); return $("#deck_share_dialog").dialog('open');
}); });
$('#deck_url_shorten').click(function() { $('#deck_url_shorten').click(function() {
$('#deck_url_shorten').attr("disabled", true); $('#deck_url_shorten').attr("disabled", true);
return $.ajax({ return $.ajax({
...@@ -905,33 +908,39 @@ ...@@ -905,33 +908,39 @@
} }
}); });
}); });
$('#deck_load').change(function() { $('#deck_load').change(function() {
return decks.upload(this.files); return decks.upload(this.files);
}); });
$(window).bind('popstate', function(ev) { $(window).bind('popstate', function(ev) {
if (ev.state) { if (ev.state) {
return deck.refresh(ev.state, false); return deck.refresh(ev.state, false);
} }
}); });
$('.main_div').bind('dragover', function(ev) { $('.main_div').bind('dragover', function(ev) {
return ev.preventDefault(); return ev.preventDefault();
}); });
$('.main_div').bind('drop', function(ev) { $('.main_div').bind('drop', function(ev) {
ev.preventDefault(); ev.preventDefault();
$("#drop_upload_dialog").dialog('close'); $("#drop_upload_dialog").dialog('close');
return decks.upload(event.dataTransfer.files); return decks.upload(event.dataTransfer.files);
}); });
$(".switch").click(function() { $(".switch").click(function() {
$(".text,.graphic").toggleClass("graphic text"); $(".text,.graphic").toggleClass("graphic text");
return decks.render(); return decks.render();
}); });
$.i18n.properties({ $.i18n.properties({
name: 'card', name: 'card',
path: '/locales/', path: '/locales/',
mode: 'map', mode: 'map',
cache: true cache: true
}); });
return addthis.init();
}); addthis.init();
}).call(this); }).call(this);
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