| 1 | ##---------------------------------------------------------------------------- | ||||||||||
| 2 | ## HTML Object - ~/lib/HTML/Object/DOM/Screen.pm | ||||||||||
| 3 | ## Version v0.2.0 | ||||||||||
| 4 | ## Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||
| 6 | ## Created 2021/12/31 | ||||||||||
| 7 | ## Modified 2022/09/18 | ||||||||||
| 8 | ## All rights reserved | ||||||||||
| 9 | ## | ||||||||||
| 10 | ## | ||||||||||
| 11 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||
| 12 | ## under the same terms as Perl itself. | ||||||||||
| 13 | ##---------------------------------------------------------------------------- | ||||||||||
| 14 | package HTML::Object::DOM::Screen; | ||||||||||
| 15 | BEGIN | ||||||||||
| 16 | { | ||||||||||
| 17 | 32 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 32 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 32 | ▶ | warnings::register_categories( 'HTML::Object' ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 32 | ▶ | use parent qw( HTML::Object::EventTarget ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 32 | ▶ | use vars qw( $VERSION ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 32 | our $VERSION = 'v0.2.0'; | |||||||||
| 23 | }; | ||||||||||
| 24 | |||||||||||
| 25 | 32 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 32 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | sub init | ||||||||||
| 29 | { | ||||||||||
| 30 | 32 | ▶ | my $self = shift( @_ ); | ||||||||
|
Subroutine
init: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 31 | 32 | $self->{tag} = 'screen'; | |||||||||
| 32 | 32 | $self->{_init_strict_use_sub} = 1; | |||||||||
| 33 | 32 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 32 | return( $self ); | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | # Note: property availHeight | ||||||||||
| 38 | 0 | ▶ | sub availHeight : lvalue { return( shift->_set_get_number( 'availheight', @_ ) ); } | ||||||||
|
Subroutine
availHeight: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 39 | |||||||||||
| 40 | # Note: property availLeft | ||||||||||
| 41 | 0 | ▶ | sub availLeft : lvalue { return( shift->_set_get_number( 'availleft', @_ ) ); } | ||||||||
|
Subroutine
availLeft: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 42 | |||||||||||
| 43 | # Note: property availTop | ||||||||||
| 44 | 0 | ▶ | sub availTop : lvalue { return( shift->_set_get_number( 'availtop', @_ ) ); } | ||||||||
|
Subroutine
availTop: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 45 | |||||||||||
| 46 | # Note: property availWidth | ||||||||||
| 47 | 0 | ▶ | sub availWidth : lvalue { return( shift->_set_get_number( 'availwidth', @_ ) ); } | ||||||||
|
Subroutine
availWidth: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 48 | |||||||||||
| 49 | # Note: property colorDepth | ||||||||||
| 50 | 0 | ▶ | sub colorDepth : lvalue { return( shift->_set_get_number( 'colordepth', @_ ) ); } | ||||||||
|
Subroutine
colorDepth: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 51 | |||||||||||
| 52 | # Note: property height | ||||||||||
| 53 | 0 | ▶ | sub height : lvalue { return( shift->_set_get_number( 'height', @_ ) ); } | ||||||||
|
Subroutine
height: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 54 | |||||||||||
| 55 | # Note: property left | ||||||||||
| 56 | 0 | ▶ | sub left : lvalue { return( shift->_set_get_number( 'left', @_ ) ); } | ||||||||
|
Subroutine
left: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | sub lockOrientation { return( shift->_set_get_scalar_as_object( 'lockorientation', @_ ) ); } | ||||||||
|
Subroutine
lockOrientation: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 59 | |||||||||||
| 60 | # Note: property mozBrightness | ||||||||||
| 61 | 0 | ▶ | sub mozBrightness : lvalue { return( shift->_set_get_number( 'mozbrightness', @_ ) ); } | ||||||||
|
Subroutine
mozBrightness: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 62 | |||||||||||
| 63 | # Note: property mozEnabled | ||||||||||
| 64 | 0 | ▶ | sub mozEnabled : lvalue { return( shift->_set_get_boolean( 'mozenabled', @_ ) ); } | ||||||||
|
Subroutine
mozEnabled: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 65 | |||||||||||
| 66 | # Note: property orientation | ||||||||||
| 67 | 0 | ▶ | sub orientation : lvalue { return( shift->_set_get_scalar_as_object( 'orientation', @_ ) ); } | ||||||||
|
Subroutine
orientation: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 68 | |||||||||||
| 69 | # Note: property pixelDepth | ||||||||||
| 70 | 0 | ▶ | sub pixelDepth : lvalue { return( shift->_set_get_number( 'pixeldepth', @_ ) ); } | ||||||||
|
Subroutine
pixelDepth: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 71 | |||||||||||
| 72 | # Note: property top | ||||||||||
| 73 | 0 | ▶ | sub top : lvalue { return( shift->_set_get_number( 'top', @_ ) ); } | ||||||||
|
Subroutine
top: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 74 | |||||||||||
| 75 | 0 | ▶ | sub unlockOrientation { return; } | ||||||||
|
Subroutine
unlockOrientation: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 76 | |||||||||||
| 77 | # Note: property width | ||||||||||
| 78 | 0 | ▶ | sub width : lvalue { return( shift->_set_get_number( 'width', @_ ) ); } | ||||||||
|
Subroutine
width: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 79 | |||||||||||
| 80 | 32 | 1; | |||||||||
| 81 | # NOTE: POD | ||||||||||
| 82 | __END__ | ||||||||||
| 83 | |||||||||||
| 84 | =encoding utf-8 | ||||||||||
| 85 | |||||||||||
| 86 | =head1 NAME | ||||||||||
| 87 | |||||||||||
| 88 | HTML::Object::DOM::Screen - HTML Object DOM Screen Class | ||||||||||
| 89 | |||||||||||
| 90 | =head1 SYNOPSIS | ||||||||||
| 91 | |||||||||||
| 92 | use HTML::Object::DOM::Screen; | ||||||||||
| 93 | my $screen = HTML::Object::DOM::Screen->new || | ||||||||||
| 94 | die( HTML::Object::DOM::Screen->error, "\n" ); | ||||||||||
| 95 | |||||||||||
| 96 | =head1 VERSION | ||||||||||
| 97 | |||||||||||
| 98 | v0.2.0 | ||||||||||
| 99 | |||||||||||
| 100 | =head1 DESCRIPTION | ||||||||||
| 101 | |||||||||||
| 102 | The C<Screen> interface represents the screen, the only one, under perl, on which the current L<window object|HTML::Object::DOM::Window> exists, and is obtained using L<HTML::Object::DOM::Window/screen>. | ||||||||||
| 103 | |||||||||||
| 104 | =head1 INHERITANCE | ||||||||||
| 105 | |||||||||||
| 106 | +-----------------------+ +---------------------------+ +---------------------------+ | ||||||||||
| 107 | | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Screen | | ||||||||||
| 108 | +-----------------------+ +---------------------------+ +---------------------------+ | ||||||||||
| 109 | |||||||||||
| 110 | =head1 PROPERTIES | ||||||||||
| 111 | |||||||||||
| 112 | Inherits properties from its parent L<HTML::Object::EventTarget> | ||||||||||
| 113 | |||||||||||
| 114 | =head2 availHeight | ||||||||||
| 115 | |||||||||||
| 116 | Normally this returns C<undef> under perl, but you can set whatever number value you want. | ||||||||||
| 117 | |||||||||||
| 118 | Under JavaScript, this specifies the height of the screen, in pixels, minus permanent or semipermanent user interface features displayed by the operating system, such as the Taskbar on Windows. | ||||||||||
| 119 | |||||||||||
| 120 | Example: | ||||||||||
| 121 | |||||||||||
| 122 | use HTML::Object::DOM qw( screen window ); | ||||||||||
| 123 | my $availHeight = window->screen->availHeight; | ||||||||||
| 124 | |||||||||||
| 125 | my $paletteWindow = window->open( "panels.html", "Panels", "left=0, top=0, width=200" ); | ||||||||||
| 126 | |||||||||||
| 127 | Another example: | ||||||||||
| 128 | |||||||||||
| 129 | window->outerHeight = window->screen->availHeight; | ||||||||||
| 130 | |||||||||||
| 131 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/availHeight> | ||||||||||
| 132 | |||||||||||
| 133 | =head2 availLeft | ||||||||||
| 134 | |||||||||||
| 135 | Normally this returns C<undef> under perl, but you can set whatever number value you want. | ||||||||||
| 136 | |||||||||||
| 137 | Under JavaScript, this returns the first available pixel available from the left side of the screen. | ||||||||||
| 138 | |||||||||||
| 139 | Example: | ||||||||||
| 140 | |||||||||||
| 141 | use HTML::Object::DOM qw( screen window ); | ||||||||||
| 142 | my $availLeft = window->screen->availLeft; | ||||||||||
| 143 | |||||||||||
| 144 | my $setX = window->screen->width - window->screen->availLeft; | ||||||||||
| 145 | my $setY = window->screen->height - window->screen->availTop; | ||||||||||
| 146 | # The following does absolutely nothing in perl, obviously | ||||||||||
| 147 | window->moveTo( $setX, $setY ); | ||||||||||
| 148 | |||||||||||
| 149 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/availLeft> | ||||||||||
| 150 | |||||||||||
| 151 | =head2 availTop | ||||||||||
| 152 | |||||||||||
| 153 | Normally this returns C<undef> under perl, but you can set whatever number value you want. | ||||||||||
| 154 | |||||||||||
| 155 | Under JavaScript, this specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features. | ||||||||||
| 156 | |||||||||||
| 157 | Example: | ||||||||||
| 158 | |||||||||||
| 159 | my $availTop = window->screen->availTop; | ||||||||||
| 160 | |||||||||||
| 161 | my $setX = window->screen->width - window->screen->availLeft; | ||||||||||
| 162 | my $setY = window->screen->height - window->screen->availTop; | ||||||||||
| 163 | # The following does absolutely nothing in perl, obviously | ||||||||||
| 164 | window->moveTo( $setX, $setY ); | ||||||||||
| 165 | |||||||||||
| 166 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/availTop> | ||||||||||
| 167 | |||||||||||
| 168 | =head2 availWidth | ||||||||||
| 169 | |||||||||||
| 170 | Normally this returns C<undef> under perl, but you can set whatever number value you want. | ||||||||||
| 171 | |||||||||||
| 172 | Under JavaScript, this returns the amount of horizontal space in pixels available to the window. | ||||||||||
| 173 | |||||||||||
| 174 | Example: | ||||||||||
| 175 | |||||||||||
| 176 | my $width = window->screen->availWidth | ||||||||||
| 177 | |||||||||||
| 178 | my $screenAvailWidth = window->screen->availWidth; | ||||||||||
| 179 | |||||||||||
| 180 | say( $screenAvailWidth ); | ||||||||||
| 181 | |||||||||||
| 182 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/availWidth> | ||||||||||
| 183 | |||||||||||
| 184 | =head2 colorDepth | ||||||||||
| 185 | |||||||||||
| 186 | Normally this returns C<undef> under perl, but you can set whatever number value you want. | ||||||||||
| 187 | |||||||||||
| 188 | Under JavaScript, this returns the color depth of the screen. | ||||||||||
| 189 | |||||||||||
| 190 | Example: | ||||||||||
| 191 | |||||||||||
| 192 | use HTML::Object::DOM qw( screen window ); | ||||||||||
| 193 | # Check the color depth of the screen | ||||||||||
| 194 | if( window->screen->colorDepth < 8 ) | ||||||||||
| 195 | { | ||||||||||
| 196 | # Use low-color version of page | ||||||||||
| 197 | } | ||||||||||
| 198 | else | ||||||||||
| 199 | { | ||||||||||
| 200 | # Use regular, colorful page | ||||||||||
| 201 | } | ||||||||||
| 202 | |||||||||||
| 203 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/colorDepth> | ||||||||||
| 204 | |||||||||||
| 205 | =head2 height | ||||||||||
| 206 | |||||||||||
| 207 | Normally this returns C<undef> under perl, but you can set whatever number value you want. | ||||||||||
| 208 | |||||||||||
| 209 | Under JavaScript, this returns the height of the screen in pixels. | ||||||||||
| 210 | |||||||||||
| 211 | Example: | ||||||||||
| 212 | |||||||||||
| 213 | my $height = window->screen->height | ||||||||||
| 214 | |||||||||||
| 215 | use HTML::Object::DOM qw( screen window ); | ||||||||||
| 216 | if( window->screen->availHeight !== window->screen->height ) | ||||||||||
| 217 | { | ||||||||||
| 218 | # Something is occupying some screen real estate! | ||||||||||
| 219 | } | ||||||||||
| 220 | |||||||||||
| 221 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/height> | ||||||||||
| 222 | |||||||||||
| 223 | =head2 left | ||||||||||
| 224 | |||||||||||
| 225 | Normally this returns C<undef> under perl, but you can set whatever number value you want. | ||||||||||
| 226 | |||||||||||
| 227 | Under JavaScript, this returns the distance in pixels from the left side of the main screen to the left side of the current screen. | ||||||||||
| 228 | |||||||||||
| 229 | Example: | ||||||||||
| 230 | |||||||||||
| 231 | use HTML::Object::DOM qw( screen window ); | ||||||||||
| 232 | my $left = window->screen->left; | ||||||||||
| 233 | |||||||||||
| 234 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/left> | ||||||||||
| 235 | |||||||||||
| 236 | =head2 lockOrientation | ||||||||||
| 237 | |||||||||||
| 238 | Under perl environment this returns C<undef> by default, but you can set whatever value you want. | ||||||||||
| 239 | |||||||||||
| 240 | Under JavaScript, this locks the screen into a specified orientation into which to lock the screen. This is either a string or an array of strings. Passing several strings lets the screen rotate only in the selected orientations. | ||||||||||
| 241 | |||||||||||
| 242 | Possible values that are not enforced under this perl interface are: | ||||||||||
| 243 | |||||||||||
| 244 | =over 4 | ||||||||||
| 245 | |||||||||||
| 246 | =item portrait-primary | ||||||||||
| 247 | |||||||||||
| 248 | It represents the orientation of the screen when it is in its primary portrait mode. A screen is considered in its primary portrait mode if the device is held in its normal position and that position is in portrait, or if the normal position of the device is in landscape and the device held turned by 90° clockwise. The normal position is device dependant. | ||||||||||
| 249 | |||||||||||
| 250 | =item portrait-secondary | ||||||||||
| 251 | |||||||||||
| 252 | It represents the orientation of the screen when it is in its secondary portrait mode. A screen is considered in its secondary portrait mode if the device is held 180° from its normal position and that position is in portrait, or if the normal position of the device is in landscape and the device held is turned by 90° counterclockwise. The normal position is device dependant. | ||||||||||
| 253 | |||||||||||
| 254 | =item landscape-primary | ||||||||||
| 255 | |||||||||||
| 256 | It represents the orientation of the screen when it is in its primary landscape mode. A screen is considered in its primary landscape mode if the device is held in its normal position and that position is in landscape, or if the normal position of the device is in portrait and the device held is turned by 90° clockwise. The normal position is device dependant. | ||||||||||
| 257 | |||||||||||
| 258 | =item landscape-secondary | ||||||||||
| 259 | |||||||||||
| 260 | It represents the orientation of the screen when it is in its secondary landscape mode. A screen is considered in its secondary landscape mode if the device held is 180° from its normal position and that position is in landscape, or if the normal position of the device is in portrait and the device held is turned by 90° counterclockwise. The normal position is device dependant. | ||||||||||
| 261 | |||||||||||
| 262 | =item portrait | ||||||||||
| 263 | |||||||||||
| 264 | It represents both portrait-primary and portrait-secondary. | ||||||||||
| 265 | |||||||||||
| 266 | =item landscape | ||||||||||
| 267 | |||||||||||
| 268 | It represents both landscape-primary and landscape-secondary. | ||||||||||
| 269 | |||||||||||
| 270 | =item default | ||||||||||
| 271 | |||||||||||
| 272 | It represents either portrait-primary and landscape-primary depends on natural orientation of devices. For example, if the panel resolution is 1280*800, default will make it landscape, if the resolution is 800*1280, default will make it to portrait. | ||||||||||
| 273 | |||||||||||
| 274 | =back | ||||||||||
| 275 | |||||||||||
| 276 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation> | ||||||||||
| 277 | |||||||||||
| 278 | =head2 mozBrightness | ||||||||||
| 279 | |||||||||||
| 280 | Normally this returns C<undef> under perl, but you can set whatever number value you want. | ||||||||||
| 281 | |||||||||||
| 282 | Under JavaScript, this Controls the brightness of a device's screen. A double between 0 and 1.0 is expected. | ||||||||||
| 283 | |||||||||||
| 284 | Example: | ||||||||||
| 285 | |||||||||||
| 286 | use HTML::Object::DOM qw( screen window ); | ||||||||||
| 287 | my $screenBrightness = window->screen->mozBrightness; | ||||||||||
| 288 | |||||||||||
| 289 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/mozBrightness> | ||||||||||
| 290 | |||||||||||
| 291 | =head2 mozEnabled | ||||||||||
| 292 | |||||||||||
| 293 | Normally this is read-only, but under perl you can set whatever boolean value you want. | ||||||||||
| 294 | |||||||||||
| 295 | Under JavaScript, when this is set to false, it will turn off the device's screen. | ||||||||||
| 296 | |||||||||||
| 297 | Example: | ||||||||||
| 298 | |||||||||||
| 299 | use HTML::Object::DOM qw( screen window ); | ||||||||||
| 300 | my $screenEnabled = window->screen->mozEnabled | ||||||||||
| 301 | |||||||||||
| 302 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/mozEnabled> | ||||||||||
| 303 | |||||||||||
| 304 | =head2 orientation | ||||||||||
| 305 | |||||||||||
| 306 | Normally this returns C<undef> under perl, but you can set whatever string value you want. This returns a L<scalar object|Module::Generic::Scalar> | ||||||||||
| 307 | |||||||||||
| 308 | Under JavaScript, this returns the C<ScreenOrientation> instance associated with this screen. | ||||||||||
| 309 | |||||||||||
| 310 | Example: | ||||||||||
| 311 | |||||||||||
| 312 | use HTML::Object::DOM qw( screen window ); | ||||||||||
| 313 | my $orientation = screen->$orientation; | ||||||||||
| 314 | |||||||||||
| 315 | my $orientation = screen->orientation; | ||||||||||
| 316 | |||||||||||
| 317 | if( $orientation == "landscape-primary" ) | ||||||||||
| 318 | { | ||||||||||
| 319 | say( "That looks good." ); | ||||||||||
| 320 | } | ||||||||||
| 321 | elsif( $orientation == "landscape-secondary" ) | ||||||||||
| 322 | { | ||||||||||
| 323 | say( "Mmmh... the screen is upside down!" ); | ||||||||||
| 324 | } | ||||||||||
| 325 | elsif( $orientation == "portrait-secondary" || $orientation == "portrait-primary" ) | ||||||||||
| 326 | { | ||||||||||
| 327 | say( "Mmmh... you should rotate your device to landscape" ); | ||||||||||
| 328 | } | ||||||||||
| 329 | elsif( $orientation == undefined ) | ||||||||||
| 330 | { | ||||||||||
| 331 | say( "The orientation API is not supported in this browser :(" ); | ||||||||||
| 332 | } | ||||||||||
| 333 | |||||||||||
| 334 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation> | ||||||||||
| 335 | |||||||||||
| 336 | =head2 pixelDepth | ||||||||||
| 337 | |||||||||||
| 338 | Normally this returns C<undef> under perl, but you can set whatever number value you want. | ||||||||||
| 339 | |||||||||||
| 340 | Under JavaScript, this gets the bit depth of the screen. | ||||||||||
| 341 | |||||||||||
| 342 | Example: | ||||||||||
| 343 | |||||||||||
| 344 | use HTML::Object::DOM qw( screen window ); | ||||||||||
| 345 | my $depth = window->screen->pixelDepth | ||||||||||
| 346 | |||||||||||
| 347 | # if there is not adequate bit depth | ||||||||||
| 348 | # choose a simpler color | ||||||||||
| 349 | if( window->screen->pixelDepth > 8 ) | ||||||||||
| 350 | { | ||||||||||
| 351 | $doc->style->color = "#FAEBD7"; | ||||||||||
| 352 | } | ||||||||||
| 353 | else | ||||||||||
| 354 | { | ||||||||||
| 355 | $doc->style->color = "#FFFFFF"; | ||||||||||
| 356 | } | ||||||||||
| 357 | |||||||||||
| 358 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/pixelDepth> | ||||||||||
| 359 | |||||||||||
| 360 | =head2 top | ||||||||||
| 361 | |||||||||||
| 362 | Normally this returns C<undef> under perl, but you can set whatever number value you want. | ||||||||||
| 363 | |||||||||||
| 364 | Under JavaScript, this returns the distance in pixels from the top side of the current screen. | ||||||||||
| 365 | |||||||||||
| 366 | Example: | ||||||||||
| 367 | |||||||||||
| 368 | use HTML::Object::DOM qw( screen window ); | ||||||||||
| 369 | my $top = window->screen->top; | ||||||||||
| 370 | |||||||||||
| 371 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/top> | ||||||||||
| 372 | |||||||||||
| 373 | =head2 width | ||||||||||
| 374 | |||||||||||
| 375 | Normally this returns C<undef> under perl, but you can set whatever number value you want. | ||||||||||
| 376 | |||||||||||
| 377 | Under JavaScript, this returns the width of the screen. | ||||||||||
| 378 | |||||||||||
| 379 | Example: | ||||||||||
| 380 | |||||||||||
| 381 | use HTML::Object::DOM qw( screen window ); | ||||||||||
| 382 | my $lWidth = window->screen->width | ||||||||||
| 383 | |||||||||||
| 384 | # Crude way to check that the screen is at least 1024x768 | ||||||||||
| 385 | if( window->screen->width >= 1024 && window->screen->height >= 768 ) | ||||||||||
| 386 | { | ||||||||||
| 387 | # Resolution is 1024x768 or above | ||||||||||
| 388 | } | ||||||||||
| 389 | |||||||||||
| 390 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/width> | ||||||||||
| 391 | |||||||||||
| 392 | =head1 METHODS | ||||||||||
| 393 | |||||||||||
| 394 | Inherits methods from its parent L<HTML::Object::EventTarget> | ||||||||||
| 395 | |||||||||||
| 396 | =head2 unlockOrientation | ||||||||||
| 397 | |||||||||||
| 398 | This always returns C<undef> under perl. | ||||||||||
| 399 | |||||||||||
| 400 | Normally, under JavaScript, this unlocks the screen orientation (only works in fullscreen or for installed apps) | ||||||||||
| 401 | |||||||||||
| 402 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Screen/unlockOrientation> | ||||||||||
| 403 | |||||||||||
| 404 | =head1 AUTHOR | ||||||||||
| 405 | |||||||||||
| 406 | Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> | ||||||||||
| 407 | |||||||||||
| 408 | =head1 SEE ALSO | ||||||||||
| 409 | |||||||||||
| 410 | L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Window> | ||||||||||
| 411 | |||||||||||
| 412 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 413 | |||||||||||
| 414 | Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||
| 415 | |||||||||||
| 416 | All rights reserved | ||||||||||
| 417 | |||||||||||
| 418 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||
| 419 | |||||||||||
| 420 | =cut | ||||||||||