Skip to content

Commit b137245

Browse files
committed
version 2.0.5
0 parents  commit b137245

File tree

12 files changed

+11286
-0
lines changed

12 files changed

+11286
-0
lines changed

RandomUserGenerator.jsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
if(typeof($)=='undefined')
2+
$={};
3+
4+
$._ext = {
5+
//Evaluate a file and catch the exception.
6+
evalFile : function(path) {
7+
try {
8+
$.evalFile(path);
9+
} catch (e) {alert("Exception:" + e);}
10+
},
11+
// Evaluate all the files in the given folder
12+
evalFiles: function(jsxFolderPath) {
13+
var folder = new Folder(jsxFolderPath);
14+
if (folder.exists) {
15+
var jsxFiles = folder.getFiles("*.jsx");
16+
for (var i = 0; i < jsxFiles.length; i++) {
17+
var jsxFile = jsxFiles[i];
18+
$._ext.evalFile(jsxFile);
19+
}
20+
}
21+
}
22+
};

ext.js

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
version = "2.0.5";
2+
counter = 0;
3+
lego = "";
4+
legoMode = false;
5+
6+
function onLoaded() {
7+
getAUser();
8+
$(".update").html("Version " + version);
9+
checkForUpdates();
10+
var a = new CSInterface,
11+
c = a.hostEnvironment.appName;
12+
"FLPR" != c && loadJSX();
13+
for (var b = ["PHXS"], d = 0; d < b.length; d++) {
14+
var e = b[d];
15+
if (0 <= c.indexOf(e) && (e = document.getElementById("btn_" + e))) e.disabled = !1
16+
}
17+
updateThemeWithAppSkinInfo(a.hostEnvironment.appSkinInfo);
18+
a.addEventListener(CSInterface.THEME_COLOR_CHANGED_EVENT, onAppThemeColorChanged);
19+
}
20+
21+
function updateThemeWithAppSkinInfo(a) {
22+
var c = a.panelBackgroundColor.color;
23+
document.body.bgColor = toHex(c);
24+
var b = (new CSInterface).hostEnvironment.appName;
25+
"PHXS" == b && addRule("ppstyle", "button, select, input[type=button], input[type=submit]", "border-radius:3px;");
26+
"PHXS" == b || ("PPRO" == b || "PRLD" == b) || (addRule("ppstyle", ".default", "font-size:" + a.baseFontSize + "px; color:" + reverseColor(c) + "; background-color:" + toHex(c, 20)), addRule("ppstyle", "button", "border-color: " + toHex(panelBgColor, -50)))
27+
}
28+
29+
function addRule(a, c, b) {
30+
if (a = document.getElementById(a)) a = a.sheet, a.addRule ? a.addRule(c, b) : a.insertRule && a.insertRule(c + " { " + b + " }", a.cssRules.length)
31+
}
32+
33+
function reverseColor(a, c) {
34+
return toHex({
35+
red: Math.abs(255 - a.red),
36+
green: Math.abs(255 - a.green),
37+
blue: Math.abs(255 - a.blue)
38+
}, c)
39+
}
40+
41+
function toHex(a, c) {
42+
function b(a, c) {
43+
var b = !isNaN(c) ? a + c : a;
44+
0 > b ? b = 0 : 255 < b && (b = 255);
45+
b = b.toString(16);
46+
return 1 == b.length ? "0" + b : b
47+
}
48+
var d = "";
49+
if (a) with(a) d = b(red, c) + b(green, c) + b(blue, c);
50+
return "#" + d
51+
}
52+
53+
function onAppThemeColorChanged(a) {
54+
a = JSON.parse(window.__adobe_cep__.getHostEnvironment()).appSkinInfo;
55+
updateThemeWithAppSkinInfo(a)
56+
}
57+
58+
function loadJSX() {
59+
var a = new CSInterface,
60+
c = a.getSystemPath(SystemPath.EXTENSION) + "/jsx/";
61+
a.evalScript('$._ext.evalFiles("' + c + '")')
62+
}
63+
64+
function evalScript(a, c) {
65+
(new CSInterface).evalScript(a, c)
66+
}
67+
68+
function getAUser() {
69+
$("#new-user").addClass("active");
70+
71+
if ($("#men").hasClass("active")) {
72+
var gender = "&gender=male";
73+
} else if ($("#both").hasClass("active")) {
74+
var gender = "";
75+
} else {
76+
var gender = "&gender=female";
77+
}
78+
$.ajax({
79+
url: "http://api.randomuser.me/?" + lego + "extension=true" + gender,
80+
dataType: "json",
81+
success: function(a) {
82+
a.error || (a = a.results[0].user, $(".photo img").attr("src", a.picture.replace("portraits/", "portraits/med/")), $(".new-user").removeClass("active"), $("#name").html(a.name.first + " " + a.name.last), $(".control").removeAttr("disabled"), $(".counter").html(++counter + " user" + ((counter == 1) ? "" : "s") + " generated this session"), evalScript("$._random_image.save('" + a.picture + "')"))
83+
}
84+
})
85+
}
86+
87+
function addImage() {
88+
evalScript("$._random_image.open()")
89+
}
90+
91+
function insertAndClip() {
92+
evalScript("$._image.clip()")
93+
};
94+
95+
function menButton() {
96+
if (!$("#men").hasClass("active")) {
97+
$("#men").addClass("active");
98+
$("#women").removeClass("active");
99+
$("#both").removeClass("active");
100+
getAUser();
101+
}
102+
}
103+
104+
function bothButton() {
105+
if (!$("#both").hasClass("active")) {
106+
$("#men").removeClass("active");
107+
$("#both").addClass ("active");
108+
$("#women").removeClass("active");
109+
getAUser();
110+
}
111+
}
112+
113+
function womenButton() {
114+
if (!$("#women").hasClass("active")) {
115+
$("#men").removeClass("active");
116+
$("#both").removeClass("active");
117+
$("#women").addClass("active");
118+
getAUser();
119+
}
120+
}
121+
122+
function thumbButton() {
123+
if (!$("#thumb").hasClass("active")) {
124+
$("#thumb").addClass("active");
125+
$("#medium").removeClass("active");
126+
$("#large").removeClass("active");
127+
}
128+
}
129+
130+
function mediumButton() {
131+
if (!$("#medium").hasClass("active")) {
132+
$("#thumb").removeClass("active");
133+
$("#medium").addClass("active");
134+
$("#large").removeClass ("active");
135+
}
136+
}
137+
138+
function largeButton() {
139+
if (!$("#large").hasClass("active")) {
140+
$("#thumb").removeClass("active");
141+
$("#medium").removeClass("active");
142+
$("#large").addClass("active");
143+
}
144+
}
145+
146+
function checkForUpdates() {
147+
$.ajax({
148+
type: "POST",
149+
cache: false,
150+
data: {"version": version},
151+
url: "https://randomuser.me/download/version.php",
152+
dataType: "json",
153+
success: function(a) {
154+
setTimeout(function () {
155+
if (version != a.version) {
156+
$(".update").html("<font color='#89c63c'>Version " + a.version + " is now available!</font>");
157+
}
158+
}, 1000);
159+
}
160+
})
161+
}
162+
163+
function legoButton() {
164+
if (!legoMode) {
165+
lego = "lego&";
166+
$("#legoText").html("Lego mode activated");
167+
$("#men").attr("disabled", true);
168+
$("#both").attr("disabled", true);
169+
$("#women").attr("disabled", true);
170+
legoMode = true;
171+
} else {
172+
lego = "";
173+
$("#legoText").html("Lego mode deactivated");
174+
$("#men").removeAttr("disabled");
175+
$("#both").removeAttr("disabled");
176+
$("#women").removeAttr("disabled");
177+
legoMode = false;
178+
}
179+
getAUser();
180+
}

