Skip to content

Commit

Permalink
Merge pull request #32 from maxwroc/DevBranch
Browse files Browse the repository at this point in the history
Dev branch
  • Loading branch information
maxwroc authored Aug 23, 2016
2 parents af22a61 + 21cfd04 commit 1ce04b0
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 38 deletions.
4 changes: 2 additions & 2 deletions UrlEditorPRO/app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "Url Editor PRO",
"description": "Url parser which makes editing complex URLs as easy as possible. Features: params decoding, auto-suggest, keyboard navigation..",
"version": "0.8.3.0",
"version": "0.8.3.1",

"permissions": [
"http://*/*",
Expand All @@ -28,5 +28,5 @@
}
}
},
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'"
"content_security_policy": "script-src 'self' https://www.google-analytics.com; object-src 'self'"
}
13 changes: 12 additions & 1 deletion UrlEditorPRO/app/modules/autosuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,18 @@
switch (elem.className) {
case "suggestion":
this.inputElem.value = (<ISuggestion>elem).suggestionText;

Tracking.trackEvent(Tracking.Category.AutoSuggest, "used");

// trigger event which will update param in the url (via view model)
var e = new Event("updated");
e.initEvent("updated", true, true);
this.inputElem.dispatchEvent(e)
break;
case "delete":

Tracking.trackEvent(Tracking.Category.AutoSuggest, "delete");

this.deleteSuggestion(<ISuggestion>elem.parentElement);
// prevent from triggering same event on suggestion
evt.stopPropagation();
Expand Down Expand Up @@ -328,7 +338,8 @@
}

Tracking.trackEvent(Tracking.Category.AutoSuggest, "used");


// trigger event which will update param in the url (via view model)
var e = new Event("updated");
e.initEvent("updated", true, true);
this.inputElem.dispatchEvent(e)
Expand Down
4 changes: 2 additions & 2 deletions UrlEditorPRO/app/modules/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ module UrlEditor {
/**
* Wrapper for document.getElementById
*/
export function ge(elementId: string): HTMLElement {
return document.getElementById(elementId);
export function ge<T extends HTMLElement>(elementId: string): T {
return <T>document.getElementById(elementId);
}

/**
Expand Down
56 changes: 30 additions & 26 deletions UrlEditorPRO/app/modules/tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,59 @@ module UrlEditor.Tracking {
Sort
}

_gaq = window["_gaq"] = window["_gaq"] || [];
_gaq.push(['_setAccount', 'UA-81916828-1']);
export class Dimension {
public static Version = "dimension1";
}

var enableLogOncePerSession = true;
var trackingEnabled = true;
var logOncePerSession: IMap<boolean> = {};

// create global analytics object
(function internalInit(hostObject, propertyName) {
hostObject['GoogleAnalyticsObject'] = propertyName;
hostObject[propertyName] = hostObject[propertyName] || function () {
(hostObject[propertyName].q = hostObject[propertyName].q || []).push(arguments)
};
hostObject[propertyName].l = 1 * <any>new Date();
})(window, 'ga');

// initial tracking variavles setup
ga('create', 'UA-81916828-1', 'auto');
ga('set', 'checkProtocolTask', null); // Disables file protocol checking.

export function init(_trackingEnabled: boolean) {
trackingEnabled = _trackingEnabled;

if (!trackingEnabled) {
return;
}
_gaq.push(['_trackPageview']);

var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);

// load Analytics library
var a = document.createElement("script");
a.async = true;
a.src = "https://www.google-analytics.com/analytics.js";
var m = document.getElementsByTagName("script")[0];
m.parentNode.insertBefore(a, m);

ga('send', 'pageview');
}

export function trackUserVariable(name: string, value: string) {
_gaq.push(['_setCustomVar',
1, // This custom var is set to slot #1. Required parameter.
name, // The name of the custom variable. Required parameter.
value, // The value of the custom variable. Required parameter.
1 // Sets the scope to visitor-level. Optional parameter.
]);
export function setCustomDimension(name: string, value: string) {
ga('set', name, value);
}

export function trackEvent(category: Category, action: string, label?: string, value?: string | number) {
if (!trackingEnabled) {
return;
}

var eventData: Array<string | number> = ["_trackEvent", Category[category], action];

addOptionalEventParam(eventData, label);
addOptionalEventParam(eventData, value);

// check if we should log this event
if (!isLoggingEnabled(eventData)) {
if (!isLoggingEnabled(Array.prototype.slice.call(arguments))) {
return;
}

_gaq.push(eventData);
ga('send', 'event', Category[category], action, label, value);
}

function addOptionalEventParam(eventData: Array<string | number>, param: string | number) {
Expand Down
17 changes: 11 additions & 6 deletions UrlEditorPRO/app/modules/view_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
constructor(private url: Uri, private doc: HTMLDocument, settings: Settings, private submit: (uri: Uri, openIn: OpenIn) => void) {


this.measureElem = <HTMLSpanElement>ge("measure");
this.measureElem = ge<HTMLSpanElement>("measure");

// bind event handlers
doc.body.addEventListener("click", evt => this.clickEventDispatcher(evt));
Expand Down Expand Up @@ -135,7 +135,7 @@
}

if (activeElem.id != "full_url" || !isTextFieldActive) {
(<HTMLTextAreaElement>ge("full_url")).value = this.url.url();
ge<HTMLTextAreaElement>("full_url").value = this.url.url();
}
}

Expand Down Expand Up @@ -165,7 +165,7 @@

private populateParams(setFocusOnLastOne: boolean = false) {
var param: IParamContainerElement;
var params = ge("params");
var params = ge<HTMLDivElement>("params");

// clean old set of params
params.innerHTML = "";
Expand Down Expand Up @@ -217,8 +217,13 @@
this.doc.body.style.width = Math.min(longestBoth, maxClientWidth) + "px";
}

if (setFocusOnLastOne && param) {
param.nameElement.focus();
if (setFocusOnLastOne) {
if (param) {
param.nameElement.focus();
}
else {
ge<HTMLInputElement>("hostname").focus();
}
}
}

Expand Down Expand Up @@ -257,7 +262,7 @@

private setErrorMessage(err: string, elem?: HTMLElement) {
// setting error message
ge("err").textContent = err ? "Error: " + err : "";
ge<HTMLDivElement>("err").textContent = err ? "Error: " + err : "";

// if DOM element was passed we're setting or removing the error indicator color
if (elem) {
Expand Down
3 changes: 2 additions & 1 deletion UrlEditorPRO/app/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ module UrlEditor {
var settings = new Settings(localStorage);

// it is better to set variable before page view event (init)
Tracking.trackUserVariable("Version", version);
Tracking.setCustomDimension(Tracking.Dimension.Version, version);

Tracking.init(settings.trackingEnabled);

var versionElem = ge("version");
Expand Down
26 changes: 26 additions & 0 deletions pack_extension.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@echo off
set extDir=""
set packer="%~dp0..\WinScripts\batch\ExtensionPacker.bat"

rem if not "%1%"=="" set extDir=%1
if not exist %extDir% (
set extDir="UrlEditorPRO\UrlEditorPRO\app"
)


if not exist %extDir% (
goto error
)

if not exist %packer% (
echo Packer not found %packer%
goto :eof
)

%packer% %extDir%

goto :eof

:error
echo Extension directory not found:
echo %extDir%, %1

0 comments on commit 1ce04b0

Please sign in to comment.