Skip to content

Commit

Permalink
pwkvn display added.
Browse files Browse the repository at this point in the history
  • Loading branch information
funderburkjim committed Apr 26, 2022
1 parent 4f58a13 commit 9fbf784
Show file tree
Hide file tree
Showing 20 changed files with 34,763 additions and 62 deletions.
6 changes: 3 additions & 3 deletions basicadjust.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct($getParms,$xmlrecs) {
$key = $getParms->key;
$this->dbg=false;
$this->dal_ab = new Dal($dict,"ab");
if (in_array($dict,array('pwg','pw'))) {
if (in_array($dict,array('pwg','pw','pwkvn'))) {
$this->dal_auth = new Dal($dict,"bib"); # pwgbib
dbgprint(false,"basicadjust: bib file open? " . $this->dal_auth->status ."\n");
}else if (in_array($dict,array('mw','ap90','ben'))){
Expand Down Expand Up @@ -66,7 +66,7 @@ public function line_adjust($line) {
/* Replace the 'title' part of a known ls with its capitalized form
This is probably particular to pwg and/or pw
*/
if (in_array($this->getParms->dict,array('pw','pwg'))) {
if (in_array($this->getParms->dict,array('pw','pwg','pwkvn'))) {
$line = preg_replace_callback('|<ls(.*?)>(.*?)</ls>|',
"BasicAdjust::ls_callback_pwg",$line);

Expand Down Expand Up @@ -219,7 +219,7 @@ public function ls_matchabbr($fieldname,$fieldidx,$data) {
if (!preg_match("|^([^ .,']+)|",$data,$matches)) {
return $ans;
}
//$tabid = 'code'; // pw, pwg
//$tabid = 'code'; // pw, pwg, pwkvn
$key = $matches[1];
$key1 = $key . '%';
$sql = "select * from $table where $fieldname LIKE '$key1'";
Expand Down
3 changes: 2 additions & 1 deletion dictinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DictInfo {
"PUI"=>"2014" , "PWG"=>"2013" , "PW"=>"2014" , "SCH"=>"2014",
"SHS"=>"2014" , "SKD"=>"2013" , "SNP"=>"2014" , "STC"=>"2013",
"VCP"=>"2019" , "VEI"=>"2014" , "WIL"=>"2014" , "YAT"=>"2014",
"LAN"=>"2019","ARMH"=>"2020");
"LAN"=>"2019","ARMH"=>"2020","PWKVN"=>"2020");
//static public $scanpath = "../.."; // scan dir.depends on loc of this file!
//static public $scanpath = preg_replace('|/awork/apidev|','',__DIR__);
#public $scanpath;
Expand Down Expand Up @@ -195,6 +195,7 @@ public function get_cologne_pdfpages_url() {
"YAT"=>"//www.sanskrit-lexicon.uni-koeln.de/scans/YATScan/2014/web/pdfpages" ,
"LAN"=>"//www.sanskrit-lexicon.uni-koeln.de/scans/LANScan/2019/web/pdfpages" ,
"ARMH"=>"//www.sanskrit-lexicon.uni-koeln.de/scans/ARMHScan/2020/web/pdfpages" ,
"PWKVN"=>"//www.sanskrit-lexicon.uni-koeln.de/scans/PWScan/2014/web/pdfpages" ,
);
$url = $cologne_pdfpages_urls[$this->dictupper];
return $url;
Expand Down
146 changes: 146 additions & 0 deletions pwkvn/csl-citation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import { html, css, LitElement,unsafeHTML } from './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);}

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

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

];
}

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

constructor() {
super();
this.dict="mw";
}
dictnames =
[['WIL' , 'Wilson Sanskrit-English'],
['YAT' , 'Yates Sanskrit-English'],
['GST' , 'Goldstücker Sanskrit-English'],
['BEN' , 'Benfey Sanskrit-English'],
['MW72' , 'Monier-Williams 1872 Sanskrit-English'],
['AP90' , 'Apte Practical Sanskrit-English'],
['CAE' , 'Cappeller Sanskrit-English'],
['MD' , 'Macdonell Sanskrit-English'],
['MW' , 'Monier-Williams Sanskrit-English'],
['SHS' , 'Shabda-Sagara Sanskrit-English'],
['BHS' , 'Edgerton Buddhist Hybrid Sanskrit'],
['AP' , 'Practical Sanskrit-English, revised'],
['PD' , 'An Encyclopedic Dictionary of Sanskrit'], // on Historical Principles'],
['MWE' , 'Monier-Williams English-Sanskrit'],
['BOR' , 'Borooah English-Sanskrit'],
['AE' , 'Apte Student English-Sanskrit'],
['BUR' , 'Burnouf D. Sanscrit-Français'], //'Burnouf Dictionnaire Sanscrit-Français'],
['STC' , 'Stchoupak D. Sanscrit-Français'], //'Stchoupak Dictionnaire Sanscrit-Français'],
['PWG' , 'Grosses Petersburger Wörterbuch'], //'Böhtlingk and Roth Grosses Petersburger Wörterbuch'],
['GRA' , 'Grassman Wörterbuch zum Rig Veda'],
['PW' , 'Böhtlingk Sanskrit-Wörterbuch'], // in kürzerer Fassung'],
['PWKVN' , 'PW, Nachträge und Verbesserungen'],
['CCS' , 'Cappeller Sanskrit Wörterbuch'],
['SCH' , 'Schmidt Nachträge'], // zum Sanskrit-Wörterbuch'],
['BOP' , 'Bopp Glossarium Sanscritum'],
['SKD' , 'Sabda-kalpadruma'],
['VCP' , 'Vacaspatyam'],
['INM' , 'Names in the Mahabharata'],//'Index to the Names in the Mahabharata'],
['VEI' , 'The Vedic Index'], // of Names and Subjects'],
['PUI' , 'The Purana Index'],
['ACC' , 'Aufrecht Catalogus Catalogorum'],
['KRM' , 'Kṛdantarūpamālā'],
['IEG' , 'Indian Epigraphical Glossary'],
['SNP' , 'Meulenbeld Sanskrit Names of Plants'],
['PE' , 'Puranic Encyclopedia'],
['PGN' , 'Names in the Gupta Inscriptions'], //'Personal and Geographical Names in the Gupta Inscriptions'],
['MCI' , 'Mahabharata Cultural Index']
];
dictitemF = function(item) {
let value = item[0];
let name = item[1];
let markup;
if (this.dict.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.dict = event.target.value;
//console.log('csl-dict: new value of this.dict=',this.dict);
var new_event = new CustomEvent('new-dict',
{detail: {dict:this.dict}
});
this.dispatchEvent(new_event); // this. is needed. Not sure why
}

render() {
return html`
<div id="dictdiv">
<select name="input" id="input"
@change=${this.onChangeF}>
${this.dictnames.map(item =>this.dictitemF(item))}
</select>
</div>
`;
}
}

if (!customElements.get('csl-dict')) {
customElements.define('csl-dict', cslDict);
}

/*
<!-- <label for="input">input</label> -->
}
<!--
<option value='hk' selected='selected'>KH </option>
<option value='slp1'>SLP1</option>
<option value='itrans'>ITRANS</option>
<option value='deva'>Devanagari</option>
<option value='roman'>IAST</option>
-->
*/
73 changes: 73 additions & 0 deletions pwkvn/csl-getword02.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { html, css, LitElement,unsafeHTML } from './lit-element-2.3.1.js';
import {getwordStyles} from './getword_styles.js';

class cslGetword02 extends LitElement {
static get styles() {
return [
getwordStyles
];
}

static get properties() {
return {
dict: { type: String },
key: { type: String },
input: { type: String },
output: { type: String },
accent: { type: String},
result: { type: String }
};
}

constructor() {
super();
this.dict = 'md';
this.key = 'guru';
this.input = 'slp1';
this.output = 'deva'; // fixed
this.accent = 'no';
this.result = '... working ...';
}
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) {
return css`https://sanskrit-lexicon.uni-koeln.de/scans`;
}else {
//return origin + "/cologne";
return css`http://localhost/cologne`;
}
}

// Don't use connectedCallback() since it can't be async
//async firstUpdated() {
async updated() {
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
//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`
//console.log('updated. url=',url);
await fetch(url)
.then(r => r.text())
.then(async data => {
//console.log('csl-getword02: updated result=','found'); //data);
this.result = data;
});
}

render() {

const result=`${this.result}`;
return html`
<div id="CologneBasic">
${unsafeHTML(result)}
</div>
`;
}
}

customElements.define('csl-getword', cslGetword02);
Loading

0 comments on commit 9fbf784

Please sign in to comment.