add a scale element to the frame view. Include some bits from StorageAreas to make it work

pull/1661/head
Isaac Connor 2016-10-26 13:34:28 -04:00 committed by Isaac Connor
parent 9e9b1a3a35
commit 568160e5aa
3 changed files with 89 additions and 42 deletions

View File

@ -27,10 +27,26 @@ class Storage {
if ( isset( $this->{'Path'} ) and ( $this->{'Path'} != '' ) ) { if ( isset( $this->{'Path'} ) and ( $this->{'Path'} != '' ) ) {
return $this->{'Path'}; return $this->{'Path'};
} else if ( ! isset($this->{'Id'}) ) { } else if ( ! isset($this->{'Id'}) ) {
return ZM_DIR_EVENTS; $path = ZM_DIR_EVENTS;
if ( $path[0] != '/' ) {
$this->{'Path'} = ZM_PATH_WEB.'/'.ZM_DIR_EVENTS;
} else {
$this->{'Path'} = ZM_DIR_EVENTS;
}
return $this->{'Path'};
} }
return $this->{'Name'}; return $this->{'Name'};
} }
public function Name() {
if ( isset( $this->{'Name'} ) and ( $this->{'Name'} != '' ) ) {
return $this->{'Name'};
} else if ( ! isset($this->{'Id'}) ) {
return 'Default';
}
return $this->{'Name'};
}
public function __call( $fn, array $args= NULL){ public function __call( $fn, array $args= NULL){
if(isset($this->{$fn})){ if(isset($this->{$fn})){
return $this->{$fn}; return $this->{$fn};
@ -47,5 +63,19 @@ class Storage {
} }
return $storage_areas; return $storage_areas;
} }
public function disk_usage_percent() {
$path = $this->Path();
$total = disk_total_space( $path );
if ( ! $total ) {
Error("disk_total_space returned false for " . $path );
return 0;
}
$free = disk_free_space( $path );
if ( ! $free ) {
Error("disk_free_space returned false for " . $path );
}
$usage = round(($total - $free) / $total * 100);
return $usage;
}
} }
?> ?>

View File

@ -0,0 +1,15 @@
function changeScale() {
var scale = $('scale').get('value');
var img = $('frameImg');
if ( img ) {
var baseWidth = $('base_width').value;
var baseHeight = $('base_height').value;
var newWidth = ( baseWidth * scale ) / SCALE_BASE;
var newHeight = ( baseHeight * scale ) / SCALE_BASE;
img.style.width = newWidth + "px";
img.style.height = newHeight + "px";
}
Cookie.write( 'zmWatchScale', scale, { duration: 10*365 } );
}

View File

@ -0,0 +1,2 @@
var SCALE_BASE = <?php echo SCALE_BASE ?>;