Browse Source

trying to fix jsdoc error

sisyphus
Dustin Falgout 9 years ago
parent
commit
10398f0612
  1. 673
      themes/_vendor/js/mock.js

673
themes/_vendor/js/mock.js vendored

@ -30,7 +30,7 @@ let lightdm = null,
config = null, config = null,
MockData; MockData;
if ('undefined' !== typeof lightdm) { if ( 'undefined' !== typeof lightdm ) {
throw new Error('Cannot use LightDM Mock while the greeter is running!'); throw new Error('Cannot use LightDM Mock while the greeter is running!');
} }
@ -38,7 +38,7 @@ if ('undefined' !== typeof lightdm) {
* @ignore * @ignore
*/ */
String.prototype.capitalize = function() { String.prototype.capitalize = function() {
return this.charAt( 0 ).toUpperCase() + this.slice( 1 ); return this.charAt(0).toUpperCase() + this.slice(1);
}; };
@ -47,28 +47,30 @@ String.prototype.capitalize = function() {
* created by the theme's code, but rather by the {@link LightDMGreeter} class. * created by the theme's code, but rather by the {@link LightDMGreeter} class.
* @interface * @interface
*/ */
let LightDMSession = ({comment, key, name}) => ({ let LightDMSession = function( { comment, key, name } ) {
/** return {
* The comment for the session. /**
* @type {String} * The comment for the session.
* @readonly * @type {String}
*/ * @readonly
comment, */
comment,
/**
* The key for the session. /**
* @type {String} * The key for the session.
* @readonly * @type {String}
*/ * @readonly
key, */
key,
/**
* The name for the session. /**
* @type {String} * The name for the session.
* @readonly * @type {String}
*/ * @readonly
name */
}); name
}
};
/** /**
@ -76,28 +78,30 @@ let LightDMSession = ({comment, key, name}) => ({
* created by the theme's code, but rather by the {@link LightDMGreeter} class. * created by the theme's code, but rather by the {@link LightDMGreeter} class.
* @interface * @interface
*/ */
let LightDMLanguage = ({code, name, territory}) => ({ let LightDMLanguage = function( { code, name, territory } ) {
/** return {
* The code for the language. /**
* @type {String} * The code for the language.
* @readonly * @type {String}
*/ * @readonly
code, */
code,
/**
* The name for the language. /**
* @type {String} * The name for the language.
* @readonly * @type {String}
*/ * @readonly
name, */
name,
/**
* The territory for the language. /**
* @type {String} * The territory for the language.
* @readonly * @type {String}
*/ * @readonly
territory */
}); territory
}
};
/** /**
@ -105,28 +109,30 @@ let LightDMLanguage = ({code, name, territory}) => ({
* objects are not created by the theme's code, but rather by the {@link LightDMGreeter} class. * objects are not created by the theme's code, but rather by the {@link LightDMGreeter} class.
* @interface * @interface
*/ */
let LightDMLayout = ({description, name, short_description}) => ({ let LightDMLayout = function( { description, name, short_description } ) {
/** return {
* The description for the layout. /**
* @type {String} * The description for the layout.
* @readonly * @type {String}
*/ * @readonly
description, */
description,
/**
* The name for the layout. /**
* @type {String} * The name for the layout.
* @readonly * @type {String}
*/ * @readonly
name, */
name,
/**
* The territory for the layout. /**
* @type {String} * The territory for the layout.
* @readonly * @type {String}
*/ * @readonly
short_description */
}); short_description
}
};
/** /**
@ -134,79 +140,81 @@ let LightDMLayout = ({description, name, short_description}) => ({
* objects are not created by the theme's code, but rather by the {@link LightDMGreeter} class. * objects are not created by the theme's code, but rather by the {@link LightDMGreeter} class.
* @interface * @interface
*/ */
let LightDMUser = ( user_info ) => ({ let LightDMUser = function( user_info ) {
/** return {
* The display name for the user. /**
* @type {String} * The display name for the user.
* @readonly * @type {String}
*/ * @readonly
display_name: user_info.display_name || '', */
display_name: user_info.display_name || '',
/**
* The language for the user. /**
* @type {String} * The language for the user.
* @readonly * @type {String}
*/ * @readonly
language: user_info.language || '', */
language: user_info.language || '',
/**
* The keyboard layout for the user. /**
* @type {String} * The keyboard layout for the user.
* @readonly * @type {String}
*/ * @readonly
layout: user_info.layout || '', */
layout: user_info.layout || '',
/**
* The image for the user. /**
* @type {String} * The image for the user.
* @readonly * @type {String}
*/ * @readonly
image: user_info.image || '', */
image: user_info.image || '',
/**
* The home_directory for the user. /**
* @type {String} * The home_directory for the user.
* @readonly * @type {String}
*/ * @readonly
home_directory: user_info.home_directory || '', */
home_directory: user_info.home_directory || '',
/**
* The username for the user. /**
* @type {String} * The username for the user.
* @readonly * @type {String}
*/ * @readonly
username: user_info.username || '', */
username: user_info.username || '',
/**
* Whether or not the user is currently logged in. /**
* @type {Boolean} * Whether or not the user is currently logged in.
* @readonly * @type {Boolean}
*/ * @readonly
logged_in: user_info.logged_in || false, */
logged_in: user_info.logged_in || false,
/**
* The last session that the user logged into. /**
* @type {String|null} * The last session that the user logged into.
* @readonly * @type {String|null}
*/ * @readonly
session: user_info.session || '', */
session: user_info.session || '',
/**
* DEPRECATED! /**
* @deprecated See {@link LightDMUser.username}. * DEPRECATED!
* @type {String} * @deprecated See {@link LightDMUser.username}.
* @readonly * @type {String}
*/ * @readonly
name: user_info.name || '', */
name: user_info.name || '',
/**
* DEPRECATED! /**
* @deprecated See {@link LightDMUser.display_name}. * DEPRECATED!
* @type {String} * @deprecated See {@link LightDMUser.display_name}.
* @readonly * @type {String}
*/ * @readonly
real_name: user_info.real_name || '' */
}); real_name: user_info.real_name || ''
}
};
/** /**
@ -228,7 +236,7 @@ let MockObjects = {
class GreeterUtil { class GreeterUtil {
constructor() { constructor() {
if (null !== greeter_util) { if ( null !== greeter_util ) {
return greeter_util; return greeter_util;
} }
@ -253,9 +261,14 @@ class GreeterUtil {
* @returns {String} * @returns {String}
*/ */
txt2html( text ) { txt2html( text ) {
let entities_map = { '"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;' }; let entities_map = {
'"': '&quot;',
'&': '&amp;',
'<': '&lt;',
'>': '&gt;'
};
return text.replace(/[\"&<>]/g, a => entities_map[a] ); return text.replace(/[\"&<>]/g, a => entities_map[a]);
} }
} }
@ -269,7 +282,7 @@ class GreeterUtil {
class ConfigFile { class ConfigFile {
constructor() { constructor() {
if (null !== config) { if ( null !== config ) {
return config; return config;
} }
@ -284,7 +297,7 @@ class ConfigFile {
* @returns {Boolean} Config value for `key`. * @returns {Boolean} Config value for `key`.
*/ */
getbool( key ) { getbool( key ) {
return ( key in this._mock_data.config ) ? Boolean( this._mock_data.config[key] ) : false; return ( key in this._mock_data.config ) ? Boolean(this._mock_data.config[key]) : false;
} }
/** /**
@ -294,7 +307,7 @@ class ConfigFile {
* @returns {Number} Config value for `key`. * @returns {Number} Config value for `key`.
*/ */
getnum( key ) { getnum( key ) {
return ( key in this._mock_data.config ) ? parseInt( this._mock_data.config[key] ) : 0; return ( key in this._mock_data.config ) ? parseInt(this._mock_data.config[key]) : 0;
} }
/** /**
@ -353,7 +366,7 @@ class LightDMGreeter {
ObjectClass = `LightDM${object_name}`; ObjectClass = `LightDM${object_name}`;
for ( let object_info of this._mock_data[object_type] ) { for ( let object_info of this._mock_data[object_type] ) {
this[object_type].push( MockObjects[ObjectClass]( object_info ) ); this[object_type].push(MockObjects[ObjectClass](object_info));
} }
} }
} }
@ -362,7 +375,7 @@ class LightDMGreeter {
* @private * @private
*/ */
_set_default_property_values() { _set_default_property_values() {
for ( let property_type of Object.keys( this._mock_data.greeter.properties ) ) { for ( let property_type of Object.keys(this._mock_data.greeter.properties) ) {
for ( let property of this._mock_data.greeter.properties[property_type] ) { for ( let property of this._mock_data.greeter.properties[property_type] ) {
if ( property.indexOf('can_') > -1 ) { if ( property.indexOf('can_') > -1 ) {
// System Power Actions // System Power Actions
@ -530,7 +543,7 @@ class LightDMGreeter {
return this._layout; return this._layout;
} }
set layout(value) { set layout( value ) {
this._layout = value; this._layout = value;
} }
@ -632,7 +645,7 @@ class LightDMGreeter {
* @returns {Boolean} {@link true} if hibernation initiated, otherwise {@link false} * @returns {Boolean} {@link true} if hibernation initiated, otherwise {@link false}
*/ */
hibernate() { hibernate() {
return this._do_mocked_system_action( 'hibernate' ); return this._do_mocked_system_action('hibernate');
} }
/** /**
@ -646,7 +659,7 @@ class LightDMGreeter {
* @returns {Boolean} {@link true} if restart initiated, otherwise {@link false} * @returns {Boolean} {@link true} if restart initiated, otherwise {@link false}
*/ */
restart() { restart() {
return this._do_mocked_system_action( 'restart' ); return this._do_mocked_system_action('restart');
} }
/** /**
@ -662,7 +675,7 @@ class LightDMGreeter {
* @returns {Boolean} {@link true} if shutdown initiated, otherwise {@link false} * @returns {Boolean} {@link true} if shutdown initiated, otherwise {@link false}
*/ */
shutdown() { shutdown() {
return this._do_mocked_system_action( 'shutdown' ); return this._do_mocked_system_action('shutdown');
} }
/** /**
@ -677,7 +690,7 @@ class LightDMGreeter {
* @returns {Boolean} {@link true} if suspend/sleep initiated, otherwise {@link false} * @returns {Boolean} {@link true} if suspend/sleep initiated, otherwise {@link false}
*/ */
suspend() { suspend() {
return this._do_mocked_system_action( 'suspend' ); return this._do_mocked_system_action('suspend');
} }
} }
@ -688,7 +701,13 @@ class LightDMGreeter {
*/ */
MockData = () => ({ MockData = () => ({
greeter: { greeter: {
default_values: {string: () => '', int: () => 0, bool: () => false, list: () => [], 'null': () => null}, default_values: {
string: () => '',
int: () => 0,
bool: () => false,
list: () => [],
'null': () => null
},
hostname: 'Mock Greeter', hostname: 'Mock Greeter',
properties: { properties: {
string: ['authentication_user', 'autologin_user', 'default_session', 'hostname', 'num_users'], string: ['authentication_user', 'autologin_user', 'default_session', 'hostname', 'num_users'],
@ -703,21 +722,65 @@ MockData = () => ({
} }
}, },
languages: [ languages: [
{name: 'English', code: 'en_US.utf8', territory: 'USA'}, {
{name: 'Catalan', code: 'ca_ES.utf8', territory: 'Spain'}, name: 'English',
{name: 'French', code: 'fr_FR.utf8', territory: 'France'} code: 'en_US.utf8',
territory: 'USA'
},
{
name: 'Catalan',
code: 'ca_ES.utf8',
territory: 'Spain'
},
{
name: 'French',
code: 'fr_FR.utf8',
territory: 'France'
}
], ],
layouts: [ layouts: [
{name: 'us', short_description: 'en', description: 'English (US)'}, {
{name: 'at', short_description: 'de', description: 'German (Austria)'}, name: 'us',
{name: 'us rus', short_description: 'ru', description: 'Russian (US, phonetic)'} short_description: 'en',
description: 'English (US)'
},
{
name: 'at',
short_description: 'de',
description: 'German (Austria)'
},
{
name: 'us rus',
short_description: 'ru',
description: 'Russian (US, phonetic)'
}
], ],
sessions: [ sessions: [
{key: 'gnome', name: 'GNOME', comment: 'This session logs you into GNOME'}, {
{key: 'cinnamon', name: 'Cinnamon', comment: 'This session logs you into Cinnamon'}, key: 'gnome',
{key: 'plasma', name: 'Plasma', comment: 'Plasma by KDE'}, name: 'GNOME',
{key: 'mate', name: 'MATE', comment: 'This session logs you into MATE'}, comment: 'This session logs you into GNOME'
{key: 'openbox', name: 'Openbox', comment: 'This session logs you into Openbox'} },
{
key: 'cinnamon',
name: 'Cinnamon',
comment: 'This session logs you into Cinnamon'
},
{
key: 'plasma',
name: 'Plasma',
comment: 'Plasma by KDE'
},
{
key: 'mate',
name: 'MATE',
comment: 'This session logs you into MATE'
},
{
key: 'openbox',
name: 'Openbox',
comment: 'This session logs you into Openbox'
}
], ],
users: [ users: [
{ {
@ -770,142 +833,142 @@ new LightDMGreeter();
// mock lighdm for testing // mock lighdm for testing
/* /*
lightdm.provide_secret = function (secret) { lightdm.provide_secret = function (secret) {
if (typeof lightdm._username == 'undefined' || !lightdm._username) { if (typeof lightdm._username == 'undefined' || !lightdm._username) {
throw "must call start_authentication first" throw "must call start_authentication first"
} }
_lightdm_mock_check_argument_length(arguments, 1); _lightdm_mock_check_argument_length(arguments, 1);
var user = _lightdm_mock_get_user(lightdm.username); var user = _lightdm_mock_get_user(lightdm.username);
if (!user && secret == lightdm._username) { if (!user && secret == lightdm._username) {
lightdm.is_authenticated = true; lightdm.is_authenticated = true;
lightdm.authentication_user = user; lightdm.authentication_user = user;
} else { } else {
lightdm.is_authenticated = false; lightdm.is_authenticated = false;
lightdm.authentication_user = null; lightdm.authentication_user = null;
lightdm._username = null; lightdm._username = null;
} }
authentication_complete(); authentication_complete();
}; };
lightdm.start_authentication = function (username) { lightdm.start_authentication = function (username) {
if ('undefined' === typeof username) { if ('undefined' === typeof username) {
show_prompt("Username?", 'text'); show_prompt("Username?", 'text');
lightdm.awaiting_username = true; lightdm.awaiting_username = true;
return; return;
} }
_lightdm_mock_check_argument_length(arguments, 1); _lightdm_mock_check_argument_length(arguments, 1);
if (lightdm._username) { if (lightdm._username) {
throw "Already authenticating!"; throw "Already authenticating!";
} }
var user = _lightdm_mock_get_user(username); var user = _lightdm_mock_get_user(username);
if (!user) { if (!user) {
show_error(username + " is an invalid user"); show_error(username + " is an invalid user");
} }
show_prompt("Password: "); show_prompt("Password: ");
lightdm._username = username; lightdm._username = username;
}; };
lightdm.cancel_authentication = function () { lightdm.cancel_authentication = function () {
_lightdm_mock_check_argument_length(arguments, 0); _lightdm_mock_check_argument_length(arguments, 0);
if (!lightdm._username) { if (!lightdm._username) {
console.log("we are not authenticating"); console.log("we are not authenticating");
} }
lightdm._username = null; lightdm._username = null;
}; };
lightdm.suspend = function () { lightdm.suspend = function () {
alert("System Suspended. Bye Bye"); alert("System Suspended. Bye Bye");
document.location.reload(true); document.location.reload(true);
}; };
lightdm.hibernate = function () { lightdm.hibernate = function () {
alert("System Hibernated. Bye Bye"); alert("System Hibernated. Bye Bye");
document.location.reload(true); document.location.reload(true);
}; };
lightdm.restart = function () { lightdm.restart = function () {
alert("System restart. Bye Bye"); alert("System restart. Bye Bye");
document.location.reload(true); document.location.reload(true);
}; };
lightdm.shutdown = function () { lightdm.shutdown = function () {
alert("System Shutdown. Bye Bye"); alert("System Shutdown. Bye Bye");
document.location.reload(true); document.location.reload(true);
}; };
lightdm.login = function (user, session) { lightdm.login = function (user, session) {
_lightdm_mock_check_argument_length(arguments, 2); _lightdm_mock_check_argument_length(arguments, 2);
if (!lightdm.is_authenticated) { if (!lightdm.is_authenticated) {
throw "The system is not authenticated"; throw "The system is not authenticated";
} }
if (user !== lightdm.authentication_user) { if (user !== lightdm.authentication_user) {
throw "this user is not authenticated"; throw "this user is not authenticated";
} }
alert("logged in successfully!!"); alert("logged in successfully!!");
document.location.reload(true); document.location.reload(true);
}; };
lightdm.authenticate = function (session) { lightdm.authenticate = function (session) {
lightdm.login(null, session); lightdm.login(null, session);
}; };
lightdm.respond = function (response) { lightdm.respond = function (response) {
if (true === lightdm.awaiting_username) { if (true === lightdm.awaiting_username) {
lightdm.awaiting_username = false; lightdm.awaiting_username = false;
lightdm.start_authentication(response); lightdm.start_authentication(response);
} else { } else {
lightdm.provide_secret(response); lightdm.provide_secret(response);
} }
}; };
lightdm.start_session_sync = function () { lightdm.start_session_sync = function () {
lightdm.login(null, null); lightdm.login(null, null);
}; };
if (lightdm.timed_login_delay > 0) { if (lightdm.timed_login_delay > 0) {
setTimeout(function () { setTimeout(function () {
if (!lightdm._timed_login_cancelled()) { if (!lightdm._timed_login_cancelled()) {
timed_login(); timed_login();
} }
}, lightdm.timed_login_delay); }, lightdm.timed_login_delay);
} }
var config = {}, greeterutil = {}; var config = {}, greeterutil = {};
config.get_str = function (section, key) { config.get_str = function (section, key) {
var branding = { var branding = {
logo: 'img/antergos.png', logo: 'img/antergos.png',
user_logo: 'ing/antergos-logo-user.png', user_logo: 'ing/antergos-logo-user.png',
background_images: '/usr/share/antergos/wallpapers' background_images: '/usr/share/antergos/wallpapers'
}; };
if ('branding' === section) { if ('branding' === section) {
return branding[key]; return branding[key];
} }
}; };
config.get_bool = function (section, key) { config.get_bool = function (section, key) {
return true; return true;
}; };
greeterutil.dirlist = function (directory) { greeterutil.dirlist = function (directory) {
if ('/usr/share/antergos/wallpapers' === directory) { if ('/usr/share/antergos/wallpapers' === directory) {
return ['/usr/share/antergos/wallpapers/83II_by_bo0xVn.jpg', '/usr/share/antergos/wallpapers/antergos-wallpaper.png', '/usr/share/antergos/wallpapers/as_time_goes_by____by_moskanon-d5dgvt8.jpg', '/usr/share/antergos/wallpapers/autumn_hike___plant_details_by_aoiban-d5l7y83.jpg', '/usr/share/antergos/wallpapers/blossom_by_snipes2.jpg', '/usr/share/antergos/wallpapers/c65sk3mshowxrtlljbvh.jpg', '/usr/share/antergos/wallpapers/early_morning_by_kylekc.jpg', '/usr/share/antergos/wallpapers/extinction_by_signcropstealer-d5j4y84.jpg', '/usr/share/antergos/wallpapers/field_by_stevenfields-d59ap2i.jpg', '/usr/share/antergos/wallpapers/Grass_by_masha_darkelf666.jpg', '/usr/share/antergos/wallpapers/Grass_Fullscreen.jpg', '/usr/share/antergos/wallpapers/humble_by_splendidofsun-d5g47hb.jpg', '/usr/share/antergos/wallpapers/In_the_Grass.jpg', '/usr/share/antergos/wallpapers/morning_light.jpg', '/usr/share/antergos/wallpapers/Nautilus_Fullscreen.jpg', '/usr/share/antergos/wallpapers/nikon_d40.jpg', '/usr/share/antergos/wallpapers/sky_full_of_stars.jpg', '/usr/share/antergos/wallpapers/solely_by_stevenfields.jpg', '/usr/share/antergos/wallpapers/the_world_inside_my_lens__by_moskanon-d5fsiqs.jpg', '/usr/share/antergos/wallpapers/white_line_by_snipes2.jpg'] return ['/usr/share/antergos/wallpapers/83II_by_bo0xVn.jpg', '/usr/share/antergos/wallpapers/antergos-wallpaper.png', '/usr/share/antergos/wallpapers/as_time_goes_by____by_moskanon-d5dgvt8.jpg', '/usr/share/antergos/wallpapers/autumn_hike___plant_details_by_aoiban-d5l7y83.jpg', '/usr/share/antergos/wallpapers/blossom_by_snipes2.jpg', '/usr/share/antergos/wallpapers/c65sk3mshowxrtlljbvh.jpg', '/usr/share/antergos/wallpapers/early_morning_by_kylekc.jpg', '/usr/share/antergos/wallpapers/extinction_by_signcropstealer-d5j4y84.jpg', '/usr/share/antergos/wallpapers/field_by_stevenfields-d59ap2i.jpg', '/usr/share/antergos/wallpapers/Grass_by_masha_darkelf666.jpg', '/usr/share/antergos/wallpapers/Grass_Fullscreen.jpg', '/usr/share/antergos/wallpapers/humble_by_splendidofsun-d5g47hb.jpg', '/usr/share/antergos/wallpapers/In_the_Grass.jpg', '/usr/share/antergos/wallpapers/morning_light.jpg', '/usr/share/antergos/wallpapers/Nautilus_Fullscreen.jpg', '/usr/share/antergos/wallpapers/nikon_d40.jpg', '/usr/share/antergos/wallpapers/sky_full_of_stars.jpg', '/usr/share/antergos/wallpapers/solely_by_stevenfields.jpg', '/usr/share/antergos/wallpapers/the_world_inside_my_lens__by_moskanon-d5fsiqs.jpg', '/usr/share/antergos/wallpapers/white_line_by_snipes2.jpg']
} }
} }
} }
function _lightdm_mock_check_argument_length(args, length) { function _lightdm_mock_check_argument_length(args, length) {
if (args.length != length) { if (args.length != length) {
throw "incorrect number of arguments in function call"; throw "incorrect number of arguments in function call";
} }
} }
function _lightdm_mock_get_user(username) { function _lightdm_mock_get_user(username) {
var user = null; var user = null;
for (var i = 0; i < lightdm.users.length; ++i) { for (var i = 0; i < lightdm.users.length; ++i) {
if (lightdm.users[i].name == username) { if (lightdm.users[i].name == username) {
user = lightdm.users[i]; user = lightdm.users[i];
break; break;
} }
} }
return user; return user;
} }
*/ */

Loading…
Cancel
Save