Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Priority colors

  • Loading branch information...
commit 4d8ad48621ac56a3e05f1a4f66cba31afc7a2adc 1 parent c165262
@ivov-dry ivov-dry authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/ProcessList.js
View
12 lib/ProcessList.js
@@ -2,7 +2,8 @@ function ProcessList() {
this.processes = {};
this.count = 0;
this.colors = ['b1a2f4', 'daa2f4', 'f9a5d5', 'ffaaaa', 'ffccaa', 'ffddaa', 'ffeeaa', 'ffffaa', 'e6fda8', 'a2f4a4', 'a2dff4', 'a2c4f4'];
- this.max_arrival = 0;
+ this.colors_priority = ['ff99cc', '66ccff', 'ccff99'];
+ this.max_arrival = 0;
}
ProcessList.prototype.addNew = function(arrival, burst, priority) {
@@ -13,7 +14,7 @@ ProcessList.prototype.addNew = function(arrival, burst, priority) {
alert('Incorrect numbers.');
return false;
}
-
+
if (this.max_arrival > arrival) {
alert('Incorrect arrival time. Arrival must be >= ' + this.max_arrival);
return false;
@@ -22,7 +23,12 @@ ProcessList.prototype.addNew = function(arrival, burst, priority) {
$("h2.main").show();
var new_id = this.count + 1;
- var new_color = this.colors[new_id % this.colors.length];
+ var new_color;
+ if (priority != undefined) {
+ new_color = this.colors_priority[priority - 1];
+ } else {
+ new_color = this.colors[new_id % this.colors.length];
+ }
var p = new Process(new_id, arrival, burst, priority, new_color);
if (p.id == -1) return false;
Please sign in to comment.
Something went wrong with that request. Please try again.