code stringlengths 5 1.01M | repo_name stringlengths 5 84 | path stringlengths 4 311 | language stringclasses 30
values | license stringclasses 15
values | size int64 5 1.01M | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|
/**
* @author Iftikhar Ul Hassan
* @date 4/10/17.
*/
const util = require('../util');
module.exports = function (length) {
length = length || 21;
var isValid;
var kidNumber;
do {
kidNumber = util.generateRandomNumber(0, 9, length) + "";
var controlDigit = kidNumber.charAt(kidNumber.length - 1);
isValid = parseInt(controlDigit, 10) === util.mod11(kidNumber) || parseInt(controlDigit, 10) === util.luhnValue(kidNumber);
} while (!isValid);
return kidNumber;
}; | khiftikhar/random-no | lib/no/kid.js | JavaScript | mit | 518 | [
30522,
1013,
1008,
1008,
1008,
1030,
3166,
2065,
3775,
22510,
17359,
13222,
1008,
1030,
3058,
1018,
1013,
2184,
1013,
2459,
1012,
1008,
1013,
9530,
3367,
21183,
4014,
1027,
5478,
1006,
1005,
1012,
1012,
1013,
21183,
4014,
1005,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!--Page Header-->
<section class="page_header child_nursing padding-top">
<div class="container">
<div class="row">
<div class="col-md-12 page-content">
<h1>Rural Health Centre</h1>
<div class="page_nav">
<span>You are here:</span> <a href="<?php echo base_url() ?>">Home</a> <span><i class="fa fa-angle-double-right"></i>Rural Health Centre</span>
</div>
</div>
</div>
</div>
</section>
<!--Page Header-->
<!-- Courses -->
<section id="course_all" class="padding-bottom-half padding-top">
<div class="container content-container">
<div class="row">
<div class="col-sm-10 col-sm-offset-1 course_detail wow fadeIn" data-wow-delay="400ms">
<img src="<?php echo base_url() ?>images/community/rural.jpg" alt="Course" class=" border_radius img-responsive bottom15 hero-image">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
Location
</h4>
</div>
</a>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
<p class="bottom25">Chancellor and Founder Dr.N.M.Veeraiyan had the vision for developing the rural community. His idea was to serve the needy people to improve the health status. As a result Accordingly a Rural Health Center was established in the Kuthambakkam village on 12-12-2001 by our honorable Chancellor. It is located at Kuthambakkam Road in Thiruvallur district, just 2 km away from Saveetha Medical College and near to Chennai Bangalore High way Road.
</p>
</div>
</div>
</div>
<div class="panel panel-default">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
Infrastructure
</h4>
</div>
</a>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
<ul class="bottom25">
<li>Reception</li>
<li>Consultation Rooms-2</li>
<li>Clinical Laboratory </li>
<li>Pharmacy</li>
<li>ILR Room</li>
<li>Speciality OPD-2</li>
<li>Labour Room </li>
<li>Ward</li>
<li>Treatment Room</li>
<li>Toilet-5</li>
<li>Store Room</li>
<li>Medical Officer Rest room</li>
<li>Nurses Room</li>
<li>CRRI Rooms-2</li>
</ul>
</div>
</div>
</div>
<div class="panel panel-default">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
<div class="panel-heading" role="tab" id="headingThree">
<h4 class="panel-title">
Floor Plan
</h4>
</div>
</a>
<div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
<div class="panel-body">
<img style="width: 50%;" src="<?php echo base_url() ?>images/rural-floor-plan.jpg" alt="Course" class=" border_radius img-responsive bottom15 hero-image">
</div>
</div>
</div>
<div class="panel panel-default">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseFour" aria-expanded="false" aria-controls="collapseFour">
<div class="panel-heading" role="tab" id="headingThree">
<h4 class="panel-title">
Staffing Pattern
</h4>
</div>
</a>
<div id="collapseFour" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingFour">
<div class="panel-body">
<ul class="bottom25">
<li>1. Medical Officer Incharge -1</li>
<li>2. Asst. Medical Officers -2</li>
<li>3. PHN -1</li>
<li>4. VHN -2</li>
<li>5. Social Worker -1</li>
<li>6. Health Educator -1</li>
<li>7. Lab. Technician -1</li>
<li>8. Sanitary Inspector -1</li>
<li>9. Peon -1</li>
<li>10. Ayah -1</li>
<li>11. Driver -1</li>
</ul>
</div>
</div>
</div>
<div class="panel panel-default">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseFive" aria-expanded="false" aria-controls="collapseFive">
<div class="panel-heading" role="tab" id="headingThree">
<h4 class="panel-title">
Services Rendered
</h4>
</div>
</a>
<div id="collapseFive" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingFive">
<div class="panel-body">
<p class="bottom25">The services rendered by heath centre at free of cost are </p>
<ul class="bottom25">
<li> Preventive & Curative Services</li>
<li> Maternal And Child Welfare Services</li>
<li> Immunization</li>
<li> Family Welfare Programmes</li>
<li> Diagnostic services</li>
<li> Screening,</li>
<li> Minor Ailments</li>
<li> Surveillance Works</li>
<li> Health Awareness</li>
<li> Conduction of camps </li>
<li> Outreach reach at nearby areas</li>
<li> Drugs Issuing and </li>
<li> Referral services to Saveetha Medical College Hospital.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Courses -->
| rutvijkanzaria/scon | application/views/rural.php | PHP | mit | 6,856 | [
30522,
1026,
999,
1011,
1011,
3931,
20346,
1011,
1011,
1028,
1026,
2930,
2465,
1027,
1000,
3931,
1035,
20346,
2775,
1035,
8329,
11687,
4667,
1011,
2327,
1000,
1028,
1026,
4487,
2615,
2465,
1027,
1000,
11661,
1000,
1028,
1026,
4487,
2615,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
namespace Fubber;
class Redirect extends Response {
/**
* Cacheable redirect, but changes the protocol to GET if it is not already.
*/
const MOVED_PERMANENTLY = 301;
/**
* Temporary redirect. Changes the protocol to GET if it is not already.
*/
const TEMPORARY_REDIRECT = 307;
/**
* Cacheable redirect. Keeps protocol, so it allows POST-data to follow.
*/
const PERMANENT_REDIRECT = 308;
public function __construct($targetUri, $status=self::TEMPORARY_REDIRECT) {
parent::__construct($status, ["Location" => $targetUri]);
}
} | frodeborli/fubberframework | src/Fubber/Redirect.php | PHP | mit | 617 | [
30522,
1026,
1029,
25718,
3415,
15327,
11865,
29325,
1025,
2465,
2417,
7442,
6593,
8908,
3433,
1063,
1013,
1008,
1008,
1008,
17053,
3085,
2417,
7442,
6593,
1010,
2021,
3431,
1996,
8778,
2000,
2131,
2065,
2009,
2003,
2025,
2525,
1012,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Function Get-HostsFile {
<#
.SYNOPSIS
Split out the windows HOST file and converts it into a custom object
.DESCRIPTION
Split out the windows HOST file and converts it into a custom object
.PARAMETER InputFile
Use an alternative file instead of the default
.EXAMPLE
Get-HostsFile
.NOTES
For additional information please see my GitHub wiki page
.LINK
https://github.com/My-Random-Thoughts
#>
Param (
$InputFile = "$env:SystemRoot\System32\drivers\etc\hosts"
)
ForEach ($line In (Get-Content -Path $InputFile)) {
If ((-not $line.Trim()) -or ($line.StartsWith('#'))) { Continue }
[string[]]$entry = ($line.Split(' ').Trim())
$result = [pscustomobject]@{
IpAddress = $entry[0].Trim()
Hostname = @()
Comment = ''
}
# Do not start from 0, this should always be the IP address
For ($i = 1; $i -lt $entry.Count; $i++) {
If (-not $entry[$i].Trim()) { Continue }
If ($entry[$i].Trim() -ne '#') {
$result.Hostname += $entry[$i].Trim()
}
Else {
$result.Comment = ($entry[$($i + 1)..$($entry.Count - 1)] -join ' ').Trim()
Break
}
}
Write-Output $result
}
}
| My-Random-Thoughts/Various-Code | Get-HostsFile.ps1 | PowerShell | mit | 1,425 | [
30522,
3853,
2131,
1011,
6184,
8873,
2571,
1063,
1026,
1001,
1012,
19962,
22599,
3975,
2041,
1996,
3645,
3677,
5371,
1998,
19884,
2009,
2046,
1037,
7661,
4874,
1012,
6412,
3975,
2041,
1996,
3645,
3677,
5371,
1998,
19884,
2009,
2046,
1037,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# -*- coding: utf-8 -*-
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@
from google.appengine.ext import db
import mc_unittest
from rogerthat.models import CompressedIntegerListExpando
class TestCase(mc_unittest.TestCase):
l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1]
def setUp(self, datastore_hr_probability=0):
mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability)
class MyModel(db.Expando):
pass
m = MyModel(key_name='test')
m.test = TestCase.l
m.put()
def test_get_custom_prop(self):
class MyModel(CompressedIntegerListExpando):
_attribute_prefix = 'test'
m = MyModel.get_by_key_name('test')
self.assertListEqual(TestCase.l, m.test)
dict_repr = db.to_dict(m)
self.assertTrue(isinstance(dict_repr['test'], basestring))
def test_append(self):
class MyModel(CompressedIntegerListExpando):
_attribute_prefix = 'test'
m = MyModel.get_by_key_name('test')
m.test.append(5)
m.put()
m = MyModel.get_by_key_name('test')
self.assertListEqual(TestCase.l + [5], m.test)
def test_ljust(self):
class MyModel(CompressedIntegerListExpando):
_attribute_prefix = 'test'
m = MyModel.get_by_key_name('test')
print 'Before: %r' % m.test
m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10
print 'After: %r' % m.test
expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0]
print 'Expected: %r' % expected
m.put()
m = MyModel.get_by_key_name('test')
self.assertListEqual(expected, m.test)
| rogerthat-platform/rogerthat-backend | src-test/rogerthat_tests/mobicage/models/test_compressed_int_list.py | Python | apache-2.0 | 2,303 | [
30522,
1001,
1011,
1008,
1011,
16861,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
1001,
9385,
2418,
15453,
2974,
1050,
2615,
1001,
1001,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// MooTools: the javascript framework.
// Load this file's selection again by visiting: http://mootools.net/more/f0c28d76aff2f0ba12270c81dc5e8d18
// Or build this file again with packager using: packager build More/Assets More/Hash.Cookie
/*
---
script: More.js
name: More
description: MooTools More
license: MIT-style license
authors:
- Guillermo Rauch
- Thomas Aylott
- Scott Kyle
- Arian Stolwijk
- Tim Wienk
- Christoph Pojer
- Aaron Newton
- Jacob Thornton
requires:
- Core/MooTools
provides: [MooTools.More]
...
*/
MooTools.More = {
'version': '1.4.0.1',
'build': 'a4244edf2aa97ac8a196fc96082dd35af1abab87'
};
/*
---
script: Assets.js
name: Assets
description: Provides methods to dynamically load JavaScript, CSS, and Image files into the document.
license: MIT-style license
authors:
- Valerio Proietti
requires:
- Core/Element.Event
- /MooTools.More
provides: [Assets]
...
*/
var Asset = {
javascript: function(source, properties){
if (!properties) properties = {};
var script = new Element('script', {src: source, type: 'text/javascript'}),
doc = properties.document || document,
load = properties.onload || properties.onLoad;
delete properties.onload;
delete properties.onLoad;
delete properties.document;
if (load){
if (typeof script.onreadystatechange != 'undefined'){
script.addEvent('readystatechange', function(){
if (['loaded', 'complete'].contains(this.readyState)) load.call(this);
});
} else {
script.addEvent('load', load);
}
}
return script.set(properties).inject(doc.head);
},
css: function(source, properties){
if (!properties) properties = {};
var link = new Element('link', {
rel: 'stylesheet',
media: 'screen',
type: 'text/css',
href: source
});
var load = properties.onload || properties.onLoad,
doc = properties.document || document;
delete properties.onload;
delete properties.onLoad;
delete properties.document;
if (load) link.addEvent('load', load);
return link.set(properties).inject(doc.head);
},
image: function(source, properties){
if (!properties) properties = {};
var image = new Image(),
element = document.id(image) || new Element('img');
['load', 'abort', 'error'].each(function(name){
var type = 'on' + name,
cap = 'on' + name.capitalize(),
event = properties[type] || properties[cap] || function(){};
delete properties[cap];
delete properties[type];
image[type] = function(){
if (!image) return;
if (!element.parentNode){
element.width = image.width;
element.height = image.height;
}
image = image.onload = image.onabort = image.onerror = null;
event.delay(1, element, element);
element.fireEvent(name, element, 1);
};
});
image.src = element.src = source;
if (image && image.complete) image.onload.delay(1);
return element.set(properties);
},
images: function(sources, options){
sources = Array.from(sources);
var fn = function(){},
counter = 0;
options = Object.merge({
onComplete: fn,
onProgress: fn,
onError: fn,
properties: {}
}, options);
return new Elements(sources.map(function(source, index){
return Asset.image(source, Object.append(options.properties, {
onload: function(){
counter++;
options.onProgress.call(this, counter, index, source);
if (counter == sources.length) options.onComplete();
},
onerror: function(){
counter++;
options.onError.call(this, counter, index, source);
if (counter == sources.length) options.onComplete();
}
}));
}));
}
};
/*
---
name: Hash
description: Contains Hash Prototypes. Provides a means for overcoming the JavaScript practical impossibility of extending native Objects.
license: MIT-style license.
requires:
- Core/Object
- /MooTools.More
provides: [Hash]
...
*/
(function(){
if (this.Hash) return;
var Hash = this.Hash = new Type('Hash', function(object){
if (typeOf(object) == 'hash') object = Object.clone(object.getClean());
for (var key in object) this[key] = object[key];
return this;
});
this.$H = function(object){
return new Hash(object);
};
Hash.implement({
forEach: function(fn, bind){
Object.forEach(this, fn, bind);
},
getClean: function(){
var clean = {};
for (var key in this){
if (this.hasOwnProperty(key)) clean[key] = this[key];
}
return clean;
},
getLength: function(){
var length = 0;
for (var key in this){
if (this.hasOwnProperty(key)) length++;
}
return length;
}
});
Hash.alias('each', 'forEach');
Hash.implement({
has: Object.prototype.hasOwnProperty,
keyOf: function(value){
return Object.keyOf(this, value);
},
hasValue: function(value){
return Object.contains(this, value);
},
extend: function(properties){
Hash.each(properties || {}, function(value, key){
Hash.set(this, key, value);
}, this);
return this;
},
combine: function(properties){
Hash.each(properties || {}, function(value, key){
Hash.include(this, key, value);
}, this);
return this;
},
erase: function(key){
if (this.hasOwnProperty(key)) delete this[key];
return this;
},
get: function(key){
return (this.hasOwnProperty(key)) ? this[key] : null;
},
set: function(key, value){
if (!this[key] || this.hasOwnProperty(key)) this[key] = value;
return this;
},
empty: function(){
Hash.each(this, function(value, key){
delete this[key];
}, this);
return this;
},
include: function(key, value){
if (this[key] == undefined) this[key] = value;
return this;
},
map: function(fn, bind){
return new Hash(Object.map(this, fn, bind));
},
filter: function(fn, bind){
return new Hash(Object.filter(this, fn, bind));
},
every: function(fn, bind){
return Object.every(this, fn, bind);
},
some: function(fn, bind){
return Object.some(this, fn, bind);
},
getKeys: function(){
return Object.keys(this);
},
getValues: function(){
return Object.values(this);
},
toQueryString: function(base){
return Object.toQueryString(this, base);
}
});
Hash.alias({indexOf: 'keyOf', contains: 'hasValue'});
})();
/*
---
script: Hash.Cookie.js
name: Hash.Cookie
description: Class for creating, reading, and deleting Cookies in JSON format.
license: MIT-style license
authors:
- Valerio Proietti
- Aaron Newton
requires:
- Core/Cookie
- Core/JSON
- /MooTools.More
- /Hash
provides: [Hash.Cookie]
...
*/
Hash.Cookie = new Class({
Extends: Cookie,
options: {
autoSave: true
},
initialize: function(name, options){
this.parent(name, options);
this.load();
},
save: function(){
var value = JSON.encode(this.hash);
if (!value || value.length > 4096) return false; //cookie would be truncated!
if (value == '{}') this.dispose();
else this.write(value);
return true;
},
load: function(){
this.hash = new Hash(JSON.decode(this.read(), true));
return this;
}
});
Hash.each(Hash.prototype, function(method, name){
if (typeof method == 'function') Hash.Cookie.implement(name, function(){
var value = method.apply(this.hash, arguments);
if (this.options.autoSave) this.save();
return value;
});
});
| donatj/CorpusPHP | Source/js/mootools.more.js | JavaScript | mit | 7,181 | [
30522,
1013,
1013,
9587,
11439,
27896,
1024,
1996,
9262,
22483,
7705,
1012,
1013,
1013,
7170,
2023,
5371,
1005,
1055,
4989,
2153,
2011,
5873,
1024,
8299,
1024,
1013,
1013,
9587,
11439,
27896,
1012,
5658,
1013,
2062,
1013,
1042,
2692,
2278,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
var path = require('path');
var fs = require('fs')
var http = require('http')
var url = require('url')
var mime = require('./mime').types
var config = require("./config");
var zlib = require("zlib")
var utils = require("./utils")
var port = 8089;
var server = http.createServer(function(request, response){
var pathname = url.parse(request.url).pathname;
var realpath = path.join("assets", path.normalize(pathname.replace(/\.\./g, "")))
var ext = path.extname(realpath)
ext = ext ? ext.slice(1):"unknown"
var contentType = mime[ext] || "text/plain"
fs.exists(realpath, function(exists) {
if (!exists) {
response.writeHead(404, {
'Content-Type': 'text/plain'
})
response.write("This request URL " + pathname + "was not found on this server");
response.end();
} else {
response.setHeader("Content-Type",contentType);
var stats = fs.statSync(realpath);
if (request.headers["range"]) {
var range = utils.parseRange(request.headers["range"], stats.size);
if (range) {
response.setHeader("Content-Range", "bytes " + range.start + "-" + range.end + "/" + stats.size);
response.setHeader("Content-Length", (range.end - range.start + 1));
var stream = fs.createReadStream(realpath, {
"start": range.start,
"end": range.end
});
response.writeHead('206', "Partial Content");
stream.pipe(response);
} else {
response.removeHeader("Content-Length");
response.writeHead(416, "Request Range Not Satisfiable");
response.end();
}
} else {
var stream = fs.createReadStream(realpath);
response.writeHead('200', "Partial Content");
stream.pipe(response);
}
}
})
})
server.listen(port)
| huang303513/Debug-Instruments | 视频断点播放/app.js | JavaScript | apache-2.0 | 2,168 | [
30522,
13075,
4130,
1027,
5478,
1006,
1005,
4130,
1005,
1007,
1025,
13075,
1042,
2015,
1027,
5478,
1006,
1005,
1042,
2015,
1005,
1007,
13075,
8299,
1027,
5478,
1006,
1005,
8299,
1005,
1007,
13075,
24471,
2140,
1027,
5478,
1006,
1005,
24471,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
version https://git-lfs.github.com/spec/v1
oid sha256:505b4ccd47ed9526d0238c6f2d03a343ce476abc1c4aa79a9f22cabcbd0a3c16
size 12575
| yogeshsaroya/new-cdnjs | ajax/libs/require.js/0.22.0/require.min.js | JavaScript | mit | 130 | [
30522,
2544,
16770,
1024,
1013,
1013,
21025,
2102,
1011,
1048,
10343,
1012,
21025,
2705,
12083,
1012,
4012,
1013,
28699,
1013,
1058,
2487,
1051,
3593,
21146,
17788,
2575,
1024,
28952,
2497,
2549,
9468,
2094,
22610,
2098,
2683,
25746,
2575,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# $OpenBSD: cfgmatch.sh,v 1.9 2015/03/03 22:35:19 markus Exp $
# Placed in the Public Domain.
tid="sshd_config match"
pidfile=$OBJ/remote_pid
fwdport=3301
fwd="-L $fwdport:127.0.0.1:$PORT"
echo "ExitOnForwardFailure=yes" >> $OBJ/ssh_config
echo "ExitOnForwardFailure=yes" >> $OBJ/ssh_proxy
start_client()
{
rm -f $pidfile
${SSH} -q -$p $fwd "$@" somehost \
exec sh -c \'"echo \$\$ > $pidfile; exec sleep 100"\' \
>>$TEST_REGRESS_LOGFILE 2>&1 &
client_pid=$!
# Wait for remote end
n=0
while test ! -f $pidfile ; do
sleep 1
n=`expr $n + 1`
if test $n -gt 60; then
kill $client_pid
fatal "timeout waiting for background ssh"
fi
done
}
stop_client()
{
pid=`cat $pidfile`
if [ ! -z "$pid" ]; then
kill $pid
fi
wait
}
cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
echo "PermitOpen 127.0.0.1:1" >>$OBJ/sshd_config
echo "Match Address 127.0.0.1" >>$OBJ/sshd_config
echo "PermitOpen 127.0.0.1:$PORT" >>$OBJ/sshd_config
grep -v AuthorizedKeysFile $OBJ/sshd_proxy_bak > $OBJ/sshd_proxy
echo "AuthorizedKeysFile /dev/null" >>$OBJ/sshd_proxy
echo "PermitOpen 127.0.0.1:1" >>$OBJ/sshd_proxy
echo "Match user $USER" >>$OBJ/sshd_proxy
echo "AuthorizedKeysFile /dev/null $OBJ/authorized_keys_%u" >>$OBJ/sshd_proxy
echo "Match Address 127.0.0.1" >>$OBJ/sshd_proxy
echo "PermitOpen 127.0.0.1:$PORT" >>$OBJ/sshd_proxy
start_sshd
#set -x
# Test Match + PermitOpen in sshd_config. This should be permitted
for p in ${SSH_PROTOCOLS}; do
trace "match permitopen localhost proto $p"
start_client -F $OBJ/ssh_config
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true || \
fail "match permitopen permit proto $p"
stop_client
done
# Same but from different source. This should not be permitted
for p in ${SSH_PROTOCOLS}; do
trace "match permitopen proxy proto $p"
start_client -F $OBJ/ssh_proxy
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true && \
fail "match permitopen deny proto $p"
stop_client
done
# Retry previous with key option, should also be denied.
cp /dev/null $OBJ/authorized_keys_$USER
for t in ${SSH_KEYTYPES}; do
printf 'permitopen="127.0.0.1:'$PORT'" ' >> $OBJ/authorized_keys_$USER
cat $OBJ/$t.pub >> $OBJ/authorized_keys_$USER
done
for p in ${SSH_PROTOCOLS}; do
trace "match permitopen proxy w/key opts proto $p"
start_client -F $OBJ/ssh_proxy
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true && \
fail "match permitopen deny w/key opt proto $p"
stop_client
done
# Test both sshd_config and key options permitting the same dst/port pair.
# Should be permitted.
for p in ${SSH_PROTOCOLS}; do
trace "match permitopen localhost proto $p"
start_client -F $OBJ/ssh_config
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true || \
fail "match permitopen permit proto $p"
stop_client
done
cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
echo "PermitOpen 127.0.0.1:1 127.0.0.1:$PORT 127.0.0.2:2" >>$OBJ/sshd_proxy
echo "Match User $USER" >>$OBJ/sshd_proxy
echo "PermitOpen 127.0.0.1:1 127.0.0.1:2" >>$OBJ/sshd_proxy
# Test that a Match overrides a PermitOpen in the global section
for p in ${SSH_PROTOCOLS}; do
trace "match permitopen proxy w/key opts proto $p"
start_client -F $OBJ/ssh_proxy
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true && \
fail "match override permitopen proto $p"
stop_client
done
cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
echo "PermitOpen 127.0.0.1:1 127.0.0.1:$PORT 127.0.0.2:2" >>$OBJ/sshd_proxy
echo "Match User NoSuchUser" >>$OBJ/sshd_proxy
echo "PermitOpen 127.0.0.1:1 127.0.0.1:2" >>$OBJ/sshd_proxy
# Test that a rule that doesn't match doesn't override, plus test a
# PermitOpen entry that's not at the start of the list
for p in ${SSH_PROTOCOLS}; do
trace "nomatch permitopen proxy w/key opts proto $p"
start_client -F $OBJ/ssh_proxy
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true || \
fail "nomatch override permitopen proto $p"
stop_client
done
| TigerBSD/TigerBSD | FreeBSD/crypto/openssh/regress/cfgmatch.sh | Shell | isc | 3,915 | [
30522,
1001,
1002,
2330,
5910,
2094,
1024,
12935,
21693,
4017,
2818,
1012,
14021,
1010,
1058,
1015,
1012,
1023,
2325,
1013,
6021,
1013,
6021,
2570,
1024,
3486,
1024,
2539,
23030,
4654,
2361,
1002,
1001,
2872,
1999,
1996,
2270,
5884,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import { Component, Input, OnInit } from '@angular/core';
import { MonitorApiService } from '../../services/monitor-api/monitor-api.service';
import { Monitor } from '../../models/monitor';
@Component({
selector: 'app-monitor-list',
templateUrl: './monitor-list.component.html',
styleUrls: ['./monitor-list.component.scss'],
providers: [MonitorApiService]
})
export class MonitorListComponent implements OnInit {
private isLoading: boolean;
private didLoadingFail: boolean;
private responseStatusCode: any;
private monitors: Monitor[];
private didDeleteMonitorFail: boolean;
private shouldShowDeleteMonitorAlert: boolean;
private deleteMonitorAlertText: string;
constructor(private monitorApiService: MonitorApiService) {
}
ngOnInit() {
this.loadMonitors();
}
private loadMonitors() {
this.isLoading = true;
this.monitorApiService
.getMonitors()
.subscribe(data => {
this.finishLoading(data);
}, err => {
this.onLoadError(err);
});
}
private finishLoading(data) {
this.isLoading = false;
this.didLoadingFail = false;
this.monitors = data;
}
private onLoadError(err) {
this.isLoading = false;
this.didLoadingFail = true;
this.responseStatusCode = err.status;
}
private hasMonitors(): boolean {
return this.monitors && this.monitors.length > 0;
}
private shouldListMonitors(): boolean {
return !this.isLoading
&& !this.didLoadingFail
&& this.monitors
&& this.monitors.length > 0;
}
private getIsActiveText(monitor: Monitor): string {
return monitor.isActive === true ? 'Yes' : 'No';
}
private deleteMonitor(monitor: Monitor) {
if (confirm('Are you sure you want to delete this monitor?')) {
this.monitorApiService
.deleteMonitor(monitor._id)
.subscribe(data => {
console.log('deleted');
this.shouldShowDeleteMonitorAlert = true;
this.didDeleteMonitorFail = false;
this.deleteMonitorAlertText = 'Monitor deleted successfully.';
this.loadMonitors();
}, err => {
this.shouldShowDeleteMonitorAlert = true;
this.didDeleteMonitorFail = true;
this.deleteMonitorAlertText = 'Error occurred when deleting monitor.';
});
}
}
private shouldDisplayDeleteMonitorAlertText(): boolean {
return this.shouldShowDeleteMonitorAlert === true
&& this.deleteMonitorAlertText !== null
&& this.deleteMonitorAlertText !== undefined
&& this.deleteMonitorAlertText.length > 0;
}
}
| meutley/InfraMon | src/app/home/monitor-list/monitor-list.component.ts | TypeScript | mit | 2,586 | [
30522,
12324,
1063,
6922,
1010,
7953,
1010,
2006,
5498,
2102,
1065,
2013,
1005,
1030,
16108,
1013,
4563,
1005,
1025,
12324,
1063,
8080,
9331,
17288,
7903,
2063,
1065,
2013,
1005,
1012,
1012,
1013,
1012,
1012,
1013,
2578,
1013,
8080,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>ActiveJob::Execution</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div class="banner">
<span>Ruby on Rails 4.2.3</span><br />
<h1>
<span class="type">Module</span>
ActiveJob::Execution
</h1>
<ul class="files">
<li><a href="../../files/__/__/__/__/usr/local/lib64/ruby/gems/2_1_0/gems/activejob-4_2_3/lib/active_job/execution_rb.html">/usr/local/lib64/ruby/gems/2.1.0/gems/activejob-4.2.3/lib/active_job/execution.rb</a></li>
</ul>
</div>
<div id="bodyContent">
<div id="content">
<!-- Namespace -->
<div class="sectiontitle">Namespace</div>
<ul>
<li>
<span class="type">MODULE</span>
<a href="Execution/ClassMethods.html">ActiveJob::Execution::ClassMethods</a>
</li>
</ul>
<!-- Method ref -->
<div class="sectiontitle">Methods</div>
<dl class="methods">
<dt>P</dt>
<dd>
<ul>
<li>
<a href="#method-i-perform">perform</a>,
</li>
<li>
<a href="#method-i-perform_now">perform_now</a>
</li>
</ul>
</dd>
</dl>
<!-- Includes -->
<div class="sectiontitle">Included Modules</div>
<ul>
<li>
<a href="../ActiveSupport/Rescuable.html">
ActiveSupport::Rescuable
</a>
</li>
</ul>
<!-- Methods -->
<div class="sectiontitle">Instance Public methods</div>
<div class="method">
<div class="title method-title" id="method-i-perform">
<b>perform</b>(*)
<a href="../../classes/ActiveJob/Execution.html#method-i-perform" name="method-i-perform" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-perform_source')" id="l_method-i-perform_source">show</a>
</p>
<div id="method-i-perform_source" class="dyn-source">
<pre><span class="ruby-comment"># File ../../../../usr/local/lib64/ruby/gems/2.1.0/gems/activejob-4.2.3/lib/active_job/execution.rb, line 38</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">perform</span>(<span class="ruby-operator">*</span>)
<span class="ruby-identifier">fail</span> <span class="ruby-constant">NotImplementedError</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title method-title" id="method-i-perform_now">
<b>perform_now</b>()
<a href="../../classes/ActiveJob/Execution.html#method-i-perform_now" name="method-i-perform_now" class="permalink">Link</a>
</div>
<div class="description">
<p>Performs the job immediately. The job is not sent to the queueing adapter
but directly executed by blocking the execution of others until it's
finished.</p>
<pre><code>MyJob.new(*args).perform_now
</code></pre>
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-perform_now_source')" id="l_method-i-perform_now_source">show</a>
</p>
<div id="method-i-perform_now_source" class="dyn-source">
<pre><span class="ruby-comment"># File ../../../../usr/local/lib64/ruby/gems/2.1.0/gems/activejob-4.2.3/lib/active_job/execution.rb, line 29</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">perform_now</span>
<span class="ruby-identifier">deserialize_arguments_if_needed</span>
<span class="ruby-identifier">run_callbacks</span> <span class="ruby-value">:perform</span> <span class="ruby-keyword">do</span>
<span class="ruby-identifier">perform</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">arguments</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">exception</span>
<span class="ruby-identifier">rescue_with_handler</span>(<span class="ruby-identifier">exception</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">raise</span>(<span class="ruby-identifier">exception</span>)
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
</div>
</div>
</body>
</html> | FiloSpaTeam/thinks | doc/api/classes/ActiveJob/Execution.html | HTML | agpl-3.0 | 6,265 | [
30522,
1026,
1029,
20950,
2544,
1027,
1000,
1015,
1012,
1014,
1000,
17181,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1029,
1028,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hazelcast.client.impl.protocol.task.cache;
import com.hazelcast.cache.impl.CacheClearResponse;
import com.hazelcast.cache.impl.CacheOperationProvider;
import com.hazelcast.cache.impl.operation.CacheRemoveAllOperationFactory;
import com.hazelcast.client.impl.protocol.ClientMessage;
import com.hazelcast.client.impl.protocol.codec.CacheRemoveAllKeysCodec;
import com.hazelcast.instance.impl.Node;
import com.hazelcast.internal.nio.Connection;
import com.hazelcast.internal.serialization.Data;
import com.hazelcast.security.permission.ActionConstants;
import com.hazelcast.security.permission.CachePermission;
import com.hazelcast.spi.impl.operationservice.OperationFactory;
import javax.cache.CacheException;
import java.security.Permission;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* This client request specifically calls {@link CacheRemoveAllOperationFactory} on the server side.
*
* @see CacheRemoveAllOperationFactory
*/
public class CacheRemoveAllKeysMessageTask
extends AbstractCacheAllPartitionsTask<CacheRemoveAllKeysCodec.RequestParameters> {
public CacheRemoveAllKeysMessageTask(ClientMessage clientMessage, Node node, Connection connection) {
super(clientMessage, node, connection);
}
@Override
protected CacheRemoveAllKeysCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) {
return CacheRemoveAllKeysCodec.decodeRequest(clientMessage);
}
@Override
protected ClientMessage encodeResponse(Object response) {
return CacheRemoveAllKeysCodec.encodeResponse();
}
@Override
protected OperationFactory createOperationFactory() {
CacheOperationProvider operationProvider = getOperationProvider(parameters.name);
Set<Data> keys = new HashSet<Data>(parameters.keys);
return operationProvider.createRemoveAllOperationFactory(keys, parameters.completionId);
}
@Override
protected ClientMessage reduce(Map<Integer, Object> map) {
for (Map.Entry<Integer, Object> entry : map.entrySet()) {
if (entry.getValue() == null) {
continue;
}
final CacheClearResponse cacheClearResponse = (CacheClearResponse) nodeEngine.toObject(entry.getValue());
final Object response = cacheClearResponse.getResponse();
if (response instanceof CacheException) {
throw (CacheException) response;
}
}
return null;
}
@Override
public Permission getRequiredPermission() {
return new CachePermission(parameters.name, ActionConstants.ACTION_REMOVE);
}
@Override
public String getDistributedObjectName() {
return parameters.name;
}
@Override
public Object[] getParameters() {
return new Object[]{parameters.keys};
}
@Override
public String getMethodName() {
return "removeAll";
}
}
| emre-aydin/hazelcast | hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/cache/CacheRemoveAllKeysMessageTask.java | Java | apache-2.0 | 3,582 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2263,
1011,
25682,
1010,
14015,
10526,
1010,
4297,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.clockwork.light;
import com.clockwork.export.*;
import com.clockwork.scene.Spatial;
import com.clockwork.util.SortUtil;
import java.io.IOException;
import java.util.*;
/**
* LightList is used internally by Spatial}s to manage
* lights that are attached to them.
*
*/
public final class LightList implements Iterable<Light>, Savable, Cloneable {
private Light[] list, tlist;
private float[] distToOwner;
private int listSize;
private Spatial owner;
private static final int DEFAULT_SIZE = 1;
private static final Comparator<Light> c = new Comparator<Light>() {
/**
* This assumes lastDistance have been computed in a previous step.
*/
public int compare(Light l1, Light l2) {
if (l1.lastDistance < l2.lastDistance)
return -1;
else if (l1.lastDistance > l2.lastDistance)
return 1;
else
return 0;
}
};
/**
* Default constructor for serialisation. Do not use
*/
public LightList(){
}
/**
* Creates a LightList for the given Spatial}.
*
* @param owner The spatial owner
*/
public LightList(Spatial owner) {
listSize = 0;
list = new Light[DEFAULT_SIZE];
distToOwner = new float[DEFAULT_SIZE];
Arrays.fill(distToOwner, Float.NEGATIVE_INFINITY);
this.owner = owner;
}
/**
* Set the owner of the LightList. Only used for cloning.
* @param owner
*/
public void setOwner(Spatial owner){
this.owner = owner;
}
private void doubleSize(){
Light[] temp = new Light[list.length * 2];
float[] temp2 = new float[list.length * 2];
System.arraycopy(list, 0, temp, 0, list.length);
System.arraycopy(distToOwner, 0, temp2, 0, list.length);
list = temp;
distToOwner = temp2;
}
/**
* Adds a light to the list. List size is doubled if there is no room.
*
* @param l
* The light to add.
*/
public void add(Light l) {
if (listSize == list.length) {
doubleSize();
}
list[listSize] = l;
distToOwner[listSize++] = Float.NEGATIVE_INFINITY;
}
/**
* Remove the light at the given index.
*
* @param index
*/
public void remove(int index){
if (index >= listSize || index < 0)
throw new IndexOutOfBoundsException();
listSize --;
if (index == listSize){
list[listSize] = null;
return;
}
for (int i = index; i < listSize; i++){
list[i] = list[i+1];
}
list[listSize] = null;
}
/**
* Removes the given light from the LightList.
*
* @param l the light to remove
*/
public void remove(Light l){
for (int i = 0; i < listSize; i++){
if (list[i] == l){
remove(i);
return;
}
}
}
/**
* @return The size of the list.
*/
public int size(){
return listSize;
}
/**
* @return the light at the given index.
* @throws IndexOutOfBoundsException If the given index is outside bounds.
*/
public Light get(int num){
if (num >= listSize || num < 0)
throw new IndexOutOfBoundsException();
return list[num];
}
/**
* Resets list size to 0.
*/
public void clear() {
if (listSize == 0)
return;
for (int i = 0; i < listSize; i++)
list[i] = null;
if (tlist != null)
Arrays.fill(tlist, null);
listSize = 0;
}
/**
* Sorts the elements in the list acording to their Comparator.
* There are two reasons why lights should be resorted.
* First, if the lights have moved, that means their distance to
* the spatial changed.
* Second, if the spatial itself moved, it means the distance from it to
* the individual lights might have changed.
*
*
* @param transformChanged Whether the spatial's transform has changed
*/
public void sort(boolean transformChanged) {
if (listSize > 1) {
// resize or populate our temporary array as necessary
if (tlist == null || tlist.length != list.length) {
tlist = list.clone();
} else {
System.arraycopy(list, 0, tlist, 0, list.length);
}
if (transformChanged){
// check distance of each light
for (int i = 0; i < listSize; i++){
list[i].computeLastDistance(owner);
}
}
// now merge sort tlist into list
SortUtil.msort(tlist, list, 0, listSize - 1, c);
}
}
/**
* Updates a "world-space" light list, using the spatial's local-space
* light list and its parent's world-space light list.
*
* @param local
* @param parent
*/
public void update(LightList local, LightList parent){
// clear the list as it will be reconstructed
// using the arguments
clear();
while (list.length <= local.listSize){
doubleSize();
}
// add the lights from the local list
System.arraycopy(local.list, 0, list, 0, local.listSize);
for (int i = 0; i < local.listSize; i++){
// list[i] = local.list[i];
distToOwner[i] = Float.NEGATIVE_INFINITY;
}
// if the spatial has a parent node, add the lights
// from the parent list as well
if (parent != null){
int sz = local.listSize + parent.listSize;
while (list.length <= sz)
doubleSize();
for (int i = 0; i < parent.listSize; i++){
int p = i + local.listSize;
list[p] = parent.list[i];
distToOwner[p] = Float.NEGATIVE_INFINITY;
}
listSize = local.listSize + parent.listSize;
}else{
listSize = local.listSize;
}
}
/**
* Returns an iterator that can be used to iterate over this LightList.
*
* @return an iterator that can be used to iterate over this LightList.
*/
public Iterator<Light> iterator() {
return new Iterator<Light>(){
int index = 0;
public boolean hasNext() {
return index < size();
}
public Light next() {
if (!hasNext())
throw new NoSuchElementException();
return list[index++];
}
public void remove() {
LightList.this.remove(--index);
}
};
}
@Override
public LightList clone(){
try{
LightList clone = (LightList) super.clone();
clone.owner = null;
clone.list = list.clone();
clone.distToOwner = distToOwner.clone();
clone.tlist = null; // list used for sorting only
return clone;
}catch (CloneNotSupportedException ex){
throw new AssertionError();
}
}
public void write(CWExporter ex) throws IOException {
OutputCapsule oc = ex.getCapsule(this);
// oc.write(owner, "owner", null);
ArrayList<Light> lights = new ArrayList<Light>();
for (int i = 0; i < listSize; i++){
lights.add(list[i]);
}
oc.writeSavableArrayList(lights, "lights", null);
}
public void read(CWImporter im) throws IOException {
InputCapsule ic = im.getCapsule(this);
// owner = (Spatial) ic.readSavable("owner", null);
List<Light> lights = ic.readSavableArrayList("lights", null);
listSize = lights.size();
// NOTE: make sure the array has a length of at least 1
int arraySize = Math.max(DEFAULT_SIZE, listSize);
list = new Light[arraySize];
distToOwner = new float[arraySize];
for (int i = 0; i < listSize; i++){
list[i] = lights.get(i);
}
Arrays.fill(distToOwner, Float.NEGATIVE_INFINITY);
}
}
| PlanetWaves/clockworkengine | branches/3.0/engine/src/core/com/clockwork/light/LightList.java | Java | apache-2.0 | 8,354 | [
30522,
7427,
4012,
1012,
5119,
6198,
1012,
2422,
1025,
12324,
4012,
1012,
5119,
6198,
1012,
9167,
1012,
1008,
1025,
12324,
4012,
1012,
5119,
6198,
1012,
3496,
1012,
13589,
1025,
12324,
4012,
1012,
5119,
6198,
1012,
21183,
4014,
1012,
4066,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*=============================================================================
Copyright (c) 2002-2003 Joel de Guzman
http://spirit.sourceforge.net/
Use, modification and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
////////////////////////////////////////////////////////////////////////////
//
// Full calculator example demonstrating Phoenix
// This is discussed in the "Closures" chapter in the Spirit User's Guide.
//
// [ JDG 6/29/2002 ]
//
////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <boost/spirit/core.hpp>
#include <boost/spirit/attribute.hpp>
#include <boost/spirit/phoenix/functions.hpp>
#include <iostream>
#include <string>
#include "Main.h"
//#include "bigfp.h"
////////////////////////////////////////////////////////////////////////////
using namespace std;
using namespace boost::spirit;
using namespace phoenix;
////////////////////////////////////////////////////////////////////////////
//
// Our calculator grammar using phoenix to do the semantics
//
// Note: The top rule propagates the expression result (value) upwards
// to the calculator grammar self.val closure member which is
// then visible outside the grammar (i.e. since self.val is the
// member1 of the closure, it becomes the attribute passed by
// the calculator to an attached semantic action. See the
// driver code that uses the calculator below).
//
////////////////////////////////////////////////////////////////////////////
struct calc_closure : boost::spirit::closure<calc_closure, double>
{
member1 val;
};
struct pow_
{
template <typename X, typename Y>
struct result { typedef X type; };
template <typename X, typename Y>
X operator()(X x, Y y) const
{
using namespace std;
return pow(x, y);
}
};
// Notice how power(x, y) is lazily implemented using Phoenix function.
function<pow_> power;
struct calculator : public grammar<calculator, calc_closure::context_t>
{
template <typename ScannerT>
struct definition
{
definition(calculator const& self)
{
top = expression[self.val = arg1];
expression
= term[expression.val = arg1]
>> *( ('+' >> term[expression.val += arg1])
| ('-' >> term[expression.val -= arg1])
)
;
term
= factor[term.val = arg1]
>> *( ('*' >> factor[term.val *= arg1])
| ('/' >> factor[term.val /= arg1])
)
;
factor
= ureal_p[factor.val = arg1]
| '(' >> expression[factor.val = arg1] >> ')'
| ('-' >> factor[factor.val = -arg1])
| ('+' >> factor[factor.val = arg1])
;
}
// const uint_parser<bigint, 10, 1, -1> bigint_parser;
typedef rule<ScannerT, calc_closure::context_t> rule_t;
rule_t expression, term, factor;
rule<ScannerT> top;
rule<ScannerT> const&
start() const { return top; }
};
};
bool DoCalculation(const TCHAR* str, double& result) {
// Our parser
calculator calc;
double n = 0;
parse_info<const wchar_t *> info = parse(str, calc[var(n) = arg1], space_p);
if (info.full) {
result = n;
return true;
}
return false;
}
| Slesa/launchy | old/Launchy_VC7/Plugins/Calcy/Main.cpp | C++ | gpl-2.0 | 3,793 | [
30522,
1013,
1008,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Borreria lagurus S.Moore SPECIES
#### Status
SYNONYM
#### According to
The Catalogue of Life, 3rd January 2011
#### Published in
null
#### Original name
null
### Remarks
null | mdoering/backbone | life/Plantae/Magnoliophyta/Magnoliopsida/Gentianales/Rubiaceae/Spermacoce/Spermacoce lagurus/ Syn. Borreria lagurus/README.md | Markdown | apache-2.0 | 181 | [
30522,
1001,
8945,
14343,
4360,
2474,
27390,
2271,
1055,
1012,
5405,
2427,
1001,
1001,
1001,
1001,
3570,
10675,
1001,
1001,
1001,
1001,
2429,
2000,
1996,
10161,
1997,
2166,
1010,
3822,
2254,
2249,
1001,
1001,
1001,
1001,
2405,
1999,
19701,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
db_config = YAML.load(File.read(ROOT_DIR + '/../config/database.yaml'))['production']
ActiveRecord::Base.establish_connection(db_config)
class Node < ActiveRecord::Base
has_many :cidrs
has_one :limit
def flow_id
self.id + 10
end
def mark_in
$config['iptables']['mark_prefix_in'] + "%04d" % self.id
end
def mark_out
$config['iptables']['mark_prefix_out'] + "%04d" % self.id
end
end
class Cidr < ActiveRecord::Base
belongs_to :node
end
class Limit < ActiveRecord::Base
belongs_to :node
end
| pawelsawicki/onoclea-qos | webapp/lib/database.rb | Ruby | mit | 527 | [
30522,
16962,
1035,
9530,
8873,
2290,
1027,
8038,
19968,
1012,
7170,
1006,
5371,
1012,
3191,
1006,
7117,
1035,
16101,
1009,
1005,
1013,
1012,
1012,
1013,
9530,
8873,
2290,
1013,
7809,
1012,
8038,
19968,
1005,
1007,
1007,
1031,
1005,
2537,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* The LibVMI Library is an introspection library that simplifies access to
* memory in a target virtual machine or in a file containing a dump of
* a system's physical memory. LibVMI is based on the XenAccess Library.
*
* Copyright 2011 Sandia Corporation. Under the terms of Contract
* DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
* retains certain rights in this software.
*
* Author: Bryan D. Payne (bdpayne@acm.org)
* Author: Tamas K Lengyel (tamas.lengyel@zentific.com)
*
* This file is part of LibVMI.
*
* LibVMI is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* LibVMI is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with LibVMI. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XEN_DRIVER_H
#define XEN_DRIVER_H
#if ENABLE_XEN_EVENTS == 1
#include "driver/xen/xen_events.h"
#endif
status_t xen_init(
vmi_instance_t vmi);
status_t xen_init_vmi(
vmi_instance_t vmi);
void xen_destroy(
vmi_instance_t vmi);
uint64_t xen_get_domainid_from_name(
vmi_instance_t vmi,
const char *name);
status_t xen_get_name_from_domainid(
vmi_instance_t vmi,
uint64_t domainid,
char **name);
uint64_t xen_get_domainid(
vmi_instance_t vmi);
void xen_set_domainid(
vmi_instance_t vmi,
uint64_t domainid);
status_t xen_check_domainid(
vmi_instance_t vmi,
uint64_t domainid);
status_t xen_get_domainname(
vmi_instance_t vmi,
char **name);
void xen_set_domainname(
vmi_instance_t vmi,
const char *name);
status_t xen_get_memsize(
vmi_instance_t vmi,
uint64_t *allocated_ram_size,
addr_t *maximum_physical_address);
status_t xen_get_vcpureg(
vmi_instance_t vmi,
uint64_t *value,
reg_t reg,
unsigned long vcpu);
status_t xen_get_vcpuregs(
vmi_instance_t vmi,
registers_t *regs,
unsigned long vcpu);
status_t xen_set_vcpureg(
vmi_instance_t vmi,
uint64_t value,
reg_t reg,
unsigned long vcpu);
status_t xen_set_vcpuregs(
vmi_instance_t vmi,
registers_t *regs,
unsigned long vcpu);
status_t xen_get_address_width(
vmi_instance_t vmi,
uint8_t * width_in_bytes);
void *xen_read_page(
vmi_instance_t vmi,
addr_t page);
status_t xen_write(
vmi_instance_t vmi,
addr_t paddr,
void *buf,
uint32_t length);
int xen_is_pv(
vmi_instance_t vmi);
status_t xen_test(
vmi_instance_t vmi,
uint64_t domainid,
const char *name);
status_t xen_pause_vm(
vmi_instance_t vmi);
status_t xen_resume_vm(
vmi_instance_t vmi);
status_t xen_set_domain_debug_control(
vmi_instance_t vmi,
unsigned long vcpu,
int enable);
status_t xen_create_shm_snapshot(
vmi_instance_t vmi);
status_t xen_destroy_shm_snapshot(
vmi_instance_t vmi);
size_t xen_get_dgpma(
vmi_instance_t vmi,
addr_t paddr,
void** medial_addr_ptr,
size_t count);
static inline status_t
driver_xen_setup(vmi_instance_t vmi)
{
driver_interface_t driver = { 0 };
driver.initialized = true;
driver.init_ptr = &xen_init;
driver.init_vmi_ptr = &xen_init_vmi;
driver.destroy_ptr = &xen_destroy;
driver.get_id_from_name_ptr = &xen_get_domainid_from_name;
driver.get_name_from_id_ptr = &xen_get_name_from_domainid;
driver.get_id_ptr = &xen_get_domainid;
driver.set_id_ptr = &xen_set_domainid;
driver.check_id_ptr = &xen_check_domainid;
driver.get_name_ptr = &xen_get_domainname;
driver.set_name_ptr = &xen_set_domainname;
driver.get_memsize_ptr = &xen_get_memsize;
driver.get_vcpureg_ptr = &xen_get_vcpureg;
driver.get_vcpuregs_ptr = &xen_get_vcpuregs;
driver.set_vcpureg_ptr = &xen_set_vcpureg;
driver.set_vcpuregs_ptr = &xen_set_vcpuregs;
driver.get_address_width_ptr = &xen_get_address_width;
driver.read_page_ptr = &xen_read_page;
driver.write_ptr = &xen_write;
driver.is_pv_ptr = &xen_is_pv;
driver.pause_vm_ptr = &xen_pause_vm;
driver.resume_vm_ptr = &xen_resume_vm;
#if ENABLE_SHM_SNAPSHOT == 1
driver.create_shm_snapshot_ptr = &xen_create_shm_snapshot;
driver.destroy_shm_snapshot_ptr = &xen_destroy_shm_snapshot;
driver.get_dgpma_ptr = &xen_get_dgpma;
#endif
vmi->driver = driver;
return VMI_SUCCESS;
}
#endif /* XEN_DRIVER_H */
| masthoon/libvmi | libvmi/driver/xen/xen.h | C | gpl-3.0 | 4,705 | [
30522,
1013,
1008,
1996,
5622,
2497,
2615,
4328,
3075,
2003,
2019,
17174,
13102,
18491,
3075,
2008,
21934,
24759,
14144,
3229,
2000,
1008,
3638,
1999,
1037,
4539,
7484,
3698,
2030,
1999,
1037,
5371,
4820,
1037,
15653,
1997,
1008,
1037,
2291... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<label style='font-weight: bold; margin-top: 12px; width: auto!important;'><?php echo __("Licence"); ?> : </label>
<select name="licence_<?php echo $file->getId(); ?>" id="licence_<?php echo $file->getId(); ?>" class="licence" rel="<?php echo $file->getId(); ?>">
<option value="-1" <?php echo $preset ? ($preset->getLicenceId() == null ? "selected" : "") : ($file->getLicenceId() == null ? "selected" : ""); ?>><?php echo __("To inform"); ?></option>
<?php foreach($licences as $licence) : ?>
<option value="<?php echo $licence->getId(); ?>" <?php echo $preset ? ($preset->getLicenceId() == $licence->getId() ? "selected" : "") : ($file->getLicenceId() == $licence->getId() ? "selected" : ""); ?>><?php echo $licence->getTitle(); ?></option>
<?php endforeach; ?>
</select>
<div id="div_creative_commons_<?php echo $file->getId(); ?>" <?php echo $preset ? ($preset->getLicenceId() != LicencePeer::__CREATIVE_COMMONS ? "style='display: none;'" : "") : ($file->getLicenceId() != LicencePeer::__CREATIVE_COMMONS ? "style='display: none;'" : ""); ?>>
<div id="creative_commons_img_<?php echo $file->getId(); ?>">
<span>
<a href="javascript: void(0);" class="tooltip" name="<?php echo $preset ? ($preset->getCreativeCommonsId() ? $preset->getCreativeCommons()->getDescription() : "") : ($file->getCreativeCommonsId() ? $file->getCreativeCommons()->getDescription() : ""); ?>">
<img src="<?php echo $preset ? ($preset->getCreativeCommonsId() ? image_path($preset->getCreativeCommons()->getImagePath()) : image_path("creative_commons/cc.jpg")) : ($file->getCreativeCommonsId() ? image_path($file->getCreativeCommons()->getImagePath()) : image_path("creative_commons/cc.jpg")); ?>" />
</a>
</span>
<a href="javascript: void(0);" class="edit-limitation"></a>
</div>
<div id="edit_creative_commons_<?php echo $file->getId(); ?>" style="display: none;">
<select name="creative_commons_select_<?php echo $file->getId(); ?>" id="creative_commons_select_<?php echo $file->getId(); ?>" style="float: left; width: 150px;">
<?php $creative_commons = CreativeCommonsPeer::getCreativeCommons(); ?>
<?php foreach($creative_commons as $creative_common) : ?>
<option value="<?php echo $creative_common->getId(); ?>" <?php echo $preset ? ($preset->getCreativeCommonsId() == $creative_common->getId() ? "selected" : "") : ($file->getCreativeCommonsId() == $creative_common->getId() ? "selected" : ""); ?>><?php echo $creative_common->getTitle(); ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<br clear="all">
<label style='font-weight: bold; margin-top: 12px; width: auto!important;'><?php echo __("Use"); ?> : </label>
<select name="use_<?php echo $file->getId(); ?>" id="use_<?php echo $file->getId(); ?>" class="use" rel="<?php echo $file->getId(); ?>">
<option value="-1" <?php echo $preset ? ($preset->getUsageUseId() == null ? "selected" : "") : ($file->getUsageUseId() == null ? "selected" : ""); ?>><?php echo __("To inform"); ?></option>
<?php foreach($uses as $use) : ?>
<option value="<?php echo $use->getId(); ?>" <?php echo $preset ? ($preset->getUsageUseId() == $use->getId() ? "selected" : "") : ($file->getUsageUseId() == $use->getId() ? "selected" : ""); ?>><?php echo $use->getTitle(); ?></option>
<?php endforeach; ?>
</select>
<br clear="all">
<label style='font-weight: bold; margin-top: 12px; width: auto!important;'><?php echo __("Distribution"); ?> : </label>
<select name="distribution_<?php echo $file->getId(); ?>" id="distribution_<?php echo $file->getId(); ?>" class="distribution" rel="<?php echo $file->getId(); ?>">
<!--<option value="-1" <?php echo $file->getUsageDistributionId() == null ? "selected" : ""; ?>><?php echo __("To inform"); ?></option>-->
<?php foreach($distributions as $distribution) : ?>
<option value="<?php echo $distribution->getId(); ?>" <?php echo $preset ? ($preset->getUsageDistributionId() == $distribution->getId() ? "selected" : "") : ($file->getUsageDistributionId() == $distribution->getId() ? "selected" : ""); ?>><?php echo $distribution->getTitle(); ?></option>
<?php endforeach; ?>
</select>
<div id="div_limitation_<?php echo $file->getId(); ?>" <?php echo $preset ? ($preset->getUsageDistributionId() != UsageDistributionPeer::__AUTH ? "style='display: none;'" : "") : ($file->getUsageDistributionId() != UsageDistributionPeer::__AUTH ? "style='display: none;'" : ""); ?> class="limitation_div">
<label style='font-weight: bold; margin-top: 12px; width: auto!important;'><?php echo __("Distribution restrictions"); ?> : </label>
<ul style="margin-top: 5px;">
<?php foreach($limitations as $limitation) : ?>
<?php $addClass = ""; ?>
<?php $file_right = $preset ? FileRightPeer::retrieveByTypeAndLimitation($preset->getId(), 4, $limitation->getId()) : FileRightPeer::retrieveByTypeAndLimitation($file->getId(), 3, $limitation->getId()); ?>
<?php $value_hidden = $file_right ? $file_right->getValue() : ""; ?>
<li class="text">
<input type="checkbox" name="check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>" value="<?php echo $limitation->getId(); ?>" id="check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>" class="left check_limitation_<?php echo $file->getId(); ?>" style="margin-right: 5px;" <?php echo !empty($value_hidden) ? "checked" : ""; ?> />
<label for="check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>" class="label_limitation">
<?php echo $limitation->getTitle(); ?>
<?php switch($limitation->getUsageTypeId()) :
case UsageTypePeer::__TYPE_BOOLEAN: ?>
<script>
jQuery(document).ready(function() {
if(jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").is(":checked"))
{
var val = jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val();
jQuery(".check_limitation").each(function() {
if(jQuery(this).val() != val)
{
jQuery(this).attr("disabled", "disabled");
jQuery(this).attr("checked", false);
jQuery("#show_limitation_" + jQuery(this).val()).addClass("disabled");
jQuery("#show_limitation_" + jQuery(this).val()).val("");
jQuery("#limitation_" + jQuery(this).val()).val("");
}
});
}
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").bind("click", function() {
var val = jQuery(this).val();
if(jQuery(this).is(":checked"))
{
jQuery("#limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val(1);
jQuery(".check_limitation_<?php echo $file->getId(); ?>").each(function() {
if(jQuery(this).val() != val)
{
jQuery(this).attr("disabled", "disabled");
jQuery(this).attr("checked", false);
jQuery("#show_limitation_" + jQuery(this).val() + "_<?php echo $file->getId(); ?>").addClass("disabled");
jQuery("#show_limitation_" + jQuery(this).val() + "_<?php echo $file->getId(); ?>").val("");
jQuery("#limitation_" + jQuery(this).val() + "_<?php echo $file->getId(); ?>").val("");
}
});
}
else
{
jQuery("#limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val(0);
jQuery(".check_limitation_<?php echo $file->getId(); ?>").each(function() {
if(jQuery(this).val() != val)
jQuery(this).attr("disabled", "");
});
}
});
});
</script>
<?php break;
case UsageTypePeer::__TYPE_TEXT:
$ro = "";
$value_text = $value_hidden; ?>
<script>
jQuery(document).ready(function() {
jQuery("#show_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").bind("blur", function() {
jQuery("#limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val(jQuery(this).val());
if(jQuery(this).val() == "")
{
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").attr("checked", false);
checkLimitation(jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>"), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
}
});
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").bind("click", function() {
checkLimitation(jQuery(this), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
});
});
</script>
<?php break;
case UsageTypePeer::__TYPE_NUM:
$ro = "";
$value_text = $value_hidden; ?>
<script>
jQuery(document).ready(function() {
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").bind("click", function() {
checkLimitation(jQuery(this), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
});
jQuery("#show_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").bind("blur", function() {
jQuery("#limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val(jQuery(this).val());
if(jQuery(this).val() == "")
{
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").attr("checked", false);
checkLimitation(jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>"), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
}
});
jQuery("#show_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").keydown(function(event) {
// Allow: backspace, delete, tab and escape
if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 ||
// Allow: Ctrl+A
(event.keyCode == 65 && event.ctrlKey === true) ||
// Allow: home, end, left, right
(event.keyCode >= 35 && event.keyCode <= 39)) {
// let it happen, don't do anything
return;
}
else
{
// Ensure that it is a number and stop the keypress
if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
event.preventDefault();
}
else if(event.keyCode >= 48 && event.keyCode <= 57)
{
var val = jQuery(this).val();
switch(event.keyCode)
{
case 48: jQuery(this).val(val + "0"); break;
case 49: jQuery(this).val(val + "1"); break;
case 50: jQuery(this).val(val + "2"); break;
case 51: jQuery(this).val(val + "3"); break;
case 52: jQuery(this).val(val + "4"); break;
case 53: jQuery(this).val(val + "5"); break;
case 54: jQuery(this).val(val + "6"); break;
case 55: jQuery(this).val(val + "7"); break;
case 56: jQuery(this).val(val + "8"); break;
case 57: jQuery(this).val(val + "9"); break;
}
event.preventDefault();
}
}
});
});
</script>
<?php break;
case UsageTypePeer::__TYPE_DATE:
$ro = "readonly";
$value_text = $value_hidden;
if(!empty($value_hidden))
{
$temp = explode(" ", $value_hidden);
$date = explode("/", $temp[0]);
if(time() > mktime(0, 0, 0, $date[1], $date[0], $date[2]))
$addClass = 'expired';
} ?>
<a href='javascript: void(0);' class='edit-limitation' id="date_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>"></a>
<script>
jQuery(document).ready(function() {
jQuery.datepicker.setDefaults($.datepicker.regional['<?php echo $sf_user->getCulture(); ?>']);
jQuery("#show_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").datepicker({
showOn: "focus",
currentText: '<?php echo addslashes(__("Now")); ?>',
closeText: '<?php echo __("Save"); ?>',
buttonText: '',
dateFormat: 'dd/mm/yy',
firstDay: 1,
gotoCurrent: true,
minDate: 0,
beforeShow: function(input, inst) {
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").attr("checked", true);
checkLimitation(jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>"), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
},
onClose: function(dateText, inst) {
if(dateText == "")
{
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").attr("checked", false);
checkLimitation(jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>"), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
}
},
onSelect: function(dateText, inst) {
if(dateText != "")
{
var selected = jQuery(this).datepicker('getDate');
var now = new Date();
if(now.getTime() > selected.getTime())
jQuery("#show_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").addClass("expired");
else
jQuery("#show_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").removeClass("expired");
jQuery("#limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val(dateText);
jQuery("#show_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val(dateText);
jQuery(this).datepicker("hide");
}
}
});
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").bind("click", function() {
if(jQuery(this).is(":checked") == true)
jQuery("#show_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").focus();
checkLimitation(jQuery(this), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
});
jQuery("#date_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").bind("click", function() {
jQuery("#show_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").focus();
});
});
</script>
<?php break;
case UsageTypePeer::__TYPE_GEO:
$ro = "readonly";
$value_text = $value_hidden;
if(!empty($value_text))
{
$countries = explode(";", $value_text);
$value_text = "";
$ids = Array();
foreach($countries as $country_id)
{
if(!empty($country_id))
{
$country = CountryPeer::retrieveByPk($country_id);
$value_text .= $country->getTitle().", ";
$ids[] = $country->getId();
}
}
$value_text = substr($value_text, 0, -2);
if($text = ContinentPeer::referToContinent($ids))
$value_text = $text;
} ?>
<a href='javascript: void(0);' class='edit-limitation' id="map_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>"></a>
<script>
jQuery(document).ready(function() {
jQuery("#map_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").bind("click", function() {
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").attr("checked", true);
checkLimitation(jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>"), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
var div = jQuery("<div id='map_dialog'><div style='width: 100%; text-align: center;'><img src='<?php echo image_path('loader-rotate.gif'); ?>' /></div></div>").insertAfter(this);
jQuery(div).dialog({
title: "<span class='first-title'><?php echo __("Select continent / country"); ?></span>",
resizable: false,
draggable: false,
modal: true,
width: "630",
height: "400",
show: 'fade',
hide: 'fade',
buttons: [
{
text: "<?php echo __("Save"); ?>",
click: function() {
var text = "";
var ids = "";
jQuery(".check_country:checked").each(function() {
jQuery("#limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val(jQuery("#limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val() + jQuery(this).val() + ";");
text += jQuery(this).attr("rel") + ", ";
ids += jQuery(this).val() + ";";
});
jQuery(".continent").each(function() {
if(jQuery(this).attr("rel") == ids)
text = jQuery(this).val();
});
jQuery("#show_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val(text);
if(jQuery(".check_country:checked").length == 0)
{
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").attr("checked", false);
checkLimitation(jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>"), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
}
jQuery(this).dialog("close");
}
}
],
open: function(event, ui) {
jQuery.post(
"<?php echo url_for("right/loadGeo"); ?>",
function(data) {
jQuery(div).fadeOut(200, function() {
jQuery(div).html(data);
var ids = jQuery("#limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val().split(";");
for(var i = 0; i < ids.length; i++)
jQuery('.check_country[value="' + ids[i] + '"]').attr("checked", true);
jQuery(".continent").each(function() {
if(jQuery(this).attr("rel") == jQuery("#limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val())
jQuery('#continent_' + jQuery(this).attr('title')).attr('checked', true);
});
jQuery(div).fadeIn();
});
}
);
},
close: function(event, ui) {
if(jQuery(".check_country:checked").length == 0)
{
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").attr("checked", false);
checkLimitation(jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>"), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
}
jQuery(this).remove();
}
});
});
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").bind("click", function() {
if(jQuery(this).is(":checked") == true)
jQuery("#map_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").trigger("click");
checkLimitation(jQuery(this), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
});
});
</script>
<?php break;
case UsageTypePeer::__TYPE_SUPPORT:
$ro = "readonly";
$value_text = $value_hidden;
if(!empty($value_text))
{
$supports = explode(";", $value_text);
$value_text = "";
foreach($supports as $support_id)
{
if(!empty($support_id))
{
$support = UsageSupportPeer::retrieveByPk($support_id);
$value_text .= $support->getTitle().", ";
}
}
$value_text = substr($value_text, 0, -2);
} ?>
<a href='javascript: void(0);' class='edit-limitation' id="support_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>"></a>
<script>
jQuery(document).ready(function() {
jQuery("#support_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").bind("click", function() {
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").attr("checked", true);
checkLimitation(jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>"), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
var div = jQuery("<div id='support_dialog'><div style='width: 100%; text-align: center;'><img src='<?php echo image_path('loader-rotate.gif'); ?>' /></div></div>").insertAfter(this);
jQuery(div).dialog({
title: "<span class='first-title'><?php echo __("Select support"); ?></span>",
resizable: false,
draggable: false,
modal: true,
width: "630",
height: "400",
show: 'fade',
hide: 'fade',
buttons: [
{
text: "<?php echo __("Save"); ?>",
click: function() {
var text = "";
jQuery(".check_support:checked").each(function() {
jQuery("#limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val(jQuery("#limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val() + jQuery(this).val() + ";");
text += jQuery(this).attr("rel") + ", ";
});
jQuery("#show_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val(text);
if(jQuery(".check_support:checked").length == 0)
{
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").attr("checked", false);
checkLimitation(jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>"), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
}
jQuery(this).dialog("close");
}
}
],
open: function(event, ui) {
jQuery.post(
"<?php echo url_for("right/loadSupport"); ?>",
function(data) {
jQuery(div).fadeOut(200, function() {
jQuery(div).html(data);
var ids = jQuery("#limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").val().split(";");
for(var i = 0; i < ids.length; i++)
jQuery('.check_support[value="' + ids[i] + '"]').attr("checked", true);
jQuery(div).fadeIn();
});
}
);
},
close: function(event, ui) {
if(jQuery(".check_support:checked").length == 0)
{
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").attr("checked", false);
checkLimitation(jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>"), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
}
jQuery(this).remove();
}
});
});
jQuery("#check_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").bind("click", function() {
if(jQuery(this).is(":checked") == true)
jQuery("#support_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>").trigger("click");
checkLimitation(jQuery(this), <?php echo $limitation->getId(); ?>, <?php echo $file->getId(); ?>);
});
});
</script>
<?php break;
endswitch; ?>
<input type="hidden" name="limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>" id="limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>" value="<?php echo $value_hidden; ?>" />
<img id="ok_<?php echo $limitation->getId(); ?>" src="<?php echo image_path("icons/accept.png"); ?>" class="ok" />
</label>
<?php if($limitation->getUsageTypeId() != UsageTypePeer::__TYPE_BOOLEAN) : ?>
<br clear="all" />
<input type="text" name="show_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>" id="show_limitation_<?php echo $limitation->getId(); ?>_<?php echo $file->getId(); ?>" <?php echo $ro; ?> style="width: 200px; clear: both;" <?php echo empty($value_hidden) ? 'disabled="true"' : ""; ?> class="<?php echo empty($value_hidden) ? 'disabled' : ""; ?> <?php echo $addClass; ?>" value="<?php echo $value_text; ?>" />
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div> | martin-wikipixel/openDAM | opendam/apps/backend/modules/file/templates/_copyrightSelected.php | PHP | lgpl-3.0 | 25,522 | [
30522,
1026,
3830,
2806,
1027,
1005,
15489,
1011,
3635,
1024,
7782,
1025,
7785,
1011,
2327,
1024,
2260,
2361,
2595,
1025,
9381,
1024,
8285,
999,
2590,
1025,
1005,
1028,
1026,
1029,
25718,
9052,
1035,
1035,
1006,
1000,
11172,
1000,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package org.schabi.newpipe.player;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.AsyncTask;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import org.schabi.newpipe.ActivityCommunicator;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.stream_info.AudioStream;
import org.schabi.newpipe.extractor.stream_info.StreamExtractor;
import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfo;
import org.schabi.newpipe.extractor.stream_info.VideoStream;
import org.schabi.newpipe.playList.NewPipeSQLiteHelper;
import org.schabi.newpipe.settings.NetworkHelper;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.schabi.newpipe.search_fragment.SearchInfoItemFragment.PLAYLIST_ID;
public class LunchAudioTrack {
private final static String TAG = LunchAudioTrack.class.getName();
private final Context activity;
private StreamPreviewInfo info = null;
private Bitmap bitmap = null;
private AudioStream audioStream = null;
private final int playListId;
private boolean hasLoadBitmap = false;
private boolean hasAudioStream = false;
public LunchAudioTrack(final Context activity, @NonNull final StreamPreviewInfo info, final int playListId) {
this.activity = activity;
this.info = info;
this.playListId = playListId;
}
public void retrieveBitmap(final Runnable callback) {
hasLoadBitmap = true;
if (!TextUtils.isEmpty(info.thumbnail_url)) {
ImageLoader.getInstance().loadImage(info.thumbnail_url, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
Log.e(TAG, String.format("FAILED to load bitmap at %s", imageUri), failReason.getCause());
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
Log.d(TAG, String.format("SUCCESS to load bitmap at %s", imageUri));
bitmap = loadedImage;
if(callback != null) {
callback.run();
}
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
}
}
public void retrieveInfoFromService(final Runnable callback) {
hasAudioStream = true;
new AsyncTask<Void, Void, AudioStream>() {
@Override
protected AudioStream doInBackground(Void... voids) {
if(info != null) {
try {
final StreamExtractor extractor = NewPipe.getService(info.service_id)
.getExtractorInstance(info.webpage_url);
try {
final List<AudioStream> audioStreams = extractor.getAudioStreams();
Log.d(TAG, String.format("Found %d audio track for song at %s",
audioStreams.size(), info.webpage_url));
final AudioStream audioStream = audioStreams
.get(getPreferredAudioStreamId(audioStreams));
Log.d(TAG, String.format("Url for track at %s\r\n%s", info.webpage_url,
audioStream));
return audioStream;
} catch (ParsingException e) {
// fail back convert video to audio
final List<VideoStream> videoStreams = extractor.getVideoStreams();
VideoStream selectedVideoStreamsBest = null;
VideoStream selectedVideoStreamsSmall = null;
int previousResolution = -1;
for (final VideoStream videoStream : videoStreams) {
if ("360p".equals(videoStream.resolution)) {
selectedVideoStreamsBest = videoStream;
}
final int resolution = extractNumberPositiveInteger(videoStream.resolution);
if (previousResolution == -1 || resolution < previousResolution) {
previousResolution = resolution;
selectedVideoStreamsSmall = videoStream;
}
}
// check if we use wifi or not for avoid big download data on mobile network
final boolean isConnectedByWifi = NetworkHelper.isOnlineByWifi(activity);
final VideoStream videoStream = isConnectedByWifi &&
selectedVideoStreamsBest != null ?
selectedVideoStreamsBest : selectedVideoStreamsSmall;
if(videoStream == null) {
return null;
}
Log.w(TAG, String.format("No audio track found, use fallback process " +
"convert to AudioStream the video item (%s - %s)",
MediaFormat.getMimeById(videoStream.format),
videoStream.resolution));
return new AudioStream(videoStream.url, videoStream.format, -1, -1);
}
} catch (Exception e) {
Log.e(TAG, "FAILED to found a proper audioStream value!", e);
return null;
}
} else {
return null;
}
}
private int extractNumberPositiveInteger(final String str) {
final Matcher m = Pattern.compile("[0-9]+").matcher(str);
return m.find() ? Integer.parseInt(m.group()) : -1;
}
@Override
protected void onPostExecute(AudioStream preferedAudioStream) {
super.onPostExecute(preferedAudioStream);
audioStream = preferedAudioStream;
if(callback != null) {
callback.run();
}
}
}.execute();
}
private int getPreferredAudioStreamId(final List<AudioStream> audioStreams) {
String preferredFormatString = PreferenceManager.getDefaultSharedPreferences(activity)
.getString(activity.getString(R.string.default_audio_format_key), "webm");
int preferredFormat = MediaFormat.WEBMA.id;
switch (preferredFormatString) {
case "webm":
preferredFormat = MediaFormat.WEBMA.id;
break;
case "m4a":
preferredFormat = MediaFormat.M4A.id;
break;
default:
break;
}
for (int i = 0; i < audioStreams.size(); i++) {
if (audioStreams.get(i).format == preferredFormat) {
Log.d(TAG, String.format("Preferred audio format found : %s with id : %d", preferredFormatString, preferredFormat));
return i;
}
}
//todo: make this a proper error
Log.e(TAG, "FAILED to set audioStream value, use the default value 0 !");
return 0;
}
public boolean hasLoadBitmap() {
return hasLoadBitmap;
}
public boolean hasAudioStream() {
return hasAudioStream;
}
public Intent retrieveIntent() {
if (bitmap != null && audioStream != null) {
ActivityCommunicator.getCommunicator().backgroundPlayerThumbnail = bitmap;
final String mime = MediaFormat.getMimeById(audioStream.format);
final Uri uri = Uri.parse(audioStream.url);
final Intent intent = new Intent(activity, BackgroundPlayer.class);
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(uri, mime);
intent.putExtra(BackgroundPlayer.TITLE, info.title);
intent.putExtra(BackgroundPlayer.WEB_URL, info.webpage_url);
intent.putExtra(BackgroundPlayer.SERVICE_ID, info.service_id);
intent.putExtra(PLAYLIST_ID, playListId);
intent.putExtra(NewPipeSQLiteHelper.PLAYLIST_LINK_ENTRIES.POSITION, info.position);
intent.putExtra(BackgroundPlayer.CHANNEL_NAME, info.uploader);
return intent;
} else {
return null;
}
}
public void process(final boolean forcePlay) {
if (!BackgroundPlayer.isRunning || forcePlay) {
if (bitmap != null && audioStream != null) {
activity.startService(retrieveIntent());
} else if (!hasLoadBitmap) {
retrieveBitmap(new Runnable() {
@Override
public void run() {
process(forcePlay);
}
});
} else if (!hasAudioStream) {
retrieveInfoFromService(new Runnable() {
@Override
public void run() {
process(forcePlay);
}
});
}
}
}
}
| BlenderViking/NewPipe | app/src/main/java/org/schabi/newpipe/player/LunchAudioTrack.java | Java | gpl-3.0 | 10,189 | [
30522,
7427,
8917,
1012,
8040,
25459,
2072,
1012,
2047,
24548,
1012,
2447,
1025,
12324,
11924,
1012,
4180,
1012,
6123,
1025,
12324,
11924,
1012,
4180,
1012,
7848,
1025,
12324,
11924,
1012,
8389,
1012,
2978,
2863,
2361,
1025,
12324,
11924,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular.module('messages')
.controller('messageCtrl',['$scope','messages','socket','$stateParams',MessageController])
function MessageController($scope,messages,socket,$stateParams) {
$scope.messages = messages;
$scope.msg = '';
$scope.sendMsg = function() {
socket.sendMsg({content : $scope.msg, to : $stateParams.id});
};
}; | Pranay92/collaborate-client | app/modules/messages/messages.controller.js | JavaScript | mit | 351 | [
30522,
16108,
1012,
11336,
1006,
1005,
7696,
1005,
1007,
1012,
11486,
1006,
1005,
4471,
6593,
12190,
1005,
1010,
1031,
1005,
1002,
9531,
1005,
1010,
1005,
7696,
1005,
1010,
1005,
22278,
1005,
1010,
1005,
1002,
2110,
28689,
5244,
1005,
1010,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package org.apache.geode.cache.query.data;
import java.util.Set;
public class Manager extends Employee {
public int manager_id;
/** Creates a new instance of Manager */
public Manager(String name, int age, int empId, String title, int salary, Set addresses,
int mgrId) {
super(name, age, empId, title, salary, addresses);
manager_id = mgrId;
}
public int getManager_id() {
return manager_id;
}
}
| jdeppe-pivotal/geode | geode-junit/src/main/java/org/apache/geode/cache/query/data/Manager.java | Java | apache-2.0 | 1,221 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
2030,
2062,
12130,
6105,
1008,
10540,
1012,
2156,
1996,
5060,
5371,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
4953,
1008,
9385,
6095,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Slimey - SLIdeshow Microformat Editor - http://slimey.sourceforge.net
* Copyright (C) 2007 - 2008 Ignacio de Soto
*
* Base Action definitions.
*/
/**
* abstract class SlimeyAction - Actions on the editor
* name: name of the action
*/
var SlimeyAction = function(name, slimey) {
this.name = name;
this.slimey = slimey;
}
/**
* returns the action's name.
*/
SlimeyAction.prototype.getName = function() {
return this.name;
}
/**
* base perform() implementation
*/
SlimeyAction.prototype.perform = function() {
}
/**
* base undo() implementation
*/
SlimeyAction.prototype.undo = function() {
}
/*---------------------------------------------------------------------------*/
/**
* class SlimeyInsertAction - Handles insertion of new elements
* tagname: HTML tagname of the element to be inserted
*/
var SlimeyInsertAction = function(slimey, tagname) {
SlimeyAction.call(this, 'insert', slimey);
var elem = this.slimey.editor.getContainer().ownerDocument.createElement(tagname);
/* set element attributes */
elem.slimey = this.slimey;
elem.className = 'slimeyElement';
elem.style.position = 'absolute';
elem.style.left = '40%';
elem.style.top = '30%';
elem.style.lineHeight = '1.';
elem.style.cursor = 'move';
elem.style.fontFamily = 'sans-serif';
elem.style.fontSize = '160%';
elem.style.margin = '0px';
elem.style.padding = '0px';
elem.style.border = '0px';
elem.style.zIndex = 10000;
if (elem.tagName == 'DIV') {
elem.style.left = '5%';
elem.style.top = '15%';
elem.style.width = '90%';
elem.style.height = '10%';
elem.innerHTML = lang("some text");
elem.style.textAlign = 'center';
elem.resizable = true;
elem.editable = true;
} else if (elem.tagName == 'IMG') {
elem.style.width = '20%';
elem.style.height = '20%';
elem.resizable = true;
elem.title = lang("drag the bottom right corner to resize");
} else {
if (elem.tagName == 'UL') {
elem.innerHTML = '<li>' + lang("some text") + '</li>';
} else if (elem.tagName == 'OL') {
elem.innerHTML = '<li>' + lang("some text") + '</li>';
} else {
elem.innerHTML = lang("some text");
}
elem.editable = true;
elem.title = lang("double click to edit content");
}
/* event handlers */
setEventHandler(elem, "mousedown", slimeyDrag);
setEventHandler(elem, "click", slimeyClick);
setEventHandler(elem, "dblclick", slimeyEdit);
setEventHandler(elem, "mouseover", slimeyHighlight);
setEventHandler(elem, "mouseout", slimeyLowshadow);
this.element = elem;
}
/**
* SlimeyInsertAction extends SlimeyAction
*/
SlimeyInsertAction.prototype = new SlimeyAction();
/**
* returns the element created by this action
*/
SlimeyInsertAction.prototype.getElement = function() {
return this.element;
}
/**
* adds the created element to the editor
*/
SlimeyInsertAction.prototype.perform = function() {
this.slimey.editor.getContainer().appendChild(this.element);
}
/**
* removes the created element from the editor
*/
SlimeyInsertAction.prototype.undo = function() {
this.slimey.editor.getContainer().removeChild(this.element);
var selected = this.slimey.editor.getSelected();
if (selected == this.element) {
this.slimey.editor.deselect();
}
}
/*---------------------------------------------------------------------------*/
/**
* class SlimeyEditContentAction - edits the contents of the selected element in the editor
* content: HTML content to set to the element
*/
var SlimeyEditContentAction = function(slimey, content, element) {
SlimeyAction.call(this, 'editContent', slimey);
if (element) {
this.element = element;
} else {
this.element = this.slimey.editor.getSelected();
}
this.content = content;
}
/**
* SlimeyInsertAction extends SlimeyAction
*/
SlimeyEditContentAction.prototype = new SlimeyAction();
/**
* edits the contents of the selected item in the editor
*/
SlimeyEditContentAction.prototype.perform = function() {
this.previousContent = this.element.innerHTML;
this.element.innerHTML = this.content;
}
/**
* restores the elements original content
*/
SlimeyEditContentAction.prototype.undo = function() {
this.element.innerHTML = this.previousContent;
}
/*---------------------------------------------------------------------------*/
/**
* class SlimeyEditStyleAction - edits a style property of the selected element in the editor
* property: CSS property to be modified (i.e. fontFamily)
* value: Value to set to the property (i.e. sans-serif)
*/
var SlimeyEditStyleAction = function(slimey, property, value) {
SlimeyAction.call(this, 'editStyle', slimey);
this.element = this.slimey.editor.getSelected();
this.property = property;
this.value = value;
}
/**
* SlimeyInsertAction extends SlimeyAction
*/
SlimeyEditStyleAction.prototype = new SlimeyAction();
/**
* edits the contents of the selected item in the editor
*/
SlimeyEditStyleAction.prototype.perform = function() {
this.previousValue = this.element.style[this.property];
this.element.style[this.property] = this.value;
}
/**
* restores the elements original content
*/
SlimeyEditStyleAction.prototype.undo = function() {
this.element.style[this.property] = this.previousValue;
}
/*---------------------------------------------------------------------------*/
/**
* class SlimeyDeleteAction - Deletes the selected element
*/
var SlimeyDeleteAction = function(slimey) {
SlimeyAction.call(this, 'delete', slimey);
var selected = this.slimey.editor.getSelected();
this.element = selected;
}
/**
* SlimeyDeleteAction extends SlimeyAction
*/
SlimeyDeleteAction.prototype = new SlimeyAction();
/**
* removes the selected element from the editor
*/
SlimeyDeleteAction.prototype.perform = function() {
this.slimey.editor.getContainer().removeChild(this.element);
this.slimey.editor.deselect();
}
/**
* adds the previously deleted element to the editor
*/
SlimeyDeleteAction.prototype.undo = function() {
this.slimey.editor.getContainer().appendChild(this.element);
}
/*---------------------------------------------------------------------------*/
/**
* class SlimeyMoveAction - Moves the selected element
* newx: new horizontal position
* newy: new vertical position
* oldx: (optional) previous horizontal position if different than current
* oldy: (optional) previous vertical position if different than current
*/
var SlimeyMoveAction = function(slimey, newx, newy, oldx, oldy) {
SlimeyAction.call(this, 'move', slimey);
var selected = this.slimey.editor.getSelected();
this.newx = newx;
this.newy = newy;
if (oldx) {
this.oldx = oldx;
} else {
this.oldx = selected.style.left;
}
if (oldy) {
this.oldy = oldy;
} else {
this.oldy = selected.style.top;
}
this.element = selected;
}
/**
* SlimeyMoveAction extends SlimeyAction
*/
SlimeyMoveAction.prototype = new SlimeyAction();
/**
* moves the selected element to the new position
*/
SlimeyMoveAction.prototype.perform = function() {
this.element.style.left = this.newx;
this.element.style.top = this.newy;
}
/**
* returns the moved element to its original position
*/
SlimeyMoveAction.prototype.undo = function() {
this.element.style.left = this.oldx;
this.element.style.top = this.oldy;
}
/*---------------------------------------------------------------------------*/
/**
* class SlimeyResizeAction - Resizes the selected element
* neww: new width
* newh: new height
* oldw: (optional) previous width if different than current
* oldh: (optional) previous height if different than current
*/
var SlimeyResizeAction = function(slimey, neww, newh, oldw, oldh) {
SlimeyAction.call(this, 'resize', slimey);
var selected = this.slimey.editor.getSelected();
this.neww = neww;
this.newh = newh;
if (oldw) {
this.oldw = oldw;
} else {
this.oldw = selected.style.width;
}
if (oldh) {
this.oldh = oldh;
} else {
this.oldh = selected.style.height;
}
this.element = selected;
}
/**
* SlimeyResizeAction extends SlimeyAction
*/
SlimeyResizeAction.prototype = new SlimeyAction();
/**
* resizes the selected element
*/
SlimeyResizeAction.prototype.perform = function() {
this.element.style.width = this.neww;
this.element.style.height = this.newh;
}
/**
* returns the element to its original size
*/
SlimeyResizeAction.prototype.undo = function() {
this.element.style.width = this.oldw;
this.element.style.height = this.oldh;
}
/*---------------------------------------------------------------------------*/
/**
* class SlimeySendToBackAction - Sends the selected element to the back
*/
var SlimeySendToBackAction = function(slimey) {
SlimeyAction.call(this, 'sendToBack', slimey);
var selected = this.slimey.editor.getSelected();
this.element = selected;
}
/**
* SlimeySendToBackAction extends SlimeyAction
*/
SlimeySendToBackAction.prototype = new SlimeyAction();
/**
* sends the selected element to the back
*/
SlimeySendToBackAction.prototype.perform = function() {
var minZ = 100000000;
for (var elem = this.slimey.editor.getContainer().firstChild; elem; elem = elem.nextSibling) {
if (elem.nodeType == 1) {
thisZ = parseInt(elem.style.zIndex);
if (thisZ < minZ) {
minZ = thisZ;
}
}
}
this.oldZ = this.element.style.zIndex;
this.element.style.zIndex = minZ - 1;
}
/**
* sends the selected element back ot the previous z-index
*/
SlimeySendToBackAction.prototype.undo = function() {
this.element.style.zIndex = this.oldZ;
}
/*---------------------------------------------------------------------------*/
/**
* class SlimeyBringToFrontAction - Brings the selected element to the front
*/
var SlimeyBringToFrontAction = function(slimey) {
SlimeyAction.call(this, 'bringToFront', slimey);
var selected = this.slimey.editor.getSelected();
this.element = selected;
}
/**
* SlimeyBringToFrontAction extends SlimeyAction
*/
SlimeyBringToFrontAction.prototype = new SlimeyAction();
/**
* brings the selected element to the front
*/
SlimeyBringToFrontAction.prototype.perform = function() {
var maxZ = 0;
for (var elem = this.slimey.editor.getContainer().firstChild; elem; elem = elem.nextSibling) {
if (elem.nodeType == 1) {
thisZ = parseInt(elem.style.zIndex);
if (thisZ > maxZ) {
maxZ = thisZ;
}
}
}
this.oldZ = this.element.style.zIndex;
this.element.style.zIndex = maxZ + 1;
}
/**
* returns the element to its original z-index
*/
SlimeyBringToFrontAction.prototype.undo = function() {
this.element.style.zIndex = this.oldZ;
}
/*---------------------------------------------------------------------------*/
/**
* class SlimeyChangeSlideAction - Changes the current slide
* num: Slide number to change to
*/
var SlimeyChangeSlideAction = function(slimey, num) {
SlimeyAction.call(this, 'changeSlide', slimey);
this.num = num;
}
/**
* SlimeyChangeSlideAction extends SlimeyAction
*/
SlimeyChangeSlideAction.prototype = new SlimeyAction();
/**
* changes the current slide
*/
SlimeyChangeSlideAction.prototype.perform = function() {
this.previousSlide = this.slimey.navigation.currentSlide;
this.slimey.navigation.getSlide(this.num);
}
/**
* returns to the previous slide
*/
SlimeyChangeSlideAction.prototype.undo = function() {
this.slimey.navigation.getSlide(this.previousSlide);
}
/*---------------------------------------------------------------------------*/
/**
* class SlimeyInsertSlideAction - Inserts a new slide
* num: Position where to insert the new slide
*/
var SlimeyInsertSlideAction = function(slimey, num) {
SlimeyAction.call(this, 'insertSlide', slimey);
this.num = num;
}
/**
* SlimeyInsertSlideAction extends SlimeyAction
*/
SlimeyInsertSlideAction.prototype = new SlimeyAction();
/**
* insert the new slide
*/
SlimeyInsertSlideAction.prototype.perform = function() {
this.slimey.navigation.insertNewSlide(this.num);
}
/**
* remove the inserted slide
*/
SlimeyInsertSlideAction.prototype.undo = function() {
this.slimey.navigation.deleteSlide(this.num);
}
/*---------------------------------------------------------------------------*/
/**
* class SlimeyDeleteSlideAction - Deletes the current slide
* num: Number of the slide to be deleted
*/
var SlimeyDeleteSlideAction = function(slimey, num) {
SlimeyAction.call(this, 'deleteSlide', slimey);
this.num = num;
}
/**
* SlimeyDeleteSlideAction extends SlimeyAction
*/
SlimeyDeleteSlideAction.prototype = new SlimeyAction();
/**
* delete the current slide
*/
SlimeyDeleteSlideAction.prototype.perform = function() {
this.html = this.slimey.editor.getHTML();
this.dom = document.createElement('div');
this.slimey.editor.getDOM(this.dom);
this.slimey.navigation.deleteSlide(this.num);
}
/**
* reinsert the deleted slide
*/
SlimeyDeleteSlideAction.prototype.undo = function() {
this.slimey.navigation.insertNewSlide(this.num, this.html, this.dom);
}
/*---------------------------------------------------------------------------*/
/**
* class SlimeyMoveSlideAction - Moves the current slide to a new position
* from: Number of the slide to be moved
* to: The new position of the slide
*/
var SlimeyMoveSlideAction = function(slimey, from, to) {
SlimeyAction.call(this, 'moveSlide', slimey);
this.from = from;
this.to = to;
}
/**
* SlimeyMoveSlideAction extends SlimeyAction
*/
SlimeyMoveSlideAction.prototype = new SlimeyAction();
/**
* move the slide to the new position
*/
SlimeyMoveSlideAction.prototype.perform = function() {
this.slimey.navigation.moveSlide(this.from, this.to);
}
/**
* move the slide back to its original position
*/
SlimeyMoveSlideAction.prototype.undo = function() {
this.slimey.navigation.moveSlide(this.to, this.from);
}
/*---------------------------------------------------------------------------*/ | maestrano/fengoffice | public/assets/javascript/slimey/actions.js | JavaScript | agpl-3.0 | 14,292 | [
30522,
1013,
1008,
1008,
11754,
3240,
1011,
14816,
14406,
12702,
14192,
4017,
3559,
1011,
8299,
1024,
1013,
1013,
11754,
3240,
1012,
3120,
29278,
3351,
1012,
5658,
1008,
9385,
1006,
1039,
1007,
2289,
1011,
2263,
22988,
2139,
22768,
1008,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>guest card report</title>
<link rel="stylesheet" type="text/css" href="jquery.contextmenu.css">
<link rel="stylesheet" type="text/css" href="table.css"/>
<link rel="stylesheet" href="grid.css" type="text/css"/>
<link rel="stylesheet" href="formeter.css" type="text/css"/>
<link rel="stylesheet" href="slick.css" type="text/css"/>
<!--<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>-->
<script type="text/javascript" src="java.js"></script>
<script type="text/javascript" src="jquery.contextmenu.js"></script>
<!---->
<script type="text/javascript">
/*
$(document).ready(function(){
$("#contextLocationBtn").click(function(e){$('#contextMenu').menu('show', {
left: e.pageX,
top: e.pageY,
onClick: function(e)
{
alert($(e));
}
});
return false;
});
});*/
</script>
<script>
/*
$("#excelExport").jqxButton({
theme: 'energyblue'
});
$("#excelExport").click(function() {
$("#formatter").formatter('exportdata', 'xls', 'formatter');
});
*/
</script>
<script>
$(document).ready(function() {
$('ul#tools').prepend('<li class="print"><a href="#print">Click me to print</a></li>');
$('ul#tools li.print a').click(function() {
window.print();
return false;
});
});
/*
function check()
{
var columnHeader = [
{id: "Guest Card name", name: "Guest Card Name", field: "Guest Card Name", width: 80, cssClass: "cell-title", formatter: formatter},
{id: "Email Address", name: "Email Address", field: "Email Address", width: 80, cssClass: "cell-title", formatter: formatter},
{id: "Phone No", name: "Phone No", field: "Phone No", width: 80, cssClass: "cell-title", formatter: formatter},
{id: "Received Date", name: "Recevied Date", field: "Received Date", width: 60, cssClass: "cell-title", formatter: formatter},
{id: "Status", name: "Status", field: "Status", width: 90, cssClass: "cell-title", formatter: formatter},
{id: "Move In Property Date", name: "Move In Property Date", field: "Move In Property Date", width: 90, cssClass: "cell-title", formatter: formatter},
{id: "Max Rent", name: "Max Rent", field: "Max Rent", width: 90, cssClass: "cell-title", formatter: formatter},
{id: "Bed & Bath", name: "Bed & Bath", field: "Bed & Bath", width: 120, cssClass: "cell-title", formatter: formatter},
{id: "Pet Preference", name: "Pet Preference", field: "Pet Preference", width: 120, cssClass: "cell-title", formatter: formatter},
];
if(document.getElementById("source").checked==true)
{
var columnHeader = [
{id: "Guest Card name", name: "Guest Card Name", field: "Guest Card Name", width: 80, cssClass: "cell-title", formatter: formatter},
{id: "Email Address", name: "Email Address", field: "Email Address", width: 80, cssClass: "cell-title", formatter: formatter},
{id: "Phone No", name: "Phone No", field: "Phone No", width: 80, cssClass: "cell-title", formatter: formatter},
{id: "Received Date", name: "Recevied Date", field: "Received Date", width: 60, cssClass: "cell-title", formatter: formatter},
{id: "Status", name: "Status", field: "Status", width: 90, cssClass: "cell-title", formatter: formatter},
{id: "Move In Property Date", name: "Move In Property Date", field: "Move In Property Date", width: 90, cssClass: "cell-title", formatter: formatter},
{id: "Max Rent", name: "Max Rent", field: "Max Rent", width: 90, cssClass: "cell-title", formatter: formatter},
{id: "Bed & Bath", name: "Bed & Bath", field: "Bed & Bath", width: 120, cssClass: "cell-title", formatter: formatter},
{id: "Pet Preference", name: "Pet Preference", field: "Pet Preference", width: 120, cssClass: "cell-title", formatter: formatter},
{id: "Source", name: "Source", field: "Source", width: 120, cssClass: "cell-title", formatter: formatter},
];
}
if(document.getElementById("property").checked==true)
{
alert("gujv");
}
grid = new Slick.Grid("#myGrid", data, columnHeader, options);
}
*/
</script>
<style>
}
table
{
border-collapse:collapse;
}
table, td,th
{
border:0px solid #d0e4ef ;
border-collapse:collapse;
background-color:#FFFFFF;
}
th
{
background-color:#f5f5f5;
color:black;
}
.cell-title {
font-weight:normal;
}
.cell-effort-driven {
text-align: center;
}
</style>
</head>
<body>
<div id="contextMenu" class="easyui-menu" style="width:200px;">
<!-- <div ><input name="s" id="source" type="checkbox" value="">Source</div>
<div ><input name="s" id="source" type="checkbox" value="">Guest Card name</div>
<div><input name="p" id="property" type="checkbox" value="">property Information</div>
<div><input name="" type="checkbox" value="">Email Address</div>
<div><input name="" type="checkbox" value="">Phone Number</div>
<div><input name="" type="checkbox" value="">Received Date</div>
<div><input id="unit" type="checkbox" value="">Units Interested In</div> -->
</div>
<div id="container" style="width:1000px;">
<div class="outset-colored">
<div id="header" style="background-color:#d0e4ef;height:150px">
<div id="text2">GUEST CARD <a href="mahesh.php">
<img src="image/1395222267_arrow_state_blue_expanded.png"></a>
<li>
<a href="save.html" class="export">
<img src="image/save.png" alt="save" />
<span class="site"><strong>SAVE</strong></span> </a> </li>
<li>
<a href="email.html" class="export">
<img src="image/emailcom.png" alt="Facebook icon" />
<span class="site"><strong>EMAIL</strong></span> </a> </li>
<li>
<a href="" onClick="window.print(); return true;" class="export">
<img src="image/printcom.png"alt="Twitter icon" />
<span class="site"><strong>PRINT</strong></span> </a> </li>
<li id="excelExport">
<a href="" class="export" id='formatter'>
<img src="image/export.png"alt="expotr icon"/>
<span class="site"><strong >EXPORT</strong></span> </a> </li>
<li>
<a href="filll.html"class="export">
<img src="image/fi.png" alt="gmail icon" />
<span class="site"><strong>FILTER</strong></span> </a> </li>
<li>
<a href="guest card report.html" onClick="javascript:window.location.reload()" class="export">
<img src="image/ref.png" alt="Flickr icon" />
<span class="site"><strong>REFRESH</strong></span> </a> </li>
<h1>
</div>
</div>
<div id="footer" style="background-color:#d0e4ef;clear:both;text-align:left;">
<table border="2" style="border-collapse:collapse;" >
<tr><td>
<div id="myGrid" style="width:988px;height:510px; border-color:#d0e4ef;"></div>
</td>
<td>
<a class="img" id="contextLocationBtn" >
<img src="image/ZA010180635.GIF"/></a><strong></strong>
</div>
</td>
</tr>
</table>
<script src="tab.js"></script>
<script src="jav.js"></script>
<script src="jquery.event.drag-2.2.js"></script>
<script src="slick.core.js"></script>
<script src="slick.formatters.js"></script>
<script src="slick.grid.js"></script>
<script>
// Speed up calls to hasOwnProperty
var hasOwnProperty = Object.prototype.hasOwnProperty;
function isEmpty(obj) {
// null and undefined are "empty"
if (obj == null) return true;
// Assume if it has a length property with a non-zero value
// that that property is correct.
if (obj.length > 0) return false;
if (obj.length === 0) return true;
// Otherwise, does it have any properties of its own?
// Note that this doesn't handle
// toString and valueOf enumeration bugs in IE < 9
for (var key in obj) {
if (hasOwnProperty.call(obj, key)) return false;
}
return true;
}
var setVisibleIndex = 5;
function initDisplay()
{
var columnHeader = [
{id: "Guest_Card_Name", name: "Guest Card Name", field: "Guest Card Name", width: 80, cssClass: "cell-title", formatter: formatter},
{id: "Email Address", name: "Email Address", field: "Email Address", width: 80, cssClass: "cell-title", formatter: formatter},
{id: "Phone No", name: "Phone No", field: "Phone No", width: 80, cssClass: "cell-title", formatter: formatter},
{id: "Received Date", name: "Recevied Date", field: "Received Date", width: 60, cssClass: "cell-title", formatter: formatter},
{id: "Status", name: "Status", field: "Status", width: 90, cssClass: "cell-title", formatter: formatter},
{id: "Move In Property Date", name: "Move In Property Date", field: "Move In Property Date", width: 90, cssClass: "cell-title", formatter: formatter}];
return columnHeader;
}
function constructHeader()
{
var columnHeader = [
{id: "Guest_Card_Name", name: "Guest Card Name", field: "Guest Card Name", width: 80, cssClass: "cell-title", formatter: formatter},
{id: "Email Address", name: "Email Address", field: "Email Address", width: 80, cssClass: "cell-title", formatter: formatter},
{id: "Phone No", name: "Phone No", field: "Phone No", width: 80, cssClass: "cell-title", formatter: formatter},
{id: "Received Date", name: "Recevied Date", field: "Received Date", width: 60, cssClass: "cell-title", formatter: formatter},
{id: "Status", name: "Status", field: "Status", width: 90, cssClass: "cell-title", formatter: formatter},
{id: "Move In Property Date", name: "Move In Property Date", field: "Move In Property Date", width: 90, cssClass: "cell-title", formatter: formatter},
{id: "Max Rent", name: "Max Rent", field: "Max Rent", width: 90, cssClass: "cell-title", formatter: formatter},
{id: "Bed & Bath", name: "Bed & Bath", field: "Bed & Bath", width: 120, cssClass: "cell-title", formatter: formatter},
{id: "Pet Preference", name: "Pet Preference", field: "Pet Preference", width: 120, cssClass: "cell-title", formatter: formatter}
];
return columnHeader;
}
function formatter(row, cell, value, columnDef, dataContext) {
return value;
}
var grid;
var data = new Array();
var options = {
editable: false,
enableAddRow: false,
enableCellNavigation: true,
};
function menuModified(e)
{
var selectedColumns = new Array()
var selectedElements = $(".context-menu-list input:checkbox:checked ");
var count = selectedElements.length;
$(".context-menu-list input:checkbox:checked ").each(function(i, element)
{
var columnName = $(element).val();
var data = {id: columnName, name: columnName, field: columnName, width: 90, cssClass: "cell-title", formatter: formatter};
selectedColumns.push(data);
if (!--count)
{
grid.setColumns(selectedColumns);
}
});
}
$(function () {
var items = new Array();
$.each(constructHeader(), function(i, column){
items.push({name:column.name, value:column.name, type:'checkbox', selected:true, events: {change: menuModified}
});
});
$.contextMenu({
selector: '#contextLocationBtn',
trigger: 'left',
items: items,
sep2: "---------",
callback: function(key, options) {
},
events: {
show: function(opt) {
// this is the trigger element
var $this = this;
// import states from data store
$.contextMenu.setInputValues(opt, $this.data());
// this basically fills the input commands from an object
// like {name: "foo", yesno: true, radio: "3", …}
},
hide: function(opt) {
// this is the trigger element
var $this = this;
// export states to data store
$.contextMenu.getInputValues(opt, $this.data());
// this basically dumps the input commands' values to an object
// like {name: "foo", yesno: true, radio: "3", …}
}
}
});
// $(document.body).on("contextmenu:hide", ".context-menu-item", function(e){
// console.log("focus:", this);
// alert("hide contextmenu event called");
// });
$.contextMenu.setInputValues = function(opt, data) {
if (isEmpty(data)) {
data = {};
$.each(opt.inputs, function(key, item) {
if (key <= setVisibleIndex)
{
item.selected = true;
}
else
{
item.selected = false;
}
});
}
else
{
$.each(opt.inputs, function(key, item) {
item.selected = data[key];
});
}
};
for (var i = 0; i < 5; i++) {
var rowItem = {};
rowItem["Guest Card Name"] = "" + i;
rowItem["Email Address"] = "Bangalore";
rowItem["Phone No"] = "4372928" ;
rowItem["Received Date"] = "12/01/2014";
rowItem["Status"] = "Active ";
rowItem["Move In Property Date"] = "12-03-2014 ";
rowItem["Max Rent"] = "50,000 ";
rowItem["Bed & Bath"] = "2/1.50 ";
rowItem["Pet Preference"] = "Dogs";
rowItem["Source"] = "Dogs";
data.push(rowItem);
}
grid = new Slick.Grid("#myGrid", data, initDisplay(), options);
});
</script>
Help & Training »Make a Suggestion » Find
<input name="textfield" type="text" id="text"style="background:url(image/searchbutton3.gif)no-repeat;background-color:#FFFFFF; background-position:right;border:1px solid #d0e4ef;size=" size="35"200px">
</div>
</div>
</body>
</html>
| tukobit/simplecrud | reports/index.html | HTML | mit | 16,050 | [
30522,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
1000,
4180,
1011,
2828,
1000,
4180,
1027,
1000,
3793,
1013,
16129,
1025,
25869,
13462,
1027,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
2516,
1028... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.catglo.dashplaygroundfree;
import java.util.LinkedList;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
interface MenuExecutor {
void execute();
}
class MenuItem extends Object {
Rect area;
private MenuExecutor executor;
boolean inverted=false;
public MenuItem(Rect r,MenuExecutor executor){
area = r;
this.executor = executor;
}
void go(){
executor.execute();
}
public void invert() {
inverted=true;
}
}
| marchold/DashAndDittosPlayground | PlaygroundFree/src/com/catglo/dashplaygroundfree/MenuExecutor.java | Java | gpl-2.0 | 973 | [
30522,
7427,
4012,
1012,
4937,
23296,
2080,
1012,
11454,
13068,
16365,
23301,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
5799,
9863,
1025,
12324,
11924,
1012,
10439,
1012,
4023,
1025,
12324,
30524,
2978,
2863,
14376,
18908,
10253,
1025,
1232... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html>
<head lang="en">
<title>Atmosphere - Weather Forecast</title>
<base href="/">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="favicon.ico">
<link href="node_modules/bootstrap/dist/css/bootstrap.css" rel="stylesheet" />
<style type="text/css">
body { padding-top: 50px; }
.starter-template {
padding: 80px 15px;
text-align: center;
}
h1 { text-align: center; vertical-align: middle; font-weight: bolder; color: burlywood }
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top navbar-inverse">
<h1>Atmosphere</h1>
</nav>
<angular-app></angular-app>
<script src="node_modules/jquery/dist/jquery.min.js" />
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js" />
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<!-- Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</body>
</html> | DeepakChoudhari/Atmosphere | src/index.html | HTML | mit | 1,509 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
2132,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2516,
1028,
7224,
1011,
4633,
19939,
1026,
1013,
2516,
1028,
1026,
2918,
17850,
12879,
1027,
1000,
1013,
1000,
1028,
1026,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
*
* Author: Sylvain Afchain <safchain@gmail.com>, (C) 2008 - 2013
*
* Copyright: See COPYING file that comes with this distribution
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <stropts.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <linux/netdevice.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
#include <types.h>
#include <mm.h>
#include <hl.h>
#include <misc.h>
#include <xml.h>
#include <log.h>
#include "rdb.h"
#include "options.h"
static char *curr_addr = NULL;
static uint16_t curr_port = 53;
static int _add_addr (LIST *addrs) {
struct rdb_addr_s *addr;
if ((addr = (struct rdb_addr_s *) malloc (sizeof(struct rdb_addr_s))) == NULL)
return -1;
addr->addr = curr_addr;
addr->port = curr_port;
if (hl_list_push(addrs, &addr, sizeof (struct rdb_addr_s *)) == -1)
return -1;
return 0;
}
static int _add_all_addr (LIST *addrs) {
char ip[INET_ADDRSTRLEN];
struct ifconf ifconf;
struct ifreq ifr[50];
struct sockaddr_in *s_in;
int ifs, sock, i;
ifconf.ifc_buf = (char *) ifr;
ifconf.ifc_len = sizeof ifr;
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1)
return -1;
if (ioctl(sock, SIOCGIFCONF, &ifconf) == -1)
return -1;
ifs = ifconf.ifc_len / sizeof(ifr[0]);
for (i = 0; i < ifs; i++) {
s_in = (struct sockaddr_in *) &ifr[i].ifr_addr;
if (!inet_ntop(AF_INET, &s_in->sin_addr, ip, sizeof(ip))) {
LOG_ERR("unable to get address of %s", ifr[i].ifr_name);
return -1;
}
curr_addr = strdup(ip);
if (_add_addr (addrs) == -1) {
LOG_ERR("unable to add address of %s to listener interfaces", ifr[i].ifr_name);
return -1;
}
}
return 0;
}
static int _tag_attr(char *tagname, char *attrname, char *attrvalue, XML_CONFIG *config) {
struct rdb_options_s *options = ((RDB *) config->backptr)->options;
if (strcasecmp(config->xpath, "/nnodes/options/listen") == 0) {
if (strcasecmp(attrname, "port") == 0 && attrvalue) {
curr_port = atoi(attrvalue);
}
else if (strcasecmp(attrname, "addr") == 0 && attrvalue) {
curr_addr = strdup(attrvalue);
}
} else if (strcasecmp(config->xpath, "/nnodes/options/user") == 0) {
if (strcasecmp(attrname, "uid") == 0 && attrvalue) {
options->uid = atoi(attrvalue);
} else if (strcasecmp(attrname, "gid") == 0 && attrvalue) {
options->gid = atoi(attrvalue);
}
} else if (strcasecmp(config->xpath, "/nnodes/options/pid") == 0) {
if (strcasecmp(attrname, "file") == 0 && attrvalue) {
options->pid = strdup(attrvalue);
}
} else if (strcasecmp(config->xpath, "/nnodes/options/threads") == 0) {
if (strcasecmp(attrname, "value") == 0 && attrvalue) {
options->nthreads = atoi(attrvalue);
}
} else if (strcasecmp(config->xpath, "/nnodes/options/log") == 0) {
if (strcasecmp(attrname, "file") == 0 && attrvalue) {
options->log_file = strdup(attrvalue);
}
else if (strcasecmp(attrname, "level") == 0 && attrvalue) {
options->log_level = atoi(attrvalue);
}
else if (strcasecmp(attrname, "maxfile") == 0 && attrvalue) {
options->log_maxfile = atoi(attrvalue);
}
} else if (strcasecmp(config->xpath, "/nnodes/options/websrv") == 0) {
if (strcasecmp(attrname, "xslt") == 0 && attrvalue) {
options->websrv_xslt = strdup(attrvalue);
}
else if (strcasecmp(attrname, "port") == 0 && attrvalue) {
options->websrv_port = atoi(attrvalue);
}
} else if (strcasecmp(config->xpath, "/nnodes/options/geoip") == 0) {
#ifdef HAVE_GEOIP
if (strcasecmp(attrname, "database") == 0 && attrvalue) {
if ((options->gi = GeoIP_open(attrvalue, GEOIP_MEMORY_CACHE)) == NULL) {
LOG_ERR("error opening database %s", attrvalue);
return -1;
}
}
#else
LOG_WARN ("%s\n", "not compiled with geoip");
#endif
}
return 0;
}
static int _tag_open(char *tagname, XML_CONFIG *config) {
RDB *rdb = (RDB *) config->backptr;
if (strcasecmp(config->xpath, "/nnodes/options") == 0) {
if ((rdb->options = calloc(1, sizeof (struct rdb_options_s))) == NULL)
return -1;
}
return 0;
}
static int _tag_close(char *tagname, XML_CONFIG *config) {
RDB *rdb = (RDB *) config->backptr;
if (strcasecmp(config->xpath, "/nnodes/options/listen") == 0) {
if (curr_addr) {
if (! rdb->options->addrs)
if((rdb->options->addrs = hl_list_alloc ()) == NULL)
return -1;
if (strcmp(curr_addr, "0.0.0.0") == 0)
_add_all_addr(rdb->options->addrs);
else
_add_addr (rdb->options->addrs);
}
curr_addr = NULL;
curr_port = 53;
}
return 0;
}
void rdb_options_add_xc(HCODE *xch) {
XML_CALLBACKS xc;
memset(&xc, 0, sizeof(xc));
xc.on_tag_attr = _tag_attr;
xc.on_tag_open = _tag_open;
xc.on_tag_close = _tag_close;
hl_hash_put(xch, "/nnodes/options", &xc, sizeof(XML_CALLBACKS));
}
| safchain/nnodes | src/librdb/options.c | C | gpl-2.0 | 4,752 | [
30522,
1013,
1008,
1008,
1008,
3166,
1024,
25353,
22144,
2378,
10511,
10932,
2078,
1026,
7842,
11329,
10932,
2078,
1030,
20917,
4014,
1012,
4012,
1028,
1010,
1006,
1039,
1007,
2263,
1011,
2286,
1008,
1008,
9385,
1024,
2156,
24731,
5371,
200... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*!
* \file force-atlas-2.c
* Sequential implementation for the Force Atlas 2 spring embedding algorithm.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <limits.h>
#include <assert.h>
#include "force-atlas-2.h"
#include "math.h"
#include "timer.h"
#include "vector.h"
#include "util.h"
/*!
* Calculates the number of neighbours for every node.
* \param[in] g The input graph.
* \param[out] numNeighbours An array containing the out-degree for each node in
* the given graph.
*/
void calcNumNeighbours(Graph* g, unsigned int* numNeighbours);
/*!
* Updates the current force on each vertex with the current gravity.
* \param g The graph on which to apply the update.
* \param forceX Array holding the x-direction forces on each vertex.
* \param forceY Array holding the y-direction forces on each vertex.
* \param deg Array holding the out-degree for each vertex.
*/
void fa2Gravity(Graph* g, float* forceX, float* forceY, unsigned int* deg);
/*!
* Applies repulsion forces on each vertex.
* \param g The graph that contains the vertices on which to apply the repulsion
* forces.
* \param forceX Array holding the x-direction forces on each vertex.
* \param forceY Array holding the y-direction forces on each vertex.
* \param deg Array holding the out-degree of each vertex.
*/
void fa2Repulsion(Graph* g, float* forceX, float* forceY, unsigned int* deg);
/*!
* Applies attraction forces on all pairs of vertices that are connected by an
* edge.
* \param g The graph which holds the vertices and edges on which to apply the
* attraction forces.
* \param forceX Array holding the x-direction forces on each vertex.
* \param forceY Array holding the y-direction forces on each vertex.
*/
void fa2Attraction(Graph* g, float* forceX, float* forceY);
/*!
* Updates the swing value of each vertex in the Graph.
* \param[in] g The graph to update.
* \param[in] forceX Array holding the x-direction forces on each vertex.
* \param[in] forceY Array holding the y-direction forces on each vertex.
* \param[in] oldForceX Array holding the x-direction forces on each vertex for the
* previous iteration.
* \param[in] oldForceY Array holding the y-direction forces on each vertex for the
* previous iteration.
* \param[out] swg An array holding the calculated swing values for each vertex.
*/
void fa2UpdateSwing(Graph* g, float* forceX, float* forceY, float* oldForceX,
float* oldForceY, float* swg);
/*!
* Updates the traction value of each vertex in the Graph.
* \param[in] g The graph to update.
* \param[in] forceX Array holding the x-direction forces on each vertex.
* \param[in] forceY Array holding the y-direction forces on each vertex.
* \param[in] oldForceX Array holding the x-direction forces on each vertex for the
* previous iteration.
* \param[in] oldForceY Array holding the y-direction forces on each vertex for the
* previous iteration.
* \param[out] tra An array holding the calculated traction values for each
* vertex.
*/
void fa2UpdateTract(Graph* g, float* forceX, float* forceY, float* oldForceX,
float* oldForceY, float* tra);
/*!
* Update the swing value of the Graph itself.
* \param[in] g The graph whose swing value should be calculated.
* \param[in] swg The array holding the swing values for each vertex in the
* graph.
* \param[in] deg The array holding the out degree values for each vertex in the
* graph.
* \param[out] gSwing A float pointer where the graph swing value should be
* stored.
*/
void fa2UpdateSwingGraph(Graph* g, float* swg, unsigned int* deg, float* gSwing);
/*!
* Update the traction value of the graph itself.
* \param[in] g The graph whoses traction should be calculated.
* \param[in] tra The array holding the traction values for each vertex in the
* graph.
* \param[in] deg The array holding the out degree values for each vertex in the
* graph.
* \param[out] gTract A float pointer where the graph traction value should be
* stored.
*/
void fa2UpdateTractGraph(Graph* g, float* tra, unsigned int* deg, float* gTract);
/*!
* Updates the speed value of the graph itself.
* \param[in] gSwing The graph swing value.
* \param[in] gTract The graph traction value.
* \param[out] gSpeed The graph speed value.
*/
void fa2UpdateSpeedGraph(float gSwing, float gTract, float* gSpeed);
/*!
* Updates the speed value for each vertex in the graph.
* \param[in] g The graph.
* \param[out] speed The array where the speed values should be stored.
* \param[in] swg The swing values for all vertices in the graph.
* \param[in] forceX The x forces for all vertices in the graph.
* \param[in] forceY The y forces for all vertices in the graph.
* \param[in] gs The graph speed value.
*/
void fa2UpdateSpeed(Graph* g, float* speed, float* swg, float* forceX,
float* forceY, float gs);
/*!
* Updates the displacement value for each vertex in the graph.
* \param[in] g The graph.
* \param[in] speed The array that holds the speed values for each vertex.
* \param[in] forceX The x forces for each vertex in the graph.
* \param[in] forceY The y forces for each vertex in the graph.
* \param[out] dispX The array where the x displacement for each vertex should
* be stored.
* \param[out] dispY The array where the y displacement for each vertex should
* be stored.
*/
void fa2UpdateDisplacement(Graph*, float*, float*, float*, float*, float*);
/*!
* Stores the forces from the current iteration as old forces. Deletes the
* forces from the previous iteration.
*
* \param[in] g The graph.
* \param[in] forceX The x forces of the current iteration.
* \param[in] forceY The y forces of the current iteration.
* \param[out] oldForceX The array that should be used to store the x forces of
* the current iteration.
* \param[out] oldForceY The array that should be used to store the y forces of
* the current iteration.
*/
void fa2SaveOldForces(Graph*, float*, float*, float*, float*);
/*!
* Updates the location of each vertex according to the given displacement.
*
* \param[in] g The graph.
* \param[in] xdisp The array of x displacement values for each vertex.
* \param[in] ydisp The array of y displacement values for each vertex.
*/
void fa2UpdateLocation(Graph* g, float* xdisp, float* ydisp);
void fa2Gravity(Graph* g, float* forceX, float* forceY, unsigned int* deg)
{
if (!g)
return;
for (size_t i = 0; i < g->vertices->numvertices; i++)
{
float vx = g->vertices->vertexXLocs[i];
float vy = g->vertices->vertexYLocs[i];
float vlen = vectorGetLength(vx, vy);
assert(vlen != 0);
vectorInverse(&vx, &vy);
vectorMultiply(&vx, &vy, K_G * (deg[i] + 1) / vlen);
if (i == 0)
{
DEBUG_PRINT("g:%f\n", vx);
}
vectorAdd(&forceX[i], &forceY[i], vx, vy);
}
}
void fa2Repulsion(Graph* g, float* forceX, float* forceY, unsigned int* deg)
{
if (!g)
return;
for (size_t i = 0; i < g->vertices->numvertices; i++)
{
for (size_t j = 0; j < g->vertices->numvertices; j++)
{
if (i == j)
continue;
float vx1 = g->vertices->vertexXLocs[i];
float vy1 = g->vertices->vertexYLocs[i];
float vx2 = g->vertices->vertexXLocs[j];
float vy2 = g->vertices->vertexYLocs[j];
vectorSubtract(&vx1, &vy1, vx2, vy2);
float dist = vectorGetLength(vx1, vy1);
if (dist > 0)
{
vectorNormalize(&vx1, &vy1);
vectorMultiply(&vx1, &vy1,
K_R * (((deg[i] + 1) * (deg[j] + 1)) / dist));
// vectorMultiply(&vx1, &vy1, 0.5);
vectorAdd(&forceX[i], &forceY[i], vx1, vy1);
}
}
}
}
void fa2Attraction(Graph* g, float* forceX, float* forceY)
{
if (!g)
return;
float* vxLocs = g->vertices->vertexXLocs;
float* vyLocs = g->vertices->vertexYLocs;
for (size_t gid = 0; gid < g->vertices->numvertices; gid++)
{
float vx1 = vxLocs[gid];
float vy1 = vyLocs[gid];
// Each thread goes through its array of edges.
unsigned int maxedges = g->edges->numedges[gid];
for (size_t i = 0; i < maxedges; i++)
{
unsigned int index = gid + (g->vertices->numvertices * i);
unsigned int target = g->edges->edgeTargets[index];
if (target == UINT_MAX)
continue;
// Compute attraction force.
float vx2 = vxLocs[target];
float vy2 = vyLocs[target];
vectorSubtract(&vx2, &vy2, vx1, vy1);
// vectorMultiply(&vx2, &vy2, 0.5);
vectorAdd(&forceX[gid], &forceY[gid], vx2, vy2);
if (gid == 0)
{
DEBUG_PRINT("a:%f\t%u\n", vx2, target);
}
}
}
}
// Updates the swing for each vertex, as described in the Force Atlas 2 paper.
void fa2UpdateSwing(Graph* g, float* forceX, float* forceY, float* oldForceX,
float* oldForceY, float* swg)
{
for (size_t i = 0; i < g->vertices->numvertices; i++)
{
float fx = oldForceX[i];
float fy = oldForceY[i];
vectorSubtract(&fx, &fy, forceX[i], forceY[i]);
float vlen = vectorGetLength(fx, fy);
swg[i] = vlen;
}
}
// Updates the traction for each vertex, as described in the Force Atlas 2
// paper.
void fa2UpdateTract(Graph* g, float* forceX, float* forceY, float* oldForceX,
float* oldForceY, float* tra)
{
for (size_t i = 0; i < g->vertices->numvertices; i++)
{
float fx = oldForceX[i];
float fy = oldForceY[i];
vectorAdd(&fx, &fy, forceX[i], forceY[i]);
float vlen = vectorGetLength(fx, fy);
tra[i] = vlen / 2;
}
}
// Calculate the current swing of the graph.
void fa2UpdateSwingGraph(Graph* g, float* swg, unsigned int* deg, float* gswing)
{
*gswing = 0;
for (size_t i = 0; i < g->vertices->numvertices; i++)
{
*gswing += (deg[i] + 1) * swg[i];
}
}
// Calculate the current traction of the graph.
void fa2UpdateTractGraph(Graph* g, float* tra, unsigned int* deg, float* gtract)
{
*gtract = 0;
for (size_t i = 0; i < g->vertices->numvertices; i++)
{
*gtract += (deg[i] + 1) * tra[i];
}
}
void fa2UpdateSpeedGraph(float gswing, float gtract, float* gspeed)
{
float oldSpeed = *gspeed;
if (gswing == 0)
{
gswing = FLOAT_EPSILON;
}
*gspeed = TAU * (gtract / gswing);
if (oldSpeed > 0 && *gspeed > 1.5 * oldSpeed)
{
*gspeed = 1.5 * oldSpeed;
}
}
void fa2UpdateSpeed(Graph* g, float* speed, float* swg, float* forceX,
float* forceY, float gs)
{
for (size_t i = 0; i < g->vertices->numvertices; i++)
{
float vSwg = swg[i];
if (vSwg <= 0)
vSwg = EPSILON;
float vForceLen = vectorGetLength(forceX[i], forceY[i]);
if (vForceLen <= 0)
vForceLen = EPSILON;
speed[i] = K_S * gs / (1 + (gs * sqrt(vSwg)));
}
}
// Save current forces as the previous forces for the next tick.
void fa2SaveOldForces(Graph* g, float* forceX, float* forceY, float* oldForceX,
float* oldForceY)
{
for (size_t i = 0; i < g->vertices->numvertices; i++)
{
oldForceX[i] = forceX[i];
oldForceY[i] = forceY[i];
}
}
void fa2UpdateDisplacement(Graph* g, float* speed, float* forceX, float* forceY,
float* dispX, float* dispY)
{
for (size_t i = 0; i < g->vertices->numvertices; i++)
{
dispX[i] = forceX[i];
dispY[i] = forceY[i];
vectorMultiply(&dispX[i], &dispY[i], speed[i]);
}
}
void fa2UpdateLocation(Graph* g, float* xdisp, float* ydisp)
{
for (size_t i = 0; i < g->vertices->numvertices; i++)
{
g->vertices->vertexXLocs[i] += xdisp[i];
g->vertices->vertexYLocs[i] += ydisp[i];
}
}
/*!
* Runs one iteration of the force atlas 2 spring embedding on the given graph.
*
* \param[in,out] g The graph to use for force atlas 2.
*/
void fa2RunOnce(Graph* g)
{
static int firstRun = 1;
static float* tra = NULL;
static float* swg = NULL;
static float* speed = NULL;
static float* forceX = NULL;
static float* forceY = NULL;
static float* oldForceX = NULL;
static float* oldForceY = NULL;
static float* dispX = NULL;
static float* dispY = NULL;
Timer* timer = timerNew();
float graphSwing = 0.0;
float graphTract = 0.0;
static float graphSpeed = 0.0;
if (firstRun)
{
tra = (float*) calloc(g->vertices->numvertices, sizeof(float));
swg = (float*) calloc(g->vertices->numvertices, sizeof(float));
speed = (float*) calloc(g->vertices->numvertices, sizeof(float));
forceX = (float*) calloc(g->vertices->numvertices, sizeof(float));
forceY = (float*) calloc(g->vertices->numvertices, sizeof(float));
oldForceX = (float*) calloc(g->vertices->numvertices, sizeof(float));
oldForceY = (float*) calloc(g->vertices->numvertices, sizeof(float));
dispX = (float*) calloc(g->vertices->numvertices, sizeof(float));
dispY = (float*) calloc(g->vertices->numvertices, sizeof(float));
firstRun = 0;
}
// Reset forces on vertices to 0.
memset(forceX, 0, sizeof(float) * g->vertices->numvertices);
memset(forceY, 0, sizeof(float) * g->vertices->numvertices);
// Gravity force
startTimer(timer);
fa2Gravity(g, forceX, forceY, g->edges->numedges);
stopTimer(timer);
DEBUG_PRINT_DEVICE(forceX, g->vertices->numvertices);
printTimer(timer, "force: gravity");
// Repulsion between vertices
startTimer(timer);
fa2Repulsion(g, forceX, forceY, g->edges->numedges);
stopTimer(timer);
DEBUG_PRINT_DEVICE(forceX, g->vertices->numvertices);
printTimer(timer, "force: repulsion");
// Attraction on edges
startTimer(timer);
fa2Attraction(g, forceX, forceY);
stopTimer(timer);
DEBUG_PRINT_DEVICE(forceX, g->vertices->numvertices);
printTimer(timer, "force: attraction");
// Calculate speed of vertices.
// Update swing of vertices.
fa2UpdateSwing(g, forceX, forceY, oldForceX, oldForceY, swg);
// Update traction of vertices.
fa2UpdateTract(g, forceX, forceY, oldForceX, oldForceY, tra);
DEBUG_PRINT_DEVICE(forceX, g->vertices->numvertices);
// Update swing of Graph.
fa2UpdateSwingGraph(g, swg, g->edges->numedges, &graphSwing);
// Update traction of Graph.
fa2UpdateTractGraph(g, tra, g->edges->numedges, &graphTract);
// Update speed of Graph.
fa2UpdateSpeedGraph(graphSwing, graphTract, &graphSpeed);
// Update speed of vertices.
fa2UpdateSpeed(g, speed, swg, forceX, forceY, graphSpeed);
// Update displacement of vertices.
fa2UpdateDisplacement(g, speed, forceX, forceY, dispX, dispY);
// Update vertex locations based on speed.
startTimer(timer);
fa2UpdateLocation(g, dispX, dispY);
stopTimer(timer);
printTimer(timer, "moving vertices");
// Set current forces as old forces in vertex data.
fa2SaveOldForces(g, forceX, forceY, oldForceX, oldForceY);
timerClean(timer);
}
void fa2RunOnGraph(Graph* g, unsigned int n)
{
Timer* timer = timerNew();
for (size_t i = 0; i < n; i++)
{
startTimer(timer);
fa2RunOnce(g);
stopTimer(timer);
printTimer(timer, "embedding iteration");
}
timerClean(timer);
}
| DSRC-GPU/Accelerated-Pipeline | src/force-atlas-2.c | C | mit | 14,877 | [
30522,
1013,
1008,
999,
1008,
1032,
5371,
2486,
1011,
11568,
1011,
1016,
1012,
1039,
1008,
25582,
7375,
2005,
1996,
2486,
11568,
1016,
3500,
7861,
8270,
4667,
9896,
1012,
1008,
1013,
1001,
2421,
1026,
2358,
20617,
1012,
1044,
1028,
1001,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "radialActuationDiskSource.H"
#include "geometricOneField.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(radialActuationDiskSource, 0);
addToRunTimeSelectionTable
(
option,
radialActuationDiskSource,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::radialActuationDiskSource::radialActuationDiskSource
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
actuationDiskSource(name, modelType, dict, mesh),
radialCoeffs_(coeffs_.lookup("coeffs"))
{
Info<< " - creating radial actuation disk zone: " << name_ << endl;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fv::radialActuationDiskSource::addSup
(
fvMatrix<vector>& eqn,
const label fieldI
)
{
const scalargpuField& cellsV = mesh_.V().getField();
vectorgpuField& Usource = eqn.source();
const vectorgpuField& U = eqn.psi();
if (V_ > VSMALL)
{
addRadialActuationDiskAxialInertialResistance
(
Usource,
cells_,
cellsV,
geometricOneField(),
U
);
}
}
void Foam::fv::radialActuationDiskSource::addSup
(
const volScalarField& rho,
fvMatrix<vector>& eqn,
const label fieldI
)
{
const scalargpuField& cellsV = mesh_.V();
vectorgpuField& Usource = eqn.source();
const vectorgpuField& U = eqn.psi();
if (V_ > VSMALL)
{
addRadialActuationDiskAxialInertialResistance
(
Usource,
cells_,
cellsV,
rho,
U
);
}
}
void Foam::fv::radialActuationDiskSource::writeData(Ostream& os) const
{
actuationDiskSource::writeData(os);
}
bool Foam::fv::radialActuationDiskSource::read(const dictionary& dict)
{
if (option::read(dict))
{
coeffs_.readIfPresent("diskDir", diskDir_);
coeffs_.readIfPresent("Cp", Cp_);
coeffs_.readIfPresent("Ct", Ct_);
coeffs_.readIfPresent("diskArea", diskArea_);
coeffs_.lookup("coeffs") >> radialCoeffs_;
return true;
}
else
{
return false;
}
}
// ************************************************************************* //
| Atizar/RapidCFD-dev | src/fvOptions/sources/derived/radialActuationDiskSource/radialActuationDiskSource.C | C++ | gpl-3.0 | 3,628 | [
30522,
1013,
1008,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
from planarprocess import *
from gds_helpers import *
from itertools import cycle
xmin, xmax = -5, 5
layers = gds_cross_section('mypmos.gds', [(0,xmin), (0, xmax)], 'gdsmap.map')
['P-Active-Well', 'Active-Cut', 'N-Well', 'Metal-2', 'Metal-1', 'P-Select',
'N-Select', 'Transistor-Poly', 'Via1']
wafer = Wafer(1., 5., 0, xmax - xmin)
# N-Well
nw = layers['N-Well']
wafer.implant(.7, nw, outdiffusion=5., label='N-Well')
# Field and gate oxides
de = layers['P-Active-Well']
# TODO: channel stop under field oxide
fox = wafer.grow(.5, wafer.blank_mask().difference(de),
y_offset=-.2, outdiffusion=.1)
gox = wafer.grow(.05, de, outdiffusion=.05, base=wafer.wells,
label='Gate oxide')
# Gate poly and N+/P+ implants
gp = layers['Transistor-Poly']
poly = wafer.grow(.25, gp, outdiffusion=.25, label='Gate poly')
np = layers['N-Select'].intersection(
layers['P-Active-Well']).difference(gp)
nplus = wafer.implant(.1, np, outdiffusion=.1, target=wafer.wells, source=gox,
label='N+')
pp = layers['P-Select'].intersection(
layers['P-Active-Well']).difference(gp)
pplus = wafer.implant(.1, pp, outdiffusion=.1, target=wafer.wells, source=gox,
label='P+')
# Multi-level dielectric and contacts
mld_thickness = .5
mld = wafer.grow(mld_thickness, wafer.blank_mask(), outdiffusion=.1)
ct = layers['Active-Cut']
contact = wafer.grow(-mld_thickness*1.1, ct, consuming=[mld, gox], base=wafer.air,
outdiffusion=.05, outdiffusion_vertices=3)
# Metals and vias
m1 = layers['Metal-1']
metal1 = wafer.grow(.6, m1, outdiffusion=.1, label='Metal-1')
ild_thickness = 1.2
ild1 = wafer.grow(ild_thickness, wafer.blank_mask(), outdiffusion=.1)
wafer.planarize()
v1 = layers['Via1']
via1 = wafer.grow(-ild_thickness*1.1, v1, consuming=[ild1], base=wafer.air,
outdiffusion=.05, outdiffusion_vertices=3)
m2 = layers['Metal-2']
metal2 = wafer.grow(1., m2, outdiffusion=.1, label='Metal-2')
# Presentation
custom_style = {s: {} for s in wafer.solids}
for solid, color in {
fox: '.4', gox: 'r', poly: 'g', mld: 'k',
ild1: '.3', contact: '.5', via1: '.5',
metal1: '.7', metal2: '.8'}.items():
custom_style[solid].update(dict(facecolor=color, edgecolor='k'))
for solid in wafer.solids:
if solid not in wafer.wells:
custom_style[solid].update(dict(hatch=None, fill=True))
base_hatches = r'\/' # r'/\|-+xoO.*'
hatches = cycle(list(base_hatches) + [h1+h2 for h1 in base_hatches
for h2 in base_hatches])
colors = cycle('krgbcmy')
plot_geometryref(wafer.air, hatch='.', fill=False, linewidth=0, color=(.9,.9,.9),
zorder=-100)
zorder = -99
for solid in wafer.solids:
style = dict(hatch=next(hatches), fill=False,
edgecolor=next(colors), zorder=zorder)
zorder += 1
style.update(custom_style.get(solid, {}))
plot_geometryref(solid, **style)
pyplot.legend()
pyplot.savefig('mypmos-x.png')
pyplot.show()
| ignamv/PlanarProcess | test.py | Python | gpl-3.0 | 2,927 | [
30522,
2013,
2933,
2906,
21572,
9623,
2015,
12324,
1008,
2013,
1043,
5104,
1035,
2393,
2545,
12324,
1008,
2013,
2009,
8743,
13669,
2015,
12324,
5402,
1060,
10020,
1010,
1060,
17848,
1027,
1011,
1019,
1010,
1019,
9014,
1027,
1043,
5104,
1035... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* Prototype JavaScript framework, version 1.6.0
* (c) 2005-2007 Sam Stephenson
*
* Prototype is freely distributable under the terms of an MIT-style license.
* For details, see the Prototype web site: http://www.prototypejs.org/
*
*--------------------------------------------------------------------------*/
var Prototype = {
Version: '1.6.0',
Browser: {
IE: !!(window.attachEvent && !window.opera),
Opera: !!window.opera,
WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1,
MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
},
BrowserFeatures: {
XPath: !!document.evaluate,
ElementExtensions: !!window.HTMLElement,
SpecificElementExtensions:
document.createElement('div').__proto__ &&
document.createElement('div').__proto__ !==
document.createElement('form').__proto__
},
ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
emptyFunction: function() { },
K: function(x) { return x }
};
if (Prototype.Browser.MobileSafari)
Prototype.BrowserFeatures.SpecificElementExtensions = false;
if (Prototype.Browser.WebKit)
Prototype.BrowserFeatures.XPath = false;
/* Based on Alex Arnell's inheritance implementation. */
var Class = {
create: function() {
var parent = null, properties = $A(arguments);
if (Object.isFunction(properties[0]))
parent = properties.shift();
function klass() {
this.initialize.apply(this, arguments);
}
Object.extend(klass, Class.Methods);
klass.superclass = parent;
klass.subclasses = [];
if (parent) {
var subclass = function() { };
subclass.prototype = parent.prototype;
klass.prototype = new subclass;
parent.subclasses.push(klass);
}
for (var i = 0; i < properties.length; i++)
klass.addMethods(properties[i]);
if (!klass.prototype.initialize)
klass.prototype.initialize = Prototype.emptyFunction;
klass.prototype.constructor = klass;
return klass;
}
};
Class.Methods = {
addMethods: function(source) {
var ancestor = this.superclass && this.superclass.prototype;
var properties = Object.keys(source);
if (!Object.keys({ toString: true }).length)
properties.push("toString", "valueOf");
for (var i = 0, length = properties.length; i < length; i++) {
var property = properties[i], value = source[property];
if (ancestor && Object.isFunction(value) &&
value.argumentNames().first() == "$super") {
var method = value, value = Object.extend((function(m) {
return function() { return ancestor[m].apply(this, arguments) };
})(property).wrap(method), {
valueOf: function() { return method },
toString: function() { return method.toString() }
});
}
this.prototype[property] = value;
}
return this;
}
};
var Abstract = { };
Object.extend = function(destination, source) {
for (var property in source)
destination[property] = source[property];
return destination;
};
Object.extend(Object, {
inspect: function(object) {
try {
if (object === undefined) return 'undefined';
if (object === null) return 'null';
return object.inspect ? object.inspect() : object.toString();
} catch (e) {
if (e instanceof RangeError) return '...';
throw e;
}
},
toJSON: function(object) {
var type = typeof object;
switch (type) {
case 'undefined':
case 'function':
case 'unknown': return;
case 'boolean': return object.toString();
}
if (object === null) return 'null';
if (object.toJSON) return object.toJSON();
if (Object.isElement(object)) return;
var results = [];
for (var property in object) {
var value = Object.toJSON(object[property]);
if (value !== undefined)
results.push(property.toJSON() + ': ' + value);
}
return '{' + results.join(', ') + '}';
},
toQueryString: function(object) {
return $H(object).toQueryString();
},
toHTML: function(object) {
return object && object.toHTML ? object.toHTML() : String.interpret(object);
},
keys: function(object) {
var keys = [];
for (var property in object)
keys.push(property);
return keys;
},
values: function(object) {
var values = [];
for (var property in object)
values.push(object[property]);
return values;
},
clone: function(object) {
return Object.extend({ }, object);
},
isElement: function(object) {
return object && object.nodeType == 1;
},
isArray: function(object) {
return object && object.constructor === Array;
},
isHash: function(object) {
return object instanceof Hash;
},
isFunction: function(object) {
return typeof object == "function";
},
isString: function(object) {
return typeof object == "string";
},
isNumber: function(object) {
return typeof object == "number";
},
isUndefined: function(object) {
return typeof object == "undefined";
}
});
Object.extend(Function.prototype, {
argumentNames: function() {
var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip");
return names.length == 1 && !names[0] ? [] : names;
},
bind: function() {
if (arguments.length < 2 && arguments[0] === undefined) return this;
var __method = this, args = $A(arguments), object = args.shift();
return function() {
return __method.apply(object, args.concat($A(arguments)));
}
},
bindAsEventListener: function() {
var __method = this, args = $A(arguments), object = args.shift();
return function(event) {
return __method.apply(object, [event || window.event].concat(args));
}
},
curry: function() {
if (!arguments.length) return this;
var __method = this, args = $A(arguments);
return function() {
return __method.apply(this, args.concat($A(arguments)));
}
},
delay: function() {
var __method = this, args = $A(arguments), timeout = args.shift() * 1000;
return window.setTimeout(function() {
return __method.apply(__method, args);
}, timeout);
},
wrap: function(wrapper) {
var __method = this;
return function() {
return wrapper.apply(this, [__method.bind(this)].concat($A(arguments)));
}
},
methodize: function() {
if (this._methodized) return this._methodized;
var __method = this;
return this._methodized = function() {
return __method.apply(null, [this].concat($A(arguments)));
};
}
});
Function.prototype.defer = Function.prototype.delay.curry(0.01);
Date.prototype.toJSON = function() {
return '"' + this.getUTCFullYear() + '-' +
(this.getUTCMonth() + 1).toPaddedString(2) + '-' +
this.getUTCDate().toPaddedString(2) + 'T' +
this.getUTCHours().toPaddedString(2) + ':' +
this.getUTCMinutes().toPaddedString(2) + ':' +
this.getUTCSeconds().toPaddedString(2) + 'Z"';
};
var Try = {
these: function() {
var returnValue;
for (var i = 0, length = arguments.length; i < length; i++) {
var lambda = arguments[i];
try {
returnValue = lambda();
break;
} catch (e) { }
}
return returnValue;
}
};
RegExp.prototype.match = RegExp.prototype.test;
RegExp.escape = function(str) {
return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
};
/*--------------------------------------------------------------------------*/
var PeriodicalExecuter = Class.create({
initialize: function(callback, frequency) {
this.callback = callback;
this.frequency = frequency;
this.currentlyExecuting = false;
this.registerCallback();
},
registerCallback: function() {
this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
},
execute: function() {
this.callback(this);
},
stop: function() {
if (!this.timer) return;
clearInterval(this.timer);
this.timer = null;
},
onTimerEvent: function() {
if (!this.currentlyExecuting) {
try {
this.currentlyExecuting = true;
this.execute();
} finally {
this.currentlyExecuting = false;
}
}
}
});
Object.extend(String, {
interpret: function(value) {
return value == null ? '' : String(value);
},
specialChar: {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'\\': '\\\\'
}
});
Object.extend(String.prototype, {
gsub: function(pattern, replacement) {
var result = '', source = this, match;
replacement = arguments.callee.prepareReplacement(replacement);
while (source.length > 0) {
if (match = source.match(pattern)) {
result += source.slice(0, match.index);
result += String.interpret(replacement(match));
source = source.slice(match.index + match[0].length);
} else {
result += source, source = '';
}
}
return result;
},
sub: function(pattern, replacement, count) {
replacement = this.gsub.prepareReplacement(replacement);
count = count === undefined ? 1 : count;
return this.gsub(pattern, function(match) {
if (--count < 0) return match[0];
return replacement(match);
});
},
scan: function(pattern, iterator) {
this.gsub(pattern, iterator);
return String(this);
},
truncate: function(length, truncation) {
length = length || 30;
truncation = truncation === undefined ? '...' : truncation;
return this.length > length ?
this.slice(0, length - truncation.length) + truncation : String(this);
},
strip: function() {
return this.replace(/^\s+/, '').replace(/\s+$/, '');
},
stripTags: function() {
return this.replace(/<\/?[^>]+>/gi, '');
},
stripScripts: function() {
return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
},
extractScripts: function() {
var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
return (this.match(matchAll) || []).map(function(scriptTag) {
return (scriptTag.match(matchOne) || ['', ''])[1];
});
},
evalScripts: function() {
return this.extractScripts().map(function(script) { return eval(script) });
},
escapeHTML: function() {
var self = arguments.callee;
self.text.data = this;
return self.div.innerHTML;
},
unescapeHTML: function() {
var div = new Element('div');
div.innerHTML = this.stripTags();
return div.childNodes[0] ? (div.childNodes.length > 1 ?
$A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) :
div.childNodes[0].nodeValue) : '';
},
toQueryParams: function(separator) {
var match = this.strip().match(/([^?#]*)(#.*)?$/);
if (!match) return { };
return match[1].split(separator || '&').inject({ }, function(hash, pair) {
if ((pair = pair.split('='))[0]) {
var key = decodeURIComponent(pair.shift());
var value = pair.length > 1 ? pair.join('=') : pair[0];
if (value != undefined) value = decodeURIComponent(value);
if (key in hash) {
if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
hash[key].push(value);
}
else hash[key] = value;
}
return hash;
});
},
toArray: function() {
return this.split('');
},
succ: function() {
return this.slice(0, this.length - 1) +
String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
},
times: function(count) {
return count < 1 ? '' : new Array(count + 1).join(this);
},
camelize: function() {
var parts = this.split('-'), len = parts.length;
if (len == 1) return parts[0];
var camelized = this.charAt(0) == '-'
? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
: parts[0];
for (var i = 1; i < len; i++)
camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
return camelized;
},
capitalize: function() {
return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
},
underscore: function() {
return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
},
dasherize: function() {
return this.gsub(/_/,'-');
},
inspect: function(useDoubleQuotes) {
var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) {
var character = String.specialChar[match[0]];
return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
});
if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
return "'" + escapedString.replace(/'/g, '\\\'') + "'";
},
toJSON: function() {
return this.inspect(true);
},
unfilterJSON: function(filter) {
return this.sub(filter || Prototype.JSONFilter, '#{1}');
},
isJSON: function() {
var str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
},
evalJSON: function(sanitize) {
var json = this.unfilterJSON();
try {
if (!sanitize || json.isJSON()) return eval('(' + json + ')');
} catch (e) { }
throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
},
include: function(pattern) {
return this.indexOf(pattern) > -1;
},
startsWith: function(pattern) {
return this.indexOf(pattern) === 0;
},
endsWith: function(pattern) {
var d = this.length - pattern.length;
return d >= 0 && this.lastIndexOf(pattern) === d;
},
empty: function() {
return this == '';
},
blank: function() {
return /^\s*$/.test(this);
},
interpolate: function(object, pattern) {
return new Template(this, pattern).evaluate(object);
}
});
if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, {
escapeHTML: function() {
return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
},
unescapeHTML: function() {
return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
}
});
String.prototype.gsub.prepareReplacement = function(replacement) {
if (Object.isFunction(replacement)) return replacement;
var template = new Template(replacement);
return function(match) { return template.evaluate(match) };
};
String.prototype.parseQuery = String.prototype.toQueryParams;
Object.extend(String.prototype.escapeHTML, {
div: document.createElement('div'),
text: document.createTextNode('')
});
with (String.prototype.escapeHTML) div.appendChild(text);
var Template = Class.create({
initialize: function(template, pattern) {
this.template = template.toString();
this.pattern = pattern || Template.Pattern;
},
evaluate: function(object) {
if (Object.isFunction(object.toTemplateReplacements))
object = object.toTemplateReplacements();
return this.template.gsub(this.pattern, function(match) {
if (object == null) return '';
var before = match[1] || '';
if (before == '\\') return match[2];
var ctx = object, expr = match[3];
var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/, match = pattern.exec(expr);
if (match == null) return before;
while (match != null) {
var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1];
ctx = ctx[comp];
if (null == ctx || '' == match[3]) break;
expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);
match = pattern.exec(expr);
}
return before + String.interpret(ctx);
}.bind(this));
}
});
Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
var $break = { };
var Enumerable = {
each: function(iterator, context) {
var index = 0;
iterator = iterator.bind(context);
try {
this._each(function(value) {
iterator(value, index++);
});
} catch (e) {
if (e != $break) throw e;
}
return this;
},
eachSlice: function(number, iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K;
var index = -number, slices = [], array = this.toArray();
while ((index += number) < array.length)
slices.push(array.slice(index, index+number));
return slices.collect(iterator, context);
},
all: function(iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K;
var result = true;
this.each(function(value, index) {
result = result && !!iterator(value, index);
if (!result) throw $break;
});
return result;
},
any: function(iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K;
var result = false;
this.each(function(value, index) {
if (result = !!iterator(value, index))
throw $break;
});
return result;
},
collect: function(iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K;
var results = [];
this.each(function(value, index) {
results.push(iterator(value, index));
});
return results;
},
detect: function(iterator, context) {
iterator = iterator.bind(context);
var result;
this.each(function(value, index) {
if (iterator(value, index)) {
result = value;
throw $break;
}
});
return result;
},
findAll: function(iterator, context) {
iterator = iterator.bind(context);
var results = [];
this.each(function(value, index) {
if (iterator(value, index))
results.push(value);
});
return results;
},
grep: function(filter, iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K;
var results = [];
if (Object.isString(filter))
filter = new RegExp(filter);
this.each(function(value, index) {
if (filter.match(value))
results.push(iterator(value, index));
});
return results;
},
include: function(object) {
if (Object.isFunction(this.indexOf))
if (this.indexOf(object) != -1) return true;
var found = false;
this.each(function(value) {
if (value == object) {
found = true;
throw $break;
}
});
return found;
},
inGroupsOf: function(number, fillWith) {
fillWith = fillWith === undefined ? null : fillWith;
return this.eachSlice(number, function(slice) {
while(slice.length < number) slice.push(fillWith);
return slice;
});
},
inject: function(memo, iterator, context) {
iterator = iterator.bind(context);
this.each(function(value, index) {
memo = iterator(memo, value, index);
});
return memo;
},
invoke: function(method) {
var args = $A(arguments).slice(1);
return this.map(function(value) {
return value[method].apply(value, args);
});
},
max: function(iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K;
var result;
this.each(function(value, index) {
value = iterator(value, index);
if (result == undefined || value >= result)
result = value;
});
return result;
},
min: function(iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K;
var result;
this.each(function(value, index) {
value = iterator(value, index);
if (result == undefined || value < result)
result = value;
});
return result;
},
partition: function(iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K;
var trues = [], falses = [];
this.each(function(value, index) {
(iterator(value, index) ?
trues : falses).push(value);
});
return [trues, falses];
},
pluck: function(property) {
var results = [];
this.each(function(value) {
results.push(value[property]);
});
return results;
},
reject: function(iterator, context) {
iterator = iterator.bind(context);
var results = [];
this.each(function(value, index) {
if (!iterator(value, index))
results.push(value);
});
return results;
},
sortBy: function(iterator, context) {
iterator = iterator.bind(context);
return this.map(function(value, index) {
return {value: value, criteria: iterator(value, index)};
}).sort(function(left, right) {
var a = left.criteria, b = right.criteria;
return a < b ? -1 : a > b ? 1 : 0;
}).pluck('value');
},
toArray: function() {
return this.map();
},
zip: function() {
var iterator = Prototype.K, args = $A(arguments);
if (Object.isFunction(args.last()))
iterator = args.pop();
var collections = [this].concat(args).map($A);
return this.map(function(value, index) {
return iterator(collections.pluck(index));
});
},
size: function() {
return this.toArray().length;
},
inspect: function() {
return '#<Enumerable:' + this.toArray().inspect() + '>';
}
};
Object.extend(Enumerable, {
map: Enumerable.collect,
find: Enumerable.detect,
select: Enumerable.findAll,
filter: Enumerable.findAll,
member: Enumerable.include,
entries: Enumerable.toArray,
every: Enumerable.all,
some: Enumerable.any
});
function $A(iterable) {
if (!iterable) return [];
if (iterable.toArray) return iterable.toArray();
var length = iterable.length, results = new Array(length);
while (length--) results[length] = iterable[length];
return results;
}
if (Prototype.Browser.WebKit) {
function $A(iterable) {
if (!iterable) return [];
if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') &&
iterable.toArray) return iterable.toArray();
var length = iterable.length, results = new Array(length);
while (length--) results[length] = iterable[length];
return results;
}
}
Array.from = $A;
Object.extend(Array.prototype, Enumerable);
if (!Array.prototype._reverse) Array.prototype._reverse = Array.prototype.reverse;
Object.extend(Array.prototype, {
_each: function(iterator) {
for (var i = 0, length = this.length; i < length; i++)
iterator(this[i]);
},
clear: function() {
this.length = 0;
return this;
},
first: function() {
return this[0];
},
last: function() {
return this[this.length - 1];
},
compact: function() {
return this.select(function(value) {
return value != null;
});
},
flatten: function() {
return this.inject([], function(array, value) {
return array.concat(Object.isArray(value) ?
value.flatten() : [value]);
});
},
without: function() {
var values = $A(arguments);
return this.select(function(value) {
return !values.include(value);
});
},
reverse: function(inline) {
return (inline !== false ? this : this.toArray())._reverse();
},
reduce: function() {
return this.length > 1 ? this : this[0];
},
uniq: function(sorted) {
return this.inject([], function(array, value, index) {
if (0 == index || (sorted ? array.last() != value : !array.include(value)))
array.push(value);
return array;
});
},
intersect: function(array) {
return this.uniq().findAll(function(item) {
return array.detect(function(value) { return item === value });
});
},
clone: function() {
return [].concat(this);
},
size: function() {
return this.length;
},
inspect: function() {
return '[' + this.map(Object.inspect).join(', ') + ']';
},
toJSON: function() {
var results = [];
this.each(function(object) {
var value = Object.toJSON(object);
if (value !== undefined) results.push(value);
});
return '[' + results.join(', ') + ']';
}
});
// use native browser JS 1.6 implementation if available
if (Object.isFunction(Array.prototype.forEach))
Array.prototype._each = Array.prototype.forEach;
if (!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) {
i || (i = 0);
var length = this.length;
if (i < 0) i = length + i;
for (; i < length; i++)
if (this[i] === item) return i;
return -1;
};
if (!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i) {
i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1;
var n = this.slice(0, i).reverse().indexOf(item);
return (n < 0) ? n : i - n - 1;
};
Array.prototype.toArray = Array.prototype.clone;
function $w(string) {
if (!Object.isString(string)) return [];
string = string.strip();
return string ? string.split(/\s+/) : [];
}
if (Prototype.Browser.Opera){
Array.prototype.concat = function() {
var array = [];
for (var i = 0, length = this.length; i < length; i++) array.push(this[i]);
for (var i = 0, length = arguments.length; i < length; i++) {
if (Object.isArray(arguments[i])) {
for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
array.push(arguments[i][j]);
} else {
array.push(arguments[i]);
}
}
return array;
};
}
Object.extend(Number.prototype, {
toColorPart: function() {
return this.toPaddedString(2, 16);
},
succ: function() {
return this + 1;
},
times: function(iterator) {
$R(0, this, true).each(iterator);
return this;
},
toPaddedString: function(length, radix) {
var string = this.toString(radix || 10);
return '0'.times(length - string.length) + string;
},
toJSON: function() {
return isFinite(this) ? this.toString() : 'null';
}
});
$w('abs round ceil floor').each(function(method){
Number.prototype[method] = Math[method].methodize();
});
function $H(object) {
return new Hash(object);
}
var Hash = Class.create(Enumerable, (function() {
if (function() {
var i = 0, Test = function(value) { this.key = value };
Test.prototype.key = 'foo';
for (var property in new Test('bar')) i++;
return i > 1;
}()) {
function each(iterator) {
var cache = [];
for (var key in this._object) {
var value = this._object[key];
if (cache.include(key)) continue;
cache.push(key);
var pair = [key, value];
pair.key = key;
pair.value = value;
iterator(pair);
}
}
} else {
function each(iterator) {
for (var key in this._object) {
var value = this._object[key], pair = [key, value];
pair.key = key;
pair.value = value;
iterator(pair);
}
}
}
function toQueryPair(key, value) {
if (Object.isUndefined(value)) return key;
return key + '=' + encodeURIComponent(String.interpret(value));
}
return {
initialize: function(object) {
this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
},
_each: each,
set: function(key, value) {
return this._object[key] = value;
},
get: function(key) {
return this._object[key];
},
unset: function(key) {
var value = this._object[key];
delete this._object[key];
return value;
},
toObject: function() {
return Object.clone(this._object);
},
keys: function() {
return this.pluck('key');
},
values: function() {
return this.pluck('value');
},
index: function(value) {
var match = this.detect(function(pair) {
return pair.value === value;
});
return match && match.key;
},
merge: function(object) {
return this.clone().update(object);
},
update: function(object) {
return new Hash(object).inject(this, function(result, pair) {
result.set(pair.key, pair.value);
return result;
});
},
toQueryString: function() {
return this.map(function(pair) {
var key = encodeURIComponent(pair.key), values = pair.value;
if (values && typeof values == 'object') {
if (Object.isArray(values))
return values.map(toQueryPair.curry(key)).join('&');
}
return toQueryPair(key, values);
}).join('&');
},
inspect: function() {
return '#<Hash:{' + this.map(function(pair) {
return pair.map(Object.inspect).join(': ');
}).join(', ') + '}>';
},
toJSON: function() {
return Object.toJSON(this.toObject());
},
clone: function() {
return new Hash(this);
}
}
})());
Hash.prototype.toTemplateReplacements = Hash.prototype.toObject;
Hash.from = $H;
var ObjectRange = Class.create(Enumerable, {
initialize: function(start, end, exclusive) {
this.start = start;
this.end = end;
this.exclusive = exclusive;
},
_each: function(iterator) {
var value = this.start;
while (this.include(value)) {
iterator(value);
value = value.succ();
}
},
include: function(value) {
if (value < this.start)
return false;
if (this.exclusive)
return value < this.end;
return value <= this.end;
}
});
var $R = function(start, end, exclusive) {
return new ObjectRange(start, end, exclusive);
};
var Ajax = {
getTransport: function() {
return Try.these(
function() {return new XMLHttpRequest()},
function() {return new ActiveXObject('Msxml2.XMLHTTP')},
function() {return new ActiveXObject('Microsoft.XMLHTTP')}
) || false;
},
activeRequestCount: 0
};
Ajax.Responders = {
responders: [],
_each: function(iterator) {
this.responders._each(iterator);
},
register: function(responder) {
if (!this.include(responder))
this.responders.push(responder);
},
unregister: function(responder) {
this.responders = this.responders.without(responder);
},
dispatch: function(callback, request, transport, json) {
this.each(function(responder) {
if (Object.isFunction(responder[callback])) {
try {
responder[callback].apply(responder, [request, transport, json]);
} catch (e) { }
}
});
}
};
Object.extend(Ajax.Responders, Enumerable);
Ajax.Responders.register({
onCreate: function() { Ajax.activeRequestCount++ },
onComplete: function() { Ajax.activeRequestCount-- }
});
Ajax.Base = Class.create({
initialize: function(options) {
this.options = {
method: 'post',
asynchronous: true,
contentType: 'application/x-www-form-urlencoded',
encoding: 'UTF-8',
parameters: '',
evalJSON: true,
evalJS: true
};
Object.extend(this.options, options || { });
this.options.method = this.options.method.toLowerCase();
if (Object.isString(this.options.parameters))
this.options.parameters = this.options.parameters.toQueryParams();
}
});
Ajax.Request = Class.create(Ajax.Base, {
_complete: false,
initialize: function($super, url, options) {
$super(options);
this.transport = Ajax.getTransport();
this.request(url);
},
request: function(url) {
this.url = url;
this.method = this.options.method;
var params = Object.clone(this.options.parameters);
if (!['get', 'post'].include(this.method)) {
// simulate other verbs over post
params['_method'] = this.method;
this.method = 'post';
}
this.parameters = params;
if (params = Object.toQueryString(params)) {
// when GET, append parameters to URL
if (this.method == 'get')
this.url += (this.url.include('?') ? '&' : '?') + params;
else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
params += '&_=';
}
try {
var response = new Ajax.Response(this);
if (this.options.onCreate) this.options.onCreate(response);
Ajax.Responders.dispatch('onCreate', this, response);
this.transport.open(this.method.toUpperCase(), this.url,
this.options.asynchronous);
if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);
this.transport.onreadystatechange = this.onStateChange.bind(this);
this.setRequestHeaders();
this.body = this.method == 'post' ? (this.options.postBody || params) : null;
this.transport.send(this.body);
/* Force Firefox to handle ready state 4 for synchronous requests */
if (!this.options.asynchronous && this.transport.overrideMimeType)
this.onStateChange();
}
catch (e) {
this.dispatchException(e);
}
},
onStateChange: function() {
var readyState = this.transport.readyState;
if (readyState > 1 && !((readyState == 4) && this._complete))
this.respondToReadyState(this.transport.readyState);
},
setRequestHeaders: function() {
var headers = {
'X-Requested-With': 'XMLHttpRequest',
'X-Prototype-Version': Prototype.Version,
'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
};
if (this.method == 'post') {
headers['Content-type'] = this.options.contentType +
(this.options.encoding ? '; charset=' + this.options.encoding : '');
/* Force "Connection: close" for older Mozilla browsers to work
* around a bug where XMLHttpRequest sends an incorrect
* Content-length header. See Mozilla Bugzilla #246651.
*/
if (this.transport.overrideMimeType &&
(navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
headers['Connection'] = 'close';
}
// user-defined headers
if (typeof this.options.requestHeaders == 'object') {
var extras = this.options.requestHeaders;
if (Object.isFunction(extras.push))
for (var i = 0, length = extras.length; i < length; i += 2)
headers[extras[i]] = extras[i+1];
else
$H(extras).each(function(pair) { headers[pair.key] = pair.value });
}
for (var name in headers)
this.transport.setRequestHeader(name, headers[name]);
},
success: function() {
var status = this.getStatus();
return !status || (status >= 200 && status < 300);
},
getStatus: function() {
try {
return this.transport.status || 0;
} catch (e) { return 0 }
},
respondToReadyState: function(readyState) {
var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);
if (state == 'Complete') {
try {
this._complete = true;
(this.options['on' + response.status]
|| this.options['on' + (this.success() ? 'Success' : 'Failure')]
|| Prototype.emptyFunction)(response, response.headerJSON);
} catch (e) {
this.dispatchException(e);
}
var contentType = response.getHeader('Content-type');
if (this.options.evalJS == 'force'
|| (this.options.evalJS && contentType
&& contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))
this.evalResponse();
}
try {
(this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON);
Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON);
} catch (e) {
this.dispatchException(e);
}
if (state == 'Complete') {
// avoid memory leak in MSIE: clean up
this.transport.onreadystatechange = Prototype.emptyFunction;
}
},
getHeader: function(name) {
try {
return this.transport.getResponseHeader(name);
} catch (e) { return null }
},
evalResponse: function() {
try {
return eval((this.transport.responseText || '').unfilterJSON());
} catch (e) {
this.dispatchException(e);
}
},
dispatchException: function(exception) {
(this.options.onException || Prototype.emptyFunction)(this, exception);
Ajax.Responders.dispatch('onException', this, exception);
}
});
Ajax.Request.Events =
['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
Ajax.Response = Class.create({
initialize: function(request){
this.request = request;
var transport = this.transport = request.transport,
readyState = this.readyState = transport.readyState;
if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) {
this.status = this.getStatus();
this.statusText = this.getStatusText();
this.responseText = String.interpret(transport.responseText);
this.headerJSON = this._getHeaderJSON();
}
if(readyState == 4) {
var xml = transport.responseXML;
this.responseXML = xml === undefined ? null : xml;
this.responseJSON = this._getResponseJSON();
}
},
status: 0,
statusText: '',
getStatus: Ajax.Request.prototype.getStatus,
getStatusText: function() {
try {
return this.transport.statusText || '';
} catch (e) { return '' }
},
getHeader: Ajax.Request.prototype.getHeader,
getAllHeaders: function() {
try {
return this.getAllResponseHeaders();
} catch (e) { return null }
},
getResponseHeader: function(name) {
return this.transport.getResponseHeader(name);
},
getAllResponseHeaders: function() {
return this.transport.getAllResponseHeaders();
},
_getHeaderJSON: function() {
var json = this.getHeader('X-JSON');
if (!json) return null;
json = decodeURIComponent(escape(json));
try {
return json.evalJSON(this.request.options.sanitizeJSON);
} catch (e) {
this.request.dispatchException(e);
}
},
_getResponseJSON: function() {
var options = this.request.options;
if (!options.evalJSON || (options.evalJSON != 'force' &&
!(this.getHeader('Content-type') || '').include('application/json')))
return null;
try {
return this.transport.responseText.evalJSON(options.sanitizeJSON);
} catch (e) {
this.request.dispatchException(e);
}
}
});
Ajax.Updater = Class.create(Ajax.Request, {
initialize: function($super, container, url, options) {
this.container = {
success: (container.success || container),
failure: (container.failure || (container.success ? null : container))
};
options = options || { };
var onComplete = options.onComplete;
options.onComplete = (function(response, param) {
this.updateContent(response.responseText);
if (Object.isFunction(onComplete)) onComplete(response, param);
}).bind(this);
$super(url, options);
},
updateContent: function(responseText) {
var receiver = this.container[this.success() ? 'success' : 'failure'],
options = this.options;
if (!options.evalScripts) responseText = responseText.stripScripts();
if (receiver = $(receiver)) {
if (options.insertion) {
if (Object.isString(options.insertion)) {
var insertion = { }; insertion[options.insertion] = responseText;
receiver.insert(insertion);
}
else options.insertion(receiver, responseText);
}
else receiver.update(responseText);
}
if (this.success()) {
if (this.onComplete) this.onComplete.bind(this).defer();
}
}
});
Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
initialize: function($super, container, url, options) {
$super(options);
this.onComplete = this.options.onComplete;
this.frequency = (this.options.frequency || 2);
this.decay = (this.options.decay || 1);
this.updater = { };
this.container = container;
this.url = url;
this.start();
},
start: function() {
this.options.onComplete = this.updateComplete.bind(this);
this.onTimerEvent();
},
stop: function() {
this.updater.options.onComplete = undefined;
clearTimeout(this.timer);
(this.onComplete || Prototype.emptyFunction).apply(this, arguments);
},
updateComplete: function(response) {
if (this.options.decay) {
this.decay = (response.responseText == this.lastText ?
this.decay * this.options.decay : 1);
this.lastText = response.responseText;
}
this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
},
onTimerEvent: function() {
this.updater = new Ajax.Updater(this.container, this.url, this.options);
}
});
function $(element) {
if (arguments.length > 1) {
for (var i = 0, elements = [], length = arguments.length; i < length; i++)
elements.push($(arguments[i]));
return elements;
}
if (Object.isString(element))
element = document.getElementById(element);
return Element.extend(element);
}
if (Prototype.BrowserFeatures.XPath) {
document._getElementsByXPath = function(expression, parentElement) {
var results = [];
var query = document.evaluate(expression, $(parentElement) || document,
null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0, length = query.snapshotLength; i < length; i++)
results.push(Element.extend(query.snapshotItem(i)));
return results;
};
}
/*--------------------------------------------------------------------------*/
if (!window.Node) var Node = { };
if (!Node.ELEMENT_NODE) {
// DOM level 2 ECMAScript Language Binding
Object.extend(Node, {
ELEMENT_NODE: 1,
ATTRIBUTE_NODE: 2,
TEXT_NODE: 3,
CDATA_SECTION_NODE: 4,
ENTITY_REFERENCE_NODE: 5,
ENTITY_NODE: 6,
PROCESSING_INSTRUCTION_NODE: 7,
COMMENT_NODE: 8,
DOCUMENT_NODE: 9,
DOCUMENT_TYPE_NODE: 10,
DOCUMENT_FRAGMENT_NODE: 11,
NOTATION_NODE: 12
});
}
(function() {
var element = this.Element;
this.Element = function(tagName, attributes) {
attributes = attributes || { };
tagName = tagName.toLowerCase();
var cache = Element.cache;
if (Prototype.Browser.IE && attributes.name) {
tagName = '<' + tagName + ' name="' + attributes.name + '">';
delete attributes.name;
return Element.writeAttribute(document.createElement(tagName), attributes);
}
if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));
return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);
};
Object.extend(this.Element, element || { });
}).call(window);
Element.cache = { };
Element.Methods = {
visible: function(element) {
return $(element).style.display != 'none';
},
toggle: function(element) {
element = $(element);
Element[Element.visible(element) ? 'hide' : 'show'](element);
return element;
},
hide: function(element) {
$(element).style.display = 'none';
return element;
},
show: function(element) {
$(element).style.display = '';
return element;
},
remove: function(element) {
element = $(element);
element.parentNode.removeChild(element);
return element;
},
update: function(element, content) {
element = $(element);
if (content && content.toElement) content = content.toElement();
if (Object.isElement(content)) return element.update().insert(content);
content = Object.toHTML(content);
element.innerHTML = content.stripScripts();
content.evalScripts.bind(content).defer();
return element;
},
replace: function(element, content) {
element = $(element);
if (content && content.toElement) content = content.toElement();
else if (!Object.isElement(content)) {
content = Object.toHTML(content);
var range = element.ownerDocument.createRange();
range.selectNode(element);
content.evalScripts.bind(content).defer();
content = range.createContextualFragment(content.stripScripts());
}
element.parentNode.replaceChild(content, element);
return element;
},
insert: function(element, insertions) {
element = $(element);
if (Object.isString(insertions) || Object.isNumber(insertions) ||
Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
insertions = {bottom:insertions};
var content, t, range;
for (position in insertions) {
content = insertions[position];
position = position.toLowerCase();
t = Element._insertionTranslations[position];
if (content && content.toElement) content = content.toElement();
if (Object.isElement(content)) {
t.insert(element, content);
continue;
}
content = Object.toHTML(content);
range = element.ownerDocument.createRange();
t.initializeRange(element, range);
t.insert(element, range.createContextualFragment(content.stripScripts()));
content.evalScripts.bind(content).defer();
}
return element;
},
wrap: function(element, wrapper, attributes) {
element = $(element);
if (Object.isElement(wrapper))
$(wrapper).writeAttribute(attributes || { });
else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes);
else wrapper = new Element('div', wrapper);
if (element.parentNode)
element.parentNode.replaceChild(wrapper, element);
wrapper.appendChild(element);
return wrapper;
},
inspect: function(element) {
element = $(element);
var result = '<' + element.tagName.toLowerCase();
$H({'id': 'id', 'className': 'class'}).each(function(pair) {
var property = pair.first(), attribute = pair.last();
var value = (element[property] || '').toString();
if (value) result += ' ' + attribute + '=' + value.inspect(true);
});
return result + '>';
},
recursivelyCollect: function(element, property) {
element = $(element);
var elements = [];
while (element = element[property])
if (element.nodeType == 1)
elements.push(Element.extend(element));
return elements;
},
ancestors: function(element) {
return $(element).recursivelyCollect('parentNode');
},
descendants: function(element) {
return $A($(element).getElementsByTagName('*')).each(Element.extend);
},
firstDescendant: function(element) {
element = $(element).firstChild;
while (element && element.nodeType != 1) element = element.nextSibling;
return $(element);
},
immediateDescendants: function(element) {
if (!(element = $(element).firstChild)) return [];
while (element && element.nodeType != 1) element = element.nextSibling;
if (element) return [element].concat($(element).nextSiblings());
return [];
},
previousSiblings: function(element) {
return $(element).recursivelyCollect('previousSibling');
},
nextSiblings: function(element) {
return $(element).recursivelyCollect('nextSibling');
},
siblings: function(element) {
element = $(element);
return element.previousSiblings().reverse().concat(element.nextSiblings());
},
match: function(element, selector) {
if (Object.isString(selector))
selector = new Selector(selector);
return selector.match($(element));
},
up: function(element, expression, index) {
element = $(element);
if (arguments.length == 1) return $(element.parentNode);
var ancestors = element.ancestors();
return expression ? Selector.findElement(ancestors, expression, index) :
ancestors[index || 0];
},
down: function(element, expression, index) {
element = $(element);
if (arguments.length == 1) return element.firstDescendant();
var descendants = element.descendants();
return expression ? Selector.findElement(descendants, expression, index) :
descendants[index || 0];
},
previous: function(element, expression, index) {
element = $(element);
if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
var previousSiblings = element.previousSiblings();
return expression ? Selector.findElement(previousSiblings, expression, index) :
previousSiblings[index || 0];
},
next: function(element, expression, index) {
element = $(element);
if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
var nextSiblings = element.nextSiblings();
return expression ? Selector.findElement(nextSiblings, expression, index) :
nextSiblings[index || 0];
},
select: function() {
var args = $A(arguments), element = $(args.shift());
return Selector.findChildElements(element, args);
},
adjacent: function() {
var args = $A(arguments), element = $(args.shift());
return Selector.findChildElements(element.parentNode, args).without(element);
},
identify: function(element) {
element = $(element);
var id = element.readAttribute('id'), self = arguments.callee;
if (id) return id;
do { id = 'anonymous_element_' + self.counter++ } while ($(id));
element.writeAttribute('id', id);
return id;
},
readAttribute: function(element, name) {
element = $(element);
if (Prototype.Browser.IE) {
var t = Element._attributeTranslations.read;
if (t.values[name]) return t.values[name](element, name);
if (t.names[name]) name = t.names[name];
if (name.include(':')) {
return (!element.attributes || !element.attributes[name]) ? null :
element.attributes[name].value;
}
}
return element.getAttribute(name);
},
writeAttribute: function(element, name, value) {
element = $(element);
var attributes = { }, t = Element._attributeTranslations.write;
if (typeof name == 'object') attributes = name;
else attributes[name] = value === undefined ? true : value;
for (var attr in attributes) {
var name = t.names[attr] || attr, value = attributes[attr];
if (t.values[attr]) name = t.values[attr](element, value);
if (value === false || value === null)
element.removeAttribute(name);
else if (value === true)
element.setAttribute(name, name);
else element.setAttribute(name, value);
}
return element;
},
getHeight: function(element) {
return $(element).getDimensions().height;
},
getWidth: function(element) {
return $(element).getDimensions().width;
},
classNames: function(element) {
return new Element.ClassNames(element);
},
hasClassName: function(element, className) {
if (!(element = $(element))) return;
var elementClassName = element.className;
return (elementClassName.length > 0 && (elementClassName == className ||
new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
},
addClassName: function(element, className) {
if (!(element = $(element))) return;
if (!element.hasClassName(className))
element.className += (element.className ? ' ' : '') + className;
return element;
},
removeClassName: function(element, className) {
if (!(element = $(element))) return;
element.className = element.className.replace(
new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip();
return element;
},
toggleClassName: function(element, className) {
if (!(element = $(element))) return;
return element[element.hasClassName(className) ?
'removeClassName' : 'addClassName'](className);
},
// removes whitespace-only text node children
cleanWhitespace: function(element) {
element = $(element);
var node = element.firstChild;
while (node) {
var nextNode = node.nextSibling;
if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
element.removeChild(node);
node = nextNode;
}
return element;
},
empty: function(element) {
return $(element).innerHTML.blank();
},
descendantOf: function(element, ancestor) {
element = $(element), ancestor = $(ancestor);
if (element.compareDocumentPosition)
return (element.compareDocumentPosition(ancestor) & 8) === 8;
if (element.sourceIndex && !Prototype.Browser.Opera) {
var e = element.sourceIndex, a = ancestor.sourceIndex,
nextAncestor = ancestor.nextSibling;
if (!nextAncestor) {
do { ancestor = ancestor.parentNode; }
while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode);
}
if (nextAncestor) return (e > a && e < nextAncestor.sourceIndex);
}
while (element = element.parentNode)
if (element == ancestor) return true;
return false;
},
scrollTo: function(element) {
element = $(element);
var pos = element.cumulativeOffset();
window.scrollTo(pos[0], pos[1]);
return element;
},
getStyle: function(element, style) {
element = $(element);
style = style == 'float' ? 'cssFloat' : style.camelize();
var value = element.style[style];
if (!value) {
var css = document.defaultView.getComputedStyle(element, null);
value = css ? css[style] : null;
}
if (style == 'opacity') return value ? parseFloat(value) : 1.0;
return value == 'auto' ? null : value;
},
getOpacity: function(element) {
return $(element).getStyle('opacity');
},
setStyle: function(element, styles) {
element = $(element);
var elementStyle = element.style, match;
if (Object.isString(styles)) {
element.style.cssText += ';' + styles;
return styles.include('opacity') ?
element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element;
}
for (var property in styles)
if (property == 'opacity') element.setOpacity(styles[property]);
else
elementStyle[(property == 'float' || property == 'cssFloat') ?
(elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') :
property] = styles[property];
return element;
},
setOpacity: function(element, value) {
element = $(element);
element.style.opacity = (value == 1 || value === '') ? '' :
(value < 0.00001) ? 0 : value;
return element;
},
getDimensions: function(element) {
element = $(element);
var display = $(element).getStyle('display');
if (display != 'none' && display != null) // Safari bug
return {width: element.offsetWidth, height: element.offsetHeight};
// All *Width and *Height properties give 0 on elements with display none,
// so enable the element temporarily
var els = element.style;
var originalVisibility = els.visibility;
var originalPosition = els.position;
var originalDisplay = els.display;
els.visibility = 'hidden';
els.position = 'absolute';
els.display = 'block';
var originalWidth = element.clientWidth;
var originalHeight = element.clientHeight;
els.display = originalDisplay;
els.position = originalPosition;
els.visibility = originalVisibility;
return {width: originalWidth, height: originalHeight};
},
makePositioned: function(element) {
element = $(element);
var pos = Element.getStyle(element, 'position');
if (pos == 'static' || !pos) {
element._madePositioned = true;
element.style.position = 'relative';
// Opera returns the offset relative to the positioning context, when an
// element is position relative but top and left have not been defined
if (window.opera) {
element.style.top = 0;
element.style.left = 0;
}
}
return element;
},
undoPositioned: function(element) {
element = $(element);
if (element._madePositioned) {
element._madePositioned = undefined;
element.style.position =
element.style.top =
element.style.left =
element.style.bottom =
element.style.right = '';
}
return element;
},
makeClipping: function(element) {
element = $(element);
if (element._overflow) return element;
element._overflow = Element.getStyle(element, 'overflow') || 'auto';
if (element._overflow !== 'hidden')
element.style.overflow = 'hidden';
return element;
},
undoClipping: function(element) {
element = $(element);
if (!element._overflow) return element;
element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;
element._overflow = null;
return element;
},
cumulativeOffset: function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.offsetTop || 0;
valueL += element.offsetLeft || 0;
element = element.offsetParent;
} while (element);
return Element._returnOffset(valueL, valueT);
},
positionedOffset: function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.offsetTop || 0;
valueL += element.offsetLeft || 0;
element = element.offsetParent;
if (element) {
if (element.tagName == 'BODY') break;
var p = Element.getStyle(element, 'position');
if (p == 'relative' || p == 'absolute') break;
}
} while (element);
return Element._returnOffset(valueL, valueT);
},
absolutize: function(element) {
element = $(element);
if (element.getStyle('position') == 'absolute') return;
// Position.prepare(); // To be done manually by Scripty when it needs it.
var offsets = element.positionedOffset();
var top = offsets[1];
var left = offsets[0];
var width = element.clientWidth;
var height = element.clientHeight;
element._originalLeft = left - parseFloat(element.style.left || 0);
element._originalTop = top - parseFloat(element.style.top || 0);
element._originalWidth = element.style.width;
element._originalHeight = element.style.height;
element.style.position = 'absolute';
element.style.top = top + 'px';
element.style.left = left + 'px';
element.style.width = width + 'px';
element.style.height = height + 'px';
return element;
},
relativize: function(element) {
element = $(element);
if (element.getStyle('position') == 'relative') return;
// Position.prepare(); // To be done manually by Scripty when it needs it.
element.style.position = 'relative';
var top = parseFloat(element.style.top || 0) - (element._originalTop || 0);
var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
element.style.top = top + 'px';
element.style.left = left + 'px';
element.style.height = element._originalHeight;
element.style.width = element._originalWidth;
return element;
},
cumulativeScrollOffset: function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.scrollTop || 0;
valueL += element.scrollLeft || 0;
element = element.parentNode;
} while (element);
return Element._returnOffset(valueL, valueT);
},
getOffsetParent: function(element) {
if (element.offsetParent) return $(element.offsetParent);
if (element == document.body) return $(element);
while ((element = element.parentNode) && element != document.body)
if (Element.getStyle(element, 'position') != 'static')
return $(element);
return $(document.body);
},
viewportOffset: function(forElement) {
var valueT = 0, valueL = 0;
var element = forElement;
do {
valueT += element.offsetTop || 0;
valueL += element.offsetLeft || 0;
// Safari fix
if (element.offsetParent == document.body &&
Element.getStyle(element, 'position') == 'absolute') break;
} while (element = element.offsetParent);
element = forElement;
do {
if (!Prototype.Browser.Opera || element.tagName == 'BODY') {
valueT -= element.scrollTop || 0;
valueL -= element.scrollLeft || 0;
}
} while (element = element.parentNode);
return Element._returnOffset(valueL, valueT);
},
clonePosition: function(element, source) {
var options = Object.extend({
setLeft: true,
setTop: true,
setWidth: true,
setHeight: true,
offsetTop: 0,
offsetLeft: 0
}, arguments[2] || { });
// find page position of source
source = $(source);
var p = source.viewportOffset();
// find coordinate system to use
element = $(element);
var delta = [0, 0];
var parent = null;
// delta [0,0] will do fine with position: fixed elements,
// position:absolute needs offsetParent deltas
if (Element.getStyle(element, 'position') == 'absolute') {
parent = element.getOffsetParent();
delta = parent.viewportOffset();
}
// correct by body offsets (fixes Safari)
if (parent == document.body) {
delta[0] -= document.body.offsetLeft;
delta[1] -= document.body.offsetTop;
}
// set position
if (options.setLeft) element.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px';
if (options.setTop) element.style.top = (p[1] - delta[1] + options.offsetTop) + 'px';
if (options.setWidth) element.style.width = source.offsetWidth + 'px';
if (options.setHeight) element.style.height = source.offsetHeight + 'px';
return element;
}
};
Element.Methods.identify.counter = 1;
Object.extend(Element.Methods, {
getElementsBySelector: Element.Methods.select,
childElements: Element.Methods.immediateDescendants
});
Element._attributeTranslations = {
write: {
names: {
className: 'class',
htmlFor: 'for'
},
values: { }
}
};
if (!document.createRange || Prototype.Browser.Opera) {
Element.Methods.insert = function(element, insertions) {
element = $(element);
if (Object.isString(insertions) || Object.isNumber(insertions) ||
Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
insertions = { bottom: insertions };
var t = Element._insertionTranslations, content, position, pos, tagName;
for (position in insertions) {
content = insertions[position];
position = position.toLowerCase();
pos = t[position];
if (content && content.toElement) content = content.toElement();
if (Object.isElement(content)) {
pos.insert(element, content);
continue;
}
content = Object.toHTML(content);
tagName = ((position == 'before' || position == 'after')
? element.parentNode : element).tagName.toUpperCase();
if (t.tags[tagName]) {
var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
if (position == 'top' || position == 'after') fragments.reverse();
fragments.each(pos.insert.curry(element));
}
else element.insertAdjacentHTML(pos.adjacency, content.stripScripts());
content.evalScripts.bind(content).defer();
}
return element;
};
}
if (Prototype.Browser.Opera) {
Element.Methods._getStyle = Element.Methods.getStyle;
Element.Methods.getStyle = function(element, style) {
switch(style) {
case 'left':
case 'top':
case 'right':
case 'bottom':
if (Element._getStyle(element, 'position') == 'static') return null;
default: return Element._getStyle(element, style);
}
};
Element.Methods._readAttribute = Element.Methods.readAttribute;
Element.Methods.readAttribute = function(element, attribute) {
if (attribute == 'title') return element.title;
return Element._readAttribute(element, attribute);
};
}
else if (Prototype.Browser.IE) {
$w('positionedOffset getOffsetParent viewportOffset').each(function(method) {
Element.Methods[method] = Element.Methods[method].wrap(
function(proceed, element) {
element = $(element);
var position = element.getStyle('position');
if (position != 'static') return proceed(element);
element.setStyle({ position: 'relative' });
var value = proceed(element);
element.setStyle({ position: position });
return value;
}
);
});
Element.Methods.getStyle = function(element, style) {
element = $(element);
style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
var value = element.style[style];
if (!value && element.currentStyle) value = element.currentStyle[style];
if (style == 'opacity') {
if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
if (value[1]) return parseFloat(value[1]) / 100;
return 1.0;
}
if (value == 'auto') {
if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
return element['offset' + style.capitalize()] + 'px';
return null;
}
return value;
};
Element.Methods.setOpacity = function(element, value) {
function stripAlpha(filter){
return filter.replace(/alpha\([^\)]*\)/gi,'');
}
element = $(element);
var currentStyle = element.currentStyle;
if ((currentStyle && !currentStyle.hasLayout) ||
(!currentStyle && element.style.zoom == 'normal'))
element.style.zoom = 1;
var filter = element.getStyle('filter'), style = element.style;
if (value == 1 || value === '') {
(filter = stripAlpha(filter)) ?
style.filter = filter : style.removeAttribute('filter');
return element;
} else if (value < 0.00001) value = 0;
style.filter = stripAlpha(filter) +
'alpha(opacity=' + (value * 100) + ')';
return element;
};
Element._attributeTranslations = {
read: {
names: {
'class': 'className',
'for': 'htmlFor'
},
values: {
_getAttr: function(element, attribute) {
return element.getAttribute(attribute, 2);
},
_getAttrNode: function(element, attribute) {
var node = element.getAttributeNode(attribute);
return node ? node.value : "";
},
_getEv: function(element, attribute) {
var attribute = element.getAttribute(attribute);
return attribute ? attribute.toString().slice(23, -2) : null;
},
_flag: function(element, attribute) {
return $(element).hasAttribute(attribute) ? attribute : null;
},
style: function(element) {
return element.style.cssText.toLowerCase();
},
title: function(element) {
return element.title;
}
}
}
};
Element._attributeTranslations.write = {
names: Object.clone(Element._attributeTranslations.read.names),
values: {
checked: function(element, value) {
element.checked = !!value;
},
style: function(element, value) {
element.style.cssText = value ? value : '';
}
}
};
Element._attributeTranslations.has = {};
$w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' +
'encType maxLength readOnly longDesc').each(function(attr) {
Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;
Element._attributeTranslations.has[attr.toLowerCase()] = attr;
});
(function(v) {
Object.extend(v, {
href: v._getAttr,
src: v._getAttr,
type: v._getAttr,
action: v._getAttrNode,
disabled: v._flag,
checked: v._flag,
readonly: v._flag,
multiple: v._flag,
onload: v._getEv,
onunload: v._getEv,
onclick: v._getEv,
ondblclick: v._getEv,
onmousedown: v._getEv,
onmouseup: v._getEv,
onmouseover: v._getEv,
onmousemove: v._getEv,
onmouseout: v._getEv,
onfocus: v._getEv,
onblur: v._getEv,
onkeypress: v._getEv,
onkeydown: v._getEv,
onkeyup: v._getEv,
onsubmit: v._getEv,
onreset: v._getEv,
onselect: v._getEv,
onchange: v._getEv
});
})(Element._attributeTranslations.read.values);
}
else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) {
Element.Methods.setOpacity = function(element, value) {
element = $(element);
element.style.opacity = (value == 1) ? 0.999999 :
(value === '') ? '' : (value < 0.00001) ? 0 : value;
return element;
};
}
else if (Prototype.Browser.WebKit) {
Element.Methods.setOpacity = function(element, value) {
element = $(element);
element.style.opacity = (value == 1 || value === '') ? '' :
(value < 0.00001) ? 0 : value;
if (value == 1)
if(element.tagName == 'IMG' && element.width) {
element.width++; element.width--;
} else try {
var n = document.createTextNode(' ');
element.appendChild(n);
element.removeChild(n);
} catch (e) { }
return element;
};
// Safari returns margins on body which is incorrect if the child is absolutely
// positioned. For performance reasons, redefine Position.cumulativeOffset for
// KHTML/WebKit only.
Element.Methods.cumulativeOffset = function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.offsetTop || 0;
valueL += element.offsetLeft || 0;
if (element.offsetParent == document.body)
if (Element.getStyle(element, 'position') == 'absolute') break;
element = element.offsetParent;
} while (element);
return Element._returnOffset(valueL, valueT);
};
}
if (Prototype.Browser.IE || Prototype.Browser.Opera) {
// IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements
Element.Methods.update = function(element, content) {
element = $(element);
if (content && content.toElement) content = content.toElement();
if (Object.isElement(content)) return element.update().insert(content);
content = Object.toHTML(content);
var tagName = element.tagName.toUpperCase();
if (tagName in Element._insertionTranslations.tags) {
$A(element.childNodes).each(function(node) { element.removeChild(node) });
Element._getContentFromAnonymousElement(tagName, content.stripScripts())
.each(function(node) { element.appendChild(node) });
}
else element.innerHTML = content.stripScripts();
content.evalScripts.bind(content).defer();
return element;
};
}
if (document.createElement('div').outerHTML) {
Element.Methods.replace = function(element, content) {
element = $(element);
if (content && content.toElement) content = content.toElement();
if (Object.isElement(content)) {
element.parentNode.replaceChild(content, element);
return element;
}
content = Object.toHTML(content);
var parent = element.parentNode, tagName = parent.tagName.toUpperCase();
if (Element._insertionTranslations.tags[tagName]) {
var nextSibling = element.next();
var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
parent.removeChild(element);
if (nextSibling)
fragments.each(function(node) { parent.insertBefore(node, nextSibling) });
else
fragments.each(function(node) { parent.appendChild(node) });
}
else element.outerHTML = content.stripScripts();
content.evalScripts.bind(content).defer();
return element;
};
}
Element._returnOffset = function(l, t) {
var result = [l, t];
result.left = l;
result.top = t;
return result;
};
Element._getContentFromAnonymousElement = function(tagName, html) {
var div = new Element('div'), t = Element._insertionTranslations.tags[tagName];
div.innerHTML = t[0] + html + t[1];
t[2].times(function() { div = div.firstChild });
return $A(div.childNodes);
};
Element._insertionTranslations = {
before: {
adjacency: 'beforeBegin',
insert: function(element, node) {
element.parentNode.insertBefore(node, element);
},
initializeRange: function(element, range) {
range.setStartBefore(element);
}
},
top: {
adjacency: 'afterBegin',
insert: function(element, node) {
element.insertBefore(node, element.firstChild);
},
initializeRange: function(element, range) {
range.selectNodeContents(element);
range.collapse(true);
}
},
bottom: {
adjacency: 'beforeEnd',
insert: function(element, node) {
element.appendChild(node);
}
},
after: {
adjacency: 'afterEnd',
insert: function(element, node) {
element.parentNode.insertBefore(node, element.nextSibling);
},
initializeRange: function(element, range) {
range.setStartAfter(element);
}
},
tags: {
TABLE: ['<table>', '</table>', 1],
TBODY: ['<table><tbody>', '</tbody></table>', 2],
TR: ['<table><tbody><tr>', '</tr></tbody></table>', 3],
TD: ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4],
SELECT: ['<select>', '</select>', 1]
}
};
(function() {
this.bottom.initializeRange = this.top.initializeRange;
Object.extend(this.tags, {
THEAD: this.tags.TBODY,
TFOOT: this.tags.TBODY,
TH: this.tags.TD
});
}).call(Element._insertionTranslations);
Element.Methods.Simulated = {
hasAttribute: function(element, attribute) {
attribute = Element._attributeTranslations.has[attribute] || attribute;
var node = $(element).getAttributeNode(attribute);
return node && node.specified;
}
};
Element.Methods.ByTag = { };
Object.extend(Element, Element.Methods);
if (!Prototype.BrowserFeatures.ElementExtensions &&
document.createElement('div').__proto__) {
window.HTMLElement = { };
window.HTMLElement.prototype = document.createElement('div').__proto__;
Prototype.BrowserFeatures.ElementExtensions = true;
}
Element.extend = (function() {
if (Prototype.BrowserFeatures.SpecificElementExtensions)
return Prototype.K;
var Methods = { }, ByTag = Element.Methods.ByTag;
var extend = Object.extend(function(element) {
if (!element || element._extendedByPrototype ||
element.nodeType != 1 || element == window) return element;
var methods = Object.clone(Methods),
tagName = element.tagName, property, value;
// extend methods for specific tags
if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]);
for (property in methods) {
value = methods[property];
if (Object.isFunction(value) && !(property in element))
element[property] = value.methodize();
}
element._extendedByPrototype = Prototype.emptyFunction;
return element;
}, {
refresh: function() {
// extend methods for all tags (Safari doesn't need this)
if (!Prototype.BrowserFeatures.ElementExtensions) {
Object.extend(Methods, Element.Methods);
Object.extend(Methods, Element.Methods.Simulated);
}
}
});
extend.refresh();
return extend;
})();
Element.hasAttribute = function(element, attribute) {
if (element.hasAttribute) return element.hasAttribute(attribute);
return Element.Methods.Simulated.hasAttribute(element, attribute);
};
Element.addMethods = function(methods) {
var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
if (!methods) {
Object.extend(Form, Form.Methods);
Object.extend(Form.Element, Form.Element.Methods);
Object.extend(Element.Methods.ByTag, {
"FORM": Object.clone(Form.Methods),
"INPUT": Object.clone(Form.Element.Methods),
"SELECT": Object.clone(Form.Element.Methods),
"TEXTAREA": Object.clone(Form.Element.Methods)
});
}
if (arguments.length == 2) {
var tagName = methods;
methods = arguments[1];
}
if (!tagName) Object.extend(Element.Methods, methods || { });
else {
if (Object.isArray(tagName)) tagName.each(extend);
else extend(tagName);
}
function extend(tagName) {
tagName = tagName.toUpperCase();
if (!Element.Methods.ByTag[tagName])
Element.Methods.ByTag[tagName] = { };
Object.extend(Element.Methods.ByTag[tagName], methods);
}
function copy(methods, destination, onlyIfAbsent) {
onlyIfAbsent = onlyIfAbsent || false;
for (var property in methods) {
var value = methods[property];
if (!Object.isFunction(value)) continue;
if (!onlyIfAbsent || !(property in destination))
destination[property] = value.methodize();
}
}
function findDOMClass(tagName) {
var klass;
var trans = {
"OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph",
"FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList",
"DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading",
"H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote",
"INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION":
"TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD":
"TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR":
"TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET":
"FrameSet", "IFRAME": "IFrame"
};
if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';
if (window[klass]) return window[klass];
klass = 'HTML' + tagName + 'Element';
if (window[klass]) return window[klass];
klass = 'HTML' + tagName.capitalize() + 'Element';
if (window[klass]) return window[klass];
window[klass] = { };
window[klass].prototype = document.createElement(tagName).__proto__;
return window[klass];
}
if (F.ElementExtensions) {
copy(Element.Methods, HTMLElement.prototype);
copy(Element.Methods.Simulated, HTMLElement.prototype, true);
}
if (F.SpecificElementExtensions) {
for (var tag in Element.Methods.ByTag) {
var klass = findDOMClass(tag);
if (Object.isUndefined(klass)) continue;
copy(T[tag], klass.prototype);
}
}
Object.extend(Element, Element.Methods);
delete Element.ByTag;
if (Element.extend.refresh) Element.extend.refresh();
Element.cache = { };
};
document.viewport = {
getDimensions: function() {
var dimensions = { };
$w('width height').each(function(d) {
var D = d.capitalize();
dimensions[d] = self['inner' + D] ||
(document.documentElement['client' + D] || document.body['client' + D]);
});
return dimensions;
},
getWidth: function() {
return this.getDimensions().width;
},
getHeight: function() {
return this.getDimensions().height;
},
getScrollOffsets: function() {
return Element._returnOffset(
window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
}
};
/* Portions of the Selector class are derived from Jack Slocum’s DomQuery,
* part of YUI-Ext version 0.40, distributed under the terms of an MIT-style
* license. Please see http://www.yui-ext.com/ for more information. */
var Selector = Class.create({
initialize: function(expression) {
this.expression = expression.strip();
this.compileMatcher();
},
compileMatcher: function() {
// Selectors with namespaced attributes can't use the XPath version
if (Prototype.BrowserFeatures.XPath && !(/(\[[\w-]*?:|:checked)/).test(this.expression))
return this.compileXPathMatcher();
var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
c = Selector.criteria, le, p, m;
if (Selector._cache[e]) {
this.matcher = Selector._cache[e];
return;
}
this.matcher = ["this.matcher = function(root) {",
"var r = root, h = Selector.handlers, c = false, n;"];
while (e && le != e && (/\S/).test(e)) {
le = e;
for (var i in ps) {
p = ps[i];
if (m = e.match(p)) {
this.matcher.push(Object.isFunction(c[i]) ? c[i](m) :
new Template(c[i]).evaluate(m));
e = e.replace(m[0], '');
break;
}
}
}
this.matcher.push("return h.unique(n);\n}");
eval(this.matcher.join('\n'));
Selector._cache[this.expression] = this.matcher;
},
compileXPathMatcher: function() {
var e = this.expression, ps = Selector.patterns,
x = Selector.xpath, le, m;
if (Selector._cache[e]) {
this.xpath = Selector._cache[e]; return;
}
this.matcher = ['.//*'];
while (e && le != e && (/\S/).test(e)) {
le = e;
for (var i in ps) {
if (m = e.match(ps[i])) {
this.matcher.push(Object.isFunction(x[i]) ? x[i](m) :
new Template(x[i]).evaluate(m));
e = e.replace(m[0], '');
break;
}
}
}
this.xpath = this.matcher.join('');
Selector._cache[this.expression] = this.xpath;
},
findElements: function(root) {
root = root || document;
if (this.xpath) return document._getElementsByXPath(this.xpath, root);
return this.matcher(root);
},
match: function(element) {
this.tokens = [];
var e = this.expression, ps = Selector.patterns, as = Selector.assertions;
var le, p, m;
while (e && le !== e && (/\S/).test(e)) {
le = e;
for (var i in ps) {
p = ps[i];
if (m = e.match(p)) {
// use the Selector.assertions methods unless the selector
// is too complex.
if (as[i]) {
this.tokens.push([i, Object.clone(m)]);
e = e.replace(m[0], '');
} else {
// reluctantly do a document-wide search
// and look for a match in the array
return this.findElements(document).include(element);
}
}
}
}
var match = true, name, matches;
for (var i = 0, token; token = this.tokens[i]; i++) {
name = token[0], matches = token[1];
if (!Selector.assertions[name](element, matches)) {
match = false; break;
}
}
return match;
},
toString: function() {
return this.expression;
},
inspect: function() {
return "#<Selector:" + this.expression.inspect() + ">";
}
});
Object.extend(Selector, {
_cache: { },
xpath: {
descendant: "//*",
child: "/*",
adjacent: "/following-sibling::*[1]",
laterSibling: '/following-sibling::*',
tagName: function(m) {
if (m[1] == '*') return '';
return "[local-name()='" + m[1].toLowerCase() +
"' or local-name()='" + m[1].toUpperCase() + "']";
},
className: "[contains(concat(' ', @class, ' '), ' #{1} ')]",
id: "[@id='#{1}']",
attrPresence: "[@#{1}]",
attr: function(m) {
m[3] = m[5] || m[6];
return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
},
pseudo: function(m) {
var h = Selector.xpath.pseudos[m[1]];
if (!h) return '';
if (Object.isFunction(h)) return h(m);
return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
},
operators: {
'=': "[@#{1}='#{3}']",
'!=': "[@#{1}!='#{3}']",
'^=': "[starts-with(@#{1}, '#{3}')]",
'$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",
'*=': "[contains(@#{1}, '#{3}')]",
'~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",
'|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]"
},
pseudos: {
'first-child': '[not(preceding-sibling::*)]',
'last-child': '[not(following-sibling::*)]',
'only-child': '[not(preceding-sibling::* or following-sibling::*)]',
'empty': "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]",
'checked': "[@checked]",
'disabled': "[@disabled]",
'enabled': "[not(@disabled)]",
'not': function(m) {
var e = m[6], p = Selector.patterns,
x = Selector.xpath, le, m, v;
var exclusion = [];
while (e && le != e && (/\S/).test(e)) {
le = e;
for (var i in p) {
if (m = e.match(p[i])) {
v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m);
exclusion.push("(" + v.substring(1, v.length - 1) + ")");
e = e.replace(m[0], '');
break;
}
}
}
return "[not(" + exclusion.join(" and ") + ")]";
},
'nth-child': function(m) {
return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m);
},
'nth-last-child': function(m) {
return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m);
},
'nth-of-type': function(m) {
return Selector.xpath.pseudos.nth("position() ", m);
},
'nth-last-of-type': function(m) {
return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m);
},
'first-of-type': function(m) {
m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m);
},
'last-of-type': function(m) {
m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m);
},
'only-of-type': function(m) {
var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m);
},
nth: function(fragment, m) {
var mm, formula = m[6], predicate;
if (formula == 'even') formula = '2n+0';
if (formula == 'odd') formula = '2n+1';
if (mm = formula.match(/^(\d+)$/)) // digit only
return '[' + fragment + "= " + mm[1] + ']';
if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
if (mm[1] == "-") mm[1] = -1;
var a = mm[1] ? Number(mm[1]) : 1;
var b = mm[2] ? Number(mm[2]) : 0;
predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " +
"((#{fragment} - #{b}) div #{a} >= 0)]";
return new Template(predicate).evaluate({
fragment: fragment, a: a, b: b });
}
}
}
},
criteria: {
tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;',
className: 'n = h.className(n, r, "#{1}", c); c = false;',
id: 'n = h.id(n, r, "#{1}", c); c = false;',
attrPresence: 'n = h.attrPresence(n, r, "#{1}"); c = false;',
attr: function(m) {
m[3] = (m[5] || m[6]);
return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m);
},
pseudo: function(m) {
if (m[6]) m[6] = m[6].replace(/"/g, '\\"');
return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m);
},
descendant: 'c = "descendant";',
child: 'c = "child";',
adjacent: 'c = "adjacent";',
laterSibling: 'c = "laterSibling";'
},
patterns: {
// combinators must be listed first
// (and descendant needs to be last combinator)
laterSibling: /^\s*~\s*/,
child: /^\s*>\s*/,
adjacent: /^\s*\+\s*/,
descendant: /^\s/,
// selectors follow
tagName: /^\s*(\*|[\w\-]+)(\b|$)?/,
id: /^#([\w\-\*]+)(\b|$)/,
className: /^\.([\w\-\*]+)(\b|$)/,
pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s)|(?=:))/,
attrPresence: /^\[([\w]+)\]/,
attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/
},
// for Selector.match and Element#match
assertions: {
tagName: function(element, matches) {
return matches[1].toUpperCase() == element.tagName.toUpperCase();
},
className: function(element, matches) {
return Element.hasClassName(element, matches[1]);
},
id: function(element, matches) {
return element.id === matches[1];
},
attrPresence: function(element, matches) {
return Element.hasAttribute(element, matches[1]);
},
attr: function(element, matches) {
var nodeValue = Element.readAttribute(element, matches[1]);
return Selector.operators[matches[2]](nodeValue, matches[3]);
}
},
handlers: {
// UTILITY FUNCTIONS
// joins two collections
concat: function(a, b) {
for (var i = 0, node; node = b[i]; i++)
a.push(node);
return a;
},
// marks an array of nodes for counting
mark: function(nodes) {
for (var i = 0, node; node = nodes[i]; i++)
node._counted = true;
return nodes;
},
unmark: function(nodes) {
for (var i = 0, node; node = nodes[i]; i++)
node._counted = undefined;
return nodes;
},
// mark each child node with its position (for nth calls)
// "ofType" flag indicates whether we're indexing for nth-of-type
// rather than nth-child
index: function(parentNode, reverse, ofType) {
parentNode._counted = true;
if (reverse) {
for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) {
var node = nodes[i];
if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
}
} else {
for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++)
if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
}
},
// filters out duplicates and extends all nodes
unique: function(nodes) {
if (nodes.length == 0) return nodes;
var results = [], n;
for (var i = 0, l = nodes.length; i < l; i++)
if (!(n = nodes[i])._counted) {
n._counted = true;
results.push(Element.extend(n));
}
return Selector.handlers.unmark(results);
},
// COMBINATOR FUNCTIONS
descendant: function(nodes) {
var h = Selector.handlers;
for (var i = 0, results = [], node; node = nodes[i]; i++)
h.concat(results, node.getElementsByTagName('*'));
return results;
},
child: function(nodes) {
var h = Selector.handlers;
for (var i = 0, results = [], node; node = nodes[i]; i++) {
for (var j = 0, children = [], child; child = node.childNodes[j]; j++)
if (child.nodeType == 1 && child.tagName != '!') results.push(child);
}
return results;
},
adjacent: function(nodes) {
for (var i = 0, results = [], node; node = nodes[i]; i++) {
var next = this.nextElementSibling(node);
if (next) results.push(next);
}
return results;
},
laterSibling: function(nodes) {
var h = Selector.handlers;
for (var i = 0, results = [], node; node = nodes[i]; i++)
h.concat(results, Element.nextSiblings(node));
return results;
},
nextElementSibling: function(node) {
while (node = node.nextSibling)
if (node.nodeType == 1) return node;
return null;
},
previousElementSibling: function(node) {
while (node = node.previousSibling)
if (node.nodeType == 1) return node;
return null;
},
// TOKEN FUNCTIONS
tagName: function(nodes, root, tagName, combinator) {
tagName = tagName.toUpperCase();
var results = [], h = Selector.handlers;
if (nodes) {
if (combinator) {
// fastlane for ordinary descendant combinators
if (combinator == "descendant") {
for (var i = 0, node; node = nodes[i]; i++)
h.concat(results, node.getElementsByTagName(tagName));
return results;
} else nodes = this[combinator](nodes);
if (tagName == "*") return nodes;
}
for (var i = 0, node; node = nodes[i]; i++)
if (node.tagName.toUpperCase() == tagName) results.push(node);
return results;
} else return root.getElementsByTagName(tagName);
},
id: function(nodes, root, id, combinator) {
var targetNode = $(id), h = Selector.handlers;
if (!targetNode) return [];
if (!nodes && root == document) return [targetNode];
if (nodes) {
if (combinator) {
if (combinator == 'child') {
for (var i = 0, node; node = nodes[i]; i++)
if (targetNode.parentNode == node) return [targetNode];
} else if (combinator == 'descendant') {
for (var i = 0, node; node = nodes[i]; i++)
if (Element.descendantOf(targetNode, node)) return [targetNode];
} else if (combinator == 'adjacent') {
for (var i = 0, node; node = nodes[i]; i++)
if (Selector.handlers.previousElementSibling(targetNode) == node)
return [targetNode];
} else nodes = h[combinator](nodes);
}
for (var i = 0, node; node = nodes[i]; i++)
if (node == targetNode) return [targetNode];
return [];
}
return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : [];
},
className: function(nodes, root, className, combinator) {
if (nodes && combinator) nodes = this[combinator](nodes);
return Selector.handlers.byClassName(nodes, root, className);
},
byClassName: function(nodes, root, className) {
if (!nodes) nodes = Selector.handlers.descendant([root]);
var needle = ' ' + className + ' ';
for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) {
nodeClassName = node.className;
if (nodeClassName.length == 0) continue;
if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle))
results.push(node);
}
return results;
},
attrPresence: function(nodes, root, attr) {
if (!nodes) nodes = root.getElementsByTagName("*");
var results = [];
for (var i = 0, node; node = nodes[i]; i++)
if (Element.hasAttribute(node, attr)) results.push(node);
return results;
},
attr: function(nodes, root, attr, value, operator) {
if (!nodes) nodes = root.getElementsByTagName("*");
var handler = Selector.operators[operator], results = [];
for (var i = 0, node; node = nodes[i]; i++) {
var nodeValue = Element.readAttribute(node, attr);
if (nodeValue === null) continue;
if (handler(nodeValue, value)) results.push(node);
}
return results;
},
pseudo: function(nodes, name, value, root, combinator) {
if (nodes && combinator) nodes = this[combinator](nodes);
if (!nodes) nodes = root.getElementsByTagName("*");
return Selector.pseudos[name](nodes, value, root);
}
},
pseudos: {
'first-child': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++) {
if (Selector.handlers.previousElementSibling(node)) continue;
results.push(node);
}
return results;
},
'last-child': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++) {
if (Selector.handlers.nextElementSibling(node)) continue;
results.push(node);
}
return results;
},
'only-child': function(nodes, value, root) {
var h = Selector.handlers;
for (var i = 0, results = [], node; node = nodes[i]; i++)
if (!h.previousElementSibling(node) && !h.nextElementSibling(node))
results.push(node);
return results;
},
'nth-child': function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, formula, root);
},
'nth-last-child': function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, formula, root, true);
},
'nth-of-type': function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, formula, root, false, true);
},
'nth-last-of-type': function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, formula, root, true, true);
},
'first-of-type': function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, "1", root, false, true);
},
'last-of-type': function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, "1", root, true, true);
},
'only-of-type': function(nodes, formula, root) {
var p = Selector.pseudos;
return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root);
},
// handles the an+b logic
getIndices: function(a, b, total) {
if (a == 0) return b > 0 ? [b] : [];
return $R(1, total).inject([], function(memo, i) {
if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i);
return memo;
});
},
// handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type
nth: function(nodes, formula, root, reverse, ofType) {
if (nodes.length == 0) return [];
if (formula == 'even') formula = '2n+0';
if (formula == 'odd') formula = '2n+1';
var h = Selector.handlers, results = [], indexed = [], m;
h.mark(nodes);
for (var i = 0, node; node = nodes[i]; i++) {
if (!node.parentNode._counted) {
h.index(node.parentNode, reverse, ofType);
indexed.push(node.parentNode);
}
}
if (formula.match(/^\d+$/)) { // just a number
formula = Number(formula);
for (var i = 0, node; node = nodes[i]; i++)
if (node.nodeIndex == formula) results.push(node);
} else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
if (m[1] == "-") m[1] = -1;
var a = m[1] ? Number(m[1]) : 1;
var b = m[2] ? Number(m[2]) : 0;
var indices = Selector.pseudos.getIndices(a, b, nodes.length);
for (var i = 0, node, l = indices.length; node = nodes[i]; i++) {
for (var j = 0; j < l; j++)
if (node.nodeIndex == indices[j]) results.push(node);
}
}
h.unmark(nodes);
h.unmark(indexed);
return results;
},
'empty': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++) {
// IE treats comments as element nodes
if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue;
results.push(node);
}
return results;
},
'not': function(nodes, selector, root) {
var h = Selector.handlers, selectorType, m;
var exclusions = new Selector(selector).findElements(root);
h.mark(exclusions);
for (var i = 0, results = [], node; node = nodes[i]; i++)
if (!node._counted) results.push(node);
h.unmark(exclusions);
return results;
},
'enabled': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++)
if (!node.disabled) results.push(node);
return results;
},
'disabled': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++)
if (node.disabled) results.push(node);
return results;
},
'checked': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++)
if (node.checked) results.push(node);
return results;
}
},
operators: {
'=': function(nv, v) { return nv == v; },
'!=': function(nv, v) { return nv != v; },
'^=': function(nv, v) { return nv.startsWith(v); },
'$=': function(nv, v) { return nv.endsWith(v); },
'*=': function(nv, v) { return nv.include(v); },
'~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
'|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); }
},
matchElements: function(elements, expression) {
var matches = new Selector(expression).findElements(), h = Selector.handlers;
h.mark(matches);
for (var i = 0, results = [], element; element = elements[i]; i++)
if (element._counted) results.push(element);
h.unmark(matches);
return results;
},
findElement: function(elements, expression, index) {
if (Object.isNumber(expression)) {
index = expression; expression = false;
}
return Selector.matchElements(elements, expression || '*')[index || 0];
},
findChildElements: function(element, expressions) {
var exprs = expressions.join(','), expressions = [];
exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
expressions.push(m[1].strip());
});
var results = [], h = Selector.handlers;
for (var i = 0, l = expressions.length, selector; i < l; i++) {
selector = new Selector(expressions[i].strip());
h.concat(results, selector.findElements(element));
}
return (l > 1) ? h.unique(results) : results;
}
});
function $$() {
return Selector.findChildElements(document, $A(arguments));
}
var Form = {
reset: function(form) {
$(form).reset();
return form;
},
serializeElements: function(elements, options) {
if (typeof options != 'object') options = { hash: !!options };
else if (options.hash === undefined) options.hash = true;
var key, value, submitted = false, submit = options.submit;
var data = elements.inject({ }, function(result, element) {
if (!element.disabled && element.name) {
key = element.name; value = $(element).getValue();
if (value != null && (element.type != 'submit' || (!submitted &&
submit !== false && (!submit || key == submit) && (submitted = true)))) {
if (key in result) {
// a key is already present; construct an array of values
if (!Object.isArray(result[key])) result[key] = [result[key]];
result[key].push(value);
}
else result[key] = value;
}
}
return result;
});
return options.hash ? data : Object.toQueryString(data);
}
};
Form.Methods = {
serialize: function(form, options) {
return Form.serializeElements(Form.getElements(form), options);
},
getElements: function(form) {
return $A($(form).getElementsByTagName('*')).inject([],
function(elements, child) {
if (Form.Element.Serializers[child.tagName.toLowerCase()])
elements.push(Element.extend(child));
return elements;
}
);
},
getInputs: function(form, typeName, name) {
form = $(form);
var inputs = form.getElementsByTagName('input');
if (!typeName && !name) return $A(inputs).map(Element.extend);
for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {
var input = inputs[i];
if ((typeName && input.type != typeName) || (name && input.name != name))
continue;
matchingInputs.push(Element.extend(input));
}
return matchingInputs;
},
disable: function(form) {
form = $(form);
Form.getElements(form).invoke('disable');
return form;
},
enable: function(form) {
form = $(form);
Form.getElements(form).invoke('enable');
return form;
},
findFirstElement: function(form) {
var elements = $(form).getElements().findAll(function(element) {
return 'hidden' != element.type && !element.disabled;
});
var firstByIndex = elements.findAll(function(element) {
return element.hasAttribute('tabIndex') && element.tabIndex >= 0;
}).sortBy(function(element) { return element.tabIndex }).first();
return firstByIndex ? firstByIndex : elements.find(function(element) {
return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
});
},
focusFirstElement: function(form) {
form = $(form);
form.findFirstElement().activate();
return form;
},
request: function(form, options) {
form = $(form), options = Object.clone(options || { });
var params = options.parameters, action = form.readAttribute('action') || '';
if (action.blank()) action = window.location.href;
options.parameters = form.serialize(true);
if (params) {
if (Object.isString(params)) params = params.toQueryParams();
Object.extend(options.parameters, params);
}
if (form.hasAttribute('method') && !options.method)
options.method = form.method;
return new Ajax.Request(action, options);
}
};
/*--------------------------------------------------------------------------*/
Form.Element = {
focus: function(element) {
$(element).focus();
return element;
},
select: function(element) {
$(element).select();
return element;
}
};
Form.Element.Methods = {
serialize: function(element) {
element = $(element);
if (!element.disabled && element.name) {
var value = element.getValue();
if (value != undefined) {
var pair = { };
pair[element.name] = value;
return Object.toQueryString(pair);
}
}
return '';
},
getValue: function(element) {
element = $(element);
var method = element.tagName.toLowerCase();
return Form.Element.Serializers[method](element);
},
setValue: function(element, value) {
element = $(element);
var method = element.tagName.toLowerCase();
Form.Element.Serializers[method](element, value);
return element;
},
clear: function(element) {
$(element).value = '';
return element;
},
present: function(element) {
return $(element).value != '';
},
activate: function(element) {
element = $(element);
try {
element.focus();
if (element.select && (element.tagName.toLowerCase() != 'input' ||
!['button', 'reset', 'submit'].include(element.type)))
element.select();
} catch (e) { }
return element;
},
disable: function(element) {
element = $(element);
element.blur();
element.disabled = true;
return element;
},
enable: function(element) {
element = $(element);
element.disabled = false;
return element;
}
};
/*--------------------------------------------------------------------------*/
var Field = Form.Element;
var $F = Form.Element.Methods.getValue;
/*--------------------------------------------------------------------------*/
Form.Element.Serializers = {
input: function(element, value) {
switch (element.type.toLowerCase()) {
case 'checkbox':
case 'radio':
return Form.Element.Serializers.inputSelector(element, value);
default:
return Form.Element.Serializers.textarea(element, value);
}
},
inputSelector: function(element, value) {
if (value === undefined) return element.checked ? element.value : null;
else element.checked = !!value;
},
textarea: function(element, value) {
if (value === undefined) return element.value;
else element.value = value;
},
select: function(element, index) {
if (index === undefined)
return this[element.type == 'select-one' ?
'selectOne' : 'selectMany'](element);
else {
var opt, value, single = !Object.isArray(index);
for (var i = 0, length = element.length; i < length; i++) {
opt = element.options[i];
value = this.optionValue(opt);
if (single) {
if (value == index) {
opt.selected = true;
return;
}
}
else opt.selected = index.include(value);
}
}
},
selectOne: function(element) {
var index = element.selectedIndex;
return index >= 0 ? this.optionValue(element.options[index]) : null;
},
selectMany: function(element) {
var values, length = element.length;
if (!length) return null;
for (var i = 0, values = []; i < length; i++) {
var opt = element.options[i];
if (opt.selected) values.push(this.optionValue(opt));
}
return values;
},
optionValue: function(opt) {
// extend element because hasAttribute may not be native
return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text;
}
};
/*--------------------------------------------------------------------------*/
Abstract.TimedObserver = Class.create(PeriodicalExecuter, {
initialize: function($super, element, frequency, callback) {
$super(callback, frequency);
this.element = $(element);
this.lastValue = this.getValue();
},
execute: function() {
var value = this.getValue();
if (Object.isString(this.lastValue) && Object.isString(value) ?
this.lastValue != value : String(this.lastValue) != String(value)) {
this.callback(this.element, value);
this.lastValue = value;
}
}
});
Form.Element.Observer = Class.create(Abstract.TimedObserver, {
getValue: function() {
return Form.Element.getValue(this.element);
}
});
Form.Observer = Class.create(Abstract.TimedObserver, {
getValue: function() {
return Form.serialize(this.element);
}
});
/*--------------------------------------------------------------------------*/
Abstract.EventObserver = Class.create({
initialize: function(element, callback) {
this.element = $(element);
this.callback = callback;
this.lastValue = this.getValue();
if (this.element.tagName.toLowerCase() == 'form')
this.registerFormCallbacks();
else
this.registerCallback(this.element);
},
onElementEvent: function() {
var value = this.getValue();
if (this.lastValue != value) {
this.callback(this.element, value);
this.lastValue = value;
}
},
registerFormCallbacks: function() {
Form.getElements(this.element).each(this.registerCallback, this);
},
registerCallback: function(element) {
if (element.type) {
switch (element.type.toLowerCase()) {
case 'checkbox':
case 'radio':
Event.observe(element, 'click', this.onElementEvent.bind(this));
break;
default:
Event.observe(element, 'change', this.onElementEvent.bind(this));
break;
}
}
}
});
Form.Element.EventObserver = Class.create(Abstract.EventObserver, {
getValue: function() {
return Form.Element.getValue(this.element);
}
});
Form.EventObserver = Class.create(Abstract.EventObserver, {
getValue: function() {
return Form.serialize(this.element);
}
});
if (!window.Event) var Event = { };
Object.extend(Event, {
KEY_BACKSPACE: 8,
KEY_TAB: 9,
KEY_RETURN: 13,
KEY_ESC: 27,
KEY_LEFT: 37,
KEY_UP: 38,
KEY_RIGHT: 39,
KEY_DOWN: 40,
KEY_DELETE: 46,
KEY_HOME: 36,
KEY_END: 35,
KEY_PAGEUP: 33,
KEY_PAGEDOWN: 34,
KEY_INSERT: 45,
cache: { },
relatedTarget: function(event) {
var element;
switch(event.type) {
case 'mouseover': element = event.fromElement; break;
case 'mouseout': element = event.toElement; break;
default: return null;
}
return Element.extend(element);
}
});
Event.Methods = (function() {
var isButton;
if (Prototype.Browser.IE) {
var buttonMap = { 0: 1, 1: 4, 2: 2 };
isButton = function(event, code) {
return event.button == buttonMap[code];
};
} else if (Prototype.Browser.WebKit) {
isButton = function(event, code) {
switch (code) {
case 0: return event.which == 1 && !event.metaKey;
case 1: return event.which == 1 && event.metaKey;
default: return false;
}
};
} else {
isButton = function(event, code) {
return event.which ? (event.which === code + 1) : (event.button === code);
};
}
return {
isLeftClick: function(event) { return isButton(event, 0) },
isMiddleClick: function(event) { return isButton(event, 1) },
isRightClick: function(event) { return isButton(event, 2) },
element: function(event) {
var node = Event.extend(event).target;
return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode : node);
},
findElement: function(event, expression) {
var element = Event.element(event);
return element.match(expression) ? element : element.up(expression);
},
pointer: function(event) {
return {
x: event.pageX || (event.clientX +
(document.documentElement.scrollLeft || document.body.scrollLeft)),
y: event.pageY || (event.clientY +
(document.documentElement.scrollTop || document.body.scrollTop))
};
},
pointerX: function(event) { return Event.pointer(event).x },
pointerY: function(event) { return Event.pointer(event).y },
stop: function(event) {
Event.extend(event);
event.preventDefault();
event.stopPropagation();
event.stopped = true;
}
};
})();
Event.extend = (function() {
var methods = Object.keys(Event.Methods).inject({ }, function(m, name) {
m[name] = Event.Methods[name].methodize();
return m;
});
if (Prototype.Browser.IE) {
Object.extend(methods, {
stopPropagation: function() { this.cancelBubble = true },
preventDefault: function() { this.returnValue = false },
inspect: function() { return "[object Event]" }
});
return function(event) {
if (!event) return false;
if (event._extendedByPrototype) return event;
event._extendedByPrototype = Prototype.emptyFunction;
var pointer = Event.pointer(event);
Object.extend(event, {
target: event.srcElement,
relatedTarget: Event.relatedTarget(event),
pageX: pointer.x,
pageY: pointer.y
});
return Object.extend(event, methods);
};
} else {
Event.prototype = Event.prototype || document.createEvent("HTMLEvents").__proto__;
Object.extend(Event.prototype, methods);
return Prototype.K;
}
})();
Object.extend(Event, (function() {
var cache = Event.cache;
function getEventID(element) {
if (element._eventID) return element._eventID;
arguments.callee.id = arguments.callee.id || 1;
return element._eventID = ++arguments.callee.id;
}
function getDOMEventName(eventName) {
if (eventName && eventName.include(':')) return "dataavailable";
return eventName;
}
function getCacheForID(id) {
return cache[id] = cache[id] || { };
}
function getWrappersForEventName(id, eventName) {
var c = getCacheForID(id);
return c[eventName] = c[eventName] || [];
}
function createWrapper(element, eventName, handler) {
var id = getEventID(element);
var c = getWrappersForEventName(id, eventName);
if (c.pluck("handler").include(handler)) return false;
var wrapper = function(event) {
if (!Event || !Event.extend ||
(event.eventName && event.eventName != eventName))
return false;
Event.extend(event);
handler.call(element, event)
};
wrapper.handler = handler;
c.push(wrapper);
return wrapper;
}
function findWrapper(id, eventName, handler) {
var c = getWrappersForEventName(id, eventName);
return c.find(function(wrapper) { return wrapper.handler == handler });
}
function destroyWrapper(id, eventName, handler) {
var c = getCacheForID(id);
if (!c[eventName]) return false;
c[eventName] = c[eventName].without(findWrapper(id, eventName, handler));
}
function destroyCache() {
for (var id in cache)
for (var eventName in cache[id])
cache[id][eventName] = null;
}
if (window.attachEvent) {
window.attachEvent("onunload", destroyCache);
}
return {
observe: function(element, eventName, handler) {
element = $(element);
var name = getDOMEventName(eventName);
var wrapper = createWrapper(element, eventName, handler);
if (!wrapper) return element;
if (element.addEventListener) {
element.addEventListener(name, wrapper, false);
} else {
element.attachEvent("on" + name, wrapper);
}
return element;
},
stopObserving: function(element, eventName, handler) {
element = $(element);
var id = getEventID(element), name = getDOMEventName(eventName);
if (!handler && eventName) {
getWrappersForEventName(id, eventName).each(function(wrapper) {
element.stopObserving(eventName, wrapper.handler);
});
return element;
} else if (!eventName) {
Object.keys(getCacheForID(id)).each(function(eventName) {
element.stopObserving(eventName);
});
return element;
}
var wrapper = findWrapper(id, eventName, handler);
if (!wrapper) return element;
if (element.removeEventListener) {
element.removeEventListener(name, wrapper, false);
} else {
element.detachEvent("on" + name, wrapper);
}
destroyWrapper(id, eventName, handler);
return element;
},
fire: function(element, eventName, memo) {
element = $(element);
if (element == document && document.createEvent && !element.dispatchEvent)
element = document.documentElement;
if (document.createEvent) {
var event = document.createEvent("HTMLEvents");
event.initEvent("dataavailable", true, true);
} else {
var event = document.createEventObject();
event.eventType = "ondataavailable";
}
event.eventName = eventName;
event.memo = memo || { };
if (document.createEvent) {
element.dispatchEvent(event);
} else {
element.fireEvent(event.eventType, event);
}
return event;
}
};
})());
Object.extend(Event, Event.Methods);
Element.addMethods({
fire: Event.fire,
observe: Event.observe,
stopObserving: Event.stopObserving
});
Object.extend(document, {
fire: Element.Methods.fire.methodize(),
observe: Element.Methods.observe.methodize(),
stopObserving: Element.Methods.stopObserving.methodize()
});
(function() {
/* Support for the DOMContentLoaded event is based on work by Dan Webb,
Matthias Miller, Dean Edwards and John Resig. */
var timer, fired = false;
function fireContentLoadedEvent() {
if (fired) return;
if (timer) window.clearInterval(timer);
document.fire("dom:loaded");
fired = true;
}
if (document.addEventListener) {
if (Prototype.Browser.WebKit) {
timer = window.setInterval(function() {
if (/loaded|complete/.test(document.readyState))
fireContentLoadedEvent();
}, 0);
Event.observe(window, "load", fireContentLoadedEvent);
} else {
document.addEventListener("DOMContentLoaded",
fireContentLoadedEvent, false);
}
} else {
document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");
$("__onDOMContentLoaded").onreadystatechange = function() {
if (this.readyState == "complete") {
this.onreadystatechange = null;
fireContentLoadedEvent();
}
};
}
})();
/*------------------------------- DEPRECATED -------------------------------*/
Hash.toQueryString = Object.toQueryString;
var Toggle = { display: Element.toggle };
Element.Methods.childOf = Element.Methods.descendantOf;
var Insertion = {
Before: function(element, content) {
return Element.insert(element, {before:content});
},
Top: function(element, content) {
return Element.insert(element, {top:content});
},
Bottom: function(element, content) {
return Element.insert(element, {bottom:content});
},
After: function(element, content) {
return Element.insert(element, {after:content});
}
};
var $continue = new Error('"throw $continue" is deprecated, use "return" instead');
// This should be moved to script.aculo.us; notice the deprecated methods
// further below, that map to the newer Element methods.
var Position = {
// set to true if needed, warning: firefox performance problems
// NOT neeeded for page scrolling, only if draggable contained in
// scrollable elements
includeScrollOffsets: false,
// must be called before calling withinIncludingScrolloffset, every time the
// page is scrolled
prepare: function() {
this.deltaX = window.pageXOffset
|| document.documentElement.scrollLeft
|| document.body.scrollLeft
|| 0;
this.deltaY = window.pageYOffset
|| document.documentElement.scrollTop
|| document.body.scrollTop
|| 0;
},
// caches x/y coordinate pair to use with overlap
within: function(element, x, y) {
if (this.includeScrollOffsets)
return this.withinIncludingScrolloffsets(element, x, y);
this.xcomp = x;
this.ycomp = y;
this.offset = Element.cumulativeOffset(element);
return (y >= this.offset[1] &&
y < this.offset[1] + element.offsetHeight &&
x >= this.offset[0] &&
x < this.offset[0] + element.offsetWidth);
},
withinIncludingScrolloffsets: function(element, x, y) {
var offsetcache = Element.cumulativeScrollOffset(element);
this.xcomp = x + offsetcache[0] - this.deltaX;
this.ycomp = y + offsetcache[1] - this.deltaY;
this.offset = Element.cumulativeOffset(element);
return (this.ycomp >= this.offset[1] &&
this.ycomp < this.offset[1] + element.offsetHeight &&
this.xcomp >= this.offset[0] &&
this.xcomp < this.offset[0] + element.offsetWidth);
},
// within must be called directly before
overlap: function(mode, element) {
if (!mode) return 0;
if (mode == 'vertical')
return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
element.offsetHeight;
if (mode == 'horizontal')
return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
element.offsetWidth;
},
// Deprecation layer -- use newer Element methods now (1.5.2).
cumulativeOffset: Element.Methods.cumulativeOffset,
positionedOffset: Element.Methods.positionedOffset,
absolutize: function(element) {
Position.prepare();
return Element.absolutize(element);
},
relativize: function(element) {
Position.prepare();
return Element.relativize(element);
},
realOffset: Element.Methods.cumulativeScrollOffset,
offsetParent: Element.Methods.getOffsetParent,
page: Element.Methods.viewportOffset,
clone: function(source, target, options) {
options = options || { };
return Element.clonePosition(target, source, options);
}
};
/*--------------------------------------------------------------------------*/
if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){
function iter(name) {
return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]";
}
instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ?
function(element, className) {
className = className.toString().strip();
var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className);
return cond ? document._getElementsByXPath('.//*' + cond, element) : [];
} : function(element, className) {
className = className.toString().strip();
var elements = [], classNames = (/\s/.test(className) ? $w(className) : null);
if (!classNames && !className) return elements;
var nodes = $(element).getElementsByTagName('*');
className = ' ' + className + ' ';
for (var i = 0, child, cn; child = nodes[i]; i++) {
if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
(classNames && classNames.all(function(name) {
return !name.toString().blank() && cn.include(' ' + name + ' ');
}))))
elements.push(Element.extend(child));
}
return elements;
};
return function(className, parentElement) {
return $(parentElement || document.body).getElementsByClassName(className);
};
}(Element.Methods);
/*--------------------------------------------------------------------------*/
Element.ClassNames = Class.create();
Element.ClassNames.prototype = {
initialize: function(element) {
this.element = $(element);
},
_each: function(iterator) {
this.element.className.split(/\s+/).select(function(name) {
return name.length > 0;
})._each(iterator);
},
set: function(className) {
this.element.className = className;
},
add: function(classNameToAdd) {
if (this.include(classNameToAdd)) return;
this.set($A(this).concat(classNameToAdd).join(' '));
},
remove: function(classNameToRemove) {
if (!this.include(classNameToRemove)) return;
this.set($A(this).without(classNameToRemove).join(' '));
},
toString: function() {
return $A(this).join(' ');
}
};
Object.extend(Element.ClassNames.prototype, Enumerable);
/*--------------------------------------------------------------------------*/
Element.addMethods(); | amastov/studiocracy-public | vendor/bundle/ruby/2.2.0/gems/json-1.8.2/data/prototype.js | JavaScript | gpl-3.0 | 124,134 | [
30522,
1013,
1008,
8773,
9262,
22483,
7705,
1010,
2544,
1015,
1012,
1020,
1012,
1014,
1008,
1006,
1039,
1007,
2384,
1011,
2289,
3520,
19789,
1008,
1008,
8773,
2003,
10350,
4487,
3367,
3089,
8569,
10880,
2104,
1996,
3408,
1997,
2019,
10210,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package net.sourcewalker.svnnotify.data.xmldb;
import java.util.Date;
import net.sourcewalker.svnnotify.data.interfaces.IRevision;
/**
* Revision class to be used with the flat-file XML database implementation in
* {@link XmlDatabase}.
*
* @author Xperimental
*/
public class XmlRevision implements IRevision {
/**
* Contains the revision number.
*/
private int revision;
/**
* Contains the revision author.
*/
private String author;
/**
* Contains the commit message of the revision.
*/
private String message;
/**
* Contains the creation time of the revision.
*/
private Date timestamp;
/**
* Create a new instance of the class with the attributes initialized to the
* specified values.
*
* @param revNumber
* Revision number.
* @param revAuthor
* Revision author.
* @param revTime
* Creation time of revision.
* @param revMessage
* Commit message of revision.
*/
public XmlRevision(final int revNumber, final String revAuthor,
final Date revTime, final String revMessage) {
this.revision = revNumber;
this.author = revAuthor;
this.timestamp = revTime;
this.message = revMessage;
}
@Override
public final int getRevision() {
return revision;
}
@Override
public final String getAuthor() {
return author;
}
@Override
public final String getMessage() {
return message;
}
@Override
public final Date getTimestamp() {
return timestamp;
}
}
| xperimental/svn-notify | src/net/sourcewalker/svnnotify/data/xmldb/XmlRevision.java | Java | gpl-3.0 | 1,667 | [
30522,
7427,
5658,
1012,
3120,
26965,
1012,
17917,
10695,
4140,
8757,
1012,
2951,
1012,
20950,
18939,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
3058,
1025,
12324,
5658,
1012,
3120,
26965,
1012,
17917,
10695,
4140,
8757,
1012,
2951,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#ifndef __CXXU_TYPE_TRAITS_H__
#define __CXXU_TYPE_TRAITS_H__
#include <type_traits>
#include <memory>
namespace cxxu {
template <typename T>
struct is_shared_ptr_helper : std::false_type
{
typedef T element_type;
static
element_type& deref(element_type& e)
{ return e; }
static
const element_type& deref(const element_type& e)
{ return e; }
};
template <typename T>
struct is_shared_ptr_helper<std::shared_ptr<T>> : std::true_type
{
typedef typename std::remove_cv<T>::type element_type;
typedef std::shared_ptr<element_type> ptr_type;
static
element_type& deref(ptr_type& p)
{ return *p; }
static
const element_type& deref(const ptr_type& p)
{ return *p; }
};
template <typename T>
struct is_shared_ptr
: is_shared_ptr_helper<typename std::remove_cv<T>::type>
{};
} // namespace cxxu
#endif // __CXXU_TYPE_TRAITS_H__
| ExpandiumSAS/cxxutils | sources/include/cxxu/cxxu/type_traits.hpp | C++ | mit | 890 | [
30522,
1001,
2065,
13629,
2546,
1035,
1035,
1039,
20348,
2226,
1035,
2828,
1035,
12955,
1035,
1044,
1035,
1035,
1001,
9375,
1035,
1035,
1039,
20348,
2226,
1035,
2828,
1035,
12955,
1035,
1044,
1035,
1035,
1001,
2421,
1026,
2828,
1035,
12955,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<button class="submit" account-manage-delete-account-dir>Delete my account</button> | thlem/Agilog | src/partials/account/manage/account-manage-delete-account.html | HTML | mit | 83 | [
30522,
1026,
6462,
2465,
1027,
1000,
12040,
1000,
4070,
1011,
6133,
1011,
3972,
12870,
1011,
4070,
1011,
16101,
1028,
3972,
12870,
2026,
4070,
1026,
1013,
6462,
1028,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/** @jsx jsx */
import { Editor } from 'slate'
import { jsx } from '../..'
export const input = (
<editor>
<block>
<mark key="a">
<anchor />o
</mark>
n
<mark key="b">
e<focus />
</mark>
</block>
</editor>
)
export const run = editor => {
return Array.from(Editor.activeMarks(editor, { union: true }))
}
export const output = [{ key: 'a' }, { key: 'b' }]
| isubastiCadmus/slate | packages/slate/test/queries/activeMarks/union.js | JavaScript | mit | 418 | [
30522,
1013,
1008,
1008,
1030,
1046,
2015,
2595,
1046,
2015,
2595,
1008,
1013,
12324,
1063,
3559,
1065,
2013,
1005,
12796,
1005,
12324,
1063,
1046,
2015,
2595,
1065,
2013,
1005,
1012,
1012,
1013,
1012,
1012,
1005,
9167,
9530,
3367,
7953,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* @file id_10361.c
* @brief AOAPC I 10361
* @author chenxilinsidney
* @version 1.0
* @date 2015-03-24
*/
#include <stdio.h>
#include <string.h>
#define MAX_LINE_LENGTH 101
char line[2][MAX_LINE_LENGTH];
int main()
{
int num_case;
scanf("%d\n", &num_case);
while (num_case--) {
gets(*line);
gets(*(line+ 1));
int line_length_a = strlen(*line);
int line_length_b = strlen(*(line + 1));
int line_index = 0;
int char_position[4] = {0};
int position_index = 0;
/* output first line */
while (line_index < line_length_a) {
int character = line[0][line_index];
if (character != '<' && character != '>')
putchar(character);
else
char_position[position_index++] = line_index;
line_index++;
}
printf("\n");
/* output second line */
line[1][line_length_b - 3] = '\0';
printf("%s", line[1]);
for (position_index = 2; position_index >= 0; position_index--)
for (line_index = char_position[position_index] + 1; line_index <
char_position[position_index + 1]; line_index++)
putchar(line[0][line_index]);
printf("%s", line[0] + char_position[3] + 1);
printf("\n");
}
return 0;
}
| chenxilinsidney/funnycprogram | acm/aoapc/id_10361.c | C | gpl-2.0 | 1,360 | [
30522,
1013,
1008,
1008,
1008,
1030,
5371,
8909,
1035,
9800,
2575,
2487,
1012,
1039,
1008,
1030,
4766,
20118,
9331,
2278,
1045,
9800,
2575,
2487,
1008,
1030,
3166,
8802,
9048,
24412,
3593,
5420,
1008,
1030,
2544,
1015,
1012,
1014,
1008,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
using System.Collections.Generic;
using System.Net;
using Enyim.Caching.Memcached;
namespace Enyim.Caching.Configuration
{
/// <summary>
/// Defines an interface for configuring the <see cref="T:MemcachedClient"/>.
/// </summary>
public interface IMemcachedClientConfiguration
{
/// <summary>
/// Gets a list of <see cref="T:IPEndPoint"/> each representing a Memcached server in the pool.
/// </summary>
IList<EndPoint> Servers { get; }
/// <summary>
/// Gets the configuration of the socket pool.
/// </summary>
ISocketPoolConfiguration SocketPool { get; }
/// <summary>
/// Gets the authentication settings.
/// </summary>
IAuthenticationConfiguration Authentication { get; }
/// <summary>
/// Creates an <see cref="T:Enyim.Caching.Memcached.IMemcachedKeyTransformer"/> instance which will be used to convert item keys for Memcached.
/// </summary>
IMemcachedKeyTransformer CreateKeyTransformer();
/// <summary>
/// Creates an <see cref="T:Enyim.Caching.Memcached.IMemcachedNodeLocator"/> instance which will be used to assign items to Memcached nodes.
/// </summary>
IMemcachedNodeLocator CreateNodeLocator();
/// <summary>
/// Creates an <see cref="T:Enyim.Caching.Memcached.ITranscoder"/> instance which will be used to serialize or deserialize items.
/// </summary>
ITranscoder CreateTranscoder();
IServerPool CreatePool();
}
}
#region [ License information ]
/* ************************************************************
*
* Copyright (c) 2010 Attila Kisk? enyim.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ************************************************************/
#endregion
| DukeCheng/EnyimMemcachedCore | Enyim.Caching/Configuration/IMemcachedClientConfiguration.cs | C# | apache-2.0 | 2,250 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
5658,
1025,
2478,
4372,
10139,
2213,
1012,
6187,
8450,
1012,
2033,
12458,
15395,
2094,
1025,
3415,
15327,
4372,
10139,
2213,
1012,
6187,
8450,
1012,
9563,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Xml;
using System.Xml.Serialization;
using SubSonic;
using SubSonic.Utilities;
// <auto-generated />
namespace Southwind{
/// <summary>
/// Strongly-typed collection for the OrderSubtotal class.
/// </summary>
[Serializable]
public partial class OrderSubtotalCollection : ReadOnlyList<OrderSubtotal, OrderSubtotalCollection>
{
public OrderSubtotalCollection() {}
}
/// <summary>
/// This is Read-only wrapper class for the order subtotals view.
/// </summary>
[Serializable]
public partial class OrderSubtotal : ReadOnlyRecord<OrderSubtotal>, IReadOnlyRecord
{
#region Default Settings
protected static void SetSQLProps()
{
GetTableSchema();
}
#endregion
#region Schema Accessor
public static TableSchema.Table Schema
{
get
{
if (BaseSchema == null)
{
SetSQLProps();
}
return BaseSchema;
}
}
private static void GetTableSchema()
{
if(!IsSchemaInitialized)
{
//Schema declaration
TableSchema.Table schema = new TableSchema.Table("order subtotals", TableType.View, DataService.GetInstance("Southwind"));
schema.Columns = new TableSchema.TableColumnCollection();
schema.SchemaName = @"";
//columns
TableSchema.TableColumn colvarOrderID = new TableSchema.TableColumn(schema);
colvarOrderID.ColumnName = "OrderID";
colvarOrderID.DataType = DbType.Int32;
colvarOrderID.MaxLength = 10;
colvarOrderID.AutoIncrement = false;
colvarOrderID.IsNullable = false;
colvarOrderID.IsPrimaryKey = false;
colvarOrderID.IsForeignKey = false;
colvarOrderID.IsReadOnly = false;
schema.Columns.Add(colvarOrderID);
TableSchema.TableColumn colvarSubtotal = new TableSchema.TableColumn(schema);
colvarSubtotal.ColumnName = "Subtotal";
colvarSubtotal.DataType = DbType.Decimal;
colvarSubtotal.MaxLength = 0;
colvarSubtotal.AutoIncrement = false;
colvarSubtotal.IsNullable = true;
colvarSubtotal.IsPrimaryKey = false;
colvarSubtotal.IsForeignKey = false;
colvarSubtotal.IsReadOnly = false;
schema.Columns.Add(colvarSubtotal);
BaseSchema = schema;
//add this schema to the provider
//so we can query it later
DataService.Providers["Southwind"].AddSchema("order subtotals",schema);
}
}
#endregion
#region Query Accessor
public static Query CreateQuery()
{
return new Query(Schema);
}
#endregion
#region .ctors
public OrderSubtotal()
{
SetSQLProps();
SetDefaults();
MarkNew();
}
public OrderSubtotal(bool useDatabaseDefaults)
{
SetSQLProps();
if(useDatabaseDefaults)
{
ForceDefaults();
}
MarkNew();
}
public OrderSubtotal(object keyID)
{
SetSQLProps();
LoadByKey(keyID);
}
public OrderSubtotal(string columnName, object columnValue)
{
SetSQLProps();
LoadByParam(columnName,columnValue);
}
#endregion
#region Props
[XmlAttribute("OrderID")]
[Bindable(true)]
public int OrderID
{
get
{
return GetColumnValue<int>("OrderID");
}
set
{
SetColumnValue("OrderID", value);
}
}
[XmlAttribute("Subtotal")]
[Bindable(true)]
public decimal? Subtotal
{
get
{
return GetColumnValue<decimal?>("Subtotal");
}
set
{
SetColumnValue("Subtotal", value);
}
}
#endregion
#region Columns Struct
public struct Columns
{
public static string OrderID = @"OrderID";
public static string Subtotal = @"Subtotal";
}
#endregion
#region IAbstractRecord Members
public new CT GetColumnValue<CT>(string columnName) {
return base.GetColumnValue<CT>(columnName);
}
public object GetColumnValue(string columnName) {
return base.GetColumnValue<object>(columnName);
}
#endregion
}
}
| w8in/SubSonic-2.0 | SubSonic.Tests/Generated/Southwind/OrderSubtotal.cs | C# | bsd-3-clause | 5,138 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
3793,
1025,
30524,
12391,
1025,
2478,
2291,
1012,
6922,
5302,
9247,
1025,
2478,
2291,
1012,
9563,
1025,
2478,
2291,
1012,
20950,
1025,
2478,
2291,
1012,
20950,
1012,
7642,
3989,
1025,
2478,
4942,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
.size 8000
.text@48
jp lstatint
.text@100
jp lbegin
.data@143
c0
.text@150
lbegin:
ld a, 04
ldff(43), a
ld b, 42
call lwaitly_b
ld a, 40
ldff(41), a
ld a, 02
ldff(ff), a
xor a, a
ldff(0f), a
ei
ld a, 44
ldff(45), a
.text@1000
lstatint:
ld a, 30
ldff(00), a
xor a, a
ldff(ff), a
inc a
ldff(4d), a
nop
stop, 00
ldff(4d), a
nop
stop, 00
.text@101f
ldff a, (41)
jp lprint_a
.text@7000
lprint_a:
push af
ld b, 91
call lwaitly_b
xor a, a
ldff(40), a
ld bc, 7a00
ld hl, 8000
ld d, 00
lprint_copytiles:
ld a, (bc)
inc bc
ld(hl++), a
dec d
jrnz lprint_copytiles
pop af
ld b, a
swap a
and a, 0f
ld(9800), a
ld a, b
and a, 0f
ld(9801), a
ld a, c0
ldff(47), a
ld a, 80
ldff(68), a
ld a, ff
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
xor a, a
ldff(69), a
ldff(69), a
ldff(43), a
ld a, 91
ldff(40), a
lprint_limbo:
jr lprint_limbo
.text@7400
lwaitly_b:
ld c, 44
lwaitly_b_loop:
ldff a, (c)
cmp a, b
jrnz lwaitly_b_loop
ret
.data@7a00
00 00 7f 7f 41 41 41 41
41 41 41 41 41 41 7f 7f
00 00 08 08 08 08 08 08
08 08 08 08 08 08 08 08
00 00 7f 7f 01 01 01 01
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 01 01 01 01
3f 3f 01 01 01 01 7f 7f
00 00 41 41 41 41 41 41
7f 7f 01 01 01 01 01 01
00 00 7f 7f 40 40 40 40
7e 7e 01 01 01 01 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 41 41 41 41 7f 7f
00 00 7f 7f 01 01 02 02
04 04 08 08 10 10 10 10
00 00 3e 3e 41 41 41 41
3e 3e 41 41 41 41 3e 3e
00 00 7f 7f 41 41 41 41
7f 7f 01 01 01 01 7f 7f
00 00 08 08 22 22 41 41
7f 7f 41 41 41 41 41 41
00 00 7e 7e 41 41 41 41
7e 7e 41 41 41 41 7e 7e
00 00 3e 3e 41 41 40 40
40 40 40 40 41 41 3e 3e
00 00 7e 7e 41 41 41 41
41 41 41 41 41 41 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 40 40 40 40
7f 7f 40 40 40 40 40 40
| Ben10do/gambatte | test/hwtests/speedchange/speedchange2_nop_ly44_m3_nop_m3stat_scx4_1_cgb04c_outC3.asm | Assembly | gpl-2.0 | 1,832 | [
30522,
1012,
2946,
5385,
2692,
1012,
3793,
1030,
4466,
16545,
1048,
9153,
7629,
2102,
1012,
3793,
1030,
2531,
16545,
6053,
13910,
2378,
1012,
2951,
1030,
16065,
1039,
2692,
1012,
3793,
1030,
5018,
6053,
13910,
2378,
1024,
25510,
1037,
1010,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="BloggerCMS" />
<meta name="description" content="BloggerCMS Official Blog">
<meta name="author" content="BloggerCMS">
<title>BloggerCMS Blog</title>
<!-- rss feed url -->
<link rel="alternate" type="application/rss+xml" title="BloggerCMS Blog" href="https://bloggercms.github.io/rss.xml"/>
<!-- favicon -->
<link rel="shortcut icon" href="/favicon.ico"/>
<link rel="shortcut icon" href="https://bloggercms.github.io/favicon.ico"/>
<!-- Bootstrap CSS file -->
<link href="https://bloggercms.github.io/js/plugins/bootstrap-3.0.3/css/slate.min.css" rel="stylesheet"/>
<link href="https://bloggercms.github.io/js/plugins/font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://bloggercms.github.io/js/plugins/bootstrap-3.0.3/plugins/social-buttons.css" rel="stylesheet"/>
<!-- syntax highlighter css file -->
<link href="https://bloggercms.github.io/js/plugins/highlight/styles/railscasts.css" rel="stylesheet" />
<!-- lightbox for images -->
<link href="https://bloggercms.github.io/js/plugins/lightbox/ekko-lightbox.min.css" rel="stylesheet" />
<!-- blog custom CSS file -->
<link href="https://bloggercms.github.io/css/style.css" rel="stylesheet"/>
</head><body>
<!-- Header -->
<header class="navbar navbar-default
navbar-fixed-top bs-docs-nav" role="banner">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="https://bloggercms.github.io/index.html" class="navbar-brand"><i class="fa fa-edit"></i> BloggerCMS Blog</a>
</div>
<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
<div class="navbar-form navbar-right" role="search">
<div class="form-group">
<input type="text" class="searchQuery form-control" placeholder="Search Posts">
</div>
<button type="button" class="searchButton btn btn-default"><i class="glyphicon glyphicon-search"></i>
Submit
</button>
</div>
<ul class="nav navbar-nav page-links">
<li><a href="https://bloggercms.github.io/page/get-started.html">Get Started</a></li>
<li><a href="https://bloggercms.github.io/page/about.html">About</a></li>
<li><a href="https://bloggercms.github.io/page/showcase.html">Showcase</a></li>
<li><a href="https://bloggercms.github.io/page/support.html">Support</a></li>
<li><a href="https://bloggercms.github.io/page/donations.html">Donations</a></li>
</ul>
</nav>
</div>
</header>
<div class="container">
<div class="row">
<div class="col-md-8 main-content">
<h1>Category Posts</h1>
<hr/>
<br/>
<h3><a href="https://bloggercms.github.io/post/how-to-use-specific-custom-value-in-layouts.html">How to Use Specific Custom Value in Layouts</a></h3>
<span class="glyphicon glyphicon-time"></span> April 11, 2015 10:20 AM
<h3><a href="https://bloggercms.github.io/post/how-to-add-pagination-feature-to-custom-bloggercms-layouts.html">How to Add Pagination Feature to Custom BloggerCMS Layouts</a></h3>
<span class="glyphicon glyphicon-time"></span> April 10, 2015 10:40 AM
<h3><a href="https://bloggercms.github.io/post/how-to-add-search-feature-to-custom-bloggercms-layouts.html">How to Add Search Feature to Custom BloggerCMS Layouts</a></h3>
<span class="glyphicon glyphicon-time"></span> April 09, 2015 04:03 PM
<h3><a href="https://bloggercms.github.io/post/new-layout-initializr.html">New Layout: Initializr</a></h3>
<span class="glyphicon glyphicon-time"></span> April 09, 2015 12:05 AM
</div>
<div class="sidebar col-md-4">
<div class="well text-center">
<a href="https://github.com/sarfraznawaz2005/BloggerCMS" class="btn btn-success"><i class="fa fa-download"></i> Download BloggerCMS</a>
</div>
<!-- Follow Panel -->
<div class="panel panel-primary text-center">
<div class="panel-heading">
<strong>Follow BloggerCMS Blog</strong>
</div>
<div class="panel-body">
<a target="_blank" href="https://bloggercms.github.io/rss.xml" class="btn btn-social-icon btn-outline"><i class="fa fa-rss"></i></a>
<a target="_blank" href="https://github.com/bloggercms/bloggercms.github.io" class="btn btn-social-icon btn-github"><i class="fa fa-github"></i></a>
</div>
</div>
<!-- Latest Posts -->
<div class="panel panel-primary">
<div class="panel-heading">
<strong>Latest Posts</strong>
</div>
<ul class="list-group">
<li class="list-group-item"><a href="https://bloggercms.github.io/post/how-to-use-specific-custom-value-in-layouts.html">How to Use Specific Custom Value in Layouts</a></li>
<li class="list-group-item"><a href="https://bloggercms.github.io/post/bloggercms-added-to-list-of-static-site-generators.html">BloggerCMS Added to List of Static Site Generators</a></li>
<li class="list-group-item"><a href="https://bloggercms.github.io/post/how-to-add-pagination-feature-to-custom-bloggercms-layouts.html">How to Add Pagination Feature to Custom BloggerCMS Layouts</a></li>
<li class="list-group-item"><a href="https://bloggercms.github.io/post/how-to-add-search-feature-to-custom-bloggercms-layouts.html">How to Add Search Feature to Custom BloggerCMS Layouts</a></li>
<li class="list-group-item"><a href="https://bloggercms.github.io/post/how-to-create-a-layout-for-bloggercms.html">How to Create a Layout for BloggerCMS</a></li>
</ul>
</div>
<!-- Categories -->
<div class="panel panel-primary">
<div class="panel-heading">
<strong>Categories</strong>
</div>
<ul class="list-group">
<li class="list-group-item"><a href="https://bloggercms.github.io/category/bloggercms.html">BloggerCMS</a></li>
<li class="list-group-item"><a href="https://bloggercms.github.io/category/layouts.html">Layouts</a></li>
<li class="list-group-item"><a href="https://bloggercms.github.io/category/tutorial.html">Tutorial</a></li>
</ul>
</div>
<!-- Archives -->
<div class="panel panel-primary">
<div class="panel-heading">
<strong>Archives</strong>
</div>
<ul class="archives list-group"><li class="list-group-item archive_link"><a href="https://bloggercms.github.io/archive/april-2015">April 2015</a></li></ul>
</div>
<!-- Tags -->
<div class="panel panel-primary">
<div class="panel-heading">
<strong>Tags Cloud</strong>
</div>
<div class="panel-body">
<ul class="list-inline">
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/admin.html" title="'admin' returned a count of 0">admin</a>
<a style="font-size: 21px" class="tag_cloud" href="https://bloggercms.github.io/tag/bloggercms.html" title="'bloggercms' returned a count of 2">bloggercms</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/cms.html" title="'cms' returned a count of 0">cms</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/custom.html" title="'custom' returned a count of 0">custom</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/disqus.html" title="'disqus' returned a count of 0">disqus</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/image.html" title="'image' returned a count of 0">image</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/imagemanager.html" title="'imagemanager' returned a count of 0">imagemanager</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/initializr.html" title="'initializr' returned a count of 0">initializr</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/intro.html" title="'intro' returned a count of 0">intro</a>
<a style="font-size: 30px" class="tag_cloud" href="https://bloggercms.github.io/tag/layout.html" title="'layout' returned a count of 4">layout</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/page.html" title="'page' returned a count of 0">page</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/pagination.html" title="'pagination' returned a count of 0">pagination</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/paging.html" title="'paging' returned a count of 0">paging</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/php.html" title="'php' returned a count of 0">php</a>
<a style="font-size: 16px" class="tag_cloud" href="https://bloggercms.github.io/tag/post.html" title="'post' returned a count of 1">post</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/search.html" title="'search' returned a count of 0">search</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/settings.html" title="'settings' returned a count of 0">settings</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/template.html" title="'template' returned a count of 0">template</a>
<a style="font-size: 25px" class="tag_cloud" href="https://bloggercms.github.io/tag/tutorial.html" title="'tutorial' returned a count of 3">tutorial</a>
<a style="font-size: 12px" class="tag_cloud" href="https://bloggercms.github.io/tag/value.html" title="'value' returned a count of 0">value</a>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- Footer -->
<footer>
<div class="container">
<hr/>
<p class="text-center">Published by <strong><a target="_blank" href="https://github.com/sarfraznawaz2005/BloggerCMS">BloggerCMS</a></strong></p>
</div>
</footer>
<!-- Jquery and Bootstrap Script files -->
<script src="https://bloggercms.github.io/js/jquery-2.0.3.min.js"></script>
<script src="https://bloggercms.github.io/js/plugins/bootstrap-3.0.3/js/bootstrap.min.js"></script>
<script src="https://bloggercms.github.io/js/plugins/highlight/highlight.pack.js"></script>
<script src="https://bloggercms.github.io/js/plugins/lightbox/ekko-lightbox.min.js"></script>
<script>
var __blogURL = 'https://bloggercms.github.io';
</script>
<script src="https://bloggercms.github.io/js/blog.js"></script>
<script src="https://bloggercms.github.io/js/search.js"></script>
</body>
</html> | bloggercms/bloggercms.github.io | category/layouts.html | HTML | mit | 12,211 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,user-scalable=no" />
<title>无标题文档</title>
<script>
var html = document.getElementsByTagName("html")[0];
setRem();
window.addEventListener("resize",setRem,false);
window.addEventListener("orientationchange",setRem,false);
function setRem(){
var witdh = html.getBoundingClientRect().width;
html.style.fontSize = witdh/16 + "px";
}
</script>
<style>
html ,body{
height: 100%;
overflow: hidden;
font-size: .6rem;
font-family: "宋体";
background: #ccc;
}
body,ul {
margin: 0;
padding: 0;
}
li {
list-style: none;
}
img {
vertical-align: middle;
}
header {
height: 2rem;
background: #000;
color: #fff;
text-align: center;
line-height: 2rem;
font-size: .8rem;
}
#wrap {
position: absolute;
top: 2rem;
bottom: 0;
left: 0;
right: 0;
overflow: hidden;
}
#list {
overflow: hidden;
}
#list li{
width: 6rem;
height: 6rem;
margin: .5rem;
border: .5rem solid #fff;
border-radius: .25rem;
box-shadow: 0 0 10px rgba(0, 0, 0, .5);
float: left;
background:url(pics/loadingImg.gif) no-repeat center center;
}
#list img {
width: 6rem;
opacity: 0;
}
footer{
background: #fff;
font: .6rem / 60px "宋体";
text-align: center;
color: #333;
position: absolute;
bottom: -60px;
left: 0;
right: 0;
}
footer img {
height: 40px;
}
#scroll {
position: relative;
}
</style>
<script src="miaov.touch.js"></script>
<script>
var aImg = [];
for(var i =0; i < 200 ; i++){
aImg[i] = "pics/"+(i%16+1)+".jpg";
}
</script>
<script>
window.onload = function(){
var wrap = document.getElementById("wrap");
var list = document.getElementById("list");
var imgW = html.getBoundingClientRect().width/2;
var wrapClient = wrap.clientHeight;
var length = 16//Math.ceil(wrapClient / imgW)*2;
var lis = wrap.getElementsByTagName("li");
var Scroll = null;
createImg();
function createImg(){
var start = lis.length;
var end = start + length;
for(var i = start; i < end; i++){
create(i);
}
function create(i){
var li = document.createElement("li");
var img = document.createElement("img");
li.appendChild(img);
list.appendChild(li);
var newImg = new Image();
newImg.src = aImg[i];
newImg.onload = function(){
img.src = aImg[i];
mTween(img,{opacity: 100},300,"easeOut");
};
}
if(!Scroll){
initScroll();
}
}
function initScroll(){
Scroll = new MScroll(
{
element: wrap,
showBar: true,
dir: "y",
isOver: true,
offMove: false
}
);
Scroll.backout = 60;
Scroll.onscrollend = function(target){
if(target == this.minTranslate){
console.log("动画结束之后,加载新的");
}
if(this.iScroll < this.minTranslate){
console.log("不需要回弹,直接加载新的");
}
}
}
};
</script>
</head>
<body>
<header id="header">miaov--下拉加载</header>
<section id="wrap">
<div id="scroll">
<ul id="list">
</ul>
<footer><img src="pics/loading.gif" />加载更多</footer>
</div>
</section>
</body>
</html>
| skybjf/MyTestProject | 20160423/2_下拉加载.html | HTML | mit | 3,061 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
18804,
2171,
1027,
1000,
3193,
6442,
1000,
4180,
1027,
1000,
9381,
1027,
5080... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_COMMON_DATA_REDUCTION_PROXY_HEADERS_TEST_UTILS_H_
#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_COMMON_DATA_REDUCTION_PROXY_HEADERS_TEST_UTILS_H_
#include <string>
namespace data_reduction_proxy {
// Transform "normal"-looking headers (\n-separated) to the appropriate
// input format for ParseRawHeaders (\0-separated).
void HeadersToRaw(std::string* headers);
} // namespace data_reduction_proxy
#endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_COMMON_DATA_REDUCTION_PROXY_HEADERS_TEST_UTILS_H_
| ssaroha/node-webrtc | third_party/webrtc/include/chromium/src/components/data_reduction_proxy/core/common/data_reduction_proxy_headers_test_utils.h | C | bsd-2-clause | 711 | [
30522,
1013,
1013,
9385,
2297,
1996,
10381,
21716,
5007,
6048,
1012,
2035,
2916,
9235,
1012,
1013,
1013,
2224,
1997,
2023,
3120,
3642,
2003,
9950,
2011,
1037,
18667,
2094,
1011,
2806,
6105,
2008,
2064,
2022,
1013,
1013,
2179,
1999,
1996,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Listview Responsive Grid - jQuery Mobile Demos</title>
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" href="../css/themes/default/jquery.mobile-1.4.2.min.css">
<link rel="stylesheet" href="listview-grid.css">
<script src="../js/jquery.js"></script>
<script src="../js/jquery.mobile-1.4.2.min.js"></script>
</head>
<body>
<div data-role="page" data-theme="b" id="demo-page" class="my-page">
<div data-role="header">
<h1>Listview Responsive Grid</h1>
<a href="./" data-shadow="false" data-iconshadow="false" data-icon="carat-l" data-iconpos="notext" data-rel="back" data-ajax="false">Back</a>
</div><!-- /header -->
<div role="main" class="ui-content">
<ul data-role="listview" data-inset="true">
<li><a href="#">
<img src="../_assets/img/apple.png" class="ui-li-thumb">
<h2>iOS 6.1</h2>
<p>Apple released iOS 6.1</p>
<p class="ui-li-aside">iOS</p>
</a></li>
<li><a href="#">
<img src="../_assets/img/blackberry_10.png" class="ui-li-thumb">
<h2>BlackBerry 10</h2>
<p>BlackBerry launched the Z10 and Q10 with the new BB10 OS</p>
<p class="ui-li-aside">BlackBerry</p>
</a></li>
<li><a href="#">
<img src="../_assets/img/lumia_800.png" class="ui-li-thumb">
<h2>WP 7.8</h2>
<p>Nokia rolls out WP 7.8 to Lumia 800</p>
<p class="ui-li-aside">Windows Phone</p>
</a></li>
<li><a href="#">
<img src="../_assets/img/galaxy_express.png" class="ui-li-thumb">
<h2>Galaxy</h2>
<p>New Samsung Galaxy Express</p>
<p class="ui-li-aside">Samsung</p>
</a></li>
<li><a href="#">
<img src="../_assets/img/nexus_7.png" class="ui-li-thumb">
<h2>Nexus 7</h2>
<p>Rumours about new full HD Nexus 7</p>
<p class="ui-li-aside">Android</p>
</a></li>
<li><a href="#">
<img src="../_assets/img/firefox_os.png" class="ui-li-thumb">
<h2>Firefox OS</h2>
<p>ZTE to launch Firefox OS smartphone at MWC</p>
<p class="ui-li-aside">Firefox</p>
</a></li>
<li><a href="#">
<img src="../_assets/img/tizen.png" class="ui-li-thumb">
<h2>Tizen</h2>
<p>First Samsung phones with Tizen can be expected in 2013</p>
<p class="ui-li-aside">Tizen</p>
</a></li>
<li><a href="#">
<h2>Symbian</h2>
<p>Nokia confirms the end of Symbian</p>
<p class="ui-li-aside">Symbian</p>
</a></li>
</ul>
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>
| gitubo/watchnwater | www/js/demos/listview-grid/listview-grid.html | HTML | gpl-3.0 | 3,087 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
18804,
2171,
1027,
1000,
3193,
6442,
1000,
4180,
1027,
1000,
9381,
1027,
5080... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2014-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.worklink.model;
import java.io.Serializable;
import javax.annotation.Generated;
/**
*
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/worklink-2018-09-25/DescribeDevice" target="_top">AWS API
* Documentation</a>
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class DescribeDeviceResult extends com.amazonaws.AmazonWebServiceResult<com.amazonaws.ResponseMetadata> implements Serializable, Cloneable {
/**
* <p>
* The current state of the device.
* </p>
*/
private String status;
/**
* <p>
* The model of the device.
* </p>
*/
private String model;
/**
* <p>
* The manufacturer of the device.
* </p>
*/
private String manufacturer;
/**
* <p>
* The operating system of the device.
* </p>
*/
private String operatingSystem;
/**
* <p>
* The operating system version of the device.
* </p>
*/
private String operatingSystemVersion;
/**
* <p>
* The operating system patch level of the device.
* </p>
*/
private String patchLevel;
/**
* <p>
* The date that the device first signed in to Amazon WorkLink.
* </p>
*/
private java.util.Date firstAccessedTime;
/**
* <p>
* The date that the device last accessed Amazon WorkLink.
* </p>
*/
private java.util.Date lastAccessedTime;
/**
* <p>
* The user name associated with the device.
* </p>
*/
private String username;
/**
* <p>
* The current state of the device.
* </p>
*
* @param status
* The current state of the device.
* @see DeviceStatus
*/
public void setStatus(String status) {
this.status = status;
}
/**
* <p>
* The current state of the device.
* </p>
*
* @return The current state of the device.
* @see DeviceStatus
*/
public String getStatus() {
return this.status;
}
/**
* <p>
* The current state of the device.
* </p>
*
* @param status
* The current state of the device.
* @return Returns a reference to this object so that method calls can be chained together.
* @see DeviceStatus
*/
public DescribeDeviceResult withStatus(String status) {
setStatus(status);
return this;
}
/**
* <p>
* The current state of the device.
* </p>
*
* @param status
* The current state of the device.
* @return Returns a reference to this object so that method calls can be chained together.
* @see DeviceStatus
*/
public DescribeDeviceResult withStatus(DeviceStatus status) {
this.status = status.toString();
return this;
}
/**
* <p>
* The model of the device.
* </p>
*
* @param model
* The model of the device.
*/
public void setModel(String model) {
this.model = model;
}
/**
* <p>
* The model of the device.
* </p>
*
* @return The model of the device.
*/
public String getModel() {
return this.model;
}
/**
* <p>
* The model of the device.
* </p>
*
* @param model
* The model of the device.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public DescribeDeviceResult withModel(String model) {
setModel(model);
return this;
}
/**
* <p>
* The manufacturer of the device.
* </p>
*
* @param manufacturer
* The manufacturer of the device.
*/
public void setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
}
/**
* <p>
* The manufacturer of the device.
* </p>
*
* @return The manufacturer of the device.
*/
public String getManufacturer() {
return this.manufacturer;
}
/**
* <p>
* The manufacturer of the device.
* </p>
*
* @param manufacturer
* The manufacturer of the device.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public DescribeDeviceResult withManufacturer(String manufacturer) {
setManufacturer(manufacturer);
return this;
}
/**
* <p>
* The operating system of the device.
* </p>
*
* @param operatingSystem
* The operating system of the device.
*/
public void setOperatingSystem(String operatingSystem) {
this.operatingSystem = operatingSystem;
}
/**
* <p>
* The operating system of the device.
* </p>
*
* @return The operating system of the device.
*/
public String getOperatingSystem() {
return this.operatingSystem;
}
/**
* <p>
* The operating system of the device.
* </p>
*
* @param operatingSystem
* The operating system of the device.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public DescribeDeviceResult withOperatingSystem(String operatingSystem) {
setOperatingSystem(operatingSystem);
return this;
}
/**
* <p>
* The operating system version of the device.
* </p>
*
* @param operatingSystemVersion
* The operating system version of the device.
*/
public void setOperatingSystemVersion(String operatingSystemVersion) {
this.operatingSystemVersion = operatingSystemVersion;
}
/**
* <p>
* The operating system version of the device.
* </p>
*
* @return The operating system version of the device.
*/
public String getOperatingSystemVersion() {
return this.operatingSystemVersion;
}
/**
* <p>
* The operating system version of the device.
* </p>
*
* @param operatingSystemVersion
* The operating system version of the device.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public DescribeDeviceResult withOperatingSystemVersion(String operatingSystemVersion) {
setOperatingSystemVersion(operatingSystemVersion);
return this;
}
/**
* <p>
* The operating system patch level of the device.
* </p>
*
* @param patchLevel
* The operating system patch level of the device.
*/
public void setPatchLevel(String patchLevel) {
this.patchLevel = patchLevel;
}
/**
* <p>
* The operating system patch level of the device.
* </p>
*
* @return The operating system patch level of the device.
*/
public String getPatchLevel() {
return this.patchLevel;
}
/**
* <p>
* The operating system patch level of the device.
* </p>
*
* @param patchLevel
* The operating system patch level of the device.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public DescribeDeviceResult withPatchLevel(String patchLevel) {
setPatchLevel(patchLevel);
return this;
}
/**
* <p>
* The date that the device first signed in to Amazon WorkLink.
* </p>
*
* @param firstAccessedTime
* The date that the device first signed in to Amazon WorkLink.
*/
public void setFirstAccessedTime(java.util.Date firstAccessedTime) {
this.firstAccessedTime = firstAccessedTime;
}
/**
* <p>
* The date that the device first signed in to Amazon WorkLink.
* </p>
*
* @return The date that the device first signed in to Amazon WorkLink.
*/
public java.util.Date getFirstAccessedTime() {
return this.firstAccessedTime;
}
/**
* <p>
* The date that the device first signed in to Amazon WorkLink.
* </p>
*
* @param firstAccessedTime
* The date that the device first signed in to Amazon WorkLink.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public DescribeDeviceResult withFirstAccessedTime(java.util.Date firstAccessedTime) {
setFirstAccessedTime(firstAccessedTime);
return this;
}
/**
* <p>
* The date that the device last accessed Amazon WorkLink.
* </p>
*
* @param lastAccessedTime
* The date that the device last accessed Amazon WorkLink.
*/
public void setLastAccessedTime(java.util.Date lastAccessedTime) {
this.lastAccessedTime = lastAccessedTime;
}
/**
* <p>
* The date that the device last accessed Amazon WorkLink.
* </p>
*
* @return The date that the device last accessed Amazon WorkLink.
*/
public java.util.Date getLastAccessedTime() {
return this.lastAccessedTime;
}
/**
* <p>
* The date that the device last accessed Amazon WorkLink.
* </p>
*
* @param lastAccessedTime
* The date that the device last accessed Amazon WorkLink.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public DescribeDeviceResult withLastAccessedTime(java.util.Date lastAccessedTime) {
setLastAccessedTime(lastAccessedTime);
return this;
}
/**
* <p>
* The user name associated with the device.
* </p>
*
* @param username
* The user name associated with the device.
*/
public void setUsername(String username) {
this.username = username;
}
/**
* <p>
* The user name associated with the device.
* </p>
*
* @return The user name associated with the device.
*/
public String getUsername() {
return this.username;
}
/**
* <p>
* The user name associated with the device.
* </p>
*
* @param username
* The user name associated with the device.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public DescribeDeviceResult withUsername(String username) {
setUsername(username);
return this;
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getStatus() != null)
sb.append("Status: ").append(getStatus()).append(",");
if (getModel() != null)
sb.append("Model: ").append(getModel()).append(",");
if (getManufacturer() != null)
sb.append("Manufacturer: ").append(getManufacturer()).append(",");
if (getOperatingSystem() != null)
sb.append("OperatingSystem: ").append(getOperatingSystem()).append(",");
if (getOperatingSystemVersion() != null)
sb.append("OperatingSystemVersion: ").append(getOperatingSystemVersion()).append(",");
if (getPatchLevel() != null)
sb.append("PatchLevel: ").append(getPatchLevel()).append(",");
if (getFirstAccessedTime() != null)
sb.append("FirstAccessedTime: ").append(getFirstAccessedTime()).append(",");
if (getLastAccessedTime() != null)
sb.append("LastAccessedTime: ").append(getLastAccessedTime()).append(",");
if (getUsername() != null)
sb.append("Username: ").append(getUsername());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof DescribeDeviceResult == false)
return false;
DescribeDeviceResult other = (DescribeDeviceResult) obj;
if (other.getStatus() == null ^ this.getStatus() == null)
return false;
if (other.getStatus() != null && other.getStatus().equals(this.getStatus()) == false)
return false;
if (other.getModel() == null ^ this.getModel() == null)
return false;
if (other.getModel() != null && other.getModel().equals(this.getModel()) == false)
return false;
if (other.getManufacturer() == null ^ this.getManufacturer() == null)
return false;
if (other.getManufacturer() != null && other.getManufacturer().equals(this.getManufacturer()) == false)
return false;
if (other.getOperatingSystem() == null ^ this.getOperatingSystem() == null)
return false;
if (other.getOperatingSystem() != null && other.getOperatingSystem().equals(this.getOperatingSystem()) == false)
return false;
if (other.getOperatingSystemVersion() == null ^ this.getOperatingSystemVersion() == null)
return false;
if (other.getOperatingSystemVersion() != null && other.getOperatingSystemVersion().equals(this.getOperatingSystemVersion()) == false)
return false;
if (other.getPatchLevel() == null ^ this.getPatchLevel() == null)
return false;
if (other.getPatchLevel() != null && other.getPatchLevel().equals(this.getPatchLevel()) == false)
return false;
if (other.getFirstAccessedTime() == null ^ this.getFirstAccessedTime() == null)
return false;
if (other.getFirstAccessedTime() != null && other.getFirstAccessedTime().equals(this.getFirstAccessedTime()) == false)
return false;
if (other.getLastAccessedTime() == null ^ this.getLastAccessedTime() == null)
return false;
if (other.getLastAccessedTime() != null && other.getLastAccessedTime().equals(this.getLastAccessedTime()) == false)
return false;
if (other.getUsername() == null ^ this.getUsername() == null)
return false;
if (other.getUsername() != null && other.getUsername().equals(this.getUsername()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode());
hashCode = prime * hashCode + ((getModel() == null) ? 0 : getModel().hashCode());
hashCode = prime * hashCode + ((getManufacturer() == null) ? 0 : getManufacturer().hashCode());
hashCode = prime * hashCode + ((getOperatingSystem() == null) ? 0 : getOperatingSystem().hashCode());
hashCode = prime * hashCode + ((getOperatingSystemVersion() == null) ? 0 : getOperatingSystemVersion().hashCode());
hashCode = prime * hashCode + ((getPatchLevel() == null) ? 0 : getPatchLevel().hashCode());
hashCode = prime * hashCode + ((getFirstAccessedTime() == null) ? 0 : getFirstAccessedTime().hashCode());
hashCode = prime * hashCode + ((getLastAccessedTime() == null) ? 0 : getLastAccessedTime().hashCode());
hashCode = prime * hashCode + ((getUsername() == null) ? 0 : getUsername().hashCode());
return hashCode;
}
@Override
public DescribeDeviceResult clone() {
try {
return (DescribeDeviceResult) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
}
| jentfoo/aws-sdk-java | aws-java-sdk-worklink/src/main/java/com/amazonaws/services/worklink/model/DescribeDeviceResult.java | Java | apache-2.0 | 16,586 | [
30522,
1013,
1008,
1008,
9385,
2297,
1011,
10476,
9733,
1012,
4012,
1010,
4297,
1012,
2030,
2049,
18460,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
30524,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#pragma once
#include <aws/config/ConfigService_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <utility>
namespace Aws
{
namespace Utils
{
namespace Json
{
class JsonValue;
class JsonView;
} // namespace Json
} // namespace Utils
namespace ConfigService
{
namespace Model
{
/**
* <p>Defines which resources trigger an evaluation for an AWS Config rule. The
* scope can include one or more resource types, a combination of a tag key and
* value, or a combination of one resource type and one resource ID. Specify a
* scope to constrain which resources trigger an evaluation for a rule. Otherwise,
* evaluations for the rule are triggered when any resource in your recording group
* changes in configuration.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/config-2014-11-12/Scope">AWS API
* Reference</a></p>
*/
class AWS_CONFIGSERVICE_API Scope
{
public:
Scope();
Scope(Aws::Utils::Json::JsonView jsonValue);
Scope& operator=(Aws::Utils::Json::JsonView jsonValue);
Aws::Utils::Json::JsonValue Jsonize() const;
/**
* <p>The resource types of only those AWS resources that you want to trigger an
* evaluation for the rule. You can only specify one type if you also specify a
* resource ID for <code>ComplianceResourceId</code>.</p>
*/
inline const Aws::Vector<Aws::String>& GetComplianceResourceTypes() const{ return m_complianceResourceTypes; }
/**
* <p>The resource types of only those AWS resources that you want to trigger an
* evaluation for the rule. You can only specify one type if you also specify a
* resource ID for <code>ComplianceResourceId</code>.</p>
*/
inline bool ComplianceResourceTypesHasBeenSet() const { return m_complianceResourceTypesHasBeenSet; }
/**
* <p>The resource types of only those AWS resources that you want to trigger an
* evaluation for the rule. You can only specify one type if you also specify a
* resource ID for <code>ComplianceResourceId</code>.</p>
*/
inline void SetComplianceResourceTypes(const Aws::Vector<Aws::String>& value) { m_complianceResourceTypesHasBeenSet = true; m_complianceResourceTypes = value; }
/**
* <p>The resource types of only those AWS resources that you want to trigger an
* evaluation for the rule. You can only specify one type if you also specify a
* resource ID for <code>ComplianceResourceId</code>.</p>
*/
inline void SetComplianceResourceTypes(Aws::Vector<Aws::String>&& value) { m_complianceResourceTypesHasBeenSet = true; m_complianceResourceTypes = std::move(value); }
/**
* <p>The resource types of only those AWS resources that you want to trigger an
* evaluation for the rule. You can only specify one type if you also specify a
* resource ID for <code>ComplianceResourceId</code>.</p>
*/
inline Scope& WithComplianceResourceTypes(const Aws::Vector<Aws::String>& value) { SetComplianceResourceTypes(value); return *this;}
/**
* <p>The resource types of only those AWS resources that you want to trigger an
* evaluation for the rule. You can only specify one type if you also specify a
* resource ID for <code>ComplianceResourceId</code>.</p>
*/
inline Scope& WithComplianceResourceTypes(Aws::Vector<Aws::String>&& value) { SetComplianceResourceTypes(std::move(value)); return *this;}
/**
* <p>The resource types of only those AWS resources that you want to trigger an
* evaluation for the rule. You can only specify one type if you also specify a
* resource ID for <code>ComplianceResourceId</code>.</p>
*/
inline Scope& AddComplianceResourceTypes(const Aws::String& value) { m_complianceResourceTypesHasBeenSet = true; m_complianceResourceTypes.push_back(value); return *this; }
/**
* <p>The resource types of only those AWS resources that you want to trigger an
* evaluation for the rule. You can only specify one type if you also specify a
* resource ID for <code>ComplianceResourceId</code>.</p>
*/
inline Scope& AddComplianceResourceTypes(Aws::String&& value) { m_complianceResourceTypesHasBeenSet = true; m_complianceResourceTypes.push_back(std::move(value)); return *this; }
/**
* <p>The resource types of only those AWS resources that you want to trigger an
* evaluation for the rule. You can only specify one type if you also specify a
* resource ID for <code>ComplianceResourceId</code>.</p>
*/
inline Scope& AddComplianceResourceTypes(const char* value) { m_complianceResourceTypesHasBeenSet = true; m_complianceResourceTypes.push_back(value); return *this; }
/**
* <p>The tag key that is applied to only those AWS resources that you want to
* trigger an evaluation for the rule.</p>
*/
inline const Aws::String& GetTagKey() const{ return m_tagKey; }
/**
* <p>The tag key that is applied to only those AWS resources that you want to
* trigger an evaluation for the rule.</p>
*/
inline bool TagKeyHasBeenSet() const { return m_tagKeyHasBeenSet; }
/**
* <p>The tag key that is applied to only those AWS resources that you want to
* trigger an evaluation for the rule.</p>
*/
inline void SetTagKey(const Aws::String& value) { m_tagKeyHasBeenSet = true; m_tagKey = value; }
/**
* <p>The tag key that is applied to only those AWS resources that you want to
* trigger an evaluation for the rule.</p>
*/
inline void SetTagKey(Aws::String&& value) { m_tagKeyHasBeenSet = true; m_tagKey = std::move(value); }
/**
* <p>The tag key that is applied to only those AWS resources that you want to
* trigger an evaluation for the rule.</p>
*/
inline void SetTagKey(const char* value) { m_tagKeyHasBeenSet = true; m_tagKey.assign(value); }
/**
* <p>The tag key that is applied to only those AWS resources that you want to
* trigger an evaluation for the rule.</p>
*/
inline Scope& WithTagKey(const Aws::String& value) { SetTagKey(value); return *this;}
/**
* <p>The tag key that is applied to only those AWS resources that you want to
* trigger an evaluation for the rule.</p>
*/
inline Scope& WithTagKey(Aws::String&& value) { SetTagKey(std::move(value)); return *this;}
/**
* <p>The tag key that is applied to only those AWS resources that you want to
* trigger an evaluation for the rule.</p>
*/
inline Scope& WithTagKey(const char* value) { SetTagKey(value); return *this;}
/**
* <p>The tag value applied to only those AWS resources that you want to trigger an
* evaluation for the rule. If you specify a value for <code>TagValue</code>, you
* must also specify a value for <code>TagKey</code>.</p>
*/
inline const Aws::String& GetTagValue() const{ return m_tagValue; }
/**
* <p>The tag value applied to only those AWS resources that you want to trigger an
* evaluation for the rule. If you specify a value for <code>TagValue</code>, you
* must also specify a value for <code>TagKey</code>.</p>
*/
inline bool TagValueHasBeenSet() const { return m_tagValueHasBeenSet; }
/**
* <p>The tag value applied to only those AWS resources that you want to trigger an
* evaluation for the rule. If you specify a value for <code>TagValue</code>, you
* must also specify a value for <code>TagKey</code>.</p>
*/
inline void SetTagValue(const Aws::String& value) { m_tagValueHasBeenSet = true; m_tagValue = value; }
/**
* <p>The tag value applied to only those AWS resources that you want to trigger an
* evaluation for the rule. If you specify a value for <code>TagValue</code>, you
* must also specify a value for <code>TagKey</code>.</p>
*/
inline void SetTagValue(Aws::String&& value) { m_tagValueHasBeenSet = true; m_tagValue = std::move(value); }
/**
* <p>The tag value applied to only those AWS resources that you want to trigger an
* evaluation for the rule. If you specify a value for <code>TagValue</code>, you
* must also specify a value for <code>TagKey</code>.</p>
*/
inline void SetTagValue(const char* value) { m_tagValueHasBeenSet = true; m_tagValue.assign(value); }
/**
* <p>The tag value applied to only those AWS resources that you want to trigger an
* evaluation for the rule. If you specify a value for <code>TagValue</code>, you
* must also specify a value for <code>TagKey</code>.</p>
*/
inline Scope& WithTagValue(const Aws::String& value) { SetTagValue(value); return *this;}
/**
* <p>The tag value applied to only those AWS resources that you want to trigger an
* evaluation for the rule. If you specify a value for <code>TagValue</code>, you
* must also specify a value for <code>TagKey</code>.</p>
*/
inline Scope& WithTagValue(Aws::String&& value) { SetTagValue(std::move(value)); return *this;}
/**
* <p>The tag value applied to only those AWS resources that you want to trigger an
* evaluation for the rule. If you specify a value for <code>TagValue</code>, you
* must also specify a value for <code>TagKey</code>.</p>
*/
inline Scope& WithTagValue(const char* value) { SetTagValue(value); return *this;}
/**
* <p>The ID of the only AWS resource that you want to trigger an evaluation for
* the rule. If you specify a resource ID, you must specify one resource type for
* <code>ComplianceResourceTypes</code>.</p>
*/
inline const Aws::String& GetComplianceResourceId() const{ return m_complianceResourceId; }
/**
* <p>The ID of the only AWS resource that you want to trigger an evaluation for
* the rule. If you specify a resource ID, you must specify one resource type for
* <code>ComplianceResourceTypes</code>.</p>
*/
inline bool ComplianceResourceIdHasBeenSet() const { return m_complianceResourceIdHasBeenSet; }
/**
* <p>The ID of the only AWS resource that you want to trigger an evaluation for
* the rule. If you specify a resource ID, you must specify one resource type for
* <code>ComplianceResourceTypes</code>.</p>
*/
inline void SetComplianceResourceId(const Aws::String& value) { m_complianceResourceIdHasBeenSet = true; m_complianceResourceId = value; }
/**
* <p>The ID of the only AWS resource that you want to trigger an evaluation for
* the rule. If you specify a resource ID, you must specify one resource type for
* <code>ComplianceResourceTypes</code>.</p>
*/
inline void SetComplianceResourceId(Aws::String&& value) { m_complianceResourceIdHasBeenSet = true; m_complianceResourceId = std::move(value); }
/**
* <p>The ID of the only AWS resource that you want to trigger an evaluation for
* the rule. If you specify a resource ID, you must specify one resource type for
* <code>ComplianceResourceTypes</code>.</p>
*/
inline void SetComplianceResourceId(const char* value) { m_complianceResourceIdHasBeenSet = true; m_complianceResourceId.assign(value); }
/**
* <p>The ID of the only AWS resource that you want to trigger an evaluation for
* the rule. If you specify a resource ID, you must specify one resource type for
* <code>ComplianceResourceTypes</code>.</p>
*/
inline Scope& WithComplianceResourceId(const Aws::String& value) { SetComplianceResourceId(value); return *this;}
/**
* <p>The ID of the only AWS resource that you want to trigger an evaluation for
* the rule. If you specify a resource ID, you must specify one resource type for
* <code>ComplianceResourceTypes</code>.</p>
*/
inline Scope& WithComplianceResourceId(Aws::String&& value) { SetComplianceResourceId(std::move(value)); return *this;}
/**
* <p>The ID of the only AWS resource that you want to trigger an evaluation for
* the rule. If you specify a resource ID, you must specify one resource type for
* <code>ComplianceResourceTypes</code>.</p>
*/
inline Scope& WithComplianceResourceId(const char* value) { SetComplianceResourceId(value); return *this;}
private:
Aws::Vector<Aws::String> m_complianceResourceTypes;
bool m_complianceResourceTypesHasBeenSet;
Aws::String m_tagKey;
bool m_tagKeyHasBeenSet;
Aws::String m_tagValue;
bool m_tagValueHasBeenSet;
Aws::String m_complianceResourceId;
bool m_complianceResourceIdHasBeenSet;
};
} // namespace Model
} // namespace ConfigService
} // namespace Aws
| cedral/aws-sdk-cpp | aws-cpp-sdk-config/include/aws/config/model/Scope.h | C | apache-2.0 | 13,287 | [
30522,
1013,
1008,
1008,
9385,
2230,
1011,
2418,
9733,
1012,
4012,
1010,
4297,
1012,
2030,
2049,
18460,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Apache License
* Version 2.0, January 2004
* http://www.apache.org/licenses/
*
* TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
*
* 1. Definitions.
*
* "License" shall mean the terms and conditions for use, reproduction,
* and distribution as defined by Sections 1 through 9 of this document.
*
* "Licensor" shall mean the copyright owner or entity authorized by
* the copyright owner that is granting the License.
*
* "Legal Entity" shall mean the union of the acting entity and all
* other entities that control, are controlled by, or are under common
* control with that entity. For the purposes of this definition,
* "control" means (i) the power, direct or indirect, to cause the
* direction or management of such entity, whether by contract or
* otherwise, or (ii) ownership of fifty percent (50%) or more of the
* outstanding shares, or (iii) beneficial ownership of such entity.
*
* "You" (or "Your") shall mean an individual or Legal Entity
* exercising permissions granted by this License.
*
* "Source" form shall mean the preferred form for making modifications,
* including but not limited to software source code, documentation
* source, and configuration files.
*
* "Object" form shall mean any form resulting from mechanical
* transformation or translation of a Source form, including but
* not limited to compiled object code, generated documentation,
* and conversions to other media types.
*
* "Work" shall mean the work of authorship, whether in Source or
* Object form, made available under the License, as indicated by a
* copyright notice that is included in or attached to the work
* (an example is provided in the Appendix below).
*
* "Derivative Works" shall mean any work, whether in Source or Object
* form, that is based on (or derived from) the Work and for which the
* editorial revisions, annotations, elaborations, or other modifications
* represent, as a whole, an original work of authorship. For the purposes
* of this License, Derivative Works shall not include works that remain
* separable from, or merely link (or bind by name) to the interfaces of,
* the Work and Derivative Works thereof.
*
* "Contribution" shall mean any work of authorship, including
* the original version of the Work and any modifications or additions
* to that Work or Derivative Works thereof, that is intentionally
* submitted to Licensor for inclusion in the Work by the copyright owner
* or by an individual or Legal Entity authorized to submit on behalf of
* the copyright owner. For the purposes of this definition, "submitted"
* means any form of electronic, verbal, or written communication sent
* to the Licensor or its representatives, including but not limited to
* communication on electronic mailing lists, source code control systems,
* and issue tracking systems that are managed by, or on behalf of, the
* Licensor for the purpose of discussing and improving the Work, but
* excluding communication that is conspicuously marked or otherwise
* designated in writing by the copyright owner as "Not a Contribution."
*
* "Contributor" shall mean Licensor and any individual or Legal Entity
* on behalf of whom a Contribution has been received by Licensor and
* subsequently incorporated within the Work.
*
* 2. Grant of Copyright License. Subject to the terms and conditions of
* this License, each Contributor hereby grants to You a perpetual,
* worldwide, non-exclusive, no-charge, royalty-free, irrevocable
* copyright license to reproduce, prepare Derivative Works of,
* publicly display, publicly perform, sublicense, and distribute the
* Work and such Derivative Works in Source or Object form.
*
* 3. Grant of Patent License. Subject to the terms and conditions of
* this License, each Contributor hereby grants to You a perpetual,
* worldwide, non-exclusive, no-charge, royalty-free, irrevocable
* (except as stated in this section) patent license to make, have made,
* use, offer to sell, sell, import, and otherwise transfer the Work,
* where such license applies only to those patent claims licensable
* by such Contributor that are necessarily infringed by their
* Contribution(s) alone or by combination of their Contribution(s)
* with the Work to which such Contribution(s) was submitted. If You
* institute patent litigation against any entity (including a
* cross-claim or counterclaim in a lawsuit) alleging that the Work
* or a Contribution incorporated within the Work constitutes direct
* or contributory patent infringement, then any patent licenses
* granted to You under this License for that Work shall terminate
* as of the date such litigation is filed.
*
* 4. Redistribution. You may reproduce and distribute copies of the
* Work or Derivative Works thereof in any medium, with or without
* modifications, and in Source or Object form, provided that You
* meet the following conditions:
*
* (a) You must give any other recipients of the Work or
* Derivative Works a copy of this License; and
*
* (b) You must cause any modified files to carry prominent notices
* stating that You changed the files; and
*
* (c) You must retain, in the Source form of any Derivative Works
* that You distribute, all copyright, patent, trademark, and
* attribution notices from the Source form of the Work,
* excluding those notices that do not pertain to any part of
* the Derivative Works; and
*
* (d) If the Work includes a "NOTICE" text file as part of its
* distribution, then any Derivative Works that You distribute must
* include a readable copy of the attribution notices contained
* within such NOTICE file, excluding those notices that do not
* pertain to any part of the Derivative Works, in at least one
* of the following places: within a NOTICE text file distributed
* as part of the Derivative Works; within the Source form or
* documentation, if provided along with the Derivative Works; or,
* within a display generated by the Derivative Works, if and
* wherever such third-party notices normally appear. The contents
* of the NOTICE file are for informational purposes only and
* do not modify the License. You may add Your own attribution
* notices within Derivative Works that You distribute, alongside
* or as an addendum to the NOTICE text from the Work, provided
* that such additional attribution notices cannot be construed
* as modifying the License.
*
* You may add Your own copyright statement to Your modifications and
* may provide additional or different license terms and conditions
* for use, reproduction, or distribution of Your modifications, or
* for any such Derivative Works as a whole, provided Your use,
* reproduction, and distribution of the Work otherwise complies with
* the conditions stated in this License.
*
* 5. Submission of Contributions. Unless You explicitly state otherwise,
* any Contribution intentionally submitted for inclusion in the Work
* by You to the Licensor shall be under the terms and conditions of
* this License, without any additional terms or conditions.
* Notwithstanding the above, nothing herein shall supersede or modify
* the terms of any separate license agreement you may have executed
* with Licensor regarding such Contributions.
*
* 6. Trademarks. This License does not grant permission to use the trade
* names, trademarks, service marks, or product names of the Licensor,
* except as required for reasonable and customary use in describing the
* origin of the Work and reproducing the content of the NOTICE file.
*
* 7. Disclaimer of Warranty. Unless required by applicable law or
* agreed to in writing, Licensor provides the Work (and each
* Contributor provides its Contributions) on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied, including, without limitation, any warranties or conditions
* of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
* PARTICULAR PURPOSE. You are solely responsible for determining the
* appropriateness of using or redistributing the Work and assume any
* risks associated with Your exercise of permissions under this License.
*
* 8. Limitation of Liability. In no event and under no legal theory,
* whether in tort (including negligence), contract, or otherwise,
* unless required by applicable law (such as deliberate and grossly
* negligent acts) or agreed to in writing, shall any Contributor be
* liable to You for damages, including any direct, indirect, special,
* incidental, or consequential damages of any character arising as a
* result of this License or out of the use or inability to use the
* Work (including but not limited to damages for loss of goodwill,
* work stoppage, computer failure or malfunction, or any and all
* other commercial damages or losses), even if such Contributor
* has been advised of the possibility of such damages.
*
* 9. Accepting Warranty or Additional Liability. While redistributing
* the Work or Derivative Works thereof, You may choose to offer,
* and charge a fee for, acceptance of support, warranty, indemnity,
* or other liability obligations and/or rights consistent with this
* License. However, in accepting such obligations, You may act only
* on Your own behalf and on Your sole responsibility, not on behalf
* of any other Contributor, and only if You agree to indemnify,
* defend, and hold each Contributor harmless for any liability
* incurred by, or claims asserted against, such Contributor by reason
* of your accepting any such warranty or additional liability.
*
* END OF TERMS AND CONDITIONS
*
* APPENDIX: How to apply the Apache License to your work.
*
* To apply the Apache License to your work, attach the following
* boilerplate notice, with the fields enclosed by brackets "{}"
* replaced with your own identifying information. (Don't include
* the brackets!) The text should be enclosed in the appropriate
* comment syntax for the file format. We also recommend that a
* file or class name and description of purpose be included on the
* same "printed page" as the copyright notice for easier
* identification within third-party archives.
*
* Copyright {yyyy} {name of copyright owner}
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.deleidos.rtws.webapp.auth.registration;
import org.apache.commons.lang.StringUtils;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import com.deleidos.rtws.webapp.auth.TmsProxyUser;
import com.deleidos.rtws.webapp.client.RestClientException;
import com.deleidos.rtws.webapp.client.RestClientManager;
import com.deleidos.rtws.webapp.client.UUIDClient;
public class RegistrationUserDetailsService implements UserDetailsService {
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
if(StringUtils.isBlank(username)) {
throw new UsernameNotFoundException("No API Key Provided");
}
UUIDClient registrationClientService = RestClientManager.getUUIDClient();
boolean isValidRegistrationKey = false;
Throwable validationErrorCause = null;
try {
isValidRegistrationKey = registrationClientService.validate(username);
} catch (RestClientException rce) {
isValidRegistrationKey = false;
validationErrorCause = rce;
}
if(!isValidRegistrationKey) {
throw new BadCredentialsException("Invalid API Key", validationErrorCause);
}
String tenantId = null;
try {
tenantId = registrationClientService.getTenantId(username);
} catch (RestClientException rce) {
throw new AuthenticationServiceException("Failed to validate the API Key", rce);
}
// Note: The tenantId may be null at this point indicating that this UUID is known,
// but not yet associated with a tenantId. Downstream services should dictate if this is valid or not.
return new TmsProxyUser(username, AuthorityUtils.createAuthorityList(new String[]{TmsProxyUser.TENANT_PROXY_USER_ROLE_NAME}), tenantId);
}
}
| deleidos/digitaledge-platform | webapp-proxy/src/main/java/com/deleidos/rtws/webapp/auth/registration/RegistrationUserDetailsService.java | Java | apache-2.0 | 14,025 | [
30522,
1013,
1008,
1008,
1008,
15895,
6105,
1008,
2544,
1016,
1012,
1014,
1010,
2254,
2432,
1008,
8299,
1024,
1013,
1013,
7479,
1012,
15895,
1012,
8917,
1013,
15943,
1013,
1008,
1008,
3408,
1998,
3785,
2005,
2224,
1010,
14627,
1010,
1998,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jsonp({"cep":"88115210","logradouro":"Rua C\u00e9sar Zuchinalli","bairro":"Serraria","cidade":"S\u00e3o Jos\u00e9","uf":"SC","estado":"Santa Catarina"});
| lfreneda/cepdb | api/v1/88115210.jsonp.js | JavaScript | cc0-1.0 | 154 | [
30522,
1046,
3385,
2361,
1006,
1063,
1000,
8292,
2361,
1000,
1024,
1000,
6070,
14526,
25746,
10790,
1000,
1010,
1000,
8833,
12173,
8162,
2080,
1000,
1024,
1000,
21766,
2050,
1039,
1032,
1057,
8889,
2063,
2683,
10286,
16950,
17231,
8095,
207... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* @package modx
*/
/**
* Represents a user setting which overrides system and context settings.
*
*
* @param int $user The ID of the User
* @property string $key The key of the Setting
* @property string $value The value of the Setting
* @property string $xtype The xtype that is used to render the Setting input in the manager
* @property string $namespace The Namespace of the setting
* @property string $area The area of the Setting
* @property timestamp $editedon The last edited on time of this Setting
* @package modx
*/
class modUserSetting extends xPDOObject {} | wshearn/openshift-quickstart-modx | php/core/model/modx/modusersetting.class.php | PHP | gpl-2.0 | 593 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1030,
7427,
16913,
2595,
1008,
1013,
1013,
1008,
1008,
1008,
5836,
1037,
5310,
4292,
2029,
2058,
15637,
2015,
2291,
1998,
6123,
10906,
1012,
1008,
1008,
1008,
1030,
11498,
2213,
20014,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require 'english/class'
class English
# = Noun Number Inflections
#
# This module provides english singular <-> plural noun inflections.
module Inflect
@singular_of = {}
@plural_of = {}
@singular_rules = []
@plural_rules = []
# This class provides the DSL for creating inflections, you can add additional rules.
# Examples:
#
# word "ox", "oxen"
# word "octopus", "octopi"
# word "man", "men"
#
# rule "lf", "lves"
#
# word "equipment"
#
# Rules are evaluated by size, so rules you add to override specific cases should be longer than the rule
# it overrides. For instance, if you want "pta" to pluralize to "ptas", even though a general purpose rule
# for "ta" => "tum" already exists, simply add a new rule for "pta" => "ptas", and it will automatically win
# since it is longer than the old rule.
#
# Also, single-word exceptions win over general words ("ox" pluralizes to "oxen", because it's a single word
# exception, even though "fox" pluralizes to "foxes")
class << self
# Define a general two-way exception.
#
# This also defines a general rule, so foo_child will correctly become
# foo_children.
#
# Whole words also work if they are capitalized (Goose => Geese).
def word(singular, plural=nil)
plural = singular unless plural
singular_word(singular, plural)
plural_word(singular, plural)
rule(singular, plural)
end
# Define a singularization exception.
def singular_word(singular, plural)
@singular_of[plural] = singular
@singular_of[plural.capitalize] = singular.capitalize
end
# Define a pluralization exception.
def plural_word(singular, plural)
@plural_of[singular] = plural
@plural_of[singular.capitalize] = plural.capitalize
end
# Define a general rule.
def rule(singular, plural)
singular_rule(singular, plural)
plural_rule(singular, plural)
end
# Define a singularization rule.
def singular_rule(singular, plural)
@singular_rules << [singular, plural]
end
# Define a plurualization rule.
def plural_rule(singular, plural)
@plural_rules << [singular, plural]
end
# Read prepared singularization rules.
def singularization_rules
if defined?(@singularization_regex) && @singularization_regex
return [@singularization_regex, @singularization_hash]
end
# No sorting needed: Regexen match on longest string
@singularization_regex = Regexp.new("(" + @singular_rules.map {|s,p| p}.join("|") + ")$", "i")
@singularization_hash = Hash[*@singular_rules.flatten].invert
[@singularization_regex, @singularization_hash]
end
# Read prepared singularization rules.
#def singularization_rules
# return @singularization_rules if @singularization_rules
# sorted = @singular_rules.sort_by{ |s, p| "#{p}".size }.reverse
# @singularization_rules = sorted.collect do |s, p|
# [ /#{p}$/, "#{s}" ]
# end
#end
# Read prepared pluralization rules.
def pluralization_rules
if defined?(@pluralization_regex) && @pluralization_regex
return [@pluralization_regex, @pluralization_hash]
end
@pluralization_regex = Regexp.new("(" + @plural_rules.map {|s,p| s}.join("|") + ")$", "i")
@pluralization_hash = Hash[*@plural_rules.flatten]
[@pluralization_regex, @pluralization_hash]
end
# Read prepared pluralization rules.
#def pluralization_rules
# return @pluralization_rules if @pluralization_rules
# sorted = @plural_rules.sort_by{ |s, p| "#{s}".size }.reverse
# @pluralization_rules = sorted.collect do |s, p|
# [ /#{s}$/, "#{p}" ]
# end
#end
#
def singular_of ; @singular_of ; end
#
def plural_of ; @plural_of ; end
# Convert an English word from plurel to singular.
#
# "boys".singular #=> boy
# "tomatoes".singular #=> tomato
#
def singular(word)
return "" if word == ""
if result = singular_of[word]
return result.dup
end
result = word.dup
regex, hash = singularization_rules
result.sub!(regex) {|m| hash[m]}
singular_of[word] = result
return result
#singularization_rules.each do |(match, replacement)|
# break if result.gsub!(match, replacement)
#end
#return result
end
# Alias for #singular (a Railism).
#
alias_method(:singularize, :singular)
# Convert an English word from singular to plurel.
#
# "boy".plural #=> boys
# "tomato".plural #=> tomatoes
#
def plural(word)
return "" if word == ""
if result = plural_of[word]
return result.dup
end
#return self.dup if /s$/ =~ self # ???
result = word.dup
regex, hash = pluralization_rules
result.sub!(regex) {|m| hash[m]}
plural_of[word] = result
return result
#pluralization_rules.each do |(match, replacement)|
# break if result.gsub!(match, replacement)
#end
#return result
end
# Alias for #plural (a Railism).
alias_method(:pluralize, :plural)
# Clear all rules.
def clear(type = :all)
if type == :singular || type == :all
@singular_of = {}
@singular_rules = []
@singularization_rules, @singularization_regex = nil, nil
end
if type == :plural || type == :all
@singular_of = {}
@singular_rules = []
@singularization_rules, @singularization_regex = nil, nil
end
end
end
# One argument means singular and plural are the same.
word 'equipment'
word 'information'
word 'money'
word 'species'
word 'series'
word 'fish'
word 'sheep'
word 'moose'
word 'hovercraft'
word 'news'
word 'rice'
word 'plurals'
# Two arguments defines a singular and plural exception.
word 'Swiss' , 'Swiss'
word 'alias' , 'aliases'
word 'analysis' , 'analyses'
#word 'axis' , 'axes'
word 'basis' , 'bases'
word 'buffalo' , 'buffaloes'
word 'child' , 'children'
#word 'cow' , 'kine'
word 'crisis' , 'crises'
word 'criterion' , 'criteria'
word 'datum' , 'data'
word 'goose' , 'geese'
word 'hive' , 'hives'
word 'index' , 'indices'
word 'life' , 'lives'
word 'louse' , 'lice'
word 'man' , 'men'
word 'matrix' , 'matrices'
word 'medium' , 'media'
word 'mouse' , 'mice'
word 'movie' , 'movies'
word 'octopus' , 'octopi'
word 'ox' , 'oxen'
word 'person' , 'people'
word 'potato' , 'potatoes'
word 'quiz' , 'quizzes'
word 'shoe' , 'shoes'
word 'status' , 'statuses'
word 'testis' , 'testes'
word 'thesis' , 'theses'
word 'thief' , 'thieves'
word 'tomato' , 'tomatoes'
word 'torpedo' , 'torpedoes'
word 'vertex' , 'vertices'
word 'virus' , 'viri'
word 'wife' , 'wives'
# One-way singularization exception (convert plural to singular).
singular_word 'cactus', 'cacti'
# One-way pluralizaton exception (convert singular to plural).
plural_word 'axis', 'axes'
# General rules.
rule 'rf' , 'rves'
rule 'ero' , 'eroes'
rule 'ch' , 'ches'
rule 'sh' , 'shes'
rule 'ss' , 'sses'
#rule 'ess' , 'esses'
rule 'ta' , 'tum'
rule 'ia' , 'ium'
rule 'ra' , 'rum'
rule 'ay' , 'ays'
rule 'ey' , 'eys'
rule 'oy' , 'oys'
rule 'uy' , 'uys'
rule 'y' , 'ies'
rule 'x' , 'xes'
rule 'lf' , 'lves'
rule 'ffe' , 'ffes'
rule 'af' , 'aves'
rule 'us' , 'uses'
rule 'ouse' , 'ouses'
rule 'osis' , 'oses'
rule 'ox' , 'oxes'
rule '' , 's'
# One-way singular rules.
singular_rule 'of' , 'ofs' # proof
singular_rule 'o' , 'oes' # hero, heroes
#singular_rule 'f' , 'ves'
# One-way plural rules.
plural_rule 's' , 'ses'
plural_rule 'ive' , 'ives' # don't want to snag wife
plural_rule 'fe' , 'ves' # don't want to snag perspectives
end
#
def self.singular(string)
English::Inflect.singular(string)
end
#
def self.plural(string)
English::Inflect.plural(string)
end
# Convert an English word from plurel to singular.
#
# "boys".singular #=> boy
# "tomatoes".singular #=> tomato
#
def singular
self.class.singular(@self)
end
# Alias for #singular.
alias_method(:singularize, :singular)
# Convert an English word from plurel to singular.
#
# "boys".singular #=> boy
# "tomatoes".singular #=> tomato
#
def plural
self.class.plural(@self)
end
# Alias for #plural.
alias_method(:pluralize, :plural)
end
| rubygengo/english | lib/english/inflect.rb | Ruby | mit | 9,263 | [
30522,
5478,
1005,
2394,
1013,
2465,
1005,
2465,
2394,
1001,
1027,
15156,
2193,
1999,
21031,
22014,
1001,
1001,
2023,
11336,
3640,
2394,
13048,
1026,
1011,
1028,
13994,
15156,
1999,
21031,
22014,
1012,
11336,
1999,
21031,
6593,
1030,
13048,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
const filter = require('./filter')
module.exports = (collection, test, callback) => {
return filter(collection, function(value, index, collection) {
return !test(value, index, collection)
}, callback)
}
| Gattermeier/a_ | src/reject.js | JavaScript | mit | 214 | [
30522,
9530,
3367,
11307,
1027,
5478,
1006,
1005,
1012,
1013,
11307,
1005,
1007,
11336,
1012,
14338,
1027,
1006,
3074,
1010,
3231,
1010,
2655,
5963,
1007,
1027,
1028,
1063,
2709,
11307,
1006,
3074,
1010,
3853,
1006,
3643,
1010,
5950,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* Elgg pageshell
* The standard HTML page shell that everything else fits into
*
* @package Elgg
* @subpackage Core
*
* @uses $vars['derecha'] Seccion derecha de la pagina (menu)
* @uses $vars['izquierda'] Seccion Izquierda de la Pagina (Contenido)
*/
// backward compatability support for plugins that are not using the new approach
// of routing through admin. See reportedcontent plugin for a simple example.
if (elgg_get_context() == 'admin') {
if (get_input('handler') != 'admin') {
elgg_deprecated_notice("admin plugins should route through 'admin'.", 1.8);
}
elgg_admin_add_plugin_settings_menu();
elgg_unregister_css('elgg');
echo elgg_view('page/admin', $vars);
return true;
}
// render content before head so that JavaScript and CSS can be loaded. See #4032
if (!elgg_is_rol_logged_user("coordinador")) {
$site_url = elgg_get_site_url();
forward($site_url);
}
$messages = elgg_view('page/elements/messages', array('object' => $vars['sysmessages']));
$header = elgg_view('page/elements/coordinacion/header', $vars);
$body = elgg_view('page/elements/coordinacion/body', $vars);
// Set the content type
elgg_unregister_css('inicio');
header("Content-type: text/html; charset=UTF-8");
$lang = get_current_language();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $lang; ?>" lang="<?php echo $lang; ?>">
<head>
<?php echo elgg_view('page/elements/logged/head', $vars);
?>
</head>
<body>
<div class="elgg-page-messages">
<?php echo $messages; ?>
<?php echo $notices_html; ?>
</div>
<div class="todo">
<div class="header">
<?php echo $header; ?>
</div>
<div class="contenido">
<?php echo $body; ?>
</div>
</div>
<footer>
<?php echo elgg_view('page/elements/footer_chat', array()); ?>
</footer>
</body>
</html>
| jonreycas/enjambre | mod/tema_comunidad_ondas/views/views/default/page/coordinacion_one_column.php | PHP | gpl-2.0 | 2,175 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
3449,
13871,
5530,
18223,
1008,
1996,
3115,
16129,
3931,
5806,
2008,
2673,
2842,
16142,
2046,
1008,
1008,
1030,
7427,
3449,
13871,
1008,
1030,
4942,
23947,
4270,
4563,
1008,
1008,
1030,
3594... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* @license Highcharts JS v7.1.1 (2019-04-09)
*
* (c) 2014-2019 Highsoft AS
* Authors: Jon Arild Nygard / Oystein Moseng
*
* License: www.highcharts.com/license
*/
'use strict';
(function (factory) {
if (typeof module === 'object' && module.exports) {
factory['default'] = factory;
module.exports = factory;
} else if (typeof define === 'function' && define.amd) {
define('highcharts/modules/treemap', ['highcharts'], function (Highcharts) {
factory(Highcharts);
factory.Highcharts = Highcharts;
return factory;
});
} else {
factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
}
}(function (Highcharts) {
var _modules = Highcharts ? Highcharts._modules : {};
function _registerModule(obj, path, args, fn) {
if (!obj.hasOwnProperty(path)) {
obj[path] = fn.apply(null, args);
}
}
_registerModule(_modules, 'mixins/tree-series.js', [_modules['parts/Globals.js']], function (H) {
var extend = H.extend,
isArray = H.isArray,
isBoolean = function (x) {
return typeof x === 'boolean';
},
isFn = function (x) {
return typeof x === 'function';
},
isObject = H.isObject,
isNumber = H.isNumber,
merge = H.merge,
pick = H.pick;
// TODO Combine buildTree and buildNode with setTreeValues
// TODO Remove logic from Treemap and make it utilize this mixin.
var setTreeValues = function setTreeValues(tree, options) {
var before = options.before,
idRoot = options.idRoot,
mapIdToNode = options.mapIdToNode,
nodeRoot = mapIdToNode[idRoot],
levelIsConstant = (
isBoolean(options.levelIsConstant) ?
options.levelIsConstant :
true
),
points = options.points,
point = points[tree.i],
optionsPoint = point && point.options || {},
childrenTotal = 0,
children = [],
value;
extend(tree, {
levelDynamic: tree.level - (levelIsConstant ? 0 : nodeRoot.level),
name: pick(point && point.name, ''),
visible: (
idRoot === tree.id ||
(isBoolean(options.visible) ? options.visible : false)
)
});
if (isFn(before)) {
tree = before(tree, options);
}
// First give the children some values
tree.children.forEach(function (child, i) {
var newOptions = extend({}, options);
extend(newOptions, {
index: i,
siblings: tree.children.length,
visible: tree.visible
});
child = setTreeValues(child, newOptions);
children.push(child);
if (child.visible) {
childrenTotal += child.val;
}
});
tree.visible = childrenTotal > 0 || tree.visible;
// Set the values
value = pick(optionsPoint.value, childrenTotal);
extend(tree, {
children: children,
childrenTotal: childrenTotal,
isLeaf: tree.visible && !childrenTotal,
val: value
});
return tree;
};
var getColor = function getColor(node, options) {
var index = options.index,
mapOptionsToLevel = options.mapOptionsToLevel,
parentColor = options.parentColor,
parentColorIndex = options.parentColorIndex,
series = options.series,
colors = options.colors,
siblings = options.siblings,
points = series.points,
getColorByPoint,
chartOptionsChart = series.chart.options.chart,
point,
level,
colorByPoint,
colorIndexByPoint,
color,
colorIndex;
function variation(color) {
var colorVariation = level && level.colorVariation;
if (colorVariation) {
if (colorVariation.key === 'brightness') {
return H.color(color).brighten(
colorVariation.to * (index / siblings)
).get();
}
}
return color;
}
if (node) {
point = points[node.i];
level = mapOptionsToLevel[node.level] || {};
getColorByPoint = point && level.colorByPoint;
if (getColorByPoint) {
colorIndexByPoint = point.index % (colors ?
colors.length :
chartOptionsChart.colorCount
);
colorByPoint = colors && colors[colorIndexByPoint];
}
// Select either point color, level color or inherited color.
if (!series.chart.styledMode) {
color = pick(
point && point.options.color,
level && level.color,
colorByPoint,
parentColor && variation(parentColor),
series.color
);
}
colorIndex = pick(
point && point.options.colorIndex,
level && level.colorIndex,
colorIndexByPoint,
parentColorIndex,
options.colorIndex
);
}
return {
color: color,
colorIndex: colorIndex
};
};
/**
* Creates a map from level number to its given options.
*
* @private
* @function getLevelOptions
*
* @param {object} params
* Object containing parameters.
* - `defaults` Object containing default options. The default options
* are merged with the userOptions to get the final options for a
* specific level.
* - `from` The lowest level number.
* - `levels` User options from series.levels.
* - `to` The highest level number.
*
* @return {Highcharts.Dictionary<object>}
* Returns a map from level number to its given options.
*/
var getLevelOptions = function getLevelOptions(params) {
var result = null,
defaults,
converted,
i,
from,
to,
levels;
if (isObject(params)) {
result = {};
from = isNumber(params.from) ? params.from : 1;
levels = params.levels;
converted = {};
defaults = isObject(params.defaults) ? params.defaults : {};
if (isArray(levels)) {
converted = levels.reduce(function (obj, item) {
var level,
levelIsConstant,
options;
if (isObject(item) && isNumber(item.level)) {
options = merge({}, item);
levelIsConstant = (
isBoolean(options.levelIsConstant) ?
options.levelIsConstant :
defaults.levelIsConstant
);
// Delete redundant properties.
delete options.levelIsConstant;
delete options.level;
// Calculate which level these options apply to.
level = item.level + (levelIsConstant ? 0 : from - 1);
if (isObject(obj[level])) {
extend(obj[level], options);
} else {
obj[level] = options;
}
}
return obj;
}, {});
}
to = isNumber(params.to) ? params.to : 1;
for (i = 0; i <= to; i++) {
result[i] = merge(
{},
defaults,
isObject(converted[i]) ? converted[i] : {}
);
}
}
return result;
};
/**
* Update the rootId property on the series. Also makes sure that it is
* accessible to exporting.
*
* @private
* @function updateRootId
*
* @param {object} series
* The series to operate on.
*
* @return {string}
* Returns the resulting rootId after update.
*/
var updateRootId = function (series) {
var rootId,
options;
if (isObject(series)) {
// Get the series options.
options = isObject(series.options) ? series.options : {};
// Calculate the rootId.
rootId = pick(series.rootNode, options.rootId, '');
// Set rootId on series.userOptions to pick it up in exporting.
if (isObject(series.userOptions)) {
series.userOptions.rootId = rootId;
}
// Set rootId on series to pick it up on next update.
series.rootNode = rootId;
}
return rootId;
};
var result = {
getColor: getColor,
getLevelOptions: getLevelOptions,
setTreeValues: setTreeValues,
updateRootId: updateRootId
};
return result;
});
_registerModule(_modules, 'mixins/draw-point.js', [], function () {
var isFn = function (x) {
return typeof x === 'function';
};
/**
* Handles the drawing of a component.
* Can be used for any type of component that reserves the graphic property, and
* provides a shouldDraw on its context.
*
* @private
* @function draw
*
* @param {object} params
* Parameters.
*
* TODO: add type checking.
* TODO: export this function to enable usage
*/
var draw = function draw(params) {
var component = this,
graphic = component.graphic,
animatableAttribs = params.animatableAttribs,
onComplete = params.onComplete,
css = params.css,
renderer = params.renderer;
if (component.shouldDraw()) {
if (!graphic) {
component.graphic = graphic =
renderer[params.shapeType](params.shapeArgs).add(params.group);
}
graphic
.css(css)
.attr(params.attribs)
.animate(
animatableAttribs,
params.isNew ? false : undefined,
onComplete
);
} else if (graphic) {
var destroy = function () {
component.graphic = graphic = graphic.destroy();
if (isFn(onComplete)) {
onComplete();
}
};
// animate only runs complete callback if something was animated.
if (Object.keys(animatableAttribs).length) {
graphic.animate(animatableAttribs, undefined, function () {
destroy();
});
} else {
destroy();
}
}
};
/**
* An extended version of draw customized for points.
* It calls additional methods that is expected when rendering a point.
*
* @param {object} params Parameters
*/
var drawPoint = function drawPoint(params) {
var point = this,
attribs = params.attribs = params.attribs || {};
// Assigning class in dot notation does go well in IE8
// eslint-disable-next-line dot-notation
attribs['class'] = point.getClassName();
// Call draw to render component
draw.call(point, params);
};
return drawPoint;
});
_registerModule(_modules, 'modules/treemap.src.js', [_modules['parts/Globals.js'], _modules['mixins/tree-series.js'], _modules['mixins/draw-point.js']], function (H, mixinTreeSeries, drawPoint) {
/* *
* (c) 2014-2019 Highsoft AS
*
* Authors: Jon Arild Nygard / Oystein Moseng
*
* License: www.highcharts.com/license
*/
var seriesType = H.seriesType,
seriesTypes = H.seriesTypes,
addEvent = H.addEvent,
merge = H.merge,
extend = H.extend,
error = H.error,
defined = H.defined,
noop = H.noop,
fireEvent = H.fireEvent,
getColor = mixinTreeSeries.getColor,
getLevelOptions = mixinTreeSeries.getLevelOptions,
isArray = H.isArray,
isBoolean = function (x) {
return typeof x === 'boolean';
},
isNumber = H.isNumber,
isObject = H.isObject,
isString = H.isString,
pick = H.pick,
Series = H.Series,
stableSort = H.stableSort,
color = H.Color,
eachObject = function (list, func, context) {
context = context || this;
H.objectEach(list, function (val, key) {
func.call(context, val, key, list);
});
},
// @todo find correct name for this function.
// @todo Similar to reduce, this function is likely redundant
recursive = function (item, func, context) {
var next;
context = context || this;
next = func.call(context, item);
if (next !== false) {
recursive(next, func, context);
}
},
updateRootId = mixinTreeSeries.updateRootId;
/**
* @private
* @class
* @name Highcharts.seriesTypes.treemap
*
* @augments Highcharts.Series
*/
seriesType(
'treemap',
'scatter'
/**
* A treemap displays hierarchical data using nested rectangles. The data
* can be laid out in varying ways depending on options.
*
* @sample highcharts/demo/treemap-large-dataset/
* Treemap
*
* @extends plotOptions.scatter
* @excluding marker, jitter
* @product highcharts
* @optionparent plotOptions.treemap
*/
, {
/**
* When enabled the user can click on a point which is a parent and
* zoom in on its children. Deprecated and replaced by
* [allowTraversingTree](#plotOptions.treemap.allowTraversingTree).
*
* @sample {highcharts} highcharts/plotoptions/treemap-allowdrilltonode/
* Enabled
*
* @deprecated
* @type {boolean}
* @default false
* @since 4.1.0
* @product highcharts
* @apioption plotOptions.treemap.allowDrillToNode
*/
/**
* When enabled the user can click on a point which is a parent and
* zoom in on its children.
*
* @sample {highcharts} highcharts/plotoptions/treemap-allowtraversingtree/
* Enabled
*
* @since 7.0.3
* @product highcharts
*/
allowTraversingTree: false,
animationLimit: 250,
/**
* When the series contains less points than the crop threshold, all
* points are drawn, event if the points fall outside the visible plot
* area at the current zoom. The advantage of drawing all points
* (including markers and columns), is that animation is performed on
* updates. On the other hand, when the series contains more points than
* the crop threshold, the series data is cropped to only contain points
* that fall within the plot area. The advantage of cropping away
* invisible points is to increase performance on large series.
*
* @type {number}
* @default 300
* @since 4.1.0
* @product highcharts
* @apioption plotOptions.treemap.cropThreshold
*/
/**
* Fires on a request for change of root node for the tree, before the
* update is made. An event object is passed to the function, containing
* additional properties `newRootId`, `previousRootId`, `redraw` and
* `trigger`.
*
* @type {function}
* @default undefined
* @sample {highcharts} highcharts/plotoptions/treemap-events-setrootnode/
* Alert update information on setRootNode event.
* @since 7.0.3
* @product highcharts
* @apioption plotOptions.treemap.events.setRootNode
*/
/**
* This option decides if the user can interact with the parent nodes
* or just the leaf nodes. When this option is undefined, it will be
* true by default. However when allowTraversingTree is true, then it
* will be false by default.
*
* @sample {highcharts} highcharts/plotoptions/treemap-interactbyleaf-false/
* False
* @sample {highcharts} highcharts/plotoptions/treemap-interactbyleaf-true-and-allowtraversingtree/
* InteractByLeaf and allowTraversingTree is true
*
* @type {boolean}
* @since 4.1.2
* @product highcharts
* @apioption plotOptions.treemap.interactByLeaf
*/
/**
* The sort index of the point inside the treemap level.
*
* @sample {highcharts} highcharts/plotoptions/treemap-sortindex/
* Sort by years
*
* @type {number}
* @since 4.1.10
* @product highcharts
* @apioption plotOptions.treemap.sortIndex
*/
/**
* When using automatic point colors pulled from the `options.colors`
* collection, this option determines whether the chart should receive
* one color per series or one color per point.
*
* @see [series colors](#plotOptions.treemap.colors)
*
* @type {boolean}
* @default false
* @since 2.0
* @product highcharts
* @apioption plotOptions.treemap.colorByPoint
*/
/**
* A series specific or series type specific color set to apply instead
* of the global [colors](#colors) when
* [colorByPoint](#plotOptions.treemap.colorByPoint) is true.
*
* @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
* @since 3.0
* @product highcharts
* @apioption plotOptions.treemap.colors
*/
/**
* Whether to display this series type or specific series item in the
* legend.
*/
showInLegend: false,
/**
* @ignore-option
*/
marker: false,
colorByPoint: false,
/**
* @since 4.1.0
*/
dataLabels: {
/** @ignore-option */
defer: false,
/** @ignore-option */
enabled: true,
/** @ignore-option */
formatter: function () {
var point = this && this.point ? this.point : {},
name = isString(point.name) ? point.name : '';
return name;
},
/** @ignore-option */
inside: true,
/** @ignore-option */
verticalAlign: 'middle'
},
tooltip: {
headerFormat: '',
pointFormat: '<b>{point.name}</b>: {point.value}<br/>'
},
/**
* Whether to ignore hidden points when the layout algorithm runs.
* If `false`, hidden points will leave open spaces.
*
* @since 5.0.8
*/
ignoreHiddenPoint: true,
/**
* This option decides which algorithm is used for setting position
* and dimensions of the points.
*
* @see [How to write your own algorithm](https://www.highcharts.com/docs/chart-and-series-types/treemap)
*
* @sample {highcharts} highcharts/plotoptions/treemap-layoutalgorithm-sliceanddice/
* SliceAndDice by default
* @sample {highcharts} highcharts/plotoptions/treemap-layoutalgorithm-stripes/
* Stripes
* @sample {highcharts} highcharts/plotoptions/treemap-layoutalgorithm-squarified/
* Squarified
* @sample {highcharts} highcharts/plotoptions/treemap-layoutalgorithm-strip/
* Strip
*
* @since 4.1.0
* @validvalue ["sliceAndDice", "stripes", "squarified", "strip"]
*/
layoutAlgorithm: 'sliceAndDice',
/**
* Defines which direction the layout algorithm will start drawing.
*
* @since 4.1.0
* @validvalue ["vertical", "horizontal"]
*/
layoutStartingDirection: 'vertical',
/**
* Enabling this option will make the treemap alternate the drawing
* direction between vertical and horizontal. The next levels starting
* direction will always be the opposite of the previous.
*
* @sample {highcharts} highcharts/plotoptions/treemap-alternatestartingdirection-true/
* Enabled
*
* @since 4.1.0
*/
alternateStartingDirection: false,
/**
* Used together with the levels and allowTraversingTree options. When
* set to false the first level visible to be level one, which is
* dynamic when traversing the tree. Otherwise the level will be the
* same as the tree structure.
*
* @since 4.1.0
*/
levelIsConstant: true,
/**
* Options for the button appearing when drilling down in a treemap.
* Deprecated and replaced by
* [traverseUpButton](#plotOptions.treemap.traverseUpButton).
*
* @deprecated
*/
drillUpButton: {
/**
* The position of the button.
*
* @deprecated
*/
position: {
/**
* Vertical alignment of the button.
*
* @deprecated
* @type {Highcharts.VerticalAlignValue}
* @default top
* @product highcharts
* @apioption plotOptions.treemap.drillUpButton.position.verticalAlign
*/
/**
* Horizontal alignment of the button.
*
* @deprecated
* @type {Highcharts.AlignValue}
*/
align: 'right',
/**
* Horizontal offset of the button.
*
* @deprecated
*/
x: -10,
/**
* Vertical offset of the button.
*
* @deprecated
*/
y: 10
}
},
/**
* Options for the button appearing when traversing down in a treemap.
*/
traverseUpButton: {
/**
* The position of the button.
*/
position: {
/**
* Vertical alignment of the button.
*
* @type {Highcharts.VerticalAlignValue}
* @default top
* @product highcharts
* @apioption plotOptions.treemap.traverseUpButton.position.verticalAlign
*/
/**
* Horizontal alignment of the button.
*
* @type {Highcharts.AlignValue}
*/
align: 'right',
/**
* Horizontal offset of the button.
*/
x: -10,
/**
* Vertical offset of the button.
*/
y: 10
}
},
/**
* Set options on specific levels. Takes precedence over series options,
* but not point options.
*
* @sample {highcharts} highcharts/plotoptions/treemap-levels/
* Styling dataLabels and borders
* @sample {highcharts} highcharts/demo/treemap-with-levels/
* Different layoutAlgorithm
*
* @type {Array<*>}
* @since 4.1.0
* @product highcharts
* @apioption plotOptions.treemap.levels
*/
/**
* Can set a `borderColor` on all points which lies on the same level.
*
* @type {Highcharts.ColorString}
* @since 4.1.0
* @product highcharts
* @apioption plotOptions.treemap.levels.borderColor
*/
/**
* Set the dash style of the border of all the point which lies on the
* level. See <a href"#plotoptions.scatter.dashstyle">
* plotOptions.scatter.dashStyle</a> for possible options.
*
* @type {string}
* @since 4.1.0
* @product highcharts
* @apioption plotOptions.treemap.levels.borderDashStyle
*/
/**
* Can set the borderWidth on all points which lies on the same level.
*
* @type {number}
* @since 4.1.0
* @product highcharts
* @apioption plotOptions.treemap.levels.borderWidth
*/
/**
* Can set a color on all points which lies on the same level.
*
* @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
* @since 4.1.0
* @product highcharts
* @apioption plotOptions.treemap.levels.color
*/
/**
* A configuration object to define how the color of a child varies from
* the parent's color. The variation is distributed among the children
* of node. For example when setting brightness, the brightness change
* will range from the parent's original brightness on the first child,
* to the amount set in the `to` setting on the last node. This allows a
* gradient-like color scheme that sets children out from each other
* while highlighting the grouping on treemaps and sectors on sunburst
* charts.
*
* @sample highcharts/demo/sunburst/
* Sunburst with color variation
*
* @since 6.0.0
* @product highcharts
* @apioption plotOptions.treemap.levels.colorVariation
*/
/**
* The key of a color variation. Currently supports `brightness` only.
*
* @type {string}
* @since 6.0.0
* @product highcharts
* @validvalue ["brightness"]
* @apioption plotOptions.treemap.levels.colorVariation.key
*/
/**
* The ending value of a color variation. The last sibling will receive
* this value.
*
* @type {number}
* @since 6.0.0
* @product highcharts
* @apioption plotOptions.treemap.levels.colorVariation.to
*/
/**
* Can set the options of dataLabels on each point which lies on the
* level.
* [plotOptions.treemap.dataLabels](#plotOptions.treemap.dataLabels) for
* possible values.
*
* @type {object}
* @since 4.1.0
* @product highcharts
* @apioption plotOptions.treemap.levels.dataLabels
*/
/**
* Can set the layoutAlgorithm option on a specific level.
*
* @type {string}
* @since 4.1.0
* @product highcharts
* @validvalue ["sliceAndDice", "stripes", "squarified", "strip"]
* @apioption plotOptions.treemap.levels.layoutAlgorithm
*/
/**
* Can set the layoutStartingDirection option on a specific level.
*
* @type {string}
* @since 4.1.0
* @product highcharts
* @validvalue ["vertical", "horizontal"]
* @apioption plotOptions.treemap.levels.layoutStartingDirection
*/
/**
* Decides which level takes effect from the options set in the levels
* object.
*
* @sample {highcharts} highcharts/plotoptions/treemap-levels/
* Styling of both levels
*
* @type {number}
* @since 4.1.0
* @product highcharts
* @apioption plotOptions.treemap.levels.level
*/
// Presentational options
/**
* The color of the border surrounding each tree map item.
*
* @type {Highcharts.ColorString}
*/
borderColor: '#e6e6e6',
/**
* The width of the border surrounding each tree map item.
*/
borderWidth: 1,
/**
* The opacity of a point in treemap. When a point has children, the
* visibility of the children is determined by the opacity.
*
* @since 4.2.4
*/
opacity: 0.15,
/**
* A wrapper object for all the series options in specific states.
*
* @extends plotOptions.heatmap.states
*/
states: {
/**
* Options for the hovered series
*
* @extends plotOptions.heatmap.states.hover
* @excluding halo
*/
hover: {
/**
* The border color for the hovered state.
*/
borderColor: '#999999',
/**
* Brightness for the hovered point. Defaults to 0 if the
* heatmap series is loaded first, otherwise 0.1.
*
* @type {number}
* @default undefined
*/
brightness: seriesTypes.heatmap ? 0 : 0.1,
/**
* @extends plotOptions.heatmap.states.hover.halo
*/
halo: false,
/**
* The opacity of a point in treemap. When a point has children,
* the visibility of the children is determined by the opacity.
*
* @since 4.2.4
*/
opacity: 0.75,
/**
* The shadow option for hovered state.
*/
shadow: false
}
}
// Prototype members
}, {
pointArrayMap: ['value'],
directTouch: true,
optionalAxis: 'colorAxis',
getSymbol: noop,
parallelArrays: ['x', 'y', 'value', 'colorValue'],
colorKey: 'colorValue', // Point color option key
trackerGroups: ['group', 'dataLabelsGroup'],
/**
* Creates an object map from parent id to childrens index.
*
* @private
* @function Highcharts.Series#getListOfParents
*
* @param {Highcharts.SeriesTreemapDataOptions} data
* List of points set in options.
*
* @param {Array<string>} existingIds
* List of all point ids.
*
* @return {object}
* Map from parent id to children index in data.
*/
getListOfParents: function (data, existingIds) {
var arr = isArray(data) ? data : [],
ids = isArray(existingIds) ? existingIds : [],
listOfParents = arr.reduce(function (prev, curr, i) {
var parent = pick(curr.parent, '');
if (prev[parent] === undefined) {
prev[parent] = [];
}
prev[parent].push(i);
return prev;
}, {
'': [] // Root of tree
});
// If parent does not exist, hoist parent to root of tree.
eachObject(listOfParents, function (children, parent, list) {
if ((parent !== '') && (ids.indexOf(parent) === -1)) {
children.forEach(function (child) {
list[''].push(child);
});
delete list[parent];
}
});
return listOfParents;
},
// Creates a tree structured object from the series points
getTree: function () {
var series = this,
allIds = this.data.map(function (d) {
return d.id;
}),
parentList = series.getListOfParents(this.data, allIds);
series.nodeMap = [];
return series.buildNode('', -1, 0, parentList, null);
},
// Define hasData function for non-cartesian series.
// Returns true if the series has points at all.
hasData: function () {
return !!this.processedXData.length; // != 0
},
init: function (chart, options) {
var series = this,
colorSeriesMixin = H.colorSeriesMixin;
// If color series logic is loaded, add some properties
if (H.colorSeriesMixin) {
this.translateColors = colorSeriesMixin.translateColors;
this.colorAttribs = colorSeriesMixin.colorAttribs;
this.axisTypes = colorSeriesMixin.axisTypes;
}
// Handle deprecated options.
addEvent(series, 'setOptions', function (event) {
var options = event.userOptions;
if (
defined(options.allowDrillToNode) &&
!defined(options.allowTraversingTree)
) {
options.allowTraversingTree = options.allowDrillToNode;
delete options.allowDrillToNode;
}
if (
defined(options.drillUpButton) &&
!defined(options.traverseUpButton)
) {
options.traverseUpButton = options.drillUpButton;
delete options.drillUpButton;
}
});
Series.prototype.init.call(series, chart, options);
if (series.options.allowTraversingTree) {
addEvent(series, 'click', series.onClickDrillToNode);
}
},
buildNode: function (id, i, level, list, parent) {
var series = this,
children = [],
point = series.points[i],
height = 0,
node,
child;
// Actions
((list[id] || [])).forEach(function (i) {
child = series.buildNode(
series.points[i].id,
i,
(level + 1),
list,
id
);
height = Math.max(child.height + 1, height);
children.push(child);
});
node = {
id: id,
i: i,
children: children,
height: height,
level: level,
parent: parent,
visible: false // @todo move this to better location
};
series.nodeMap[node.id] = node;
if (point) {
point.node = node;
}
return node;
},
setTreeValues: function (tree) {
var series = this,
options = series.options,
idRoot = series.rootNode,
mapIdToNode = series.nodeMap,
nodeRoot = mapIdToNode[idRoot],
levelIsConstant = (
isBoolean(options.levelIsConstant) ?
options.levelIsConstant :
true
),
childrenTotal = 0,
children = [],
val,
point = series.points[tree.i];
// First give the children some values
tree.children.forEach(function (child) {
child = series.setTreeValues(child);
children.push(child);
if (!child.ignore) {
childrenTotal += child.val;
}
});
// Sort the children
stableSort(children, function (a, b) {
return a.sortIndex - b.sortIndex;
});
// Set the values
val = pick(point && point.options.value, childrenTotal);
if (point) {
point.value = val;
}
extend(tree, {
children: children,
childrenTotal: childrenTotal,
// Ignore this node if point is not visible
ignore: !(pick(point && point.visible, true) && (val > 0)),
isLeaf: tree.visible && !childrenTotal,
levelDynamic: (
tree.level - (levelIsConstant ? 0 : nodeRoot.level)
),
name: pick(point && point.name, ''),
sortIndex: pick(point && point.sortIndex, -val),
val: val
});
return tree;
},
/**
* Recursive function which calculates the area for all children of a
* node.
*
* @private
* @function Highcharts.Series#calculateChildrenAreas
*
* @param {object} node
* The node which is parent to the children.
*
* @param {object} area
* The rectangular area of the parent.
*/
calculateChildrenAreas: function (parent, area) {
var series = this,
options = series.options,
mapOptionsToLevel = series.mapOptionsToLevel,
level = mapOptionsToLevel[parent.level + 1],
algorithm = pick(
(
series[level &&
level.layoutAlgorithm] &&
level.layoutAlgorithm
),
options.layoutAlgorithm
),
alternate = options.alternateStartingDirection,
childrenValues = [],
children;
// Collect all children which should be included
children = parent.children.filter(function (n) {
return !n.ignore;
});
if (level && level.layoutStartingDirection) {
area.direction = level.layoutStartingDirection === 'vertical' ?
0 :
1;
}
childrenValues = series[algorithm](area, children);
children.forEach(function (child, index) {
var values = childrenValues[index];
child.values = merge(values, {
val: child.childrenTotal,
direction: (alternate ? 1 - area.direction : area.direction)
});
child.pointValues = merge(values, {
x: (values.x / series.axisRatio),
width: (values.width / series.axisRatio)
});
// If node has children, then call method recursively
if (child.children.length) {
series.calculateChildrenAreas(child, child.values);
}
});
},
setPointValues: function () {
var series = this,
xAxis = series.xAxis,
yAxis = series.yAxis;
series.points.forEach(function (point) {
var node = point.node,
values = node.pointValues,
x1,
x2,
y1,
y2,
crispCorr = 0;
// Get the crisp correction in classic mode. For this to work in
// styled mode, we would need to first add the shape (without x,
// y, width and height), then read the rendered stroke width
// using point.graphic.strokeWidth(), then modify and apply the
// shapeArgs. This applies also to column series, but the
// downside is performance and code complexity.
if (!series.chart.styledMode) {
crispCorr = (
(series.pointAttribs(point)['stroke-width'] || 0) % 2
) / 2;
}
// Points which is ignored, have no values.
if (values && node.visible) {
x1 = Math.round(
xAxis.translate(values.x, 0, 0, 0, 1)
) - crispCorr;
x2 = Math.round(
xAxis.translate(values.x + values.width, 0, 0, 0, 1)
) - crispCorr;
y1 = Math.round(
yAxis.translate(values.y, 0, 0, 0, 1)
) - crispCorr;
y2 = Math.round(
yAxis.translate(values.y + values.height, 0, 0, 0, 1)
) - crispCorr;
// Set point values
point.shapeArgs = {
x: Math.min(x1, x2),
y: Math.min(y1, y2),
width: Math.abs(x2 - x1),
height: Math.abs(y2 - y1)
};
point.plotX =
point.shapeArgs.x + (point.shapeArgs.width / 2);
point.plotY =
point.shapeArgs.y + (point.shapeArgs.height / 2);
} else {
// Reset visibility
delete point.plotX;
delete point.plotY;
}
});
},
// Set the node's color recursively, from the parent down.
setColorRecursive: function (
node,
parentColor,
colorIndex,
index,
siblings
) {
var series = this,
chart = series && series.chart,
colors = chart && chart.options && chart.options.colors,
colorInfo,
point;
if (node) {
colorInfo = getColor(node, {
colors: colors,
index: index,
mapOptionsToLevel: series.mapOptionsToLevel,
parentColor: parentColor,
parentColorIndex: colorIndex,
series: series,
siblings: siblings
});
point = series.points[node.i];
if (point) {
point.color = colorInfo.color;
point.colorIndex = colorInfo.colorIndex;
}
// Do it all again with the children
(node.children || []).forEach(function (child, i) {
series.setColorRecursive(
child,
colorInfo.color,
colorInfo.colorIndex,
i,
node.children.length
);
});
}
},
algorithmGroup: function (h, w, d, p) {
this.height = h;
this.width = w;
this.plot = p;
this.direction = d;
this.startDirection = d;
this.total = 0;
this.nW = 0;
this.lW = 0;
this.nH = 0;
this.lH = 0;
this.elArr = [];
this.lP = {
total: 0,
lH: 0,
nH: 0,
lW: 0,
nW: 0,
nR: 0,
lR: 0,
aspectRatio: function (w, h) {
return Math.max((w / h), (h / w));
}
};
this.addElement = function (el) {
this.lP.total = this.elArr[this.elArr.length - 1];
this.total = this.total + el;
if (this.direction === 0) {
// Calculate last point old aspect ratio
this.lW = this.nW;
this.lP.lH = this.lP.total / this.lW;
this.lP.lR = this.lP.aspectRatio(this.lW, this.lP.lH);
// Calculate last point new aspect ratio
this.nW = this.total / this.height;
this.lP.nH = this.lP.total / this.nW;
this.lP.nR = this.lP.aspectRatio(this.nW, this.lP.nH);
} else {
// Calculate last point old aspect ratio
this.lH = this.nH;
this.lP.lW = this.lP.total / this.lH;
this.lP.lR = this.lP.aspectRatio(this.lP.lW, this.lH);
// Calculate last point new aspect ratio
this.nH = this.total / this.width;
this.lP.nW = this.lP.total / this.nH;
this.lP.nR = this.lP.aspectRatio(this.lP.nW, this.nH);
}
this.elArr.push(el);
};
this.reset = function () {
this.nW = 0;
this.lW = 0;
this.elArr = [];
this.total = 0;
};
},
algorithmCalcPoints: function (
directionChange, last, group, childrenArea
) {
var pX,
pY,
pW,
pH,
gW = group.lW,
gH = group.lH,
plot = group.plot,
keep,
i = 0,
end = group.elArr.length - 1;
if (last) {
gW = group.nW;
gH = group.nH;
} else {
keep = group.elArr[group.elArr.length - 1];
}
group.elArr.forEach(function (p) {
if (last || (i < end)) {
if (group.direction === 0) {
pX = plot.x;
pY = plot.y;
pW = gW;
pH = p / pW;
} else {
pX = plot.x;
pY = plot.y;
pH = gH;
pW = p / pH;
}
childrenArea.push({
x: pX,
y: pY,
width: pW,
height: H.correctFloat(pH)
});
if (group.direction === 0) {
plot.y = plot.y + pH;
} else {
plot.x = plot.x + pW;
}
}
i = i + 1;
});
// Reset variables
group.reset();
if (group.direction === 0) {
group.width = group.width - gW;
} else {
group.height = group.height - gH;
}
plot.y = plot.parent.y + (plot.parent.height - group.height);
plot.x = plot.parent.x + (plot.parent.width - group.width);
if (directionChange) {
group.direction = 1 - group.direction;
}
// If not last, then add uncalculated element
if (!last) {
group.addElement(keep);
}
},
algorithmLowAspectRatio: function (directionChange, parent, children) {
var childrenArea = [],
series = this,
pTot,
plot = {
x: parent.x,
y: parent.y,
parent: parent
},
direction = parent.direction,
i = 0,
end = children.length - 1,
group = new this.algorithmGroup( // eslint-disable-line new-cap
parent.height,
parent.width,
direction,
plot
);
// Loop through and calculate all areas
children.forEach(function (child) {
pTot =
(parent.width * parent.height) * (child.val / parent.val);
group.addElement(pTot);
if (group.lP.nR > group.lP.lR) {
series.algorithmCalcPoints(
directionChange,
false,
group,
childrenArea,
plot
);
}
// If last child, then calculate all remaining areas
if (i === end) {
series.algorithmCalcPoints(
directionChange,
true,
group,
childrenArea,
plot
);
}
i = i + 1;
});
return childrenArea;
},
algorithmFill: function (directionChange, parent, children) {
var childrenArea = [],
pTot,
direction = parent.direction,
x = parent.x,
y = parent.y,
width = parent.width,
height = parent.height,
pX,
pY,
pW,
pH;
children.forEach(function (child) {
pTot =
(parent.width * parent.height) * (child.val / parent.val);
pX = x;
pY = y;
if (direction === 0) {
pH = height;
pW = pTot / pH;
width = width - pW;
x = x + pW;
} else {
pW = width;
pH = pTot / pW;
height = height - pH;
y = y + pH;
}
childrenArea.push({
x: pX,
y: pY,
width: pW,
height: pH
});
if (directionChange) {
direction = 1 - direction;
}
});
return childrenArea;
},
strip: function (parent, children) {
return this.algorithmLowAspectRatio(false, parent, children);
},
squarified: function (parent, children) {
return this.algorithmLowAspectRatio(true, parent, children);
},
sliceAndDice: function (parent, children) {
return this.algorithmFill(true, parent, children);
},
stripes: function (parent, children) {
return this.algorithmFill(false, parent, children);
},
translate: function () {
var series = this,
options = series.options,
// NOTE: updateRootId modifies series.
rootId = updateRootId(series),
rootNode,
pointValues,
seriesArea,
tree,
val;
// Call prototype function
Series.prototype.translate.call(series);
// @todo Only if series.isDirtyData is true
tree = series.tree = series.getTree();
rootNode = series.nodeMap[rootId];
series.renderTraverseUpButton(rootId);
series.mapOptionsToLevel = getLevelOptions({
from: rootNode.level + 1,
levels: options.levels,
to: tree.height,
defaults: {
levelIsConstant: series.options.levelIsConstant,
colorByPoint: options.colorByPoint
}
});
if (
rootId !== '' &&
(!rootNode || !rootNode.children.length)
) {
series.setRootNode('', false);
rootId = series.rootNode;
rootNode = series.nodeMap[rootId];
}
// Parents of the root node is by default visible
recursive(series.nodeMap[series.rootNode], function (node) {
var next = false,
p = node.parent;
node.visible = true;
if (p || p === '') {
next = series.nodeMap[p];
}
return next;
});
// Children of the root node is by default visible
recursive(
series.nodeMap[series.rootNode].children,
function (children) {
var next = false;
children.forEach(function (child) {
child.visible = true;
if (child.children.length) {
next = (next || []).concat(child.children);
}
});
return next;
}
);
series.setTreeValues(tree);
// Calculate plotting values.
series.axisRatio = (series.xAxis.len / series.yAxis.len);
series.nodeMap[''].pointValues = pointValues =
{ x: 0, y: 0, width: 100, height: 100 };
series.nodeMap[''].values = seriesArea = merge(pointValues, {
width: (pointValues.width * series.axisRatio),
direction: (
options.layoutStartingDirection === 'vertical' ? 0 : 1
),
val: tree.val
});
series.calculateChildrenAreas(tree, seriesArea);
// Logic for point colors
if (series.colorAxis) {
series.translateColors();
} else if (!options.colorByPoint) {
series.setColorRecursive(series.tree);
}
// Update axis extremes according to the root node.
if (options.allowTraversingTree) {
val = rootNode.pointValues;
series.xAxis.setExtremes(val.x, val.x + val.width, false);
series.yAxis.setExtremes(val.y, val.y + val.height, false);
series.xAxis.setScale();
series.yAxis.setScale();
}
// Assign values to points.
series.setPointValues();
},
/**
* Extend drawDataLabels with logic to handle custom options related to
* the treemap series:
*
* - Points which is not a leaf node, has dataLabels disabled by
* default.
*
* - Options set on series.levels is merged in.
*
* - Width of the dataLabel is set to match the width of the point
* shape.
*
* @private
* @function Highcharts.Series#drawDataLabels
*/
drawDataLabels: function () {
var series = this,
mapOptionsToLevel = series.mapOptionsToLevel,
points = series.points.filter(function (n) {
return n.node.visible;
}),
options,
level;
points.forEach(function (point) {
level = mapOptionsToLevel[point.node.level];
// Set options to new object to avoid problems with scope
options = { style: {} };
// If not a leaf, then label should be disabled as default
if (!point.node.isLeaf) {
options.enabled = false;
}
// If options for level exists, include them as well
if (level && level.dataLabels) {
options = merge(options, level.dataLabels);
series._hasPointLabels = true;
}
// Set dataLabel width to the width of the point shape.
if (point.shapeArgs) {
options.style.width = point.shapeArgs.width;
if (point.dataLabel) {
point.dataLabel.css({
width: point.shapeArgs.width + 'px'
});
}
}
// Merge custom options with point options
point.dlOptions = merge(options, point.options.dataLabels);
});
Series.prototype.drawDataLabels.call(this);
},
// Over the alignment method by setting z index
alignDataLabel: function (point, dataLabel, labelOptions) {
var style = labelOptions.style;
// #8160: Prevent the label from exceeding the point's
// boundaries in treemaps by applying ellipsis overflow.
// The issue was happening when datalabel's text contained a
// long sequence of characters without a whitespace.
if (
!H.defined(style.textOverflow) &&
dataLabel.text &&
dataLabel.getBBox().width > dataLabel.text.textWidth
) {
dataLabel.css({
textOverflow: 'ellipsis',
// unit (px) is required when useHTML is true
width: style.width += 'px'
});
}
seriesTypes.column.prototype.alignDataLabel.apply(this, arguments);
if (point.dataLabel) {
// point.node.zIndex could be undefined (#6956)
point.dataLabel.attr({ zIndex: (point.node.zIndex || 0) + 1 });
}
},
// Get presentational attributes
pointAttribs: function (point, state) {
var series = this,
mapOptionsToLevel = (
isObject(series.mapOptionsToLevel) ?
series.mapOptionsToLevel :
{}
),
level = point && mapOptionsToLevel[point.node.level] || {},
options = this.options,
attr,
stateOptions = (state && options.states[state]) || {},
className = (point && point.getClassName()) || '',
opacity;
// Set attributes by precedence. Point trumps level trumps series.
// Stroke width uses pick because it can be 0.
attr = {
'stroke':
(point && point.borderColor) ||
level.borderColor ||
stateOptions.borderColor ||
options.borderColor,
'stroke-width': pick(
point && point.borderWidth,
level.borderWidth,
stateOptions.borderWidth,
options.borderWidth
),
'dashstyle':
(point && point.borderDashStyle) ||
level.borderDashStyle ||
stateOptions.borderDashStyle ||
options.borderDashStyle,
'fill': (point && point.color) || this.color
};
// Hide levels above the current view
if (className.indexOf('highcharts-above-level') !== -1) {
attr.fill = 'none';
attr['stroke-width'] = 0;
// Nodes with children that accept interaction
} else if (
className.indexOf('highcharts-internal-node-interactive') !== -1
) {
opacity = pick(stateOptions.opacity, options.opacity);
attr.fill = color(attr.fill).setOpacity(opacity).get();
attr.cursor = 'pointer';
// Hide nodes that have children
} else if (className.indexOf('highcharts-internal-node') !== -1) {
attr.fill = 'none';
} else if (state) {
// Brighten and hoist the hover nodes
attr.fill = color(attr.fill)
.brighten(stateOptions.brightness)
.get();
}
return attr;
},
// Override drawPoints
drawPoints: function () {
var series = this,
chart = series.chart,
renderer = chart.renderer,
points = series.points,
styledMode = chart.styledMode,
options = series.options,
shadow = styledMode ? {} : options.shadow,
borderRadius = options.borderRadius,
withinAnimationLimit =
chart.pointCount < options.animationLimit,
allowTraversingTree = options.allowTraversingTree;
points.forEach(function (point) {
var levelDynamic = point.node.levelDynamic,
animate = {},
attr = {},
css = {},
groupKey = 'level-group-' + levelDynamic,
hasGraphic = !!point.graphic,
shouldAnimate = withinAnimationLimit && hasGraphic,
shapeArgs = point.shapeArgs;
// Don't bother with calculate styling if the point is not drawn
if (point.shouldDraw()) {
if (borderRadius) {
attr.r = borderRadius;
}
merge(
true, // Extend object
// Which object to extend
shouldAnimate ? animate : attr,
// Add shapeArgs to animate/attr if graphic exists
hasGraphic ? shapeArgs : {},
// Add style attribs if !styleMode
styledMode ?
{} :
series.pointAttribs(
point, point.selected && 'select'
)
);
// In styled mode apply point.color. Use CSS, otherwise the
// fill used in the style sheet will take precedence over
// the fill attribute.
if (series.colorAttribs && styledMode) {
// Heatmap is loaded
extend(css, series.colorAttribs(point));
}
if (!series[groupKey]) {
series[groupKey] = renderer.g(groupKey)
.attr({
// @todo Set the zIndex based upon the number of
// levels, instead of using 1000
zIndex: 1000 - levelDynamic
})
.add(series.group);
}
}
// Draw the point
point.draw({
animatableAttribs: animate,
attribs: attr,
css: css,
group: series[groupKey],
renderer: renderer,
shadow: shadow,
shapeArgs: shapeArgs,
shapeType: 'rect'
});
// If setRootNode is allowed, set a point cursor on clickables &
// add drillId to point
if (allowTraversingTree && point.graphic) {
point.drillId = options.interactByLeaf ?
series.drillToByLeaf(point) :
series.drillToByGroup(point);
}
});
},
// Add drilling on the suitable points
onClickDrillToNode: function (event) {
var series = this,
point = event.point,
drillId = point && point.drillId;
// If a drill id is returned, add click event and cursor.
if (isString(drillId)) {
point.setState(''); // Remove hover
series.setRootNode(drillId, true, { trigger: 'click' });
}
},
/**
* Finds the drill id for a parent node. Returns false if point should
* not have a click event.
*
* @private
* @function Highcharts.Series#drillToByGroup
*
* @param {object} point
*
* @return {boolean|string}
* Drill to id or false when point should not have a click
* event.
*/
drillToByGroup: function (point) {
var series = this,
drillId = false;
if ((point.node.level - series.nodeMap[series.rootNode].level) ===
1 &&
!point.node.isLeaf
) {
drillId = point.id;
}
return drillId;
},
/**
* Finds the drill id for a leaf node. Returns false if point should not
* have a click event
*
* @private
* @function Highcharts.Series#drillToByLeaf
*
* @param {object} point
*
* @return {boolean|string}
* Drill to id or false when point should not have a click
* event.
*/
drillToByLeaf: function (point) {
var series = this,
drillId = false,
nodeParent;
if ((point.node.parent !== series.rootNode) &&
point.node.isLeaf
) {
nodeParent = point.node;
while (!drillId) {
nodeParent = series.nodeMap[nodeParent.parent];
if (nodeParent.parent === series.rootNode) {
drillId = nodeParent.id;
}
}
}
return drillId;
},
drillUp: function () {
var series = this,
node = series.nodeMap[series.rootNode];
if (node && isString(node.parent)) {
series.setRootNode(
node.parent,
true,
{ trigger: 'traverseUpButton' }
);
}
},
// TODO remove this function at a suitable version.
drillToNode: function (id, redraw) {
error(
'WARNING: treemap.drillToNode has been renamed to treemap.' +
'setRootNode, and will be removed in the next major version.'
);
this.setRootNode(id, redraw);
},
/**
* Sets a new root node for the series.
*
* @private
* @function Highcharts.Series#setRootNode
*
* @param {string} id The id of the new root node.
* @param {boolean} [redraw=true] Wether to redraw the chart or not.
* @param {object} [eventArguments] Arguments to be accessed in
* event handler.
* @param {string} [eventArguments.newRootId] Id of the new root.
* @param {string} [eventArguments.previousRootId] Id of the previous
* root.
* @param {boolean} [eventArguments.redraw] Wether to redraw the
* chart after.
* @param {object} [eventArguments.series] The series to update the root
* of.
* @param {string} [eventArguments.trigger] The action which
* triggered the event. Undefined if the setRootNode is called
* directly.
*/
setRootNode: function (id, redraw, eventArguments) {
var series = this,
eventArgs = extend({
newRootId: id,
previousRootId: series.rootNode,
redraw: pick(redraw, true),
series: series
}, eventArguments);
/**
* The default functionality of the setRootNode event.
*
* @private
* @param {object} args The event arguments.
* @param {string} args.newRootId Id of the new root.
* @param {string} args.previousRootId Id of the previous root.
* @param {boolean} args.redraw Wether to redraw the chart after.
* @param {object} args.series The series to update the root of.
* @param {string} [args.trigger=undefined] The action which
* triggered the event. Undefined if the setRootNode is called
* directly.
*/
var defaultFn = function (args) {
var series = args.series;
// Store previous and new root ids on the series.
series.idPreviousRoot = args.previousRootId;
series.rootNode = args.newRootId;
// Redraw the chart
series.isDirty = true; // Force redraw
if (args.redraw) {
series.chart.redraw();
}
};
// Fire setRootNode event.
fireEvent(series, 'setRootNode', eventArgs, defaultFn);
},
renderTraverseUpButton: function (rootId) {
var series = this,
nodeMap = series.nodeMap,
node = nodeMap[rootId],
name = node.name,
buttonOptions = series.options.traverseUpButton,
backText = pick(buttonOptions.text, name, '< Back'),
attr,
states;
if (rootId === '') {
if (series.drillUpButton) {
series.drillUpButton = series.drillUpButton.destroy();
}
} else if (!this.drillUpButton) {
attr = buttonOptions.theme;
states = attr && attr.states;
this.drillUpButton = this.chart.renderer.button(
backText,
null,
null,
function () {
series.drillUp();
},
attr,
states && states.hover,
states && states.select
)
.addClass('highcharts-drillup-button')
.attr({
align: buttonOptions.position.align,
zIndex: 7
})
.add()
.align(
buttonOptions.position,
false,
buttonOptions.relativeTo || 'plotBox'
);
} else {
this.drillUpButton.placed = false;
this.drillUpButton.attr({
text: backText
})
.align();
}
},
buildKDTree: noop,
drawLegendSymbol: H.LegendSymbolMixin.drawRectangle,
getExtremes: function () {
// Get the extremes from the value data
Series.prototype.getExtremes.call(this, this.colorValueData);
this.valueMin = this.dataMin;
this.valueMax = this.dataMax;
// Get the extremes from the y data
Series.prototype.getExtremes.call(this);
},
getExtremesFromAll: true,
bindAxes: function () {
var treeAxis = {
endOnTick: false,
gridLineWidth: 0,
lineWidth: 0,
min: 0,
dataMin: 0,
minPadding: 0,
max: 100,
dataMax: 100,
maxPadding: 0,
startOnTick: false,
title: null,
tickPositions: []
};
Series.prototype.bindAxes.call(this);
H.extend(this.yAxis.options, treeAxis);
H.extend(this.xAxis.options, treeAxis);
},
/**
* Workaround for `inactive` state. Since `series.opacity` option is
* already reserved, don't use that state at all by disabling
* `inactiveOtherPoints` and not inheriting states by points.
*
* @private
*/
setState: function (state) {
this.options.inactiveOtherPoints = true;
Series.prototype.setState.call(this, state, false);
this.options.inactiveOtherPoints = false;
},
utils: {
recursive: recursive
}
// Point class
}, {
draw: drawPoint,
getClassName: function () {
var className = H.Point.prototype.getClassName.call(this),
series = this.series,
options = series.options;
// Above the current level
if (this.node.level <= series.nodeMap[series.rootNode].level) {
className += ' highcharts-above-level';
} else if (
!this.node.isLeaf &&
!pick(options.interactByLeaf, !options.allowTraversingTree)
) {
className += ' highcharts-internal-node-interactive';
} else if (!this.node.isLeaf) {
className += ' highcharts-internal-node';
}
return className;
},
/**
* A tree point is valid if it has han id too, assume it may be a parent
* item.
*
* @private
* @function Highcharts.Point#isValid
*/
isValid: function () {
return this.id || isNumber(this.value);
},
setState: function (state) {
H.Point.prototype.setState.call(this, state);
// Graphic does not exist when point is not visible.
if (this.graphic) {
this.graphic.attr({
zIndex: state === 'hover' ? 1 : 0
});
}
},
setVisible: seriesTypes.pie.prototype.pointClass.prototype.setVisible,
shouldDraw: function () {
var point = this;
return isNumber(point.plotY) && point.y !== null;
}
}
);
/**
* A `treemap` series. If the [type](#series.treemap.type) option is
* not specified, it is inherited from [chart.type](#chart.type).
*
* @extends series,plotOptions.treemap
* @excluding dataParser, dataURL, stack
* @product highcharts
* @apioption series.treemap
*/
/**
* An array of data points for the series. For the `treemap` series
* type, points can be given in the following ways:
*
* 1. An array of numerical values. In this case, the numerical values will be
* interpreted as `value` options. Example:
* ```js
* data: [0, 5, 3, 5]
* ```
*
* 2. An array of objects with named values. The following snippet shows only a
* few settings, see the complete options set below. If the total number of
* data points exceeds the series'
* [turboThreshold](#series.treemap.turboThreshold),
* this option is not available.
* ```js
* data: [{
* value: 9,
* name: "Point2",
* color: "#00FF00"
* }, {
* value: 6,
* name: "Point1",
* color: "#FF00FF"
* }]
* ```
*
* @sample {highcharts} highcharts/chart/reflow-true/
* Numerical values
* @sample {highcharts} highcharts/series/data-array-of-objects/
* Config objects
*
* @type {Array<number|null|*>}
* @extends series.heatmap.data
* @excluding x, y
* @product highcharts
* @apioption series.treemap.data
*/
/**
* The value of the point, resulting in a relative area of the point
* in the treemap.
*
* @type {number|null}
* @product highcharts
* @apioption series.treemap.data.value
*/
/**
* Serves a purpose only if a `colorAxis` object is defined in the chart
* options. This value will decide which color the point gets from the
* scale of the colorAxis.
*
* @type {number}
* @since 4.1.0
* @product highcharts
* @apioption series.treemap.data.colorValue
*/
/**
* Only for treemap. Use this option to build a tree structure. The
* value should be the id of the point which is the parent. If no points
* has a matching id, or this option is undefined, then the parent will
* be set to the root.
*
* @sample {highcharts} highcharts/point/parent/
* Point parent
* @sample {highcharts} highcharts/demo/treemap-with-levels/
* Example where parent id is not matching
*
* @type {string}
* @since 4.1.0
* @product highcharts
* @apioption series.treemap.data.parent
*/
});
_registerModule(_modules, 'masters/modules/treemap.src.js', [], function () {
});
}));
| Qesy/Q-Frame | Static/bootstrap/Highcharts-7.1.1/modules/treemap.src.js | JavaScript | apache-2.0 | 92,176 | [
30522,
1013,
1008,
1008,
1008,
1030,
6105,
2152,
7507,
21217,
30524,
1006,
1039,
1007,
2297,
1011,
10476,
26836,
15794,
2004,
1008,
6048,
1024,
6285,
10488,
6392,
6396,
13444,
1013,
1051,
27268,
12377,
9587,
5054,
2290,
1008,
1008,
6105,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package org.mimosaframework.core.server;
import org.mimosaframework.core.exception.ServerException;
import java.util.List;
public interface JoinServer extends Server {
void setLeaderServerHost(String host);
void setLeaderServerPort(int port);
void joinServerGroup() throws ServerException;
List<ServerNode> checkServerGroup();
void notifyServerGroupRemoved(List<ServerNode> nodes) throws ServerException;
void setLeaderServer(boolean isLeaderServer);
boolean isLeaderServer();
}
| yangankang/mimosa | mimosa-core/src/main/java/org/mimosaframework/core/server/JoinServer.java | Java | apache-2.0 | 517 | [
30522,
7427,
8917,
1012,
2771,
15530,
10354,
6444,
7974,
2953,
2243,
1012,
4563,
1012,
8241,
1025,
12324,
8917,
1012,
2771,
15530,
10354,
6444,
7974,
2953,
2243,
1012,
4563,
1012,
6453,
1012,
8241,
10288,
24422,
1025,
12324,
9262,
1012,
305... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
define(["Log","FS"],function (Log,FS) {//MODJSL
return function showErrorPos(elem, err) {
var mesg, src, pos;
if (!err) {
close();
return;
}
var row,col;
if (err.isTError) {
mesg=err.mesg;
src=err.src;
pos=err.pos;
row=err.row+1;
col=err.col+1;
} else {
src={name:function (){return "不明";},text:function () {
return null;
}};
pos=0;
mesg=err;
}
function close(){
elem.empty();
}
if(typeof pos=="object") {row=pos.row; col=pos.col;}
close();
var mesgd=$("<div>").text(mesg+" 場所:"+src.name()+(typeof row=="number"?":"+row+":"+col:""));
//mesgd.append($("<button>").text("閉じる").click(close));
elem.append(mesgd);
elem.append($("<div>").attr("class","quickFix"));
console.log("src=",src);
var str=src.text();
if (str && typeof pos=="object") {
var npos=0;
var lines=str.split(/\n/);
for (var i=0 ; i<lines.length && i+1<pos.row ; i++) {
npos+=lines[i].length;
}
npos+=pos.col;
pos=npos;
}
var srcd=$("<pre>");
srcd.append($("<span>").text(str.substring(0,pos)));
srcd.append($("<img>").attr("src",FS.expandPath("${sampleImg}/ecl.png")));//MODJSL
srcd.append($("<span>").text(str.substring(pos)));
elem.append(srcd);
//elem.attr("title",mesg+" 場所:"+src.name());
elem.attr("title","エラー");
var diag=elem.dialog({width:600,height:400});
Log.d("error", mesg+"\nat "+src+":"+err.pos+"\n"+str.substring(0,err.pos)+"##HERE##"+str.substring(err.pos));
return diag;
};
}); | hoge1e3/tonyuedit | war/js/ide/ErrorPos.js | JavaScript | apache-2.0 | 1,670 | [
30522,
9375,
1006,
1031,
1000,
8833,
1000,
1010,
1000,
1042,
2015,
1000,
1033,
1010,
3853,
1006,
8833,
1010,
1042,
2015,
1007,
1063,
1013,
1013,
16913,
22578,
2140,
2709,
3853,
6457,
29165,
6873,
2015,
1006,
3449,
6633,
1010,
9413,
2099,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
declare(strict_types=1);
namespace Brick\Money\ExchangeRateProvider;
use Brick\Money\ExchangeRateProvider;
use Brick\Money\Exception\CurrencyConversionException;
/**
* Reads exchange rates from a PDO database connection.
*/
final class PDOProvider implements ExchangeRateProvider
{
/**
* The SELECT statement.
*
* @var \PDOStatement
*/
private $statement;
/**
* The source currency code if fixed, or null if dynamic.
*
* @var string|null
*/
private $sourceCurrencyCode;
/**
* The target currency code if fixed, or null if dynamic.
*
* @var string|null
*/
private $targetCurrencyCode;
/**
* Extra parameters set dynamically to resolve the query placeholders.
*
* @var array
*/
private $parameters = [];
/**
* @param \PDO $pdo
* @param PDOProviderConfiguration $configuration
*
* @throws \InvalidArgumentException
*/
public function __construct(\PDO $pdo, PDOProviderConfiguration $configuration)
{
$conditions = [];
/** @psalm-suppress DocblockTypeContradiction */
if ($configuration->tableName === null) {
throw new \InvalidArgumentException('Invalid configuration: $tableName is not set.');
}
/** @psalm-suppress DocblockTypeContradiction */
if ($configuration->exchangeRateColumnName === null) {
throw new \InvalidArgumentException('Invalid configuration: $exchangeRateColumnName is not set.');
}
if ($configuration->sourceCurrencyCode !== null && $configuration->targetCurrencyCode !== null) {
throw new \InvalidArgumentException('Invalid configuration: $sourceCurrencyCode and $targetCurrencyCode cannot be both set.');
}
if ($configuration->whereConditions !== null) {
$conditions[] = '(' . $configuration->whereConditions . ')';
}
if ($configuration->sourceCurrencyCode !== null) {
$this->sourceCurrencyCode = $configuration->sourceCurrencyCode;
} elseif ($configuration->sourceCurrencyColumnName !== null) {
$conditions[] = $configuration->sourceCurrencyColumnName . ' = ?';
} else {
throw new \InvalidArgumentException('Invalid configuration: one of $sourceCurrencyCode or $sourceCurrencyColumnName must be set.');
}
if ($configuration->targetCurrencyCode !== null) {
$this->targetCurrencyCode = $configuration->targetCurrencyCode;
} elseif ($configuration->targetCurrencyColumnName !== null) {
$conditions[] = $configuration->targetCurrencyColumnName . ' = ?';
} else {
throw new \InvalidArgumentException('Invalid configuration: one of $targetCurrencyCode or $targetCurrencyColumnName must be set.');
}
$conditions = implode(' AND ' , $conditions);
$query = sprintf(
'SELECT %s FROM %s WHERE %s',
$configuration->exchangeRateColumnName,
$configuration->tableName,
$conditions
);
$this->statement = $pdo->prepare($query);
}
/**
* Sets the parameters to dynamically resolve the extra query placeholders, if any.
*
* This is used in conjunction with $whereConditions in the configuration class.
* The number of parameters passed to this method must match the number of placeholders.
*
* @param mixed ...$parameters
*
* @return void
*/
public function setParameters(...$parameters) : void
{
$this->parameters = $parameters;
}
/**
* {@inheritdoc}
*/
public function getExchangeRate(string $sourceCurrencyCode, string $targetCurrencyCode)
{
$parameters = $this->parameters;
if ($this->sourceCurrencyCode === null) {
$parameters[] = $sourceCurrencyCode;
} elseif ($this->sourceCurrencyCode !== $sourceCurrencyCode) {
$info = 'source currency must be ' . $this->sourceCurrencyCode;
throw CurrencyConversionException::exchangeRateNotAvailable($sourceCurrencyCode, $targetCurrencyCode, $info);
}
if ($this->targetCurrencyCode === null) {
$parameters[] = $targetCurrencyCode;
} elseif ($this->targetCurrencyCode !== $targetCurrencyCode) {
$info = 'target currency must be ' . $this->targetCurrencyCode;
throw CurrencyConversionException::exchangeRateNotAvailable($sourceCurrencyCode, $targetCurrencyCode, $info);
}
$this->statement->execute($parameters);
/** @var int|float|numeric-string|false $exchangeRate */
$exchangeRate = $this->statement->fetchColumn();
if ($exchangeRate === false) {
if ($this->parameters !== []) {
$info = [];
/** @psalm-suppress MixedAssignment */
foreach ($this->parameters as $parameter) {
$info[] = var_export($parameter, true);
}
$info = 'parameters: ' . implode(', ', $info);
} else {
$info = null;
}
throw CurrencyConversionException::exchangeRateNotAvailable($sourceCurrencyCode, $targetCurrencyCode, $info);
}
return $exchangeRate;
}
}
| brick/money | src/ExchangeRateProvider/PDOProvider.php | PHP | mit | 5,366 | [
30522,
1026,
1029,
25718,
13520,
1006,
9384,
1035,
4127,
1027,
1015,
1007,
1025,
3415,
15327,
5318,
1032,
2769,
1032,
3863,
11657,
21572,
17258,
2121,
1025,
2224,
5318,
1032,
2769,
1032,
3863,
11657,
21572,
17258,
2121,
1025,
2224,
5318,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
var expect = require('chai').expect;
var sinon = require('sinon');
var ColumnShifter = require('component/grid/projection/column-shifter');
var Base = require('component/grid/projection/base');
var Response = require('component/grid/model/response');
describe('projection ColumnShifter', function () {
it('update should run normal', function () {
var model = new ColumnShifter();
var originalData = new Base();
originalData.data = new Response({
columns: {
name: { name: 'hello', property: 'name' },
id: { id: '007', property: 'id' },
},
select: ['name', 'id'],
});
originalData.pipe(model);
expect(model.data.get('select')[0]).to.be.equal('column.skip.less');
expect(model.data.get('select')[3]).to.be.equal('column.skip.more');
});
it('thClick should run normal', function () {
var model = new ColumnShifter();
model.get = sinon.stub().returns(1);
sinon.spy(model, 'set');
model.thClick({}, {
column: { $metadata: { enabled: true } },
property: 'column.skip.less',
});
expect(model.set.calledWith({ 'column.skip': 0 })).to.be.true;
});
});
| steins024/projection-grid | spec/unit/column-shifter-spec.js | JavaScript | mit | 1,152 | [
30522,
13075,
5987,
1027,
30524,
1007,
1025,
13075,
2918,
1027,
5478,
1006,
1005,
6922,
1013,
8370,
1013,
13996,
1013,
2918,
1005,
1007,
1025,
13075,
3433,
1027,
5478,
1006,
1005,
6922,
1013,
8370,
1013,
2944,
1013,
3433,
1005,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require 'edge'
require 'yaml'
require 'rspec'
database_config = YAML.load_file(File.expand_path("../database.yml", __FILE__))
ActiveRecord::Base.establish_connection database_config["test"]
RSpec.configure do |config|
config.before(:all) do |example|
ActiveRecord::Base.connection.execute <<-SQL
truncate body_parts;
truncate locations;
SQL
end
config.around do |example|
ActiveRecord::Base.transaction do
example.call
raise ActiveRecord::Rollback
end
end
end
| jackc/edge | spec/spec_helper.rb | Ruby | mit | 512 | [
30522,
5478,
1005,
3341,
1005,
5478,
1005,
8038,
19968,
1005,
5478,
1005,
12667,
5051,
2278,
1005,
7809,
1035,
9530,
8873,
2290,
1027,
8038,
19968,
1012,
7170,
1035,
5371,
1006,
5371,
1012,
7818,
1035,
4130,
1006,
1000,
1012,
1012,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.arjanvlek.cyngnotainfo.Support;
import android.app.Activity;
import android.app.DownloadManager;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import com.arjanvlek.cyngnotainfo.Model.CyanogenOTAUpdate;
import com.arjanvlek.cyngnotainfo.Model.DownloadProgressData;
import com.arjanvlek.cyngnotainfo.R;
import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static android.app.DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR;
import static android.app.DownloadManager.COLUMN_REASON;
import static android.app.DownloadManager.COLUMN_STATUS;
import static android.app.DownloadManager.COLUMN_TOTAL_SIZE_BYTES;
import static android.app.DownloadManager.Request.VISIBILITY_VISIBLE;
import static android.app.DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED;
import static android.app.DownloadManager.STATUS_PAUSED;
import static android.app.DownloadManager.STATUS_PENDING;
import static android.app.DownloadManager.STATUS_RUNNING;
import static android.os.Environment.DIRECTORY_DOWNLOADS;
import static com.arjanvlek.cyngnotainfo.Support.SettingsManager.PROPERTY_DOWNLOAD_ID;
import static com.arjanvlek.cyngnotainfo.Support.UpdateDownloader.DownloadSpeedUnits.BYTES;
import static com.arjanvlek.cyngnotainfo.Support.UpdateDownloader.DownloadSpeedUnits.KILO_BYTES;
import static com.arjanvlek.cyngnotainfo.Support.UpdateDownloader.DownloadSpeedUnits.MEGA_BYTES;
import static java.math.BigDecimal.ROUND_CEILING;
public class UpdateDownloader {
private final Activity baseActivity;
private final DownloadManager downloadManager;
private final SettingsManager settingsManager;
private UpdateDownloadListener listener;
private List<Double> measurements = new ArrayList<>();
public final static int NOT_SET = -1;
private boolean initialized;
private long previousBytesDownloadedSoFar = NOT_SET;
private long previousTimeStamp;
private DownloadSpeedUnits previousSpeedUnits = BYTES;
private double previousDownloadSpeed = NOT_SET;
private long previousNumberOfSecondsRemaining = NOT_SET;
public UpdateDownloader(Activity baseActivity) {
this.baseActivity = baseActivity;
this.downloadManager = (DownloadManager) baseActivity.getSystemService(Context.DOWNLOAD_SERVICE);
this.settingsManager = new SettingsManager(baseActivity.getApplicationContext());
}
public UpdateDownloader setUpdateDownloadListener(UpdateDownloadListener listener) {
this.listener = listener;
if(!initialized) {
listener.onDownloadManagerInit();
initialized = true;
}
return this;
}
public void downloadUpdate(CyanogenOTAUpdate cyanogenOTAUpdate) {
if(cyanogenOTAUpdate != null) {
if(!cyanogenOTAUpdate.getDownloadUrl().contains("http")) {
listener.onDownloadError(404);
} else {
Uri downloadUri = Uri.parse(cyanogenOTAUpdate.getDownloadUrl());
DownloadManager.Request request = new DownloadManager.Request(downloadUri)
.setDescription(baseActivity.getString(R.string.download_description))
.setTitle(cyanogenOTAUpdate.getName() != null && !cyanogenOTAUpdate.getName().equals("null") && !cyanogenOTAUpdate.getName().isEmpty() ? cyanogenOTAUpdate.getName() : baseActivity.getString(R.string.download_unknown_update_name))
.setDestinationInExternalPublicDir(DIRECTORY_DOWNLOADS, cyanogenOTAUpdate.getFileName())
.setVisibleInDownloadsUi(false)
.setNotificationVisibility(VISIBILITY_VISIBLE);
long downloadID = downloadManager.enqueue(request);
previousBytesDownloadedSoFar = NOT_SET;
settingsManager.saveLongPreference(PROPERTY_DOWNLOAD_ID, downloadID);
checkDownloadProgress(cyanogenOTAUpdate);
listener.onDownloadStarted(downloadID);
}
}
}
public void cancelDownload() {
if(settingsManager.containsPreference(PROPERTY_DOWNLOAD_ID)) {
downloadManager.remove(settingsManager.getLongPreference(PROPERTY_DOWNLOAD_ID));
clearUp();
listener.onDownloadCancelled();
}
}
public void checkDownloadProgress(CyanogenOTAUpdate cyanogenOTAUpdate) {
final long downloadId = settingsManager.getLongPreference(PROPERTY_DOWNLOAD_ID);
if(settingsManager.containsPreference(PROPERTY_DOWNLOAD_ID)) {
DownloadManager.Query query = new DownloadManager.Query();
query.setFilterById(downloadId);
Cursor cursor = downloadManager.query(query);
if (cursor != null && cursor.moveToFirst()) {
int status = cursor.getInt(cursor.getColumnIndex(COLUMN_STATUS));
switch (status) {
case STATUS_PENDING:
listener.onDownloadPending();
recheckDownloadProgress(cyanogenOTAUpdate, 1);
break;
case STATUS_PAUSED:
listener.onDownloadPaused(cursor.getInt(cursor.getColumnIndex(COLUMN_REASON)));
recheckDownloadProgress(cyanogenOTAUpdate, 5);
break;
case STATUS_RUNNING:
int bytesDownloadedSoFar = cursor.getInt(cursor.getColumnIndex(COLUMN_BYTES_DOWNLOADED_SO_FAR));
int totalSizeBytes = cursor.getInt(cursor.getColumnIndex(COLUMN_TOTAL_SIZE_BYTES));
DownloadProgressData eta = calculateDownloadETA(bytesDownloadedSoFar, totalSizeBytes);
listener.onDownloadProgressUpdate(eta);
previousBytesDownloadedSoFar = cursor.getInt(cursor.getColumnIndex(COLUMN_BYTES_DOWNLOADED_SO_FAR));
recheckDownloadProgress(cyanogenOTAUpdate, 1);
break;
case DownloadManager.STATUS_SUCCESSFUL:
clearUp();
listener.onDownloadComplete();
verifyDownload(cyanogenOTAUpdate);
break;
case DownloadManager.STATUS_FAILED:
clearUp();
listener.onDownloadError(cursor.getInt(cursor.getColumnIndex(COLUMN_REASON)));
break;
}
cursor.close();
}
}
}
public void verifyDownload(CyanogenOTAUpdate cyanogenOTAUpdate) {
new DownloadVerifier().execute(cyanogenOTAUpdate);
}
public boolean makeDownloadDirectory() {
File downloadDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
return downloadDirectory.mkdirs();
}
private void recheckDownloadProgress(final CyanogenOTAUpdate cyanogenOTAUpdate, int secondsDelay) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
checkDownloadProgress(cyanogenOTAUpdate);
}
}, (secondsDelay * 1000));
}
private void clearUp() {
previousTimeStamp = NOT_SET;
previousBytesDownloadedSoFar = NOT_SET;
previousSpeedUnits = BYTES;
previousDownloadSpeed = NOT_SET;
previousNumberOfSecondsRemaining = NOT_SET;
settingsManager.deletePreference(PROPERTY_DOWNLOAD_ID);
}
private DownloadProgressData calculateDownloadETA(long bytesDownloadedSoFar, long totalSizeBytes) {
double bytesDownloadedInSecond;
boolean validMeasurement = false;
double downloadSpeed = NOT_SET;
long numberOfSecondsRemaining = NOT_SET;
long averageBytesPerSecond = NOT_SET;
long currentTimeStamp = System.currentTimeMillis();
long bytesRemainingToDownload = totalSizeBytes - bytesDownloadedSoFar;
DownloadSpeedUnits speedUnits = BYTES;
if(previousBytesDownloadedSoFar != NOT_SET) {
double numberOfElapsedSeconds = TimeUnit.MILLISECONDS.toSeconds(currentTimeStamp - previousTimeStamp);
if(numberOfElapsedSeconds > 0.0) {
bytesDownloadedInSecond = (bytesDownloadedSoFar - previousBytesDownloadedSoFar) / (numberOfElapsedSeconds);
} else {
bytesDownloadedInSecond = 0;
}
// DownloadManager.query doesn't always have new data. If no new data is available, return the previously stored data to keep the UI showing that.
validMeasurement = bytesDownloadedInSecond > 0 || numberOfElapsedSeconds > 5;
if (validMeasurement) {
// In case of no network, clear all measurements to allow displaying the now-unknown ETA...
if (bytesDownloadedInSecond == 0) {
measurements.clear();
}
// Remove old measurements to keep the average calculation based on 5 measurements
if (measurements.size() >= 5) {
measurements.subList(0, 1).clear();
}
measurements.add(bytesDownloadedInSecond);
}
// Calculate number of seconds remaining based off average download spead.
averageBytesPerSecond = (long) calculateAverageBytesDownloadedInSecond(measurements);
if (averageBytesPerSecond > 0) {
numberOfSecondsRemaining = bytesRemainingToDownload / averageBytesPerSecond;
} else {
numberOfSecondsRemaining = NOT_SET;
}
}
if(averageBytesPerSecond != NOT_SET) {
if (averageBytesPerSecond >= 0 && averageBytesPerSecond < 1024) {
downloadSpeed = averageBytesPerSecond;
speedUnits = BYTES;
} else if (averageBytesPerSecond >= 1024 && averageBytesPerSecond < 1048576) {
downloadSpeed = new BigDecimal(averageBytesPerSecond).setScale(0, ROUND_CEILING).divide(new BigDecimal(1024), ROUND_CEILING).doubleValue();
speedUnits = KILO_BYTES;
} else if (averageBytesPerSecond >= 1048576) {
downloadSpeed = new BigDecimal(averageBytesPerSecond).setScale(2, ROUND_CEILING).divide(new BigDecimal(1048576), ROUND_CEILING).doubleValue();
speedUnits = MEGA_BYTES;
}
if(validMeasurement) {
previousNumberOfSecondsRemaining = numberOfSecondsRemaining;
previousTimeStamp = currentTimeStamp;
previousDownloadSpeed = downloadSpeed;
previousSpeedUnits = speedUnits;
} else {
downloadSpeed = previousDownloadSpeed;
speedUnits = previousSpeedUnits;
numberOfSecondsRemaining = previousNumberOfSecondsRemaining;
}
}
previousBytesDownloadedSoFar = bytesDownloadedSoFar;
int progress = 0;
if(totalSizeBytes > 0.0) {
progress = (int) ((bytesDownloadedSoFar * 100) / totalSizeBytes);
}
return new DownloadProgressData(downloadSpeed, speedUnits, numberOfSecondsRemaining, progress);
}
private double calculateAverageBytesDownloadedInSecond(List<Double> measurements) {
if(measurements == null || measurements.isEmpty()) {
return 0;
} else {
double totalBytesDownloadedInSecond = 0;
for (Double measurementData : measurements) {
totalBytesDownloadedInSecond += measurementData;
}
return totalBytesDownloadedInSecond / measurements.size();
}
}
private class DownloadVerifier extends AsyncTask<CyanogenOTAUpdate, Integer, Boolean> {
@Override
protected void onPreExecute() {
listener.onVerifyStarted();
}
@Override
protected Boolean doInBackground(CyanogenOTAUpdate... params) {
String filename = params[0].getFileName();
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath() + File.separator + filename);
return params[0] == null || params[0].getMD5Sum() == null || MD5.checkMD5(params[0].getMD5Sum(), file);
}
@Override
protected void onPostExecute(Boolean result) {
if (result) {
listener.onVerifyComplete();
clearUp();
} else {
listener.onVerifyError();
clearUp();
}
}
}
public enum DownloadSpeedUnits {
BYTES("B/s"), KILO_BYTES("KB/s"), MEGA_BYTES("MB/s");
String stringValue;
DownloadSpeedUnits(String stringValue) {
this.stringValue = stringValue;
}
public String getStringValue() {
return stringValue;
}
}
}
| arjanvlek/cyanogen-update-tracker-app | app/src/main/java/com/arjanvlek/cyngnotainfo/Support/UpdateDownloader.java | Java | mit | 13,204 | [
30522,
7427,
4012,
1012,
12098,
8405,
2615,
2571,
2243,
1012,
22330,
3070,
17048,
8113,
14876,
1012,
2490,
1025,
12324,
11924,
1012,
10439,
1012,
4023,
1025,
12324,
11924,
1012,
10439,
1012,
8816,
24805,
4590,
1025,
12324,
11924,
1012,
4180,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// (C) Copyright Nick Thompson and Matt Borland 2020.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <random>
#include <boost/math/statistics/univariate_statistics.hpp>
#include <benchmark/benchmark.h>
template <class Z>
void test_mode(benchmark::State& state)
{
using boost::math::statistics::sorted_mode;
std::random_device rd;
std::mt19937_64 mt(rd());
std::uniform_int_distribution<> dist {1, 10};
auto gen = [&dist, &mt](){return dist(mt);};
std::vector<Z> v(state.range(0));
std::generate(v.begin(), v.end(), gen);
for (auto _ : state)
{
std::vector<Z> modes;
benchmark::DoNotOptimize(sorted_mode(v.begin(), v.end(), std::back_inserter(modes)));
}
state.SetComplexityN(state.range(0));
}
template <class Z>
void sequential_test_mode(benchmark::State& state)
{
using boost::math::statistics::sorted_mode;
std::vector<Z> v(state.range(0));
size_t current_num {1};
// produces {1, 2, 3, 4, 5...}
for(size_t i {}; i < v.size(); ++i)
{
v[i] = current_num;
++current_num;
}
for (auto _ : state)
{
std::vector<Z> modes;
benchmark::DoNotOptimize(sorted_mode(v, std::back_inserter(modes)));
}
state.SetComplexityN(state.range(0));
}
template <class Z>
void sequential_pairs_test_mode(benchmark::State& state)
{
using boost::math::statistics::sorted_mode;
std::vector<Z> v(state.range(0));
size_t current_num {1};
size_t current_num_counter {};
// produces {1, 1, 2, 2, 3, 3, ...}
for(size_t i {}; i < v.size(); ++i)
{
v[i] = current_num;
++current_num_counter;
if(current_num_counter > 2)
{
++current_num;
current_num_counter = 0;
}
}
for (auto _ : state)
{
std::vector<Z> modes;
benchmark::DoNotOptimize(sorted_mode(v, std::back_inserter(modes)));
}
state.SetComplexityN(state.range(0));
}
template <class Z>
void sequential_multiple_test_mode(benchmark::State& state)
{
using boost::math::statistics::sorted_mode;
std::vector<Z> v(state.range(0));
size_t current_num {1};
size_t current_num_counter {};
// produces {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, ...}
for(size_t i {}; i < v.size(); ++i)
{
v[i] = current_num;
++current_num_counter;
if(current_num_counter > current_num)
{
++current_num;
current_num_counter = 0;
}
}
for (auto _ : state)
{
std::vector<Z> modes;
benchmark::DoNotOptimize(sorted_mode(v, std::back_inserter(modes)));
}
state.SetComplexityN(state.range(0));
}
BENCHMARK_TEMPLATE(test_mode, int32_t)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity();
BENCHMARK_TEMPLATE(test_mode, int64_t)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity();
BENCHMARK_TEMPLATE(test_mode, uint32_t)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity();
BENCHMARK_TEMPLATE(sequential_test_mode, int32_t)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity();
BENCHMARK_TEMPLATE(sequential_test_mode, int64_t)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity();
BENCHMARK_TEMPLATE(sequential_test_mode, uint32_t)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity();
BENCHMARK_TEMPLATE(sequential_pairs_test_mode, int32_t)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity();
BENCHMARK_TEMPLATE(sequential_pairs_test_mode, int64_t)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity();
BENCHMARK_TEMPLATE(sequential_pairs_test_mode, uint32_t)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity();
BENCHMARK_TEMPLATE(sequential_multiple_test_mode, int32_t)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity();
BENCHMARK_TEMPLATE(sequential_multiple_test_mode, int64_t)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity();
BENCHMARK_TEMPLATE(sequential_multiple_test_mode, uint32_t)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity();
BENCHMARK_MAIN();
| stan-dev/math | lib/boost_1.75.0/libs/math/reporting/performance/test_mode.cpp | C++ | bsd-3-clause | 4,151 | [
30522,
1013,
1013,
1006,
1039,
1007,
9385,
4172,
5953,
1998,
4717,
8945,
18324,
12609,
1012,
1013,
1013,
30524,
1013,
1013,
6105,
1035,
1015,
1035,
1014,
1012,
19067,
2102,
2030,
6100,
2012,
8299,
1024,
1013,
1013,
7479,
1012,
12992,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
* Copyright (C) Research In Motion Limited 2011. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#if ENABLE(WEB_SOCKETS)
#include "WebSocketHandshake.h"
#include "Base64.h"
#include "Cookie.h"
#include "CookieJar.h"
#include "Document.h"
#include "HTTPHeaderMap.h"
#include "KURL.h"
#include "Logging.h"
#include "ScriptCallStack.h"
#include "ScriptExecutionContext.h"
#include "SecurityOrigin.h"
#include <wtf/CryptographicallyRandomNumber.h>
#include <wtf/MD5.h>
#include <wtf/SHA1.h>
#include <wtf/StdLibExtras.h>
#include <wtf/StringExtras.h>
#include <wtf/Vector.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
#include <wtf/text/WTFString.h>
#include <wtf/unicode/CharacterNames.h>
namespace WebCore {
static const char randomCharacterInSecWebSocketKey[] = "!\"#$%&'()*+,-./:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
static String resourceName(const KURL& url)
{
String name = url.path();
if (name.isEmpty())
name = "/";
if (!url.query().isNull())
name += "?" + url.query();
ASSERT(!name.isEmpty());
ASSERT(!name.contains(' '));
return name;
}
static String hostName(const KURL& url, bool secure)
{
ASSERT(url.protocolIs("wss") == secure);
StringBuilder builder;
builder.append(url.host().lower());
if (url.port() && ((!secure && url.port() != 80) || (secure && url.port() != 443))) {
builder.append(':');
builder.append(String::number(url.port()));
}
return builder.toString();
}
static const size_t maxConsoleMessageSize = 128;
static String trimConsoleMessage(const char* p, size_t len)
{
String s = String(p, std::min<size_t>(len, maxConsoleMessageSize));
if (len > maxConsoleMessageSize)
s.append(horizontalEllipsis);
return s;
}
static uint32_t randomNumberLessThan(uint32_t n)
{
if (!n)
return 0;
if (n == std::numeric_limits<uint32_t>::max())
return cryptographicallyRandomNumber();
uint32_t max = std::numeric_limits<uint32_t>::max() - (std::numeric_limits<uint32_t>::max() % n);
ASSERT(!(max % n));
uint32_t v;
do {
v = cryptographicallyRandomNumber();
} while (v >= max);
return v % n;
}
static void generateHixie76SecWebSocketKey(uint32_t& number, String& key)
{
uint32_t space = randomNumberLessThan(12) + 1;
uint32_t max = 4294967295U / space;
number = randomNumberLessThan(max);
uint32_t product = number * space;
String s = String::number(product);
int n = randomNumberLessThan(12) + 1;
DEFINE_STATIC_LOCAL(String, randomChars, (randomCharacterInSecWebSocketKey));
for (int i = 0; i < n; i++) {
int pos = randomNumberLessThan(s.length() + 1);
int chpos = randomNumberLessThan(randomChars.length());
s.insert(randomChars.substring(chpos, 1), pos);
}
DEFINE_STATIC_LOCAL(String, spaceChar, (" "));
for (uint32_t i = 0; i < space; i++) {
int pos = randomNumberLessThan(s.length() - 1) + 1;
s.insert(spaceChar, pos);
}
ASSERT(s[0] != ' ');
ASSERT(s[s.length() - 1] != ' ');
key = s;
}
static void generateHixie76Key3(unsigned char key3[8])
{
cryptographicallyRandomValues(key3, 8);
}
static void setChallengeNumber(unsigned char* buf, uint32_t number)
{
unsigned char* p = buf + 3;
for (int i = 0; i < 4; i++) {
*p = number & 0xFF;
--p;
number >>= 8;
}
}
static void generateHixie76ExpectedChallengeResponse(uint32_t number1, uint32_t number2, unsigned char key3[8], unsigned char expectedChallenge[16])
{
unsigned char challenge[16];
setChallengeNumber(&challenge[0], number1);
setChallengeNumber(&challenge[4], number2);
memcpy(&challenge[8], key3, 8);
MD5 md5;
md5.addBytes(challenge, sizeof(challenge));
Vector<uint8_t, 16> digest;
md5.checksum(digest);
memcpy(expectedChallenge, digest.data(), 16);
}
static String generateSecWebSocketKey()
{
static const size_t nonceSize = 16;
unsigned char key[nonceSize];
cryptographicallyRandomValues(key, nonceSize);
return base64Encode(reinterpret_cast<char*>(key), nonceSize);
}
static String getExpectedWebSocketAccept(const String& secWebSocketKey)
{
static const char* const webSocketKeyGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
static const size_t sha1HashSize = 20; // FIXME: This should be defined in SHA1.h.
SHA1 sha1;
CString keyData = secWebSocketKey.ascii();
sha1.addBytes(reinterpret_cast<const uint8_t*>(keyData.data()), keyData.length());
sha1.addBytes(reinterpret_cast<const uint8_t*>(webSocketKeyGUID), strlen(webSocketKeyGUID));
Vector<uint8_t, sha1HashSize> hash;
sha1.computeHash(hash);
return base64Encode(reinterpret_cast<const char*>(hash.data()), sha1HashSize);
}
WebSocketHandshake::WebSocketHandshake(const KURL& url, const String& protocol, ScriptExecutionContext* context, bool useHixie76Protocol)
: m_url(url)
, m_clientProtocol(protocol)
, m_secure(m_url.protocolIs("wss"))
, m_context(context)
, m_useHixie76Protocol(useHixie76Protocol)
, m_mode(Incomplete)
{
if (m_useHixie76Protocol) {
uint32_t number1;
uint32_t number2;
generateHixie76SecWebSocketKey(number1, m_hixie76SecWebSocketKey1);
generateHixie76SecWebSocketKey(number2, m_hixie76SecWebSocketKey2);
generateHixie76Key3(m_hixie76Key3);
generateHixie76ExpectedChallengeResponse(number1, number2, m_hixie76Key3, m_hixie76ExpectedChallengeResponse);
} else {
m_secWebSocketKey = generateSecWebSocketKey();
m_expectedAccept = getExpectedWebSocketAccept(m_secWebSocketKey);
}
}
WebSocketHandshake::~WebSocketHandshake()
{
}
const KURL& WebSocketHandshake::url() const
{
return m_url;
}
void WebSocketHandshake::setURL(const KURL& url)
{
m_url = url.copy();
}
const String WebSocketHandshake::host() const
{
return m_url.host().lower();
}
const String& WebSocketHandshake::clientProtocol() const
{
return m_clientProtocol;
}
void WebSocketHandshake::setClientProtocol(const String& protocol)
{
m_clientProtocol = protocol;
}
bool WebSocketHandshake::secure() const
{
return m_secure;
}
String WebSocketHandshake::clientOrigin() const
{
return m_context->securityOrigin()->toString();
}
String WebSocketHandshake::clientLocation() const
{
StringBuilder builder;
builder.append(m_secure ? "wss" : "ws");
builder.append("://");
builder.append(hostName(m_url, m_secure));
builder.append(resourceName(m_url));
return builder.toString();
}
CString WebSocketHandshake::clientHandshakeMessage() const
{
// Keep the following consistent with clientHandshakeRequest().
StringBuilder builder;
builder.append("GET ");
builder.append(resourceName(m_url));
builder.append(" HTTP/1.1\r\n");
Vector<String> fields;
if (m_useHixie76Protocol)
fields.append("Upgrade: WebSocket");
else
fields.append("Upgrade: websocket");
fields.append("Connection: Upgrade");
fields.append("Host: " + hostName(m_url, m_secure));
if (m_useHixie76Protocol)
fields.append("Origin: " + clientOrigin());
else
fields.append("Sec-WebSocket-Origin: " + clientOrigin());
if (!m_clientProtocol.isEmpty())
fields.append("Sec-WebSocket-Protocol: " + m_clientProtocol);
KURL url = httpURLForAuthenticationAndCookies();
if (m_context->isDocument()) {
Document* document = static_cast<Document*>(m_context);
String cookie = cookieRequestHeaderFieldValue(document, url);
if (!cookie.isEmpty())
fields.append("Cookie: " + cookie);
// Set "Cookie2: <cookie>" if cookies 2 exists for url?
}
if (m_useHixie76Protocol) {
fields.append("Sec-WebSocket-Key1: " + m_hixie76SecWebSocketKey1);
fields.append("Sec-WebSocket-Key2: " + m_hixie76SecWebSocketKey2);
} else {
fields.append("Sec-WebSocket-Key: " + m_secWebSocketKey);
fields.append("Sec-WebSocket-Version: 8");
}
// Fields in the handshake are sent by the client in a random order; the
// order is not meaningful. Thus, it's ok to send the order we constructed
// the fields.
for (size_t i = 0; i < fields.size(); i++) {
builder.append(fields[i]);
builder.append("\r\n");
}
builder.append("\r\n");
CString handshakeHeader = builder.toString().utf8();
// Hybi-10 handshake is complete at this point.
if (!m_useHixie76Protocol)
return handshakeHeader;
// Hixie-76 protocol requires sending eight-byte data (so-called "key3") after the request header fields.
char* characterBuffer = 0;
CString msg = CString::newUninitialized(handshakeHeader.length() + sizeof(m_hixie76Key3), characterBuffer);
memcpy(characterBuffer, handshakeHeader.data(), handshakeHeader.length());
memcpy(characterBuffer + handshakeHeader.length(), m_hixie76Key3, sizeof(m_hixie76Key3));
return msg;
}
WebSocketHandshakeRequest WebSocketHandshake::clientHandshakeRequest() const
{
// Keep the following consistent with clientHandshakeMessage().
// FIXME: do we need to store m_secWebSocketKey1, m_secWebSocketKey2 and
// m_key3 in WebSocketHandshakeRequest?
WebSocketHandshakeRequest request("GET", m_url);
if (m_useHixie76Protocol)
request.addHeaderField("Upgrade", "WebSocket");
else
request.addHeaderField("Upgrade", "websocket");
request.addHeaderField("Connection", "Upgrade");
request.addHeaderField("Host", hostName(m_url, m_secure));
if (m_useHixie76Protocol)
request.addHeaderField("Origin", clientOrigin());
else
request.addHeaderField("Sec-WebSocket-Origin", clientOrigin());
if (!m_clientProtocol.isEmpty())
request.addHeaderField("Sec-WebSocket-Protocol:", m_clientProtocol);
KURL url = httpURLForAuthenticationAndCookies();
if (m_context->isDocument()) {
Document* document = static_cast<Document*>(m_context);
String cookie = cookieRequestHeaderFieldValue(document, url);
if (!cookie.isEmpty())
request.addHeaderField("Cookie", cookie);
// Set "Cookie2: <cookie>" if cookies 2 exists for url?
}
if (m_useHixie76Protocol) {
request.addHeaderField("Sec-WebSocket-Key1", m_hixie76SecWebSocketKey1);
request.addHeaderField("Sec-WebSocket-Key2", m_hixie76SecWebSocketKey2);
request.setKey3(m_hixie76Key3);
} else {
request.addHeaderField("Sec-WebSocket-Key", m_secWebSocketKey);
request.addHeaderField("Sec-WebSocket-Version", "8");
}
return request;
}
void WebSocketHandshake::reset()
{
m_mode = Incomplete;
}
void WebSocketHandshake::clearScriptExecutionContext()
{
m_context = 0;
}
int WebSocketHandshake::readServerHandshake(const char* header, size_t len)
{
m_mode = Incomplete;
int statusCode;
String statusText;
int lineLength = readStatusLine(header, len, statusCode, statusText);
if (lineLength == -1)
return -1;
if (statusCode == -1) {
m_mode = Failed; // m_failureReason is set inside readStatusLine().
return len;
}
LOG(Network, "response code: %d", statusCode);
m_response.setStatusCode(statusCode);
m_response.setStatusText(statusText);
if (statusCode != 101) {
m_mode = Failed;
m_failureReason = "Unexpected response code: " + String::number(statusCode);
return len;
}
m_mode = Normal;
if (!strnstr(header, "\r\n\r\n", len)) {
// Just hasn't been received fully yet.
m_mode = Incomplete;
return -1;
}
const char* p = readHTTPHeaders(header + lineLength, header + len);
if (!p) {
LOG(Network, "readHTTPHeaders failed");
m_mode = Failed; // m_failureReason is set inside readHTTPHeaders().
return len;
}
if (!checkResponseHeaders()) {
LOG(Network, "header process failed");
m_mode = Failed;
return p - header;
}
if (!m_useHixie76Protocol) { // Hybi-10 handshake is complete at this point.
m_mode = Connected;
return p - header;
}
// In hixie-76 protocol, server's handshake contains sixteen-byte data (called "challenge response")
// after the header fields.
if (len < static_cast<size_t>(p - header + sizeof(m_hixie76ExpectedChallengeResponse))) {
// Just hasn't been received /expected/ yet.
m_mode = Incomplete;
return -1;
}
m_response.setChallengeResponse(static_cast<const unsigned char*>(static_cast<const void*>(p)));
if (memcmp(p, m_hixie76ExpectedChallengeResponse, sizeof(m_hixie76ExpectedChallengeResponse))) {
m_mode = Failed;
return (p - header) + sizeof(m_hixie76ExpectedChallengeResponse);
}
m_mode = Connected;
return (p - header) + sizeof(m_hixie76ExpectedChallengeResponse);
}
WebSocketHandshake::Mode WebSocketHandshake::mode() const
{
return m_mode;
}
String WebSocketHandshake::failureReason() const
{
return m_failureReason;
}
String WebSocketHandshake::serverWebSocketOrigin() const
{
return m_response.headerFields().get("sec-websocket-origin");
}
String WebSocketHandshake::serverWebSocketLocation() const
{
return m_response.headerFields().get("sec-websocket-location");
}
String WebSocketHandshake::serverWebSocketProtocol() const
{
return m_response.headerFields().get("sec-websocket-protocol");
}
String WebSocketHandshake::serverSetCookie() const
{
return m_response.headerFields().get("set-cookie");
}
String WebSocketHandshake::serverSetCookie2() const
{
return m_response.headerFields().get("set-cookie2");
}
String WebSocketHandshake::serverUpgrade() const
{
return m_response.headerFields().get("upgrade");
}
String WebSocketHandshake::serverConnection() const
{
return m_response.headerFields().get("connection");
}
String WebSocketHandshake::serverWebSocketAccept() const
{
return m_response.headerFields().get("sec-websocket-accept");
}
String WebSocketHandshake::serverWebSocketExtensions() const
{
return m_response.headerFields().get("sec-websocket-extensions");
}
const WebSocketHandshakeResponse& WebSocketHandshake::serverHandshakeResponse() const
{
return m_response;
}
KURL WebSocketHandshake::httpURLForAuthenticationAndCookies() const
{
KURL url = m_url.copy();
bool couldSetProtocol = url.setProtocol(m_secure ? "https" : "http");
ASSERT_UNUSED(couldSetProtocol, couldSetProtocol);
return url;
}
// Returns the header length (including "\r\n"), or -1 if we have not received enough data yet.
// If the line is malformed or the status code is not a 3-digit number,
// statusCode and statusText will be set to -1 and a null string, respectively.
int WebSocketHandshake::readStatusLine(const char* header, size_t headerLength, int& statusCode, String& statusText)
{
// Arbitrary size limit to prevent the server from sending an unbounded
// amount of data with no newlines and forcing us to buffer it all.
static const int maximumLength = 1024;
statusCode = -1;
statusText = String();
const char* space1 = 0;
const char* space2 = 0;
const char* p;
size_t consumedLength;
for (p = header, consumedLength = 0; consumedLength < headerLength; p++, consumedLength++) {
if (*p == ' ') {
if (!space1)
space1 = p;
else if (!space2)
space2 = p;
} else if (*p == '\0') {
// The caller isn't prepared to deal with null bytes in status
// line. WebSockets specification doesn't prohibit this, but HTTP
// does, so we'll just treat this as an error.
m_failureReason = "Status line contains embedded null";
return p + 1 - header;
} else if (*p == '\n')
break;
}
if (consumedLength == headerLength)
return -1; // We have not received '\n' yet.
const char* end = p + 1;
int lineLength = end - header;
if (lineLength > maximumLength) {
m_failureReason = "Status line is too long";
return maximumLength;
}
// The line must end with "\r\n".
if (lineLength < 2 || *(end - 2) != '\r') {
m_failureReason = "Status line does not end with CRLF";
return lineLength;
}
if (!space1 || !space2) {
m_failureReason = "No response code found: " + trimConsoleMessage(header, lineLength - 2);
return lineLength;
}
String statusCodeString(space1 + 1, space2 - space1 - 1);
if (statusCodeString.length() != 3) // Status code must consist of three digits.
return lineLength;
for (int i = 0; i < 3; ++i)
if (statusCodeString[i] < '0' || statusCodeString[i] > '9') {
m_failureReason = "Invalid status code: " + statusCodeString;
return lineLength;
}
bool ok = false;
statusCode = statusCodeString.toInt(&ok);
ASSERT(ok);
statusText = String(space2 + 1, end - space2 - 3); // Exclude "\r\n".
return lineLength;
}
const char* WebSocketHandshake::readHTTPHeaders(const char* start, const char* end)
{
m_response.clearHeaderFields();
Vector<char> name;
Vector<char> value;
for (const char* p = start; p < end; p++) {
name.clear();
value.clear();
for (; p < end; p++) {
switch (*p) {
case '\r':
if (name.isEmpty()) {
if (p + 1 < end && *(p + 1) == '\n')
return p + 2;
m_failureReason = "CR doesn't follow LF at " + trimConsoleMessage(p, end - p);
return 0;
}
m_failureReason = "Unexpected CR in name at " + trimConsoleMessage(name.data(), name.size());
return 0;
case '\n':
m_failureReason = "Unexpected LF in name at " + trimConsoleMessage(name.data(), name.size());
return 0;
case ':':
break;
default:
name.append(*p);
continue;
}
if (*p == ':') {
++p;
break;
}
}
for (; p < end && *p == 0x20; p++) { }
for (; p < end; p++) {
switch (*p) {
case '\r':
break;
case '\n':
m_failureReason = "Unexpected LF in value at " + trimConsoleMessage(value.data(), value.size());
return 0;
default:
value.append(*p);
}
if (*p == '\r') {
++p;
break;
}
}
if (p >= end || *p != '\n') {
m_failureReason = "CR doesn't follow LF after value at " + trimConsoleMessage(p, end - p);
return 0;
}
AtomicString nameStr = AtomicString::fromUTF8(name.data(), name.size());
String valueStr = String::fromUTF8(value.data(), value.size());
if (nameStr.isNull()) {
m_failureReason = "Invalid UTF-8 sequence in header name";
return 0;
}
if (valueStr.isNull()) {
m_failureReason = "Invalid UTF-8 sequence in header value";
return 0;
}
LOG(Network, "name=%s value=%s", nameStr.string().utf8().data(), valueStr.utf8().data());
m_response.addHeaderField(nameStr, valueStr);
}
ASSERT_NOT_REACHED();
return 0;
}
bool WebSocketHandshake::checkResponseHeaders()
{
const String& serverWebSocketLocation = this->serverWebSocketLocation();
const String& serverWebSocketOrigin = this->serverWebSocketOrigin();
const String& serverWebSocketProtocol = this->serverWebSocketProtocol();
const String& serverUpgrade = this->serverUpgrade();
const String& serverConnection = this->serverConnection();
const String& serverWebSocketAccept = this->serverWebSocketAccept();
const String& serverWebSocketExtensions = this->serverWebSocketExtensions();
if (serverUpgrade.isNull()) {
m_failureReason = "Error during WebSocket handshake: 'Upgrade' header is missing";
return false;
}
if (serverConnection.isNull()) {
m_failureReason = "Error during WebSocket handshake: 'Connection' header is missing";
return false;
}
if (m_useHixie76Protocol) {
if (serverWebSocketOrigin.isNull()) {
m_failureReason = "Error during WebSocket handshake: 'Sec-WebSocket-Origin' header is missing";
return false;
}
if (serverWebSocketLocation.isNull()) {
m_failureReason = "Error during WebSocket handshake: 'Sec-WebSocket-Location' header is missing";
return false;
}
} else {
if (serverWebSocketAccept.isNull()) {
m_failureReason = "Error during WebSocket handshake: 'Sec-WebSocket-Accept' header is missing";
return false;
}
}
if (!equalIgnoringCase(serverUpgrade, "websocket")) {
m_failureReason = "Error during WebSocket handshake: 'Upgrade' header value is not 'WebSocket'";
return false;
}
if (!equalIgnoringCase(serverConnection, "upgrade")) {
m_failureReason = "Error during WebSocket handshake: 'Connection' header value is not 'Upgrade'";
return false;
}
if (m_useHixie76Protocol) {
if (clientOrigin() != serverWebSocketOrigin) {
m_failureReason = "Error during WebSocket handshake: origin mismatch: " + clientOrigin() + " != " + serverWebSocketOrigin;
return false;
}
if (clientLocation() != serverWebSocketLocation) {
m_failureReason = "Error during WebSocket handshake: location mismatch: " + clientLocation() + " != " + serverWebSocketLocation;
return false;
}
if (!m_clientProtocol.isEmpty() && m_clientProtocol != serverWebSocketProtocol) {
m_failureReason = "Error during WebSocket handshake: protocol mismatch: " + m_clientProtocol + " != " + serverWebSocketProtocol;
return false;
}
} else {
if (serverWebSocketAccept != m_expectedAccept) {
m_failureReason = "Error during WebSocket handshake: Sec-WebSocket-Accept mismatch";
return false;
}
if (!serverWebSocketExtensions.isNull()) {
// WebSocket protocol extensions are not supported yet.
// We do not send Sec-WebSocket-Extensions header in our request, thus
// servers should not return this header, either.
m_failureReason = "Error during WebSocket handshake: Sec-WebSocket-Extensions header is invalid";
return false;
}
}
return true;
}
} // namespace WebCore
#endif // ENABLE(WEB_SOCKETS)
| Treeeater/WebPermission | websockets/WebSocketHandshake.cpp | C++ | bsd-2-clause | 24,458 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2249,
8224,
4297,
1012,
2035,
2916,
9235,
1012,
1008,
9385,
1006,
1039,
1007,
2470,
1999,
4367,
3132,
2249,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
25707,
1998,
2224,
1999,
3120,
1998,
12... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright (c) 2014 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package btcjson_test
import (
"reflect"
"sort"
"testing"
"github.com/btcsuite/btcd/btcjson"
)
// TestUsageFlagStringer tests the stringized output for the UsageFlag type.
func TestUsageFlagStringer(t *testing.T) {
t.Parallel()
tests := []struct {
in btcjson.UsageFlag
want string
}{
{0, "0x0"},
{btcjson.UFWalletOnly, "UFWalletOnly"},
{btcjson.UFWebsocketOnly, "UFWebsocketOnly"},
{btcjson.UFNotification, "UFNotification"},
{btcjson.UFWalletOnly | btcjson.UFWebsocketOnly,
"UFWalletOnly|UFWebsocketOnly"},
{btcjson.UFWalletOnly | btcjson.UFWebsocketOnly | (1 << 31),
"UFWalletOnly|UFWebsocketOnly|0x80000000"},
}
// Detect additional usage flags that don't have the stringer added.
numUsageFlags := 0
highestUsageFlagBit := btcjson.TstHighestUsageFlagBit
for highestUsageFlagBit > 1 {
numUsageFlags++
highestUsageFlagBit >>= 1
}
if len(tests)-3 != numUsageFlags {
t.Errorf("It appears a usage flag was added without adding " +
"an associated stringer test")
}
t.Logf("Running %d tests", len(tests))
for i, test := range tests {
result := test.in.String()
if result != test.want {
t.Errorf("String #%d\n got: %s want: %s", i, result,
test.want)
continue
}
}
}
// TestRegisterCmdErrors ensures the RegisterCmd function returns the expected
// error when provided with invalid types.
func TestRegisterCmdErrors(t *testing.T) {
t.Parallel()
tests := []struct {
name string
method string
cmdFunc func() interface{}
flags btcjson.UsageFlag
err btcjson.Error
}{
{
name: "duplicate method",
method: "getblock",
cmdFunc: func() interface{} {
return struct{}{}
},
err: btcjson.Error{ErrorCode: btcjson.ErrDuplicateMethod},
},
{
name: "invalid usage flags",
method: "registertestcmd",
cmdFunc: func() interface{} {
return 0
},
flags: btcjson.TstHighestUsageFlagBit,
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidUsageFlags},
},
{
name: "invalid type",
method: "registertestcmd",
cmdFunc: func() interface{} {
return 0
},
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "invalid type 2",
method: "registertestcmd",
cmdFunc: func() interface{} {
return &[]string{}
},
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "embedded field",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ int }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrEmbeddedType},
},
{
name: "unexported field",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ a int }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnexportedField},
},
{
name: "unsupported field type 1",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ A **int }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnsupportedFieldType},
},
{
name: "unsupported field type 2",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ A chan int }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnsupportedFieldType},
},
{
name: "unsupported field type 3",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ A complex64 }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnsupportedFieldType},
},
{
name: "unsupported field type 4",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ A complex128 }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnsupportedFieldType},
},
{
name: "unsupported field type 5",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ A func() }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnsupportedFieldType},
},
{
name: "unsupported field type 6",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ A interface{} }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnsupportedFieldType},
},
{
name: "required after optional",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct {
A *int
B int
}
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrNonOptionalField},
},
{
name: "non-optional with default",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct {
A int `jsonrpcdefault:"1"`
}
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrNonOptionalDefault},
},
{
name: "mismatched default",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct {
A *int `jsonrpcdefault:"1.7"`
}
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrMismatchedDefault},
},
}
t.Logf("Running %d tests", len(tests))
for i, test := range tests {
err := btcjson.RegisterCmd(test.method, test.cmdFunc(),
test.flags)
if reflect.TypeOf(err) != reflect.TypeOf(test.err) {
t.Errorf("Test #%d (%s) wrong error - got %T, "+
"want %T", i, test.name, err, test.err)
continue
}
gotErrorCode := err.(btcjson.Error).ErrorCode
if gotErrorCode != test.err.ErrorCode {
t.Errorf("Test #%d (%s) mismatched error code - got "+
"%v, want %v", i, test.name, gotErrorCode,
test.err.ErrorCode)
continue
}
}
}
// TestMustRegisterCmdPanic ensures the MustRegisterCmd function panics when
// used to register an invalid type.
func TestMustRegisterCmdPanic(t *testing.T) {
t.Parallel()
// Setup a defer to catch the expected panic to ensure it actually
// paniced.
defer func() {
if err := recover(); err == nil {
t.Error("MustRegisterCmd did not panic as expected")
}
}()
// Intentionally try to register an invalid type to force a panic.
btcjson.MustRegisterCmd("panicme", 0, 0)
}
// TestRegisteredCmdMethods tests the RegisteredCmdMethods function ensure it
// works as expected.
func TestRegisteredCmdMethods(t *testing.T) {
t.Parallel()
// Ensure the registerd methods are returned.
methods := btcjson.RegisteredCmdMethods()
if len(methods) == 0 {
t.Fatal("RegisteredCmdMethods: no methods")
}
// Ensure the returned methods are sorted.
sortedMethods := make([]string, len(methods))
copy(sortedMethods, methods)
sort.Sort(sort.StringSlice(sortedMethods))
if !reflect.DeepEqual(sortedMethods, methods) {
t.Fatal("RegisteredCmdMethods: methods are not sorted")
}
}
| adrianbrink/tendereum | vendor/github.com/cosmos/tendereum/vendor/github.com/btcsuite/btcd/btcjson/register_test.go | GO | agpl-3.0 | 6,815 | [
30522,
1013,
1013,
9385,
1006,
1039,
30524,
1013,
1013,
2224,
1997,
2023,
3120,
3642,
2003,
9950,
2011,
2019,
2003,
2278,
1013,
1013,
6105,
2008,
2064,
2022,
2179,
1999,
1996,
6105,
5371,
1012,
7427,
18411,
2278,
22578,
2239,
1035,
3231,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.assertEqual(15 , total)
def test_iterating_with_next(self):
stages = iter(['alpha','beta','gamma'])
try:
self.assertEqual('alpha', next(stages))
next(stages)
self.assertEqual('gamma', next(stages))
next(stages)
except StopIteration as ex:
err_msg = 'Ran out of iterations'
self.assertRegex(err_msg, 'Ran out')
# ------------------------------------------------------------------
def add_ten(self, item):
return item + 10
def test_map_transforms_elements_of_a_list(self):
seq = [1, 2, 3]
mapped_seq = list()
mapping = map(self.add_ten, seq)
self.assertNotEqual(list, mapping.__class__)
self.assertEqual(map, mapping.__class__)
# In Python 3 built in iterator funcs return iterable view objects
# instead of lists
for item in mapping:
mapped_seq.append(item)
self.assertEqual([11, 12, 13], mapped_seq)
# Note, iterator methods actually return objects of iter type in
# python 3. In python 2 map() would give you a list.
def test_filter_selects_certain_items_from_a_list(self):
def is_even(item):
return (item % 2) == 0
seq = [1, 2, 3, 4, 5, 6]
even_numbers = list()
for item in filter(is_even, seq):
even_numbers.append(item)
self.assertEqual([2,4,6], even_numbers)
def test_just_return_first_item_found(self):
def is_big_name(item):
return len(item) > 4
names = ["Jim", "Bill", "Clarence", "Doug", "Eli"]
name = None
iterator = filter(is_big_name, names)
try:
name = next(iterator)
except StopIteration:
msg = 'Ran out of big names'
self.assertEqual("Clarence", name)
# ------------------------------------------------------------------
def add(self,accum,item):
return accum + item
def multiply(self,accum,item):
return accum * item
def test_reduce_will_blow_your_mind(self):
import functools
# As of Python 3 reduce() has been demoted from a builtin function
# to the functools module.
result = functools.reduce(self.add, [2, 3, 4])
self.assertEqual(int, result.__class__)
# Reduce() syntax is same as Python 2
self.assertEqual(9, result)
result2 = functools.reduce(self.multiply, [2, 3, 4], 1)
self.assertEqual(24, result2)
# Extra Credit:
# Describe in your own words what reduce does.
# ------------------------------------------------------------------
def test_use_pass_for_iterations_with_no_body(self):
for num in range(1,5):
pass
self.assertEqual(4, num)
# ------------------------------------------------------------------
def test_all_iteration_methods_work_on_any_sequence_not_just_lists(self):
# Ranges are an iterable sequence
result = map(self.add_ten, range(1,4))
self.assertEqual([11, 12, 13], list(result))
try:
file = open("example_file.txt")
try:
def make_upcase(line):
return line.strip().upper()
upcase_lines = map(make_upcase, file.readlines())
self.assertEqual(["THIS", "IS", "A", "TEST"] , list(upcase_lines))
finally:
# Arg, this is ugly.
# We will figure out how to fix this later.
file.close()
except IOError:
# should never happen
self.fail()
| bohdan7/python_koans | python3/koans/about_iteration.py | Python | mit | 3,923 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
18750,
1001,
1011,
1008,
1011,
16861,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
2013,
5479,
1012,
12849,
2319,
12324,
1008,
2465,
2055,
21646,
3370,
1006,
12849,
2319,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*********************************************************\
* Copyright (c) 2012-2021 The Unrimp Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\*********************************************************/
//[-------------------------------------------------------]
//[ Includes ]
//[-------------------------------------------------------]
#include "Renderer/Public/Resource/Material/MaterialPropertyValue.h"
//[-------------------------------------------------------]
//[ Namespace ]
//[-------------------------------------------------------]
namespace Renderer
{
//[-------------------------------------------------------]
//[ Public static methods ]
//[-------------------------------------------------------]
uint32_t MaterialPropertyValue::getValueTypeNumberOfBytes(ValueType valueType)
{
switch (valueType)
{
case ValueType::UNKNOWN:
return 0;
case ValueType::BOOLEAN:
return sizeof(bool);
case ValueType::INTEGER:
return sizeof(int);
case ValueType::INTEGER_2:
return sizeof(int) * 2;
case ValueType::INTEGER_3:
return sizeof(int) * 3;
case ValueType::INTEGER_4:
return sizeof(int) * 4;
case ValueType::FLOAT:
return sizeof(float);
case ValueType::FLOAT_2:
return sizeof(float) * 2;
case ValueType::FLOAT_3:
return sizeof(float) * 3;
case ValueType::FLOAT_4:
return sizeof(float) * 4;
case ValueType::FLOAT_3_3:
return sizeof(float) * 3 * 3;
case ValueType::FLOAT_4_4:
return sizeof(float) * 4 * 4;
case ValueType::FILL_MODE:
return sizeof(Rhi::FillMode);
case ValueType::CULL_MODE:
return sizeof(Rhi::CullMode);
case ValueType::CONSERVATIVE_RASTERIZATION_MODE:
return sizeof(Rhi::ConservativeRasterizationMode);
case ValueType::DEPTH_WRITE_MASK:
return sizeof(Rhi::DepthWriteMask);
case ValueType::STENCIL_OP:
return sizeof(Rhi::StencilOp);
case ValueType::COMPARISON_FUNC:
return sizeof(Rhi::ComparisonFunc);
case ValueType::BLEND:
return sizeof(Rhi::Blend);
case ValueType::BLEND_OP:
return sizeof(Rhi::BlendOp);
case ValueType::FILTER_MODE:
return sizeof(Rhi::FilterMode);
case ValueType::TEXTURE_ADDRESS_MODE:
return sizeof(Rhi::TextureAddressMode);
case ValueType::TEXTURE_ASSET_ID:
return sizeof(AssetId);
case ValueType::GLOBAL_MATERIAL_PROPERTY_ID:
return sizeof(MaterialPropertyId);
}
// Error, we should never ever end up in here
return 0;
}
//[-------------------------------------------------------]
//[ Public methods ]
//[-------------------------------------------------------]
bool MaterialPropertyValue::operator ==(const MaterialPropertyValue& materialPropertyValue) const
{
// Check value type
if (mValueType != materialPropertyValue.getValueType())
{
// Not identical due to value type mismatch
return false;
}
// Check value type
switch (mValueType)
{
case ValueType::UNKNOWN:
return true;
case ValueType::BOOLEAN:
return (mValue.Boolean == materialPropertyValue.mValue.Boolean);
case ValueType::INTEGER:
return (mValue.Integer == materialPropertyValue.mValue.Integer);
case ValueType::INTEGER_2:
return (mValue.Integer2[0] == materialPropertyValue.mValue.Integer2[0] &&
mValue.Integer2[1] == materialPropertyValue.mValue.Integer2[1]);
case ValueType::INTEGER_3:
return (mValue.Integer3[0] == materialPropertyValue.mValue.Integer3[0] &&
mValue.Integer3[1] == materialPropertyValue.mValue.Integer3[1] &&
mValue.Integer3[2] == materialPropertyValue.mValue.Integer3[2]);
case ValueType::INTEGER_4:
return (mValue.Integer4[0] == materialPropertyValue.mValue.Integer4[0] &&
mValue.Integer4[1] == materialPropertyValue.mValue.Integer4[1] &&
mValue.Integer4[2] == materialPropertyValue.mValue.Integer4[2] &&
mValue.Integer4[3] == materialPropertyValue.mValue.Integer4[3]);
case ValueType::FLOAT:
return (mValue.Float == materialPropertyValue.mValue.Float);
case ValueType::FLOAT_2:
return (mValue.Float2[0] == materialPropertyValue.mValue.Float2[0] &&
mValue.Float2[1] == materialPropertyValue.mValue.Float2[1]);
case ValueType::FLOAT_3:
return (mValue.Float3[0] == materialPropertyValue.mValue.Float3[0] &&
mValue.Float3[1] == materialPropertyValue.mValue.Float3[1] &&
mValue.Float3[2] == materialPropertyValue.mValue.Float3[2]);
case ValueType::FLOAT_4:
return (mValue.Float4[0] == materialPropertyValue.mValue.Float4[0] &&
mValue.Float4[1] == materialPropertyValue.mValue.Float4[1] &&
mValue.Float4[2] == materialPropertyValue.mValue.Float4[2] &&
mValue.Float4[3] == materialPropertyValue.mValue.Float4[3]);
case ValueType::FLOAT_3_3:
// Declaration property only
return true;
case ValueType::FLOAT_4_4:
// Declaration property only
return true;
case ValueType::FILL_MODE:
return (mValue.FillMode == materialPropertyValue.mValue.FillMode);
case ValueType::CULL_MODE:
return (mValue.CullMode == materialPropertyValue.mValue.CullMode);
case ValueType::CONSERVATIVE_RASTERIZATION_MODE:
return (mValue.ConservativeRasterizationMode == materialPropertyValue.mValue.ConservativeRasterizationMode);
case ValueType::DEPTH_WRITE_MASK:
return (mValue.DepthWriteMask == materialPropertyValue.mValue.DepthWriteMask);
case ValueType::STENCIL_OP:
return (mValue.StencilOp == materialPropertyValue.mValue.StencilOp);
case ValueType::COMPARISON_FUNC:
return (mValue.ComparisonFunc == materialPropertyValue.mValue.ComparisonFunc);
case ValueType::BLEND:
return (mValue.Blend == materialPropertyValue.mValue.Blend);
case ValueType::BLEND_OP:
return (mValue.BlendOp == materialPropertyValue.mValue.BlendOp);
case ValueType::FILTER_MODE:
return (mValue.FilterMode == materialPropertyValue.mValue.FilterMode);
case ValueType::TEXTURE_ADDRESS_MODE:
return (mValue.TextureAddressMode == materialPropertyValue.mValue.TextureAddressMode);
case ValueType::TEXTURE_ASSET_ID:
return (mValue.TextureAssetId == materialPropertyValue.mValue.TextureAssetId);
case ValueType::GLOBAL_MATERIAL_PROPERTY_ID:
return (mValue.GlobalMaterialPropertyId == materialPropertyValue.mValue.GlobalMaterialPropertyId);
}
// Not identical
ASSERT(false, "Invalid value type")
return false;
}
//[-------------------------------------------------------]
//[ Namespace ]
//[-------------------------------------------------------]
} // Renderer
| cofenberg/unrimp | Source/Renderer/Public/Resource/Material/MaterialPropertyValue.cpp | C++ | mit | 7,771 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Selection strategies for training with multiple adversarial representations.
A selector can select one representation for training at each step, and
maintain its internal state for subsequent selections. The state can also be
updated once every K epochs when the model is evaluated on the validation set.
"""
import gin
import tensorflow.compat.v2 as tf
class SelectionStrategy(tf.Module):
"""Base class for strategies to select representations.
This base class handles sample and update frequencies, as well as logging
selection statistics to TensorBoard. Sub-classes should implement _select()
and _update().
"""
def __init__(self, representation_names, sample_freq, update_freq):
"""Constructs a SelectionStrategy object.
Args:
representation_names: A list of representations names for tf.summary.
sample_freq: Frequency to draw a new selection (in steps).
update_freq: Frequency to update the selector's state (in epochs).
"""
self.num_representations = len(representation_names)
self.representation_names = representation_names
self.sample_freq = sample_freq
self.update_freq = update_freq
# index of the selected representation
self.current_selection = tf.Variable(0, trainable=False)
self.last_selection_step = tf.Variable(-1, trainable=False)
self.last_update_epoch = tf.Variable(0, trainable=False)
self.selection_counter = tf.Variable([0] * self.num_representations)
def select(self, step):
"""Returns the index of the selected representation for a training step."""
if step - self.last_selection_step >= self.sample_freq:
self.current_selection.assign(self._select())
self.last_selection_step.assign(step)
# Increment the counter for the newly selected item.
self.selection_counter.scatter_add(
tf.IndexedSlices(1, self.current_selection))
return self.current_selection.numpy()
def should_update(self, epoch):
"""Returns whether the strategy should update its state at this epoch."""
return epoch - self.last_update_epoch >= self.update_freq
def update(self, epoch, validation_losses):
"""Updates the strategy's state based on current validation losses.
Args:
epoch: Current epoch number.
validation_losses: A list of numbers, one for each representation.
"""
self._update(epoch, validation_losses)
self.last_update_epoch.assign(epoch)
# Log the counts since last update to the summary and reset the counts.
for i in range(self.num_representations):
tf.summary.scalar(
f"representations/selected/{self.representation_names[i]}",
self.selection_counter[i],
step=epoch)
self.selection_counter.assign([0] * self.num_representations)
def _select(self):
raise NotImplementedError
def _update(self, epoch, validation_losses):
"""See update()."""
raise NotImplementedError
class GreedyStrategy(SelectionStrategy):
"""Greedy strategy which selects the one with the highest validation loss."""
def _select(self):
# No needs to reselect since this strategy is deterministic.
return self.current_selection.numpy()
def _update(self, epoch, validation_losses):
del epoch # unused
self.current_selection.assign(
tf.cast(tf.argmax(validation_losses), self.current_selection.dtype))
class RoundRobinStrategy(SelectionStrategy):
"""Round-robin strategy which selects each representation sequentially."""
def _select(self):
return (self.current_selection + 1) % self.num_representations
def _update(self, epoch, validation_losses):
pass
@gin.configurable
def eta_scheduler(epoch, values=(0.1,), breakpoints=()):
"""Piecewise constant schedule for eta (selector weight learning rate)."""
idx = sum(1 if epoch > b else 0 for b in breakpoints)
return values[idx]
class MultiplicativeWeightStrategy(SelectionStrategy):
"""Multiplicative-weight strategy which samples representations adaptively."""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Weights of each representation. Each selection is a sample drawn
# proportionally to the weights.
# TODO(csferng): Store the weights in logit space.
self.weights = tf.Variable(tf.ones(self.num_representations))
self.current_selection.assign(self._select())
def _select(self):
logits = tf.math.log(self.weights / tf.reduce_sum(self.weights))
return tf.random.categorical(tf.reshape(logits, [1, -1]), 1)[0][0].numpy()
def _update(self, epoch, validation_losses):
validation_losses = tf.convert_to_tensor(validation_losses)
eta = eta_scheduler(epoch)
self.weights.assign(self.weights * tf.math.exp(eta * validation_losses))
for i in range(self.num_representations):
tf.summary.scalar(
f"representations/weight/{self.representation_names[i]}",
self.weights[i],
step=epoch)
STRATEGY_CLASSES = {
"greedy": GreedyStrategy,
"roundrobin": RoundRobinStrategy,
"multiweight": MultiplicativeWeightStrategy,
}
@gin.configurable
def construct_representation_selector(representation_names,
selection_strategy="multiweight",
sample_freq=351, # in number of steps
update_freq=5): # in number of epochs
return STRATEGY_CLASSES[selection_strategy](representation_names, sample_freq,
update_freq)
| tensorflow/neural-structured-learning | research/multi_representation_adversary/multi_representation_adversary/selectors.py | Python | apache-2.0 | 6,095 | [
30522,
1001,
9385,
12609,
8224,
11775,
1001,
1001,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1001,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
1996,
6105,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<section data-ng-controller="EmaxiningboardsController" data-ng-init="findOne()">
<div class="page-header">
<h1 data-ng-bind="emaxiningboard.name"></h1>
</div>
<div class="pull-right" data-ng-show="((authentication.user) && (authentication.user._id == emaxiningboard.user._id))">
<a class="btn btn-primary" href="/#!/emaxiningboards/{{emaxiningboard._id}}/edit">
<i class="glyphicon glyphicon-edit"></i>
</a>
<a class="btn btn-primary" data-ng-click="remove();">
<i class="glyphicon glyphicon-trash"></i>
</a>
</div>
<small>
<em class="text-muted">
Posted on
<span data-ng-bind="emaxiningboard.created | date:'mediumDate'"></span>
by
<span data-ng-bind="emaxiningboard.user.displayName"></span>
</em>
</small>
</section>
| maisquestoes/api-mean | public/modules/emaxiningboards/views/view-emaxiningboard.client.view.html | HTML | mit | 759 | [
30522,
1026,
2930,
2951,
1011,
12835,
1011,
11486,
1027,
1000,
7861,
8528,
24002,
15271,
8663,
13181,
10820,
1000,
2951,
1011,
12835,
1011,
1999,
4183,
1027,
1000,
2424,
5643,
1006,
1007,
1000,
1028,
1026,
4487,
2615,
2465,
1027,
1000,
3931... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* @package tikiwiki
*/
// (c) Copyright 2002-2013 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id: tiki-browse_freetags.php 50798 2014-04-14 16:24:53Z jyhem $
$section = 'freetags';
require_once ('tiki-setup.php');
include_once ('lib/freetag/freetaglib.php');
$access->check_feature('feature_freetags');
$access->check_permission('tiki_p_view_freetags');
if (isset($_REQUEST['del'])) {
if ($tiki_p_admin == 'y' || $tiki_p_unassign_freetags == 'y') {
$freetaglib->delete_object_tag($_REQUEST['itemit'], $_REQUEST['typeit'], $_REQUEST['tag']);
} else {
$smarty->assign('errortype', 401);
$smarty->assign('msg', tra('Permission denied'));
$smarty->display('error.tpl');
die;
}
}
if ($freetaglib->count_tags() == 0) {
$smarty->assign('msg', tra("Nothing tagged yet") . '.');
$smarty->display("error.tpl");
die;
}
if (!isset($_REQUEST['tag']) && $prefs['freetags_preload_random_search'] == 'y') {
$tag = $freetaglib->get_tag_suggestion('', 1);
if (!empty($tag[0])) {
$_REQUEST['tag'] = $tag[0];
if (strstr($tag[0], ' ')) {
$_REQUEST['tag'] = '"'.$_REQUEST['tag'].'"';
}
}
}
if (!isset($_REQUEST["sort_mode"])) {
$sort_mode = 'name_asc';
} else {
$sort_mode = $_REQUEST["sort_mode"];
$sort_mode = str_replace('created', 'o.`created`', $sort_mode);
}
if (isset($_REQUEST["find"])) {
$find = $_REQUEST["find"];
} else {
$find = '';
}
$smarty->assign_by_ref('sort_mode', $sort_mode);
$smarty->assign_by_ref('find', $find);
if (!isset($_REQUEST["offset"])) {
$offset = 0;
} else {
$offset = $_REQUEST["offset"];
}
$smarty->assign_by_ref('offset', $offset);
if (!isset($_REQUEST["type"])) {
$type = isset($_REQUEST['old_type'])?$_REQUEST['old_type']: '';
} else {
$type = $_REQUEST["type"];
}
$smarty->assign('type', $type);
if (isset($_REQUEST["user_only"]) && $_REQUEST["user_only"] == 'on') {
$view_user = $user;
$smarty->assign('user_only', 'on');
} else {
$view_user = '';
$smarty->assign('user_only', 'off');
}
if (isset($_REQUEST['broaden']) && $_REQUEST['broaden'] == 'last') {
$broaden = 'last';
} elseif ((isset($_REQUEST['broaden']) && $_REQUEST['broaden'] == 'n') || (isset($_REQUEST['stopbroaden']) && $_REQUEST['stopbroaden'] == 'on')) {
$broaden = 'n';
} else {
$broaden = 'y';
}
$smarty->assign('broaden', $broaden);
$tagArray = $freetaglib->_parse_tag((isset($_REQUEST['tag'])) ? $_REQUEST['tag'] : '');
$tagString = '';
foreach ($tagArray as $t_ar) {
if (strstr($t_ar, ' ')) {
$tagString.= '"' . $t_ar . '" ';
} else {
$tagString.= $t_ar . ' ';
}
}
$smarty->assign('tagString', trim($tagString));
$smarty->assign('tag', (isset($tagArray[0])) ? $tagArray[0] : '');
if (empty($_REQUEST['maxPopular'])) {
$maxPopular = $prefs['freetags_browse_amount_tags_in_cloud'];
} else {
$maxPopular = $_REQUEST['maxPopular'];
$smarty->assign_by_ref('maxPopular', $maxPopular);
}
if (empty($_REQUEST['tsort_mode'])) {
$tsort_mode = 'tag_asc';
} else {
$tsort_mode = $_REQUEST['tsort_mode'];
$smarty->assign_by_ref('tsort_mode', $tsort_mode);
}
if (!empty($_REQUEST['objectId'])) {
$objectId = $_REQUEST['objectId'];
} else {
$objectId = null;
}
$smarty->assign_by_ref('objectId', $objectId);
if ($prefs['feature_blogs'] == 'y' && $type == 'blog post') {
$blogs = TikiLib::lib('blog')->list_blogs();
$smarty->assign('blogs', $blogs['data']);
}
$most_popular_tags = $freetaglib->get_most_popular_tags('', 0, $maxPopular, $type, $objectId, $tsort_mode);
if (!empty($prefs['freetags_cloud_colors'])) {
$colors = explode(',', $prefs['freetags_cloud_colors']);
$prev = '';
foreach ($most_popular_tags as $id => $tag) {
if (count($colors) == 1) {
$i = 0;
} elseif (count($colors) == 2) {
$i = $prev ? 0 : 1;
}
$most_popular_tags[$id]['color'] = $colors[$i];
$prev = $i;
}
}
$smarty->assign('most_popular_tags', $most_popular_tags);
if ($broaden == 'last') {
$broaden = 'n';
$tagArray = array(
$tagArray[count($tagArray) - 1]
);
}
$objects = $freetaglib->get_objects_with_tag_combo($tagArray, $type, $view_user, $offset, $maxRecords, $sort_mode, $find, $broaden, $objectId);
$smarty->assign_by_ref('objects', $objects["data"]);
$smarty->assign_by_ref('cantobjects', $objects["cant"]);
$cant = $objects['cant'];
$smarty->assign('cant', $objects['cant']);
include_once ('tiki-section_options.php');
ask_ticket('browse-freetags');
$smarty->assign(
'objects_with_freetags',
array (
'wiki page',
'blog post',
'article',
'directory',
'faq',
'file gallery',
'image gallery',
'image',
'poll',
'quiz',
'survey',
'tracker',
'tracker %d'
)
);
$smarty->assign('mid', 'tiki-browse_freetags.tpl');
$smarty->display("tiki.tpl");
| shailendrairis/TikiWiki12.2 | tiki-browse_freetags.php | PHP | lgpl-2.1 | 4,815 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1030,
7427,
14841,
3211,
9148,
3211,
1008,
1013,
1013,
1013,
1006,
1039,
1007,
9385,
2526,
1011,
2286,
2011,
6048,
1997,
1996,
14841,
3211,
15536,
3211,
4642,
2015,
2177,
8059,
2622,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/env node
/**
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
let baseModule;
try {
// To support easy development when making changes in the source repo, we
// first try looking for a copy of the base module using a relative path. In
// this context, we prefer the local copy over one that may already be
// installed.
baseModule = require('../../generic-webdriver-server');
} catch (error) {
if (!error.message.includes('Cannot find module')) {
throw error;
}
// When this module is running in an installed context, we fall back to
// requiring the installed base module by name.
baseModule = require('generic-webdriver-server');
}
const {GenericSingleSessionWebDriverServer, yargs} = baseModule;
const {
checkPlatformRequirements,
loadOnXboxOne,
takeScreenshot,
addXboxOneArgs,
} = require('./xbox-one-utils');
/** WebDriver server backend for Xbox One */
class XboxOneWebDriverServer extends GenericSingleSessionWebDriverServer {
constructor() {
super();
checkPlatformRequirements();
}
/** @override */
async navigateToSingleSession(url) {
await loadOnXboxOne(this.flags, this.log, url);
}
/** @override */
async closeSingleSession() {
// Send the device back to the home screen.
await loadOnXboxOne(this.flags, this.log, null);
}
/** @override */
async screenshot(sessionId) {
return await takeScreenshot(
this.flags.hostname, this.flags.username, this.flags.password);
}
}
addXboxOneArgs(yargs);
const server = new XboxOneWebDriverServer();
server.listen();
| shaka-project/generic-webdriver-server | backends/xboxone/xbox-one-webdriver-server.js | JavaScript | apache-2.0 | 2,114 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
13045,
1013,
1008,
1008,
1008,
9385,
12609,
8224,
11775,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
/**
* Validates that a card number belongs to a specified scheme.
*
* @author Tim Nagel <t.nagel@infinite.net.au>
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @see http://en.wikipedia.org/wiki/Bank_card_number
* @see http://www.regular-expressions.info/creditcard.html
* @see http://www.barclaycard.co.uk/business/files/Ranges_and_Rules_September_2014.pdf
*/
class CardSchemeValidator extends ConstraintValidator
{
protected $schemes = [
// American Express card numbers start with 34 or 37 and have 15 digits.
'AMEX' => [
'/^3[47][0-9]{13}$/',
],
// China UnionPay cards start with 62 and have between 16 and 19 digits.
// Please note that these cards do not follow Luhn Algorithm as a checksum.
'CHINA_UNIONPAY' => [
'/^62[0-9]{14,17}$/',
],
// Diners Club card numbers begin with 300 through 305, 36 or 38. All have 14 digits.
// There are Diners Club cards that begin with 5 and have 16 digits.
// These are a joint venture between Diners Club and MasterCard, and should be processed like a MasterCard.
'DINERS' => [
'/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/',
],
// Discover card numbers begin with 6011, 622126 through 622925, 644 through 649 or 65.
// All have 16 digits.
'DISCOVER' => [
'/^6011[0-9]{12}$/',
'/^64[4-9][0-9]{13}$/',
'/^65[0-9]{14}$/',
'/^622(12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|91[0-9]|92[0-5])[0-9]{10}$/',
],
// InstaPayment cards begin with 637 through 639 and have 16 digits.
'INSTAPAYMENT' => [
'/^63[7-9][0-9]{13}$/',
],
// JCB cards beginning with 2131 or 1800 have 15 digits.
// JCB cards beginning with 35 have 16 digits.
'JCB' => [
'/^(?:2131|1800|35[0-9]{3})[0-9]{11}$/',
],
// Laser cards begin with either 6304, 6706, 6709 or 6771 and have between 16 and 19 digits.
'LASER' => [
'/^(6304|670[69]|6771)[0-9]{12,15}$/',
],
// Maestro international cards begin with 675900..675999 and have between 12 and 19 digits.
// Maestro UK cards begin with either 500000..509999 or 560000..699999 and have between 12 and 19 digits.
'MAESTRO' => [
'/^(6759[0-9]{2})[0-9]{6,13}$/',
'/^(50[0-9]{4})[0-9]{6,13}$/',
'/^5[6-9][0-9]{10,17}$/',
'/^6[0-9]{11,18}$/',
],
// All MasterCard numbers start with the numbers 51 through 55. All have 16 digits.
// October 2016 MasterCard numbers can also start with 222100 through 272099.
'MASTERCARD' => [
'/^5[1-5][0-9]{14}$/',
'/^2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12})$/',
],
// All Visa card numbers start with a 4 and have a length of 13, 16, or 19 digits.
'VISA' => [
'/^4([0-9]{12}|[0-9]{15}|[0-9]{18})$/',
],
];
/**
* Validates a creditcard belongs to a specified scheme.
*
* @param mixed $value
* @param Constraint $constraint
*/
public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof CardScheme) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\CardScheme');
}
if (null === $value || '' === $value) {
return;
}
if (!is_numeric($value)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(CardScheme::NOT_NUMERIC_ERROR)
->addViolation();
return;
}
$schemes = array_flip((array) $constraint->schemes);
$schemeRegexes = array_intersect_key($this->schemes, $schemes);
foreach ($schemeRegexes as $regexes) {
foreach ($regexes as $regex) {
if (preg_match($regex, $value)) {
return;
}
}
}
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(CardScheme::INVALID_FORMAT_ERROR)
->addViolation();
}
}
| enslyon/ensl | vendor/symfony/validator/Constraints/CardSchemeValidator.php | PHP | gpl-2.0 | 4,811 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
1996,
25353,
2213,
14876,
4890,
7427,
1012,
1008,
1008,
1006,
1039,
1007,
6904,
11283,
2078,
8962,
2368,
19562,
1026,
6904,
11283,
2078,
1030,
25353,
2213,
14876,
489... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2017 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Internal struct to represent a command we will send to the server - command
* parameters are collected in a mongoc_cmd_parts_t until we know the server's
* wire version and whether it is mongos, then we collect the parts into a
* mongoc_cmd_t, and gather that into a mongoc_rpc_t.
*/
#ifndef MONGOC_CMD_PRIVATE_H
#define MONGOC_CMD_PRIVATE_H
#if !defined(MONGOC_COMPILATION)
#error "Only <mongoc.h> can be included directly."
#endif
#include <bson.h>
#include "mongoc-server-stream-private.h"
#include "mongoc-read-prefs.h"
#include "mongoc.h"
#include "mongoc-opts-private.h"
BSON_BEGIN_DECLS
typedef enum {
MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_UNKNOWN,
MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_YES,
MONGOC_CMD_PARTS_ALLOW_TXN_NUMBER_NO
} mongoc_cmd_parts_allow_txn_number_t;
typedef struct _mongoc_cmd_t {
const char *db_name;
mongoc_query_flags_t query_flags;
const bson_t *command;
const char *command_name;
const uint8_t *payload;
int32_t payload_size;
const char *payload_identifier;
const mongoc_server_stream_t *server_stream;
int64_t operation_id;
mongoc_client_session_t *session;
bool is_acknowledged;
} mongoc_cmd_t;
typedef struct _mongoc_cmd_parts_t {
mongoc_cmd_t assembled;
mongoc_query_flags_t user_query_flags;
const bson_t *body;
bson_t read_concern_document;
bson_t write_concern_document;
bson_t extra;
const mongoc_read_prefs_t *read_prefs;
bson_t assembled_body;
bool is_read_command;
bool is_write_command;
bool prohibit_lsid;
mongoc_cmd_parts_allow_txn_number_t allow_txn_number;
bool is_retryable_write;
bool has_temp_session;
mongoc_client_t *client;
} mongoc_cmd_parts_t;
void
mongoc_cmd_parts_init (mongoc_cmd_parts_t *op,
mongoc_client_t *client,
const char *db_name,
mongoc_query_flags_t user_query_flags,
const bson_t *command_body);
void
mongoc_cmd_parts_set_session (mongoc_cmd_parts_t *parts,
mongoc_client_session_t *cs);
bool
mongoc_cmd_parts_append_opts (mongoc_cmd_parts_t *parts,
bson_iter_t *iter,
int max_wire_version,
bson_error_t *error);
bool
mongoc_cmd_parts_set_read_concern (mongoc_cmd_parts_t *parts,
const mongoc_read_concern_t *rc,
int max_wire_version,
bson_error_t *error);
bool
mongoc_cmd_parts_set_write_concern (mongoc_cmd_parts_t *parts,
const mongoc_write_concern_t *wc,
int max_wire_version,
bson_error_t *error);
bool
mongoc_cmd_parts_append_read_write (mongoc_cmd_parts_t *parts,
mongoc_read_write_opts_t *rw_opts,
int max_wire_version,
bson_error_t *error);
bool
mongoc_cmd_parts_assemble (mongoc_cmd_parts_t *parts,
const mongoc_server_stream_t *server_stream,
bson_error_t *error);
bool
mongoc_cmd_is_compressible (mongoc_cmd_t *cmd);
void
mongoc_cmd_parts_cleanup (mongoc_cmd_parts_t *op);
BSON_END_DECLS
#endif /* MONGOC_CMD_PRIVATE_H */
| ajdavis/mongo-c-driver | src/libmongoc/src/mongoc/mongoc-cmd-private.h | C | apache-2.0 | 3,997 | [
30522,
1013,
1008,
1008,
9385,
2418,
12256,
3995,
18939,
1010,
4297,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#import <Foundation/Foundation.h>
#import "WXApmProtocol.h"
@interface WXApmImpl : NSObject <WXApmProtocol>
@end
| Hanks10100/incubator-weex | ios/playground/WeexDemo/extend/handler/WXApmImpl.h | C | apache-2.0 | 115 | [
30522,
1001,
12324,
1026,
3192,
1013,
3192,
1012,
1044,
1028,
1001,
12324,
1000,
1059,
18684,
9737,
21572,
3406,
25778,
1012,
1044,
1000,
1030,
8278,
1059,
18684,
9737,
5714,
24759,
1024,
24978,
16429,
20614,
1026,
1059,
18684,
9737,
21572,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.vaadin.server.react.harnesses;
import java.util.function.Supplier;
import com.vaadin.server.react.Flow;
import com.vaadin.server.react.Subscriber;
public class SyncFlowTestHarness extends FlowTestHarness {
@Override
@SuppressWarnings("unchecked")
public <T> Flow<T> flow(T... actual) {
return Flow.of(actual);
}
@Override
public <T> void verifyFlow(Flow<T> flow,
Supplier<Subscriber<? super T>> subSup) {
for (int i = 0; i < 2; i++) {
verifyFlow(flow, subSup.get());
}
}
}
| jdahlstrom/vaadin.react | server/src/test/java/com/vaadin/server/react/harnesses/SyncFlowTestHarness.java | Java | apache-2.0 | 566 | [
30522,
7427,
4012,
1012,
12436,
17190,
2078,
1012,
8241,
1012,
10509,
1012,
17445,
2229,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
3853,
1012,
17024,
1025,
12324,
4012,
1012,
12436,
17190,
2078,
1012,
8241,
1012,
10509,
1012,
4834,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*/
#include "libuavcan/libuavcan.hpp"
#include "libuavcan/time.hpp"
namespace
{
class TooBig : public libuavcan::time::Base<TooBig, libuavcan::duration::Monotonic>
{
uint8_t more_;
};
} // namespace
int main()
{
TooBig a;
(void) a;
return 0;
}
| UAVCAN/libuavcan | test/compile/test_time_003.cpp | C++ | mit | 342 | [
30522,
1013,
1008,
1008,
9385,
10476,
9733,
1012,
4012,
1010,
4297,
1012,
2030,
2049,
18460,
1012,
2035,
2916,
9235,
1012,
1008,
1013,
1001,
2421,
1000,
5622,
8569,
11431,
9336,
1013,
5622,
8569,
11431,
9336,
1012,
6522,
2361,
1000,
1001,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import os
import sys
import json
from optional_django import staticfiles
from optional_django.serializers import JSONEncoder
from optional_django.safestring import mark_safe
from optional_django import six
from js_host.function import Function
from js_host.exceptions import FunctionError
from react.render import RenderedComponent
from react.exceptions import ComponentSourceFileNotFound
from react.exceptions import ReactRenderingError
from react_router.conf import settings
from react_router.templates import MOUNT_JS
from react_router.bundle import bundle_component
from webpack.compiler import WebpackBundle
class RouteRenderedComponent(RenderedComponent):
def get_client_asset(self):
client_asset = None
bundled_component = self.get_bundle()
assets = bundled_component.get_assets()
for asset in assets:
if asset['path'] == self.path_to_source:
client_asset = asset
break
return client_asset
def get_var(self):
client_asset = self.get_client_asset()
if client_asset:
return 'client'
raise Exception("Client asset not found.")
def render_js(self):
client_asset = self.get_client_asset()
if client_asset:
client_bundle = mark_safe(WebpackBundle.render_tag(client_asset['url']))
return mark_safe(
'\n{bundle}\n<script>\n{mount_js}\n</script>\n'.format(
bundle=client_bundle,
mount_js=self.render_mount_js(),
)
)
def render_mount_js(self):
return mark_safe(
MOUNT_JS.format(
var=self.get_var(),
props=self.serialized_props or 'null',
container_id=self.get_container_id()
)
)
class RouteRedirect(object):
def __init__(self, pathname, query = None, state = None, *args, **kwargs):
self.path = pathname
self.query = query
if state and 'nextPathname' in state:
self.nextPath = state['nextPathname']
else:
self.nextPath = None
if self.path is None:
raise ReactRenderingError("No path returned for redirection.")
super(RouteRedirect, self).__init__(*args, **kwargs)
@property
def url(self):
if self.query:
return "%s?next=%s&%s" % (self.path, self.nextPath, self.query)
else:
return "%s?next=%s" % (self.path, self.nextPath)
class RouteNotFound(object):
def __init__(self, *args, **kwargs):
super(RouteNotFound, self).__init__(*args, **kwargs)
js_host_function = Function(settings.JS_HOST_FUNCTION)
def render_route(
# Rendering options
path, # path to routes file
client_path, # path to client routes file
request, # pass in request object
props=None,
to_static_markup=None,
# Bundling options
bundle=None,
translate=None,
# Prop handling
json_encoder=None
):
if not os.path.isabs(path):
abs_path = staticfiles.find(path)
if not abs_path:
raise ComponentSourceFileNotFound(path)
path = abs_path
if not os.path.exists(path):
raise ComponentSourceFileNotFound(path)
if not os.path.isabs(client_path):
abs_client_path = staticfiles.find(client_path)
if not abs_client_path:
raise ComponentSourceFileNotFound(client_path)
client_path = abs_client_path
if not os.path.exists(client_path):
raise ComponentSourceFileNotFound(client_path)
bundled_component = None
import re
client_re = re.compile(r"client-(?:\w*\d*).js",re.IGNORECASE)
server_re = re.compile(r"server-(?:\w*\d*).js",re.IGNORECASE)
if bundle or translate:
bundled_component = bundle_component(path, client_path, translate=translate)
assets = bundled_component.get_assets()
for asset in assets:
m = client_re.search(asset['name'])
if m:
client_path = asset['path']
m = server_re.search(asset['name'])
if m:
path = asset['path']
if json_encoder is None:
json_encoder = JSONEncoder
if props is not None:
serialized_props = json.dumps(props, cls=json_encoder)
else:
serialized_props = None
try:
location = {
'pathname': request.path,
'query': request.GET.dict()
}
cbData = json.loads(js_host_function.call(
path=path,
location=location,
serializedProps=serialized_props,
toStaticMarkup=to_static_markup
))
except FunctionError as e:
raise six.reraise(ReactRenderingError, ReactRenderingError(*e.args), sys.exc_info()[2])
if cbData['match']:
return RouteRenderedComponent(cbData['markup'], client_path, props, serialized_props, bundled_component, to_static_markup)
else:
if cbData['redirectInfo']:
return RouteRedirect(**cbData['redirectInfo'])
else:
return RouteNotFound()
| HorizonXP/python-react-router | react_router/render.py | Python | mit | 5,105 | [
30522,
12324,
9808,
12324,
25353,
2015,
12324,
1046,
3385,
2013,
11887,
1035,
6520,
23422,
12324,
10763,
8873,
4244,
2013,
11887,
1035,
6520,
23422,
1012,
7642,
17629,
2015,
12324,
1046,
3385,
2368,
16044,
2099,
2013,
11887,
1035,
6520,
23422... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
class PersonalFileUploader < FileUploader
def self.dynamic_path_segment(model)
File.join(CarrierWave.root, model_path(model))
end
def self.base_dir
File.join(root_dir, '-', 'system')
end
private
def secure_url
File.join(self.class.model_path(model), secret, file.filename)
end
def self.model_path(model)
if model
File.join("/#{base_dir}", model.class.to_s.underscore, model.id.to_s)
else
File.join("/#{base_dir}", 'temp')
end
end
end
| t-zuehlsdorff/gitlabhq | app/uploaders/personal_file_uploader.rb | Ruby | mit | 492 | [
30522,
2465,
3167,
8873,
2571,
6279,
11066,
2121,
1026,
5371,
6279,
11066,
2121,
13366,
2969,
1012,
8790,
1035,
4130,
1035,
6903,
1006,
2944,
1007,
5371,
1012,
3693,
1006,
6839,
16535,
1012,
7117,
1010,
2944,
1035,
4130,
1006,
2944,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
---
layout: static
title: Obligations
---
**What obligations do we have as members of the co-op?**
**What is the financial contribution to the co-op?**
**Is a member required to participate in _estimation_ ?**
| dovadi/rubycoop | obligations.md | Markdown | mit | 213 | [
30522,
1011,
1011,
1011,
9621,
1024,
10763,
2516,
1024,
14422,
1011,
1011,
1011,
1008,
1008,
2054,
14422,
2079,
2057,
2031,
2004,
2372,
1997,
1996,
2522,
1011,
6728,
1029,
1008,
1008,
1008,
1008,
2054,
2003,
1996,
3361,
6691,
2000,
1996,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
---
layout: post
title: "Angular uygulamasında RxJs ve Observables ile Global Messaging servisi yazalım"
date: 2017-05-25 16:00
author: engin.polat
comments: true
category: [Web]
tags: [angular, typescript, rxjs, observable, class, injectable, global, event, service, instance, constructor, static, component, implements, pipe, pipetransform, json, subscribe]
---
<div class="alert alert-success" role="alert" style="margin: 10px 0px; display: block;"> Bu makalenin kodlarına <strong>Github</strong> üzerinde <a href="https://github.com/polatengin" class="alert-link" target="_blank" rel="noopener">polatengin</a> hesabımda yer alan <a href="https://github.com/polatengin/blog-codes/tree/master/angular-global-messaging-sample" class="alert-link" target="_blank" rel="noopener">Global Messaging Sample</a> aracılığıyla erişebilirsiniz.</div>
<mark><em>Bu makaleyi okumadan önce <a href="/etiketler/#angular-ref" target="_blank" rel="noopener">Angular</a> etiketindeki diğer makalelerimi okumanızı tavsiye ederim.</em></mark>
Geçtiğimiz hafta *Yazılım Mimarı* olarak, çeşitli projelerine yardımcı olduğum bir müşteride yeni başladığımız **Angular** projesinde *global* bir *event* mekanizması kurgulamamız gerekti.
Bu yapacağımız *event* mekanizması sayesinde, uygulamanın herhangi bir nesnesinden fırlatacağımız bir bilgiyi, tamamen başka bir nesne (*hatta nesneler*) alıp, kendi istediği gibi işleyebilecek.
Örneğin, ürünler dizisi içerisinde bir üründe yeralan *Sepete Ekle* butonuna basıldığında, eğer ekranda sepetin tamamı gözüküyorsa yeni bir satır oluşsun, sepetin tamamı gözükmüyorsa oluşmasın, login olduysak ödeme sayfasına gidelim, olmadıysak *Giriş Yap* uyarısı çıksın, gibi..
Hemen yeni bir **Angular** projesi oluşturalım;
<script src="https://gist.github.com/polatengin/b9d1a51a15989359e2db0297424fffaa.js?file=ng-new-project.cmd"></script>
Projeye yeni bir **Service** eklemek için aşağıdaki komutu çalıştıralım;
<script src="https://gist.github.com/polatengin/b9d1a51a15989359e2db0297424fffaa.js?file=ng-generate-service.cmd"></script>
Bu sayede, projenin çeşitli dosyalarında kullanabileceğimiz, <code>Injectable()</code> bir servisimiz oluştu.
Yeni oluşturduğumuz servisi açalım ve aşağıdaki kodları içerecek şekilde güncelleyelim;
<script src="https://gist.github.com/polatengin/b9d1a51a15989359e2db0297424fffaa.js?file=global-messaging.service.ts"></script>
Bu servisin <code>Injectable()</code> olmasını sağladık, fakat hala <code>instance</code>'i alınıp kullanılabilir. <code>constructor()</code> method içerisinde kurguladığımız mantık sayesinde bu servisin yeni <code>instance</code>'inin alınmasının önüne geçmiş olduk.
<code>GetInstance()</code> methodu ile de, bir çeşit **Singleton Pattern** implemente etmiş olduk.
<code>broadcast()</code> methodu, parametre ile aldığı bilgiyi, *Global Messaging* servisine kendini bağlamış (*attached*) olan her nesneye iletir.
<code>messaging$</code> değişkenini ise, başka nesnelerin *Global Messaging* servisine kendilerini bağlayabilmeleri için ekledik.
Örnek kullanımı, *app.component.html* dosyasını açalım ve aşağıdaki 2 satırı ekleyelim;
<script src="https://gist.github.com/polatengin/b9d1a51a15989359e2db0297424fffaa.js?file=app.component.html"></script>
Özellikle ikinci satırdaki kullanıma dikkat edelim. <code>message</code> değişkeni olduğu hali ile değil, <code>json</code> karşılığı ile ekrana gelecek. Bir değişkeni olduğu hali ile değil, bir takım değişikliklerin uygulandığı hali ile kullanmak için <a href="https://angular.io/api/core/PipeTransform" target="_blank" rel="noopener">Angular PipeTransform</a> sınıfını kullanıyoruz.
Son olarak, *app.component.ts* dosyasını açalım ve aşağıdaki şekilde güncelleyelim;
<script src="https://gist.github.com/polatengin/b9d1a51a15989359e2db0297424fffaa.js?file=app.component.ts"></script>
<code>AppComponent</code> *class*'ı <a href="https://angular.io/api/core/OnInit" target="_blank" rel="noopener">OnInit</a> *interface*'ini *implemente* ediyor ve <code>ngOnInit()</code> methodu içerisinde <code>GlobalMessagingService</code> *class*'ının <code>GetInstance()</code> methodu aracılığı ile *instance*'ına ulaşıyor ve <code>messaging$</code> değişkeni aracılığı ile *global event*'e **subscribe** oluyor. Tek yaptığımız ise, *event* aracılığı ile gelen değeri <code>message</code> değişkenine atamak.
<code>sendMessage()</code> methodunda ise <code>GlobalMessagingService</code> *class*'ının <code>GetInstance()</code> methodu aracılığı ile *instance*'ına ulaşıyor ve <code>broadcast()</code> methodunu istediğimiz bir parametre ile çağırıyoruz.
Yukarıdaki örnekte <code>{ title: 'Laptop', price: 1200, command: 'SepeteEkle', date: new Date() }</code> parametresi ile çağırdığımız için ekrandaki butona her bastığımızda <code>messaging$</code> değişkeni üzerinden kendini bağlamış her nesne, sepete *1200* değerinde bir *Laptop* eklendiğini öğrenecek.
<img class="lazy img-responsive" data-src="/assets/uploads/2017/05/angular-global-messaging.gif" width="658" height="492" /> | polatengin/polatengin.github.io | _posts/2017-05-25-angular-uygulamasinda-rxjs-ve-observables-ile-global-messaging-servisi-yazalim.md | Markdown | mit | 5,341 | [
30522,
1011,
1011,
1011,
9621,
1024,
2695,
2516,
1024,
1000,
16108,
1057,
2100,
24848,
8067,
2015,
11722,
8943,
1054,
2595,
22578,
2310,
27885,
8043,
12423,
2015,
17869,
3795,
24732,
14262,
11365,
2072,
8038,
16739,
11722,
2213,
1000,
3058,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
using System.Collections.Generic;
using System.Text;
using _03BarracksFactory.Contracts;
namespace P03_BarraksWars.Core.Commands
{
class RetireCommand : Command
{
public RetireCommand(string[] data, IRepository repository, IUnitFactory unitFactory)
: base(data, repository, unitFactory)
{
}
public override string Execute()
{
try
{
this.Repository.RemoveUnit(this.Data[1]);
return $"{this.Data[1]} retured!";
}
catch (InvalidOperationException ex)
{
return ex.Message;
}
}
}
}
| CvetelinLozanov/SoftUni-C- | C# OOP Advanced/Reflection_And_Attributes-Exercise/P03_BarraksWars/P03_BarraksWars/Core/Commands/RetireCommand.cs | C# | mit | 700 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
3793,
1025,
2478,
1035,
6021,
8237,
22648,
5705,
21450,
1012,
8311,
1025,
3415,
15327,
1052,
2692,
30524,
3094,
1063,
2270,
11036,
9006,
2386,
2094,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2015-2016 Red Hat, Inc, and individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.hal.client.configuration.subsystem.elytron;
import org.jboss.hal.ballroom.form.Form;
import org.jboss.hal.core.mbui.MbuiContext;
import org.jboss.hal.core.mbui.MbuiViewImpl;
import org.jboss.hal.dmr.ModelNode;
import org.jboss.hal.spi.MbuiElement;
import org.jboss.hal.spi.MbuiView;
@MbuiView
@SuppressWarnings("DuplicateStringLiteralInspection")
public abstract class ElytronSubsystemView extends MbuiViewImpl<ElytronSubsystemPresenter>
implements ElytronSubsystemPresenter.MyView {
public static ElytronSubsystemView create(final MbuiContext mbuiContext) {
return new Mbui_ElytronSubsystemView(mbuiContext);
}
@MbuiElement("elytron-global-settings-form") Form<ModelNode> form;
ElytronSubsystemView(final MbuiContext mbuiContext) {
super(mbuiContext);
}
@Override
public void update(final ModelNode modelNode) {
form.view(modelNode);
}
}
| hpehl/hal.next | app/src/main/java/org/jboss/hal/client/configuration/subsystem/elytron/ElytronSubsystemView.java | Java | apache-2.0 | 1,555 | [
30522,
1013,
1008,
1008,
9385,
2325,
1011,
2355,
2417,
6045,
1010,
4297,
1010,
1998,
3265,
16884,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include <bits/stdc++.h>
using namespace std;
int n,m;
int r;
int main()
{
scanf("%d %d",&n,&m);
while(n>0)
{
n--;
r++;
if(r%m==0)
n++;
}
printf("%d",r);
return 0;
} | orlandoisay/Competitive-programming-solutions | Codeforces/460A.cpp | C++ | gpl-2.0 | 253 | [
30522,
1001,
2421,
1026,
9017,
1013,
2358,
16409,
1009,
1009,
1012,
1044,
1028,
2478,
3415,
15327,
2358,
2094,
1025,
20014,
1050,
1010,
1049,
1025,
20014,
1054,
1025,
20014,
2364,
1006,
1007,
1063,
13594,
2546,
1006,
1000,
1003,
1040,
1003,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.java.group34;
import java.util.ArrayList;
/**
* Created by dell-pc on 2017/9/11.
*/
public class NewsPictures {
private Value[] value;
private static class Value
{
String contentUrl;
}
public ArrayList<String> getFirstNthPictures(int n)
{
ArrayList<String> ans=new ArrayList<String>();
System.out.println(value.length);
for(int i=0;i<n&&i<value.length;++i)
ans.add(value[i].contentUrl);
return ans;
}
}
| bennyguo/AssemblyNews | app/src/main/java/com/java/group34/NewsPictures.java | Java | mit | 500 | [
30522,
7427,
4012,
1012,
9262,
1012,
2177,
22022,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
9140,
9863,
1025,
1013,
1008,
1008,
1008,
2580,
2011,
12418,
1011,
7473,
2006,
2418,
1013,
1023,
30524,
2797,
10763,
2465,
3643,
1063,
5164,
4180,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright 2014 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package models
import (
"bufio"
"bytes"
"fmt"
"html"
"html/template"
"io"
"io/ioutil"
"os"
"os/exec"
"strings"
"github.com/Unknwon/com"
"github.com/sergi/go-diff/diffmatchpatch"
"golang.org/x/net/html/charset"
"golang.org/x/text/transform"
"github.com/gogits/git-module"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/process"
)
type DiffLineType uint8
const (
DIFF_LINE_PLAIN DiffLineType = iota + 1
DIFF_LINE_ADD
DIFF_LINE_DEL
DIFF_LINE_SECTION
)
type DiffFileType uint8
const (
DIFF_FILE_ADD DiffFileType = iota + 1
DIFF_FILE_CHANGE
DIFF_FILE_DEL
DIFF_FILE_RENAME
)
type DiffLine struct {
LeftIdx int
RightIdx int
Type DiffLineType
Content string
}
func (d *DiffLine) GetType() int {
return int(d.Type)
}
type DiffSection struct {
Name string
Lines []*DiffLine
}
var (
addedCodePrefix = []byte("<span class=\"added-code\">")
removedCodePrefix = []byte("<span class=\"removed-code\">")
codeTagSuffix = []byte("</span>")
)
func diffToHTML(diffs []diffmatchpatch.Diff, lineType DiffLineType) template.HTML {
var buf bytes.Buffer
for i := range diffs {
if diffs[i].Type == diffmatchpatch.DiffInsert && lineType == DIFF_LINE_ADD {
buf.Write(addedCodePrefix)
buf.WriteString(html.EscapeString(diffs[i].Text))
buf.Write(codeTagSuffix)
} else if diffs[i].Type == diffmatchpatch.DiffDelete && lineType == DIFF_LINE_DEL {
buf.Write(removedCodePrefix)
buf.WriteString(html.EscapeString(diffs[i].Text))
buf.Write(codeTagSuffix)
} else if diffs[i].Type == diffmatchpatch.DiffEqual {
buf.WriteString(html.EscapeString(diffs[i].Text))
}
}
return template.HTML(buf.Bytes())
}
// get an specific line by type (add or del) and file line number
func (diffSection *DiffSection) GetLine(lineType DiffLineType, idx int) *DiffLine {
difference := 0
for _, diffLine := range diffSection.Lines {
if diffLine.Type == DIFF_LINE_PLAIN {
// get the difference of line numbers between ADD and DEL versions
difference = diffLine.RightIdx - diffLine.LeftIdx
continue
}
if lineType == DIFF_LINE_DEL {
if diffLine.RightIdx == 0 && diffLine.LeftIdx == idx-difference {
return diffLine
}
} else if lineType == DIFF_LINE_ADD {
if diffLine.LeftIdx == 0 && diffLine.RightIdx == idx+difference {
return diffLine
}
}
}
return nil
}
// computes inline diff for the given line
func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine) template.HTML {
var compareDiffLine *DiffLine
var diff1, diff2 string
getDefaultReturn := func() template.HTML {
return template.HTML(html.EscapeString(diffLine.Content[1:]))
}
// just compute diff for adds and removes
if diffLine.Type != DIFF_LINE_ADD && diffLine.Type != DIFF_LINE_DEL {
return getDefaultReturn()
}
// try to find equivalent diff line. ignore, otherwise
if diffLine.Type == DIFF_LINE_ADD {
compareDiffLine = diffSection.GetLine(DIFF_LINE_DEL, diffLine.RightIdx)
if compareDiffLine == nil {
return getDefaultReturn()
}
diff1 = compareDiffLine.Content
diff2 = diffLine.Content
} else {
compareDiffLine = diffSection.GetLine(DIFF_LINE_ADD, diffLine.LeftIdx)
if compareDiffLine == nil {
return getDefaultReturn()
}
diff1 = diffLine.Content
diff2 = compareDiffLine.Content
}
dmp := diffmatchpatch.New()
diffRecord := dmp.DiffMain(diff1[1:], diff2[1:], true)
diffRecord = dmp.DiffCleanupSemantic(diffRecord)
return diffToHTML(diffRecord, diffLine.Type)
}
type DiffFile struct {
Name string
OldName string
Index int
Addition, Deletion int
Type DiffFileType
IsCreated bool
IsDeleted bool
IsBin bool
IsRenamed bool
Sections []*DiffSection
}
func (diffFile *DiffFile) GetType() int {
return int(diffFile.Type)
}
type Diff struct {
TotalAddition, TotalDeletion int
Files []*DiffFile
}
func (diff *Diff) NumFiles() int {
return len(diff.Files)
}
const DIFF_HEAD = "diff --git "
func ParsePatch(maxlines int, reader io.Reader) (*Diff, error) {
var (
diff = &Diff{Files: make([]*DiffFile, 0)}
curFile *DiffFile
curSection = &DiffSection{
Lines: make([]*DiffLine, 0, 10),
}
leftLine, rightLine int
lineCount int
)
input := bufio.NewReader(reader)
isEOF := false
for {
if isEOF {
break
}
line, err := input.ReadString('\n')
if err != nil {
if err == io.EOF {
isEOF = true
} else {
return nil, fmt.Errorf("ReadString: %v", err)
}
}
if len(line) > 0 && line[len(line)-1] == '\n' {
// Remove line break.
line = line[:len(line)-1]
}
if strings.HasPrefix(line, "+++ ") || strings.HasPrefix(line, "--- ") {
continue
} else if len(line) == 0 {
continue
}
lineCount++
// Diff data too large, we only show the first about maxlines lines
if lineCount >= maxlines {
log.Warn("Diff data too large")
io.Copy(ioutil.Discard, reader)
diff.Files = nil
return diff, nil
}
switch {
case line[0] == ' ':
diffLine := &DiffLine{Type: DIFF_LINE_PLAIN, Content: line, LeftIdx: leftLine, RightIdx: rightLine}
leftLine++
rightLine++
curSection.Lines = append(curSection.Lines, diffLine)
continue
case line[0] == '@':
curSection = &DiffSection{}
curFile.Sections = append(curFile.Sections, curSection)
ss := strings.Split(line, "@@")
diffLine := &DiffLine{Type: DIFF_LINE_SECTION, Content: line}
curSection.Lines = append(curSection.Lines, diffLine)
// Parse line number.
ranges := strings.Split(ss[1][1:], " ")
leftLine, _ = com.StrTo(strings.Split(ranges[0], ",")[0][1:]).Int()
if len(ranges) > 1 {
rightLine, _ = com.StrTo(strings.Split(ranges[1], ",")[0]).Int()
} else {
log.Warn("Parse line number failed: %v", line)
rightLine = leftLine
}
continue
case line[0] == '+':
curFile.Addition++
diff.TotalAddition++
diffLine := &DiffLine{Type: DIFF_LINE_ADD, Content: line, RightIdx: rightLine}
rightLine++
curSection.Lines = append(curSection.Lines, diffLine)
continue
case line[0] == '-':
curFile.Deletion++
diff.TotalDeletion++
diffLine := &DiffLine{Type: DIFF_LINE_DEL, Content: line, LeftIdx: leftLine}
if leftLine > 0 {
leftLine++
}
curSection.Lines = append(curSection.Lines, diffLine)
case strings.HasPrefix(line, "Binary"):
curFile.IsBin = true
continue
}
// Get new file.
if strings.HasPrefix(line, DIFF_HEAD) {
middle := -1
// Note: In case file name is surrounded by double quotes (it happens only in git-shell).
// e.g. diff --git "a/xxx" "b/xxx"
hasQuote := line[len(DIFF_HEAD)] == '"'
if hasQuote {
middle = strings.Index(line, ` "b/`)
} else {
middle = strings.Index(line, " b/")
}
beg := len(DIFF_HEAD)
a := line[beg+2 : middle]
b := line[middle+3:]
if hasQuote {
a = string(git.UnescapeChars([]byte(a[1 : len(a)-1])))
b = string(git.UnescapeChars([]byte(b[1 : len(b)-1])))
}
curFile = &DiffFile{
Name: a,
Index: len(diff.Files) + 1,
Type: DIFF_FILE_CHANGE,
Sections: make([]*DiffSection, 0, 10),
}
diff.Files = append(diff.Files, curFile)
// Check file diff type.
for {
line, err := input.ReadString('\n')
if err != nil {
if err == io.EOF {
isEOF = true
} else {
return nil, fmt.Errorf("ReadString: %v", err)
}
}
switch {
case strings.HasPrefix(line, "new file"):
curFile.Type = DIFF_FILE_ADD
curFile.IsCreated = true
case strings.HasPrefix(line, "deleted"):
curFile.Type = DIFF_FILE_DEL
curFile.IsDeleted = true
case strings.HasPrefix(line, "index"):
curFile.Type = DIFF_FILE_CHANGE
case strings.HasPrefix(line, "similarity index 100%"):
curFile.Type = DIFF_FILE_RENAME
curFile.IsRenamed = true
curFile.OldName = curFile.Name
curFile.Name = b
}
if curFile.Type > 0 {
break
}
}
}
}
// FIXME: detect encoding while parsing.
var buf bytes.Buffer
for _, f := range diff.Files {
buf.Reset()
for _, sec := range f.Sections {
for _, l := range sec.Lines {
buf.WriteString(l.Content)
buf.WriteString("\n")
}
}
charsetLabel, err := base.DetectEncoding(buf.Bytes())
if charsetLabel != "UTF-8" && err == nil {
encoding, _ := charset.Lookup(charsetLabel)
if encoding != nil {
d := encoding.NewDecoder()
for _, sec := range f.Sections {
for _, l := range sec.Lines {
if c, _, err := transform.String(d, l.Content); err == nil {
l.Content = c
}
}
}
}
}
}
return diff, nil
}
func GetDiffRange(repoPath, beforeCommitID string, afterCommitID string, maxlines int) (*Diff, error) {
repo, err := git.OpenRepository(repoPath)
if err != nil {
return nil, err
}
commit, err := repo.GetCommit(afterCommitID)
if err != nil {
return nil, err
}
var cmd *exec.Cmd
// if "after" commit given
if len(beforeCommitID) == 0 {
// First commit of repository.
if commit.ParentCount() == 0 {
cmd = exec.Command("git", "show", afterCommitID)
} else {
c, _ := commit.Parent(0)
cmd = exec.Command("git", "diff", "-M", c.ID.String(), afterCommitID)
}
} else {
cmd = exec.Command("git", "diff", "-M", beforeCommitID, afterCommitID)
}
cmd.Dir = repoPath
cmd.Stderr = os.Stderr
stdout, err := cmd.StdoutPipe()
if err != nil {
return nil, fmt.Errorf("StdoutPipe: %v", err)
}
if err = cmd.Start(); err != nil {
return nil, fmt.Errorf("Start: %v", err)
}
pid := process.Add(fmt.Sprintf("GetDiffRange (%s)", repoPath), cmd)
defer process.Remove(pid)
diff, err := ParsePatch(maxlines, stdout)
if err != nil {
return nil, fmt.Errorf("ParsePatch: %v", err)
}
if err = cmd.Wait(); err != nil {
return nil, fmt.Errorf("Wait: %v", err)
}
return diff, nil
}
func GetDiffCommit(repoPath, commitId string, maxlines int) (*Diff, error) {
return GetDiffRange(repoPath, "", commitId, maxlines)
}
| svcavallar/gogs | models/git_diff.go | GO | mit | 10,244 | [
30522,
1013,
1013,
9385,
2297,
1996,
2175,
5620,
6048,
1012,
2035,
2916,
9235,
1012,
1013,
1013,
2224,
1997,
2023,
3120,
3642,
2003,
9950,
2011,
1037,
10210,
1011,
2806,
1013,
1013,
6105,
2008,
2064,
2022,
2179,
1999,
1996,
6105,
5371,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta charset="utf-8">
<title>Phing API Documentation » \DataTypeHandler</title>
<meta name="author" content="Mike van Riel">
<meta name="description" content="">
<link href="../css/template.css" rel="stylesheet" media="all">
<script src="../js/jquery-1.7.1.min.js" type="text/javascript"></script><script src="../js/jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script><script src="../js/jquery.mousewheel.min.js" type="text/javascript"></script><script src="../js/bootstrap.js" type="text/javascript"></script><script src="../js/template.js" type="text/javascript"></script><script src="../js/prettify/prettify.min.js" type="text/javascript"></script><link rel="shortcut icon" href="../img/favicon.ico">
<link rel="apple-touch-icon" href="../img/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="../img/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="../img/apple-touch-icon-114x114.png">
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner"><div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></a><a class="brand" href="../index.html">Phing API Documentation</a><div class="nav-collapse"><ul class="nav">
<li class="dropdown">
<a href="#api" class="dropdown-toggle" data-toggle="dropdown">
API Documentation <b class="caret"></b></a><ul class="dropdown-menu">
<li><a>Packages</a></li>
<li><a href="../packages/Default.html"><i class="icon-folder-open"></i> Default</a></li>
<li><a href="../packages/JSMin.html"><i class="icon-folder-open"></i> JSMin</a></li>
<li><a href="../packages/Parallel.html"><i class="icon-folder-open"></i> Parallel</a></li>
<li><a href="../packages/Phing.html"><i class="icon-folder-open"></i> Phing</a></li>
<li><a href="../packages/phing.html"><i class="icon-folder-open"></i> phing</a></li>
</ul>
</li>
<li class="dropdown" id="charts-menu">
<a href="#charts" class="dropdown-toggle" data-toggle="dropdown">
Charts <b class="caret"></b></a><ul class="dropdown-menu"><li><a href="../graph_class.html"><i class="icon-list-alt"></i> Class hierarchy diagram</a></li></ul>
</li>
<li class="dropdown" id="reports-menu">
<a href="#reports" class="dropdown-toggle" data-toggle="dropdown">
Reports <b class="caret"></b></a><ul class="dropdown-menu">
<li><a href="../errors.html"><i class="icon-remove-sign"></i> Errors
<span class="label label-info">2573</span></a></li>
<li><a href="../markers.html"><i class="icon-map-marker"></i> Markers
<ul>
<li>todo
<span class="label label-info">15</span>
</li>
<li>fixme
<span class="label label-info">8</span>
</li>
</ul></a></li>
<li><a href="../deprecated.html"><i class="icon-stop"></i> Deprecated elements
<span class="label label-info">11</span></a></li>
</ul>
</li>
</ul></div>
</div></div>
<div class="go_to_top"><a href="#___" style="color: inherit">Back to top <i class="icon-upload icon-white"></i></a></div>
</div>
<div id="___" class="container">
<noscript><div class="alert alert-warning">
Javascript is disabled; several features are only available
if Javascript is enabled.
</div></noscript>
<div class="row">
<div class="span4">
<span class="btn-group visibility" data-toggle="buttons-checkbox"><button class="btn public active" title="Show public elements">Public</button><button class="btn protected" title="Show protected elements">Protected</button><button class="btn private" title="Show private elements">Private</button><button class="btn inherited active" title="Show inherited elements">Inherited</button></span><div class="btn-group view pull-right" data-toggle="buttons-radio">
<button class="btn details" title="Show descriptions and method names"><i class="icon-list"></i></button><button class="btn simple" title="Show only method names"><i class="icon-align-justify"></i></button>
</div>
<ul class="side-nav nav nav-list">
<li class="nav-header">
<i class="icon-custom icon-method"></i> Methods
<ul>
<li class="method public "><a href="#method___construct" title="__construct :: Constructs a new DataTypeHandler and sets up everything."><span class="description">Constructs a new DataTypeHandler and sets up everything.</span><pre>__construct()</pre></a></li>
<li class="method public "><a href="#method_characters" title="characters :: Handles character data."><span class="description">Handles character data.</span><pre>characters()</pre></a></li>
<li class="method public "><a href="#method_endElement" title="endElement :: Overrides endElement for data types."><span class="description">Overrides endElement for data types.</span><pre>endElement()</pre></a></li>
<li class="method public "><a href="#method_init" title="init :: Executes initialization actions required to setup the data structures
related to the tag."><span class="description">Executes initialization actions required to setup the data structures
related to the tag.</span><pre>init()</pre></a></li>
<li class="method public "><a href="#method_startElement" title="startElement :: Checks for nested tags within the current one."><span class="description">Checks for nested tags within the current one.</span><pre>startElement()</pre></a></li>
</ul>
</li>
<li class="nav-header protected">» Protected
<ul><li class="method protected inherited"><a href="#method_finished" title="finished :: Gets invoked when element closes method."><span class="description">Gets invoked when element closes method.</span><pre>finished()</pre></a></li></ul>
</li>
<li class="nav-header">
<i class="icon-custom icon-property"></i> Properties
<ul>
<li class="property public inherited"><a href="#property_parentHandler" title="$parentHandler :: "><span class="description"></span><pre>$parentHandler</pre></a></li>
<li class="property public inherited"><a href="#property_parser" title="$parser :: "><span class="description"></span><pre>$parser</pre></a></li>
</ul>
</li>
<li class="nav-header private">» Private
<ul>
<li class="property private "><a href="#property_element" title="$element :: "><span class="description"></span><pre>$element</pre></a></li>
<li class="property private "><a href="#property_target" title="$target :: "><span class="description"></span><pre>$target</pre></a></li>
<li class="property private "><a href="#property_wrapper" title="$wrapper :: "><span class="description"></span><pre>$wrapper</pre></a></li>
</ul>
</li>
</ul>
</div>
<div class="span8">
<a id="\DataTypeHandler"></a><ul class="breadcrumb">
<li>
<a href="../index.html"><i class="icon-custom icon-class"></i></a><span class="divider">\</span>
</li>
<li><a href="../namespaces/global.html">global</a></li>
<li class="active">
<span class="divider">\</span><a href="../classes/DataTypeHandler.html">DataTypeHandler</a>
</li>
</ul>
<div class="element class">
<p class="short_description">Configures a Project (complete with Targets and Tasks) based on
a XML build file.</p>
<div class="details">
<div class="long_description"><p><</p>
<p>p>
Design/ZE2 migration note:
If PHP would support nested classes. All the phing/parser/*Filter
classes would be nested within this class</p></div>
<table class="table table-bordered">
<tr>
<th>author</th>
<td><a href="mailto:andi@binarycloud.com">Andreas Aderhold</a></td>
</tr>
<tr>
<th>copyright</th>
<td>2001,2002 THYRELL. All rights reserved</td>
</tr>
<tr>
<th>version</th>
<td>$Id$</td>
</tr>
<tr>
<th>access</th>
<td>public</td>
</tr>
<tr>
<th>package</th>
<td><a href="../packages/phing.parser.html">phing.parser</a></td>
</tr>
</table>
<h3>
<i class="icon-custom icon-method"></i> Methods</h3>
<a id="method___construct"></a><div class="element clickable method public method___construct" data-toggle="collapse" data-target=".method___construct .collapse">
<h2>Constructs a new DataTypeHandler and sets up everything.</h2>
<pre>__construct(\AbstractSAXParser $parser, \AbstractHandler $parentHandler, \ProjectConfigurator $configurator, <a href="../classes/Target.html">\Target</a> $target) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"><p>The constructor must be called by all derived classes.</p></div>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$parser</h4>
<code><a href="../classes/AbstractSAXParser.html">\AbstractSAXParser</a></code><p>The XML parser (default: ExpatParser)</p>
</div>
<div class="subelement argument">
<h4>$parentHandler</h4>
<code><a href="../classes/AbstractHandler.html">\AbstractHandler</a></code><p>The parent handler that invoked this handler.</p></div>
<div class="subelement argument">
<h4>$configurator</h4>
<code><a href="../classes/ProjectConfigurator.html">\ProjectConfigurator</a></code><p>The ProjectConfigurator object</p></div>
<div class="subelement argument">
<h4>$target</h4>
<code><a href="../classes/Target.html">\Target</a></code><p>The target object this datatype is contained in (null for top-level datatypes).</p>
</div>
</div></div>
</div>
<a id="method_characters"></a><div class="element clickable method public method_characters" data-toggle="collapse" data-target=".method_characters .collapse">
<h2>Handles character data.</h2>
<pre>characters(string $data) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<table class="table table-bordered"><tr>
<th>access</th>
<td>public</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$data</h4>
<code>string</code><p>the CDATA that comes in</p></div>
</div></div>
</div>
<a id="method_endElement"></a><div class="element clickable method public method_endElement" data-toggle="collapse" data-target=".method_endElement .collapse">
<h2>Overrides endElement for data types.</h2>
<pre>endElement(string $name) : void</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"><p>Tells the type
handler that processing the element had been finished so
handlers know they can perform actions that need to be
based on the data contained within the element.</p></div>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$name</h4>
<code>string</code><p>the name of the XML element</p></div>
</div></div>
</div>
<a id="method_init"></a><div class="element clickable method public method_init" data-toggle="collapse" data-target=".method_init .collapse">
<h2>Executes initialization actions required to setup the data structures
related to the tag.</h2>
<pre>init(string $propType, array $attrs) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"><p><</p>
<p>p>
This includes:</p>
<ul>
<li>creation of the datatype object</li>
<li>calling the setters for attributes</li>
<li>adding the type to the target object if any</li>
<li>adding a reference to the task (if id attribute is given)</li>
</ul></div>
<table class="table table-bordered"><tr>
<th>access</th>
<td>public</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$propType</h4>
<code>string</code><p>the tag that comes in</p></div>
<div class="subelement argument">
<h4>$attrs</h4>
<code>array</code><p>attributes the tag carries</p></div>
<h3>Exceptions</h3>
<table class="table table-bordered"><tr>
<th><code><a href="../classes/ExpatParseException.html">\ExpatParseException</a></code></th>
<td>if attributes are incomplete or invalid</td>
</tr></table>
</div></div>
</div>
<a id="method_startElement"></a><div class="element clickable method public method_startElement" data-toggle="collapse" data-target=".method_startElement .collapse">
<h2>Checks for nested tags within the current one.</h2>
<pre>startElement(string $name, array $attrs) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"><p>Creates and calls
handlers respectively.</p></div>
<table class="table table-bordered"><tr>
<th>access</th>
<td>public</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$name</h4>
<code>string</code><p>the tag that comes in</p></div>
<div class="subelement argument">
<h4>$attrs</h4>
<code>array</code><p>attributes the tag carries</p></div>
</div></div>
</div>
<a id="method_finished"></a><div class="element clickable method protected method_finished" data-toggle="collapse" data-target=".method_finished .collapse">
<h2>Gets invoked when element closes method.</h2>
<pre>finished() </pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\AbstractHandler::finished()</td>
</tr></table>
</div></div>
</div>
<h3>
<i class="icon-custom icon-property"></i> Properties</h3>
<a id="property_parentHandler"> </a><div class="element clickable property public property_parentHandler" data-toggle="collapse" data-target=".property_parentHandler .collapse">
<h2></h2>
<pre>$parentHandler </pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\AbstractHandler::$$parentHandler</td>
</tr></table>
</div></div>
</div>
<a id="property_parser"> </a><div class="element clickable property public property_parser" data-toggle="collapse" data-target=".property_parser .collapse">
<h2></h2>
<pre>$parser </pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\AbstractHandler::$$parser</td>
</tr></table>
</div></div>
</div>
<a id="property_element"> </a><div class="element clickable property private property_element" data-toggle="collapse" data-target=".property_element .collapse">
<h2></h2>
<pre>$element </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"></div></div></div>
</div>
<a id="property_target"> </a><div class="element clickable property private property_target" data-toggle="collapse" data-target=".property_target .collapse">
<h2></h2>
<pre>$target </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"></div></div></div>
</div>
<a id="property_wrapper"> </a><div class="element clickable property private property_wrapper" data-toggle="collapse" data-target=".property_wrapper .collapse">
<h2></h2>
<pre>$wrapper </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"></div></div></div>
</div>
</div>
</div>
</div>
</div>
<div class="row"><footer class="span12">
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a11</a> and<br>
generated on 2012-11-20T07:50:45+01:00.<br></footer></div>
</div>
</body>
</html>
| theghostbel/pimcore | pimcore/lib/Deployment/Phing/docs/api/docs/classes/DataTypeHandler.html | HTML | bsd-3-clause | 15,955 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
1000,
4180,
1011,
2828,
1000,
4180,
1027,
1000,
3793,
1013,
16129,
1025,
25869... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{blockmyaccountfooter}default-bootstrap>blockmyaccountfooter_b97d23f7cde011d190f39468e146425e'] = 'Bloque Mi cuenta en el pie de página';
$_MODULE['<{blockmyaccountfooter}default-bootstrap>blockmyaccountfooter_abdb95361b4c92488add0a5a37afabcb'] = 'Muestra un bloque con enlaces relativos a la cuenta de usuario';
$_MODULE['<{blockmyaccountfooter}default-bootstrap>blockmyaccountfooter_ae9ec80afffec5a455fbf2361a06168a'] = 'Administrar mi cuenta de cliente';
$_MODULE['<{blockmyaccountfooter}default-bootstrap>blockmyaccountfooter_d95cf4ab2cbf1dfb63f066b50558b07d'] = 'Mi cuenta';
$_MODULE['<{blockmyaccountfooter}default-bootstrap>blockmyaccountfooter_74ecd9234b2a42ca13e775193f391833'] = 'Mis compras';
$_MODULE['<{blockmyaccountfooter}default-bootstrap>blockmyaccountfooter_5973e925605a501b18e48280f04f0347'] = 'Mis devoluciones';
$_MODULE['<{blockmyaccountfooter}default-bootstrap>blockmyaccountfooter_89080f0eedbd5491a93157930f1e45fc'] = 'Mis devoluciones';
$_MODULE['<{blockmyaccountfooter}default-bootstrap>blockmyaccountfooter_9132bc7bac91dd4e1c453d4e96edf219'] = 'Mis vales descuento';
$_MODULE['<{blockmyaccountfooter}default-bootstrap>blockmyaccountfooter_e45be0a0d4a0b62b15694c1a631e6e62'] = 'Mis direcciones';
$_MODULE['<{blockmyaccountfooter}default-bootstrap>blockmyaccountfooter_b4b80a59559e84e8497f746aac634674'] = 'Administrar mi información personal';
$_MODULE['<{blockmyaccountfooter}default-bootstrap>blockmyaccountfooter_63b1ba91576576e6cf2da6fab7617e58'] = 'Mis datos personales';
$_MODULE['<{blockmyaccountfooter}default-bootstrap>blockmyaccountfooter_95d2137c196c7f84df5753ed78f18332'] = 'Mis vales';
$_MODULE['<{blockmyaccountfooter}default-bootstrap>blockmyaccountfooter_c87aacf5673fada1108c9f809d354311'] = 'Cerrar sesión';
| lfelipeqn/serta | themes/default-bootstrap/modules/blockmyaccountfooter/translations/es.php | PHP | gpl-3.0 | 1,809 | [
30522,
1026,
1029,
25718,
3795,
1002,
1035,
11336,
1025,
1002,
1035,
11336,
1027,
9140,
1006,
1007,
1025,
1002,
1035,
11336,
1031,
1005,
1026,
1063,
3796,
8029,
6305,
3597,
16671,
13064,
2121,
1065,
12398,
1011,
6879,
6494,
2361,
1028,
3796... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.client;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
/**
* Created by wanjian on 2017/4/5.
*/
public class Install {
public static void main(String[] args) {
install();
}
public static void install() {
adbCommond("push Main.dex /sdcard/Main.dex");
String path = "export CLASSPATH=/sdcard/Main.dex";
String app = "exec app_process /sdcard com.wanjian.puppet.Main";
shellCommond(new String[]{path, app});
}
private static void adbCommond(String com) {
System.out.println("adbCommond...."+com);
commond("sh", "./adb " + com);
}
private static void shellCommond(String[] com) {
System.out.println("shell commond..."+ Arrays.toString(com));
try {
Process process = Runtime
.getRuntime()
.exec("./adb shell "); // adb
// shell
final BufferedWriter outputStream = new BufferedWriter(
new OutputStreamWriter(process.getOutputStream()));
for (String s : com) {
outputStream.write(s);
outputStream.write("\n");
}
outputStream.flush();
System.out.println("shell write finished...");
readError(process.getErrorStream());
adbCommond("forward tcp:8888 localabstract:puppet-ver1");
readResult(process.getInputStream());
while (true) {
Thread.sleep(Integer.MAX_VALUE);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private static void readError(final InputStream errorStream) {
new Thread(){
@Override
public void run() {
super.run();
readResult(errorStream);
}
}.start();
}
///////////////
private static void commond(String c, String com) {
System.out.println("---> " + c + com);
try {
Process process = Runtime
.getRuntime()
.exec(c); // adb
final BufferedWriter outputStream = new BufferedWriter(
new OutputStreamWriter(process.getOutputStream()));
outputStream.write(com);
outputStream.write("\n");
outputStream.write("exit\n");
outputStream.flush();
int i = process.waitFor();
readResult(process.getInputStream());
System.out.println("------END-------");
} catch (Exception e) {
e.printStackTrace();
}
}
private static void readResult(final InputStream stream) {
System.out.println("read result.....");
try {
String line;
final BufferedReader reader = new BufferedReader(
new InputStreamReader(stream));
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
System.out.println("-------END------");
} catch (IOException e) {
e.printStackTrace();
try {
stream.close();
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
}
| dede12138/androidScreenShareAndControl | lib/src/main/java/com/client/Install.java | Java | mit | 3,466 | [
30522,
7427,
4012,
1012,
7396,
1025,
12324,
9262,
1012,
22834,
1012,
17698,
2098,
16416,
4063,
1025,
12324,
9262,
1012,
22834,
1012,
17698,
2098,
15994,
1025,
12324,
9262,
1012,
22834,
1012,
22834,
10288,
24422,
1025,
12324,
9262,
1012,
22834... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//
// IMUIMacros.h
// JLWeChat
//
// Created by jimneylee on 14-5-19.
// Copyright (c) 2014年 jimneylee. All rights reserved.
//
#ifndef JLWeChat_IMUIMacros_h
#define JLWeChat_IMUIMacros_h
// APP 主色调
#define APP_MAIN_COLOR RGBCOLOR(33.f, 40.f, 42.f)
// 搜索框激活时背景色
#define SEARCH_ACTIVE_BG_COLOR RGBCOLOR(201, 201, 206)
#define TABLEVIEW_GROUP_BG_COLOR RGBCOLOR(240, 239, 246)
// Cell布局
#define CELL_PADDING_10 10
#define CELL_PADDING_8 8
#define CELL_PADDING_6 6
#define CELL_PADDING_4 4
#define CELL_PADDING_2 2
// Screen Size
#define SCREEN_SIZE [UIScreen mainScreen].bounds.size
// Line Color
#define LINE_COLOR RGBCOLOR(240, 240, 240)
// 消息页面Cell固定高度
#define MESSAGE_MAIN_ROW_HEIGHT 68.f
// 通讯录页面Cell固定高度
#define ADDRESS_BOOK_ROW_HEIGHT 55.f
// group头部高度
#define GROUP_SECTION_HEADER_HEIGHT 20.f
#endif
| jimneylee/JLWeChat-iPhone | JLWeChat/Macros/IMUIMacros.h | C | mit | 891 | [
30522,
1013,
1013,
1013,
1013,
10047,
10179,
22911,
7352,
1012,
1044,
1013,
1013,
1046,
2140,
8545,
7507,
2102,
1013,
1013,
1013,
1013,
2580,
2011,
3958,
5420,
10559,
2006,
2403,
1011,
1019,
1011,
2539,
1012,
1013,
1013,
9385,
1006,
1039,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#ifndef AISTREAMS_UTIL_GRPC_STATUS_DELEGATE_H_
#define AISTREAMS_UTIL_GRPC_STATUS_DELEGATE_H_
#include "absl/strings/string_view.h"
#include "aistreams/port/status.h"
#include "grpcpp/grpcpp.h"
namespace aistreams {
namespace util {
// Creates a aistreams::Status from a grpc::Status.
aistreams::Status MakeStatusFromRpcStatus(grpc::Status const& status);
// Creates a aistreams::Status from a grpc::StatusCode and description.
aistreams::Status MakeStatusFromRpcStatus(grpc::StatusCode code,
absl::string_view message);
} // namespace util
} // namespace aistreams
#endif // AISTREAMS_UTIL_GRPC_STATUS_DELEGATE_H_
| google/aistreams | aistreams/util/grpc_status_delegate.h | C | apache-2.0 | 666 | [
30522,
1001,
2065,
13629,
2546,
9932,
21422,
2015,
1035,
21183,
4014,
1035,
24665,
15042,
1035,
3570,
1035,
11849,
1035,
1044,
1035,
1001,
9375,
9932,
21422,
2015,
1035,
21183,
4014,
1035,
24665,
15042,
1035,
3570,
1035,
11849,
1035,
1044,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
function startup()
print('Starting up...\n')
dofile('cat_toy.lua')
end
print('Use tmr.stop(1) to stop startup.\n')
tmr.alarm(0,5000,0,startup)
| lithboy/wiggletron3000 | init.lua | Lua | gpl-3.0 | 152 | [
30522,
3853,
22752,
1006,
1007,
6140,
1006,
1005,
3225,
2039,
1012,
1012,
1012,
1032,
1050,
1005,
1007,
2079,
8873,
2571,
1006,
1005,
4937,
1035,
9121,
1012,
11320,
2050,
1005,
1007,
2203,
6140,
1006,
1005,
2224,
1056,
2213,
2099,
1012,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* ----------------------------------------------------------------------------
* Copyright (c) 2012-2013, xSky <guozhw at gmail dot com>
* All rights reserved.
* Distributed under GPL license.
* ----------------------------------------------------------------------------
*/
#include <event.h>
#include "xBlog.h"
#include "xMysqlPool.h"
#include "xConfig.h"
#include "xBlogCache.h"
xBlog::xBlog()
{
memset(szDir, 0, sizeof(szDir));
#ifdef WIN32
WSADATA WSAData;
WSAStartup(0x101, &WSAData);
#else
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
{
log_error("void xBlog::xBlog() SIGPIPE error\n");;
}
#endif
}
xBlog::~xBlog()
{
}
bool xBlog::Init()
{
StartTime = time(NULL);
xBlogPageTemplate::GetInstance()->Init();
strncpy(szDir, Config::GetInstance()->strRootFullPath.c_str(),
Config::GetInstance()->strRootFullPath.length());
return true;
}
void xBlog::OnTimer()
{
//log_debug("void xBlog::OnTimer()\n");
xBlogCache::GetInstance()->OnTimer();
}
void xBlog::DebugHttpHeader(struct evhttp_request *req)
{
struct evkeyval *header;
struct evkeyvalq *headers;
headers = evhttp_request_get_input_headers(req);
for (header = headers->tqh_first; header; header = header->next.tqe_next)
{
log_debug("%s: %s\n", header->key, header->value);
}
}
const char *xBlog::DebugHttpGetCommand(struct evhttp_request *req)
{
const char *cmdtype;
switch (evhttp_request_get_command(req))
{
case EVHTTP_REQ_GET:
cmdtype = "GET";
break;
case EVHTTP_REQ_POST:
cmdtype = "POST";
break;
case EVHTTP_REQ_HEAD:
cmdtype = "HEAD";
break;
case EVHTTP_REQ_PUT:
cmdtype = "PUT";
break;
case EVHTTP_REQ_DELETE:
cmdtype = "DELETE";
break;
case EVHTTP_REQ_OPTIONS:
cmdtype = "OPTIONS";
break;
case EVHTTP_REQ_TRACE:
cmdtype = "TRACE";
break;
case EVHTTP_REQ_CONNECT:
cmdtype = "CONNECT";
break;
case EVHTTP_REQ_PATCH:
cmdtype = "PATCH";
break;
default:
cmdtype = "unknown";
break;
}
log_debug("Received a %s request for %s \n", cmdtype, evhttp_request_get_uri(req));
return cmdtype;
}
void xBlog::HttpParseURL(struct evhttp_request *req, struct evkeyvalq *evMyheader)
{
const char *xBlog_query;
xBlog_query = evhttp_uri_get_query(evhttp_request_get_evhttp_uri(req));
evhttp_parse_query_str(xBlog_query, evMyheader);
}
void xBlog::GetHttpPostData(struct evhttp_request *req, struct evkeyvalq *evdata)
{
evbuffer *pevBuf = evhttp_request_get_input_buffer(req);
int data_len = evbuffer_get_length(pevBuf);
char *pbuffer = (char *) malloc(data_len + 1);
memset(pbuffer, 0, data_len + 1);
evbuffer_copyout(pevBuf, pbuffer, data_len);
log_debug("%s\r\n", pbuffer);
evhttp_parse_query_str(pbuffer, evdata);
free(pbuffer);
}
void xBlog::SendHttpResphone(struct evhttp_request *req, const string & strData)
{
struct evbuffer *buf = evbuffer_new();
if (NULL==buf)
{
log_error("failed to create response buffer\r\n");
return;
}
evbuffer_add_printf(buf, "%s", strData.c_str());
evhttp_add_header(evhttp_request_get_output_headers(req),
"Content-Type", "text/html; charset=utf-8");
evhttp_send_reply(req, 200, "OK", buf);
evbuffer_free(buf);
}
int xBlog::BindSocket(const char *ip, uint16 port)
{
int skt;
skt = socket(AF_INET, SOCK_STREAM, 0);
if (skt < 0)
{
log_error("socket error, nfd=%d \r\n", skt);
return -1;
}
#ifdef _WIN32
int flag = 1;
ioctlsocket(skt, FIONBIO, (unsigned long *) &flag);
#else
/* set socket nonblocking */
int flags;
if ((flags = fcntl(skt, F_GETFL, NULL)) < 0 || fcntl(skt, F_SETFL, flags | O_NONBLOCK) == -1)
{
log_error("O_NONBLOCK error, skt=%d \r\n", skt);
return -1;
}
/* set socket closeonexec */
if ((flags = fcntl(skt, F_GETFD, NULL)) < 0 || fcntl(skt, F_SETFD, flags | FD_CLOEXEC) == -1)
{
log_error("FD_CLOEXEC error, skt=%d \r\n", skt);
return -1;
}
#endif
int on = 1;
setsockopt(skt, SOL_SOCKET, SO_KEEPALIVE, (const char *) &on, sizeof(on));
setsockopt(skt, SOL_SOCKET, SO_REUSEADDR, (const char *) &on, sizeof(on));
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = inet_addr(ip);
addr.sin_port = htons(port);
if (bind(skt, (struct sockaddr *) &addr, sizeof(addr)) < 0)
{
log_error("bind %s %d error\r\n", ip, port);
return -1;
}
if (listen(skt, 128) < 0)
{
log_error("listen %s %d error\r\n", ip, port);
return -1;
}
return skt;
}
bool xBlog::Run(const char *ip, uint16 port, uint32 timeout_secs, uint32 nthreads)
{
int ret = -1;
int skt = BindSocket(ip, port);
if (skt < 0)
{
log_error("BindSocket %s %d error\r\n", ip, port);
return false;
}
#ifdef _WIN32
HANDLE ths[128];
for (uint32 i = 0; i < nthreads; i++)
{
struct event_base *base = event_base_new();
if (base == NULL)
{
return false;
}
struct evhttp *httpd = evhttp_new(base);
if (httpd == NULL)
{
return false;
}
ret = evhttp_accept_socket(httpd, skt);
if (r != 0)
{
return false;
}
SetRouteTable(httpd);
ths[i] = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE) xBlog::Dispatch, base, NULL, NULL);
log_info("%d %d \r\n", i, ths[i]);
if (ret != 0)
{
return false;
}
}
#else
pthread_t ths[128];
for (uint32 i = 0; i < nthreads; i++)
{
struct event_base *base = event_base_new();
if (base == NULL)
{
return false;
}
struct evhttp *httpd = evhttp_new(base);
if (httpd == NULL)
{
return false;
}
ret = evhttp_accept_socket(httpd, skt);
if (ret != 0)
{
return false;
}
SetRouteTable(httpd);
ret = pthread_create(&ths[i], NULL, xBlog::Dispatch, base);
log_info("%d %d \r\n", i, ths[i]);
if (ret != 0)
{
return false;
}
}
/*
for (int i = 0; i < nthreads; i++)
{
pthread_join(ths[i], NULL);
}
*/
#endif
return true;
}
void *xBlog::Dispatch(void *arg)
{
if (NULL==arg)
{
log_error("error arg is null\n");
return NULL;
}
event_base_dispatch((struct event_base *) arg);
return NULL;
}
void xBlog::SetRouteTable(evhttp * http)
{
evhttp_set_cb(http, "/download", xBlogPage::DownloadCallback, this); // 测试
evhttp_set_cb(http, "/post", xBlogPage::PostRequestCallback, this); // 请求文章
evhttp_set_cb(http, "/guestbook", xBlogPage::GuestbookCallback, this); // 查看-留言
evhttp_set_cb(http, "/postmessage", xBlogPage::GuestPostCallback, this); // 添加-评论留言
evhttp_set_cb(http, "/catalog", xBlogPage::CatalogRequestCallback, this); // 分类
evhttp_set_cb(http, "/", xBlogPage::IndexRequestCallback, this); // 首页
evhttp_set_cb(http, "/page", xBlogPage::PageRequestCallback, this); // 页面
// 管理后台功能
evhttp_set_cb(http, "/admin", xBlogPage::AdminCallback, this); // 管理后台
evhttp_set_cb(http, "/checklogin", xBlogPage::AdminCheckLoginCallback, this); // 权限验证
evhttp_set_cb(http, "/shell", xBlogPage::AdminShellCallback, this); // 测试
evhttp_set_cb(http, "/status", xBlogPage::AdminStatusCallback, this); // 测试
evhttp_set_cb(http, "/postmanager", xBlogPage::AdminPostManagerCallback, this); // 文章管理
evhttp_set_cb(http, "/siteconfig", xBlogPage::AdminSiteConfigCallback, this); // 网站配置参数管理
evhttp_set_cb(http, "/links", xBlogPage::AdminLinksCallback, this); // 链接管理
evhttp_set_cb(http, "/catalogset", xBlogPage::AdminCatalogCallback, this); // 链接管理
evhttp_set_cb(http, "/comments", xBlogPage::AdminCommentsCallback, this); // 留言评论管理
evhttp_set_cb(http, "/system", xBlogPage::AdminSystemCallback, this); // 系统配置
evhttp_set_cb(http, "/user", xBlogPage::AdminUserCallback, this); // 系统配置
evhttp_set_timeout(http, Config::GetInstance()->xBlogAppConfig.HttpdTimeOut);
evhttp_set_gencb(http, xBlogPage::SendDocumentCallback, this);
}
void xBlog::StartMysqlPool()
{
xBlogData::GetInstance()->pMysqlPool = MysqlPool::GetInstance();
xBlogData::GetInstance()->pMysqlPool->Init(Config::GetInstance()->xBlogMysqlcfg.ipaddr.c_str(),
Config::GetInstance()->xBlogMysqlcfg.username.c_str(),
Config::GetInstance()->xBlogMysqlcfg.passwd.c_str(),
Config::GetInstance()->xBlogMysqlcfg.dbname.c_str());
xBlogData::GetInstance()->pMysqlPool->ConnectDB(Config::GetInstance()->xBlogMysqlcfg.poolsize);
bool bRet = Config::GetInstance()->LoadxBlogSiteConfig();
if (!bRet)
{
log_error("xBlog::StartMysqlPool() site config error, exit\r\n");
exit(0);
}
}
| caibaibai/xblog | xBlog.cpp | C++ | gpl-2.0 | 10,012 | [
30522,
1013,
1008,
1008,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
## [Unreleased]
## [0.4.3] - 2016-02-22
### Fixed
- metrics-es-heap.rb: Assignment of node from the stats variable happened before stats was assigned. Moved node assignment to be after stats assignment.
## [0.4.2] - 2016-01-27
### Added
- metrics-es-cluster.rb: Added i/o cluster stats
## [0.4.1] - 2016-01-26
### Fixed
- metrics-es-cluster.rb: Allow metrics to be gathered even if the cluster has zero documents. Also updated cache name for Elasticsearch 2.0+
- metrics-es-node-graphite.rb: Update node stats for Elasticsearch 2.0+
## [0.4.0] - 2016-01-22
### Added
- metrics-es-node-graphite.rb: Added file system and cpu stats
- metrics-es-cluster.rb: Added cluster metrics including optional percolator metrics, allocation status, and option to run on non-master nodes
## [0.3.2] - 2015-12-29
### Changed
- Update metrics-es-node.rb for Elasticsearch 2.0
## [0.3.1] - 2015-12-29
### Changed
- Update metrics-es-node.rb to use version checks consistent with other metrics
- Update metrics-es-cluster.rb to use `_stats` api instead of `/_count?q=*:*` see [Unbound wildcard range query cripples es on larger installs #20](https://github.com/sensu-plugins/sensu-plugins-elasticsearch/issues/20)
## [0.3.0] - 2015-11-18
### Changed
- Update metrics-es-node-graphite.rb, check-es-node-status.rb, and check-es-file-descriptors.rb for Elasticsearch 2.0
- Update elasticsearch gem to 1.0.14
### Added
- Add check-es-circuit-breakers.rb, to alert when circuit breakers have been tripped
## [0.2.0] - 2015-10-15
### Changed
- cluster-status check: added a new `status_timeout` option that will use elasticsearch's [`wait_for_status` parameter](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html#request-params) and wait up to the given number of seconds for the cluster to be green. This pervents false alerting during normal elasticsearch operations.
## [0.1.2] - 2015-08-11
### Added
- add parameters for elasticsearch auth
## [0.1.1] - 2015-07-14
### Changed
- updated sensu-plugin gem to 1.2.0
## [0.1.0] - 2015-07-06
### Added
- `check-es-node-status` node status check
### Fixed
- uri resource path for `get_es_resource` method
### Changed
- `get_es_resource` URI path needs to start with `/`
- clean cruft from Rakefile
- put deps in alpha order in gemspec
- update documentation links in README and CONTRIBUTING
## [0.0.2] - 2015-06-02
### Fixed
- added binstubs
### Changed
- removed cruft from /lib
## 0.0.1 - 2015-05-21
### Added
- initial release
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.4.3...HEAD
[0.4.2]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.4.2...0.4.3
[0.4.2]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.4.1...0.4.2
[0.4.1]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.4.0...0.4.1
[0.4.0]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.3.2...0.4.0
[0.3.2]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.3.1...0.3.2
[0.3.1]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.3.0...0.3.1
[0.3.0]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.2.0...0.3.0
[0.2.0]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.1.2...0.2.0
[0.1.2]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.1.1...0.1.2
[0.1.1]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.1.0...0.1.1
[0.1.0]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.0.2...0.1.0
[0.0.2]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/0.0.1...0.0.2
| ministryofjustice/sensu-plugins-elasticsearch | CHANGELOG.md | Markdown | mit | 3,877 | [
30522,
1001,
2689,
8833,
2023,
2622,
25276,
2015,
2000,
1031,
21641,
2544,
2075,
1033,
1006,
8299,
1024,
1013,
1013,
7367,
2213,
6299,
1012,
8917,
1013,
1007,
1012,
2023,
2689,
21197,
4076,
1996,
4289,
3205,
2012,
1031,
2562,
1037,
2689,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
This file is auto-generated from the drm_pciids.txt in the DRM CVS
Please contact dri-devel@lists.sf.net to add new cards to this list
*/
#define radeon_PCI_IDS \
{0x1002, 0x3150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \
{0x1002, 0x3152, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x3154, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x3155, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x3E50, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \
{0x1002, 0x3E54, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|RADEON_IS_IGP}, \
{0x1002, 0x4137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP}, \
{0x1002, 0x4144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
{0x1002, 0x4145, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
{0x1002, 0x4146, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
{0x1002, 0x4147, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
{0x1002, 0x4148, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \
{0x1002, 0x4149, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \
{0x1002, 0x414A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \
{0x1002, 0x414B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \
{0x1002, 0x4150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \
{0x1002, 0x4151, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \
{0x1002, 0x4152, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \
{0x1002, 0x4153, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \
{0x1002, 0x4154, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \
{0x1002, 0x4155, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \
{0x1002, 0x4156, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \
{0x1002, 0x4237, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP}, \
{0x1002, 0x4242, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \
{0x1002, 0x4336, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \
{0x1002, 0x4337, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \
{0x1002, 0x4437, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \
{0x1002, 0x4966, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250}, \
{0x1002, 0x4967, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250}, \
{0x1002, 0x4A48, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4A49, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4A4A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4A4B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4A4C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4A4D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4A4E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4A4F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4A50, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4A54, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4B48, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4B49, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4B4A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4B4B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4B4C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \
{0x1002, 0x4C57, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV200|RADEON_IS_MOBILITY}, \
{0x1002, 0x4C58, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV200|RADEON_IS_MOBILITY}, \
{0x1002, 0x4C59, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100|RADEON_IS_MOBILITY}, \
{0x1002, 0x4C5A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100|RADEON_IS_MOBILITY}, \
{0x1002, 0x4C64, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \
{0x1002, 0x4C66, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \
{0x1002, 0x4C67, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \
{0x1002, 0x4E44, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
{0x1002, 0x4E45, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
{0x1002, 0x4E46, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
{0x1002, 0x4E47, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
{0x1002, 0x4E48, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \
{0x1002, 0x4E49, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \
{0x1002, 0x4E4A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \
{0x1002, 0x4E4B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \
{0x1002, 0x4E50, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|RADEON_IS_MOBILITY}, \
{0x1002, 0x4E51, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|RADEON_IS_MOBILITY}, \
{0x1002, 0x4E52, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|RADEON_IS_MOBILITY}, \
{0x1002, 0x4E53, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|RADEON_IS_MOBILITY}, \
{0x1002, 0x4E54, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|RADEON_IS_MOBILITY}, \
{0x1002, 0x4E56, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|RADEON_IS_MOBILITY}, \
{0x1002, 0x5144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|RADEON_SINGLE_CRTC}, \
{0x1002, 0x5145, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|RADEON_SINGLE_CRTC}, \
{0x1002, 0x5146, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|RADEON_SINGLE_CRTC}, \
{0x1002, 0x5147, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|RADEON_SINGLE_CRTC}, \
{0x1002, 0x5148, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \
{0x1002, 0x514C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \
{0x1002, 0x514D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \
{0x1002, 0x5157, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV200}, \
{0x1002, 0x5158, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV200}, \
{0x1002, 0x5159, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100}, \
{0x1002, 0x515A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100}, \
{0x1002, 0x515E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100|RADEON_SINGLE_CRTC}, \
{0x1002, 0x5460, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \
{0x1002, 0x5462, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \
{0x1002, 0x5464, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \
{0x1002, 0x5548, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5549, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x554A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x554B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x554C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x554D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x554E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x554F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5550, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5551, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5552, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5554, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x564A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x564B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x564F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5652, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5657, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP}, \
{0x1002, 0x5835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \
{0x1002, 0x5954, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
{0x1002, 0x5955, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
{0x1002, 0x5974, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
{0x1002, 0x5975, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
{0x1002, 0x5960, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
{0x1002, 0x5961, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
{0x1002, 0x5962, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
{0x1002, 0x5964, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
{0x1002, 0x5965, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
{0x1002, 0x5969, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100|RADEON_SINGLE_CRTC}, \
{0x1002, 0x5a41, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_IGPGART}, \
{0x1002, 0x5a42, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
{0x1002, 0x5a61, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_IGPGART}, \
{0x1002, 0x5a62, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
{0x1002, 0x5b60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5b62, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5b63, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5b64, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5b65, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5c61, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280|RADEON_IS_MOBILITY}, \
{0x1002, 0x5c63, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280|RADEON_IS_MOBILITY}, \
{0x1002, 0x5d48, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5d49, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5d4a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5d4c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5d4d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5d4e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5d4f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5d50, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5d52, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5d57, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5e48, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5e4a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5e4b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5e4c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5e4d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \
{0x1002, 0x5e4f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6721, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6722, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6723, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6724, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6725, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6726, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6727, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6728, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6729, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6738, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6739, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x673e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6740, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6741, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6742, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6743, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6744, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6745, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6746, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6747, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6748, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6749, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6750, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6758, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6759, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6760, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6761, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6762, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6763, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6764, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6765, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6766, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6767, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6768, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6770, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6779, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6880, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6888, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6889, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x688A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x688C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x688D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6898, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6899, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x689b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x689c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HEMLOCK|RADEON_NEW_MEMMAP}, \
{0x1002, 0x689d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HEMLOCK|RADEON_NEW_MEMMAP}, \
{0x1002, 0x689e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68a0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68a1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68a8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68a9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68b8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68b9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68ba, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68be, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68bf, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68c1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68c7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68c8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68c9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68d9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68da, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68de, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68e0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68e1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68e4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68e5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68e8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68e9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68f1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68f2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68f8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68f9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \
{0x1002, 0x68fe, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
{0x1002, 0x710A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
{0x1002, 0x710B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
{0x1002, 0x710C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
{0x1002, 0x710E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
{0x1002, 0x710F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7140, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7141, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7142, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7143, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7145, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7146, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7147, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7149, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x714A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x714B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x714C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x714D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x714E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x714F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7151, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7152, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7153, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x715E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x715F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7180, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7181, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7183, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7186, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7187, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7188, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x718A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x718B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x718C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x718D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x718F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7193, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7196, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x719B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x719F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71C0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71C1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71C2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71C3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71C4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71C5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71C6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71C7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71CD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71CE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71D2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71D4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71D5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71D6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71DA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
{0x1002, 0x71DE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7210, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7243, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7244, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7245, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7246, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7247, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7248, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7249, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x724A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x724B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x724C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x724D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x724E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x724F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7280, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7281, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7283, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7284, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7287, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7289, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \
{0x1002, 0x728B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \
{0x1002, 0x728C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7290, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7291, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7293, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7297, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x791e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \
{0x1002, 0x791f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \
{0x1002, 0x793f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS600|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7941, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS600|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \
{0x1002, 0x7942, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS600|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \
{0x1002, 0x796c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \
{0x1002, 0x796d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \
{0x1002, 0x796e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \
{0x1002, 0x796f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \
{0x1002, 0x9400, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9401, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9402, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9403, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9405, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \
{0x1002, 0x940A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \
{0x1002, 0x940B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \
{0x1002, 0x940F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94A1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94A3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94B1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94B3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94B4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94B5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94B9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9440, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9441, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9442, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9443, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9444, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9446, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
{0x1002, 0x944A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x944B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x944C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
{0x1002, 0x944E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9450, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9452, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9456, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
{0x1002, 0x945A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x945B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x945E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9460, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9462, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
{0x1002, 0x946A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x946B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x947A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x947B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9480, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9487, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9488, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9489, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x948A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x948F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9490, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9491, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9495, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9498, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
{0x1002, 0x949C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
{0x1002, 0x949E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
{0x1002, 0x949F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94C0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94C1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94C3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94C4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94C5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94C6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94C7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94C8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94C9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94CB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94CC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \
{0x1002, 0x94CD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9500, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9501, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9504, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9505, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9506, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9507, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9508, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9509, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x950F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9511, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9515, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9517, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9519, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9540, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9541, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9542, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_NEW_MEMMAP}, \
{0x1002, 0x954E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_NEW_MEMMAP}, \
{0x1002, 0x954F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9552, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9553, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9555, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9557, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x955f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9580, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9581, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9583, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9586, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9587, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9588, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9589, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \
{0x1002, 0x958A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \
{0x1002, 0x958B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x958C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \
{0x1002, 0x958D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \
{0x1002, 0x958E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \
{0x1002, 0x958F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9590, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9591, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9593, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9595, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9596, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9597, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9598, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9599, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_NEW_MEMMAP}, \
{0x1002, 0x959B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x95C0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \
{0x1002, 0x95C2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x95C4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x95C5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \
{0x1002, 0x95C6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \
{0x1002, 0x95C7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \
{0x1002, 0x95C9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \
{0x1002, 0x95CC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \
{0x1002, 0x95CD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \
{0x1002, 0x95CE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \
{0x1002, 0x95CF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \
{0x1002, 0x9610, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9611, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9612, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9613, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9614, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9615, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9616, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9711, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9713, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9714, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9715, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9802, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9803, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9804, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9805, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9806, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x9807, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0, 0, 0}
#define r128_PCI_IDS \
{0x1002, 0x4c45, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4c46, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4d46, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4d4c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5041, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5042, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5043, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5044, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5045, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5046, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5047, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5048, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5049, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x504A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x504B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x504C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x504D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x504E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x504F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5050, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5051, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5052, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5053, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5054, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5055, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5056, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5057, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5245, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5246, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5247, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x524b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x524c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x534d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5446, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x544C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x5452, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0}
#define mga_PCI_IDS \
{0x102b, 0x0520, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MGA_CARD_TYPE_G200}, \
{0x102b, 0x0521, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MGA_CARD_TYPE_G200}, \
{0x102b, 0x0525, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MGA_CARD_TYPE_G400}, \
{0x102b, 0x2527, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MGA_CARD_TYPE_G550}, \
{0, 0, 0}
#define mach64_PCI_IDS \
{0x1002, 0x4749, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4750, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4751, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4742, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4744, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4c49, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4c50, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4c51, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4c42, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4c44, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x474c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x474f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4752, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4753, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x474d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x474e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4c52, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4c53, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4c4d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1002, 0x4c4e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0}
#define sisdrv_PCI_IDS \
{0x1039, 0x0300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1039, 0x5300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1039, 0x6300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1039, 0x6330, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \
{0x1039, 0x6351, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1039, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x18CA, 0x0040, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \
{0x18CA, 0x0042, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \
{0, 0, 0}
#define tdfx_PCI_IDS \
{0x121a, 0x0003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x121a, 0x0004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x121a, 0x0005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x121a, 0x0007, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x121a, 0x0009, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x121a, 0x000b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0}
#define viadrv_PCI_IDS \
{0x1106, 0x3022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1106, 0x3118, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VIA_PRO_GROUP_A}, \
{0x1106, 0x3122, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1106, 0x7205, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1106, 0x3108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1106, 0x3344, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1106, 0x3343, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1106, 0x3230, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VIA_DX9_0}, \
{0x1106, 0x3157, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VIA_PRO_GROUP_A}, \
{0, 0, 0}
#define i810_PCI_IDS \
{0x8086, 0x7121, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x8086, 0x7123, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x8086, 0x7125, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x8086, 0x1132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0}
#define i830_PCI_IDS \
{0x8086, 0x3577, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x8086, 0x2562, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x8086, 0x3582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x8086, 0x358e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0}
#define gamma_PCI_IDS \
{0x3d3d, 0x0008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0}
#define savage_PCI_IDS \
{0x5333, 0x8a20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE3D}, \
{0x5333, 0x8a21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE3D}, \
{0x5333, 0x8a22, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE4}, \
{0x5333, 0x8a23, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE4}, \
{0x5333, 0x8c10, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE_MX}, \
{0x5333, 0x8c11, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE_MX}, \
{0x5333, 0x8c12, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE_MX}, \
{0x5333, 0x8c13, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE_MX}, \
{0x5333, 0x8c22, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \
{0x5333, 0x8c24, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \
{0x5333, 0x8c26, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \
{0x5333, 0x8c2a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \
{0x5333, 0x8c2b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \
{0x5333, 0x8c2c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \
{0x5333, 0x8c2d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \
{0x5333, 0x8c2e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \
{0x5333, 0x8c2f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \
{0x5333, 0x8a25, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_PROSAVAGE}, \
{0x5333, 0x8a26, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_PROSAVAGE}, \
{0x5333, 0x8d01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_TWISTER}, \
{0x5333, 0x8d02, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_TWISTER}, \
{0x5333, 0x8d03, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_PROSAVAGEDDR}, \
{0x5333, 0x8d04, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_PROSAVAGEDDR}, \
{0, 0, 0}
#define ffb_PCI_IDS \
{0, 0, 0}
#define i915_PCI_IDS \
{0x8086, 0x3577, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2562, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x3582, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x258a, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x27a2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x27ae, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2972, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2982, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2992, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x29a2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x29b2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x29c2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x29d2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2a02, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2a12, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2a42, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2e02, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2e12, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2e22, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2e32, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x2e42, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0xa001, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0xa011, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x35e8, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x0042, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x0046, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0x8086, 0x0102, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \
{0, 0, 0}
| moonlightly/kernel_htc_qsd8k | include/drm/drm_pciids.h | C | gpl-2.0 | 49,461 | [
30522,
1013,
1008,
2023,
5371,
2003,
8285,
1011,
7013,
2013,
1996,
2852,
2213,
1035,
7473,
6137,
5104,
1012,
19067,
2102,
1999,
1996,
2852,
2213,
26226,
2015,
3531,
3967,
2852,
2072,
1011,
16475,
2884,
1030,
7201,
1012,
16420,
1012,
5658,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=392338
-->
<head>
<title>Test for Bug 392338</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=392338">Mozilla Bug 392338</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 392338 **/
function obs () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
this.observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
this.observerService.addObserver(this,"http-on-modify-request", false);
this.window = window;
}
obs.prototype = {
observe: function obs_observe (theSubject, theTopic, theData)
{
try{
this.window.netscape.security
.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var ir = theSubject.QueryInterface(this.window.Components.interfaces
.nsIChannel).notificationCallbacks;
if (!(ir instanceof this.window.Components.interfaces.nsIDOMDocument)) {
return;
}
this.window.is(ir instanceof
this.window.Components.interfaces.nsIInterfaceRequestor,
true, "Must be an interface requestor");
var count = {};
var interfaces = ir.
QueryInterface(this.window.Components
.interfaces.nsIClassInfo).
getInterfaces(count).
map(function(id) {
return this.window.Components
.interfacesByID[id].toString();
});
this.window.isnot(interfaces.indexOf("nsIInterfaceRequestor"), -1,
"Must have interface requestor classinfo");
} catch(ex) {
this.window.is(true, false, "Exception thrown " + ex);
} finally {
this.remove();
this.window.SimpleTest.finish();
this.window = null;
}
},
remove: function obs_remove()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
this.observerService.removeObserver(this,"http-on-modify-request");
this.observerService = null;
}
}
var o;
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
var doc = document.implementation.createDocument("", "", null);
o = new obs();
doc.load(window.location.href);
});
</script>
</pre>
</body>
</html>
| tmhorne/celtx | content/xml/document/test/test_bug392338.html | HTML | mpl-2.0 | 2,845 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
999,
1011,
1011,
16770,
1024,
1013,
1013,
11829,
5831,
4571,
30524,
1029,
8909,
1027,
4464,
21926,
22025,
1011,
1011,
1028,
1026,
2132,
1028,
1026,
2516,
1028,
3231,
2005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat licenses this file to you under the Apache License, version
* 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package org.apache.activemq.artemis.tests.extras.jms.ra;
import javax.jms.Message;
import javax.resource.ResourceException;
import javax.resource.spi.LocalTransactionException;
import javax.resource.spi.UnavailableException;
import javax.resource.spi.endpoint.MessageEndpoint;
import javax.resource.spi.endpoint.MessageEndpointFactory;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.RollbackException;
import javax.transaction.Status;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import javax.transaction.xa.XAResource;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
import com.arjuna.ats.arjuna.coordinator.TxControl;
import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.client.ClientConsumer;
import org.apache.activemq.artemis.api.core.client.ClientMessage;
import org.apache.activemq.artemis.api.core.client.ClientProducer;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.server.ServerConsumer;
import org.apache.activemq.artemis.core.server.ServerSession;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter;
import org.apache.activemq.artemis.ra.inflow.ActiveMQActivation;
import org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.tests.integration.ra.ActiveMQRATestBase;
import org.apache.activemq.artemis.utils.RandomUtil;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* Simulates several messages being received over multiple instances with reconnects during the process.
*/
public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase {
final ConcurrentHashMap<Integer, AtomicInteger> mapCounter = new ConcurrentHashMap<>();
volatile ActiveMQResourceAdapter resourceAdapter;
ServerLocator nettyLocator;
// This thread will keep bugging the handlers.
// if they behave well with XA, the test pass!
final AtomicBoolean running = new AtomicBoolean(true);
private volatile boolean playTXTimeouts = true;
private volatile boolean playServerClosingSession = true;
private volatile boolean playServerClosingConsumer = true;
@Override
@Before
public void setUp() throws Exception {
nettyLocator = createNettyNonHALocator();
nettyLocator.setRetryInterval(100);
nettyLocator.setReconnectAttempts(300);
mapCounter.clear();
resourceAdapter = null;
super.setUp();
createQueue(true, "outQueue");
DummyTMLocator.startTM();
running.set(true);
}
@Override
@After
public void tearDown() throws Exception {
DummyTMLocator.stopTM();
super.tearDown();
}
@Override
protected boolean usePersistence() {
return true;
}
@Override
public boolean useSecurity() {
return false;
}
@Test
public void testReconnectMDBNoMessageLoss() throws Exception {
AddressSettings settings = new AddressSettings();
settings.setRedeliveryDelay(100);
settings.setMaxDeliveryAttempts(-1);
server.getAddressSettingsRepository().clear();
server.getAddressSettingsRepository().addMatch("#", settings);
ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
resourceAdapter = qResourceAdapter;
resourceAdapter.setConfirmationWindowSize(-1);
resourceAdapter.setCallTimeout(1000L);
resourceAdapter.setConsumerWindowSize(1024 * 1024);
resourceAdapter.setReconnectAttempts(-1);
resourceAdapter.setRetryInterval(100L);
// qResourceAdapter.setTransactionManagerLocatorClass(DummyTMLocator.class.getName());
// qResourceAdapter.setTransactionManagerLocatorMethod("getTM");
MyBootstrapContext ctx = new MyBootstrapContext();
qResourceAdapter.setConnectorClassName(NETTY_CONNECTOR_FACTORY);
qResourceAdapter.start(ctx);
final int NUMBER_OF_SESSIONS = 10;
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setTransactionTimeout(1);
spec.setMaxSession(NUMBER_OF_SESSIONS);
spec.setSetupAttempts(-1);
spec.setSetupInterval(100L);
spec.setResourceAdapter(qResourceAdapter);
spec.setUseJNDI(false);
spec.setDestinationType("javax.jms.Queue");
spec.setDestination(MDBQUEUE);
// Some the routines would be screwed up if using the default one
Assert.assertFalse(spec.isHasBeenUpdated());
TestEndpointFactory endpointFactory = new TestEndpointFactory(true);
qResourceAdapter.endpointActivation(endpointFactory, spec);
Assert.assertEquals(1, resourceAdapter.getActivations().values().size());
ActiveMQActivation activation = resourceAdapter.getActivations().values().toArray(new ActiveMQActivation[1])[0];
final int NUMBER_OF_MESSAGES = 1000;
Thread producer = new Thread() {
@Override
public void run() {
try {
ServerLocator locator = createInVMLocator(0);
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession session = factory.createSession(false, false);
ClientProducer clientProducer = session.createProducer(MDBQUEUEPREFIXED);
StringBuffer buffer = new StringBuffer();
for (int b = 0; b < 500; b++) {
buffer.append("ab");
}
for (int i = 0; i < NUMBER_OF_MESSAGES; i++) {
ClientMessage message = session.createMessage(true);
message.getBodyBuffer().writeString(buffer.toString() + i);
message.putIntProperty("i", i);
clientProducer.send(message);
if (i % 100 == 0) {
session.commit();
}
}
session.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
};
producer.start();
final AtomicBoolean metaDataFailed = new AtomicBoolean(false);
Thread buggerThread = new Thread() {
@Override
public void run() {
while (running.get()) {
try {
Thread.sleep(RandomUtil.randomInterval(100, 200));
} catch (InterruptedException intex) {
intex.printStackTrace();
return;
}
List<ServerSession> serverSessions = lookupServerSessions("resource-adapter", NUMBER_OF_SESSIONS);
System.err.println("Contains " + serverSessions.size() + " RA sessions");
if (serverSessions.size() != NUMBER_OF_SESSIONS) {
System.err.println("the server was supposed to have " + NUMBER_OF_MESSAGES + " RA Sessions but it only contained accordingly to the meta-data");
metaDataFailed.set(true);
} else if (serverSessions.size() == NUMBER_OF_SESSIONS) {
// it became the same after some reconnect? which would be acceptable
metaDataFailed.set(false);
}
if (playServerClosingSession && serverSessions.size() > 0) {
int randomBother = RandomUtil.randomInterval(0, serverSessions.size() - 1);
System.out.println("bugging session " + randomBother);
ServerSession serverSession = serverSessions.get(randomBother);
if (playServerClosingConsumer && RandomUtil.randomBoolean()) {
// will play this randomly, only half of the times
for (ServerConsumer consumer : serverSession.getServerConsumers()) {
try {
// Simulating a rare race that could happen in production
// where the consumer is closed while things are still happening
consumer.close(true);
Thread.sleep(100);
} catch (Exception e) {
e.printStackTrace();
}
}
}
RemotingConnection connection = serverSession.getRemotingConnection();
connection.fail(new ActiveMQException("failed at random " + randomBother));
}
}
}
};
buggerThread.start();
ServerLocator locator = createInVMLocator(0);
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession session = factory.createSession(false, false);
session.start();
ClientConsumer consumer = session.createConsumer("outQueue");
for (int i = 0; i < NUMBER_OF_MESSAGES; i++) {
ClientMessage message = consumer.receive(60000);
if (message == null) {
break;
}
if (i == NUMBER_OF_MESSAGES * 0.50) {
// This is to make sure the MDBs will survive a reboot
// and no duplications or message loss will happen because of this
System.err.println("Rebooting the MDBs at least once!");
activation.startReconnectThread("I");
}
if (i == NUMBER_OF_MESSAGES * 0.90) {
System.out.println("Disabled failures at " + i);
playTXTimeouts = false;
playServerClosingSession = false;
playServerClosingConsumer = false;
}
System.out.println("Received " + i + " messages");
doReceiveMessage(message);
if (i % 200 == 0) {
System.out.println("received " + i);
session.commit();
}
}
session.commit();
while (true) {
ClientMessage message = consumer.receiveImmediate();
if (message == null) {
break;
}
System.out.println("Received extra message " + message);
doReceiveMessage(message);
}
session.commit();
Assert.assertNull(consumer.receiveImmediate());
StringWriter writer = new StringWriter();
PrintWriter out = new PrintWriter(writer);
boolean failed = false;
for (int i = 0; i < NUMBER_OF_MESSAGES; i++) {
AtomicInteger atomicInteger = mapCounter.get(Integer.valueOf(i));
if (atomicInteger == null) {
out.println("didn't receive message with i=" + i);
failed = true;
} else if (atomicInteger.get() > 1) {
out.println("message with i=" + i + " received " + atomicInteger.get() + " times");
failed = true;
}
}
running.set(false);
buggerThread.join();
producer.join();
qResourceAdapter.stop();
session.close();
if (failed) {
for (int i = 0; i < 10; i++) {
System.out.println("----------------------------------------------------");
}
System.out.println(writer.toString());
}
Assert.assertFalse(writer.toString(), failed);
System.out.println("Received " + NUMBER_OF_MESSAGES + " messages");
Assert.assertFalse("There was meta-data failures, some sessions didn't reconnect properly", metaDataFailed.get());
}
private void doReceiveMessage(ClientMessage message) throws Exception {
Assert.assertNotNull(message);
message.acknowledge();
Integer value = message.getIntProperty("i");
AtomicInteger mapCount = new AtomicInteger(1);
mapCount = mapCounter.putIfAbsent(value, mapCount);
if (mapCount != null) {
mapCount.incrementAndGet();
}
}
private List<ServerSession> lookupServerSessions(String parameter, int numberOfSessions) {
long timeout = System.currentTimeMillis() + 50000;
List<ServerSession> serverSessions = new LinkedList<>();
do {
if (!serverSessions.isEmpty()) {
System.err.println("Retry on serverSessions!!! currently with " + serverSessions.size());
serverSessions.clear();
try {
Thread.sleep(100);
} catch (Exception e) {
break;
}
}
serverSessions.clear();
for (ServerSession session : server.getSessions()) {
if (session.getMetaData(parameter) != null) {
serverSessions.add(session);
}
}
}
while (running.get() && serverSessions.size() != numberOfSessions && timeout > System.currentTimeMillis());
System.err.println("Returning " + serverSessions.size() + " sessions");
return serverSessions;
}
protected class TestEndpointFactory implements MessageEndpointFactory {
private final boolean isDeliveryTransacted;
public TestEndpointFactory(boolean deliveryTransacted) {
isDeliveryTransacted = deliveryTransacted;
}
@Override
public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException {
TestEndpoint retEnd = new TestEndpoint();
if (xaResource != null) {
retEnd.setXAResource(xaResource);
}
return retEnd;
}
@Override
public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException {
return isDeliveryTransacted;
}
}
public class TestEndpoint extends DummyMessageEndpoint {
ClientSessionFactory factory;
ClientSession endpointSession;
ClientProducer producer;
Transaction currentTX;
public TestEndpoint() {
super(null);
try {
factory = nettyLocator.createSessionFactory();
// buggingList.add(factory);
endpointSession = factory.createSession(true, false, false);
producer = endpointSession.createProducer("outQueue");
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
@Override
public void beforeDelivery(Method method) throws NoSuchMethodException, ResourceException {
super.beforeDelivery(method);
try {
DummyTMLocator.tm.begin();
currentTX = DummyTMLocator.tm.getTransaction();
currentTX.enlistResource(xaResource);
} catch (Throwable e) {
throw new RuntimeException(e.getMessage(), e);
}
}
@Override
public void onMessage(Message message) {
Integer value = 0;
try {
value = message.getIntProperty("i");
} catch (Exception e) {
}
super.onMessage(message);
try {
currentTX.enlistResource(endpointSession);
ClientMessage message1 = endpointSession.createMessage(true);
message1.putIntProperty("i", value);
producer.send(message1);
currentTX.delistResource(endpointSession, XAResource.TMSUCCESS);
if (playTXTimeouts) {
if (RandomUtil.randomInterval(0, 5) == 3) {
Thread.sleep(2000);
}
}
} catch (Exception e) {
e.printStackTrace();
try {
currentTX.setRollbackOnly();
} catch (Exception ex) {
}
e.printStackTrace();
// throw new RuntimeException(e);
}
}
@Override
public void afterDelivery() throws ResourceException {
// This is a copy & paste of what the Application server would do here
try {
if (currentTX.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
DummyTMLocator.tm.rollback();
} else {
DummyTMLocator.tm.commit();
}
} catch (HeuristicMixedException e) {
throw new LocalTransactionException(e);
} catch (SystemException e) {
throw new LocalTransactionException(e);
} catch (HeuristicRollbackException e) {
throw new LocalTransactionException(e);
} catch (RollbackException e) {
throw new LocalTransactionException(e);
}
super.afterDelivery();
}
}
public static class DummyTMLocator {
public static TransactionManagerImple tm;
public static void stopTM() {
try {
TransactionReaper.terminate(true);
TxControl.disable(true);
} catch (Exception e) {
e.printStackTrace();
}
tm = null;
}
public static void startTM() {
tm = new TransactionManagerImple();
TxControl.enable();
}
public TransactionManager getTM() {
return tm;
}
}
}
| pgfox/activemq-artemis | tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/ra/MDBMultipleHandlersServerDisconnectTest.java | Java | apache-2.0 | 18,149 | [
30522,
1013,
1008,
1008,
9385,
2384,
1011,
2297,
2417,
6045,
1010,
4297,
1012,
1008,
2417,
6045,
15943,
2023,
5371,
2000,
2017,
2104,
1996,
15895,
6105,
1010,
2544,
1008,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
2017,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* This file is part of JsonFL.
*
* JsonFL is free software: you can redistribute it and/or modify it under the
* terms of the Lesser GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* JsonFL is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the Lesser GNU General Public License for more
* details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with JsonFL. If not, see <http://www.gnu.org/licenses/>.
*/
package au.com.houliston.jsonfl;
/**
* Is thrown when the creation string for the JsonFL is invalid
*
* @author Trent Houliston
* @version 1.0
*/
public class InvalidJsonFLException extends Exception
{
/**
* Creates a new InvalidJsonFLException with the passed message
*
* @param message The message to set
*/
public InvalidJsonFLException(String message)
{
super(message);
}
/**
* Creates a new InvalidJsonFLException along with a message and a cause
*
* @param message The message to set
* @param cause The root cause which made this exception
*/
public InvalidJsonFLException(String message, Throwable cause)
{
super(message, cause);
}
}
| TrentHouliston/JsonFL | src/main/java/au/com/houliston/jsonfl/InvalidJsonFLException.java | Java | gpl-3.0 | 1,371 | [
30522,
1013,
1008,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
1046,
3385,
10258,
1012,
1008,
1008,
1046,
3385,
10258,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
2009,
2104,
1996,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* @group Echo
*/
class SuppressionMaintenanceTest extends MediaWikiTestCase {
public static function provider_updateRow() {
$input = array(
'event_id' => 2,
'event_type' => 'mention',
'event_variant' => null,
'event_agent_id' => 3,
'event_agent_ip' => null,
'event_page_title' => '',
'event_page_namespace' => 0,
'event_page_extra' => null,
'event_extra' => null,
'event_page_id' => null,
);
return array(
array( 'Unrelated row must result in no update', array(), $input ),
array(
'Page title and namespace for non-existant page must move into event_extra',
array( // expected update
'event_extra' => serialize( array(
'page_title' => 'Yabba Dabba Do',
'page_namespace' => NS_MAIN
) ),
),
array( // input row
'event_page_title' => 'Yabba Dabba Do',
'event_page_namespace' => NS_MAIN,
) + $input,
),
array(
'Page title and namespace for existing page must be result in update to event_page_id',
array( // expected update
'event_page_id' => 42,
),
array( // input row
'event_page_title' => 'Mount Rushmore',
'event_page_namespace' => NS_MAIN,
) + $input,
self::attachTitleFor( 42, 'Mount Rushmore', NS_MAIN )
),
array(
'When updating non-existant page must keep old extra data',
array( // expected update
'event_extra' => serialize( array(
'foo' => 'bar',
'page_title' => 'Yabba Dabba Do',
'page_namespace' => NS_MAIN
) ),
),
array( // input row
'event_page_title' => 'Yabba Dabba Do',
'event_page_namespace' => NS_MAIN,
'event_extra' => serialize( array( 'foo' => 'bar' ) ),
) + $input,
),
array(
'Must update link-from-title/namespace to link-from-page-id for page-linked events',
array( // expected update
'event_extra' => serialize( array( 'link-from-page-id' => 99 ) ),
),
array( //input row
'event_type' => 'page-linked',
'event_extra' => serialize( array(
'link-from-title' => 'Horse',
'link-from-namespace' => NS_USER_TALK
) ),
) + $input,
self::attachTitleFor( 99, 'Horse', NS_USER_TALK )
),
array(
'Must perform both generic update and page-linked update at same time',
array( // expected update
'event_extra' => serialize( array( 'link-from-page-id' => 8675309 ) ),
'event_page_id' => 8675309,
),
array( //input row
'event_type' => 'page-linked',
'event_extra' => serialize( array(
'link-from-title' => 'Jenny',
'link-from-namespace' => NS_MAIN,
) ),
'event_page_title' => 'Jenny',
'event_page_namespace' => NS_MAIN,
) + $input,
self::attachTitleFor( 8675309, 'Jenny', NS_MAIN ),
),
);
}
protected static function attachTitleFor( $id, $providedText, $providedNamespace ) {
return function( $test, $gen ) use ( $id, $providedText, $providedNamespace ) {
$title = $test->getMock( 'Title' );
$title->expects( $test->any() )
->method( 'getArticleId' )
->will( $test->returnValue( $id ) );
$titles = array( $providedNamespace => array( $providedText => $title ) );
$gen->setNewTitleFromText( function( $text, $defaultNamespace ) use( $titles ) {
if ( isset( $titles[$defaultNamespace][$text] ) ) {
return $titles[$defaultNamespace][$text];
}
return Title::newFromText( $text, $defaultNamespace );
} );
};
}
/**
* @dataProvider provider_updateRow
*/
public function testUpdateRow( $message, $expected, $input, $callable = null ) {
$gen = new EchoSuppressionRowUpdateGenerator;
if ( $callable ) {
call_user_func( $callable, $this, $gen );
}
$update = $gen->update( (object) $input );
$this->assertEquals( $expected, $update, $message );
}
}
| tuxun/smw-funwiki | extensions/Echo/tests/phpunit/maintenance/SupressionMaintenanceTest.php | PHP | gpl-2.0 | 3,786 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1030,
2177,
9052,
1008,
1013,
2465,
16341,
24238,
6528,
6651,
22199,
8908,
2865,
9148,
23615,
4355,
18382,
1063,
2270,
10763,
3853,
10802,
1035,
10651,
10524,
1006,
1007,
1063,
1002,
7953,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require 'spec_helper'
describe VisitorsController do
let(:valid_params){ {name: 'Ivan', email: 'my@email.com', message: 'Love your site!'} }
it 'renders index template' do
get :index
expect(response).to render_template('index')
end
it 'assigns event to next_occurrence' do
event = double(Event)
expect(Event).to receive(:next_occurrence).with(:Scrum).and_return(event)
get :index
expect(assigns(:event)).to eq event
end
end
| freeranger/WebsiteOne | spec/controllers/visitors_controller_spec.rb | Ruby | mit | 460 | [
30522,
5478,
1005,
28699,
1035,
2393,
2121,
1005,
6235,
5731,
8663,
13181,
10820,
2079,
2292,
1006,
1024,
9398,
1035,
11498,
5244,
1007,
1063,
1063,
2171,
1024,
1005,
7332,
1005,
1010,
10373,
1024,
1005,
2026,
1030,
10373,
1012,
4012,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
final class DrydockLeaseViewController extends DrydockLeaseController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$lease = id(new DrydockLeaseQuery())
->setViewer($viewer)
->withIDs(array($id))
->needUnconsumedCommands(true)
->executeOne();
if (!$lease) {
return new Aphront404Response();
}
$lease_uri = $this->getApplicationURI('lease/'.$lease->getID().'/');
$title = pht('Lease %d', $lease->getID());
$header = id(new PHUIHeaderView())
->setHeader($title);
if ($lease->isReleasing()) {
$header->setStatus('fa-exclamation-triangle', 'red', pht('Releasing'));
}
$actions = $this->buildActionListView($lease);
$properties = $this->buildPropertyListView($lease, $actions);
$pager = new PHUIPagerView();
$pager->setURI(new PhutilURI($lease_uri), 'offset');
$pager->setOffset($request->getInt('offset'));
$logs = id(new DrydockLogQuery())
->setViewer($viewer)
->withLeaseIDs(array($lease->getID()))
->executeWithOffsetPager($pager);
$log_table = id(new DrydockLogListView())
->setUser($viewer)
->setLogs($logs)
->render();
$log_table->appendChild($pager);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title, $lease_uri);
$locks = $this->buildLocksTab($lease->getPHID());
$commands = $this->buildCommandsTab($lease->getPHID());
$object_box = id(new PHUIObjectBoxView())
->setHeader($header)
->addPropertyList($properties, pht('Properties'))
->addPropertyList($locks, pht('Slot Locks'))
->addPropertyList($commands, pht('Commands'));
$log_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Lease Logs'))
->setTable($log_table);
return $this->buildApplicationPage(
array(
$crumbs,
$object_box,
$log_box,
),
array(
'title' => $title,
));
}
private function buildActionListView(DrydockLease $lease) {
$viewer = $this->getViewer();
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($this->getRequest()->getRequestURI())
->setObject($lease);
$id = $lease->getID();
$can_release = $lease->canRelease();
if ($lease->isReleasing()) {
$can_release = false;
}
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$lease,
PhabricatorPolicyCapability::CAN_EDIT);
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Release Lease'))
->setIcon('fa-times')
->setHref($this->getApplicationURI("/lease/{$id}/release/"))
->setWorkflow(true)
->setDisabled(!$can_release || !$can_edit));
return $view;
}
private function buildPropertyListView(
DrydockLease $lease,
PhabricatorActionListView $actions) {
$viewer = $this->getViewer();
$view = new PHUIPropertyListView();
$view->setActionList($actions);
$view->addProperty(
pht('Status'),
DrydockLeaseStatus::getNameForStatus($lease->getStatus()));
$view->addProperty(
pht('Resource Type'),
$lease->getResourceType());
$owner_phid = $lease->getOwnerPHID();
if ($owner_phid) {
$owner_display = $viewer->renderHandle($owner_phid);
} else {
$owner_display = phutil_tag('em', array(), pht('No Owner'));
}
$view->addProperty(pht('Owner'), $owner_display);
$resource_phid = $lease->getResourcePHID();
if ($resource_phid) {
$resource_display = $viewer->renderHandle($resource_phid);
} else {
$resource_display = phutil_tag('em', array(), pht('No Resource'));
}
$view->addProperty(pht('Resource'), $resource_display);
$until = $lease->getUntil();
if ($until) {
$until_display = phabricator_datetime($until, $viewer);
} else {
$until_display = phutil_tag('em', array(), pht('Never'));
}
$view->addProperty(pht('Expires'), $until_display);
$attributes = $lease->getAttributes();
if ($attributes) {
$view->addSectionHeader(
pht('Attributes'), 'fa-list-ul');
foreach ($attributes as $key => $value) {
$view->addProperty($key, $value);
}
}
return $view;
}
}
| librewiki/phabricator | src/applications/drydock/controller/DrydockLeaseViewController.php | PHP | apache-2.0 | 4,366 | [
30522,
1026,
1029,
25718,
2345,
2465,
4318,
14647,
19738,
3366,
8584,
8663,
13181,
10820,
8908,
4318,
14647,
19738,
3366,
8663,
13181,
10820,
1063,
2270,
3853,
28213,
2063,
15500,
1006,
9706,
8093,
12162,
2890,
15500,
1002,
5227,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
-----------------------------------
-- Area: Southern SandOria [S]
-- NPC: Machionage
-- @zone 80
-- !pos -255 -3 109
-----------------------------------
package.loaded["scripts/zones/Southern_San_dOria_[S]/TextIDs"] = nil;
require("scripts/zones/Southern_San_dOria_[S]/TextIDs");
require("scripts/globals/quests");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(CRYSTAL_WAR,GIFTS_OF_THE_GRIFFON) == QUEST_ACCEPTED and player:getVar("GiftsOfGriffonProg") == 2) then
local mask = player:getVar("GiftsOfGriffonPlumes");
if (trade:hasItemQty(2528,1) and trade:getItemCount() == 1 and not player:getMaskBit(mask,0)) then
player:startEvent(0x01C) -- Gifts of Griffon Trade
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x026B); -- Default Dialogue
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x01C) then
player:tradeComplete()
local mask = player:getVar("GiftsOfGriffonPlumes");
player:setMaskBit(mask,"GiftsOfGriffonPlumes",0,true);
end
end; | RebootRevival/FFXI_Test | scripts/zones/Southern_San_dOria_[S]/npcs/Machionage.lua | Lua | gpl-3.0 | 1,611 | [
30522,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
2181,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php declare(strict_types=1);
namespace Y0lk\SQLDumper;
use ArrayObject;
use PDO;
use InvalidArgumentException;
/**
* A TableDumperCollection is used to group TableDumper objects together, allowing you to specify dump options on multiple table at once.
* All TableDumper methods can be called directly on a TableDumperCollection, and will be executed on all the TableDumper instances in that collection.
*
* @author Gabriel Jean <gabriel@inkrebit.com>
*/
class TableDumperCollection extends ArrayObject
{
/**
* {@inheritDoc}
*/
public function append($value): void
{
//Make sure we're adding a TableDumper object
if (!($value instanceof TableDumper)) {
throw new InvalidArgumentException("TableDumperCollection only accepts TableDumper objects", 1);
}
//Append with table_name as key
$this->offsetSet($value->getTable()->getName(), $value);
}
/**
* {@inheritDoc}
*/
public function offsetSet($index, $newval): void
{
//Make sure we're adding a TableDumper object
if (!($newval instanceof TableDumper)) {
throw new InvalidArgumentException("TableDumperCollection only accepts TableDumper objects", 1);
}
//Append with table_name as key
parent::offsetSet($newval->getTable()->getName(), $newval);
}
/**
* @param Table|string $table Adds a table, either by name, or by Table instance, to the collection
*
* @return TableDumper Returns a TableDumper of the table that was just added
*/
public function addTable($table): TableDumper
{
if ($table instanceof Table) {
$tableName = $table->getName();
} else {
$tableName = $table;
$table = new Table($tableName);
}
//First check if a dumper already exists for this table
if (!$this->offsetExists($tableName)) {
//Create new one
$this->offsetSet($tableName, new TableDumper($table));
}
return $this->offsetGet($tableName);
}
/**
* @param TableDumperCollection|array<TableDumper|Table|string> $listTables Adds a list of tables, either by passing TableDumperCollection, or an array containing either TableDumper objects, Table objects or table naes
*
* @return TableDumperCollection Returns a TableDumperCollection of the list of tables that was just added
*/
public function addListTables($listTables): TableDumperCollection
{
//If arg is a TableDumperCollection, merge into this one
if ($listTables instanceof TableDumperCollection) {
foreach ($listTables as $table) {
$this->append($table);
}
return $listTables;
} else {
return $this->addListTableArray($listTables);
}
}
/**
* Adds a list of tables passed as an array
* @param array $listTables Array of tables to add
*
* @return TableDumperCollection Returns a TableDumperCollection of the list of tables that was just added
*/
protected function addListTableArray(array $listTables): TableDumperCollection
{
//Create TableDumperCollection
$listDumpers = new TableDumperCollection;
foreach ($listTables as $table) {
//If table is already a Dumper, simply append to this
if ($table instanceof TableDumper) {
$listDumpers[] = $table;
$this->append($table);
} else {
$listDumpers[] = $this->addTable($table);
}
}
return $listDumpers;
}
/**
* Writes all DROP statements to the dump stream
*
* @param resource $stream Stream to write the dump to
*
* @return void
*/
public function dumpDropStatements($stream): void
{
foreach ($this as $dumper) {
if ($dumper->hasDrop()) {
$dumper->dumpDropStatement($stream);
}
}
}
/**
* Writes all INSERT statements to the dump stream
*
* @param PDO $db PDO instance to use for DB queries
* @param resource $stream Stream to write the dump to
*
* @return void
*/
public function dumpInsertStatements(PDO $db, $stream): void
{
foreach ($this as $dumper) {
if ($dumper->hasData()) {
$dumper->dumpInsertStatement($db, $stream);
}
}
}
/**
* Writes all the SQL statements of this dumper to the dump stream
*
* @param PDO $db PDO instance to use for DB queries
* @param resource $stream Stream to write the dump to
* @param boolean $groupDrops Determines if DROP statements will be grouped
* @param boolean $groupInserts Determines if INSERT statements will be grouped
*
* @return void
*/
public function dump(PDO $db, $stream, bool $groupDrops = false, bool $groupInserts = false): void
{
if ($groupDrops) {
$this->dumpDropStatements($stream);
}
foreach ($this as $dumper) {
if (!$groupDrops) {
$dumper->dumpDropStatement($stream);
}
$dumper->dumpCreateStatement($db, $stream);
if (!$groupInserts) {
$dumper->dumpInsertStatement($db, $stream);
}
}
if ($groupInserts) {
$this->dumpInsertStatements($db, $stream);
}
}
public function __call(string $name, array $arguments)
{
//Call methods on TableDumper values
foreach ($this as $value) {
call_user_func_array([$value, $name], $arguments);
}
return $this;
}
} | Y0lk/sqldumper | src/TableDumperCollection.php | PHP | mit | 5,834 | [
30522,
1026,
1029,
25718,
13520,
1006,
9384,
1035,
4127,
1027,
1015,
1007,
1025,
3415,
15327,
1061,
2692,
13687,
1032,
29296,
8566,
8737,
2121,
1025,
2224,
9140,
16429,
20614,
1025,
2224,
22851,
2080,
1025,
2224,
19528,
2906,
22850,
15781,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2010 Tilera Corporation. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
* NON INFRINGEMENT. See the GNU General Public License for
* more details.
*/
#ifndef _ASM_TILE_KMAP_TYPES_H
#define _ASM_TILE_KMAP_TYPES_H
/*
* In 32-bit TILE Linux we have to balance the desire to have a lot of
* nested atomic mappings with the fact that large page sizes and many
* processors chew up address space quickly. In a typical
* 64-processor, 64KB-page layout build, making KM_TYPE_NR one larger
* adds 4MB of required address-space. For now we leave KM_TYPE_NR
* set to depth 8.
*/
enum km_type {
KM_TYPE_NR = 8
};
/*
* We provide dummy definitions of all the stray values that used to be
* required for kmap_atomic() and no longer are.
*/
enum {
KM_BOUNCE_READ,
KM_SKB_SUNRPC_DATA,
KM_SKB_DATA_SOFTIRQ,
KM_USER0,
KM_USER1,
KM_BIO_SRC_IRQ,
KM_BIO_DST_IRQ,
KM_PTE0,
KM_PTE1,
KM_IRQ0,
KM_IRQ1,
KM_SOFTIRQ0,
KM_SOFTIRQ1,
KM_SYNC_ICACHE,
KM_SYNC_DCACHE,
KM_UML_USERCOPY,
KM_IRQ_PTE,
KM_NMI,
KM_NMI_PTE,
KM_KDB
};
#endif /* _ASM_TILE_KMAP_TYPES_H */
| talnoah/android_kernel_htc_dlx | virt/arch/tile/include/asm/kmap_types.h | C | gpl-2.0 | 1,475 | [
30522,
1013,
1008,
1008,
9385,
2230,
14090,
2527,
3840,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1025,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
1008,
19933,
2009,
2104,
1996,
3408,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Copyright (c) 2019 Anup Patel.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* @file uart8250.h
* @author Anup Patel (anup@brainfault.org)
* @brief Header file for UART 8250 serial port driver.
*/
#ifndef __UART8250_H_
#define __UART8250_H_
#include <arch_types.h>
bool uart8250_can_getc(virtual_addr_t base, u32 reg_shift, u32 reg_width);
char uart8250_getc(virtual_addr_t base, u32 reg_shift, u32 reg_width);
void uart8250_putc(virtual_addr_t base,
u32 reg_shift, u32 reg_width, char ch);
void uart8250_init(virtual_addr_t base,
u32 reg_shift, u32 reg_width,
u32 baudrate, u32 input_clock);
#endif /* __UART8250_H_ */
| hschauhan/xvisor-x86_64 | tests/common/basic/serial/uart8250.h | C | gpl-2.0 | 1,321 | [
30522,
1013,
1008,
1008,
1008,
9385,
1006,
1039,
1007,
10476,
2019,
6279,
20455,
1012,
1008,
2035,
2916,
9235,
1012,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1025,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package scala.lms
package internal
import util.GraphUtil
import scala.collection.mutable
import java.util.IdentityHashMap
import scala.collection.JavaConversions._
trait Scheduling {
val IR: Expressions
import IR._
def getUnsortedSchedule(scope: List[Stm])(result: Any): List[Stm] = {
getSchedule(scope)(result, false)
}
// checks if a and b share at least one element. O(N^2), but with no allocation and possible early exit.
def containsAny(a: List[Sym[Any]], b: List[Sym[Any]]): Boolean = {
var aIter = a
while (aIter.nonEmpty) {
val aElem = aIter.head
aIter = aIter.tail
var bIter = b
while (bIter.nonEmpty) {
if (bIter.head eq aElem) return true
bIter = bIter.tail
}
}
false
}
//TBD: not used?
def getStronglySortedSchedule(scope: List[Stm])(result: Any): List[Stm] = {
def deps(st: List[Sym[Any]]): List[Stm] =
scope.filter(d => containsAny(st, d.lhs))
// scope.filter(d => (st intersect d.lhs).nonEmpty)
def allSyms(r: Any) = syms(r) ++ softSyms(r)
val xx = GraphUtil.stronglyConnectedComponents[Stm](deps(allSyms(result)), t => deps(allSyms(t.rhs)))
xx.foreach { x =>
if (x.length > 1) {
printerr("warning: recursive schedule for result " + result + ": " + x)
(new Exception) printStackTrace
}
}
xx.flatten.reverse
}
//performance hotspot!
//should be O(1) wrt 'scope' (nodes in graph), try to keep this as efficient as possible
protected def scheduleDepsWithIndex(syms: List[Sym[Any]], cache: IdentityHashMap[Sym[Any], (Stm,Int)]): List[Stm] = {
//syms.map(cache.get(_)).filter(_ ne null).distinct.sortBy(_._2).map(_._1)
val sortedSet = new java.util.TreeSet[(Stm,Int)](
new java.util.Comparator[(Stm,Int)] { def compare(a:(Stm,Int), b:(Stm,Int)) = if (b._2 < a._2) -1 else if (b._2 == a._2) 0 else 1 }
)
for (sym <- syms) {
val stm = cache.get(sym)
if (stm ne null) sortedSet.add(stm)
}
var res: List[Stm] = Nil
val iter = sortedSet.iterator //return stms in the original order given by 'scope'
while (iter.hasNext) {
res ::= iter.next._1
}
res
}
protected def buildScopeIndex(scope: List[Stm]): IdentityHashMap[Sym[Any], (Stm,Int)] = {
val cache = new IdentityHashMap[Sym[Any], (Stm,Int)]
var idx = 0
for (stm <- scope) {
for (s <- stm.lhs) cache.put(s, (stm,idx)) //remember the original order of the stms
idx += 1
}
cache
}
def getSchedule(scope: List[Stm])(result: Any, sort: Boolean = true): List[Stm] = {
val scopeIndex = buildScopeIndex(scope)
val xx = GraphUtil.stronglyConnectedComponents[Stm](scheduleDepsWithIndex(syms(result), scopeIndex), t => scheduleDepsWithIndex(syms(t.rhs), scopeIndex))
if (sort) xx.foreach { x =>
if (x.length > 1) {
printerr("warning: recursive schedule for result " + result + ": " + x)
(new Exception) printStackTrace
}
}
xx.flatten.reverse
}
def getScheduleM(scope: List[Stm])(result: Any, cold: Boolean, hot: Boolean): List[Stm] = {
def mysyms(st: Any) = {
val db = symsFreq(st).groupBy(_._1).mapValues(_.map(_._2).sum).toList
assert(syms(st).toSet == db.map(_._1).toSet, "different list of syms: "+syms(st)+"!="+db+" for "+st)
if (cold && hot) db.map(_._1)
else if (cold && !hot) db.withFilter(_._2 < 100.0).map(_._1)
else if (!cold && hot) db.withFilter(_._2 > 0.75).map(_._1)
else db.withFilter(p=>p._2 > 0.75 && p._2 < 100.0).map(_._1)
}
val scopeIndex = buildScopeIndex(scope)
GraphUtil.stronglyConnectedComponents[Stm](scheduleDepsWithIndex(mysyms(result), scopeIndex), t => scheduleDepsWithIndex(mysyms(t.rhs), scopeIndex)).flatten.reverse
}
/** begin performance hotspot **/
/*
for each symbol s in sts, find all statements that depend on it.
we need to stop when we reach the statement where s is bound.
it would be tempting to do only one scc call but then we mix
up the locations where different symbols are bound.
*/
def getFatDependentStuff(scope: List[Stm])(sts: List[Sym[Any]]): List[Stm] = {
if (sts.isEmpty) return Nil
/*
precompute:
s => all d in scope such that: d.lhs contains s || syms(d.rhs).contains(s)
st => all d in scope such that: boundSyms(d.rhs) contains st
*/
//type IdentityHashMap[K,V] = HashMap[K,V]
// IdentityHashMap appears faster than scala.collection.mutable.HashMap here (based on perf. testing)
// possible improvement: use an integer hashmap that works directly with sym ids
val lhsCache = new IdentityHashMap[Sym[Any], List[Stm]]()
val symsCache = new IdentityHashMap[Sym[Any], List[Stm]]()
val boundSymsCache = new IdentityHashMap[Sym[Any], List[Stm]]()
//val boundSymsCache = new IdentityHashMap[Sym[Any], Set[Stm]]()
def infix_getOrElse[K,V](map: IdentityHashMap[K, V], s: K, f: => V) = {
var res = map.get(s) //map(s)
if (res == null) res = f
res
}
def putDef(map: IdentityHashMap[Sym[Any], List[Stm]], s: Sym[Any], d: Stm): Unit = {
var res = map.get(s) //map(s)
if (res == null) res = Nil
//map.getOrElse(s, Nil) match {
res match {
case `d`::ds =>
case ds => map.update(s,d::ds) //map.put(s,d::ds)
}
}
def putDefSet(map: IdentityHashMap[Sym[Any], Set[Stm]], s: Sym[Any], d: Stm): Unit = {
var res = map(s) //map.get(s)
if (res == null) {
res = Set[Stm]()
map.update(s,res) //map.put(s,res)
}
res += d
}
for (d <- scope) {
d.lhs.foreach(s => putDef(lhsCache, s, d))
syms(d.rhs).foreach(s => putDef(symsCache, s, d))
boundSyms(d.rhs).foreach(st => putDef(boundSymsCache, st, d))
tunnelSyms(d.rhs).foreach(st => putDef(boundSymsCache, st, d)) // treat tunnel like bound
}
/*
optimization:
traverse syms by ascending id. if sym s1 is used by s2, do not evaluate further
uses of s2 because they are already there.
CAVEAT: TRANSFORMERS !!!
assumption: if s2 uses s1, the scope of s2 is completely included in s1's scope:
val A = loop { s1 => ... val B = sum { s2 => ... val y = s2 + s1; .../* use y */ ... } }
once we reach y the second time (from s2) we can stop, because the uses of
y have been tracked up to A, which includes all of B
*/
val seen = new mutable.HashSet[Sym[Any]]
def getDepStuff(st: Sym[Any]) = {
// could also precalculate uses, but computing all combinations eagerly is also expensive
def uses(s: Sym[Any]): List[Stm] = if (seen(s)) Nil else {
//seen += s
lhsCache.getOrElse(s,Nil) ::: symsCache.getOrElse(s,Nil) filterNot (boundSymsCache.getOrElse(st, Nil) contains _)
}
GraphUtil.stronglyConnectedComponents[Stm](
uses(st),
t => t.lhs flatMap uses
).flatten
}
/*
reference impl:*/
val res = sts.flatMap(getDepStuff).distinct
/*if (sts.contains(Sym(1064))) {
println("dep on x1064:")
res.foreach { r =>
println(" " + r)
}
}*/
res
// CAVEAT: TRANSFORMERS !!! see CloseWorldRestage app in Delite
//sts.sortBy(_.id).flatMap(getDepStuff)
}
/** end performance hotspot **/
}
| astojanov/virtualization-lms-core | src/internal/Scheduling.scala | Scala | bsd-3-clause | 7,393 | [
30522,
7427,
26743,
1012,
1048,
5244,
7427,
4722,
12324,
21183,
4014,
1012,
10629,
21823,
2140,
12324,
26743,
1012,
3074,
1012,
14163,
10880,
12324,
9262,
1012,
21183,
4014,
1012,
4767,
14949,
22444,
2361,
12324,
26743,
1012,
3074,
1012,
9262... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.