Skip to content

Commit

Permalink
pwkvn: experimental displays 01, 02, 03.
Browse files Browse the repository at this point in the history
  • Loading branch information
funderburkjim committed May 7, 2022
1 parent af4086e commit 13cd948
Show file tree
Hide file tree
Showing 46 changed files with 2,369 additions and 56 deletions.
6 changes: 3 additions & 3 deletions css/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#CologneBasic .pb {font-size:smaller; }
#CologneBasic .hom {color:red;}
#CologneBasic .footnote {font-size:smaller;}
#CologneBasic .ls {color:gray; font-size:smaller;}
#CologneBasic .ls {color:gray; font-size:11pt; font-family: charterindocapital;}
#CologneBasic .gram {font-weight:bold;}
#CologneBasic .divm {font-weight:bold;}
#CologneBasic .wide {font-stretch:wider;}
Expand All @@ -71,11 +71,11 @@
margin-right: 15px; /*5px;*/

margin-top: 10px; /* 20px; Dec 5, 2013 */
font-size: 14px;
font-size: 11pt;
padding-right: 15px ;/*15px;*/ /* 04-18-2017 For AP display, with indenting */
}
#CologneBasic td, th {
padding-left,padding-right: 15px;
padding-left:10px; padding-right: 35px;
padding-top: 5px;
text-align: left;
}
Expand Down
2 changes: 1 addition & 1 deletion pwkvn/csl-accent.js → pwkvn/01/csl-accent.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, css, LitElement,unsafeHTML } from './lit-element-2.3.1.js';
import { html, css, LitElement,unsafeHTML } from '../js/lit-element-2.3.1.js';

class cslAccent extends LitElement {
static get styles() {
Expand Down
2 changes: 1 addition & 1 deletion pwkvn/csl-citation.js → pwkvn/01/csl-citation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, css, LitElement,unsafeHTML } from './lit-element-2.3.1.js';
import { html, css, LitElement,unsafeHTML } from '../js/lit-element-2.3.1.js';

class cslCitation1 extends LitElement {
static get styles() {
Expand Down
2 changes: 1 addition & 1 deletion pwkvn/csl-dict.js → pwkvn/01/csl-dict.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, css, LitElement,unsafeHTML } from './lit-element-2.3.1.js';
import { html, css, LitElement,unsafeHTML } from '../js/lit-element-2.3.1.js';

class cslDict extends LitElement {
static get styles() {
Expand Down
10 changes: 5 additions & 5 deletions pwkvn/csl-getword02.js → pwkvn/01/csl-getword02.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, css, LitElement,unsafeHTML } from './lit-element-2.3.1.js';
import { html, css, LitElement,unsafeHTML } from '../js/lit-element-2.3.1.js';
import {getwordStyles} from './getword_styles.js';

class cslGetword02 extends LitElement {
Expand Down Expand Up @@ -28,7 +28,7 @@ class cslGetword02 extends LitElement {
this.accent = 'yes';
this.result = '... working ...';
}
urlbaseF = function () {
unused_urlbaseF = function () {
return css`https://sanskrit-lexicon.uni-koeln.de/scans`;
let origin = window.location.origin;
if (origin.indexOf("sanskrit-lexicon.uni-koeln.de") >= 0) {
Expand All @@ -42,10 +42,10 @@ class cslGetword02 extends LitElement {
// Don't use connectedCallback() since it can't be async
//async firstUpdated() {
async updated() {
const urlbase = this.urlbaseF();
//const urlbase = this.urlbaseF();
//console.log('csl-getword02: urlbase=',urlbase);
let url_apidev = `${urlbase}/csl-apidev`;
url_apidev = '../' ; // when running app in subfolder of csl-apidev
//let url_apidev = `${urlbase}/csl-apidev`;
let url_apidev = '../../' ; // when running app in sub-subfolder of csl-apidev
//const baseurl = 'https://sanskrit-lexicon.uni-koeln.de/scans/csl-apidev/getword.php';
const baseurl = `${url_apidev}/getword.php`;
const url = `${baseurl}?dict=${this.dict}&key=${this.key}&input=${this.input}&output=${this.output}&dispopt=3&accent=${this.accent}`
Expand Down
2 changes: 1 addition & 1 deletion pwkvn/csl-input.js → pwkvn/01/csl-input.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, css, LitElement,unsafeHTML } from './lit-element-2.3.1.js';
import { html, css, LitElement,unsafeHTML } from '../js/lit-element-2.3.1.js';

class cslInput extends LitElement {
static get styles() {
Expand Down
2 changes: 1 addition & 1 deletion pwkvn/csl-output.js → pwkvn/01/csl-output.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, css, LitElement,unsafeHTML } from './lit-element-2.3.1.js';
import { html, css, LitElement,unsafeHTML } from '../js/lit-element-2.3.1.js';

class cslOutput extends LitElement {
static get styles() {
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions pwkvn/getsuggestClass.php → pwkvn/01/getsuggestClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
//getsuggestClass.php 04-19-2022
// Read a list of headwords from a text file
// and return first few that start with a given string.
require_once('../utilities/transcoder.php'); // initializes transcoder
require_once("../dbgprint.php");
require_once('../../utilities/transcoder.php'); // initializes transcoder
require_once("../../dbgprint.php");

require_once('../parm.php');
require_once('../../parm.php');
class GetsuggestClass {
public $matches,$json;
public function __construct() {
Expand All @@ -28,7 +28,7 @@ public function __construct() {
$more = True;
$max = 10; # max number of return results
$maxlike=100;
$filename = "mergehw.txt";
$filename = "../mergehw/mergehw.txt";
$lines = file($filename,FILE_IGNORE_NEW_LINES);
$results1 = array();
$keymatch = $key;
Expand Down
2 changes: 1 addition & 1 deletion pwkvn/getword_styles.js → pwkvn/01/getword_styles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css, unsafeCSS} from './lit-element-2.3.1.js';
import { css, unsafeCSS} from '../js/lit-element-2.3.1.js';
/* Adaptaion of csl-apidev/css/basic.css. Almost identical.
*/
/*
Expand Down
28 changes: 28 additions & 0 deletions pwkvn/01/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>

<title>01 pwkvn</title>
<style>
.grid-container {
display: grid;
grid-gap: 10px;
grid-template-columns: auto auto;
}
.grid-item {
width:400px;
(padding: 10px;
}

</style>
<link rel="stylesheet" type="text/css" href="./fonts.css">

</head>
<body>
<my-app1 input="HK">
</my-app1>

<script type="module" src="./my-app1.js"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion pwkvn/my-app.js → pwkvn/01/my-app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, css, LitElement,unsafeHTML } from './lit-element-2.3.1.js';
import { html, css, LitElement,unsafeHTML } from '../js/lit-element-2.3.1.js';
//import {getwordStyles} from './getword_styles.js';

import './csl-getword02.js';
Expand Down
2 changes: 1 addition & 1 deletion pwkvn/my-app1.js → pwkvn/01/my-app1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, css, LitElement,unsafeHTML } from './lit-element-2.3.1.js';
import { html, css, LitElement,unsafeHTML } from '../js/lit-element-2.3.1.js';
import './csl-input.js';
import './my-app.js';
import './csl-citation.js';
Expand Down
62 changes: 62 additions & 0 deletions pwkvn/02/csl-accent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { html, css, LitElement,unsafeHTML } from '../js/lit-element-2.3.1.js';

class cslAccent extends LitElement {
static get styles() {
return [

];
}

static get properties() {
return {
accent: { type: String },
};
}

constructor() {
super();
this.input="yes";
}
itemnames = [
['yes', 'Show Accent'],
['no', 'Hide Accent'],
];

itemF = function(item) {
let value = item[0];
let name = item[1];
let markup;
if (this.accent.toLowerCase() == value.toLowerCase()) {
markup = html`<option value="${value}" selected>${name}</option>`;
} else {
markup = html`<option value="${value}">${name}</option>`;
}
return markup;
}
onChangeF (event) {
//event.preventDefault();
this.accent = event.target.value;
//console.log('csl-accent: new value of this.accent=',this.accent);
var new_event = new CustomEvent('new-accent',
{detail: {accent:this.accent}
});
this.dispatchEvent(new_event); // this. is needed. Not sure why
}

render() {
return html`
<div id="accentdiv" title="accent selection">
<select name="accent" id="accent"
@change=${this.onChangeF}
>
${this.itemnames.map(item =>this.itemF(item))}
</select>
</div>
`;
}
}


customElements.define('csl-accent', cslAccent);


146 changes: 146 additions & 0 deletions pwkvn/02/csl-citation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import { html, css, LitElement,unsafeHTML } from '../js/lit-element-2.3.1.js';

class cslCitation1 extends LitElement {
static get styles() {
return [
css``
];
}

static get properties() {
return {
key: { type: String },
appname: { type: String },
dict: { type: String},
input: { type: String},
datalist: {type: Array},
oldval: {type: String},
value: {type: String},
suggest: {type: String},
dbg: Boolean
};
}

constructor() {
super();
this.key='';
this.appname='csl-citation';
this.dict="";
this.input="";
this.datalist=[];
this.oldval='';
this.value='';
this.suggest='no'; // or 'yes'
this.dbg=false;
}
customEvent() {
let new_event = new CustomEvent('new-citation',
{detail: {key:this.key,appname:this.appname}
});
this.dispatchEvent(new_event); // this. is needed. Not sure why
}
onReturnKey = (event) => {
// Number 13 is the "Enter" key on the keyboard
if (event.keyCode === 13) {
// Cancel the default action, if needed
event.preventDefault();
// value is a string of form x : y
let text = event.target.value
let result = text.match(/^[^ ]+/);
this.key = result[0];
if (this.dbg) {console.log('return key: result=',result);}
var new_event = new CustomEvent('new-citation',
{detail: {key:this.key,appname:this.appname}
});
this.dispatchEvent(new_event); // this. is required why?
}
}

async onKeyup (event) {
// User hits enter key. This finishes the search
if ((event.keyCode === 13) ) {
// the second condition may be undesireable when some
// elements of the datalist are prefixes of other elements.
// value is a string of form x : y
let text = this.value;
let result = text.match(/^[^ ]+/); // returns array
this.key = result[0];
if (this.dbg) {console.log('onKeyup: result=',result);}
event.target.blur(); // causes option to stop
//this.requestUpdate();
this.customEvent();
return;
}

event.preventDefault();
let value = event.target.value;
if (value == this.oldval) {return;}
this.oldval = value;
this.value=value;
if (this.dbg) {console.log('onKeyup: new value =',value);}
if (value == '') {
this.key = "";
this.customEvent();
//this.requestUpdate();
return;
}
this.key="";
if (value.length < 2) {
return;
}

const baseurl = `getsuggest.php`;
//if (this.dbg) {console.log('this.dict=',this.dict);}
//let url = `${baseurl}?dict=${this.dict}&input=${this.input}&term=${this.value}`;
let url = `${baseurl}?input=${this.input}&term=${this.value}`;
if (this.dbg) {console.log('begin fetch from url',url);}
await fetch(url)
.then(r => r.json())
.then(async data => {
this.datalist = data; // an array of strings
if (this.dbg) {console.log('end fetch. data=',data);}
})
/*.then(() => this.requestUpdate());*/
}

render() {
if (this.dbg) {console.log('render: suggest comes in as',this.suggest);}
//if(this.suggest === undefined) {this.suggest = 'no';}
// Not sure why above statement does NOT always catch undefine
if (this.suggest != 'yes') {this.suggest = 'no';}
if (this.dbg) {console.log('csl-citation render. dict=',this.dict,this.suggest);}
if (this.suggest == 'no') {
return html`
<div class="citationdiv">
<input class="keyInput" type="text" name="key" size="20" value="${this.key}"
style="height:2.0em"
placeholder="Search headword"
@keyup=${this.onReturnKey} />
</div>
`;
}
return html`
<div>
<input class="keyInput" name="key" size="20" value="${this.key}"
style="height:2.0em"
list="lang"
placeholder="Search headword"
title="headword"
@keyup=${this.onKeyup} />
<datalist id="lang">
${this.datalist.map(item =>
html`
<option value="${item}"
>${item}</option>
`)}
</datalist>
</div>
`;
}
}
if (!customElements.get('csl-citation')) {
customElements.define('csl-citation', cslCitation1);}

Loading

0 comments on commit 13cd948

Please sign in to comment.