corrade-nucleus-nucleons

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 5  →  ?path2? @ 6
/script-kiddie/002_script_kiddie/script-kiddie/index.html
@@ -29,7 +29,7 @@
 
<body>
<!-- Dialog Modal -->
<div id="popup" class="modal fade bs-example-modal-lg" role="dialog">
<div id="avatar-select" class="modal fade bs-example-modal-lg" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
 
@@ -37,20 +37,24 @@
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
 
<h1 id="title" class="modal-title"></h1>
<h1 id="title" class="modal-title">Avatar Selection</h1>
</div>
 
<div id="content" class="modal-body">
<div class="progress">
<div id="progressbar" class="progress-bar" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em; width: 2%;">
0%
<form id="avatar-select-form" class="form-inline" data-toggle="validator" onSubmit="event.preventDefault();">
<div id="content" class="modal-body">
<p>Please enter the avatar firstname and lastname to send the script to.</p>
<div class="form-group has-feedback">
<label for="avatar-firstname">First Name</label>
<input id="avatar-firstname" type="text" class="form-control" aria-describedby="basic-addon1" required>
<label for="avatar-lastname">Last Name</label>
<input id="avatar-lastname" type="text" class="form-control" aria-describedby="basic-addon1" required>
</div>
</div>
 
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button id="send-script" type="submit" class="btn btn-primary">Confirm</button>
</div>
</div>
</form>
</div>
</div>
</div>
@@ -67,12 +71,11 @@
 
