Skip to content

Commit

Permalink
Merge pull request #4 from VirusTotal/feature/minor-changes
Browse files Browse the repository at this point in the history
Feature/minor changes
  • Loading branch information
danipv authored Mar 17, 2021
2 parents 2608207 + 7275e8f commit 19f018b
Show file tree
Hide file tree
Showing 10 changed files with 451 additions and 637 deletions.
21 changes: 6 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ vta.url("...").openDrawer()

#### Drawer

TODO

#### Embedded

TODO
This is the default mode, VT Augment will be shown in a right side panel.

# API

Expand Down Expand Up @@ -130,15 +126,6 @@ vtaugment(container).closeDrawer()

```

#### listen(event: string, callback: any)

Not implemented yet.

```js
vtaugment(container).listen("...", callback)

```

#### loading(active: boolean)

The loading state is managed internally by the library but in the case of need the api provides this method to control loading manually. (Active loading hide the content)
Expand All @@ -150,4 +137,8 @@ vtaugment(container).loading(true)

## Options

TODO
```js
{
background: '#fff', // Background color for loading states
}
```
107 changes: 0 additions & 107 deletions deploy.js

This file was deleted.

28 changes: 28 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FOLDER_PATH="dist"
BUCKET="vtaugment"
BUCKET_FOLDER="dev"
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')

# Get arguments
while getopts "nv:p" opt; do
case $opt in
v)
BUCKET_FOLDER=$OPTARG
;;
p)
BUCKET_FOLDER=$PACKAGE_VERSION
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done

# Upload to the bucket with no cache
gsutil -m -h "Cache-Control:no-cache" cp -r ./$FOLDER_PATH/* gs://$BUCKET/$BUCKET_FOLDER/
886 changes: 391 additions & 495 deletions dist/vt-augment.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions externs.js
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
var localStorage;

var lscache = {};
lscache.set = function (key, value, time) {};
lscache.get = function (key) {};
lscache.remove = function (key) {};
lscache.flush = function () {};

7 changes: 5 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ gulp.task('default', function() {
src('./src/**/*.js').
pipe(closureCompiler({
compilation_level: 'SIMPLE',
language_in: 'ECMASCRIPT_2015',
language_out: 'ECMASCRIPT5',
warning_level: 'VERBOSE',
js_output_file: 'dist/vt-augment.min.js',
process_common_js_modules: true,
entry_point: 'vt-augment',
module_resolution: 'NODE',
externs: 'externs.js',
output_wrapper_file: 'umd-wrapper.js',
dependency_mode: 'PRUNE_LEGACY',
dependency_mode: 'PRUNE',
assume_function_wrapper: true,
js: [
'node_modules/google-closure-library/**/*.js',
'node_modules/google-closure-library/closure/**/*.js',
'node_modules/lscache/lscache.js',
],
})).
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<script>
var vta = new vtaugment(document.querySelector('#container'), {});
vta.openDrawer();
vta.load('https://pascu8-dot-core-dot-virustotalcloud.appspot.com/ui/widget/html/OC44LjguOHx8aXBfYWRkcmVzc3x8eyJiZzEiOiAiI2ZmZmZmZiIsICJiZzIiOiAiI2Y5ZjlmOSIsICJiZDEiOiAiI2U2ZTZlNiIsICJ0eXBlIjogImFsZXJ0LWNlbnRlciIsICJmZzEiOiAiIzRkNGQ0ZCJ9fHxUcnVlfHxUcnVlfHwxNjEyNDUwMjE0fHw1M2ZkOTcyMDM3MmUwOTk0ZjcyMTNjZTFlOGFhMDcyMmNmY2MzNTAwMDliMTdjMTZlMWNmMzlhNzVjMTEzYjgy');
vta.load('https://www.virustotal.com/ui/widget/html/NDYyZGI4OWQzY2ZhNGVlOGExMTQyNjgwMDI4NTEwNmQyNTQ5NDU1M2YyZjE2M2EyNDVkYWUxYjM4NDRmMWRlZnx8ZmlsZXx8eyJiZDEiOiAiIzRkNjM4NSIsICJiZzEiOiAiIzMxM2Q1YSIsICJiZzIiOiAiIzIyMmM0MiIsICJ0eXBlIjogImFsZXJ0LWNlbnRlciIsICJmZzEiOiAiI2ZmZmZmZiJ9fHxGYWxzZXx8RmFsc2V8fDE2MTU3OTk2NjF8fDJlZWQzOGFlODVhN2FlMzI0MmZlYjlkZGU3YWQ3ZWZjOThjMzFlODE2NmVjZTIxZTAyMTZmZmRhMjA4Njc1YmU');
</script>
</body>
</html>
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@virustotal/vt-augment",
"version": "1.4.0",
"version": "1.4.1",
"description": "Client library that wraps common patterns when interact with the Virustotal Augment product",
"keywords": [
"virustotal",
Expand All @@ -16,7 +16,8 @@
"url": "https://github.com/VirusTotal/vt-augment/issues"
},
"scripts": {
"build": "gulp"
"build": "gulp && npm run size",
"size": "ls -hl dist/ | awk 'FNR == 2 {print $5}'"
},
"author": "",
"license": "",
Expand Down
23 changes: 9 additions & 14 deletions src/vt-augment.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ class VTAugment {
constructor(container, options) {
this.container = container;
this.options = options || {};
this.isSrcdocSupported = !!("srcdoc" in document.createElement("iframe"))
this.isSrcdocSupported = !!('srcdoc' in document.createElement('iframe'))
&& SafeHtml.canUseSandboxIframe();

this.createStyleSheet_();

this.container.classList.add(`vt-augment`);
this.container.classList.add('vt-augment');

if (this.options.background) {
this.container.style.background = this.options.background;
Expand Down Expand Up @@ -221,15 +221,6 @@ class VTAugment {
return this;
}

/**
* @public
* @return {!VTAugment}
*/
listen() {
console.error('listen: Not implemented yet');
return this;
}

/**
* @private
* @param {boolean} active
Expand Down Expand Up @@ -293,7 +284,7 @@ class VTAugment {

setInnerHtml(temp, sandboxedIframe);
temp.firstChild.setAttribute(
'sandbox', 'allow-scripts allow-same-origin');
'sandbox', 'allow-scripts allow-same-origin allow-popups');

container.appendChild(temp.removeChild(temp.firstChild));
}
Expand Down Expand Up @@ -324,17 +315,18 @@ class VTAugment {
getHtmlAjax_(url) {
const xmlhr = new XMLHttpRequest();

xmlhr.onreadystatechange = function () {
xmlhr.onreadystatechange = () => {
if (xmlhr.readyState === XMLHttpRequest.DONE) {
if (xmlhr.status === 200) {
lscache.set(url, xmlhr.response, 60);
this.loading_(false);
} else {
lscache.remove(url);
}
}
};

xmlhr.open("GET", url, true);
xmlhr.open('GET', url, true);
xmlhr.send();
}

Expand All @@ -352,6 +344,9 @@ class VTAugment {
case 'VTAUGMENT:CLOSE':
this.closeDrawer();
break;
case 'VTAUGMENT:CLEAR_CACHE':
lscache.flush();
break;
default:
}
}
Expand Down
2 changes: 1 addition & 1 deletion umd-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
}
}(this, function () {
%output%
return module$exports$vtaugment.VTAugment;
return Z.VTAugment;
}.bind(this)));

0 comments on commit 19f018b

Please sign in to comment.