-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f58a13
commit 9fbf784
Showing
20 changed files
with
34,763 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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);} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
--> | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Oops, something went wrong.