Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

Commit

Permalink
Update to krinkle/toollabs-base 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Dec 8, 2018
1 parent 825c01f commit 7a44e71
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 86 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
@@ -0,0 +1,2 @@
/public_html/base
/vendor
12 changes: 12 additions & 0 deletions .eslintrc.yml
@@ -0,0 +1,12 @@
extends: semistandard
parserOptions:
ecmaVersion: 5
env:
es6: false
node: false
browser: true
globals:
jQuery: false
KRINKLE: false
rules:
one-var: 0
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,3 +1,5 @@
vendor
node_modules
composer.lock
config.php
package-lock.json
16 changes: 0 additions & 16 deletions .jshintrc

This file was deleted.

12 changes: 5 additions & 7 deletions .travis.yml
@@ -1,14 +1,12 @@
sudo: false
language: php
php:
- "5.6"
- "5.5"
- "hhvm"
- "7.2"
- "7.1"
install:
- composer install
# Upgrade default Node.js version in Travis' PHP image from Node.js v0.10.x to 8.x
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash;
- source ~/.nvm/nvm.sh; nvm install 8
script:
- composer test
notifications:
irc:
channels:
- "chat.freenode.net##krinkle"
12 changes: 8 additions & 4 deletions composer.json
@@ -1,12 +1,16 @@
{
"require": {
"Krinkle/toollabs-base": "~0.7.0",
"Krinkle/intuition": "~0.2.1"
"php": ">=7.0",
"Krinkle/toollabs-base": "1.0.2",
"Krinkle/intuition": "^1.2.0"
},
"require-dev": {
"jakub-onderka/php-parallel-lint": "0.9.*"
"jakub-onderka/php-parallel-lint": "^1.0.0"
},
"scripts": {
"test": "parallel-lint . --exclude vendor"
"test": [
"parallel-lint . --exclude vendor",
"npm install && npm test"
]
}
}
15 changes: 15 additions & 0 deletions package.json
@@ -0,0 +1,15 @@
{
"private": true,
"scripts": {
"test": "eslint ."
},
"devDependencies": {
"eslint": "^5.4.0",
"eslint-config-semistandard": "^12.0.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.0",
"eslint-plugin-standard": "^3.1.0"
}
}
8 changes: 3 additions & 5 deletions public_html/index.php
Expand Up @@ -2,8 +2,7 @@
/**
* Main index
*
* @author Timo Tijhof, 2011-2015
* @license http://krinkle.mit-license.org/
* @copyright 2011-2018 Timo Tijhof
* @package wmf-tool-wikiinfo
*/

Expand All @@ -13,17 +12,16 @@
*/

require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../config.php';
require_once __DIR__ . '/../class.php';

$tool = new WikiInfoTool();
require_once __DIR__ . '/../config.php';

$I18N = new Intuition( 'getwikiapi' );

$kgBase = BaseTool::newFromArray( array(
'displayTitle' => $I18N->msg( 'title' ),
'remoteBasePath' => dirname( $kgConf->getRemoteBase() ). '/',
'revisionId' => '1.5.0',
'remoteBasePath' => dirname( $_SERVER['PHP_SELF'] ),
'styles' => array(
'main.css',
),
Expand Down
107 changes: 53 additions & 54 deletions public_html/main.js
@@ -1,62 +1,61 @@
(function (K, $) {
var $input = $('#ot-form-wikiids'),
$submit = $('#ot-form-submit'),
$form = $('#ot-form'),
resultNode = $('#ot-result')[0],
lastVal,
jqXhr;
var $input = $('#ot-form-wikiids'),
$submit = $('#ot-form-submit'),
$form = $('#ot-form'),
resultNode = $('#ot-result')[0],
lastVal,
jqXhr;

function handleInput(val) {
if (jqXhr) {
return;
}
function handleInput (val) {
if (jqXhr) {
return;
}

val = $.trim(val);
if (!val) {
return;
}
val = $.trim(val);
if (!val) {
return;
}

// Ensure de-duplication between submit-click and
// input-blur, and input-change and input-blur.
if (val === lastVal) {
return;
}
lastVal = val;
// Ensure de-duplication between submit-click and
// input-blur, and input-change and input-blur.
if (val === lastVal) {
return;
}
lastVal = val;

$submit.prop('disabled', true).addClass('ot-is-active');
$form.addClass('ot-is-active');
jqXhr = $.ajax({
url: K.baseTool.basePath,
type: 'POST',
data: {
format: '_tool',
_tool: 'ajax',
wikiids: val
},
dataType: 'html'
}).done(function (html) {
resultNode.innerHTML = html;
if (history.replaceState) {
history.replaceState(null, null, './?wikiids=' + val);
}
}).always(function () {
jqXhr = null;
$submit.prop('disabled', false).removeClass('ot-is-active');
$form.removeClass('ot-is-active');
}).fail(function () {
$form.submit();
});
}
$submit.prop('disabled', true).addClass('ot-is-active');
$form.addClass('ot-is-active');
jqXhr = $.ajax({
url: K.baseTool.basePath,
type: 'POST',
data: {
format: '_tool',
_tool: 'ajax',
wikiids: val
},
dataType: 'html'
}).done(function (html) {
resultNode.innerHTML = html;
if (history.replaceState) {
history.replaceState(null, null, './?wikiids=' + val);
}
}).always(function () {
jqXhr = null;
$submit.prop('disabled', false).removeClass('ot-is-active');
$form.removeClass('ot-is-active');
}).fail(function () {
$form.submit();
});
}

$input.on('change blur', function () {
handleInput(this.value);
});

$submit.on('click', function (e) {
handleInput($input.val());
e.preventDefault();
})
.addClass('ot-has-spinner')
.append('<span class="ot-spinner"> <i class="glyphicon-spin glyphicon glyphicon-refresh"></i></span>');
$input.on('change blur', function () {
handleInput(this.value);
});

$submit.on('click', function (e) {
handleInput($input.val());
e.preventDefault();
})
.addClass('ot-has-spinner')
.append('<span class="ot-spinner"> <i class="glyphicon-spin glyphicon glyphicon-refresh"></i></span>');
}(KRINKLE, jQuery));

0 comments on commit 7a44e71

Please sign in to comment.