mirror of
https://github.com/hak5/nano-tetra-modules.git
synced 2025-10-29 16:58:09 +00:00
Add modules to repository
This commit is contained in:
57
base64encdec/api/module.php
Normal file
57
base64encdec/api/module.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php namespace pineapple;
|
||||
|
||||
|
||||
/* The class name must be the name of your module, without spaces. */
|
||||
/* It must also extend the "Module" class. This gives your module access to API functions */
|
||||
class base64encdec extends Module
|
||||
{
|
||||
public function route()
|
||||
{
|
||||
switch ($this->request->action) {
|
||||
case 'getContents': // If you request the action "getContents" from your Javascript, this is where the PHP will see it, and use the correct function
|
||||
$this->getContents(); // $this->getContents(); refers to your private function that contains all of the code for your request.
|
||||
break; // Break here, and add more cases after that for different requests.
|
||||
|
||||
case 'encode':
|
||||
$this->encode();
|
||||
break;
|
||||
|
||||
case 'decode':
|
||||
$this->decode();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function getContents() // This is the function that will be executed when you send the request "getContents".
|
||||
{
|
||||
$this->response = array("success" => true, // define $this->response. We can use an array to set multiple responses.
|
||||
"greeting" => "Hey there!",
|
||||
"content" => "This is the HTML template for your new module! The example shows you the basics of using HTML, AngularJS and PHP to seamlessly pass information to and from Javascript and PHP and output it to HTML.");
|
||||
}
|
||||
|
||||
private function encode()
|
||||
{
|
||||
$inputContent = $this->request->data;
|
||||
|
||||
$result = base64_encode( $inputContent );
|
||||
|
||||
$this->response = array("success" => true,
|
||||
"content" => $result);
|
||||
}
|
||||
|
||||
private function decode()
|
||||
{
|
||||
$inputContent = $this->request->data;
|
||||
|
||||
$result = base64_decode( $inputContent );
|
||||
|
||||
$this->response = array("success" => true,
|
||||
"content" => $result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
38
base64encdec/js/module.js
Normal file
38
base64encdec/js/module.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/* This is our AngularJS controller, called "ExampleController". */
|
||||
registerController('base64encdecController', ['$api', '$scope', function($api, $scope) {
|
||||
|
||||
|
||||
$scope.workspace = {inputcontent: "", outputcontent: ""};
|
||||
$scope.content = "";
|
||||
|
||||
|
||||
$scope.encode = function() {
|
||||
//console.log("encode pressed");
|
||||
$api.request({
|
||||
module: 'base64encdec',
|
||||
action: 'encode',
|
||||
data: $scope.workspace.inputcontent
|
||||
}, function(response) {
|
||||
if (response.success === true) {
|
||||
$scope.workspace.outputcontent = response.content;
|
||||
}
|
||||
//console.log(response) //Log the response to the console, this is useful for debugging.
|
||||
});
|
||||
}
|
||||
|
||||
$scope.decode = function() {
|
||||
//console.log("decode pressed");
|
||||
$api.request({
|
||||
module: 'base64encdec',
|
||||
action: 'decode',
|
||||
data: $scope.workspace.inputcontent
|
||||
}, function(response) {
|
||||
if (response.success === true) {
|
||||
$scope.workspace.outputcontent = response.content;
|
||||
}
|
||||
//console.log(response) //Log the response to the console, this is useful for debugging.
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}]);
|
||||
70
base64encdec/module.html
Normal file
70
base64encdec/module.html
Normal file
@@ -0,0 +1,70 @@
|
||||
<!-- This HTML has bootstrap classes such as "col-md-12" and "jumbotron". For more information, see http://getbootstrap.com/css/ -->
|
||||
<!-- This HTML makes use of AngularJS data-bindings and controllers. For more information, see https://docs.angularjs.org/api/ -->
|
||||
<!-- Don't forget to look at the module.js and module.php files too! -->
|
||||
<!-- This HTML is a template for generated modules via the Module Maker. -->
|
||||
|
||||
<div class="col-md-12" ng-controller="base64encdecController">
|
||||
<div class="panel-group" id="accordion">
|
||||
<div class="col-md-12">
|
||||
<!-- Base64 Encode/Decode Panel -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-header text-muted text-center">
|
||||
<h5><a href="javascript:;" data-toggle="collapse" data-parent="#accordion" data-target="#collapseInformation">Base64 Encode/Decode</a></h5>
|
||||
</div>
|
||||
<div id="collapseInformation" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
|
||||
|
||||
<!-- input section -->
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal">
|
||||
<div class="form-group">
|
||||
<label class="control-label text-center">Input</label> <a href="javascript:;" ng-click="workspace.inputcontent = ''">Clear</a>
|
||||
<p>
|
||||
<textarea class="form-control" rows="10" ng-model="workspace.inputcontent" placeholder="Enter input"></textarea>
|
||||
</p>
|
||||
<div class="input-group">
|
||||
<span class="input-group-btn text-center">
|
||||
<button class="btn btn-default" type="button" ng-click="encode()">Encode</button>
|
||||
<button class="btn btn-default" type="button" ng-click="decode()">Decode</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- output section -->
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label text-center">Output</label> <a href="javascript:;" ng-click="workspace.outputcontent = ''">Clear</a>
|
||||
<p>
|
||||
<textarea class="form-control" rows="10" ng-model="workspace.outputcontent" placeholder="" readonly></textarea>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Change Log Pannel -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-header text-muted text-center">
|
||||
<h5><a href="javascript:;" data-toggle="collapse" data-parent="#accordion" data-target="#collapseChangelog">Change Log</a></h5>
|
||||
</div>
|
||||
<div id="collapseChangelog" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li><b>1.0</b></li>
|
||||
<ul>
|
||||
<li class="text-muted">Initial Pineapple Nano Release</li>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
10
base64encdec/module.info
Normal file
10
base64encdec/module.info
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"author": "dustbyter",
|
||||
"description": "Base64 encoder and decoder",
|
||||
"devices": [
|
||||
"nano",
|
||||
"tetra"
|
||||
],
|
||||
"title": "base64encdec",
|
||||
"version": "1.0"
|
||||
}
|
||||
Reference in New Issue
Block a user