Subversion Repositories HomeAutomation

Rev

Rev 1806 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1806 Rev 1899
Line 35... Line 35...
35
    case "left":
35
    case "left":
36
        if (this.mode == 0) {
36
        if (this.mode == 0) {
37
            this.parentDisplay.changeToLeft();
37
            this.parentDisplay.changeToLeft();
38
        } else {
38
        } else {
39
            this.currentPhoneItem--;
39
            this.currentPhoneItem--;
-
 
40
            //Log("currentPhoneItem is now-: "+ this.currentPhoneItem + "\n");
40
            if (this.currentPhoneItem < 0) {
41
            if (this.currentPhoneItem < 0) {
41
                this.currentPhoneItem = this.numberOfItemsInPhonebook-1;
42
                this.currentPhoneItem = this.numberOfItemsInPhonebook-1;
42
            }
43
            }
43
        }
44
        }
44
        break;
45
        break;
Line 46... Line 47...
46
    case "right":
47
    case "right":
47
        if (this.mode == 0) {
48
        if (this.mode == 0) {
48
            this.parentDisplay.changeToRight();
49
            this.parentDisplay.changeToRight();
49
        } else {
50
        } else {
50
            this.currentPhoneItem++;
51
            this.currentPhoneItem++;
-
 
52
            //Log("currentPhoneItem is now+: "+ this.currentPhoneItem + "\n");
51
            if (this.currentPhoneItem >= this.numberOfItemsInPhonebook) {
53
            if (this.currentPhoneItem >= this.numberOfItemsInPhonebook) {
52
                this.currentPhoneItem = 0;
54
                this.currentPhoneItem = 0;
53
            }
55
            }
54
        }
56
        }
55
        break;
57
        break;
