Advertisement
sirjordan

WCScript_0.5

Mar 3rd, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ### GLOBALS ###
  2. var customers = new Array();
  3. var positions = new Array();
  4. var selectedFirm;
  5. var selectedProfile;
  6. var selectedGlass;
  7.  
  8. var Profiles = {};
  9.  
  10. var Glasess = {
  11.     regular: { name: 'Бяло/Бяло', value: 1 },
  12.     Ka: { name: 'Бяло/Ка', value: 2 },
  13.     fourSeason: { name: 'Бяло/4 сезона', value: 3 }
  14. };
  15.  
  16. var MechanismsEnum = {
  17.     Siegenia: 'Siegenia',
  18.     Endow: 'Endow',
  19.     Winkhaus: 'Winkhaus'
  20. };
  21.  
  22. // Design the configurations, for displaying
  23. function createPosition(src, alt, id) {
  24.     var img = document.createElement('img');
  25.     img.src = src;
  26.     img.id = id;
  27.  
  28.     img.setAttribute('width', '150');
  29.     img.setAttribute('height', '80');
  30.  
  31.     if (alt != null) img.alt = alt;
  32.  
  33.     img.onclick = function () {
  34.         onImageClick(this);
  35.     };
  36.  
  37.     return img;
  38. }
  39.  
  40. // Returns if some array contains some object
  41. function contains(array, obj) {
  42.     var i = a.length;
  43.     while (i--) {
  44.         if (a[i] === obj) {
  45.             return true;
  46.         }
  47.     }
  48.     return false;
  49. }
  50.  
  51. function InitializePositions() {
  52.  
  53.     // Some positions
  54.     positions.push(new createPosition('images/fix.jpg', 'fix', 'fix'));
  55.     positions.push(new createPosition('images/fix_otv_fix.jpg', 'fix_otv_fix', 'fix_otv_fix'));
  56.     positions.push(new createPosition('images/fix_otv_otv_fix.jpg', 'fix_otv_otv_fix', 'fix_otv_otv_fix'));
  57.  
  58.     positions.push(new createPosition('images/otv.jpg', 'otv', 'otv'));
  59.     positions.push(new createPosition('images/otv_fix.jpg', 'otv_fix', 'otv_fix'));
  60.     positions.push(new createPosition('images/otv_fix_otv.jpg', 'otv_fix_otv', 'otv_fix_otv'));
  61.  
  62.     positions.push(new createPosition('images/otv_fix_vrata.jpg', 'otv_fix_vrata', 'otv_fix_vrata'));
  63.     positions.push(new createPosition('images/proz_fix_vrata.jpg', 'proz_fix_vrata', 'proz_fix_vrata'));
  64.     positions.push(new createPosition('images/vrata.jpg', 'vrata', 'vrata'));
  65.  
  66.     // Displaying
  67.     for (var i = 0; i < positions.length; i++) {
  68.         var disp = document.getElementById('positionSelection');
  69.         disp.appendChild(positions[i]);
  70.     }
  71.  
  72. }
  73.  
  74. function onImageClick(image) {
  75.     var imgToDisplay = createPosition(image.src, image.alt, image.id);
  76.  
  77.     var location = document.getElementById('picturePresent');
  78.     location.innerHTML = '';
  79.     location.appendChild(imgToDisplay);
  80.  
  81.     // Show or hide the door's fields
  82.     if (imgToDisplay.id == 'otv_fix_vrata' || imgToDisplay.id == 'proz_fix_vrata') {
  83.         showElement('doorWidth', true);
  84.         showElement('doorHeight', true);
  85.     }
  86.     else {
  87.         showElement('doorWidth', false);
  88.         showElement('doorHeight', false);
  89.     }
  90.  
  91.     // show/hide wingWidth field
  92.     if (imgToDisplay.id == 'fix' || imgToDisplay.id == 'otv' || imgToDisplay.id == 'vrata' || imgToDisplay.id == 'proz_fix_vrata') {
  93.         showElement('wingWidth', false);
  94.     }
  95.     else {
  96.         showElement('wingWidth', true);
  97.     }
  98. }
  99.  
  100. function Profile(name, casePrice, wingPrice, delimeterPrice, delimeterPricePerCount, casePriceColor, wingPriceColor, delPriceColor, wingDoorPrice, wingDoorColorPrice) {
  101.     this.name = name;
  102.     this.workCost = 0;
  103.     this.delimeterPricePerCount = delimeterPricePerCount;
  104.    
  105.     // White
  106.     this.casePrice = casePrice;
  107.     this.wingPrice = wingPrice;
  108.     this.delimeterPrice = delimeterPrice;
  109.     this.wingDoorPrice = wingDoorPrice;
  110.    
  111.     // Color
  112.     this.casePriceColor = casePriceColor;
  113.     this.wingPriceColor = wingPriceColor;
  114.     this.delPriceColor = delPriceColor;
  115.     this.wingDoorColorPrice = wingDoorColorPrice;
  116.    
  117. }
  118.  
  119. function Glass(name, price, squareCoeficient) {
  120.     this.name = name;
  121.     this.pricePerSQRTMeter = price;
  122.  
  123.     // 1 usualy
  124.     this.squareCoeficient = squareCoeficient;
  125.  
  126.     this.GetPrice = function (sqrtMeters) {
  127.  
  128.         var result = sqrtMeters;
  129.  
  130.         if (this.squareCoeficient != 1) {
  131.             result *= squareCoeficient;
  132.             result = sqrtMeters - result;
  133.             return result * this.pricePerSQRTMeter;
  134.         }
  135.         else {
  136.             return sqrtMeters * this.pricePerSQRTMeter;
  137.         }
  138.     }
  139. }
  140.  
  141. function Window(w, h, profileType, delimeters, mechanismTipe) {
  142.  
  143.     // Properties
  144.     var profile = new Profile(),
  145.         wings = new Array(),
  146.         width = w,
  147.         height = h;
  148.  
  149.     profile = profileType;
  150.  
  151.     // Private functions
  152.     function delimetersLen() {
  153.         var result = 0;
  154.         for (var i = 0; i < delimeters.length; i++) {
  155.             result += delimeters[i];
  156.         }
  157.         return result;
  158.     }
  159.  
  160.     function Wing(w, h, hasDouble) {
  161.         var _width = w,
  162.             _height = h,
  163.             _hasDouble = hasDouble,
  164.             len = function () { return _width * 2 + _height * 2; },
  165.             _mechanism = new Mechanism();
  166.  
  167.         //_mechanism = mechanismTipe;
  168.         getMechPrice = function () {
  169.             var result = _mechanism.normalPrice;
  170.  
  171.             if (_width > _mechanism.upperL_Len) {
  172.                 result += _mechanism.upperL_Price;
  173.                 if (_hasDouble == true) {
  174.                     result += _mechanism.double_UpperL_Price;
  175.                 }
  176.             }
  177.  
  178.             if (_height > _mechanism.upperH_Len) {
  179.                 result += _mechanism.upperH_Price;
  180.                 if (_hasDouble == true) {
  181.                     result += _mechanism.double_upperH_Price;
  182.                 }
  183.             }
  184.  
  185.             // REMOVE ofter FIX
  186.             if (isNaN(result)) {
  187.                 result = 0;
  188.             }
  189.  
  190.             return result;
  191.         };
  192.  
  193.         this.Price = function () {
  194.             return len() * profile.wingPrice + getMechPrice();
  195.         };
  196.     }
  197.  
  198.     function Area() {
  199.         return width * height;
  200.     }
  201.  
  202.     // Public functions
  203.     this.GetWindowArea = function () {
  204.         return Area();
  205.     }
  206.  
  207.     this.AddWing = function (w, h, hasDouble) {
  208.         wings.push(new Wing(w, h, hasDouble));
  209.         // TODO: Add mechanism
  210.     }
  211.  
  212.     this.GetPrice = function () {
  213.         var totalPrice = 0;
  214.         totalPrice += (2 * width + 2 * height) * profile.casePrice; // Case price
  215.  
  216.         if (delimetersLen() > 0) {
  217.             totalPrice += delimetersLen() * profile.delimeterPrice + delimeters.length * profile.delimeterPricePerCount;   // Delimeters price +
  218.         }
  219.  
  220.         totalPrice += Area() * profile.workCost;    // Work Cost price
  221.  
  222.         for (var i = 0; i < wings.length; i++) {
  223.             totalPrice += wings[i].Price();   // Wings prises
  224.         }
  225.  
  226.         return totalPrice;
  227.     }
  228.  
  229. }
  230.  
  231. function Customer(name) {
  232.     this.name = name;
  233.     this.profilesSupport = new Array();
  234.     this.glassesSupport = new Array();
  235.     this.mechanismSupport = new Array();
  236. }
  237.  
  238. function Mechanism(name, forProfileType, normalPrice, upperH_Len, upperH_Price, upperL_Len, upperL_Price, securityPrice, doubleNormalPrice, double_upperH_Price, double_UpperL_Price) {
  239.     this.name = name;
  240.     this.normalPrice = normalPrice;
  241.     this.upperH_Price = upperH_Price;
  242.     this.upperL_Price = upperL_Price;
  243.     this.securityPrice = securityPrice;
  244.     this.doubleNormalPrice = doubleNormalPrice;
  245.     this.double_upperH_Price = double_upperH_Price;
  246.     this.double_UpperL_Price = double_UpperL_Price;
  247.     this.upperH_Len = upperH_Len;
  248.     this.upperL_Len = upperL_Len;
  249.     this.forProfileType = forProfileType;
  250. }
  251.  
  252. function Manifacture() {
  253.  
  254. }
  255.  
  256. function ManageUserEntry() {
  257.     // TODO: check boundaries ...
  258.     var overallWidth = parseInt(document.getElementById('overallWidth').value) / 100;
  259.     var overallHeight = parseInt(document.getElementById('overallHeight').value) / 100;
  260.  
  261.     var doorWidth = parseInt(document.getElementById('doorWidth').value) / 100;
  262.     var doorHeight = parseInt(document.getElementById('doorHeight').value) / 100;
  263.  
  264.     var wingWidth = parseInt(document.getElementById('wingWidth').value) / 100;
  265.     if (!isNaN(wingWidth)) {
  266.         if (wingWidth == 0 || wingWidth > 100) {
  267.             wingWidth = 0.75;
  268.         }
  269.     }
  270.     else {
  271.         wingWidth = 0.75;
  272.     }
  273.  
  274.     var dblMechanism = document.getElementById("doubleMech").checked;
  275.    
  276.     (positionManager = function () {
  277.         // Check selected pictire's ID
  278.         // confugire and create a window for that picture
  279.         // get the price
  280.  
  281.         var configuration = document.getElementById('picturePresent').firstChild;
  282.         var posId = configuration.id;
  283.  
  284.         var del;
  285.         var currentWindow;
  286.         var currentFirm;
  287.         var currentGlass;
  288.         var currentFirmCurrentProfileIndex;
  289.         var currentFirmCurrentGlassIndex;
  290.  
  291.         var resultToDisplay = 0;
  292.  
  293.         // getSelectet firm
  294.         var temp = document.getElementById('firmList');
  295.         selectedFirm = temp.options[temp.selectedIndex].text;   // change the global variable
  296.  
  297.         // getting gthe selected profile
  298.         temp = document.getElementById('profilesList');
  299.         selectedProfile = temp.options[temp.selectedIndex].text;   // change the global variable
  300.  
  301.         // getting the selected glass
  302.         temp = document.getElementById('glassesList');
  303.         selectedGlass = temp.options[temp.selectedIndex].text;   // change the global variable
  304.  
  305.         // find it profile the list
  306.         for (var i = 0; i < customers.length; i++) {
  307.             if (customers[i].name == selectedFirm) {
  308.                 for (var j = 0; j < customers[i].profilesSupport.length; j++) {
  309.                     // find the selcted profile in customer's list ot profiles
  310.                     if (customers[i].profilesSupport[j].name == selectedProfile) {
  311.                         currentFirm = customers[i];
  312.                         currentFirmCurrentProfileIndex = j;
  313.                         continue;
  314.                     }
  315.                 }
  316.  
  317.                 // find the current firms's supporetd glass in their list
  318.                 for (var k = 0; k < customers[i].glassesSupport.length; k++) {
  319.                     if (customers[i].glassesSupport[k].name.name == selectedGlass) {
  320.                         currentFirmCurrentGlassIndex = k;
  321.                     }
  322.                 }
  323.                 continue;
  324.             }
  325.         }
  326.  
  327.         switch (posId) {
  328.             case 'fix': {
  329.                 del = [0, 0] // no delimeters for the fix ;)
  330.                 currentWindow = new Window(overallWidth, overallHeight, currentFirm.profilesSupport[currentFirmCurrentProfileIndex], del);
  331.                 break;
  332.             }
  333.             case 'fix_otv_fix': {
  334.                 del = [overallHeight, overallHeight];   // two delimeters by window height
  335.                 currentWindow = new Window(overallWidth, overallHeight, currentFirm.profilesSupport[currentFirmCurrentProfileIndex], del);
  336.                 currentWindow.AddWing(wingWidth, overallHeight);
  337.                 break;
  338.             }
  339.             case 'fix_otv_otv_fix': {
  340.                 del = [overallHeight, overallHeight, overallHeight];
  341.                 currentWindow = new Window(overallWidth, overallHeight, currentFirm.profilesSupport[currentFirmCurrentProfileIndex], del);
  342.                 currentWindow.AddWing(wingWidth, overallHeight);
  343.                 currentWindow.AddWing(wingWidth, overallHeight);
  344.                 break;
  345.             }
  346.             case 'otv': {
  347.                 del = [0, 0]
  348.                 currentWindow = new Window(overallWidth, overallHeight, currentFirm.profilesSupport[currentFirmCurrentProfileIndex], del);
  349.                 currentWindow.AddWing(overallWidth, overallHeight);
  350.                 break;
  351.             }
  352.             case 'otv_fix': {
  353.                 del = [overallHeight];
  354.                 currentWindow = new Window(overallWidth, overallHeight, currentFirm.profilesSupport[currentFirmCurrentProfileIndex], del);
  355.                 currentWindow.AddWing(wingWidth, overallHeight);
  356.                 break;
  357.             }
  358.             case 'otv_fix_otv': {
  359.                 del = [overallHeight, overallHeight];   // two delimeters by window height
  360.                 currentWindow = new Window(overallWidth, overallHeight, currentFirm.profilesSupport[currentFirmCurrentProfileIndex], del);
  361.                 currentWindow.AddWing(wingWidth, overallHeight);
  362.                 currentWindow.AddWing(wingWidth, overallHeight);
  363.                 break;
  364.             }
  365.             case 'otv_fix_vrata': {
  366.                 // the door part
  367.                 del = [doorWidth];
  368.                 currentWindow = new Window(doorWidth, doorHeight, currentFirm.profilesSupport[currentFirmCurrentProfileIndex], del);
  369.                 currentWindow.AddWing(doorWidth, doorHeight);
  370.                 resultToDisplay += currentFirm.glassesSupport[currentFirmCurrentGlassIndex].GetPrice(currentWindow.GetWindowArea());
  371.                 resultToDisplay += currentWindow.GetPrice();
  372.  
  373.                 // the window part
  374.                 del = [overallHeight];
  375.                 currentWindow = new Window(overallWidth, overallHeight, currentFirm.profilesSupport[currentFirmCurrentProfileIndex], del);
  376.                 currentWindow.AddWing(wingWidth, overallHeight);
  377.  
  378.                 break;
  379.             }
  380.             case 'proz_fix_vrata': {
  381.                 // the door part
  382.                 del = [doorWidth];
  383.                 currentWindow = new Window(doorWidth, doorHeight, currentFirm.profilesSupport[currentFirmCurrentProfileIndex], del);
  384.                 currentWindow.AddWing(doorWidth, doorHeight);
  385.                 resultToDisplay += currentFirm.glassesSupport[currentFirmCurrentGlassIndex].GetPrice(currentWindow.GetWindowArea());
  386.                 resultToDisplay += currentWindow.GetPrice();
  387.  
  388.                 // the window part
  389.                 del = [0, 0];
  390.                 currentWindow = new Window(overallWidth, overallHeight, currentFirm.profilesSupport[currentFirmCurrentProfileIndex], del);
  391.                 break;
  392.             }
  393.             case 'vrata': {
  394.                 del = [overallWidth]
  395.                 currentWindow = new Window(overallWidth, overallHeight, currentFirm.profilesSupport[currentFirmCurrentProfileIndex], del);
  396.                 currentWindow.AddWing(overallWidth, overallHeight);
  397.                 break;
  398.             }
  399.  
  400.             default: break;
  401.         }
  402.  
  403.         // Procceed and Return the COST result
  404.         resultToDisplay += currentFirm.glassesSupport[currentFirmCurrentGlassIndex].GetPrice(currentWindow.GetWindowArea());
  405.         resultToDisplay += currentWindow.GetPrice();
  406.         resultToDisplay = resultToDisplay.toFixed(2);
  407.  
  408.         alert(resultToDisplay);
  409.     })();
  410. }
  411.  
  412. function showElement(elementId, show) {
  413.     var element = document.getElementById(elementId);
  414.  
  415.     if (show == false) {
  416.         document.getElementById(elementId).style.visibility = 'hidden';
  417.     }
  418.     else {
  419.         document.getElementById(elementId).style.visibility = 'visible';
  420.     }
  421. }
  422.  
  423. function LoadLists() {
  424.     // First time initialazation and displayng of whole data
  425.     // After select an option the other dropdowns has filtering
  426.  
  427.     // Every firm
  428.     (loadFirms = function () {
  429.         var selectLocation = document.getElementById('firmList');
  430.  
  431.         for (var i = 0; i < customers.length; i++) {
  432.             selectLocation.options[selectLocation.options.length] = new Option(customers[i].name)
  433.         }
  434.     })();
  435.  
  436.     // Every Profile
  437.     (loadProfiles = function () {
  438.         var selectLocation = document.getElementById('profilesList');
  439.  
  440.         for (var i in Profiles) {
  441.             selectLocation.options[selectLocation.options.length] = new Option(i);
  442.         }
  443.     })();
  444.  
  445.     // Every glass
  446.     (loadGlasses = function () {
  447.         var selectLocation = document.getElementById('glassesList');
  448.  
  449.         for (var i in Glasess) {
  450.             var t = Glasess[i];
  451.             selectLocation.options[selectLocation.options.length] = new Option(t.name);
  452.         }
  453.     })();
  454.  
  455.     (loadMechanisms = function () {
  456.         // removes every option before insert all to avoid dublicate
  457.         document.getElementById('mechanismList').options.length = 1;
  458.  
  459.         var selectLocation = document.getElementById('mechanismList');
  460.  
  461.         for (var i in MechanismsEnum) {
  462.             selectLocation.options[selectLocation.options.length] = new Option(i);
  463.         }
  464.     })();
  465.  
  466.     // The profileColors is inline written
  467.     // TODO: Check the option items Contains() an option, and if not to add it, if yes -> no
  468. }
  469.  
  470. function Filter(filterBy) {
  471.     // Remove Every option
  472.     function removeAllOptions(id) {
  473.         document.getElementById(id).options.length = 1;
  474.     }
  475.  
  476.     // Reload everytink
  477.     function Clear() {
  478.         removeAllOptions('firmList');
  479.         removeAllOptions('profilesList');
  480.         removeAllOptions('glassesList');
  481.         LoadLists();
  482.     }
  483.  
  484.     switch (filterBy) {
  485.         case 'profile': {
  486.             if (document.getElementById("profilesList").selectedIndex > 0) {
  487.                
  488.                 // Removers every firm
  489.                 var _firmList = document.getElementById('firmList');
  490.                 var _selectedFirm = _firmList.options[_firmList.selectedIndex].text;
  491.                 removeAllOptions('firmList');
  492.  
  493.                 // Set only firm's that have that profile
  494.                 var profilelist = document.getElementById('profilesList');
  495.                 var profileName = profilelist.options[profilelist.selectedIndex].text;
  496.  
  497.                 for (var i = 0; i < customers.length; i++) {
  498.                     for (var j = 0; j < customers[i].profilesSupport.length; j++) {
  499.                         if (customers[i].profilesSupport[j].name == profileName) {
  500.                             var selectLocation = document.getElementById('firmList');
  501.                             selectLocation.options[selectLocation.options.length] = new Option(customers[i].name)
  502.                         }
  503.                     }
  504.                 }
  505.                 // restore the prevouse selected after refreshing
  506.                 _firmList.value = _selectedFirm;
  507.                 break;
  508.             }
  509.             else {
  510.                 Clear();
  511.                 break;
  512.             }
  513.         }
  514.  
  515.         case 'firm': {
  516.             if (document.getElementById("firmList").selectedIndex > 0) {
  517.  
  518.                 // Removers every profile and every glass, than set only relevant
  519.                 var _profileList = document.getElementById('profilesList');
  520.                 var _selectedProfile = _profileList.options[_profileList.selectedIndex].text;
  521.  
  522.                 var _glassList = document.getElementById('glassesList');
  523.                 var _selectedGlass = _glassList.options[_glassList.selectedIndex].text;
  524.  
  525.                 removeAllOptions('profilesList');
  526.                 removeAllOptions('glassesList');
  527.  
  528.                 // Set only profiles that support that firm
  529.                 var firmList = document.getElementById('firmList');
  530.                 var firmName = firmList.options[firmList.selectedIndex].text;
  531.                 var firmSearchIndex = 0;
  532.                 for (var i = 0; i < customers.length; i++) {
  533.                     if (customers[i].name == firmName) {
  534.                         firmSearchIndex = i;
  535.                         continue;
  536.                     }
  537.                 }
  538.                 // update the profile list
  539.                 debugger;
  540.                 for (var j = 0; j < customers[firmSearchIndex].profilesSupport.length; j++) {
  541.                     var selectLocation = document.getElementById('profilesList');
  542.                     selectLocation.options[selectLocation.options.length] = new Option(customers[firmSearchIndex].profilesSupport[j].name);
  543.                 }
  544.  
  545.                 // update the glass list
  546.                 for (var k = 0; k < customers[firmSearchIndex].glassesSupport.length; k++) {
  547.                     var selectLocation = document.getElementById('glassesList');
  548.                     selectLocation.options[selectLocation.options.length] = new Option(customers[firmSearchIndex].glassesSupport[k].name.name);
  549.                 }
  550.  
  551.                 // restore the prevouse selected after refreshing
  552.                 _profileList.value = _selectedProfile;
  553.                 break;
  554.             }
  555.             else {
  556.                 Clear();
  557.                 break;
  558.             }
  559.         }
  560.  
  561.         case 'glass': {
  562.             // TODO:
  563.             break;
  564.         }
  565.  
  566.         case 'clear': {
  567.             // Clear the whole form
  568.             Clear();
  569.             break;
  570.         }
  571.  
  572.         case 'mech': {
  573.             // Filter the firms that has current mech and profile that has supported
  574.  
  575.             if (document.getElementById("mechanismList").selectedIndex > 0) {
  576.                 // 1. Get all firms that support that mech
  577.                 // Removers every firm
  578.                 var _firmList = document.getElementById('firmList');
  579.                 var _selectedFirm = _firmList.options[_firmList.selectedIndex].text;
  580.                 var loadedFirms = new Array();
  581.                 removeAllOptions('firmList');
  582.  
  583.                 // Set only firm's that have that mechanism
  584.                 var mechanismList = document.getElementById('mechanismList');
  585.                 var _mechanismName = mechanismList.options[mechanismList.selectedIndex].text;
  586.  
  587.                 for (var i = 0; i < customers.length; i++) {
  588.                     for (var j = 0; j < customers[i].mechanismSupport.length; j++) {
  589.                         if (customers[i].mechanismSupport[j].name == _mechanismName) {
  590.                             var selectLocation = document.getElementById('firmList');
  591.                             // TODO:
  592.                             //if (contains(loadedFirms,customers[i]) == false) {
  593.                                 loadedFirms.push(customers[i]);
  594.                                 selectLocation.options[selectLocation.options.length] = new Option(customers[i].name)
  595.                             //}
  596.                         }
  597.                     }
  598.                 }
  599.  
  600.                 // 2. Get all the profiles of that firm that support that mech
  601.                 var _profileList = document.getElementById('profilesList');
  602.                 removeAllOptions('profilesList');
  603.                 debugger;  
  604.                 for (var i = 0; i < loadedFirms.length; i++) {
  605.                     for (var j = 0; j < loadedFirms[i].profilesSupport.length; j++) {
  606.                         for (var k = 0; k < loadedFirms[i].mechanismSupport.length; k++) {
  607.                             if (loadedFirms[i].mechanismSupport[k].name == _mechanismName) {
  608.                                 var tmp = loadedFirms[i].mechanismSupport[k];
  609.                                 if (loadedFirms[i].profilesSupport[j].name == tmp.forProfileType) {
  610.                                     // TODO:
  611.                                     _profileList.options[_profileList.options.length] = new Option(loadedFirms[i].profilesSupport[j].name);
  612.                                 }
  613.                             }
  614.                         }
  615.                     }
  616.                 }
  617.             }
  618.             else {
  619.                 // DO NOTHING
  620.             }
  621.  
  622.             break;
  623.         }
  624.  
  625.         default:
  626.             break;
  627.     }
  628. }
  629.  
  630. // ### MAIN ###
  631.  
  632. // StartUp function
  633. function Initialize() {
  634.     // Load saved positions for windows, and they'r images
  635.     InitializePositions();
  636.     // First time initialazation and displayng of whole data
  637.     LoadLists();
  638. }
  639.  
  640. // Load firms and specifications
  641. function loadFirmData(firmName) {
  642.     // # Push Profile:
  643.     // # new Profile(name, casePrice, wingPrice, delimeterPrice, delimeterPricePerCount, workCost);
  644.     // # Description:
  645.     // name: ...
  646.     // casePrice: ...
  647.     // ...
  648.     // Customer #1
  649.     var inputFirm = new Customer(firmName);
  650.     /*
  651.     inputFirm.profilesSupport.push(new Profile(Profiles.KMG, 5.8, 5.8, 5.8, 5, 5));
  652.     inputFirm.profilesSupport.push(new Profile(Profiles.VEKA, 5.8, 5.8, 5.8, 5, 5));
  653.     inputFirm.profilesSupport.push(new Profile(Profiles.Salamander, 5.8, 5.8, 5.8, 5, 5));
  654.     inputFirm.glassesSupport.push(new Glass(Glasess.regular, 24, 0.18));
  655.     inputFirm.glassesSupport.push(new Glass(Glasess.Ka, 29, 0.18));
  656.     inputFirm.mechanismSupport.push(new Mechanism(MechanismsEnum.Endow, Profiles.KMG));
  657.     inputFirm.mechanismSupport.push(new Mechanism(MechanismsEnum.Siegenia, Profiles.KMG));
  658.     inputFirm.mechanismSupport.push(new Mechanism(MechanismsEnum.Siegenia, Profiles.VEKA));
  659.     */
  660.     customers.push(inputFirm);
  661.  
  662.     // Customer #2
  663.     /*
  664.     var RollPlast = new Customer(firmName);
  665.     RollPlast.profilesSupport.push(new Profile(Profiles.Trocal, 5.8, 5.8, 5.8));
  666.     RollPlast.profilesSupport.push(new Profile(Profiles.VEKA, 5.8, 5.8, 5.8));
  667.     RollPlast.glassesSupport.push(new Glass(Glasess.regular, 24, 1));
  668.     RollPlast.mechanismSupport.push(new Mechanism(MechanismsEnum.Winkhaus, Profiles.Trocal));
  669.     customers.push(RollPlast);
  670.     */
  671.    
  672.     // Customer #3
  673.     //
  674.     //
  675.     //
  676.  
  677. }
  678.  
  679. function Wizard(step) {
  680.     // Recursive
  681.     // 6-7 steps or more
  682.     var stepMessages = new Array();
  683.     // Push some messages
  684.     // Massage 1 - step1
  685.     // Massage 2 - step2
  686.     //....
  687.  
  688.     var stepCounter = stepMessages.length;
  689. }
  690.  
  691. function getCustomerIndexByName(customerName){
  692.     for (var i=0; i < customers.length; i++) {
  693.       if (customers[i].name == customerName) {
  694.         return i;
  695.         continue;
  696.       };
  697.     };
  698. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement