JSFiddle - React, Tailwind, and code Playground
by PhillipSenn
HTML
This is actually coll.cfc, not the html
component {
url.returnformat = "json";
url.queryformat = "column";
remote function WhereScannerName(ScannerName) {
include "/Inc/newQuery.cfm";
local.sql = "
SELECT *
FROM CollView
WHERE CollID IN(
SELECT Distinct CollID
FROM FabricView
WHERE FabricDiscDate is null
AND MfgID IN(
SELECT MfgID
FROM swatchdog.swatchdog.UsrMfg
WHERE UsrID = (
SELECT TOP 1 Scanner_UsrID
FROM Scanner
WHERE ScannerName = ?
ORDER BY ScannerName
)
)
)
";
local.svc.addParam(cfsqltype="CF_SQL_VARCHAR",value=arguments.ScannerName);
include "/Inc/execute.cfm";
return local.result;
}
}
CSS
This doesn't run, I just wanted a place to show a lot of source code.
JavaScript
request.Coll = $.Deferred();
(function() {
Print('Coll.js');
var Variables = {};
Variables.Recordcount = 0;
var webSQL = {};
var remote = {};
webSQL.Drop = function(SQLTransaction) {
var local = {};
local.sqlite = "DROP TABLE IF EXISTS Coll";
SQLTransaction.executeSql(
local.sqlite
,[]
,webSQL.CreateTransaction
,request.dboFail
);
}
webSQL.CreateTransaction = function() {
dbo.transaction(webSQL.Create);
}
webSQL.Create = function(SQLTransaction) {
var local = {};
local.sqlite = "CREATE TABLE IF NOT EXISTS Coll"
+ "(CollID Integer NOT NULL PRIMARY KEY"
+ ",Coll_MfgID Integer"
+ ",CollName Varchar(128)"
+ ",CollSort Integer"
+ ",ScanOnOff Integer"
+ ",CollUpdated Date"
+ ");"
SQLTransaction.executeSql(
local.sqlite
,[]
,remote.Select
,request.dboFail
);
}
remote.Select = function() {
var local = {};
local.data = {};
local.data.method = 'WhereScannerName';
local.data.ScannerName = window.localStorage.getItem('serial');
local.Promise = $.ajax('Coll.cfc', local);
local.Promise.done(remote.SelectDone);
local.Promise.fail(request.PromiseFail);
}
remote.SelectDone = function(RESULT) {
var local = {};
if (RESULT.MSG) {
$('header').text(RESULT.MSG);
} else {
local.qry = RESULT.QRY.DATA;
Variables.Recordcount=RESULT.QRY.ROWCOUNT;
dbo.transaction(function(SQLTransaction) {
for (local.CurrentRow=0; local.CurrentRow < Variables.Recordcount; local.CurrentRow++) {
webSQL.Insert(local.qry,local.CurrentRow,SQLTransaction);
}
});
}
};
webSQL.Insert = function(qry,CurrentRow,SQLTransaction) {
var local = {};
local.CollUpdated = YYYY_MM_DD(qry.COLLUPDATED[CurrentRow]); // UPPERCASE
local.sqlite = "INSERT INTO Coll(CollID,Coll_MfgID,CollName,CollSort,ScanOnOff,CollUpdated) VALUES(?1,?2,?3,?4,?5,?6)"
SQLTransaction.executeSql(
local.sqlite
,[
qry.COLLID[CurrentRow] // UPPERCASE 1
,qry.COLL_MFGID[CurrentRow] // UPPERCASE...