diff --git a/httpdocs/theme/react/src/entry-home-main-container.js b/httpdocs/theme/react/src/entry-home-main-container.js deleted file mode 100644 index 5637e27cf..000000000 --- a/httpdocs/theme/react/src/entry-home-main-container.js +++ /dev/null @@ -1,4 +0,0 @@ -import React from 'react'; -import HomeMainContainer from './opendesktop-home/HomeMainContainer'; - -ReactDOM.render(, document.getElementById('main-content')); diff --git a/httpdocs/theme/react/src/entry-metaheader-local.js b/httpdocs/theme/react/src/entry-metaheader-local.js deleted file mode 100644 index 36d1d4c4a..000000000 --- a/httpdocs/theme/react/src/entry-metaheader-local.js +++ /dev/null @@ -1,4 +0,0 @@ -import React from 'react'; -import MetaHeader from './metaheader/MetaHeader'; - -ReactDOM.render(, document.getElementById('metaheader')); diff --git a/httpdocs/theme/react/src/entry-metaheader.js b/httpdocs/theme/react/src/entry-metaheader.js deleted file mode 100644 index 83b6d68b7..000000000 --- a/httpdocs/theme/react/src/entry-metaheader.js +++ /dev/null @@ -1,93 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import MetaHeader from './metaheader/MetaHeader'; -import '@webcomponents/custom-elements'; -async function initConfig(target, redirect) -{ - let url = `https://www.opendesktop.org/home/metamenubundlejs?target=${target}&url=${redirect}`; - if (window.location.hostname.endsWith('cc')) { - url = `https://www.opendesktop.cc/home/metamenubundlejs?target=${target}&url=${redirect}`; - } - - - try { - const response = await fetch(url, { - mode: 'cors', - credentials: 'include' - }); - if (!response.ok) { - throw new Error('Network response error'); - } - let config = await response.json(); - config.isAdmin = config.json_isAdmin; - config.showModal = false; - config.isExternal = true; - config.modalUrl = ''; - return config; - } - catch (error) { - console.error(error); - return false; - } - - -} - -// async function f() { -// let config = await initConfig('opendesktop',window.location.href); // wait till the promise resolves (*) -// ReactDOM.render(, document.getElementById('metaheader')) -// } -// -// f(); - - -customElements.define('opendesktop-metaheader', class extends HTMLElement { - constructor() { - super(); - this.buildComponent(); - } - - async buildComponent() { - - const stylesheetElement = document.createElement('link'); - stylesheetElement.rel = 'stylesheet'; - stylesheetElement.href = 'https://www.opendesktop.org/theme/react/assets/css/metaheader.css'; - - if (window.location.hostname.endsWith('cc')) { - stylesheetElement.href = 'https://www.opendesktop.cc/theme/react/assets/css/metaheader.css'; - }/*else if(location.hostname.endsWith('localhost')) - { - //stylesheetElement.href = 'https://www.opendesktop.cc/theme/react/assets/css/metaheader.css'; - }*/ - // else if (location.hostname.endsWith('localhost')) { - // stylesheetElement.href = 'https://www.opendesktop.cc/theme/react/assets/css/metaheader.css'; - // }else if (location.hostname.endsWith('local')) { - // stylesheetElement.href = 'https://www.opendesktop.cc/theme/react/assets/css/metaheader.css'; - // } - // else{ - // stylesheetElement.href = 'https://www.opendesktop.org/theme/react/assets/css/metaheader.css'; - // } - this.appendChild(stylesheetElement); - - const metaheaderElement = document.createElement('div'); - metaheaderElement.id = 'metaheader'; - let config = await initConfig(this.getAttribute('config-target'),window.location.href); // wait till the promise resolves (*) - - - ReactDOM.render(, metaheaderElement); - - - // Component must be capsule within Shadow DOM, and don't hack - // context/scope of external sites. - /* - this.attachShadow({mode: 'open'}); - this.shadowRoot.appendChild(stylesheetElement); - this.shadowRoot.appendChild(metaheaderElement); - */ - - // However, make this as Light DOM for now, because current - // implementation is not real component design yet. - // Need solve event handling, scoped CSS. - this.appendChild(metaheaderElement); - } -}); diff --git a/httpdocs/theme/react/src/header/MobileSiteHeader.js b/httpdocs/theme/react/src/header/MobileSiteHeader.js deleted file mode 100644 index b905c9a03..000000000 --- a/httpdocs/theme/react/src/header/MobileSiteHeader.js +++ /dev/null @@ -1,116 +0,0 @@ -import React from 'react'; -import SiteHeaderSearchForm from './SiteHeaderSearchForm'; -import Support from './Support'; -class MobileSiteHeader extends React.Component { - constructor(props){ - super(props); - this.state = { - status:"switch" - }; - this.showMobileUserMenu = this.showMobileUserMenu.bind(this); - this.showMobileSearchForm = this.showMobileSearchForm.bind(this); - this.showMobileSwitchMenu = this.showMobileSwitchMenu.bind(this); - - } - - showMobileUserMenu(){ - this.setState({status:"user"}); - } - - showMobileSearchForm(){ - this.setState({status:"search"}); - } - - showMobileSwitchMenu(){ - this.setState({status:"switch"}); - } - - render(){ - const menuItemCssClass = { - "borderColor":this.props.template['header-nav-tabs']['border-color'], - "backgroundColor":this.props.template['header-nav-tabs']['background-color'] - } - - const closeMenuElementDisplay = ( - - - - ); - - let PlingDisplay; - if(this.props.section ) - { - PlingDisplay = -
- -
- } - - let mobileMenuDisplay; - if (this.state.status === "switch"){ - mobileMenuDisplay = ( -
- - - - {/* - - - - */} - { PlingDisplay } -
- ); - } else if (this.state.status === "user"){ - mobileMenuDisplay = ( -
-
- -
- {closeMenuElementDisplay} -
- ) - } else if (this.state.status === "search"){ - mobileMenuDisplay = ( -
-
- -
- {closeMenuElementDisplay} -
- ) - } - - let logoElementCssClass = this.props.store.name; - if (this.state.status !== "switch"){ - logoElementCssClass += " mini-version"; - } - - return( -
- -
- {mobileMenuDisplay} -
-
- ); - } -} - -export default MobileSiteHeader; diff --git a/httpdocs/theme/react/src/header/MobileUserContainer.js b/httpdocs/theme/react/src/header/MobileUserContainer.js deleted file mode 100644 index a97e38e78..000000000 --- a/httpdocs/theme/react/src/header/MobileUserContainer.js +++ /dev/null @@ -1,39 +0,0 @@ -import React from 'react'; -import SiteHeaderLoginMenu from './SiteHeaderLoginMenu'; -class MobileUserContainer extends React.Component { - constructor(props){ - super(props); - this.state = {}; - } - - render(){ - - let userDisplay; - if (this.props.user){ - // userDisplay = ( - // - // ); - } else { - userDisplay = ( - - ); - } - - return ( -
- {userDisplay} -
- ) - } -} - -export default MobileUserContainer; diff --git a/httpdocs/theme/react/src/header/SiteHeader.js b/httpdocs/theme/react/src/header/SiteHeader.js deleted file mode 100644 index d738e0f89..000000000 --- a/httpdocs/theme/react/src/header/SiteHeader.js +++ /dev/null @@ -1,150 +0,0 @@ -import React, { Component } from 'react'; -import MobileSiteHeader from './MobileSiteHeader'; -import SiteHeaderSearchForm from './SiteHeaderSearchForm'; -import Support from './Support'; -class SiteHeader extends Component { - constructor(props){ - super(props); - this.state = { - baseUrl:window.json_baseurl, - searchBaseUrl:window.json_searchbaseurl, - cat_title:window.json_cat_title, - hasIdentity:window.json_hasIdentity, - is_show_title:window.json_is_show_title, - redirectString:window.json_redirectString, - serverUrl:window.json_serverUrl, - serverUri:window.json_serverUri, - store:{ - sName:window.json_sname, - name:window.json_store_name, - order:window.json_store_order, - last_char_store_order:window.json_last_char_store_order, - }, - user:window.json_member, - logo:window.json_logoWidth, - cat_title_left:window.json_cat_title_left, - tabs_left:window.tabs_left, - template:window.json_template, - status:"", - section:window.json_section, - url_logout:window.json_logouturl - }; - this.updateDimensions = this.updateDimensions.bind(this); - } - - componentWillMount() { - this.updateDimensions(); - } - - componentDidMount() { - window.addEventListener("resize", this.updateDimensions); - window.addEventListener("orientationchange",this.updateDimensions); - } - - updateDimensions(){ - const width = window.innerWidth; - let device; - if (width >= 910){ - device = "large"; - } else if (width < 910 && width >= 610){ - device = "mid"; - } else if (width < 610){ - device = "tablet"; - } - this.setState({device:device}); - } - - render(){ - let siteHeaderTopRightCssClass; - let logoLink = this.state.serverUrl; - if (this.state.serverUri.indexOf('/s/') > -1){ - logoLink += "/s/" + this.state.store.name; - } - - let siteHeaderStoreNameDisplay; - if (this.state.is_show_title === "1"){ - siteHeaderStoreNameDisplay = ( - - ); - } - let PlingDisplay; - if(this.state.section) - { - PlingDisplay = -
- -
- } - - let HeaderDisplay; - if (this.state.device !== "tablet"){ - let logoStyle = this.state.template['header-logo']; - logoStyle.left="80px"; - HeaderDisplay = ( - - ); - } else { - HeaderDisplay = ( - - ) - } - - let templateHeaderStyle; - if (this.state.template){ - templateHeaderStyle = { - "backgroundImage":this.state.template.header['background-image'], - "backgroundColor":this.state.template.header['background-color'], - "height":this.state.template.header['height'] - } - } - - let headerStoreClassName = this.state.store.name.toLowerCase(); - if (headerStoreClassName.indexOf('.') > -1) headerStoreClassName = headerStoreClassName.split('.')[0] - - return ( - - ) - } -} - -export default SiteHeader; diff --git a/httpdocs/theme/react/src/header/SiteHeaderSearchForm.js b/httpdocs/theme/react/src/header/SiteHeaderSearchForm.js deleted file mode 100644 index f181933f1..000000000 --- a/httpdocs/theme/react/src/header/SiteHeaderSearchForm.js +++ /dev/null @@ -1,44 +0,0 @@ -import React from 'react'; - -class SiteHeaderSearchForm extends React.Component { - constructor(props){ - super(props); - this.state = { - searchText:'' - }; - this.onSearchTextChange = this.onSearchTextChange.bind(this); - this.onSearchFormSubmit = this.onSearchFormSubmit.bind(this); - } - - onSearchTextChange(e){ - this.setState({searchText:e.target.value}); - } - - onSearchFormSubmit(e){ - e.preventDefault(); - window.location.href = this.props.searchBaseUrl + this.state.searchText; - } - - render(){ - - let siteHeaderSearchFormStyle; - - if (this.props.store.name.toLowerCase().indexOf("appimagehub") > -1) { - let tHeight = parseInt(this.props.height.split('px')[0]); - siteHeaderSearchFormStyle = { - "marginTop": (tHeight / 2) - 19 + "px" - } - } - - return ( -
-
- - -
-
- ) - } -} - -export default SiteHeaderSearchForm; diff --git a/httpdocs/theme/react/src/header/Support.js b/httpdocs/theme/react/src/header/Support.js deleted file mode 100644 index e0e41bbf1..000000000 --- a/httpdocs/theme/react/src/header/Support.js +++ /dev/null @@ -1,91 +0,0 @@ -import React, { Component } from 'react'; -class Support extends Component { - constructor(props){ - super(props); - this.state = {selected:'month'}; - this.handleClick = this.handleClick.bind(this); - this.tabSwitch = this.tabSwitch.bind(this); - } - - componentWillMount() { - document.addEventListener('click',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('click',this.handleClick, false); - } - - - handleClick(e){ - - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if(e.target.className === "header-supporters" ) - { - // only btn click open dropdown - if (this.state.dropdownClass === "open"){ - dropdownClass = ""; - }else{ - dropdownClass = "open"; - } - }else{ - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - tabSwitch(selected) - { - this.setState({selected:selected}); - } - - render(){ - let supporters; - if(this.props.section.supporters) - { - const sectioncontainer =
-
    -
  • this.tabSwitch('month')} - > - Months -
  • -
- Become a Supporter -
- - // default show month panel - let content = this.props.section.supporters.sort((a, b) => Number(a.active_months) < Number(b.active_months)).map((mg,i) => ( -
-
{mg.active_months+' months'}
- )) - - - const t = ( -
- {sectioncontainer} - { content } -
- ) - - supporters =
    {t}
- } - const s = this.props.section.supporters?this.props.section.supporters.length:0; - return( -
-
- -
this.node = node} className={'supporter-container '+this.state.dropdownClass }> - {this.props.section ? this.props.section.name:''} {s} Supporters ⌄ - {supporters} -
-
-
- ) - } -} - -export default Support; diff --git a/httpdocs/theme/react/src/header/_SiteHeaderLoginMenu.js b/httpdocs/theme/react/src/header/_SiteHeaderLoginMenu.js deleted file mode 100644 index e11c6baa9..000000000 --- a/httpdocs/theme/react/src/header/_SiteHeaderLoginMenu.js +++ /dev/null @@ -1,36 +0,0 @@ -import React from 'react'; - -class SiteHeaderLoginMenu extends React.Component { - constructor(props){ - super(props); - this.state = {}; - } - render(){ - - let registerButtonCssClass, - loginButtonCssClass; - - if (window.location.href.indexOf('/register') > -1){ - registerButtonCssClass = "active"; - } - - if (window.location.href.indexOf('/login') > -1){ - loginButtonCssClass = "active"; - } - - const menuItemCssClass = { - "borderColor":this.props.template['header-nav-tabs']['border-color'], - "backgroundColor":this.props.template['header-nav-tabs']['background-color'] - } - //
  • Register
  • - return ( -
    - -
    - ) - } -} - -export default SiteHeaderLoginMenu; diff --git a/httpdocs/theme/react/src/header/_SiteHeaderUserMenu.js b/httpdocs/theme/react/src/header/_SiteHeaderUserMenu.js deleted file mode 100644 index 953768f0c..000000000 --- a/httpdocs/theme/react/src/header/_SiteHeaderUserMenu.js +++ /dev/null @@ -1,58 +0,0 @@ -import React from 'react'; - -class SiteHeaderUserMenu extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "profile-menu-toggle" || - e.target.className === "profile-menu-image" ||  - e.target.className === "profile-menu-username"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - render(){ - - return ( - - ) - } -} -export default SiteHeaderUserMenu; diff --git a/httpdocs/theme/react/src/metaheader.js b/httpdocs/theme/react/src/metaheader.js deleted file mode 100644 index 2b053648d..000000000 --- a/httpdocs/theme/react/src/metaheader.js +++ /dev/null @@ -1,1773 +0,0 @@ -//import '@babel/polyfill'; -import "core-js/shim"; -import "regenerator-runtime/runtime"; -import '@webcomponents/custom-elements' -import React from 'react'; -import ReactDOM from 'react-dom'; - -// Use this object for config data instead of window.domains, -// window.baseUrl, window.etc... so don't set variables in global scope. -// Please see initConfig() -let config = {}; - -async function initConfig(target,url_afterlogin) { - // API https://www.opendesktop.org/home/metamenujs should send - // JSON data with CORS. - // Please see config-dummy.php. - - // Also this API call sends cookie of www.opendesktop.org/cc - // by fetch() with option "credentials: 'include'", so - // www.opendesktop.org/cc possible detect user session. - // Can we consider if include user information into JSON data of - // API response instead of cookie set each external site? - - let url = `https://www.opendesktop.org/home/metamenubundlejs?target=${target}`; - - if (location.hostname.endsWith('cc')) { - url = `https://www.opendesktop.cc/home/metamenubundlejs?target=${target}`; - } - else if (location.hostname.endsWith('localhost')) { - url = `http://localhost:${location.port}/config-dummy.php`; - } - else if (location.hostname.endsWith('pling.local')) { - url = `http://pling.local/home/metamenubundlejs?target=${target}`; - } - - if(url_afterlogin) - { - url = url+`&url=${url_afterlogin}`; - } - - try { - const response = await fetch(url, { - mode: 'cors', - credentials: 'include' - }); - if (!response.ok) { - throw new Error('Network response error'); - } - config = await response.json(); - return true; - } - catch (error) { - console.error(error); - return false; - } -} - -window.appHelpers = function () { - - function generateMenuGroupsArray(domains) { - let menuGroups = []; - domains.forEach(function (domain, index) { - if (menuGroups.indexOf(domain.menugroup) === -1) { - menuGroups.push(domain.menugroup); - } - }); - return menuGroups; - } - - function getDeviceFromWidth(width) { - let device; - if (width >= 910) { - device = "large"; - } else if (width < 910 && width >= 610) { - device = "mid"; - } else if (width < 610) { - device = "tablet"; - } - return device; - } - - function generatePopupLinks() { - - let pLink = {}; - pLink.plingListUrl = "/#plingList", pLink.ocsapiContentUrl = "/#ocsapiContent", pLink.aboutContentUrl = "/#aboutContent", pLink.linkTarget = "_blank"; - - if (window.location.hostname.indexOf('opendesktop') === -1 || window.location.hostname === "opencode.net" || window.location.hostname === "git.opendesktop.cc" || window.location.hostname === "forum.opendesktop.org" || window.location.hostname === "forum.opendesktop.cc" || window.location.hostname === "my.opendesktop.org" || window.location.hostname === "my.opendesktop.cc") { - pLink.plingListUrl = "/plings"; - pLink.ocsapiContentUrl = "/partials/ocsapicontent.phtml"; - pLink.aboutContentUrl = "/partials/about.phtml"; - pLink.linkTarget = ""; - } - return pLink; - } - - function getPopupUrl(key, isExternal, baseUrl) { - let url = baseUrl; - return url; - } - - return { - generateMenuGroupsArray, - getDeviceFromWidth, - generatePopupLinks, - getPopupUrl - }; -}(); - -class MetaHeader extends React.Component { - constructor(props){ - super(props); - this.state = { - domains:config.domains, - baseUrl:config.baseUrl, - blogUrl:config.blogUrl, - forumUrl:config.forumUrl, - loginUrl:config.loginUrl, - logoutUrl:config.logoutUrl, - gitlabUrl:config.gitlabUrl, - sName:config.sName, - isExternal:config.isExternal, - user:config.user, - showModal:false, - modalUrl:'', - metamenuTheme:config.metamenuTheme, - isAdmin:config.json_isAdmin - }; - this.initMetaHeader = this.initMetaHeader.bind(this); - this.updateDimensions = this.updateDimensions.bind(this); - this.onSwitchStyle = this.onSwitchStyle.bind(this); - - //this.getUser = this.getUser.bind(this); - } - - - componentWillMount() { - this.updateDimensions(); - } - - componentDidMount() { - this.initMetaHeader(); - //this.initMetamenuTheme(); - - } - - componentWillUnmount(){ - window.removeEventListener("resize", this.updateDimensions); - window.removeEventListener("orientationchange",this.updateDimensions); - - } - - initMetaHeader(){ - window.addEventListener("resize", this.updateDimensions); - window.addEventListener("orientationchange",this.updateDimensions); - //this.getUser(); - } - - fetchMetaheaderThemeSettings(){ - - let url = 'https://www.opendesktop.org/membersetting/getsettings'; - if (location.hostname.endsWith('cc') || location.hostname.endsWith('local')) { - url = 'https://www.opendesktop.cc/membersetting/getsettings'; - } - - fetch(url,{ - mode: 'cors', - credentials: 'include' - }) - .then(response => response.json()) - .then(data => { - const results = data.results; - if(results.length>0) - { - const theme = results.filter(r => r.member_setting_item_id == 1); - if(theme.length>0 && theme[0].value==1) - { - this.setState({metamenuTheme:'metamenu-theme-dark'}); - } - } - }); - - - } - - // change metamenu class - onSwitchStyle(evt){ - - let url = 'https://www.opendesktop.org/membersetting/setsettings/itemid/1/itemvalue/'; - if (location.hostname.endsWith('cc') || location.hostname.endsWith('local')) { - url = 'https://www.opendesktop.cc/membersetting/setsettings/itemid/1/itemvalue/'; - } - url = url +(evt.target.checked?'1':'0'); - const isChecked = evt.target.checked; - fetch(url,{ - mode: 'cors', - credentials: 'include' - }) - .then(response => response.json()) - .then(data => { - this.setState({metamenuTheme:`${isChecked?'metamenu-theme-dark':''}`}); - }); - } - - getUser(){ - const decodedCookie = decodeURIComponent(document.cookie); - let ocs_data = decodedCookie.split('ocs_data=')[1]; - if (ocs_data){ - if (ocs_data.indexOf(';') > -1){ ocs_data = ocs_data.split(';')[0]; } - const user = JSON.parse(ocs_data); - this.setState({user:user}); - } - } - - updateDimensions(){ - const width = window.innerWidth; - let device; - if (width >= 1015){ - device = "large"; - } else if (width < 1015 && width >= 730){ - device = "mid"; - } else if (width < 730){ - device = "tablet"; - } - this.setState({device:device}); - } - - render(){ - - let domainsMenuDisplay; - if (this.state.device === "tablet"){ - domainsMenuDisplay = ( - - ) - } else { - domainsMenuDisplay = ( - - ) - } - const metamenuCls = `metamenu ${this.state.metamenuTheme}`; - let paraChecked = false; - if(this.state.metamenuTheme){ - paraChecked=true; - } - return ( - - ) - } -} - -class DomainsMenu extends React.Component { - constructor(props){ - super(props); - this.state = { - }; - } - - render(){ - - let moreMenuItemDisplay, adminsDropDownMenuDisplay, myOpendesktopMenuDisplay; - if (this.props.device !== "large"){ - moreMenuItemDisplay = ( - - ) - } - - return ( - - ) - } -} - -class DomainsDropDownMenu extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - } - - componentDidMount() { - let menuGroups = []; - this.props.domains.forEach(function(domain,index){ - if (menuGroups.indexOf(domain.menugroup) === -1){ - menuGroups.push(domain.menugroup); - } - }); - this.setState({menuGroups:menuGroups}); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "domains-menu-link-item"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - render(){ - - let menuGroupsDisplayLeft, menuGroupsDisplayRight; - if (this.state.menuGroups){ - menuGroupsDisplayLeft = this.state.menuGroups.slice(0,2).map((mg,i) => ( - - )); - menuGroupsDisplayRight = this.state.menuGroups.slice(2).map((mg,i) => ( - - )); - } - - return ( -
  • this.node = node} id="domains-dropdown-menu" className={this.state.dropdownClass}> - Store Listings -
      -
    • -
        - {menuGroupsDisplayLeft} -
      -
    • -
    • -
        - {menuGroupsDisplayRight} -
      -
    • -
    -
  • - ); - } -} - -class DiscussionBoardsDropDownMenu extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "discussion-menu-link-item"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - render(){ - return ( -
  • this.node = node} id="discussion-boards" className={this.state.dropdownClass}> - - Discussion Boards - -
  • - ); - } - -} - -class DevelopmentDropDownMenu extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.state = { - gitlabLink:config.gitlabUrl+"/dashboard/issues?assignee_id=" - }; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - componentDidMount() { - /*const self = this; - const xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - const res = JSON.parse(this.response); - const gitlabLink = self.state.gitlabLink + res[0].id; - self.setState({gitlabLink:gitlabLink,loading:false}); - } - }; - xhttp.open("GET", config.gitlabUrl+"/api/v4/users?username="+this.props.user.username, true); - xhttp.send();*/ - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "admins-menu-link-item"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - render(){ - let issuesMenuItem; - if (this.props.isAdmin){ - issuesMenuItem = ( -
  • Issues
  • - ) - } - - let gitfaqLinkItem; - if (config.isExternal === false){ - gitfaqLinkItem = (
  • Git FAQ
  • ); - } else { - gitfaqLinkItem = (
  • Git FAQ
  • ); - } - - return ( -
  • this.node = node} id="admins-dropdown-menu" className={this.state.dropdownClass}> - Development -
      -
    • Projects
    • - {issuesMenuItem} - {gitfaqLinkItem} -
    -
  • - ) - } -} - -class MoreDropDownMenu extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "more-menu-link-item"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - render(){ - - let faqLinkItem, apiLinkItem, aboutLinkItem; - if (config.isExternal === false){ - faqLinkItem = (
  • FAQ
  • ); - apiLinkItem = (
  • API
  • ); - aboutLinkItem = (
  • About
  • ); - } else { - faqLinkItem = (
  • FAQ
  • ); - apiLinkItem = (
  • API
  • ); - aboutLinkItem = (
  • About
  • ); - } - - return( -
  • this.node = node} id="more-dropdown-menu" className={this.state.dropdownClass}> - More - -
  • - ) - } -} - -class DomainsMenuGroup extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.filterDomainsByMenuGroup = this.filterDomainsByMenuGroup.bind(this); - } - - filterDomainsByMenuGroup(domain){ - if (domain.menugroup === this.props.menuGroup){ - return domain; - } - } - - render(){ - const domainsDisplay = this.props.domains.filter(this.filterDomainsByMenuGroup).map((domain,index) => { - let domainPrefix = ""; - if (domain.menuhref.indexOf('https://') === -1 && domain.menuhref.indexOf('http://') === -1){ - domainPrefix += "http://"; - } - return ( -
  • - {domain.name} -
  • - ); - }); - - return ( -
  • - {this.props.menuGroup} -
      - {domainsDisplay} -
    -
  • - ) - } -} - -function SwitchItem(props){ - return( -
    - -
    - ) -} - -class UserMenu extends React.Component { - constructor(props){ - super(props); - this.state = {}; - } - - render(){ - let userDropdownDisplay, userAppsContextDisplay, developmentAppMenuDisplay; - if (this.props.user && this.props.user.member_id){ - userDropdownDisplay = ( - - ); - userAppsContextDisplay = ( - - ); - developmentAppMenuDisplay = ( - - ); - } else { - userDropdownDisplay = ( -
  • Login
  • - ) - } - - let userMenuContainerDisplay; - if (this.props.device === "large"){ - - let faqLinkItem, apiLinkItem, aboutLinkItem; - if (config.isExternal === false){ - faqLinkItem = (
  • FAQ
  • ); - apiLinkItem = (
  • API
  • ); - aboutLinkItem = (
  • About
  • ); - } else { - faqLinkItem = (
  • FAQ
  • ); - apiLinkItem = (
  • API
  • ); - aboutLinkItem = (
  • About
  • ); - } - - let switchItem; - - if (this.props.user && this.props.user.member_id && this.props.isAdmin){ - switchItem =(
  • ); - } - - userMenuContainerDisplay = ( -
      -
    • Community
    • -
    • Support
    • -
    • Blog
    • - {faqLinkItem} - {apiLinkItem} - {aboutLinkItem} - {switchItem} - {developmentAppMenuDisplay} - {userAppsContextDisplay} - {userDropdownDisplay} -
    - ); - } else { - userMenuContainerDisplay = ( -
      - {developmentAppMenuDisplay} - {userAppsContextDisplay} - {userDropdownDisplay} -
    - ); - } - - - return ( -
    - {userMenuContainerDisplay} -
    - ) - } -} - -class UserContextMenuContainer extends React.Component { - constructor(props){ - super(props); - this.state = { - gitlabLink:props.gitlabUrl+"/dashboard/issues?assignee_id=" - }; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - componentDidMount() { - const self = this; - const xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - const res = JSON.parse(this.response); - const gitlabLink = self.state.gitlabLink + res[0].id; - //const gitlabLink = self.state.gitlabLink; - self.setState({gitlabLink:gitlabLink,loading:false}); - } - }; - xhttp.open("GET", config.gitlabUrl+"/api/v4/users?username="+this.props.user.username, true); - xhttp.send(); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "th-icon" || e.target.className === "btn btn-default dropdown-toggle"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - render(){ - - /* - // BU CODE - - */ - - const urlEnding = config.baseUrl.split('opendesktop.')[1]; - - let contextMenuDisplay; - if (this.props.isAdmin){ - contextMenuDisplay = ( - - ); - } else { - contextMenuDisplay = ( - - ); - } - return ( -
  • this.node = node} id="user-context-menu-container"> -
    - - {contextMenuDisplay} -
    -
  • - ) - } -} - -class DevelopmentAppMenu extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - componentDidMount() { - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "th-icon" || e.target.className === "btn btn-default dropdown-toggle"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - render(){ - - - return ( -
  • this.node = node} id="development-app-menu-container"> - -
  • - ) - } -} - -class UserLoginMenuContainerVersionTwo extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "th-icon" || e.target.className === "btn btn-default dropdown-toggle"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass},function(){ - if (dropdownClass === "open"){ - $('body').addClass('drawer-open'); - } else { - $('body').removeClass('drawer-open'); - } - }); - } - - - render(){ - return ( -
  • this.node = node}> -
    - -
    -
      -
    • -
      -
      -
      - -
      -
      -
      -
        -
      • {this.props.user.username}

      • -
      • {this.props.user.mail}
      • -
      • - Settings - Logout -
      • -
      -
      -
      -
    • -
    • - -
    • -
    -
    -
    -
  • - ) - } -} - -class UserLoginMenuContainer extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "th-icon" || e.target.className === "btn btn-default dropdown-toggle"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - - render(){ - return ( -
  • this.node = node}> -
    - -
      -
    • -
      -
      -
      - -
      -
      -
      -
        -
      • {this.props.user.username}
      • -
      • {this.props.user.mail}
      • -
      -
      -
      -
    • -
    • - Settings - Logout -
    • -
    -
    -
  • - ) - } -} - -class UserTabs extends React.Component { - constructor(props){ - super(props); - this.state = { - currentTab:'comments', - searchPhrase:'' - }; - this.onTabMenuItemClick = this.onTabMenuItemClick.bind(this); - this.onUserSearchInputChange = this.onUserSearchInputChange.bind(this); - this.getUsersAutocompleteList = this.getUsersAutocompleteList.bind(this); - this.selectUserFromAutocompleteList = this.selectUserFromAutocompleteList.bind(this); - } - - onTabMenuItemClick(val){ - this.setState({currentTab:val}); - } - - onUserSearchInputChange(e){ - const searchPhrase = e.target.value; - this.setState({searchPhrase:e.target.value},function(){ - let showUserList; - if (searchPhrase.length > 2){ - showUserList = true; - } else { - showUserList = false; - } - this.setState({showUserList:showUserList,selectedUser:''},function(){ - this.getUsersAutocompleteList(searchPhrase); - }); - }); - } - - getUsersAutocompleteList(searchPhrase){ - const self = this; - const xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - const res = JSON.parse(this.response); - self.setState({usersList:res,showUserList:true}); - } - }; - xhttp.open("GET", "https://www.opendesktop.cc/home/searchmember?username="+searchPhrase, true); - xhttp.send(); - } - - selectUserFromAutocompleteList(user){ - this.setState({selectedUser:user,searchPhrase:user.username,showUserList:false}); - } - - render(){ - - let usersAutocompleteList; - if (this.state.usersList && this.state.showUserList){ - const users = this.state.usersList.map((u,index) => ( -
  • this.selectUserFromAutocompleteList(u)} key={index}> - {u.username} -
  • - )); - usersAutocompleteList = ( -
      - {users} -
    - ); - } - - - let tabContentDisplay; - if (this.state.currentTab === 'comments'){ - tabContentDisplay = ( - - ); - } else if (this.state.currentTab === 'search'){ - if (this.state.selectedUser){ - - tabContentDisplay = ( - - ); - } else { - tabContentDisplay = ( -

    search user

    - ); - } - } - - return( -
    - -
    - {tabContentDisplay} -
    -
    - ); - } -} - -class UserCommentsTab extends React.Component { - constructor(props){ - super(props); - this.state = { - loading:true - }; - this.getUserOdComments = this.getUserOdComments.bind(this); - this.getUserForumComments = this.getUserForumComments.bind(this); - } - - componentDidMount() { - this.setState({odComments:[],forumComments:[],loading:true},function(){ - this.getUserOdComments(); - }); - } - - getUserOdComments(){ - const user = this.props.user; - const self = this; - const xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - const res = JSON.parse(this.response); - self.setState({odComments:res.commentsOpendeskop,loading:false},function(){ - self.getUserForumComments(); - }); - } - }; - xhttp.open("GET", "home/memberjson?member_id="+user.member_id, true); - xhttp.send(); - } - - getUserForumComments(){ - const user = this.props.user; - const self = this; - const xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - const res = JSON.parse(this.response); - self.setState({forumComments:res.user_actions,loading:false}); - } - }; - xhttp.open("GET", "https://forum.opendesktop.cc/user_actions.json?offset=0&username=" + user.username + "&filter=5", true); - xhttp.send(); - } - - render(){ - let contentDisplay; - if (!this.state.loading){ - let odCommentsDisplay, forumCommentsDisplay; - if (this.state.odComments.length > 0){ - odCommentsDisplay = ( - - ); - } - if (this.state.forumComments.length > 0){ - forumCommentsDisplay = ( - - ); - } - - contentDisplay = ( -
    - {odCommentsDisplay} - {forumCommentsDisplay} -
    - ) - - } else { - contentDisplay = ( -
    loading
    - ); - } - - return( -
    - {contentDisplay} -
    - ) - } -} - -class UserSearchTab extends React.Component { - constructor(props){ - super(props); - this.state = { - loading:true - }; - this.getUserOdComments = this.getUserOdComments.bind(this); - this.getUserForumComments = this.getUserForumComments.bind(this); - } - - componentDidMount() { - this.setState({odComments:[],forumComments:[],loading:true},function(){ - this.getUserOdComments(); - }); - } - - getUserOdComments(){ - const user = this.props.user; - const self = this; - const xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - const res = JSON.parse(this.response); - self.setState({odComments:res.commentsOpendeskop,loading:false},function(){ - self.getUserForumComments(); - }); - } else { - console.log('what happends here'); - console.log(this); - } - }; - xhttp.open("GET", "home/memberjson?member_id="+user.member_id, true); - xhttp.send(); - } - - getUserForumComments(){ - const user = this.props.user; - const self = this; - const xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - console.log('this '); - if (this.readyState == 4 && this.status == 200) { - const res = JSON.parse(this.response); - self.setState({forumComments:res.user_actions,loading:false}); - } - }; - xhttp.open("GET", "https://forum.opendesktop.cc/user_actions.json?offset=0&username=" + user.username + "&filter=5", true); - xhttp.send(); - } - - render(){ - let contentDisplay; - if (!this.state.loading){ - let odCommentsDisplay, forumCommentsDisplay; - if (this.state.odComments.length > 0){ - odCommentsDisplay = ( - - ); - } - if (this.state.forumComments.length > 0){ - forumCommentsDisplay = ( - - ); - } - - contentDisplay = ( -
    - {odCommentsDisplay} - {forumCommentsDisplay} -
    - ) - - } else { - contentDisplay = ( -
    loading
    - ); - } - - return( -
    - {contentDisplay} -
    - ) - } -} - -class UserCommentsTabThreadsContainer extends React.Component { - constructor(props){ - super(props); - this.state = {}; - } - - componentDidMount() { - let siteInfo; - if (this.props.type === 'od'){ - siteInfo = { - address:'openDesktop.org', - url:'https://www.opendesktop.org' - } - } else if (this.props.type === 'forum'){ - siteInfo = { - address:'forum', - url:'https://forum.opendesktop.org' - } - } - - let threads = []; - this.props.comments.forEach(function(c,index){ - if (threads.indexOf(c.title) === -1){ - const thread = { - title:c.title, - id:c.project_id - } - threads.push(thread) - } - }); - - this.setState({siteInfo:siteInfo,comments:this.props.comments,threads:threads}); - } - - render(){ - const t = this.state.siteInfo; - const comments = this.state.comments; - const user = this.props.user; - let headerDisplay, threadsDisplay, threadCommentsDisplay; - if (this.state.threads){ - threadsDisplay = this.state.threads.map((tr,index) => ( - - )); - headerDisplay = ( -
    -
    -

    Discussion on {this.state.siteInfo.address}

    -

    {this.state.comments.length} comments

    -
    - {threadsDisplay} -
    - ); - } - - return ( -
    - {headerDisplay} -
    - {threadCommentsDisplay} -
    -
    - ) - } -} - -class UserCommentsTabThread extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.filterCommentsByThread = this.filterCommentsByThread.bind(this); - } - - filterCommentsByThread(comment){ - if (comment.title === this.props.thread.title){ - return comment; - } - } - - render(){ - let commentsDisplay; - if (this.props.comments){ - const user = this.props.user; - commentsDisplay = this.props.comments.filter(this.filterCommentsByThread).map((c,index) => ( - - )); - } - return ( -
    - -
    - {commentsDisplay} -
    -
    - ); - } -} - -class UserCommentsTabThreadCommentItem extends React.Component { - constructor(props){ - super(props); - this.state = {}; - } - - render(){ - const c = this.props.comment; - const user = this.props.user; - let repliedUsernameDisplay; - if (c.p_comment_member_id){ - repliedUsernameDisplay = (

    {c.p_username}

    ) - } - - let userImage = user.avatar; - if (this.props.uType === 'search'){ - userImage = user.profile_image_url; - } - - return ( -
    -
    - -
    -
    -

    {user.username}

    - {repliedUsernameDisplay} -

    {c.comment_created_at}

    -
    -
    -
    -
    -
    - ) - } -} - -/** MOBILE SPECIFIC **/ - -class MobileLeftMenu extends React.Component { - constructor(props){ - super(props); - this.state = { - overlayClass:"" - }; - this.toggleLeftSideOverlay = this.toggleLeftSideOverlay.bind(this); - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - window.addEventListener('mousedown',this.handleClick, false); - window.addEventListener('touchend', this.handleClick, false); - } - - componentWillUnmount() { - window.removeEventListener('mousedown',this.handleClick, false); - window.addEventListener('touchend', this.handleClick, false); - } - - toggleLeftSideOverlay(){ - let overlayClass = "open"; - if (this.state.overlayClass === "open") { - overlayClass = ""; - } - this.setState({overlayClass:overlayClass}); - } - - handleClick(e){ - let overlayClass = ""; - if (this.node.contains(e.target)){ - if (this.state.overlayClass === "open"){ - if (e.target.id === "left-side-overlay" || e.target.id === "menu-toggle-item"){ - overlayClass = ""; - } else { - overlayClass = "open"; - } - } else { - overlayClass = "open"; - } - } - - const self = this; - setTimeout(function () { - console.log('time out'); - self.setState({overlayClass:overlayClass}); - }, 200); - } - - render(){ - return ( -
    this.node = node} id="metaheader-left-mobile" className={this.state.overlayClass}> - -
    - -
    -
    - ); - } -} - -class MobileLeftSidePanel extends React.Component { - constructor(props){ - super(props); - this.state = {}; - } - - componentDidMount() { - let menuGroups = []; - this.props.domains.forEach(function(domain,index){ - if (menuGroups.indexOf(domain.menugroup) === -1){ - menuGroups.push(domain.menugroup); - } - }); - this.setState({menuGroups:menuGroups}); - } - - render(){ - let panelMenuGroupsDisplay; - if (this.state.menuGroups){ - panelMenuGroupsDisplay = this.state.menuGroups.map((mg,i) => ( - - )); - } - - let faqLinkItem, apiLinkItem, aboutLinkItem; - if (config.isExternal === false){ - faqLinkItem = (
  • FAQ
  • ); - apiLinkItem = (
  • API
  • ); - aboutLinkItem = (
  • About
  • ); - } else { - faqLinkItem = (
  • FAQ
  • ); - apiLinkItem = (
  • API
  • ); - aboutLinkItem = (
  • About
  • ); - } - - return ( -
    - -
    - -
    -
    - ) - } -} - -customElements.define('opendesktop-metaheader', class extends HTMLElement { - constructor() { - super(); - this.buildComponent(); - } - - async buildComponent() { - - const stylesheetElement = document.createElement('link'); - stylesheetElement.rel = 'stylesheet'; - stylesheetElement.href = 'https://www.opendesktop.org/theme/react/assets/css/metaheader.css'; - - if (location.hostname.endsWith('cc')) { - stylesheetElement.href = 'https://www.opendesktop.cc/theme/react/assets/css/metaheader.css'; - } - else if (location.hostname.endsWith('localhost')) { - stylesheetElement.href = 'https://www.opendesktop.cc/theme/react/assets/css/metaheader.css'; - }else if (location.hostname.endsWith('local')) { - stylesheetElement.href = '/theme/react/assets/css/metaheader.css'; - } - else{ - stylesheetElement.href = 'https://www.opendesktop.org/theme/react/assets/css/metaheader.css'; - } - this.appendChild(stylesheetElement); - - await initConfig(this.getAttribute('config-target'),window.location.href); - - const metaheaderElement = document.createElement('div'); - metaheaderElement.id = 'metaheader'; - ReactDOM.render(React.createElement(MetaHeader, null), metaheaderElement); - - // Component must be capsule within Shadow DOM, and don't hack - // context/scope of external sites. - /* - this.attachShadow({mode: 'open'}); - this.shadowRoot.appendChild(stylesheetElement); - this.shadowRoot.appendChild(metaheaderElement); - */ - - // However, make this as Light DOM for now, because current - // implementation is not real component design yet. - // Need solve event handling, scoped CSS. - this.appendChild(metaheaderElement); - } -}); diff --git a/httpdocs/theme/react/src/metaheader/AboutMenu.js b/httpdocs/theme/react/src/metaheader/AboutMenu.js deleted file mode 100644 index b3de30a02..000000000 --- a/httpdocs/theme/react/src/metaheader/AboutMenu.js +++ /dev/null @@ -1,57 +0,0 @@ -import React from 'react'; -import AboutMenuItems from './function/AboutMenuItems'; - -class AboutMenu extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('click',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('click',this.handleClick, false); - } - - - - handleClick(e){ - let dropdownClass = ""; - - if (this.node.contains(e.target)){ - - if(e.target.className === "about-menu-link-item" || "th-icon"===e.target.className) - { - // only btn click open dropdown - if (this.state.dropdownClass === "open"){ - dropdownClass = ""; - }else{ - dropdownClass = "open"; - } - }else{ - dropdownClass = ""; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - render(){ - return ( -
  • this.node = node} id="about-dropdown-menu" className={this.state.dropdownClass}> - About ⌄ -
      - -
    -
  • - ) - } -} - -export default AboutMenu; diff --git a/httpdocs/theme/react/src/metaheader/AnonymousMenu.js b/httpdocs/theme/react/src/metaheader/AnonymousMenu.js deleted file mode 100644 index 39ed5dd46..000000000 --- a/httpdocs/theme/react/src/metaheader/AnonymousMenu.js +++ /dev/null @@ -1,84 +0,0 @@ -import React from 'react'; -import DownloadSection from './function/DownloadSection'; -class AnonymousMenu extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - this.loadAnonymousDl = this.loadAnonymousDl.bind(this); - } - - componentWillMount() { - document.addEventListener('click',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('click',this.handleClick, false); - } - - componentDidMount(){ - this.loadAnonymousDl(); - } - - loadAnonymousDl(){ - let url = this.props.baseUrlStore+'/json/anonymousdl'; - fetch(url,{ - mode: 'cors', - credentials: 'include' - }) - .then(response => response.json()) - .then(data => { - this.setState(prevState => ({ anonymousdl: data.dls , section:data.section})) - }); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "th-icon" || e.target.className === "btn btn-default dropdown-toggle"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - - } - - render(){ - - let downloadSection; - if (this.state.section){ - downloadSection = - } - return ( -
  • this.node = node} id="anonymous-dropdown-menu-container" > -
    - -
      -
    • - {downloadSection} -
    • - - {(this.props.user && this.props.user.isSupporter) ? ( -
    • Thanks for being a supporter!
    • - ) : ( -
    • - You are not a supporter yet. -
    • - )} -
    -
    -
  • - ) - } -} - -export default AnonymousMenu; diff --git a/httpdocs/theme/react/src/metaheader/DevelopmentAppMenu.js b/httpdocs/theme/react/src/metaheader/DevelopmentAppMenu.js deleted file mode 100644 index a60d35bc3..000000000 --- a/httpdocs/theme/react/src/metaheader/DevelopmentAppMenu.js +++ /dev/null @@ -1,162 +0,0 @@ -import React from 'react'; -import MyButton from './function/MyButton'; - -class DevelopmentAppMenu extends React.Component { - constructor(props){ - super(props); - this.state = { - gitlabLink:this.props.gitlabUrl+"/dashboard/issues?assignee_id=" - }; - this.handleClick = this.handleClick.bind(this); - this.loadNotification = this.loadNotification.bind(this); - } - - componentWillMount() { - //document.addEventListener('mousedown',this.handleClick, false); - document.addEventListener('click',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('click',this.handleClick, false); - } - - componentDidMount() { - this.loadNotification(); - const self = this; - const xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState === 4 && this.status === 200) { - const res = JSON.parse(this.response); - const gitlabLink = self.state.gitlabLink + res[0].id; - self.setState({gitlabLink:gitlabLink,loading:false}); - } - }; - xhttp.open("GET", this.props.gitlabUrl+"/api/v4/users?username="+this.props.user.username, true); - xhttp.send(); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if(e.target.className === "btn btn-default dropdown-toggle" - || e.target.className === "th-icon") - { - // only btn click open dropdown - if (this.state.dropdownClass === "open"){ - dropdownClass = ""; - }else{ - dropdownClass = "open"; - } - }else{ - dropdownClass = ""; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - loadNotification(){ - if(this.props.user){ - let url = this.props.baseUrl+'/membersetting/notification'; - fetch(url,{ - mode: 'cors', - credentials: 'include' - }) - .then(response => response.json()) - .then(data => { - if(data.notifications){ - const nots = data.notifications.filter(note => note.read==false); - if(nots.length>0 && this.state.notification_count !== nots.length) - { - this.setState(prevState => ({ notification: true, notification_count:nots.length })) - } - } - }); - } - } - - render(){ - - - - let badgeNot; - if(this.state.notification) - { - badgeNot = ({this.state.notification_count}); - } - - - let personalMenuDisplay=( - - {/* - - - - */} - - {/* - - */} - - - - - ); - - let contextMenuDisplay = ( - - - - - - {this.props.isAdmin && - - - - } - - {/* - - */} - - - ); - - return ( -
  • this.node = node} id="development-app-menu-container"> -
    - -
      - {personalMenuDisplay} -
    • - {contextMenuDisplay} - -
    - -
    -
  • - ) - } -} - -export default DevelopmentAppMenu; diff --git a/httpdocs/theme/react/src/metaheader/DevelopmentDropDownMenu.js b/httpdocs/theme/react/src/metaheader/DevelopmentDropDownMenu.js deleted file mode 100644 index a7fe8def0..000000000 --- a/httpdocs/theme/react/src/metaheader/DevelopmentDropDownMenu.js +++ /dev/null @@ -1,79 +0,0 @@ -import React from 'react'; -class DevelopmentDropDownMenu extends React.Component { - constructor(props){ - super(props); - this.state = { - /*gitlabLink:this.props.gitlabUrl+"/dashboard/issues?assignee_id="*/ - }; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - componentDidMount() { - /*const self = this; - const xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - const res = JSON.parse(this.response); - const gitlabLink = self.state.gitlabLink + res[0].id; - self.setState({gitlabLink:gitlabLink,loading:false}); - } - }; - xhttp.open("GET", this.props.gitlabUrl+"/api/v4/users?username="+this.props.user.username, true); - xhttp.send();*/ - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "admins-menu-link-item"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - render(){ - let issuesMenuItem; - - - if (this.props.isAdmin){ - issuesMenuItem = ( -
  • Issues
  • - ) - } - - let gitfaqLinkItem; - if (this.props.isExternal === false){ - gitfaqLinkItem = (
  • FAQ
  • ); - } else { - gitfaqLinkItem = (
  • Git FAQ
  • ); - } - - return ( -
  • this.node = node} id="admins-dropdown-menu" className={this.state.dropdownClass}> - Development - -
  • - ) - } -} - -export default DevelopmentDropDownMenu; diff --git a/httpdocs/theme/react/src/metaheader/DiscussionBoardsDropDownMenu.js b/httpdocs/theme/react/src/metaheader/DiscussionBoardsDropDownMenu.js deleted file mode 100644 index 0961d8cc0..000000000 --- a/httpdocs/theme/react/src/metaheader/DiscussionBoardsDropDownMenu.js +++ /dev/null @@ -1,50 +0,0 @@ -import React from 'react'; -import CommunityMenuItems from './function/CommunityMenuItems'; -class DiscussionBoardsDropDownMenu extends React.Component { - constructor(props){ - super(props); - this.state = {notification: false ,notification_count:0}; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "discussion-menu-link-item"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - render(){ - - return ( -
  • this.node = node} id="discussion-boards" className={this.state.dropdownClass}> - Community ⌄ -
      - -
    -
  • - ); - } - -} - -export default DiscussionBoardsDropDownMenu; diff --git a/httpdocs/theme/react/src/metaheader/DomainsDropDownMenu.js b/httpdocs/theme/react/src/metaheader/DomainsDropDownMenu.js deleted file mode 100644 index 4c9d87ea5..000000000 --- a/httpdocs/theme/react/src/metaheader/DomainsDropDownMenu.js +++ /dev/null @@ -1,111 +0,0 @@ -import React from 'react'; -import DomainsMenuGroup from './DomainsMenuGroup'; -class DomainsDropDownMenu extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - } - - - componentDidMount() { - - // let menuGroups = []; - // if(!this.props.domains) return; - // this.props.domains.forEach(function(domain,index){ - // if (menuGroups.indexOf(domain.menugroup) === -1){ - // menuGroups.push(domain.menugroup); - // } - // }); - // this.setState({menuGroups:menuGroups}); - - // here is dirty coded because CT want to place other at firt section without modify db sort. - // and if other then show groupname => Pling. so DomainsMenuGroup also hardcode display groupname - let menuGroups=[ "Other","Artwork","Desktops", "Applications", "Addons" ]; - this.setState({menuGroups:menuGroups}); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "domains-menu-link-item"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - render(){ - - let menuGroupsDisplayLeft, menuGroupsDisplayRight,menuGroupsDisplayMiddle; - - if (this.state.menuGroups){ - menuGroupsDisplayLeft = this.state.menuGroups.slice(0,2).map((mg,i) => ( - - )); - menuGroupsDisplayMiddle = this.state.menuGroups.slice(2,3).map((mg,i) => ( - - )); - - menuGroupsDisplayRight = this.state.menuGroups.slice(3).map((mg,i) => ( - - )); - - } - - return ( -
  • this.node = node} id="domains-dropdown-menu" className={this.state.dropdownClass}> - Store Listings -
      -
    • -
        - {menuGroupsDisplayLeft} -
      -
    • -
    • -
        - {menuGroupsDisplayMiddle} -
      -
    • - -
    • -
        - {menuGroupsDisplayRight} -
      -
    • -
    -
  • - ); - } -} - -export default DomainsDropDownMenu; diff --git a/httpdocs/theme/react/src/metaheader/DomainsMenu.js b/httpdocs/theme/react/src/metaheader/DomainsMenu.js deleted file mode 100644 index 0360de56c..000000000 --- a/httpdocs/theme/react/src/metaheader/DomainsMenu.js +++ /dev/null @@ -1,56 +0,0 @@ -import React from 'react'; -import MoreDropDownMenu from './MoreDropDownMenu'; -import DiscussionBoardsDropDownMenu from './DiscussionBoardsDropDownMenu'; -class DomainsMenu extends React.Component { - constructor(props){ - super(props); - this.state = { - }; - } - - - - render(){ - - let moreMenuItemDisplay, adminsDropDownMenuDisplay, myOpendesktopMenuDisplay; - if (this.props.device !== "large"){ - moreMenuItemDisplay = ( - - ) - } - - return ( - - ) - } -} -export default DomainsMenu; diff --git a/httpdocs/theme/react/src/metaheader/DomainsMenuGroup.js b/httpdocs/theme/react/src/metaheader/DomainsMenuGroup.js deleted file mode 100644 index 41decfe63..000000000 --- a/httpdocs/theme/react/src/metaheader/DomainsMenuGroup.js +++ /dev/null @@ -1,39 +0,0 @@ -import React from 'react'; -class DomainsMenuGroup extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.filterDomainsByMenuGroup = this.filterDomainsByMenuGroup.bind(this); - } - - filterDomainsByMenuGroup(domain){ - if (domain.menugroup === this.props.menuGroup){ - return domain; - } - } - - render(){ - const domainsDisplay = this.props.domains.filter(this.filterDomainsByMenuGroup).map((domain,index) => { - let domainPrefix = ""; - if (domain.menuhref.indexOf('https://') === -1 && domain.menuhref.indexOf('http://') === -1){ - domainPrefix += "http://"; - } - return ( -
  • - {domain.name} -
  • - ); - }); - - return ( -
  • - {this.props.menuGroup=='Other'?'Pling':this.props.menuGroup} -
      - {domainsDisplay} -
    -
  • - ) - } -} - -export default DomainsMenuGroup; diff --git a/httpdocs/theme/react/src/metaheader/Helpers.js b/httpdocs/theme/react/src/metaheader/Helpers.js deleted file mode 100644 index 1cfd9f2bb..000000000 --- a/httpdocs/theme/react/src/metaheader/Helpers.js +++ /dev/null @@ -1,42 +0,0 @@ -const Helpers = { - generateMenuGroupsArray: function(domains){ - let menuGroups = []; - domains.forEach(function (domain, index) { - if (menuGroups.indexOf(domain.menugroup) === -1) { - menuGroups.push(domain.menugroup); - } - }); - return menuGroups; - }, - getDeviceFromWidth: function(width){ - let device; - if (width >= 910) { - device = "large"; - } else if (width < 910 && width >= 610) { - device = "mid"; - } else if (width < 610) { - device = "tablet"; - } - return device; - - - }, - getPopupUrl: function(key, isExternal, baseUrl){ - let url = baseUrl; - return url; - }, - generatePopupLinks: function(){ - let pLink = {}; - pLink.plingListUrl = "/#plingList", pLink.ocsapiContentUrl = "/#ocsapiContent", pLink.aboutContentUrl = "/#aboutContent", pLink.linkTarget = "_blank"; - - if (window.location.hostname.indexOf('opendesktop') === -1 || window.location.hostname === "opencode.net" || window.location.hostname === "git.opendesktop.cc" || window.location.hostname === "forum.opendesktop.org" || window.location.hostname === "forum.opendesktop.cc" || window.location.hostname === "my.opendesktop.org" || window.location.hostname === "my.opendesktop.cc") { - pLink.plingListUrl = "/plings"; - pLink.ocsapiContentUrl = "/partials/ocsapicontent.phtml"; - pLink.aboutContentUrl = "/partials/about.phtml"; - pLink.linkTarget = ""; - } - return pLink; - } -} - -export default Helpers; diff --git a/httpdocs/theme/react/src/metaheader/MetaHeader.js b/httpdocs/theme/react/src/metaheader/MetaHeader.js deleted file mode 100644 index 9ef06b591..000000000 --- a/httpdocs/theme/react/src/metaheader/MetaHeader.js +++ /dev/null @@ -1,177 +0,0 @@ -import "core-js/shim"; -import "regenerator-runtime/runtime"; -import React from 'react'; -import MobileLeftMenu from './MobileLeftMenu'; -import DomainsMenu from './DomainsMenu'; -import UserMenu from './UserMenu'; -import WhereAmI from './function/WhereAmI'; - -class MetaHeader extends React.Component { - constructor(props){ - super(props); - this.state = {...this.props.config}; - this.initMetaHeader = this.initMetaHeader.bind(this); - this.updateDimensions = this.updateDimensions.bind(this); - this.onSwitchStyle = this.onSwitchStyle.bind(this); - - //this.getUser = this.getUser.bind(this); - } - - - componentWillMount() { - this.updateDimensions(); - } - - componentDidMount() { - - this.initMetaHeader(); - - } - - componentWillUnmount(){ - window.removeEventListener("resize", this.updateDimensions); - window.removeEventListener("orientationchange",this.updateDimensions); - - } - - initMetaHeader(){ - window.addEventListener("resize", this.updateDimensions); - window.addEventListener("orientationchange",this.updateDimensions); - } - - // change metamenu class - onSwitchStyle(evt){ - let url = 'https://www.opendesktop.org/membersetting/setsettings/itemid/1/itemvalue/'; - if(this.state.isExternal) - { - if (this.props.hostname.endsWith('cc') || this.props.hostname.endsWith('local')) { - url = 'https://www.opendesktop.cc/membersetting/setsettings/itemid/1/itemvalue/'; - } - }else - { - url = '/membersetting/setsettings/itemid/1/itemvalue/'; - } - url = url +(evt.target.checked?'1':'0'); - const isChecked = evt.target.checked; - fetch(url,{ - mode: 'cors', - credentials: 'include' - }) - .then(response => response.json()) - .then(data => { - this.setState({metamenuTheme:`${isChecked?'metamenu-theme-dark':''}`}); - }); - } - - getUser(){ - const decodedCookie = decodeURIComponent(document.cookie); - let ocs_data = decodedCookie.split('ocs_data=')[1]; - if (ocs_data){ - if (ocs_data.indexOf(';') > -1){ ocs_data = ocs_data.split(';')[0]; } - const user = JSON.parse(ocs_data); - this.setState({user:user}); - } - } - - updateDimensions(){ - const width = window.innerWidth; - let device; - if (width >= 1015){ - device = "large"; - } else if (width < 1015 && width >= 730){ - device = "mid"; - } else if (width < 730){ - device = "tablet"; - } - this.setState({device:device}); - } - - render(){ - - let domainsMenuDisplay; - if (this.state.device === "tablet"){ - domainsMenuDisplay = ( - - ) - } else { - - domainsMenuDisplay = ( - - ) - } - const metamenuCls = `metamenu ${this.state.metamenuTheme}`; - let paraChecked = false; - if(this.state.metamenuTheme){ - paraChecked=true; - } - - return ( - - ) - } -} - -export default MetaHeader; diff --git a/httpdocs/theme/react/src/metaheader/MobileLeftMenu.js b/httpdocs/theme/react/src/metaheader/MobileLeftMenu.js deleted file mode 100644 index 1bd36f908..000000000 --- a/httpdocs/theme/react/src/metaheader/MobileLeftMenu.js +++ /dev/null @@ -1,75 +0,0 @@ -import React from 'react'; -import MobileLeftSidePanel from './MobileLeftSidePanel'; -class MobileLeftMenu extends React.Component { - constructor(props){ - super(props); - this.state = { - overlayClass:"" - }; - this.toggleLeftSideOverlay = this.toggleLeftSideOverlay.bind(this); - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - window.addEventListener('mousedown',this.handleClick, false); - window.addEventListener('touchend', this.handleClick, false); - } - - componentWillUnmount() { - window.removeEventListener('mousedown',this.handleClick, false); - window.addEventListener('touchend', this.handleClick, false); - } - - toggleLeftSideOverlay(){ - let overlayClass = "open"; - if (this.state.overlayClass === "open") { - overlayClass = ""; - } - this.setState({overlayClass:overlayClass}); - } - - handleClick(e){ - let overlayClass = ""; - if (this.node.contains(e.target)){ - if (this.state.overlayClass === "open"){ - if (e.target.id === "left-side-overlay" || e.target.id === "menu-toggle-item"){ - overlayClass = ""; - } else { - overlayClass = "open"; - } - } else { - overlayClass = "open"; - } - } - - const self = this; - setTimeout(function () { - console.log('time out'); - self.setState({overlayClass:overlayClass}); - }, 200); - } - - render(){ - return ( -
    this.node = node} id="metaheader-left-mobile" className={this.state.overlayClass}> - -
    - -
    -
    - ); - } -} - -export default MobileLeftMenu; diff --git a/httpdocs/theme/react/src/metaheader/MobileLeftSidePanel.js b/httpdocs/theme/react/src/metaheader/MobileLeftSidePanel.js deleted file mode 100644 index c408b18fd..000000000 --- a/httpdocs/theme/react/src/metaheader/MobileLeftSidePanel.js +++ /dev/null @@ -1,72 +0,0 @@ -import React from 'react'; -import AboutMenuItems from './function/AboutMenuItems'; -import CommunityMenuItems from './function/CommunityMenuItems'; -class MobileLeftSidePanel extends React.Component { - constructor(props){ - super(props); - this.state = {}; - } - - componentDidMount() { - // let menuGroups = []; - // this.props.domains.forEach(function(domain,index){ - // if (menuGroups.indexOf(domain.menugroup) === -1){ - // menuGroups.push(domain.menugroup); - // } - // }); - // this.setState({menuGroups:menuGroups}); - } - - render(){ - // let panelMenuGroupsDisplay; - // if (this.state.menuGroups){ - // panelMenuGroupsDisplay = this.state.menuGroups.map((mg,i) => ( - // - // )); - // } - - - return ( -
    - -
    - -
    -
    - ) - } -} - -export default MobileLeftSidePanel; diff --git a/httpdocs/theme/react/src/metaheader/MoreDropDownMenu.js b/httpdocs/theme/react/src/metaheader/MoreDropDownMenu.js deleted file mode 100644 index 053a6990a..000000000 --- a/httpdocs/theme/react/src/metaheader/MoreDropDownMenu.js +++ /dev/null @@ -1,66 +0,0 @@ -import React from 'react'; -class MoreDropDownMenu extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "more-menu-link-item"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - render(){ - - let faqLinkItem, apiLinkItem, aboutLinkItem,aboutPlingItem, aboutopencodeItem; - - aboutPlingItem = (
  • FAQ Pling
  • ); - aboutopencodeItem = (
  • FAQ Opencode
  • ); - aboutLinkItem = (
  • About
  • ); - apiLinkItem = (
  • API
  • ); - // if (this.props.isExternal === false){ - // apiLinkItem = (
  • API
  • ); - // } else { - // apiLinkItem = (
  • API
  • ); - // } - if (this.props.isAdmin ){ - faqLinkItem = (
  • Plings (admin only)
  • ); - } - - return( -
  • this.node = node} id="more-dropdown-menu" className={this.state.dropdownClass}> - More -
      - {/*
    • Supporter
    • */} -
    • Blog
    • - {faqLinkItem} - {apiLinkItem} - {aboutPlingItem} - {aboutopencodeItem} - {aboutLinkItem} -
    -
  • - ) - } -} -export default MoreDropDownMenu; diff --git a/httpdocs/theme/react/src/metaheader/MyButton.js b/httpdocs/theme/react/src/metaheader/MyButton.js deleted file mode 100644 index 8a75d9574..000000000 --- a/httpdocs/theme/react/src/metaheader/MyButton.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -function MyButton(props) -{ - return ( -
  • - -
    - {props.label} - -
    -
  • - ); -} -export default MyButton; diff --git a/httpdocs/theme/react/src/metaheader/SearchMenuContainer.js b/httpdocs/theme/react/src/metaheader/SearchMenuContainer.js deleted file mode 100644 index 35dd6b151..000000000 --- a/httpdocs/theme/react/src/metaheader/SearchMenuContainer.js +++ /dev/null @@ -1,68 +0,0 @@ -import React from 'react'; -import UserAutoCompleteInput from './UserAutoCompleteInput'; - -class SearchMenuContainer extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "th-icon" || e.target.className === "btn btn-default dropdown-toggle"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass}); - // this.setState({dropdownClass:dropdownClass},function(){ - // if (dropdownClass === "open"){ - // let el = document.body; - // el.classList.add('drawer-open'); - // } else { - // let el = document.body; - // el.classList.remove('drawer-open'); - // - // } - // }); - } - - - render(){ - - return ( -
  • this.node = node}> -
    - -
    -
      -
    • - -
    • -
    -
    -
    -
  • - ) - } -} - -export default SearchMenuContainer; diff --git a/httpdocs/theme/react/src/metaheader/UserAutoCompleteInput.js b/httpdocs/theme/react/src/metaheader/UserAutoCompleteInput.js deleted file mode 100644 index 7ac5cce87..000000000 --- a/httpdocs/theme/react/src/metaheader/UserAutoCompleteInput.js +++ /dev/null @@ -1,171 +0,0 @@ -import React from 'react'; -import Autosuggest from 'react-autosuggest'; -import UserAutoCompleteTabs from './UserAutoCompleteTabs'; -function getSuggestionValue(suggestion) { - return suggestion.username; -} - -function renderSuggestion(suggestion) { - return ( - {suggestion.username} - ); -} - -const renderInputComponent = inputProps => ( -
    - - -
    -); - -class UserAutoCompleteInput extends React.Component { - constructor() { - super(); - - this.state = { - value: '', - suggestions: [], - showTabs:false, - userSelected:[], - isLoading: false, - userinfo:[], - odComments:[] - }; - - this.onChange = this.onChange.bind(this); - this.loadSuggestions = this.loadSuggestions.bind(this); - this.onSuggestionsFetchRequested = this.onSuggestionsFetchRequested.bind(this); - this.onSuggestionsClearRequested = this.onSuggestionsClearRequested.bind(this); - this.shouldRenderSuggestions = this.shouldRenderSuggestions.bind(this); - this.onSuggestionSelected = this.onSuggestionSelected.bind(this); - - this.getUserInfo = this.getUserInfo.bind(this); - this.getUserOdComments = this.getUserOdComments.bind(this); - } - - loadSuggestions(value) { - const inputLength = value.length; - if(inputLength<3) return; - this.setState({ - isLoading: true - }); - let url = this.props.baseUrl+'/membersetting/searchmember?username='+value; - fetch(url,{ - mode: 'cors', - credentials: 'include' - }) - .then(response => response.json()) - .then(data => { - if(data) - { - this.setState({suggestions:data,isLoading:false}); - } - }); - } - - onChange(event, { newValue, method }){ - this.setState({value:newValue}); - } - - shouldRenderSuggestions(value) { - return value.trim().length > 2; - } - - onSuggestionsFetchRequested({ value }){ - this.loadSuggestions(value); - } - - onSuggestionsClearRequested(){ - this.setState({ - suggestions: [] - }); - } - - getUserInfo(member_id){ - let url = `${this.props.baseUrl}/membersetting/userinfo?member_id=${member_id}`; - fetch(url,{ - mode: 'cors', - credentials: 'include' - }) - .then(response => response.json()) - .then(data => { - this.setState({userinfo:data},function(){ - this.getUserOdComments(member_id); - }); - }); - } - - getUserOdComments(member_id){ - let url = `${this.props.baseUrl}/membersetting/memberjson?member_id=${member_id}`; - fetch(url,{ - mode: 'cors', - credentials: 'include' - }) - .then(response => response.json()) - .then(data => { - this.setState({odComments:data.commentsOpendeskop,showTabs: true},function(){ - //this.getUserForumComments(); - }); - }); - } - - - onSuggestionSelected(event, { suggestion, suggestionValue, suggestionIndex, sectionIndex, method }) - { - this.getUserInfo(suggestion.member_id); - this.setState({ - userSelected:suggestion - }); - } - - render() { - const { value, suggestions, isLoading } = this.state; - const inputProps = { - placeholder: "Type to search min.3 chars", - value, - onChange: this.onChange - - }; - const status = (isLoading ? 'Loading...' : ''); - - let contentTabs; - if(this.state.showTabs) - { - contentTabs = - } - - return ( -
    -
    - - - -
    - {status} -
    -
    -
    - {contentTabs} -
    -
    - ); - } -} - -export default UserAutoCompleteInput; diff --git a/httpdocs/theme/react/src/metaheader/UserAutoCompleteTabs.js b/httpdocs/theme/react/src/metaheader/UserAutoCompleteTabs.js deleted file mode 100644 index 1f859f989..000000000 --- a/httpdocs/theme/react/src/metaheader/UserAutoCompleteTabs.js +++ /dev/null @@ -1,80 +0,0 @@ -import React from 'react'; -import UserCommentsTab from './UserCommentsTab'; -import UserInfo from './function/UserInfo'; -import UserCommentsTabThreadsContainer from './UserCommentsTabThreadsContainer'; -class UserAutoCompleteTabs extends React.Component { - constructor(props){ - super(props); - this.state = { - currentTab:'userinfo', - loading:true - }; - this.onTabMenuItemClick = this.onTabMenuItemClick.bind(this); - } - - onTabMenuItemClick(val){ - this.setState({currentTab:val}); - } - - // getUserForumComments(){ - // const user = this.props.user; - // const self = this; - // const xhttp = new XMLHttpRequest(); - // xhttp.onreadystatechange = function() { - // console.log('this '); - // if (this.readyState == 4 && this.status == 200) { - // const res = JSON.parse(this.response); - // self.setState({forumComments:res.user_actions,loading:false}); - // } - // }; - // xhttp.open("GET", "https://forum.opendesktop.cc/user_actions.json?offset=0&username=" + user.username + "&filter=5", true); - // xhttp.send(); - // } - - render(){ - - let tabContentDisplay; - if (this.state.currentTab === 'userinfo'){ - - tabContentDisplay = - - }else if(this.state.currentTab === 'comment' && this.props.odComments.length>0){ - tabContentDisplay = - - } - - return( - - ); - } -} - -export default UserAutoCompleteTabs; diff --git a/httpdocs/theme/react/src/metaheader/UserCommentsTab.js b/httpdocs/theme/react/src/metaheader/UserCommentsTab.js deleted file mode 100644 index 4e51f842c..000000000 --- a/httpdocs/theme/react/src/metaheader/UserCommentsTab.js +++ /dev/null @@ -1,91 +0,0 @@ -import React from 'react'; -import UserCommentsTabThreadsContainer from './UserCommentsTabThreadsContainer'; -class UserCommentsTab extends React.Component { - constructor(props){ - super(props); - this.state = { - loading:true - }; - this.getUserOdComments = this.getUserOdComments.bind(this); - this.getUserForumComments = this.getUserForumComments.bind(this); - } - - componentDidMount() { - this.setState({odComments:[],forumComments:[],loading:true},function(){ - this.getUserOdComments(); - }); - } - - getUserOdComments(){ - let url = '/membersetting/memberjson?member_id='+this.props.user.member_id; - fetch(url,{ - mode: 'cors', - credentials: 'include' - }) - .then(response => response.json()) - .then(data => { - this.setState({odComments:data.commentsOpendeskop,loading:false},function(){ - this.getUserForumComments(); - }); - }); - } - - getUserForumComments(){ - const user = this.props.user; - const self = this; - const xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - const res = JSON.parse(this.response); - self.setState({forumComments:res.user_actions,loading:false}); - } - }; - xhttp.open("GET", "https://forum.opendesktop.cc/user_actions.json?offset=0&username=" + user.username + "&filter=5", true); - xhttp.send(); - } - - render(){ - let contentDisplay; - if (!this.state.loading){ - let odCommentsDisplay, forumCommentsDisplay; - if (this.state.odComments.length > 0){ - odCommentsDisplay = ( - - ); - } - if (this.state.forumComments.length > 0){ - forumCommentsDisplay = ( - - ); - } - - contentDisplay = ( -
    - {odCommentsDisplay} - {forumCommentsDisplay} -
    - ) - - } else { - contentDisplay = ( -
    loading
    - ); - } - - return( -
    - {contentDisplay} -
    - ) - } -} - -export default UserCommentsTab; diff --git a/httpdocs/theme/react/src/metaheader/UserCommentsTabThread.js b/httpdocs/theme/react/src/metaheader/UserCommentsTabThread.js deleted file mode 100644 index b4f1d9205..000000000 --- a/httpdocs/theme/react/src/metaheader/UserCommentsTabThread.js +++ /dev/null @@ -1,42 +0,0 @@ -import React from 'react'; -import UserCommentsTabThreadCommentItem from './UserCommentsTabThreadCommentItem'; -class UserCommentsTabThread extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.filterCommentsByThread = this.filterCommentsByThread.bind(this); - } - - filterCommentsByThread(comment){ - if (comment.title === this.props.thread.title){ - return comment; - } - } - - render(){ - let commentsDisplay; - if (this.props.comments){ - const user = this.props.user; - commentsDisplay = this.props.comments.filter(this.filterCommentsByThread).map((c,index) => ( - - )); - } - return ( -
    - -
    - {commentsDisplay} -
    -
    - ); - } -} - -export default UserCommentsTabThread; diff --git a/httpdocs/theme/react/src/metaheader/UserCommentsTabThreadCommentItem.js b/httpdocs/theme/react/src/metaheader/UserCommentsTabThreadCommentItem.js deleted file mode 100644 index c33f165b0..000000000 --- a/httpdocs/theme/react/src/metaheader/UserCommentsTabThreadCommentItem.js +++ /dev/null @@ -1,39 +0,0 @@ -import React from 'react'; -class UserCommentsTabThreadCommentItem extends React.Component { - constructor(props){ - super(props); - this.state = {}; - } - - render(){ - const c = this.props.comment; - const user = this.props.user; - let repliedUsernameDisplay; - if (c.p_comment_member_id){ - repliedUsernameDisplay = (

    {c.p_username}

    ) - } - - let userImage = user.avatar; - if (this.props.uType === 'search'){ - userImage = user.profile_image_url; - } - - return ( -
    -
    - -
    -
    -

    {user.username}

    - {repliedUsernameDisplay} -

    {c.comment_created_at}

    -
    -
    -
    -
    -
    - ) - } -} - -export default UserCommentsTabThreadCommentItem; diff --git a/httpdocs/theme/react/src/metaheader/UserCommentsTabThreadsContainer.js b/httpdocs/theme/react/src/metaheader/UserCommentsTabThreadsContainer.js deleted file mode 100644 index c0b5b8453..000000000 --- a/httpdocs/theme/react/src/metaheader/UserCommentsTabThreadsContainer.js +++ /dev/null @@ -1,75 +0,0 @@ -import React from 'react'; -import UserCommentsTabThread from './UserCommentsTabThread'; -class UserCommentsTabThreadsContainer extends React.Component { - constructor(props){ - super(props); - this.state = {}; - } - - componentDidMount() { - let siteInfo; - if (this.props.type === 'od'){ - siteInfo = { - address:'openDesktop.org', - url:'https://www.opendesktop.org' - } - } else if (this.props.type === 'forum'){ - siteInfo = { - address:'forum', - url:'https://forum.opendesktop.org' - } - } - - let threads = []; - this.props.comments.forEach(function(c,index){ - let pos = threads.map(function(e) { return e.id; }).indexOf(c.project_id); - if(pos===-1) - { - const thread = { - title:c.title, - id:c.project_id - } - threads.push(thread) - } - }); - - this.setState({siteInfo:siteInfo,comments:this.props.comments,threads:threads}); - } - - render(){ - const t = this.state.siteInfo; - const comments = this.state.comments; - const user = this.props.user; - let headerDisplay, threadsDisplay, threadCommentsDisplay; - if (this.state.threads){ - - threadsDisplay = this.state.threads.map((tr,index) => ( - - )); - headerDisplay = ( -
    -
    -

    Discussion on {this.state.siteInfo.address}

    -

    {this.state.comments.length} comments

    -
    -
    - ); - } - - return ( -
    - {headerDisplay} -
    - {threadsDisplay} -
    -
    - ) - } -} -export default UserCommentsTabThreadsContainer; diff --git a/httpdocs/theme/react/src/metaheader/UserContextMenuContainer.js b/httpdocs/theme/react/src/metaheader/UserContextMenuContainer.js deleted file mode 100644 index 0d3674b1e..000000000 --- a/httpdocs/theme/react/src/metaheader/UserContextMenuContainer.js +++ /dev/null @@ -1,162 +0,0 @@ -import React from 'react'; -class UserContextMenuContainer extends React.Component { - constructor(props){ - super(props); - this.state = { - /*gitlabLink:this.props.gitlabUrl+"/dashboard/issues?assignee_id="*/ - }; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - //document.addEventListener('mousedown',this.handleClick, false); - document.addEventListener('click',this.handleClick,false); - } - - componentWillUnmount() { - document.removeEventListener('click',this.handleClick, false); - } - - componentDidMount() { - /*const self = this; - const xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState === 4 && this.status === 200) { - const res = JSON.parse(this.response); - const gitlabLink = self.state.gitlabLink + res[0].id; - self.setState({gitlabLink:gitlabLink,loading:false}); - } - }; - xhttp.open("GET", this.props.gitlabUrl+"/api/v4/users?username="+this.props.user.username, true); - xhttp.send();*/ - } - - handleClick(e){ - // let dropdownClass = ""; - // if (this.node.contains(e.target)){ - // if (this.state.dropdownClass === "open"){ - // if (e.target.className === "th-icon" || e.target.className === "btn btn-default dropdown-toggle"){ - // dropdownClass = ""; - // } else { - // dropdownClass = "open"; - // } - // } else { - // dropdownClass = "open"; - // } - // } - // this.setState({dropdownClass:dropdownClass}); - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if(e.target.className === "btn btn-default dropdown-toggle" - || e.target.className === "th-icon") - { - // only btn click open dropdown - if (this.state.dropdownClass === "open"){ - dropdownClass = ""; - }else{ - dropdownClass = "open"; - } - }else{ - dropdownClass = ""; - } - } - this.setState({dropdownClass:dropdownClass}); - } - - render(){ - - /* - // BU CODE - - */ - - let urlEnding; - if(this.props.baseUrl.endsWith("cc")) - { - urlEnding = "cc"; - }else if(this.props.baseUrl.endsWith("com")){ - urlEnding = "com"; - }else{ - urlEnding = "com"; - } - - let contextMenuDisplay; - if (this.props.isAdmin){ - contextMenuDisplay = ( - - ); - } else { - contextMenuDisplay = ( - - ); - } - - return ( -
  • this.node = node} id="user-context-menu-container"> -
    - - {contextMenuDisplay} -
    -
  • - ) - } -} - -export default UserContextMenuContainer; diff --git a/httpdocs/theme/react/src/metaheader/UserLoginMenuContainer.js b/httpdocs/theme/react/src/metaheader/UserLoginMenuContainer.js deleted file mode 100644 index 193f7b966..000000000 --- a/httpdocs/theme/react/src/metaheader/UserLoginMenuContainer.js +++ /dev/null @@ -1,106 +0,0 @@ -import React from 'react'; -import SwitchItem from './function/SwitchItem'; - -class UserLoginMenuContainer extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - - - } - - componentWillMount() { - document.addEventListener('click',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('click',this.handleClick, false); - } - - componentDidMount(){ - - - } - - handleClick(e){ - let dropdownClass = ""; - - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "th-icon" || e.target.className === "btn btn-default dropdown-toggle"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - - } - - this.setState({dropdownClass:dropdownClass}); - - } - - render(){ - const theme = this.props.onSwitchStyleChecked?"Metaheader theme dark":"Metaheader theme light"; - - let downloadSection; - if (this.state.section){ - downloadSection = - } - - return ( -
  • this.node = node}> -
    - - -
    -
  • - ) - } -} - -export default UserLoginMenuContainer; diff --git a/httpdocs/theme/react/src/metaheader/UserLoginMenuContainerVersionTwo.js b/httpdocs/theme/react/src/metaheader/UserLoginMenuContainerVersionTwo.js deleted file mode 100644 index 2f91997af..000000000 --- a/httpdocs/theme/react/src/metaheader/UserLoginMenuContainerVersionTwo.js +++ /dev/null @@ -1,102 +0,0 @@ -import React from 'react'; -import UserAutoCompleteInput from './UserAutoCompleteInput'; -import SwitchItem from './function/SwitchItem'; -class UserLoginMenuContainerVersionTwo extends React.Component { - constructor(props){ - super(props); - this.state = {}; - this.handleClick = this.handleClick.bind(this); - } - - componentWillMount() { - document.addEventListener('mousedown',this.handleClick, false); - } - - componentWillUnmount() { - document.removeEventListener('mousedown',this.handleClick, false); - } - - handleClick(e){ - let dropdownClass = ""; - if (this.node.contains(e.target)){ - if (this.state.dropdownClass === "open"){ - if (e.target.className === "th-icon" || e.target.className === "btn btn-default dropdown-toggle"){ - dropdownClass = ""; - } else { - dropdownClass = "open"; - } - } else { - dropdownClass = "open"; - } - } - this.setState({dropdownClass:dropdownClass},function(){ - if (dropdownClass === "open"){ - let el = document.body; - el.classList.add('drawer-open'); - } else { - let el = document.body; - el.classList.remove('drawer-open'); - - } - }); - } - - - render(){ - const theme = this.props.onSwitchStyleChecked?"Metaheader theme dark":"Metaheader theme light"; - return ( -
  • this.node = node}> -
    - -
    -
      -
    • -
      -
      -
      - -
      -
      -
      -
        -
      • {this.props.user.username}

      • -
      • {this.props.user.mail}
      • -
      • - Settings - Logout -
      • -
      -
      -
      -
    • - -
    • - Metaheader theme light - - dark - -
    • -
    • - {/* - - */ - } - -
    • -
    -
    -
    -
  • - ) - } -} - -export default UserLoginMenuContainerVersionTwo; diff --git a/httpdocs/theme/react/src/metaheader/UserMenu.js b/httpdocs/theme/react/src/metaheader/UserMenu.js deleted file mode 100644 index 4fd4b1e0b..000000000 --- a/httpdocs/theme/react/src/metaheader/UserMenu.js +++ /dev/null @@ -1,119 +0,0 @@ -import React from 'react'; -import UserLoginMenuContainer from './UserLoginMenuContainer'; -import DevelopmentAppMenu from './DevelopmentAppMenu'; -import SearchMenuContainer from './SearchMenuContainer'; -import AboutMenu from './AboutMenu'; - - -class UserMenu extends React.Component { - constructor(props){ - super(props); - this.state = {}; - } - - render(){ - let searchMenuDisplay; - if (this.props.user && this.props.isAdmin ){ - searchMenuDisplay = - - } - - let userDropdownDisplay, developmentAppMenuDisplay; - if (this.props.user && this.props.user.member_id){ - userDropdownDisplay = ( - - ); - - - developmentAppMenuDisplay = ( - - ); - } else { - userDropdownDisplay = ( - -
  • Register or
  • -
  • Login
  • -
    - ) - } - - - - - let chatItem=(); - - - - let userMenuContainerDisplay; - if (this.props.device === "large"){ - - - const aboutMenu = - - - - - userMenuContainerDisplay = ( -
      - - {aboutMenu} - {chatItem} - {searchMenuDisplay} - - {developmentAppMenuDisplay} - {userDropdownDisplay} - -
    - ); - } else { - userMenuContainerDisplay = ( -
      - { this.props.device === "mid" && chatItem } - {developmentAppMenuDisplay} - {userDropdownDisplay} - -
    - ); - } - - return ( - - {userMenuContainerDisplay} - - ) - } -} - -export default UserMenu; diff --git a/httpdocs/theme/react/src/metaheader/UserSearchTab.js b/httpdocs/theme/react/src/metaheader/UserSearchTab.js deleted file mode 100644 index 31a4f7bab..000000000 --- a/httpdocs/theme/react/src/metaheader/UserSearchTab.js +++ /dev/null @@ -1,116 +0,0 @@ -import React from 'react'; -import UserCommentsTabThreadsContainer from './UserCommentsTabThreadsContainer'; -import UserInfo from './function/UserInfo'; -class UserSearchTab extends React.Component { - constructor(props){ - super(props); - this.state = { - loading:true - }; - this.getUserOdComments = this.getUserOdComments.bind(this); - this.getUserInfo = this.getUserInfo.bind(this); - this.getUserForumComments = this.getUserForumComments.bind(this); - } - - componentDidMount() { - this.setState({odComments:[],forumComments:[],userinfo:[],loading:true},function(){ - //this.getUserOdComments(); - this.getUserInfo(); - }); - } - - getUserInfo(){ - let url = `${this.props.baseUrl}/membersetting/userinfo?member_id=${this.props.user.member_id}`; - fetch(url,{ - mode: 'cors', - credentials: 'include' - }) - .then(response => response.json()) - .then(data => { - this.setState({userinfo:data,loading:false},function(){ - this.getUserOdComments(); - }); - }); - } - - getUserOdComments(){ - let url = `${this.props.baseUrl}/membersetting/memberjson?member_id=${this.props.user.member_id}`; - fetch(url,{ - mode: 'cors', - credentials: 'include' - }) - .then(response => response.json()) - .then(data => { - this.setState({odComments:data.commentsOpendeskop,loading:false},function(){ - //this.getUserForumComments(); - }); - }); - } - - getUserForumComments(){ - const user = this.props.user; - const self = this; - const xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - - if (this.readyState == 4 && this.status == 200) { - const res = JSON.parse(this.response); - self.setState({forumComments:res.user_actions,loading:false}); - } - }; - xhttp.open("GET", "https://forum.opendesktop.cc/user_actions.json?offset=0&username=" + user.username + "&filter=5", true); - xhttp.send(); - } - - render(){ - let contentDisplay; - if (!this.state.loading){ - let odCommentsDisplay, forumCommentsDisplay, userinfoDisplay; - if (this.state.odComments.length > 0){ - odCommentsDisplay = ( - - ); - } - if(this.state.userinfo) - { - userinfoDisplay = - } - if (this.state.forumComments.length > 0){ - forumCommentsDisplay = ( - - ); - } - - contentDisplay = ( -
    - {userinfoDisplay} - {odCommentsDisplay} - {forumCommentsDisplay} -
    - ) - - } else { - contentDisplay = ( -
    loading
    - ); - } - - return( -
    - {contentDisplay} -
    - ) - } -} - -export default UserSearchTab; diff --git a/httpdocs/theme/react/src/metaheader/UserTabs.js b/httpdocs/theme/react/src/metaheader/UserTabs.js deleted file mode 100644 index 724a056bf..000000000 --- a/httpdocs/theme/react/src/metaheader/UserTabs.js +++ /dev/null @@ -1,125 +0,0 @@ -import React from 'react'; -import UserCommentsTab from './UserCommentsTab'; -import UserSearchTab from './UserSearchTab'; -import UserAutoCompleteInput from './UserAutoCompleteInput'; -class UserTabs extends React.Component { - constructor(props){ - super(props); - this.state = { - currentTab:'autocompletetest', - searchPhrase:'' - }; - this.onTabMenuItemClick = this.onTabMenuItemClick.bind(this); - this.onUserSearchInputChange = this.onUserSearchInputChange.bind(this); - this.getUsersAutocompleteList = this.getUsersAutocompleteList.bind(this); - this.selectUserFromAutocompleteList = this.selectUserFromAutocompleteList.bind(this); - } - - onTabMenuItemClick(val){ - this.setState({currentTab:val}); - } - - onUserSearchInputChange(e){ - const searchPhrase = e.target.value; - this.setState({searchPhrase:e.target.value},function(){ - let showUserList; - if (searchPhrase.length > 2){ - showUserList = true; - } else { - showUserList = false; - } - this.setState({showUserList:showUserList,selectedUser:''},function(){ - this.getUsersAutocompleteList(searchPhrase); - }); - }); - } - - getUsersAutocompleteList(searchPhrase){ - - let url = this.props.baseUrl+'/membersetting/searchmember?username='+searchPhrase; - fetch(url,{ - mode: 'cors', - credentials: 'include' - }) - .then(response => response.json()) - .then(data => { - this.setState({usersList:data,showUserList:true}); - }); - } - - selectUserFromAutocompleteList(user){ - this.setState({selectedUser:user,searchPhrase:user.username,showUserList:false}); - } - - render(){ - - let usersAutocompleteList; - if (this.state.usersList && this.state.showUserList){ - const users = this.state.usersList.map((u,index) => ( -
  • this.selectUserFromAutocompleteList(u)} key={index}> - {u.username} -
  • - )); - usersAutocompleteList = ( -
      - {users} -
    - ); - } - - - let tabContentDisplay; - if (this.state.currentTab === 'comments'){ - tabContentDisplay = ( - - ); - } else if (this.state.currentTab === 'search'){ - if (this.state.selectedUser){ - - tabContentDisplay = ( - - ); - } else { - tabContentDisplay = ( -

    search user

    - ); - } - }else if(this.state.currentTab === 'autocompletetest'){ - tabContentDisplay = - } - - return( -
    - -
    - {tabContentDisplay} -
    -
    - ); - } -} - -export default UserTabs; diff --git a/httpdocs/theme/react/src/metaheader/function/AboutMenuItems.js b/httpdocs/theme/react/src/metaheader/function/AboutMenuItems.js deleted file mode 100644 index b4334cc9a..000000000 --- a/httpdocs/theme/react/src/metaheader/function/AboutMenuItems.js +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -function AboutMenuItems(props) -{ - return ( - -
  • Blog
  • - { props.isAdmin && -
  • Plings (admin only)
  • - } -
  • FAQ Pling
  • -
  • FAQ Opencode
  • -
  • API
  • -
  • About
  • -
    - ); -} - -export default AboutMenuItems; diff --git a/httpdocs/theme/react/src/metaheader/function/CommunityMenuItems.js b/httpdocs/theme/react/src/metaheader/function/CommunityMenuItems.js deleted file mode 100644 index 092867bee..000000000 --- a/httpdocs/theme/react/src/metaheader/function/CommunityMenuItems.js +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -function CommunityMenuItems(props) -{ - return ( - -
  • Members
  • -
  • Discussion
  • -
  • Become a Supporter
  • -
    - ); -} - -export default CommunityMenuItems; diff --git a/httpdocs/theme/react/src/metaheader/function/DownloadSection.js b/httpdocs/theme/react/src/metaheader/function/DownloadSection.js deleted file mode 100644 index 4561bb14f..000000000 --- a/httpdocs/theme/react/src/metaheader/function/DownloadSection.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -function DownloadSection(props) -{ - return ( -
    -
    Download counter this month
    - { props.section.map((mg,i) => ( -
    {mg.name}:
    {mg.dls}
    - )) - } -
    - ); -} -export default DownloadSection; diff --git a/httpdocs/theme/react/src/metaheader/function/MyButton.js b/httpdocs/theme/react/src/metaheader/function/MyButton.js deleted file mode 100644 index 84e92ca25..000000000 --- a/httpdocs/theme/react/src/metaheader/function/MyButton.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -function MyButton(props) -{ - return ( -
  • - -
    - {props.label} - -
    -
  • - ); -} -export default MyButton; diff --git a/httpdocs/theme/react/src/metaheader/function/SwitchItem.js b/httpdocs/theme/react/src/metaheader/function/SwitchItem.js deleted file mode 100644 index a5779a5b6..000000000 --- a/httpdocs/theme/react/src/metaheader/function/SwitchItem.js +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -function SwitchItem(props){ - return( -
    - -
    - ) -} - -export default SwitchItem; diff --git a/httpdocs/theme/react/src/metaheader/function/UserInfo.js b/httpdocs/theme/react/src/metaheader/function/UserInfo.js deleted file mode 100644 index a82ec5ba2..000000000 --- a/httpdocs/theme/react/src/metaheader/function/UserInfo.js +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -function UserInfo(props){ - return( -
    -
    {props.userinfo.username} {props.userinfo.countrycity}
    -
    -
    {props.userinfo.cntProjects} products
    -
    {props.userinfo.totalComments} comments
    -
    Likes {props.userinfo.cntLikesGave} products
    -
    Got {props.userinfo.cntLikesGot} Likes
    -
    Last time active :{props.userinfo.lastactive_at}
    -
    Member since : {props.userinfo.created_at}
    -
    -
    - ) -} -export default UserInfo; diff --git a/httpdocs/theme/react/src/metaheader/function/WhereAmI.js b/httpdocs/theme/react/src/metaheader/function/WhereAmI.js deleted file mode 100644 index eb6f1d6b4..000000000 --- a/httpdocs/theme/react/src/metaheader/function/WhereAmI.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -function WhereAmI(props) -{ - return ( - - ); -} - -export default WhereAmI; diff --git a/httpdocs/theme/react/src/opendesktop-home/BlogFeedContainer.js b/httpdocs/theme/react/src/opendesktop-home/BlogFeedContainer.js deleted file mode 100644 index 013b03782..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/BlogFeedContainer.js +++ /dev/null @@ -1,50 +0,0 @@ -import React, { Component } from 'react'; -import TimeAgo from 'react-timeago'; -class BlogFeedContainer extends React.Component { - constructor(props){ - super(props); - this.state = {}; - } - - componentDidMount() { - const self = this; - var json_url = '/json/forum'; - //$.ajax("https://forum.opendesktop.org/latest.json").then(function (result) { - $.ajax(json_url).then(function (result) { - let topics = result.topic_list.topics; - topics.sort(function(a,b){ - return new Date(b.last_posted_at) - new Date(a.last_posted_at); - }); - topics = topics.slice(0,5); - self.setState({items:topics}); - }); - } - - render(){ - let feedItemsContainer; - if (this.state.items){ - - const feedItems = this.state.items.map((fi,index) => ( -
  • - - {fi.title} - - - {fi.timeago} - {fi.replyMsg} - -
  • - )); - - feedItemsContainer =
      {feedItems}
    ; - } - return ( -
    - - {feedItemsContainer} -
    - ) - } -} - -export default BlogFeedContainer; diff --git a/httpdocs/theme/react/src/opendesktop-home/ChatContainer.js b/httpdocs/theme/react/src/opendesktop-home/ChatContainer.js deleted file mode 100755 index a239caf86..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/ChatContainer.js +++ /dev/null @@ -1,68 +0,0 @@ -import React, { Component } from 'react'; - -class ChatContainer extends Component { - - constructor(props){ - super(props); - this.chatUrl = '/json/chat'; - this.avatarUrl= 'https://chat.opendesktop.org/_matrix/media/v1/thumbnail'; - this.state = {items:[]}; - } - - componentDidMount() { - fetch(this.chatUrl) - .then(response => response.json()) - .then(data => { - this.setState({items:data}); - }); - } - - render(){ - let container, members; - if (this.state.items){ - const feedItems = this.state.items.map((fi,index) => { - if(fi.members){ - let mb=Object.values(fi.members); - if(mb.length>0){ - members = mb.slice(0,4).map((m,index) => { - let imgAvatar; - if(m.avatar_url){ - imgAvatar = - } - return ( -
    - {imgAvatar} -
    - {m.display_name} -
    -
    - ) - } - ); - } - if(fi.guest_can_join==false) - { - return ( -
  • - - join our chat {(fi.canonical_alias)?fi.canonical_alias.substring(0,fi.canonical_alias.indexOf(':'))+' ('+fi.num_joined_members+')':''} - - {members} -
  • - ) - } - } - - }); - container =
      {feedItems}
    ; - } - return ( -
    - - {container} -
    - ) - } -} - -export default ChatContainer; diff --git a/httpdocs/theme/react/src/opendesktop-home/ChatMember.js b/httpdocs/theme/react/src/opendesktop-home/ChatMember.js deleted file mode 100755 index d4ee063bf..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/ChatMember.js +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; - -function ChatMember(props) { - return ( -
    - - {props.display_name} -
    ; - ) -} - -export default ChatMember; diff --git a/httpdocs/theme/react/src/opendesktop-home/CommentsContainer.js b/httpdocs/theme/react/src/opendesktop-home/CommentsContainer.js deleted file mode 100644 index 31f6635d8..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/CommentsContainer.js +++ /dev/null @@ -1,38 +0,0 @@ -import React, { Component } from 'react'; - -class CommentsContainer extends React.Component { - render(){ - let commentsContainer; - if (this.props.comments){ - const comments = this.props.comments.map((cm,index) => ( -
  • -
    - - - {cm.username} - - {cm.title} - - {cm.comment_text} - - - - {cm.comment_created_at} - - - -
    -
  • - )); - commentsContainer =
      {comments}
    - } - return ( -
    -
    {this.props.title}
    - {commentsContainer} -
    - ) - } -} - -export default CommentsContainer; diff --git a/httpdocs/theme/react/src/opendesktop-home/DrawerOpenRight.js b/httpdocs/theme/react/src/opendesktop-home/DrawerOpenRight.js deleted file mode 100644 index 9616203c9..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/DrawerOpenRight.js +++ /dev/null @@ -1,33 +0,0 @@ -import React from 'react'; -import Drawer from '@material-ui/core/Drawer'; -import AppBar from '@material-ui/core/AppBar'; -import Button from '@material-ui/core/Button'; - -class DrawerOpenRight extends React.Component { - - constructor(props) { - super(props); - this.state = {open: false}; - this.handleToggle=this.handleToggle.bind(this); - } - - handleToggle(){ - this.setState({open: !this.state.open}); - } - - render() { - return ( -
    -
    - ); - } -} - -export default DrawerOpenRight; diff --git a/httpdocs/theme/react/src/opendesktop-home/HomeMainContainer.js b/httpdocs/theme/react/src/opendesktop-home/HomeMainContainer.js deleted file mode 100644 index c8df8c96c..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/HomeMainContainer.js +++ /dev/null @@ -1,100 +0,0 @@ -import React, { Component } from 'react'; -import RssNewsContainer from './RssNewsContainer'; -import BlogFeedContainer from './BlogFeedContainer'; -import CommentsContainer from './CommentsContainer'; -import RatingContainer from './RatingContainer'; -import ProductsContainer from './ProductsContainer'; -import MySpamContainer from './MySpamContainer'; -import ChatContainer from './ChatContainer'; -import ProductsGitContainer from './ProductsGitContainer'; -import Introduction from './Introduction'; -import PersonalActivityContainer from './PersonalActivityContainer'; -import PersonalLinksContainer from './function/PersonalLinksContainer'; -import AdminLinksContainer from './function/AdminLinksContainer'; -class HomeMainContainer extends Component { - constructor(props){ - super(props); - this.state ={...window.data}; - } - render() { - let content; - let supporterinfo; - if(this.state.supporterinfo && this.state.supporterinfo.member_id) - { - supporterinfo =
    Thanks for supporting Pling.com
    - }else{ - supporterinfo = - } - if(this.state.user) - { - content = ( -
    -
    -
    - -
    - - {supporterinfo} -
    -

    - Hi {this.state.user.username}, good to see you!

    - go here for the startpage. - - -
    -
    -
    - - - - { this.state.spams.length>0 && - - } - { this.state.user.isAdmin && -
    -
    Special links (Admin only)
    - -
    - } -
    -
    - ) - }else{ - content = ( -
    -
    - -
    -
    - - - - - - - - -
    -
    - ) - } - - return ( - - {content} - - ); - } -} -export default HomeMainContainer; diff --git a/httpdocs/theme/react/src/opendesktop-home/Introduction.js b/httpdocs/theme/react/src/opendesktop-home/Introduction.js deleted file mode 100644 index 42276b141..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/Introduction.js +++ /dev/null @@ -1,111 +0,0 @@ -import React, { Component } from 'react'; -import IntroductionDetailCode from './function/IntroductionDetailCode'; -import IntroductionDetailPublish from './function/IntroductionDetailPublish'; -import IntroductionDetailCommunity from './function/IntroductionDetailCommunity'; -import IntroductionDetailPersonal from './function/IntroductionDetailPersonal'; - -class Introduction extends Component { - constructor(props){ - super(props); - this.state = {isToggleOn: true}; - // This binding is necessary to make `this` work in the callback - this.handleClick = this.handleClick.bind(this); - } - - handleClick(t) { - this.setState(state => ({ - isToggleOn: !state.isToggleOn, - section:(t==state.section)?'':t - })); - } - render() { - let introductionDetail=null; - switch (this.state.section) { - case 'code': - introductionDetail = ; - break; - case 'publish': - introductionDetail = ; - break; - case 'community': - introductionDetail = ; - break; - case 'personal': - introductionDetail = ; - break; - default: - break; - } - return ( - - - ) - } -} - -export default Introduction; diff --git a/httpdocs/theme/react/src/opendesktop-home/MySpamContainer.js b/httpdocs/theme/react/src/opendesktop-home/MySpamContainer.js deleted file mode 100644 index 44798b7f2..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/MySpamContainer.js +++ /dev/null @@ -1,26 +0,0 @@ -import React, { Component } from 'react'; -import Product from './Product'; -class MySpamContainer extends React.Component { - constructor(props){ - super(props); - } - render(){ - let container; - if (this.props.spams){ - const products = this.props.spams.map((product,index) => ( -
  • - -
  • - )); - container =
      {products}
    - } - return ( -
    -
    Spam
    - {container} -
    - ) - } -} - -export default MySpamContainer; diff --git a/httpdocs/theme/react/src/opendesktop-home/PersonalActivityContainer.js b/httpdocs/theme/react/src/opendesktop-home/PersonalActivityContainer.js deleted file mode 100644 index 353c52f29..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/PersonalActivityContainer.js +++ /dev/null @@ -1,14 +0,0 @@ -import React, { Component } from 'react'; -import TimeAgo from 'react-timeago'; - -class PersonalActivityContainer extends React.Component { - render(){ - return ( -
    - -
    - ) - } -} - -export default PersonalActivityContainer; diff --git a/httpdocs/theme/react/src/opendesktop-home/Product.js b/httpdocs/theme/react/src/opendesktop-home/Product.js deleted file mode 100644 index 42dfddc4c..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/Product.js +++ /dev/null @@ -1,46 +0,0 @@ -import React, { Component } from 'react'; - -class Product extends React.Component { - render(){ - let projectUrl = this.props.baseUrlStore+"/p/"+this.props.product.project_id; - const scoreDisplay=( -
    -
    - {(this.props.product.laplace_score/10).toFixed(1) + "%"} -
    -
    -
    -
    -
    - ); - - const productInfoDisplay = ( -
    - {this.props.product.title} - {this.props.product.cat_title} - {this.props.product.updated_at} -
    - ); - - - return ( -
    - -
    - {productInfoDisplay} -
    -
    - {scoreDisplay} -
    -
    - ) - } -} - -export default Product; diff --git a/httpdocs/theme/react/src/opendesktop-home/ProductGit.js b/httpdocs/theme/react/src/opendesktop-home/ProductGit.js deleted file mode 100755 index cfadad0dd..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/ProductGit.js +++ /dev/null @@ -1,71 +0,0 @@ -import React, { Component } from 'react'; -import TimeAgo from 'react-timeago'; -import TextTruncate from 'react-text-truncate'; -class ProductGit extends React.Component { - constructor(props){ - super(props); - this.gitBaseUrl='https://opencode.net/'; - } - render(){ - - const userDisplay =( - - - - - {this.props.product.namespace.name} - - - - ); - const productInfoDisplay = ( -
    - {this.props.product.name} - - - - - {this.props.product.timeago} -
    - ); - - let imageProject; - if(this.props.product.avatar_url) - { - imageProject =( -
    - -
    - ); - }else { - imageProject =( -
    -
    {this.props.product.name.substr(0,1)}
    -
    - ); - } - - return ( -
    - -
    - {productInfoDisplay} -
    -
    - {userDisplay} -
    -
    - ) - } -} - -export default ProductGit; diff --git a/httpdocs/theme/react/src/opendesktop-home/ProductsContainer.js b/httpdocs/theme/react/src/opendesktop-home/ProductsContainer.js deleted file mode 100644 index be6748dc9..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/ProductsContainer.js +++ /dev/null @@ -1,26 +0,0 @@ -import React, { Component } from 'react'; -import Product from './Product'; -class ProductsContainer extends React.Component { - constructor(props){ - super(props); - } - render(){ - let container; - if (this.props.products){ - const products = this.props.products.map((product,index) => ( -
  • - -
  • - )); - container =
      {products}
    - } - return ( -
    - - {container} -
    - ) - } -} - -export default ProductsContainer; diff --git a/httpdocs/theme/react/src/opendesktop-home/ProductsGitContainer.js b/httpdocs/theme/react/src/opendesktop-home/ProductsGitContainer.js deleted file mode 100755 index 57cbd8bd8..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/ProductsGitContainer.js +++ /dev/null @@ -1,52 +0,0 @@ -import React, { Component } from 'react'; -import ProductGit from './ProductGit'; - -class ProductsGitContainer extends React.Component { - constructor(props){ - super(props); - this.gitUrl = '/json/gitlabnewprojects'; - this.gitUserUrl = '/json/gitlabfetchuser?username='; - this.state = {items:[]}; - } - - componentDidMount() { - fetch(this.gitUrl) - .then(response => response.json()) - .then(data => { - data.map((fi,index) => { - let url = this.gitUserUrl+fi.namespace.name; - return fetch(url) - .then(response => response.json()) - .then(data => { - fi.user_avatar_url = data[0].avatar_url; - let items = this.state.items.concat(fi); - this.setState({items:items}); - }) - }); - }); - } - - render(){ - let container; - container =

    git-container

    - if (this.state.items){ - const items = this.state.items.sort(function(a,b){ - return new Date(b.created_at) - new Date(a.created_at); - }); - const products = items.map((product,index) => ( -
  • - -
  • - )); - container =
      {products}
    - } - return ( -
    - - {container} -
    - ) - } -} - -export default ProductsGitContainer; diff --git a/httpdocs/theme/react/src/opendesktop-home/RatingContainer.js b/httpdocs/theme/react/src/opendesktop-home/RatingContainer.js deleted file mode 100644 index 85d1c8b38..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/RatingContainer.js +++ /dev/null @@ -1,38 +0,0 @@ -import React, { Component } from 'react'; - -class RatingContainer extends React.Component { - render(){ - let ratingContainer; - if (this.props.votes){ - const votes = this.props.votes.map((cm,index) => ( -
  • -
    - - - {cm.username} - - {cm.title} - - Score:{cm.score} {cm.comment_text} - - - - {cm.created_at} - - - -
    -
  • - )); - ratingContainer =
      {votes}
    - } - return ( -
    -
    {this.props.title}
    - {ratingContainer} -
    - ) - } -} - -export default RatingContainer; diff --git a/httpdocs/theme/react/src/opendesktop-home/RssNewsContainer.js b/httpdocs/theme/react/src/opendesktop-home/RssNewsContainer.js deleted file mode 100644 index 7bd14906d..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/RssNewsContainer.js +++ /dev/null @@ -1,44 +0,0 @@ -import React, { Component } from 'react'; -import TimeAgo from 'react-timeago'; -class RssNewsContainer extends Component { - constructor(props){ - super(props); - this.state = {}; - } - - componentDidMount() { - const self = this; - $.getJSON("https://blog.opendesktop.org/?json=1&callback=?", function (res) { - self.setState({items:res.posts}); - }); - } - - render(){ - let feedItemsContainer; - if (this.state.items){ - - const feedItems = this.state.items.slice(0,5).map((fi,index) => ( -
  • - - {fi.title} - - - - - {fi.comment_count} comments - -
  • - )); - - feedItemsContainer =
      {feedItems}
    ; - } - return ( -
    - - {feedItemsContainer} -
    - ) - } -} - -export default RssNewsContainer; diff --git a/httpdocs/theme/react/src/opendesktop-home/app.js b/httpdocs/theme/react/src/opendesktop-home/app.js deleted file mode 100644 index 96d52c297..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/app.js +++ /dev/null @@ -1,478 +0,0 @@ -window.hpHelpers = (function(){ - - function dechex(number) { - // discuss at: http://locutus.io/php/dechex/ - // original by: Philippe Baumann - // bugfixed by: Onno Marsman (https://twitter.com/onnomarsman) - // improved by: http://stackoverflow.com/questions/57803/how-to-convert-decimal-to-hex-in-javascript - // input by: pilus - // example 1: dechex(10) - // returns 1: 'a' - // example 2: dechex(47) - // returns 2: '2f' - // example 3: dechex(-1415723993) - // returns 3: 'ab9dc427' - - if (number < 0) { - number = 0xFFFFFFFF + number + 1 - } - return parseInt(number, 10).toString(16) - } - - function calculateScoreColor(score){ - let blue, red, green, defaultColor = 200; - if (score > 50){ - red = defaultColor - ((score-50)*4); - green = defaultColor; - blue = defaultColor - ((score-50)*4); - } else if (score < 51){ - red = defaultColor; - green = defaultColor - ((score-50)*4); - blue = defaultColor - ((score-50)*4); - } - - return "rgb("+red+","+green+","+blue+")"; - } - - return { - dechex, - calculateScoreColor - } -}()); - -class App extends React.Component { - constructor(props){ - super(props); - this.state = { - loading:true, - hpVersion:window.hpVersion - }; - this.initHomePage = this.initHomePage.bind(this); - this.updateDimensions = this.updateDimensions.bind(this); - } - - - componentWillMount() { - this.updateDimensions(); - } - - componentWillUnmount(){ - window.removeEventListener("resize", this.updateDimensions); - window.removeEventListener("orientationchange",this.updateDimensions); - } - - componentDidMount() { - this.initHomePage(); - } - - initHomePage(){ - - window.addEventListener("resize", this.updateDimensions); - window.addEventListener("orientationchange",this.updateDimensions); - - let env = "live"; - if (location.hostname.endsWith('cc')) { - env = "test"; - } else if (location.hostname.endsWith('localhost')) { - env = "test"; - } - - this.setState({env:env}); - } - - updateDimensions(){ - - const width = window.innerWidth; - let device; - if (width >= 910){ - device = "large"; - } else if (width < 910 && width >= 610){ - device = "mid"; - } else if (width < 610){ - device = "tablet"; - } - - this.setState({device:device}); - - } - - render(){ - const featuredProduct = JSON.parse(window.data['featureProducts']); - return ( -
    - -
    - ) - } -} - -class SpotlightProduct extends React.Component { - constructor(props){ - super(props); - this.state = { - featuredProduct:this.props.featuredProduct, - type:"featured", - featuredPage:0, - loading:true - }; - this.onSpotlightMenuClick = this.onSpotlightMenuClick.bind(this); - } - - componentDidMount() { - this.onSpotlightMenuClick('plinged'); - } - - onSpotlightMenuClick(val){ - - this.setState({type:val,loading:true},function(){ - - let url = "/home/showfeaturejson/page/"; - let featuredPage = this.state.featuredPage; - if (this.state.type === "plinged"){ - url = "/home/getnewactiveplingedproductjson?limit=1&offset=" + this.state.featuredPage; - featuredPage = this.state.featuredPage + 1; - } else if (this.state.type === "random"){ - url += "0"; - } else { - url += "1"; - } - const self = this; - - $.ajax({url: url,cache: false}).done(function(response){ - - let featuredProduct = response; - if (self.state.type === "plinged"){ - featuredProduct = response[0]; - } - - console.log(featuredProduct); - - self.setState({ - featuredProduct:featuredProduct, - featuredPage:featuredPage, - loading:false - }); - }); - }); - } - - render(){ - - let spotlightProductDisplay; - if (this.state.loading){ - spotlightProductDisplay = ( - - ); - } else { - - let productImageUrl; - if (this.state.type === "plinged"){ - productImageUrl = this.state.featuredProduct.image_small; - } else { - let imageBaseUrl; - if (this.props.env === 'live') { - imageBaseUrl = 'cn.opendesktop.org'; - } else { - imageBaseUrl = 'cn.opendesktop.cc'; - } - productImageUrl = "https://" + imageBaseUrl + "/cache/300x230-1/img/" + this.state.featuredProduct.image_small; - } - - let description = this.state.featuredProduct.description; - if (description && description.length > 295){ - description = this.state.featuredProduct.description.substring(0,295) + "..."; - } - - let featuredLabelDisplay; - if (this.state.type === "featured"){ - featuredLabelDisplay = ( - featured - ); - } else if (this.state.type === "plinged"){ - featuredLabelDisplay = ( - plinged - ); - } - - let cDate = new Date(this.state.featuredProduct.created_at); - cDate = cDate.toString(); - const createdDate = cDate.split(' ')[1] + " " + cDate.split(' ')[2] + " " + cDate.split(' ')[3]; - // const productScoreColor = window.hpHelpers.calculateScoreColor(this.state.featuredProduct.laplace_score); - - let commentCount; - if (this.state.featuredProduct.count_comments){ - commentCount = this.state.featuredProduct.count_comments; - } else { - commentCount = "0"; - } - - let categoryDisplay = this.state.featuredProduct.category; - if (this.state.type === "plinged"){ - categoryDisplay = this.state.featuredProduct.cat_title; - } - - spotlightProductDisplay = ( -
    -
    - -
    - -
    -
    -
    -
    - {featuredLabelDisplay} -
    -

    {this.state.featuredProduct.title}

    -

    {categoryDisplay}

    -
    - - {this.state.featuredProduct.username} -
    - {commentCount} comments -
    -
    - score {this.state.featuredProduct.laplace_score + "%"} -
    -
    -
    -
    -
    - {createdDate} -
    -
    -
    -
    - {description} -
    -
    - -
    -
    - ); - } - - return( -
    -

    In the Spotlight

    - {spotlightProductDisplay} -
    - ); - } -} - -class SpotlightProductDummy extends React.Component { - constructor(props){ - super(props); - this.state = {}; - } - - render(){ - return( -
    -
    -
    -
    -
    -
    -
    -
    -
    -

    -

    -
    -
    - -
    - -
    -
    -
    -
    -
    -
    -
    -
    -
    - - - - -
    -
    -
    -
    - ); - } -} - -class SpotlightUser extends React.Component { - constructor(props){ - super(props); - this.state = { - loading:true, - version:2 - }; - this.updateDimensions = this.updateDimensions.bind(this); - this.getSpotlightUser = this.getSpotlightUser.bind(this); - } - - componentWillMount() { - window.addEventListener("resize", this.updateDimensions); - } - - componentDidMount() { - this.updateDimensions(); - this.getSpotlightUser(); - } - - updateDimensions(){ - const containerWidth = $('#main-content').width(); - const userProductsPerRow = 4; - const userProductsDimensions = containerWidth / userProductsPerRow; - this.setState({itemWidth:userProductsDimensions,itemHeight:userProductsDimensions}); - } - - getSpotlightUser(page){ - if (!page) { page = 0 } - this.setState({loading:true,page: page},function(){ - let url = "/home/showspotlightjson?page=" + this.state.page; - const self = this; - $.ajax({url: url,cache: false}).done(function(response){ - self.setState({user:response,loading:false},function(){ - const height = $('#user-container').height(); - if (height > 0){ - this.setState({containerHeight:height}); - } - }); - }); - }); - } - - render(){ - - let spotlightUserDisplay; - if (this.state.loading){ - let loadingStyle; - if (this.state.containerHeight){ - loadingStyle = { - "height":this.state.containerHeight - } - } - spotlightUserDisplay = ( -
    -
    -
    - ); - } else { - let userProducts; - if (this.state.itemWidth){ - userProducts = this.state.user.products.map((p,index) => ( - - )); - } - spotlightUserDisplay = ( -
    - -
    - {userProducts} -
    -
    - ); - } - - let prevButtonDisplay; - if (this.state.page > 0){ - prevButtonDisplay = ( - this.getSpotlightUser(this.state.page - 1)} className="spotlight-user-next"> - {"< Prev"} - - ); - } - - let nextButtonDisplay; - if (this.state.page < 8){ - nextButtonDisplay = ( - this.getSpotlightUser(this.state.page + 1)} className="spotlight-user-next"> - {"Next >"} - - ); - } - - let versionCssClass; - if (this.state.version === 2){ - versionCssClass = "v-two" - } - - return( -
    -

    In the Spotlight

    - {spotlightUserDisplay} -
    - {prevButtonDisplay} - {nextButtonDisplay} -
    -
    - ) - } -} - -class SpotlightUserProduct extends React.Component { - constructor(props){ - super(props); - this.state = {}; - } - - componentDidMount() { - console.log(this.props); - } - - render(){ - let userProductStyle; - if (this.props.itemWidth){ - userProductStyle = { - "height":this.props.itemHeight, - "width":this.props.itemWidth - } - } - return ( -
    -
    - -
    -
    -
    - {this.props.product.title} -
    -
    -
    - - {this.props.product.sum_plings} -
    -
    - ) - } -} - -ReactDOM.render( - , - document.getElementById('main-content') -); diff --git a/httpdocs/theme/react/src/opendesktop-home/function/AdminLinksContainer.js b/httpdocs/theme/react/src/opendesktop-home/function/AdminLinksContainer.js deleted file mode 100644 index 9fe827724..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/function/AdminLinksContainer.js +++ /dev/null @@ -1,79 +0,0 @@ -import React from 'react'; -function AdminlLinksContainer(props) -{ - return ( - - ); -} - -export default AdminlLinksContainer; diff --git a/httpdocs/theme/react/src/opendesktop-home/function/IntroductionDetailCode.js b/httpdocs/theme/react/src/opendesktop-home/function/IntroductionDetailCode.js deleted file mode 100644 index 4070436b9..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/function/IntroductionDetailCode.js +++ /dev/null @@ -1,24 +0,0 @@ -import React from 'react'; -function IntroductionDetailCode(props){ - return( -
    - -
    - -
    -
    -
    -
    -

    - openCode.net -

    -
    -

    Develop your projects online for free. Git and CI, powered by Gitlab.

    - www.opencode.net -
    -
    -
    - ) -} - -export default IntroductionDetailCode; diff --git a/httpdocs/theme/react/src/opendesktop-home/function/IntroductionDetailCommunity.js b/httpdocs/theme/react/src/opendesktop-home/function/IntroductionDetailCommunity.js deleted file mode 100644 index 2b36df0e3..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/function/IntroductionDetailCommunity.js +++ /dev/null @@ -1,27 +0,0 @@ -import React from 'react'; -function IntroductionDetailCommunity(props){ - return( -
    - -
    - -
    -
    -
    -
    -

    - Discourse, Matrix/Riot -

    -
    -

    - Join the community and discuss on Discourse or chat with anyone via Riot/Matrix. -

    - https://forum.opendesktop.org/ - https://chat.opendesktop.org -
    -
    -
    - ) -} - -export default IntroductionDetailCommunity; diff --git a/httpdocs/theme/react/src/opendesktop-home/function/IntroductionDetailPersonal.js b/httpdocs/theme/react/src/opendesktop-home/function/IntroductionDetailPersonal.js deleted file mode 100644 index 5e8e70628..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/function/IntroductionDetailPersonal.js +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; -function IntroductionDetailPersonal(props){ - return( -
    - -
    - -
    -
    -
    -
    -

    - Nextcloud -

    -
    -

    Nextcloud offers file storage, contacts, calendar and online Office document editing technology. Keep your data private. -

    - https://my.opendesktop.org -
    -
    -
    - ) -} - -export default IntroductionDetailPersonal; diff --git a/httpdocs/theme/react/src/opendesktop-home/function/IntroductionDetailPublish.js b/httpdocs/theme/react/src/opendesktop-home/function/IntroductionDetailPublish.js deleted file mode 100644 index a41c6bd68..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/function/IntroductionDetailPublish.js +++ /dev/null @@ -1,24 +0,0 @@ -import React from 'react'; -function IntroductionDetailPublish(props){ - return( -
    - -
    - -
    -
    -
    -
    -

    - Pling.com -

    -
    - The publishing platform for open source software and free content. - www.pling.com -
    -
    -
    - ) -} - -export default IntroductionDetailPublish; diff --git a/httpdocs/theme/react/src/opendesktop-home/function/PersonalLinksContainer.js b/httpdocs/theme/react/src/opendesktop-home/function/PersonalLinksContainer.js deleted file mode 100644 index 69fe29718..000000000 --- a/httpdocs/theme/react/src/opendesktop-home/function/PersonalLinksContainer.js +++ /dev/null @@ -1,65 +0,0 @@ -import React from 'react'; -function PersonalLinksContainer(props) -{ - return ( - - ); -} - -export default PersonalLinksContainer; diff --git a/httpdocs/theme/react/src/pling-section/Header.js b/httpdocs/theme/react/src/pling-section/Header.js deleted file mode 100644 index 1b52879e1..000000000 --- a/httpdocs/theme/react/src/pling-section/Header.js +++ /dev/null @@ -1,47 +0,0 @@ -import React, { Component } from 'react'; -class Header extends Component { - constructor(props){ - super(props); - } - render(){ - - function compare(el,idx,array) { - for (let i = 0; i < array.length; i++) { - if (array[i].member_id == el.member_id) - { - if(idx==i){ - return el; - }else - { - break; - } - } - } - } - const s = this.props.supporters.filter(compare).length; - let goal = Math.ceil((s/50))*50; - if(goal==0) - { - goal = 50; - } - return( -
    -
    - {this.props.section ? this.props.section.name:''} -
    -
    - Goal: -
    -
    - {s} -
    -
    - {goal} - -
    -
    - ) - } -} - -export default Header; diff --git a/httpdocs/theme/react/src/pling-section/PlingSection.js b/httpdocs/theme/react/src/pling-section/PlingSection.js deleted file mode 100644 index 48be1e4fd..000000000 --- a/httpdocs/theme/react/src/pling-section/PlingSection.js +++ /dev/null @@ -1,127 +0,0 @@ -import React, { Component } from 'react'; -import TopProducts from './TopProducts'; -import TopCreators from './TopCreators'; -import Support from './Support'; -import Supporters from './Supporters'; -import Header from './Header'; -class PlingSection extends Component { - constructor(props){ - super(props); - this.state ={...window.data,showContent:'overview'}; - //this.handleClick = this.handleClick.bind(this); - this.loadData = this.loadData.bind(this); - this.onClickCategory = this.onClickCategory.bind(this); - this.showDetail = this.showDetail.bind(this); - } - - - // handleClick(section) { - // this.setState(state => ({ - // isToggleOn: !state.isToggleOn, - // section:section, - // loading:true, - // category:'' - // })); - // this.loadData(section); - // } - - loadData(section){ - let url = '/section/top?id='+section.section_id; - fetch(url) - .then(response => response.json()) - .then(data => { - this.setState(prevState => ({loading:false, products:data.products, creators:data.creators})) - }); - } - - showDetail(showContent){ - this.setState(state => ({ - showContent: showContent - })); - if(showContent=='overview'){ this.loadData(this.state.section);} - } - onClickCategory(category) - { - let url = '/section/topcat?cat_id='+category.project_category_id; - fetch(url) - .then(response => response.json()) - .then(data => { - this.setState(prevState => ({loading:false,showContent: 'overview',products:data.products, creators:data.creators,category:category})) - }); - } - - render() { - - let sectioncontainer, sectiondetail; - //onClick={()=>this.handleClick(section)} - if (this.state.sections){ - const s = this.state.sections.map((section,index) => ( -
  • - {section.name} -
  • - )); - sectioncontainer =
    -
      {s}
    -
    - } - - let s; - if (this.state.details && this.state.section){ - s = this.state.details.map((detail,index) => { - if(detail.section_id==this.state.section.section_id) - return
  • this.onClickCategory(detail)}>{detail.title}
  • - }); - } - - let detailContent; - if(this.state.showContent=='supporters') - { - detailContent = - }else { - detailContent = ( - - - - - ) - } - - sectiondetail =
    - { this.state.section && - - } -
    - {detailContent} -
    -
    -
    Become a Supporter
    - { this.state.section && - - } -
    -
    - - return ( - -
    - {sectioncontainer} - {sectiondetail} - - ); - } -} -export default PlingSection; diff --git a/httpdocs/theme/react/src/pling-section/Product.js b/httpdocs/theme/react/src/pling-section/Product.js deleted file mode 100644 index 76b03b791..000000000 --- a/httpdocs/theme/react/src/pling-section/Product.js +++ /dev/null @@ -1,47 +0,0 @@ -import React, { Component } from 'react'; - -class Product extends React.Component { - render(){ - let projectUrl = this.props.baseUrlStore+"/p/"+this.props.product.project_id; - const scoreDisplay=( -
    -
    - {(this.props.product.laplace_score/10).toFixed(1) + "%"} -
    -
    -
    - ${this.props.product.probably_payout_amount_factor} {this.props.isAdmin?"($"+this.props.product.probably_payout_amount+")":""} -
    -
    - ); - - const productInfoDisplay = ( -
    - {this.props.product.title} - {this.props.product.cat_title} - {this.props.product.updated_at} -
    - ); - - - return ( -
    - -
    - {productInfoDisplay} -
    -
    - {scoreDisplay} -
    -
    - ) - } -} - -export default Product; diff --git a/httpdocs/theme/react/src/pling-section/Support.js b/httpdocs/theme/react/src/pling-section/Support.js deleted file mode 100644 index aadeecab4..000000000 --- a/httpdocs/theme/react/src/pling-section/Support.js +++ /dev/null @@ -1,107 +0,0 @@ -import React, { Component } from 'react'; - -class Support extends React.Component { - - constructor(props){ - super(props); - this.state ={}; - this.onChangeFreeamount = this.onChangeFreeamount.bind(this); - } - - onChangeFreeamount(event){ - this.setState({typed: event.target.value}); - } - - render(){ - - let tiers=[0.99,2,5,10,20,50]; - let limits = [2,5,10,20,50,100] - const container = tiers.map((t,index) => { - let c; - let tmp = t; - let left, right; - if(index==0) - { - left = 0; - }else { - left = limits[index-1]; - } - right=limits[index]; - const result = this.props.supporters.filter(s => (s.section_support_tier >= left && s.section_support_tier { - // return ( - //
  • - // - //
  • - // ) - // } - // ); - // c =
      {x}
    - // let url = this.props.baseUrlStore+'/support-predefined?section_id='+this.props.section.section_id; - // url = url+'&amount_predefined='+tmp; - - return ( -
    - {result.length+ ' Supporters'} - -
    - ); - } - ); - - let result = this.props.supporters; - // tiers.forEach(function(element) { - // result = result.filter(s => s.section_support_tier!=element); - // }); - - result = result.filter(s => s.section_support_tier>=100); - - let othertiers; - let o; - - const x = result.map((s,index) => { - return ( -
  • - -
  • - ) - } - ); - o =
      {x}
    - - let url = this.props.baseUrlStore+'/support-predefined?section_id='+this.props.section.section_id; - url = url+'&amount_predefined='+this.state.typed; - - othertiers = ( -
    - { o && - {x.length} Supporters - } - -
    -
    - $100 or more -
    -
    - Join -
    -
    -
    - ) - - - return ( -
    -
    -
    Tiers
    -
    - {container} - {othertiers} -
    - ) - } -} - -export default Support; diff --git a/httpdocs/theme/react/src/pling-section/Supporters.js b/httpdocs/theme/react/src/pling-section/Supporters.js deleted file mode 100644 index 6b41300e0..000000000 --- a/httpdocs/theme/react/src/pling-section/Supporters.js +++ /dev/null @@ -1,44 +0,0 @@ -import React, { Component } from 'react'; - -class Supporters extends React.Component { - - constructor(props){ - super(props); - this.state ={}; - } - - render(){ - - function compare(el,idx,array) { - for (let i = 0; i < array.length; i++) { - if (array[i].member_id == el.member_id) - { - if(idx==i){ - return el; - }else - { - break; - } - } - } - } - - const x = this.props.supporters.filter(compare).map((s,index) => { - return ( -
  • - -
    {s.username}
    -
  • - ) - } - ); - const c =
      {x}
    - - return ( -
    - {c} -
    - ) - } -} -export default Supporters; diff --git a/httpdocs/theme/react/src/pling-section/TopCreators.js b/httpdocs/theme/react/src/pling-section/TopCreators.js deleted file mode 100644 index 72f3c27d0..000000000 --- a/httpdocs/theme/react/src/pling-section/TopCreators.js +++ /dev/null @@ -1,39 +0,0 @@ -import React from 'react'; -import Creator from './function/Creator'; -class TopCreators extends React.Component { - constructor(props){ - super(props); - this.state = {}; - - } - render(){ - let container; - if (this.props.creators){ - const creators = this.props.creators.map((creator,index) => ( -
  • - -
  • - )); - container =
      {creators}
    - } - let title = 'Top 20 Creators Last Month Payout'; - // if(this.props.category){ - // title = title + ':' +this.props.category.title; - // }else { - // // if(this.props.section){ - // // title = this.props.section.name; - // // }else { - // // title = 'All'; - // // } - // } - - return ( -
    -
    {title}
    - {container} -
    - ) - } -} - -export default TopCreators; diff --git a/httpdocs/theme/react/src/pling-section/TopProducts.js b/httpdocs/theme/react/src/pling-section/TopProducts.js deleted file mode 100644 index 0065a67c6..000000000 --- a/httpdocs/theme/react/src/pling-section/TopProducts.js +++ /dev/null @@ -1,38 +0,0 @@ -import React from 'react'; -import Product from './Product'; -class TopProducts extends React.Component { - constructor(props){ - super(props); - this.state = {}; - - } - render(){ - let container; - if (this.props.products){ - const products = this.props.products.map((product,index) => ( -
  • - -
  • - )); - container =
      {products}
    - } - let title; - if(this.props.category){ - title = this.props.category.title; - }else { - if(this.props.section){ - title = this.props.section.name; - }else { - title = 'All'; - } - } - return ( -
    -
    Top 20 Products Last Month Payout
    - {container} -
    - ) - } -} - -export default TopProducts; diff --git a/httpdocs/theme/react/src/pling-section/function/Creator.js b/httpdocs/theme/react/src/pling-section/function/Creator.js deleted file mode 100644 index 87b036a15..000000000 --- a/httpdocs/theme/react/src/pling-section/function/Creator.js +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; -function Creator(props){ - return( -
    - -
    -
    {props.creator.username}
    - ${props.creator.probably_payout_amount_factor} {props.isAdmin?"($"+props.creator.probably_payout_amount+")":""} - {/* -
      -
    • {props.creator.userinfo.cntProjects} products
    • -
    • {props.creator.userinfo.totalComments} comments
    • -
    • Like {props.creator.userinfo.cntLikesGave} products
    • -
    • Got {props.creator.userinfo.cntLikesGot} likes
    • -
    • Last time active {props.creator.userinfo.lastactive_at}
    • -
    • Member since {props.creator.userinfo.created_at}
    • -
    - */} -
    -
    - ) -} - -export default Creator; diff --git a/httpdocs/theme/react/src/pling-section/function/Header.js b/httpdocs/theme/react/src/pling-section/function/Header.js deleted file mode 100644 index 0a19dc3cc..000000000 --- a/httpdocs/theme/react/src/pling-section/function/Header.js +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react'; -function Header(props){ - return( -
    -
    - {props.section ? props.section.name:''} -
    -
    - Goal: -
    -
    {props.amount_factor}
    -
    - { props.goal} - -
    -
    - ) -} - -export default Header; diff --git a/httpdocs/theme/react/src/pling-section/function/Product.js b/httpdocs/theme/react/src/pling-section/function/Product.js deleted file mode 100644 index 42dfddc4c..000000000 --- a/httpdocs/theme/react/src/pling-section/function/Product.js +++ /dev/null @@ -1,46 +0,0 @@ -import React, { Component } from 'react'; - -class Product extends React.Component { - render(){ - let projectUrl = this.props.baseUrlStore+"/p/"+this.props.product.project_id; - const scoreDisplay=( -
    -
    - {(this.props.product.laplace_score/10).toFixed(1) + "%"} -
    -
    -
    -
    -
    - ); - - const productInfoDisplay = ( -
    - {this.props.product.title} - {this.props.product.cat_title} - {this.props.product.updated_at} -
    - ); - - - return ( -
    - -
    - {productInfoDisplay} -
    -
    - {scoreDisplay} -
    -
    - ) - } -} - -export default Product; diff --git a/httpdocs/theme/react/webpack.config.js b/httpdocs/theme/react/webpack.config.js index 4e68784f7..6f26a227d 100644 --- a/httpdocs/theme/react/webpack.config.js +++ b/httpdocs/theme/react/webpack.config.js @@ -1,29 +1,29 @@ module.exports = { entry: { //'metaheader':'./src/entry-metaheader.js', //'metaheader-local':'./src/entry-metaheader-local.js', //'home-main-container':'./src/entry-home-main-container.js' - 'pling-section':'./src/entry-pling-section.js' + //'pling-section':'./src/entry-pling-section.js' }, output: { path: `${__dirname}/bundle`, filename: '[name]-bundle.js' }, module: { rules: [ { test: /\.jsx?$/, use: { loader: 'babel-loader', options: { presets: [ '@babel/preset-env', '@babel/preset-react' ] } }, exclude: /node_modules/ } ] } };