PageRenderTime 87ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/MVC/js/commented.js

https://github.com/GuggerJoel/mmready-test
JavaScript | 328 lines | 0 code | 2 blank | 326 comment | 0 complexity | 6d1df6db407690ca033fc0ba1b9d1219 MD5 | raw file
  1. //FROM main.js
  2. // //***************************************************************************//
  3. //******************* Blog Chabloz adapté musicians ***********************//
  4. //***************************************************************************//
  5. //var Instrument = MyModel.extend({});
  6. //
  7. // var guitar = new Instrument();
  8. //
  9. // var Instruments = MyCollection.extend({
  10. // url: URLSERVEURinstruSuccess,
  11. // model: Instrument,
  12. // comparator: function (instrument) {
  13. // return -instrument.get('createdAt');
  14. // }
  15. // });
  16. // var Musician = MyModelNestedCollection.extend({
  17. // nested: 'instruments',
  18. // urlRoot: URLSERVEURMusicianSuccess,
  19. // defaults: function () {
  20. // return {
  21. // instruments: new Instruments()
  22. // };
  23. // },
  24. // parse: function (response) {
  25. // if (typeof response.data != "undefined") {
  26. // response = response.data;
  27. // }
  28. // response.instruments = new Instruments(response.instruments);
  29. // return response;
  30. // }
  31. // });
  32. // var Musicians = MyCollection.extend({
  33. // url: URLSERVEURMusicianSuccess,
  34. // model: Musician,
  35. // parse: function (response) {
  36. // // si jsend, ne prend que les data
  37. // if (typeof response.data != 'undefined') {
  38. // response = response.data;
  39. // }
  40. // return response;
  41. // }
  42. // });
  43. //
  44. // var blog = new Musicians();
  45. //
  46. // blog.fetch({reset: true, success: function (collection, response, options) {
  47. // console.log("Fetch sur Musicians");
  48. // console.log(blog.models[0].get('instruments').at(0).get('name'));
  49. // blog.models[0].set('lastname', 'Cerantola');
  50. // console.log(blog.models[0].toJSON());
  51. // console.log(JSON.stringify(blog.models[0]));
  52. // blog.models[0].get('instruments').create({
  53. // text: 'This is something new',
  54. // musician_id: blog.models[0].id - 0
  55. // });
  56. // blog.models[0].save();
  57. // }});
  58. //
  59. //
  60. //
  61. //
  62. //
  63. //
  64. //
  65. //
  66. //
  67. //
  68. //
  69. //
  70. ////***************************************************************************//
  71. ////******************* Appel fetch ***********************//
  72. ////***************************************************************************//
  73. //
  74. //
  75. //
  76. //
  77. //
  78. ////
  79. ////
  80. ////var Musicians = MyCollection.extend({
  81. //// model: Musician
  82. ////});
  83. ////
  84. ////
  85. ////var Artist = MyModelNestedCollection.extend({
  86. //// nested: 'musicians',
  87. ////// defaults: function () {return {
  88. ////// musicians: new Musicians()
  89. ////// }},
  90. ////initialize: function(){
  91. //// console.log("Nouvel Artist créé. Name: "+this.get('name'));
  92. //// },
  93. //// parse: function (response) {
  94. //// if (typeof response.data != "undefined") {
  95. //// response = response.data;
  96. //// }
  97. //// response.musicians = new Musicians(response.musicians);
  98. //// return response;
  99. //// }
  100. ////});
  101. ////
  102. ////
  103. ////var Artists = MyCollection.extend({
  104. //// url: "URLallArtists",
  105. //// model: Artist
  106. ////});
  107. ////
  108. ////
  109. ////
  110. ////
  111. ////var Event = MyModelNestedCollection.extend({
  112. //// nested: 'artists',
  113. ////// defaults: function () {return {
  114. ////// artists: new Artists()
  115. ////// }},
  116. ////initialize: function(){
  117. //// console.log("Nouvel Event créé. Name: "+this.get('name'));
  118. //// },
  119. //// parse: function (response) {
  120. //// if (typeof response.data != "undefined") {
  121. //// response = response.data;
  122. //// }
  123. //// response.artists = new Artists()(response.artists);
  124. //// return response;
  125. //// }
  126. ////});
  127. ////var Events = MyCollection.extend({
  128. //// url: URLSERVEUR_EVENTsuccess,
  129. //// model: Event
  130. ////});
  131. ////
  132. ////
  133. ////
  134. //////var Evenement = MyModelNestedCollection.extend({
  135. ////// nested: 'artists',
  136. ////// defaults: function () {return {
  137. ////// artists: new Artists()
  138. ////// }}
  139. //////});
  140. //////
  141. //////var Evenements = MyCollection.extend({
  142. ////// url: URLSERVEURsuccess,
  143. ////// model: Evenement,
  144. ////// //je fais le lien avec le model
  145. ////// comparator: function(event) {
  146. ////// return -event.get('name');
  147. ////// conlole.log(Evenement.get('name'));
  148. ////// },
  149. ////// initialize: function() {
  150. ////// var that = this;
  151. ////// setInterval(function() {
  152. ////// that.fetch();
  153. ////// }, 10000)
  154. //////
  155. ////// }
  156. //////});
  157. ////
  158. ////
  159. //////***************************************************************************//
  160. //////******************* new ***********************//
  161. //////***************************************************************************//
  162. ////
  163. ////
  164. ////
  165. ////
  166. //////var guitar = new Instrument({"name":"Guitar"});
  167. ////var bass = new Instrument({"name":"Bass"});
  168. ////bass.set("name","BASS");
  169. ////bass.set("nb_corde","4");
  170. ////
  171. ////
  172. //////**** test si la validation fonctionne *************
  173. //////***************************************************
  174. ////
  175. ////
  176. ////console.log("************************");
  177. ////console.log("Début: test si la validation fonctionne");
  178. ////console.log("************************");
  179. ////
  180. ////var guitar = new Instrument({"name":"Guitar"});
  181. ////
  182. ////console.log("L'objet en JSON : "+JSON.stringify(guitar));
  183. ////
  184. ////var mess = guitar.unset("name", {validate:true});
  185. ////console.log("Après l'action unset sur 'name' le message de retour :" +mess);
  186. ////console.log("Aperçu de l'attribut : " +guitar.get("name"));
  187. ////
  188. ////
  189. ////console.log("************************");
  190. ////console.log("Fin: test si la validation fonctionne");
  191. ////console.log("******** oui elle fonctionne *******");
  192. ////
  193. //////***************************************************
  194. //////***************************************************
  195. ////
  196. ////var musician1 = new Musician({'name': 'Romain'});
  197. ////musician1.get('instruments').add(bass);
  198. ////var musician2 = new Musician({'name': 'Clélia'});
  199. ////musician2.get('instruments').add(vocal);
  200. ////
  201. ////var mmready = new Artist({'name': 'mmready()'});
  202. ////mmready.get('musicians').add([musician1, musician2]);
  203. ////var zed = new Artist({'name': 'ZED'});
  204. ////
  205. ////
  206. ////var event1 = new Event({name: 'La grosse fiesta 2014'});
  207. ////event1.get('artists').add([mmready, zed]);
  208. //////var event2 = new Event({title: 'Why so serious Party!'});
  209. ////
  210. ////
  211. ////var listOfEvents1 = new Events([event1]);
  212. ////
  213. ////console.log('***************************************');
  214. ////console.log('***************************************');
  215. ////console.log(listOfEvents1.toJSON());
  216. ////console.log(JSON.stringify(listOfEvents1));
  217. ////
  218. ////console.log('***************************************');
  219. ////console.log('***************************************');
  220. ////
  221. ////var francais = new LangFR();
  222. ////
  223. ////var francais2 = francais.fetch(
  224. ////
  225. //// {
  226. //// success: function(model, response, options){
  227. //// console.log('Fetch langue success');
  228. //// return response;
  229. //// },
  230. //// error: function(model, response, options){
  231. //// console.log('Fetch langue error');
  232. //// console.log(model);
  233. //// console.log(response);
  234. //// console.log(options);
  235. //// },
  236. //// fail: function(model, response, options){
  237. //// console.log('Fetch langue fail');
  238. //// }
  239. ////}
  240. ////
  241. //// );
  242. ////console.log("Test LANGUAGE ////////////////////////////////// L'objet : " +JSON.stringify(francais2));
  243. ////
  244. ////
  245. //////*********** test Fetch sur un model
  246. ////bass.fetch({
  247. //// success: function(model, response, options){
  248. //// console.log('Fetch instrument success');
  249. //// },
  250. //// error: function(model, response, options){
  251. //// console.log('Fetch error');
  252. //// console.log(model);
  253. //// console.log(response);
  254. //// console.log(options);
  255. //// },
  256. //// fail: function(model, response, options){
  257. //// console.log('Fetch instrument fail');
  258. //// }
  259. ////});
  260. ////
  261. ////
  262. //////var drum = new Instrument({"name":"Drum"});
  263. ////var vocal = new Instrument({"name":"Vocal"});
  264. //////var synth = new Instrument({"name":"Synth"});
  265. ////
  266. ////
  267. ////
  268. ////
  269. //
  270. //
  271. //
  272. //
  273. //
  274. //
  275. // -------------------------------------------------------------------
  276. // // FROM myNestedCollection
  277. ////var MyCollection = Backbone.Collection.extend();
  278. //var MyModel = Backbone.Model.extend();
  279. //
  280. //
  281. //
  282. //var MyModelNestedCollection = Backbone.Model.extend({
  283. // nested: 'collection',
  284. // initialize: function(attrs, options) {
  285. // this.get(this.nested).on('change', function() {
  286. // this.trigger('change', this);
  287. // }, this);
  288. // },
  289. // toJSON: function() {
  290. // var colObj = {};
  291. // colObj[this.nested] = this.get(this.nested).toJSON();
  292. // return _.extend(
  293. // Backbone.Model.prototype.toJSON.apply(this, arguments),
  294. // colObj
  295. // );
  296. //
  297. // }
  298. //
  299. //});
  300. //
  301. //
  302. //var eventsNested = MyModelNestedCollection.extend();
  303. //var artists = MyModelNestedCollection.extend();
  304. //
  305. //
  306. //
  307. //
  308. //var eventModel = MyModel.extend();
  309. //
  310. //
  311. //
  312. // var allEvents = MyCollection.extend({
  313. // url: URLSERVEURsuccess,
  314. // model: eventModel, //je fais le lien avec le model
  315. // events: new eventsNested(),
  316. // initialize: function() {
  317. //
  318. // console.log("La collection events est cr��e");
  319. // var that = this;//astuce car "this" se perd trop profond dans anonymous function
  320. // setInterval(function() {
  321. // that.fetch();
  322. // }, 10000);
  323. // }
  324. //
  325. // });
  326. //------------------------------------------------------------------