Browse Source

only compile parts of es6 syntax that webkit doesn't support yet.

sisyphus
Dustin Falgout 9 years ago
parent
commit
a8da155ee1
  1. 8
      themes/antergos/.babelrc
  2. 6
      themes/antergos/index.html
  3. 53
      themes/antergos/js/greeter-compiled.js
  4. 2
      themes/antergos/js/greeter-compiled.js.map
  5. 43
      themes/antergos/js/greeter.js
  6. 312
      themes/antergos/js/mock.js

8
themes/antergos/.babelrc

@ -1,10 +1,14 @@
{
"plugins": [
[
"/usr/lib/node_modules/babel-plugin-transform-es2015-spread",
"transform-es2015-spread",
{
"loose": true
}
]
],
["transform-object-rest-spread"],
["syntax-class-constructor-call"],
["syntax-class-properties"],
["transform-es2015-parameters"]
]
}

6
themes/antergos/index.html

@ -247,10 +247,6 @@
} );
$( '*' ).each( function() {
$( this ).attr( 'tabindex', - 1 );
} );
$( '#collapseTwo' ).on( 'shown.bs.collapse', function() {
$( '#collapseTwo a' ).filter( ':not(.dropdown-menu *)' ).each( function( index ) {
var i = index + 1;
@ -259,7 +255,7 @@
} );
$( '#collapseTwo' ).on( 'hidden.bs.collapse', function() {
$( '#collapseTwo a' ).filter( ':not(.dropdown-menu *)' ).each( function( index ) {
$( this ).attr( 'tabindex', - 1 );
$( this ).attr( 'tabindex', -1 );
} );
} );

53
themes/antergos/js/greeter-compiled.js

@ -29,8 +29,8 @@
/**
* This is used to access our classes from within jQuery callbacks.
*/
let _self = null;
let _bg_self = null;
var _self = null,
_bg_self = null;
/**
* Capitalize a string.
@ -47,7 +47,7 @@ String.prototype.capitalize = function () {
class GreeterThemeComponent {
constructor() {
this.debug = this.cache_get('debug', 'enabled');
this.debug = true;
this.lang = window.navigator.language.split('-')[0].toLowerCase();
this.translations = window.ant_translations;
@ -64,7 +64,7 @@ class GreeterThemeComponent {
* @param {string} text - To be added to the log.
*/
log(text) {
if ('true' === this.debug) {
if (true === this.debug) {
console.log(text);
}
$('#logArea').append(`${ text }<br/>`);
@ -76,9 +76,13 @@ class GreeterThemeComponent {
*
* @param {...string} key_parts - Strings that are combined to form the key.
*/
cache_get(...key_parts) {
cache_get() {
var key = `ant`;
for (var _len = arguments.length, key_parts = Array(_len), _key = 0; _key < _len; _key++) {
key_parts[_key] = arguments[_key];
}
for (var part of key_parts) {
key += `:${ part }`;
}
@ -92,9 +96,13 @@ class GreeterThemeComponent {
* @param {string} value - The value to set.
* @param {...string} key_parts - Strings that are combined to form the key.
*/
cache_set(value, ...key_parts) {
cache_set(value) {
var key = `ant`;
for (var _len2 = arguments.length, key_parts = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
key_parts[_key2 - 1] = arguments[_key2];
}
for (var part of key_parts) {
key += `:${ part }`;
}
@ -105,7 +113,7 @@ class GreeterThemeComponent {
* Get some values from `lightdm-webkit2-greeter.conf` and save them for later.
*/
init_config_values() {
let logo = '',
var logo = '',
user_image = '',
background_images = [],
background_images_dir = '';
@ -146,7 +154,6 @@ class AntergosBackgroundManager extends GreeterThemeComponent {
constructor() {
super();
if (null === _bg_self) {
_bg_self = this;
}
@ -185,23 +192,27 @@ class AntergosBackgroundManager extends GreeterThemeComponent {
if ('true' === random_background || !current_background) {
current_background = this.get_random_image();
this.cache_set('true', 'background_manager', 'random_background');
}
this.current_background = current_background;
this.cache_set(this.current_background, 'background_manager', 'current_background');
}
this.do_background();
}
do_background() {
$('.header').fadeTo(300, 0.5, function () {
let tpl = `url('file://${ this.current_background }')`;
$('.header').css("background-image", tpl);
}).fadeTo(300, 1);
if ('undefined' !== typeof this.current_background) {
$('.header').fadeTo(300, 0.5, function () {
var tpl = `url(${ this.current_background })`;
$('.header').css("background-image", tpl);
}).fadeTo(300, 1);
}
}
get_random_image() {
let random_bg;
var random_bg;
random_bg = Math.floor(Math.random() * this.background_images.length);
@ -211,7 +222,7 @@ class AntergosBackgroundManager extends GreeterThemeComponent {
setup_background_thumbnails() {
if (this.background_images.length) {
for (var image_file of this.background_images) {
let $link = $('<a href="#"><img>'),
var $link = $('<a href="#"><img>'),
$img_el = $link.children('img'),
tpl = `file://${ image_file }`;
@ -224,17 +235,17 @@ class AntergosBackgroundManager extends GreeterThemeComponent {
}
background_selected_handler(event) {
let img = $(this).attr('data-img');
var img = $(this).attr('data-img');
if ('random' === img) {
this.cache_set('true', 'background_manager', 'randmom_background');
img = this.get_random_image();
_bg_self.cache_set('true', 'background_manager', 'random_background');
img = _bg_self.get_random_image();
}
this.cache_set(img, 'background_manager', 'current_background');
this.current_background = img;
_bg_self.cache_set(img, 'background_manager', 'current_background');
_bg_self.current_background = img;
this.do_background();
_bg_self.do_background();
}
}
@ -400,7 +411,7 @@ class AntergosTheme extends GreeterThemeComponent {
this.$clock.html(moment().format(format));
setInterval(() => {
this.$clock.html(moment().format(format));
_self.$clock.html(moment().format(format));
}, 60000);
}

2
themes/antergos/js/greeter-compiled.js.map

File diff suppressed because one or more lines are too long

43
themes/antergos/js/greeter.js

@ -30,8 +30,8 @@
/**
* This is used to access our classes from within jQuery callbacks.
*/
let _self = null;
let _bg_self = null;
var _self = null,
_bg_self = null;
/**
@ -54,7 +54,7 @@ String.prototype.capitalize = function() {
class GreeterThemeComponent {
constructor() {
this.debug = this.cache_get( 'debug', 'enabled' );
this.debug = true;
this.lang = window.navigator.language.split( '-' )[ 0 ].toLowerCase();
this.translations = window.ant_translations;
@ -72,7 +72,7 @@ class GreeterThemeComponent {
* @param {string} text - To be added to the log.
*/
log( text ) {
if ( 'true' === this.debug ) {
if ( true === this.debug ) {
console.log( text );
}
$( '#logArea' ).append( `${text}<br/>` );
@ -116,7 +116,7 @@ class GreeterThemeComponent {
* Get some values from `lightdm-webkit2-greeter.conf` and save them for later.
*/
init_config_values() {
let logo = '', user_image = '', background_images = [], background_images_dir = '';
var logo = '', user_image = '', background_images = [], background_images_dir = '';
if ( 'undefined' !== typeof config ) {
if ( this instanceof AntergosTheme ) {
@ -160,7 +160,6 @@ class AntergosBackgroundManager extends GreeterThemeComponent {
constructor() {
super();
if ( null === _bg_self ) {
_bg_self = this;
}
@ -201,9 +200,11 @@ class AntergosBackgroundManager extends GreeterThemeComponent {
if ( 'true' === random_background || ! current_background ) {
current_background = this.get_random_image();
this.cache_set( 'true', 'background_manager', 'random_background' );
}
this.current_background = current_background;
this.cache_set( this.current_background, 'background_manager', 'current_background' );
}
this.do_background();
@ -211,15 +212,17 @@ class AntergosBackgroundManager extends GreeterThemeComponent {
do_background() {
$( '.header' ).fadeTo( 300, 0.5, function() {
let tpl = `url('file://${this.current_background}')`;
$( '.header' ).css( "background-image", tpl );
} ).fadeTo( 300, 1 );
if ('undefined' !== typeof this.current_background) {
$( '.header' ).fadeTo( 300, 0.5, function() {
var tpl = `url(${this.current_background})`;
$( '.header' ).css("background-image", tpl );
} ).fadeTo( 300, 1 );
}
}
get_random_image() {
let random_bg;
var random_bg;
random_bg = Math.floor( Math.random() * this.background_images.length );
@ -229,7 +232,7 @@ class AntergosBackgroundManager extends GreeterThemeComponent {
setup_background_thumbnails() {
if (this.background_images.length) {
for ( var image_file of this.background_images ) {
let $link = $('<a href="#"><img>'),
var $link = $('<a href="#"><img>'),
$img_el = $link.children('img'),
tpl = `file://${image_file}`;
@ -243,17 +246,17 @@ class AntergosBackgroundManager extends GreeterThemeComponent {
background_selected_handler( event ) {
let img = $(this).attr('data-img');
var img = $(this).attr('data-img');
if ('random' === img) {
this.cache_set('true', 'background_manager', 'randmom_background' );
img = this.get_random_image();
_bg_self.cache_set('true', 'background_manager', 'random_background' );
img = _bg_self.get_random_image();
}
this.cache_set(img, 'background_manager', 'current_background' );
this.current_background = img;
_bg_self.cache_set(img, 'background_manager', 'current_background' );
_bg_self.current_background = img;
this.do_background();
_bg_self.do_background();
}
}
@ -262,8 +265,6 @@ class AntergosBackgroundManager extends GreeterThemeComponent {
/**
* This is the theme's main class object. It contains almost all the theme's logic.
*/
@ -430,7 +431,7 @@ class AntergosTheme extends GreeterThemeComponent {
this.$clock.html( moment().format( format ) );
setInterval( () => {
this.$clock.html( moment().format( format ) );
_self.$clock.html( moment().format( format ) );
}, 60000 );
}

312
themes/antergos/js/mock.js

@ -27,152 +27,270 @@
*/
// mock lighdm for testing
if (typeof lightdm == 'undefined') {
lightdm= {};
lightdm.hostname="test-host";
lightdm.languages= [{code: "en_US", name: "English(US)", territory: "USA"}, {code: "en_UK", name: "English(UK)", territory: "UK"}];
lightdm.default_language= lightdm.languages[0];
lightdm.layouts= [{name: "test", short_description: "test description", short_description:"really long epic description"}];
lightdm.default_layout= lightdm.layouts[0];
lightdm.layout= lightdm.layouts[0];
lightdm.sessions=[{key: "gnome", name: "gnome", comment: "no comment"}, {key: "cinnamon", name: "cinnamon", comment: "no comment"},{key: "openbox", name: "openbox", comment: "no comment"}, {key: "key4", name: "kde", comment: "no comment"}];
lightdm.default_session=lightdm.sessions[0]['name'];
lightdm.authentication_user= null;
lightdm.is_authenticated= false;
lightdm.can_suspend= true;
lightdm.can_hibernate= true;
lightdm.can_restart= true;
lightdm.can_shutdown= true;
if ( typeof lightdm == 'undefined' ) {
lightdm = {};
lightdm.hostname = "test-host";
lightdm.languages = [ {
code: "en_US",
name: "English(US)",
territory: "USA"
}, { code: "en_UK", name: "English(UK)", territory: "UK" } ];
lightdm.default_language = lightdm.languages[ 0 ];
lightdm.layouts = [ {
name: "test",
short_description: "test description",
short_description: "really long epic description"
} ];
lightdm.default_layout = lightdm.layouts[ 0 ];
lightdm.layout = lightdm.layouts[ 0 ];
lightdm.sessions = [ { key: "gnome", name: "gnome", comment: "no comment" }, {
key: "cinnamon",
name: "cinnamon",
comment: "no comment"
}, { key: "openbox", name: "openbox", comment: "no comment" }, {
key: "key4",
name: "kde",
comment: "no comment"
} ];
lightdm.default_session = lightdm.sessions[ 0 ][ 'name' ];
lightdm.authentication_user = null;
lightdm.is_authenticated = false;
lightdm.can_suspend = true;
lightdm.can_hibernate = true;
lightdm.can_restart = true;
lightdm.can_shutdown = true;
lightdm.awaiting_username = false;
lightdm.users = [
{ name: "clarkk", real_name: "Superman", display_name: "Clark Kent", image: "", language: "en_US", layout: null, session: "gnome", logged_in: false },
{ name: "brucew", real_name: "Batman", display_name: "Bruce Wayne", image: "", language: "en_US", layout: null, session: "cinnamon", logged_in: false},
{ name: "peterp", real_name: "Spiderman", display_name: "Peter Parker", image: "", language: "en_US", layout: null, session: "gnome", logged_in: true},
{ name: "clarkk2", real_name: "Superman", display_name: "Clark Kent", image: "", language: "en_US", layout: null, session: "gnome", logged_in: false },
{ name: "brucew2", real_name: "Batman", display_name: "Bruce Wayne", image: "", language: "en_US", layout: null, session: "cinnamon", logged_in: false},
{ name: "peterp2", real_name: "Spiderman", display_name: "Peter Parker", image: "", language: "en_US", layout: null, session: "gnome", logged_in: true}
];
lightdm.num_users= lightdm.users.length;
lightdm.timed_login_delay= 0; //set to a number higher than 0 for timed login simulation
lightdm.timed_login_user= lightdm.timed_login_delay > 0 ? lightdm.users[0] : null;
lightdm.get_string_property= function() {};
lightdm.get_integer_property= function() {};
lightdm.get_boolean_property= function() {};
lightdm.cancel_timed_login= function() {
_lightdm_mock_check_argument_length(arguments, 0);
lightdm._timed_login_cancelled= true;
};
lightdm.provide_secret= function(secret) {
if (typeof lightdm._username == 'undefined' || !lightdm._username) {
{
name: "clarkk",
real_name: "Superman",
display_name: "Clark Kent",
image: "",
language: "en_US",
layout: null,
session: "gnome",
logged_in: false
},
{
name: "brucew",
real_name: "Batman",
display_name: "Bruce Wayne",
image: "",
language: "en_US",
layout: null,
session: "cinnamon",
logged_in: false
},
{
name: "peterp",
real_name: "Spiderman",
display_name: "Peter Parker",
image: "",
language: "en_US",
layout: null,
session: "gnome",
logged_in: true
},
{
name: "clarkk2",
real_name: "Superman",
display_name: "Clark Kent",
image: "",
language: "en_US",
layout: null,
session: "gnome",
logged_in: false
},
{
name: "brucew2",
real_name: "Batman",
display_name: "Bruce Wayne",
image: "",
language: "en_US",
layout: null,
session: "cinnamon",
logged_in: false
},
{
name: "peterp2",
real_name: "Spiderman",
display_name: "Peter Parker",
image: "",
language: "en_US",
layout: null,
session: "gnome",
logged_in: true
}
];
lightdm.num_users = lightdm.users.length;
lightdm.timed_login_delay = 0; //set to a number higher than 0 for timed login simulation
lightdm.timed_login_user = lightdm.timed_login_delay > 0 ? lightdm.users[ 0 ] : null;
lightdm.get_string_property = function() {
};
lightdm.get_integer_property = function() {
};
lightdm.get_boolean_property = function() {
};
lightdm.cancel_timed_login = function() {
_lightdm_mock_check_argument_length( arguments, 0 );
lightdm._timed_login_cancelled = true;
};
lightdm.provide_secret = function( secret ) {
if ( typeof lightdm._username == 'undefined' || ! lightdm._username ) {
throw "must call start_authentication first"
}
_lightdm_mock_check_argument_length(arguments, 1);
var user= _lightdm_mock_get_user(lightdm.username);
if (!user && secret == lightdm._username) {
lightdm.is_authenticated= true;
lightdm.authentication_user= user;
_lightdm_mock_check_argument_length( arguments, 1 );
var user = _lightdm_mock_get_user( lightdm.username );
if ( ! user && secret == lightdm._username ) {
lightdm.is_authenticated = true;
lightdm.authentication_user = user;
} else {
lightdm.is_authenticated= false;
lightdm.authentication_user= null;
lightdm._username= null;
lightdm.is_authenticated = false;
lightdm.authentication_user = null;
lightdm._username = null;
}
authentication_complete();
};
lightdm.start_authentication= function(username) {
if ('undefined' === typeof username) {
show_prompt("Username?", 'text');
lightdm.start_authentication = function( username ) {
if ( 'undefined' === typeof username ) {
show_prompt( "Username?", 'text' );
lightdm.awaiting_username = true;
return;
}
_lightdm_mock_check_argument_length(arguments, 1);
if (lightdm._username) {
_lightdm_mock_check_argument_length( arguments, 1 );
if ( lightdm._username ) {
throw "Already authenticating!";
}
var user= _lightdm_mock_get_user(username);
if (!user) {
show_error(username + " is an invalid user");
var user = _lightdm_mock_get_user( username );
if ( ! user ) {
show_error( username + " is an invalid user" );
}
show_prompt("Password: ");
lightdm._username= username;
show_prompt( "Password: " );
lightdm._username = username;
};
lightdm.cancel_authentication= function() {
_lightdm_mock_check_argument_length(arguments, 0);
if (!lightdm._username) {
console.log("we are not authenticating");
lightdm.cancel_authentication = function() {
_lightdm_mock_check_argument_length( arguments, 0 );
if ( ! lightdm._username ) {
console.log( "we are not authenticating" );
}
lightdm._username= null;
lightdm._username = null;
};
lightdm.suspend= function() {
alert("System Suspended. Bye Bye");
document.location.reload(true);
lightdm.suspend = function() {
alert( "System Suspended. Bye Bye" );
document.location.reload( true );
};
lightdm.hibernate= function() {
alert("System Hibernated. Bye Bye");
document.location.reload(true);
lightdm.hibernate = function() {
alert( "System Hibernated. Bye Bye" );
document.location.reload( true );
};
lightdm.restart= function() {
alert("System restart. Bye Bye");
document.location.reload(true);
lightdm.restart = function() {
alert( "System restart. Bye Bye" );
document.location.reload( true );
};
lightdm.shutdown= function() {
alert("System Shutdown. Bye Bye");
document.location.reload(true);
lightdm.shutdown = function() {
alert( "System Shutdown. Bye Bye" );
document.location.reload( true );
};
lightdm.login= function(user, session) {
_lightdm_mock_check_argument_length(arguments, 2);
if (!lightdm.is_authenticated) {
lightdm.login = function( user, session ) {
_lightdm_mock_check_argument_length( arguments, 2 );
if ( ! lightdm.is_authenticated ) {
throw "The system is not authenticated";
}
if (user !== lightdm.authentication_user) {
if ( user !== lightdm.authentication_user ) {
throw "this user is not authenticated";
}
alert("logged in successfully!!");
document.location.reload(true);
alert( "logged in successfully!!" );
document.location.reload( true );
};
lightdm.authenticate = function(session) {
lightdm.login(null, session);
lightdm.authenticate = function( session ) {
lightdm.login( null, session );
};
lightdm.respond = function(response) {
if (true === lightdm.awaiting_username) {
lightdm.respond = function( response ) {
if ( true === lightdm.awaiting_username ) {
lightdm.awaiting_username = false;
lightdm.start_authentication(response);
lightdm.start_authentication( response );
} else {
lightdm.provide_secret(response);
lightdm.provide_secret( response );
}
};
lightdm.start_session_sync = function() {
lightdm.login(null, null);
lightdm.login( null, null );
};
if ( lightdm.timed_login_delay > 0 ) {
setTimeout( function() {
if ( ! lightdm._timed_login_cancelled() ) {
timed_login();
}
}, lightdm.timed_login_delay );
}
var config = {},
greeterutil = {};
config.get_str = function( section, key ) {
var branding = {
logo: 'img/antergos.png',
user_logo: 'ing/antergos-logo-user.png',
background_images: '/usr/share/antergos/wallpapers'
};
if ( 'branding' === section ) {
return branding[ key ];
}
};
if (lightdm.timed_login_delay > 0) {
setTimeout(function() { if (!lightdm._timed_login_cancelled()) timed_login();}, lightdm.timed_login_delay);
greeterutil.dirlist = function( 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'
]
}
}
}
function _lightdm_mock_check_argument_length(args, length) {
if (args.length != length) {
function _lightdm_mock_check_argument_length( args, length ) {
if ( args.length != length ) {
throw "incorrect number of arguments in function call";
}
}
function _lightdm_mock_get_user(username) {
var user= null;
for (var i= 0; i < lightdm.users.length; ++i) {
if (lightdm.users[i].name == username) {
user= lightdm.users[i];
function _lightdm_mock_get_user( username ) {
var user = null;
for ( var i = 0; i < lightdm.users.length; ++ i ) {
if ( lightdm.users[ i ].name == username ) {
user = lightdm.users[ i ];
break;
}
}

Loading…
Cancel
Save