--- a
+++ b/compass-app/platforms/android/assets/www/js/app-old.js
@@ -0,0 +1,347 @@
+App = Ember.Application.create();
+
+
+App.ApplicationAdapter = DS.LSAdapter.extend({
+ namespace: 'compass'
+});
+
+DS.LSAdapter.create({
+ namespace: 'compass-store'
+});
+
+//creating models
+
+App.Animation = DS.Model.extend({
+ animation: DS.attr('string') // css string from animate.css
+});
+
+App.Question = DS.Model.extend({
+ detail : DS.attr('string'), // question text
+ nextQNo: DS.belongsTo('question'), // id of next question if no is selected
+ nextQYes: DS.belongsTo('question'), // id of next questions if yes is selected
+ stopNo: DS.belongsTo('stop'), // id of stop if no is selected
+ stopYes: DS.belongsTo('stop'), // id of stop if yes is selected
+ animation: DS.belongsTo('animation') //
+});
+
+App.Stop = DS.Model.extend({
+ detail : DS.attr('string'), // stop text
+ nextQ : DS.belongsTo('question'), // id of next question if is required
+ licence: DS.attr(), // id of license if reached
+ animation: DS.belongsTo('animation') //
+});
+
+//model to record users route through the app
+
+App.Choice = DS.Model.extend({
+ question: DS.attr('string'),
+ selectY: DS.attr('string'),
+ selectN: DS.attr('string')
+});
+
+//pushing models into store
+
+App.ApplicationRoute = Ember.Route.extend({
+
+ model: function() {
+
+ //adding animations to store
+ //animations use animate.css
+ this.store.push('animation', {
+ id: 1,
+ animation: "animated bounceIn "
+
+ });
+
+ this.store.push('animation', {
+ id: 2,
+ animation: "animated slideInLeft"
+
+ });
+
+ this.store.push('animation', {
+ id: 3,
+ animation: "animated slideInRight"
+
+ });
+
+ // Adding Questions to store
+ this.store.push('question', {
+ id: 1,
+ detail: "Did you create software?",
+ nextQYes: 2,
+ nextQNo: 3,
+ animation: 1
+ });
+
+ this.store.push('question', {
+ id: 2,
+ detail: "Do you hold copyright?",
+ stopNo: 1,
+ stopYes: 2,
+ animation: 2
+ });
+
+ this.store.push('question', {
+ id: 3,
+ detail: "Have you obtained rights to code?",
+ nextQYes:4,
+ stopNo: 1,
+ animation: 3
+ });
+
+ this.store.push('question', {
+ id: 4,
+ detail: "Do you want to share source?",
+ stopNo: 3,
+ stopYes: 4,
+ animation: 1
+ });
+
+ this.store.push('question', {
+ id: 5,
+ detail: "Should any future distributions be required to use your licence choice?",
+ stopNo: 6,
+ stopYes: 5,
+ animation: 2
+ });
+
+ this.store.push('question', {
+ id: 6,
+ detail: "May users distribute their extensions and modifications on a different licence ?",
+ stopNo: 7,
+ stopYes: 8,
+ animation: 3
+
+ });
+
+ this.store.push('question', {
+ id: 7,
+ detail: "May the code be proprieterised?",
+ nextQNo: 8,
+ animation: 1
+ });
+
+ this.store.push('question', {
+ id: 8,
+ detail: "Do you require attribution?",
+ animation: 2
+ });
+
+ //adding stops to store
+ this.store.push('stop', {
+ id: 1,
+ detail: "May not grant a licence!",
+ animation: 3
+ });
+
+ this.store.push('stop', {
+ id: 2,
+ detail: "You may licence copyright",
+ nextQ: 4 ,
+ animation: 1
+ });
+
+ this.store.push('stop', {
+ id: 3,
+ detail: "Not suitable for FOSS final proprietary licence",
+ animation: 2
+ });
+
+ this.store.push('stop', {
+ id: 4,
+ detail: "FOSS licence is appropriate",
+ nextQ: 5,
+ animation: 3
+ });
+
+ this.store.push('stop', {
+ id: 5,
+ detail: "Copyleft = vial effect",
+ nextQ: 6,
+ animation: 1
+ });
+
+ this.store.push('stop', {
+ id: 6,
+ detail: "Permissive",
+ nextQ: 7,
+ animation: 2
+
+ });
+
+ this.store.push('stop', {
+ id: 7,
+ detail: "Strong Copyleft",
+ animation: 3
+
+ });
+
+ this.store.push('stop', {
+ id: 8,
+ detail: "Weak Copyleft",
+ animation: 1
+
+ });
+
+ }
+});
+
+App.Router.map(function() {
+ // put your routes here
+
+ this.route("animations");
+ this.route("questions");
+ this.route("choices");
+ this.resource('question', { path: '/question/:question_id' });
+ this.resource('stop', { path: '/stop/:stop_id' });
+
+});
+
+App.AnimationsRoute = Ember.Route.extend({
+ model: function(){
+ return this.store.find('animation');
+ }
+})
+
+App.QuestionsRoute = Ember.Route.extend({
+ model: function() {
+ return this.store.find('question');
+ }//,
+ //setupController: function(controller, question) {
+ //controller.set('model', question);
+ //}
+});
+
+App.QuestionRoute = Ember.Route.extend({
+ model: function(params) {
+ return this.store.find('question', params.question_id);
+}
+});
+
+
+App.stopRoute = Ember.Route.extend({
+ model: function(params) {
+ return this.store.find('stop', params.stop_id);
+ }
+});
+
+App.ChoicesRoute = Ember.Route.extend({
+ model: function() {
+ return this.store.find('choice');
+ }
+});
+
+App.IndexController = Ember.ObjectController.extend({
+
+ actions:{
+ begin : function(){
+
+ this.get('store').findAll('choice').then(function(record){
+ record.content.forEach(function(rec) {
+ Ember.run.once(this, function() {
+ rec.deleteRecord();
+ rec.save();
+ });
+ }, this);
+ });
+
+
+ this.transitionToRoute('question', 1)
+
+
+ }
+}
+
+});
+
+
+App.QuestionController = Ember.ObjectController.extend({
+
+ actions:{
+ selectYes: function(){
+
+ var choice = this.store.createRecord('choice', {
+ selectY: 'Yes',
+ question: this.get('model.detail')
+ });
+
+ choice.save();
+
+ var qId = this.get('model.nextQYes.id');
+ if(qId == null)
+ {
+ var sId = this.get('model.stopYes');
+ this.transitionToRoute('stop', sId);
+ }
+ else
+ {
+ this.transitionToRoute('question', qId);
+ }
+ },
+
+ selectNo: function(){
+
+ var choice = this.store.createRecord('choice', {
+ selectN: 'No',
+ question: this.get('model.detail')
+ });
+
+ choice.save();
+
+ var qId = this.get('model.nextQNo.id');
+ if(qId == null)
+ {
+ var sId = this.get('model.stopNo');
+ this.transitionToRoute('stop', sId);
+ }
+ else
+ {
+ this.transitionToRoute('question', qId);
+ }
+ }
+}
+});
+
+App.StopController = Ember.ObjectController.extend({
+
+ actions:{
+
+ stopAction: function(){
+
+ var choice = this.store.createRecord('choice', {
+ question: this.get('model.detail')
+ });
+
+ choice.save();
+
+ var qId = this.get('model.nextQ');
+
+ if(qId == null)
+ {
+
+ this.get('store').findAll('choice').then(function(record){
+ record.content.forEach(function(rec) {
+ Ember.run.once(this, function() {
+ rec.deleteRecord();
+ rec.save();
+ });
+ }, this);
+ });
+
+
+ this.transitionToRoute('question', 1)
+
+ }
+ else
+ {
+ this.transitionToRoute('question', qId);
+ }
+
+ }
+
+
+
+ }
+
+});