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

fix

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