1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
// Define the data service that manages the data . Factory ('dataservice ', ['requestnotifchannel channel', function (requestNotificationChannel ){ // Private data Var hops = [ {"_ Id": {"$ oid": "50ae677361d118e3646d7d6c"}, "Name": "Admiral", "Origin": "United Kingdom", "Alpha": 14.75, "Amount": 0.0, "Use": "Boil", "Time": 0.0, "Notes": "Bittering hops derived from Wye Challenger. good high-alpha bittering hops. use for: Ales Aroma: Primarily for bittering Substitutions: Target, Northdown, Challenger "," Type ":" Bittering "," Form ":" Pellet "," Beta ": 5.6, "HSI": 15.0, "Humulene": 0.0, "Caryophyllene": 0.0, "Cohumulone": 0.0, "Myrcene": 0.0, "Substitutes ":""}, {"_ Id": {"$ oid": "50ae677361d118e3646d7d6d"}, "Name": "Ahtanum", "Origin": "U. s. "," Alpha ": 6.0," Amount ": 0.0," Use ":" Boil "," Time ": 0.0," Notes ": "Distinctive aromatic hops with moderate bittering power from Washington. use for: Distinctive aroma Substitutes: N/A "," Type ":" Aroma "," Form ":" Pellet "," Beta ": 5.25," HSI ": 30.0, "Humulene": 0.0, "Caryophyllene": 0.0, "Cohumulone": 0.0, "Myrcene": 0.0, "Substitutes ":""}, {"_ Id": {"$ oid": "50ae677361d118e3646d7d6e"}, "Name": "Amarillo Gold", "Origin": "U. s. "," Alpha ": 8.5," Amount ": 0.0," Use ":" Boil "," Time ": 0.0," Notes ":" Unknown origin, but character similar to Cascade. use for: IPAs, Ales Aroma: Citrus, Flowery Substitutions: Cascade, centenrix "," Type ":" Aroma "," Form ":" Pellet "," Beta ": 6.0, "HSI": 25.0, "Humulene": 0.0, "Caryophyllene": 0.0, "Cohumulone": 0.0, "Myrcene": 0.0, "Substitutes ":""}, {"_ Id": {"$ oid": "50ae677361d118e3646d7d6f"}, "Name": "Aquila", "Origin": "U. s. "," Alpha ": 6.5," Amount ": 0.0," Use ":" Boil "," Time ": 0.0," Notes ":" Aroma hops developed in 1988. limited use due to high cohumolone. used for: Aroma hops Substitutes: ClusterNo longer extends cially grown. "," Type ":" Aroma "," Form ":" Pellet "," Beta ": 3.0," HSI ": 35.0," Humulene ": 0.0," Caryophyllene ": 0.0, "Cohumulone": 0.0, "Myrcene": 0.0, "Substitutes ":""}, {"_ Id": {"$ oid": "50ae677361d118e3646d7d70"}, "Name": "Auscha (Saaz)", "Origin": "Czech Republic ", "Alpha": 3.3, "Amount": 0.0, "Use": "Boil", "Time": 0.0, "Notes": "Use: pilsners and Bohemian style lagers Aroma: Delicate, mild, clean, somewhat floral -- Noble hops Substitute: Tettnanger, LublinExamples: Pulsner Urquell "," Type ":" Aroma "," Form ": "Pellet", "Beta": 3.5, "HSI": 42.0, "Humulene": 0.0, "Caryophyllene": 0.0, "Cohumulone": 0.0, "Myrcene": 0.0, "Substitutes ":""}, ]; // Sends notification that data has been updated Var saveHop = function (hop ){ RequestNotificationChannel. dataUpdated (); }; // Removes the item from the array and sends a notification that data has been updated Var deleteHop = function (hop ){ For (var I = 0; I If (hops [I]. _ id. $ oid === hop. _ id. $ oid ){ Hops. splice (I, 1 ); RequestNotificationChannel. dataUpdated (); Return; } }; }; // Internal function to generate a random number guid generation Var S4 = function (){ Return (1 + Math. random () x 0x10000) | 0). toString (16). substring (1 ); }; // Generates a guid for adding items to array Var guid = function (){ Return (S4 () + S4 () + "-" + S4 () + "-4" + S4 (). substr (0, 3) + "-" + S4 () + "-" + S4 () + S4 () + S4 ()). toLowerCase (); }; // Function to add a hop to the array and sends a notification that data has been updated Var addHop = function (hop ){ Hops. id. $ oid = guid (); Hops. push (hop ); RequestNotificationChannel. dataUpdated (); }; // Returns the array of hops Var getHops = function (){ Return hops; }; // Returns a specific hop with the given id Var getHop = function (id ){ For (var I = 0; I If (hops [I]. _ id. $ oid === id ){ Return hops [I]; } }; }; // Return the publicly accessible methods Return { GetHops: getHops, GetHop: getHop, SaveHop: saveHop, DeleteHop: deleteHop, AddHop: addHop } }]); |