Line 81... Line 83...
81
DtmfMenuItem.prototype.onEnter = function ()
83
DtmfMenuItem.prototype.onEnter = function ()
82
{
84
{
83
    this.PhoneNumberList = Storage_GetParameters("PhoneCalls");
85
    this.PhoneNumberList = Storage_GetParameters("PhoneCalls");
84
    if (this.PhoneNumberList)
86
    if (this.PhoneNumberList)
85
    {
87
    {
86
 
-
 
87
        for(k in this.PhoneNumberList)
88
        for(k in this.PhoneNumberList)
88
        {
89
        {
89
                this.PhoneNumberListKeys.push(k);
90
                this.PhoneNumberListKeys.push(k);
90
            //Log("hittade: "+k+"\n");
91
            //Log("hittade: "+k+"\n");
91
        }
92
        }
92
        this.PhoneNumberListKeys.sort(function(a, b) {return b - a;});
93
        this.PhoneNumberListKeys.sort(function(a, b) {return b - a;});
93
        if (this.PhoneNumberListKeys.length > this.numberOfItemsInPhonebook) {
94
        if (this.PhoneNumberListKeys.length > this.numberOfItemsInPhonebook) {
94
            this.PhoneNumberListKeys.slice(0, this.numberOfItemsInPhonebook-1);
95
            this.PhoneNumberListKeys.slice(0, this.numberOfItemsInPhonebook-1);
95
        }              
96
        }              
96
    } else {
97
    } else {
97
        //No calls found, clear list?
98
        //No calls found, clear list?
98
        Log("hittade inga nummer!\n");
99
        Log("hittade inga nummer!\n");
99
    }
100
    }
100
    this.currentPhoneItem = 0;
101
    this.currentPhoneItem = 0;
101
    this.numberOfItemsInPhonebook = this.PhoneNumberListKeys.length;
102
    this.numberOfItemsInPhonebook = this.PhoneNumberListKeys.length;
102
    Display_Clear(this.display);
103
    Display_Clear(this.display);
103
    this.mode = 0;
104
    this.mode = 0;
-
 
105
    //for(k in this.PhoneNumberList)
-
 
106
    //{
-
 
107
    //  Log("hittade: "+k+"\n");
-
 
108
    //}
104
}
109
}
105
DtmfMenuItem.prototype.update = function ()
110
DtmfMenuItem.prototype.update = function ()
106
{
111
{
107
    if (this.mode == 0) {
112
    if (this.mode == 0) {
108
        if (this.PhoneNumberListKeys[0] != null) {
113
        if (this.PhoneNumberListKeys[0] != null) {
109
            Display_Clear(this.display);
114
            Display_Clear(this.display);
110
            Display_Print(this.display, 0, 0,"Senaste nummer:");
115
            Display_Print(this.display, 0, 0,"Senaste nummer:");
111
            var numbers = {};
116
            var numbers = {};
112
            numbers  = eval("(" + this.PhoneNumberList[this.PhoneNumberListKeys[0]] + ")");
117
            numbers  = eval("(" + this.PhoneNumberList[this.PhoneNumberListKeys[0]] + ")");
-
 
118
            if (numbers["direction"]==null)
-
 
119
              Display_Print(this.display, 0, 0,"Senaste nummer:   - ");
-
 
120
            else if (numbers["direction"]=="in")
-
 
121
              Display_Print(this.display, 0, 0,"Senaste nummer:   In");
-
 
122
            else
-
 
123
              Display_Print(this.display, 0, 0,"Senaste nummer:   Ut");
113
            var date = new Date(parseInt(this.PhoneNumberListKeys[0])*1000);
124
            var date = new Date(parseInt(this.PhoneNumberListKeys[0])*1000);
114
            Display_Print(this.display, 0, 1,""+date.getDateFormated()+" "+date.getTimeShortFormated());
125
            Display_Print(this.display, 0, 1,""+date.getDateFormated()+" "+date.getTimeShortFormated());
115
            Display_Print(this.display, 0, 2,""+numbers["number"]);
126
            Display_Print(this.display, 0, 2,""+numbers["number"]);
-
 
127
            var phonebook = Storage_GetJsonParamter("PhoneBook",numbers["number"])
-
 
128
            if (phonebook) {
-
 
129
                Display_Print(this.display, 0, 3, phonebook[0]);
-
 
130
            }
116
        } else {
131
        } else {
117
            Display_Clear(this.display);
132
            Display_Clear(this.display);
118
            Display_Print(this.display, 0, 0,"SenAste nummer:");
133
            Display_Print(this.display, 0, 0,"SenAste nummer:");
119
            Display_Print(this.display, 0, 2,"IngA nummer");
134
            Display_Print(this.display, 0, 2,"IngA nummer");
120
            Display_Print(this.display, 0, 3,"i liStan!");
135
            Display_Print(this.display, 0, 3,"i liStan!");
Line 122... Line 137...
122
    } else {
137
    } else {
123
        Display_Clear(this.display);
138
        Display_Clear(this.display);
124
        var numbers = {};
139
        var numbers = {};
125
        numbers  = eval("(" + this.PhoneNumberList[this.PhoneNumberListKeys[this.currentPhoneItem]] + ")");
140
        numbers  = eval("(" + this.PhoneNumberList[this.PhoneNumberListKeys[this.currentPhoneItem]] + ")");
126
        var date = new Date(parseInt(this.PhoneNumberListKeys[this.currentPhoneItem])*1000);
141
        var date = new Date(parseInt(this.PhoneNumberListKeys[this.currentPhoneItem])*1000);
127
 
-
 
-
 
142
        if (numbers["direction"]==null)
128
        Display_Print(this.display, 0, 0,""+date.getDateFormated()+" "+date.getTimeShortFormated());
143
          Display_Print(this.display, 0, 0,""+date.getDateFormated()+" "+date.getTimeShortFormated());
-
 
144
        else if (numbers["direction"]=="in")
-
 
145
          Display_Print(this.display, 0, 0,""+date.getDateFormated()+" "+date.getTimeShortFormated()+"  In");
-
 
146
        else
-
 
147
          Display_Print(this.display, 0, 0,""+date.getDateFormated()+" "+date.getTimeShortFormated()+"  Ut");
129
        Display_Print(this.display, 0, 1,""+numbers["number"]);
148
        Display_Print(this.display, 0, 1,""+numbers["number"]);
-
 
149
        var phonebook = Storage_GetJsonParamter("PhoneBook",numbers["number"])
-
 
150
        if (phonebook) {
-
 
151
            Display_Print(this.display, 0, 2, phonebook[0]);
-
 
152
            if (phonebook.length > 1) {
-
 
153
                Display_Print(this.display, 0, 3, phonebook[1]);
-
 
154
            }
-
 
155
        }
130
    }
156
    }
131
}
157
}
132
 
158
 
133
DtmfMenuItem.prototype.onExit = function ()
159
DtmfMenuItem.prototype.onExit = function ()
134
{
160
{