<div id="editor-panel" class="panel panel-default draggable movable">
<div class="panel-heading">
<form id="script-tools" class="form-inline" data-toggle="validator" onSubmit="event.preventDefault();">
<div class="input-group">
<span class="input-group-btn">
<form id="script-tools" data-toggle="validator" onSubmit="event.preventDefault();">
<div class="form-group">
<button id="compile-script" class="btn btn-default check-image checkButton" type="button" title="Compile script.">Compile</button>
<button id="tidy-script" class="btn btn-default" type="button" title="Tidy source-code.">Cleanup</button>
</span>
</div>
<div class="form-group has-feedback">
<div class="input-group">
@@ -81,7 +84,10 @@
</span>
<input id="script-name" type="text" class="form-control" placeholder="Script Name" aria-describedby="basic-addon1" required>
<span class="input-group-addon">-</span>
<input id="script-UUID" type="text" class="form-control" aria-describedby="basic-addon2" size="36" readonly>
<input id="script-UUID" type="text" class="form-control" aria-describedby="basic-addon2" size="36">
<span class="input-group-btn">
<button id="give-script" class="btn btn-default" type="button" title="Give script." disabled="disabled">Give</button>
</span>
</div>
</div>
</form>
@@ -137,9 +143,6 @@
<script type="text/javascript" src="/script-kiddie/bower_components/velocity/velocity.min.js"></script>
<!-- Interact JS -->
<script type="text/javascript" src="/script-kiddie/bower_components/interactjs/dist/interact.min.js"></script>
<!-- CryptoJS -->
<script src="/bower_components/cryptojslib/components/core-min.js" type="text/javascript"></script>
<script src="/bower_components/cryptojslib/components/enc-base64-min.js" type="text/javascript"></script>
<!-- Wizardry and Steamworks JavaScript Includes -->
<script src="/js/was/csv.js" type="text/javascript"></script>
<script src="/js/was/jquery/arrays.js" type="text/javascript"></script>
@@ -159,11 +162,11 @@
});
// Get the script from the storage.
var storeScriptText = localStorage.getItem("nucleus-script-kiddie.lsl");
if (typeof value == "string")
var storeScriptText = localStorage.getItem('nucleus-script-kiddie-script-body');
if (typeof storeScriptText == "string")
editor.getSession().setValue(storeScriptText);
function compile(lsl) {
function compile(lsl, callback) {
// Set the editor to read-only.
editor.setReadOnly(true);
@@ -186,10 +189,11 @@
},
dataType: 'json'
}).done(function(response) {
var success = response.success === "True";
// Set the editor to read-enabled.
editor.setReadOnly(false);
if(response.success === "True") {
if(success) {
// Set the button image.
$('#compile-script').removeClass("activity-image");
$('#compile-script').removeClass("activityButton");
@@ -200,6 +204,7 @@
$("#message").velocity("slideUp", {
duration: 1000
});
callback(success);
return;
}
@@ -219,23 +224,28 @@
});
$('#message').val(wasCSVToArray(response.data).join(''));
callback(success);
});
}
function store(lsl) {
function store(lsl, callback) {
$.ajax({
type: 'POST',
url: '/',
data: {
command: 'upload',
type: 'LSLText',
command: 'updatescript',
create: true,
type: 'agent',
entity: 'text',
item: $('#script-UUID').val(),
name: $('#script-name').val(),
data: CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(lsl))
target: $('#script-name').val(),
data: lsl
},
dataType: 'json'
}).done(function(response) {
if(response.success === "True") {
var success = response.success === "True";
if(success) {
// Get the response data and item UUID.
var data = wasCSVToArray(response.data);
var UUID = data[data.indexOf('item') + 1];
@@ -243,8 +253,8 @@
$('#script-UUID').val(UUID);
localStorage.setItem('nucleus-script-kiddie-script-UUID', UUID);
return;
}
callback(success);
});
}
@@ -257,9 +267,24 @@
},
exec: editor => {
var data = editor.getSession().getValue();
compile(data);
if($('#store-script').prop('checked') === true)
store(data);
// Store locally on save.
localStorage.setItem('nucleus-script-kiddie-script-body', data);
compile(data, (success) => {
// Script did not compile so do not store.
if(!success)
return;
// Storing is not enabled so return.
if($('#store-script').prop('checked') !== true)
return;
store(data, (success) => {
// Script was stored successfully.
//alert("Script stored succssfully.");
});
});
},
readOnly: false // false if this command should not apply in readOnly mode
});
@@ -310,9 +335,49 @@
);
});
function give(firstname, lastname, callback) {
$.ajax({
type: 'POST',
url: '/',
data: {
command: 'give',
entity: 'avatar',
item: $('#script-UUID').val(),
firstname: firstname,
lastname: lastname,
permissions: 'c--mvt------------c--mvtc--mvt'
},
dataType: 'json'
}).done(function(response) {
callback(response);
});
}
// Add click listener for give button.
$('#give-script').on('click', function (e) {
if($('#compile-script').hasClass("activity-image"))
return;
// Show the popup.
$('#avatar-select').modal('show');
});
// Add click listener to modal confirmation.
$('#send-script').on('click', function(e) {
// Hide the popup.
$('#avatar-select').modal('hide');
// Disable give button.
$('#give-script').attr('disabled', true);
give($('#avatar-firstname').val(), $('#avatar-lastname').val(), (response) => {
// Enable give button.
$('#give-script').attr('disabled', false);
});
})
// Save script on change.
editor.getSession().on('change', function(e) {
localStorage.setItem("nucleus-script-kiddie.lsl", editor.getValue());
localStorage.setItem('nucleus-script-kiddie-script-body', editor.getSession().getValue());
});
// Move windows to top on click.
@@ -326,12 +391,12 @@
// enable inertial throwing
inertia: true,
// keep the element within the area of it's parent
restrict: {
/*restrict: {
// Let the user move the windows freely.
//restriction: "parent",
endOnly: true,
elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
},
restriction: "self",
endOnly: true//,
//elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
},*/
// enable autoScroll
autoScroll: true,
@@ -346,7 +411,8 @@
event.target.style.opacity = 0.5;
}
})
.allowFrom('.panel-heading');
.allowFrom('.panel-heading')
.ignoreFrom('a, input, button, textarea');
function getTopWindowIndex() {
return Math.max.apply(null,
@@ -392,7 +458,7 @@
var value = $(this).val();
if($(this).data('lastval')!= value){
 
$(this).data('lastval',value);
$(this).data('lastval',value);
clearTimeout(scriptNameTimerID);
 
scriptNameTimerID = setTimeout(function() {
@@ -411,6 +477,37 @@
$('#store-script').bootstrapToggle('enable');
});
$('#store-script').change(function() {
switch($('#store-script').prop('checked'))
{
case true:
// Disable script name and UUID.
$('#script-name').attr('disabled', true);
$('#script-UUID').attr('disabled', true);
var data = editor.getSession().getValue();
// Store locally on save.
localStorage.setItem('nucleus-script-kiddie-script-body', data);
$('#give-script').attr('disabled', true);
compile(data, (success) => {
store(data, (success) => {
// Script was stored successfully.
// Enable the give button.
$('#give-script').attr('disabled', false);
});
});
break;
default:
// Enable script name and UUID.
$('#script-name').attr('disabled', false);
$('#script-UUID').attr('disabled', false);
// Disable the give button.
$('#give-script').attr('disabled', true);
break;
}
});
});
</script>