pixflow-upgrade-planning 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  const parse = new DOMParser();
2
2
  const fs = require("fs");
3
3
  const path = require("path");
4
+ const price_details = require("pixflow-price-details");
5
+ const PurchaseCodeActivate = require("pixflow-purchase-code-activate");
6
+ const PixflowCEPManifest = require("pixflow-cep-manifest");
4
7
 
5
8
  class PixflowUpgradePlanning extends HTMLElement {
6
9
 
@@ -10,7 +13,8 @@ class PixflowUpgradePlanning extends HTMLElement {
10
13
  this.port = localStorage.getItem("port");
11
14
  }
12
15
 
13
- connectedCallback(){
16
+ async connectedCallback(){
17
+ this.cep_manifest = new PixflowCEPManifest();
14
18
  const style = document.createElement("style");
15
19
  style.textContent = fs.readFileSync(path.join(__dirname, "styles", `${this.port}.css`));
16
20
  this.appendChild(style);
@@ -18,13 +22,39 @@ class PixflowUpgradePlanning extends HTMLElement {
18
22
  this.template = parse.parseFromString(fs.readFileSync(path.join(__dirname, "template.html")).toString("utf8"), "text/html");
19
23
  this.appendChild(this.template.querySelector(`div.${this.port}`));
20
24
 
21
- this.querySelector(`img.close`).addEventListener("click", this.close_click);
22
-
23
25
  if(this.port == "pixflow"){
26
+ const p = await price_details(this.cep_manifest.get_post_id());
27
+ this.querySelector("div.pixflow > div.plan > div.single > div > div").innerHTML = p.single;
28
+ this.querySelector("div.pixflow > div.plan > div.team > div > div").innerHTML = p.team;
24
29
  this.appendChild(this.template.querySelector("div.purchase-code"));
25
30
  this.querySelector("div.activate-code").addEventListener("click", this.activate_code_click);
31
+ this.querySelector("div.pixflow > div.activate-code-block > button").addEventListener("click", this.activate_code_block_click);
32
+ this.querySelector("div.purchase-code > div > button").addEventListener("click", this.purchase_code_click);
26
33
  }
27
34
 
35
+ this.querySelectorAll(`img.close`).forEach(function(element){
36
+ element.addEventListener("click", self.close_click)
37
+ });
38
+
39
+ }
40
+
41
+ async purchase_code_click(e){
42
+ e.preventDefault();
43
+ const purchase_code_activate = new PurchaseCodeActivate(
44
+ e.target.parentNode.parentNode.querySelector("input[type='text']").value,
45
+ e.target.parentNode.parentNode.parentNode.getAttribute("item-name"),
46
+ e.target.parentNode.parentNode.parentNode.getAttribute("item-id")
47
+ );
48
+ await purchase_code_activate.check_devices();
49
+ }
50
+
51
+ activate_code_block_click(e){
52
+ const item_name = this.parentNode.parentNode.parentNode.getAttribute("item-name");
53
+ const license = this.parentNode.parentNode.querySelector("div.plan > div > div.active").parentNode.className.split(" ")[0];
54
+ var link = `https://pixflow.net/product/px-${item_name}/?active-license=free`;
55
+ if(license != "free")
56
+ link = `https://pixflow.net/aff/${item_name}-plugin-${license}/`;
57
+ window.cep.util.openURLInDefaultBrowser(link);
28
58
  }
29
59
 
30
60
  activate_code_click(e){
@@ -35,12 +65,8 @@ class PixflowUpgradePlanning extends HTMLElement {
35
65
  this.querySelector(`div.${this.port}`).classList.add("active");
36
66
  }
37
67
 
38
- close(){
39
- this.querySelector(`div.${this.port}`).classList.remove("active");
40
- }
41
-
42
68
  close_click(e){
43
- e.target.parentNode.parentNode.close();
69
+ e.target.parentNode.classList.remove("active");
44
70
  }
45
71
 
46
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixflow-upgrade-planning",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,5 +8,10 @@
8
8
  },
9
9
  "keywords": [],
10
10
  "author": "",
11
- "license": "ISC"
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "pixflow-price-details": "^1.0.0",
14
+ "pixflow-purchase-code-activate": "^1.0.0",
15
+ "pixflow-cep-manifest": "^1.0.0"
16
+ }
12
17
  }
package/template.html CHANGED
@@ -60,10 +60,10 @@
60
60
  <img src="./node_modules/pixflow-upgrade-planning/images/drawer.svg" class="close">
61
61
  <img src="./node_modules/pixflow-upgrade-planning/images/pixflow/purchase-code.svg">
62
62
  <p class="describe">Use the code you received after the purchase process to activate the plugin</p>
63
- <form>
63
+ <div>
64
64
  <input type="text" spellcheck="false" placeholder="Purchase code">
65
65
  <p class="message"></p>
66
66
  <button>ACTIVATE</button>
67
67
  <div class="back-upgrade-plan">Purchase Pro Membership</div>
68
- </form>
68
+ </div>
69
69
  </div>