Ember. JS is the most powerful JavaScript MVC Framework today. When a bearded man ran into the JS community to do this, it showed the arrival of the JS heyday.
You may have heard of the well-known frameworks supported by jquery in javascriptmvc. JS, or the more popular backbone, but they are eclipsed by Ember. js. However, it seems very high-end and many people are scared away. As rich applications become increasingly popular today, more and more work has been transferred to the front-end, and JavaScript code has become very large, so organizing them is a challenge. If the company uses a powerful UI framework such as Ext, this can be avoided. However, many companies can only play with jquery, which is a powerful tool for coding. This is also a special feature. Jquery is easy to get started, so its developers are mixed. Of course, this is relative to foreign countries. Considering the cost and Chinese characteristics in China, the quality of front-end personnel is very poor, the jquery code they wrote is very difficult to maintain. Therefore, we need to introduce norms and measures. MVC is undoubtedly the most reliable option. If you write your business code and UI according to MVC rules, all rules can be followed, which greatly reduces the maintenance cost.
Some people say that the framework will turn programmers into code farmers who fill in blank questions. The strong constraint of MVC makes programmers become pipeline workers. Migrant workers can only make some products, but they can assemble precision instruments. Happy! Front-end coders! You have now upgraded the main pillar of the proletarian society-pipeline workers! You will understand why back-end programmers are so high, because they have achieved success under the great framework of Java, C #, C ++, and Java ten years ago! Compared with the back-end industrial countries, the front-end countries are poor like the African tribal Emirates. Even if jquery is present, it only turns the tribe into the people of Pharaoh.
If ('undefined' === typeof ember) {ember ={}; // If ('undefined '! = Typeof window) {window. em = Window. ember = em = ember;} Ember. isnamespace = true; Ember. tostring = function () {return "Ember" ;}; Ember. version = '0. 9.8.1 '; Ember. ENV = 'undefined' = typeof env? {}: ENV; // determines whether to cache the calculated value. You can use volatile to disable it from Ember. cp_default_cacheable = (Ember. Env. cp_default_cacheable! = False); Ember. view_preserves_context = (Ember. Env. view_preserves_context! = False); Ember. k = function () {return this ;}; // debug related if ('undefined' === typeof Ember. assert) {Ember. assert = Ember. k;} If ('undefined' = typeof Ember. warn) {Ember. warn = Ember. k;} If ('undefined' = typeof Ember. deprecate) {Ember. deprecate = Ember. k;} If ('undefined' = typeof Ember. deprecatefunc) {Ember. deprecatefunc = function (_, func) {return func ;};}// forward compatibility if ('undefined' === typeof embe R_assert) {window. ember_assert = Ember. k;} If ('undefined' = typeof ember_warn) {window. ember_warn = Ember. k;} If ('undefined' = typeof ember_deprecate) {window. ember_deprecate = Ember. k;} If ('undefined' === typeof ember_deprecatefunc) {window. ember_deprecatefunc = function (_, func) {return func ;};}// debug related Ember. logger = Window. console | {log: Ember. k, warn: Ember. k, error: Ember. k}; // used for storage Static methods and feature Test Results var platform = Ember. platform ={}; // class factory, only object. create alias platform. create = object. create; If (! Platform. create) {// forward compatible with VAR o_ctor = function () {}, o_proto = o_ctor.prototype; platform. create = function (OBJ, descs) {o_ctor.prototype = OBJ; OBJ = new o_ctor (); o_ctor.prototype = o_proto; If (descs! = Undefined) {for (var key in descs) {If (! Descs. hasownproperty (key) continue; // The second parameter is also supplemented with platform. defineproperty (OBJ, key, descs [Key]) ;}} return OBJ ;}; // The identifier is a counterfeit platform. create. issimulated = true;} var defineproperty = object. defineproperty; var canredefineproperties, candefinepropertyondom; // IE8 object. defineproperty is a semi-finished product and can only process the DOM property if (defineproperty) {try {defineproperty ({}, 'A', {Get: function () {}});} catch (E) {/** @ private */ Defineproperty = NULL ;}/// process other exotic bugif (defineproperty) {// detects a bug in Android <3.2 where you cannot redefine a property using // object. defineproperty once accessors have already been set. /** @ private */canredefineproperties = (function () {var OBJ = {}; defineproperty (OBJ, 'A', {retriable: True, enumerable: True, get: function () {}, set: function () {}}); defineproperty (OBJ, 'A ', {Retriable: True, enumerable: True, writable: True, value: true}); Return obj. A === true ;}) (); // This is for Safari 5.0, which supports object. defineproperty, but not // on DOM nodes. /** @ private */candefinepropertyondom = (function () {try {defineproperty (document. createelement ('div '), 'definepropertyondom', {}); return true;} catch (e) {}return false ;}) (); If (! Canredefineproperties) {/** @ private */defineproperty = NULL;} else if (! Candefinepropertyondom) {/** @ private */defineproperty = function (OBJ, keyname, DESC) {var isnode; If (typeof node = "object ") {isnode = OBJ instanceof node;} else {isnode = typeof OBJ = "object" & typeof obj. nodetype = "Number" & typeof obj. nodename = "string";} If (isnode) {// todo: shocould we have a warning here? Return (OBJ [keyname] = DESC. value);} else {return object. defineproperty (OBJ, keyname, DESC) ;};}} platform. defineproperty = defineproperty; platform. haspropertyaccessors = true; If (! Platform. defineproperty) {platform. haspropertyaccessors = false; platform. defineproperty = function (OBJ, keyname, DESC) {ember_assert ("property descriptor cannot have 'get' or 'set' on this platform ",! Desc. Get &&! Desc. set); OBJ [keyname] = DESC. value; // if not supported, only the value of this object can be obtained for value assignment}; platform. defineproperty. issimulated = true;} // var guid_key = '_ ember' + (+ new date (); var UUID, numbercache, stringcache; UUID = 0; numbercache = []; stringcache ={}; // make it inaccessible to traverse var guid_desc = Ember. guid_desc = {retriable: True, writable: True, enumerable: false}; var o_defineproperty = Ember. platform. defineproperty; var o_crea Te = Ember. Platform. Create; Ember. guid_key = guid_key; // generate a uuidember. generateguid = function (OBJ, prefix) {If (! Prefix) prefix = 'ember'; var ret = (prefix + (UUID ++); If (OBJ) {guid_desc.value = ret; o_defineproperty (OBJ, guid_key, guid_desc ); guid_desc.value = NULL;} return ret;}; // obtain the key name corresponding to the uuid of each object. UUID is used for the object. Therefore, for the basic data type, their return values are specified Ember. guidfor = function (OBJ) {// special cases where we don't want to add a key to object if (OBJ = undefined) Return "(undefined )"; if (OBJ = NULL) Return "(null)"; VA R cache, RET; var type = typeof OBJ; Switch (type) {Case 'number': // process immutable object ret = numbercache [OBJ]; If (! RET) ret = numbercache [OBJ] = 'nu '+ OBJ; return ret; Case 'string': // process immutable object ret = stringcache [OBJ]; If (! RET) ret = stringcache [OBJ] = 'st' + (UUID ++); return ret; Case 'boolean': // process immutable object return OBJ? '(True)': '(false)'; default: If (OBJ [guid_key]) return OBJ [guid_key]; If (OBJ = Object) return '(object) '; // skip the native object constructor if (OBJ = array) return' (array) '; // skip the native object constructor return Ember. generateguid (OBJ, 'ember') ;};// meta var meta_desc ={// its feature description writable: True, retriable: false, enumerable: false, value: null}; var meta_key = Ember. guid_key + '_ meta'; Ember. meta_key = meta_key; // placeholder for non- Writable Metas. vaR empty_meta = {// empty meta descs :{}, watching :{}}; if (object. freeze) object. freeze (empty_meta); var createmeta = Ember. platform. defineproperty. issimulated? O_create: (function (Meta) {return Meta;}); Ember. meta = function Meta (OBJ, writable) {var ret = OBJ [meta_key]; If (writable = false) return ret | empty_meta; // how to disable write, directly return or return NULL element if (! RET) {// if this object has just set o_defineproperty (OBJ, meta_key, meta_desc); ret = OBJ [meta_key] = createmeta ({descs :{}, watching :{}, values: {}, lastsetvalues :{}, cache :{}, Source: OBJ}); // make sure we don't accidentally try to create constructor like DESC ret. descs. constructor = NULL;} else if (Ret. source! = OBJ) {ret = o_create (RET); // copy ret. descs = o_create (Ret. descs); // copy ret. values = o_create (Ret. values); // copy ret. watching = o_create (Ret. watching); // copy ret. lastsetvalues ={}; ret. cache ={}; ret. source = OBJ; o_defineproperty (OBJ, meta_key, meta_desc); ret = OBJ [meta_key] = createmeta (RET);} return ret ;}; // get some metadata of the object. getmeta = function getmeta (OBJ, property) {var meta = Ember. meta (OBJ, Fa LSE); Return meta [property] ;}; Ember. setmeta = function setmeta (OBJ, property, value) {var meta = Ember. meta (OBJ, true); Meta [property] = value; Return Value ;}; Ember. metapath = function (OBJ, path, writable) {var meta = Ember. meta (OBJ, writable), keyname, value; For (VAR I = 0, L = path. length; I <L; I ++) {keyname = path [I]; value = meta [keyname]; If (! Value) {If (! Writable) {return undefined;} value = meta [keyname] = {_ ember_source __: OBJ};} else if (value. _ ember_source __! = OBJ) {If (! Writable) {return undefined;} value = meta [keyname] = o_create (value); value. _ ember_source _ = OBJ;} meta = value;} return value;}; Ember. wrap = function (func, superfunc) {function K () {} var newfunc = function () {var ret, sup = This. _ super; this. _ super = superfunc | K; ret = func. apply (this, arguments); this. _ super = sup; return ret;}; newfunc. base = func; return newfunc;}; // used to determine whether it is a class array mber. Isarray = function (OBJ) {If (! OBJ | obj. setinterval) {return false;} If (array. isarray & array. isarray (OBJ) {return true;} If (Ember. array & Ember. array. detect (OBJ) {return true;} If (obj. length! = Undefined) & 'object' = typeof OBJ) {return true;} return false ;}; // convert everything to an array // Ember. makearray (); => [] // Ember. makearray (null); => [] // Ember. makearray (undefined); => [] // Ember. makearray ('lintery'); => ['lintery'] // Ember. makearray ([1, 2, 42]); => [1, 2, 42] Ember. makearray = function (OBJ) {If (OBJ = NULL | OBJ = undefined) return []; return Ember. isarray (OBJ )? OBJ: [OBJ];};
So far, this article only knows that it has spent a lot of effort to simulate object. defineproperties, and has implemented a meta mechanism, so I do not know what to use for the moment.