10.06.2016, 12:55
(08.06.2016, 10:57)Erwin van der Zwart Wrote: Hi Buuudzik,
Give your landscape and portait plans the exact same name and use _V and _H on the end of the name and use this code as custom JavaScript:
Code:$(function(){
function OrientationChange(orientation){
var currentplan_name = planStore[currentPlanId].name;
var firstChars = currentplan_name.substr(0, (currentplan_name.length - 2));
var lastChars = currentplan_name.substr(currentplan_name.length - 2);
var newPlanName = 'Not Found'
if (lastChars == '_V' && orientation == '_H'){
var newPlanName = firstChars + '_H'
}
if (lastChars == '_H' && orientation == '_V'){
var newPlanName = firstChars + '_V'
}
if (newPlanName != 'Not Found'){
for (var key in planStore) {
// skip loop if the property is from prototype
if (!planStore.hasOwnProperty(key)) continue;
var obj = planStore[key];
for (var prop in obj) {
// skip loop if the property is from prototype
if(!obj.hasOwnProperty(prop)) continue;
//console.log(prop + " = " + obj[prop]);
if (obj.name == newPlanName){
showPlan(obj.id);
}
}
}
}
}
function doOnOrientationChange(){
switch(window.orientation)
{
case -90:
case 90:
OrientationChange('_H')
break;
default:
OrientationChange('_V')
break;
}
}
window.addEventListener('orientationchange', doOnOrientationChange);
// Initial execution if needed
doOnOrientationChange();
});
That should do the trick (;
Good luck!
BR,
Erwin van der Zwart
It works very good and this is what I need. Eventually is there a possibility to detect a mobile view _MV and _MH? Because unfortunately I can't prepare visualisation which will have apropriate icons for iPad and iPhone both. If there is no such possibility it will be ok but if there is it will helpful.
And second think:
Maybe do you know how change a color of the temperature text e.g. when actual is less than setpoint -> ORANGE, when actual is near setpoint -> white or default(don't change), when actual is more than setpoint -> BLUE.