2012-05-26 14:38:15 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
pandora.ui.onloadDialog = function() {
|
|
|
|
|
2012-06-11 07:17:39 +00:00
|
|
|
var dialogHeight = Math.round((window.innerHeight - 48) * 0.75),
|
|
|
|
dialogWidth = Math.round(window.innerWidth * 0.75),
|
|
|
|
$input = Ox.Input({
|
|
|
|
height: dialogHeight - 32,
|
|
|
|
id: 'onload',
|
|
|
|
placeholder: '/*\nAny JavaScript you paste here will run on load.\n'
|
|
|
|
+ 'If you ever need to manually change or remove it, '
|
|
|
|
+ 'you can do so by setting localStorage["pandora.onload"] in the console.\n*/',
|
|
|
|
type: 'textarea',
|
|
|
|
value: localStorage['pandora.onload'] || '',
|
|
|
|
width: dialogWidth - 32
|
|
|
|
})
|
|
|
|
.css({margin: '16px'}),
|
2012-05-26 14:38:15 +00:00
|
|
|
that = Ox.Dialog({
|
|
|
|
buttons: [
|
|
|
|
Ox.Button({
|
|
|
|
title: 'Clear'
|
|
|
|
})
|
|
|
|
.css({margin: '4px 4px 4px 0'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Ox.Button({
|
|
|
|
id: 'done',
|
|
|
|
title: 'Done',
|
|
|
|
width: 48
|
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.close();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
closeButton: true,
|
2012-06-11 07:17:39 +00:00
|
|
|
content: $input,
|
2012-05-26 14:38:15 +00:00
|
|
|
height: dialogHeight,
|
|
|
|
maximizeButton: true,
|
|
|
|
minHeight: 256,
|
|
|
|
minWidth: 512,
|
|
|
|
removeOnClose: true,
|
2012-05-28 21:04:27 +00:00
|
|
|
title: 'Run Script on Load',
|
2012-05-26 14:38:15 +00:00
|
|
|
width: dialogWidth
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resize: resize
|
|
|
|
});
|
|
|
|
|
|
|
|
function resize(data) {
|
|
|
|
dialogHeight = data.height;
|
|
|
|
dialogWidth = data.width;
|
2012-06-11 07:17:39 +00:00
|
|
|
$input.options({
|
|
|
|
height: dialogHeight - 32,
|
|
|
|
width: dialogWidth - 32
|
2012-05-26 14:38:15 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function clear() {
|
|
|
|
delete localStorage['pandora.onload'];
|
2012-06-11 07:17:39 +00:00
|
|
|
$input.options({value: ''});
|
2012-05-26 14:38:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
that.superClose = that.close;
|
|
|
|
that.close = function() {
|
2012-06-11 07:17:39 +00:00
|
|
|
var value = $input.value();
|
2012-06-10 18:31:02 +00:00
|
|
|
if (value) {
|
2012-05-26 14:38:15 +00:00
|
|
|
localStorage['pandora.onload'] = value;
|
|
|
|
} else {
|
|
|
|
delete localStorage['pandora.onload'];
|
|
|
|
}
|
|
|
|
that.superClose();
|
|
|
|
};
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|
|
|
|
|