From 63320bad55de421a1a2cf225005d3a63ff5a1d88 Mon Sep 17 00:00:00 2001 From: exane Date: Mon, 22 Jun 2015 17:29:01 +0200 Subject: [PATCH] add proper templates --- client/index.html | 239 ---------------------- client/js/client.js | 34 +-- client/templates/battle.handlebars | 128 ++++++++++++ client/templates/cards.handlebars | 3 + client/templates/info.handlebars | 23 +++ client/templates/lobby.handlebars | 23 +++ client/templates/modal.handlebars | 13 ++ client/templates/modal.medic.handlebars | 13 ++ client/templates/multipleCards.handlebars | 6 + client/templates/preview.handlebars | 1 + gulpfile.js | 2 + package.json | 1 + public/index.html | 239 ---------------------- server/Battle.js | 13 +- 14 files changed, 232 insertions(+), 506 deletions(-) create mode 100644 client/templates/battle.handlebars create mode 100644 client/templates/cards.handlebars create mode 100644 client/templates/info.handlebars create mode 100644 client/templates/lobby.handlebars create mode 100644 client/templates/modal.handlebars create mode 100644 client/templates/modal.medic.handlebars create mode 100644 client/templates/multipleCards.handlebars create mode 100644 client/templates/preview.handlebars diff --git a/client/index.html b/client/index.html index f8811de..4773550 100644 --- a/client/index.html +++ b/client/index.html @@ -9,245 +9,6 @@ - - - - - - - diff --git a/client/js/client.js b/client/js/client.js index 65a1a3a..f8bb2a2 100644 --- a/client/js/client.js +++ b/client/js/client.js @@ -8,19 +8,6 @@ var $ = require("jquery"); window.$ = $; -Handlebars.registerHelper("health", function(lives, options){ - var out = ""; - - for(var i = 0; i < 2; i++) { - out += "' + - '' + - ''), - templateCards: Handlebars.compile('{{#each this}}' + - '
' + - '{{#if boost}}+{{boost}}{{/if}}' + - '' + - '
' + - '{{/each}}'), + template: require("../templates/cards.handlebars"), + templateCards: require("../templates/multipleCards.handlebars"), initialize: function(options){ var self = this; this.side = options.side; @@ -231,8 +211,8 @@ var calculateCardMargin = function($selector, totalWidth, cardWidth, n){ var BattleView = Backbone.View.extend({ className: "container", - template: Handlebars.compile($("#battle-template").html()), - templatePreview: Handlebars.compile($("#preview-template").html()), + template: require("../templates/battle.handlebars"), + templatePreview: require("../templates/preview.handlebars"), initialize: function(options){ var self = this; var user = this.user = options.user; @@ -481,7 +461,7 @@ var BattleView = Backbone.View.extend({ }); var Modal = Backbone.Modal.extend({ - template: Handlebars.compile($("#modal-template").html()), + template: require("../templates/modal.handlebars"), cancelEl: ".bbm-close", cancel: function(){ this.model.set("openDiscard", false); @@ -489,7 +469,7 @@ var Modal = Backbone.Modal.extend({ }); var MedicModal = Modal.extend({ - template: Handlebars.compile($("#modal-medic-template").html()), + template: require("../templates/modal.medic.handlebars"), events: { "click .card": "onCardClick" }, @@ -608,7 +588,7 @@ var Lobby = Backbone.View.extend({ }, className: "container", - template: Handlebars.compile($("#matchmaker-template").html()), + template: require("../templates/lobby.handlebars"), initialize: function(options){ this.user = options.user; this.app = options.app; diff --git a/client/templates/battle.handlebars b/client/templates/battle.handlebars new file mode 100644 index 0000000..072c25b --- /dev/null +++ b/client/templates/battle.handlebars @@ -0,0 +1,128 @@ +
+
+
+
+
+
+
Points:
+
0
+
+
+
Hand:
+
0
+
+
+
+ + +
+
+
+
Passed
+
+
+
+
+ field +
+
+
{{name}}
+
+
+
+
Points:
+
{{score}}
+
+
+
Hand:
+
{{hand}}
+
+
+
+ +
+
+
+
Passed
+
+
+
+ +
+
+
+
+
+
+
+
+
+
0
+
+
+
+
+
+
0
+
+
+
+
+
+
0
+
+
+
+
+
+
+
+
+
0
+
+
+
+
+
+
0
+
+
+
+
+
+
0
+
+
+
+
+
+
+ {{#each cards}} +
+ +
+ {{/each}} +
+
+
+
+
+ +
+
+
+ discard deck +
+
+ main deck +
+
+
+
+ discard deck +
+
+ main deck +
+
+
\ No newline at end of file diff --git a/client/templates/cards.handlebars b/client/templates/cards.handlebars new file mode 100644 index 0000000..260ec08 --- /dev/null +++ b/client/templates/cards.handlebars @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/client/templates/info.handlebars b/client/templates/info.handlebars new file mode 100644 index 0000000..b5f06fd --- /dev/null +++ b/client/templates/info.handlebars @@ -0,0 +1,23 @@ +
+
{{name}}
+
+
+
+
Points:
+
{{score}}
+
+
+
Hand:
+
{{hand}}
+
+
+
+ {{#health}} + {{/health}} +
+
+
+
Passed
+
+
+
\ No newline at end of file diff --git a/client/templates/lobby.handlebars b/client/templates/lobby.handlebars new file mode 100644 index 0000000..0349e6c --- /dev/null +++ b/client/templates/lobby.handlebars @@ -0,0 +1,23 @@ +
+
+
Gwent
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
\ No newline at end of file diff --git a/client/templates/modal.handlebars b/client/templates/modal.handlebars new file mode 100644 index 0000000..d91f4c8 --- /dev/null +++ b/client/templates/modal.handlebars @@ -0,0 +1,13 @@ +
+

Discard of {{openDiscard.name}}

+
+
+ {{#each openDiscard.discard}} +
+ +
+ {{/each}} +
+
+
close
+
\ No newline at end of file diff --git a/client/templates/modal.medic.handlebars b/client/templates/modal.medic.handlebars new file mode 100644 index 0000000..c014dd9 --- /dev/null +++ b/client/templates/modal.medic.handlebars @@ -0,0 +1,13 @@ +
+

Choose one card from your discard

+
+
+ {{#each medicDiscard.cards}} +
+ +
+ {{/each}} +
+
+
close
+
\ No newline at end of file diff --git a/client/templates/multipleCards.handlebars b/client/templates/multipleCards.handlebars new file mode 100644 index 0000000..3fd3bd6 --- /dev/null +++ b/client/templates/multipleCards.handlebars @@ -0,0 +1,6 @@ +{{#each this}} +
+ {{#if boost}}+{{boost}}{{/if}} + +
+{{/each}} \ No newline at end of file diff --git a/client/templates/preview.handlebars b/client/templates/preview.handlebars new file mode 100644 index 0000000..20a8111 --- /dev/null +++ b/client/templates/preview.handlebars @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index dbd8527..afe405c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,6 +5,7 @@ var fs = require("fs"); var babelify = require("babelify"); var livereload = require("gulp-livereload"); var sass = require("gulp-sass"); +var handlebars = require("browserify-handlebars"); livereload({start: true}); //fast install @@ -13,6 +14,7 @@ livereload({start: true}); gulp.task('browserify', function(){ browserify('./client/js/main.js', {standalone: "app", debug: true}) + .transform(handlebars) .transform(babelify) .bundle().on("error", function(err){ console.log(err); diff --git a/package.json b/package.json index 261a9d8..3de8d8f 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "devDependencies": { "babelify": "^6.1.2", "browserify": "^10.2.4", + "browserify-handlebars": "^1.0.0", "gulp": "^3.9.0", "gulp-livereload": "^3.8.0", "gulp-sass": "^2.0.1", diff --git a/public/index.html b/public/index.html index f8811de..4773550 100644 --- a/public/index.html +++ b/public/index.html @@ -9,245 +9,6 @@ - - - - - - - diff --git a/server/Battle.js b/server/Battle.js index 5c4a1bc..c424190 100644 --- a/server/Battle.js +++ b/server/Battle.js @@ -61,9 +61,20 @@ var Battle = (function(){ this.p2.setLeadercard(); this.p1.draw(10); this.p2.draw(10); + /*this.p1.hand.add(Card("commanders_horn")); + this.p2.hand.add(Card("commanders_horn")); + this.p1.hand.add(Card("milva")); + this.p2.hand.add(Card("milva")); + this.p1.hand.add(Card("havekar_healer")); + this.p2.hand.add(Card("havekar_healer")); + this.p1.hand.add(Card("toruviel")); + this.p2.hand.add(Card("toruviel")); + this.p1.hand.add(Card("vrihedd_brigade_recruit")); + this.p2.hand.add(Card("vrihedd_brigade_recruit")); + this.p1.hand.add(Card("impenetrable_fog")); + this.p2.hand.add(Card("impenetrable_fog"));*/ /* this.p1.hand.add(Card("commanders_horn")); - this.p2.hand.add(Card("commanders_horn")); this.p1.hand.add(Card("commanders_horn")); this.p2.hand.add(Card("commanders_horn"));*/ /*