Skip to content

Commit

Permalink
Add 2 funcitions
Browse files Browse the repository at this point in the history
  • Loading branch information
jondy committed Nov 4, 2018
1 parent 0464d72 commit c50f032
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/webui/_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ def newLicense(args):
output = os.path.join(path, 'licenses', title, 'license.lic')
return dict(title=title, filename=output)

def obfuscateScripts(args):
return args

def generateLicenses(args):
return args

if __name__ == '__main__':
import doctest
doctest.testmod()
12 changes: 6 additions & 6 deletions src/webui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,21 @@
<div class="panel-body">
<form>
<div class="form-group">
<label for="input_project_src">Src</label>
<label for="input_src">Source Path</label>
<input type="text" class="form-control" id="input_src"/>
<p class="help-block">Required. Base path for MANIFEST.in to match files.</p>
<p class="help-block">Required. All the <code>.py</code> files in this path will be obfuscated recursively.</p>
</div>
<div class="form-group">
<label for="input_project_entry">Entry Script</label>
<label for="input_entry">Entry Script</label>
<input type="text" class="form-control" id="input_entry"/>
<p class="help-block">Filename of entry script, relative to Src path</p>
</div>
<div class="form-group">
<label for="input_project_output">Output</label>
<label for="input_output">Output</label>
<input type="text" class="form-control" id="input_output"/>
<p class="help-block">Where to save obfuscated scripts and runtime files</p>
</div>
<button type="button" class="btn btn-primary btn-lg" id="obfuscate-scripts">Build</button>
<button type="button" class="btn btn-primary" id="obfuscate-scripts">Build</button>
</form>
</div>
<!-- /.panel-body -->
Expand Down Expand Up @@ -118,7 +118,7 @@
<input type="text" class="form-control" id="input_license_rcode"/>
<p class="help-block">Identify string, for example, <em>Customer-Tom</em></p>
</div>
<button type="button" class="btn btn-primary pull-right" id="generate-license">Generate</button>
<button type="button" class="btn btn-primary" id="generate-license">Generate</button>
</form>
</div>
<!-- /.panel-body -->
Expand Down
8 changes: 8 additions & 0 deletions src/webui/js/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ define(['settings', 'utils', 'demo'], function(settings, utils, demo) {

return {

obfuscateScripts: function (args, callback) {
sendRequest('/obfuscateScripts', args, callback);
},

generateLicenses: function (args, callback) {
sendRequest('/generateLicenses', args, callback);
},

newProject: function (callback) {
sendRequest('/newProject', {}, callback);
},
Expand Down
2 changes: 2 additions & 0 deletions src/webui/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ define(['settings', 'utils', 'connector', 'project'], function (settings, utils,
&& (e.target.parentElement.getAttribute('data-target') !== '#navbar-main-tab'))
document.getElementById('navbar-main-tab').classList.remove('in');
}, false);
document.getElementById('obfuscate-scripts').addEventListener('click', project.obfuscateScripts, false);
document.getElementById('generate-licenses').addEventListener('click', project.generateLicenses, false);
}

// Project mode
Expand Down
35 changes: 35 additions & 0 deletions src/webui/js/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,41 @@ define(['connector', 'utils'], function(conn, utils) {
conn.queryProject({ name: name }, _callback);
}

function obfuscateScripts() {
var _callback = function (response) {
if (response.errcode) {
utils.showMessage(response.result);
return ;
}
var result = response.result;
utils.showMessage('Obfuscate scripts "' + result + '" OK.');
};
var args = {};
args.src = document.getElementById('input_src').value;
args.entry = document.getElementById('input_entry').value;
args.output = document.getElementById('input_output').value;
conn.obfuscateScripts(args, _callback);
}

function generateLicenses() {
var _callback = function (response) {
if (response.errcode) {
utils.showMessage(response.result);
return ;
}
var result = response.result;
utils.showMessage('Generate license "' + result + '" OK.');
};
var args = {};
args.expired = document.getElementById('input_expired_date').value;
args.bind_disk = document.getElementById('input_bind_disk').value;
args.bind_ipv4 = document.getElementById('input_bind_ipv4').value;
args.bind_mac = document.getElementById('input_bind_mac').value;
args.rcode = document.getElementById('input_license_rcode').value;
args.name = _project.name;
conn.obfuscateScripts(args, _callback);
}

return {
currentProject: _project,

Expand Down

0 comments on commit c50f032

Please sign in to comment.