Projekt

Obecné

Profil

Stáhnout (1.86 KB) Statistiky
| Větev: | Tag: | Revize:
1
/**
2
* This class represents creation of symbols.
3
 * @constructor
4
*/
5
function MarkSymbol() {
6
	var CONST_MARK_SYMBOLS = ["", "", "", "", "", "", "", "", "", "",
7
	"", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
8
	"", "", "", "", "", "", "", "", "", "", "", "", "", "",
9
	"", "+", "-", "*", "÷", "×", "=", "±", "Ø", "~", "«", "»", "¤", "", "§",
10
	"", "!", "#", "$", "%", "&", "@", "A", "B", "C", "D", "E", "F", "G", "H",
11
	"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
12
	"X", "Y", "Z",   "©", "®", "α", "β", "γ", "δ", "ε", "ζ", "η", "θ", "ι", "κ",
13
	"λ", "μ", "ν", "ξ", "π", "ρ", "σ", "τ", "υ", "φ", "χ", "ψ", "ω", "Ω", "Φ",
14
	"Σ", "Λ", "Δ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
15
	
16
	var CONST_MARK_COLORS = ["#DC143C", "#B23AEE", "#63B8FF", "#3D9140", "#B3EE3A",
17
	"#FFD700", "#B7B7B7", "#FF8000"];
18

    
19
	var removeMarkSymbolList = [];
20
	var symbolIndex = -1;
21
	var colorIndex = -1;
22
	var startColorIndex = 0;
23

    
24
	/**
25
	* Returns symbol with unique char and color.
26
	*/
27
	this.getMarkSymbol = function() {
28
		if (removeMarkSymbolList.length > 0) {
29
			return removeMarkSymbolList.shift();
30
		}
31
		
32
		symbolIndex++;
33
		colorIndex++;
34
		
35
		if (colorIndex === CONST_MARK_COLORS.length) {
36
			colorIndex = 0;
37
		}
38
		
39
		if (symbolIndex === CONST_MARK_SYMBOLS.length) {
40
			if (startColorIndex === CONST_MARK_COLORS.length) {
41
				startColorIndex = 0;
42
			}
43
			
44
			symbolIndex = 0;
45
			startColorIndex++;
46
			colorIndex = startColorIndex;
47
		}
48
		
49
		return [CONST_MARK_SYMBOLS[symbolIndex], CONST_MARK_COLORS[colorIndex]];
50
	};
51

    
52
	/**
53
	 * Save removed symbol (char + color) to the list of removes symbols.
54
	 *
55
	 * @param symbol symbol to be removed
56
	 */
57
	this.removeSymbol = function(symbol) {
58
		removeMarkSymbolList.push(symbol);
59
	};
60
}
(10-10/11)