index.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Extension</title>
5+
<meta charset="utf-8">
6+
7+
<!-- CSS -->
8+
<link id="ppstyle" rel="stylesheet" type="text/css" href="./style.css">
9+
10+
<!-- JS -->
11+
<script src="./lib/jquery-1.9.1.js"></script>
12+
<script src="./ext.js"></script>
13+
<script src="./lib/CSInterface-4.0.0.js"></script>
14+
</head>
15+
<body onLoad="onLoaded()">
16+
<div class="frame" id="content">
17+
<div class="user">
18+
<div class="photo">
19+
<img src="">
20+
</div>
21+
<!-- <span class="greeting">Hello, my name is</span> -->
22+
<span class="name" id="name">&nbsp;</span>
23+
</div>
24+
<ul class="controls">
25+
<li><button class="control default add" disabled onClick="addImage()"></button></li>
26+
<li><button class="control default mask" disabled onClick="insertAndClip()"></button></li>
27+
</ul>
28+
<!-- <ul class="size">
29+
<li><button id="thumb" onClick="thumbButton()">Thumb</button></li>
30+
<li><button id="medium" onClick="mediumButton()" class="active">Medium</button></li>
31+
<li><button id="large" onClick="largeButton()">Large</button></li>
32+
</ul> -->
33+
<ul class="genders">
34+
<li><button id="men" onClick="menButton()">Men</button></li>
35+
<li><button id="both" onClick="bothButton()" class="active">Both</button></li>
36+
<li><button id="women" onClick="womenButton()">Women</button></li>
37+
</ul>
38+
<span class="counter smalltext">0 users generated this session</span><br>
39+
<button id="new-user" class="new-user" onClick="getAUser()"></button><br>
40+
<a id="legoText" href="#" onClick="legoButton();">Lego Mode</a><br>
41+
<a href="https://randomapi.com" target="_blank">Powered by RandomAPI</a>
42+
<a href="https://randomuser.me" target="_blank" style="display: block; margin-top: 2px;">https://randomuser.me</a><br>
43+
<span class="update smalltext" style="display: block; margin-top: -10px;"></span><br>
44+
</div>
45+
</body>
46+
</html>

0 commit comments

Comments
 (0)