Skip to content

Commit 8c3a701

Browse files
committed
Create
0 parents  commit 8c3a701

13 files changed

+804
-0
lines changed

.gitattributes

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
7+
# Standard to msysgit
8+
*.doc diff=astextplain
9+
*.DOC diff=astextplain
10+
*.docx diff=astextplain
11+
*.DOCX diff=astextplain
12+
*.dot diff=astextplain
13+
*.DOT diff=astextplain
14+
*.pdf diff=astextplain
15+
*.PDF diff=astextplain
16+
*.rtf diff=astextplain
17+
*.RTF diff=astextplain

.gitignore

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Windows image file caches
2+
Thumbs.db
3+
ehthumbs.db
4+
5+
# Folder config file
6+
Desktop.ini
7+
8+
# Recycle Bin used on file shares
9+
$RECYCLE.BIN/
10+
11+
# Windows Installer files
12+
*.cab
13+
*.msi
14+
*.msm
15+
*.msp
16+
17+
# Windows shortcuts
18+
*.lnk
19+
20+
# =========================
21+
# Operating System Files
22+
# =========================
23+
24+
# OSX
25+
# =========================
26+
27+
.DS_Store
28+
.AppleDouble
29+
.LSOverride
30+
31+
# Thumbnails
32+
._*
33+
34+
# Files that might appear in the root of a volume
35+
.DocumentRevisions-V100
36+
.fseventsd
37+
.Spotlight-V100
38+
.TemporaryItems
39+
.Trashes
40+
.VolumeIcon.icns
41+
42+
# Directories potentially created on remote AFP share
43+
.AppleDB
44+
.AppleDesktop
45+
Network Trash Folder
46+
Temporary Items
47+
.apdisk
48+
49+
node_modules
50+
Gruntfile.js
51+
www
52+

.npmignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Gruntfile.js
2+
tasks
3+
node_modules
4+
.idea
5+
.git
6+
/node_modules
7+
test

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
![Logo](admin/samsung.png)
2+
# ioBroker.samsung
3+
=================
4+
5+
6+
## License
7+
The MIT License (MIT)
8+
9+
Copyright (c) 2015 Author Name<[email protected]>
10+
11+
Permission is hereby granted, free of charge, to any person obtaining a copy
12+
of this software and associated documentation files (the "Software"), to deal
13+
in the Software without restriction, including without limitation the rights
14+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
copies of the Software, and to permit persons to whom the Software is
16+
furnished to do so, subject to the following conditions:
17+
18+
The above copyright notice and this permission notice shall be included in
19+
all copies or substantial portions of the Software.
20+
21+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27+
THE SOFTWARE.

admin/index.html

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<html>
2+
3+
<!-- these 4 files always have to be included -->
4+
<link rel="stylesheet" type="text/css" href="../../lib/css/themes/jquery-ui/redmond/jquery-ui.min.css"/>
5+
<script type="text/javascript" src="../../lib/js/jquery-1.11.1.min.js"></script>
6+
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
7+
<script type="text/javascript" src="../../lib/js/jquery-ui-1.10.3.full.min.js"></script>
8+
9+
10+
<!-- optional: use jqGrid
11+
<link rel="stylesheet" type="text/css" href="../../lib/css/jqGrid/ui.jqgrid-4.5.4.css"/>
12+
<script type="text/javascript" src="../../lib/js/jqGrid/jquery.jqGrid-4.5.4.min.js"></script>
13+
<script type="text/javascript" src="../../lib/js/jqGrid/i18n/grid.locale-all.js"></script>
14+
-->
15+
16+
<!-- optional: use multiselect
17+
<link rel="stylesheet" type="text/css" href="../../lib/css/jquery.multiselect-1.13.css"/>
18+
<script type="text/javascript" src="../../lib/js/jquery.multiselect-1.13.min.js"></script>
19+
-->
20+
21+
<!-- these two file always have to be included -->
22+
<link rel="stylesheet" type="text/css" href="../../css/adapter.css"/>
23+
<script type="text/javascript" src="../../js/translate.js"></script>
24+
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
25+
26+
27+
<!-- you have to define 2 functions in the global scope: -->
28+
<script type="text/javascript">
29+
30+
// Dictionary (systemDictionary is global variable from adapter-settings.js)
31+
systemDictionary = {
32+
"samsung adapter settings": {"de": "Samsung Einstellungen", "ru": "Samsung"},
33+
"IP": {"en": "IP", "de": "IP", "ru": "IP"},
34+
"test2": {"en": "Test 2", "de": "Test 2", "ru": "Тест 2"},
35+
"on save adapter restarts with new config immediately": {
36+
"de": "Beim Speichern von Einstellungen der Adapter wird sofort neu gestartet.",
37+
"ru": "Сразу после сохранения настроек драйвер перезапуститься с новыми значениями"
38+
}
39+
};
40+
41+
// the function loadSettings has to exist ...
42+
function load(settings, onChange) {
43+
// example: select elements with id=key and class=value and insert value
44+
for (var key in settings) {
45+
// example: select elements with id=key and class=value and insert value
46+
if ($('#' + key + '.value').attr('type') == 'checkbox') {
47+
$('#' + key + '.value').prop('checked', settings[key]).change(function () {
48+
onChange();
49+
});
50+
} else {
51+
$('#' + key + '.value').val(settings[key]).change(function () {
52+
onChange();
53+
}).keyup(function () {
54+
$(this).trigger('change');
55+
});
56+
}
57+
}
58+
// Signal to admin, that no changes yet
59+
onChange(false);
60+
}
61+
62+
// ... and the function save has to exist.
63+
// you have to make sure the callback is called with the settings object as first param!
64+
function save(callback) {
65+
// example: select elements with class=value and build settings object
66+
var obj = {};
67+
$('.value').each(function () {
68+
var $this = $(this);
69+
obj[$this.attr('id')] = $this.val();
70+
});
71+
callback(obj);
72+
}
73+
</script>
74+
75+
<!-- you have to put your config page in a div with id adapter-container -->
76+
<div id="adapter-container">
77+
78+
<table><tr>
79+
<td><img src="samsung.png"/></td>
80+
<td><h3 class="translate">samsung adapter settings</h3></td>
81+
</tr></table>
82+
<p>
83+
<span class="translate">IP</span> <input class="value" id="IP"/><br>
84+
</p>
85+
86+
<p class="translate">on save adapter restarts with new config immediately</p>
87+
88+
</div>
89+
90+
</html>

