Permalink
Browse files

Work on link to Data Set option (incomplete); closes #28, closes #29

  • Loading branch information...
1 parent 9bdd5e7 commit 5134868f943185bd821c9bddf57be317f0d5c5fa @benkeen committed Dec 30, 2012
View
@@ -40,4 +40,4 @@
}
} else {
echo $encoded;
-}
+}
View
@@ -7,7 +7,8 @@
<h2>Thanks!</h2>
<p>
- The Data Generator uses the work of a LOT of people. Thanks to the everybody involved in the following:
+ The Data Generator uses the work of a LOT of people. Thanks to the everybody involved in the following. You all rock. I would be <i>proud</i>
+ if any of you wanted to marry my sister.
</p>
<ul>
@@ -19,14 +20,15 @@
<li><a href="http://harvesthq.github.com/chosen/" target="_blank">Chosen</a> - select box enhancement script</li>
<li><a href="http://code.google.com/p/jquery-json/" target="_blank">jQuery JSON plugin</a></li>
<li><a href="http://twitter.github.com/bootstrap/" target="_blank">Bootstrap</a></li>
+ <li><a href="http://sass-lang.com/" target="_blank">Sass</a> - Syntactically Awesome Stylesheets</li>
<li><a href="http://excanvas.sourceforge.net/" target="_blank">ExplorerCanvas</a> - </li>
<li><a href="http://www.iconfinder.com/icondetails/50830/128/dice_icon" target="_blank">La Glanz Studio - dice icon (main logo)</a></li>
<li><a href="http://led24.de/iconset/" target="_blank">Nice bug icon</a></li>
</ul>
<p>
And a big thanks to Addy Osmani for his excellent article: <a href="http://addyosmani.com/largescalejavascript/">Patterns For
- Large-Scale JavaScript Application Architecture</a>. The client-side code was largely based on his article.
+ Large-Scale JavaScript Application Architecture</a>. The client-side code architecture was largely based on his article.
</p>
</div>
@@ -1,4 +1,4 @@
-/*global $:false*/
+/*global $:false,define:false*/
define([
"manager",
"constants",
@@ -18,11 +18,24 @@ define([
var MODULE_ID = "data-type-TextFixed";
var LANG = L.dataTypePlugins.TextFixed;
- var _saveRow = function() {
-
+ var _saveRow = function(rowNum) {
+ return {
+ numWords: $("dtNumWords_" + rowNum).val()
+ };
};
- var _loadRow = function() {
+ var _loadRow = function(rowNum, data) {
+ return {
+ execute: function() { },
+ isComplete: function() {
+ if (data && $("#dtNumWords_" + rowNum).length) {
+ $("dtNumWords_" + rowNum).val(data.numWords);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ };
};
@@ -181,7 +181,7 @@ private function generateCreateTableSQL_MySQL() {
}
if ($this->createTable) {
- $content = "CREATE TABLE {$this->backquote}{$this->tableName}{$this->backquote} ($endLineChar";
+ $content .= "CREATE TABLE {$this->backquote}{$this->tableName}{$this->backquote} ($endLineChar";
if ($this->primaryKey == "default") {
$content .= "{$prefix}{$this->backquote}id{$this->backquote} mediumint(8) unsigned NOT NULL auto_increment,$endLineChar";
}
@@ -258,7 +258,7 @@ private function generateCreateTableSQL_Oracle() {
}
if ($this->createTable) {
- $content = "CREATE TABLE {$this->backquote}{$this->tableName}{$this->backquote} ($endLineChar";
+ $content .= "CREATE TABLE {$this->backquote}{$this->tableName}{$this->backquote} ($endLineChar";
if ($this->primaryKey == "default") {
$content .= "{$prefix}{$this->backquote}id{$this->backquote} number primary key,$endLineChar";
}
@@ -331,7 +331,7 @@ private function generateCreateTableSQL_SQLite() {
}
if ($this->createTable) {
- $content = "CREATE TABLE {$this->backquote}{$this->tableName}{$this->backquote} ($endLineChar";
+ $content .= "CREATE TABLE {$this->backquote}{$this->tableName}{$this->backquote} ($endLineChar";
if ($this->primaryKey == "default") {
$content .= "{$prefix}{$this->backquote}id{$this->backquote} INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,$endLineChar";
}
@@ -47,24 +47,25 @@ public function __construct($accountID) {
$this->date_expires = date("U", strtotime($accountInfo["date_expires"]));
$this->firstName = $accountInfo["first_name"];
$this->lastName = $accountInfo["last_name"];
-
$this->getConfigurations();
+ $this->numRowsGenerated = $accountInfo["num_rows_generated"];
}
}
public function getAccount() {
return array(
- "isAnonymous" => $this->isAnonymous,
- "accountID" => $this->accountID,
- "accountType" => $this->accountType,
- "dateCreated" => $this->dateCreated,
- "lastUpdated" => $this->lastUpdated,
- "dateExpires" => $this->dateExpires,
- "firstName" => $this->firstName,
- "lastName" => $this->lastName,
- "email" => $this->email,
- "configurations" => $this->configurations
+ "isAnonymous" => $this->isAnonymous,
+ "accountID" => $this->accountID,
+ "accountType" => $this->accountType,
+ "dateCreated" => $this->dateCreated,
+ "lastUpdated" => $this->lastUpdated,
+ "dateExpires" => $this->dateExpires,
+ "firstName" => $this->firstName,
+ "lastName" => $this->lastName,
+ "email" => $this->email,
+ "configurations" => $this->configurations,
+ "numRowsGenerated" => $this->numRowsGenerated
);
}
@@ -157,8 +158,8 @@ public function saveConfiguration($data) {
if ($configurationID == null) {
$response = Core::$db->query("
- INSERT INTO {$prefix}configurations (date_created, last_updated, account_id, configuration_name, content)
- VALUES ('$now', '$now', $accountID, '" . $configurationName . "', '" . $content . "')
+ INSERT INTO {$prefix}configurations (status, date_created, last_updated, account_id, configuration_name, content)
+ VALUES ('private', '$now', '$now', $accountID, '" . $configurationName . "', '" . $content . "')
");
if ($response["success"]) {
@@ -228,7 +229,6 @@ public static function createUser($accountInfo) {
}
-
public function updateRowsGeneratedCount($configurationID, $rowsGenerated) {
if (!is_numeric($rowsGenerated)) {
return;
@@ -242,6 +242,12 @@ public function updateRowsGeneratedCount($configurationID, $rowsGenerated) {
SET num_rows_generated = num_rows_generated+$cleanRowsGenerated
WHERE account_id = $accountID AND configuration_id = $configurationID
");
+
+ $response = Core::$db->query("
+ UPDATE {$prefix}user_accounts
+ SET num_rows_generated = num_rows_generated+$cleanRowsGenerated
+ WHERE account_id = $accountID
+ ");
}
}
@@ -227,6 +227,25 @@ public function __construct($action, $post = array()) {
$this->response["content"] = $response["message"];
break;
+ case "getDataSetLink":
+ Core::init();
+ $configurationIDs = $post["configurationIDs"];
+
+ $google_url_shortener_key = "***enter code here***";
+ $url = array("longUrl" => $_POST["url"]);
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, "https://www.googleapis.com/urlshortener/v1/url?key=$google_url_shortener_key");
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($url));
+ $output = curl_exec($ch);
+ curl_close($ch);
+
+ echo $output;
+
+ break;
+
/*
case "login":
break;
@@ -27,7 +27,7 @@ class Core {
private static $defaultTheme = "classic";
// non-overidable settings
- private static $version = "3.0.0";
+ private static $version = "3.0.0 alpha 1";
private static $minimumPHPVersion = "5.2.0";
private static $settingsFileExists = false;
private static $dataTypeGroups = array("human_data", "geo", "text", "numeric", "other");
@@ -84,6 +84,7 @@ public static function createCoreTables() {
$queries[] = "
CREATE TABLE {$prefix}configurations (
configuration_id mediumint(9) NOT NULL auto_increment,
+ status ENUM('public','private') NOT NULL,
date_created datetime NOT NULL,
last_updated datetime NOT NULL,
account_id mediumint(9) NOT NULL,
@@ -151,6 +152,7 @@ public static function createCoreTables() {
password varchar(50) NOT NULL,
password_recovery_question varchar(100) default NULL,
password_recovery_answer varchar(100) default NULL,
+ num_rows_generated mediumint(9) default 0,
max_records mediumint(9) default NULL,
PRIMARY KEY (account_id)
)
@@ -115,6 +115,7 @@ define([
$("#gdResetPluginsBtn").bind("click", _resetPluginsDialog);
$("#gdTextSize").on("click", "li", _changeTextSize);
$("#gdGenerationPanelCancel").on("click", _cancelGeneration);
+ $("#gdDataSetPublic").on("click", _toggleDataSetVisibilityStatus);
// icon actions
$("#gdSaveBtn").on("click", _onClickSaveIcon);
@@ -131,6 +132,7 @@ define([
$("#gdDataSetHelpNav").on("click", "a", _onclickDataTypeHelpNav);
$("#gdTableRows").on("click", ".ui-icon-help", _onClickDataSetRowHelp);
$("#gdSelectAllDataSets").on("click", _onToggleSelectAllDataSets);
+ $("#gdDataSetStatusLine").html("not saved");
_initMainDialog();
_initExportTypeTab();
@@ -197,7 +199,7 @@ define([
// update the status line
var lastUpdated = moment.unix(configuration.last_updated_unix).format("h:mm A, MMM Do YYYY");
- $("#gdDataSetStatusLine").html("Last edited " + lastUpdated);
+ $("#gdDataSetStatusLine").html("last edited " + lastUpdated);
utils.stopProcessing();
@@ -311,10 +313,8 @@ define([
success: function(response) {
if (response.success) {
_currConfigurationID = response.content;
- console.log(response);
-
var lastUpdated = moment.unix(response.lastUpdated).format("h:mm A, MMM Do YYYY");
- $("#gdDataSetStatusLine").html("Last saved: " + lastUpdated);
+ $("#gdDataSetStatusLine").html("last saved: " + lastUpdated);
_getAccount();
} else {
// TODO
@@ -460,6 +460,8 @@ define([
_selectExportTypeTab($(".gdDefaultExportType").data("exportType"), true);
manager.resetExportTypes();
+ $("#gdDataSetStatusLine").html("not saved");
+
manager.publish({
sender: MODULE_ID,
type: C.EVENT.DATA_TABLE.CLEAR
@@ -1232,8 +1234,6 @@ define([
var _onSuccessDeleteDataSets = function(response) {
-
- // if the delete was successful
if (response.success) {
// update the first tab (Num Saved Data Sets)
@@ -1252,6 +1252,8 @@ define([
_displayDataSets();
_toggleDeleteDataSetButton();
+ } else {
+ // TODO
}
};
@@ -1295,17 +1297,13 @@ define([
if (_accountInfo.isAnonymous) {
$("#gdAccount_AccountType").html("Anonymous admin account");
} else {
-
+ // TODO
}
$("#gdAccount_NumSavedDataSets").html(_dataSets.length);
$("#gdAccount_DateAccountCreated").html(moment.unix(_accountInfo.dateCreated).format("MMM Do, YYYY"));
-
- var totalRowsGenerated = 0;
- for (var i=0; i<_dataSets.length; i++) {
- totalRowsGenerated += parseInt(_dataSets[i].num_rows_generated, 10);
- }
- $("#gdAccount_TotalRowsGenerated").html(utils.formatNumWithCommas(totalRowsGenerated));
+ var numRowsGenerated = parseInt(_accountInfo.numRowsGenerated, 10);
+ $("#gdAccount_TotalRowsGenerated").html(utils.formatNumWithCommas(numRowsGenerated));
};
var _displayDataSets = function() {
@@ -1318,11 +1316,13 @@ define([
currDataSet = _dataSets[i];
var dateCreated = moment.unix(currDataSet.date_created_unix).format("MMM Do, YYYY");
var lastUpdated = moment.unix(currDataSet.last_updated_unix).format("MMM Do, YYYY");
+ var isPublic = (currDataSet.status == "public") ? 'checked="checked"' : "";
row = '<tr data-id="' + currDataSet.configuration_id + '">' +
'<td class="leftAligned">' + currDataSet.configuration_name + '</td>' +
'<td class="leftAligned">' + dateCreated + '</td>' +
'<td class="leftAligned">' + lastUpdated + '</td>' +
+ '<td align="center"><input type="checkbox" class="gdDataSetStatus" id="gdDataSetStatus_' + currDataSet.configuration_id + '" ' + isPublic + ' /></td>' +
'<td class="gdDataSetNumRowsGenerated" align="center">' + utils.formatNumWithCommas(currDataSet.num_rows_generated) + '</td>' +
'<td align="center"><a href="#">load</a></td>' +
'<td align="center"><input type="checkbox" class="gdDeleteDataSets" value="' + currDataSet.configuration_id + '"/></td>' +
@@ -1389,7 +1389,55 @@ define([
};
var _openDataSetLinkDialog = function(e) {
-
+ if (_currConfigurationID === null) {
+ $("#gdLinkToDataSet_incomplete").removeClass("hidden");
+ $("#gdLinkToDataSet_complete").addClass("hidden");
+ } else {
+ $("#gdLinkToDataSet_incomplete").addClass("hidden");
+ $("#gdLinkToDataSet_complete").removeClass("hidden");
+ }
+
+ $("#gdLinkToDataSetDialog").dialog({
+ title: 'Link to Data Set',
+ dialogClass: "gdMainDialog",
+ width: 500,
+ modal: true,
+ resizable: false,
+ open: function() {
+ if (_currConfigurationID !== null) {
+ var url = window.location.href.replace(/(#.*)/, "");
+ url = url.replace(/(\?.*)/, "") + "?load=" + _currConfigurationID;
+ $("#gdLinkURL").data("url", url);
+
+ var config = _getConfiguration(_currConfigurationID);
+ if (config.status == "public") {
+ $("#gdDataSetPublic").attr("checked", "checked");
+ $("#gdLinkURL").val(url + "?load=" + _currConfigurationID).removeClass("gdDisabled").removeAttr("disabled").select();
+ } else {
+ $("#gdDataSetPublic").removeAttr("checked");
+ $("#gdLinkURL").val("-").attr("disabled", "disabled").addClass("gdDisabled");
+ }
+ }
+ },
+ buttons: [
+ {
+ text: "Close",
+ click: function() { $(this).dialog("close"); }
+ }
+ ]
+ });
+
+ return false;
+ };
+
+
+ var _toggleDataSetVisibilityStatus = function(e) {
+ if (e.target.checked) {
+ var url = $("#gdLinkURL").data("url");
+ $("#gdLinkURL").removeClass("gdDisabled").removeAttr("disabled").val(url).select();
+ } else {
+ $("#gdLinkURL").addClass("gdDisabled").attr("disabled", "disabled").val("-");
+ }
};
Oops, something went wrong.

0 comments on commit 5134868

Please sign in to comment.