admin/samsung.png

2.49 KB
Loading

io-package.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"common": {
3+
"name": "samsung",
4+
"version": "0.0.1",
5+
"title": "Samsung TV Adapter",
6+
"desc": {
7+
"en": "ioBroker samsung Adapter",
8+
"de": "ioBroker Samsung Adapter",
9+
"ru": "ioBroker Samsung драйвер как образец"
10+
},
11+
"platform": "Javascript/Node.js",
12+
"mode": "daemon",
13+
"icon": "samsung.png",
14+
"extIcon": "https://raw.githubusercontent.com/soef/iobroker.samsung/master/admin/samsung.png",
15+
"readme": "https://github.com/ioBroker/ioBroker.samsung/blob/master/README.md",
16+
"loglevel": "info",
17+
"type": "hardware"
18+
},
19+
"native": {
20+
"IP": "192.168.1.63"
21+
},
22+
"objects": [
23+
24+
]
25+
}

lib/utils.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
var controllerDir;
2+
3+
// Get js-controller directory to load libs
4+
function getControllerDir(isInstall) {
5+
var fs = require('fs');
6+
// Find the js-controller location
7+
var controllerDir = __dirname.replace(/\\/g, '/');
8+
controllerDir = controllerDir.split('/');
9+
if (controllerDir[controllerDir.length - 3] == 'adapter') {
10+
controllerDir.splice(controllerDir.length - 3, 3);
11+
controllerDir = controllerDir.join('/');
12+
} else if (controllerDir[controllerDir.length - 3] == 'node_modules') {
13+
controllerDir.splice(controllerDir.length - 3, 3);
14+
controllerDir = controllerDir.join('/');
15+
if (fs.existsSync(controllerDir + '/node_modules/iobroker.js-controller')) {
16+
controllerDir += '/node_modules/iobroker.js-controller';
17+
} else if (fs.existsSync(controllerDir + '/node_modules/ioBroker.js-controller')) {
18+
controllerDir += '/node_modules/ioBroker.js-controller';
19+
} else if (!fs.existsSync(controllerDir + '/controller.js')) {
20+
if (!isInstall) {
21+
console.log('Cannot find js-controller');
22+
process.exit(10);
23+
} else {
24+
process.exit();
25+
}
26+
}
27+
} else {
28+
if (!isInstall) {
29+
console.log('Cannot find js-controller');
30+
process.exit(10);
31+
} else {
32+
process.exit();
33+
}
34+
}
35+
return controllerDir;
36+
}
37+
38+
// Read controller configuration file
39+
function getConfig() {
40+
return JSON.parse(fs.readFileSync(controllerDir + '/conf/iobroker.json'));
41+
}
42+
controllerDir = getControllerDir(typeof process != 'undefined' && process.argv && process.argv.indexOf('--install') != -1);
43+
44+
exports.controllerDir = controllerDir;
45+
exports.getConfig = getConfig;
46+
exports.adapter = require(controllerDir + '/lib/adapter.js');

0 commit comments

Comments
 (0)